Delete patches_treble_personal/device_phh_treble/0001-Add-Meizu-18-vibrator-support.patch
This commit is contained in:
parent
49b5b90784
commit
487db27c59
@ -1,431 +0,0 @@
|
||||
From c329331ba9e37c24809afbd026bcc770f7950384 Mon Sep 17 00:00:00 2001
|
||||
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
|
||||
Date: Tue, 22 Jun 2021 13:38:31 +0000
|
||||
Subject: [PATCH 1/3] Add Meizu 18 vibrator support
|
||||
|
||||
Thanks to:
|
||||
- @phhusson for guidance
|
||||
- Google for marlin HAL as reference in implementing 1.0
|
||||
- @xingrz for Meizu 16th HAL as reference in implementing 1.3
|
||||
|
||||
Change-Id: Iecf12cd814e8773abfd78a19f98e31125a73761a
|
||||
---
|
||||
base.mk | 4 +
|
||||
meizu-vibrator/Android.bp | 32 ++++
|
||||
meizu-vibrator/Vibrator.cpp | 140 ++++++++++++++++++
|
||||
meizu-vibrator/Vibrator.h | 60 ++++++++
|
||||
...oid.hardware.vibrator@1.3-service.meizu.rc | 5 +
|
||||
...id.hardware.vibrator@1.3-service.meizu.xml | 11 ++
|
||||
meizu-vibrator/service.cpp | 72 +++++++++
|
||||
sepolicy/file_contexts | 1 +
|
||||
sepolicy/hal.te | 11 ++
|
||||
9 files changed, 336 insertions(+)
|
||||
create mode 100644 meizu-vibrator/Android.bp
|
||||
create mode 100644 meizu-vibrator/Vibrator.cpp
|
||||
create mode 100644 meizu-vibrator/Vibrator.h
|
||||
create mode 100644 meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc
|
||||
create mode 100644 meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml
|
||||
create mode 100644 meizu-vibrator/service.cpp
|
||||
|
||||
diff --git a/base.mk b/base.mk
|
||||
index 49c4da6..3a99248 100644
|
||||
--- a/base.mk
|
||||
+++ b/base.mk
|
||||
@@ -259,3 +259,7 @@ PRODUCT_PACKAGES += \
|
||||
# Two-pane layout in Settings
|
||||
PRODUCT_PACKAGES += \
|
||||
androidx.window.extensions
|
||||
+
|
||||
+# Meizu vibrator
|
||||
+PRODUCT_PACKAGES += \
|
||||
+ android.hardware.vibrator@1.3-service.meizu
|
||||
diff --git a/meizu-vibrator/Android.bp b/meizu-vibrator/Android.bp
|
||||
new file mode 100644
|
||||
index 0000000..76ad034
|
||||
--- /dev/null
|
||||
+++ b/meizu-vibrator/Android.bp
|
||||
@@ -0,0 +1,32 @@
|
||||
+//
|
||||
+// Copyright (C) 2017 The Android Open Source Project
|
||||
+//
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+cc_binary {
|
||||
+ name: "android.hardware.vibrator@1.3-service.meizu",
|
||||
+ relative_install_path: "hw",
|
||||
+ vintf_fragments: ["android.hardware.vibrator@1.3-service.meizu.xml"],
|
||||
+ init_rc: ["android.hardware.vibrator@1.3-service.meizu.rc"],
|
||||
+ srcs: ["service.cpp", "Vibrator.cpp"],
|
||||
+ cflags: ["-Wall", "-Werror"],
|
||||
+ shared_libs: [
|
||||
+ "libhidlbase",
|
||||
+ "liblog",
|
||||
+ "libutils",
|
||||
+ "libhardware",
|
||||
+ "android.hardware.vibrator@1.0",
|
||||
+ "android.hardware.vibrator@1.1",
|
||||
+ "android.hardware.vibrator@1.2",
|
||||
+ "android.hardware.vibrator@1.3",
|
||||
+ ],
|
||||
+}
|
||||
diff --git a/meizu-vibrator/Vibrator.cpp b/meizu-vibrator/Vibrator.cpp
|
||||
new file mode 100644
|
||||
index 0000000..8f12987
|
||||
--- /dev/null
|
||||
+++ b/meizu-vibrator/Vibrator.cpp
|
||||
@@ -0,0 +1,140 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2017 The Android Open Source Project
|
||||
+ *
|
||||
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+ * you may not use this file except in compliance with the License.
|
||||
+ * You may obtain a copy of the License at
|
||||
+ *
|
||||
+ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
+ *
|
||||
+ * Unless required by applicable law or agreed to in writing, software
|
||||
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ * See the License for the specific language governing permissions and
|
||||
+ * limitations under the License.
|
||||
+ */
|
||||
+
|
||||
+#define LOG_TAG "VibratorService"
|
||||
+
|
||||
+#include <log/log.h>
|
||||
+
|
||||
+#include <hardware/hardware.h>
|
||||
+#include <hardware/vibrator.h>
|
||||
+
|
||||
+#include "Vibrator.h"
|
||||
+
|
||||
+#include <cinttypes>
|
||||
+#include <cmath>
|
||||
+#include <iostream>
|
||||
+#include <fstream>
|
||||
+#include <thread>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+namespace android {
|
||||
+namespace hardware {
|
||||
+namespace vibrator {
|
||||
+namespace V1_3 {
|
||||
+namespace implementation {
|
||||
+
|
||||
+Vibrator::Vibrator(std::ofstream&& timeoutAndAmplitude, std::ofstream&& waveNumber, std::ofstream&& effectTrigger) :
|
||||
+ mTimeoutAndAmplitude(std::move(timeoutAndAmplitude)),
|
||||
+ mWaveNumber(std::move(waveNumber)),
|
||||
+ mEffectTrigger(std::move(effectTrigger)) {}
|
||||
+
|
||||
+Return<Status> Vibrator::on(uint32_t timeout_ms) {
|
||||
+ // Wave number 12 for vibrations slightly stronger than stock (13)
|
||||
+ mWaveNumber << 12 << std::endl;
|
||||
+ mTimeoutAndAmplitude << timeout_ms << std::endl;
|
||||
+ if (!mTimeoutAndAmplitude) {
|
||||
+ ALOGE("Failed to turn vibrator on (%d): %s", errno, strerror(errno));
|
||||
+ return Status::UNKNOWN_ERROR;
|
||||
+ }
|
||||
+ return Status::OK;
|
||||
+}
|
||||
+
|
||||
+Return<Status> Vibrator::off() {
|
||||
+ mTimeoutAndAmplitude << 0 << std::endl;
|
||||
+ if (!mTimeoutAndAmplitude) {
|
||||
+ ALOGE("Failed to turn vibrator off (%d): %s", errno, strerror(errno));
|
||||
+ 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(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
+ return perform<decltype(effect)>(effect, strength, _hidl_cb);
|
||||
+}
|
||||
+
|
||||
+Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
+ return perform<decltype(effect)>(effect, strength, _hidl_cb);
|
||||
+}
|
||||
+
|
||||
+Return<void> Vibrator::perform_1_2(V1_2::Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
+ return perform<decltype(effect)>(effect, strength, _hidl_cb);
|
||||
+}
|
||||
+
|
||||
+Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
+ return perform<decltype(effect)>(effect, strength, _hidl_cb);
|
||||
+}
|
||||
+
|
||||
+Return<bool> Vibrator::supportsExternalControl() {
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+Return<Status> Vibrator::setExternalControl(bool) {
|
||||
+ return Status::UNSUPPORTED_OPERATION;
|
||||
+}
|
||||
+
|
||||
+Return<void> Vibrator::perform(Effect effect, EffectStrength, perform_cb _hidl_cb) {
|
||||
+ uint32_t id;
|
||||
+ switch (effect) {
|
||||
+ case Effect::CLICK:
|
||||
+ id = 31008;
|
||||
+ break;
|
||||
+ case Effect::DOUBLE_CLICK:
|
||||
+ id = 31003;
|
||||
+ break;
|
||||
+ case Effect::TICK:
|
||||
+ case Effect::TEXTURE_TICK:
|
||||
+ id = 21000;
|
||||
+ break;
|
||||
+ case Effect::THUD:
|
||||
+ id = 30900;
|
||||
+ break;
|
||||
+ case Effect::POP:
|
||||
+ id = 22520;
|
||||
+ break;
|
||||
+ case Effect::HEAVY_CLICK:
|
||||
+ id = 30900;
|
||||
+ break;
|
||||
+ default:
|
||||
+ _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
|
||||
+ return Void();
|
||||
+ }
|
||||
+ mEffectTrigger << id << std::endl;
|
||||
+ _hidl_cb(Status::OK, 200);
|
||||
+ return Void();
|
||||
+}
|
||||
+
|
||||
+template <typename T> Return<void> Vibrator::perform(T effect, EffectStrength strength, perform_cb _hidl_cb) {
|
||||
+ auto validRange = hidl_enum_range<T>();
|
||||
+ if (effect < *validRange.begin() || effect > *std::prev(validRange.end())) {
|
||||
+ _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
|
||||
+ return Void();
|
||||
+ }
|
||||
+ return perform(static_cast<Effect>(effect), strength, _hidl_cb);
|
||||
+}
|
||||
+
|
||||
+} // namespace implementation
|
||||
+} // namespace V1_3
|
||||
+} // namespace vibrator
|
||||
+} // namespace hardware
|
||||
+} // namespace android
|
||||
diff --git a/meizu-vibrator/Vibrator.h b/meizu-vibrator/Vibrator.h
|
||||
new file mode 100644
|
||||
index 0000000..df901aa
|
||||
--- /dev/null
|
||||
+++ b/meizu-vibrator/Vibrator.h
|
||||
@@ -0,0 +1,60 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2017 The Android Open Source Project
|
||||
+ *
|
||||
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+ * you may not use this file except in compliance with the License.
|
||||
+ * You may obtain a copy of the License at
|
||||
+ *
|
||||
+ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
+ *
|
||||
+ * Unless required by applicable law or agreed to in writing, software
|
||||
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ * See the License for the specific language governing permissions and
|
||||
+ * limitations under the License.
|
||||
+ */
|
||||
+#ifndef ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H
|
||||
+#define ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H
|
||||
+
|
||||
+#include <android/hardware/vibrator/1.3/IVibrator.h>
|
||||
+#include <hidl/Status.h>
|
||||
+
|
||||
+#include <fstream>
|
||||
+
|
||||
+namespace android {
|
||||
+namespace hardware {
|
||||
+namespace vibrator {
|
||||
+namespace V1_3 {
|
||||
+namespace implementation {
|
||||
+
|
||||
+using android::hardware::vibrator::V1_0::EffectStrength;
|
||||
+using android::hardware::vibrator::V1_0::Status;
|
||||
+
|
||||
+class Vibrator : public IVibrator {
|
||||
+public:
|
||||
+ Vibrator(std::ofstream&& timeoutAndAmplitude, std::ofstream&& waveNumber, std::ofstream&& effectTrigger);
|
||||
+ 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(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(V1_2::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
|
||||
+ Return<void> perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
|
||||
+ Return<bool> supportsExternalControl() override;
|
||||
+ Return<Status> setExternalControl(bool enabled) override;
|
||||
+
|
||||
+private:
|
||||
+ Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb);
|
||||
+ template <typename T> Return<void> perform(T effect, EffectStrength strength, perform_cb _hidl_cb);
|
||||
+ std::ofstream mTimeoutAndAmplitude;
|
||||
+ std::ofstream mWaveNumber;
|
||||
+ std::ofstream mEffectTrigger;
|
||||
+};
|
||||
+} // namespace implementation
|
||||
+} // namespace V1_3
|
||||
+} // namespace vibrator
|
||||
+} // namespace hardware
|
||||
+} // namespace android
|
||||
+
|
||||
+#endif // ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H
|
||||
diff --git a/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc b/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc
|
||||
new file mode 100644
|
||||
index 0000000..527ff66
|
||||
--- /dev/null
|
||||
+++ b/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc
|
||||
@@ -0,0 +1,5 @@
|
||||
+service vibrator.meizu /system/bin/hw/android.hardware.vibrator@1.3-service.meizu
|
||||
+ class late_start
|
||||
+ user system
|
||||
+ group system
|
||||
+ oneshot
|
||||
diff --git a/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml b/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml
|
||||
new file mode 100644
|
||||
index 0000000..d1b836e
|
||||
--- /dev/null
|
||||
+++ b/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml
|
||||
@@ -0,0 +1,11 @@
|
||||
+<manifest version="1.0" type="framework">
|
||||
+ <hal format="hidl">
|
||||
+ <name>android.hardware.vibrator</name>
|
||||
+ <transport>hwbinder</transport>
|
||||
+ <version>1.3</version>
|
||||
+ <interface>
|
||||
+ <name>IVibrator</name>
|
||||
+ <instance>default</instance>
|
||||
+ </interface>
|
||||
+ </hal>
|
||||
+</manifest>
|
||||
diff --git a/meizu-vibrator/service.cpp b/meizu-vibrator/service.cpp
|
||||
new file mode 100644
|
||||
index 0000000..1405dfb
|
||||
--- /dev/null
|
||||
+++ b/meizu-vibrator/service.cpp
|
||||
@@ -0,0 +1,72 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2017 The Android Open Source Project
|
||||
+ *
|
||||
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+ * you may not use this file except in compliance with the License.
|
||||
+ * You may obtain a copy of the License at
|
||||
+ *
|
||||
+ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
+ *
|
||||
+ * Unless required by applicable law or agreed to in writing, software
|
||||
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ * See the License for the specific language governing permissions and
|
||||
+ * limitations under the License.
|
||||
+ */
|
||||
+#define LOG_TAG "android.hardware.vibrator@1.3-service.meizu"
|
||||
+
|
||||
+#include <android/hardware/vibrator/1.3/IVibrator.h>
|
||||
+#include <hidl/HidlSupport.h>
|
||||
+#include <hidl/HidlTransportSupport.h>
|
||||
+#include <utils/Errors.h>
|
||||
+#include <utils/StrongPointer.h>
|
||||
+
|
||||
+#include "Vibrator.h"
|
||||
+
|
||||
+using android::hardware::configureRpcThreadpool;
|
||||
+using android::hardware::joinRpcThreadpool;
|
||||
+using android::hardware::vibrator::V1_3::IVibrator;
|
||||
+using android::hardware::vibrator::V1_3::implementation::Vibrator;
|
||||
+using namespace android;
|
||||
+
|
||||
+static const char *CONTROL_PATH_TIMEOUT = "/sys/class/timed_output/vibrator/enable";
|
||||
+static const char *PATH_WAVE_NUMBER = "/sys/class/meizu/motor/waveform";
|
||||
+static const char *CONTROL_PATH_EFFECT = "/sys/class/meizu/motor/on_off";
|
||||
+
|
||||
+status_t registerVibratorService() {
|
||||
+ std::ofstream timeoutAndAmplitude{CONTROL_PATH_TIMEOUT};
|
||||
+ if (!timeoutAndAmplitude) {
|
||||
+ int error = errno;
|
||||
+ ALOGE("Failed to open %s (%d): %s", CONTROL_PATH_TIMEOUT, error, strerror(error));
|
||||
+ return -error;
|
||||
+ }
|
||||
+
|
||||
+ std::ofstream waveNumber{PATH_WAVE_NUMBER};
|
||||
+ if (!waveNumber) {
|
||||
+ int error = errno;
|
||||
+ ALOGE("Failed to open %s (%d): %s", PATH_WAVE_NUMBER, error, strerror(error));
|
||||
+ return -error;
|
||||
+ }
|
||||
+
|
||||
+ std::ofstream effectTrigger{CONTROL_PATH_EFFECT};
|
||||
+ if (!effectTrigger) {
|
||||
+ int error = errno;
|
||||
+ ALOGE("Failed to open %s (%d): %s", CONTROL_PATH_EFFECT, error, strerror(error));
|
||||
+ return -error;
|
||||
+ }
|
||||
+
|
||||
+ sp<IVibrator> vibrator = new Vibrator(std::move(timeoutAndAmplitude), std::move(waveNumber), std::move(effectTrigger));
|
||||
+ (void) vibrator->registerAsService(); // suppress unused-result warning
|
||||
+ return OK;
|
||||
+}
|
||||
+
|
||||
+int main() {
|
||||
+ configureRpcThreadpool(1, true);
|
||||
+ status_t status = registerVibratorService();
|
||||
+
|
||||
+ if (status != OK) {
|
||||
+ return status;
|
||||
+ }
|
||||
+
|
||||
+ joinRpcThreadpool();
|
||||
+}
|
||||
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
|
||||
index beb639a..3bc437c 100644
|
||||
--- a/sepolicy/file_contexts
|
||||
+++ b/sepolicy/file_contexts
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
/system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.oppo.compat u:object_r:hal_fingerprint_oppo_compat_exec:s0
|
||||
/system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.oplus.compat u:object_r:hal_fingerprint_oppo_compat_exec:s0
|
||||
+/system/bin/hw/android.hardware.vibrator@1.3-service.meizu u:object_r:hal_vibrator_default_exec:s0
|
||||
|
||||
/efs u:object_r:efs_file:s0
|
||||
|
||||
diff --git a/sepolicy/hal.te b/sepolicy/hal.te
|
||||
index cb44422..280ae2d 100644
|
||||
--- a/sepolicy/hal.te
|
||||
+++ b/sepolicy/hal.te
|
||||
@@ -8,3 +8,14 @@ init_daemon_domain(hal_fingerprint_oppo_compat)
|
||||
|
||||
type hal_fingerprint_oppo, domain;
|
||||
allow hal_fingerprint_oppo vendor_default_prop:property_service { set };
|
||||
+
|
||||
+type vib_strength_sysfs, fs_type, sysfs_type;
|
||||
+
|
||||
+type hal_vibrator_default, domain;
|
||||
+hal_server_domain(hal_vibrator_default, hal_vibrator)
|
||||
+
|
||||
+type hal_vibrator_default_exec, exec_type, vendor_file_type, file_type;
|
||||
+init_daemon_domain(hal_vibrator_default)
|
||||
+
|
||||
+allow hal_vibrator_default vib_strength_sysfs:dir rw_dir_perms;
|
||||
+allow hal_vibrator_default vib_strength_sysfs:file rw_file_perms;
|
||||
--
|
||||
2.34.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user