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

Commit 458f0ddb authored by Nate Myren's avatar Nate Myren
Browse files

Safe iterate over AttributedOp in doForAllInProgressStartOpEvents

We were calling "finished" with the method, which removes items from the
map, causing exceptions sometimes. Instead, we get a copy of the keys, and iterate that way.

Fixes: 341407506
Test: manual
Change-Id: I253e2b8e8cdfde2503329f58b60e2076dcb3f040
parent af9c0cfd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1549,6 +1549,9 @@ public class AppOpsService extends IAppOpsService.Stub {
        final SparseLongArray chainsToFinish = new SparseLongArray();
        doForAllAttributedOpsInUidLocked(uid, (attributedOp) -> {
            attributedOp.doForAllInProgressStartOpEvents((event) -> {
                if (event == null) {
                    return;
                }
                int chainId = event.getAttributionChainId();
                if (chainId != ATTRIBUTION_CHAIN_ID_NONE) {
                    long currentEarliestStartTime =
+3 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.LongSparseArray;
import android.util.Pools;
import android.util.Slog;
@@ -265,8 +266,9 @@ final class AttributedOp {
        }

        int numStartedOps = events.size();
        ArraySet<IBinder> keys = new ArraySet<>(events.keySet());
        for (int i = 0; i < numStartedOps; i++) {
            action.accept(events.valueAt(i));
            action.accept(events.get(keys.valueAt(i)));
        }
    }