Loading services/core/java/com/android/server/AppOpsService.java +9 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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()) { Loading @@ -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); Loading @@ -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 Loading Loading @@ -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)); } } } Loading Loading
services/core/java/com/android/server/AppOpsService.java +9 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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()) { Loading @@ -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); Loading @@ -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 Loading Loading @@ -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)); } } } Loading