Add adaptive haptics scaling to external vibrations
Converting the usage of haptic intensity, which only covers the scale
level, to HapticScale which includes both scale level and adaptive
haptics scale.
Bug: 305957324
Test: N/A
Change-Id: Ib3a5b83e20707207affbbe6dbc0586669ae4841b
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index 826ba65..6c22e21 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -174,15 +174,15 @@
void setHapticPlaybackEnabled(bool hapticPlaybackEnabled) final {
mHapticPlaybackEnabled = hapticPlaybackEnabled;
}
- /** Return at what intensity to play haptics, used in mixer. */
- os::HapticScale getHapticIntensity() const final { return mHapticIntensity; }
+ /** Return the haptics scale, used in mixer. */
+ os::HapticScale getHapticScale() const final { return mHapticScale; }
/** Return the maximum amplitude allowed for haptics data, used in mixer. */
float getHapticMaxAmplitude() const final { return mHapticMaxAmplitude; }
/** Set intensity of haptic playback, should be set after querying vibrator service. */
- void setHapticIntensity(os::HapticScale hapticIntensity) final {
- if (os::isValidHapticScale(hapticIntensity)) {
- mHapticIntensity = hapticIntensity;
- setHapticPlaybackEnabled(mHapticIntensity != os::HapticScale::MUTE);
+ void setHapticScale(os::HapticScale hapticScale) final {
+ if (os::isValidHapticScale(hapticScale)) {
+ mHapticScale = hapticScale;
+ setHapticPlaybackEnabled(!mHapticScale.isScaleMute());
}
}
/** Set maximum amplitude allowed for haptic data, should be set after querying
@@ -329,8 +329,8 @@
sp<OpPlayAudioMonitor> mOpPlayAudioMonitor;
bool mHapticPlaybackEnabled = false; // indicates haptic playback enabled or not
- // intensity to play haptic data
- os::HapticScale mHapticIntensity = os::HapticScale::MUTE;
+ // scale to play haptic data
+ os::HapticScale mHapticScale = os::HapticScale::mute();
// max amplitude allowed for haptic data
float mHapticMaxAmplitude = NAN;
class AudioVibrationController : public os::BnExternalVibrationController {