From 0cfe875ac51b1efd8119eb8d4d66429776ae9764 Mon Sep 17 00:00:00 2001 From: narayan Date: Wed, 21 May 2014 20:54:50 +0100 Subject: [PATCH] Fix NPE in PackageManagerService. Check that each package from the setting has a parsed pkg before we attempt to perform dex-opt on it. If it doesn't have a parsed package, adjust the ABI in the settings, but don't perform dexopt. It will be dexopted later if it's still active based on the setting. bug: 15081286 Change-Id: Ifb6d1d5efdc9c59b251731972afa951ad930d05c --- .../server/pm/PackageManagerService.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index ca58da07c8c6b..5d69ba300b5e6 100755 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -5676,21 +5676,23 @@ public class PackageManagerService extends IPackageManager.Stub { } for (PackageSetting ps : packagesForUser) { - if (scannedPackage == null || ! scannedPackage.packageName.equals(ps.name)) { + if (scannedPackage == null || !scannedPackage.packageName.equals(ps.name)) { if (ps.cpuAbiString != null) { continue; } ps.cpuAbiString = adjustedAbi; - ps.pkg.applicationInfo.cpuAbi = adjustedAbi; - Slog.i(TAG, "Adjusting ABI for : " + ps.name + " to " + adjustedAbi); + if (ps.pkg != null && ps.pkg.applicationInfo != null) { + ps.pkg.applicationInfo.cpuAbi = adjustedAbi; + Slog.i(TAG, "Adjusting ABI for : " + ps.name + " to " + adjustedAbi); - 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()); + 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()); + } } } }