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

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

Merge "Separate the predictive back transition request from start navigation." into main

parents 2daa6268 4bc760b9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -375,6 +375,12 @@ interface IActivityTaskManager {
    android.window.BackNavigationInfo startBackNavigation(
            in RemoteCallback navigationObserver, in BackAnimationAdapter adaptor);

    /**
     * This setups the leashed for sysui to animate the current back gesture.
     * Only valid after startBackNavigation.
     */
    void startPredictiveBackAnimation();

    /**
     * registers a callback to be invoked when a background activity launch is aborted.
     *
+0 −7
Original line number Diff line number Diff line
@@ -80,13 +80,6 @@ public final class BackNavigationInfo implements Parcelable {
     */
    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_GESTURE_FINISHED = "GestureFinished";

    /**
     * Touch gestured has transferred to embedded window, Shell should pilfer pointers so the
     * embedded won't receive motion events.
+10 −0
Original line number Diff line number Diff line
@@ -431,6 +431,16 @@ flag {
    }
}

flag {
    name: "predictive_back_delay_wm_transition"
    namespace: "windowing_frontend"
    description: "Separate the predictive back transition request from start navigation"
    bug: "301195601"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "current_animator_scale_uses_shared_memory"
    namespace: "wear_system_health"
+29 −15
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP;
import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_PREDICTIVE_BACK_HOME;
import static com.android.systemui.Flags.predictiveBackDelayWmTransition;
import static com.android.window.flags.Flags.predictiveBackDelayWmTransition;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BACK_PREVIEW;

import android.annotation.NonNull;
@@ -339,12 +339,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

        @Override
        public void onThresholdCrossed() {
            if (predictiveBackDelayWmTransition()) {
                mShellExecutor.execute(BackAnimationController.this::onThresholdCrossed);
            } else {
            BackAnimationController.this.onThresholdCrossed();
        }
        }

        @Override
        public void setTriggerBack(boolean triggerBack) {
@@ -443,11 +439,6 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    @VisibleForTesting
    public void onThresholdCrossed() {
        mThresholdCrossed = true;
        BackTouchTracker activeTracker = getActiveTracker();
        if (predictiveBackDelayWmTransition() && activeTracker != null && mActiveCallback == null
                && mBackGestureStarted) {
            startBackNavigation(activeTracker);
        }
        // There was no focus window when calling startBackNavigation, still pilfer pointers so
        // the next focus window won't receive motion events.
        if (mBackNavigationInfo == null && mReceivedNullNavigationInfo) {
@@ -466,6 +457,25 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        } else if (shouldDispatchToAnimator) {
            tryPilferPointers();
        }

        if (predictiveBackDelayWmTransition()) {
            mShellExecutor.execute(() -> {
                if (shouldDispatchToAnimator()) {
                    try {
                        mActivityTaskManager.startPredictiveBackAnimation();
                    } catch (RemoteException r) {
                        Log.e(TAG, "Failed to start predictive animation", r);
                        finishBackNavigation(mCurrentTracker.getTriggerBack());
                        return;
                    }
                    final int backType = mBackNavigationInfo.getType();
                    if (!mShellBackAnimationRegistry.startGesture(backType)) {
                        mActiveCallback = null;
                    }
                    requestTopUi(true, backType);
                }
            });
        }
    }

    private boolean isAppProgressGenerationAllowed() {
@@ -575,7 +585,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            mPostCommitAnimationInProgress = false;
            mShellExecutor.removeCallbacks(mAnimationTimeoutRunnable);
            startSystemAnimation();
        } else if (!predictiveBackDelayWmTransition()) {
        } else {
            startBackNavigation(touchTracker);
        }
    }
@@ -615,10 +625,12 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        final int backType = backNavigationInfo.getType();
        final boolean shouldDispatchToAnimator = shouldDispatchToAnimator();
        if (shouldDispatchToAnimator) {
            if (!predictiveBackDelayWmTransition()) {
                if (!mShellBackAnimationRegistry.startGesture(backType)) {
                    mActiveCallback = null;
                }
                requestTopUi(true, backType);
            }
            tryPilferPointers();
        } else {
            mActiveCallback = mBackNavigationInfo.getOnBackInvokedCallback();
@@ -829,6 +841,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                            ? mBackNavigationInfo.getFocusedTaskId()
                            : INVALID_TASK_ID);
        }
        final boolean hasRequestAnimation = mThresholdCrossed;
        // Reset gesture states.
        mThresholdCrossed = false;
        mPointersPilfered = false;
@@ -858,6 +871,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        final int backType = mBackNavigationInfo.getType();
        // Simply trigger and finish back navigation when no animator defined.
        if (!shouldDispatchToAnimator()
                || (!hasRequestAnimation && predictiveBackDelayWmTransition())
                || mShellBackAnimationRegistry.isAnimationCancelledOrNull(backType)) {
            ProtoLog.d(WM_SHELL_BACK_PREVIEW, "Trigger back without dispatching to animator.");
            invokeOrCancelBack(mCurrentTracker);
+1 −11
Original line number Diff line number Diff line
@@ -7,13 +7,3 @@ flag {
    description: "Enable Shade Animations"
    bug: "327732946"
}
 No newline at end of file

flag {
    name: "predictive_back_delay_wm_transition"
    namespace: "systemui"
    description: "Slightly delays the back transition start"
    bug: "301195601"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}
Loading