diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-31 02:05:32 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-31 02:05:32 +0000 |
commit | 27d1e22ca357c72d813e146e298186b962b2bd43 (patch) | |
tree | 9eca0c76b18f3e180614f2d8e38db020c42e1326 | |
parent | b2b2016ddde0bed280f0e7055a98d9f476796ae9 (diff) | |
parent | d1573663edbf3c486ef89ce92064ff4a9d743b66 (diff) | |
download | pixel-android12-d1-s3-release.tar.gz |
Merge cherrypicks of [15721650, 15722323, 15721651, 15722211, 15719975, 15722214, 15722327, 15722329, 15722504, 15722519, 15722520, 15722521] into sc-d1-releaseandroid-12.0.0_r7android-12.0.0_r6android-12.0.0_r5android-12.0.0_r4android-12.0.0_r15android-12.0.0_r14android-12.0.0_r13android-12.0.0_r12android12-d1-s6-releaseandroid12-d1-s5-releaseandroid12-d1-s4-releaseandroid12-d1-s3-releaseandroid12-d1-s2-releaseandroid12-d1-s1-releaseandroid12-d1-release
Change-Id: If17281c92bf7a79ee8adf82f67a385a1c86f0e00
-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); |