• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "Vibrator.h"
18 
19 #include <android-base/logging.h>
20 
21 namespace aidl::android::hardware::vibrator {
22 
getCapabilities(int32_t * _aidl_return)23 ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) {
24     // basic example with only amplitude control capability
25     *_aidl_return = IVibrator::CAP_AMPLITUDE_CONTROL;
26     return ndk::ScopedAStatus::ok();
27 }
28 
off()29 ndk::ScopedAStatus Vibrator::off() {
30     LOG(INFO) << "Vibrator off";
31     return ndk::ScopedAStatus::ok();
32 }
33 
on(int32_t timeoutMs,const std::shared_ptr<IVibratorCallback> &)34 ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>&) {
35     LOG(INFO) << "Vibrator on for timeoutMs: " << timeoutMs;
36     return ndk::ScopedAStatus::ok();
37 }
38 
setAmplitude(float amplitude)39 ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) {
40     LOG(INFO) << "Vibrator set amplitude: " << amplitude;
41     if (amplitude <= 0.0f || amplitude > 1.0f) {
42         return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
43     }
44     return ndk::ScopedAStatus::ok();
45 }
46 
perform(Effect,EffectStrength,const std::shared_ptr<IVibratorCallback> &,int32_t *)47 ndk::ScopedAStatus Vibrator::perform(Effect, EffectStrength,
48                                      const std::shared_ptr<IVibratorCallback>&, int32_t*) {
49     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
50 }
51 
getSupportedEffects(std::vector<Effect> * _aidl_return)52 ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) {
53     *_aidl_return = {};
54     return ndk::ScopedAStatus::ok();
55 }
56 
setExternalControl(bool)57 ndk::ScopedAStatus Vibrator::setExternalControl(bool) {
58     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
59 }
60 
getCompositionDelayMax(int32_t *)61 ndk::ScopedAStatus Vibrator::getCompositionDelayMax(int32_t*) {
62     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
63 }
64 
getCompositionSizeMax(int32_t *)65 ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t*) {
66     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
67 }
68 
getSupportedPrimitives(std::vector<CompositePrimitive> *)69 ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive>*) {
70     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
71 }
72 
getPrimitiveDuration(CompositePrimitive,int32_t *)73 ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive, int32_t*) {
74     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
75 }
76 
compose(const std::vector<CompositeEffect> &,const std::shared_ptr<IVibratorCallback> &)77 ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>&,
78                                      const std::shared_ptr<IVibratorCallback>&) {
79     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
80 }
81 
getSupportedAlwaysOnEffects(std::vector<Effect> *)82 ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect>*) {
83     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
84 }
85 
alwaysOnEnable(int32_t,Effect,EffectStrength)86 ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t, Effect, EffectStrength) {
87     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
88 }
89 
alwaysOnDisable(int32_t)90 ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t) {
91     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
92 }
93 
getResonantFrequency(float *)94 ndk::ScopedAStatus Vibrator::getResonantFrequency(float*) {
95     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
96 }
97 
getQFactor(float *)98 ndk::ScopedAStatus Vibrator::getQFactor(float*) {
99     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
100 }
101 
getFrequencyResolution(float *)102 ndk::ScopedAStatus Vibrator::getFrequencyResolution(float*) {
103     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
104 }
105 
getFrequencyMinimum(float *)106 ndk::ScopedAStatus Vibrator::getFrequencyMinimum(float*) {
107     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
108 }
109 
getBandwidthAmplitudeMap(std::vector<float> *)110 ndk::ScopedAStatus Vibrator::getBandwidthAmplitudeMap(std::vector<float>*) {
111     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
112 }
113 
getPwlePrimitiveDurationMax(int32_t *)114 ndk::ScopedAStatus Vibrator::getPwlePrimitiveDurationMax(int32_t*) {
115     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
116 }
117 
getPwleCompositionSizeMax(int32_t *)118 ndk::ScopedAStatus Vibrator::getPwleCompositionSizeMax(int32_t*) {
119     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
120 }
121 
getSupportedBraking(std::vector<Braking> *)122 ndk::ScopedAStatus Vibrator::getSupportedBraking(std::vector<Braking>*) {
123     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
124 }
125 
composePwle(const std::vector<PrimitivePwle> &,const std::shared_ptr<IVibratorCallback> &)126 ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle>&,
127                                          const std::shared_ptr<IVibratorCallback>&) {
128     return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
129 }
130 
131 }  // namespace aidl::android::hardware::vibrator
132