Loading vibrator/1.3/example/Vibrator.cpp +21 −4 Original line number Diff line number Diff line Loading @@ -56,27 +56,30 @@ Return<bool> Vibrator::supportsAmplitudeControl() { } Return<Status> Vibrator::setAmplitude(uint8_t amplitude) { if (!amplitude) { return Status::BAD_VALUE; } ALOGI("Amplitude: %u -> %u\n", mAmplitude, amplitude); mAmplitude = amplitude; return Status::OK; } Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) { return perform_1_1(static_cast<V1_1::Effect_1_1>(effect), strength, _hidl_cb); return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Methods from ::android::hardware::vibrator::V1_1::IVibrator follow. Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) { return perform_1_2(static_cast<V1_2::Effect>(effect), strength, _hidl_cb); return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Methods from ::android::hardware::vibrator::V1_2::IVibrator follow. Return<void> Vibrator::perform_1_2(V1_2::Effect effect, EffectStrength strength, perform_cb _hidl_cb) { return perform_1_3(static_cast<V1_3::Effect>(effect), strength, _hidl_cb); return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Methods from ::android::hardware::vibrator::V1_3::IVibrator follow. Loading @@ -98,6 +101,12 @@ Return<Status> Vibrator::setExternalControl(bool enabled) { } Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Private methods follow. Return<void> Vibrator::perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { uint8_t amplitude; uint32_t ms; Status status = Status::OK; Loading @@ -123,7 +132,15 @@ Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perfo return Void(); } // Private methods follow. template <typename T> Return<void> Vibrator::perform(T effect, EffectStrength strength, perform_cb _hidl_cb) { auto validRange = hidl_enum_range<T>(); if (effect < *validRange.begin() || effect > *std::prev(validRange.end())) { _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); return Void(); } return perform(static_cast<Effect>(effect), strength, _hidl_cb); } Status Vibrator::enable(bool enabled) { if (mExternalControl) { Loading vibrator/1.3/example/Vibrator.h +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,9 @@ class Vibrator : public IVibrator { Return<void> perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; private: Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb); template <typename T> Return<void> perform(T effect, EffectStrength strength, perform_cb _hidl_cb); Status enable(bool enabled); Status activate(uint32_t ms); void timeout(); Loading Loading
vibrator/1.3/example/Vibrator.cpp +21 −4 Original line number Diff line number Diff line Loading @@ -56,27 +56,30 @@ Return<bool> Vibrator::supportsAmplitudeControl() { } Return<Status> Vibrator::setAmplitude(uint8_t amplitude) { if (!amplitude) { return Status::BAD_VALUE; } ALOGI("Amplitude: %u -> %u\n", mAmplitude, amplitude); mAmplitude = amplitude; return Status::OK; } Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) { return perform_1_1(static_cast<V1_1::Effect_1_1>(effect), strength, _hidl_cb); return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Methods from ::android::hardware::vibrator::V1_1::IVibrator follow. Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) { return perform_1_2(static_cast<V1_2::Effect>(effect), strength, _hidl_cb); return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Methods from ::android::hardware::vibrator::V1_2::IVibrator follow. Return<void> Vibrator::perform_1_2(V1_2::Effect effect, EffectStrength strength, perform_cb _hidl_cb) { return perform_1_3(static_cast<V1_3::Effect>(effect), strength, _hidl_cb); return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Methods from ::android::hardware::vibrator::V1_3::IVibrator follow. Loading @@ -98,6 +101,12 @@ Return<Status> Vibrator::setExternalControl(bool enabled) { } Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { return perform<decltype(effect)>(effect, strength, _hidl_cb); } // Private methods follow. Return<void> Vibrator::perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { uint8_t amplitude; uint32_t ms; Status status = Status::OK; Loading @@ -123,7 +132,15 @@ Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perfo return Void(); } // Private methods follow. template <typename T> Return<void> Vibrator::perform(T effect, EffectStrength strength, perform_cb _hidl_cb) { auto validRange = hidl_enum_range<T>(); if (effect < *validRange.begin() || effect > *std::prev(validRange.end())) { _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); return Void(); } return perform(static_cast<Effect>(effect), strength, _hidl_cb); } Status Vibrator::enable(bool enabled) { if (mExternalControl) { Loading
vibrator/1.3/example/Vibrator.h +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,9 @@ class Vibrator : public IVibrator { Return<void> perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; private: Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb); template <typename T> Return<void> perform(T effect, EffectStrength strength, perform_cb _hidl_cb); Status enable(bool enabled); Status activate(uint32_t ms); void timeout(); Loading