Initial unified commit for Android 11, syncing up to v311

This commit is contained in:
Andy CrossGate Yan
2021-08-08 02:20:00 +00:00
commit 01693449b8
191 changed files with 23879 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
From 79bc0294a742981eff0905118921e035241878dc Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Sun, 8 Aug 2021 09:31:01 +0000
Subject: [PATCH 1/3] Revert "treble: Set BOARD_EXT4_SHARE_DUP_BLOCKS
explicitly"
This reverts commit d7b179f234d76c3acf7a723fc05f07efe9adc84c.
---
board-base.mk | 1 -
1 file changed, 1 deletion(-)
diff --git a/board-base.mk b/board-base.mk
index e270068..0da1061 100644
--- a/board-base.mk
+++ b/board-base.mk
@@ -4,4 +4,3 @@ TARGET_EXFAT_DRIVER := exfat
DEVICE_FRAMEWORK_MANIFEST_FILE := device/phh/treble/framework_manifest.xml
BOARD_ROOT_EXTRA_FOLDERS += bt_firmware sec_storage efs
-BOARD_EXT4_SHARE_DUP_BLOCKS := true
--
2.25.1

View File

@@ -0,0 +1,430 @@
From ec91b5cae6341702dc39bf6e579a4fd791af87c0 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 2/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 | 3 +
framework_manifest.xml | 10 ++
hal/meizu-vibrator/Android.bp | 31 ++++
hal/meizu-vibrator/Vibrator.cpp | 140 ++++++++++++++++++
hal/meizu-vibrator/Vibrator.h | 60 ++++++++
...oid.hardware.vibrator@1.3-service.meizu.rc | 4 +
hal/meizu-vibrator/service.cpp | 72 +++++++++
sepolicy/file_contexts | 1 +
sepolicy/hal.te | 11 ++
9 files changed, 332 insertions(+)
create mode 100644 hal/meizu-vibrator/Android.bp
create mode 100644 hal/meizu-vibrator/Vibrator.cpp
create mode 100644 hal/meizu-vibrator/Vibrator.h
create mode 100644 hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc
create mode 100644 hal/meizu-vibrator/service.cpp
diff --git a/base.mk b/base.mk
index 878aaae..1755f9e 100644
--- a/base.mk
+++ b/base.mk
@@ -203,3 +203,6 @@ PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
# AOSP overlays
PRODUCT_PACKAGES += \
NavigationBarMode2ButtonOverlay
+
+PRODUCT_PACKAGES += \
+ android.hardware.vibrator@1.3-service.meizu
diff --git a/framework_manifest.xml b/framework_manifest.xml
index cb37b49..1b45b4a 100644
--- a/framework_manifest.xml
+++ b/framework_manifest.xml
@@ -19,5 +19,15 @@
<instance>default</instance>
</interface>
</hal>
+
+ <hal>
+ <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/hal/meizu-vibrator/Android.bp b/hal/meizu-vibrator/Android.bp
new file mode 100644
index 0000000..4e3c1b9
--- /dev/null
+++ b/hal/meizu-vibrator/Android.bp
@@ -0,0 +1,31 @@
+//
+// 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",
+ 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/hal/meizu-vibrator/Vibrator.cpp b/hal/meizu-vibrator/Vibrator.cpp
new file mode 100644
index 0000000..8f12987
--- /dev/null
+++ b/hal/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/hal/meizu-vibrator/Vibrator.h b/hal/meizu-vibrator/Vibrator.h
new file mode 100644
index 0000000..df901aa
--- /dev/null
+++ b/hal/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/hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc b/hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc
new file mode 100644
index 0000000..ddf39c4
--- /dev/null
+++ b/hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.rc
@@ -0,0 +1,4 @@
+service vibrator.meizu /system/bin/hw/android.hardware.vibrator@1.3-service.meizu
+ class late_start
+ user system
+ group system
diff --git a/hal/meizu-vibrator/service.cpp b/hal/meizu-vibrator/service.cpp
new file mode 100644
index 0000000..1405dfb
--- /dev/null
+++ b/hal/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 7ab5e91..2b59077 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -12,6 +12,7 @@
/dev/dsm u:object_r:dmd_device:s0
/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.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.25.1

View File

@@ -0,0 +1,115 @@
From 271f7db60868e2e96fbe5be09b81b943d8fbc91d Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Sun, 27 Jun 2021 05:21:38 +0000
Subject: [PATCH 3/3] Only use meizu-vibrator on Meizu 18
- Convert manifest to VINTF fragment
- If not the target device, bind to dummy manifest on boot
Change-Id: I97fc52a98a77aa72bbd5601f36abc0cf18efbaea
---
framework_manifest.xml | 10 ----------
hal/meizu-vibrator/Android.bp | 1 +
.../android.hardware.vibrator@1.3-service.meizu.xml | 11 +++++++++++
hal/meizu-vibrator/manifest_dummy.xml | 3 +++
rw-system.sh | 10 ++++++++--
5 files changed, 23 insertions(+), 12 deletions(-)
create mode 100644 hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml
create mode 100644 hal/meizu-vibrator/manifest_dummy.xml
diff --git a/framework_manifest.xml b/framework_manifest.xml
index 1b45b4a..cb37b49 100644
--- a/framework_manifest.xml
+++ b/framework_manifest.xml
@@ -19,15 +19,5 @@
<instance>default</instance>
</interface>
</hal>
-
- <hal>
- <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/hal/meizu-vibrator/Android.bp b/hal/meizu-vibrator/Android.bp
index 4e3c1b9..276728c 100644
--- a/hal/meizu-vibrator/Android.bp
+++ b/hal/meizu-vibrator/Android.bp
@@ -15,6 +15,7 @@
cc_binary {
name: "android.hardware.vibrator@1.3-service.meizu",
relative_install_path: "hw",
+ vintf_fragments: ["android.hardware.vibrator@1.3-service.meizu.xml", "manifest_dummy.xml"],
init_rc: ["android.hardware.vibrator@1.3-service.meizu.rc"],
srcs: ["service.cpp", "Vibrator.cpp"],
cflags: ["-Wall", "-Werror"],
diff --git a/hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml b/hal/meizu-vibrator/android.hardware.vibrator@1.3-service.meizu.xml
new file mode 100644
index 0000000..d1b836e
--- /dev/null
+++ b/hal/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/hal/meizu-vibrator/manifest_dummy.xml b/hal/meizu-vibrator/manifest_dummy.xml
new file mode 100644
index 0000000..b34a10b
--- /dev/null
+++ b/hal/meizu-vibrator/manifest_dummy.xml
@@ -0,0 +1,3 @@
+<!-- Dummy manifest XML -->
+<manifest version="1.0" type="framework">
+</manifest>
diff --git a/rw-system.sh b/rw-system.sh
index 38271b4..dcb007e 100644
--- a/rw-system.sh
+++ b/rw-system.sh
@@ -314,6 +314,12 @@ if [ "$foundFingerprint" = false ];then
mount -o bind system/phh/empty /system/etc/permissions/android.hardware.fingerprint.xml
fi
+if ! getprop ro.vendor.build.fingerprint | grep -qE 'meizu_18'; then
+ mount -o bind system/phh/empty /system/bin/hw/android.hardware.vibrator@1.3-service.meizu
+ mount -o bind system/phh/empty /system/etc/init/android.hardware.vibrator@1.3-service.meizu.rc
+ mount -o bind system/etc/vintf/manifest/manifest_dummy.xml /system/etc/vintf/manifest/android.hardware.vibrator@1.3-service.meizu.xml
+fi
+
if ! grep android.hardware.bluetooth /vendor/manifest.xml && ! grep android.hardware.bluetooth /vendor/etc/vintf/manifest.xml; then
mount -o bind system/phh/empty /system/etc/permissions/android.hardware.bluetooth.xml
mount -o bind system/phh/empty /system/etc/permissions/android.hardware.bluetooth_le.xml
@@ -385,7 +391,7 @@ if getprop ro.build.overlay.deviceid |grep -q -e CPH1859 -e CPH1861 -e RMX1811 -
setprop persist.sys.qcom-brightness "$(cat /sys/class/leds/lcd-backlight/max_brightness)"
fi
-if getprop ro.build.overlay.deviceid |grep -iq -e RMX2020 -e RMX2027 -e RMX2040 -e RMX2193 -e RMX2191;then
+if getprop ro.build.overlay.deviceid |grep -iq -e RMX2020 -e RMX2027 -e RMX2040 -e RMX2193 -e RMX2191;then
setprop persist.sys.qcom-brightness 2047
setprop persist.sys.overlay.devinputjack true
setprop persist.sys.phh.fingerprint.nocleanup true
@@ -873,7 +879,7 @@ if getprop ro.build.overlay.deviceid |grep -qiE -e '^RMX' -e '^CPH';then
setprop persist.sys.phh.fod.bbk true
fi
-if getprop ro.build.overlay.deviceid |grep -iq -e RMX1941 -e RMX1945 -e RMX1943 -e RMX1942;then
+if getprop ro.build.overlay.deviceid |grep -iq -e RMX1941 -e RMX1945 -e RMX1943 -e RMX1942;then
setprop persist.sys.qcom-brightness "$(cat /sys/class/leds/lcd-backlight/max_brightness)"
setprop persist.sys.phh.mainkeys 0
fi
--
2.25.1