Merge "Enable in-process permission caches for system_server"

This commit is contained in:
Lee Shombert
2020-10-15 15:37:03 +00:00
committed by Android (Google) Code Review
3 changed files with 9 additions and 5 deletions

View File

@@ -206,6 +206,10 @@ public abstract class PropertyInvalidatedCache<Query, Result> {
private static final String TAG = "PropertyInvalidatedCache";
private static final boolean DEBUG = false;
private static final boolean VERIFY = false;
// If this is true, dumpsys will dump the cache entries along with cache statistics.
// Most of the time this causes dumpsys to fail because the output stream is too
// large. Only set it to true in development images.
private static final boolean DETAILED = false;
// Per-Cache performance counters. As some cache instances are declared static,
@GuardedBy("mLock")
@@ -912,14 +916,13 @@ public abstract class PropertyInvalidatedCache<Query, Result> {
" Current Size: %d, Max Size: %d, HW Mark: %d, Overflows: %d",
mCache.size(), mMaxEntries, mHighWaterMark, mMissOverflow));
pw.println(String.format(" Enabled: %s", mDisabled ? "false" : "true"));
pw.println("");
Set<Map.Entry<Query, Result>> cacheEntries = mCache.entrySet();
if (cacheEntries.size() == 0) {
pw.println("");
if (!DETAILED || cacheEntries.size() == 0) {
return;
}
pw.println("");
pw.println(" Contents:");
for (Map.Entry<Query, Result> entry : cacheEntries) {
String key = Objects.toString(entry.getKey());

View File

@@ -609,7 +609,7 @@ public final class PermissionManager {
/** @hide */
private static final PropertyInvalidatedCache<PermissionQuery, Integer> sPermissionCache =
new PropertyInvalidatedCache<PermissionQuery, Integer>(
16, CACHE_KEY_PACKAGE_INFO, "checkPermission") {
2048, CACHE_KEY_PACKAGE_INFO, "checkPermission") {
@Override
protected Integer recompute(PermissionQuery query) {
return checkPermissionUncached(query.permission, query.pid, query.uid);

View File

@@ -378,8 +378,9 @@ public class PermissionManagerService extends IPermissionManager.Stub {
@NonNull Injector injector) {
mInjector = injector;
// The package info cache is the cache for package and permission information.
// Disable the package info and package permission caches locally but leave the
// checkPermission cache active.
mInjector.invalidatePackageInfoCache();
mInjector.disablePermissionCache();
mInjector.disablePackageNamePermissionCache();
mContext = context;