Move haptic from FaceAuthenticationClient to SysUI(1/2)
1. Set shouldVibrate flag as false to disable the haptic feedback 2. Add haptic when face authentication to systemui BUG: 231756704 Test: Check if the haptic is abnormal Change-Id: I243c1654bff9192474bd1f62d910d94ce193495b
This commit is contained in:
@@ -30,4 +30,5 @@
|
||||
lockscreen, setting this to true should come with customized drawables. -->
|
||||
<bool name="use_lock_pattern_drawable">false</bool>
|
||||
<bool name="resolver_landscape_phone">true</bool>
|
||||
<bool name="system_server_plays_face_haptics">true</bool>
|
||||
</resources>
|
||||
|
||||
@@ -4799,4 +4799,6 @@
|
||||
<java-symbol type="id" name="language_picker_header" />
|
||||
|
||||
<java-symbol type="dimen" name="status_bar_height_default" />
|
||||
|
||||
<java-symbol type="bool" name="system_server_plays_face_haptics" />
|
||||
</resources>
|
||||
|
||||
@@ -27,8 +27,11 @@ import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.metrics.LogMaker;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.os.Trace;
|
||||
import android.os.VibrationAttributes;
|
||||
import android.os.VibrationEffect;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -61,6 +64,7 @@ import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.VibratorHelper;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -83,6 +87,12 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
private static final String BIOMETRIC_WAKE_LOCK_NAME = "wake-and-unlock:wakelock";
|
||||
private static final UiEventLogger UI_EVENT_LOGGER = new UiEventLoggerImpl();
|
||||
private static final int FP_ATTEMPTS_BEFORE_SHOW_BOUNCER = 2;
|
||||
private static final VibrationEffect SUCCESS_VIBRATION_EFFECT =
|
||||
VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
|
||||
private static final VibrationEffect ERROR_VIBRATION_EFFECT =
|
||||
VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK);
|
||||
private static final VibrationAttributes HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES =
|
||||
VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK);
|
||||
|
||||
@IntDef(prefix = { "MODE_" }, value = {
|
||||
MODE_NONE,
|
||||
@@ -158,6 +168,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
private final NotificationShadeWindowController mNotificationShadeWindowController;
|
||||
private final SessionTracker mSessionTracker;
|
||||
private final int mConsecutiveFpFailureThreshold;
|
||||
private final boolean mShouldVibrate;
|
||||
private int mMode;
|
||||
private BiometricSourceType mBiometricType;
|
||||
private KeyguardViewController mKeyguardViewController;
|
||||
@@ -174,6 +185,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
private final AuthController mAuthController;
|
||||
private final StatusBarStateController mStatusBarStateController;
|
||||
private final LatencyTracker mLatencyTracker;
|
||||
private final VibratorHelper mVibratorHelper;
|
||||
|
||||
private long mLastFpFailureUptimeMillis;
|
||||
private int mNumConsecutiveFpFailures;
|
||||
@@ -278,7 +290,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
|
||||
SessionTracker sessionTracker,
|
||||
LatencyTracker latencyTracker,
|
||||
ScreenOffAnimationController screenOffAnimationController) {
|
||||
ScreenOffAnimationController screenOffAnimationController,
|
||||
VibratorHelper vibrator) {
|
||||
mPowerManager = powerManager;
|
||||
mShadeController = shadeController;
|
||||
mUpdateMonitor = keyguardUpdateMonitor;
|
||||
@@ -297,6 +310,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
mHandler = handler;
|
||||
mConsecutiveFpFailureThreshold = resources.getInteger(
|
||||
R.integer.fp_consecutive_failure_time_ms);
|
||||
mShouldVibrate = !(resources.getBoolean(
|
||||
com.android.internal.R.bool.system_server_plays_face_haptics));
|
||||
mKeyguardBypassController = keyguardBypassController;
|
||||
mKeyguardBypassController.setUnlockController(this);
|
||||
mMetricsLogger = metricsLogger;
|
||||
@@ -305,6 +320,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
|
||||
mSessionTracker = sessionTracker;
|
||||
mScreenOffAnimationController = screenOffAnimationController;
|
||||
mVibratorHelper = vibrator;
|
||||
|
||||
dumpManager.registerDumpable(getClass().getName(), this);
|
||||
}
|
||||
|
||||
@@ -407,8 +424,14 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
}
|
||||
|
||||
public void startWakeAndUnlock(BiometricSourceType biometricSourceType,
|
||||
boolean isStrongBiometric) {
|
||||
startWakeAndUnlock(calculateMode(biometricSourceType, isStrongBiometric));
|
||||
boolean isStrongBiometric) {
|
||||
int mode = calculateMode(biometricSourceType, isStrongBiometric);
|
||||
if (BiometricSourceType.FACE == biometricSourceType && (mode == MODE_WAKE_AND_UNLOCK
|
||||
|| mode == MODE_WAKE_AND_UNLOCK_PULSING || mode == MODE_UNLOCK_COLLAPSING
|
||||
|| mode == MODE_WAKE_AND_UNLOCK_FROM_DREAM || mode == MODE_DISMISS_BOUNCER)) {
|
||||
vibrateSuccess();
|
||||
}
|
||||
startWakeAndUnlock(mode);
|
||||
}
|
||||
|
||||
public void startWakeAndUnlock(@WakeAndUnlockMode int mode) {
|
||||
@@ -652,6 +675,11 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
mNumConsecutiveFpFailures = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (biometricSourceType == BiometricSourceType.FACE) {
|
||||
vibrateError();
|
||||
}
|
||||
|
||||
cleanup();
|
||||
}
|
||||
|
||||
@@ -674,9 +702,34 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
startWakeAndUnlock(MODE_SHOW_BOUNCER);
|
||||
UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId());
|
||||
}
|
||||
|
||||
if (biometricSourceType == BiometricSourceType.FACE) {
|
||||
vibrateError();
|
||||
}
|
||||
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void vibrateSuccess() {
|
||||
if (mShouldVibrate) {
|
||||
mVibratorHelper.vibrate(Process.myUid(),
|
||||
"com.android.systemui",
|
||||
SUCCESS_VIBRATION_EFFECT,
|
||||
getClass().getSimpleName() + "::success",
|
||||
HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
|
||||
private void vibrateError() {
|
||||
if (mShouldVibrate) {
|
||||
mVibratorHelper.vibrate(Process.myUid(),
|
||||
"com.android.systemui",
|
||||
ERROR_VIBRATION_EFFECT,
|
||||
getClass().getSimpleName() + "::error",
|
||||
HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
releaseBiometricWakeLock();
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.android.systemui.log.SessionTracker;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
import com.android.systemui.statusbar.VibratorHelper;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -115,6 +116,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
|
||||
private LatencyTracker mLatencyTracker;
|
||||
@Mock
|
||||
private ScreenOffAnimationController mScreenOffAnimationController;
|
||||
@Mock
|
||||
private VibratorHelper mVibratorHelper;
|
||||
private BiometricUnlockController mBiometricUnlockController;
|
||||
|
||||
@Before
|
||||
@@ -136,7 +139,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
|
||||
mMetricsLogger, mDumpManager, mPowerManager,
|
||||
mNotificationMediaManager, mWakefulnessLifecycle, mScreenLifecycle,
|
||||
mAuthController, mStatusBarStateController, mKeyguardUnlockAnimationController,
|
||||
mSessionTracker, mLatencyTracker, mScreenOffAnimationController);
|
||||
mSessionTracker, mLatencyTracker, mScreenOffAnimationController, mVibratorHelper);
|
||||
mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
|
||||
mBiometricUnlockController.setBiometricModeListener(mBiometricModeListener);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,10 @@ class FaceAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
super(context, lazyDaemon, token, listener, targetUserId, operationId, restricted,
|
||||
owner, cookie, requireConfirmation, sensorId, logger, biometricContext,
|
||||
isStrongBiometric, null /* taskStackListener */, lockoutCache,
|
||||
allowBackgroundAuthentication, true /* shouldVibrate */,
|
||||
allowBackgroundAuthentication,
|
||||
context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.system_server_plays_face_haptics)
|
||||
/* shouldVibrate */,
|
||||
isKeyguardBypassEnabled);
|
||||
setRequestId(requestId);
|
||||
mUsageStats = usageStats;
|
||||
|
||||
Reference in New Issue
Block a user