Merge "Use SystemUI config to easily adjust udfps haptics" into sc-v2-dev
This commit is contained in:
@@ -595,6 +595,17 @@
|
|||||||
280
|
280
|
||||||
</integer>
|
</integer>
|
||||||
|
|
||||||
|
<!-- Haptic feedback intensity for ticks used for the udfps dwell time -->
|
||||||
|
<item name="config_udfpsTickIntensity" translatable="false" format="float"
|
||||||
|
type="dimen">.5</item>
|
||||||
|
|
||||||
|
<!-- Haptic feedback delay between ticks used for udfps dwell time -->
|
||||||
|
<integer name="config_udfpsTickDelay" translatable="false">25</integer>
|
||||||
|
|
||||||
|
<!-- Haptic feedback tick type - if true, uses VibrationEffect.Composition.PRIMITIVE_LOW_TICK
|
||||||
|
else uses VibrationEffect.Composition.PRIMITIVE_TICK -->
|
||||||
|
<bool name="config_udfpsUseLowTick">true</bool>
|
||||||
|
|
||||||
<!-- package name of a built-in camera app to use to restrict implicit intent resolution
|
<!-- package name of a built-in camera app to use to restrict implicit intent resolution
|
||||||
when the double-press power gesture is used. Ignored if empty. -->
|
when the double-press power gesture is used. Ignored if empty. -->
|
||||||
<string translatable="false" name="config_cameraGesturePackage"></string>
|
<string translatable="false" name="config_cameraGesturePackage"></string>
|
||||||
|
|||||||
@@ -163,7 +163,10 @@ 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;
|
|
||||||
|
// by default, use low tick
|
||||||
|
private int mPrimitiveTick = VibrationEffect.Composition.PRIMITIVE_LOW_TICK;
|
||||||
|
private final VibrationEffect mTick;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES =
|
public static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES =
|
||||||
@@ -572,7 +575,7 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
mConfigurationController = configurationController;
|
mConfigurationController = configurationController;
|
||||||
mSystemClock = systemClock;
|
mSystemClock = systemClock;
|
||||||
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
||||||
mLowTick = lowTick();
|
mTick = lowTick();
|
||||||
|
|
||||||
mSensorProps = findFirstUdfps();
|
mSensorProps = findFirstUdfps();
|
||||||
// At least one UDFPS sensor exists
|
// At least one UDFPS sensor exists
|
||||||
@@ -608,22 +611,31 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VibrationEffect lowTick() {
|
private VibrationEffect lowTick() {
|
||||||
|
boolean useLowTickDefault = mContext.getResources()
|
||||||
|
.getBoolean(R.bool.config_udfpsUseLowTick);
|
||||||
|
if (Settings.Global.getFloat(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
"tick-low", useLowTickDefault ? 1 : 0) == 0) {
|
||||||
|
mPrimitiveTick = VibrationEffect.Composition.PRIMITIVE_TICK;
|
||||||
|
}
|
||||||
float tickIntensity = Settings.Global.getFloat(
|
float tickIntensity = Settings.Global.getFloat(
|
||||||
mContext.getContentResolver(), "low-tick-intensity", .5f);
|
mContext.getContentResolver(),
|
||||||
VibrationEffect.Composition composition = VibrationEffect.startComposition();
|
"tick-intensity",
|
||||||
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
|
mContext.getResources().getFloat(R.dimen.config_udfpsTickIntensity));
|
||||||
tickIntensity, 0);
|
|
||||||
int tickDelay = Settings.Global.getInt(
|
int tickDelay = Settings.Global.getInt(
|
||||||
mContext.getContentResolver(), "low-tick-delay", 25);
|
mContext.getContentResolver(),
|
||||||
|
"tick-delay",
|
||||||
|
mContext.getResources().getInteger(R.integer.config_udfpsTickDelay));
|
||||||
|
|
||||||
|
VibrationEffect.Composition composition = VibrationEffect.startComposition();
|
||||||
|
composition.addPrimitive(mPrimitiveTick, tickIntensity, 0);
|
||||||
int primitives = 1000 / tickDelay;
|
int primitives = 1000 / tickDelay;
|
||||||
float[] rampUp = new float[]{.48f, .58f, .69f, .83f};
|
float[] rampUp = new float[]{.48f, .58f, .69f, .83f};
|
||||||
for (int i = 0; i < rampUp.length; i++) {
|
for (int i = 0; i < rampUp.length; i++) {
|
||||||
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
|
composition.addPrimitive(mPrimitiveTick, tickIntensity * rampUp[i], tickDelay);
|
||||||
tickIntensity * rampUp[i], tickDelay);
|
|
||||||
}
|
}
|
||||||
for (int i = rampUp.length; i < primitives; i++) {
|
for (int i = rampUp.length; i < primitives; i++) {
|
||||||
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
|
composition.addPrimitive(mPrimitiveTick, tickIntensity, tickDelay);
|
||||||
tickIntensity, tickDelay);
|
|
||||||
}
|
}
|
||||||
return composition.compose();
|
return composition.compose();
|
||||||
}
|
}
|
||||||
@@ -637,7 +649,7 @@ public class UdfpsController implements DozeReceiver {
|
|||||||
mVibrator.vibrate(
|
mVibrator.vibrate(
|
||||||
Process.myUid(),
|
Process.myUid(),
|
||||||
mContext.getOpPackageName(),
|
mContext.getOpPackageName(),
|
||||||
mLowTick,
|
mTick,
|
||||||
"udfps-onStart-tick",
|
"udfps-onStart-tick",
|
||||||
VIBRATION_SONIFICATION_ATTRIBUTES);
|
VIBRATION_SONIFICATION_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user