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

Commit 3e9e15c3 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Revert "Fix OnBackAnimationCallback not receiving updates"

This reverts commit b3305a61.

Reason for revert: Performance regression (see b/322593724)

Change-Id: I9bac726bab90f346b2d1ebaee7f519780e6d809b
parent b3305a61
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -226,6 +226,9 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
            setTopOnBackInvokedCallback(null);
            setTopOnBackInvokedCallback(null);
        }
        }


        // We should also stop running animations since all callbacks have been removed.
        // note: mSpring.skipToEnd(), in ProgressAnimator.reset(), requires the main handler.
        Handler.getMain().post(mProgressAnimator::reset);
        mAllCallbacks.clear();
        mAllCallbacks.clear();
        mOnBackInvokedCallbacks.clear();
        mOnBackInvokedCallbacks.clear();
    }
    }
+5 −5
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.window.OnBackInvokedDispatcher.PRIORITY_DEFAULT;
import static android.window.OnBackInvokedDispatcher.PRIORITY_OVERLAY;
import static android.window.OnBackInvokedDispatcher.PRIORITY_OVERLAY;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeast;
@@ -359,7 +358,7 @@ public class WindowOnBackInvokedDispatcherTest {
    }
    }


    @Test
    @Test
    public void onDetachFromWindow_cancelsBackAnimation() throws RemoteException {
    public void onDetachFromWindow_cancelCallbackAndIgnoreOnBackInvoked() throws RemoteException {
        mDispatcher.registerOnBackInvokedCallback(PRIORITY_DEFAULT, mCallback1);
        mDispatcher.registerOnBackInvokedCallback(PRIORITY_DEFAULT, mCallback1);


        OnBackInvokedCallbackInfo callbackInfo = assertSetCallbackInfo();
        OnBackInvokedCallbackInfo callbackInfo = assertSetCallbackInfo();
@@ -369,12 +368,13 @@ public class WindowOnBackInvokedDispatcherTest {
        waitForIdle();
        waitForIdle();
        verify(mCallback1).onBackStarted(any(BackEvent.class));
        verify(mCallback1).onBackStarted(any(BackEvent.class));


        // This should trigger mCallback1.onBackCancelled() and unset the callback in WM
        // This should trigger mCallback1.onBackCancelled()
        mDispatcher.detachFromWindow();
        mDispatcher.detachFromWindow();
        // This should be ignored by mCallback1
        callbackInfo.getCallback().onBackInvoked();


        OnBackInvokedCallbackInfo callbackInfo1 = assertSetCallbackInfo();
        assertNull(callbackInfo1);
        waitForIdle();
        waitForIdle();
        verify(mCallback1, never()).onBackInvoked();
        verify(mCallback1).onBackCancelled();
        verify(mCallback1).onBackCancelled();
    }
    }
}
}