Revert "Always apply compat changes to system apps."

This reverts commit 345b1d5344.

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
This commit is contained in:
Anna Trostanetski
2019-08-22 16:20:36 +00:00
parent 6162efbfa7
commit 1b54316f53
2 changed files with 0 additions and 34 deletions

View File

@@ -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);
}

View File

@@ -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,