diff options
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 e3c00e20781b..2b115508e525 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<Boolean> 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 487ca9a1f7ae..625304371d5b 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<Boolean> 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<Boolean> 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 ed8da7c3d80b..aa435165d3f3 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<Rect, Rect> mSplitScreenBoundsChangeListener = this::notifySplitScreenBoundsChanged; + private final Consumer<Boolean> 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 */, |