summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-31 02:05:32 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-31 02:05:32 +0000
commit27d1e22ca357c72d813e146e298186b962b2bd43 (patch)
tree9eca0c76b18f3e180614f2d8e38db020c42e1326
parentb2b2016ddde0bed280f0e7055a98d9f476796ae9 (diff)
parentd1573663edbf3c486ef89ce92064ff4a9d743b66 (diff)
downloadpixel-android12-d1-s3-release.tar.gz
Change-Id: If17281c92bf7a79ee8adf82f67a385a1c86f0e00
-rw-r--r--vibrator/cs40l25/Vibrator.cpp27
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);