diff options
author | Narayan Kamath <narayan@google.com> | 2014-05-01 13:53:08 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-01 13:53:08 +0000 |
commit | 99253c2da945cbd4725efced6cac2dc40c858d6c (patch) | |
tree | 36d6b85b1c791447c14126bd2d120b633fcd6816 /services/java | |
parent | a7b465efc4eede46b8dfc8932c6c30346e8e79de (diff) | |
parent | fde594288bff0b8f95567e6b27f273f50f0c5f87 (diff) | |
download | frameworks_base-99253c2da945cbd4725efced6cac2dc40c858d6c.zip frameworks_base-99253c2da945cbd4725efced6cac2dc40c858d6c.tar.gz frameworks_base-99253c2da945cbd4725efced6cac2dc40c858d6c.tar.bz2 |
am fde59428: Merge "Handle /oem and /vendor as well"
* commit 'fde594288bff0b8f95567e6b27f273f50f0c5f87':
Handle /oem and /vendor as well
Diffstat (limited to 'services/java')
-rwxr-xr-x | services/java/com/android/server/pm/PackageManagerService.java | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index aae2725..8111872 100755 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -4321,17 +4321,6 @@ public class PackageManagerService extends IPackageManager.Stub { // writer synchronized (mPackages) { - if ((parseFlags&PackageParser.PARSE_IS_SYSTEM_DIR) == 0) { - // Check all shared libraries and map to their actual file path. - // We only do this here for apps not on a system dir, because those - // are the only ones that can fail an install due to this. We - // will take care of the system apps by updating all of their - // library paths after the scan is done. - if (!updateSharedLibrariesLPw(pkg, null)) { - return null; - } - } - if (pkg.mSharedUserId != null) { suid = mSettings.getSharedUserLPw(pkg.mSharedUserId, 0, true); if (suid == null) { @@ -4442,6 +4431,17 @@ public class PackageManagerService extends IPackageManager.Stub { pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; } + if ((parseFlags&PackageParser.PARSE_IS_SYSTEM_DIR) == 0) { + // Check all shared libraries and map to their actual file path. + // We only do this here for apps not on a system dir, because those + // are the only ones that can fail an install due to this. We + // will take care of the system apps by updating all of their + // library paths after the scan is done. + if (!updateSharedLibrariesLPw(pkg, null)) { + return null; + } + } + if (mFoundPolicyFile) { SELinuxMMAC.assignSeinfoValue(pkg); } @@ -5248,6 +5248,37 @@ public class PackageManagerService extends IPackageManager.Stub { } } + private String calculateApkRoot(final File codePath) { + final File codeRoot; + if (FileUtils.contains(Environment.getRootDirectory(), codePath)) { + codeRoot = Environment.getRootDirectory(); + } else if (FileUtils.contains(Environment.getOemDirectory(), codePath)) { + codeRoot = Environment.getRootDirectory(); + } else if (FileUtils.contains(Environment.getVendorDirectory(), codePath)) { + codeRoot = Environment.getVendorDirectory(); + } else { + // Unrecognized code path; take its top real segment as the apk root: + // e.g. /something/app/blah.apk => /something + try { + File f = codePath.getCanonicalFile(); + File parent = f.getParentFile(); // non-null because codePath is a file + File tmp; + while ((tmp = parent.getParentFile()) != null) { + f = parent; + parent = tmp; + } + codeRoot = f; + Slog.w(TAG, "Unrecognized code path " + + codePath + " - using " + codeRoot); + } catch (IOException e) { + // Can't canonicalize the lib path -- shenanigans? + Slog.w(TAG, "Can't canonicalize code path " + codePath); + return Environment.getRootDirectory().getPath(); + } + } + return codeRoot.getPath(); + } + // 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, @@ -5259,11 +5290,10 @@ public class PackageManagerService extends IPackageManager.Stub { 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); + String apkRoot = calculateApkRoot(pkgSetting.codePath); + File lib64 = new File(apkRoot, LIB64_DIR_NAME); File packLib64 = new File(lib64, apkName); - libDir = (packLib64.exists()) - ? lib64 - : new File(Environment.getRootDirectory(), LIB_DIR_NAME); + libDir = (packLib64.exists()) ? lib64 : new File(apkRoot, LIB_DIR_NAME); } else { libDir = mAppLibInstallDir; } |