Loading packages/SystemUI/src/com/android/systemui/Dependency.java +3 −15 Original line number Diff line number Diff line Loading @@ -139,7 +139,6 @@ import java.util.function.Consumer; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import dagger.Lazy; Loading Loading @@ -198,12 +197,6 @@ public class Dependency { */ public static final String ALLOW_NOTIFICATION_LONG_PRESS_NAME = "allow_notif_longpress"; /** * A provider of {@link EdgeBackGestureHandler}. */ public static final String EDGE_BACK_GESTURE_HANDLER_PROVIDER_NAME = "edge_back_gesture_handler_provider"; /** * Key for getting a background Looper for background work. */ Loading Loading @@ -239,12 +232,6 @@ public class Dependency { */ public static final DependencyKey<String> LEAK_REPORT_EMAIL = new DependencyKey<>(LEAK_REPORT_EMAIL_NAME); /** * Key for retrieving an Provider<EdgeBackGestureHandler>. */ public static final DependencyKey<Provider<EdgeBackGestureHandler>> EDGE_BACK_GESTURE_HANDLER_PROVIDER = new DependencyKey<>(EDGE_BACK_GESTURE_HANDLER_PROVIDER_NAME); private final ArrayMap<Object, Object> mDependencies = new ArrayMap<>(); private final ArrayMap<Object, LazyDependencyCreator> mProviders = new ArrayMap<>(); Loading Loading @@ -369,7 +356,7 @@ public class Dependency { @Inject Lazy<TelephonyListenerManager> mTelephonyListenerManager; @Inject Lazy<SystemStatusAnimationScheduler> mSystemStatusAnimationSchedulerLazy; @Inject Lazy<PrivacyDotViewController> mPrivacyDotViewControllerLazy; @Inject Provider<EdgeBackGestureHandler> mEdgeBackGestureHandlerProvider; @Inject Lazy<EdgeBackGestureHandler.Factory> mEdgeBackGestureHandlerFactoryLazy; @Inject Lazy<UiEventLogger> mUiEventLogger; @Inject Lazy<InternetDialogFactory> mInternetDialogFactory; @Inject Lazy<FeatureFlags> mFeatureFlagsLazy; Loading Loading @@ -584,7 +571,8 @@ public class Dependency { mSystemStatusAnimationSchedulerLazy::get); mProviders.put(PrivacyDotViewController.class, mPrivacyDotViewControllerLazy::get); mProviders.put(InternetDialogFactory.class, mInternetDialogFactory::get); mProviders.put(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mEdgeBackGestureHandlerProvider); mProviders.put(EdgeBackGestureHandler.Factory.class, mEdgeBackGestureHandlerFactoryLazy::get); mProviders.put(UiEventLogger.class, mUiEventLogger::get); mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get); Loading packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.systemui.navigationbar; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; Loading Loading @@ -352,7 +351,8 @@ public class NavigationBarView extends FrameLayout implements mNavColorSampleMargin = getResources() .getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin); mEdgeBackGestureHandler = Dependency.get(EDGE_BACK_GESTURE_HANDLER_PROVIDER).get(); mEdgeBackGestureHandler = Dependency.get(EdgeBackGestureHandler.Factory.class) .create(mContext); mEdgeBackGestureHandler.setStateChangeCallback(this::updateStates); mRegionSamplingHelper = new RegionSamplingHelper(this, new RegionSamplingHelper.SamplingCallback() { Loading packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +49 −2 Original line number Diff line number Diff line Loading @@ -292,8 +292,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker } }; @Inject public EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService, EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService, SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor, BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer, NavigationModeController navigationModeController, ViewConfiguration viewConfiguration, Loading Loading @@ -942,6 +942,53 @@ public class EdgeBackGestureHandler extends CurrentUserTracker proto.edgeBackGestureHandler.allowGesture = mAllowGesture; } /** * Injectable instance to create a new EdgeBackGestureHandler. * * Necessary because we don't have good handling of per-display contexts at the moment. With * this, you can pass in a specific context that knows what display it is in. */ public static class Factory { private final OverviewProxyService mOverviewProxyService; private final SysUiState mSysUiState; private final PluginManager mPluginManager; private final Executor mExecutor; private final BroadcastDispatcher mBroadcastDispatcher; private final ProtoTracer mProtoTracer; private final NavigationModeController mNavigationModeController; private final ViewConfiguration mViewConfiguration; private final WindowManager mWindowManager; private final IWindowManager mWindowManagerService; private final FalsingManager mFalsingManager; @Inject public Factory(OverviewProxyService overviewProxyService, SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor, BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer, NavigationModeController navigationModeController, ViewConfiguration viewConfiguration, WindowManager windowManager, IWindowManager windowManagerService, FalsingManager falsingManager) { mOverviewProxyService = overviewProxyService; mSysUiState = sysUiState; mPluginManager = pluginManager; mExecutor = executor; mBroadcastDispatcher = broadcastDispatcher; mProtoTracer = protoTracer; mNavigationModeController = navigationModeController; mViewConfiguration = viewConfiguration; mWindowManager = windowManager; mWindowManagerService = windowManagerService; mFalsingManager = falsingManager; } /** Construct a {@link EdgeBackGestureHandler}. */ public EdgeBackGestureHandler create(Context context) { return new EdgeBackGestureHandler(context, mOverviewProxyService, mSysUiState, mPluginManager, mExecutor, mBroadcastDispatcher, mProtoTracer, mNavigationModeController, mViewConfiguration, mWindowManager, mWindowManagerService, mFalsingManager); } } private static class LogArray extends ArrayDeque<String> { private final int mLength; Loading packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarButtonTest.java +15 −6 Original line number Diff line number Diff line Loading @@ -16,12 +16,12 @@ package com.android.systemui.navigationbar; import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import android.content.Context; import android.graphics.PixelFormat; import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; Loading @@ -38,7 +38,6 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestableContext; import com.android.systemui.assist.AssistManager; import com.android.systemui.navigationbar.NavigationBarView; import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.statusbar.policy.KeyguardStateController; Loading @@ -47,6 +46,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.function.Predicate; Loading @@ -56,6 +57,10 @@ import java.util.function.Predicate; @SmallTest public class NavigationBarButtonTest extends SysuiTestCase { @Mock EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory; @Mock EdgeBackGestureHandler mEdgeBackGestureHandler; private static final String TAG = "NavigationBarButtonTest"; private ImageReader mReader; private NavigationBarView mNavBar; Loading @@ -63,16 +68,20 @@ public class NavigationBarButtonTest extends SysuiTestCase { @Before public void setup() { MockitoAnnotations.initMocks(this); final Display display = createVirtualDisplay(); final SysuiTestableContext context = (SysuiTestableContext) mContext.createDisplayContext(display); when(mEdgeBackGestureHandlerFactory.create(any(Context.class))) .thenReturn(mEdgeBackGestureHandler); mDependency.injectMockDependency(AssistManager.class); mDependency.injectMockDependency(OverviewProxyService.class); mDependency.injectMockDependency(KeyguardStateController.class); mDependency.injectMockDependency(NavigationBarController.class); mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mock(EdgeBackGestureHandler.class)); mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class, mEdgeBackGestureHandlerFactory); mNavBar = new NavigationBarView(context, null); } Loading packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS; import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS; import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER; import static com.android.systemui.navigationbar.NavigationBar.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS; import static org.junit.Assert.assertEquals; Loading Loading @@ -119,6 +118,10 @@ public class NavigationBarTest extends SysuiTestCase { private BroadcastDispatcher mBroadcastDispatcher; @Mock private UiEventLogger mUiEventLogger; @Mock EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory; @Mock EdgeBackGestureHandler mEdgeBackGestureHandler; @Rule public final LeakCheckedTest.SysuiLeakCheck mLeakCheck = new LeakCheckedTest.SysuiLeakCheck(); Loading @@ -129,6 +132,8 @@ public class NavigationBarTest extends SysuiTestCase { public void setup() throws Exception { MockitoAnnotations.initMocks(this); when(mEdgeBackGestureHandlerFactory.create(any(Context.class))) .thenReturn(mEdgeBackGestureHandler); mCommandQueue = new CommandQueue(mContext); setupSysuiDependency(); mDependency.injectMockDependency(AssistManager.class); Loading @@ -136,8 +141,8 @@ public class NavigationBarTest extends SysuiTestCase { mDependency.injectMockDependency(StatusBarStateController.class); mDependency.injectMockDependency(NavigationBarController.class); mOverviewProxyService = mDependency.injectMockDependency(OverviewProxyService.class); mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mock(EdgeBackGestureHandler.class)); mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class, mEdgeBackGestureHandlerFactory); TestableLooper.get(this).runWithLooper(() -> { mNavigationBar = createNavBar(mContext); mExternalDisplayNavigationBar = createNavBar(mSysuiTestableContextExternal); Loading Loading
packages/SystemUI/src/com/android/systemui/Dependency.java +3 −15 Original line number Diff line number Diff line Loading @@ -139,7 +139,6 @@ import java.util.function.Consumer; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import dagger.Lazy; Loading Loading @@ -198,12 +197,6 @@ public class Dependency { */ public static final String ALLOW_NOTIFICATION_LONG_PRESS_NAME = "allow_notif_longpress"; /** * A provider of {@link EdgeBackGestureHandler}. */ public static final String EDGE_BACK_GESTURE_HANDLER_PROVIDER_NAME = "edge_back_gesture_handler_provider"; /** * Key for getting a background Looper for background work. */ Loading Loading @@ -239,12 +232,6 @@ public class Dependency { */ public static final DependencyKey<String> LEAK_REPORT_EMAIL = new DependencyKey<>(LEAK_REPORT_EMAIL_NAME); /** * Key for retrieving an Provider<EdgeBackGestureHandler>. */ public static final DependencyKey<Provider<EdgeBackGestureHandler>> EDGE_BACK_GESTURE_HANDLER_PROVIDER = new DependencyKey<>(EDGE_BACK_GESTURE_HANDLER_PROVIDER_NAME); private final ArrayMap<Object, Object> mDependencies = new ArrayMap<>(); private final ArrayMap<Object, LazyDependencyCreator> mProviders = new ArrayMap<>(); Loading Loading @@ -369,7 +356,7 @@ public class Dependency { @Inject Lazy<TelephonyListenerManager> mTelephonyListenerManager; @Inject Lazy<SystemStatusAnimationScheduler> mSystemStatusAnimationSchedulerLazy; @Inject Lazy<PrivacyDotViewController> mPrivacyDotViewControllerLazy; @Inject Provider<EdgeBackGestureHandler> mEdgeBackGestureHandlerProvider; @Inject Lazy<EdgeBackGestureHandler.Factory> mEdgeBackGestureHandlerFactoryLazy; @Inject Lazy<UiEventLogger> mUiEventLogger; @Inject Lazy<InternetDialogFactory> mInternetDialogFactory; @Inject Lazy<FeatureFlags> mFeatureFlagsLazy; Loading Loading @@ -584,7 +571,8 @@ public class Dependency { mSystemStatusAnimationSchedulerLazy::get); mProviders.put(PrivacyDotViewController.class, mPrivacyDotViewControllerLazy::get); mProviders.put(InternetDialogFactory.class, mInternetDialogFactory::get); mProviders.put(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mEdgeBackGestureHandlerProvider); mProviders.put(EdgeBackGestureHandler.Factory.class, mEdgeBackGestureHandlerFactoryLazy::get); mProviders.put(UiEventLogger.class, mUiEventLogger::get); mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get); Loading
packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.systemui.navigationbar; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; Loading Loading @@ -352,7 +351,8 @@ public class NavigationBarView extends FrameLayout implements mNavColorSampleMargin = getResources() .getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin); mEdgeBackGestureHandler = Dependency.get(EDGE_BACK_GESTURE_HANDLER_PROVIDER).get(); mEdgeBackGestureHandler = Dependency.get(EdgeBackGestureHandler.Factory.class) .create(mContext); mEdgeBackGestureHandler.setStateChangeCallback(this::updateStates); mRegionSamplingHelper = new RegionSamplingHelper(this, new RegionSamplingHelper.SamplingCallback() { Loading
packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +49 −2 Original line number Diff line number Diff line Loading @@ -292,8 +292,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker } }; @Inject public EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService, EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService, SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor, BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer, NavigationModeController navigationModeController, ViewConfiguration viewConfiguration, Loading Loading @@ -942,6 +942,53 @@ public class EdgeBackGestureHandler extends CurrentUserTracker proto.edgeBackGestureHandler.allowGesture = mAllowGesture; } /** * Injectable instance to create a new EdgeBackGestureHandler. * * Necessary because we don't have good handling of per-display contexts at the moment. With * this, you can pass in a specific context that knows what display it is in. */ public static class Factory { private final OverviewProxyService mOverviewProxyService; private final SysUiState mSysUiState; private final PluginManager mPluginManager; private final Executor mExecutor; private final BroadcastDispatcher mBroadcastDispatcher; private final ProtoTracer mProtoTracer; private final NavigationModeController mNavigationModeController; private final ViewConfiguration mViewConfiguration; private final WindowManager mWindowManager; private final IWindowManager mWindowManagerService; private final FalsingManager mFalsingManager; @Inject public Factory(OverviewProxyService overviewProxyService, SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor, BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer, NavigationModeController navigationModeController, ViewConfiguration viewConfiguration, WindowManager windowManager, IWindowManager windowManagerService, FalsingManager falsingManager) { mOverviewProxyService = overviewProxyService; mSysUiState = sysUiState; mPluginManager = pluginManager; mExecutor = executor; mBroadcastDispatcher = broadcastDispatcher; mProtoTracer = protoTracer; mNavigationModeController = navigationModeController; mViewConfiguration = viewConfiguration; mWindowManager = windowManager; mWindowManagerService = windowManagerService; mFalsingManager = falsingManager; } /** Construct a {@link EdgeBackGestureHandler}. */ public EdgeBackGestureHandler create(Context context) { return new EdgeBackGestureHandler(context, mOverviewProxyService, mSysUiState, mPluginManager, mExecutor, mBroadcastDispatcher, mProtoTracer, mNavigationModeController, mViewConfiguration, mWindowManager, mWindowManagerService, mFalsingManager); } } private static class LogArray extends ArrayDeque<String> { private final int mLength; Loading
packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarButtonTest.java +15 −6 Original line number Diff line number Diff line Loading @@ -16,12 +16,12 @@ package com.android.systemui.navigationbar; import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import android.content.Context; import android.graphics.PixelFormat; import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; Loading @@ -38,7 +38,6 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestableContext; import com.android.systemui.assist.AssistManager; import com.android.systemui.navigationbar.NavigationBarView; import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.statusbar.policy.KeyguardStateController; Loading @@ -47,6 +46,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.function.Predicate; Loading @@ -56,6 +57,10 @@ import java.util.function.Predicate; @SmallTest public class NavigationBarButtonTest extends SysuiTestCase { @Mock EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory; @Mock EdgeBackGestureHandler mEdgeBackGestureHandler; private static final String TAG = "NavigationBarButtonTest"; private ImageReader mReader; private NavigationBarView mNavBar; Loading @@ -63,16 +68,20 @@ public class NavigationBarButtonTest extends SysuiTestCase { @Before public void setup() { MockitoAnnotations.initMocks(this); final Display display = createVirtualDisplay(); final SysuiTestableContext context = (SysuiTestableContext) mContext.createDisplayContext(display); when(mEdgeBackGestureHandlerFactory.create(any(Context.class))) .thenReturn(mEdgeBackGestureHandler); mDependency.injectMockDependency(AssistManager.class); mDependency.injectMockDependency(OverviewProxyService.class); mDependency.injectMockDependency(KeyguardStateController.class); mDependency.injectMockDependency(NavigationBarController.class); mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mock(EdgeBackGestureHandler.class)); mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class, mEdgeBackGestureHandlerFactory); mNavBar = new NavigationBarView(context, null); } Loading
packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS; import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS; import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER; import static com.android.systemui.navigationbar.NavigationBar.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS; import static org.junit.Assert.assertEquals; Loading Loading @@ -119,6 +118,10 @@ public class NavigationBarTest extends SysuiTestCase { private BroadcastDispatcher mBroadcastDispatcher; @Mock private UiEventLogger mUiEventLogger; @Mock EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory; @Mock EdgeBackGestureHandler mEdgeBackGestureHandler; @Rule public final LeakCheckedTest.SysuiLeakCheck mLeakCheck = new LeakCheckedTest.SysuiLeakCheck(); Loading @@ -129,6 +132,8 @@ public class NavigationBarTest extends SysuiTestCase { public void setup() throws Exception { MockitoAnnotations.initMocks(this); when(mEdgeBackGestureHandlerFactory.create(any(Context.class))) .thenReturn(mEdgeBackGestureHandler); mCommandQueue = new CommandQueue(mContext); setupSysuiDependency(); mDependency.injectMockDependency(AssistManager.class); Loading @@ -136,8 +141,8 @@ public class NavigationBarTest extends SysuiTestCase { mDependency.injectMockDependency(StatusBarStateController.class); mDependency.injectMockDependency(NavigationBarController.class); mOverviewProxyService = mDependency.injectMockDependency(OverviewProxyService.class); mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mock(EdgeBackGestureHandler.class)); mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class, mEdgeBackGestureHandlerFactory); TestableLooper.get(this).runWithLooper(() -> { mNavigationBar = createNavBar(mContext); mExternalDisplayNavigationBar = createNavBar(mSysuiTestableContextExternal); Loading