From 01f68a446b18adbef04612d4b281f16c73c28e63 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Tue, 29 Jan 2019 22:22:15 +0100 Subject: [PATCH] Add vibrator-lge debug toy --- cmds/Android.bp | 12 +++++++++++ cmds/vibrator-lge.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 cmds/vibrator-lge.cpp diff --git a/cmds/Android.bp b/cmds/Android.bp index 4c04469..c65f4cc 100644 --- a/cmds/Android.bp +++ b/cmds/Android.bp @@ -36,3 +36,15 @@ cc_binary { ], host_supported: true, } + +cc_binary { + name: "vibrator-lge", + srcs: [ + "vibrator-lge.cpp", + ], + shared_libs: [ + "vendor.lge.hardware.vibrator@1.0", + "libutils", + "libhidlbase", + ], +} diff --git a/cmds/vibrator-lge.cpp b/cmds/vibrator-lge.cpp new file mode 100644 index 0000000..5797854 --- /dev/null +++ b/cmds/vibrator-lge.cpp @@ -0,0 +1,48 @@ +#include +#include + +using ::vendor::lge::hardware::vibrator::V1_0::IVibratorEx; +using ::android::sp; + +int main(int argc, char **argv) { + auto svc = IVibratorEx::getService(); + + auto supportsAmplitude = svc->supportsAmplitudeControl(); + if(supportsAmplitude.isOk()) + std::cerr << "supportsAmplitudeControl? " << supportsAmplitude << std::endl; + + /* +public int on(int timeoutMs) throws RemoteException { +public int off() throws RemoteException { +public int setAmplitude(byte amplitude) throws RemoteException { +public void perform(int effect, byte strength, performCallback _hidl_cb) throws RemoteException { +public int playEffectWithStrength(ArrayList effectData, int effectIndex, int strength) throws RemoteException { +*/ + + + if(strcmp(argv[1], "on") == 0) { + int v = 100; + if(argc>=3) + v = atoi(argv[2]); + auto ret = svc->on(v); + if(ret.isOk()) { + android::hardware::vibrator::V1_0::Status r = ret; + std::cout << "vibrator on returned " << (int)r << std::endl; + } else { + std::cerr << "Binder failed request" << std::endl; + } + } else if(strcmp(argv[1], "amplitude") == 0) { + int v = 127; + if(argc>=3) + v = atoi(argv[2]); + auto ret = svc->setAmplitude(v); + if(ret.isOk()) { + android::hardware::vibrator::V1_0::Status r = ret; + std::cout << "vibrator amplitude returned " << (int)r << std::endl; + } else { + std::cerr << "Binder failed request" << std::endl; + } + } else { + std::cerr << "Not supported (yet)" << std::endl; + } +}