Ignore prebuilt shared library if it doesn't exist on device
Bug: 191232777 Test: atest PackageManagerTest Test: atest SystemConfigTest Change-Id: I756e2c909af6ad0dcf8f1857ba398cfe07862b29 Merged-In: I756e2c909af6ad0dcf8f1857ba398cfe07862b29
This commit is contained in:
@@ -870,7 +870,8 @@ public class SystemConfig {
|
|||||||
boolean allowedMinSdk = minDeviceSdk <= Build.VERSION.SDK_INT;
|
boolean allowedMinSdk = minDeviceSdk <= Build.VERSION.SDK_INT;
|
||||||
boolean allowedMaxSdk =
|
boolean allowedMaxSdk =
|
||||||
maxDeviceSdk == 0 || maxDeviceSdk >= Build.VERSION.SDK_INT;
|
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,
|
int bcpSince = XmlUtils.readIntAttribute(parser,
|
||||||
"on-bootclasspath-since", 0);
|
"on-bootclasspath-since", 0);
|
||||||
int bcpBefore = XmlUtils.readIntAttribute(parser,
|
int bcpBefore = XmlUtils.readIntAttribute(parser,
|
||||||
@@ -880,6 +881,19 @@ public class SystemConfig {
|
|||||||
? new String[0] : ldependency.split(":"),
|
? new String[0] : ldependency.split(":"),
|
||||||
bcpSince, bcpBefore);
|
bcpSince, bcpBefore);
|
||||||
mSharedLibraries.put(lname, entry);
|
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 {
|
} else {
|
||||||
|
|||||||
@@ -62,12 +62,15 @@ public class SystemConfigTest {
|
|||||||
private static final String LOG_TAG = "SystemConfigTest";
|
private static final String LOG_TAG = "SystemConfigTest";
|
||||||
|
|
||||||
private SystemConfig mSysConfig;
|
private SystemConfig mSysConfig;
|
||||||
|
private File mFooJar;
|
||||||
|
|
||||||
@Rule public TemporaryFolder mTemporaryFolder = new TemporaryFolder();
|
@Rule public TemporaryFolder mTemporaryFolder = new TemporaryFolder();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mSysConfig = new SystemConfigTestClass();
|
mSysConfig = new SystemConfigTestClass();
|
||||||
|
mFooJar = createTempFile(
|
||||||
|
mTemporaryFolder.getRoot().getCanonicalFile(), "foo.jar", "JAR");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,7 +343,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " on-bootclasspath-before=\"10\"\n"
|
+ " on-bootclasspath-before=\"10\"\n"
|
||||||
+ " on-bootclasspath-since=\"20\"\n"
|
+ " on-bootclasspath-since=\"20\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
@@ -362,7 +365,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <apex-library \n"
|
+ " <apex-library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " on-bootclasspath-before=\"10\"\n"
|
+ " on-bootclasspath-before=\"10\"\n"
|
||||||
+ " on-bootclasspath-since=\"20\"\n"
|
+ " on-bootclasspath-since=\"20\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
@@ -384,7 +387,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " min-device-sdk=\"30\"\n"
|
+ " min-device-sdk=\"30\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
+ " </permissions>";
|
+ " </permissions>";
|
||||||
@@ -402,7 +405,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " min-device-sdk=\"" + Build.VERSION.SDK_INT + "\"\n"
|
+ " min-device-sdk=\"" + Build.VERSION.SDK_INT + "\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
+ " </permissions>";
|
+ " </permissions>";
|
||||||
@@ -420,7 +423,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " min-device-sdk=\"" + (Build.VERSION.SDK_INT + 1) + "\"\n"
|
+ " min-device-sdk=\"" + (Build.VERSION.SDK_INT + 1) + "\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
+ " </permissions>";
|
+ " </permissions>";
|
||||||
@@ -438,7 +441,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " max-device-sdk=\"30\"\n"
|
+ " max-device-sdk=\"30\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
+ " </permissions>";
|
+ " </permissions>";
|
||||||
@@ -456,7 +459,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " max-device-sdk=\"" + Build.VERSION.SDK_INT + "\"\n"
|
+ " max-device-sdk=\"" + Build.VERSION.SDK_INT + "\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
+ " </permissions>";
|
+ " </permissions>";
|
||||||
@@ -474,7 +477,7 @@ public class SystemConfigTest {
|
|||||||
"<permissions>\n"
|
"<permissions>\n"
|
||||||
+ " <library \n"
|
+ " <library \n"
|
||||||
+ " name=\"foo\"\n"
|
+ " name=\"foo\"\n"
|
||||||
+ " file=\"foo.jar\"\n"
|
+ " file=\"" + mFooJar + "\"\n"
|
||||||
+ " max-device-sdk=\"" + (Build.VERSION.SDK_INT + 1) + "\"\n"
|
+ " max-device-sdk=\"" + (Build.VERSION.SDK_INT + 1) + "\"\n"
|
||||||
+ " />\n\n"
|
+ " />\n\n"
|
||||||
+ " </permissions>";
|
+ " </permissions>";
|
||||||
@@ -507,7 +510,7 @@ public class SystemConfigTest {
|
|||||||
* @param folder pre-existing subdirectory of mTemporaryFolder to put the file
|
* @param folder pre-existing subdirectory of mTemporaryFolder to put the file
|
||||||
* @param fileName name of the file (e.g. filename.xml) to create
|
* @param fileName name of the file (e.g. filename.xml) to create
|
||||||
* @param contents contents to write to the file
|
* @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)
|
private File createTempFile(File folder, String fileName, String contents)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -523,13 +526,13 @@ public class SystemConfigTest {
|
|||||||
Log.d(LOG_TAG, input.nextLine());
|
Log.d(LOG_TAG, input.nextLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
return folder;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFooIsOnlySharedLibrary() {
|
private void assertFooIsOnlySharedLibrary() {
|
||||||
assertThat(mSysConfig.getSharedLibraries().size()).isEqualTo(1);
|
assertThat(mSysConfig.getSharedLibraries().size()).isEqualTo(1);
|
||||||
SystemConfig.SharedLibraryEntry entry = mSysConfig.getSharedLibraries().get("foo");
|
SystemConfig.SharedLibraryEntry entry = mSysConfig.getSharedLibraries().get("foo");
|
||||||
assertThat(entry.name).isEqualTo("foo");
|
assertThat(entry.name).isEqualTo("foo");
|
||||||
assertThat(entry.filename).isEqualTo("foo.jar");
|
assertThat(entry.filename).isEqualTo(mFooJar.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user