Set UID appops mode instead of package appops mode
In PermissionManagerService and DefaultPermissionGrantPolicy.
This mirrors what the permission controller is doing. Better make sure
all modules changing app-ops for runtime permissions do it the same way.
Test: Looked at pre-grants after boot, changed permissions after boot
Change-Id: I88386ec6842324b28ab408ea5cd113c9cc7de9fe
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index f027253..3cdf09e 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -4096,10 +4096,15 @@
private static String[] getPackagesForUid(int uid) {
String[] packageNames = null;
- try {
- packageNames = AppGlobals.getPackageManager().getPackagesForUid(uid);
- } catch (RemoteException e) {
- /* ignore - local call */
+
+ // Very early during boot the package manager is not yet or not yet fully started. At this
+ // time there are no packages yet.
+ if (AppGlobals.getPackageManager() != null) {
+ try {
+ packageNames = AppGlobals.getPackageManager().getPackagesForUid(uid);
+ } catch (RemoteException e) {
+ /* ignore - local call */
+ }
}
if (packageNames == null) {
return EmptyArray.STRING;
@@ -4269,9 +4274,8 @@
}
@Override
- public void setMode(int code, int uid, @NonNull String packageName, int mode,
- boolean isPrivileged) {
- AppOpsService.this.setMode(code, uid, packageName, mode, false, isPrivileged);
+ public void setUidMode(int code, int uid, int mode) {
+ AppOpsService.this.setUidMode(code, uid, mode);
}
}
}