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

Commit 13ef57fd authored by JW Wang's avatar JW Wang
Browse files

Add a flag to facilitate merging 2 rollback collections (8/n)

We will move rollbacks from #mNewRollbacks to #mRollbacks in the next
CL. To preserve the same semantics for new rollbacks, rollbacks
originally managed by #mNewRollbacks will have
Rollback#mIsNewRollback==true.

Bug: 147400979
Test: atest RollbackTest
Change-Id: I7edd3cf75d40ff2a61c485efc0cc4ec7de7d4f99
parent 06a09a93
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -181,6 +181,15 @@ class Rollback {
    @GuardedBy("mLock")
    private int mNumPackageSessionsWithSuccess;

    /**
     * A temp flag to facilitate merging of the 2 rollback collections managed by
     * RollbackManagerServiceImpl. True if this rollback is in the process of enabling and was
     * originally managed by RollbackManagerServiceImpl#mNewRollbacks.
     * TODO: remove this flag when merge is completed.
     */
    @GuardedBy("mLock")
    private boolean mIsNewRollback = false;

    /**
     * Constructs a new, empty Rollback instance.
     *
@@ -829,6 +838,18 @@ class Rollback {
        }
    }

    void setIsNewRollback(boolean newRollback) {
        synchronized (mLock) {
            mIsNewRollback = newRollback;
        }
    }

    boolean isNewRollback() {
        synchronized (mLock) {
            return mIsNewRollback;
        }
    }

    static String rollbackStateToString(@RollbackState int state) {
        switch (state) {
            case Rollback.ROLLBACK_STATE_ENABLING: return "enabling";
+2 −0
Original line number Diff line number Diff line
@@ -811,6 +811,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
            if (newRollback == null) {
                newRollback = createNewRollbackLocked(parentSession);
                mNewRollbacks.add(newRollback);
                newRollback.setIsNewRollback(true);
            }
        }
        newRollback.addToken(token);
@@ -1201,6 +1202,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
                    newRollback = getNewRollbackForPackageSessionLocked(sessionId);
                    if (newRollback != null && newRollback.notifySessionWithSuccess()) {
                        mNewRollbacks.remove(newRollback);
                        newRollback.setIsNewRollback(false);
                    } else {
                        // Not all child sessions finished with success.
                        // Don't enable the rollback yet.