diff options
author | chasewu <chasewu@google.com> | 2021-08-30 01:30:16 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-08-30 01:30:16 +0000 |
commit | 2f56f5f47a6b97e8a617324039fc81f9b2476241 (patch) | |
tree | 9eca0c76b18f3e180614f2d8e38db020c42e1326 | |
parent | cd3295f32ca1ef5fc55b668416d643358e21c86a (diff) | |
parent | 4d23aaa3a31441bc0fb3774c26705fe7d8c36770 (diff) | |
download | pixel-2f56f5f47a6b97e8a617324039fc81f9b2476241.tar.gz |
vibrator: Checking the external control before trigger haptics am: 4d23aaa3a3android-mainline-12.0.0_r99android-mainline-12.0.0_r77android-mainline-12.0.0_r70android-mainline-12.0.0_r63android-mainline-12.0.0_r59android-mainline-12.0.0_r49android-mainline-12.0.0_r122android-mainline-12.0.0_r100android12-mainline-networkstack-release
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/pixel/+/15674268
Change-Id: Ib66464968e8869e70d96550a6b12e77db5b71c78
-rw-r--r-- | vibrator/cs40l25/Vibrator.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vibrator/cs40l25/Vibrator.cpp b/vibrator/cs40l25/Vibrator.cpp index d3da217b..826a28d8 100644 --- a/vibrator/cs40l25/Vibrator.cpp +++ b/vibrator/cs40l25/Vibrator.cpp @@ -234,6 +234,7 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal) } createPwleMaxLevelLimitMap(); + mIsUnderExternalControl = false; } ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) { @@ -309,6 +310,27 @@ ndk::ScopedAStatus Vibrator::setExternalControl(bool enabled) { ATRACE_NAME("Vibrator::setExternalControl"); setGlobalAmplitude(enabled); + if (isUnderExternalControl() == enabled) { + if (enabled) { + ALOGE("Restart the external process."); + if (mHasHapticAlsaDevice) { + if (!enableHapticPcmAmp(&mHapticPcm, !enabled, mCard, mDevice)) { + ALOGE("Failed to %s haptic pcm device: %d", (enabled ? "enable" : "disable"), + mDevice); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); + } + } + if (mHwApi->hasAspEnable()) { + if (!mHwApi->setAspEnable(!enabled)) { + ALOGE("Failed to set external control (%d): %s", errno, strerror(errno)); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); + } + } + } else { + ALOGE("The external control is already disabled."); + return ndk::ScopedAStatus::ok(); + } + } if (mHasHapticAlsaDevice) { if (!enableHapticPcmAmp(&mHapticPcm, enabled, mCard, mDevice)) { ALOGE("Failed to %s haptic pcm device: %d", (enabled ? "enable" : "disable"), mDevice); @@ -415,6 +437,11 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect> &composi ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, const std::shared_ptr<IVibratorCallback> &callback) { + if (isUnderExternalControl()) { + setExternalControl(false); + ALOGE("Device is under external control mode. Force to disable it to prevent chip hang " + "problem."); + } if (mAsyncHandle.wait_for(ASYNC_COMPLETION_TIMEOUT) != std::future_status::ready) { ALOGE("Previous vibration pending."); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); |