├── Android.bp
├── sensors
├── .clang-format
├── Android.bp
└── udfps_hal.cpp
├── hidl
├── touch
│ ├── .clang-format
│ ├── vendor.lineage.touch@1.0-service.xiaomi.rc
│ ├── vendor.lineage.touch@1.0-service.xiaomi.xml
│ ├── HighTouchPollingRate.h
│ ├── HighTouchPollingRate.cpp
│ ├── service.cpp
│ └── Android.bp
├── sensors
│ ├── 1.0
│ │ ├── .clang-format
│ │ ├── Android.bp
│ │ ├── include
│ │ │ └── sensors
│ │ │ │ └── convert.h
│ │ ├── Sensors.h
│ │ ├── Sensors.cpp
│ │ └── convert.cpp
│ ├── android.hardware.sensors@2.1-service.xiaomi-multihal.rc
│ ├── android.hardware.sensors@2.1.xiaomi-multihal.xml
│ ├── service.cpp
│ ├── Android.bp
│ └── HalProxyCallback.cpp
├── biometrics
│ └── fingerprint
│ │ ├── .clang-format
│ │ ├── android.hardware.biometrics.fingerprint@2.3-service.xiaomi.rc
│ │ ├── android.hardware.biometrics.fingerprint@2.3-service.xiaomi.xml
│ │ ├── UdfpsExtension.cpp
│ │ ├── include
│ │ ├── UdfpsHandler.h
│ │ └── fingerprint.h
│ │ ├── UdfpsHandler.cpp
│ │ ├── service.cpp
│ │ ├── Android.bp
│ │ ├── BiometricsFingerprint.h
│ │ └── BiometricsFingerprint.cpp
├── consumerir
│ ├── android.hardware.ir@1.0-service.xiaomi.rc
│ ├── android.hardware.ir@1.0-service.xiaomi.xml
│ ├── Android.bp
│ ├── service.cpp
│ ├── ConsumerIr.h
│ └── ConsumerIr.cpp
└── powershare
│ ├── vendor.lineage.powershare@1.0-service.xiaomi.rc
│ ├── vendor.lineage.powershare@1.0-service.xiaomi.xml
│ ├── PowerShare.h
│ ├── service.cpp
│ ├── Android.bp
│ └── PowerShare.cpp
├── IFAAService
├── res
│ └── values
│ │ └── strings.xml
├── Android.bp
├── src
│ └── org
│ │ └── ifaa
│ │ └── aidl
│ │ └── manager
│ │ ├── IfaaManagerService.aidl
│ │ └── IfaaService.java
└── AndroidManifest.xml
├── aidl
├── light
│ ├── android.hardware.light-service.xiaomi.xml
│ ├── Backlight.h
│ ├── LED.h
│ ├── Android.bp
│ ├── service.cpp
│ ├── Utils.h
│ ├── LED.cpp
│ ├── Lights.h
│ ├── android.hardware.light-service.xiaomi.rc
│ ├── Utils.cpp
│ ├── Backlight.cpp
│ └── Lights.cpp
├── power-libperfmgr
│ ├── android.hardware.power-service.xiaomi.xml
│ ├── android.hardware.power-service.xiaomi-libperfmgr.rc
│ ├── PowerExt.h
│ ├── InteractionHandler.h
│ ├── Android.mk
│ ├── Power.h
│ ├── service.cpp
│ ├── PowerExt.cpp
│ ├── PowerSessionManager.h
│ ├── PowerHintSession.h
│ ├── PowerSessionManager.cpp
│ ├── InteractionHandler.cpp
│ └── Power.cpp
└── Android.mk
├── interfaces
├── Android.bp
├── updates-makefiles.sh
├── xiaomi
│ ├── hardware
│ │ ├── mlipay
│ │ │ ├── 1.0
│ │ │ │ ├── Android.bp
│ │ │ │ └── IMlipayService.hal
│ │ │ └── 1.1
│ │ │ │ ├── IMlipayService.hal
│ │ │ │ └── Android.bp
│ │ ├── mtdservice
│ │ │ ├── 1.0
│ │ │ │ ├── Android.bp
│ │ │ │ └── IMTService.hal
│ │ │ ├── 1.1
│ │ │ │ ├── Android.bp
│ │ │ │ └── IMTService.hal
│ │ │ └── 1.2
│ │ │ │ ├── Android.bp
│ │ │ │ └── IMTService.hal
│ │ ├── touchfeature
│ │ │ └── 1.0
│ │ │ │ ├── Android.bp
│ │ │ │ └── ITouchFeature.hal
│ │ ├── fingerprintextension
│ │ │ └── 1.0
│ │ │ │ ├── Android.bp
│ │ │ │ └── IXiaomiFingerprint.hal
│ │ ├── motor
│ │ │ └── 1.0
│ │ │ │ ├── Android.bp
│ │ │ │ ├── types.hal
│ │ │ │ ├── IMotorCallback.hal
│ │ │ │ └── IMotor.hal
│ │ └── displayfeature
│ │ │ └── 1.0
│ │ │ ├── Android.bp
│ │ │ ├── IDisplayFeatureCallback.hal
│ │ │ ├── types.hal
│ │ │ └── IDisplayFeature.hal
│ └── hw
│ │ └── touchfeature
│ │ └── 1.0
│ │ ├── Android.bp
│ │ └── ITouchFeature.hal
└── goodix
│ └── hardware
│ └── biometrics
│ └── fingerprint
│ └── 2.1
│ ├── Android.bp
│ ├── IGoodixFingerprintDaemonCallback.hal
│ └── IGoodixFingerprintDaemon.hal
├── megvii
├── Android.bp
└── megvii.c
└── Android.mk
/Android.bp:
--------------------------------------------------------------------------------
1 | soong_namespace {
2 | }
3 |
--------------------------------------------------------------------------------
/sensors/.clang-format:
--------------------------------------------------------------------------------
1 | ../../../build/soong/scripts/system-clang-format
--------------------------------------------------------------------------------
/hidl/touch/.clang-format:
--------------------------------------------------------------------------------
1 | ../../../../build/soong/scripts/system-clang-format
--------------------------------------------------------------------------------
/hidl/sensors/1.0/.clang-format:
--------------------------------------------------------------------------------
1 | ../../../../../build/soong/scripts/system-clang-format
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/.clang-format:
--------------------------------------------------------------------------------
1 | ../../../../../build/soong/scripts/system-clang-format
--------------------------------------------------------------------------------
/IFAAService/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | IFAAService
4 |
5 |
--------------------------------------------------------------------------------
/hidl/consumerir/android.hardware.ir@1.0-service.xiaomi.rc:
--------------------------------------------------------------------------------
1 | service ir-hal-1-0 /vendor/bin/hw/android.hardware.ir@1.0-service.xiaomi
2 | class hal
3 | user system
4 | group system
5 |
--------------------------------------------------------------------------------
/hidl/powershare/vendor.lineage.powershare@1.0-service.xiaomi.rc:
--------------------------------------------------------------------------------
1 | service vendor.powershare-hal-1-0 /vendor/bin/hw/vendor.lineage.powershare@1.0-service.xiaomi
2 | class hal
3 | user system
4 | group system
5 |
--------------------------------------------------------------------------------
/aidl/light/android.hardware.light-service.xiaomi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android.hardware.light
4 | ILights/default
5 |
6 |
7 |
--------------------------------------------------------------------------------
/interfaces/Android.bp:
--------------------------------------------------------------------------------
1 | hidl_package_root {
2 | name: "vendor.goodix",
3 | path: "hardware/xiaomi/interfaces/goodix",
4 | }
5 |
6 | hidl_package_root {
7 | name: "vendor.xiaomi",
8 | path: "hardware/xiaomi/interfaces/xiaomi",
9 | }
10 |
--------------------------------------------------------------------------------
/hidl/touch/vendor.lineage.touch@1.0-service.xiaomi.rc:
--------------------------------------------------------------------------------
1 | service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.xiaomi
2 | interface vendor.lineage.touch@1.0::IHighTouchPollingRate default
3 | class hal
4 | user system
5 | group system
6 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/android.hardware.power-service.xiaomi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android.hardware.power
4 | 2
5 | IPower/default
6 |
7 |
8 |
--------------------------------------------------------------------------------
/interfaces/updates-makefiles.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source $ANDROID_BUILD_TOP/system/tools/hidl/update-makefiles-helper.sh
4 |
5 | do_makefiles_update \
6 | "vendor.goodix:hardware/xiaomi/interfaces/goodix"
7 |
8 | do_makefiles_update \
9 | "vendor.xiaomi:hardware/xiaomi/interfaces/xiaomi"
10 |
--------------------------------------------------------------------------------
/hidl/sensors/android.hardware.sensors@2.1-service.xiaomi-multihal.rc:
--------------------------------------------------------------------------------
1 | service vendor.sensors-hal-2-1-multihal /vendor/bin/hw/android.hardware.sensors@2.1-service.xiaomi-multihal
2 | class hal
3 | user system
4 | group system wakelock context_hub uhid
5 | writepid /dev/cpuset/system-background/tasks
6 | capabilities BLOCK_SUSPEND
7 | rlimit rtprio 10 10
8 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mlipay/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.mlipay@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IMlipayService.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | ],
13 | gen_java: true,
14 | }
15 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hw/touchfeature/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hw.touchfeature@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "ITouchFeature.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | ],
13 | gen_java: true,
14 | }
15 |
--------------------------------------------------------------------------------
/hidl/consumerir/android.hardware.ir@1.0-service.xiaomi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android.hardware.ir
4 | hwbinder
5 | 1.0
6 |
7 | IConsumerIr
8 | default
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mtdservice/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.mtdservice@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IMTService.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | ],
13 | gen_java: true,
14 | }
15 |
--------------------------------------------------------------------------------
/hidl/sensors/android.hardware.sensors@2.1.xiaomi-multihal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android.hardware.sensors
4 | hwbinder
5 | 2.1
6 |
7 | ISensors
8 | default
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/hidl/touch/vendor.lineage.touch@1.0-service.xiaomi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | vendor.lineage.touch
4 | hwbinder
5 | 1.0
6 |
7 | IHighTouchPollingRate
8 | default
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/touchfeature/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.touchfeature@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "ITouchFeature.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | ],
13 | gen_java: true,
14 | }
15 |
--------------------------------------------------------------------------------
/hidl/powershare/vendor.lineage.powershare@1.0-service.xiaomi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | vendor.lineage.powershare
4 | hwbinder
5 | 1.0
6 |
7 | IPowerShare
8 | default
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/android.hardware.biometrics.fingerprint@2.3-service.xiaomi.rc:
--------------------------------------------------------------------------------
1 | service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.xiaomi
2 | # "class hal" causes a race condition on some devices due to files created
3 | # in /data. As a workaround, postpone startup until later in boot once
4 | # /data is mounted.
5 | class late_start
6 | user system
7 | group system input uhid
8 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/fingerprintextension/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.fingerprintextension@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IXiaomiFingerprint.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | ],
13 | gen_java: true,
14 | }
15 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mlipay/1.1/IMlipayService.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package vendor.xiaomi.hardware.mlipay@1.1;
8 |
9 | import @1.0::IMlipayService;
10 |
11 | interface IMlipayService extends @1.0::IMlipayService {
12 | ifaa_key_dump() generates (string hex);
13 | ifaa_get_idlist(uint32_t bioType) generates (vec idList);
14 | };
15 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mlipay/1.1/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.mlipay@1.1",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IMlipayService.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | "vendor.xiaomi.hardware.mlipay@1.0",
13 | ],
14 | gen_java: true,
15 | }
16 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/motor/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.motor@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "types.hal",
9 | "IMotor.hal",
10 | "IMotorCallback.hal",
11 | ],
12 | interfaces: [
13 | "android.hidl.base@1.0",
14 | ],
15 | gen_java: true,
16 | }
17 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mtdservice/1.1/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.mtdservice@1.1",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IMTService.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | "vendor.xiaomi.hardware.mtdservice@1.0",
13 | ],
14 | gen_java: true,
15 | }
16 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/android.hardware.biometrics.fingerprint@2.3-service.xiaomi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android.hardware.biometrics.fingerprint
4 | hwbinder
5 | 2.3
6 |
7 | IBiometricsFingerprint
8 | default
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/megvii/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | cc_defaults {
8 | name: "libMegviiFacepp_defaults",
9 | vendor: true,
10 | srcs: [
11 | "megvii.c",
12 | ],
13 | }
14 |
15 | cc_library_shared {
16 | name: "libMegviiFacepp-0.5.2",
17 | defaults: ["libMegviiFacepp_defaults"],
18 | }
19 |
20 | cc_library_shared {
21 | name: "libmegface",
22 | vendor: true,
23 | }
24 |
--------------------------------------------------------------------------------
/sensors/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | cc_library_shared {
8 | name: "sensors.udfps",
9 | defaults: ["hidl_defaults"],
10 | srcs: [
11 | "udfps_hal.cpp",
12 | ],
13 | shared_libs: [
14 | "libcutils",
15 | "liblog",
16 | "libutils",
17 | ],
18 | header_libs: [
19 | "libhardware_headers",
20 | ],
21 | vendor: true,
22 | }
23 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/displayfeature/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.displayfeature@1.0",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "types.hal",
9 | "IDisplayFeature.hal",
10 | "IDisplayFeatureCallback.hal",
11 | ],
12 | interfaces: [
13 | "android.hidl.base@1.0",
14 | ],
15 | gen_java: true,
16 | }
17 |
--------------------------------------------------------------------------------
/interfaces/goodix/hardware/biometrics/fingerprint/2.1/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.goodix.hardware.biometrics.fingerprint@2.1",
5 | root: "vendor.goodix",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IGoodixFingerprintDaemon.hal",
9 | "IGoodixFingerprintDaemonCallback.hal",
10 | ],
11 | interfaces: [
12 | "android.hidl.base@1.0",
13 | ],
14 | gen_java: true,
15 | }
16 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mtdservice/1.2/Android.bp:
--------------------------------------------------------------------------------
1 | // This file is autogenerated by hidl-gen -Landroidbp.
2 |
3 | hidl_interface {
4 | name: "vendor.xiaomi.hardware.mtdservice@1.2",
5 | root: "vendor.xiaomi",
6 | system_ext_specific: true,
7 | srcs: [
8 | "IMTService.hal",
9 | ],
10 | interfaces: [
11 | "android.hidl.base@1.0",
12 | "vendor.xiaomi.hardware.mtdservice@1.0",
13 | "vendor.xiaomi.hardware.mtdservice@1.1",
14 | ],
15 | gen_java: true,
16 | }
17 |
--------------------------------------------------------------------------------
/aidl/light/Backlight.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "Utils.h"
8 |
9 | namespace aidl {
10 | namespace android {
11 | namespace hardware {
12 | namespace light {
13 |
14 | class BacklightDevice {
15 | public:
16 | virtual ~BacklightDevice() = default;
17 |
18 | virtual void setBacklight(uint8_t value) = 0;
19 | virtual bool exists() = 0;
20 | };
21 |
22 | BacklightDevice *getBacklightDevice();
23 |
24 | } // namespace light
25 | } // namespace hardware
26 | } // namespace android
27 | } // namespace aidl
28 |
--------------------------------------------------------------------------------
/IFAAService/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | android_app {
8 | name: "IFAAService",
9 | srcs: [
10 | "src/**/*.java",
11 | "src/**/I*.aidl",
12 | ],
13 | aidl: {
14 | local_include_dirs: ["src"],
15 | },
16 | resource_dirs: ["res"],
17 |
18 | static_libs: [
19 | "android.hidl.base-V1.0-java",
20 | "vendor.xiaomi.hardware.mlipay-V1.1-java",
21 | ],
22 |
23 | certificate: "platform",
24 | platform_apis: true,
25 | system_ext_specific: true,
26 | }
27 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mlipay/1.0/IMlipayService.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package vendor.xiaomi.hardware.mlipay@1.0;
8 |
9 | interface IMlipayService {
10 | invoke_command(vec sbuf, uint32_t sbuf_len) generates (vec ret);
11 | ifaa_key_get_version() generates (int32_t result);
12 | ifaa_key_prepare() generates (string hex);
13 | ifaa_key_load(string data_text, string sign_text) generates (int32_t result);
14 | ifaa_key_extract(vec buf, uint32_t buf_len) generates (int32_t result);
15 | };
16 |
--------------------------------------------------------------------------------
/IFAAService/src/org/ifaa/aidl/manager/IfaaManagerService.aidl:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | package org.ifaa.aidl.manager;
8 |
9 | interface IfaaManagerService {
10 | int getSupportBIOTypes();
11 | int startBIOManager(int authType);
12 | String getDeviceModel();
13 | byte[] processCmd(inout byte[] param);
14 | int getVersion();
15 | String getExtInfo(int authType, String keyExtInfo);
16 | void setExtInfo(int authType, String keyExtInfo, String valExtInfo);
17 | int getEnabled(int bioType);
18 | int[] getIDList(int bioType);
19 | }
20 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/UdfpsExtension.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include
8 |
9 | #if __has_include()
10 | #include
11 | #elif __has_include()
12 | #include
13 | #endif
14 |
15 | uint32_t getUdfpsZOrder(uint32_t z, bool touched) {
16 | if (touched) {
17 | z |= FOD_PRESSED_LAYER_ZORDER;
18 | }
19 | return z;
20 | }
21 |
22 | uint64_t getUdfpsUsageBits(uint64_t usageBits, bool /* touched */) {
23 | return usageBits;
24 | }
25 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mtdservice/1.1/IMTService.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package vendor.xiaomi.hardware.mtdservice@1.1;
8 |
9 | import @1.0::IMTService;
10 |
11 | interface IMTService extends @1.0::IMTService {
12 | persist_read(int32_t dir_id, string file_name) generates (int32_t ret, vec rbuf);
13 | persist_write(int32_t dir_id, string file_name, vec sbuf, uint32_t sbuf_len) generates (int32_t ret);
14 | persist_remove(int32_t dir_id, string file_name) generates (int32_t ret);
15 | ifaa_key_dump() generates (string ret);
16 | };
17 |
--------------------------------------------------------------------------------
/aidl/light/LED.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 |
11 | namespace aidl {
12 | namespace android {
13 | namespace hardware {
14 | namespace light {
15 |
16 | class LED {
17 | public:
18 | LED(std::string type);
19 |
20 | bool exists();
21 | bool setBreath(uint8_t value);
22 | bool setBrightness(uint8_t value);
23 | private:
24 | std::string mBasePath;
25 | uint32_t mMaxBrightness;
26 | bool mBreath;
27 | };
28 |
29 | } // namespace light
30 | } // namespace hardware
31 | } // namespace android
32 | } // namespace aidl
33 |
--------------------------------------------------------------------------------
/aidl/Android.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2021 The LineageOS Project
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | include $(call all-subdir-makefiles)
18 |
--------------------------------------------------------------------------------
/Android.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2021 The LineageOS Project
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | ifeq ($(BOARD_VENDOR),xiaomi)
18 |
19 | include $(call all-subdir-makefiles)
20 |
21 | endif
22 |
--------------------------------------------------------------------------------
/aidl/light/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2021-2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | cc_binary {
8 | name: "android.hardware.light-service.xiaomi",
9 | overrides: ["android.hardware.lights-service.qti"],
10 | relative_install_path: "hw",
11 | init_rc: ["android.hardware.light-service.xiaomi.rc"],
12 | vintf_fragments: ["android.hardware.light-service.xiaomi.xml"],
13 | srcs: [
14 | "Backlight.cpp",
15 | "Lights.cpp",
16 | "LED.cpp",
17 | "Utils.cpp",
18 | "service.cpp",
19 | ],
20 | shared_libs: [
21 | "libbase",
22 | "libbinder_ndk",
23 | "android.hardware.light-V1-ndk",
24 | ],
25 | vendor: true,
26 | }
27 |
--------------------------------------------------------------------------------
/hidl/sensors/1.0/Android.bp:
--------------------------------------------------------------------------------
1 | package {
2 | // See: http://go/android-license-faq
3 | default_applicable_licenses: ["Android-Apache-2.0"],
4 | }
5 |
6 | cc_library_shared {
7 | name: "android.hardware.sensors@1.0-impl-xiaomi",
8 | defaults: ["hidl_defaults"],
9 | proprietary: true,
10 | relative_install_path: "hw",
11 | srcs: [
12 | "Sensors.cpp",
13 | "convert.cpp",
14 | ],
15 | shared_libs: [
16 | "liblog",
17 | "libcutils",
18 | "libhardware",
19 | "libbase",
20 | "libutils",
21 | "libhidlbase",
22 | "android.hardware.sensors@1.0",
23 | ],
24 | static_libs: [
25 | "multihal",
26 | ],
27 | local_include_dirs: ["include/sensors"],
28 | }
29 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/include/UdfpsHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 | #include "fingerprint.h"
11 |
12 | class UdfpsHandler {
13 | public:
14 | virtual ~UdfpsHandler() = default;
15 |
16 | virtual void init(fingerprint_device_t *device) = 0;
17 | virtual void onFingerDown(uint32_t x, uint32_t y, float minor, float major) = 0;
18 | virtual void onFingerUp() = 0;
19 |
20 | virtual void onAcquired(int32_t result, int32_t vendorCode) = 0;
21 | virtual void cancel() = 0;
22 | };
23 |
24 | struct UdfpsHandlerFactory {
25 | UdfpsHandler* (*create)();
26 | void (*destroy)(UdfpsHandler* handler);
27 | };
28 |
29 | UdfpsHandlerFactory *getUdfpsHandlerFactory();
30 |
--------------------------------------------------------------------------------
/hidl/touch/HighTouchPollingRate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 |
11 | namespace vendor {
12 | namespace lineage {
13 | namespace touch {
14 | namespace V1_0 {
15 | namespace implementation {
16 |
17 | using ::android::hardware::Return;
18 |
19 | class HighTouchPollingRate : public IHighTouchPollingRate {
20 | public:
21 | // Methods from ::vendor::lineage::touch::V1_0::IHighTouchPollingRate follow.
22 | Return isEnabled() override;
23 | Return setEnabled(bool enabled) override;
24 | };
25 |
26 | } // namespace implementation
27 | } // namespace V1_0
28 | } // namespace touch
29 | } // namespace lineage
30 | } // namespace vendor
31 |
--------------------------------------------------------------------------------
/IFAAService/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/motor/1.0/types.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.motor@1.0;
18 |
19 | struct MotorEvent {
20 | int32_t vaalue;
21 | int32_t cookie;
22 | };
23 |
--------------------------------------------------------------------------------
/megvii/megvii.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | static int stub_fail() {
8 | return -1;
9 | }
10 |
11 | static char *stub_fail_str() {
12 | return "stub";
13 | }
14 |
15 | void *mg_facepp[] = {
16 | &stub_fail,
17 | &stub_fail,
18 | &stub_fail,
19 | &stub_fail_str,
20 | &stub_fail_str,
21 | &stub_fail,
22 | &stub_fail,
23 | &stub_fail,
24 | &stub_fail,
25 | &stub_fail,
26 | &stub_fail,
27 | &stub_fail,
28 | &stub_fail,
29 | &stub_fail,
30 | &stub_fail,
31 | &stub_fail,
32 | &stub_fail,
33 | &stub_fail,
34 | &stub_fail,
35 | &stub_fail,
36 | &stub_fail,
37 | &stub_fail,
38 | &stub_fail,
39 | &stub_fail,
40 | &stub_fail,
41 | &stub_fail,
42 | &stub_fail,
43 | };
44 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/motor/1.0/IMotorCallback.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.motor@1.0;
18 |
19 | interface IMotorCallback {
20 | oneway onNotify(MotorEvent event);
21 | };
22 |
--------------------------------------------------------------------------------
/aidl/light/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "Lights.h"
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | using ::aidl::android::hardware::light::Lights;
14 |
15 | int main() {
16 | ABinderProcess_setThreadPoolMaxThreadCount(0);
17 | std::shared_ptr lights = ndk::SharedRefBase::make();
18 | if (!lights) {
19 | return EXIT_FAILURE;
20 | }
21 |
22 | const std::string instance = std::string() + Lights::descriptor + "/default";
23 | binder_status_t status = AServiceManager_addService(lights->asBinder().get(), instance.c_str());
24 | CHECK(status == STATUS_OK);
25 |
26 | ABinderProcess_joinThreadPool();
27 | return EXIT_FAILURE; // should not reach
28 | }
29 |
--------------------------------------------------------------------------------
/hidl/powershare/PowerShare.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 |
11 | namespace vendor {
12 | namespace lineage {
13 | namespace powershare {
14 | namespace V1_0 {
15 | namespace implementation {
16 |
17 | using ::android::sp;
18 | using ::android::hardware::Return;
19 | using ::android::hardware::Void;
20 |
21 | class PowerShare : public IPowerShare {
22 | public:
23 | Return isEnabled() override;
24 | Return setEnabled(bool enable) override;
25 | Return getMinBattery() override;
26 | Return setMinBattery(uint32_t minBattery) override;
27 | };
28 |
29 | } // namespace implementation
30 | } // namespace V1_0
31 | } // namespace powershare
32 | } // namespace lineage
33 | } // namespace vendor
34 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/fingerprintextension/1.0/IXiaomiFingerprint.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.fingerprintextension@1.0;
18 |
19 | interface IXiaomiFingerprint {
20 | extCmd(int32_t cmd, int32_t param) generates (int32_t result);
21 | };
22 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/UdfpsHandler.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "UdfpsHandler.h"
8 | #include
9 |
10 | #define UDFPS_HANDLER_LIB_NAME "libudfpshandler.so"
11 | #define UDFPS_HANDLER_FACTORY "UDFPS_HANDLER_FACTORY"
12 |
13 | UdfpsHandlerFactory* getUdfpsHandlerFactory() {
14 | void* libudfpshander;
15 | UdfpsHandlerFactory* factory_handler;
16 |
17 | libudfpshander = dlopen(UDFPS_HANDLER_LIB_NAME, RTLD_LAZY);
18 | if (!libudfpshander) {
19 | goto error;
20 | }
21 |
22 | factory_handler = (UdfpsHandlerFactory*)dlsym(libudfpshander, UDFPS_HANDLER_FACTORY);
23 | if (!factory_handler) {
24 | goto error;
25 | }
26 |
27 | return factory_handler;
28 |
29 | error:
30 | if (libudfpshander) {
31 | dlclose(libudfpshander);
32 | }
33 |
34 | return nullptr;
35 | }
36 |
--------------------------------------------------------------------------------
/hidl/touch/HighTouchPollingRate.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #define LOG_TAG "HighTouchPollingRateService"
8 |
9 | #include "HighTouchPollingRate.h"
10 |
11 | #include
12 |
13 | namespace vendor {
14 | namespace lineage {
15 | namespace touch {
16 | namespace V1_0 {
17 | namespace implementation {
18 |
19 | Return HighTouchPollingRate::isEnabled() {
20 | std::ifstream file(HIGH_TOUCH_POLLING_PATH);
21 | int enabled;
22 | file >> enabled;
23 |
24 | return enabled == 1;
25 | }
26 |
27 | Return HighTouchPollingRate::setEnabled(bool enabled) {
28 | std::ofstream file(HIGH_TOUCH_POLLING_PATH);
29 | file << (enabled ? "1" : "0");
30 | return !file.fail();
31 | }
32 |
33 | } // namespace implementation
34 | } // namespace V1_0
35 | } // namespace touch
36 | } // namespace lineage
37 | } // namespace vendor
38 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/displayfeature/1.0/IDisplayFeatureCallback.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.displayfeature@1.0;
18 |
19 | interface IDisplayFeatureCallback {
20 | oneway displayfeatureInfoChanged(uint32_t caseId, uint32_t value, float red, float green, float blue);
21 | };
22 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/displayfeature/1.0/types.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.displayfeature@1.0;
18 |
19 | // Based on observations using Ghidra, all methods that return Status
20 | // only set the result of __android_log_print and cast it to Status.
21 | enum Status : int32_t {};
22 |
--------------------------------------------------------------------------------
/interfaces/goodix/hardware/biometrics/fingerprint/2.1/IGoodixFingerprintDaemonCallback.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.goodix.hardware.biometrics.fingerprint@2.1;
18 |
19 | interface IGoodixFingerprintDaemonCallback {
20 | onDaemonMessage(int64_t devId, int32_t msgId, int32_t cmdId, vec msgData);
21 | };
22 |
--------------------------------------------------------------------------------
/aidl/light/Utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 |
11 | namespace aidl {
12 | namespace android {
13 | namespace hardware {
14 | namespace light {
15 |
16 | typedef struct rgb {
17 | rgb(uint8_t r, uint8_t g, uint8_t b) : red(r), green(g), blue(b) {};
18 | rgb(uint32_t color);
19 | rgb() : red(0), green(0), blue(0) {};
20 |
21 | uint8_t red;
22 | uint8_t green;
23 | uint8_t blue;
24 |
25 | bool isLit();
26 | uint8_t toBrightness();
27 | } rgb_t;
28 |
29 | bool fileWriteable(const std::string& file);
30 | bool readFromFile(const std::string& file, std::string *content);
31 | bool readFromFile(const std::string& file, uint32_t *content);
32 | bool writeToFile(const std::string& file, uint32_t content);
33 |
34 | } // namespace light
35 | } // namespace hardware
36 | } // namespace android
37 | } // namespace aidl
38 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hw/touchfeature/1.0/ITouchFeature.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package vendor.xiaomi.hw.touchfeature@1.0;
8 |
9 | interface ITouchFeature {
10 | getModeCurValue(int32_t touchId, int32_t ControlMode) generates (int32_t result);
11 | getModeDefaultValue(int32_t touchId, int32_t ControlMode) generates (int32_t result);
12 | getModeMaxValue(int32_t touchId, int32_t ControlMode) generates (int32_t result);
13 | getModeMinValue(int32_t touchId, int32_t ControlMode) generates (int32_t result);
14 | getModeValue(int32_t touchId, int32_t mode) generates (vec result);
15 | modeReset(int32_t touchId, int32_t ControlMode) generates (int32_t result);
16 | setModeLongValue(int32_t touchId, int32_t ControlMode, uint32_t ValueLen, vec ValueBuf) generates (int32_t result);
17 | setModeValue(int32_t touchId, int32_t ControlMode, int32_t ModeValue) generates (int32_t result);
18 | };
19 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mtdservice/1.0/IMTService.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package vendor.xiaomi.hardware.mtdservice@1.0;
8 |
9 | interface IMTService {
10 | getFid() generates (string fid);
11 | eccSign(uint32_t keyType, string text) generates (string signData);
12 | reload(string text, string sign) generates (int32_t result);
13 | enroll(string appname, int32_t enrollType) generates (string enrolldata);
14 | ifaa_key_get_version() generates (int32_t result);
15 | ifaa_key_prepare() generates (string ret);
16 | ifaa_key_load(string data_text, string sign_text) generates (int32_t result);
17 | fido_key_get_version() generates (int32_t result);
18 | fido_key_prepare() generates (string ret);
19 | fido_key_load(string data_text, string sign_text) generates (int32_t result);
20 | soter_generate() generates (string ret);
21 | soter_get_state() generates (int32_t result);
22 | soter_set_state(int32_t state);
23 | };
24 |
--------------------------------------------------------------------------------
/hidl/touch/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #define LOG_TAG "lineage.touch@1.0-service.xiaomi"
8 |
9 | #include
10 | #include
11 |
12 | #include "HighTouchPollingRate.h"
13 |
14 | using ::vendor::lineage::touch::V1_0::IHighTouchPollingRate;
15 | using ::vendor::lineage::touch::V1_0::implementation::HighTouchPollingRate;
16 |
17 | int main() {
18 | android::sp highTouchPollingRate = new HighTouchPollingRate();
19 |
20 | android::hardware::configureRpcThreadpool(1, true);
21 |
22 | if (highTouchPollingRate->registerAsService() != android::OK) {
23 | LOG(ERROR) << "Cannot register touchscreen high polling rate HAL service.";
24 | return 1;
25 | }
26 |
27 | LOG(INFO) << "Touchscreen HAL service ready.";
28 |
29 | android::hardware::joinRpcThreadpool();
30 |
31 | LOG(ERROR) << "Touchscreen HAL service failed to join thread pool.";
32 | return 1;
33 | }
34 |
--------------------------------------------------------------------------------
/aidl/light/LED.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "LED.h"
8 |
9 | #include "Utils.h"
10 |
11 | namespace aidl {
12 | namespace android {
13 | namespace hardware {
14 | namespace light {
15 |
16 | static const uint32_t kDefaultMaxLedBrightness = 255;
17 |
18 | LED::LED(std::string type) : mBasePath("/sys/class/leds/" + type + "/") {
19 | if (!readFromFile(mBasePath + "max_brightness", &mMaxBrightness))
20 | mMaxBrightness = kDefaultMaxLedBrightness;
21 | mBreath = fileWriteable(mBasePath + "breath");
22 | }
23 |
24 | bool LED::exists() {
25 | return fileWriteable(mBasePath + "brightness");
26 | }
27 |
28 | bool LED::setBreath(uint8_t value) {
29 | return writeToFile(mBasePath + (mBreath ? "breath" : "blink"), value);
30 | }
31 |
32 | bool LED::setBrightness(uint8_t value) {
33 | return writeToFile(mBasePath + "brightness", value * mMaxBrightness / 0xFF);
34 | }
35 |
36 | } // namespace light
37 | } // namespace hardware
38 | } // namespace android
39 | } // namespace aidl
40 |
--------------------------------------------------------------------------------
/interfaces/goodix/hardware/biometrics/fingerprint/2.1/IGoodixFingerprintDaemon.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.goodix.hardware.biometrics.fingerprint@2.1;
18 |
19 | import vendor.goodix.hardware.biometrics.fingerprint@2.1::IGoodixFingerprintDaemonCallback;
20 |
21 | interface IGoodixFingerprintDaemon {
22 | setNotify(IGoodixFingerprintDaemonCallback Callback);
23 | sendCommand(int32_t cmd, vec data) generates (int32_t resultCode, vec data);
24 | };
25 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/motor/1.0/IMotor.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.motor@1.0;
18 |
19 | import vendor.xiaomi.hardware.motor@1.0::IMotorCallback;
20 |
21 | interface IMotor {
22 | popupMotor(int32_t cookie);
23 | takebackMotor(int32_t cookie);
24 | setMotorCallback(IMotorCallback motorcallback);
25 | init();
26 | release();
27 | getMotorStatus() generates (int32_t result);
28 | calibration();
29 | takebackMotorShortly();
30 | };
31 |
--------------------------------------------------------------------------------
/hidl/powershare/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #define LOG_TAG "vendor.lineage.powershare@1.0-service.xiaomi"
8 |
9 | #include
10 | #include
11 |
12 | #include "PowerShare.h"
13 |
14 | using android::hardware::configureRpcThreadpool;
15 | using android::hardware::joinRpcThreadpool;
16 |
17 | using vendor::lineage::powershare::V1_0::IPowerShare;
18 | using vendor::lineage::powershare::V1_0::implementation::PowerShare;
19 |
20 | using android::OK;
21 | using android::status_t;
22 |
23 | int main() {
24 | android::sp service = new PowerShare();
25 |
26 | configureRpcThreadpool(1, true);
27 |
28 | status_t status = service->registerAsService();
29 | if (status != OK) {
30 | LOG(ERROR) << "Cannot register PowerShare HAL service.";
31 | return 1;
32 | }
33 |
34 | LOG(INFO) << "PowerShare HAL service ready.";
35 |
36 | joinRpcThreadpool();
37 |
38 | LOG(ERROR) << "PowerShare HAL service failed to join thread pool.";
39 | return 1;
40 | }
41 |
--------------------------------------------------------------------------------
/aidl/light/Lights.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 | #include
11 | #include "Backlight.h"
12 |
13 | using ::aidl::android::hardware::light::HwLightState;
14 | using ::aidl::android::hardware::light::HwLight;
15 |
16 | namespace aidl {
17 | namespace android {
18 | namespace hardware {
19 | namespace light {
20 |
21 | class Lights : public BnLights {
22 | public:
23 | Lights();
24 |
25 | ndk::ScopedAStatus setLightState(int32_t id, const HwLightState& state) override;
26 | ndk::ScopedAStatus getLights(std::vector *_aidl_return) override;
27 | private:
28 | void setLED(const HwLightState& state);
29 |
30 | std::vector mLights;
31 |
32 | BacklightDevice *mBacklightDevice;
33 | std::vector mButtonsPaths;
34 | bool mWhiteLED;
35 |
36 | std::mutex mLEDMutex;
37 | HwLightState mLastBatteryState;
38 | HwLightState mLastNotificationState;
39 | };
40 |
41 | } // namespace light
42 | } // namespace hardware
43 | } // namespace android
44 | } // namespace aidl
45 |
--------------------------------------------------------------------------------
/hidl/consumerir/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2017-2018,2020 The LineageOS Project
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | cc_binary {
17 | name: "android.hardware.ir@1.0-service.xiaomi",
18 | relative_install_path: "hw",
19 | defaults: ["hidl_defaults"],
20 | init_rc: ["android.hardware.ir@1.0-service.xiaomi.rc"],
21 | vintf_fragments: ["android.hardware.ir@1.0-service.xiaomi.xml"],
22 | srcs: ["service.cpp", "ConsumerIr.cpp"],
23 | shared_libs: [
24 | "android.hardware.ir@1.0",
25 | "libbase",
26 | "libhardware",
27 | "libhidlbase",
28 | "libutils",
29 | ],
30 | proprietary: true,
31 | }
32 |
--------------------------------------------------------------------------------
/hidl/touch/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | soong_config_module_type {
8 | name: "xiaomi_touch_hal_cc_defaults",
9 | module_type: "cc_defaults",
10 | config_namespace: "XIAOMI_TOUCH",
11 | value_variables: ["HIGH_TOUCH_POLLING_PATH"],
12 | properties: ["cppflags"],
13 | }
14 |
15 | xiaomi_touch_hal_cc_defaults {
16 | name: "xiaomi_touch_hal_defaults",
17 | soong_config_variables: {
18 | HIGH_TOUCH_POLLING_PATH: {
19 | cppflags: ["-DHIGH_TOUCH_POLLING_PATH=\"%s\""],
20 | },
21 | },
22 | }
23 |
24 | cc_binary {
25 | name: "vendor.lineage.touch@1.0-service.xiaomi",
26 | vintf_fragments: ["vendor.lineage.touch@1.0-service.xiaomi.xml"],
27 | init_rc: ["vendor.lineage.touch@1.0-service.xiaomi.rc"],
28 | defaults: [
29 | "hidl_defaults",
30 | "xiaomi_touch_hal_defaults",
31 | ],
32 | relative_install_path: "hw",
33 | proprietary: true,
34 | srcs: [
35 | "HighTouchPollingRate.cpp",
36 | "service.cpp",
37 | ],
38 | shared_libs: [
39 | "libbase",
40 | "libbinder",
41 | "libhidlbase",
42 | "libutils",
43 | "vendor.lineage.touch@1.0",
44 | ],
45 | }
46 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/touchfeature/1.0/ITouchFeature.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.touchfeature@1.0;
18 |
19 | interface ITouchFeature {
20 | setTouchMode(int32_t mode, int32_t value) generates (int32_t result);
21 | getTouchModeCurValue(int32_t mode) generates (int32_t result);
22 | getTouchModeMaxValue(int32_t mode) generates (int32_t result);
23 | getTouchModeMinValue(int32_t mode) generates (int32_t result);
24 | getTouchModeDefValue(int32_t mode) generates (int32_t result);
25 | resetTouchMode(int32_t mode) generates (int32_t result);
26 | getModeValues(int32_t mode) generates (vec result);
27 | };
28 |
--------------------------------------------------------------------------------
/hidl/powershare/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2020 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | soong_config_module_type {
8 | name: "xiaomi_powershare_hal_cc_defaults",
9 | module_type: "cc_defaults",
10 | config_namespace: "XIAOMI_POWERSHARE",
11 | value_variables: ["WIRELESS_TX_ENABLE_PATH"],
12 | properties: ["cppflags"],
13 | }
14 |
15 | xiaomi_powershare_hal_cc_defaults {
16 | name: "xiaomi_powershare_hal_defaults",
17 | soong_config_variables: {
18 | WIRELESS_TX_ENABLE_PATH: {
19 | cppflags: ["-DWIRELESS_TX_ENABLE_PATH=\"%s\""],
20 | },
21 | },
22 | }
23 |
24 | cc_binary {
25 | name: "vendor.lineage.powershare@1.0-service.xiaomi",
26 | defaults: [
27 | "hidl_defaults",
28 | "xiaomi_powershare_hal_defaults",
29 | ],
30 | relative_install_path: "hw",
31 | init_rc: ["vendor.lineage.powershare@1.0-service.xiaomi.rc"],
32 | vintf_fragments: ["vendor.lineage.powershare@1.0-service.xiaomi.xml"],
33 | srcs: [
34 | "service.cpp",
35 | "PowerShare.cpp",
36 | ],
37 | shared_libs: [
38 | "libbase",
39 | "libhardware",
40 | "libhidlbase",
41 | "liblog",
42 | "libutils",
43 | "vendor.lineage.powershare@1.0",
44 | ],
45 | proprietary: true,
46 | }
47 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | * 2022 The LineageOS Project
4 | *
5 | * SPDX-License-Identifier: Apache-2.0
6 | */
7 |
8 | #define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.xiaomi"
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include "BiometricsFingerprint.h"
16 |
17 | using android::sp;
18 | using android::hardware::configureRpcThreadpool;
19 | using android::hardware::joinRpcThreadpool;
20 | using android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
21 | using android::hardware::biometrics::fingerprint::V2_3::implementation::BiometricsFingerprint;
22 |
23 | int main() {
24 | android::sp bio = BiometricsFingerprint::getInstance();
25 |
26 | configureRpcThreadpool(1, true /*callerWillJoin*/);
27 |
28 | if (bio != nullptr) {
29 | if (::android::OK != bio->registerAsService()) {
30 | return 1;
31 | }
32 | } else {
33 | ALOGE("Can't create instance of BiometricsFingerprint, nullptr");
34 | }
35 |
36 | joinRpcThreadpool();
37 |
38 | return 0; // should never get here
39 | }
40 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/android.hardware.power-service.xiaomi-libperfmgr.rc:
--------------------------------------------------------------------------------
1 | service vendor.power-hal-aidl /vendor/bin/hw/android.hardware.power-service.xiaomi-libperfmgr
2 | class hal
3 | user root
4 | group system
5 | priority -20
6 |
7 | on late-fs
8 | start vendor.power-hal-aidl
9 |
10 | # Restart powerHAL when framework died
11 | on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
12 | setprop vendor.powerhal.state ""
13 | setprop vendor.powerhal.audio ""
14 | setprop vendor.powerhal.rendering ""
15 | restart vendor.power-hal-aidl
16 |
17 | # Clean up after b/163539793 resolved
18 | on property:vendor.powerhal.dalvik.vm.dex2oat-threads=*
19 | setprop dalvik.vm.dex2oat-threads ${vendor.powerhal.dalvik.vm.dex2oat-threads}
20 | setprop dalvik.vm.restore-dex2oat-threads ${vendor.powerhal.dalvik.vm.dex2oat-threads}
21 |
22 | on property:vendor.powerhal.dalvik.vm.dex2oat-cpu-set=*
23 | setprop dalvik.vm.dex2oat-cpu-set ${vendor.powerhal.dalvik.vm.dex2oat-cpu-set}
24 | setprop dalvik.vm.restore-dex2oat-cpu-set ${vendor.powerhal.dalvik.vm.dex2oat-cpu-set}
25 |
26 | # Restart powerHAL when debug property set
27 | on property:ro.debuggable=1 && property:vendor.powerhal.config.debug=*
28 | restart vendor.power-hal-aidl
29 |
30 | on property:persist.vendor.powerhal.config.debug=*
31 | setprop vendor.powerhal.config.debug ${persist.vendor.powerhal.config.debug}
32 |
33 |
--------------------------------------------------------------------------------
/hidl/powershare/PowerShare.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #define LOG_TAG "PowerShareService"
8 |
9 | #include "PowerShare.h"
10 | #include
11 | #include
12 |
13 | namespace vendor {
14 | namespace lineage {
15 | namespace powershare {
16 | namespace V1_0 {
17 | namespace implementation {
18 |
19 | /*
20 | * Write value to path and close file.
21 | */
22 | template
23 | static void set(const std::string& path, const T& value) {
24 | std::ofstream file(path);
25 | file << value;
26 | }
27 |
28 | template
29 | static T get(const std::string& path, const T& def) {
30 | std::ifstream file(path);
31 | T result;
32 |
33 | file >> result;
34 | return file.fail() ? def : result;
35 | }
36 |
37 | Return PowerShare::isEnabled() {
38 | const auto value = get(WIRELESS_TX_ENABLE_PATH, "0");
39 | return !(value == "disable" || value == "0");
40 | }
41 |
42 | Return PowerShare::setEnabled(bool enable) {
43 | set(WIRELESS_TX_ENABLE_PATH, enable ? 1 : 0);
44 |
45 | return isEnabled();
46 | }
47 |
48 | Return PowerShare::getMinBattery() {
49 | return 0;
50 | }
51 |
52 | Return PowerShare::setMinBattery(uint32_t) {
53 | return getMinBattery();
54 | }
55 |
56 | } // namespace implementation
57 | } // namespace V1_0
58 | } // namespace powershare
59 | } // namespace lineage
60 | } // namespace vendor
61 |
--------------------------------------------------------------------------------
/hidl/sensors/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include "HalProxy.h"
22 |
23 | using android::hardware::configureRpcThreadpool;
24 | using android::hardware::joinRpcThreadpool;
25 | using android::hardware::sensors::V2_1::ISensors;
26 | using android::hardware::sensors::V2_1::implementation::HalProxyV2_1;
27 |
28 | int main(int /* argc */, char** /* argv */) {
29 | configureRpcThreadpool(1, true);
30 |
31 | android::sp halProxy = new HalProxyV2_1();
32 | if (halProxy->registerAsService() != ::android::OK) {
33 | ALOGE("Failed to register Sensors HAL instance");
34 | return -1;
35 | }
36 |
37 | joinRpcThreadpool();
38 | return 1; // joinRpcThreadpool shouldn't exit
39 | }
40 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/displayfeature/1.0/IDisplayFeature.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2022 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package vendor.xiaomi.hardware.displayfeature@1.0;
18 |
19 | import @1.0::IDisplayFeatureCallback;
20 |
21 | interface IDisplayFeature {
22 | notifyBrightness(uint32_t brightness);
23 | registerCallback(uint32_t displayId, IDisplayFeatureCallback callback) generates (Status status);
24 | sendMessage(uint32_t index, uint32_t value, string cmd);
25 | sendPanelCommand(string cmd) generates (Status status);
26 | sendPostProcCommand(uint32_t cmd, uint32_t value) generates (Status status);
27 | sendRefreshCommand() generates (Status status);
28 | setFeature(uint32_t displayId, uint32_t caseId, uint32_t modeId, uint32_t cookie) generates (Status status);
29 | setFunction(uint32_t displayId, uint32_t caseId, uint32_t modeId, uint32_t cookie) generates (Status status);
30 | };
31 |
--------------------------------------------------------------------------------
/hidl/sensors/1.0/include/sensors/convert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 |
22 | namespace android {
23 | namespace hardware {
24 | namespace sensors {
25 | namespace V1_0 {
26 | namespace implementation {
27 |
28 | void convertFromSensor(const sensor_t& src, SensorInfo* dst);
29 | void convertToSensor(const SensorInfo& src, sensor_t* dst);
30 |
31 | void convertFromSensorEvent(const sensors_event_t& src, Event* dst);
32 | void convertToSensorEvent(const Event& src, sensors_event_t* dst);
33 |
34 | bool convertFromSharedMemInfo(const SharedMemInfo& memIn, sensors_direct_mem_t* memOut);
35 | int convertFromRateLevel(RateLevel rate);
36 |
37 | bool patchXiaomiPickupSensor(SensorInfo& sensor);
38 |
39 | } // namespace implementation
40 | } // namespace V1_0
41 | } // namespace sensors
42 | } // namespace hardware
43 | } // namespace android
44 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2017 The Android Open Source Project
3 | // 2022 The LineageOS Project
4 | //
5 | // SPDX-License-Identifier: Apache-2.0
6 | //
7 |
8 | cc_binary {
9 | name: "android.hardware.biometrics.fingerprint@2.3-service.xiaomi",
10 | defaults: ["hidl_defaults"],
11 | init_rc: ["android.hardware.biometrics.fingerprint@2.3-service.xiaomi.rc"],
12 | vintf_fragments: ["android.hardware.biometrics.fingerprint@2.3-service.xiaomi.xml"],
13 | vendor: true,
14 | relative_install_path: "hw",
15 | srcs: [
16 | "BiometricsFingerprint.cpp",
17 | "UdfpsHandler.cpp",
18 | "service.cpp",
19 | ],
20 |
21 | shared_libs: [
22 | "libbase",
23 | "libcutils",
24 | "libdl",
25 | "liblog",
26 | "libhidlbase",
27 | "libhardware",
28 | "libutils",
29 | "android.hardware.biometrics.fingerprint@2.1",
30 | "android.hardware.biometrics.fingerprint@2.2",
31 | "android.hardware.biometrics.fingerprint@2.3",
32 | ],
33 |
34 | header_libs: ["xiaomifingerprint_headers"],
35 | }
36 |
37 | cc_library_headers {
38 | name: "xiaomifingerprint_headers",
39 | export_include_dirs: ["include"],
40 | vendor: true,
41 | header_libs: ["libhardware_headers"],
42 | export_header_lib_headers: ["libhardware_headers"],
43 | }
44 |
45 | cc_library_static {
46 | name: "libudfps_extension.xiaomi",
47 | srcs: ["UdfpsExtension.cpp"],
48 | include_dirs: [
49 | "frameworks/native/services/surfaceflinger/CompositionEngine/include"
50 | ],
51 | header_libs: [
52 | "generated_kernel_headers",
53 | ],
54 | }
55 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/PowerExt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | namespace aidl {
27 | namespace google {
28 | namespace hardware {
29 | namespace power {
30 | namespace impl {
31 | namespace pixel {
32 |
33 | class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
34 | public:
35 | PowerExt() {}
36 | ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
37 | ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
38 | ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
39 | ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
40 |
41 | private:
42 | };
43 |
44 | } // namespace pixel
45 | } // namespace impl
46 | } // namespace power
47 | } // namespace hardware
48 | } // namespace google
49 | } // namespace aidl
50 |
--------------------------------------------------------------------------------
/hidl/consumerir/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017-2018 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #define LOG_TAG "android.hardware.ir@1.0-service.xiaomi"
18 |
19 | #include
20 | #include
21 |
22 | #include "ConsumerIr.h"
23 |
24 | // libhwbinder:
25 | using android::hardware::configureRpcThreadpool;
26 | using android::hardware::joinRpcThreadpool;
27 |
28 | // Generated HIDL files
29 | using android::hardware::ir::V1_0::IConsumerIr;
30 | using android::hardware::ir::V1_0::implementation::ConsumerIr;
31 |
32 | int main() {
33 | android::sp service = new ConsumerIr();
34 |
35 | configureRpcThreadpool(1, true /*callerWillJoin*/);
36 |
37 | android::status_t status = service->registerAsService();
38 | if (status != android::OK) {
39 | LOG(ERROR) << "Cannot register ConsumerIr HAL service";
40 | return 1;
41 | }
42 |
43 | LOG(INFO) << "ConsumerIr HAL Ready.";
44 | joinRpcThreadpool();
45 | // Under normal cases, execution will not reach this line.
46 | LOG(ERROR) << "ConsumerIr HAL failed to join thread pool.";
47 | return 1;
48 | }
49 |
--------------------------------------------------------------------------------
/hidl/sensors/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2020 The Android Open Source Project
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | cc_binary {
17 | name: "android.hardware.sensors@2.1-service.xiaomi-multihal",
18 | defaults: [
19 | "hidl_defaults",
20 | ],
21 | vendor: true,
22 | relative_install_path: "hw",
23 | srcs: [
24 | "service.cpp",
25 | "HalProxy.cpp",
26 | "HalProxyCallback.cpp",
27 | ],
28 | init_rc: ["android.hardware.sensors@2.1-service.xiaomi-multihal.rc"],
29 | vintf_fragments: ["android.hardware.sensors@2.1.xiaomi-multihal.xml"],
30 | header_libs: [
31 | "android.hardware.sensors@2.X-shared-utils",
32 | ],
33 | shared_libs: [
34 | "android.hardware.sensors@2.0",
35 | "android.hardware.sensors@2.0-ScopedWakelock",
36 | "android.hardware.sensors@2.1",
37 | "libbase",
38 | "libcutils",
39 | "libfmq",
40 | "libhidlbase",
41 | "liblog",
42 | "libpower",
43 | "libutils",
44 | ],
45 | static_libs: [
46 | "android.hardware.sensors@1.0-convert",
47 | "android.hardware.sensors@2.X-multihal",
48 | ],
49 | }
50 |
--------------------------------------------------------------------------------
/hidl/consumerir/ConsumerIr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017-2018 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef ANDROID_HARDWARE_IR_V1_0_IR_H
18 | #define ANDROID_HARDWARE_IR_V1_0_IR_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace android {
25 | namespace hardware {
26 | namespace ir {
27 | namespace V1_0 {
28 | namespace implementation {
29 |
30 | using ::android::hardware::Return;
31 | using ::android::hardware::Void;
32 | using ::android::hardware::hidl_vec;
33 | using ::android::hardware::ir::V1_0::ConsumerIrFreqRange;
34 | using ::android::hardware::ir::V1_0::IConsumerIr;
35 |
36 | class ConsumerIr : public IConsumerIr {
37 | // Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
38 | Return transmit(int32_t carrierFreq, const hidl_vec& pattern) override;
39 | Return getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) override;
40 | };
41 |
42 | } // namespace implementation
43 | } // namespace V1_0
44 | } // namespace ir
45 | } // namespace hardware
46 | } // namespace android
47 |
48 | #endif // ANDROID_HARDWARE_IR_V1_0_IR_H
49 |
--------------------------------------------------------------------------------
/interfaces/xiaomi/hardware/mtdservice/1.2/IMTService.hal:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package vendor.xiaomi.hardware.mtdservice@1.2;
8 |
9 | import @1.1::IMTService;
10 |
11 | interface IMTService extends @1.1::IMTService {
12 | widevine_get_version() generates (int32_t ret);
13 | widevine_prepare() generates (string ret);
14 | widevine_load(string data_text, string sign_text) generates (int32_t ret);
15 | widevine_dump() generates (string ret);
16 | runExternalCmd(int32_t taType, vec ta, uint32_t cmdId, vec data) generates (int32_t ret, vec rsp);
17 | installTa(int32_t taType, vec ta, vec ta_buf) generates (int32_t ret);
18 | unInstallTa(int32_t taType, vec ta) generates (int32_t ret);
19 | loadTa(int32_t taType, vec ta) generates (int32_t ret);
20 | runTaCmd(int32_t taType, vec ta, vec data) generates (int32_t ret, vec rsp);
21 | unloadTa(int32_t taType, vec ta) generates (int32_t ret);
22 | checkPermission(vec packageName, vec signature) generates (bool ret);
23 | updateWhitelist(int32_t operation, vec whitelist) generates (int32_t ret);
24 | getWhitelistVersion() generates (int32_t ret);
25 | enrollV2(int32_t taType, vec ta, vec data) generates (int32_t ret, vec rsp);
26 | external_key_version(int32_t key_type) generates (int32_t ret);
27 | external_key_prepare(int32_t key_type) generates (string ret);
28 | external_key_load(int32_t key_type, string data_text, string sign_text) generates (int32_t ret);
29 | external_key_dump(int32_t key_type) generates (string ret);
30 | };
31 |
--------------------------------------------------------------------------------
/aidl/light/android.hardware.light-service.xiaomi.rc:
--------------------------------------------------------------------------------
1 | on early-boot
2 | # Notification LEDs
3 | chown system system /sys/class/leds/red/blink
4 | chown system system /sys/class/leds/red/breath
5 | chown system system /sys/class/leds/red/brightness
6 | chown system system /sys/class/leds/red/max_brightness
7 |
8 | chown system system /sys/class/leds/green/blink
9 | chown system system /sys/class/leds/green/breath
10 | chown system system /sys/class/leds/green/brightness
11 | chown system system /sys/class/leds/green/max_brightness
12 |
13 | chown system system /sys/class/leds/blue/blink
14 | chown system system /sys/class/leds/blue/breath
15 | chown system system /sys/class/leds/blue/brightness
16 | chown system system /sys/class/leds/blue/max_brightness
17 |
18 | chown system system /sys/class/leds/white/blink
19 | chown system system /sys/class/leds/white/breath
20 | chown system system /sys/class/leds/white/brightness
21 | chown system system /sys/class/leds/white/max_brightness
22 |
23 | # Backlight
24 | chown system system /sys/class/backlight/backlight/brightness
25 | chown system system /sys/class/backlight/backlight/max_brightness
26 |
27 | chown system system /sys/class/backlight/panel0-backlight/brightness
28 | chown system system /sys/class/backlight/panel0-backlight/max_brightness
29 |
30 | chown system system /sys/class/leds/lcd-backlight/brightness
31 | chown system system /sys/class/leds/lcd-backlight/max_brightness
32 |
33 | # Buttons
34 | chown system system /sys/class/leds/button-backlight/brightness
35 | chown system system /sys/class/leds/button-backlight1/brightness
36 |
37 | service vendor.light-default /vendor/bin/hw/android.hardware.light-service.xiaomi
38 | class hal
39 | user system
40 | group system
41 | shutdown critical
42 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/InteractionHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace aidl {
26 | namespace google {
27 | namespace hardware {
28 | namespace power {
29 | namespace impl {
30 | namespace pixel {
31 |
32 | enum InteractionState {
33 | INTERACTION_STATE_UNINITIALIZED,
34 | INTERACTION_STATE_IDLE,
35 | INTERACTION_STATE_INTERACTION,
36 | INTERACTION_STATE_WAITING,
37 | };
38 |
39 | class InteractionHandler {
40 | public:
41 | InteractionHandler();
42 | ~InteractionHandler();
43 | bool Init();
44 | void Exit();
45 | void Acquire(int32_t duration);
46 |
47 | private:
48 | void Release();
49 | void WaitForIdle(int32_t wait_ms, int32_t timeout_ms);
50 | void AbortWaitLocked();
51 | void Routine();
52 |
53 | void PerfLock();
54 | void PerfRel();
55 |
56 | enum InteractionState mState;
57 | int mIdleFd;
58 | int mEventFd;
59 | int32_t mDurationMs;
60 | struct timespec mLastTimespec;
61 | std::unique_ptr mThread;
62 | std::mutex mLock;
63 | std::condition_variable mCond;
64 | };
65 |
66 | } // namespace pixel
67 | } // namespace impl
68 | } // namespace power
69 | } // namespace hardware
70 | } // namespace google
71 | } // namespace aidl
72 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/Android.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2021 The LineageOS Project
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | ifneq (,$(findstring hardware/google/interfaces, $(PRODUCT_SOONG_NAMESPACES)))
18 | ifneq (,$(findstring hardware/google/pixel, $(PRODUCT_SOONG_NAMESPACES)))
19 |
20 | LOCAL_PATH := $(call my-dir)
21 |
22 | include $(CLEAR_VARS)
23 |
24 | LOCAL_MODULE_RELATIVE_PATH := hw
25 |
26 | LOCAL_SHARED_LIBRARIES := \
27 | android.hardware.power-V2-ndk \
28 | libbase \
29 | libbinder_ndk \
30 | libcutils \
31 | libdl \
32 | liblog \
33 | libperfmgr \
34 | libprocessgroup \
35 | libutils \
36 | pixel-power-ext-V1-ndk
37 |
38 | LOCAL_SRC_FILES := \
39 | service.cpp \
40 | InteractionHandler.cpp \
41 | Power.cpp \
42 | PowerExt.cpp \
43 | PowerHintSession.cpp \
44 | PowerSessionManager.cpp
45 |
46 | LOCAL_CFLAGS := -Wno-unused-parameter -Wno-unused-variable
47 |
48 | ifneq ($(TARGET_POWERHAL_MODE_EXT),)
49 | LOCAL_CFLAGS += -DMODE_EXT
50 | LOCAL_SRC_FILES += ../../../../$(TARGET_POWERHAL_MODE_EXT)
51 | endif
52 |
53 | ifneq ($(TARGET_TAP_TO_WAKE_NODE),)
54 | LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\"
55 | endif
56 |
57 | LOCAL_MODULE := android.hardware.power-service.xiaomi-libperfmgr
58 | LOCAL_INIT_RC := android.hardware.power-service.xiaomi-libperfmgr.rc
59 | LOCAL_MODULE_TAGS := optional
60 | LOCAL_VENDOR_MODULE := true
61 | LOCAL_VINTF_FRAGMENTS := android.hardware.power-service.xiaomi.xml
62 |
63 | include $(BUILD_EXECUTABLE)
64 |
65 | endif
66 | endif
67 |
--------------------------------------------------------------------------------
/aidl/light/Utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "Utils.h"
8 |
9 | #define LOG_TAG "android.hardware.light-service.xiaomi"
10 |
11 | #include
12 | #include
13 | #include
14 |
15 | using ::android::base::ReadFileToString;
16 | using ::android::base::WriteStringToFile;
17 |
18 | namespace aidl {
19 | namespace android {
20 | namespace hardware {
21 | namespace light {
22 |
23 | bool fileWriteable(const std::string& file) {
24 | return !access(file.c_str(), W_OK);
25 | }
26 |
27 | bool readFromFile(const std::string& file, std::string *content) {
28 | return ReadFileToString(file, content, true);
29 | }
30 |
31 | bool readFromFile(const std::string& file, uint32_t *content) {
32 | std::string content_str;
33 | if (readFromFile(file, &content_str))
34 | *content = std::stoi(content_str);
35 | else
36 | return false;
37 | return true;
38 | }
39 |
40 | bool writeToFile(const std::string& file, std::string content) {
41 | return WriteStringToFile(content, file);
42 | }
43 |
44 | bool writeToFile(const std::string& file, uint32_t content) {
45 | return writeToFile(file, std::to_string(content));
46 | }
47 |
48 | rgb::rgb(uint32_t color) {
49 | // Extract brightness from AARRGGBB.
50 | uint8_t alpha = (color >> 24) & 0xFF;
51 |
52 | // Retrieve each of the RGB colors
53 | red = (color >> 16) & 0xFF;
54 | green = (color >> 8) & 0xFF;
55 | blue = color & 0xFF;
56 |
57 | // Scale RGB colors if a brightness has been applied by the user
58 | if (alpha > 0 && alpha < 255) {
59 | red = red * alpha / 0xFF;
60 | green = green * alpha / 0xFF;
61 | blue = blue * alpha / 0xFF;
62 | }
63 | }
64 |
65 | bool rgb::isLit() {
66 | return !!red || !!green || !!blue;
67 | }
68 |
69 | uint8_t rgb::toBrightness() {
70 | return (77 * red + 150 * green + 29 * blue) >> 8;
71 | }
72 |
73 | } // namespace light
74 | } // namespace hardware
75 | } // namespace android
76 | } // namespace aidl
77 |
--------------------------------------------------------------------------------
/aidl/light/Backlight.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "Backlight.h"
8 |
9 | #include "LED.h"
10 |
11 | namespace aidl {
12 | namespace android {
13 | namespace hardware {
14 | namespace light {
15 |
16 | class BacklightBrightness : public BacklightDevice {
17 | public:
18 | BacklightBrightness(std::string name) : mBasePath(mkBacklightBasePath + name + "/") {
19 | if (!readFromFile(mBasePath + "max_brightness", &mMaxBrightness)) {
20 | mMaxBrightness = kDefaultMaxBrightness;
21 | }
22 | };
23 |
24 | void setBacklight(uint8_t value) {
25 | writeToFile(mBasePath + "brightness", value * mMaxBrightness / 0xFF);
26 | }
27 |
28 | bool exists() {
29 | return fileWriteable(mBasePath + "brightness");
30 | }
31 | private:
32 | std::string mBasePath;
33 | uint32_t mMaxBrightness;
34 |
35 | inline static const std::string mkBacklightBasePath = "/sys/class/backlight/";
36 | inline static const uint32_t kDefaultMaxBrightness = 255;
37 | };
38 |
39 | class LEDBacklight : public BacklightDevice {
40 | public:
41 | LEDBacklight(std::string type) : mLED(type) {};
42 |
43 | void setBacklight(uint8_t value) {
44 | mLED.setBrightness(value);
45 | }
46 |
47 | bool exists() {
48 | return mLED.exists();
49 | }
50 | private:
51 | LED mLED;
52 | };
53 |
54 | static const std::string kBacklightDevices[] = {
55 | "backlight",
56 | "panel0-backlight",
57 | };
58 |
59 | static const std::string kLedDevices[] = {
60 | "lcd-backlight",
61 | };
62 |
63 | BacklightDevice *getBacklightDevice() {
64 | for (auto &device : kBacklightDevices) {
65 | auto backlight = new BacklightBrightness(device);
66 | if (backlight->exists()) {
67 | return backlight;
68 | }
69 | delete backlight;
70 | }
71 |
72 | for (auto& device : kLedDevices) {
73 | auto backlight = new LEDBacklight(device);
74 | if (backlight->exists()) {
75 | return backlight;
76 | }
77 | delete backlight;
78 | }
79 |
80 | return nullptr;
81 | }
82 |
83 | } // namespace light
84 | } // namespace hardware
85 | } // namespace android
86 | } // namespace aidl
87 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/Power.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #include "InteractionHandler.h"
26 |
27 | namespace aidl {
28 | namespace google {
29 | namespace hardware {
30 | namespace power {
31 | namespace impl {
32 | namespace pixel {
33 |
34 | using ::aidl::android::hardware::power::Boost;
35 | using ::aidl::android::hardware::power::IPowerHintSession;
36 | using ::aidl::android::hardware::power::Mode;
37 |
38 | class Power : public ::aidl::android::hardware::power::BnPower {
39 | public:
40 | Power();
41 | ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
42 | ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
43 | ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
44 | ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override;
45 | ndk::ScopedAStatus createHintSession(int32_t tgid, int32_t uid,
46 | const std::vector &threadIds,
47 | int64_t durationNanos,
48 | std::shared_ptr *_aidl_return) override;
49 | ndk::ScopedAStatus getHintSessionPreferredRate(int64_t *outNanoseconds) override;
50 | binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
51 |
52 | private:
53 | std::unique_ptr mInteractionHandler;
54 | std::atomic mSustainedPerfModeOn;
55 | };
56 |
57 | } // namespace pixel
58 | } // namespace impl
59 | } // namespace power
60 | } // namespace hardware
61 | } // namespace google
62 | } // namespace aidl
63 |
--------------------------------------------------------------------------------
/hidl/sensors/1.0/Sensors.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace android {
26 | namespace hardware {
27 | namespace sensors {
28 | namespace V1_0 {
29 | namespace implementation {
30 |
31 | struct Sensors : public ::android::hardware::sensors::V1_0::ISensors {
32 | Sensors();
33 |
34 | status_t initCheck() const;
35 |
36 | Return getSensorsList(getSensorsList_cb _hidl_cb) override;
37 |
38 | Return setOperationMode(OperationMode mode) override;
39 |
40 | Return activate(int32_t sensor_handle, bool enabled) override;
41 |
42 | Return poll(int32_t maxCount, poll_cb _hidl_cb) override;
43 |
44 | Return batch(int32_t sensor_handle, int64_t sampling_period_ns,
45 | int64_t max_report_latency_ns) override;
46 |
47 | Return flush(int32_t sensor_handle) override;
48 |
49 | Return injectSensorData(const Event& event) override;
50 |
51 | Return registerDirectChannel(const SharedMemInfo& mem,
52 | registerDirectChannel_cb _hidl_cb) override;
53 |
54 | Return unregisterDirectChannel(int32_t channelHandle) override;
55 |
56 | Return configDirectReport(int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
57 | configDirectReport_cb _hidl_cb) override;
58 |
59 | private:
60 | static constexpr int32_t kPollMaxBufferSize = 128;
61 | status_t mInitCheck;
62 | sensors_module_t* mSensorModule;
63 | sensors_poll_device_1_t* mSensorDevice;
64 | std::mutex mPollLock;
65 |
66 | int getHalDeviceVersion() const;
67 | std::vector getFixedUpSensorList();
68 |
69 | static void convertFromSensorEvents(size_t count, const sensors_event_t* src,
70 | std::vector& dst,
71 | std::vector sensorsList);
72 |
73 | DISALLOW_COPY_AND_ASSIGN(Sensors);
74 | };
75 |
76 | extern "C" ISensors* HIDL_FETCH_ISensors(const char* name);
77 |
78 | } // namespace implementation
79 | } // namespace V1_0
80 | } // namespace sensors
81 | } // namespace hardware
82 | } // namespace android
83 |
--------------------------------------------------------------------------------
/hidl/consumerir/ConsumerIr.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017-2018 The LineageOS Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #define LOG_TAG "ConsumerIrService"
18 |
19 | #include
20 | #include
21 |
22 | #include
23 |
24 | #include "ConsumerIr.h"
25 |
26 | namespace android {
27 | namespace hardware {
28 | namespace ir {
29 | namespace V1_0 {
30 | namespace implementation {
31 |
32 | #define LIRC_DEV_PATH "/dev/lirc0"
33 |
34 | static const int dutyCycle = 33;
35 |
36 | static hidl_vec rangeVec{
37 | {.min = 30000, .max = 60000},
38 | };
39 |
40 | static int openLircDev() {
41 | int fd = open(LIRC_DEV_PATH, O_RDWR);
42 |
43 | if (fd < 0) {
44 | LOG(ERROR) << "failed to open " << LIRC_DEV_PATH << ", error " << fd;
45 | }
46 |
47 | return fd;
48 | }
49 |
50 | // Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
51 | Return ConsumerIr::transmit(int32_t carrierFreq, const hidl_vec& pattern) {
52 | size_t entries = pattern.size();
53 | int rc;
54 | int lircFd;
55 |
56 | lircFd = openLircDev();
57 | if (lircFd < 0) {
58 | return lircFd;
59 | }
60 |
61 | rc = ioctl(lircFd, LIRC_SET_SEND_CARRIER, &carrierFreq);
62 | if (rc < 0) {
63 | LOG(ERROR) << "failed to set carrier " << carrierFreq << ", error: " << errno;
64 | goto out_close;
65 | }
66 |
67 | rc = ioctl(lircFd, LIRC_SET_SEND_DUTY_CYCLE, &dutyCycle);
68 | if (rc < 0) {
69 | LOG(ERROR) << "failed to set duty cycle " << dutyCycle << ", error: " << errno;
70 | goto out_close;
71 | }
72 |
73 | if ((entries & 1) != 0) {
74 | rc = write(lircFd, pattern.data(), sizeof(int32_t) * entries);
75 | } else {
76 | rc = write(lircFd, pattern.data(), sizeof(int32_t) * (entries - 1));
77 | usleep(pattern[entries - 1]);
78 | }
79 |
80 | if (rc < 0) {
81 | LOG(ERROR) << "failed to write pattern " << pattern.size() << ", error: " << errno;
82 | goto out_close;
83 | }
84 |
85 | rc = 0;
86 |
87 | out_close:
88 | close(lircFd);
89 |
90 | return rc == 0;
91 | }
92 |
93 | Return ConsumerIr::getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) {
94 | _hidl_cb(true, rangeVec);
95 | return Void();
96 | }
97 |
98 | } // namespace implementation
99 | } // namespace V1_0
100 | } // namespace ir
101 | } // namespace hardware
102 | } // namespace android
103 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #define LOG_TAG "powerhal-libperfmgr"
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #include
27 |
28 | #include "Power.h"
29 | #include "PowerExt.h"
30 | #include "PowerSessionManager.h"
31 |
32 | using aidl::google::hardware::power::impl::pixel::Power;
33 | using aidl::google::hardware::power::impl::pixel::PowerExt;
34 | using aidl::google::hardware::power::impl::pixel::PowerHintMonitor;
35 | using aidl::google::hardware::power::impl::pixel::PowerSessionManager;
36 | using ::android::perfmgr::HintManager;
37 |
38 | constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init");
39 |
40 | int main() {
41 | // Parse config but do not start the looper
42 | std::shared_ptr hm = HintManager::GetInstance();
43 | if (!hm) {
44 | LOG(FATAL) << "HintManager Init failed";
45 | }
46 |
47 | // single thread
48 | ABinderProcess_setThreadPoolMaxThreadCount(0);
49 |
50 | // core service
51 | std::shared_ptr pw = ndk::SharedRefBase::make();
52 | ndk::SpAIBinder pwBinder = pw->asBinder();
53 | AIBinder_setMinSchedulerPolicy(pwBinder.get(), SCHED_NORMAL, -20);
54 |
55 | // extension service
56 | std::shared_ptr pwExt = ndk::SharedRefBase::make();
57 | auto pwExtBinder = pwExt->asBinder();
58 | AIBinder_setMinSchedulerPolicy(pwExtBinder.get(), SCHED_NORMAL, -20);
59 |
60 | // attach the extension to the same binder we will be registering
61 | CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
62 |
63 | const std::string instance = std::string() + Power::descriptor + "/default";
64 | binder_status_t status = AServiceManager_addService(pw->asBinder().get(), instance.c_str());
65 | CHECK(status == STATUS_OK);
66 | LOG(INFO) << "Xiaomi Power HAL AIDL Service with Extension is started.";
67 |
68 | if (HintManager::GetInstance()->GetAdpfProfile()) {
69 | PowerHintMonitor::getInstance()->start();
70 | }
71 |
72 | std::thread initThread([&]() {
73 | ::android::base::WaitForProperty(kPowerHalInitProp.data(), "1");
74 | HintManager::GetInstance()->Start();
75 | });
76 | initThread.detach();
77 |
78 | ABinderProcess_joinThreadPool();
79 |
80 | // should not reach
81 | LOG(ERROR) << "Xiaomi Power HAL AIDL Service with Extension just died.";
82 | return EXIT_FAILURE;
83 | }
84 |
--------------------------------------------------------------------------------
/hidl/sensors/HalProxyCallback.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include "HalProxyCallback.h"
18 |
19 | #include
20 |
21 | namespace android {
22 | namespace hardware {
23 | namespace sensors {
24 | namespace V2_0 {
25 | namespace implementation {
26 |
27 | static constexpr int32_t kBitsAfterSubHalIndex = 24;
28 |
29 | /**
30 | * Set the subhal index as first byte of sensor handle and return this modified version.
31 | *
32 | * @param sensorHandle The sensor handle to modify.
33 | * @param subHalIndex The index in the hal proxy of the sub hal this sensor belongs to.
34 | *
35 | * @return The modified sensor handle.
36 | */
37 | int32_t setSubHalIndex(int32_t sensorHandle, size_t subHalIndex) {
38 | return sensorHandle | (static_cast(subHalIndex) << kBitsAfterSubHalIndex);
39 | }
40 |
41 | void HalProxyCallbackBase::postEvents(const std::vector& events,
42 | ScopedWakelock wakelock) {
43 | if (events.empty() || !mCallback->areThreadsRunning()) return;
44 | size_t numWakeupEvents;
45 | std::vector processedEvents = processEvents(events, &numWakeupEvents);
46 | if (numWakeupEvents > 0) {
47 | ALOG_ASSERT(wakelock.isLocked(),
48 | "Wakeup events posted while wakelock unlocked for subhal"
49 | " w/ index %" PRId32 ".",
50 | mSubHalIndex);
51 | } else {
52 | ALOG_ASSERT(!wakelock.isLocked(),
53 | "No Wakeup events posted but wakelock locked for subhal"
54 | " w/ index %" PRId32 ".",
55 | mSubHalIndex);
56 | }
57 | mCallback->postEventsToMessageQueue(processedEvents, numWakeupEvents, std::move(wakelock));
58 | }
59 |
60 | ScopedWakelock HalProxyCallbackBase::createScopedWakelock(bool lock) {
61 | ScopedWakelock wakelock(mRefCounter, lock);
62 | return wakelock;
63 | }
64 |
65 | std::vector HalProxyCallbackBase::processEvents(const std::vector& events,
66 | size_t* numWakeupEvents) const {
67 | *numWakeupEvents = 0;
68 | std::vector eventsOut;
69 | for (V2_1::Event event : events) {
70 | event.sensorHandle = setSubHalIndex(event.sensorHandle, mSubHalIndex);
71 | const V2_1::SensorInfo& sensor = mCallback->getSensorInfo(event.sensorHandle);
72 |
73 | if (sensor.type == V2_1::SensorType::PICK_UP_GESTURE
74 | && event.u.scalar != 1) {
75 | continue;
76 | }
77 |
78 | if ((sensor.flags & V1_0::SensorFlagBits::WAKE_UP) != 0) {
79 | (*numWakeupEvents)++;
80 | }
81 | eventsOut.push_back(event);
82 | }
83 | return eventsOut;
84 | }
85 |
86 | } // namespace implementation
87 | } // namespace V2_0
88 | } // namespace sensors
89 | } // namespace hardware
90 | } // namespace android
91 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/PowerExt.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #define LOG_TAG "android.hardware.power-service.xiaomi.ext-libperfmgr"
18 |
19 | #include "PowerExt.h"
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include
30 |
31 | #include "PowerSessionManager.h"
32 |
33 | namespace aidl {
34 | namespace google {
35 | namespace hardware {
36 | namespace power {
37 | namespace impl {
38 | namespace pixel {
39 |
40 | using ::android::perfmgr::HintManager;
41 |
42 | ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
43 | LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
44 |
45 | if (enabled) {
46 | HintManager::GetInstance()->DoHint(mode);
47 | } else {
48 | HintManager::GetInstance()->EndHint(mode);
49 | }
50 | if (HintManager::GetInstance()->GetAdpfProfile() &&
51 | HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
52 | PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
53 | }
54 |
55 | return ndk::ScopedAStatus::ok();
56 | }
57 |
58 | ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
59 | bool supported = HintManager::GetInstance()->IsHintSupported(mode);
60 | LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
61 | *_aidl_return = supported;
62 | return ndk::ScopedAStatus::ok();
63 | }
64 |
65 | ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t durationMs) {
66 | LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
67 | if (HintManager::GetInstance()->GetAdpfProfile() &&
68 | HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
69 | PowerSessionManager::getInstance()->updateHintBoost(boost, durationMs);
70 | }
71 |
72 | if (durationMs > 0) {
73 | HintManager::GetInstance()->DoHint(boost, std::chrono::milliseconds(durationMs));
74 | } else if (durationMs == 0) {
75 | HintManager::GetInstance()->DoHint(boost);
76 | } else {
77 | HintManager::GetInstance()->EndHint(boost);
78 | }
79 |
80 | return ndk::ScopedAStatus::ok();
81 | }
82 |
83 | ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
84 | bool supported = HintManager::GetInstance()->IsHintSupported(boost);
85 | LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
86 | *_aidl_return = supported;
87 | return ndk::ScopedAStatus::ok();
88 | }
89 |
90 | } // namespace pixel
91 | } // namespace impl
92 | } // namespace power
93 | } // namespace hardware
94 | } // namespace google
95 | } // namespace aidl
96 |
--------------------------------------------------------------------------------
/hidl/biometrics/fingerprint/BiometricsFingerprint.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | * 2022 The LineageOS Project
4 | *
5 | * SPDX-License-Identifier: Apache-2.0
6 | */
7 |
8 | #pragma once
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include "UdfpsHandler.h"
17 | #include "fingerprint.h"
18 |
19 | namespace android {
20 | namespace hardware {
21 | namespace biometrics {
22 | namespace fingerprint {
23 | namespace V2_3 {
24 | namespace implementation {
25 |
26 | using ::android::sp;
27 | using ::android::hardware::hidl_string;
28 | using ::android::hardware::hidl_vec;
29 | using ::android::hardware::Return;
30 | using ::android::hardware::Void;
31 | using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo;
32 | using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError;
33 | using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
34 | using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
35 | using ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
36 |
37 | struct BiometricsFingerprint : public IBiometricsFingerprint {
38 | public:
39 | BiometricsFingerprint();
40 | ~BiometricsFingerprint();
41 |
42 | // Method to wrap legacy HAL with BiometricsFingerprint class
43 | static IBiometricsFingerprint* getInstance();
44 |
45 | // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint
46 | // follow.
47 | Return setNotify(
48 | const sp& clientCallback) override;
49 | Return preEnroll() override;
50 | Return enroll(const hidl_array& hat, uint32_t gid,
51 | uint32_t timeoutSec) override;
52 | Return postEnroll() override;
53 | Return getAuthenticatorId() override;
54 | Return cancel() override;
55 | Return enumerate() override;
56 | Return remove(uint32_t gid, uint32_t fid) override;
57 | Return setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
58 | Return authenticate(uint64_t operationId, uint32_t gid) override;
59 |
60 | // Methods from ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint
61 | // follow.
62 | Return isUdfps(uint32_t sensorId) override;
63 | Return onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
64 | Return onFingerUp() override;
65 |
66 | private:
67 | static fingerprint_device_t* openHal(const char* class_name);
68 | static void notify(
69 | const fingerprint_msg_t* msg); /* Static callback for legacy HAL implementation */
70 | static Return ErrorFilter(int32_t error);
71 | static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
72 | static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
73 | static BiometricsFingerprint* sInstance;
74 |
75 | std::mutex mClientCallbackMutex;
76 | sp mClientCallback;
77 | fingerprint_device_t* mDevice;
78 | bool mIsUdfps;
79 | UdfpsHandlerFactory* mUdfpsHandlerFactory;
80 | UdfpsHandler* mUdfpsHandler;
81 | };
82 |
83 | } // namespace implementation
84 | } // namespace V2_3
85 | } // namespace fingerprint
86 | } // namespace biometrics
87 | } // namespace hardware
88 | } // namespace android
89 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/PowerSessionManager.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include "PowerHintSession.h"
28 |
29 | namespace aidl {
30 | namespace google {
31 | namespace hardware {
32 | namespace power {
33 | namespace impl {
34 | namespace pixel {
35 |
36 | using ::android::Looper;
37 | using ::android::Message;
38 | using ::android::MessageHandler;
39 | using ::android::Thread;
40 | using ::android::perfmgr::HintManager;
41 |
42 | constexpr char kPowerHalAdpfDisableTopAppBoost[] = "vendor.powerhal.adpf.disable.hint";
43 |
44 | class PowerSessionManager : public MessageHandler {
45 | public:
46 | // current hint info
47 | void updateHintMode(const std::string &mode, bool enabled);
48 | void updateHintBoost(const std::string &boost, int32_t durationMs);
49 | int getDisplayRefreshRate();
50 | // monitoring session status
51 | void addPowerSession(PowerHintSession *session);
52 | void removePowerSession(PowerHintSession *session);
53 | void setUclampMin(PowerHintSession *session, int min);
54 | void setUclampMinLocked(PowerHintSession *session, int min);
55 | void handleMessage(const Message &message) override;
56 | void dumpToFd(int fd);
57 |
58 | // Singleton
59 | static sp getInstance() {
60 | static sp instance = new PowerSessionManager();
61 | return instance;
62 | }
63 |
64 | private:
65 | class WakeupHandler : public MessageHandler {
66 | public:
67 | WakeupHandler() {}
68 | void handleMessage(const Message &message) override;
69 | };
70 |
71 | private:
72 | void wakeSessions();
73 | std::optional isAnyAppSessionActive();
74 | void disableSystemTopAppBoost();
75 | void enableSystemTopAppBoost();
76 | const std::string kDisableBoostHintName;
77 |
78 | std::unordered_set mSessions; // protected by mLock
79 | std::unordered_map mTidRefCountMap; // protected by mLock
80 | std::unordered_map> mTidSessionListMap;
81 | sp mWakeupHandler;
82 | bool mActive; // protected by mLock
83 | /**
84 | * mLock to pretect the above data objects opertions.
85 | **/
86 | std::mutex mLock;
87 | int mDisplayRefreshRate;
88 | // Singleton
89 | PowerSessionManager()
90 | : kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
91 | "ADPF_DISABLE_TA_BOOST")),
92 | mActive(false),
93 | mDisplayRefreshRate(60) {
94 | mWakeupHandler = sp(new WakeupHandler());
95 | }
96 | PowerSessionManager(PowerSessionManager const &) = delete;
97 | void operator=(PowerSessionManager const &) = delete;
98 | };
99 |
100 | class PowerHintMonitor : public Thread {
101 | public:
102 | void start();
103 | bool threadLoop() override;
104 | sp getLooper();
105 | // Singleton
106 | static sp getInstance() {
107 | static sp instance = new PowerHintMonitor();
108 | return instance;
109 | }
110 | PowerHintMonitor(PowerHintMonitor const &) = delete;
111 | void operator=(PowerHintMonitor const &) = delete;
112 |
113 | private:
114 | sp mLooper;
115 | // Singleton
116 | PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {}
117 | };
118 |
119 | } // namespace pixel
120 | } // namespace impl
121 | } // namespace power
122 | } // namespace hardware
123 | } // namespace google
124 | } // namespace aidl
125 |
--------------------------------------------------------------------------------
/aidl/light/Lights.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #include "Lights.h"
8 |
9 | #include
10 | #include "LED.h"
11 | #include "Utils.h"
12 |
13 | namespace aidl {
14 | namespace android {
15 | namespace hardware {
16 | namespace light {
17 |
18 | static const std::string kAllButtonsPaths[] = {
19 | "/sys/class/leds/button-backlight/brightness",
20 | "/sys/class/leds/button-backlight1/brightness",
21 | };
22 |
23 | enum led_type {
24 | RED,
25 | GREEN,
26 | BLUE,
27 | WHITE,
28 | MAX_LEDS,
29 | };
30 |
31 | static LED kLEDs[MAX_LEDS] = {
32 | [RED] = LED("red"),
33 | [GREEN] = LED("green"),
34 | [BLUE] = LED("blue"),
35 | [WHITE] = LED("white"),
36 | };
37 |
38 | #define AutoHwLight(light) {.id = (int32_t)light, .type = light, .ordinal = 0}
39 |
40 | static const HwLight kBacklightHwLight = AutoHwLight(LightType::BACKLIGHT);
41 | static const HwLight kBatteryHwLight = AutoHwLight(LightType::BATTERY);
42 | static const HwLight kButtonsHwLight = AutoHwLight(LightType::BUTTONS);
43 | static const HwLight kNotificationHwLight = AutoHwLight(LightType::NOTIFICATIONS);
44 |
45 | Lights::Lights() {
46 | mBacklightDevice = getBacklightDevice();
47 | if (mBacklightDevice) {
48 | mLights.push_back(kBacklightHwLight);
49 | }
50 |
51 | for (auto& buttons : kAllButtonsPaths) {
52 | if (!fileWriteable(buttons))
53 | continue;
54 |
55 | mButtonsPaths.push_back(buttons);
56 | }
57 |
58 | if (!mButtonsPaths.empty())
59 | mLights.push_back(kButtonsHwLight);
60 |
61 | mWhiteLED = kLEDs[WHITE].exists();
62 |
63 | mLights.push_back(kBatteryHwLight);
64 | mLights.push_back(kNotificationHwLight);
65 | }
66 |
67 | ndk::ScopedAStatus Lights::setLightState(int32_t id, const HwLightState& state) {
68 | rgb_t color(state.color);
69 | rgb_t batteryStateColor;
70 |
71 | LightType type = static_cast(id);
72 | switch (type) {
73 | case LightType::BACKLIGHT:
74 | if (mBacklightDevice)
75 | mBacklightDevice->setBacklight(color.toBrightness());
76 | break;
77 | case LightType::BUTTONS:
78 | for (auto& buttons : mButtonsPaths)
79 | writeToFile(buttons, color.isLit());
80 | break;
81 | case LightType::BATTERY:
82 | case LightType::NOTIFICATIONS:
83 | mLEDMutex.lock();
84 | if (type == LightType::BATTERY)
85 | mLastBatteryState = state;
86 | else
87 | mLastNotificationState = state;
88 | batteryStateColor = rgb_t(mLastBatteryState.color);
89 | setLED(batteryStateColor.isLit() ? mLastBatteryState : mLastNotificationState);
90 | mLEDMutex.unlock();
91 | break;
92 | default:
93 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
94 | break;
95 | }
96 |
97 | return ndk::ScopedAStatus::ok();
98 | }
99 |
100 | ndk::ScopedAStatus Lights::getLights(std::vector *_aidl_return) {
101 | for (auto& light : mLights)
102 | _aidl_return->push_back(light);
103 |
104 | return ndk::ScopedAStatus::ok();
105 | }
106 |
107 | void Lights::setLED(const HwLightState& state) {
108 | bool rc = true;
109 | rgb_t color(state.color);
110 | uint8_t blink = (state.flashOnMs != 0 && state.flashOffMs != 0);
111 |
112 | switch (state.flashMode) {
113 | case FlashMode::HARDWARE:
114 | case FlashMode::TIMED:
115 | if (mWhiteLED) {
116 | rc = kLEDs[WHITE].setBreath(blink);
117 | } else {
118 | if (!!color.red)
119 | rc &= kLEDs[RED].setBreath(blink);
120 | if (!!color.green)
121 | rc &= kLEDs[GREEN].setBreath(blink);
122 | if (!!color.blue)
123 | rc &= kLEDs[BLUE].setBreath(blink);
124 | }
125 | if (rc)
126 | break;
127 | FALLTHROUGH_INTENDED;
128 | default:
129 | if (mWhiteLED) {
130 | rc = kLEDs[WHITE].setBrightness(color.toBrightness());
131 | } else {
132 | rc = kLEDs[RED].setBrightness(color.red);
133 | rc &= kLEDs[GREEN].setBrightness(color.green);
134 | rc &= kLEDs[BLUE].setBrightness(color.blue);
135 | }
136 | break;
137 | }
138 |
139 | return;
140 | }
141 |
142 | } // namespace light
143 | } // namespace hardware
144 | } // namespace android
145 | } // namespace aidl
146 |
--------------------------------------------------------------------------------
/aidl/power-libperfmgr/PowerHintSession.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 | #include
26 |
27 | namespace aidl {
28 | namespace google {
29 | namespace hardware {
30 | namespace power {
31 | namespace impl {
32 | namespace pixel {
33 |
34 | using aidl::android::hardware::power::BnPowerHintSession;
35 | using aidl::android::hardware::power::WorkDuration;
36 | using ::android::Message;
37 | using ::android::MessageHandler;
38 | using ::android::sp;
39 | using std::chrono::milliseconds;
40 | using std::chrono::nanoseconds;
41 | using std::chrono::steady_clock;
42 | using std::chrono::time_point;
43 |
44 | struct AppHintDesc {
45 | AppHintDesc(int32_t tgid, int32_t uid, std::vector threadIds)
46 | : tgid(tgid),
47 | uid(uid),
48 | threadIds(std::move(threadIds)),
49 | duration(0LL),
50 | current_min(0),
51 | is_active(true),
52 | update_count(0),
53 | integral_error(0),
54 | previous_error(0) {}
55 | std::string toString() const;
56 | const int32_t tgid;
57 | const int32_t uid;
58 | const std::vector threadIds;
59 | nanoseconds duration;
60 | int current_min;
61 | // status
62 | std::atomic is_active;
63 | // pid
64 | uint64_t update_count;
65 | int64_t integral_error;
66 | int64_t previous_error;
67 | };
68 |
69 | class PowerHintSession : public BnPowerHintSession {
70 | public:
71 | explicit PowerHintSession(int32_t tgid, int32_t uid, const std::vector &threadIds,
72 | int64_t durationNanos);
73 | ~PowerHintSession();
74 | ndk::ScopedAStatus close() override;
75 | ndk::ScopedAStatus pause() override;
76 | ndk::ScopedAStatus resume() override;
77 | ndk::ScopedAStatus updateTargetWorkDuration(int64_t targetDurationNanos) override;
78 | ndk::ScopedAStatus reportActualWorkDuration(
79 | const std::vector &actualDurations) override;
80 | bool isActive();
81 | bool isTimeout();
82 | void wakeup();
83 | void setStale();
84 | // Is this hint session for a user application
85 | bool isAppSession();
86 | const std::vector &getTidList() const;
87 | int getUclampMin();
88 | void dumpToStream(std::ostream &stream);
89 |
90 | void updateWorkPeriod(const std::vector &actualDurations);
91 | time_point getEarlyBoostTime();
92 | time_point getStaleTime();
93 |
94 | private:
95 | class StaleTimerHandler : public MessageHandler {
96 | public:
97 | StaleTimerHandler(PowerHintSession *session)
98 | : mSession(session), mIsMonitoring(false), mIsSessionDead(false) {}
99 | void updateTimer();
100 | void updateTimer(time_point staleTime);
101 | void handleMessage(const Message &message) override;
102 | void setSessionDead();
103 |
104 | private:
105 | PowerHintSession *mSession;
106 | std::mutex mStaleLock;
107 | std::mutex mMessageLock;
108 | std::atomic> mStaleTime;
109 | std::atomic mIsMonitoring;
110 | bool mIsSessionDead;
111 | };
112 |
113 | class EarlyBoostHandler : public MessageHandler {
114 | public:
115 | EarlyBoostHandler(PowerHintSession *session)
116 | : mSession(session), mIsMonitoring(false), mIsSessionDead(false) {}
117 | void updateTimer(time_point boostTime);
118 | void handleMessage(const Message &message) override;
119 | void setSessionDead();
120 |
121 | private:
122 | PowerHintSession *mSession;
123 | std::mutex mBoostLock;
124 | std::mutex mMessageLock;
125 | std::atomic> mBoostTime;
126 | std::atomic mIsMonitoring;
127 | bool mIsSessionDead;
128 | };
129 |
130 | private:
131 | void updateUniveralBoostMode();
132 | int setSessionUclampMin(int32_t min);
133 | std::string getIdString() const;
134 | AppHintDesc *mDescriptor = nullptr;
135 | sp mStaleTimerHandler;
136 | sp mEarlyBoostHandler;
137 | std::atomic> mLastUpdatedTime;
138 | sp mPowerManagerHandler;
139 | std::mutex mSessionLock;
140 | std::atomic mSessionClosed = false;
141 | // These 3 variables are for earlyboost work period estimation.
142 | int64_t mLastStartedTimeNs;
143 | int64_t mLastDurationNs;
144 | int64_t mWorkPeriodNs;
145 | };
146 |
147 | } // namespace pixel
148 | } // namespace impl
149 | } // namespace power
150 | } // namespace hardware
151 | } // namespace google
152 | } // namespace aidl
153 |
--------------------------------------------------------------------------------
/sensors/udfps_hal.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #define LOG_TAG "sensors.udfps"
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 |
19 | static const char *udfps_state_paths[] = {
20 | "/sys/devices/virtual/touch/tp_dev/fp_state",
21 | "/sys/touchpanel/fp_state",
22 | NULL,
23 | };
24 |
25 | static struct sensor_t udfps_sensor = {
26 | .name = "UDFPS Sensor",
27 | .vendor = "The LineageOS Project",
28 | .version = 1,
29 | .handle = 0,
30 | .type = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 1,
31 | .maxRange = 2048.0f,
32 | .resolution = 1.0f,
33 | .power = 0,
34 | .minDelay = -1,
35 | .fifoReservedEventCount = 0,
36 | .fifoMaxEventCount = 0,
37 | .stringType = "org.lineageos.sensor.udfps",
38 | .requiredPermission = "",
39 | .maxDelay = 0,
40 | .flags = SENSOR_FLAG_ONE_SHOT_MODE | SENSOR_FLAG_WAKE_UP,
41 | .reserved = {},
42 | };
43 |
44 | struct udfps_context_t {
45 | sensors_poll_device_1_t device;
46 | int fd;
47 | };
48 |
49 | static int udfps_read_line(int fd, char* buf, size_t len) {
50 | int rc;
51 |
52 | rc = lseek(fd, 0, SEEK_SET);
53 | if (rc < 0) {
54 | ALOGE("Failed to seek: %d", -errno);
55 | return rc;
56 | }
57 |
58 | rc = read(fd, buf, len);
59 | if (rc < 0) {
60 | ALOGE("Failed to read: %d", -errno);
61 | return rc;
62 | }
63 |
64 | return rc;
65 | }
66 |
67 | static int udfps_read_state(int fd, int& pos_x, int& pos_y) {
68 | int rc, state = 0;
69 | char buf[64];
70 |
71 | rc = udfps_read_line(fd, buf, sizeof(buf));
72 | if (rc > 0) {
73 | rc = sscanf(buf, "%d,%d,%d", &pos_x, &pos_y, &state);
74 | if (rc != 3) {
75 | ALOGE("Failed to parse fp_state: %d", rc);
76 | state = 0;
77 | }
78 | }
79 |
80 | return state;
81 | }
82 |
83 | static int udfps_wait_event(int fd, int timeout) {
84 | struct pollfd fds = {
85 | .fd = fd,
86 | .events = POLLERR | POLLPRI,
87 | .revents = 0,
88 | };
89 | int rc;
90 |
91 | do {
92 | rc = poll(&fds, 1, timeout);
93 | } while (rc < 0 && errno == EINTR);
94 |
95 | return rc;
96 | }
97 |
98 | static void udfps_flush_events(int fd) {
99 | char buf[64];
100 |
101 | while (udfps_wait_event(fd, 0) > 0) {
102 | udfps_read_line(fd, buf, sizeof(buf));
103 | }
104 | }
105 |
106 | static int udfps_close(struct hw_device_t* dev) {
107 | udfps_context_t* ctx = reinterpret_cast(dev);
108 |
109 | if (ctx) {
110 | close(ctx->fd);
111 | delete ctx;
112 | }
113 |
114 | return 0;
115 | }
116 |
117 | static int udfps_activate(struct sensors_poll_device_t* dev, int handle, int enabled) {
118 | udfps_context_t* ctx = reinterpret_cast(dev);
119 |
120 | if (!ctx || handle) {
121 | return -EINVAL;
122 | }
123 |
124 | // Flush any pending events
125 | if (enabled) udfps_flush_events(ctx->fd);
126 |
127 | return 0;
128 | }
129 |
130 | static int udfps_setDelay(struct sensors_poll_device_t* dev, int handle, int64_t /* ns */) {
131 | udfps_context_t* ctx = reinterpret_cast(dev);
132 |
133 | if (!ctx || handle) {
134 | return -EINVAL;
135 | }
136 |
137 | return 0;
138 | }
139 |
140 | static int udfps_poll(struct sensors_poll_device_t* dev, sensors_event_t* data, int /* count */) {
141 | udfps_context_t* ctx = reinterpret_cast(dev);
142 |
143 | if (!ctx) {
144 | return -EINVAL;
145 | }
146 |
147 | int fod_x, fod_y, fod_state = 0;
148 |
149 | do {
150 | int rc = udfps_wait_event(ctx->fd, -1);
151 | if (rc < 0) {
152 | ALOGE("Failed to poll fp_state: %d", -errno);
153 | return -errno;
154 | } else if (rc > 0) {
155 | fod_state = udfps_read_state(ctx->fd, fod_x, fod_y);
156 | }
157 | } while (!fod_state);
158 |
159 | memset(data, 0, sizeof(sensors_event_t));
160 | data->version = sizeof(sensors_event_t);
161 | data->sensor = udfps_sensor.handle;
162 | data->type = udfps_sensor.type;
163 | data->timestamp = ::android::elapsedRealtimeNano();
164 | data->data[0] = fod_x;
165 | data->data[1] = fod_y;
166 |
167 | return 1;
168 | }
169 |
170 | static int udfps_batch(struct sensors_poll_device_1* /* dev */, int /* handle */, int /* flags */,
171 | int64_t /* period_ns */, int64_t /* max_ns */) {
172 | return 0;
173 | }
174 |
175 | static int udfps_flush(struct sensors_poll_device_1* /* dev */, int /* handle */) {
176 | return -EINVAL;
177 | }
178 |
179 | static int open_sensors(const struct hw_module_t* module, const char* /* name */,
180 | struct hw_device_t** device) {
181 | udfps_context_t* ctx = new udfps_context_t();
182 |
183 | memset(ctx, 0, sizeof(udfps_context_t));
184 | ctx->device.common.tag = HARDWARE_DEVICE_TAG;
185 | ctx->device.common.version = SENSORS_DEVICE_API_VERSION_1_3;
186 | ctx->device.common.module = const_cast(module);
187 | ctx->device.common.close = udfps_close;
188 | ctx->device.activate = udfps_activate;
189 | ctx->device.setDelay = udfps_setDelay;
190 | ctx->device.poll = udfps_poll;
191 | ctx->device.batch = udfps_batch;
192 | ctx->device.flush = udfps_flush;
193 |
194 | for (int i = 0; udfps_state_paths[i]; i++) {
195 | ctx->fd = open(udfps_state_paths[i], O_RDONLY);
196 | if (ctx->fd >= 0) {
197 | break;
198 | }
199 | }
200 |
201 | if (ctx->fd < 0) {
202 | ALOGE("Failed to open fp state: %d", -errno);
203 | delete ctx;
204 |
205 | return -ENODEV;
206 | }
207 |
208 | *device = &ctx->device.common;
209 |
210 | return 0;
211 | }
212 |
213 | static struct hw_module_methods_t udfps_module_methods = {
214 | .open = open_sensors,
215 | };
216 |
217 | static int udfps_get_sensors_list(struct sensors_module_t*, struct sensor_t const** list) {
218 | *list = &udfps_sensor;
219 |
220 | return 1;
221 | }
222 |
223 | static int udfps_set_operation_mode(unsigned int mode) {
224 | return !mode ? 0 : -EINVAL;
225 | }
226 |
227 | struct sensors_module_t HAL_MODULE_INFO_SYM = {
228 | .common = {.tag = HARDWARE_MODULE_TAG,
229 | .version_major = 1,
230 | .version_minor = 0,
231 | .id = SENSORS_HARDWARE_MODULE_ID,
232 | .name = "UDFPS Sensor module",
233 | .author = "Ivan Vecera",
234 | .methods = &udfps_module_methods,
235 | .dso = NULL,
236 | .reserved = {0}},
237 | .get_sensors_list = udfps_get_sensors_list,
238 | .set_operation_mode = udfps_set_operation_mode,
239 | };
240 |
--------------------------------------------------------------------------------
/IFAAService/src/org/ifaa/aidl/manager/IfaaService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package org.ifaa.aidl.manager;
8 |
9 | import android.app.KeyguardManager;
10 | import android.app.Service;
11 | import android.content.ActivityNotFoundException;
12 | import android.content.Context;
13 | import android.content.Intent;
14 | import android.hardware.fingerprint.Fingerprint;
15 | import android.hardware.fingerprint.FingerprintManager;
16 | import android.os.Build;
17 | import android.os.IBinder;
18 | import android.os.RemoteException;
19 | import android.os.SystemProperties;
20 | import android.util.Log;
21 | import java.lang.ref.WeakReference;
22 | import java.util.ArrayList;
23 | import java.util.List;
24 | import org.ifaa.aidl.manager.IfaaManagerService;
25 | import org.json.JSONObject;
26 | import org.json.JSONException;
27 | import vendor.xiaomi.hardware.mlipay.V1_1.IMlipayService;
28 |
29 | public class IfaaService extends Service {
30 | private static final String LOG_TAG = IfaaService.class.getSimpleName();
31 |
32 | private static final int AUTH_TYPE_NOT_SUPPORT = 0;
33 | private static final int AUTH_TYPE_FINGERPRINT = 1;
34 | private static final int AUTH_TYPE_IRIS = 1<<1;
35 | private static final int AUTH_TYPE_OPTICAL_FINGERPRINT = 1<<4;
36 |
37 | private static final int ACTIVITY_START_SUCCESS = 0;
38 | private static final int ACTIVITY_START_FAILED = -1;
39 |
40 | private IMlipayService mMlipayService = null;
41 |
42 | private final IBinder mIFAABinder = new IfaaServiceStub(this);
43 |
44 | private final class IfaaServiceStub extends IfaaManagerService.Stub {
45 | IfaaServiceStub(IfaaService ifaaService) {
46 | new WeakReference(ifaaService);
47 | }
48 |
49 | @Override
50 | public int getSupportBIOTypes() {
51 | int ifaaProp = SystemProperties.getInt("persist.vendor.sys.pay.ifaa", 0);
52 | String fpVendor = SystemProperties.get("persist.vendor.sys.fp.vendor", "");
53 |
54 | int res = "none".equalsIgnoreCase(fpVendor) ?
55 | ifaaProp & AUTH_TYPE_IRIS :
56 | ifaaProp & (AUTH_TYPE_FINGERPRINT | AUTH_TYPE_IRIS);
57 |
58 | if ((res & AUTH_TYPE_FINGERPRINT) == AUTH_TYPE_FINGERPRINT &&
59 | SystemProperties.getBoolean("ro.hardware.fp.udfps", false)) {
60 | res |= AUTH_TYPE_OPTICAL_FINGERPRINT;
61 | }
62 |
63 | return res;
64 | }
65 |
66 | @Override
67 | public int startBIOManager(int authType) {
68 | int res = ACTIVITY_START_FAILED;
69 |
70 | if (authType == AUTH_TYPE_FINGERPRINT) {
71 | Intent intent = new Intent("android.settings.SECURITY_SETTINGS");
72 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
73 | getApplicationContext().startActivity(intent);
74 | res = ACTIVITY_START_SUCCESS;
75 | }
76 |
77 | return res;
78 | }
79 |
80 | @Override
81 | public String getDeviceModel() {
82 | return Build.MANUFACTURER + "-" + Build.DEVICE;
83 | }
84 |
85 | @Override
86 | public byte[] processCmd(byte[] param) {
87 | IMlipayService mlipayService = getMlipayService();
88 | if (mlipayService == null) {
89 | Log.e(LOG_TAG, "Failed to open mlipay HAL");
90 | return null;
91 | }
92 |
93 | ArrayList