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

Commit 8bea4595 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Fix pointers pilfered when they shouldn't be

When onThresholdCrossed is called and mBackNavigationInfo==null, we should't pilfer pointers if onBackNavigationInfoReceived has not been called before. Because it is possible that onThresholdCrossed is called before onBackNavigationInfoReceived is called. In that case mBackNavigationInfo is always null even though it may be set shortly after when onBackNavigationInfoReceived is called.

The issue can be reproduced for example with the IME predictive back animation in the Google Photos app. When executing the back gesture extremely fast, there is sometimes no predictive back animation on the IME because onThresholdCrossed is called before onBackNavigationInfoReceived.

Therefore we should add an additional check that verifies that onBackNavigationInfoReceived was indeed already called.

Bug: 351763151
Flag: com.android.window.flags.predictive_back_system_anims
Test: Manual, i.e. verifying that very quick back swipes do not cause pointers to be pilfered when they shouldn't be.
Change-Id: Icadead2be06dad724bca7f27704edbe5627beeac
parent 1d1a9c34
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

    @Nullable
    private BackNavigationInfo mBackNavigationInfo;
    private boolean mReceivedNullNavigationInfo = false;
    private final IActivityTaskManager mActivityTaskManager;
    private final Context mContext;
    private final ContentResolver mContentResolver;
@@ -424,7 +425,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        mThresholdCrossed = true;
        // There was no focus window when calling startBackNavigation, still pilfer pointers so
        // the next focus window won't receive motion events.
        if (mBackNavigationInfo == null) {
        if (mBackNavigationInfo == null && mReceivedNullNavigationInfo) {
            tryPilferPointers();
            return;
        }
@@ -547,6 +548,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        ProtoLog.d(WM_SHELL_BACK_PREVIEW, "Received backNavigationInfo:%s", backNavigationInfo);
        if (backNavigationInfo == null) {
            ProtoLog.e(WM_SHELL_BACK_PREVIEW, "Received BackNavigationInfo is null.");
            mReceivedNullNavigationInfo = true;
            cancelLatencyTracking();
            tryPilferPointers();
            return;
@@ -902,6 +904,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        mPointersPilfered = false;
        mShellBackAnimationRegistry.resetDefaultCrossActivity();
        cancelLatencyTracking();
        mReceivedNullNavigationInfo = false;
        if (mBackNavigationInfo != null) {
            mPreviousNavigationType = mBackNavigationInfo.getType();
            mBackNavigationInfo.onBackNavigationFinished(triggerBack);