diff options
-rwxr-xr-x | services/core/java/com/android/server/pm/PackageManagerService.java | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 2d26851..980476f 100755 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -1609,7 +1609,10 @@ public class PackageManagerService extends IPackageManager.Stub { updateAllSharedLibrariesLPw(); for (SharedUserSetting setting : mSettings.getAllSharedUsersLPw()) { - adjustCpuAbisForSharedUserLPw(setting.packages, true /* do dexopt */, + // NOTE: We ignore potential failures here during a system scan (like + // the rest of the commands above) because there's precious little we + // can do about it. A settings error is reported, though. + adjustCpuAbisForSharedUserLPw(setting.packages, null, false /* force dexopt */, false /* defer dexopt */); } @@ -5290,8 +5293,12 @@ public class PackageManagerService extends IPackageManager.Stub { 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); + if (!adjustCpuAbisForSharedUserLPw(pkgSetting.sharedUser.packages, + pkg.applicationInfo.cpuAbi, + forceDex, (scanMode & SCAN_DEFER_DEX) != 0)) { + mLastScanError = PackageManager.INSTALL_FAILED_CPU_ABI_INCOMPATIBLE; + return null; + } } // We don't expect installation to fail beyond this point, if ((scanMode&SCAN_MONITOR) != 0) { @@ -5636,9 +5643,8 @@ public class PackageManagerService extends IPackageManager.Stub { return pkg; } - public void adjustCpuAbisForSharedUserLPw(Set<PackageSetting> packagesForUser, - boolean doDexOpt, boolean forceDexOpt, boolean deferDexOpt) { - String requiredInstructionSet = null; + private boolean adjustCpuAbisForSharedUserLPw(Set<PackageSetting> packagesForUser, + String requiredInstructionSet, boolean forceDexOpt, boolean deferDexOpt) { PackageSetting requirer = null; for (PackageSetting ps : packagesForUser) { if (ps.cpuAbiString != null) { @@ -5646,20 +5652,16 @@ public class PackageManagerService extends IPackageManager.Stub { 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 + // bail out. + String errorMessage = "Instruction set mismatch, " + + ((requirer == null) ? "[caller]" : requirer.pkg) + + " requires " + requiredInstructionSet + " whereas " + ps.pkg + " requires " + instructionSet; Slog.e(TAG, errorMessage); reportSettingsProblem(Log.WARN, errorMessage); // Give up, don't bother making any other changes to the package settings. - return; + return false; } } else { requiredInstructionSet = instructionSet; @@ -5675,14 +5677,20 @@ public class PackageManagerService extends IPackageManager.Stub { if (ps.pkg != null) { ps.pkg.applicationInfo.cpuAbi = requirer.cpuAbiString; Slog.i(TAG, "Adjusting ABI for : " + ps.name + " to " + ps.cpuAbiString); - if (doDexOpt) { - performDexOptLI(ps.pkg, forceDexOpt, deferDexOpt, true); + + if (performDexOptLI(ps.pkg, forceDexOpt, deferDexOpt, true) == DEX_OPT_FAILED) { + ps.cpuAbiString = null; + ps.pkg.applicationInfo.cpuAbi = null; + return false; + } else { mInstaller.rmdex(ps.codePathString, getPreferredInstructionSet()); } } } } } + + return true; } private void setUpCustomResolverActivity(PackageParser.Package pkg) { |