Loading services/java/com/android/server/pm/Installer.java +28 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,34 @@ public final class Installer { return execute(builder.toString()); } public int patchoat(String apkPath, int uid, boolean isPublic, String pkgName, String instructionSet) { StringBuilder builder = new StringBuilder("patchoat"); builder.append(' '); builder.append(apkPath); builder.append(' '); builder.append(uid); builder.append(isPublic ? " 1" : " 0"); builder.append(' '); builder.append(pkgName); builder.append(' '); builder.append(instructionSet); return execute(builder.toString()); } public int patchoat(String apkPath, int uid, boolean isPublic, String instructionSet) { StringBuilder builder = new StringBuilder("patchoat"); builder.append(' '); builder.append(apkPath); builder.append(' '); builder.append(uid); builder.append(isPublic ? " 1" : " 0"); builder.append(" *"); // No pkgName arg present builder.append(' '); builder.append(instructionSet); return execute(builder.toString()); } public int dexopt(String apkPath, int uid, boolean isPublic, String instructionSet) { StringBuilder builder = new StringBuilder("dexopt"); builder.append(' '); Loading services/java/com/android/server/pm/PackageManagerService.java +37 −9 Original line number Diff line number Diff line Loading @@ -1368,11 +1368,18 @@ public class PackageManagerService extends IPackageManager.Stub { } try { if (DexFile.isDexOptNeededInternal(lib, null, instructionSet, false)) { byte dexoptRequired = DexFile.isDexOptNeededInternal(lib, null, instructionSet, false); if (dexoptRequired != DexFile.UP_TO_DATE) { alreadyDexOpted.add(lib); // The list of "shared libraries" we have at this point is if (dexoptRequired == DexFile.DEXOPT_NEEDED) { mInstaller.dexopt(lib, Process.SYSTEM_UID, true, instructionSet); } else { mInstaller.patchoat(lib, Process.SYSTEM_UID, true, instructionSet); } didDexOptLibraryOrTool = true; } } catch (FileNotFoundException e) { Loading Loading @@ -1419,9 +1426,15 @@ public class PackageManagerService extends IPackageManager.Stub { continue; } try { if (DexFile.isDexOptNeededInternal(path, null, instructionSet, false)) { byte dexoptRequired = DexFile.isDexOptNeededInternal(path, null, instructionSet, false); if (dexoptRequired == DexFile.DEXOPT_NEEDED) { mInstaller.dexopt(path, Process.SYSTEM_UID, true, instructionSet); didDexOptLibraryOrTool = true; } else if (dexoptRequired == DexFile.PATCHOAT_NEEDED) { mInstaller.patchoat(path, Process.SYSTEM_UID, true, instructionSet); didDexOptLibraryOrTool = true; } } catch (FileNotFoundException e) { Slog.w(TAG, "Jar not found: " + path); Loading Loading @@ -4282,15 +4295,18 @@ public class PackageManagerService extends IPackageManager.Stub { if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0) { String path = pkg.mScanPath; try { boolean isDexOptNeededInternal = DexFile.isDexOptNeededInternal(path, pkg.packageName, instructionSet, defer); // This will return DEXOPT_NEEDED if we either cannot find any odex file for this // patckage or the one we find does not match the image checksum (i.e. it was // compiled against an old image). It will return PATCHOAT_NEEDED if we can find a // odex file and it matches the checksum of the image but not its base address, // meaning we need to move it. byte isDexOptNeededInternal = DexFile.isDexOptNeededInternal(path, pkg.packageName, instructionSet, defer); // There are three basic cases here: // 1.) we need to dexopt, either because we are forced or it is needed // 2.) we are defering a needed dexopt // 3.) we are skipping an unneeded dexopt if (forceDex || (!defer && isDexOptNeededInternal)) { if (forceDex || (!defer && isDexOptNeededInternal == DexFile.DEXOPT_NEEDED)) { Log.i(TAG, "Running dexopt on: " + pkg.applicationInfo.packageName); final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); int ret = mInstaller.dexopt(path, sharedGid, !isForwardLocked(pkg), Loading @@ -4302,8 +4318,20 @@ public class PackageManagerService extends IPackageManager.Stub { return DEX_OPT_FAILED; } return DEX_OPT_PERFORMED; } else if (!defer && isDexOptNeededInternal == DexFile.PATCHOAT_NEEDED) { Log.i(TAG, "Running patchoat on: " + pkg.applicationInfo.packageName); final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); int ret = mInstaller.patchoat(path, sharedGid, !isForwardLocked(pkg), pkg.packageName, instructionSet); // Note that we ran patchoat, since rerunning will // probably just result in an error again. pkg.mDexOptNeeded = false; if (ret < 0) { return DEX_OPT_FAILED; } return DEX_OPT_PERFORMED; } if (defer && isDexOptNeededInternal) { if (defer && isDexOptNeededInternal != DexFile.UP_TO_DATE) { if (mDeferredDexOpt == null) { mDeferredDexOpt = new HashSet<PackageParser.Package>(); } Loading Loading
services/java/com/android/server/pm/Installer.java +28 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,34 @@ public final class Installer { return execute(builder.toString()); } public int patchoat(String apkPath, int uid, boolean isPublic, String pkgName, String instructionSet) { StringBuilder builder = new StringBuilder("patchoat"); builder.append(' '); builder.append(apkPath); builder.append(' '); builder.append(uid); builder.append(isPublic ? " 1" : " 0"); builder.append(' '); builder.append(pkgName); builder.append(' '); builder.append(instructionSet); return execute(builder.toString()); } public int patchoat(String apkPath, int uid, boolean isPublic, String instructionSet) { StringBuilder builder = new StringBuilder("patchoat"); builder.append(' '); builder.append(apkPath); builder.append(' '); builder.append(uid); builder.append(isPublic ? " 1" : " 0"); builder.append(" *"); // No pkgName arg present builder.append(' '); builder.append(instructionSet); return execute(builder.toString()); } public int dexopt(String apkPath, int uid, boolean isPublic, String instructionSet) { StringBuilder builder = new StringBuilder("dexopt"); builder.append(' '); Loading
services/java/com/android/server/pm/PackageManagerService.java +37 −9 Original line number Diff line number Diff line Loading @@ -1368,11 +1368,18 @@ public class PackageManagerService extends IPackageManager.Stub { } try { if (DexFile.isDexOptNeededInternal(lib, null, instructionSet, false)) { byte dexoptRequired = DexFile.isDexOptNeededInternal(lib, null, instructionSet, false); if (dexoptRequired != DexFile.UP_TO_DATE) { alreadyDexOpted.add(lib); // The list of "shared libraries" we have at this point is if (dexoptRequired == DexFile.DEXOPT_NEEDED) { mInstaller.dexopt(lib, Process.SYSTEM_UID, true, instructionSet); } else { mInstaller.patchoat(lib, Process.SYSTEM_UID, true, instructionSet); } didDexOptLibraryOrTool = true; } } catch (FileNotFoundException e) { Loading Loading @@ -1419,9 +1426,15 @@ public class PackageManagerService extends IPackageManager.Stub { continue; } try { if (DexFile.isDexOptNeededInternal(path, null, instructionSet, false)) { byte dexoptRequired = DexFile.isDexOptNeededInternal(path, null, instructionSet, false); if (dexoptRequired == DexFile.DEXOPT_NEEDED) { mInstaller.dexopt(path, Process.SYSTEM_UID, true, instructionSet); didDexOptLibraryOrTool = true; } else if (dexoptRequired == DexFile.PATCHOAT_NEEDED) { mInstaller.patchoat(path, Process.SYSTEM_UID, true, instructionSet); didDexOptLibraryOrTool = true; } } catch (FileNotFoundException e) { Slog.w(TAG, "Jar not found: " + path); Loading Loading @@ -4282,15 +4295,18 @@ public class PackageManagerService extends IPackageManager.Stub { if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0) { String path = pkg.mScanPath; try { boolean isDexOptNeededInternal = DexFile.isDexOptNeededInternal(path, pkg.packageName, instructionSet, defer); // This will return DEXOPT_NEEDED if we either cannot find any odex file for this // patckage or the one we find does not match the image checksum (i.e. it was // compiled against an old image). It will return PATCHOAT_NEEDED if we can find a // odex file and it matches the checksum of the image but not its base address, // meaning we need to move it. byte isDexOptNeededInternal = DexFile.isDexOptNeededInternal(path, pkg.packageName, instructionSet, defer); // There are three basic cases here: // 1.) we need to dexopt, either because we are forced or it is needed // 2.) we are defering a needed dexopt // 3.) we are skipping an unneeded dexopt if (forceDex || (!defer && isDexOptNeededInternal)) { if (forceDex || (!defer && isDexOptNeededInternal == DexFile.DEXOPT_NEEDED)) { Log.i(TAG, "Running dexopt on: " + pkg.applicationInfo.packageName); final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); int ret = mInstaller.dexopt(path, sharedGid, !isForwardLocked(pkg), Loading @@ -4302,8 +4318,20 @@ public class PackageManagerService extends IPackageManager.Stub { return DEX_OPT_FAILED; } return DEX_OPT_PERFORMED; } else if (!defer && isDexOptNeededInternal == DexFile.PATCHOAT_NEEDED) { Log.i(TAG, "Running patchoat on: " + pkg.applicationInfo.packageName); final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); int ret = mInstaller.patchoat(path, sharedGid, !isForwardLocked(pkg), pkg.packageName, instructionSet); // Note that we ran patchoat, since rerunning will // probably just result in an error again. pkg.mDexOptNeeded = false; if (ret < 0) { return DEX_OPT_FAILED; } return DEX_OPT_PERFORMED; } if (defer && isDexOptNeededInternal) { if (defer && isDexOptNeededInternal != DexFile.UP_TO_DATE) { if (mDeferredDexOpt == null) { mDeferredDexOpt = new HashSet<PackageParser.Package>(); } Loading