mirror of
https://github.com/Evolution-X-Devices/device_google_wahoo
synced 2026-01-29 02:44:24 +00:00
Upgrade vibrator to HAL 1.2
Bug: 64184692 Test: build, flash and play with device Change-Id: I44d82371e6a6d7dc7e05e740aa5f2fdb5c3f8df6
This commit is contained in:
committed by
Steven Moreland
parent
87b0264022
commit
3e8e659997
@@ -164,3 +164,7 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.he
|
||||
# Remove PowerHAL
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.power*)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.power*)
|
||||
|
||||
# Remove Vibrator HAL 1.1
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.vibrator@1.1-service.wahoo.rc)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.vibrator@1.1-service.wahoo)
|
||||
|
||||
@@ -402,7 +402,7 @@ PRODUCT_PACKAGES += \
|
||||
|
||||
# Vibrator HAL
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.vibrator@1.1-service.wahoo
|
||||
android.hardware.vibrator@1.2-service.wahoo
|
||||
|
||||
# Thermal packages
|
||||
PRODUCT_PACKAGES += \
|
||||
|
||||
@@ -342,7 +342,7 @@
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.vibrator</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.1</version>
|
||||
<version>1.2</version>
|
||||
<interface>
|
||||
<name>IVibrator</name>
|
||||
<instance>default</instance>
|
||||
|
||||
2
sepolicy/vendor/file_contexts
vendored
2
sepolicy/vendor/file_contexts
vendored
@@ -186,7 +186,7 @@
|
||||
|
||||
/vendor/bin/hw/android\.hardware\.drm@1\.0-service\.widevine u:object_r:hal_drm_widevine_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.drm@1\.1-service\.clearkey u:object_r:hal_drm_clearkey_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\.vibrator@1\.2-service\.wahoo u:object_r:hal_vibrator_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.health@2\.0-service\.wahoo u:object_r:hal_health_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
|
||||
|
||||
@@ -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.1-service.wahoo",
|
||||
name: "android.hardware.vibrator@1.2-service.wahoo",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.vibrator@1.1-service.wahoo.rc"],
|
||||
init_rc: ["android.hardware.vibrator@1.2-service.wahoo.rc"],
|
||||
srcs: ["service.cpp", "Vibrator.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
@@ -31,6 +31,7 @@ cc_binary {
|
||||
"libhardware",
|
||||
"android.hardware.vibrator@1.0",
|
||||
"android.hardware.vibrator@1.1",
|
||||
"android.hardware.vibrator@1.2",
|
||||
],
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vibrator {
|
||||
namespace V1_1 {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
static constexpr int8_t MAX_RTP_INPUT = 127;
|
||||
@@ -116,7 +116,7 @@ Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWavef
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::vibrator::V1_1::IVibrator follow.
|
||||
// Methods from ::android::hardware::vibrator::V1_2::IVibrator follow.
|
||||
Return<Status> Vibrator::on(uint32_t timeoutMs) {
|
||||
return on(timeoutMs, false /* forceOpenLoop */, false /* isWaveform */);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ static uint8_t convertEffectStrength(EffectStrength strength) {
|
||||
|
||||
switch (strength) {
|
||||
case EffectStrength::LIGHT:
|
||||
scale = 1; // 50%
|
||||
scale = 2; // 50%
|
||||
break;
|
||||
case EffectStrength::MEDIUM:
|
||||
case EffectStrength::STRONG:
|
||||
@@ -169,52 +169,49 @@ static uint8_t convertEffectStrength(EffectStrength strength) {
|
||||
return scale;
|
||||
}
|
||||
|
||||
Return<void> Vibrator::perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength,
|
||||
perform_cb _hidl_cb) {
|
||||
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> Vibrator::perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> Vibrator::performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
Status status = Status::OK;
|
||||
uint32_t timeMS;
|
||||
|
||||
if (effect == Effect::CLICK) {
|
||||
switch (effect) {
|
||||
case Effect::CLICK:
|
||||
mSequencer << WAVEFORM_CLICK_EFFECT_SEQ << std::endl;
|
||||
timeMS = mClickDuration;
|
||||
} else if (effect == Effect::DOUBLE_CLICK) {
|
||||
break;
|
||||
case Effect::DOUBLE_CLICK:
|
||||
mSequencer << WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ << std::endl;
|
||||
timeMS = WAVEFORM_DOUBLE_CLICK_EFFECT_MS;
|
||||
} else {
|
||||
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
|
||||
return Void();
|
||||
}
|
||||
|
||||
mScale << convertEffectStrength(strength) << std::endl;
|
||||
on(timeMS, true /* forceOpenLoop */, true /* isWaveform */);
|
||||
|
||||
_hidl_cb(status, timeMS);
|
||||
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) {
|
||||
break;
|
||||
case Effect::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 {
|
||||
break;
|
||||
default:
|
||||
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
|
||||
return Void();
|
||||
}
|
||||
|
||||
mScale << convertEffectStrength(strength) << std::endl;
|
||||
on(timeMS, true /* forceOpenLoop */, true /* isWaveform */);
|
||||
|
||||
_hidl_cb(status, timeMS);
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_1
|
||||
} // namespace V1_2
|
||||
} // 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_1_VIBRATOR_H
|
||||
#define ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H
|
||||
#ifndef ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H
|
||||
#define ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H
|
||||
|
||||
#include <android/hardware/vibrator/1.1/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.2/IVibrator.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <fstream>
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vibrator {
|
||||
namespace V1_1 {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
class Vibrator : public IVibrator {
|
||||
@@ -42,12 +42,15 @@ public:
|
||||
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;
|
||||
Return<void> perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb)
|
||||
override;
|
||||
Return<void> perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb)
|
||||
override;
|
||||
Return<void> perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
Return<Status> on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform);
|
||||
Return<void> performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb);
|
||||
std::ofstream mActivate;
|
||||
std::ofstream mDuration;
|
||||
std::ofstream mState;
|
||||
@@ -61,9 +64,9 @@ private:
|
||||
int32_t mTickDuration;
|
||||
};
|
||||
} // namespace implementation
|
||||
} // namespace V1_1
|
||||
} // namespace V1_2
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H
|
||||
#endif // ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
service vendor.vibrator-1-1 /vendor/bin/hw/android.hardware.vibrator@1.1-service.wahoo
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
4
vibrator/android.hardware.vibrator@1.2-service.wahoo.rc
Normal file
4
vibrator/android.hardware.vibrator@1.2-service.wahoo.rc
Normal file
@@ -0,0 +1,4 @@
|
||||
service vendor.vibrator-1-2 /vendor/bin/hw/android.hardware.vibrator@1.2-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.1-service.wahoo"
|
||||
#define LOG_TAG "android.hardware.vibrator@1.2-service.wahoo"
|
||||
|
||||
#include <android/hardware/vibrator/1.1/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.2/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_1::IVibrator;
|
||||
using android::hardware::vibrator::V1_1::implementation::Vibrator;
|
||||
using android::hardware::vibrator::V1_2::IVibrator;
|
||||
using android::hardware::vibrator::V1_2::implementation::Vibrator;
|
||||
using namespace android;
|
||||
|
||||
// Refer to Documentation/ABI/testing/sysfs-class-led-driver-drv2624
|
||||
|
||||
Reference in New Issue
Block a user