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

Commit 96ee7c1c authored by JW Wang's avatar JW Wang Committed by Android (Google) Code Review
Browse files

Merge "Remove dead code"

parents cabc3108 5731f9a9
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -49,10 +49,6 @@ interface IRollbackManager {
    // NOTE: This call is synchronous.
    int notifyStagedSession(int sessionId);

    // Used by the staging manager to notify the RollbackManager of the apk
    // session for a staged session.
    void notifyStagedApkSession(int originalSessionId, int apkSessionId);

    // For test purposes only.
    void blockRollbackManager(long millis);
}
+0 −14
Original line number Diff line number Diff line
@@ -674,20 +674,6 @@ public class StagingManager {
            return;
        }

        if ((session.params.installFlags & PackageManager.INSTALL_ENABLE_ROLLBACK) != 0) {
            // If rollback is available for this session, notify the rollback
            // manager of the apk session so it can properly enable rollback.
            final RollbackManagerInternal rm =
                    LocalServices.getService(RollbackManagerInternal.class);
            try {
                // TODO(b/136257624): extra apk session id in rollback is now redundant.
                rm.notifyStagedApkSession(session.sessionId, session.sessionId);
            } catch (RuntimeException re) {
                Slog.e(TAG, "Failed to notifyStagedApkSession for session: "
                        + session.sessionId, re);
            }
        }

        final LocalIntentReceiverSync receiver = new LocalIntentReceiverSync();
        session.installStagedSession(receiver.getIntentSender());
        final Intent result = receiver.getResult();
+1 −26
Original line number Diff line number Diff line
@@ -145,11 +145,6 @@ class Rollback {
     */
    private @RollbackState int mState;

    /**
     * The id of the post-reboot apk session for a staged install, if any.
     */
    private int mApkSessionId = -1;

    /**
     * True if we are expecting the package manager to call restoreUserData
     * for this rollback because it has just been committed but the rollback
@@ -236,7 +231,7 @@ class Rollback {
     * Constructs a pre-populated Rollback instance.
     */
    Rollback(RollbackInfo info, File backupDir, Instant timestamp, int stagedSessionId,
            @RollbackState int state, int apkSessionId, boolean restoreUserDataInProgress,
            @RollbackState int state, boolean restoreUserDataInProgress,
            int userId, String installerPackageName, SparseIntArray extensionVersions) {
        this.info = info;
        mUserId = userId;
@@ -245,7 +240,6 @@ class Rollback {
        mTimestamp = timestamp;
        mStagedSessionId = stagedSessionId;
        mState = state;
        mApkSessionId = apkSessionId;
        mRestoreUserDataInProgress = restoreUserDataInProgress;
        mExtensionVersions = Objects.requireNonNull(extensionVersions);
        // TODO(b/120200473): Include this field during persistence. This field will be used to
@@ -726,25 +720,6 @@ class Rollback {
        mState = ROLLBACK_STATE_DELETED;
    }

    /**
     * Returns the id of the post-reboot apk session for a staged install, if any.
     */
    @WorkerThread
    int getApkSessionId() {
        assertInWorkerThread();
        return mApkSessionId;
    }

    /**
     * Sets the id of the post-reboot apk session for a staged install.
     */
    @WorkerThread
    void setApkSessionId(int apkSessionId) {
        assertInWorkerThread();
        mApkSessionId = apkSessionId;
        RollbackStore.saveRollback(this);
    }

    /**
     * Returns true if we are expecting the package manager to call restoreUserData for this
     * rollback because it has just been committed but the rollback has not yet been fully applied.
+0 −9
Original line number Diff line number Diff line
@@ -53,13 +53,4 @@ public interface RollbackManagerInternal {
     * @return The rollback id if rollback was enabled successfully, or -1 if not.
     */
    int notifyStagedSession(int sessionId);

    /**
     * Used by the staging manager to notify the RollbackManager of the apk
     * session for a staged session.
     *
     * @param originalSessionId The original session ID where this apk session belongs
     * @param apkSessionId The ID of this apk session
     */
    void notifyStagedApkSession(int originalSessionId, int apkSessionId);
}
+0 −57
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.ext.SdkExtensions;
import android.provider.DeviceConfig;
import android.util.IntArray;
import android.util.Log;
import android.util.LongArrayQueue;
import android.util.Slog;
@@ -152,10 +151,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub implements Rollba
    // Accessed on the handler thread only.
    private final List<Rollback> mRollbacks = new ArrayList<>();

    // Apk sessions from a staged session with no matching rollback.
    // Accessed on the handler thread only.
    private final IntArray mOrphanedApkSessionIds = new IntArray();

    private final RollbackStore mRollbackStore;

    private final Context mContext;
@@ -647,8 +642,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub implements Rollba
                onPackageReplaced(apexPackageName);
            }

            mOrphanedApkSessionIds.clear();

            mPackageHealthObserver.onBootCompletedAsync();
        });
    }
@@ -783,25 +776,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub implements Rollba
            return false;
        }

        // Check to see if this is the apk session for a staged session with
        // rollback enabled.
        for (int i = 0; i < mRollbacks.size(); ++i) {
            Rollback rollback = mRollbacks.get(i);
            if (rollback.getApkSessionId() == parentSession.getSessionId()) {
                // This is the apk session for a staged session with rollback enabled. We do
                // not need to create a new rollback for this session.
                return true;
            }
        }

        // Check to see if this is the apk session for a staged session for which rollback was
        // cancelled.
        if (mOrphanedApkSessionIds.indexOf(parentSession.getSessionId()) != -1) {
            Slog.w(TAG, "Not enabling rollback for apk as no matching staged session "
                    + "rollback exists");
            return false;
        }

        // See if we already have a Rollback that contains this package
        // session. If not, create a new Rollback for the parent session
        // that we will use for all the packages in the session.
@@ -1039,37 +1013,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub implements Rollba
        });
    }

    @ExtThread
    @Override
    public void notifyStagedApkSession(int originalSessionId, int apkSessionId) {
        assertNotInWorkerThread();
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {
            throw new SecurityException("notifyStagedApkSession may only be called by the system.");
        }
        getHandler().post(() -> {
            assertInWorkerThread();
            Rollback rollback = null;
            for (int i = 0; i < mRollbacks.size(); ++i) {
                Rollback candidate = mRollbacks.get(i);
                if (candidate.getStagedSessionId() == originalSessionId) {
                    rollback = candidate;
                    break;
                }
            }
            if (rollback == null) {
                // Did not find rollback matching originalSessionId.
                Slog.e(TAG, "notifyStagedApkSession did not find rollback for session "
                        + originalSessionId
                        + ". Adding orphaned apk session " + apkSessionId);
                mOrphanedApkSessionIds.add(apkSessionId);
            }

            if (rollback != null) {
                rollback.setApkSessionId(apkSessionId);
            }
        });
    }

    /**
     * Returns true if the installer is allowed to enable rollback for the
     * given named package, false otherwise.
Loading