New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running apps can't be determined on Android N #527

Closed
d4rken opened this Issue Sep 24, 2016 · 4 comments

Comments

1 participant
@d4rken
Owner

d4rken commented Sep 24, 2016

Since Lollipop we can't use the API to get running apps.
And now since Nougat we can't use proc to determine running apps.

馃槩

Possibly solutions:

  • On rooted devices use root for this (currently not doing that)
  • On unrooted devices ask the user to grant permission to access USAGE_STATS
@d4rken

This comment has been minimized.

Owner

d4rken commented Oct 13, 2016

  • If root is available, use a root shell to determine running apps.
@d4rken

This comment has been minimized.

Owner

d4rken commented Nov 2, 2016

@AndreaCioccarelli That's what I said in my post...

@d4rken d4rken modified the milestones: v4.5.0, Next Tasks Dec 1, 2016

@d4rken

This comment has been minimized.

Owner

d4rken commented Dec 1, 2016

Well isn't so easy... but

  • We fall back to use getRunningServices() if /proc unavailable and we can't have root
  • If getRunningServices() is returning empty, or it just contains our app (e.g. faked like getRunningAppProcesses(), then we query the UsageStatsManager for the last 3 seconds.

Querying the UsageStatsManager requires additional permission which are currently only requested if experimental features are turned on, as I don't know an Android version yet where getRunningServices() breaks (and we don't want to slap the user with another permission request).

The issue with determing running apps via the UsageStatsManager is that it does not always updates it's data so you either have to force it to update (e.g. switch apps, go home screen), which doesn't work for background operations, or we have to increase the interval so much that it's too inaccurate to determine currently running apps...

@d4rken

This comment has been minimized.

Owner

d4rken commented Dec 1, 2016

Actually scrapping the usage stats based lookup again, just doesn't work reliably for background operations, and! there are issues with Samsung devices... sigh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment