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

Commit 6d787e44 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Migrate BubbleController to DisplayImeController

This change is a no-op that migrates off of PinnedTaskController
and instead uses DisplayImeController to react to IME visibility
and position changes. The new API will allow us to hook into the IME
animation so that we can animate the expanded view together with
the IME.

One notable change here is that the new API reports the real IME height,
whereas the previous API sent the height of the area where the IME
overlaps with the window, in our case the Bubble window, excluding insets.
To keep changes here to a minimum, we adjust the height when it is set in
the positioner to account for insets.

Flag: EXEMPT bug fix
Bug: 379474417
Bug: 377329425
Test: manual
       - have some floating bubbles
       - drag stack to bottom of screen where IME would be
       - launch app and request IME
       - observe stack is repositioned above IME
       - collapse IME
       - observe stack slides to previous location
       - expand stack
       - request IME in the bubble
       - observe bubble window shrinks as the IME slides in
       - collapse IME
       - observe bubble window grows back to its previous size
Change-Id: Id7808de26cf8d99369e7ffa5fdfdf61dd213bdb4
parent cff526e4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -35,11 +35,11 @@ import com.android.internal.statusbar.IStatusBarService
import com.android.wm.shell.Flags
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.TestShellExecutor
import com.android.wm.shell.WindowManagerShellWrapper
import com.android.wm.shell.bubbles.Bubbles.SysuiProxy
import com.android.wm.shell.bubbles.properties.ProdBubbleProperties
import com.android.wm.shell.bubbles.storage.BubblePersistentRepository
import com.android.wm.shell.common.DisplayController
import com.android.wm.shell.common.DisplayImeController
import com.android.wm.shell.common.DisplayInsetsController
import com.android.wm.shell.common.FloatingContentCoordinator
import com.android.wm.shell.common.SyncTransactionQueue
@@ -268,7 +268,8 @@ class BubbleControllerBubbleBarTest {
            bubbleDataRepository,
            mock<IStatusBarService>(),
            mock<WindowManager>(),
            WindowManagerShellWrapper(mainExecutor),
            mock<DisplayInsetsController>(),
            mock<DisplayImeController>(),
            mock<UserManager>(),
            mock<LauncherApps>(),
            bubbleLogger,
+3 −2
Original line number Diff line number Diff line
@@ -36,10 +36,10 @@ import com.android.internal.statusbar.IStatusBarService
import com.android.launcher3.icons.BubbleIconFactory
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.TestShellExecutor
import com.android.wm.shell.WindowManagerShellWrapper
import com.android.wm.shell.bubbles.properties.BubbleProperties
import com.android.wm.shell.bubbles.storage.BubblePersistentRepository
import com.android.wm.shell.common.DisplayController
import com.android.wm.shell.common.DisplayImeController
import com.android.wm.shell.common.DisplayInsetsController
import com.android.wm.shell.common.FloatingContentCoordinator
import com.android.wm.shell.common.SyncTransactionQueue
@@ -141,7 +141,8 @@ class BubbleViewInfoTaskTest {
                bubbleDataRepository,
                mock<IStatusBarService>(),
                windowManager,
                WindowManagerShellWrapper(mainExecutor),
                mock<DisplayInsetsController>(),
                mock<DisplayImeController>(),
                mock<UserManager>(),
                mock<LauncherApps>(),
                bubbleLogger,
+3 −2
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import com.android.internal.statusbar.IStatusBarService
import com.android.wm.shell.R
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.TestShellExecutor
import com.android.wm.shell.WindowManagerShellWrapper
import com.android.wm.shell.bubbles.Bubble
import com.android.wm.shell.bubbles.BubbleController
import com.android.wm.shell.bubbles.BubbleData
@@ -53,6 +52,7 @@ import com.android.wm.shell.bubbles.animation.AnimatableScaleMatrix
import com.android.wm.shell.bubbles.properties.BubbleProperties
import com.android.wm.shell.bubbles.storage.BubblePersistentRepository
import com.android.wm.shell.common.DisplayController
import com.android.wm.shell.common.DisplayImeController
import com.android.wm.shell.common.DisplayInsetsController
import com.android.wm.shell.common.FloatingContentCoordinator
import com.android.wm.shell.common.SyncTransactionQueue
@@ -199,7 +199,8 @@ class BubbleBarLayerViewTest {
            bubbleDataRepository,
            mock<IStatusBarService>(),
            windowManager,
            WindowManagerShellWrapper(mainExecutor),
            mock<DisplayInsetsController>(),
            mock<DisplayImeController>(),
            mock<UserManager>(),
            mock<LauncherApps>(),
            bubbleLogger,
+54 −15
Original line number Diff line number Diff line
@@ -90,13 +90,15 @@ import com.android.launcher3.icons.BubbleIconFactory;
import com.android.wm.shell.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.bubbles.properties.BubbleProperties;
import com.android.wm.shell.bubbles.shortcut.BubbleShortcutHelper;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.ExternalInterfaceBinder;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ImeListener;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SingleInstanceRemoteListener;
@@ -106,7 +108,6 @@ import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.onehanded.OneHandedController;
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
import com.android.wm.shell.pip.PinnedStackListenerForwarder;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
@@ -182,7 +183,8 @@ public class BubbleController implements ConfigurationChangeListener,
    @Nullable private final BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
    private final FloatingContentCoordinator mFloatingContentCoordinator;
    private final BubbleDataRepository mDataRepository;
    private final WindowManagerShellWrapper mWindowManagerShellWrapper;
    private final DisplayInsetsController mDisplayInsetsController;
    private final DisplayImeController mDisplayImeController;
    private final UserManager mUserManager;
    private final LauncherApps mLauncherApps;
    private final IStatusBarService mBarService;
@@ -291,7 +293,8 @@ public class BubbleController implements ConfigurationChangeListener,
            BubbleDataRepository dataRepository,
            @Nullable IStatusBarService statusBarService,
            WindowManager windowManager,
            WindowManagerShellWrapper windowManagerShellWrapper,
            DisplayInsetsController displayInsetsController,
            DisplayImeController displayImeController,
            UserManager userManager,
            LauncherApps launcherApps,
            BubbleLogger bubbleLogger,
@@ -318,7 +321,8 @@ public class BubbleController implements ConfigurationChangeListener,
                ServiceManager.getService(Context.STATUS_BAR_SERVICE))
                : statusBarService;
        mWindowManager = windowManager;
        mWindowManagerShellWrapper = windowManagerShellWrapper;
        mDisplayInsetsController = displayInsetsController;
        mDisplayImeController = displayImeController;
        mUserManager = userManager;
        mFloatingContentCoordinator = floatingContentCoordinator;
        mDataRepository = dataRepository;
@@ -403,11 +407,15 @@ public class BubbleController implements ConfigurationChangeListener,
            mMainExecutor.execute(() -> removeBubble(bubble.getKey(), DISMISS_INVALID_INTENT));
        });

        try {
            mWindowManagerShellWrapper.addPinnedStackListener(new BubblesImeListener());
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        BubblesImeListener bubblesImeListener =
                new BubblesImeListener(mDisplayController, mContext.getDisplayId());
        // the insets controller is notified whenever the IME visibility changes whether the IME is
        // requested by a bubbled task or non-bubbled task. in the latter case, we need to update
        // the position of the stack to avoid overlapping with the IME.
        mDisplayInsetsController.addInsetsChangedListener(mContext.getDisplayId(),
                bubblesImeListener);
        // the ime controller is notified when the IME is requested only by a bubbled task.
        mDisplayImeController.addPositionProcessor(bubblesImeListener);

        mBubbleData.setCurrentUserId(mCurrentUserId);

@@ -2515,16 +2523,47 @@ public class BubbleController implements ConfigurationChangeListener,
        return contextForUser.getPackageManager();
    }

    /** PinnedStackListener that dispatches IME visibility updates to the stack. */
    //TODO(b/170442945): Better way to do this / insets listener?
    private class BubblesImeListener extends PinnedStackListenerForwarder.PinnedTaskListener {
    /** {@link ImeListener} that dispatches IME visibility updates to the stack. */
    private class BubblesImeListener extends ImeListener implements
            DisplayImeController.ImePositionProcessor {

        BubblesImeListener(DisplayController displayController, int displayId) {
            super(displayController, displayId);
        }

        @Override
        public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
            mBubblePositioner.setImeVisible(imeVisible, imeHeight);
        protected void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
            if (getDisplayId() != mContext.getDisplayId()) {
                return;
            }
            // the imeHeight here is actually the ime inset; it only includes the part of the ime
            // that overlaps with the Bubbles window. adjust it to include the bottom screen inset,
            // so we have the total height of the ime.
            int totalImeHeight = imeHeight + mBubblePositioner.getInsets().bottom;
            mBubblePositioner.setImeVisible(imeVisible, totalImeHeight);
            if (mStackView != null) {
                mStackView.setImeVisible(imeVisible);
            }
        }

        @Override
        public int onImeStartPositioning(int displayId, int hiddenTop, int shownTop,
                boolean showing, boolean isFloating, SurfaceControl.Transaction t) {
            if (mContext.getDisplayId() != displayId) {
                return IME_ANIMATION_DEFAULT;
            }

            if (showing) {
                mBubblePositioner.setImeVisible(true, hiddenTop - shownTop);
            } else {
                mBubblePositioner.setImeVisible(false, 0);
            }
            if (mStackView != null) {
                mStackView.setImeVisible(showing);
            }

            return IME_ANIMATION_DEFAULT;
        }
    }

    /**
+13 −2
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ public class BubblePositioner {
    private @Surface.Rotation int mRotation = Surface.ROTATION_0;
    private Insets mInsets;
    private boolean mImeVisible;
    /**
     * The height of the IME excluding the bottom inset. If the IME is 100 pixels tall and we have
     * 20 pixels bottom inset, the IME height is adjusted to 80 to represent the overlap with the
     * Bubbles window.
     */
    private int mImeHeight;
    private Rect mPositionRect;
    private int mDefaultMaxBubbles;
@@ -336,10 +341,16 @@ public class BubblePositioner {
        return mImeVisible;
    }

    /** Sets whether the IME is visible. **/
    /**
     * Sets whether the IME is visible and its height.
     *
     * @param visible whether the IME is visible
     * @param height the total height of the IME from the bottom of the physical screen
     **/
    public void setImeVisible(boolean visible, int height) {
        mImeVisible = visible;
        mImeHeight = height;
        // adjust the IME to account for the height as seen by the Bubbles window
        mImeHeight = visible ? Math.max(height - getInsets().bottom, 0) : 0;
    }

    private int getExpandedViewLargeScreenInsetFurthestEdge(boolean isOverflow) {
Loading