Loading services/core/java/com/android/server/compat/CompatChange.java +0 −3 Original line number Diff line number Diff line Loading @@ -252,9 +252,6 @@ public final class CompatChange extends CompatibilityChangeInfo { // If the change is gated by a platform version newer than the one currently installed // on the device, disregard the app's target sdk version. int compareSdk = Math.min(app.targetSdkVersion, buildClassifier.platformTargetSdk()); if (compareSdk != app.targetSdkVersion) { compareSdk = app.targetSdkVersion; } return compareSdk >= getEnableSinceTargetSdk(); } return true; Loading services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java +5 −24 Original line number Diff line number Diff line Loading @@ -868,6 +868,7 @@ public class CompatConfigTest { + "<compat-change id=\"1234\" name=\"MY_CHANGE1\" enableAfterTargetSdk=\"2\" />" + "<compat-change id=\"1235\" name=\"MY_CHANGE2\" disabled=\"true\" />" + "<compat-change id=\"1236\" name=\"MY_CHANGE3\" />" + "<compat-change id=\"1237\" name=\"MY_CHANGE4\" enableSinceTargetSdk=\"31\" />" + "</config>"; File dir = createTempDir(); Loading @@ -885,32 +886,12 @@ public class CompatConfigTest { ApplicationInfoBuilder.create().withTargetSdk(5).build())).isFalse(); assertThat(compatConfig.isChangeEnabled(1236L, ApplicationInfoBuilder.create().withTargetSdk(1).build())).isTrue(); } @Test public void testReadApexConfig() throws IOException { String configXml = "<config>" + "<compat-change id=\"1234\" name=\"MY_CHANGE1\" enableAfterTargetSdk=\"2\" />" + "<compat-change id=\"1235\" name=\"MY_CHANGE2\" disabled=\"true\" />" + "<compat-change id=\"1236\" name=\"MY_CHANGE3\" />" + "<compat-change id=\"1237\" name=\"MY_CHANGE4\" enableSinceTargetSdk=\"31\" />" + "</config>"; File dir = createTempDir(); writeToFile(dir, "platform_compat_config.xml", configXml); CompatConfig compatConfig = new CompatConfig(mBuildClassifier, mContext); compatConfig.forceNonDebuggableFinalForTest(false); assertThat(compatConfig.isChangeEnabled(1237L, ApplicationInfoBuilder.create().withTargetSdk(31).build())).isFalse(); compatConfig.initConfigFromLib(dir); // Force the platform sdk version to be same as enabled target sdk when(mBuildClassifier.platformTargetSdk()).thenReturn(31); assertThat(compatConfig.isChangeEnabled(1234L, ApplicationInfoBuilder.create().withTargetSdk(1).build())).isFalse(); assertThat(compatConfig.isChangeEnabled(1234L, ApplicationInfoBuilder.create().withTargetSdk(3).build())).isTrue(); assertThat(compatConfig.isChangeEnabled(1235L, ApplicationInfoBuilder.create().withTargetSdk(5).build())).isFalse(); assertThat(compatConfig.isChangeEnabled(1236L, ApplicationInfoBuilder.create().withTargetSdk(1).build())).isTrue(); assertThat(compatConfig.isChangeEnabled(1237L, ApplicationInfoBuilder.create().withTargetSdk(31).build())).isTrue(); } Loading Loading
services/core/java/com/android/server/compat/CompatChange.java +0 −3 Original line number Diff line number Diff line Loading @@ -252,9 +252,6 @@ public final class CompatChange extends CompatibilityChangeInfo { // If the change is gated by a platform version newer than the one currently installed // on the device, disregard the app's target sdk version. int compareSdk = Math.min(app.targetSdkVersion, buildClassifier.platformTargetSdk()); if (compareSdk != app.targetSdkVersion) { compareSdk = app.targetSdkVersion; } return compareSdk >= getEnableSinceTargetSdk(); } return true; Loading
services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java +5 −24 Original line number Diff line number Diff line Loading @@ -868,6 +868,7 @@ public class CompatConfigTest { + "<compat-change id=\"1234\" name=\"MY_CHANGE1\" enableAfterTargetSdk=\"2\" />" + "<compat-change id=\"1235\" name=\"MY_CHANGE2\" disabled=\"true\" />" + "<compat-change id=\"1236\" name=\"MY_CHANGE3\" />" + "<compat-change id=\"1237\" name=\"MY_CHANGE4\" enableSinceTargetSdk=\"31\" />" + "</config>"; File dir = createTempDir(); Loading @@ -885,32 +886,12 @@ public class CompatConfigTest { ApplicationInfoBuilder.create().withTargetSdk(5).build())).isFalse(); assertThat(compatConfig.isChangeEnabled(1236L, ApplicationInfoBuilder.create().withTargetSdk(1).build())).isTrue(); } @Test public void testReadApexConfig() throws IOException { String configXml = "<config>" + "<compat-change id=\"1234\" name=\"MY_CHANGE1\" enableAfterTargetSdk=\"2\" />" + "<compat-change id=\"1235\" name=\"MY_CHANGE2\" disabled=\"true\" />" + "<compat-change id=\"1236\" name=\"MY_CHANGE3\" />" + "<compat-change id=\"1237\" name=\"MY_CHANGE4\" enableSinceTargetSdk=\"31\" />" + "</config>"; File dir = createTempDir(); writeToFile(dir, "platform_compat_config.xml", configXml); CompatConfig compatConfig = new CompatConfig(mBuildClassifier, mContext); compatConfig.forceNonDebuggableFinalForTest(false); assertThat(compatConfig.isChangeEnabled(1237L, ApplicationInfoBuilder.create().withTargetSdk(31).build())).isFalse(); compatConfig.initConfigFromLib(dir); // Force the platform sdk version to be same as enabled target sdk when(mBuildClassifier.platformTargetSdk()).thenReturn(31); assertThat(compatConfig.isChangeEnabled(1234L, ApplicationInfoBuilder.create().withTargetSdk(1).build())).isFalse(); assertThat(compatConfig.isChangeEnabled(1234L, ApplicationInfoBuilder.create().withTargetSdk(3).build())).isTrue(); assertThat(compatConfig.isChangeEnabled(1235L, ApplicationInfoBuilder.create().withTargetSdk(5).build())).isFalse(); assertThat(compatConfig.isChangeEnabled(1236L, ApplicationInfoBuilder.create().withTargetSdk(1).build())).isTrue(); assertThat(compatConfig.isChangeEnabled(1237L, ApplicationInfoBuilder.create().withTargetSdk(31).build())).isTrue(); } Loading