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

Commit e7be86fd authored by Rhed Jao's avatar Rhed Jao Committed by Automerger Merge Worker
Browse files

Ignore prebuilt shared library if it doesn't exist on device am: 791eb693

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1926342

Change-Id: I63155e278047882b33af00e349d2a7a32099655c
parents be595a1c 791eb693
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -870,7 +870,8 @@ public class SystemConfig {
                                boolean allowedMinSdk = minDeviceSdk <= Build.VERSION.SDK_INT;
                                boolean allowedMaxSdk =
                                        maxDeviceSdk == 0 || maxDeviceSdk >= Build.VERSION.SDK_INT;
                                if (allowedMinSdk && allowedMaxSdk) {
                                final boolean exists = new File(lfile).exists();
                                if (allowedMinSdk && allowedMaxSdk && exists) {
                                    int bcpSince = XmlUtils.readIntAttribute(parser,
                                            "on-bootclasspath-since", 0);
                                    int bcpBefore = XmlUtils.readIntAttribute(parser,
@@ -880,6 +881,19 @@ public class SystemConfig {
                                                    ? new String[0] : ldependency.split(":"),
                                            bcpSince, bcpBefore);
                                    mSharedLibraries.put(lname, entry);
                                } else {
                                    final StringBuilder msg = new StringBuilder(
                                            "Ignore shared library ").append(lname).append(":");
                                    if (!allowedMinSdk) {
                                        msg.append(" min-device-sdk=").append(minDeviceSdk);
                                    }
                                    if (!allowedMaxSdk) {
                                        msg.append(" max-device-sdk=").append(maxDeviceSdk);
                                    }
                                    if (!exists) {
                                        msg.append(" ").append(lfile).append(" does not exist");
                                    }
                                    Slog.i(TAG, msg.toString());
                                }
                            }
                        } else {
+14 −11
Original line number Diff line number Diff line
@@ -62,12 +62,15 @@ public class SystemConfigTest {
    private static final String LOG_TAG = "SystemConfigTest";

    private SystemConfig mSysConfig;
    private File mFooJar;

    @Rule public TemporaryFolder mTemporaryFolder = new TemporaryFolder();

    @Before
    public void setUp() throws Exception {
        mSysConfig = new SystemConfigTestClass();
        mFooJar = createTempFile(
                mTemporaryFolder.getRoot().getCanonicalFile(), "foo.jar", "JAR");
    }

    /**
@@ -340,7 +343,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        on-bootclasspath-before=\"10\"\n"
                + "        on-bootclasspath-since=\"20\"\n"
                + "     />\n\n"
@@ -362,7 +365,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                        + "    <apex-library \n"
                        + "        name=\"foo\"\n"
                        + "        file=\"foo.jar\"\n"
                        + "        file=\"" + mFooJar + "\"\n"
                        + "        on-bootclasspath-before=\"10\"\n"
                        + "        on-bootclasspath-since=\"20\"\n"
                        + "     />\n\n"
@@ -384,7 +387,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        min-device-sdk=\"30\"\n"
                + "     />\n\n"
                + " </permissions>";
@@ -402,7 +405,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        min-device-sdk=\"" + Build.VERSION.SDK_INT + "\"\n"
                + "     />\n\n"
                + " </permissions>";
@@ -420,7 +423,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        min-device-sdk=\"" + (Build.VERSION.SDK_INT + 1) + "\"\n"
                + "     />\n\n"
                + " </permissions>";
@@ -438,7 +441,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        max-device-sdk=\"30\"\n"
                + "     />\n\n"
                + " </permissions>";
@@ -456,7 +459,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        max-device-sdk=\"" + Build.VERSION.SDK_INT + "\"\n"
                + "     />\n\n"
                + " </permissions>";
@@ -474,7 +477,7 @@ public class SystemConfigTest {
                "<permissions>\n"
                + "    <library \n"
                + "        name=\"foo\"\n"
                + "        file=\"foo.jar\"\n"
                + "        file=\"" + mFooJar + "\"\n"
                + "        max-device-sdk=\"" + (Build.VERSION.SDK_INT + 1) + "\"\n"
                + "     />\n\n"
                + " </permissions>";
@@ -507,7 +510,7 @@ public class SystemConfigTest {
     * @param folder   pre-existing subdirectory of mTemporaryFolder to put the file
     * @param fileName name of the file (e.g. filename.xml) to create
     * @param contents contents to write to the file
     * @return the folder containing the newly created file (not the file itself!)
     * @return the newly created file
     */
    private File createTempFile(File folder, String fileName, String contents)
            throws IOException {
@@ -523,13 +526,13 @@ public class SystemConfigTest {
            Log.d(LOG_TAG, input.nextLine());
        }

        return folder;
        return file;
    }

    private void assertFooIsOnlySharedLibrary() {
        assertThat(mSysConfig.getSharedLibraries().size()).isEqualTo(1);
        SystemConfig.SharedLibraryEntry entry = mSysConfig.getSharedLibraries().get("foo");
        assertThat(entry.name).isEqualTo("foo");
        assertThat(entry.filename).isEqualTo("foo.jar");
        assertThat(entry.filename).isEqualTo(mFooJar.toString());
    }
}