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

Commit 50d2a614 authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge "Keeps art profile for pre-dexopt" into main

parents f9952179 cfa6252c
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ final class DeletePackageHelper {

        try {
            executeDeletePackageLIF(action, packageName, deleteCodeAndResources,
                    allUserHandles, writeSettings);
                    allUserHandles, writeSettings, /* keepArtProfile= */ false);
        } catch (SystemDeleteException e) {
            if (DEBUG_REMOVE) Slog.d(TAG, "deletePackageLI: system deletion failure", e);
            return false;
@@ -433,11 +433,11 @@ final class DeletePackageHelper {
    }

    public void executeDeletePackage(DeletePackageAction action, String packageName,
            boolean deleteCodeAndResources, @NonNull int[] allUserHandles, boolean writeSettings)
            throws SystemDeleteException {
            boolean deleteCodeAndResources, @NonNull int[] allUserHandles, boolean writeSettings,
            boolean keepArtProfile)  throws SystemDeleteException {
        try (PackageManagerTracedLock installLock = mPm.mInstallLock.acquireLock()) {
            executeDeletePackageLIF(action, packageName, deleteCodeAndResources, allUserHandles,
                    writeSettings);
                    writeSettings, keepArtProfile);
        }
    }

@@ -445,11 +445,14 @@ final class DeletePackageHelper {
    @GuardedBy("mPm.mInstallLock")
    private void executeDeletePackageLIF(DeletePackageAction action,
            String packageName, boolean deleteCodeAndResources,
            @NonNull int[] allUserHandles, boolean writeSettings) throws SystemDeleteException {
            @NonNull int[] allUserHandles, boolean writeSettings, boolean keepArtProfile)
            throws SystemDeleteException {
        final PackageSetting ps = action.mDeletingPs;
        final PackageRemovedInfo outInfo = action.mRemovedInfo;
        final UserHandle user = action.mUser;
        final int flags = action.mFlags;
        final int flags =
                keepArtProfile ? action.mFlags | Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES
                        : action.mFlags;
        final boolean systemApp = PackageManagerServiceUtils.isSystemApp(ps);

        // We need to get the permission state before package state is (potentially) destroyed.
+2 −1
Original line number Diff line number Diff line
@@ -1101,6 +1101,7 @@ final class InstallPackageHelper {
                request.setError(e.error, e.getMessage());
                return;
            }
            request.setKeepArtProfile(true);
            DexOptHelper.performDexoptIfNeeded(request, mDexManager, mContext, null);
        }
    }
@@ -2406,7 +2407,7 @@ final class InstallPackageHelper {
                        // Settings will be written during the call to updateSettingsLI().
                        mDeletePackageHelper.executeDeletePackage(
                                reconciledPkg.mDeletePackageAction, packageName,
                                true, allUsers, false);
                                true, allUsers, false, installRequest.isKeepArtProfile());
                    } catch (SystemDeleteException e) {
                        if (mPm.mIsEngBuild) {
                            throw new RuntimeException("Unexpected failure", e);
+10 −0
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ final class InstallRequest {

    private final boolean mHasAppMetadataFileFromInstaller;

    private boolean mKeepArtProfile = false;

    // New install
    InstallRequest(InstallingSession params) {
        mUserId = params.getUser().getIdentifier();
@@ -1059,4 +1061,12 @@ final class InstallRequest {
            mPackageMetrics.onStepFinished(PackageMetrics.STEP_FREEZE_INSTALL);
        }
    }

    void setKeepArtProfile(boolean keepArtProfile) {
        mKeepArtProfile = keepArtProfile;
    }

    boolean isKeepArtProfile() {
        return mKeepArtProfile;
    }
}
+6 −4
Original line number Diff line number Diff line
@@ -258,9 +258,10 @@ final class RemovePackageHelper {
     */
    public void clearPackageStateForUserLIF(PackageSetting ps, int userId, int flags) {
        final String packageName = ps.getPackageName();
        // Step 1: always destroy app profiles.
        // Step 1: always destroy app profiles except when explicitly preserved
        if ((flags & Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES) == 0) {
            mAppDataHelper.destroyAppProfilesLIF(packageName);

        }
        final AndroidPackage pkg;
        final SharedUserSetting sus;
        synchronized (mPm.mLock) {
@@ -277,7 +278,8 @@ final class RemovePackageHelper {
            resolvedPkg = PackageImpl.buildFakeForDeletion(packageName, ps.getVolumeUuid());
        }

        int appDataDeletionFlags = FLAG_STORAGE_DE | FLAG_STORAGE_CE | FLAG_STORAGE_EXTERNAL;
        int appDataDeletionFlags = FLAG_STORAGE_DE | FLAG_STORAGE_CE | FLAG_STORAGE_EXTERNAL
                | (flags & Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
        // Personal data is preserved if the DELETE_KEEP_DATA flag is on
        if ((flags & PackageManager.DELETE_KEEP_DATA) != 0) {
            if ((flags & PackageManager.DELETE_ARCHIVE) != 0) {