I'm using isAppInactive() method from UsageStatsManager class on Android 6 (API 23) to detect the standby state of the app I'm developing.
The docs affirm that it is necessary to request PACKAGE_USAGE_STATS permission but I'm able to use that method without requesting the permission.
Is this a bug?
In
UsageStatsServicethere is ahasPermission[1] method that checks if the permissionPACKAGE_USAGE_STATSis granted. It is used in this methods:queryEvents[2]queryConfigurations[3]queryUsageStats[4]queryAndAggregateUsageStats(it uses the same method ofqueryUsageStats)This is the code of
isAppInactive[5], and you can see how the permission is not requested:As you can see in the message of commit that adds
isAppInactive(originally is calledisAppIdlethen it is renamed) the API should be public:I don't think this is a bug, but only an unclear documentation.