diff options
author | Mady Mellor <madym@google.com> | 2021-12-15 18:09:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-12-15 18:09:31 +0000 |
commit | 4b3ea38f9b0ffc3bf37f015ff4dae96004de693e (patch) | |
tree | 79058dbe9324ac6fec20dc6a926c76ad46528308 /libs/WindowManager | |
parent | 65d19ed0437b8dd69b87dc2faab8febdc4412da9 (diff) | |
parent | 447e4f16e274d84dd75efac1deb608aca2193543 (diff) |
Merge "Fix a potential NPE" into sc-v2-dev
Diffstat (limited to 'libs/WindowManager')
2 files changed, 14 insertions, 3 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java index f0f78748e343..19d513f81cab 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java @@ -346,6 +346,9 @@ public class ExpandedAnimationController * bubble is dragged back into the row. */ public void dragBubbleOut(View bubbleView, float x, float y) { + if (mMagnetizedBubbleDraggingOut == null) { + return; + } if (mSpringToTouchOnNextMotionEvent) { springBubbleTo(mMagnetizedBubbleDraggingOut.getUnderlyingObject(), x, y); mSpringToTouchOnNextMotionEvent = false; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationControllerTest.java index 2b9bdce45a6c..335222e98c6c 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationControllerTest.java @@ -59,19 +59,21 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC private int mStackOffset; private PointF mExpansionPoint; private BubblePositioner mPositioner; - private BubbleStackView.StackViewState mStackViewState; + private BubbleStackView.StackViewState mStackViewState = new BubbleStackView.StackViewState(); @SuppressLint("VisibleForTests") @Before public void setUp() throws Exception { super.setUp(); - BubbleStackView stackView = mock(BubbleStackView.class); - when(stackView.getState()).thenReturn(getStackViewState()); mPositioner = new BubblePositioner(getContext(), mock(WindowManager.class)); mPositioner.updateInternal(Configuration.ORIENTATION_PORTRAIT, Insets.of(0, 0, 0, 0), new Rect(0, 0, mDisplayWidth, mDisplayHeight)); + + BubbleStackView stackView = mock(BubbleStackView.class); + when(stackView.getState()).thenReturn(getStackViewState()); + mExpandedController = new ExpandedAnimationController(mPositioner, mOnBubbleAnimatedOutAction, stackView); @@ -135,6 +137,12 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC testBubblesInCorrectExpandedPositions(); } + @Test + public void testDragBubbleOutDoesntNPE() throws InterruptedException { + mExpandedController.onGestureFinished(); + mExpandedController.dragBubbleOut(mViews.get(0), 1, 1); + } + /** Expand the stack and wait for animations to finish. */ private void expand() throws InterruptedException { mExpandedController.expandFromStack(mock(Runnable.class)); |