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

Commit 929d4f72 authored by Winson Chung's avatar Winson Chung
Browse files

Add additional guards to ensure input consumer is re-registered.

- Also removing some old code related to menu start, which is already
  called when the menu is shown.

Bug: 34240533
Test: Open PIP, ensure that you can drag it after the menu fades out.
Change-Id: Ia16b405f8507f5c3d81fdf4f1049ce9359298672
parent d26d2af7
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ import android.view.IPinnedStackListener;
import android.view.IWindowManager;
import android.view.WindowManagerGlobal;

import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;

/**
 * Manages the picture-in-picture (PIP) UI and states for Phones.
 */
@@ -48,6 +51,26 @@ public class PipManager {
    private PipMenuActivityController mMenuController;
    private PipTouchHandler mTouchHandler;

    /**
     * Handler for system task stack changes.
     */
    TaskStackListener mTaskStackListener = new TaskStackListener() {
        @Override
        public void onActivityPinned() {
            mTouchHandler.onActivityPinned();
        }

        @Override
        public void onPinnedStackAnimationEnded() {
            // TODO(winsonc): Disable touch interaction with the PiP until the animation ends
        }

        @Override
        public void onPinnedActivityRestartAttempt() {
            // TODO(winsonc): Hide the menu and expand the PiP
        }
    };

    /**
     * Handler for messages from the PIP controller.
     */
@@ -102,6 +125,7 @@ public class PipManager {
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to register pinned stack listener", e);
        }
        SystemServicesProxy.getInstance(mContext).registerTaskStackListener(mTaskStackListener);

        mMenuController = new PipMenuActivityController(context, mActivityManager, mWindowManager);
        mTouchHandler = new PipTouchHandler(context, mMenuController, mActivityManager,
+0 −7
Original line number Diff line number Diff line
@@ -136,13 +136,6 @@ public class PipMenuActivity extends Activity {
        showMenu();
    }

    @Override
    protected void onStart() {
        super.onStart();
        notifyMenuVisibility(true);
        repostDelayedFinish(INITIAL_DISMISS_DELAY);
    }

    @Override
    public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
        if (!isInPictureInPictureMode) {
+8 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ public class PipMenuActivityController {
                }
                case MESSAGE_EXPAND_PIP: {
                    mListeners.forEach(l -> l.onPipExpand());
                    // Preemptively mark the menu as invisible once we expand the PiP
                    mListeners.forEach(l -> l.onPipMenuVisibilityChanged(false));
                    break;
                }
                case MESSAGE_MINIMIZE_PIP: {
@@ -83,10 +85,16 @@ public class PipMenuActivityController {
                }
                case MESSAGE_DISMISS_PIP: {
                    mListeners.forEach(l -> l.onPipDismiss());
                    // Preemptively mark the menu as invisible once we dismiss the PiP
                    mListeners.forEach(l -> l.onPipMenuVisibilityChanged(false));
                    break;
                }
                case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
                    mToActivityMessenger = msg.replyTo;
                    // Mark the menu as invisible once the activity finishes as well
                    if (mToActivityMessenger == null) {
                        mListeners.forEach(l -> l.onPipMenuVisibilityChanged(false));
                    }
                    break;
                }
            }
+11 −0
Original line number Diff line number Diff line
@@ -212,6 +212,17 @@ public class PipTouchHandler implements TunerService.Tunable {
        }
    }

    public void onActivityPinned() {
        // Reset some states once we are pinned
        if (mIsTappingThrough) {
            mIsTappingThrough = false;
            registerInputConsumer();
        }
        if (mIsMinimized) {
            setMinimizedState(false);
        }
    }

    public void onConfigurationChanged() {
        mSnapAlgorithm.onConfigurationChanged();
        updateBoundedPinnedStackBounds(false /* updatePinnedStackBounds */);