Devices without “Apps using Usage Data” or android

2019-05-05 02:41发布

问题:

Background: Android 5 introduced a new UsageStats API that can be used to query time spent with different apps. This API is used in several apps for detecting the current foreground app (as discussed in several questions, like this), but:

This API requires the permission android.permission.PACKAGE_USAGE_STATS, which is a system-level permission and will not be granted to third-party apps. However, declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings application.

As the permission is not presented to the user, apps send the user to Settings using an intent with the action android.settings.USAGE_ACCESS_SETTINGS. But sometimes not even this setting is available:

In some cases, a matching Activity may not exist, so ensure you safeguard against this.

Which means that in those phones, it's practically impossible to get access to the usage stats.

This has been discussed in other questions, like here and here. Apparently some manufacturers decided to remove the functionality from some devices (notably Samsung and LG, but maybe others also).

The question: The purpose of this question is to collect information about those devices that do not allow access to these settings. Please post brand, model and os version where you have found that this is the case. Additionally, if someone can find an alternative way of accessing the usage stats, it would be helpful for others if you share it.

Please avoid pointing to deprecated APIs like getRecentTasks, or getRunningAppProcesses (which often returns several packages with priority foreground), or to how to configure the Manifest file.

回答1:

I'll start with a list that I have confirmed don't answer to the intent:

Model                     OS version
Samsung Galaxy Note 3     5.0
Samsung Galaxy S4         5.0.1
Samsung Galaxy Note S4    5.0.1
Samsung Galaxy S5         5.0
Samsung Galaxy S5 CDMA    5.0
Meizu m2 note             5.1
Samsung Galaxy S5         5.0
OnePlus One               5.0.2
Meizu MX4                 5.0.1

Also, some of our users complained with:

LG G3                     5.0