From ae3b432a8eff9ef2e3e5be5c4d365d01b5424626 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Tue, 5 Nov 2019 19:48:24 -0500 Subject: [PATCH] Remove Recents from components. Bug: 143972303 Test: atest SystemUITests && manual Change-Id: If430d99b2a8b8721cc3ec753a85685d2485fa16b --- .../src/com/android/systemui/CarSystemUIModule.java | 10 ++++++++++ .../android/systemui/dagger/SystemUIDefaultModule.java | 10 ++++++++++ .../com/android/systemui/dagger/SystemUIModule.java | 4 ++++ .../src/com/android/systemui/recents/Recents.java | 6 ------ .../statusbar/phone/NavigationBarFragment.java | 10 ++++++---- .../statusbar/phone/NavigationBarFragmentTest.java | 9 ++++++--- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java index a65cf2e5083e4..a6377b0395b72 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java @@ -28,7 +28,10 @@ import com.android.systemui.dock.DockManager; import com.android.systemui.dock.DockManagerImpl; import com.android.systemui.power.EnhancedEstimates; import com.android.systemui.power.EnhancedEstimatesImpl; +import com.android.systemui.recents.Recents; +import com.android.systemui.recents.RecentsImplementation; import com.android.systemui.stackdivider.Divider; +import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.car.CarStatusBar; @@ -102,6 +105,13 @@ abstract class CarSystemUIModule { return SysUiServiceProvider.getComponent(context, StatusBar.class); } + @Provides + @Singleton + static Recents provideRecents(Context context, RecentsImplementation recentsImplementation, + CommandQueue commandQueue) { + return new Recents(context, recentsImplementation, commandQueue); + } + @Binds abstract SystemUIRootComponent bindSystemUIRootComponent( CarSystemUIRootComponent systemUIRootComponent); diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java index fd2824d8845f6..f86aaf13e5bd2 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java @@ -27,7 +27,10 @@ import com.android.systemui.dock.DockManager; import com.android.systemui.dock.DockManagerImpl; import com.android.systemui.power.EnhancedEstimates; import com.android.systemui.power.EnhancedEstimatesImpl; +import com.android.systemui.recents.Recents; +import com.android.systemui.recents.RecentsImplementation; import com.android.systemui.stackdivider.Divider; +import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.notification.collection.NotificationData; @@ -86,4 +89,11 @@ abstract class SystemUIDefaultModule { static Divider provideDivider(Context context) { return new Divider(context); } + + @Provides + @Singleton + static Recents provideRecents(Context context, RecentsImplementation recentsImplementation, + CommandQueue commandQueue) { + return new Recents(context, recentsImplementation, commandQueue); + } } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index a248c7fe4bbbf..6ae21b39f3313 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -25,6 +25,7 @@ import com.android.systemui.DumpController; import com.android.systemui.assist.AssistModule; import com.android.systemui.model.SysUiState; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.recents.Recents; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.notification.people.PeopleHubModule; @@ -78,6 +79,9 @@ public abstract class SystemUIModule { @BindsOptionalOf abstract Divider optionalDivider(); + @BindsOptionalOf + abstract Recents optionalRecents(); + @BindsOptionalOf abstract StatusBar optionalStatusBar(); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index a8ecc1275221f..882930bc1049a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -28,19 +28,14 @@ import com.android.systemui.statusbar.CommandQueue; import java.io.FileDescriptor; import java.io.PrintWriter; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * A proxy to a Recents implementation. */ -@Singleton public class Recents extends SystemUI implements CommandQueue.Callbacks { private final RecentsImplementation mImpl; private final CommandQueue mCommandQueue; - @Inject public Recents(Context context, RecentsImplementation impl, CommandQueue commandQueue) { super(context); mImpl = impl; @@ -50,7 +45,6 @@ public class Recents extends SystemUI implements CommandQueue.Callbacks { @Override public void start() { mCommandQueue.addCallback(this); - putComponent(Recents.class, this); mImpl.onStart(mContext, this); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 51b1bc72bda31..1c46cf8762db6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -118,6 +118,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.List; import java.util.Locale; +import java.util.Optional; import java.util.function.Consumer; import javax.inject.Inject; @@ -162,8 +163,8 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback private int mDisabledFlags1; private int mDisabledFlags2; private StatusBar mStatusBar; - private Recents mRecents; private final Divider mDivider; + private final Optional mRecentsOptional; private WindowManager mWindowManager; private final CommandQueue mCommandQueue; private long mLastLockToAppLongPress; @@ -267,7 +268,8 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback SysUiState sysUiFlagsContainer, BroadcastDispatcher broadcastDispatcher, CommandQueue commandQueue, - Divider divider) { + Divider divider, + Optional recentsOptional) { mAccessibilityManagerWrapper = accessibilityManagerWrapper; mDeviceProvisionedController = deviceProvisionedController; mStatusBarStateController = statusBarStateController; @@ -281,6 +283,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback mBroadcastDispatcher = broadcastDispatcher; mCommandQueue = commandQueue; mDivider = divider; + mRecentsOptional = recentsOptional; } // ----- Fragment Lifecycle Callbacks ----- @@ -290,7 +293,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback super.onCreate(savedInstanceState); mCommandQueue.observe(getLifecycle(), this); mStatusBar = SysUiServiceProvider.getComponent(getContext(), StatusBar.class); - mRecents = SysUiServiceProvider.getComponent(getContext(), Recents.class); mWindowManager = getContext().getSystemService(WindowManager.class); mAccessibilityManager = getContext().getSystemService(AccessibilityManager.class); mContentResolver = getContext().getContentResolver(); @@ -906,7 +908,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback } private boolean onLongPressRecents() { - if (mRecents == null || !ActivityTaskManager.supportsMultiWindow(getContext()) + if (mRecentsOptional.isPresent() || !ActivityTaskManager.supportsMultiWindow(getContext()) || !mDivider.getView().getSnapAlgorithm().isSplitScreenFeasible() || ActivityManager.isLowRamDeviceStatic() // If we are connected to the overview service, then disable the recents button diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java index 2779701db680d..9763675df6bc7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java @@ -79,6 +79,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.Optional; + @RunWith(AndroidTestingRunner.class) @RunWithLooper(setAsMainLooper = true) @SmallTest @@ -97,6 +99,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest { private BroadcastDispatcher mBroadcastDispatcher; @Mock private Divider mDivider; + @Mock + private Recents mRecents; private AccessibilityManagerWrapper mAccessibilityWrapper = new AccessibilityManagerWrapper(mContext) { @@ -154,14 +158,12 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest { private void setupSysuiDependency() { mSysuiContext.putComponent(StatusBar.class, mock(StatusBar.class)); - mSysuiContext.putComponent(Recents.class, mock(Recents.class)); Display display = new Display(DisplayManagerGlobal.getInstance(), EXTERNAL_DISPLAY_ID, new DisplayInfo(), DEFAULT_DISPLAY_ADJUSTMENTS); mSysuiTestableContextExternal = (SysuiTestableContext) mSysuiContext.createDisplayContext( display); mSysuiTestableContextExternal.putComponent(StatusBar.class, mock(StatusBar.class)); - mSysuiTestableContextExternal.putComponent(Recents.class, mock(Recents.class)); injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES); WindowManager windowManager = mock(WindowManager.class); @@ -252,7 +254,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest { mMockSysUiState, mBroadcastDispatcher, mCommandQueue, - mDivider); + mDivider, + Optional.of(mRecents)); } private class HostCallbacksForExternalDisplay extends