Merge "Use Provider for EdgeBackGestureHandler" into sc-dev am: 8981a5e756
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15303522 Change-Id: Icf95429e7b454c5c6592661e5f9fe1b0f340f287
This commit is contained in:
@@ -140,6 +140,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
@@ -198,6 +199,12 @@ 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.
|
||||
*/
|
||||
@@ -233,6 +240,12 @@ 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<>();
|
||||
@@ -359,7 +372,7 @@ public class Dependency {
|
||||
@Inject Lazy<TelephonyListenerManager> mTelephonyListenerManager;
|
||||
@Inject Lazy<SystemStatusAnimationScheduler> mSystemStatusAnimationSchedulerLazy;
|
||||
@Inject Lazy<PrivacyDotViewController> mPrivacyDotViewControllerLazy;
|
||||
@Inject Lazy<EdgeBackGestureHandler> mEdgeBackGestureHandler;
|
||||
@Inject Provider<EdgeBackGestureHandler> mEdgeBackGestureHandlerProvider;
|
||||
@Inject Lazy<UiEventLogger> mUiEventLogger;
|
||||
@Inject Lazy<FeatureFlags> mFeatureFlagsLazy;
|
||||
|
||||
@@ -574,7 +587,7 @@ public class Dependency {
|
||||
mProviders.put(SystemStatusAnimationScheduler.class,
|
||||
mSystemStatusAnimationSchedulerLazy::get);
|
||||
mProviders.put(PrivacyDotViewController.class, mPrivacyDotViewControllerLazy::get);
|
||||
mProviders.put(EdgeBackGestureHandler.class, mEdgeBackGestureHandler::get);
|
||||
mProviders.put(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mEdgeBackGestureHandlerProvider);
|
||||
mProviders.put(UiEventLogger.class, mUiEventLogger::get);
|
||||
mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ 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;
|
||||
@@ -342,7 +343,7 @@ public class NavigationBarView extends FrameLayout implements
|
||||
|
||||
mNavColorSampleMargin = getResources()
|
||||
.getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);
|
||||
mEdgeBackGestureHandler = Dependency.get(EdgeBackGestureHandler.class);
|
||||
mEdgeBackGestureHandler = Dependency.get(EDGE_BACK_GESTURE_HANDLER_PROVIDER).get();
|
||||
mEdgeBackGestureHandler.setStateChangeCallback(this::updateStates);
|
||||
mRegionSamplingHelper = new RegionSamplingHelper(this,
|
||||
new RegionSamplingHelper.SamplingCallback() {
|
||||
|
||||
@@ -58,7 +58,6 @@ import com.android.internal.policy.GestureNavigationSettingsObserver;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.model.SysUiState;
|
||||
import com.android.systemui.navigationbar.NavigationBarView;
|
||||
@@ -92,7 +91,6 @@ import javax.inject.Inject;
|
||||
/**
|
||||
* Utility class to handle edge swipes for back gesture
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
implements PluginListener<NavigationEdgeBackPlugin>, ProtoTraceable<SystemUiTraceProto> {
|
||||
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
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 android.graphics.PixelFormat;
|
||||
import android.hardware.display.DisplayManager;
|
||||
@@ -68,7 +71,8 @@ public class NavigationBarButtonTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(OverviewProxyService.class);
|
||||
mDependency.injectMockDependency(KeyguardStateController.class);
|
||||
mDependency.injectMockDependency(NavigationBarController.class);
|
||||
mDependency.injectMockDependency(EdgeBackGestureHandler.class);
|
||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
||||
() -> mock(EdgeBackGestureHandler.class));
|
||||
mNavBar = new NavigationBarView(context, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ 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;
|
||||
@@ -135,7 +136,8 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(StatusBarStateController.class);
|
||||
mDependency.injectMockDependency(NavigationBarController.class);
|
||||
mOverviewProxyService = mDependency.injectMockDependency(OverviewProxyService.class);
|
||||
mDependency.injectMockDependency(EdgeBackGestureHandler.class);
|
||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
||||
() -> mock(EdgeBackGestureHandler.class));
|
||||
TestableLooper.get(this).runWithLooper(() -> {
|
||||
mNavigationBar = createNavBar(mContext);
|
||||
mExternalDisplayNavigationBar = createNavBar(mSysuiTestableContextExternal);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.navigationbar;
|
||||
|
||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@@ -58,7 +60,8 @@ public class NavigationBarTransitionsTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(StatusBarStateController.class);
|
||||
mDependency.injectMockDependency(KeyguardStateController.class);
|
||||
mDependency.injectMockDependency(NavigationBarController.class);
|
||||
mDependency.injectMockDependency(EdgeBackGestureHandler.class);
|
||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
||||
() -> mock(EdgeBackGestureHandler.class));
|
||||
doReturn(mContext)
|
||||
.when(mDependency.injectMockDependency(NavigationModeController.class))
|
||||
.getCurrentUserContext();
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.navigationbar.buttons;
|
||||
|
||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@@ -38,6 +40,7 @@ import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.navigationbar.buttons.ContextualButton;
|
||||
import com.android.systemui.navigationbar.buttons.ContextualButtonGroup;
|
||||
import com.android.systemui.navigationbar.buttons.KeyButtonDrawable;
|
||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
@@ -65,6 +68,8 @@ public class NavigationBarContextTest extends SysuiTestCase {
|
||||
@Before
|
||||
public void setup() {
|
||||
mDependency.injectMockDependency(AssistManager.class);
|
||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
||||
() -> mock(EdgeBackGestureHandler.class));
|
||||
|
||||
mGroup = new ContextualButtonGroup(GROUP_ID);
|
||||
mBtn0 = new ContextualButton(BUTTON_0_ID, mContext, ICON_RES_ID);
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package com.android.systemui.navigationbar.buttons;
|
||||
|
||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -36,6 +39,7 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.navigationbar.buttons.NearestTouchFrame;
|
||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -52,6 +56,8 @@ public class NearestTouchFrameTest extends SysuiTestCase {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
||||
() -> mock(EdgeBackGestureHandler.class));
|
||||
Configuration c = new Configuration(mContext.getResources().getConfiguration());
|
||||
c.smallestScreenWidthDp = 500;
|
||||
mNearestTouchFrame = new NearestTouchFrame(mContext, null, c);
|
||||
|
||||
Reference in New Issue
Block a user