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

Commit e59e1b2c authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Enable IpcDataCache on Ravenwood" into main

parents 74b970b3 bad5edf3
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import java.util.concurrent.atomic.AtomicLong;
 * @hide
 */
@TestApi
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class PropertyInvalidatedCache<Query, Result> {
    /**
     * This is a configuration class that customizes a cache instance.
@@ -798,9 +799,17 @@ public class PropertyInvalidatedCache<Query, Result> {
            = new ConcurrentHashMap<>();

    // True if shared memory is flag-enabled, false otherwise.  Read the flags exactly once.
    private static final boolean sSharedMemoryAvailable =
            com.android.internal.os.Flags.applicationSharedMemoryEnabled()
    private static final boolean sSharedMemoryAvailable = isSharedMemoryAvailable();

    @android.ravenwood.annotation.RavenwoodReplace
    private static boolean isSharedMemoryAvailable() {
        return com.android.internal.os.Flags.applicationSharedMemoryEnabled()
                && android.app.Flags.picUsesSharedMemory();
    }

    private static boolean isSharedMemoryAvailable$ravenwood() {
        return false; // Always disable shared memory on Ravenwood. (for now)
    }

    // Return true if this cache can use shared memory for its nonce.  Shared memory may be used
    // if the module is the system.
+1 −0
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ import java.util.concurrent.atomic.AtomicLong;
 */
@TestApi
@SystemApi(client=SystemApi.Client.MODULE_LIBRARIES)
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class IpcDataCache<Query, Result> extends PropertyInvalidatedCache<Query, Result> {
    /**
     * {@inheritDoc}
+1 −0
Original line number Diff line number Diff line
@@ -266,6 +266,7 @@ android_ravenwood_test {
        "src/android/content/ContextTest.java",
        "src/android/content/pm/PackageManagerTest.java",
        "src/android/content/pm/UserInfoTest.java",
        "src/android/app/PropertyInvalidatedCacheTests.java",
        "src/android/database/CursorWindowTest.java",
        "src/android/os/**/*.java",
        "src/android/content/res/*.java",
+13 −6
Original line number Diff line number Diff line
@@ -52,11 +52,7 @@ import org.junit.Test;
 *  atest FrameworksCoreTests:PropertyInvalidatedCacheTests
 */
@SmallTest
@IgnoreUnderRavenwood(blockedBy = PropertyInvalidatedCache.class)
public class PropertyInvalidatedCacheTests {
    @Rule
    public final RavenwoodRule mRavenwood = new RavenwoodRule();

    public final CheckFlagsRule mCheckFlagsRule =
            DeviceFlagsValueProvider.createCheckFlagsRule();

@@ -389,9 +385,11 @@ public class PropertyInvalidatedCacheTests {
        assertEquals(n1, "cache_key.bluetooth.get_state");
    }

    // Verify that test mode works properly.
    // Verify that invalidating the cache from an app process would fail due to lack of permissions.
    @Test
    public void testTestMode() {
    @android.platform.test.annotations.DisabledOnRavenwood(
            reason = "SystemProperties doesn't have permission check")
    public void testPermissionFailure() {
        // Create a cache that will write a system nonce.
        TestCache sysCache = new TestCache(PropertyInvalidatedCache.MODULE_SYSTEM, "mode1");
        try {
@@ -403,6 +401,13 @@ public class PropertyInvalidatedCacheTests {
            // The expected exception is a bare RuntimeException.  The test does not attempt to
            // validate the text of the exception message.
        }
    }

    // Verify that test mode works properly.
    @Test
    public void testTestMode() {
        // Create a cache that will write a system nonce.
        TestCache sysCache = new TestCache(PropertyInvalidatedCache.MODULE_SYSTEM, "mode1");

        sysCache.testPropertyName();
        // Invalidate the cache.  This must succeed because the property has been marked for
@@ -441,6 +446,8 @@ public class PropertyInvalidatedCacheTests {
    // storing nonces in shared memory.
    @RequiresFlagsEnabled(FLAG_APPLICATION_SHARED_MEMORY_ENABLED)
    @Test
    @android.platform.test.annotations.DisabledOnRavenwood(
            reason = "PIC doesn't use SharedMemory on Ravenwood")
    public void testSharedMemoryStorage() {
        // Fetch a shared memory instance for testing.
        ApplicationSharedMemory shmem = ApplicationSharedMemory.create();
+11 −5
Original line number Diff line number Diff line
@@ -41,10 +41,7 @@ import org.junit.Test;
 *  atest FrameworksCoreTests:IpcDataCacheTest
 */
@SmallTest
@IgnoreUnderRavenwood(blockedBy = IpcDataCache.class)
public class IpcDataCacheTest {
    @Rule
    public final RavenwoodRule mRavenwood = new RavenwoodRule();

    // Configuration for creating caches
    private static final String MODULE = IpcDataCache.MODULE_TEST;
@@ -452,9 +449,11 @@ public class IpcDataCacheTest {
        assertEquals(ec.isDisabled(), true);
    }

    // Verify that test mode works properly.
    // Verify that invalidating the cache from an app process would fail due to lack of permissions.
    @Test
    public void testTestMode() {
    @android.platform.test.annotations.DisabledOnRavenwood(
            reason = "SystemProperties doesn't have permission check")
    public void testPermissionFailure() {
        // Create a cache that will write a system nonce.
        TestCache sysCache = new TestCache(IpcDataCache.MODULE_SYSTEM, "mode1");
        try {
@@ -466,6 +465,13 @@ public class IpcDataCacheTest {
            // The expected exception is a bare RuntimeException.  The test does not attempt to
            // validate the text of the exception message.
        }
    }

    // Verify that test mode works properly.
    @Test
    public void testTestMode() {
        // Create a cache that will write a system nonce.
        TestCache sysCache = new TestCache(IpcDataCache.MODULE_SYSTEM, "mode1");

        sysCache.testPropertyName();
        // Invalidate the cache.  This must succeed because the property has been marked for
Loading