Merge "Separate BubblesController construction from initialization" into sc-dev

This commit is contained in:
Winson Chung
2021-03-30 23:45:11 +00:00
committed by Android (Google) Code Review
5 changed files with 37 additions and 35 deletions

View File

@@ -19,6 +19,7 @@ package com.android.wm.shell;
import static com.android.wm.shell.ShellTaskOrganizer.TASK_LISTENER_TYPE_FULLSCREEN;
import com.android.wm.shell.apppairs.AppPairsController;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.annotations.ExternalThread;
@@ -40,6 +41,7 @@ public class ShellInitImpl {
private final DisplayImeController mDisplayImeController;
private final DragAndDropController mDragAndDropController;
private final ShellTaskOrganizer mShellTaskOrganizer;
private final Optional<BubbleController> mBubblesOptional;
private final Optional<LegacySplitScreenController> mLegacySplitScreenOptional;
private final Optional<SplitScreenController> mSplitScreenOptional;
private final Optional<AppPairsController> mAppPairsOptional;
@@ -54,6 +56,7 @@ public class ShellInitImpl {
public ShellInitImpl(DisplayImeController displayImeController,
DragAndDropController dragAndDropController,
ShellTaskOrganizer shellTaskOrganizer,
Optional<BubbleController> bubblesOptional,
Optional<LegacySplitScreenController> legacySplitScreenOptional,
Optional<SplitScreenController> splitScreenOptional,
Optional<AppPairsController> appPairsOptional,
@@ -65,6 +68,7 @@ public class ShellInitImpl {
mDisplayImeController = displayImeController;
mDragAndDropController = dragAndDropController;
mShellTaskOrganizer = shellTaskOrganizer;
mBubblesOptional = bubblesOptional;
mLegacySplitScreenOptional = legacySplitScreenOptional;
mSplitScreenOptional = splitScreenOptional;
mAppPairsOptional = appPairsOptional;
@@ -91,6 +95,7 @@ public class ShellInitImpl {
mAppPairsOptional.ifPresent(AppPairsController::onOrganizerRegistered);
mSplitScreenOptional.ifPresent(SplitScreenController::onOrganizerRegistered);
mBubblesOptional.ifPresent(BubbleController::initialize);
// Bind the splitscreen impl to the drag drop controller
mDragAndDropController.initialize(mSplitScreenOptional);

View File

@@ -120,6 +120,16 @@ public class BubbleController {
@Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
private final FloatingContentCoordinator mFloatingContentCoordinator;
private final BubbleDataRepository mDataRepository;
private final WindowManagerShellWrapper mWindowManagerShellWrapper;
private final LauncherApps mLauncherApps;
private final IStatusBarService mBarService;
private final WindowManager mWindowManager;
private final ShellTaskOrganizer mTaskOrganizer;
// Used to post to main UI thread
private final ShellExecutor mMainExecutor;
private final Handler mMainHandler;
private BubbleLogger mLogger;
private BubbleData mBubbleData;
private View mBubbleScrim;
@@ -148,12 +158,6 @@ public class BubbleController {
*/
@Nullable private BubbleEntry mNotifEntryToExpandOnShadeUnlock;
private IStatusBarService mBarService;
private WindowManager mWindowManager;
// Used to post to main UI thread
private final ShellExecutor mMainExecutor;
/** LayoutParams used to add the BubbleStackView to the window manager. */
private WindowManager.LayoutParams mWmLayoutParams;
/** Whether or not the BubbleStackView has been added to the WindowManager. */
@@ -177,15 +181,6 @@ public class BubbleController {
private boolean mInflateSynchronously;
private ShellTaskOrganizer mTaskOrganizer;
/**
* Whether the IME is visible, as reported by the BubbleStackView. If it is, we'll make the
* Bubbles window NOT_FOCUSABLE so that touches on the Bubbles UI doesn't steal focus from the
* ActivityView and hide the IME.
*/
private boolean mImeVisible = false;
/** true when user is in status bar unlock shade. */
private boolean mIsStatusBarShade = true;
@@ -231,13 +226,28 @@ public class BubbleController {
ShellExecutor mainExecutor,
Handler mainHandler) {
mContext = context;
mLauncherApps = launcherApps;
mBarService = statusBarService == null
? IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE))
: statusBarService;
mWindowManager = windowManager;
mWindowManagerShellWrapper = windowManagerShellWrapper;
mFloatingContentCoordinator = floatingContentCoordinator;
mDataRepository = dataRepository;
mLogger = bubbleLogger;
mMainExecutor = mainExecutor;
mMainHandler = mainHandler;
mTaskOrganizer = organizer;
mSurfaceSynchronizer = synchronizer;
mCurrentUserId = ActivityManager.getCurrentUser();
mBubblePositioner = positioner;
mBubbleData = data;
mSavedBubbleKeysPerUser = new SparseSetArray<>();
mBubbleIconFactory = new BubbleIconFactory(context);
}
public void initialize() {
mBubbleData.setListener(mBubbleDataListener);
mBubbleData.setSuppressionChangedListener(bubble -> {
// Make sure NoMan knows suppression state so that anyone querying it can tell.
@@ -261,28 +271,18 @@ public class BubbleController {
});
try {
windowManagerShellWrapper.addPinnedStackListener(new BubblesImeListener());
mWindowManagerShellWrapper.addPinnedStackListener(new BubblesImeListener());
} catch (RemoteException e) {
e.printStackTrace();
}
mSurfaceSynchronizer = synchronizer;
mWindowManager = windowManager;
mBarService = statusBarService == null
? IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE))
: statusBarService;
mSavedBubbleKeysPerUser = new SparseSetArray<>();
mCurrentUserId = ActivityManager.getCurrentUser();
mBubbleData.setCurrentUserId(mCurrentUserId);
mBubbleIconFactory = new BubbleIconFactory(context);
mTaskOrganizer = organizer;
mTaskOrganizer.addLocusIdListener((taskId, locus, visible) ->
mBubbleData.onLocusVisibilityChanged(taskId, locus, visible));
launcherApps.registerCallback(new LauncherApps.Callback() {
mLauncherApps.registerCallback(new LauncherApps.Callback() {
@Override
public void onPackageAdded(String s, UserHandle userHandle) {}
@@ -318,7 +318,7 @@ public class BubbleController {
mBubbleData.removeBubblesWithInvalidShortcuts(
packageName, validShortcuts, DISMISS_SHORTCUT_REMOVED);
}
}, mainHandler);
}, mMainHandler);
}
@VisibleForTesting
@@ -527,10 +527,6 @@ public class BubbleController {
}
}
void onImeVisibilityChanged(boolean imeVisible) {
mImeVisible = imeVisible;
}
/** Removes the BubbleStackView from the WindowManager if it's there. */
private void removeFromWindowManagerMaybe() {
if (!mAddedToWindowManager) {

View File

@@ -876,8 +876,6 @@ public class BubbleStackView extends FrameLayout
mTaskbarScrim.setVisibility(GONE);
setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> {
mBubbleController.onImeVisibilityChanged(
insets.getInsets(WindowInsets.Type.ime()).bottom > 0);
if (!mIsExpanded || mIsExpansionAnimating) {
return view.onApplyWindowInsets(insets);
}

View File

@@ -416,6 +416,7 @@ public abstract class WMShellBaseModule {
static ShellInitImpl provideShellInitImpl(DisplayImeController displayImeController,
DragAndDropController dragAndDropController,
ShellTaskOrganizer shellTaskOrganizer,
Optional<BubbleController> bubblesOptional,
Optional<LegacySplitScreenController> legacySplitScreenOptional,
Optional<SplitScreenController> splitScreenOptional,
Optional<AppPairsController> appPairsOptional,
@@ -427,6 +428,7 @@ public abstract class WMShellBaseModule {
return new ShellInitImpl(displayImeController,
dragAndDropController,
shellTaskOrganizer,
bubblesOptional,
legacySplitScreenOptional,
splitScreenOptional,
appPairsOptional,

View File

@@ -55,5 +55,6 @@ public class TestableBubbleController extends BubbleController {
statusBarService, windowManager, windowManagerShellWrapper, launcherApps,
bubbleLogger, shellTaskOrganizer, positioner, shellMainExecutor, shellMainHandler);
setInflateSynchronously(true);
initialize();
}
}