Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 000ce666 authored by Bill Lin's avatar Bill Lin
Browse files

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
parent 3bd60e6c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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) {
    }

    /**
+6 −10
Original line number Diff line number Diff line
@@ -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);
        }
    }

+18 −3
Original line number Diff line number Diff line
@@ -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,