Fix the crash on animating the accessibility floating menu.

Root cause:
The menu had been animating and moving to the screen edge and hiding the menu in the meantime.

Solution:
Should cancel the animation before hiding the menu.

Bug: 237217858
Test: atest AccessibilityFloatingMenuViewTest
Change-Id: I75f75de3299210ed9d88b3be7dbaa81abb7db2e1
This commit is contained in:
Peter_Liang
2022-07-10 22:40:47 +08:00
parent d50a2b4e63
commit 87edbcd0bc
2 changed files with 11 additions and 0 deletions

View File

@@ -353,6 +353,7 @@ public class AccessibilityFloatingMenuView extends FrameLayout
}
mIsShowing = false;
mDragAnimator.cancel();
mWindowManager.removeView(this);
setOnApplyWindowInsetsListener(null);

View File

@@ -190,6 +190,16 @@ public class AccessibilityFloatingMenuViewTest extends SysuiTestCase {
verify(mWindowManager, times(1)).removeView(eq(mMenuView));
}
@Test
public void hideMenuViewWhenStartingAnimation_animatorNotRunning() {
mMenuView.show();
mMenuView.mDragAnimator.start();
mMenuView.hide();
assertThat(mMenuView.mDragAnimator.isRunning()).isFalse();
}
@Test
public void onTargetsChanged_singleTarget_expectedRadii() {
final Position alignRightPosition = new Position(1.0f, 0.0f);