Loading core/java/com/android/server/SystemConfig.java +15 −1 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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 { Loading services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +14 −11 Original line number Diff line number Diff line Loading @@ -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"); } /** Loading Loading @@ -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" Loading @@ -362,7 +365,7 @@ public class SystemConfigTest { "<permissions>\n" + " <updatable-library \n" + " name=\"foo\"\n" + " file=\"foo.jar\"\n" + " file=\"" + mFooJar + "\"\n" + " on-bootclasspath-before=\"10\"\n" + " on-bootclasspath-since=\"20\"\n" + " />\n\n" Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading Loading @@ -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 { Loading @@ -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()); } } Loading
core/java/com/android/server/SystemConfig.java +15 −1 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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 { Loading
services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +14 −11 Original line number Diff line number Diff line Loading @@ -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"); } /** Loading Loading @@ -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" Loading @@ -362,7 +365,7 @@ public class SystemConfigTest { "<permissions>\n" + " <updatable-library \n" + " name=\"foo\"\n" + " file=\"foo.jar\"\n" + " file=\"" + mFooJar + "\"\n" + " on-bootclasspath-before=\"10\"\n" + " on-bootclasspath-since=\"20\"\n" + " />\n\n" Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading @@ -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>"; Loading Loading @@ -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 { Loading @@ -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()); } }