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

Commit ab7a9b67 authored by Lee Shombert's avatar Lee Shombert
Browse files

Update PIC Ravenwood dependencies

PIC supports three kinds of nonces: shared memory, sysprop, and local.
Shared memory is used for system nonces when shared memory is
available.  Now that ApplicationSharedMemory is a committed feature of
Android, shared memory is only unavailable when running a Ravenwood
test; this CL makes the selection of nonce type depend explicitly on
whether or not Ravenwood is running.

In particular, if Ravenwood is running then there is a single,
stand-alone process and there is no need for PIC to use either shared
memory or sysprops.  All nonces can use local storage.

Flag: EXEMPT bugfix
Bug: 423886240
Test: atest
 * CtsAppEnumerationTestCases
 * CtsMediaAudioPermissionTestCases
 * CtsMediaAudioTestCases:AudioRecordTest
 * CtsOsTestCases:IpcDataCacheTest
 * FrameworksCoreTests:IpcDataCacheTest
 * FrameworksCoreTests:PropertyInvalidatedCacheTests
 * ServiceBluetoothTests
 * android.app.appops.cts.AppOpsLoggingTest
 * android.content.pm.cts.PackageManagerTest
 * android.media.audio.cts.AudioFocusTest
 * com.android.server.pm.PackageManagerTests
Change-Id: If37c1c1a20d9c1c49aa4dc5fab118601ee716e66
parent a2e4f2de
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -1220,22 +1220,15 @@ public class PropertyInvalidatedCache<Query, Result> {
    private static final ConcurrentHashMap<CacheKey, NonceHandler> sHandlers =
            new ConcurrentHashMap<>();

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

    // True if nonces are visible to processes outside this one.
    @android.ravenwood.annotation.RavenwoodReplace
    private static boolean isSharedMemoryAvailable() {
    private static boolean isMultiProcess() {
        return true;
    }

    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.
    private static boolean sharedMemoryOkay(@NonNull CacheKey id) {
        return sSharedMemoryAvailable && sNamespaceSystem.equals(id.namespace);
    // Ravenwood processes are always stand-alone.
    private static boolean isMultiProcess$ravenwood() {
        return false;
    }

    /**
@@ -1249,7 +1242,9 @@ public class PropertyInvalidatedCache<Query, Result> {
            synchronized (sGlobalLock) {
                h = sHandlers.get(id);
                if (h == null) {
                    if (sharedMemoryOkay(id)) {
                    if (!isMultiProcess()) {
                        h = new NonceLocal(id);
                    } else if (sNamespaceSystem.equals(id.namespace)) {
                        h = new NonceSharedMem(id);
                    } else if (sNamespaceTest.equals(id.namespace)) {
                        h = new NonceLocal(id);
@@ -2098,9 +2093,10 @@ public class PropertyInvalidatedCache<Query, Result> {
        // See if brief output is requested.
        final boolean brief = briefRequested(args);

        if (sSharedMemoryAvailable) {
        NonceStore store = NonceStore.maybeGetInstance();
        if (store != null) {
            pw.println("  SharedMemory: enabled");
            NonceStore.getInstance().dump(pw, "    ", detail);
            store.dump(pw, "    ", detail);
        } else {
            pw.println("  SharedMemory: disabled");
         }
@@ -2243,6 +2239,14 @@ public class PropertyInvalidatedCache<Query, Result> {
            }
        }

        // Return the instance but only if it has been created already.  This is used for dump and
        // debug.
        static NonceStore maybeGetInstance() {
            synchronized (sLock) {
                return sInstance;
            }
        }

        // The index value of an unmapped name.
        public static final int INVALID_NONCE_INDEX = -1;