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

Commit b5ebf4be authored by Winson Chung's avatar Winson Chung
Browse files

Add single interface for SysUI to call into Shell

- Currently update configuration callbacks to use this interface
  so that individual features don't need to expose their own config
  change callbacks.  Will followup with moving keyguard/shell init
  /shell command handler.

Bug: 238217847
Test: atest WMShellUnitTests

Change-Id: Id526ed588de8cf962e821a3b9e1933a67f354d77
parent 28eb5d5f
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ 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.sysui.ConfigurationChangeListener;
import com.android.wm.shell.sysui.ShellController;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -119,7 +121,7 @@ import java.util.function.IntConsumer;
 *
 * The controller manages addition, removal, and visible state of bubbles on screen.
 */
public class BubbleController {
public class BubbleController implements ConfigurationChangeListener {

    private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES;

@@ -155,6 +157,7 @@ public class BubbleController {
    private final DisplayController mDisplayController;
    private final TaskViewTransitions mTaskViewTransitions;
    private final SyncTransactionQueue mSyncQueue;
    private final ShellController mShellController;

    // Used to post to main UI thread
    private final ShellExecutor mMainExecutor;
@@ -224,6 +227,7 @@ public class BubbleController {

  
    public BubbleController(Context context,
            ShellController shellController,
            BubbleData data,
            @Nullable BubbleStackView.SurfaceSynchronizer synchronizer,
            FloatingContentCoordinator floatingContentCoordinator,
@@ -246,6 +250,7 @@ public class BubbleController {
            TaskViewTransitions taskViewTransitions,
            SyncTransactionQueue syncQueue) {
        mContext = context;
        mShellController = shellController;
        mLauncherApps = launcherApps;
        mBarService = statusBarService == null
                ? IStatusBarService.Stub.asInterface(
@@ -414,6 +419,8 @@ public class BubbleController {
        // Clear out any persisted bubbles on disk that no longer have a valid user.
        List<UserInfo> users = mUserManager.getAliveUsers();
        mDataRepository.sanitizeBubbles(users);

        mShellController.addConfigurationChangeListener(this);
    }

    @VisibleForTesting
@@ -798,7 +805,8 @@ public class BubbleController {
        mSavedBubbleKeysPerUser.remove(userId);
    }

    private void updateForThemeChanges() {
    @Override
    public void onThemeChanged() {
        if (mStackView != null) {
            mStackView.onThemeChanged();
        }
@@ -818,7 +826,8 @@ public class BubbleController {
        }
    }

    private void onConfigChanged(Configuration newConfig) {
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (mBubblePositioner != null) {
            mBubblePositioner.update();
        }
@@ -1677,13 +1686,6 @@ public class BubbleController {
            });
        }

        @Override
        public void updateForThemeChanges() {
            mMainExecutor.execute(() -> {
                BubbleController.this.updateForThemeChanges();
            });
        }

        @Override
        public void expandStackAndSelectBubble(BubbleEntry entry) {
            mMainExecutor.execute(() -> {
@@ -1822,13 +1824,6 @@ public class BubbleController {
            });
        }

        @Override
        public void onConfigChanged(Configuration newConfig) {
            mMainExecutor.execute(() -> {
                BubbleController.this.onConfigChanged(newConfig);
            });
        }

        @Override
        public void onNotificationPanelExpandedChanged(boolean expanded) {
            mMainExecutor.execute(
+0 −10
Original line number Diff line number Diff line
@@ -107,9 +107,6 @@ public interface Bubbles {
    /** Tell the stack of bubbles to collapse. */
    void collapseStack();

    /** Tell the controller need update its UI to fit theme. */
    void updateForThemeChanges();

    /**
     * Request the stack expand if needed, then select the specified Bubble as current.
     * If no bubble exists for this entry, one is created.
@@ -255,13 +252,6 @@ public interface Bubbles {
     */
    void onUserRemoved(int removedUserId);

    /**
     * Called when config changed.
     *
     * @param newConfig the new config.
     */
    void onConfigChanged(Configuration newConfig);

    /** Description of current bubble state. */
    void dump(PrintWriter pw, String[] args);

+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.wm.shell.pip.tv.TvPipNotificationController;
import com.android.wm.shell.pip.tv.TvPipTaskOrganizer;
import com.android.wm.shell.pip.tv.TvPipTransition;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.transition.Transitions;

import java.util.Optional;
@@ -64,6 +65,7 @@ public abstract class TvPipModule {
    @Provides
    static Optional<Pip> providePip(
            Context context,
            ShellController shellController,
            TvPipBoundsState tvPipBoundsState,
            TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
            TvPipBoundsController tvPipBoundsController,
@@ -81,6 +83,7 @@ public abstract class TvPipModule {
        return Optional.of(
                TvPipController.create(
                        context,
                        shellController,
                        tvPipBoundsState,
                        tvPipBoundsAlgorithm,
                        tvPipBoundsController,
+29 −6
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ import com.android.wm.shell.startingsurface.StartingSurface;
import com.android.wm.shell.startingsurface.StartingWindowController;
import com.android.wm.shell.startingsurface.StartingWindowTypeAlgorithm;
import com.android.wm.shell.startingsurface.phone.PhoneStartingWindowTypeAlgorithm;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInterface;
import com.android.wm.shell.tasksurfacehelper.TaskSurfaceHelper;
import com.android.wm.shell.tasksurfacehelper.TaskSurfaceHelperController;
import com.android.wm.shell.transition.ShellTransitions;
@@ -159,10 +161,13 @@ public abstract class WMShellBaseModule {
    @WMSingleton
    @Provides
    static DragAndDropController provideDragAndDropController(Context context,
            DisplayController displayController, UiEventLogger uiEventLogger,
            IconProvider iconProvider, @ShellMainThread ShellExecutor mainExecutor) {
        return new DragAndDropController(context, displayController, uiEventLogger, iconProvider,
                mainExecutor);
            ShellController shellController,
            DisplayController displayController,
            UiEventLogger uiEventLogger,
            IconProvider iconProvider,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new DragAndDropController(context, shellController, displayController, uiEventLogger,
                iconProvider, mainExecutor);
    }

    @WMSingleton
@@ -377,9 +382,11 @@ public abstract class WMShellBaseModule {
    @WMSingleton
    @Provides
    static Optional<HideDisplayCutoutController> provideHideDisplayCutoutController(Context context,
            DisplayController displayController, @ShellMainThread ShellExecutor mainExecutor) {
            ShellController shellController, DisplayController displayController,
            @ShellMainThread ShellExecutor mainExecutor) {
        return Optional.ofNullable(
                HideDisplayCutoutController.create(context, displayController, mainExecutor));
                HideDisplayCutoutController.create(context, shellController, displayController,
                        mainExecutor));
    }

    //
@@ -621,6 +628,22 @@ public abstract class WMShellBaseModule {
                taskViewTransitions);
    }

    //
    // SysUI -> Shell interface
    //

    @WMSingleton
    @Provides
    static ShellInterface provideShellSysuiCallbacks(ShellController shellController) {
        return shellController.asShell();
    }

    @WMSingleton
    @Provides
    static ShellController provideShellController(@ShellMainThread ShellExecutor mainExecutor) {
        return new ShellController(mainExecutor);
    }

    //
    // Misc
    //
+10 −5
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import com.android.wm.shell.pip.phone.PipMotionHelper;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.recents.RecentTasksController;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.unfold.ShellUnfoldProgressProvider;
import com.android.wm.shell.unfold.UnfoldAnimationController;
@@ -134,6 +135,7 @@ public abstract class WMShellModule {
    @WMSingleton
    @Provides
    static BubbleController provideBubbleController(Context context,
            ShellController shellController,
            BubbleData data,
            FloatingContentCoordinator floatingContentCoordinator,
            IStatusBarService statusBarService,
@@ -153,7 +155,7 @@ public abstract class WMShellModule {
            @ShellBackgroundThread ShellExecutor bgExecutor,
            TaskViewTransitions taskViewTransitions,
            SyncTransactionQueue syncQueue) {
        return new BubbleController(context, data, null /* synchronizer */,
        return new BubbleController(context, shellController, data, null /* synchronizer */,
                floatingContentCoordinator,
                new BubbleDataRepository(context, launcherApps, mainExecutor),
                statusBarService, windowManager, windowManagerShellWrapper, userManager,
@@ -205,12 +207,14 @@ public abstract class WMShellModule {
    @Provides
    @DynamicOverride
    static OneHandedController provideOneHandedController(Context context,
            ShellController shellController,
            WindowManager windowManager, DisplayController displayController,
            DisplayLayout displayLayout, TaskStackListenerImpl taskStackListener,
            UiEventLogger uiEventLogger, InteractionJankMonitor jankMonitor,
            @ShellMainThread ShellExecutor mainExecutor, @ShellMainThread Handler mainHandler) {
        return OneHandedController.create(context, windowManager, displayController, displayLayout,
                taskStackListener, jankMonitor, uiEventLogger, mainExecutor, mainHandler);
        return OneHandedController.create(context, shellController, windowManager,
                displayController, displayLayout, taskStackListener, jankMonitor, uiEventLogger,
                mainExecutor, mainHandler);
    }

    //
@@ -242,7 +246,8 @@ public abstract class WMShellModule {

    @WMSingleton
    @Provides
    static Optional<Pip> providePip(Context context, DisplayController displayController,
    static Optional<Pip> providePip(Context context,
            ShellController shellController, DisplayController displayController,
            PipAppOpsListener pipAppOpsListener, PipBoundsAlgorithm pipBoundsAlgorithm,
            PipKeepClearAlgorithm pipKeepClearAlgorithm, PipBoundsState pipBoundsState,
            PipMotionHelper pipMotionHelper, PipMediaController pipMediaController,
@@ -254,7 +259,7 @@ public abstract class WMShellModule {
            PipParamsChangedForwarder pipParamsChangedForwarder,
            Optional<OneHandedController> oneHandedController,
            @ShellMainThread ShellExecutor mainExecutor) {
        return Optional.ofNullable(PipController.create(context, displayController,
        return Optional.ofNullable(PipController.create(context, shellController, displayController,
                pipAppOpsListener, pipBoundsAlgorithm, pipKeepClearAlgorithm, pipBoundsState,
                pipMotionHelper,
                pipMediaController, phonePipMenuController, pipTaskOrganizer, pipTransitionState,
Loading