From f8efb32379536695fcc3aa3041917eb4906d08dc Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 6 Jun 2024 15:32:33 -0700 Subject: [PATCH] Ensure starting position rect isn't empty in FloatingTaskView * on rotation taskbar re-inflates it's hotseat views. If we're already in split, then FloatingTaskView tries to do calculations on the view's position in the window, but has a reference to the old, pre-rotated view which is no longer in any window. * This sets startingPosition to be an empty rect, which is used to set LayoutParam values, which are used downstream in update() to calculate scale, and thus we end up dividing by 0. * TODO(b/345556328) figure out a better solution than checking for an empty rect Fixes: 342606096 Test: Repro steps don't cause crash Flag: EXEMPT bugfix Change-Id: Icb546a05d383d1997a92471fc1de3ffc37d06eca Merged-In: Icb546a05d383d1997a92471fc1de3ffc37d06eca (cherry picked from commit 410681a9556d334d827de74b30a566ad516dbb09) --- .../src/com/android/quickstep/views/FloatingTaskView.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java index 5eebc3e285..0ed0a2942e 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java @@ -189,7 +189,13 @@ public class FloatingTaskView extends FrameLayout { viewBounds, false /* ignoreTransform */, null /* recycle */, mStartingPosition); } - + // In some cases originalView is off-screen so we don't get a valid starting position + // ex. on rotation + // TODO(b/345556328) We shouldn't be animating if starting position of view isn't ready + if (mStartingPosition.isEmpty()) { + // Set to non empty for now so calculations in #update() don't break + mStartingPosition.set(0, 0, 1, 1); + } final BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams( Math.round(mStartingPosition.width()), Math.round(mStartingPosition.height()));