From ee947f2eccea205dad46f6486d55e9de2bcb4ea7 Mon Sep 17 00:00:00 2001 From: chaviw Date: Tue, 27 Mar 2018 16:49:27 -0700 Subject: Set snapTargetBeforeMinimized to middle target if position is negative There are cases where the last snapTarget position is negative. Specifically, it can be negative if the divider was moved up, making the last position negative off-screen. Instead save the middle SnapTarget, which is the default, so bounds aren't accidentally calculated with negative position. Fixes: 74440003 Test: Bug no longer occurs Test: Split screen with 3rd party launcher Test: ActivityManagerSplitScreenTests Change-Id: Id3261d6e31622a96f71ff80301dd9cc39599b7ec --- .../src/com/android/systemui/stackdivider/DividerView.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java index 1596d120c16f..3d8e0371871d 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java @@ -592,7 +592,16 @@ public class DividerView extends FrameLayout implements OnTouchListener, // Record last snap target the divider moved to if (mHomeStackResizable && !mIsInMinimizeInteraction) { - saveSnapTargetBeforeMinimized(snapTarget); + // The last snapTarget position can be negative when the last divider position was + // offscreen. In that case, save the middle (default) SnapTarget so calculating next + // position isn't negative. + final SnapTarget saveTarget; + if (snapTarget.position < 0) { + saveTarget = mSnapAlgorithm.getMiddleTarget(); + } else { + saveTarget = snapTarget; + } + saveSnapTargetBeforeMinimized(saveTarget); } }; Runnable notCancelledEndAction = () -> { -- cgit v1.2.3-59-g8ed1b