Merge "Make FalsingManager send out an event when second tap is required." into sc-dev

This commit is contained in:
Dave Mankoff
2021-04-26 19:22:47 +00:00
committed by Android (Google) Code Review
6 changed files with 57 additions and 2 deletions

View File

@@ -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();
}
}

View File

@@ -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, " ");

View File

@@ -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) {
}
}

View File

@@ -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);

View File

@@ -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;
@@ -545,6 +548,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,
@@ -592,6 +603,7 @@ public class NotificationPanelViewController extends PanelViewController {
statusBarKeyguardViewManager, latencyTracker, flingAnimationUtilsBuilder.get(),
statusBarTouchableRegionManager, ambientState);
mView = view;
mVibratorHelper = vibratorHelper;
mMetricsLogger = metricsLogger;
mActivityManager = activityManager;
mConfigurationController = configurationController;
@@ -4015,6 +4027,7 @@ public class NotificationPanelViewController extends PanelViewController {
// window, so
// force a call to onThemeChanged
mConfigurationListener.onThemeChanged();
mFalsingManager.addTapListener(mFalsingTapListener);
}
@Override
@@ -4023,6 +4036,7 @@ public class NotificationPanelViewController extends PanelViewController {
mStatusBarStateController.removeCallback(mStatusBarStateListener);
mConfigurationController.removeCallback(mConfigurationListener);
mUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
mFalsingManager.removeTapListener(mFalsingTapListener);
}
}

View File

@@ -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 */);