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

Commit 36be081a authored by Oli Lan's avatar Oli Lan
Browse files

Destroy DE apex data snapshots when rollback is deleted.

This calls through to ApexService to destroy all the DE snapshots
for a rollback when that rollback is deleted.

Bug: 141148175
Test: Install APEX with rollback enabled, expire rollback and check snapshot
has been deleted.
Change-Id: I8a8d3d89f7570a55b4a516376bad311a61d637ec
parent a8486be9
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -290,6 +290,14 @@ public abstract class ApexManager {
     */
    public abstract boolean restoreCeData(int userId, int rollbackId, String apexPackageName);

    /**
     * Deletes snapshots of the device encrypted apex data directories for the given
     * {@code rollbackId}.
     *
     * @return boolean true if the delete was successful
     */
    public abstract boolean destroyDeSnapshots(int rollbackId);

    /**
     * Dumps various state information to the provided {@link PrintWriter} object.
     *
@@ -720,6 +728,17 @@ public abstract class ApexManager {
            }
        }

        @Override
        public boolean destroyDeSnapshots(int rollbackId) {
            try {
                mApexService.destroyDeSnapshots(rollbackId);
                return true;
            } catch (Exception e) {
                Slog.e(TAG, e.getMessage(), e);
                return false;
            }
        }

        /**
         * Dump information about the packages contained in a particular cache
         * @param packagesCache the cache to print information about.
@@ -932,6 +951,11 @@ public abstract class ApexManager {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean destroyDeSnapshots(int rollbackId) {
            throw new UnsupportedOperationException();
        }

        @Override
        void dump(PrintWriter pw, String packageName) {
            // No-op
+15 −6
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.util.SparseLongArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.pm.ApexManager;

import java.io.File;
import java.io.IOException;
@@ -651,7 +652,11 @@ class Rollback {
     */
    void delete(AppDataRollbackHelper dataHelper) {
        synchronized (mLock) {
            boolean containsApex = false;
            for (PackageRollbackInfo pkgInfo : info.getPackages()) {
                if (pkgInfo.isApex()) {
                    containsApex = true;
                } else {
                    IntArray snapshottedUsers = pkgInfo.getSnapshottedUsers();
                    for (int i = 0; i < snapshottedUsers.size(); i++) {
                        // Destroy app data snapshot.
@@ -660,6 +665,10 @@ class Rollback {
                        dataHelper.destroyAppDataSnapshot(info.getRollbackId(), pkgInfo, userId);
                    }
                }
            }
            if (containsApex) {
                ApexManager.getInstance().destroyDeSnapshots(info.getRollbackId());
            }

            RollbackStore.deleteRollback(this);
            mState = ROLLBACK_STATE_DELETED;