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

Commit e691553a authored by Mathew Inwood's avatar Mathew Inwood Committed by Gerrit Code Review
Browse files

Merge "Always apply compat changes to system apps."

parents 1faafcb4 345b1d53
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -106,6 +106,12 @@ 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);
        }
+28 −0
Original line number Diff line number Diff line
@@ -142,4 +142,32 @@ public class CompatConfigTest {
        CompatConfig pc = new CompatConfig();
        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();
    }
}