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

Commit 2e1d6c23 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/25671849'] into 24Q1-release.

Change-Id: I31a7496d20cf16b4fa3256f21ddd6ff26c4f2d5e
parents a153f291 7edef699
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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;
+5 −24
Original line number Diff line number Diff line
@@ -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();
@@ -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();
    }