Final calls to getComponent(Recents.class) removed.
Had to reformat a block of code because linter was complaining.
Bug: 143972303
Test: atest SystemUITests
Change-Id: I96c163b09217671fcbd3f20133c3a13b696afc75
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index b14f7a9e..91ee1b9 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.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 @@
@Inject Lazy<DozeParameters> mDozeParameters;
@Inject Lazy<IWallpaperManager> mWallpaperManager;
@Inject Lazy<CommandQueue> mCommandQueue;
+ @Inject Lazy<Recents> mRecents;
@Inject Lazy<StatusBar> mStatusBar;
@Inject
@@ -519,6 +521,7 @@
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 f86aaf1..48c72d3 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.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 @@
@Singleton
@Provides
- static Divider provideDivider(Context context) {
- return new Divider(context);
+ static Divider provideDivider(Context context, Optional<Lazy<Recents>> 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 a571f01..5ae0954 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 @@
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 @@
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 @@
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 d12f3ee..90cc0e57 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 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<Lazy<Recents>> mRecentsOptionalLazy;
private DividerWindowManager mWindowManager;
private DividerView mView;
@@ -51,8 +55,9 @@
private boolean mHomeStackResizable = false;
private ForcedResizableInfoActivityController mForcedResizableController;
- public Divider(Context context) {
+ public Divider(Context context, Optional<Lazy<Recents>> recentsOptionalLazy) {
super(context);
+ mRecentsOptionalLazy = recentsOptionalLazy;
}
@Override
@@ -216,10 +221,7 @@
@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 159a829..d3c7940 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.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 @@
}
};
- 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 d7bd067..e8e38b1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -673,6 +673,7 @@
ScreenPinningRequest screenPinningRequest,
DozeScrimController dozeScrimController,
CommandQueue commandQueue,
+ Optional<Recents> recentsOptional,
PluginManager pluginManager,
RemoteInputUriController remoteInputUriController,
Optional<Divider> dividerOptional,
@@ -741,6 +742,7 @@
mDozeScrimController = dozeScrimController;
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
mCommandQueue = commandQueue;
+ mRecentsOptional = recentsOptional;
mPluginManager = pluginManager;
mRemoteInputUriController = remoteInputUriController;
mDividerOptional = dividerOptional;
@@ -805,8 +807,6 @@
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
@@ -1433,7 +1433,7 @@
}
protected boolean toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) {
- if (mRecents == null) {
+ if (!mRecentsOptional.isPresent()) {
return false;
}
int dockSide = WindowManagerProxy.getInstance().getDockSide();
@@ -1445,7 +1445,7 @@
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();
@@ -4068,7 +4068,7 @@
protected Display mDisplay;
private int mDisplayId;
- protected Recents mRecents;
+ private final Optional<Recents> 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 8c04e2b..0f8e37a 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.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;
@@ -152,6 +153,7 @@
ScreenPinningRequest screenPinningRequest,
DozeScrimController dozeScrimController,
CommandQueue commandQueue,
+ Optional<Recents> recentsOptional,
PluginManager pluginManager,
RemoteInputUriController remoteInputUriController,
Optional<Divider> dividerOptional,
@@ -221,6 +223,7 @@
screenPinningRequest,
dozeScrimController,
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 b2eb7d4..c36e216 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.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;
@@ -221,7 +222,6 @@
@Mock private NotificationIconAreaController mNotificationIconAreaController;
@Mock private StatusBarWindowViewController.Builder mStatusBarWindowViewControllerBuilder;
@Mock private StatusBarWindowViewController mStatusBarWindowViewController;
- @Mock private NotifLog mNotifLog;
@Mock private DozeParameters mDozeParameters;
@Mock private Lazy<LockscreenWallpaper> mLockscreenWallpaperLazy;
@Mock private LockscreenWallpaper mLockscreenWallpaper;
@@ -230,6 +230,7 @@
@Mock private ViewMediatorCallback mKeyguardVieMediatorCallback;
@Mock private KeyguardLiftController mKeyguardLiftController;
@Mock private CommandQueue mCommandQueue;
+ @Mock private Recents mRecents;
@Mock private PluginManager mPluginManager;
@Mock private Divider mDivider;
@Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
@@ -368,6 +369,7 @@
mPowerManager, mScreenPinningRequest,
mDozeScrimController,
mCommandQueue,
+ Optional.of(mRecents),
mPluginManager,
mRemoteInputUriController,
Optional.of(mDivider),