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

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

Remove a test-only PIC exception

PropertyInvalidatedCache.setTestMode() should not throw an exception
yet.  The protocol is that the test mode must toggle but that was not
enforced.  A recent commit threw an exception if the mode did not
toggle (all clients were updated) but the updated platform code will
not pass a legacy CTS test.

This flag-guards the exception.

Tested with a CTS build from 25Q1; verified that a log message is generated
but the test still passes.

Flag: android.app.enforce_pic_testmode_protocol
Bug: 375954058
Test: atest
 * FrameworksCoreTests:PropertyInvalidatedCacheTests
 * FrameworksCoreTests:IpcDataCacheTest
 * CtsOsTestCases:IpcDataCacheTest
 * ServiceBluetoothTests
Change-Id: Ie79958ead5190150bb4dc342c5d3aaac8791f420
parent 194dc2cd
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -944,7 +944,12 @@ public class PropertyInvalidatedCache<Query, Result> {
    public static void setTestMode(boolean mode) {
        synchronized (sGlobalLock) {
            if (sTestMode == mode) {
                throw new IllegalStateException("cannot set test mode redundantly: mode=" + mode);
                final String msg = "cannot set test mode redundantly: mode=" + mode;
                if (Flags.enforcePicTestmodeProtocol()) {
                    throw new IllegalStateException(msg);
                } else {
                    Log.e(TAG, msg);
                }
            }
            sTestMode = mode;
            if (mode) {
+9 −0
Original line number Diff line number Diff line
@@ -9,3 +9,12 @@ flag {
     description: "PropertyInvalidatedCache uses shared memory for nonces."
     bug: "366552454"
}

flag {
     namespace: "system_performance"
     name: "enforce_pic_testmode_protocol"
     is_exported: true
     is_fixed_read_only: true
     description: "Enforce PropertyInvalidatedCache.setTestMode() protocol"
     bug: "366552454"
}
+3 −1
Original line number Diff line number Diff line
@@ -420,7 +420,9 @@ public class PropertyInvalidatedCacheTests {
        PropertyInvalidatedCache.setTestMode(false);
        try {
            PropertyInvalidatedCache.setTestMode(false);
            if (Flags.enforcePicTestmodeProtocol()) {
                fail("expected an IllegalStateException");
            }
        } catch (IllegalStateException e) {
            // The expected exception.
        }
+3 −1
Original line number Diff line number Diff line
@@ -483,7 +483,9 @@ public class IpcDataCacheTest {
        IpcDataCache.setTestMode(false);
        try {
            IpcDataCache.setTestMode(false);
            if (android.app.Flags.enforcePicTestmodeProtocol()) {
                fail("expected an IllegalStateException");
            }
        } catch (IllegalStateException e) {
            // The expected exception.
        }