Merge changes I59298139,If9519ae3 into main

* changes:
  Felix HAL: Move mActiveId_mutex as a private member.
  Felix HAL: Add Destructor to the vibrator HAL.
This commit is contained in:
Zouberou Sayibou 2024-12-17 22:43:58 -08:00 committed by Android (Google) Code Review
commit e0def5d0df
3 changed files with 16 additions and 2 deletions

View file

@ -203,7 +203,6 @@ enum vibe_state {
VIBE_STATE_ASP,
};
std::mutex mActiveId_mutex; // protects mActiveId
class DspMemChunk {
private:
@ -1335,6 +1334,17 @@ static void incrementIndex(int *index) {
*index += 1;
}
Vibrator::~Vibrator() {
if (isUnderExternalControl()) {
ALOGD("Disabling external control");
setExternalControl(false);
}
ALOGD("Turning off the vibrator");
off();
ALOGD("Waiting for mAsyncHandle to complete");
mAsyncHandle.wait();
}
ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle> &composite,
const std::shared_ptr<IVibratorCallback> &callback) {
ATRACE_NAME("Vibrator::composePwle");

View file

@ -153,6 +153,7 @@ class Vibrator : public BnVibrator {
Vibrator(std::unique_ptr<HwApi> hwApiDefault, std::unique_ptr<HwCal> hwCalDefault,
std::unique_ptr<HwApi> hwApiDual, std::unique_ptr<HwCal> hwCalDual,
std::unique_ptr<HwGPIO> hwgpio);
virtual ~Vibrator();
// BnVibrator APIs
ndk::ScopedAStatus getCapabilities(int32_t *_aidl_return) override;
@ -255,6 +256,7 @@ class Vibrator : public BnVibrator {
bool mConfigHapticAlsaDeviceDone{false};
bool mGPIOStatus;
bool mIsDual{false};
std::mutex mActiveId_mutex; // protects mActiveId
};
} // namespace vibrator

View file

@ -335,7 +335,9 @@ TEST_F(VibratorTest, Constructor) {
EXPECT_CALL(*mMockApi, destructor()).WillOnce(DoDefault());
EXPECT_CALL(*mMockCal, destructor()).WillOnce(DoDefault());
EXPECT_CALL(*mMockGpio, destructor()).WillOnce(DoDefault());
// Mock calls for the VIbrator destructor.
EXPECT_CALL(*mMockApi, recordEvent(_, _)).WillRepeatedly(DoDefault());
EXPECT_CALL(*mMockApi, setFFGain(_, ON_GLOBAL_SCALE)).WillOnce(DoDefault());
deleteVibrator(false);
createMock(&mockapi, &mockcal, &mockgpio);