Search code examples
androidadb

Grant PACKAGE_USAGE_STATS permission through adb


adb shell pm grant x.y.z android.permission.PACKAGE_USAGE_STATS

This is the command to grant PACKAGE_USAGE_STATS permission through adb, but it only works if I have never toggled this permission in native settings.

The same thing happens to SYSTEM_ALERT_WINDOW permission, while there is a better command adb shell appops set x.y.z SYSTEM_ALERT_WINDOW allow to do it effectively.

The problem is I didn't find another command to toggle PACKAGE_USAGE_STATS permission.


Solution

  • You can set android:get_usage_stats using appops

    adb shell appops set x.y.z android:get_usage_stats allow