Merge "Recognize the Back Gesture in the FalsingManager." into sc-dev
This commit is contained in:
@@ -54,6 +54,7 @@ import com.android.systemui.model.SysUiState;
|
||||
import com.android.systemui.navigationbar.NavigationBarController;
|
||||
import com.android.systemui.navigationbar.NavigationBarOverlayController;
|
||||
import com.android.systemui.navigationbar.NavigationModeController;
|
||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||
import com.android.systemui.plugins.PluginDependencyProvider;
|
||||
@@ -356,6 +357,7 @@ public class Dependency {
|
||||
@Inject Lazy<TelephonyListenerManager> mTelephonyListenerManager;
|
||||
@Inject Lazy<SystemStatusAnimationScheduler> mSystemStatusAnimationSchedulerLazy;
|
||||
@Inject Lazy<PrivacyDotViewController> mPrivacyDotViewControllerLazy;
|
||||
@Inject Lazy<EdgeBackGestureHandler> mEdgeBackGestureHandler;
|
||||
|
||||
@Inject
|
||||
public Dependency() {
|
||||
@@ -568,6 +570,7 @@ public class Dependency {
|
||||
mProviders.put(SystemStatusAnimationScheduler.class,
|
||||
mSystemStatusAnimationSchedulerLazy::get);
|
||||
mProviders.put(PrivacyDotViewController.class, mPrivacyDotViewControllerLazy::get);
|
||||
mProviders.put(EdgeBackGestureHandler.class, mEdgeBackGestureHandler::get);
|
||||
|
||||
Dependency.setInstance(this);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.classifier;
|
||||
|
||||
import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
|
||||
import static com.android.systemui.classifier.Classifier.GENERIC;
|
||||
import static com.android.systemui.classifier.FalsingManagerProxy.FALSING_SUCCESS;
|
||||
import static com.android.systemui.classifier.FalsingModule.BRIGHT_LINE_GESTURE_CLASSIFERS;
|
||||
|
||||
@@ -196,7 +198,7 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
@Override
|
||||
public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
|
||||
mPriorInteractionType = interactionType;
|
||||
if (skipFalsing()) {
|
||||
if (skipFalsing(interactionType)) {
|
||||
mPriorResults = getPassedResult(1);
|
||||
logDebug("Skipped falsing");
|
||||
return false;
|
||||
@@ -229,7 +231,7 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
|
||||
@Override
|
||||
public boolean isFalseTap(@Penalty int penalty) {
|
||||
if (skipFalsing()) {
|
||||
if (skipFalsing(GENERIC)) {
|
||||
mPriorResults = getPassedResult(1);
|
||||
logDebug("Skipped falsing");
|
||||
return false;
|
||||
@@ -291,7 +293,7 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
|
||||
@Override
|
||||
public boolean isFalseDoubleTap() {
|
||||
if (skipFalsing()) {
|
||||
if (skipFalsing(GENERIC)) {
|
||||
mPriorResults = getPassedResult(1);
|
||||
logDebug("Skipped falsing");
|
||||
return false;
|
||||
@@ -306,8 +308,9 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
return result.isFalse();
|
||||
}
|
||||
|
||||
private boolean skipFalsing() {
|
||||
return !mKeyguardStateController.isShowing()
|
||||
private boolean skipFalsing(@Classifier.InteractionType int interactionType) {
|
||||
return interactionType == BACK_GESTURE
|
||||
|| !mKeyguardStateController.isShowing()
|
||||
|| mTestHarness
|
||||
|| mDataProvider.isJustUnlockedWithFace()
|
||||
|| mDockManager.isDocked();
|
||||
|
||||
@@ -43,6 +43,7 @@ public abstract class Classifier {
|
||||
public static final int UDFPS_AUTHENTICATION = 13;
|
||||
public static final int DISABLED_UDFPS_AFFORDANCE = 14;
|
||||
public static final int QS_SWIPE = 15;
|
||||
public static final int BACK_GESTURE = 16;
|
||||
|
||||
@IntDef({
|
||||
QUICK_SETTINGS,
|
||||
@@ -61,7 +62,8 @@ public abstract class Classifier {
|
||||
BRIGHTNESS_SLIDER,
|
||||
UDFPS_AUTHENTICATION,
|
||||
DISABLED_UDFPS_AFFORDANCE,
|
||||
QS_SWIPE
|
||||
QS_SWIPE,
|
||||
BACK_GESTURE
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface InteractionType {}
|
||||
|
||||
@@ -83,7 +83,6 @@ import com.android.systemui.navigationbar.gestural.RegionSamplingHelper;
|
||||
import com.android.systemui.recents.OverviewProxyService;
|
||||
import com.android.systemui.recents.Recents;
|
||||
import com.android.systemui.recents.RecentsOnboarding;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
import com.android.systemui.shared.system.SysUiStatsLog;
|
||||
@@ -113,7 +112,6 @@ public class NavigationBarView extends FrameLayout implements
|
||||
private final RegionSamplingHelper mRegionSamplingHelper;
|
||||
private final int mNavColorSampleMargin;
|
||||
private final SysUiState mSysUiFlagContainer;
|
||||
private final PluginManager mPluginManager;
|
||||
|
||||
View mCurrentView = null;
|
||||
private View mVertical;
|
||||
@@ -316,7 +314,6 @@ public class NavigationBarView extends FrameLayout implements
|
||||
boolean isGesturalMode = isGesturalMode(mNavBarMode);
|
||||
|
||||
mSysUiFlagContainer = Dependency.get(SysUiState.class);
|
||||
mPluginManager = Dependency.get(PluginManager.class);
|
||||
// Set up the context group of buttons
|
||||
mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container);
|
||||
final ContextualButton imeSwitcherButton = new ContextualButton(R.id.ime_switcher,
|
||||
@@ -366,8 +363,8 @@ public class NavigationBarView extends FrameLayout implements
|
||||
|
||||
mNavColorSampleMargin = getResources()
|
||||
.getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);
|
||||
mEdgeBackGestureHandler = new EdgeBackGestureHandler(context, mOverviewProxyService,
|
||||
mSysUiFlagContainer, mPluginManager, this::updateStates);
|
||||
mEdgeBackGestureHandler = Dependency.get(EdgeBackGestureHandler.class);
|
||||
mEdgeBackGestureHandler.setStateChangeCallback(this::updateStates);
|
||||
mRegionSamplingHelper = new RegionSamplingHelper(this,
|
||||
new RegionSamplingHelper.SamplingCallback() {
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.systemui.navigationbar.gestural;
|
||||
|
||||
import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -27,8 +29,6 @@ import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
@@ -41,6 +41,7 @@ import android.util.TypedValue;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
import android.view.ISystemGestureExclusionListener;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.InputDevice;
|
||||
import android.view.InputEvent;
|
||||
import android.view.InputMonitor;
|
||||
@@ -50,18 +51,19 @@ import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.view.WindowMetrics;
|
||||
|
||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||
import com.android.internal.policy.GestureNavigationSettingsObserver;
|
||||
import com.android.systemui.Dependency;
|
||||
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;
|
||||
import com.android.systemui.navigationbar.NavigationModeController;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.NavigationEdgeBackPlugin;
|
||||
import com.android.systemui.plugins.PluginListener;
|
||||
import com.android.systemui.recents.OverviewProxyService;
|
||||
@@ -85,9 +87,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Utility class to handle edge swipes for back gesture
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
implements PluginListener<NavigationEdgeBackPlugin>, ProtoTraceable<SystemUiTraceProto> {
|
||||
|
||||
@@ -164,9 +169,15 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
private final Context mContext;
|
||||
private final OverviewProxyService mOverviewProxyService;
|
||||
private final SysUiState mSysUiState;
|
||||
private final Runnable mStateChangeCallback;
|
||||
private Runnable mStateChangeCallback;
|
||||
|
||||
private final PluginManager mPluginManager;
|
||||
private final ProtoTracer mProtoTracer;
|
||||
private final NavigationModeController mNavigationModeController;
|
||||
private final ViewConfiguration mViewConfiguration;
|
||||
private final WindowManager mWindowManager;
|
||||
private final IWindowManager mWindowManagerService;
|
||||
private final FalsingManager mFalsingManager;
|
||||
// Activities which should not trigger Back gesture.
|
||||
private final List<ComponentName> mGestureBlockingActivities = new ArrayList<>();
|
||||
|
||||
@@ -237,6 +248,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
new NavigationEdgeBackPlugin.BackCallback() {
|
||||
@Override
|
||||
public void triggerBack() {
|
||||
// Notify FalsingManager that an intentional gesture has occurred.
|
||||
// TODO(b/186519446): use a different method than isFalseTouch
|
||||
mFalsingManager.isFalseTouch(BACK_GESTURE);
|
||||
boolean sendDown = sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
|
||||
boolean sendUp = sendEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
|
||||
if (DEBUG_MISSING_GESTURE) {
|
||||
@@ -267,16 +281,26 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
public EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService,
|
||||
SysUiState sysUiState, PluginManager pluginManager, Runnable stateChangeCallback) {
|
||||
super(Dependency.get(BroadcastDispatcher.class));
|
||||
SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor,
|
||||
BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer,
|
||||
NavigationModeController navigationModeController, ViewConfiguration viewConfiguration,
|
||||
WindowManager windowManager, IWindowManager windowManagerService,
|
||||
FalsingManager falsingManager) {
|
||||
super(broadcastDispatcher);
|
||||
mContext = context;
|
||||
mDisplayId = context.getDisplayId();
|
||||
mMainExecutor = context.getMainExecutor();
|
||||
mMainExecutor = executor;
|
||||
mOverviewProxyService = overviewProxyService;
|
||||
mSysUiState = sysUiState;
|
||||
mPluginManager = pluginManager;
|
||||
mStateChangeCallback = stateChangeCallback;
|
||||
mProtoTracer = protoTracer;
|
||||
mNavigationModeController = navigationModeController;
|
||||
mViewConfiguration = viewConfiguration;
|
||||
mWindowManager = windowManager;
|
||||
mWindowManagerService = windowManagerService;
|
||||
mFalsingManager = falsingManager;
|
||||
ComponentName recentsComponentName = ComponentName.unflattenFromString(
|
||||
context.getString(com.android.internal.R.string.config_recentsComponentName));
|
||||
if (recentsComponentName != null) {
|
||||
@@ -309,9 +333,12 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
updateCurrentUserResources();
|
||||
}
|
||||
|
||||
public void setStateChangeCallback(Runnable callback) {
|
||||
mStateChangeCallback = callback;
|
||||
}
|
||||
|
||||
public void updateCurrentUserResources() {
|
||||
Resources res = Dependency.get(NavigationModeController.class).getCurrentUserContext()
|
||||
.getResources();
|
||||
Resources res = mNavigationModeController.getCurrentUserContext().getResources();
|
||||
mEdgeWidthLeft = mGestureNavigationSettingsObserver.getLeftSensitivity(res);
|
||||
mEdgeWidthRight = mGestureNavigationSettingsObserver.getRightSensitivity(res);
|
||||
mIsBackGestureAllowed =
|
||||
@@ -336,7 +363,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
// TODO(b/130352502) Tune this value and extract into a constant
|
||||
final float backGestureSlop = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||
SystemUiDeviceConfigFlags.BACK_GESTURE_SLOP_MULTIPLIER, 0.75f);
|
||||
mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop() * backGestureSlop;
|
||||
mTouchSlop = mViewConfiguration.getScaledTouchSlop() * backGestureSlop;
|
||||
}
|
||||
|
||||
private void onNavigationSettingsChanged() {
|
||||
@@ -358,7 +385,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
*/
|
||||
public void onNavBarAttached() {
|
||||
mIsAttached = true;
|
||||
Dependency.get(ProtoTracer.class).add(this);
|
||||
mProtoTracer.add(this);
|
||||
mOverviewProxyService.addCallback(mQuickSwitchListener);
|
||||
mSysUiState.addCallback(mSysUiStateCallback);
|
||||
updateIsEnabled();
|
||||
@@ -370,7 +397,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
*/
|
||||
public void onNavBarDetached() {
|
||||
mIsAttached = false;
|
||||
Dependency.get(ProtoTracer.class).remove(this);
|
||||
mProtoTracer.remove(this);
|
||||
mOverviewProxyService.removeCallback(mQuickSwitchListener);
|
||||
mSysUiState.removeCallback(mSysUiStateCallback);
|
||||
updateIsEnabled();
|
||||
@@ -424,9 +451,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
DeviceConfig.removeOnPropertiesChangedListener(mOnPropertiesChangedListener);
|
||||
|
||||
try {
|
||||
WindowManagerGlobal.getWindowManagerService()
|
||||
.unregisterSystemGestureExclusionListener(
|
||||
mGestureExclusionListener, mDisplayId);
|
||||
mWindowManagerService.unregisterSystemGestureExclusionListener(
|
||||
mGestureExclusionListener, mDisplayId);
|
||||
} catch (RemoteException | IllegalArgumentException e) {
|
||||
Log.e(TAG, "Failed to unregister window manager callbacks", e);
|
||||
}
|
||||
@@ -439,13 +465,11 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
}
|
||||
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
|
||||
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||
runnable -> (mContext.getMainThreadHandler()).post(runnable),
|
||||
mOnPropertiesChangedListener);
|
||||
mMainExecutor::execute, mOnPropertiesChangedListener);
|
||||
|
||||
try {
|
||||
WindowManagerGlobal.getWindowManagerService()
|
||||
.registerSystemGestureExclusionListener(
|
||||
mGestureExclusionListener, mDisplayId);
|
||||
mWindowManagerService.registerSystemGestureExclusionListener(
|
||||
mGestureExclusionListener, mDisplayId);
|
||||
} catch (RemoteException | IllegalArgumentException e) {
|
||||
Log.e(TAG, "Failed to register window manager callbacks", e);
|
||||
}
|
||||
@@ -801,7 +825,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
}
|
||||
}
|
||||
|
||||
Dependency.get(ProtoTracer.class).scheduleFrameUpdate();
|
||||
mProtoTracer.scheduleFrameUpdate();
|
||||
}
|
||||
|
||||
private void updateDisabledForQuickstep(Configuration newConfig) {
|
||||
@@ -822,8 +846,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||
}
|
||||
|
||||
private void updateDisplaySize() {
|
||||
WindowMetrics metrics = mContext.getSystemService(WindowManager.class)
|
||||
.getMaximumWindowMetrics();
|
||||
WindowMetrics metrics = mWindowManager.getMaximumWindowMetrics();
|
||||
Rect bounds = metrics.getBounds();
|
||||
mDisplaySize.set(bounds.width(), bounds.height());
|
||||
if (DEBUG_MISSING_GESTURE) {
|
||||
|
||||
@@ -36,6 +36,7 @@ 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;
|
||||
|
||||
@@ -67,6 +68,7 @@ public class NavigationBarButtonTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(OverviewProxyService.class);
|
||||
mDependency.injectMockDependency(KeyguardStateController.class);
|
||||
mDependency.injectMockDependency(NavigationBarController.class);
|
||||
mDependency.injectMockDependency(EdgeBackGestureHandler.class);
|
||||
mNavBar = new NavigationBarView(context, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ import com.android.systemui.accessibility.SystemActions;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.model.SysUiState;
|
||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.recents.OverviewProxyService;
|
||||
import com.android.systemui.recents.Recents;
|
||||
@@ -132,6 +133,7 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(StatusBarStateController.class);
|
||||
mDependency.injectMockDependency(NavigationBarController.class);
|
||||
mOverviewProxyService = mDependency.injectMockDependency(OverviewProxyService.class);
|
||||
mDependency.injectMockDependency(EdgeBackGestureHandler.class);
|
||||
TestableLooper.get(this).runWithLooper(() -> {
|
||||
mNavigationBar = createNavBar(mContext);
|
||||
mExternalDisplayNavigationBar = createNavBar(mSysuiTestableContextExternal);
|
||||
|
||||
@@ -32,9 +32,7 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.navigationbar.NavigationBarTransitions;
|
||||
import com.android.systemui.navigationbar.NavigationBarView;
|
||||
import com.android.systemui.navigationbar.NavigationModeController;
|
||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.recents.OverviewProxyService;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
@@ -60,6 +58,7 @@ public class NavigationBarTransitionsTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(StatusBarStateController.class);
|
||||
mDependency.injectMockDependency(KeyguardStateController.class);
|
||||
mDependency.injectMockDependency(NavigationBarController.class);
|
||||
mDependency.injectMockDependency(EdgeBackGestureHandler.class);
|
||||
doReturn(mContext)
|
||||
.when(mDependency.injectMockDependency(NavigationModeController.class))
|
||||
.getCurrentUserContext();
|
||||
|
||||
Reference in New Issue
Block a user