Loading vibrator/1.0/Android.mk +72 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,25 @@ LOCAL_JAVA_LIBRARIES := \ android.hidl.base@1.0-java \ # # Build types.hal (Effect) # GEN := $(intermediates)/android/hardware/vibrator/V1_0/Effect.java $(GEN): $(HIDL) $(GEN): PRIVATE_HIDL := $(HIDL) $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) $(GEN): PRIVATE_CUSTOM_TOOL = \ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ -Ljava \ -randroid.hardware:hardware/interfaces \ -randroid.hidl:system/libhidl/transport \ android.hardware.vibrator@1.0::types.Effect $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) # # Build types.hal (Status) # Loading Loading @@ -72,6 +91,25 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android.hidl.base@1.0-java-static \ # # Build types.hal (Effect) # GEN := $(intermediates)/android/hardware/vibrator/V1_0/Effect.java $(GEN): $(HIDL) $(GEN): PRIVATE_HIDL := $(HIDL) $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) $(GEN): PRIVATE_CUSTOM_TOOL = \ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ -Ljava \ -randroid.hardware:hardware/interfaces \ -randroid.hidl:system/libhidl/transport \ android.hardware.vibrator@1.0::types.Effect $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) # # Build types.hal (Status) # Loading Loading @@ -114,5 +152,39 @@ LOCAL_GENERATED_SOURCES += $(GEN) include $(BUILD_STATIC_JAVA_LIBRARY) ################################################################################ include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.vibrator@1.0-java-constants LOCAL_MODULE_CLASS := JAVA_LIBRARIES intermediates := $(local-generated-sources-dir) HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) # GEN := $(intermediates)/android/hardware/vibrator/V1_0/Constants.java $(GEN): $(HIDL) $(GEN): $(LOCAL_PATH)/types.hal $(GEN): $(LOCAL_PATH)/IVibrator.hal $(GEN): PRIVATE_HIDL := $(HIDL) $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) $(GEN): PRIVATE_CUSTOM_TOOL = \ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ -Ljava-constants \ -randroid.hardware:hardware/interfaces \ -randroid.hidl:system/libhidl/transport \ android.hardware.vibrator@1.0 $(GEN): $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) # Avoid dependency cycle of framework.jar -> this-library -> framework.jar LOCAL_NO_STANDARD_LIBRARIES := true LOCAL_JAVA_LIBRARIES := core-oj include $(BUILD_STATIC_JAVA_LIBRARY) include $(call all-makefiles-under,$(LOCAL_PATH)) vibrator/1.0/IVibrator.hal +39 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ package android.hardware.vibrator@1.0; interface IVibrator { /** Turn on vibrator /** * Turn on vibrator * * This function must only be called after the previous timeout has expired or * was canceled (through off()). Loading @@ -26,10 +27,46 @@ interface IVibrator { */ on(uint32_t timeoutMs) generates (Status vibratorOnRet); /** Turn off vibrator /** * Turn off vibrator * * Cancel a previously-started vibration, if any. * @return vibratorOffRet whether vibrator command was successful or not. */ off() generates (Status vibratorOffRet); /** * Returns whether the vibrator supports changes to its vibrational amplitude. */ supportsAmplitudeControl() generates (bool supports); /** * Sets the motor's vibrational amplitude. * * Changes the force being produced by the underlying motor. * * @param amplitude The unitless force setting. Note that this number must * be between 1 and 255, inclusive. If the motor does not * have exactly 255 steps, it must do it's best to map it * onto the number of steps it does have. * @return status Whether the command was successful or not. Must return * Status::UNSUPPORTED_OPERATION if setting the amplitude is * not supported by the device. */ setAmplitude(uint8_t amplitude) generates (Status status); /** * Fire off a predefined haptic event. * * @param event The type of haptic event to trigger. * @return status Whether the effect was successfully performed or not. Must * return Status::UNSUPPORTED_OPERATION is the effect is not * supported. * @return lengthMs The length of time the event is expected to take in * milliseconds. This doesn't need to be perfectly accurate, * but should be a reasonable approximation. Should be a * positive, non-zero value if the returned status is * Status::OK, and set to 0 otherwise. */ perform(Effect effect, EffectStrength strength) generates (Status status, uint32_t lengthMs); }; vibrator/1.0/default/Vibrator.cpp +17 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #define LOG_TAG "VibratorService" #include <inttypes.h> #include <log/log.h> #include <hardware/hardware.h> Loading @@ -36,7 +38,7 @@ Return<Status> Vibrator::on(uint32_t timeout_ms) { int32_t ret = mDevice->vibrator_on(mDevice, timeout_ms); if (ret != 0) { ALOGE("on command failed : %s", strerror(-ret)); return Status::ERR; return Status::UNKNOWN_ERROR; } return Status::OK; } Loading @@ -45,11 +47,24 @@ Return<Status> Vibrator::off() { int32_t ret = mDevice->vibrator_off(mDevice); if (ret != 0) { ALOGE("off command failed : %s", strerror(-ret)); return Status::ERR; return Status::UNKNOWN_ERROR; } return Status::OK; } Return<bool> Vibrator::supportsAmplitudeControl() { return false; } Return<Status> Vibrator::setAmplitude(uint8_t) { return Status::UNSUPPORTED_OPERATION; } Return<void> Vibrator::perform(Effect, EffectStrength, perform_cb _hidl_cb) { _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); return Void(); } IVibrator* HIDL_FETCH_IVibrator(const char * /*hal*/) { vibrator_device_t *vib_device; const hw_module_t *hw_module = nullptr; Loading vibrator/1.0/default/Vibrator.h +5 −10 Original line number Diff line number Diff line Loading @@ -26,20 +26,15 @@ namespace vibrator { namespace V1_0 { namespace implementation { using ::android::hardware::vibrator::V1_0::IVibrator; using ::android::hardware::vibrator::V1_0::Status; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::hidl_vec; using ::android::hardware::hidl_string; using ::android::sp; struct Vibrator : public IVibrator { Vibrator(vibrator_device_t *device); // Methods from ::android::hardware::vibrator::V1_0::IVibrator follow. Return<Status> on(uint32_t timeoutMs) override; Return<Status> off() override; Return<bool> supportsAmplitudeControl() override; Return<Status> setAmplitude(uint8_t amplitude) override; Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; private: vibrator_device_t *mDevice; Loading vibrator/1.0/types.hal +29 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,32 @@ package android.hardware.vibrator@1.0; enum Status : uint32_t { OK = 0, ERR = 1 OK, UNKNOWN_ERROR, BAD_VALUE, UNSUPPORTED_OPERATION }; @export enum Effect : uint32_t { /** * A single click effect. * * This effect should produce a sharp, crisp click sensation. */ CLICK, /** * A double click effect. * * This effect should produce two sequential sharp, crisp click sensations with a minimal * amount of time between them. */ DOUBLE_CLICK }; @export enum EffectStrength : uint8_t { LIGHT, MEDIUM, STRONG }; Loading
vibrator/1.0/Android.mk +72 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,25 @@ LOCAL_JAVA_LIBRARIES := \ android.hidl.base@1.0-java \ # # Build types.hal (Effect) # GEN := $(intermediates)/android/hardware/vibrator/V1_0/Effect.java $(GEN): $(HIDL) $(GEN): PRIVATE_HIDL := $(HIDL) $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) $(GEN): PRIVATE_CUSTOM_TOOL = \ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ -Ljava \ -randroid.hardware:hardware/interfaces \ -randroid.hidl:system/libhidl/transport \ android.hardware.vibrator@1.0::types.Effect $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) # # Build types.hal (Status) # Loading Loading @@ -72,6 +91,25 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android.hidl.base@1.0-java-static \ # # Build types.hal (Effect) # GEN := $(intermediates)/android/hardware/vibrator/V1_0/Effect.java $(GEN): $(HIDL) $(GEN): PRIVATE_HIDL := $(HIDL) $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) $(GEN): PRIVATE_CUSTOM_TOOL = \ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ -Ljava \ -randroid.hardware:hardware/interfaces \ -randroid.hidl:system/libhidl/transport \ android.hardware.vibrator@1.0::types.Effect $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) # # Build types.hal (Status) # Loading Loading @@ -114,5 +152,39 @@ LOCAL_GENERATED_SOURCES += $(GEN) include $(BUILD_STATIC_JAVA_LIBRARY) ################################################################################ include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.vibrator@1.0-java-constants LOCAL_MODULE_CLASS := JAVA_LIBRARIES intermediates := $(local-generated-sources-dir) HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) # GEN := $(intermediates)/android/hardware/vibrator/V1_0/Constants.java $(GEN): $(HIDL) $(GEN): $(LOCAL_PATH)/types.hal $(GEN): $(LOCAL_PATH)/IVibrator.hal $(GEN): PRIVATE_HIDL := $(HIDL) $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) $(GEN): PRIVATE_CUSTOM_TOOL = \ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ -Ljava-constants \ -randroid.hardware:hardware/interfaces \ -randroid.hidl:system/libhidl/transport \ android.hardware.vibrator@1.0 $(GEN): $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) # Avoid dependency cycle of framework.jar -> this-library -> framework.jar LOCAL_NO_STANDARD_LIBRARIES := true LOCAL_JAVA_LIBRARIES := core-oj include $(BUILD_STATIC_JAVA_LIBRARY) include $(call all-makefiles-under,$(LOCAL_PATH))
vibrator/1.0/IVibrator.hal +39 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ package android.hardware.vibrator@1.0; interface IVibrator { /** Turn on vibrator /** * Turn on vibrator * * This function must only be called after the previous timeout has expired or * was canceled (through off()). Loading @@ -26,10 +27,46 @@ interface IVibrator { */ on(uint32_t timeoutMs) generates (Status vibratorOnRet); /** Turn off vibrator /** * Turn off vibrator * * Cancel a previously-started vibration, if any. * @return vibratorOffRet whether vibrator command was successful or not. */ off() generates (Status vibratorOffRet); /** * Returns whether the vibrator supports changes to its vibrational amplitude. */ supportsAmplitudeControl() generates (bool supports); /** * Sets the motor's vibrational amplitude. * * Changes the force being produced by the underlying motor. * * @param amplitude The unitless force setting. Note that this number must * be between 1 and 255, inclusive. If the motor does not * have exactly 255 steps, it must do it's best to map it * onto the number of steps it does have. * @return status Whether the command was successful or not. Must return * Status::UNSUPPORTED_OPERATION if setting the amplitude is * not supported by the device. */ setAmplitude(uint8_t amplitude) generates (Status status); /** * Fire off a predefined haptic event. * * @param event The type of haptic event to trigger. * @return status Whether the effect was successfully performed or not. Must * return Status::UNSUPPORTED_OPERATION is the effect is not * supported. * @return lengthMs The length of time the event is expected to take in * milliseconds. This doesn't need to be perfectly accurate, * but should be a reasonable approximation. Should be a * positive, non-zero value if the returned status is * Status::OK, and set to 0 otherwise. */ perform(Effect effect, EffectStrength strength) generates (Status status, uint32_t lengthMs); };
vibrator/1.0/default/Vibrator.cpp +17 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #define LOG_TAG "VibratorService" #include <inttypes.h> #include <log/log.h> #include <hardware/hardware.h> Loading @@ -36,7 +38,7 @@ Return<Status> Vibrator::on(uint32_t timeout_ms) { int32_t ret = mDevice->vibrator_on(mDevice, timeout_ms); if (ret != 0) { ALOGE("on command failed : %s", strerror(-ret)); return Status::ERR; return Status::UNKNOWN_ERROR; } return Status::OK; } Loading @@ -45,11 +47,24 @@ Return<Status> Vibrator::off() { int32_t ret = mDevice->vibrator_off(mDevice); if (ret != 0) { ALOGE("off command failed : %s", strerror(-ret)); return Status::ERR; return Status::UNKNOWN_ERROR; } return Status::OK; } Return<bool> Vibrator::supportsAmplitudeControl() { return false; } Return<Status> Vibrator::setAmplitude(uint8_t) { return Status::UNSUPPORTED_OPERATION; } Return<void> Vibrator::perform(Effect, EffectStrength, perform_cb _hidl_cb) { _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); return Void(); } IVibrator* HIDL_FETCH_IVibrator(const char * /*hal*/) { vibrator_device_t *vib_device; const hw_module_t *hw_module = nullptr; Loading
vibrator/1.0/default/Vibrator.h +5 −10 Original line number Diff line number Diff line Loading @@ -26,20 +26,15 @@ namespace vibrator { namespace V1_0 { namespace implementation { using ::android::hardware::vibrator::V1_0::IVibrator; using ::android::hardware::vibrator::V1_0::Status; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::hidl_vec; using ::android::hardware::hidl_string; using ::android::sp; struct Vibrator : public IVibrator { Vibrator(vibrator_device_t *device); // Methods from ::android::hardware::vibrator::V1_0::IVibrator follow. Return<Status> on(uint32_t timeoutMs) override; Return<Status> off() override; Return<bool> supportsAmplitudeControl() override; Return<Status> setAmplitude(uint8_t amplitude) override; Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; private: vibrator_device_t *mDevice; Loading
vibrator/1.0/types.hal +29 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,32 @@ package android.hardware.vibrator@1.0; enum Status : uint32_t { OK = 0, ERR = 1 OK, UNKNOWN_ERROR, BAD_VALUE, UNSUPPORTED_OPERATION }; @export enum Effect : uint32_t { /** * A single click effect. * * This effect should produce a sharp, crisp click sensation. */ CLICK, /** * A double click effect. * * This effect should produce two sequential sharp, crisp click sensations with a minimal * amount of time between them. */ DOUBLE_CLICK }; @export enum EffectStrength : uint8_t { LIGHT, MEDIUM, STRONG };