diff options
| author | Lee Shombert <shombert@google.com> | 2022-01-06 23:14:05 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-01-06 23:14:05 +0000 |
| commit | 9a686c07bac366d761d5973eb7d7fbc2cf01ac41 (patch) | |
| tree | fb5196cd5719ee8357295fa60202ce559b887942 /core/java/android/app | |
| parent | bb5068359996253178aba8fe0aad9a832988ae96 (diff) | |
| parent | 0cece3898b0f26b0fb026415d4c8f928d16296a3 (diff) | |
Merge "Prepare PropertyInvalidatedCache for SystemApi"
Diffstat (limited to 'core/java/android/app')
| -rw-r--r-- | core/java/android/app/ApplicationPackageManager.java | 4 | ||||
| -rw-r--r-- | core/java/android/app/PropertyInvalidatedCache.java | 10 | ||||
| -rw-r--r-- | core/java/android/app/compat/ChangeIdStateCache.java | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 44fb5db02f5d..49c75c49b2d7 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -802,7 +802,7 @@ public class ApplicationPackageManager extends PackageManager { new PropertyInvalidatedCache<HasSystemFeatureQuery, Boolean>( 256, "cache_key.has_system_feature") { @Override - protected Boolean recompute(HasSystemFeatureQuery query) { + public Boolean recompute(HasSystemFeatureQuery query) { try { return ActivityThread.currentActivityThread().getPackageManager(). hasSystemFeature(query.name, query.version); @@ -1098,7 +1098,7 @@ public class ApplicationPackageManager extends PackageManager { new PropertyInvalidatedCache<Integer, GetPackagesForUidResult>( 32, CACHE_KEY_PACKAGES_FOR_UID_PROPERTY) { @Override - protected GetPackagesForUidResult recompute(Integer uid) { + public GetPackagesForUidResult recompute(Integer uid) { try { return new GetPackagesForUidResult( ActivityThread.currentActivityThread(). diff --git a/core/java/android/app/PropertyInvalidatedCache.java b/core/java/android/app/PropertyInvalidatedCache.java index ef4d7b1f42e2..978160c1c243 100644 --- a/core/java/android/app/PropertyInvalidatedCache.java +++ b/core/java/android/app/PropertyInvalidatedCache.java @@ -505,13 +505,13 @@ public abstract class PropertyInvalidatedCache<Query, Result> { * block. If this function returns null, the result of the cache query is null. There is no * "negative cache" in the query: we don't cache null results at all. */ - protected abstract Result recompute(Query query); + public abstract Result recompute(Query query); /** * Return true if the query should bypass the cache. The default behavior is to * always use the cache but the method can be overridden for a specific class. */ - protected boolean bypass(Query query) { + public boolean bypass(Query query) { return false; } @@ -519,7 +519,7 @@ public abstract class PropertyInvalidatedCache<Query, Result> { * Determines if a pair of responses are considered equal. Used to determine whether * a cache is inadvertently returning stale results when VERIFY is set to true. */ - protected boolean debugCompareQueryResults(Result cachedResult, Result fetchedResult) { + protected boolean resultEquals(Result cachedResult, Result fetchedResult) { // If a service crashes and returns a null result, the cached value remains valid. if (fetchedResult != null) { return Objects.equals(cachedResult, fetchedResult); @@ -990,11 +990,11 @@ public abstract class PropertyInvalidatedCache<Query, Result> { } } - protected Result maybeCheckConsistency(Query query, Result proposedResult) { + private Result maybeCheckConsistency(Query query, Result proposedResult) { if (VERIFY) { Result resultToCompare = recompute(query); boolean nonceChanged = (getCurrentNonce() != mLastSeenNonce); - if (!nonceChanged && !debugCompareQueryResults(proposedResult, resultToCompare)) { + if (!nonceChanged && !resultEquals(proposedResult, resultToCompare)) { Log.e(TAG, TextUtils.formatSimple( "cache %s inconsistent for %s is %s should be %s", cacheName(), queryToString(query), diff --git a/core/java/android/app/compat/ChangeIdStateCache.java b/core/java/android/app/compat/ChangeIdStateCache.java index 3d0bf91bf8d7..acd404b7d475 100644 --- a/core/java/android/app/compat/ChangeIdStateCache.java +++ b/core/java/android/app/compat/ChangeIdStateCache.java @@ -84,7 +84,7 @@ public final class ChangeIdStateCache } @Override - protected Boolean recompute(ChangeIdStateQuery query) { + public Boolean recompute(ChangeIdStateQuery query) { final long token = Binder.clearCallingIdentity(); try { if (query.type == ChangeIdStateQuery.QUERY_BY_PACKAGE_NAME) { |
