Obtain dependency information from permissions files for SharedLibs.
Bug: 120096113 Test: Build with built-in libraries that declares new depedency flag, no more boot errors (tested with cheets_x86_64 and crosshatch_userdebug) Change-Id: I6b3e2ab7626ed8f04c0bf1a5b3c32204a2f2c56b
This commit is contained in:
@@ -22,15 +22,15 @@ package android.content.pm;
|
||||
*/
|
||||
public class SharedLibraryNames {
|
||||
|
||||
public static final String ANDROID_HIDL_BASE = "android.hidl.base-V1.0-java";
|
||||
static final String ANDROID_HIDL_BASE = "android.hidl.base-V1.0-java";
|
||||
|
||||
public static final String ANDROID_HIDL_MANAGER = "android.hidl.manager-V1.0-java";
|
||||
static final String ANDROID_HIDL_MANAGER = "android.hidl.manager-V1.0-java";
|
||||
|
||||
public static final String ANDROID_TEST_BASE = "android.test.base";
|
||||
static final String ANDROID_TEST_BASE = "android.test.base";
|
||||
|
||||
public static final String ANDROID_TEST_MOCK = "android.test.mock";
|
||||
static final String ANDROID_TEST_MOCK = "android.test.mock";
|
||||
|
||||
public static final String ANDROID_TEST_RUNNER = "android.test.runner";
|
||||
static final String ANDROID_TEST_RUNNER = "android.test.runner";
|
||||
|
||||
public static final String ORG_APACHE_HTTP_LEGACY = "org.apache.http.legacy";
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.Process;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.permission.PermissionManager.SplitPermissionInfo;
|
||||
import android.text.TextUtils;
|
||||
@@ -78,10 +77,23 @@ public class SystemConfig {
|
||||
|
||||
final ArrayList<SplitPermissionInfo> mSplitPermissions = new ArrayList<>();
|
||||
|
||||
public static final class SharedLibraryEntry {
|
||||
public final String name;
|
||||
public final String filename;
|
||||
public final String[] dependencies;
|
||||
|
||||
SharedLibraryEntry(String name, String filename, String[] dependencies) {
|
||||
this.name = name;
|
||||
this.filename = filename;
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
}
|
||||
|
||||
// These are the built-in shared libraries that were read from the
|
||||
// system configuration files. Keys are the library names; strings are the
|
||||
// paths to the libraries.
|
||||
final ArrayMap<String, String> mSharedLibraries = new ArrayMap<>();
|
||||
// system configuration files. Keys are the library names; values are
|
||||
// the individual entries that contain information such as filename
|
||||
// and dependencies.
|
||||
final ArrayMap<String, SharedLibraryEntry> mSharedLibraries = new ArrayMap<>();
|
||||
|
||||
// These are the features this devices supports that were read from the
|
||||
// system configuration files.
|
||||
@@ -200,7 +212,7 @@ public class SystemConfig {
|
||||
return mSplitPermissions;
|
||||
}
|
||||
|
||||
public ArrayMap<String, String> getSharedLibraries() {
|
||||
public ArrayMap<String, SharedLibraryEntry> getSharedLibraries() {
|
||||
return mSharedLibraries;
|
||||
}
|
||||
|
||||
@@ -497,6 +509,7 @@ public class SystemConfig {
|
||||
} else if ("library".equals(name) && allowLibs) {
|
||||
String lname = parser.getAttributeValue(null, "name");
|
||||
String lfile = parser.getAttributeValue(null, "file");
|
||||
String ldependency = parser.getAttributeValue(null, "dependency");
|
||||
if (lname == null) {
|
||||
Slog.w(TAG, "<library> without name in " + permFile + " at "
|
||||
+ parser.getPositionDescription());
|
||||
@@ -505,11 +518,12 @@ public class SystemConfig {
|
||||
+ parser.getPositionDescription());
|
||||
} else {
|
||||
//Log.i(TAG, "Got library " + lname + " in " + lfile);
|
||||
mSharedLibraries.put(lname, lfile);
|
||||
SharedLibraryEntry entry = new SharedLibraryEntry(lname, lfile,
|
||||
ldependency == null ? new String[0] : ldependency.split(":"));
|
||||
mSharedLibraries.put(lname, entry);
|
||||
}
|
||||
XmlUtils.skipCurrentTag(parser);
|
||||
continue;
|
||||
|
||||
} else if ("feature".equals(name) && allowFeatures) {
|
||||
String fname = parser.getAttributeValue(null, "name");
|
||||
int fversion = XmlUtils.readIntAttribute(parser, "version", 0);
|
||||
|
||||
@@ -225,15 +225,18 @@
|
||||
<library name="android.test.base"
|
||||
file="/system/framework/android.test.base.impl.jar" />
|
||||
<library name="android.test.mock"
|
||||
file="/system/framework/android.test.mock.impl.jar" />
|
||||
file="/system/framework/android.test.mock.impl.jar"
|
||||
dependency="android.test.base" />
|
||||
<library name="android.test.runner"
|
||||
file="/system/framework/android.test.runner.impl.jar" />
|
||||
file="/system/framework/android.test.runner.impl.jar"
|
||||
dependency="android.test.base:android.test.mock" />
|
||||
|
||||
<!-- In BOOT_JARS historically, and now added to legacy applications. -->
|
||||
<library name="android.hidl.base-V1.0-java"
|
||||
file="/system/framework/android.hidl.base-V1.0-java.jar" />
|
||||
<library name="android.hidl.manager-V1.0-java"
|
||||
file="/system/framework/android.hidl.manager-V1.0-java.jar" />
|
||||
file="/system/framework/android.hidl.manager-V1.0-java.jar"
|
||||
dependency="android.hidl.base-V1.0-java" />
|
||||
|
||||
<!-- These are the standard packages that are white-listed to always have internet
|
||||
access while in power save mode, even if they aren't in the foreground. -->
|
||||
|
||||
@@ -86,11 +86,6 @@ import static android.content.pm.PackageManager.MOVE_FAILED_SYSTEM_PACKAGE;
|
||||
import static android.content.pm.PackageManager.PERMISSION_DENIED;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.content.pm.PackageParser.isApkFile;
|
||||
import static android.content.pm.SharedLibraryNames.ANDROID_HIDL_BASE;
|
||||
import static android.content.pm.SharedLibraryNames.ANDROID_HIDL_MANAGER;
|
||||
import static android.content.pm.SharedLibraryNames.ANDROID_TEST_BASE;
|
||||
import static android.content.pm.SharedLibraryNames.ANDROID_TEST_MOCK;
|
||||
import static android.content.pm.SharedLibraryNames.ANDROID_TEST_RUNNER;
|
||||
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
|
||||
import static android.os.storage.StorageManager.FLAG_STORAGE_CE;
|
||||
import static android.os.storage.StorageManager.FLAG_STORAGE_DE;
|
||||
@@ -2093,28 +2088,6 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mPackages")
|
||||
private void setupBuiltinSharedLibraryDependenciesLocked() {
|
||||
// Builtin libraries don't have versions.
|
||||
long version = SharedLibraryInfo.VERSION_UNDEFINED;
|
||||
|
||||
SharedLibraryInfo libraryInfo = getSharedLibraryInfoLPr(ANDROID_HIDL_MANAGER, version);
|
||||
if (libraryInfo != null) {
|
||||
libraryInfo.addDependency(getSharedLibraryInfoLPr(ANDROID_HIDL_BASE, version));
|
||||
}
|
||||
|
||||
libraryInfo = getSharedLibraryInfoLPr(ANDROID_TEST_RUNNER, version);
|
||||
if (libraryInfo != null) {
|
||||
libraryInfo.addDependency(getSharedLibraryInfoLPr(ANDROID_TEST_MOCK, version));
|
||||
libraryInfo.addDependency(getSharedLibraryInfoLPr(ANDROID_TEST_BASE, version));
|
||||
}
|
||||
|
||||
libraryInfo = getSharedLibraryInfoLPr(ANDROID_TEST_MOCK, version);
|
||||
if (libraryInfo != null) {
|
||||
libraryInfo.addDependency(getSharedLibraryInfoLPr(ANDROID_TEST_BASE, version));
|
||||
}
|
||||
}
|
||||
|
||||
public PackageManagerService(Context context, Installer installer,
|
||||
boolean factoryTest, boolean onlyCore) {
|
||||
LockGuard.installLock(mPackages, LockGuard.INDEX_PACKAGES);
|
||||
@@ -2222,17 +2195,32 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
Watchdog.getInstance().addThread(mHandler, WATCHDOG_TIMEOUT);
|
||||
mInstantAppRegistry = new InstantAppRegistry(this);
|
||||
|
||||
ArrayMap<String, String> libConfig = systemConfig.getSharedLibraries();
|
||||
ArrayMap<String, SystemConfig.SharedLibraryEntry> libConfig
|
||||
= systemConfig.getSharedLibraries();
|
||||
final int builtInLibCount = libConfig.size();
|
||||
for (int i = 0; i < builtInLibCount; i++) {
|
||||
String name = libConfig.keyAt(i);
|
||||
String path = libConfig.valueAt(i);
|
||||
addSharedLibraryLPw(path, null, null, name, SharedLibraryInfo.VERSION_UNDEFINED,
|
||||
SharedLibraryInfo.TYPE_BUILTIN, PLATFORM_PACKAGE_NAME, 0);
|
||||
SystemConfig.SharedLibraryEntry entry = libConfig.valueAt(i);
|
||||
addSharedLibraryLPw(entry.filename, null, null, name,
|
||||
SharedLibraryInfo.VERSION_UNDEFINED, SharedLibraryInfo.TYPE_BUILTIN,
|
||||
PLATFORM_PACKAGE_NAME, 0);
|
||||
}
|
||||
|
||||
// Now that we have added all the libraries, iterate again to add dependency
|
||||
// information IFF their dependencies are added.
|
||||
long undefinedVersion = SharedLibraryInfo.VERSION_UNDEFINED;
|
||||
for (int i = 0; i < builtInLibCount; i++) {
|
||||
String name = libConfig.keyAt(i);
|
||||
SystemConfig.SharedLibraryEntry entry = libConfig.valueAt(i);
|
||||
final int dependencyCount = entry.dependencies.length;
|
||||
for (int j = 0; j < dependencyCount; j++) {
|
||||
final SharedLibraryInfo dependency =
|
||||
getSharedLibraryInfoLPr(entry.dependencies[j], undefinedVersion);
|
||||
if (dependency != null) {
|
||||
getSharedLibraryInfoLPr(name, undefinedVersion).addDependency(dependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Builtin libraries cannot encode their dependency where they are
|
||||
// defined, so fix that now.
|
||||
setupBuiltinSharedLibraryDependenciesLocked();
|
||||
|
||||
SELinuxMMAC.readInstallPolicy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user