Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6504f56c authored by Lee Shombert's avatar Lee Shombert Committed by Android (Google) Code Review
Browse files

Merge "Create the ADSERVICES cache module" into main

parents 11f5849e 81fc122f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -413,6 +413,7 @@ package android.os {
    method public static void invalidateCache(@NonNull String, @NonNull String);
    method @Nullable public Result query(@NonNull Query);
    method @FlaggedApi("android.os.ipc_data_cache_testmode_apis") public static void setCacheTestMode(boolean);
    field @FlaggedApi("android.os.ipc_data_cache_module_adservices") public static final String MODULE_ADSERVICES = "adservices";
    field public static final String MODULE_BLUETOOTH = "bluetooth";
  }

+1 −0
Original line number Diff line number Diff line
@@ -2492,6 +2492,7 @@ package android.os {
    method @Nullable public Result query(@NonNull Query);
    method @FlaggedApi("android.os.ipc_data_cache_testmode_apis") public static void setCacheTestMode(boolean);
    method public static void setTestMode(boolean);
    field @FlaggedApi("android.os.ipc_data_cache_module_adservices") public static final String MODULE_ADSERVICES = "adservices";
    field public static final String MODULE_BLUETOOTH = "bluetooth";
    field public static final String MODULE_SYSTEM = "system_server";
    field public static final String MODULE_TEST = "test";
+16 −4
Original line number Diff line number Diff line
@@ -152,6 +152,12 @@ public class PropertyInvalidatedCache<Query, Result> {
     */
    public static final String MODULE_TELEPHONY = "telephony";

    /**
     * The module used by the adservices caches.
     * @hide
     */
    public static final String MODULE_ADSERVICES = "adservices";

    /**
     * An object that represents a distinct domain of cache keys.  The sole attribute is the
     * string name of the domain.
@@ -161,14 +167,16 @@ public class PropertyInvalidatedCache<Query, Result> {
    // The system module that supports shared memory.
    private static final Namespace sNamespaceSystem = new Namespace(MODULE_SYSTEM);
    // Stub modules representing the known non-system domains.
    private static final Namespace sNamespaceAdservices = new Namespace(MODULE_ADSERVICES);
    private static final Namespace sNamespaceBluetooth = new Namespace(MODULE_BLUETOOTH);
    private static final Namespace sNamespaceTelephony = new Namespace(MODULE_TELEPHONY);
    private static final Namespace sNamespaceTest = new Namespace(MODULE_TEST);

    private static Namespace nameToNamespace(@NonNull String name) {
        switch (name) {
            case MODULE_SYSTEM: return sNamespaceSystem;
            case MODULE_ADSERVICES: return sNamespaceAdservices;
            case MODULE_BLUETOOTH: return sNamespaceBluetooth;
            case MODULE_SYSTEM: return sNamespaceSystem;
            case MODULE_TELEPHONY: return sNamespaceTelephony;
            case MODULE_TEST: return sNamespaceTest;
        }
@@ -191,6 +199,8 @@ public class PropertyInvalidatedCache<Query, Result> {
     */
    public static @NonNull String createPropertyName(@NonNull String module,
            @NonNull String apiName) {
        throwIfInvalidModule(module);

        char[] api = apiName.toCharArray();
        int upper = 0;
        for (int i = 1; i < api.length; i++) {
@@ -214,15 +224,16 @@ public class PropertyInvalidatedCache<Query, Result> {
                throw new IllegalArgumentException("invalid api name");
            }
        }

        return CACHE_KEY_PREFIX + "." + module + "." + new String(suffix);
        final String name = CACHE_KEY_PREFIX + "." + module + "." + new String(suffix);
        throwIfInvalidCacheKey(name);
        return name;
    }

    /**
     * The list of known and legal modules.  The order is not significant.
     */
    private static final String[] sValidModule = {
        MODULE_SYSTEM, MODULE_BLUETOOTH, MODULE_TELEPHONY, MODULE_TEST,
        MODULE_SYSTEM, MODULE_BLUETOOTH, MODULE_TELEPHONY, MODULE_TEST, MODULE_ADSERVICES,
    };

    /**
@@ -260,6 +271,7 @@ public class PropertyInvalidatedCache<Query, Result> {
        CACHE_KEY_PREFIX + "." + MODULE_BLUETOOTH + ".",
        CACHE_KEY_PREFIX + "." + MODULE_TELEPHONY + ".",
        CACHE_KEY_PREFIX + "." + MODULE_TEST + ".",
        CACHE_KEY_PREFIX + "." + MODULE_ADSERVICES + ".",
    };

    // The components needed to identify a cache.
+11 −1
Original line number Diff line number Diff line
@@ -279,7 +279,8 @@ public class IpcDataCache<Query, Result> extends PropertyInvalidatedCache<Query,
            MODULE_TEST,
            MODULE_SYSTEM,
            MODULE_BLUETOOTH,
            MODULE_TELEPHONY
            MODULE_TELEPHONY,
            MODULE_ADSERVICES,
        }
    )
    @Retention(RetentionPolicy.SOURCE)
@@ -309,6 +310,15 @@ public class IpcDataCache<Query, Result> extends PropertyInvalidatedCache<Query,
    @TestApi
    public static final String MODULE_BLUETOOTH = PropertyInvalidatedCache.MODULE_BLUETOOTH;

    /**
     * The module used for adservices caches.
     * @hide
     */
    @FlaggedApi(Flags.FLAG_IPC_DATA_CACHE_MODULE_ADSERVICES)
    @SystemApi(client=SystemApi.Client.MODULE_LIBRARIES)
    @TestApi
    public static final String MODULE_ADSERVICES = PropertyInvalidatedCache.MODULE_ADSERVICES;

    /**
     * Make a new property invalidated cache.  The key is computed from the module and api
     * parameters.
+9 −0
Original line number Diff line number Diff line
@@ -261,6 +261,15 @@ flag {
    is_exported: true
}

flag {
     name: "ipc_data_cache_module_adservices"
     namespace: "system_performance"
     description: "IpcDataCache module for AdServices."
     is_fixed_read_only: true
     bug: "415306020"
     is_exported: true
}

flag {
     name: "ipc_data_cache_testmode_apis"
     namespace: "system_performance"
Loading