Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f28002f authored by riddle_hsu's avatar riddle_hsu Committed by Steve Kondik
Browse files

Fix race condition when collecting op callback.

Other threads may change mOpModeWatchers, mPackageModeWatchers
by startWatchingMode, stopWatchingMode.

Change-Id: Id260172979ddfc2df9331880805d16ee13e183eb
parent 29e7f0d0
Loading
Loading
Loading
Loading
+24 −22
Original line number Diff line number Diff line
@@ -560,6 +560,7 @@ public class AppOpsService extends IAppOpsService.Stub {
        String[] uidPackageNames = getPackagesForUid(uid);
        ArrayMap<Callback, ArraySet<String>> callbackSpecs = null;

        synchronized (this) {
            ArrayList<Callback> callbacks = mOpModeWatchers.get(code);
            if (callbacks != null) {
                final int callbackCount = callbacks.size();
@@ -590,6 +591,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                    }
                }
            }
        }

        if (callbackSpecs == null) {
            return;