Skip to content

Commit 2af5708

Browse files
committed
Add per UID control to app ops.
The app ops mananger service maintains a mapping from UID to a list of packages where each package is mapped to a list of non-default app op states (default states are inferred and not stored). Hence, specifying the app op state for a UID requires setting the app op for each package in the shared UID. This is problematic when installing new packages if there is a non-default app op policy set for another already installed package in the same UID as the app op for the new package has to be updated to be in sync. The package installer cannot do this as it is in another process and the app op update will not be atomic. Therefore, the app ops manager service has to support specifying app op policy on a per UID basis. We now have a UID state object that contains the per package non-default app op states as well as the per uid non-default app op states. If there is a UID policy specified then it takes precedence over the per package one. Even further, changing the uid policy updates the package policies in this UID if the state is non-default. Changing a package app op state also updates the app op state for the whole UID if the per UID policy for this op is non-default. Clearing the app op state for a package, clears the policy for the UID as well. bug:22802981 Change-Id: I78044906d9fcc6066abf07e706c2c88f3397d293
1 parent 02022b7 commit 2af5708

3 files changed

Lines changed: 410 additions & 58 deletions

File tree

core/java/android/app/AppOpsManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,14 @@ public List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageNa
12331233
return null;
12341234
}
12351235

1236+
/** @hide */
1237+
public void setUidMode(int code, int uid, int mode) {
1238+
try {
1239+
mService.setUidMode(code, uid, mode);
1240+
} catch (RemoteException e) {
1241+
}
1242+
}
1243+
12361244
/** @hide */
12371245
public void setMode(int code, int uid, String packageName, int mode) {
12381246
try {

core/java/com/android/internal/app/IAppOpsService.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface IAppOpsService {
3838
int checkPackage(int uid, String packageName);
3939
List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops);
4040
List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops);
41+
void setUidMode(int code, int uid, int mode);
4142
void setMode(int code, int uid, String packageName, int mode);
4243
void resetAllModes(int reqUserId, String reqPackageName);
4344
int checkAudioOperation(int code, int usage, int uid, String packageName);

0 commit comments

Comments
 (0)