Merge "Revert "Synchronize cache-is-ready boolean with cache readiness."" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2dabd1208c
@@ -173,7 +173,7 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot {
|
|||||||
* {@link #shouldFilterApplicationInternal(PackageDataSnapshot, int, Object,
|
* {@link #shouldFilterApplicationInternal(PackageDataSnapshot, int, Object,
|
||||||
* PackageStateInternal, int)} call.
|
* PackageStateInternal, int)} call.
|
||||||
* NOTE: It can only be relied upon after the system is ready to avoid unnecessary update on
|
* NOTE: It can only be relied upon after the system is ready to avoid unnecessary update on
|
||||||
* initial scam and is empty until {@link #mCacheReady} is true.
|
* initial scam and is empty until {@link #mSystemReady} is true.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
@Watched
|
@Watched
|
||||||
@@ -181,7 +181,7 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot {
|
|||||||
@NonNull
|
@NonNull
|
||||||
protected SnapshotCache<WatchedSparseBooleanMatrix> mShouldFilterCacheSnapshot;
|
protected SnapshotCache<WatchedSparseBooleanMatrix> mShouldFilterCacheSnapshot;
|
||||||
|
|
||||||
protected volatile boolean mCacheReady = false;
|
protected volatile boolean mSystemReady = false;
|
||||||
|
|
||||||
protected boolean isForceQueryable(int callingAppId) {
|
protected boolean isForceQueryable(int callingAppId) {
|
||||||
return mForceQueryable.contains(callingAppId);
|
return mForceQueryable.contains(callingAppId);
|
||||||
@@ -312,7 +312,7 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot {
|
|||||||
|| callingAppId == targetPkgSetting.getAppId()) {
|
|| callingAppId == targetPkgSetting.getAppId()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mCacheReady) { // use cache
|
if (mSystemReady) { // use cache
|
||||||
if (!shouldFilterApplicationUsingCache(callingUid,
|
if (!shouldFilterApplicationUsingCache(callingUid,
|
||||||
targetPkgSetting.getAppId(),
|
targetPkgSetting.getAppId(),
|
||||||
userId)) {
|
userId)) {
|
||||||
|
|||||||
@@ -404,8 +404,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
+ recipientUid + " -> " + visibleUid);
|
+ recipientUid + " -> " + visibleUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/231528435): invalidate cache instead of locking.
|
if (mSystemReady) {
|
||||||
if (true/*mCacheReady*/) {
|
|
||||||
synchronized (mCacheLock) {
|
synchronized (mCacheLock) {
|
||||||
// update the cache in a one-off manner since we've got all the information we
|
// update the cache in a one-off manner since we've got all the information we
|
||||||
// need.
|
// need.
|
||||||
@@ -421,6 +420,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
mFeatureConfig.onSystemReady();
|
mFeatureConfig.onSystemReady();
|
||||||
|
|
||||||
updateEntireShouldFilterCacheAsync(pmInternal);
|
updateEntireShouldFilterCacheAsync(pmInternal);
|
||||||
|
mSystemReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,8 +444,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
final UserInfo[] users = snapshot.getUserInfos();
|
final UserInfo[] users = snapshot.getUserInfos();
|
||||||
final ArraySet<String> additionalChangedPackages =
|
final ArraySet<String> additionalChangedPackages =
|
||||||
addPackageInternal(newPkgSetting, settings);
|
addPackageInternal(newPkgSetting, settings);
|
||||||
// TODO(b/231528435): invalidate cache instead of locking.
|
if (mSystemReady) {
|
||||||
if (true/*mCacheReady*/) {
|
|
||||||
synchronized (mCacheLock) {
|
synchronized (mCacheLock) {
|
||||||
updateShouldFilterCacheForPackage(snapshot, null, newPkgSetting,
|
updateShouldFilterCacheForPackage(snapshot, null, newPkgSetting,
|
||||||
settings, users, USER_ALL, settings.size());
|
settings, users, USER_ALL, settings.size());
|
||||||
@@ -587,7 +586,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeAppIdFromVisibilityCache(int appId) {
|
private void removeAppIdFromVisibilityCache(int appId) {
|
||||||
if (!mCacheReady) {
|
if (!mSystemReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (mCacheLock) {
|
synchronized (mCacheLock) {
|
||||||
@@ -662,20 +661,18 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
|
|
||||||
updateEntireShouldFilterCacheInner(snapshot, settings, usersRef[0], USER_ALL);
|
updateEntireShouldFilterCacheInner(snapshot, settings, usersRef[0], USER_ALL);
|
||||||
onChanged();
|
onChanged();
|
||||||
|
|
||||||
mCacheReady = true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUserCreated(PackageDataSnapshot snapshot, int newUserId) {
|
public void onUserCreated(PackageDataSnapshot snapshot, int newUserId) {
|
||||||
if (!mCacheReady) {
|
if (!mSystemReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateEntireShouldFilterCache(snapshot, newUserId);
|
updateEntireShouldFilterCache(snapshot, newUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUserDeleted(@UserIdInt int userId) {
|
public void onUserDeleted(@UserIdInt int userId) {
|
||||||
if (!mCacheReady) {
|
if (!mSystemReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removeShouldFilterCacheForUser(userId);
|
removeShouldFilterCacheForUser(userId);
|
||||||
@@ -684,7 +681,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
|
|
||||||
private void updateShouldFilterCacheForPackage(PackageDataSnapshot snapshot,
|
private void updateShouldFilterCacheForPackage(PackageDataSnapshot snapshot,
|
||||||
String packageName) {
|
String packageName) {
|
||||||
if (!mCacheReady) {
|
if (!mSystemReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ArrayMap<String, ? extends PackageStateInternal> settings =
|
final ArrayMap<String, ? extends PackageStateInternal> settings =
|
||||||
@@ -933,8 +930,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeAppIdFromVisibilityCache(setting.getAppId());
|
removeAppIdFromVisibilityCache(setting.getAppId());
|
||||||
// TODO(b/231528435): invalidate cache instead of locking.
|
if (mSystemReady && setting.hasSharedUser()) {
|
||||||
if (/*mCacheReady && */setting.hasSharedUser()) {
|
|
||||||
final ArraySet<? extends PackageStateInternal> sharedUserPackages =
|
final ArraySet<? extends PackageStateInternal> sharedUserPackages =
|
||||||
getSharedUserPackages(setting.getSharedUserAppId(), sharedUserSettings);
|
getSharedUserPackages(setting.getSharedUserAppId(), sharedUserSettings);
|
||||||
for (int i = sharedUserPackages.size() - 1; i >= 0; i--) {
|
for (int i = sharedUserPackages.size() - 1; i >= 0; i--) {
|
||||||
@@ -951,8 +947,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/231528435): invalidate cache instead of locking.
|
if (mSystemReady) {
|
||||||
if (true/*mCacheReady*/) {
|
|
||||||
if (additionalChangedPackages != null) {
|
if (additionalChangedPackages != null) {
|
||||||
for (int index = 0; index < additionalChangedPackages.size(); index++) {
|
for (int index = 0; index < additionalChangedPackages.size(); index++) {
|
||||||
String changedPackage = additionalChangedPackages.valueAt(index);
|
String changedPackage = additionalChangedPackages.valueAt(index);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ abstract class AppsFilterLocked extends AppsFilterBase {
|
|||||||
/**
|
/**
|
||||||
* Guards the access for {@link AppsFilterBase#mShouldFilterCache};
|
* Guards the access for {@link AppsFilterBase#mShouldFilterCache};
|
||||||
*/
|
*/
|
||||||
protected final Object mCacheLock = new Object();
|
protected Object mCacheLock = new Object();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isForceQueryable(int appId) {
|
protected boolean isForceQueryable(int appId) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.server.pm;
|
package com.android.server.pm;
|
||||||
|
|
||||||
import com.android.server.utils.SnapshotCache;
|
import com.android.server.utils.SnapshotCache;
|
||||||
import com.android.server.utils.WatchedSparseBooleanMatrix;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@@ -50,18 +49,12 @@ public final class AppsFilterSnapshotImpl extends AppsFilterBase {
|
|||||||
mFeatureConfig = orig.mFeatureConfig.snapshot();
|
mFeatureConfig = orig.mFeatureConfig.snapshot();
|
||||||
mOverlayReferenceMapper = orig.mOverlayReferenceMapper;
|
mOverlayReferenceMapper = orig.mOverlayReferenceMapper;
|
||||||
mSystemSigningDetails = orig.mSystemSigningDetails;
|
mSystemSigningDetails = orig.mSystemSigningDetails;
|
||||||
|
|
||||||
mCacheReady = orig.mCacheReady;
|
|
||||||
if (mCacheReady) {
|
|
||||||
synchronized (orig.mCacheLock) {
|
synchronized (orig.mCacheLock) {
|
||||||
mShouldFilterCache = orig.mShouldFilterCacheSnapshot.snapshot();
|
mShouldFilterCache = orig.mShouldFilterCacheSnapshot.snapshot();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// cache is not ready, use an empty cache for the snapshot
|
|
||||||
mShouldFilterCache = new WatchedSparseBooleanMatrix();
|
|
||||||
}
|
|
||||||
mShouldFilterCacheSnapshot = new SnapshotCache.Sealed<>();
|
mShouldFilterCacheSnapshot = new SnapshotCache.Sealed<>();
|
||||||
|
}
|
||||||
|
|
||||||
mBackgroundExecutor = null;
|
mBackgroundExecutor = null;
|
||||||
|
mSystemReady = orig.mSystemReady;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user