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

Commit 463d592d authored by Eugene Susla's avatar Eugene Susla
Browse files

Synchronize when writing AppOpsService.mUidStates to file

also ensured no other place accesses mUidStates unsynchronized

Fixes: 137528177
Test: presubmit
Change-Id: I82ea6a277f61d4c053664bc59370a9f66ffd3963
parent 59dc6124
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ public class AppOpsService extends IAppOpsService.Stub {
        }
    };

    @GuardedBy("this")
    @VisibleForTesting
    final SparseArray<UidState> mUidStates = new SparseArray<>();

@@ -1187,7 +1188,7 @@ public class AppOpsService extends IAppOpsService.Stub {
        }
    }

    private void pruneOp(Op op, int uid, String packageName) {
    private void pruneOpLocked(Op op, int uid, String packageName) {
        if (!op.hasAnyTime()) {
            Ops ops = getOpsRawLocked(uid, packageName, false /* isPrivileged */, false /* edit */);
            if (ops != null) {
@@ -1396,7 +1397,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                    if (mode == AppOpsManager.opToDefaultMode(op.op)) {
                        // If going into the default mode, prune this op
                        // if there is nothing else interesting in it.
                        pruneOp(op, uid, packageName);
                        pruneOpLocked(op, uid, packageName);
                    }
                    scheduleFastWriteLocked();
                }
@@ -2979,6 +2980,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                out.startTag(null, "app-ops");
                out.attribute(null, "v", String.valueOf(CURRENT_VERSION));

                synchronized (this) {
                    final int uidStateCount = mUidStates.size();
                    for (int i = 0; i < uidStateCount; i++) {
                        UidState uidState = mUidStates.valueAt(i);
@@ -2998,6 +3000,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                            out.endTag(null, "uid");
                        }
                    }
                }

                if (allOps != null) {
                    String lastPkg = null;