diff options
author | Narayan Kamath <narayan@google.com> | 2014-07-16 08:53:30 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-07-16 13:37:16 +0100 |
commit | 7dba6eb3ac4fd6c8195cb0d0425866de50a9e114 (patch) | |
tree | 58e877fd43f72413126dc76d8d48d8494dd618a4 /core/java/android/app/LoadedApk.java | |
parent | 1d935abdd579fbcc20ef5c501e8f587e1b07ddb5 (diff) | |
download | frameworks_base-7dba6eb3ac4fd6c8195cb0d0425866de50a9e114.zip frameworks_base-7dba6eb3ac4fd6c8195cb0d0425866de50a9e114.tar.gz frameworks_base-7dba6eb3ac4fd6c8195cb0d0425866de50a9e114.tar.bz2 |
Adjust nativeLibraryDir for package contexts of multiArch installs.
When we're creating a package context for a multi-arch app,
adjust the native library directory to match the bitness of
the process creating the context.
This change also removes apkRoot (which wasn't really being used)
and replaces it with a fully constructed secondary library path.
The secondary library path is a transitional measure until we
can reorganize the system image so that we can use nativeLibraryRoot
for system paths as well (nativeLibraryRootRequiresIsa will then
be true for all packages except for legacy installs).
bug: 16013931
Change-Id: I5ae090334b377b9e087aecf40075fab81b20b132
Diffstat (limited to 'core/java/android/app/LoadedApk.java')
-rw-r--r-- | core/java/android/app/LoadedApk.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 065e88d..12e18cc 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -44,6 +44,7 @@ import android.util.Slog; import android.util.SparseArray; import android.view.DisplayAdjustments; import android.view.Display; +import dalvik.system.VMRuntime; import java.io.File; import java.io.IOException; @@ -121,6 +122,8 @@ public final class LoadedApk { CompatibilityInfo compatInfo, ClassLoader baseLoader, boolean securityViolation, boolean includeCode) { final int myUid = Process.myUid(); + aInfo = adjustNativeLibraryPaths(aInfo); + mActivityThread = activityThread; mApplicationInfo = aInfo; mPackageName = aInfo.packageName; @@ -143,6 +146,27 @@ public final class LoadedApk { mDisplayAdjustments.setCompatibilityInfo(compatInfo); } + private static ApplicationInfo adjustNativeLibraryPaths(ApplicationInfo info) { + // If we're dealing with a multi-arch application that has both + // 32 and 64 bit shared libraries, we might need to choose the secondary + // depending on what the current runtime's instruction set is. + if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { + final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); + final String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); + + // If the runtimeIsa is the same as the primary isa, then we do nothing. + // Everything will be set up correctly because info.nativeLibraryDir will + // correspond to the right ISA. + if (runtimeIsa.equals(secondaryIsa)) { + final ApplicationInfo modified = new ApplicationInfo(info); + modified.nativeLibraryDir = modified.secondaryNativeLibraryDir; + return modified; + } + } + + return info; + } + /** * Create information about the system package. * Must call {@link #installSystemApplicationInfo} later. |