From bf5a2f2c4b69b0954d7d5fbd0c17ce5eb223f91f Mon Sep 17 00:00:00 2001 From: Tai Kuo Date: Wed, 14 Sep 2022 23:30:50 +0800 Subject: [PATCH] cs40l26: remove alwaysOn support Bug: 246772422 Test: atest PtsVibratorHalTestSuite Test: atest VibratorHalCs40l26TestSuite Change-Id: I1513da7f51f380227742200baf5ec0b41da2f374 --- vibrator/cs40l26/Vibrator.cpp | 53 +++----------------- vibrator/cs40l26/tests/test-vibrator.cpp | 64 ------------------------ 2 files changed, 8 insertions(+), 109 deletions(-) diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp index 7ccaad8..fa29bb8 100644 --- a/vibrator/cs40l26/Vibrator.cpp +++ b/vibrator/cs40l26/Vibrator.cpp @@ -111,11 +111,6 @@ static uint16_t amplitudeToScale(float amplitude, float maximum) { return std::round(ratio); } -enum class AlwaysOnId : uint32_t { - GPIO_RISE, - GPIO_FALL, -}; - enum WaveformBankID : uint8_t { RAM_WVFRM_BANK, ROM_WVFRM_BANK, @@ -412,8 +407,8 @@ ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) { ATRACE_NAME("Vibrator::getCapabilities"); int32_t ret = IVibrator::CAP_ON_CALLBACK | IVibrator::CAP_PERFORM_CALLBACK | - IVibrator::CAP_AMPLITUDE_CONTROL | IVibrator::CAP_ALWAYS_ON_CONTROL | - IVibrator::CAP_GET_RESONANT_FREQUENCY | IVibrator::CAP_GET_Q_FACTOR; + IVibrator::CAP_AMPLITUDE_CONTROL | IVibrator::CAP_GET_RESONANT_FREQUENCY | + IVibrator::CAP_GET_Q_FACTOR; if (hasHapticAlsaDevice()) { ret |= IVibrator::CAP_EXTERNAL_CONTROL; } else { @@ -720,47 +715,15 @@ ndk::ScopedAStatus Vibrator::setGlobalAmplitude(bool set) { return setEffectAmplitude(amplitude, VOLTAGE_SCALE_MAX); } -ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector *_aidl_return) { - *_aidl_return = {Effect::TEXTURE_TICK, Effect::TICK, Effect::CLICK, Effect::HEAVY_CLICK}; - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t id, Effect effect, EffectStrength strength) { - ndk::ScopedAStatus status; - uint32_t effectIndex; - uint32_t timeMs; - uint32_t volLevel; - uint16_t scale; - status = getSimpleDetails(effect, strength, &effectIndex, &timeMs, &volLevel); - if (!status.isOk()) { - return status; - } - - scale = amplitudeToScale(volLevel, VOLTAGE_SCALE_MAX); - - switch (static_cast(id)) { - case AlwaysOnId::GPIO_RISE: - // mHwApi->setGpioRiseIndex(effectIndex); - // mHwApi->setGpioRiseScale(scale); - return ndk::ScopedAStatus::ok(); - case AlwaysOnId::GPIO_FALL: - // mHwApi->setGpioFallIndex(effectIndex); - // mHwApi->setGpioFallScale(scale); - return ndk::ScopedAStatus::ok(); - } - +ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector * /*_aidl_return*/) { return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } -ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t id) { - switch (static_cast(id)) { - case AlwaysOnId::GPIO_RISE: - // mHwApi->setGpioRiseIndex(0); - return ndk::ScopedAStatus::ok(); - case AlwaysOnId::GPIO_FALL: - // mHwApi->setGpioFallIndex(0); - return ndk::ScopedAStatus::ok(); - } +ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/, + EffectStrength /*strength*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} +ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t /*id*/) { return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } diff --git a/vibrator/cs40l26/tests/test-vibrator.cpp b/vibrator/cs40l26/tests/test-vibrator.cpp index 252e413..895b085 100644 --- a/vibrator/cs40l26/tests/test-vibrator.cpp +++ b/vibrator/cs40l26/tests/test-vibrator.cpp @@ -547,26 +547,6 @@ TEST_P(EffectsTest, perform) { } } -TEST_P(EffectsTest, alwaysOnEnable) { - // No real function now in P22+ - auto param = GetParam(); - auto effect = std::get<0>(param); - auto strength = std::get<1>(param); - auto scale = EFFECT_SCALE.find(param); - bool supported = (scale != EFFECT_SCALE.end()); - - if (supported) { - // Do nothing - } - - ndk::ScopedAStatus status = mVibrator->alwaysOnEnable(0, effect, strength); - if (supported) { - EXPECT_EQ(EX_NONE, status.getExceptionCode()); - } else { - EXPECT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode()); - } -} - const std::vector kEffects{ndk::enum_range().begin(), ndk::enum_range().end()}; const std::vector kEffectStrengths{ndk::enum_range().begin(), @@ -692,50 +672,6 @@ const std::vector kComposeParams = { INSTANTIATE_TEST_CASE_P(VibratorTests, ComposeTest, ValuesIn(kComposeParams.begin(), kComposeParams.end()), ComposeTest::PrintParam); - -class AlwaysOnTest : public VibratorTest, public WithParamInterface { - public: - static auto PrintParam(const TestParamInfo &info) { - return std::to_string(info.param); - } -}; - -TEST_P(AlwaysOnTest, alwaysOnEnable) { - auto param = GetParam(); - auto scale = EFFECT_SCALE.begin(); - - std::advance(scale, std::rand() % EFFECT_SCALE.size()); - - auto effect = std::get<0>(scale->first); - auto strength = std::get<1>(scale->first); - - switch (param) { - case 0: - case 1: - // Do nothing - break; - } - - ndk::ScopedAStatus status = mVibrator->alwaysOnEnable(param, effect, strength); - EXPECT_EQ(EX_NONE, status.getExceptionCode()); -} - -TEST_P(AlwaysOnTest, alwaysOnDisable) { - auto param = GetParam(); - - switch (param) { - case 0: - case 1: - // Do nothing - break; - } - - ndk::ScopedAStatus status = mVibrator->alwaysOnDisable(param); - EXPECT_EQ(EX_NONE, status.getExceptionCode()); -} - -INSTANTIATE_TEST_CASE_P(VibratorTests, AlwaysOnTest, Range(0, 1), AlwaysOnTest::PrintParam); - } // namespace vibrator } // namespace hardware } // namespace android