Merge "Custom haptic composition for assistant launched via button." into sc-dev

This commit is contained in:
Daniel Sandler
2021-04-01 15:41:57 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 1 deletions

View File

@@ -128,6 +128,12 @@ public class HapticFeedbackConstants {
*/
public static final int SAFE_MODE_ENABLED = 10001;
/**
* Invocation of the voice assistant via hardware button.
* @hide
*/
public static final int ASSISTANT_BUTTON = 10002;
/**
* Flag for {@link View#performHapticFeedback(int, int)
* View.performHapticFeedback(int, int)}: Ignore the setting in the

View File

@@ -1092,7 +1092,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
break;
case LONG_PRESS_POWER_ASSISTANT:
mPowerKeyHandled = true;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false,
performHapticFeedback(HapticFeedbackConstants.ASSISTANT_BUTTON, false,
"Power - Long Press - Go To Assistant");
final int powerKeyDeviceId = Integer.MIN_VALUE;
launchAssistAction(null, powerKeyDeviceId, eventTime);
@@ -5073,6 +5073,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
pattern = mSafeModeEnabledVibePattern;
break;
case HapticFeedbackConstants.ASSISTANT_BUTTON:
if (mVibrator.areAllPrimitivesSupported(
VibrationEffect.Composition.PRIMITIVE_QUICK_RISE)) {
// quiet ramp, short pause, then sharp tick
return VibrationEffect.startComposition()
.addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, 0.25f)
.addPrimitive(VibrationEffect.Composition.PRIMITIVE_TICK, 1f, 50)
.compose();
}
// fallback for devices without composition support
return VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK);
default:
return null;
}