cs40l26: Improve the vibrator manager stability
1. Add the return check when doing the prepareSynced process. 2. Add more debugging log pattern 3. Correst the corner case when doing the erase process Bug: 258391756 Test: command in the bug Change-Id: Ib6e189cca66f67b0501299cdb1a8c2572215a70e Signed-off-by: Chase Wu <chasewu@google.com>
This commit is contained in:
parent
8b013cbb70
commit
a5ab84ba2a
2 changed files with 17 additions and 9 deletions
|
@ -434,7 +434,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;
|
||||
|
@ -1382,10 +1382,12 @@ void Vibrator::waitForComplete(std::shared_ptr<IVibratorCallback> &&callback) {
|
|||
(!mHwApi->eraseOwtEffect(mInputFd, mActiveId, &mFfEffects))) {
|
||||
ALOGE("Failed to clean up the composed effect %d", mActiveId);
|
||||
}
|
||||
|
||||
mHwApi->clearTrigBtn(mInputFd, &mFfEffects[mActiveId], mActiveId);
|
||||
|
||||
mActiveId = -1;
|
||||
if (mActiveId >= 0) {
|
||||
mHwApi->clearTrigBtn(mInputFd, &mFfEffects[mActiveId], mActiveId);
|
||||
mActiveId = -1;
|
||||
} else {
|
||||
ALOGV("waitForComplete: Vibrator is already off");
|
||||
}
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
|
|
|
@ -101,7 +101,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);
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,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);
|
||||
|
||||
mSyncContext.emplace_back(id, callback->getFuture());
|
||||
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 {
|
||||
|
@ -138,6 +142,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);
|
||||
|
@ -171,6 +176,7 @@ ndk::ScopedAStatus VibratorManager::triggerSynced(
|
|||
ndk::ScopedAStatus VibratorManager::cancelSynced() {
|
||||
ATRACE_NAME("VibratorManager::cancelSynced");
|
||||
|
||||
ALOGV("Do cancelSynced");
|
||||
mHwApi->setTrigger(false);
|
||||
{
|
||||
std::shared_lock lock(mContextMutex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue