Attempted fix for IllegalStateException

This change attempts to fix an IllegalStateException that can occur when
dragging the bouncer while dreaming.

Test: atest BouncerSwipeTouchHandlerTest
Bug: 270736945
Change-Id: Ie243c2224d97cf070beb7a323b572deffcfcdc38
This commit is contained in:
Will Leshner
2023-02-28 17:31:56 -08:00
parent 12cc569ea6
commit b689a37751
2 changed files with 13 additions and 1 deletions

View File

@@ -254,7 +254,10 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
mCurrentScrimController = mScrimManager.getCurrentController();
session.registerCallback(() -> {
mVelocityTracker.recycle();
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
mScrimManager.removeCallback(mScrimManagerCallback);
mCapture = null;
mNotificationShadeWindowController.setForcePluginOpen(false, this);

View File

@@ -450,6 +450,15 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
swipeToPosition(0f, Direction.DOWN, 0);
}
@Test
public void testTouchSessionOnRemovedCalledTwice() {
mTouchHandler.onSessionStart(mTouchSession);
ArgumentCaptor<DreamTouchHandler.TouchSession.Callback> onRemovedCallbackCaptor =
ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.Callback.class);
verify(mTouchSession).registerCallback(onRemovedCallbackCaptor.capture());
onRemovedCallbackCaptor.getValue().onRemoved();
onRemovedCallbackCaptor.getValue().onRemoved();
}
private void swipeToPosition(float percent, Direction direction, float velocityY) {
Mockito.clearInvocations(mTouchSession);