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

Commit 923dd3bc authored by wilsonshih's avatar wilsonshih
Browse files

Ask back navigation target to start rendering asap after gesture finish

After gesture finish, use launch behind to ask app start rendering
before entire close transition finish, the snapshot will be removed once
the opening target report drawn.

Flag: ACONFIG com.android.window.flags.predictive_back_system_anim
Flag: ACONFIG com.android.window.flags.activity_snapshot_by_default
Bug: 328664843
Test: verify snapshot can be removed much faster.
Change-Id: Ifa4ea469c0f882ec51b6d1920d02234afa3e3431
parent 6130d3f7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -4126,7 +4126,6 @@ package android.window {
    method @NonNull public static String typeToString(int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.window.BackNavigationInfo> CREATOR;
    field public static final String KEY_TRIGGER_BACK = "TriggerBack";
    field public static final int TYPE_CALLBACK = 4; // 0x4
    field public static final int TYPE_CROSS_ACTIVITY = 2; // 0x2
    field public static final int TYPE_CROSS_TASK = 3; // 0x3
+25 −2
Original line number Diff line number Diff line
@@ -72,8 +72,17 @@ public final class BackNavigationInfo implements Parcelable {
    /**
     * Key to access the boolean value passed in {#mOnBackNavigationDone} result bundle
     * that represents if back navigation has been triggered.
     * @hide
     */
    public static final String KEY_NAVIGATION_FINISHED = "NavigationFinished";

    /**
     * Key to access the boolean value passed in {#mOnBackNavigationDone} result bundle
     * that represents if back gesture has been triggered.
     * @hide
     */
    public static final String KEY_TRIGGER_BACK = "TriggerBack";
    public static final String KEY_GESTURE_FINISHED = "GestureFinished";


    /**
     * Defines the type of back destinations a back even can lead to. This is used to define the
@@ -192,7 +201,21 @@ public final class BackNavigationInfo implements Parcelable {
    public void onBackNavigationFinished(boolean triggerBack) {
        if (mOnBackNavigationDone != null) {
            Bundle result = new Bundle();
            result.putBoolean(KEY_TRIGGER_BACK, triggerBack);
            result.putBoolean(KEY_NAVIGATION_FINISHED, triggerBack);
            mOnBackNavigationDone.sendResult(result);
        }
    }

    /**
     * Callback to be called when the back gesture is finished in order to notify the server that
     * it can ask app to start rendering.
     * @hide
     * @param triggerBack Boolean indicating if back gesture has been triggered.
     */
    public void onBackGestureFinished(boolean triggerBack) {
        if (mOnBackNavigationDone != null) {
            Bundle result = new Bundle();
            result.putBoolean(KEY_GESTURE_FINISHED, triggerBack);
            mOnBackNavigationDone.sendResult(result);
        }
    }
+2 −0
Original line number Diff line number Diff line
@@ -828,6 +828,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

        // The next callback should be {@link #onBackAnimationFinished}.
        if (mCurrentTracker.getTriggerBack()) {
            // notify gesture finished
            mBackNavigationInfo.onBackGestureFinished(true);
            dispatchOrAnimateOnBackInvoked(mActiveCallback, mCurrentTracker);
        } else {
            tryDispatchOnBackCancelled(mActiveCallback);
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.wm.shell.back;

import static android.window.BackNavigationInfo.KEY_TRIGGER_BACK;
import static android.window.BackNavigationInfo.KEY_NAVIGATION_FINISHED;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -677,7 +677,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
        @Override
        public void onResult(@Nullable Bundle result) {
            mBackNavigationDone = true;
            mTriggerBack = result.getBoolean(KEY_TRIGGER_BACK);
            mTriggerBack = result.getBoolean(KEY_NAVIGATION_FINISHED);
        }
    }
}
+33 −12
Original line number Diff line number Diff line
@@ -1783,8 +1783,12 @@ class BackNavigationController {
    }

    private void onBackNavigationDone(Bundle result, int backType) {
        boolean triggerBack = result != null && result.getBoolean(
                BackNavigationInfo.KEY_TRIGGER_BACK);
        if (result == null) {
            return;
        }
        if (result.containsKey(BackNavigationInfo.KEY_NAVIGATION_FINISHED)) {
            final boolean triggerBack = result.getBoolean(
                    BackNavigationInfo.KEY_NAVIGATION_FINISHED);
            ProtoLog.d(WM_DEBUG_BACK_PREVIEW, "onBackNavigationDone backType=%s, "
                    + "triggerBack=%b", backType, triggerBack);

@@ -1797,6 +1801,23 @@ class BackNavigationController {
                mPendingAnimationBuilder = null;
            }
        }
        if (result.getBoolean(BackNavigationInfo.KEY_GESTURE_FINISHED)) {
            synchronized (mWindowManagerService.mGlobalLock) {
                final AnimationHandler ah = mAnimationHandler;
                if (!ah.mComposed || ah.mWaitTransition || ah.mOpenActivities == null
                        || (ah.mSwitchType != AnimationHandler.TASK_SWITCH
                        && ah.mSwitchType != AnimationHandler.ACTIVITY_SWITCH)) {
                    return;
                }
                for (int i = mAnimationHandler.mOpenActivities.length - 1; i >= 0; --i) {
                    final ActivityRecord preDrawActivity = mAnimationHandler.mOpenActivities[i];
                    if (!preDrawActivity.mLaunchTaskBehind) {
                        setLaunchBehind(preDrawActivity);
                    }
                }
            }
        }
    }

    static TaskSnapshot getSnapshot(@NonNull WindowContainer w,
            ActivityRecord[] visibleOpenActivities) {