From b08f2d722238a919e46286d21d35d1bb72384cd8 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Mon, 10 Feb 2020 14:35:35 -0800 Subject: [PATCH] Indicate PiP animation type from Launcher to SysUI Also, need callback from SysUI to Launcher once the pip animation is started to keep back compatibility. Bug: 146594635 Test: manually Merged-In: I617a17fd5f6049d9f1d49f9f834623a2bb49f6ca Change-Id: I617a17fd5f6049d9f1d49f9f834623a2bb49f6ca (cherry picked from commit a1a91b0c5044b73433705584512794c408476d64) --- .../quickstep/FallbackSwipeHandler.java | 2 ++ .../quickstep/LauncherSwipeHandler.java | 2 ++ .../android/quickstep/views/RecentsView.java | 8 +++++ .../com/android/quickstep/SystemUiProxy.java | 33 +++++++++++++++++-- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java index 700feef790..cd001a128b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java @@ -332,6 +332,8 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler { if (!mTouchedHomeDuringTransition) { // If the user hasn't interacted with the screen during the transition, diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java index 345a147ca5..646d01fb8f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java @@ -699,6 +699,8 @@ public class LauncherSwipeHandler switch (mGestureState.getEndTarget()) { case HOME: mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT); + // Notify swipe-to-home (recents animation) is finished + SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished(); break; case RECENTS: mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 007493d0de..3046564a70 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -108,11 +108,13 @@ import com.android.quickstep.RecentsAnimationController; import com.android.quickstep.RecentsAnimationTargets; import com.android.quickstep.RecentsModel; import com.android.quickstep.RecentsModel.TaskVisualsChangeListener; +import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TaskThumbnailCache; import com.android.quickstep.TaskUtils; import com.android.quickstep.ViewUtils; import com.android.quickstep.util.AppWindowAnimationHelper; import com.android.quickstep.util.LayoutUtils; +import com.android.systemui.shared.recents.IPinnedStackAnimationListener; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -264,7 +266,10 @@ public abstract class RecentsView extends PagedView impl } }); } + }; + private final IPinnedStackAnimationListener mIPinnedStackAnimationListener = + new IPinnedStackAnimationListener.Stub() { @Override public void onPinnedStackAnimationStarted() { // Needed for activities that auto-enter PiP, which will not trigger a remote @@ -446,6 +451,8 @@ public abstract class RecentsView extends PagedView impl mSyncTransactionApplier = new SyncRtSurfaceTransactionApplierCompat(this); RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this); mIdp.addOnChangeListener(this); + SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener( + mIPinnedStackAnimationListener); } @Override @@ -458,6 +465,7 @@ public abstract class RecentsView extends PagedView impl mSyncTransactionApplier = null; RecentsModel.INSTANCE.get(getContext()).removeThumbnailChangeListener(this); mIdp.removeOnChangeListener(this); + SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null); } @Override diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 458d6a9553..eb60601c44 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -29,6 +29,7 @@ import android.util.Log; import android.view.MotionEvent; import com.android.launcher3.util.MainThreadInitializedObject; +import com.android.systemui.shared.recents.IPinnedStackAnimationListener; import com.android.systemui.shared.recents.ISystemUiProxy; /** @@ -268,9 +269,7 @@ public class SystemUiProxy implements ISystemUiProxy { } } - /** - * See SharedApiCompat#setShelfHeight() - */ + @Override public void setShelfHeight(boolean visible, int shelfHeight) { boolean changed = visible != mLastShelfVisible || shelfHeight != mLastShelfHeight; if (mSystemUiProxy != null && changed) { @@ -306,4 +305,32 @@ public class SystemUiProxy implements ISystemUiProxy { } } } + + /** + * Notifies that swipe-to-home action is finished. + */ + @Override + public void notifySwipeToHomeFinished() { + if (mSystemUiProxy != null) { + try { + mSystemUiProxy.notifySwipeToHomeFinished(); + } catch (RemoteException e) { + Log.w(TAG, "Failed call setPinnedStackAnimationType", e); + } + } + } + + /** + * Sets listener to get pinned stack animation callbacks. + */ + @Override + public void setPinnedStackAnimationListener(IPinnedStackAnimationListener listener) { + if (mSystemUiProxy != null) { + try { + mSystemUiProxy.setPinnedStackAnimationListener(listener); + } catch (RemoteException e) { + Log.w(TAG, "Failed call setPinnedStackAnimationListener", e); + } + } + } }