diff options
| -rwxr-xr-x | core/api/system-current.txt | 1 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 7 | ||||
| -rw-r--r-- | services/core/java/com/android/server/appop/AppOpsService.java | 8 |
3 files changed, 15 insertions, 1 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index f92c36d488ad..539aee825666 100755 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -105,6 +105,7 @@ package android { field public static final String FORCE_BACK = "android.permission.FORCE_BACK"; field public static final String FORCE_STOP_PACKAGES = "android.permission.FORCE_STOP_PACKAGES"; field public static final String GET_APP_OPS_STATS = "android.permission.GET_APP_OPS_STATS"; + field public static final String GET_HISTORICAL_APP_OPS_STATS = "android.permission.GET_HISTORICAL_APP_OPS_STATS"; field public static final String GET_PROCESS_STATE_AND_OOM_SCORE = "android.permission.GET_PROCESS_STATE_AND_OOM_SCORE"; field public static final String GET_RUNTIME_PERMISSIONS = "android.permission.GET_RUNTIME_PERMISSIONS"; field public static final String GET_TOP_ACTIVITY_INFO = "android.permission.GET_TOP_ACTIVITY_INFO"; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 329f02a74cb0..153b77b6aedc 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -3578,6 +3578,13 @@ <permission android:name="android.permission.GET_APP_OPS_STATS" android:protectionLevel="signature|privileged|development" /> + <!-- @SystemApi @hide Allows an application to collect historical application operation + statistics. + <p>Not for use by third party applications. + --> + <permission android:name="android.permission.GET_HISTORICAL_APP_OPS_STATS" + android:protectionLevel="internal|role" /> + <!-- @SystemApi Allows an application to update application operation statistics. Not for use by third party apps. @hide --> diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 587b5d2ce59e..66613ce85c41 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -2375,7 +2375,13 @@ public class AppOpsService extends IAppOpsService.Stub { return; } - if (!isCallerSystem && !isCallerInstrumented && !isCallerPermissionController) { + boolean doesCallerHavePermission = mContext.checkPermission( + android.Manifest.permission.GET_HISTORICAL_APP_OPS_STATS, + Binder.getCallingPid(), Binder.getCallingUid()) + == PackageManager.PERMISSION_GRANTED; + + if (!isCallerSystem && !isCallerInstrumented && !isCallerPermissionController + && !doesCallerHavePermission) { mHandler.post(() -> callback.sendResult(new Bundle())); return; } |