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
This commit is contained in:
@@ -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() {
|
||||
return new ComponentResolverSnapshot(ComponentResolver.this,
|
||||
userNeedsBadgingCache);
|
||||
synchronized (mLock) {
|
||||
return new ComponentResolverSnapshot(ComponentResolver.this,
|
||||
userNeedsBadgingCache);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user