From 9d1514b4f217c40b607b1ddfd0723e79d4e7d1f2 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Wed, 28 Apr 2021 18:03:04 -0700 Subject: [PATCH] Get PiP round corner radius from WMShell Fixed also the issue that when SystemUiProxy#setPinnedStackAnimationListener is called, SystemUiProxy#mPiP may not have been initialized, defer the set/register action in SystemUiProxy#setProxy if applicable. Video: http://recall/-/aaaaaabFQoRHlzixHdtY/dmUy8qBEMxHShFcFKB3cT3 Bug: 171721389 Test: make sure autoEnterPip has round corner support, see video Change-Id: I38866bbc77bc2fa94f0197bb90c02e786198443e --- .../android/quickstep/AbsSwipeUpHandler.java | 1 + .../com/android/quickstep/SystemUiProxy.java | 26 +++++++++++++++++++ .../util/SwipePipToHomeAnimator.java | 4 ++- .../android/quickstep/views/RecentsView.java | 24 ++++++++++++++--- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index fe1090878a..25be30fc4b 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1211,6 +1211,7 @@ public abstract class AbsSwipeUpHandler, TaskInfoCompat.getWindowConfigurationBounds(taskInfo), startBounds, destinationBounds, + mRecentsView.getPipCornerRadius(), mRecentsView); // We would assume home and app window always in the same rotation While homeRotation // is not ROTATION_0 (which implies the rotation is turned on in launcher settings). diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index f6018d1c2f..39d8888c72 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -68,6 +68,12 @@ public class SystemUiProxy implements ISystemUiProxy, MAIN_EXECUTOR.execute(() -> clearProxy()); }; + // Save the listeners passed into the proxy since when set/register these listeners, + // setProxy may not have been called, eg. OverviewProxyService is not connected yet. + private IPipAnimationListener mPendingPipAnimationListener; + private ISplitScreenListener mPendingSplitScreenListener; + private IStartingWindowListener mPendingStartingWindowListener; + // Used to dedupe calls to SystemUI private int mLastShelfHeight; private boolean mLastShelfVisible; @@ -116,6 +122,19 @@ public class SystemUiProxy implements ISystemUiProxy, mShellTransitions = shellTransitions; mStartingWindow = startingWindow; linkToDeath(); + // re-attach the listeners once missing due to setProxy has not been initialized yet. + if (mPendingPipAnimationListener != null && mPip != null) { + setPinnedStackAnimationListener(mPendingPipAnimationListener); + mPendingPipAnimationListener = null; + } + if (mPendingSplitScreenListener != null && mSplitScreen != null) { + registerSplitScreenListener(mPendingSplitScreenListener); + mPendingSplitScreenListener = null; + } + if (mPendingStartingWindowListener != null && mStartingWindow != null) { + setStartingWindowListener(mPendingStartingWindowListener); + mPendingStartingWindowListener = null; + } } public void clearProxy() { @@ -390,6 +409,8 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call setPinnedStackAnimationListener", e); } + } else { + mPendingPipAnimationListener = listener; } } @@ -427,6 +448,8 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call registerSplitScreenListener"); } + } else { + mPendingSplitScreenListener = listener; } } @@ -438,6 +461,7 @@ public class SystemUiProxy implements ISystemUiProxy, Log.w(TAG, "Failed call unregisterSplitScreenListener"); } } + mPendingSplitScreenListener = null; } public void setSideStageVisibility(boolean visible) { @@ -590,6 +614,8 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call setStartingWindowListener", e); } + } else { + mPendingStartingWindowListener = listener; } } } diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java index a1240e0f42..b5570a7445 100644 --- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java +++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java @@ -89,6 +89,7 @@ public class SwipePipToHomeAnimator extends ValueAnimator { * different from the appBounds if user has swiped a certain distance and * Launcher has performed transform on the leash. * @param destinationBounds Bounds of the destination this animator ends to + * @param cornerRadius Corner radius in pixel value for PiP window */ public SwipePipToHomeAnimator(int taskId, @NonNull ComponentName componentName, @@ -97,6 +98,7 @@ public class SwipePipToHomeAnimator extends ValueAnimator { @NonNull Rect appBounds, @NonNull Rect startBounds, @NonNull Rect destinationBounds, + int cornerRadius, @NonNull View view) { mTaskId = taskId; mComponentName = componentName; @@ -106,7 +108,7 @@ public class SwipePipToHomeAnimator extends ValueAnimator { mDestinationBounds.set(destinationBounds); mDestinationBoundsTransformed.set(mDestinationBounds); mDestinationBoundsAnimation.set(mDestinationBounds); - mSurfaceTransactionHelper = new PipSurfaceTransactionHelper(); + mSurfaceTransactionHelper = new PipSurfaceTransactionHelper(cornerRadius); if (sourceRectHint == null) { mSourceHintRectInsets = null; diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index a04b886bd4..2633ce65a5 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -469,6 +469,7 @@ public abstract class RecentsView extends IPipAnimationListener.Stub { private T mActivity; + private RecentsView mRecentsView; - public void setActivity(T activity) { + public void setActivityAndRecentsView(T activity, RecentsView recentsView) { mActivity = activity; + mRecentsView = recentsView; } @Override @@ -3748,5 +3759,12 @@ public abstract class RecentsView