Loading core/java/android/app/ApplicationPackageManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.app; import static android.app.PropertyInvalidatedCache.createSystemCacheKey; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_COLORED; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_NOT_COLORED; import static android.app.admin.DevicePolicyResources.Drawables.WORK_PROFILE_ICON; Loading Loading @@ -817,7 +818,7 @@ public class ApplicationPackageManager extends PackageManager { private final static PropertyInvalidatedCache<HasSystemFeatureQuery, Boolean> mHasSystemFeatureCache = new PropertyInvalidatedCache<HasSystemFeatureQuery, Boolean>( 256, "cache_key.has_system_feature") { 256, createSystemCacheKey("has_system_feature")) { @Override public Boolean recompute(HasSystemFeatureQuery query) { try { Loading Loading @@ -1127,7 +1128,7 @@ public class ApplicationPackageManager extends PackageManager { } private static final String CACHE_KEY_PACKAGES_FOR_UID_PROPERTY = "cache_key.get_packages_for_uid"; createSystemCacheKey("get_packages_for_uid"); private static final PropertyInvalidatedCache<Integer, GetPackagesForUidResult> mGetPackagesForUidCache = new PropertyInvalidatedCache<Integer, GetPackagesForUidResult>( Loading core/java/android/app/PropertyInvalidatedCache.java +47 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -282,6 +283,12 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide */ /** * The well-known key prefix. * @hide */ private static final String CACHE_KEY_PREFIX = "cache_key"; /** * The module used for unit tests and cts tests. It is expected that no process in * the system has permissions to write properties with this module. Loading Loading @@ -366,7 +373,44 @@ public class PropertyInvalidatedCache<Query, Result> { } } return "cache_key." + module + "." + new String(suffix); return CACHE_KEY_PREFIX + "." + module + "." + new String(suffix); } /** * All legal keys start with one of the following strings. */ private static final String[] sValidKeyPrefix = { CACHE_KEY_PREFIX + "." + MODULE_SYSTEM + ".", CACHE_KEY_PREFIX + "." + MODULE_BLUETOOTH + ".", CACHE_KEY_PREFIX + "." + MODULE_TELEPHONY + ".", CACHE_KEY_PREFIX + "." + MODULE_TEST + ".", }; /** * Verify that the property name conforms to the standard. Log a warning if this is not true. * Note that this is done once in the cache constructor; it does not have to be very fast. */ private void validateCacheKey(String name) { if (Build.IS_USER) { // Do not bother checking keys in user builds. The keys will have been tested in // eng/userdebug builds already. return; } for (int i = 0; i < sValidKeyPrefix.length; i++) { if (name.startsWith(sValidKeyPrefix[i])) return; } Log.w(TAG, "invalid cache name: " + name); } /** * Create a cache key for the system module. The parameter is the API name. This reduces * some of the boilerplate in system caches. It is not needed in other modules because other * modules must use the {@link IpcDataCache} interfaces. * @hide */ @NonNull public static String createSystemCacheKey(@NonNull String api) { return createPropertyName(MODULE_SYSTEM, api); } /** Loading Loading @@ -561,6 +605,7 @@ public class PropertyInvalidatedCache<Query, Result> { public PropertyInvalidatedCache(int maxEntries, @NonNull String propertyName, @NonNull String cacheName) { mPropertyName = propertyName; validateCacheKey(mPropertyName); mCacheName = cacheName; mMaxEntries = maxEntries; mComputer = new DefaultComputer<>(this); Loading @@ -584,6 +629,7 @@ public class PropertyInvalidatedCache<Query, Result> { public PropertyInvalidatedCache(int maxEntries, @NonNull String module, @NonNull String api, @NonNull String cacheName, @NonNull QueryHandler<Query, Result> computer) { mPropertyName = createPropertyName(module, api); validateCacheKey(mPropertyName); mCacheName = cacheName; mMaxEntries = maxEntries; mComputer = computer; Loading core/java/android/app/compat/ChangeIdStateCache.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.app.compat; import static android.app.PropertyInvalidatedCache.createSystemCacheKey; import android.annotation.NonNull; import android.app.PropertyInvalidatedCache; import android.content.Context; Loading @@ -31,7 +33,7 @@ import com.android.internal.compat.IPlatformCompat; */ public final class ChangeIdStateCache extends PropertyInvalidatedCache<ChangeIdStateQuery, Boolean> { private static final String CACHE_KEY = "cache_key.is_compat_change_enabled"; private static final String CACHE_KEY = createSystemCacheKey("is_compat_change_enabled"); private static final int MAX_ENTRIES = 2048; private static boolean sDisabled = false; private volatile IPlatformCompat mPlatformCompat; Loading core/java/android/hardware/display/DisplayManagerGlobal.java +1 −1 Original line number Diff line number Diff line Loading @@ -1445,7 +1445,7 @@ public final class DisplayManagerGlobal { * system's display configuration. */ public static final String CACHE_KEY_DISPLAY_INFO_PROPERTY = "cache_key.display_info"; PropertyInvalidatedCache.createSystemCacheKey("display_info"); /** * Invalidates the contents of the display info cache for all applications. Can only Loading core/java/android/os/PowerManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -1144,9 +1144,10 @@ public final class PowerManager { } private static final String CACHE_KEY_IS_POWER_SAVE_MODE_PROPERTY = "cache_key.is_power_save_mode"; PropertyInvalidatedCache.createSystemCacheKey("is_power_save_mode"); private static final String CACHE_KEY_IS_INTERACTIVE_PROPERTY = "cache_key.is_interactive"; private static final String CACHE_KEY_IS_INTERACTIVE_PROPERTY = PropertyInvalidatedCache.createSystemCacheKey("is_interactive"); private static final int MAX_CACHE_ENTRIES = 1; Loading Loading
core/java/android/app/ApplicationPackageManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.app; import static android.app.PropertyInvalidatedCache.createSystemCacheKey; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_COLORED; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_NOT_COLORED; import static android.app.admin.DevicePolicyResources.Drawables.WORK_PROFILE_ICON; Loading Loading @@ -817,7 +818,7 @@ public class ApplicationPackageManager extends PackageManager { private final static PropertyInvalidatedCache<HasSystemFeatureQuery, Boolean> mHasSystemFeatureCache = new PropertyInvalidatedCache<HasSystemFeatureQuery, Boolean>( 256, "cache_key.has_system_feature") { 256, createSystemCacheKey("has_system_feature")) { @Override public Boolean recompute(HasSystemFeatureQuery query) { try { Loading Loading @@ -1127,7 +1128,7 @@ public class ApplicationPackageManager extends PackageManager { } private static final String CACHE_KEY_PACKAGES_FOR_UID_PROPERTY = "cache_key.get_packages_for_uid"; createSystemCacheKey("get_packages_for_uid"); private static final PropertyInvalidatedCache<Integer, GetPackagesForUidResult> mGetPackagesForUidCache = new PropertyInvalidatedCache<Integer, GetPackagesForUidResult>( Loading
core/java/android/app/PropertyInvalidatedCache.java +47 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -282,6 +283,12 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide */ /** * The well-known key prefix. * @hide */ private static final String CACHE_KEY_PREFIX = "cache_key"; /** * The module used for unit tests and cts tests. It is expected that no process in * the system has permissions to write properties with this module. Loading Loading @@ -366,7 +373,44 @@ public class PropertyInvalidatedCache<Query, Result> { } } return "cache_key." + module + "." + new String(suffix); return CACHE_KEY_PREFIX + "." + module + "." + new String(suffix); } /** * All legal keys start with one of the following strings. */ private static final String[] sValidKeyPrefix = { CACHE_KEY_PREFIX + "." + MODULE_SYSTEM + ".", CACHE_KEY_PREFIX + "." + MODULE_BLUETOOTH + ".", CACHE_KEY_PREFIX + "." + MODULE_TELEPHONY + ".", CACHE_KEY_PREFIX + "." + MODULE_TEST + ".", }; /** * Verify that the property name conforms to the standard. Log a warning if this is not true. * Note that this is done once in the cache constructor; it does not have to be very fast. */ private void validateCacheKey(String name) { if (Build.IS_USER) { // Do not bother checking keys in user builds. The keys will have been tested in // eng/userdebug builds already. return; } for (int i = 0; i < sValidKeyPrefix.length; i++) { if (name.startsWith(sValidKeyPrefix[i])) return; } Log.w(TAG, "invalid cache name: " + name); } /** * Create a cache key for the system module. The parameter is the API name. This reduces * some of the boilerplate in system caches. It is not needed in other modules because other * modules must use the {@link IpcDataCache} interfaces. * @hide */ @NonNull public static String createSystemCacheKey(@NonNull String api) { return createPropertyName(MODULE_SYSTEM, api); } /** Loading Loading @@ -561,6 +605,7 @@ public class PropertyInvalidatedCache<Query, Result> { public PropertyInvalidatedCache(int maxEntries, @NonNull String propertyName, @NonNull String cacheName) { mPropertyName = propertyName; validateCacheKey(mPropertyName); mCacheName = cacheName; mMaxEntries = maxEntries; mComputer = new DefaultComputer<>(this); Loading @@ -584,6 +629,7 @@ public class PropertyInvalidatedCache<Query, Result> { public PropertyInvalidatedCache(int maxEntries, @NonNull String module, @NonNull String api, @NonNull String cacheName, @NonNull QueryHandler<Query, Result> computer) { mPropertyName = createPropertyName(module, api); validateCacheKey(mPropertyName); mCacheName = cacheName; mMaxEntries = maxEntries; mComputer = computer; Loading
core/java/android/app/compat/ChangeIdStateCache.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.app.compat; import static android.app.PropertyInvalidatedCache.createSystemCacheKey; import android.annotation.NonNull; import android.app.PropertyInvalidatedCache; import android.content.Context; Loading @@ -31,7 +33,7 @@ import com.android.internal.compat.IPlatformCompat; */ public final class ChangeIdStateCache extends PropertyInvalidatedCache<ChangeIdStateQuery, Boolean> { private static final String CACHE_KEY = "cache_key.is_compat_change_enabled"; private static final String CACHE_KEY = createSystemCacheKey("is_compat_change_enabled"); private static final int MAX_ENTRIES = 2048; private static boolean sDisabled = false; private volatile IPlatformCompat mPlatformCompat; Loading
core/java/android/hardware/display/DisplayManagerGlobal.java +1 −1 Original line number Diff line number Diff line Loading @@ -1445,7 +1445,7 @@ public final class DisplayManagerGlobal { * system's display configuration. */ public static final String CACHE_KEY_DISPLAY_INFO_PROPERTY = "cache_key.display_info"; PropertyInvalidatedCache.createSystemCacheKey("display_info"); /** * Invalidates the contents of the display info cache for all applications. Can only Loading
core/java/android/os/PowerManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -1144,9 +1144,10 @@ public final class PowerManager { } private static final String CACHE_KEY_IS_POWER_SAVE_MODE_PROPERTY = "cache_key.is_power_save_mode"; PropertyInvalidatedCache.createSystemCacheKey("is_power_save_mode"); private static final String CACHE_KEY_IS_INTERACTIVE_PROPERTY = "cache_key.is_interactive"; private static final String CACHE_KEY_IS_INTERACTIVE_PROPERTY = PropertyInvalidatedCache.createSystemCacheKey("is_interactive"); private static final int MAX_CACHE_ENTRIES = 1; Loading