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

Commit c729010d authored by Gabriele M's avatar Gabriele M
Browse files

AppOps: Fix yet another deadlock

A = AppOpsService.this
B = PowerManagerService.mLock

Thread 1:
  AppOpsService.noteOperation() (lock A) ->
  PowerManagerService.isInteractive() (lock B)

Thread 2:
  PowerManagerService.acquireWakeLockInternal() (lock B) ->
  AppOpsService.startOperation() (lock A)

Move PowerManagerService.isInteractive() so that 'Thread 1' becomes:
  PowerManagerService.isInteractive() (lock and release B) ->
  AppOpsService.noteOperation() (lock A)

Change-Id: I6b2050bf6deaf6db94b9243c1a81c37e25ad55a2
parent d0ee75dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1120,6 +1120,7 @@ public class AppOpsService extends IAppOpsService.Stub {
    private int noteOperationUnchecked(int code, int uid, String packageName,
            int proxyUid, String proxyPackageName) {
        PermissionDialogReq req = null;
        final boolean isInteractive = mPowerManager != null ? mPowerManager.isInteractive() : false;
        synchronized (this) {
            Ops ops = getOpsRawLocked(uid, packageName, true);
            if (ops == null) {
@@ -1195,7 +1196,6 @@ public class AppOpsService extends IAppOpsService.Stub {
                    // we move them to the back of the line. NOTE: these values are magic, and may need
                    // tuning. Ideally we'd want a ringbuffer or token bucket here to do proper rate
                    // limiting.
                    final boolean isInteractive = mPowerManager.isInteractive();
                    if (isInteractive &&
                            (ops.uidState.pkgOps.size() < AppOpsPolicy.RATE_LIMIT_OPS_TOTAL_PKG_COUNT
                            && op.noteOpCount < AppOpsPolicy.RATE_LIMIT_OP_COUNT