Loading cmds/idlcli/Android.bp +3 −2 Original line number Original line Diff line number Diff line Loading @@ -20,15 +20,16 @@ cc_defaults { "android.hardware.vibrator@1.2", "android.hardware.vibrator@1.2", "android.hardware.vibrator@1.3", "android.hardware.vibrator@1.3", "libbase", "libbase", "libbinder", "libbinder_ndk", "libhidlbase", "libhidlbase", "liblog", "liblog", "libutils", "libutils", "vintf-vibrator-cpp", "vintf-vibrator-ndk_platform", ], ], cflags: [ cflags: [ "-DLOG_TAG=\"idlcli\"", "-DLOG_TAG=\"idlcli\"", ], ], vendor_available: true, } } cc_library { cc_library { Loading cmds/idlcli/vibrator.h +16 −12 Original line number Original line Diff line number Diff line Loading @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * See the License for the specific language governing permissions and * limitations under the License. * limitations under the License. */ */ #ifndef FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #ifndef FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #define FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #define FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #include <aidl/android/hardware/vibrator/IVibrator.h> #include <android/binder_manager.h> #include <android/hardware/vibrator/1.3/IVibrator.h> #include <android/hardware/vibrator/1.3/IVibrator.h> #include <android/hardware/vibrator/IVibrator.h> #include <binder/IServiceManager.h> #include "utils.h" #include "utils.h" Loading @@ -39,21 +38,26 @@ inline R NullptrStatus() { } } template <> template <> inline binder::Status NullptrStatus() { inline ndk::ScopedAStatus NullptrStatus() { using binder::Status; return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_NULL_POINTER)); return Status::fromExceptionCode(Status::EX_NULL_POINTER); } } template <typename I> template <typename I> inline sp<I> getService() { inline auto getService() { return I::getService(); return I::getService(); } } template <> template <> inline sp<hardware::vibrator::IVibrator> getService() { inline auto getService<aidl::android::hardware::vibrator::IVibrator>() { return waitForVintfService<hardware::vibrator::IVibrator>(); const auto instance = std::string() + aidl::android::hardware::vibrator::IVibrator::descriptor + "/default"; auto vibBinder = ndk::SpAIBinder(AServiceManager_getService(instance.c_str())); return aidl::android::hardware::vibrator::IVibrator::fromBinder(vibBinder); } } template <typename I> using shared_ptr = std::result_of_t<decltype(getService<I>)&()>; template <typename I> template <typename I> class HalWrapper { class HalWrapper { public: public: Loading @@ -70,10 +74,10 @@ public: } } private: private: HalWrapper(sp<I>&& hal) : mHal(std::move(hal)) {} HalWrapper(shared_ptr<I>&& hal) : mHal(std::move(hal)) {} private: private: sp<I> mHal; shared_ptr<I> mHal; }; }; template <typename I> template <typename I> Loading @@ -95,7 +99,7 @@ namespace V1_0 = ::android::hardware::vibrator::V1_0; namespace V1_1 = ::android::hardware::vibrator::V1_1; namespace V1_1 = ::android::hardware::vibrator::V1_1; namespace V1_2 = ::android::hardware::vibrator::V1_2; namespace V1_2 = ::android::hardware::vibrator::V1_2; namespace V1_3 = ::android::hardware::vibrator::V1_3; namespace V1_3 = ::android::hardware::vibrator::V1_3; namespace aidl = ::android::hardware::vibrator; namespace aidl = ::aidl::android::hardware::vibrator; } // namespace vibrator } // namespace vibrator } // namespace idlcli } // namespace idlcli Loading cmds/idlcli/vibrator/CommandCompose.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -80,7 +80,7 @@ class CommandCompose : public Command { Status ret; Status ret; if (auto hal = getHal<aidl::IVibrator>()) { if (auto hal = getHal<aidl::IVibrator>()) { auto status = hal->call(&aidl::IVibrator::compose, mComposite, nullptr); auto status = hal->call(&aidl::IVibrator::compose, mComposite, nullptr); statusStr = status.toString8(); statusStr = status.getDescription(); ret = status.isOk() ? OK : ERROR; ret = status.isOk() ? OK : ERROR; } else { } else { return UNAVAILABLE; return UNAVAILABLE; Loading cmds/idlcli/vibrator/CommandGetCapabilities.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -48,7 +48,7 @@ class CommandGetCapabilities : public Command { if (auto hal = getHal<aidl::IVibrator>()) { if (auto hal = getHal<aidl::IVibrator>()) { auto status = hal->call(&aidl::IVibrator::getCapabilities, &cap); auto status = hal->call(&aidl::IVibrator::getCapabilities, &cap); statusStr = status.toString8(); statusStr = status.getDescription(); ret = status.isOk() ? OK : ERROR; ret = status.isOk() ? OK : ERROR; } else { } else { return UNAVAILABLE; return UNAVAILABLE; Loading cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ class CommandGetCompositionDelayMax : public Command { if (auto hal = getHal<aidl::IVibrator>()) { if (auto hal = getHal<aidl::IVibrator>()) { auto status = hal->call(&aidl::IVibrator::getCompositionDelayMax, &maxDelayMs); auto status = hal->call(&aidl::IVibrator::getCompositionDelayMax, &maxDelayMs); statusStr = status.toString8(); statusStr = status.getDescription(); ret = status.isOk() ? OK : ERROR; ret = status.isOk() ? OK : ERROR; } else { } else { return UNAVAILABLE; return UNAVAILABLE; Loading Loading
cmds/idlcli/Android.bp +3 −2 Original line number Original line Diff line number Diff line Loading @@ -20,15 +20,16 @@ cc_defaults { "android.hardware.vibrator@1.2", "android.hardware.vibrator@1.2", "android.hardware.vibrator@1.3", "android.hardware.vibrator@1.3", "libbase", "libbase", "libbinder", "libbinder_ndk", "libhidlbase", "libhidlbase", "liblog", "liblog", "libutils", "libutils", "vintf-vibrator-cpp", "vintf-vibrator-ndk_platform", ], ], cflags: [ cflags: [ "-DLOG_TAG=\"idlcli\"", "-DLOG_TAG=\"idlcli\"", ], ], vendor_available: true, } } cc_library { cc_library { Loading
cmds/idlcli/vibrator.h +16 −12 Original line number Original line Diff line number Diff line Loading @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * See the License for the specific language governing permissions and * limitations under the License. * limitations under the License. */ */ #ifndef FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #ifndef FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #define FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #define FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_ #include <aidl/android/hardware/vibrator/IVibrator.h> #include <android/binder_manager.h> #include <android/hardware/vibrator/1.3/IVibrator.h> #include <android/hardware/vibrator/1.3/IVibrator.h> #include <android/hardware/vibrator/IVibrator.h> #include <binder/IServiceManager.h> #include "utils.h" #include "utils.h" Loading @@ -39,21 +38,26 @@ inline R NullptrStatus() { } } template <> template <> inline binder::Status NullptrStatus() { inline ndk::ScopedAStatus NullptrStatus() { using binder::Status; return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_NULL_POINTER)); return Status::fromExceptionCode(Status::EX_NULL_POINTER); } } template <typename I> template <typename I> inline sp<I> getService() { inline auto getService() { return I::getService(); return I::getService(); } } template <> template <> inline sp<hardware::vibrator::IVibrator> getService() { inline auto getService<aidl::android::hardware::vibrator::IVibrator>() { return waitForVintfService<hardware::vibrator::IVibrator>(); const auto instance = std::string() + aidl::android::hardware::vibrator::IVibrator::descriptor + "/default"; auto vibBinder = ndk::SpAIBinder(AServiceManager_getService(instance.c_str())); return aidl::android::hardware::vibrator::IVibrator::fromBinder(vibBinder); } } template <typename I> using shared_ptr = std::result_of_t<decltype(getService<I>)&()>; template <typename I> template <typename I> class HalWrapper { class HalWrapper { public: public: Loading @@ -70,10 +74,10 @@ public: } } private: private: HalWrapper(sp<I>&& hal) : mHal(std::move(hal)) {} HalWrapper(shared_ptr<I>&& hal) : mHal(std::move(hal)) {} private: private: sp<I> mHal; shared_ptr<I> mHal; }; }; template <typename I> template <typename I> Loading @@ -95,7 +99,7 @@ namespace V1_0 = ::android::hardware::vibrator::V1_0; namespace V1_1 = ::android::hardware::vibrator::V1_1; namespace V1_1 = ::android::hardware::vibrator::V1_1; namespace V1_2 = ::android::hardware::vibrator::V1_2; namespace V1_2 = ::android::hardware::vibrator::V1_2; namespace V1_3 = ::android::hardware::vibrator::V1_3; namespace V1_3 = ::android::hardware::vibrator::V1_3; namespace aidl = ::android::hardware::vibrator; namespace aidl = ::aidl::android::hardware::vibrator; } // namespace vibrator } // namespace vibrator } // namespace idlcli } // namespace idlcli Loading
cmds/idlcli/vibrator/CommandCompose.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -80,7 +80,7 @@ class CommandCompose : public Command { Status ret; Status ret; if (auto hal = getHal<aidl::IVibrator>()) { if (auto hal = getHal<aidl::IVibrator>()) { auto status = hal->call(&aidl::IVibrator::compose, mComposite, nullptr); auto status = hal->call(&aidl::IVibrator::compose, mComposite, nullptr); statusStr = status.toString8(); statusStr = status.getDescription(); ret = status.isOk() ? OK : ERROR; ret = status.isOk() ? OK : ERROR; } else { } else { return UNAVAILABLE; return UNAVAILABLE; Loading
cmds/idlcli/vibrator/CommandGetCapabilities.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -48,7 +48,7 @@ class CommandGetCapabilities : public Command { if (auto hal = getHal<aidl::IVibrator>()) { if (auto hal = getHal<aidl::IVibrator>()) { auto status = hal->call(&aidl::IVibrator::getCapabilities, &cap); auto status = hal->call(&aidl::IVibrator::getCapabilities, &cap); statusStr = status.toString8(); statusStr = status.getDescription(); ret = status.isOk() ? OK : ERROR; ret = status.isOk() ? OK : ERROR; } else { } else { return UNAVAILABLE; return UNAVAILABLE; Loading
cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ class CommandGetCompositionDelayMax : public Command { if (auto hal = getHal<aidl::IVibrator>()) { if (auto hal = getHal<aidl::IVibrator>()) { auto status = hal->call(&aidl::IVibrator::getCompositionDelayMax, &maxDelayMs); auto status = hal->call(&aidl::IVibrator::getCompositionDelayMax, &maxDelayMs); statusStr = status.toString8(); statusStr = status.getDescription(); ret = status.isOk() ? OK : ERROR; ret = status.isOk() ? OK : ERROR; } else { } else { return UNAVAILABLE; return UNAVAILABLE; Loading