From 7da9a386695b959dda7dac0ce62155b1cfb7514e Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 15 Sep 2022 12:49:29 -0700 Subject: [PATCH] No auto-pip animation if SysUI is not available The Launcher crash in the bug is a consequence of SysUI being stopped due to ANR. In this rare case, we should not start the auto-pip animation to further crash the launcher. Bug: 245947669 Test: N/A Change-Id: I2e99a82d4dccf302788fdb0752f70091fe5a18a3 --- quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java | 5 +++++ quickstep/src/com/android/quickstep/SystemUiProxy.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index a580b4247c..d97842895f 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1449,6 +1449,7 @@ public abstract class AbsSwipeUpHandler, } } + @Nullable private SwipePipToHomeAnimator createWindowAnimationToPip(HomeAnimationFactory homeAnimFactory, RemoteAnimationTargetCompat runningTaskTarget, float startProgress) { // Directly animate the app to PiP (picture-in-picture) mode @@ -1474,6 +1475,10 @@ public abstract class AbsSwipeUpHandler, runningTaskTarget.taskInfo.pictureInPictureParams, homeRotation, hotseatKeepClearArea); + if (destinationBounds == null) { + // No destination bounds returned from SystemUI, bail early. + return null; + } final Rect appBounds = new Rect(); final WindowConfiguration winConfig = taskInfo.configuration.windowConfiguration; // Adjust the appBounds for TaskBar by using the calculated window crop Rect diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 944e2f985d..24d2b9bb70 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -45,6 +45,7 @@ import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.window.IOnBackInvokedCallback; +import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; import com.android.internal.logging.InstanceId; @@ -481,6 +482,10 @@ public class SystemUiProxy implements ISystemUiProxy { mPipAnimationListener = listener; } + /** + * @return Destination bounds of auto-pip animation, {@code null} if the animation is not ready. + */ + @Nullable public Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo, PictureInPictureParams pictureInPictureParams, int launcherRotation, Rect hotseatKeepClearArea) {