I used the application for receiving data, for receiving data we need to provide two permissions -
PACKAGE_USAGE_STATS
READ_PHONE_STATE
When I install the application as a playback application, it works fine, but when I click it as a system application, it crashes. The reason for this failure is permission PACKAGE_USAGE_STATS. For a system application, its value is enabled by default, but it still crashed and led to the following exception.
java.lang.SecurityException: NetworkStats: neither the user nor the current process have android.permission.READ_NETWORK_USAGE_HISTORY. at android.os.Parcel.readException (Parcel.java:1620) at android.os.Parcel.readException (Parcel.java:1573) on android.net.INetworkStatsSession $ Stub $ Proxy.getHistoryIntervalForUid (INetworkStatsSession.java:425) on android.app.usage.NetworkStats.startHistoryEnumeration (NetworkStats.javahaps41) in android.app.usage.NetworkStatsManager.queryDetailsForUid (NetworkStatsManager.java:201) at com.android.launcher3.appdatausage.DataUsageManager $ 2.runjanan DataUananananUananageUanageUanageUnage : 204) in java.lang.Thread.run (Thread.java:818)
As soon as I switch the resolution, it works fine. How to resolve this?
source share