Merge "cs40l26: remove alwaysOn support"

This commit is contained in:
TreeHugger Robot 2022-12-06 09:53:33 +00:00 committed by Android (Google) Code Review
commit d556489130
2 changed files with 8 additions and 109 deletions

View file

@ -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<Effect> *_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<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::getSupportedAlwaysOnEffects(std::vector<Effect> * /*_aidl_return*/) {
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::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);
}

View file

@ -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<Effect> kEffects{ndk::enum_range<Effect>().begin(),
ndk::enum_range<Effect>().end()};
const std::vector<EffectStrength> kEffectStrengths{ndk::enum_range<EffectStrength>().begin(),
@ -692,50 +672,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