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

Commit 1b54316f authored by Anna Trostanetski's avatar Anna Trostanetski
Browse files

Revert "Always apply compat changes to system apps."

This reverts commit 345b1d53.

Reason for revert: We should respect the targetSDK of system apps as
well, and there's no reason not to support them as far as I can see.
Usecase example: ag/9025572

Bug: 135010838
Test: atest CompatConfigTest
Change-Id: I256c377e4edc59ba998609f4d3b6b87edeb8fff3
parent 6162efbf
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -118,12 +118,6 @@ public final class CompatChange {
     * @return {@code true} if the change should be enabled for the package.
     */
    boolean isEnabled(ApplicationInfo app) {
        if (app.isSystemApp()) {
            // All changes are enabled for system apps, and we do not support overrides.
            // Compatibility issues for system apps should be addressed in the app itself when
            // the compatibility change is made.
            return true;
        }
        if (mPackageOverrides != null && mPackageOverrides.containsKey(app.packageName)) {
            return mPackageOverrides.get(app.packageName);
        }
+0 −28
Original line number Diff line number Diff line
@@ -172,34 +172,6 @@ public class CompatConfigTest {
        assertThat(pc.lookupChangeId("MY_CHANGE")).isEqualTo(-1L);
    }

    @Test
    public void testSystemAppDisabledChangeEnabled() {
        CompatConfig pc = new CompatConfig();
        pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true)); // disabled
        ApplicationInfo sysApp = makeAppInfo("system.app", 1);
        sysApp.flags |= ApplicationInfo.FLAG_SYSTEM;
        assertThat(pc.isChangeEnabled(1234L, sysApp)).isTrue();
    }

    @Test
    public void testSystemAppOverrideIgnored() {
        CompatConfig pc = new CompatConfig();
        pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false));
        pc.addOverride(1234L, "system.app", false);
        ApplicationInfo sysApp = makeAppInfo("system.app", 1);
        sysApp.flags |= ApplicationInfo.FLAG_SYSTEM;
        assertThat(pc.isChangeEnabled(1234L, sysApp)).isTrue();
    }

    @Test
    public void testSystemAppTargetSdkIgnored() {
        CompatConfig pc = new CompatConfig();
        pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, false));
        ApplicationInfo sysApp = makeAppInfo("system.app", 1);
        sysApp.flags |= ApplicationInfo.FLAG_SYSTEM;
        assertThat(pc.isChangeEnabled(1234L, sysApp)).isTrue();
    }

    @Test
    public void testReadConfig() {
        Change[] changes = {new Change(1234L, "MY_CHANGE1", false, 2), new Change(1235L,