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

Commit d84239bd authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Let TransitionHandler to clear the transition-leash"

parents 6eaf7224 028954b0
Loading
Loading
Loading
Loading
+33 −38
Original line number Diff line number Diff line
@@ -310,53 +310,48 @@ public class RemoteTransitionCompat implements Parcelable {
                return;
            }
            if (mWrapped != null) mWrapped.finish(toHome, sendUserLeaveHint);
            try {
            final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            final WindowContainerTransaction wct;

            if (!toHome && mPausingTasks != null && mOpeningLeashes == null) {
                // The gesture went back to opening the app rather than continuing with
                // recents, so end the transition by moving the app back to the top (and also
                // re-showing it's task).
                    final WindowContainerTransaction wct = new WindowContainerTransaction();
                    final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
                wct = new WindowContainerTransaction();
                for (int i = mPausingTasks.size() - 1; i >= 0; --i) {
                    // reverse order so that index 0 ends up on top
                    wct.reorder(mPausingTasks.get(i), true /* onTop */);
                    t.show(mInfo.getChange(mPausingTasks.get(i)).getLeash());
                }
                    mFinishCB.onTransitionFinished(wct, t);
            } else {
                wct = null;
                if (mOpeningLeashes != null) {
                    // TODO: the launcher animation should handle this
                        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
                    for (int i = 0; i < mOpeningLeashes.size(); ++i) {
                        t.show(mOpeningLeashes.get(i));
                        t.setAlpha(mOpeningLeashes.get(i), 1.f);
                    }
                        t.apply();
                }
                if (mPipTask != null && mPipTransaction != null) {
                        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
                    t.show(mInfo.getChange(mPipTask).getLeash());
                    PictureInPictureSurfaceTransaction.apply(mPipTransaction,
                            mInfo.getChange(mPipTask).getLeash(), t);
                    mPipTask = null;
                    mPipTransaction = null;
                        mFinishCB.onTransitionFinished(null /* wct */, t);
                    } else {
                        mFinishCB.onTransitionFinished(null /* wct */, null /* sct */);
                }

                }
            } catch (RemoteException e) {
                Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e);
            }
            // Release surface references now. This is apparently to free GPU
            // memory while doing quick operations (eg. during CTS).
            SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            for (int i = 0; i < mLeashMap.size(); ++i) {
                if (mLeashMap.keyAt(i) == mLeashMap.valueAt(i)) continue;
                t.remove(mLeashMap.valueAt(i));
            }
            try {
                mFinishCB.onTransitionFinished(wct, t);
            } catch (RemoteException e) {
                Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e);
                t.apply();
            }
            for (int i = 0; i < mInfo.getChanges().size(); ++i) {
                mInfo.getChanges().get(i).getLeash().release();
            }