Upgrade vibrator to HAL 1.2

Bug: 64184692
Test: build, flash and play with device
Change-Id: I44d82371e6a6d7dc7e05e740aa5f2fdb5c3f8df6
This commit is contained in:
Michael Wright
2018-01-29 14:54:37 +00:00
committed by Steven Moreland
parent 87b0264022
commit 3e8e659997
10 changed files with 57 additions and 52 deletions

View File

@@ -33,7 +33,7 @@
namespace android {
namespace hardware {
namespace vibrator {
namespace V1_1 {
namespace V1_2 {
namespace implementation {
static constexpr int8_t MAX_RTP_INPUT = 127;
@@ -116,7 +116,7 @@ Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWavef
return Status::OK;
}
// Methods from ::android::hardware::vibrator::V1_1::IVibrator follow.
// Methods from ::android::hardware::vibrator::V1_2::IVibrator follow.
Return<Status> Vibrator::on(uint32_t timeoutMs) {
return on(timeoutMs, false /* forceOpenLoop */, false /* isWaveform */);
}
@@ -158,7 +158,7 @@ static uint8_t convertEffectStrength(EffectStrength strength) {
switch (strength) {
case EffectStrength::LIGHT:
scale = 1; // 50%
scale = 2; // 50%
break;
case EffectStrength::MEDIUM:
case EffectStrength::STRONG:
@@ -169,52 +169,49 @@ static uint8_t convertEffectStrength(EffectStrength strength) {
return scale;
}
Return<void> Vibrator::perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
}
Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength,
perform_cb _hidl_cb) {
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
}
Return<void> Vibrator::perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
}
Return<void> Vibrator::performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
Status status = Status::OK;
uint32_t timeMS;
if (effect == Effect::CLICK) {
switch (effect) {
case Effect::CLICK:
mSequencer << WAVEFORM_CLICK_EFFECT_SEQ << std::endl;
timeMS = mClickDuration;
} else if (effect == Effect::DOUBLE_CLICK) {
break;
case Effect::DOUBLE_CLICK:
mSequencer << WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ << std::endl;
timeMS = WAVEFORM_DOUBLE_CLICK_EFFECT_MS;
} else {
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
return Void();
}
mScale << convertEffectStrength(strength) << std::endl;
on(timeMS, true /* forceOpenLoop */, true /* isWaveform */);
_hidl_cb(status, timeMS);
return Void();
}
Return<void> Vibrator::perform_1_1(Effect_1_1 effect, EffectStrength strength,
perform_cb _hidl_cb) {
Status status = Status::OK;
uint32_t timeMS;
if (effect == Effect_1_1::TICK) {
break;
case Effect::TICK:
mSequencer << WAVEFORM_TICK_EFFECT_SEQ << std::endl;
timeMS = mTickDuration;
} else if (effect < Effect_1_1::TICK) {
return perform(static_cast<Effect>(effect), strength, _hidl_cb);
} else {
break;
default:
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
return Void();
}
mScale << convertEffectStrength(strength) << std::endl;
on(timeMS, true /* forceOpenLoop */, true /* isWaveform */);
_hidl_cb(status, timeMS);
return Void();
}
} // namespace implementation
} // namespace V1_1
} // namespace V1_2
} // namespace vibrator
} // namespace hardware
} // namespace android