diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java index 2c17f22354c6e..91d00262dc18b 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java @@ -46,10 +46,13 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.volume.CarVolumeDialogComponent; import com.android.systemui.volume.VolumeDialogComponent; +import java.util.Optional; + import javax.inject.Named; import javax.inject.Singleton; import dagger.Binds; +import dagger.Lazy; import dagger.Module; import dagger.Provides; @@ -76,8 +79,8 @@ abstract class CarSystemUIModule { @Singleton @Provides - static Divider provideDivider(Context context) { - return new Divider(context); + static Divider provideDivider(Context context, Optional> recentsOptionalLazy) { + return new Divider(context, recentsOptionalLazy); } @Singleton diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index cca06208337b8..78ac96020bae8 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -79,6 +79,7 @@ import com.android.systemui.navigationbar.car.CarNavigationBarView; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.qs.QS; import com.android.systemui.qs.car.CarQSFragment; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.stackdivider.Divider; @@ -300,6 +301,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, + Optional recents, PluginManager pluginManager, RemoteInputUriController remoteInputUriController, Optional dividerOptional, @@ -372,6 +374,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt dozeScrimController, volumeComponent, commandQueue, + recents, pluginManager, remoteInputUriController, dividerOptional, diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java index a3a5015bbdc94..b9dacc0ded3e7 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java @@ -36,6 +36,7 @@ import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.navigationbar.car.CarNavigationBarController; import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.stackdivider.Divider; @@ -169,6 +170,7 @@ public class CarStatusBarModule { DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, + Optional recentsOptional, PluginManager pluginManager, RemoteInputUriController remoteInputUriController, Optional dividerOptional, @@ -239,6 +241,7 @@ public class CarStatusBarModule { dozeScrimController, volumeComponent, commandQueue, + recentsOptional, pluginManager, remoteInputUriController, dividerOptional, diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java index b14f7a9ee949f..91ee1b91fd9e8 100644 --- a/packages/SystemUI/src/com/android/systemui/Dependency.java +++ b/packages/SystemUI/src/com/android/systemui/Dependency.java @@ -59,6 +59,7 @@ import com.android.systemui.power.EnhancedEstimates; import com.android.systemui.power.PowerUI; import com.android.systemui.privacy.PrivacyItemController; import com.android.systemui.recents.OverviewProxyService; +import com.android.systemui.recents.Recents; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.DevicePolicyManagerWrapper; @@ -329,6 +330,7 @@ public class Dependency { @Inject Lazy mDozeParameters; @Inject Lazy mWallpaperManager; @Inject Lazy mCommandQueue; + @Inject Lazy mRecents; @Inject Lazy mStatusBar; @Inject @@ -519,6 +521,7 @@ public class Dependency { mProviders.put(DozeParameters.class, mDozeParameters::get); mProviders.put(IWallpaperManager.class, mWallpaperManager::get); mProviders.put(CommandQueue.class, mCommandQueue::get); + mProviders.put(Recents.class, mRecents::get); mProviders.put(StatusBar.class, mStatusBar::get); // TODO(b/118592525): to support multi-display , we start to add something which is diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java index f86aaf13e5bd2..48c72d311b1cd 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java @@ -38,10 +38,13 @@ import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; +import java.util.Optional; + import javax.inject.Named; import javax.inject.Singleton; import dagger.Binds; +import dagger.Lazy; import dagger.Module; import dagger.Provides; @@ -86,8 +89,8 @@ abstract class SystemUIDefaultModule { @Singleton @Provides - static Divider provideDivider(Context context) { - return new Divider(context); + static Divider provideDivider(Context context, Optional> recentsOptionalLazy) { + return new Divider(context, recentsOptionalLazy); } @Provides diff --git a/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java b/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java index a571f011fff32..5ae095421a809 100644 --- a/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java +++ b/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java @@ -46,6 +46,7 @@ public class ShortcutKeyDispatcher extends SystemUI private static final String TAG = "ShortcutKeyDispatcher"; private final Divider mDivider; + private final Recents mRecents; private ShortcutKeyServiceProxy mShortcutKeyServiceProxy = new ShortcutKeyServiceProxy(this); private IWindowManager mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); @@ -59,9 +60,10 @@ public class ShortcutKeyDispatcher extends SystemUI protected final long SC_DOCK_RIGHT = META_MASK | KeyEvent.KEYCODE_RIGHT_BRACKET; @Inject - public ShortcutKeyDispatcher(Context context, Divider divider) { + public ShortcutKeyDispatcher(Context context, Divider divider, Recents recents) { super(context); mDivider = divider; + mRecents = recents; } /** @@ -96,8 +98,7 @@ public class ShortcutKeyDispatcher extends SystemUI int dockSide = mWindowManagerService.getDockedStackSide(); if (dockSide == WindowManager.DOCKED_INVALID) { // Split the screen - Recents recents = getComponent(Recents.class); - recents.splitPrimaryTask((shortcutCode == SC_DOCK_LEFT) + mRecents.splitPrimaryTask((shortcutCode == SC_DOCK_LEFT) ? SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT : SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT, null, -1); } else { diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java index d12f3ee5a1ec2..90cc0e57f50cc 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java @@ -34,12 +34,16 @@ import com.android.systemui.recents.Recents; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.Optional; + +import dagger.Lazy; /** * Controls the docked stack divider. */ public class Divider extends SystemUI implements DividerView.DividerCallbacks { private static final String TAG = "Divider"; + private final Optional> mRecentsOptionalLazy; private DividerWindowManager mWindowManager; private DividerView mView; @@ -51,8 +55,9 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks { private boolean mHomeStackResizable = false; private ForcedResizableInfoActivityController mForcedResizableController; - public Divider(Context context) { + public Divider(Context context, Optional> recentsOptionalLazy) { super(context); + mRecentsOptionalLazy = recentsOptionalLazy; } @Override @@ -216,10 +221,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks { @Override public void growRecents() { - Recents recents = getComponent(Recents.class); - if (recents != null) { - recents.growRecents(); - } + mRecentsOptionalLazy.ifPresent(recentsLazy -> recentsLazy.get().growRecents()); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 159a829fc47d9..d3c79404863e6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -66,7 +66,6 @@ import com.android.systemui.Dependency; import com.android.systemui.DockedStackExistsListener; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.SysUiServiceProvider; import com.android.systemui.assist.AssistHandleViewController; import com.android.systemui.assist.AssistManager; import com.android.systemui.model.SysUiState; @@ -214,31 +213,32 @@ public class NavigationBarView extends FrameLayout implements } }; - private final AccessibilityDelegate mQuickStepAccessibilityDelegate - = new AccessibilityDelegate() { - private AccessibilityAction mToggleOverviewAction; + private final AccessibilityDelegate mQuickStepAccessibilityDelegate = + new AccessibilityDelegate() { + private AccessibilityAction mToggleOverviewAction; - @Override - public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(host, info); - if (mToggleOverviewAction == null) { - mToggleOverviewAction = new AccessibilityAction(R.id.action_toggle_overview, - getContext().getString(R.string.quick_step_accessibility_toggle_overview)); - } - info.addAction(mToggleOverviewAction); - } + @Override + public void onInitializeAccessibilityNodeInfo(View host, + AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(host, info); + if (mToggleOverviewAction == null) { + mToggleOverviewAction = new AccessibilityAction( + R.id.action_toggle_overview, getContext().getString( + R.string.quick_step_accessibility_toggle_overview)); + } + info.addAction(mToggleOverviewAction); + } - @Override - public boolean performAccessibilityAction(View host, int action, Bundle args) { - if (action == R.id.action_toggle_overview) { - SysUiServiceProvider.getComponent(getContext(), Recents.class) - .toggleRecentApps(); - } else { - return super.performAccessibilityAction(host, action, args); - } - return true; - } - }; + @Override + public boolean performAccessibilityAction(View host, int action, Bundle args) { + if (action == R.id.action_toggle_overview) { + Dependency.get(Recents.class).toggleRecentApps(); + } else { + return super.performAccessibilityAction(host, action, args); + } + return true; + } + }; private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = info -> { // When the nav bar is in 2-button or 3-button mode, or when IME is visible in fully diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 6dd6bfc8a14d7..0e1985de4371f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -674,6 +674,7 @@ public class StatusBar extends SystemUI implements DemoMode, DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, + Optional recentsOptional, PluginManager pluginManager, RemoteInputUriController remoteInputUriController, Optional dividerOptional, @@ -743,6 +744,7 @@ public class StatusBar extends SystemUI implements DemoMode, mBiometricUnlockControllerLazy = biometricUnlockControllerLazy; mVolumeComponent = volumeComponent; mCommandQueue = commandQueue; + mRecentsOptional = recentsOptional; mPluginManager = pluginManager; mRemoteInputUriController = remoteInputUriController; mDividerOptional = dividerOptional; @@ -807,8 +809,6 @@ public class StatusBar extends SystemUI implements DemoMode, mBarService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); - mRecents = getComponent(Recents.class); - mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); // Connect in to the status bar manager service @@ -1432,7 +1432,7 @@ public class StatusBar extends SystemUI implements DemoMode, } protected boolean toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) { - if (mRecents == null) { + if (!mRecentsOptional.isPresent()) { return false; } int dockSide = WindowManagerProxy.getInstance().getDockSide(); @@ -1444,7 +1444,7 @@ public class StatusBar extends SystemUI implements DemoMode, int createMode = navbarPos == NAV_BAR_POS_LEFT ? SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT : SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT; - return mRecents.splitPrimaryTask(createMode, null, metricsDockAction); + return mRecentsOptional.get().splitPrimaryTask(createMode, null, metricsDockAction); } else { if (mDividerOptional.isPresent()) { Divider divider = mDividerOptional.get(); @@ -4067,7 +4067,7 @@ public class StatusBar extends SystemUI implements DemoMode, protected Display mDisplay; private int mDisplayId; - protected Recents mRecents; + private final Optional mRecentsOptional; protected NotificationShelf mNotificationShelf; protected EmptyShadeView mEmptyShadeView; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java index 21a77ca2a243b..60e93857e9dae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java @@ -37,6 +37,7 @@ import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.stackdivider.Divider; @@ -154,6 +155,7 @@ public class StatusBarModule { DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, + Optional recentsOptional, PluginManager pluginManager, RemoteInputUriController remoteInputUriController, Optional dividerOptional, @@ -224,6 +226,7 @@ public class StatusBarModule { dozeScrimController, volumeComponent, commandQueue, + recentsOptional, pluginManager, remoteInputUriController, dividerOptional, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index f1465d9776573..f3273784c6caf 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -89,6 +89,7 @@ import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.stackdivider.Divider; @@ -222,7 +223,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private NotificationIconAreaController mNotificationIconAreaController; @Mock private StatusBarWindowViewController.Builder mStatusBarWindowViewControllerBuilder; @Mock private StatusBarWindowViewController mStatusBarWindowViewController; - @Mock private NotifLog mNotifLog; @Mock private DozeParameters mDozeParameters; @Mock private Lazy mLockscreenWallpaperLazy; @Mock private LockscreenWallpaper mLockscreenWallpaper; @@ -232,6 +232,7 @@ public class StatusBarTest extends SysuiTestCase { @Mock private KeyguardLiftController mKeyguardLiftController; @Mock private VolumeComponent mVolumeComponent; @Mock private CommandQueue mCommandQueue; + @Mock private Recents mRecents; @Mock private PluginManager mPluginManager; @Mock private Divider mDivider; @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; @@ -371,6 +372,7 @@ public class StatusBarTest extends SysuiTestCase { mDozeScrimController, mVolumeComponent, mCommandQueue, + Optional.of(mRecents), mPluginManager, mRemoteInputUriController, Optional.of(mDivider),