Merge "cs40l26: Improve the vibrator manager stability" into tm-qpr-dev am: ee8e70c340 am: 0a60197d7c

Original change: https://googleplex-android-review.googlesource.com/c/device/google/felix/+/20414375

Change-Id: I37115166b5b4fecdd32fc27be391424ad83723bd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot 2022-11-11 04:41:26 +00:00 committed by Automerger Merge Worker
commit d5ab577902
2 changed files with 17 additions and 9 deletions

View file

@ -422,7 +422,7 @@ ndk::ScopedAStatus Vibrator::off() {
mHwApi->clearTrigBtn(mInputFd, &mFfEffects[mActiveId], mActiveId);
} else {
ALOGV("Vibrator is already off");
ALOGV("Off: Vibrator is already off");
}
mActiveId = -1;
@ -1370,10 +1370,12 @@ void Vibrator::waitForComplete(std::shared_ptr<IVibratorCallback> &&callback) {
(!mHwApi->eraseOwtEffect(mInputFd, mActiveId, &mFfEffects))) {
ALOGE("Failed to clean up the composed effect %d", mActiveId);
}
if (mActiveId >= 0) {
mHwApi->clearTrigBtn(mInputFd, &mFfEffects[mActiveId], mActiveId);
mActiveId = -1;
} else {
ALOGV("waitForComplete: Vibrator is already off");
}
}
if (callback) {

View file

@ -89,7 +89,7 @@ ndk::ScopedAStatus VibratorManager::prepareSynced(const std::vector<int32_t> &id
ATRACE_NAME("VibratorManager::prepareSynced");
if (!mGPIOStatus) {
ALOGE("GetVibrator: GPIO status error");
ALOGE("prepareSynced: GPIO status error");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
@ -111,10 +111,14 @@ ndk::ScopedAStatus VibratorManager::prepareSynced(const std::vector<int32_t> &id
auto &[vib, ext] = mVibrators.at(id);
auto callback = sp<VibratorSyncCallback>::make();
ext->prepareSynced(callback);
if (ext->prepareSynced(callback).isOk()) {
mSyncContext.emplace_back(id, callback->getFuture());
} else {
ALOGV("prepareSynced: Fail");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
}
ALOGV("prepareSynced: Done");
if (mHwApi->initGPIO()) {
return ndk::ScopedAStatus::ok();
} else {
@ -126,6 +130,7 @@ ndk::ScopedAStatus VibratorManager::prepareSynced(const std::vector<int32_t> &id
ndk::ScopedAStatus VibratorManager::triggerSynced(
const std::shared_ptr<IVibratorCallback> &callback) {
ATRACE_NAME("VibratorManager::triggerSynced");
ALOGV("TriggerSynced");
if (isBusy()) {
ALOGE("TriggerSynced isBusy");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
@ -159,6 +164,7 @@ ndk::ScopedAStatus VibratorManager::triggerSynced(
ndk::ScopedAStatus VibratorManager::cancelSynced() {
ATRACE_NAME("VibratorManager::cancelSynced");
ALOGV("Do cancelSynced");
mHwApi->setTrigger(false);
{
std::shared_lock lock(mContextMutex);