Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd26b955 authored by Mathieu Chartier's avatar Mathieu Chartier Committed by android-build-merger
Browse files

Merge "Move stub APK profile logic to performDexOptUpgrade" into oc-mr1-dev

am: 4f1844cb

Change-Id: I09c82246b6f61045c2e1911f96f995d309ea4978
parents a739d220 4f1844cb
Loading
Loading
Loading
Loading
+24 −21
Original line number Original line Diff line number Diff line
@@ -3313,23 +3313,6 @@ public class PackageManagerService extends IPackageManager.Stub
            return null;
            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;
        return dstCodePath;
    }
    }
@@ -9786,10 +9769,30 @@ public class PackageManagerService extends IPackageManager.Stub
                        // package and APK names.
                        // package and APK names.
                        String systemProfilePath =
                        String systemProfilePath =
                                getPrebuildProfilePath(disabledPs.pkg).replace(STUB_SUFFIX, "");
                                getPrebuildProfilePath(disabledPs.pkg).replace(STUB_SUFFIX, "");
                        File systemProfile = new File(systemProfilePath);
                        profileFile = new File(systemProfilePath);
                        // Use the profile for compilation if there exists one for the same package
                        // If we have a profile for a compressed APK, copy it to the reference
                        // in the system partition.
                        // location.
                        useProfileForDexopt = systemProfile.exists();
                        // 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);
                            }
                        }
                    }
                    }
                }
                }
            }
            }