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

Commit f0acac41 authored by Michael Groover's avatar Michael Groover
Browse files

Add WRITE_ALLOWLISTED_DEVICE_CONFIG perm when modifying DeviceConfig

Android 16 introduces restrictions on the DeviceConfig flags that
can be modified by the shell user by removing the WRITE_DEVICE_CONFIG
permission from this user and replacing it with the
WRITE_ALLOWLISTED_DEVICE_CONFIG permission; with this permission,
only those flags that have been allowlisted can be modified. This
commit adds the ALLOWLISTED permission to any test that explicitly
adopts the shell permission identity with the WRITE_DEVICE_CONFIG
permission; the WRITE_DEVICE_CONFIG permission is not removed to
ensure tests do not break when run on previous platform releases
without the ALLOWLISTED permission.

Bug: 364083026
Flag: TEST_ONLY
Test: Manually ran all modified tests
Change-Id: Ib832d86a8100bb2118372d08c4320394f69dc5b8
parent 95ec53ee
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import org.junit.Test;
public class TextClassificationManagerPerfTest {
    private static final String WRITE_DEVICE_CONFIG_PERMISSION =
            "android.permission.WRITE_DEVICE_CONFIG";
    private static final String WRITE_ALLOWLISTED_DEVICE_CONFIG_PERMISSION =
            "android.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG";

    @Rule
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
@@ -44,7 +46,7 @@ public class TextClassificationManagerPerfTest {
    public static void setUpClass() {
        InstrumentationRegistry.getInstrumentation().getUiAutomation()
                .adoptShellPermissionIdentity(
                        WRITE_DEVICE_CONFIG_PERMISSION);
                        WRITE_DEVICE_CONFIG_PERMISSION, WRITE_ALLOWLISTED_DEVICE_CONFIG_PERMISSION);
    }

    @AfterClass
+3 −3
Original line number Diff line number Diff line
@@ -283,9 +283,9 @@ public class ActivityManagerServiceTest {
        // Required for updating DeviceConfig.
        InstrumentationRegistry.getInstrumentation()
                .getUiAutomation()
                .adoptShellPermissionIdentity(
                Manifest.permission.READ_DEVICE_CONFIG,
                Manifest.permission.WRITE_DEVICE_CONFIG);
                .adoptShellPermissionIdentity(Manifest.permission.READ_DEVICE_CONFIG,
                        Manifest.permission.WRITE_DEVICE_CONFIG,
                        Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG);
        sProcessListSettingsListener = mAms.mProcessList.getProcessListSettingsListener();
        assertThat(sProcessListSettingsListener).isNotNull();
    }
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class SoundTriggerMiddlewareLoggingLatencyTest {

        InstrumentationRegistry.getInstrumentation().getUiAutomation()
                .adoptShellPermissionIdentity(Manifest.permission.WRITE_DEVICE_CONFIG,
                        Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG,
                        Manifest.permission.READ_DEVICE_CONFIG);

        Identity identity = new Identity();
+2 −1
Original line number Diff line number Diff line
@@ -138,7 +138,8 @@ public class CrashRecoveryTest {
        new File(InstrumentationRegistry.getContext().getFilesDir(),
                "package-watchdog.xml").delete();
        adoptShellPermissions(Manifest.permission.READ_DEVICE_CONFIG,
                Manifest.permission.WRITE_DEVICE_CONFIG);
                Manifest.permission.WRITE_DEVICE_CONFIG,
                Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG);
        mTestLooper = new TestLooper();
        mSpyContext = spy(InstrumentationRegistry.getContext());
        when(mSpyContext.getPackageManager()).thenReturn(mMockPackageManager);
+2 −1
Original line number Diff line number Diff line
@@ -152,7 +152,8 @@ public class PackageWatchdogTest {
        new File(InstrumentationRegistry.getContext().getFilesDir(),
                "package-watchdog.xml").delete();
        adoptShellPermissions(Manifest.permission.READ_DEVICE_CONFIG,
                Manifest.permission.WRITE_DEVICE_CONFIG);
                Manifest.permission.WRITE_DEVICE_CONFIG,
                Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG);
        mTestLooper = new TestLooper();
        mSpyContext = spy(InstrumentationRegistry.getContext());
        when(mSpyContext.getPackageManager()).thenReturn(mMockPackageManager);
Loading