Decouple HapticScale from ExternalVibratorService scale.
Use a conversion function rather than a static cast, and convert
to a properly typed HapticScale straight away, and all the way down to
where it's marshalled into the effect params.
Bug: 248993206
Test: presubmit, manual check scaling of audio-coupled ringtone
Change-Id: I588031ace0b3562cba50449b2147acaa6098af57
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 968b8fb..12cf70d 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -642,21 +642,22 @@
}
/* static */
-int AudioFlinger::onExternalVibrationStart(const sp<os::ExternalVibration>& externalVibration) {
+os::HapticScale AudioFlinger::onExternalVibrationStart(
+ const sp<os::ExternalVibration>& externalVibration) {
sp<os::IExternalVibratorService> evs = getExternalVibratorService();
if (evs != nullptr) {
int32_t ret;
binder::Status status = evs->onExternalVibrationStart(*externalVibration, &ret);
if (status.isOk()) {
ALOGD("%s, start external vibration with intensity as %d", __func__, ret);
- return ret;
+ return os::ExternalVibration::externalVibrationScaleToHapticScale(ret);
}
}
ALOGD("%s, start external vibration with intensity as MUTE due to %s",
__func__,
evs == nullptr ? "external vibration service not found"
: "error when querying intensity");
- return static_cast<int>(os::HapticScale::MUTE);
+ return os::HapticScale::MUTE;
}
/* static */