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

Commit 09d24aba authored by Winson's avatar Winson
Browse files

Lock ComponentResolver when taking snapshot

Otherwise it's possible to hit a concurrent modification exception
when the data structures are edited while a snapshot is being taken.

Bug: 229326910

Test: presubmit

Change-Id: Ib15551a5096c47f5a238863466af08a4a88f82b9
parent b121b54f
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -79,7 +79,8 @@ import java.util.Set;
import java.util.function.Function;

/** Resolves all Android component types [activities, services, providers and receivers]. */
public class ComponentResolver extends ComponentResolverLocked implements Snappable {
public class ComponentResolver extends ComponentResolverLocked implements
        Snappable<ComponentResolverApi> {
    private static final boolean DEBUG = false;
    private static final String TAG = "PackageManager";
    private static final boolean DEBUG_FILTERS = false;
@@ -166,11 +167,13 @@ public class ComponentResolver extends ComponentResolverLocked implements Snappa
        mProvidersByAuthority = new ArrayMap<>();
        mDeferProtectedFilters = true;

        mSnapshot = new SnapshotCache<ComponentResolverApi>(this, this) {
        mSnapshot = new SnapshotCache<>(this, this) {
                @Override
                public ComponentResolverApi createSnapshot() {
                    synchronized (mLock) {
                        return new ComponentResolverSnapshot(ComponentResolver.this,
                                userNeedsBadgingCache);
                    }
                }};
    }