mirror of
https://github.com/Evolution-X-Devices/device_google_wahoo
synced 2026-01-27 18:19:03 +00:00
haptics: implements vibrator 1.1 HAL
Obtain tick/click effect duration from system property and implement the new perform 1.1 function for supporting tick effect. Bug: 62176703 Test: VtsHalVibratorV1_1TargetTest Change-Id: Icbd50c2e7d05fd520aeda4511ba95151dde2a5ed Signed-off-by: David Lin <dtwlin@google.com>
This commit is contained in:
@@ -124,3 +124,8 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk-sp-*)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/vndk-sp-*)
|
||||
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/lowi.conf)
|
||||
|
||||
# Vibrator HAL 1.0
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.vibrator@1.0-service.wahoo.rc)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.vibrator@1.0-service.wahoo)
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ PRODUCT_PACKAGES += \
|
||||
|
||||
# Vibrator HAL
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.vibrator@1.0-service.wahoo
|
||||
android.hardware.vibrator@1.1-service.wahoo
|
||||
|
||||
# Thermal packages
|
||||
PRODUCT_PACKAGES += \
|
||||
|
||||
@@ -275,7 +275,7 @@
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.vibrator</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
<interface>
|
||||
<name>IVibrator</name>
|
||||
<instance>default</instance>
|
||||
|
||||
2
sepolicy/vendor/file_contexts
vendored
2
sepolicy/vendor/file_contexts
vendored
@@ -230,7 +230,7 @@
|
||||
/vendor/bin/init\.power\.sh u:object_r:init_power_exec:s0
|
||||
/vendor/bin/init\.radio\.sh u:object_r:init_radio_exec:s0
|
||||
|
||||
/vendor/bin/hw/android\.hardware\.vibrator@1\.0-service.wahoo u:object_r:hal_vibrator_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.vibrator@1\.1-service.wahoo u:object_r:hal_vibrator_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.keymaster@3\.0-service-qti u:object_r:hal_keymaster_qti_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service-qti u:object_r:hal_gatekeeper_qti_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.gnss@1\.0-service-qti u:object_r:hal_gnss_qti_exec:s0
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
cc_binary {
|
||||
name: "android.hardware.vibrator@1.0-service.wahoo",
|
||||
name: "android.hardware.vibrator@1.1-service.wahoo",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.vibrator@1.0-service.wahoo.rc"],
|
||||
init_rc: ["android.hardware.vibrator@1.1-service.wahoo.rc"],
|
||||
srcs: ["service.cpp", "Vibrator.cpp"],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
@@ -26,6 +26,7 @@ cc_binary {
|
||||
"libutils",
|
||||
"libhardware",
|
||||
"android.hardware.vibrator@1.0",
|
||||
"android.hardware.vibrator@1.1",
|
||||
],
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vibrator {
|
||||
namespace V1_0 {
|
||||
namespace V1_1 {
|
||||
namespace implementation {
|
||||
|
||||
static constexpr int8_t MAX_RTP_INPUT = 127;
|
||||
@@ -46,6 +46,10 @@ static constexpr char WAVEFORM_MODE[] = "waveform";
|
||||
static constexpr char WAVEFORM_CLICK_EFFECT_SEQ[] = "1 0";
|
||||
static constexpr int32_t WAVEFORM_CLICK_EFFECT_MS = 6;
|
||||
|
||||
// Use effect #2 in the waveform library
|
||||
static constexpr char WAVEFORM_TICK_EFFECT_SEQ[] = "2 0";
|
||||
static constexpr int32_t WAVEFORM_TICK_EFFECT_MS = 2;
|
||||
|
||||
// Use effect #3 in the waveform library
|
||||
static constexpr char WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ[] = "3 0";
|
||||
static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 135;
|
||||
@@ -53,6 +57,9 @@ static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 135;
|
||||
// Timeout threshold for selecting open or closed loop mode
|
||||
static constexpr int8_t LOOP_MODE_THRESHOLD_MS = 20;
|
||||
|
||||
using Status = ::android::hardware::vibrator::V1_0::Status;
|
||||
using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
|
||||
|
||||
Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration,
|
||||
std::ofstream&& state, std::ofstream&& rtpinput,
|
||||
std::ofstream&& mode, std::ofstream&& sequencer,
|
||||
@@ -67,6 +74,7 @@ Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration,
|
||||
mCtrlLoop(std::move(ctrlloop)) {
|
||||
|
||||
mClickDuration = property_get_int32("ro.vibrator.hal.click.duration", WAVEFORM_CLICK_EFFECT_MS);
|
||||
mTickDuration = property_get_int32("ro.vibrator.hal.tick.duration", WAVEFORM_TICK_EFFECT_MS);
|
||||
}
|
||||
|
||||
Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop) {
|
||||
@@ -94,7 +102,7 @@ Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop) {
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::vibrator::V1_0::IVibrator follow.
|
||||
// Methods from ::android::hardware::vibrator::V1_1::IVibrator follow.
|
||||
Return<Status> Vibrator::on(uint32_t timeoutMs) {
|
||||
return on(timeoutMs, false);
|
||||
}
|
||||
@@ -177,8 +185,31 @@ Return<void> Vibrator::perform(Effect effect, EffectStrength strength, perform_c
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Vibrator::perform_1_1(Effect_1_1 effect, EffectStrength strength,
|
||||
perform_cb _hidl_cb) {
|
||||
Status status = Status::OK;
|
||||
uint32_t timeMS;
|
||||
|
||||
if (effect == Effect_1_1::TICK) {
|
||||
mSequencer << WAVEFORM_TICK_EFFECT_SEQ << std::endl;
|
||||
timeMS = mTickDuration;
|
||||
} else if (effect < Effect_1_1::TICK) {
|
||||
return perform(static_cast<Effect>(effect), strength, _hidl_cb);
|
||||
} else {
|
||||
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
|
||||
return Void();
|
||||
}
|
||||
|
||||
mMode << WAVEFORM_MODE << std::endl;
|
||||
mScale << convertEffectStrength(strength) << std::endl;
|
||||
on(timeMS, true);
|
||||
|
||||
_hidl_cb(status, timeMS);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace V1_1
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H
|
||||
#define ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H
|
||||
#ifndef ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H
|
||||
#define ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H
|
||||
|
||||
#include <android/hardware/vibrator/1.0/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.1/IVibrator.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <fstream>
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vibrator {
|
||||
namespace V1_0 {
|
||||
namespace V1_1 {
|
||||
namespace implementation {
|
||||
|
||||
class Vibrator : public IVibrator {
|
||||
@@ -35,11 +35,16 @@ public:
|
||||
std::ofstream&& scale, std::ofstream&& ctrlloop);
|
||||
|
||||
// Methods from ::android::hardware::vibrator::V1_0::IVibrator follow.
|
||||
using Status = ::android::hardware::vibrator::V1_0::Status;
|
||||
Return<Status> on(uint32_t timeoutMs) override;
|
||||
Return<Status> off() override;
|
||||
Return<bool> supportsAmplitudeControl() override;
|
||||
Return<Status> setAmplitude(uint8_t amplitude) override;
|
||||
|
||||
using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
|
||||
using Effect = ::android::hardware::vibrator::V1_0::Effect;
|
||||
Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
|
||||
Return<void> perform_1_1(Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
Return<Status> on(uint32_t timeoutMs, bool forceOpenLoop);
|
||||
@@ -52,11 +57,12 @@ private:
|
||||
std::ofstream mScale;
|
||||
std::ofstream mCtrlLoop;
|
||||
int32_t mClickDuration;
|
||||
int32_t mTickDuration;
|
||||
};
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace V1_1
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H
|
||||
#endif // ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
service vibrator-1-0 /vendor/bin/hw/android.hardware.vibrator@1.0-service.wahoo
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
4
vibrator/android.hardware.vibrator@1.1-service.wahoo.rc
Normal file
4
vibrator/android.hardware.vibrator@1.1-service.wahoo.rc
Normal file
@@ -0,0 +1,4 @@
|
||||
service vibrator-1-1 /vendor/bin/hw/android.hardware.vibrator@1.1-service.wahoo
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
@@ -13,9 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.vibrator@1.0-service.wahoo"
|
||||
#define LOG_TAG "android.hardware.vibrator@1.1-service.wahoo"
|
||||
|
||||
#include <android/hardware/vibrator/1.0/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.1/IVibrator.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <utils/Errors.h>
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using android::hardware::vibrator::V1_0::IVibrator;
|
||||
using android::hardware::vibrator::V1_0::implementation::Vibrator;
|
||||
using android::hardware::vibrator::V1_1::IVibrator;
|
||||
using android::hardware::vibrator::V1_1::implementation::Vibrator;
|
||||
using namespace android;
|
||||
|
||||
// Refer to Documentation/ABI/testing/sysfs-class-led-driver-drv2624
|
||||
|
||||
Reference in New Issue
Block a user