Implement Envelope Effect Limitations APIs
Implement APIs to support envelope effect limits in VibratorHalWrapper.
Bug: 347034419
Flag: android.os.vibrator.normalized_pwle_effects
Test: libvibratorservice_test
Change-Id: I3d45f09740754b5e120bae2ecffa9d150e66e85d
diff --git a/services/vibratorservice/VibratorHalWrapper.cpp b/services/vibratorservice/VibratorHalWrapper.cpp
index 3d8124b..4ac1618 100644
--- a/services/vibratorservice/VibratorHalWrapper.cpp
+++ b/services/vibratorservice/VibratorHalWrapper.cpp
@@ -96,6 +96,17 @@
if (mInfoCache.mMaxAmplitudes.isFailed()) {
mInfoCache.mMaxAmplitudes = getMaxAmplitudesInternal();
}
+ if (mInfoCache.mMaxEnvelopeEffectSize.isFailed()) {
+ mInfoCache.mMaxEnvelopeEffectSize = getMaxEnvelopeEffectSizeInternal();
+ }
+ if (mInfoCache.mMinEnvelopeEffectControlPointDuration.isFailed()) {
+ mInfoCache.mMinEnvelopeEffectControlPointDuration =
+ getMinEnvelopeEffectControlPointDurationInternal();
+ }
+ if (mInfoCache.mMaxEnvelopeEffectControlPointDuration.isFailed()) {
+ mInfoCache.mMaxEnvelopeEffectControlPointDuration =
+ getMaxEnvelopeEffectControlPointDurationInternal();
+ }
return mInfoCache.get();
}
@@ -210,6 +221,23 @@
ALOGV("Skipped getMaxAmplitudes because it's not available in Vibrator HAL");
return HalResult<std::vector<float>>::unsupported();
}
+HalResult<int32_t> HalWrapper::getMaxEnvelopeEffectSizeInternal() {
+ ALOGV("Skipped getMaxEnvelopeEffectSizeInternal because it's not available "
+ "in Vibrator HAL");
+ return HalResult<int32_t>::unsupported();
+}
+
+HalResult<milliseconds> HalWrapper::getMinEnvelopeEffectControlPointDurationInternal() {
+ ALOGV("Skipped getMinEnvelopeEffectControlPointDurationInternal because it's not "
+ "available in Vibrator HAL");
+ return HalResult<milliseconds>::unsupported();
+}
+
+HalResult<milliseconds> HalWrapper::getMaxEnvelopeEffectControlPointDurationInternal() {
+ ALOGV("Skipped getMaxEnvelopeEffectControlPointDurationInternal because it's not "
+ "available in Vibrator HAL");
+ return HalResult<milliseconds>::unsupported();
+}
// -------------------------------------------------------------------------------------------------
@@ -441,6 +469,24 @@
return HalResultFactory::fromStatus<std::vector<float>>(std::move(status), amplitudes);
}
+HalResult<int32_t> AidlHalWrapper::getMaxEnvelopeEffectSizeInternal() {
+ int32_t size = 0;
+ auto status = getHal()->getPwleV2CompositionSizeMax(&size);
+ return HalResultFactory::fromStatus<int32_t>(std::move(status), size);
+}
+
+HalResult<milliseconds> AidlHalWrapper::getMinEnvelopeEffectControlPointDurationInternal() {
+ int32_t durationMs = 0;
+ auto status = getHal()->getPwleV2PrimitiveDurationMinMillis(&durationMs);
+ return HalResultFactory::fromStatus<milliseconds>(std::move(status), milliseconds(durationMs));
+}
+
+HalResult<milliseconds> AidlHalWrapper::getMaxEnvelopeEffectControlPointDurationInternal() {
+ int32_t durationMs = 0;
+ auto status = getHal()->getPwleV2PrimitiveDurationMaxMillis(&durationMs);
+ return HalResultFactory::fromStatus<milliseconds>(std::move(status), milliseconds(durationMs));
+}
+
std::shared_ptr<Aidl::IVibrator> AidlHalWrapper::getHal() {
std::lock_guard<std::mutex> lock(mHandleMutex);
return mHandle;