From 8d220721957cdbd6619d5c2e870db42967935d47 Mon Sep 17 00:00:00 2001 From: Chase Wu Date: Mon, 21 Nov 2022 21:52:41 +0800 Subject: [PATCH] cs40l26: Add cancelSynced when prepare sync fail Also add more logs to improve the ability of debugging. Bug: 259012441 Test: scrolling the minute hand in alarm Change-Id: I93b9dc7999ef0285d66a54a4fa5b74f4b72150bc Signed-off-by: Chase Wu --- vibrator/cs40l26/Vibrator.cpp | 2 ++ vibrator/cs40l26/VibratorManager.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp index d290bc5..6b34a05 100644 --- a/vibrator/cs40l26/Vibrator.cpp +++ b/vibrator/cs40l26/Vibrator.cpp @@ -420,6 +420,7 @@ ndk::ScopedAStatus Vibrator::off() { const std::scoped_lock lock(mActiveId_mutex); if (mActiveId >= 0) { + ALOGV("Off: Stop the active effect: %d", mActiveId); /* Stop the active effect. */ if (!mHwApi->setFFPlay(mInputFd, mActiveId, false)) { ALOGE("Failed to stop effect %d (%d): %s", mActiveId, errno, strerror(errno)); @@ -1403,6 +1404,7 @@ void Vibrator::waitForComplete(std::shared_ptr &&callback) { } mSyncedCallback = nullptr; } + ALOGV("waitForComplete: Done"); } uint32_t Vibrator::intensityToVolLevel(float intensity, uint32_t effectIndex) { diff --git a/vibrator/cs40l26/VibratorManager.cpp b/vibrator/cs40l26/VibratorManager.cpp index 3bdad26..6530bf8 100644 --- a/vibrator/cs40l26/VibratorManager.cpp +++ b/vibrator/cs40l26/VibratorManager.cpp @@ -126,7 +126,8 @@ ndk::ScopedAStatus VibratorManager::prepareSynced(const std::vector &id if (ext->prepareSynced(callback).isOk()) { mSyncContext.emplace_back(id, callback->getFuture()); } else { - ALOGV("prepareSynced: Fail"); + cancelSynced(); + ALOGV("prepareSynced: Fail: %d", id); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); } }