summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2022-09-19 15:09:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-09-19 15:09:17 +0000
commit7aff26e3212741fca12fa2fc91583ac8759a0665 (patch)
tree87f2e46e858d5a3cc57f08d4cee03df7894c2d92
parentd09fb3c9e07040dd785cfba6456f3e4266e5d523 (diff)
parent04e3b0ec409b6e593666dfb7e8c69339798072a3 (diff)
Merge "cs40l26: remove alwaysOn support" into tm-qpr-dev
-rw-r--r--vibrator/cs40l26/Vibrator.cpp51
-rw-r--r--vibrator/cs40l26/tests/test-vibrator.cpp64
2 files changed, 7 insertions, 108 deletions
diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp
index 442aa8c..fde3377 100644
--- a/vibrator/cs40l26/Vibrator.cpp
+++ b/vibrator/cs40l26/Vibrator.cpp
@@ -100,11 +100,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,
@@ -375,8 +370,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 {
@@ -683,47 +678,15 @@ ndk::ScopedAStatus Vibrator::setGlobalAmplitude(bool set) {
return setEffectAmplitude(amplitude, VOLTAGE_SCALE_MAX);
}
-ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect> *_aidl_return) {
- *_aidl_return = {Effect::TEXTURE_TICK, Effect::TICK, Effect::CLICK, Effect::HEAVY_CLICK};
- return ndk::ScopedAStatus::ok();
+ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect> * /*_aidl_return*/) {
+ return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
-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<AlwaysOnId>(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::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/,
+ EffectStrength /*strength*/) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
-ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t id) {
- switch (static_cast<AlwaysOnId>(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::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 0cb594a..80a132f 100644
--- a/vibrator/cs40l26/tests/test-vibrator.cpp
+++ b/vibrator/cs40l26/tests/test-vibrator.cpp
@@ -549,26 +549,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<Effect> kEffects{ndk::enum_range<Effect>().begin(),
ndk::enum_range<Effect>().end()};
const std::vector<EffectStrength> kEffectStrengths{ndk::enum_range<EffectStrength>().begin(),
@@ -694,50 +674,6 @@ const std::vector<ComposeParam> kComposeParams = {
INSTANTIATE_TEST_CASE_P(VibratorTests, ComposeTest,
ValuesIn(kComposeParams.begin(), kComposeParams.end()),
ComposeTest::PrintParam);
-
-class AlwaysOnTest : public VibratorTest, public WithParamInterface<int32_t> {
- public:
- static auto PrintParam(const TestParamInfo<ParamType> &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