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

Commit 8084f4b3 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Delete expired CE APEX snapshots when user unlocks." into rvc-dev am:...

Merge "Delete expired CE APEX snapshots when user unlocks." into rvc-dev am: a6eb7fa2 am: 145b90ca

Change-Id: I98994bc15e1faf85a3d58dfa466ce641f9a4121d
parents 92e83724 145b90ca
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -300,6 +300,14 @@ public abstract class ApexManager {
     */
    public abstract boolean destroyDeSnapshots(int rollbackId);

    /**
     * Deletes snapshots of the credential encrypted apex data directories for the specified user,
     * where the rollback id is not included in {@code retainRollbackIds}.
     *
     * @return boolean true if the delete was successful
     */
    public abstract boolean destroyCeSnapshotsNotSpecified(int userId, int[] retainRollbackIds);

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

        @Override
        public boolean destroyCeSnapshotsNotSpecified(int userId, int[] retainRollbackIds) {
            try {
                mApexService.destroyCeSnapshotsNotSpecified(userId, retainRollbackIds);
                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.
@@ -962,6 +981,11 @@ public abstract class ApexManager {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean destroyCeSnapshotsNotSpecified(int userId, int[] retainRollbackIds) {
            return true;
        }

        @Override
        void dump(PrintWriter pw, String packageName) {
            // No-op
+12 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.server.LocalServices;
import com.android.server.PackageWatchdog;
import com.android.server.SystemConfig;
import com.android.server.Watchdog;
import com.android.server.pm.ApexManager;
import com.android.server.pm.Installer;

import java.io.File;
@@ -485,6 +486,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
            }

            latch.countDown();

            destroyCeSnapshotsForExpiredRollbacks(userId);
        });

        try {
@@ -494,6 +497,15 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
        }
    }

    @WorkerThread
    private void destroyCeSnapshotsForExpiredRollbacks(int userId) {
        int[] rollbackIds = new int[mRollbacks.size()];
        for (int i = 0; i < rollbackIds.length; i++) {
            rollbackIds[i] = mRollbacks.get(i).info.getRollbackId();
        }
        ApexManager.getInstance().destroyCeSnapshotsNotSpecified(userId, rollbackIds);
    }

    @WorkerThread
    private void updateRollbackLifetimeDurationInMillis() {
        mRollbackLifetimeDurationInMillis = DeviceConfig.getLong(