/* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "Vibrator.h" #include namespace aidl::android::hardware::vibrator { ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) { // basic example with only amplitude control capability *_aidl_return = IVibrator::CAP_AMPLITUDE_CONTROL; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Vibrator::off() { LOG(INFO) << "Vibrator off"; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr&) { LOG(INFO) << "Vibrator on for timeoutMs: " << timeoutMs; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) { LOG(INFO) << "Vibrator set amplitude: " << amplitude; if (amplitude <= 0.0f || amplitude > 1.0f) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT)); } return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Vibrator::perform(Effect, EffectStrength, const std::shared_ptr&, int32_t*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector* _aidl_return) { *_aidl_return = {}; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Vibrator::setExternalControl(bool) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getCompositionDelayMax(int32_t*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive, int32_t*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::compose(const std::vector&, const std::shared_ptr&) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t, Effect, EffectStrength) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getResonantFrequency(float*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getQFactor(float*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getFrequencyResolution(float*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getFrequencyMinimum(float*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getBandwidthAmplitudeMap(std::vector*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getPwlePrimitiveDurationMax(int32_t*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getPwleCompositionSizeMax(int32_t*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::getSupportedBraking(std::vector*) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } ndk::ScopedAStatus Vibrator::composePwle(const std::vector&, const std::shared_ptr&) { return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION)); } } // namespace aidl::android::hardware::vibrator