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

Commit 40b300fd authored by riddle_hsu's avatar riddle_hsu
Browse files

Fix race condition when collecting op callback.

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

Change-Id: Id260172979ddfc2df9331880805d16ee13e183eb
parent 14a0981f
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
@@ -513,6 +513,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();
@@ -543,6 +544,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                    }
                }
            }
        }

        if (callbackSpecs == null) {
            return;