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

Commit f40f8eeb authored by Jerry Chang's avatar Jerry Chang
Browse files

Migrate splitscreen to WM shell lib (3/n)

Extracts interface of split screen feature to expose APIs for
SysUISingleton scope to use.

Bug: 161116823
Test: atest SystemUITests
Test: atest SystemUIGoogleTests
Test: atest CarSystemUITests
Test: manual verified split screen behavior
Change-Id: Ic5ace86a2205cde53c074d1c0b0bf8a40e0a2968
parent c2c7ed6a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.shared.plugins.PluginManagerImpl;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.stackdivider.SplitScreenController;
import com.android.systemui.stackdivider.SplitScreen;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.phone.AutoHideController;
@@ -193,7 +193,7 @@ public class DependencyProvider {
            SysUiState sysUiFlagsContainer,
            BroadcastDispatcher broadcastDispatcher,
            CommandQueue commandQueue,
            Optional<SplitScreenController> splitScreenControllerOptional,
            Optional<SplitScreen> splitScreenOptional,
            Optional<Recents> recentsOptional,
            Lazy<StatusBar> statusBarLazy,
            ShadeController shadeController,
@@ -215,7 +215,7 @@ public class DependencyProvider {
                sysUiFlagsContainer,
                broadcastDispatcher,
                commandQueue,
                splitScreenControllerOptional,
                splitScreenOptional,
                recentsOptional,
                statusBarLazy,
                shadeController,
+8 −8
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.stackdivider.SplitScreenController;
import com.android.systemui.stackdivider.SplitScreen;
import com.android.systemui.statusbar.AutoHideUiElement;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue.Callbacks;
@@ -179,7 +179,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
    private final NavigationModeController mNavigationModeController;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final CommandQueue mCommandQueue;
    private final Optional<SplitScreenController> mSplitScreenControllerOptional;
    private final Optional<SplitScreen> mSplitScreenOptional;
    private final Optional<Recents> mRecentsOptional;
    private final SystemActions mSystemActions;
    private final Handler mHandler;
@@ -406,7 +406,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
            SysUiState sysUiFlagsContainer,
            BroadcastDispatcher broadcastDispatcher,
            CommandQueue commandQueue,
            Optional<SplitScreenController> splitScreenControllerOptional,
            Optional<SplitScreen> splitScreenOptional,
            Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy,
            ShadeController shadeController,
            NotificationRemoteInputManager notificationRemoteInputManager,
@@ -430,7 +430,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        mNavBarMode = navigationModeController.addListener(this);
        mBroadcastDispatcher = broadcastDispatcher;
        mCommandQueue = commandQueue;
        mSplitScreenControllerOptional = splitScreenControllerOptional;
        mSplitScreenOptional = splitScreenOptional;
        mRecentsOptional = recentsOptional;
        mSystemActions = systemActions;
        mHandler = mainHandler;
@@ -528,7 +528,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        }
        mNavigationBarView.setNavigationIconHints(mNavigationIconHints);
        mNavigationBarView.setWindowVisible(isNavBarWindowVisible());
        mSplitScreenControllerOptional.ifPresent(mNavigationBarView::registerDockedListener);
        mSplitScreenOptional.ifPresent(mNavigationBarView::registerDockedListener);

        prepareNavigationBarView();
        checkNavBarModes();
@@ -691,8 +691,8 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
            return;
        }

        if (mStartingQuickSwitchRotation == -1 || mSplitScreenControllerOptional
                .map(SplitScreenController::isDividerVisible).orElse(false)) {
        if (mStartingQuickSwitchRotation == -1 || mSplitScreenOptional
                .map(SplitScreen::isDividerVisible).orElse(false)) {
            // Hide the secondary home handle if we are in multiwindow since apps in multiwindow
            // aren't allowed to set the display orientation
            resetSecondaryHandle();
@@ -1251,7 +1251,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
                || ActivityManager.isLowRamDeviceStatic()
                // If we are connected to the overview service, then disable the recents button
                || mOverviewProxyService.getProxy() != null
                || !mSplitScreenControllerOptional.map(splitScreen ->
                || !mSplitScreenOptional.map(splitScreen ->
                splitScreen.getDividerView().getSnapAlgorithm().isSplitScreenFeasible())
                .orElse(false)) {
            return false;
+5 −5
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.stackdivider.SplitScreenController;
import com.android.systemui.stackdivider.SplitScreen;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue.Callbacks;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
@@ -96,7 +96,7 @@ public class NavigationBarController implements Callbacks,
    private final SysUiState mSysUiFlagsContainer;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final CommandQueue mCommandQueue;
    private final Optional<SplitScreenController> mSplitScreenControllerOptional;
    private final Optional<SplitScreen> mSplitScreenOptional;
    private final Optional<Recents> mRecentsOptional;
    private final Lazy<StatusBar> mStatusBarLazy;
    private final ShadeController mShadeController;
@@ -130,7 +130,7 @@ public class NavigationBarController implements Callbacks,
            SysUiState sysUiFlagsContainer,
            BroadcastDispatcher broadcastDispatcher,
            CommandQueue commandQueue,
            Optional<SplitScreenController> splitScreenControllerOptional,
            Optional<SplitScreen> splitScreenOptional,
            Optional<Recents> recentsOptional,
            Lazy<StatusBar> statusBarLazy,
            ShadeController shadeController,
@@ -152,7 +152,7 @@ public class NavigationBarController implements Callbacks,
        mSysUiFlagsContainer = sysUiFlagsContainer;
        mBroadcastDispatcher = broadcastDispatcher;
        mCommandQueue = commandQueue;
        mSplitScreenControllerOptional = splitScreenControllerOptional;
        mSplitScreenOptional = splitScreenOptional;
        mRecentsOptional = recentsOptional;
        mStatusBarLazy = statusBarLazy;
        mShadeController = shadeController;
@@ -278,7 +278,7 @@ public class NavigationBarController implements Callbacks,
                mSysUiFlagsContainer,
                mBroadcastDispatcher,
                mCommandQueue,
                mSplitScreenControllerOptional,
                mSplitScreenOptional,
                mRecentsOptional,
                mStatusBarLazy,
                mShadeController,
+3 −3
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.stackdivider.SplitScreenController;
import com.android.systemui.stackdivider.SplitScreen;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.LightBarTransitionsController;
@@ -1296,8 +1296,8 @@ public class NavigationBarView extends FrameLayout implements
        return super.onApplyWindowInsets(insets);
    }

    void registerDockedListener(SplitScreenController splitScreenController) {
        splitScreenController.registerInSplitScreenListener(mDockedListener);
    void registerDockedListener(SplitScreen splitScreen) {
        splitScreen.registerInSplitScreenListener(mDockedListener);
    }

    private static void dumpButton(PrintWriter pw, String caption, ButtonDispatcher button) {
+10 −11
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ import android.window.WindowOrganizer;
import com.android.internal.os.SomeArgs;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.pip.phone.PipUpdateThread;
import com.android.systemui.stackdivider.SplitScreenController;
import com.android.systemui.stackdivider.SplitScreen;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
@@ -105,7 +105,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
    private final int mEnterExitAnimationDuration;
    private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
    private final Map<IBinder, Configuration> mInitialState = new HashMap<>();
    private final Optional<SplitScreenController> mSplitScreenControllerOptional;
    private final Optional<SplitScreen> mSplitScreenOptional;
    protected final ShellTaskOrganizer mTaskOrganizer;

    // These callbacks are called on the update thread
@@ -208,7 +208,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize

    public PipTaskOrganizer(Context context, @NonNull PipBoundsHandler boundsHandler,
            @NonNull PipSurfaceTransactionHelper surfaceTransactionHelper,
            Optional<SplitScreenController> splitScreenControllerOptional,
            Optional<SplitScreen> splitScreenOptional,
            @NonNull DisplayController displayController,
            @NonNull PipUiEventLogger pipUiEventLogger,
            @NonNull ShellTaskOrganizer shellTaskOrganizer) {
@@ -221,7 +221,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
        mPipAnimationController = new PipAnimationController(mSurfaceTransactionHelper);
        mPipUiEventLoggerLogger = pipUiEventLogger;
        mSurfaceControlTransactionFactory = SurfaceControl.Transaction::new;
        mSplitScreenControllerOptional = splitScreenControllerOptional;
        mSplitScreenOptional = splitScreenOptional;
        mTaskOrganizer = shellTaskOrganizer;
        mTaskOrganizer.addListener(this, WINDOWING_MODE_PINNED);
        displayController.addDisplayWindowListener(this);
@@ -337,7 +337,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
        wct.setWindowingMode(mToken, getOutPipWindowingMode());
        // Simply reset the activity mode set prior to the animation running.
        wct.setActivityWindowingMode(mToken, WINDOWING_MODE_UNDEFINED);
        mSplitScreenControllerOptional.ifPresent(splitScreen -> {
        mSplitScreenOptional.ifPresent(splitScreen -> {
            if (direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN) {
                wct.reparent(mToken, splitScreen.getSecondaryRoot(), true /* onTop */);
            }
@@ -937,26 +937,25 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
    }

    /**
     * Sync with {@link SplitScreenController} on destination bounds if PiP is going to split
     * screen.
     * Sync with {@link SplitScreen} on destination bounds if PiP is going to split screen.
     *
     * @param destinationBoundsOut contain the updated destination bounds if applicable
     * @return {@code true} if destinationBounds is altered for split screen
     */
    private boolean syncWithSplitScreenBounds(Rect destinationBoundsOut) {
        if (!mSplitScreenControllerOptional.isPresent()) {
        if (!mSplitScreenOptional.isPresent()) {
            return false;
        }

        SplitScreenController splitScreenController = mSplitScreenControllerOptional.get();
        if (!splitScreenController.isDividerVisible()) {
        SplitScreen splitScreen = mSplitScreenOptional.get();
        if (!splitScreen.isDividerVisible()) {
            // fail early if system is not in split screen mode
            return false;
        }

        // PiP window will go to split-secondary mode instead of fullscreen, populates the
        // split screen bounds here.
        destinationBoundsOut.set(splitScreenController.getDividerView()
        destinationBoundsOut.set(splitScreen.getDividerView()
                .getNonMinimizedSplitScreenSecondaryBounds());
        return true;
    }
Loading