summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Svetoslav Ganov <svetoslavganov@google.com> 2018-03-25 16:32:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-03-25 16:32:54 +0000
commit069aa9dce4642118a03dc477c95f9a7936ce3670 (patch)
tree5dd4c9080f4366ab2180c1794659251c44e82942
parent6da53af9c55ba2231cd2f47c7dffb150f2c22a89 (diff)
parent3a95f837f32ce4a18f922b7a6409a66b480e2f9c (diff)
Merge "Notify all affected UIDs for user/audio restriction changes" into pi-dev
-rw-r--r--services/core/java/com/android/server/AppOpsService.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index a2f676b8953d..4c0578d7aa0f 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -97,6 +97,9 @@ public class AppOpsService extends IAppOpsService.Stub {
// Write at most every 30 minutes.
static final long WRITE_DELAY = DEBUG ? 1000 : 30*60*1000;
+ // Constant meaning that any UID should be matched when dispatching callbacks
+ private static final int UID_ANY = -2;
+
Context mContext;
final AtomicFile mFile;
final Handler mHandler;
@@ -766,7 +769,7 @@ public class AppOpsService extends IAppOpsService.Stub {
private void notifyOpChanged(ModeCallback callback, int code,
int uid, String packageName) {
- if (callback.mUid >= 0 && callback.mUid != uid) {
+ if (uid != UID_ANY && callback.mUid >= 0 && callback.mUid != uid) {
return;
}
// There are components watching for mode changes such as window manager
@@ -1114,7 +1117,7 @@ public class AppOpsService extends IAppOpsService.Stub {
}
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, this, code));
+ AppOpsService::notifyWatchersOfChange, this, code, UID_ANY));
}
@Override
@@ -2698,7 +2701,7 @@ public class AppOpsService extends IAppOpsService.Stub {
if (restrictionState.setRestriction(code, restricted, exceptionPackages, userHandle)) {
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, this, code));
+ AppOpsService::notifyWatchersOfChange, this, code, UID_ANY));
}
if (restrictionState.isDefault()) {
@@ -2708,7 +2711,7 @@ public class AppOpsService extends IAppOpsService.Stub {
}
}
- private void notifyWatchersOfChange(int code) {
+ private void notifyWatchersOfChange(int code, int uid) {
final ArraySet<ModeCallback> clonedCallbacks;
synchronized (this) {
ArraySet<ModeCallback> callbacks = mOpModeWatchers.get(code);
@@ -2718,7 +2721,7 @@ public class AppOpsService extends IAppOpsService.Stub {
clonedCallbacks = new ArraySet<>(callbacks);
}
- notifyOpChanged(clonedCallbacks, code, -1, null);
+ notifyOpChanged(clonedCallbacks, code, uid, null);
}
@Override
@@ -2953,7 +2956,7 @@ public class AppOpsService extends IAppOpsService.Stub {
for (int j = 0; j < restrictionCount; j++) {
if (restrictions[j]) {
final int changedCode = j;
- mHandler.post(() -> notifyWatchersOfChange(changedCode));
+ mHandler.post(() -> notifyWatchersOfChange(changedCode, UID_ANY));
}
}
}