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

Commit 5daf06c1 authored by George Mount's avatar George Mount
Browse files

Fix saving target fragment when Fragment not yet created.

Bug 35928527

During optimized transactions, a fragment may be removed without
being created. That leaves the state of the fragment in INITIALIZING
and previously, that state wasn't ever saved. This CL allows a
fragment that is being removed to be brought up to the CREATED state
so that it can be saved during saveAllState().

Test: manual and Ie7207cc647312d38b377405bc5ec8721db757d2e

Change-Id: I649f1931745be43087ec3578e9195624e80821dc
parent 537fd18e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1128,9 +1128,14 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
            newState = Fragment.CREATED;
        }
        if (f.mRemoving && newState > f.mState) {
            if (f.mState == Fragment.INITIALIZING && f.isInBackStack()) {
                // Allow the fragment to be created so that it can be saved later.
                newState = Fragment.CREATED;
            } else {
                // While removing a fragment, we can't change it to a higher state.
                newState = f.mState;
            }
        }
        // Defer start if requested; don't allow it to move to STARTED or higher
        // if it's not already started.
        if (f.mDeferStart && f.mState < Fragment.STARTED && newState > Fragment.STOPPED) {