summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-04-28 14:18:34 +0100
committerNarayan Kamath <narayan@google.com>2014-04-30 09:43:47 +0100
commitdf6d6dc2aac2912e98de3fe37869d2b179eb23db (patch)
tree4756fb3f5170fdaf84622ffd7bbd4efc5725e9ec /services
parent0f206a149d27385ef092a34e0009a8607d663659 (diff)
downloadframeworks_base-df6d6dc2aac2912e98de3fe37869d2b179eb23db.zip
frameworks_base-df6d6dc2aac2912e98de3fe37869d2b179eb23db.tar.gz
frameworks_base-df6d6dc2aac2912e98de3fe37869d2b179eb23db.tar.bz2
Adjust instruction sets for shared UID apps.
Since shared UID apps are run in the same process, we'll need to make sure they're compiled for the same instruction set. This change implements the recompilation of apps that don't have any ABI constraints. Apps that *do* have ABI constraints are harder to deal with, since we'll need to rescan them to figure out the full list of ABIs they support and then re-extract the native libraries from these apps once we find an ABI we can use throughout. Change-Id: I365c6b0b18187df814d4736da61b199dd4494e3c
Diffstat (limited to 'services')
-rwxr-xr-xservices/core/java/com/android/server/pm/PackageManagerService.java60
-rw-r--r--services/core/java/com/android/server/pm/Settings.java6
2 files changed, 66 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a921513..e1cda81 100755
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -1524,6 +1524,12 @@ public class PackageManagerService extends IPackageManager.Stub {
// the correct library paths.
updateAllSharedLibrariesLPw();
+
+ for (SharedUserSetting setting : mSettings.getAllSharedUsersLPw()) {
+ adjustCpuAbisForSharedUserLPw(setting.packages, true /* do dexopt */,
+ false /* force dexopt */, false /* defer dexopt */);
+ }
+
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,
SystemClock.uptimeMillis());
Slog.i(TAG, "Time to scan packages: "
@@ -5227,6 +5233,12 @@ public class PackageManagerService extends IPackageManager.Stub {
// writer
synchronized (mPackages) {
+ if ((scanMode&SCAN_BOOTING) == 0 && pkgSetting.sharedUser != null) {
+ // We don't do this here during boot because we can do it all
+ // at once after scanning all existing packages.
+ adjustCpuAbisForSharedUserLPw(pkgSetting.sharedUser.packages,
+ true, forceDex, (scanMode & SCAN_DEFER_DEX) != 0);
+ }
// We don't expect installation to fail beyond this point,
if ((scanMode&SCAN_MONITOR) != 0) {
mAppDirs.put(pkg.mPath, pkg);
@@ -5571,6 +5583,54 @@ public class PackageManagerService extends IPackageManager.Stub {
return pkg;
}
+ public void adjustCpuAbisForSharedUserLPw(Set<PackageSetting> packagesForUser,
+ boolean doDexOpt, boolean forceDexOpt, boolean deferDexOpt) {
+ String requiredInstructionSet = null;
+ PackageSetting requirer = null;
+ for (PackageSetting ps : packagesForUser) {
+ if (ps.requiredCpuAbiString != null) {
+ final String instructionSet = VMRuntime.getInstructionSet(ps.requiredCpuAbiString);
+ if (requiredInstructionSet != null) {
+ if (!instructionSet.equals(requiredInstructionSet)) {
+ // We have a mismatch between instruction sets (say arm vs arm64).
+ //
+ // TODO: We should rescan all the packages in a shared UID to check if
+ // they do contain shared libs for other ABIs in addition to the ones we've
+ // already extracted. For example, the package might contain both arm64-v8a
+ // and armeabi-v7a shared libs, and we'd have chosen arm64-v8a on 64 bit
+ // devices.
+ String errorMessage = "Instruction set mismatch, " + requirer.pkg.packageName
+ + " requires " + requiredInstructionSet + " whereas " + ps.pkg.packageName
+ + " requires " + instructionSet;
+ Slog.e(TAG, errorMessage);
+
+ reportSettingsProblem(Log.WARN, errorMessage);
+ // Give up, don't bother making any other changes to the package settings.
+ return;
+ }
+ } else {
+ requiredInstructionSet = instructionSet;
+ requirer = ps;
+ }
+ }
+ }
+
+ if (requiredInstructionSet != null) {
+ for (PackageSetting ps : packagesForUser) {
+ if (ps.requiredCpuAbiString == null) {
+ ps.requiredCpuAbiString = requirer.requiredCpuAbiString;
+ ps.pkg.applicationInfo.requiredCpuAbi = requirer.requiredCpuAbiString;
+
+ Slog.i(TAG, "Adjusting ABI for : " + ps.pkg.packageName + " to " + ps.requiredCpuAbiString);
+ if (doDexOpt) {
+ performDexOptLI(ps.pkg, forceDexOpt, deferDexOpt, true);
+ mInstaller.rmdex(ps.codePathString, getPreferredInstructionSet());
+ }
+ }
+ }
+ }
+ }
+
private void setUpCustomResolverActivity(PackageParser.Package pkg) {
synchronized (mPackages) {
mResolverReplaced = true;
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index e4dd2d4..678fc92 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -36,6 +36,7 @@ import com.android.internal.util.JournaledFile;
import com.android.internal.util.XmlUtils;
import com.android.server.pm.PackageManagerService.DumpState;
+import java.util.Collection;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
@@ -302,6 +303,11 @@ final class Settings {
return s;
}
+ Collection<SharedUserSetting> getAllSharedUsersLPw() {
+ return mSharedUsers.values();
+ }
+
+
boolean disableSystemPackageLPw(String name) {
final PackageSetting p = mPackages.get(name);
if(p == null) {