diff options
| author | 2017-10-12 13:55:31 -0700 | |
|---|---|---|
| committer | 2017-10-12 15:19:30 -0700 | |
| commit | 7dfb00c12f0a72885145572bdc2123753ea31724 (patch) | |
| tree | cc535d3fdc7acf2387b482b45b9895840fcabff9 | |
| parent | 0e4fcfe95dc08c39d21d9d8974bebf7e77794354 (diff) | |
Move stub APK profile logic to performDexOptUpgrade
It used to be done in decompressPackage but this was too early during
first boot and caused an error copying since the profile directories
were not set up yet.
Test: flash with wipe, confirm profile is used
Bug: 64550394
Change-Id: If06c30f3f74ab172b0e7d57998cda73de9bbdcc4
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 224791b302e1..a22a84066317 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3313,23 +3313,6 @@ public class PackageManagerService extends IPackageManager.Stub return null; } - // If we have a profile for a compressed APK, copy it to the reference location. - // Since the package is the stub one, remove the stub suffix to get the normal package and - // APK name. - File profileFile = new File(getPrebuildProfilePath(pkg).replace(STUB_SUFFIX, "")); - if (profileFile.exists()) { - try { - // We could also do this lazily before calling dexopt in - // PackageDexOptimizer to prevent this happening on first boot. The issue - // is that we don't have a good way to say "do this only once". - if (!mInstaller.copySystemProfile(profileFile.getAbsolutePath(), - pkg.applicationInfo.uid, pkg.packageName)) { - Log.e(TAG, "decompressPackage failed to copy system profile!"); - } - } catch (Exception e) { - Log.e(TAG, "Failed to copy profile " + profileFile.getAbsolutePath() + " ", e); - } - } return dstCodePath; } @@ -9786,10 +9769,30 @@ public class PackageManagerService extends IPackageManager.Stub // package and APK names. String systemProfilePath = getPrebuildProfilePath(disabledPs.pkg).replace(STUB_SUFFIX, ""); - File systemProfile = new File(systemProfilePath); - // Use the profile for compilation if there exists one for the same package - // in the system partition. - useProfileForDexopt = systemProfile.exists(); + profileFile = new File(systemProfilePath); + // If we have a profile for a compressed APK, copy it to the reference + // location. + // Note that copying the profile here will cause it to override the + // reference profile every OTA even though the existing reference profile + // may have more data. We can't copy during decompression since the + // directories are not set up at that point. + if (profileFile.exists()) { + try { + // We could also do this lazily before calling dexopt in + // PackageDexOptimizer to prevent this happening on first boot. The + // issue is that we don't have a good way to say "do this only + // once". + if (!mInstaller.copySystemProfile(profileFile.getAbsolutePath(), + pkg.applicationInfo.uid, pkg.packageName)) { + Log.e(TAG, "Failed to copy system profile for stub package!"); + } else { + useProfileForDexopt = true; + } + } catch (Exception e) { + Log.e(TAG, "Failed to copy profile " + + profileFile.getAbsolutePath() + " ", e); + } + } } } } |