Merge "Update UDFPS haptics take #1" into sc-v2-dev
This commit is contained in:
@@ -47,6 +47,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -162,6 +163,7 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
private boolean mOnFingerDown;
|
private boolean mOnFingerDown;
|
||||||
private boolean mAttemptedToDismissKeyguard;
|
private boolean mAttemptedToDismissKeyguard;
|
||||||
private Set<Callback> mCallbacks = new HashSet<>();
|
private Set<Callback> mCallbacks = new HashSet<>();
|
||||||
|
private final VibrationEffect mLowTick;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES =
|
public static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES =
|
||||||
@@ -171,6 +173,7 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
.setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY)
|
.setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
// haptic to use for successful device entry
|
||||||
public static final VibrationEffect EFFECT_CLICK =
|
public static final VibrationEffect EFFECT_CLICK =
|
||||||
VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
|
VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
|
||||||
|
|
||||||
@@ -276,6 +279,9 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mGoodCaptureReceived = true;
|
mGoodCaptureReceived = true;
|
||||||
|
if (mVibrator != null) {
|
||||||
|
mVibrator.cancel();
|
||||||
|
}
|
||||||
mView.stopIllumination();
|
mView.stopIllumination();
|
||||||
if (mServerRequest != null) {
|
if (mServerRequest != null) {
|
||||||
mServerRequest.onAcquiredGood();
|
mServerRequest.onAcquiredGood();
|
||||||
@@ -542,7 +548,6 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
@NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
|
@NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mExecution = execution;
|
mExecution = execution;
|
||||||
// TODO (b/185124905): inject main handler and vibrator once done prototyping
|
|
||||||
mVibrator = vibrator;
|
mVibrator = vibrator;
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
// The fingerprint manager is queried for UDFPS before this class is constructed, so the
|
// The fingerprint manager is queried for UDFPS before this class is constructed, so the
|
||||||
@@ -567,6 +572,7 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
mConfigurationController = configurationController;
|
mConfigurationController = configurationController;
|
||||||
mSystemClock = systemClock;
|
mSystemClock = systemClock;
|
||||||
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
||||||
|
mLowTick = lowTick();
|
||||||
|
|
||||||
mSensorProps = findFirstUdfps();
|
mSensorProps = findFirstUdfps();
|
||||||
// At least one UDFPS sensor exists
|
// At least one UDFPS sensor exists
|
||||||
@@ -601,6 +607,27 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
udfpsHapticsSimulator.setUdfpsController(this);
|
udfpsHapticsSimulator.setUdfpsController(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private VibrationEffect lowTick() {
|
||||||
|
float tickIntensity = Settings.Global.getFloat(
|
||||||
|
mContext.getContentResolver(), "low-tick-intensity", .5f);
|
||||||
|
VibrationEffect.Composition composition = VibrationEffect.startComposition();
|
||||||
|
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
|
||||||
|
tickIntensity, 0);
|
||||||
|
int tickDelay = Settings.Global.getInt(
|
||||||
|
mContext.getContentResolver(), "low-tick-delay", 25);
|
||||||
|
int primitives = 1000 / tickDelay;
|
||||||
|
float[] rampUp = new float[]{.48f, .58f, .69f, .83f};
|
||||||
|
for (int i = 0; i < rampUp.length; i++) {
|
||||||
|
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
|
||||||
|
tickIntensity * rampUp[i], tickDelay);
|
||||||
|
}
|
||||||
|
for (int i = rampUp.length; i < primitives; i++) {
|
||||||
|
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
|
||||||
|
tickIntensity, tickDelay);
|
||||||
|
}
|
||||||
|
return composition.compose();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play haptic to signal udfps scanning started.
|
* Play haptic to signal udfps scanning started.
|
||||||
*/
|
*/
|
||||||
@@ -610,8 +637,8 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
mVibrator.vibrate(
|
mVibrator.vibrate(
|
||||||
Process.myUid(),
|
Process.myUid(),
|
||||||
mContext.getOpPackageName(),
|
mContext.getOpPackageName(),
|
||||||
EFFECT_CLICK,
|
mLowTick,
|
||||||
"udfps-onStart",
|
"udfps-onStart-tick",
|
||||||
VIBRATION_SONIFICATION_ATTRIBUTES);
|
VIBRATION_SONIFICATION_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -998,6 +1025,7 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mOnFingerDown = false;
|
mOnFingerDown = false;
|
||||||
|
mVibrator.cancel();
|
||||||
if (mView.isIlluminationRequested()) {
|
if (mView.isIlluminationRequested()) {
|
||||||
mView.stopIllumination();
|
mView.stopIllumination();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,12 +642,12 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
|||||||
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
|
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
|
||||||
moveEvent.recycle();
|
moveEvent.recycle();
|
||||||
|
|
||||||
// THEN click haptic is played
|
// THEN low-tick haptic is played
|
||||||
verify(mVibrator).vibrate(
|
verify(mVibrator).vibrate(
|
||||||
anyInt(),
|
anyInt(),
|
||||||
anyString(),
|
anyString(),
|
||||||
eq(mUdfpsController.EFFECT_CLICK),
|
any(),
|
||||||
eq("udfps-onStart"),
|
eq("udfps-onStart-tick"),
|
||||||
eq(UdfpsController.VIBRATION_SONIFICATION_ATTRIBUTES));
|
eq(UdfpsController.VIBRATION_SONIFICATION_ATTRIBUTES));
|
||||||
|
|
||||||
// THEN make sure vibration attributes has so that it always will play the haptic,
|
// THEN make sure vibration attributes has so that it always will play the haptic,
|
||||||
|
|||||||
Reference in New Issue
Block a user