From 000ce66626fe7de4e396b02d21de41d0ca0d5ecf Mon Sep 17 00:00:00 2001 From: Bill Lin Date: Mon, 14 Sep 2020 18:11:34 +0800 Subject: [PATCH] Use consumer to dispatch signal between Launcher & SysUI OPS Pip(8-2/N) Since IPinnedStackAnimationListener.aidl is not able to move shell lib Add a proxy in OPS dispatching callback to Launcher when PIP animation started. Bug: 161118569 Test: make SystemUI Test: make ArcSystemUI Test: lunch aosp_tv_arm-userdebug & make Test: atest WindowManagerShellTests Test: atest SystemUITests Test: adb shell input keyevent 171(KEYCODE_WINDOW) Test: manual test Pip demo AP Test: adb shell dumpsys activity service com.android.systemui Change-Id: I750c4f773c99c8e9230d11e710e1cc3796577df2 --- .../src/com/android/systemui/pip/Pip.java | 6 +++--- .../systemui/pip/phone/PipController.java | 16 ++++++-------- .../recents/OverviewProxyService.java | 21 ++++++++++++++++--- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/Pip.java b/packages/SystemUI/src/com/android/systemui/pip/Pip.java index e3c00e20781b0..2b115508e525d 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/Pip.java +++ b/packages/SystemUI/src/com/android/systemui/pip/Pip.java @@ -22,9 +22,9 @@ import android.media.session.MediaController; import com.android.systemui.pip.phone.PipTouchHandler; import com.android.systemui.pip.tv.PipController; -import com.android.systemui.shared.recents.IPinnedStackAnimationListener; import java.io.PrintWriter; +import java.util.function.Consumer; /** * Interface to engage picture in picture feature. @@ -200,9 +200,9 @@ public interface Pip { /** * Registers the pinned stack animation listener. * - * @param listener The listener of pinned stack animation. + * @param callback The callback of pinned stack animation. */ - default void setPinnedStackAnimationListener(IPinnedStackAnimationListener listener) { + default void setPinnedStackAnimationListener(Consumer callback) { } /** diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java index 487ca9a1f7ae2..625304371d5bb 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java @@ -40,13 +40,13 @@ import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.pip.Pip; import com.android.systemui.pip.PipBoundsHandler; import com.android.systemui.pip.PipTaskOrganizer; -import com.android.systemui.shared.recents.IPinnedStackAnimationListener; import com.android.systemui.shared.system.PinnedStackListenerForwarder; import com.android.systemui.wmshell.WindowManagerShellWrapper; import com.android.wm.shell.common.DisplayChangeController; import com.android.wm.shell.common.DisplayController; import java.io.PrintWriter; +import java.util.function.Consumer; /** * Manages the picture-in-picture (PIP) UI and states for Phones. @@ -68,7 +68,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac private PipBoundsHandler mPipBoundsHandler; private PipMediaController mMediaController; private PipTouchHandler mTouchHandler; - private IPinnedStackAnimationListener mPinnedStackAnimationRecentsListener; + private Consumer mPinnedStackAnimationRecentsCallback; private WindowManagerShellWrapper mWindowManagerShellWrapper; private boolean mIsInFixedRotation; @@ -371,8 +371,8 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac } @Override - public void setPinnedStackAnimationListener(IPinnedStackAnimationListener listener) { - mHandler.post(() -> mPinnedStackAnimationRecentsListener = listener); + public void setPinnedStackAnimationListener(Consumer callback) { + mHandler.post(() -> mPinnedStackAnimationRecentsCallback = callback); } @Override @@ -384,12 +384,8 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac } // Disable touches while the animation is running mTouchHandler.setTouchEnabled(false); - if (mPinnedStackAnimationRecentsListener != null) { - try { - mPinnedStackAnimationRecentsListener.onPinnedStackAnimationStarted(); - } catch (RemoteException e) { - Log.e(TAG, "Failed to callback recents", e); - } + if (mPinnedStackAnimationRecentsCallback != null) { + mPinnedStackAnimationRecentsCallback.accept(true); } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index ed8da7c3d80bb..aa435165d3f31 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -102,6 +102,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.function.BiConsumer; +import java.util.function.Consumer; import javax.inject.Inject; @@ -142,6 +143,7 @@ public class OverviewProxyService extends CurrentUserTracker implements private Region mActiveNavBarRegion; + private IPinnedStackAnimationListener mIPinnedStackAnimationListener; private IOverviewProxy mOverviewProxy; private int mConnectionBackoffAttempts; private boolean mBound; @@ -158,7 +160,6 @@ public class OverviewProxyService extends CurrentUserTracker implements @VisibleForTesting public ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() { - @Override public void startScreenPinning(int taskId) { if (!verifyCaller("startScreenPinning")) { @@ -438,10 +439,11 @@ public class OverviewProxyService extends CurrentUserTracker implements + mHasPipFeature); return; } + mIPinnedStackAnimationListener = listener; long token = Binder.clearCallingIdentity(); try { mPipOptional.ifPresent( - pip -> pip.setPinnedStackAnimationListener(listener)); + pip -> pip.setPinnedStackAnimationListener(mPinnedStackAnimationCallback)); } finally { Binder.restoreCallingIdentity(token); } @@ -607,6 +609,8 @@ public class OverviewProxyService extends CurrentUserTracker implements private final StatusBarWindowCallback mStatusBarWindowCallback = this::onStatusBarStateChanged; private final BiConsumer mSplitScreenBoundsChangeListener = this::notifySplitScreenBoundsChanged; + private final Consumer mPinnedStackAnimationCallback = + this::notifyPinnedStackAnimationStarted; // This is the death handler for the binder from the launcher service private final IBinder.DeathRecipient mOverviewServiceDeathRcpt @@ -736,6 +740,17 @@ public class OverviewProxyService extends CurrentUserTracker implements } } + private void notifyPinnedStackAnimationStarted(Boolean isAnimationStarted) { + if (mIPinnedStackAnimationListener == null) { + return; + } + try { + mIPinnedStackAnimationListener.onPinnedStackAnimationStarted(); + } catch (RemoteException e) { + Log.e(TAG_OPS, "Failed to call onPinnedStackAnimationStarted()", e); + } + } + private void onStatusBarStateChanged(boolean keyguardShowing, boolean keyguardOccluded, boolean bouncerShowing) { mSysUiState.setFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING, @@ -766,7 +781,7 @@ public class OverviewProxyService extends CurrentUserTracker implements public void cleanupAfterDeath() { if (mInputFocusTransferStarted) { - mHandler.post(()-> { + mHandler.post(() -> { mStatusBarOptionalLazy.ifPresent(statusBarLazy -> { mInputFocusTransferStarted = false; statusBarLazy.get().onInputFocusTransfer(false, true /* cancel */,