Make FalsingManager send out an event when second tap is required.
Bug: 185908806 Test: manual Change-Id: I33b704b0f5b4fded59214ab33dbafc8de89675ad
This commit is contained in:
@@ -58,7 +58,6 @@ public interface FalsingManager {
|
||||
/** Returns true if the gesture should be rejected. */
|
||||
boolean isFalseTouch(int interactionType);
|
||||
|
||||
|
||||
/**
|
||||
* Does basic checking to see if gesture looks like a tap.
|
||||
*
|
||||
@@ -127,8 +126,19 @@ public interface FalsingManager {
|
||||
/** Removes a {@link FalsingBeliefListener}. */
|
||||
void removeFalsingBeliefListener(FalsingBeliefListener listener);
|
||||
|
||||
/** Adds a {@link FalsingTapListener}. */
|
||||
void addTapListener(FalsingTapListener falsingTapListener);
|
||||
|
||||
/** Removes a {@link FalsingTapListener}. */
|
||||
void removeTapListener(FalsingTapListener falsingTapListener);
|
||||
|
||||
/** Listener that is alerted when falsing belief level crosses a predfined threshold. */
|
||||
interface FalsingBeliefListener {
|
||||
void onFalse();
|
||||
}
|
||||
|
||||
/** Listener that is alerted when a double tap is required to confirm a single tap. */
|
||||
interface FalsingTapListener {
|
||||
void onDoubleTapRequired();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
|
||||
private final Collection<FalsingClassifier> mClassifiers;
|
||||
private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
|
||||
private List<FalsingTapListener> mFalsingTapListeners = new ArrayList<>();
|
||||
|
||||
private final SessionListener mSessionListener = new SessionListener() {
|
||||
@Override
|
||||
@@ -277,6 +278,7 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
FalsingClassifier.Result.falsed(
|
||||
0, getClass().getSimpleName(), "bad history"));
|
||||
logDebug("False Single Tap: true (bad history)");
|
||||
mFalsingTapListeners.forEach(FalsingTapListener::onDoubleTapRequired);
|
||||
return true;
|
||||
} else {
|
||||
mPriorResults = Collections.singleton(FalsingClassifier.Result.passed(0.1));
|
||||
@@ -355,6 +357,16 @@ public class BrightLineFalsingManager implements FalsingManager {
|
||||
mFalsingBeliefListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTapListener(FalsingTapListener listener) {
|
||||
mFalsingTapListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTapListener(FalsingTapListener listener) {
|
||||
mFalsingTapListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
|
||||
|
||||
@@ -146,4 +146,14 @@ public class FalsingManagerFake implements FalsingManager {
|
||||
public void removeFalsingBeliefListener(FalsingBeliefListener listener) {
|
||||
mFalsingBeliefListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTapListener(FalsingTapListener falsingTapListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTapListener(FalsingTapListener falsingTapListener) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,16 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
|
||||
mInternalFalsingManager.removeFalsingBeliefListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTapListener(FalsingTapListener listener) {
|
||||
mInternalFalsingManager.addTapListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTapListener(FalsingTapListener listener) {
|
||||
mInternalFalsingManager.removeTapListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
|
||||
mInternalFalsingManager.onProximityEvent(proximityEvent);
|
||||
|
||||
@@ -53,6 +53,7 @@ import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserManager;
|
||||
import android.os.VibrationEffect;
|
||||
import android.service.quickaccesswallet.QuickAccessWalletClient;
|
||||
import android.util.Log;
|
||||
import android.util.MathUtils;
|
||||
@@ -101,6 +102,7 @@ import com.android.systemui.fragments.FragmentHostManager.FragmentListener;
|
||||
import com.android.systemui.media.MediaDataManager;
|
||||
import com.android.systemui.media.MediaHierarchyManager;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.FalsingManager.FalsingTapListener;
|
||||
import com.android.systemui.plugins.qs.DetailAdapter;
|
||||
import com.android.systemui.plugins.qs.QS;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
@@ -206,6 +208,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
private final ExpansionCallback mExpansionCallback = new ExpansionCallback();
|
||||
private final BiometricUnlockController mBiometricUnlockController;
|
||||
private final NotificationPanelView mView;
|
||||
private final VibratorHelper mVibratorHelper;
|
||||
private final MetricsLogger mMetricsLogger;
|
||||
private final ActivityManager mActivityManager;
|
||||
private final ConfigurationController mConfigurationController;
|
||||
@@ -543,6 +546,14 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
}
|
||||
};
|
||||
|
||||
private final FalsingTapListener mFalsingTapListener = new FalsingTapListener() {
|
||||
@Override
|
||||
public void onDoubleTapRequired() {
|
||||
showTransientIndication(R.string.notification_tap_again);
|
||||
mVibratorHelper.vibrate(VibrationEffect.EFFECT_STRENGTH_MEDIUM);
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
public NotificationPanelViewController(NotificationPanelView view,
|
||||
@Main Resources resources,
|
||||
@@ -590,6 +601,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
statusBarKeyguardViewManager, latencyTracker, flingAnimationUtilsBuilder.get(),
|
||||
statusBarTouchableRegionManager, ambientState);
|
||||
mView = view;
|
||||
mVibratorHelper = vibratorHelper;
|
||||
mMetricsLogger = metricsLogger;
|
||||
mActivityManager = activityManager;
|
||||
mConfigurationController = configurationController;
|
||||
@@ -3981,6 +3993,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
// window, so
|
||||
// force a call to onThemeChanged
|
||||
mConfigurationListener.onThemeChanged();
|
||||
mFalsingManager.addTapListener(mFalsingTapListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3989,6 +4002,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mStatusBarStateController.removeCallback(mStatusBarStateListener);
|
||||
mConfigurationController.removeCallback(mConfigurationListener);
|
||||
mUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
|
||||
mFalsingManager.removeTapListener(mFalsingTapListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -364,7 +364,6 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
|
||||
MetricsEvent.ACTION_LS_NOTE,
|
||||
0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */);
|
||||
mLockscreenGestureLogger.log(LockscreenUiEvent.LOCKSCREEN_NOTIFICATION_FALSE_TOUCH);
|
||||
mNotificationPanel.showTransientIndication(R.string.notification_tap_again);
|
||||
ActivatableNotificationView previousView = mNotificationPanel.getActivatedChild();
|
||||
if (previousView != null) {
|
||||
previousView.makeInactive(true /* animate */);
|
||||
|
||||
Reference in New Issue
Block a user