summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-05-01 13:35:34 +0100
committerNarayan Kamath <narayan@google.com>2014-05-01 13:50:47 +0000
commitfc0810e565b269bc9d8f072ef0ab7365e035c630 (patch)
treec2f3d4b57108f1bc089af03e4f1cfac31b0817e1
parentb916d8adffd7ea3588bc178e1ee03f68f0a409e5 (diff)
downloadbase-fc0810e565b269bc9d8f072ef0ab7365e035c630.tar.gz
Support per-package lib dirs for bundled apps
Bundled apps can now use /system/lib/apkname or /system/lib64/apkname in addition to the (globally shared) /system/lib and /system/lib64 directories. Note that when an app is updated post hoc the update APK will look to its normal library install directory in /data/data/[packagename]/lib, so such updates must include *all* needed libraries -- the private /system/lib/apkname dir will not be in the path following such an update. "apkname" here is the base name of the physical APK that holds the package's code. For example, if a 32-bit package is resident on disk as /system/priv-app/SettingsProvider.apk then its app-specific lib directory will be /system/lib/SettingsProvider Bug 13170859 (cherry picked from commit addfbdc09ccf258395db8bfc510989a4c583f7ab) Change-Id: Id82da78024a6325458b8b134d7d91ad0e5f0785e
-rwxr-xr-xservices/java/com/android/server/pm/PackageManagerService.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index a4df576ddce9..2a16d898ff5d 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -257,6 +257,7 @@ public class PackageManagerService extends IPackageManager.Stub {
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
private static final String LIB_DIR_NAME = "lib";
+ private static final String LIB64_DIR_NAME = "lib64";
private static final String VENDOR_OVERLAY_DIR = "/vendor/overlay";
@@ -4147,6 +4148,14 @@ public class PackageManagerService extends IPackageManager.Stub {
private boolean updateSharedLibrariesLPw(PackageParser.Package pkg,
PackageParser.Package changingLib) {
+ // We might be upgrading from a version of the platform that did not
+ // provide per-package native library directories for system apps.
+ // Fix that up here.
+ if (isSystemApp(pkg)) {
+ PackageSetting ps = mSettings.mPackages.get(pkg.applicationInfo.packageName);
+ setInternalAppNativeLibraryPath(pkg, ps);
+ }
+
if (pkg.usesLibraries != null || pkg.usesOptionalLibraries != null) {
if (mTmpSharedLibraries == null ||
mTmpSharedLibraries.length < mSharedLibraries.size()) {
@@ -5232,10 +5241,26 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
+ // This is the initial scan-time determination of how to handle a given
+ // package for purposes of native library location.
private void setInternalAppNativeLibraryPath(PackageParser.Package pkg,
PackageSetting pkgSetting) {
- final String apkLibPath = getApkName(pkgSetting.codePathString);
- final String nativeLibraryPath = new File(mAppLibInstallDir, apkLibPath).getPath();
+ // "bundled" here means system-installed with no overriding update
+ final boolean bundledApk = isSystemApp(pkg) && !isUpdatedSystemApp(pkg);
+ final String apkName = getApkName(pkgSetting.codePathString);
+ final File libDir;
+ if (bundledApk) {
+ // If "/system/lib64/apkname" exists, assume that is the per-package
+ // native library directory to use; otherwise use "/system/lib/apkname".
+ File lib64 = new File(Environment.getRootDirectory(), LIB64_DIR_NAME);
+ File packLib64 = new File(lib64, apkName);
+ libDir = (packLib64.exists())
+ ? lib64
+ : new File(Environment.getRootDirectory(), LIB_DIR_NAME);
+ } else {
+ libDir = mAppLibInstallDir;
+ }
+ final String nativeLibraryPath = (new File(libDir, apkName)).getPath();
pkg.applicationInfo.nativeLibraryDir = nativeLibraryPath;
pkgSetting.nativeLibraryPathString = nativeLibraryPath;
}
@@ -9642,13 +9667,14 @@ public class PackageManagerService extends IPackageManager.Stub {
}
// writer
synchronized (mPackages) {
+ PackageSetting ps = mSettings.mPackages.get(newPkg.packageName);
+ setInternalAppNativeLibraryPath(newPkg, ps);
updatePermissionsLPw(newPkg.packageName, newPkg,
UPDATE_PERMISSIONS_ALL | UPDATE_PERMISSIONS_REPLACE_PKG);
if (applyUserRestrictions) {
if (DEBUG_REMOVE) {
Slog.d(TAG, "Propagating install state across reinstall");
}
- PackageSetting ps = mSettings.mPackages.get(newPkg.packageName);
for (int i = 0; i < allUserHandles.length; i++) {
if (DEBUG_REMOVE) {
Slog.d(TAG, " user " + allUserHandles[i]