Loading core/api/module-lib-current.txt +4 −3 Original line number Original line Diff line number Diff line Loading @@ -55,12 +55,13 @@ package android.app { } } public class PropertyInvalidatedCache<Query, Result> { public class PropertyInvalidatedCache<Query, Result> { ctor public PropertyInvalidatedCache(int, int, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); ctor public PropertyInvalidatedCache(int, @NonNull String, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); method public final void disableForCurrentProcess(); method public final void disableForCurrentProcess(); method public final void invalidateCache(); method public final void invalidateCache(); method public static void invalidateCache(int, @NonNull String); method public static void invalidateCache(@NonNull String, @NonNull String); method @Nullable public final Result query(@NonNull Query); method @Nullable public final Result query(@NonNull Query); field public static final int MODULE_BLUETOOTH = 2; // 0x2 field public static final String MODULE_BLUETOOTH = "bluetooth"; field public static final String MODULE_TELEPHONY = "telephony"; } } public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { Loading core/api/test-current.txt +7 −6 Original line number Original line Diff line number Diff line Loading @@ -372,8 +372,8 @@ package android.app { } } public class PropertyInvalidatedCache<Query, Result> { public class PropertyInvalidatedCache<Query, Result> { ctor public PropertyInvalidatedCache(int, int, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); ctor public PropertyInvalidatedCache(int, @NonNull String, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); method @NonNull public static String createPropertyName(int, @NonNull String); method @NonNull public static String createPropertyName(@NonNull String, @NonNull String); method public final void disableForCurrentProcess(); method public final void disableForCurrentProcess(); method public static void disableForTestMode(); method public static void disableForTestMode(); method public final void disableInstance(); method public final void disableInstance(); Loading @@ -381,14 +381,15 @@ package android.app { method public final void forgetDisableLocal(); method public final void forgetDisableLocal(); method public boolean getDisabledState(); method public boolean getDisabledState(); method public final void invalidateCache(); method public final void invalidateCache(); method public static void invalidateCache(int, @NonNull String); method public static void invalidateCache(@NonNull String, @NonNull String); method public final boolean isDisabled(); method public final boolean isDisabled(); method @Nullable public final Result query(@NonNull Query); method @Nullable public final Result query(@NonNull Query); method public static void setTestMode(boolean); method public static void setTestMode(boolean); method public void testPropertyName(); method public void testPropertyName(); field public static final int MODULE_BLUETOOTH = 2; // 0x2 field public static final String MODULE_BLUETOOTH = "bluetooth"; field public static final int MODULE_SYSTEM = 1; // 0x1 field public static final String MODULE_SYSTEM = "system_server"; field public static final int MODULE_TEST = 0; // 0x0 field public static final String MODULE_TELEPHONY = "telephony"; field public static final String MODULE_TEST = "test"; } } public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { Loading core/java/android/app/PropertyInvalidatedCache.java +18 −29 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.app; package android.app; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.SystemApi; Loading Loading @@ -265,13 +264,6 @@ public class PropertyInvalidatedCache<Query, Result> { * the permissions granted to the processes that contain the corresponding caches. * the permissions granted to the processes that contain the corresponding caches. * @hide * @hide */ */ @IntDef(prefix = { "MODULE_" }, value = { MODULE_TEST, MODULE_SYSTEM, MODULE_BLUETOOTH }) @Retention(RetentionPolicy.SOURCE) public @interface Module {} /** /** * The module used for unit tests and cts tests. It is expected that no process in * The module used for unit tests and cts tests. It is expected that no process in Loading @@ -279,7 +271,7 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide * @hide */ */ @TestApi @TestApi public static final int MODULE_TEST = 0; public static final String MODULE_TEST = "test"; /** /** * The module used for system server/framework caches. This is not visible outside * The module used for system server/framework caches. This is not visible outside Loading @@ -287,7 +279,7 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide * @hide */ */ @TestApi @TestApi public static final int MODULE_SYSTEM = 1; public static final String MODULE_SYSTEM = "system_server"; /** /** * The module used for bluetooth caches. * The module used for bluetooth caches. Loading @@ -295,11 +287,12 @@ public class PropertyInvalidatedCache<Query, Result> { */ */ @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @TestApi @TestApi public static final int MODULE_BLUETOOTH = 2; public static final String MODULE_BLUETOOTH = "bluetooth"; // A static array mapping module constants to strings. /** private final static String[] sModuleNames = * The module used for telephony caches. { "test", "system_server", "bluetooth" }; */ public static final String MODULE_TELEPHONY = "telephony"; /** /** * Construct a system property that matches the rules described above. The module is * Construct a system property that matches the rules described above. The module is Loading @@ -315,7 +308,8 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide * @hide */ */ @TestApi @TestApi public static @NonNull String createPropertyName(@Module int module, @NonNull String apiName) { public static @NonNull String createPropertyName(@NonNull String module, @NonNull String apiName) { char[] api = apiName.toCharArray(); char[] api = apiName.toCharArray(); int upper = 0; int upper = 0; for (int i = 0; i < api.length; i++) { for (int i = 0; i < api.length; i++) { Loading @@ -338,14 +332,7 @@ public class PropertyInvalidatedCache<Query, Result> { } } } } String moduleName = null; return "cache_key." + module + "." + new String(suffix); try { moduleName = sModuleNames[module]; } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid module " + module); } return "cache_key." + moduleName + "." + new String(suffix); } } /** /** Loading Loading @@ -548,7 +535,7 @@ public class PropertyInvalidatedCache<Query, Result> { */ */ @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @TestApi @TestApi public PropertyInvalidatedCache(int maxEntries, @Module int module, @NonNull String api, public PropertyInvalidatedCache(int maxEntries, @NonNull String module, @NonNull String api, @NonNull String cacheName, @NonNull QueryHandler<Query, Result> computer) { @NonNull String cacheName, @NonNull QueryHandler<Query, Result> computer) { mPropertyName = createPropertyName(module, api); mPropertyName = createPropertyName(module, api); mCacheName = cacheName; mCacheName = cacheName; Loading Loading @@ -989,7 +976,7 @@ public class PropertyInvalidatedCache<Query, Result> { */ */ @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @TestApi @TestApi public static void invalidateCache(@Module int module, @NonNull String api) { public static void invalidateCache(@NonNull String module, @NonNull String api) { invalidateCache(createPropertyName(module, api)); invalidateCache(createPropertyName(module, api)); } } Loading Loading @@ -1211,11 +1198,13 @@ public class PropertyInvalidatedCache<Query, Result> { getHandlerLocked().sendEmptyMessageAtTime(0, mUncorkDeadlineMs); getHandlerLocked().sendEmptyMessageAtTime(0, mUncorkDeadlineMs); PropertyInvalidatedCache.corkInvalidations(mPropertyName); PropertyInvalidatedCache.corkInvalidations(mPropertyName); } else { } else { synchronized (sCorkLock) { final long count = sCorkedInvalidates.getOrDefault(mPropertyName, (long) 0); final long count = sCorkedInvalidates.getOrDefault(mPropertyName, (long) 0); sCorkedInvalidates.put(mPropertyName, count + 1); sCorkedInvalidates.put(mPropertyName, count + 1); } } } } } } } private void handleMessage(Message msg) { private void handleMessage(Message msg) { synchronized (mLock) { synchronized (mLock) { Loading Loading @@ -1341,7 +1330,7 @@ public class PropertyInvalidatedCache<Query, Result> { } } } } private void dumpContents(PrintWriter pw, String[] args) { private void dumpContents(PrintWriter pw) { long invalidateCount; long invalidateCount; long corkedInvalidates; long corkedInvalidates; synchronized (sCorkLock) { synchronized (sCorkLock) { Loading Loading @@ -1418,7 +1407,7 @@ public class PropertyInvalidatedCache<Query, Result> { for (int i = 0; i < activeCaches.size(); i++) { for (int i = 0; i < activeCaches.size(); i++) { PropertyInvalidatedCache currentCache = activeCaches.get(i); PropertyInvalidatedCache currentCache = activeCaches.get(i); currentCache.dumpContents(pw, args); currentCache.dumpContents(pw); pw.flush(); pw.flush(); } } } catch (IOException e) { } catch (IOException e) { Loading core/tests/coretests/src/android/app/PropertyInvalidatedCacheTests.java +3 −12 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,7 @@ import org.junit.Test; public class PropertyInvalidatedCacheTests { public class PropertyInvalidatedCacheTests { // Configuration for creating caches // Configuration for creating caches private static final int MODULE = PropertyInvalidatedCache.MODULE_TEST; private static final String MODULE = PropertyInvalidatedCache.MODULE_TEST; private static final String API = "testApi"; private static final String API = "testApi"; // This class is a proxy for binder calls. It contains a counter that increments // This class is a proxy for binder calls. It contains a counter that increments Loading Loading @@ -214,13 +214,13 @@ public class PropertyInvalidatedCacheTests { this(MODULE, API); this(MODULE, API); } } TestCache(int module, String api) { TestCache(String module, String api) { this(module, api, new TestQuery()); this(module, api, new TestQuery()); setTestMode(true); setTestMode(true); testPropertyName(); testPropertyName(); } } TestCache(int module, String api, TestQuery query) { TestCache(String module, String api, TestQuery query) { super(4, module, api, api, query); super(4, module, api, api, query); mQuery = query; mQuery = query; setTestMode(true); setTestMode(true); Loading Loading @@ -364,15 +364,6 @@ public class PropertyInvalidatedCacheTests { n1 = PropertyInvalidatedCache.createPropertyName( n1 = PropertyInvalidatedCache.createPropertyName( PropertyInvalidatedCache.MODULE_SYSTEM, "get_package_info"); PropertyInvalidatedCache.MODULE_SYSTEM, "get_package_info"); assertEquals(n1, "cache_key.system_server.get_package_info"); assertEquals(n1, "cache_key.system_server.get_package_info"); try { n1 = PropertyInvalidatedCache.createPropertyName( PropertyInvalidatedCache.MODULE_SYSTEM - 1, "get package_info"); // n1 is an invalid api name. assertEquals(false, true); } catch (IllegalArgumentException e) { // An exception is expected here. } n1 = PropertyInvalidatedCache.createPropertyName( n1 = PropertyInvalidatedCache.createPropertyName( PropertyInvalidatedCache.MODULE_BLUETOOTH, "getState"); PropertyInvalidatedCache.MODULE_BLUETOOTH, "getState"); assertEquals(n1, "cache_key.bluetooth.get_state"); assertEquals(n1, "cache_key.bluetooth.get_state"); Loading Loading
core/api/module-lib-current.txt +4 −3 Original line number Original line Diff line number Diff line Loading @@ -55,12 +55,13 @@ package android.app { } } public class PropertyInvalidatedCache<Query, Result> { public class PropertyInvalidatedCache<Query, Result> { ctor public PropertyInvalidatedCache(int, int, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); ctor public PropertyInvalidatedCache(int, @NonNull String, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); method public final void disableForCurrentProcess(); method public final void disableForCurrentProcess(); method public final void invalidateCache(); method public final void invalidateCache(); method public static void invalidateCache(int, @NonNull String); method public static void invalidateCache(@NonNull String, @NonNull String); method @Nullable public final Result query(@NonNull Query); method @Nullable public final Result query(@NonNull Query); field public static final int MODULE_BLUETOOTH = 2; // 0x2 field public static final String MODULE_BLUETOOTH = "bluetooth"; field public static final String MODULE_TELEPHONY = "telephony"; } } public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { Loading
core/api/test-current.txt +7 −6 Original line number Original line Diff line number Diff line Loading @@ -372,8 +372,8 @@ package android.app { } } public class PropertyInvalidatedCache<Query, Result> { public class PropertyInvalidatedCache<Query, Result> { ctor public PropertyInvalidatedCache(int, int, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); ctor public PropertyInvalidatedCache(int, @NonNull String, @NonNull String, @NonNull String, @NonNull android.app.PropertyInvalidatedCache.QueryHandler<Query,Result>); method @NonNull public static String createPropertyName(int, @NonNull String); method @NonNull public static String createPropertyName(@NonNull String, @NonNull String); method public final void disableForCurrentProcess(); method public final void disableForCurrentProcess(); method public static void disableForTestMode(); method public static void disableForTestMode(); method public final void disableInstance(); method public final void disableInstance(); Loading @@ -381,14 +381,15 @@ package android.app { method public final void forgetDisableLocal(); method public final void forgetDisableLocal(); method public boolean getDisabledState(); method public boolean getDisabledState(); method public final void invalidateCache(); method public final void invalidateCache(); method public static void invalidateCache(int, @NonNull String); method public static void invalidateCache(@NonNull String, @NonNull String); method public final boolean isDisabled(); method public final boolean isDisabled(); method @Nullable public final Result query(@NonNull Query); method @Nullable public final Result query(@NonNull Query); method public static void setTestMode(boolean); method public static void setTestMode(boolean); method public void testPropertyName(); method public void testPropertyName(); field public static final int MODULE_BLUETOOTH = 2; // 0x2 field public static final String MODULE_BLUETOOTH = "bluetooth"; field public static final int MODULE_SYSTEM = 1; // 0x1 field public static final String MODULE_SYSTEM = "system_server"; field public static final int MODULE_TEST = 0; // 0x0 field public static final String MODULE_TELEPHONY = "telephony"; field public static final String MODULE_TEST = "test"; } } public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { public abstract static class PropertyInvalidatedCache.QueryHandler<Q, R> { Loading
core/java/android/app/PropertyInvalidatedCache.java +18 −29 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.app; package android.app; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.SystemApi; Loading Loading @@ -265,13 +264,6 @@ public class PropertyInvalidatedCache<Query, Result> { * the permissions granted to the processes that contain the corresponding caches. * the permissions granted to the processes that contain the corresponding caches. * @hide * @hide */ */ @IntDef(prefix = { "MODULE_" }, value = { MODULE_TEST, MODULE_SYSTEM, MODULE_BLUETOOTH }) @Retention(RetentionPolicy.SOURCE) public @interface Module {} /** /** * The module used for unit tests and cts tests. It is expected that no process in * The module used for unit tests and cts tests. It is expected that no process in Loading @@ -279,7 +271,7 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide * @hide */ */ @TestApi @TestApi public static final int MODULE_TEST = 0; public static final String MODULE_TEST = "test"; /** /** * The module used for system server/framework caches. This is not visible outside * The module used for system server/framework caches. This is not visible outside Loading @@ -287,7 +279,7 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide * @hide */ */ @TestApi @TestApi public static final int MODULE_SYSTEM = 1; public static final String MODULE_SYSTEM = "system_server"; /** /** * The module used for bluetooth caches. * The module used for bluetooth caches. Loading @@ -295,11 +287,12 @@ public class PropertyInvalidatedCache<Query, Result> { */ */ @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @TestApi @TestApi public static final int MODULE_BLUETOOTH = 2; public static final String MODULE_BLUETOOTH = "bluetooth"; // A static array mapping module constants to strings. /** private final static String[] sModuleNames = * The module used for telephony caches. { "test", "system_server", "bluetooth" }; */ public static final String MODULE_TELEPHONY = "telephony"; /** /** * Construct a system property that matches the rules described above. The module is * Construct a system property that matches the rules described above. The module is Loading @@ -315,7 +308,8 @@ public class PropertyInvalidatedCache<Query, Result> { * @hide * @hide */ */ @TestApi @TestApi public static @NonNull String createPropertyName(@Module int module, @NonNull String apiName) { public static @NonNull String createPropertyName(@NonNull String module, @NonNull String apiName) { char[] api = apiName.toCharArray(); char[] api = apiName.toCharArray(); int upper = 0; int upper = 0; for (int i = 0; i < api.length; i++) { for (int i = 0; i < api.length; i++) { Loading @@ -338,14 +332,7 @@ public class PropertyInvalidatedCache<Query, Result> { } } } } String moduleName = null; return "cache_key." + module + "." + new String(suffix); try { moduleName = sModuleNames[module]; } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid module " + module); } return "cache_key." + moduleName + "." + new String(suffix); } } /** /** Loading Loading @@ -548,7 +535,7 @@ public class PropertyInvalidatedCache<Query, Result> { */ */ @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @TestApi @TestApi public PropertyInvalidatedCache(int maxEntries, @Module int module, @NonNull String api, public PropertyInvalidatedCache(int maxEntries, @NonNull String module, @NonNull String api, @NonNull String cacheName, @NonNull QueryHandler<Query, Result> computer) { @NonNull String cacheName, @NonNull QueryHandler<Query, Result> computer) { mPropertyName = createPropertyName(module, api); mPropertyName = createPropertyName(module, api); mCacheName = cacheName; mCacheName = cacheName; Loading Loading @@ -989,7 +976,7 @@ public class PropertyInvalidatedCache<Query, Result> { */ */ @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES) @TestApi @TestApi public static void invalidateCache(@Module int module, @NonNull String api) { public static void invalidateCache(@NonNull String module, @NonNull String api) { invalidateCache(createPropertyName(module, api)); invalidateCache(createPropertyName(module, api)); } } Loading Loading @@ -1211,11 +1198,13 @@ public class PropertyInvalidatedCache<Query, Result> { getHandlerLocked().sendEmptyMessageAtTime(0, mUncorkDeadlineMs); getHandlerLocked().sendEmptyMessageAtTime(0, mUncorkDeadlineMs); PropertyInvalidatedCache.corkInvalidations(mPropertyName); PropertyInvalidatedCache.corkInvalidations(mPropertyName); } else { } else { synchronized (sCorkLock) { final long count = sCorkedInvalidates.getOrDefault(mPropertyName, (long) 0); final long count = sCorkedInvalidates.getOrDefault(mPropertyName, (long) 0); sCorkedInvalidates.put(mPropertyName, count + 1); sCorkedInvalidates.put(mPropertyName, count + 1); } } } } } } } private void handleMessage(Message msg) { private void handleMessage(Message msg) { synchronized (mLock) { synchronized (mLock) { Loading Loading @@ -1341,7 +1330,7 @@ public class PropertyInvalidatedCache<Query, Result> { } } } } private void dumpContents(PrintWriter pw, String[] args) { private void dumpContents(PrintWriter pw) { long invalidateCount; long invalidateCount; long corkedInvalidates; long corkedInvalidates; synchronized (sCorkLock) { synchronized (sCorkLock) { Loading Loading @@ -1418,7 +1407,7 @@ public class PropertyInvalidatedCache<Query, Result> { for (int i = 0; i < activeCaches.size(); i++) { for (int i = 0; i < activeCaches.size(); i++) { PropertyInvalidatedCache currentCache = activeCaches.get(i); PropertyInvalidatedCache currentCache = activeCaches.get(i); currentCache.dumpContents(pw, args); currentCache.dumpContents(pw); pw.flush(); pw.flush(); } } } catch (IOException e) { } catch (IOException e) { Loading
core/tests/coretests/src/android/app/PropertyInvalidatedCacheTests.java +3 −12 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,7 @@ import org.junit.Test; public class PropertyInvalidatedCacheTests { public class PropertyInvalidatedCacheTests { // Configuration for creating caches // Configuration for creating caches private static final int MODULE = PropertyInvalidatedCache.MODULE_TEST; private static final String MODULE = PropertyInvalidatedCache.MODULE_TEST; private static final String API = "testApi"; private static final String API = "testApi"; // This class is a proxy for binder calls. It contains a counter that increments // This class is a proxy for binder calls. It contains a counter that increments Loading Loading @@ -214,13 +214,13 @@ public class PropertyInvalidatedCacheTests { this(MODULE, API); this(MODULE, API); } } TestCache(int module, String api) { TestCache(String module, String api) { this(module, api, new TestQuery()); this(module, api, new TestQuery()); setTestMode(true); setTestMode(true); testPropertyName(); testPropertyName(); } } TestCache(int module, String api, TestQuery query) { TestCache(String module, String api, TestQuery query) { super(4, module, api, api, query); super(4, module, api, api, query); mQuery = query; mQuery = query; setTestMode(true); setTestMode(true); Loading Loading @@ -364,15 +364,6 @@ public class PropertyInvalidatedCacheTests { n1 = PropertyInvalidatedCache.createPropertyName( n1 = PropertyInvalidatedCache.createPropertyName( PropertyInvalidatedCache.MODULE_SYSTEM, "get_package_info"); PropertyInvalidatedCache.MODULE_SYSTEM, "get_package_info"); assertEquals(n1, "cache_key.system_server.get_package_info"); assertEquals(n1, "cache_key.system_server.get_package_info"); try { n1 = PropertyInvalidatedCache.createPropertyName( PropertyInvalidatedCache.MODULE_SYSTEM - 1, "get package_info"); // n1 is an invalid api name. assertEquals(false, true); } catch (IllegalArgumentException e) { // An exception is expected here. } n1 = PropertyInvalidatedCache.createPropertyName( n1 = PropertyInvalidatedCache.createPropertyName( PropertyInvalidatedCache.MODULE_BLUETOOTH, "getState"); PropertyInvalidatedCache.MODULE_BLUETOOTH, "getState"); assertEquals(n1, "cache_key.bluetooth.get_state"); assertEquals(n1, "cache_key.bluetooth.get_state"); Loading