├── Android.bp
├── BoardConfigCommon.mk
├── README.md
├── audio
├── audio_effects.xml
├── audio_output_policy.conf
├── audio_policy_configuration.xml
├── audio_policy_configuration_a2dp_offload_disabled.xml
├── audio_tuning_mixer_tavil.txt
├── bluetooth_hearing_aid_audio_policy_configuration.xml
├── graphite_ipc_platform_info.xml
├── listen_platform_info.xml
├── mixer_paths_tavil.xml
└── usbv2_audio_policy_configuration.xml
├── config.fs
├── configs
├── media_codecs.xml
├── media_codecs_performance.xml
├── media_profiles.xml
├── media_profiles_vendor.xml
├── public.libraries.txt
├── qti_whitelist.xml
└── system_properties.xml
├── extract-files.py
├── init
├── Android.bp
├── init.qcom.early_boot.sh
├── init.qcom.post_boot.sh
├── init.qcom.power.rc
├── init.qcom.rc
├── init.qcom.recovery.rc
├── init.qcom.sensors.sh
├── init.qcom.sh
└── ueventd.qcom.rc
├── keylayout
└── sdm845-tavil-snd-card_Button_Jack.kl
├── lineage.dependencies
├── livedisplay
├── Android.bp
├── SunlightEnhancement.cpp
├── SunlightEnhancement.h
├── service.cpp
└── vendor.lineage.livedisplay@2.0-service.xiaomi_sdm845.rc
├── manifest.xml
├── odm.prop
├── overlay-lineage
├── lineage-sdk
│ └── lineage
│ │ └── res
│ │ └── res
│ │ └── values
│ │ └── config.xml
└── packages
│ └── apps
│ └── Dialer
│ └── java
│ └── com
│ └── android
│ └── dialer
│ └── callrecord
│ └── res
│ └── values
│ └── config.xml
├── overlay
├── frameworks
│ └── base
│ │ ├── core
│ │ └── res
│ │ │ └── res
│ │ │ ├── values-mcc302-mnc370
│ │ │ └── config.xml
│ │ │ ├── values-mcc302-mnc720
│ │ │ └── config.xml
│ │ │ └── values
│ │ │ └── config.xml
│ │ └── packages
│ │ ├── SettingsProvider
│ │ └── res
│ │ │ └── values
│ │ │ └── defaults.xml
│ │ └── SystemUI
│ │ └── res
│ │ └── values
│ │ └── config.xml
└── packages
│ ├── apps
│ ├── CarrierConfig
│ │ └── res
│ │ │ └── xml
│ │ │ └── vendor.xml
│ └── Settings
│ │ └── res
│ │ └── values
│ │ └── arrays.xml
│ └── services
│ └── Telephony
│ └── res
│ └── values
│ └── config.xml
├── parts
├── Android.bp
├── AndroidManifest.xml
├── proguard.flags
├── res
│ ├── drawable
│ │ ├── ic_hand.xml
│ │ ├── ic_pickup.xml
│ │ ├── ic_pocket.xml
│ │ ├── ic_settings_thermal.xml
│ │ ├── ic_thermal_benchmark.xml
│ │ ├── ic_thermal_browser.xml
│ │ ├── ic_thermal_camera.xml
│ │ ├── ic_thermal_default.xml
│ │ ├── ic_thermal_dialer.xml
│ │ ├── ic_thermal_gaming.xml
│ │ └── ic_thermal_streaming.xml
│ ├── layout
│ │ ├── thermal_layout.xml
│ │ └── thermal_list_item.xml
│ ├── values
│ │ ├── arrays.xml
│ │ └── strings.xml
│ └── xml
│ │ ├── dirac_settings.xml
│ │ └── doze_settings.xml
└── src
│ └── org
│ └── lineageos
│ └── settings
│ ├── BootCompletedReceiver.java
│ ├── dirac
│ ├── DiracActivity.java
│ ├── DiracSettingsFragment.java
│ ├── DiracSound.java
│ └── DiracUtils.java
│ ├── doze
│ ├── DozeService.java
│ ├── DozeSettingsActivity.java
│ ├── DozeSettingsFragment.java
│ ├── DozeUtils.java
│ ├── PickupSensor.java
│ └── ProximitySensor.java
│ └── thermal
│ ├── ThermalActivity.java
│ ├── ThermalService.java
│ ├── ThermalSettingsFragment.java
│ └── ThermalUtils.java
├── permissions
├── privapp-permissions-hotword.xml
└── system_ext-privapp-permissions-qti.xml
├── pocketmode
├── Android.bp
├── AndroidManifest.xml
├── proguard.flags
└── src
│ └── org
│ └── lineageos
│ └── pocketmode
│ ├── BootCompletedReceiver.java
│ ├── PocketModeService.java
│ └── ProximitySensor.java
├── power
├── Android.bp
├── configs
│ └── powerhint.json
└── power-mode.cpp
├── product.prop
├── proprietary-files.txt
├── recovery
├── Android.bp
└── recovery_updater.cpp
├── releasetools.py
├── rro_overlays
├── TetheringOverlay
│ ├── Android.bp
│ ├── AndroidManifest.xml
│ └── res
│ │ └── values
│ │ └── config.xml
└── WifiOverlay
│ ├── Android.bp
│ ├── AndroidManifest.xml
│ └── res
│ └── values
│ └── config.xml
├── sdm845.mk
├── seccomp
└── mediacodec-seccomp.policy
├── sepolicy
├── private
│ ├── property_contexts
│ ├── seapp_contexts
│ ├── system_app.te
│ └── xiaomiparts_app.te
├── public
│ ├── attributes
│ └── property.te
└── vendor
│ ├── app.te
│ ├── appdomain.te
│ ├── device.te
│ ├── fastbootd.te
│ ├── file.te
│ ├── file_contexts
│ ├── genfs_contexts
│ ├── glgps.te
│ ├── hal_audio_default.te
│ ├── hal_bluetooth_qti.te
│ ├── hal_camera_default.te
│ ├── hal_fingerprint_default.te
│ ├── hal_gnss_default.te
│ ├── hal_health_default.te
│ ├── hal_imsrtp.te
│ ├── hal_lineage_livedisplay_qti.te
│ ├── hal_mlipay.te
│ ├── hal_mlipay_default.te
│ ├── hal_power_default.te
│ ├── hal_sensors_default.te
│ ├── healthd.te
│ ├── hwservice.te
│ ├── hwservice_contexts
│ ├── init.te
│ ├── lhd.te
│ ├── mm-pp-daemon.te
│ ├── pocketmode_app.te
│ ├── priv_app.te
│ ├── property.te
│ ├── property_contexts
│ ├── radio.te
│ ├── remosaic_daemon.te
│ ├── rild.te
│ ├── sensors.te
│ ├── system_server.te
│ ├── tee.te
│ ├── thermal-engine.te
│ ├── vendor_init.te
│ ├── vndservice.te
│ ├── vndservice_contexts
│ ├── vold.te
│ ├── vppservice.te
│ └── wcnss_service.te
├── setup-makefiles.py
├── system.prop
├── system_ext.prop
├── udfps
├── Android.bp
└── UdfpsHandler.cpp
├── vendor.prop
└── wifi
├── WCNSS_qcom_cfg.ini
├── hostapd.accept
├── hostapd.conf
├── hostapd.deny
├── p2p_supplicant_overlay.conf
└── wpa_supplicant_overlay.conf
/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 The LineageOS Project
3 | // SPDX-License-Identifier: Apache-2.0
4 | //
5 |
6 | soong_namespace {
7 | imports: [
8 | "hardware/google/interfaces",
9 | "hardware/google/pixel",
10 | "hardware/xiaomi",
11 | ],
12 | }
13 |
14 | install_symlink {
15 | name: "firmware_wlan_mac.bin_symlink",
16 | vendor: true,
17 | installed_location: "firmware/wlan/qca_cld/wlan_mac.bin",
18 | symlink_target: "/mnt/vendor/persist/wlan_mac.bin",
19 | }
20 |
21 | install_symlink {
22 | name: "firmware_WCNSS_qcom_cfg.ini_symlink",
23 | vendor: true,
24 | installed_location: "firmware/wlan/qca_cld/WCNSS_qcom_cfg.ini",
25 | symlink_target: "/vendor/etc/wifi/WCNSS_qcom_cfg.ini",
26 | }
27 |
--------------------------------------------------------------------------------
/BoardConfigCommon.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2018-2024 The LineageOS Project
3 | #
4 | # SPDX-License-Identifier: Apache-2.0
5 | #
6 |
7 | COMMON_PATH := device/xiaomi/sdm845-common
8 |
9 | # Architecture
10 | TARGET_ARCH := arm64
11 | TARGET_ARCH_VARIANT := armv8-a
12 | TARGET_CPU_ABI := arm64-v8a
13 | TARGET_CPU_ABI2 :=
14 | TARGET_CPU_VARIANT := generic
15 | TARGET_CPU_VARIANT_RUNTIME := kryo385
16 |
17 | TARGET_2ND_ARCH := arm
18 | TARGET_2ND_ARCH_VARIANT := armv8-a
19 | TARGET_2ND_CPU_ABI := armeabi-v7a
20 | TARGET_2ND_CPU_ABI2 := armeabi
21 | TARGET_2ND_CPU_VARIANT := generic
22 | TARGET_2ND_CPU_VARIANT_RUNTIME := kryo385
23 |
24 | # Bootloader
25 | TARGET_BOOTLOADER_BOARD_NAME := sdm845
26 | TARGET_NO_BOOTLOADER := true
27 |
28 | # Kernel
29 | BOARD_BOOT_HEADER_VERSION := 1
30 | BOARD_KERNEL_BASE := 0x00000000
31 | BOARD_KERNEL_CMDLINE := console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xA84000 androidboot.hardware=qcom androidboot.console=ttyMSM0 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 swiotlb=2048 androidboot.configfs=true loop.max_part=7 androidboot.usbcontroller=a600000.dwc3
32 | BOARD_KERNEL_CMDLINE += androidboot.boot_devices=soc/1d84000.ufshc
33 | BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb
34 | BOARD_KERNEL_PAGESIZE := 4096
35 | BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
36 | TARGET_KERNEL_ARCH := arm64
37 | TARGET_KERNEL_CONFIG := vendor/xiaomi/mi845_defconfig
38 | TARGET_KERNEL_SOURCE := kernel/xiaomi/sdm845
39 |
40 | # Platform
41 | TARGET_BOARD_PLATFORM := sdm845
42 |
43 | # Audio
44 | TARGET_PROVIDES_AUDIO_EXTNS := true
45 |
46 | # Filesystem
47 | TARGET_FS_CONFIG_GEN := $(COMMON_PATH)/config.fs
48 |
49 | # Graphics
50 | MAX_EGL_CACHE_KEY_SIZE := 12*1024
51 | MAX_EGL_CACHE_SIZE := 2048*1024
52 |
53 | # HIDL
54 | DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := \
55 | hardware/qcom-caf/common/vendor_framework_compatibility_matrix.xml \
56 | hardware/qcom-caf/common/vendor_framework_compatibility_matrix_legacy.xml \
57 | hardware/xiaomi/vintf/xiaomi_framework_compatibility_matrix.xml \
58 | vendor/lineage/config/device_framework_matrix.xml
59 | DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml
60 | DEVICE_MATRIX_FILE := hardware/qcom-caf/common/compatibility_matrix.xml
61 |
62 | # LMKD
63 | TARGET_LMKD_STATS_LOG := true
64 |
65 | # Media
66 | TARGET_USES_ION := true
67 |
68 | # Partitions
69 | AB_OTA_UPDATER := false
70 |
71 | BOARD_BOOTIMAGE_PARTITION_SIZE := 67092480
72 | BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456
73 | BOARD_USERDATAIMAGE_PARTITION_SIZE := 57453555712
74 |
75 | BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
76 | BOARD_ODMIMAGE_FILE_SYSTEM_TYPE := ext4
77 | BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE := ext4
78 | BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := ext4
79 | BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
80 | BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
81 |
82 | BOARD_FLASH_BLOCK_SIZE := 262144 # (BOARD_KERNEL_PAGESIZE * 64)
83 |
84 | BOARD_SUPER_PARTITION_BLOCK_DEVICES := system vendor cust
85 | BOARD_SUPER_PARTITION_METADATA_DEVICE := system
86 | BOARD_SUPER_PARTITION_SIZE := 5167382528
87 | BOARD_SUPER_PARTITION_CUST_DEVICE_SIZE := 872415232
88 | BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE := 3221225472
89 | BOARD_SUPER_PARTITION_VENDOR_DEVICE_SIZE := 1073741824
90 |
91 | BOARD_SUPER_PARTITION_GROUPS := qti_dynamic_partitions
92 | BOARD_QTI_DYNAMIC_PARTITIONS_PARTITION_LIST := odm product system system_ext vendor
93 | BOARD_QTI_DYNAMIC_PARTITIONS_SIZE := 5163188224 # (BOARD_SUPER_PARTITION_SIZE - 4194304) 4MiB overhead
94 |
95 | include vendor/lineage/config/BoardConfigReservedSize.mk
96 |
97 | TARGET_USERIMAGES_USE_EXT4 := true
98 | TARGET_USERIMAGES_USE_F2FS := true
99 | TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
100 |
101 | TARGET_COPY_OUT_ODM := odm
102 | TARGET_COPY_OUT_PRODUCT := product
103 | TARGET_COPY_OUT_SYSTEM_EXT := system_ext
104 | TARGET_COPY_OUT_VENDOR := vendor
105 |
106 | # Properties
107 | TARGET_ODM_PROP += $(COMMON_PATH)/odm.prop
108 | TARGET_PRODUCT_PROP += $(COMMON_PATH)/product.prop
109 | TARGET_SYSTEM_EXT_PROP += $(COMMON_PATH)/system_ext.prop
110 | TARGET_SYSTEM_PROP += $(COMMON_PATH)/system.prop
111 | TARGET_VENDOR_PROP += $(COMMON_PATH)/vendor.prop
112 |
113 | # QCOM
114 | BOARD_USES_QCOM_HARDWARE := true
115 | TARGET_FWK_SUPPORTS_FULL_VALUEADDS := true
116 |
117 | # Recovery
118 | TARGET_RECOVERY_PIXEL_FORMAT := BGRA_8888
119 |
120 | # Releasetools
121 | TARGET_RECOVERY_UPDATER_LIBS := librecovery_updater_xiaomi
122 | TARGET_RELEASETOOLS_EXTENSIONS := $(COMMON_PATH)
123 |
124 | # RIL
125 | ENABLE_VENDOR_RIL_SERVICE := true
126 |
127 | # Security patch level
128 | VENDOR_SECURITY_PATCH := 2020-12-01
129 |
130 | # SELinux
131 | include device/lineage/sepolicy/libperfmgr/sepolicy.mk
132 | include device/qcom/sepolicy_vndr/SEPolicy.mk
133 |
134 | BOARD_VENDOR_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor
135 | PRODUCT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private
136 | PRODUCT_PUBLIC_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/public
137 |
138 | # Verified Boot
139 | BOARD_AVB_ENABLE := true
140 | BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
141 | BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flags 2
142 | BOARD_AVB_RECOVERY_ALGORITHM := SHA256_RSA4096
143 | BOARD_AVB_RECOVERY_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
144 | BOARD_AVB_RECOVERY_ROLLBACK_INDEX := 1
145 | BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION := 1
146 |
147 | # WiFi
148 | BOARD_WLAN_DEVICE := qcwcn
149 | BOARD_HOSTAPD_DRIVER := NL80211
150 | BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
151 | BOARD_WPA_SUPPLICANT_DRIVER := NL80211
152 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
153 | WIFI_DRIVER_DEFAULT := qca_cld3
154 | WIFI_DRIVER_STATE_CTRL_PARAM := "/dev/wlan"
155 | WIFI_DRIVER_STATE_OFF := "OFF"
156 | WIFI_DRIVER_STATE_ON := "ON"
157 | WIFI_HIDL_FEATURE_DUAL_INTERFACE := true
158 | WIFI_HIDL_UNIFIED_SUPPLICANT_SERVICE_RC_ENTRY := true
159 | WPA_SUPPLICANT_VERSION := VER_0_8_X
160 |
161 | # Inherit from the proprietary version
162 | include vendor/xiaomi/sdm845-common/BoardConfigVendor.mk
163 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Copyright (C) 2018 - The LineageOS Project
2 |
3 | Common device tree for Xiaomi SDM845 based devices
4 | ==============
5 |
--------------------------------------------------------------------------------
/audio/audio_output_policy.conf:
--------------------------------------------------------------------------------
1 | # List of profiles for the output device session where stream is routed.
2 | # A stream opened with the inputs attributes which match the "flags" and
3 | # "formats" as specified in the profile is routed to a device at
4 | # sample rate specified under "sampling_rates" and bit width under
5 | # "bit_width" and the topology extracted from the acdb data against
6 | # the "app_type".
7 | #
8 | # the flags and formats are specified using the strings corresponding to
9 | # enums in audio.h and audio_policy.h. They are concatenated with "|"
10 | # without space or "\n".
11 | # the flags and formats should match the ones in "audio_policy.conf"
12 |
13 | outputs {
14 | default {
15 | flags AUDIO_OUTPUT_FLAG_PRIMARY
16 | formats AUDIO_FORMAT_PCM_16_BIT
17 | sampling_rates 48000
18 | bit_width 16
19 | app_type 69937
20 | }
21 | default_24bit {
22 | flags AUDIO_OUTPUT_FLAG_PRIMARY
23 | formats AUDIO_FORMAT_PCM_24_BIT_PACKED
24 | sampling_rates 48000
25 | bit_width 24
26 | app_type 69937
27 | }
28 | proaudio {
29 | flags AUDIO_OUTPUT_FLAG_FAST|AUDIO_OUTPUT_FLAG_RAW
30 | formats AUDIO_FORMAT_PCM_16_BIT
31 | sampling_rates 48000
32 | bit_width 16
33 | app_type 69943
34 | }
35 | voip_rx {
36 | flags AUDIO_OUTPUT_FLAG_VOIP_RX|AUDIO_OUTPUT_FLAG_DIRECT
37 | formats AUDIO_FORMAT_PCM_16_BIT
38 | sampling_rates 8000|16000|32000|48000
39 | bit_width 16
40 | app_type 69946
41 | }
42 | deep_buffer {
43 | flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER
44 | formats AUDIO_FORMAT_PCM_16_BIT
45 | sampling_rates 48000
46 | bit_width 16
47 | app_type 69936
48 | }
49 | deep_buffer_24 {
50 | flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER
51 | formats AUDIO_FORMAT_PCM_24_BIT_PACKED
52 | sampling_rates 48000
53 | bit_width 24
54 | app_type 69940
55 | }
56 | direct_pcm_16 {
57 | flags AUDIO_OUTPUT_FLAG_DIRECT
58 | formats AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_PCM_24_BIT_PACKED|AUDIO_FORMAT_PCM_8_24_BIT|AUDIO_FORMAT_PCM_32_BIT
59 | sampling_rates 44100|48000|88200|96000|176400|192000
60 | bit_width 16
61 | app_type 69936
62 | }
63 | direct_pcm_24 {
64 | flags AUDIO_OUTPUT_FLAG_DIRECT
65 | formats AUDIO_FORMAT_PCM_24_BIT_PACKED|AUDIO_FORMAT_PCM_8_24_BIT|AUDIO_FORMAT_PCM_32_BIT
66 | sampling_rates 44100|48000|88200|96000|176400|192000|352800|384000
67 | bit_width 24
68 | app_type 69940
69 | }
70 | direct_pcm_32 {
71 | flags AUDIO_OUTPUT_FLAG_DIRECT
72 | formats AUDIO_FORMAT_PCM_32_BIT
73 | sampling_rates 44100|48000|88200|96000|176400|192000|352800|384000
74 | bit_width 32
75 | app_type 69942
76 | }
77 | compress_passthrough {
78 | flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING|AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH
79 | formats AUDIO_FORMAT_DTS|AUDIO_FORMAT_DTS_HD|AUDIO_FORMAT_DSD
80 | sampling_rates 32000|44100|48000|88200|96000|176400|192000|352800
81 | bit_width 16
82 | app_type 69941
83 | }
84 | compress_offload_16 {
85 | flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
86 | formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_PCM_16_BIT_OFFLOAD|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_WMA|AUDIO_FORMAT_WMA_PRO|AUDIO_FORMAT_VORBIS|AUDIO_FORMAT_AAC_ADTS_LC|AUDIO_FORMAT_AAC_ADTS_HE_V1|AUDIO_FORMAT_AAC_ADTS_HE_V2
87 | sampling_rates 44100|48000|88200|96000|176400|192000
88 | bit_width 16
89 | app_type 69936
90 | }
91 | compress_offload_24 {
92 | flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
93 | formats AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_VORBIS|AUDIO_FORMAT_WMA|AUDIO_FORMAT_WMA_PRO
94 | sampling_rates 44100|48000|88200|96000|176400|192000
95 | bit_width 24
96 | app_type 69940
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/audio/audio_tuning_mixer_tavil.txt:
--------------------------------------------------------------------------------
1 | #ANC_TEST_P_PATH_MIC_STEREO Capture
2 | acdb_dev_id:85
3 | !Capture
4 | Txdevice:0
5 |
6 | enable
7 | AIF1_CAP Mixer SLIM TX7:1
8 | AIF1_CAP Mixer SLIM TX8:1
9 | CDC_IF TX7 MUX:DEC7
10 | ADC MUX7:DMIC
11 | DMIC MUX7:DMIC4
12 | CDC_IF TX8 MUX:DEC8
13 | ADC MUX8:DMIC
14 | DMIC MUX8:DMIC0
15 | SLIM_0_TX Channels:Two
16 | MultiMedia1 Mixer SLIM_0_TX:1
17 |
18 | disable
19 | MultiMedia1 Mixer SLIM_0_TX:0
20 | AIF1_CAP Mixer SLIM TX7:0
21 | AIF1_CAP Mixer SLIM TX8:0
22 | CDC_IF TX7 MUX:ZERO
23 | CDC_IF TX8 MUX:ZERO
24 | DMIC MUX7:ZERO
25 | DMIC MUX8:ZERO
26 |
27 | #ANC_TEST_S_PATH_MIC_STEREO Capture
28 | acdb_dev_id:88
29 | !Capture
30 | Txdevice:0
31 |
32 | enable
33 | AIF1_CAP Mixer SLIM TX7:1
34 | AIF1_CAP Mixer SLIM TX8:1
35 | CDC_IF TX7 MUX:DEC7
36 | ADC MUX7:ANC_FB_TUNE1
37 | ADC MUX10:DMIC
38 | DMIC MUX10:DMIC0
39 | CDC_IF TX8 MUX:DEC8
40 | ADC MUX8:ANC_FB_TUNE2
41 | ADC MUX12:DMIC
42 | DMIC MUX12:DMIC0
43 | ANC0 FB MUX:ANC_IN_EAR_SPKR
44 | ANC OUT EAR SPKR Enable Switch:1
45 | SLIM_0_TX Channels:Two
46 | MultiMedia1 Mixer SLIM_0_TX:1
47 |
48 | disable
49 | MultiMedia1 Mixer SLIM_0_TX:0
50 | AIF1_CAP Mixer SLIM TX7:0
51 | AIF1_CAP Mixer SLIM TX8:0
52 | CDC_IF TX7 MUX:ZERO
53 | CDC_IF TX8 MUX:ZERO
54 | ADC MUX7:DMIC
55 | ADC MUX8:DMIC
56 | DMIC MUX10:ZERO
57 | DMIC MUX12:ZERO
58 | ANC0 FB MUX:ZERO
59 | ANC OUT EAR SPKR Enable Switch:0
60 |
61 |
62 | #ANC_TEST_E_PATH_MIC_STEREO Capture
63 | acdb_dev_id:91
64 | !Capture
65 | Txdevice:0
66 |
67 | enable
68 | AIF1_CAP Mixer SLIM TX7:1
69 | AIF1_CAP Mixer SLIM TX8:1
70 | CDC_IF TX7 MUX:DEC7
71 | ADC MUX7:ANC_FB_TUNE1
72 | ADC MUX10:DMIC
73 | DMIC MUX10:DMIC4
74 | CDC_IF TX8 MUX:DEC8
75 | ADC MUX8:ANC_FB_TUNE2
76 | ADC MUX12:DMIC
77 | DMIC MUX12:DMIC4
78 | ANC0 FB MUX:ANC_IN_EAR_SPKR
79 | ANC OUT EAR SPKR Enable Switch:1
80 | SLIM_0_TX Channels:Two
81 | MultiMedia1 Mixer SLIM_0_TX:1
82 |
83 | disable
84 | MultiMedia1 Mixer SLIM_0_TX:0
85 | AIF1_CAP Mixer SLIM TX7:0
86 | AIF1_CAP Mixer SLIM TX8:0
87 | CDC_IF TX7 MUX:ZERO
88 | CDC_IF TX8 MUX:ZERO
89 | ADC MUX7:DMIC
90 | ADC MUX8:DMIC
91 | DMIC MUX10:ZERO
92 | DMIC MUX12:ZERO
93 | ANC0 FB MUX:ZERO
94 | ANC OUT EAR SPKR Enable Switch:0
95 |
96 |
97 | #ANC_TEST_S_PATH_HANDSET_SPKR_ANC_MONO
98 | acdb_dev_id:86
99 | !Playback
100 | Rxdevice:0
101 |
102 | enable
103 | ANC Function:ON
104 | SLIM RX0 MUX:AIF1_PB
105 | SLIM_0_RX Channels:One
106 | RX INT7_1 MIX1 INP0:RX0
107 | SpkrLeft SWR DAC_Port Switch:1
108 | ANC Slot:7
109 | ANC OUT EAR SPKR Enable Switch:1
110 | ANC SPKR PA Enable Switch:1
111 | SpkrLeft WSA PA Gain:G_6_DB
112 | SLIMBUS_0_RX Audio Mixer MultiMedia1:1
113 |
114 | disable
115 | SLIMBUS_0_RX Audio Mixer MultiMedia1:0
116 | SpkrLeft WSA PA Gain:G_0_DB
117 | ANC SPKR PA Enable Switch:0
118 | ANC OUT EAR SPKR Enable Switch:0
119 | SpkrLeft SWR DAC_Port Switch:0
120 | ANC Slot:0
121 | SLIM RX0 MUX:ZERO
122 | RX INT7_1 MIX1 INP0:ZERO
123 | ANC Function:OFF
124 |
125 | #ANC_TEST_E_PATH_HANDSET_SPKR_ANC_MONO
126 | acdb_dev_id:89
127 | !Playback
128 | Rxdevice:0
129 |
130 | enable
131 | ANC Function:ON
132 | SLIM RX0 MUX:AIF1_PB
133 | SLIM_0_RX Channels:One
134 | RX INT7_1 MIX1 INP0:RX0
135 | SpkrLeft SWR DAC_Port Switch:1
136 | ANC Slot:8
137 | ANC OUT EAR SPKR Enable Switch:1
138 | ANC SPKR PA Enable Switch:1
139 | SpkrLeft WSA PA Gain:G_6_DB
140 | SLIMBUS_0_RX Audio Mixer MultiMedia1:1
141 |
142 | disable
143 | SLIMBUS_0_RX Audio Mixer MultiMedia1:0
144 | SpkrLeft WSA PA Gain:G_0_DB
145 | ANC SPKR PA Enable Switch:0
146 | ANC OUT EAR SPKR Enable Switch:0
147 | SpkrLeft SWR DAC_Port Switch:0
148 | ANC Slot:0
149 | SLIM RX0 MUX:ZERO
150 | RX INT7_1 MIX1 INP0:ZERO
151 | ANC Function:OFF
152 |
153 | #RAS_TEST_SPKR_PHONE_SPKR_STEREO
154 | acdb_dev_id:136
155 | !Playback
156 | Rxdevice:0
157 |
158 | enable
159 | SLIM RX0 MUX:AIF1_PB
160 | SLIM RX1 MUX:AIF1_PB
161 | CDC_IF RX0 MUX:SLIM RX0
162 | CDC_IF RX1 MUX:SLIM RX1
163 | SLIM_0_RX Channels:Two
164 | RX INT7_1 MIX1 INP0:RX0
165 | RX INT8_1 MIX1 INP0:RX1
166 | COMP7 Switch:1
167 | COMP8 Switch:1
168 | SpkrLeft COMP Switch:1
169 | SpkrRight COMP Switch:1
170 | SpkrLeft BOOST Switch:1
171 | SpkrRight BOOST Switch:1
172 | SpkrLeft VISENSE Switch:1
173 | SpkrRight VISENSE Switch:1
174 | SpkrLeft SWR DAC_Port Switch:1
175 | SpkrRight SWR DAC_Port Switch:1
176 | SLIMBUS_0_RX Audio Mixer MultiMedia1:1
177 |
178 | disable
179 | SLIM RX0 MUX:ZERO
180 | SLIM RX1 MUX:ZERO
181 | RX INT7_1 MIX1 INP0:ZERO
182 | RX INT8_1 MIX1 INP0:ZERO
183 | COMP7 Switch:0
184 | COMP8 Switch:0
185 | SpkrLeft COMP Switch:0
186 | SpkrRight COMP Switch:0
187 | SpkrLeft BOOST Switch:0
188 | SpkrRight BOOST Switch:0
189 | SpkrLeft VISENSE Switch:0
190 | SpkrRight VISENSE Switch:0
191 | SpkrLeft SWR DAC_Port Switch:0
192 | SpkrRight SWR DAC_Port Switch:0
193 | SLIMBUS_0_RX Audio Mixer MultiMedia1:0
194 |
--------------------------------------------------------------------------------
/audio/bluetooth_hearing_aid_audio_policy_configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/audio/graphite_ipc_platform_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
35 |
36 |
38 |
39 |
40 |
42 |
43 |
44 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/audio/listen_platform_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/audio/usbv2_audio_policy_configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
40 |
42 |
44 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/config.fs:
--------------------------------------------------------------------------------
1 | [AID_VENDOR_QTI_DIAG]
2 | value:2901
3 |
4 | [AID_VENDOR_QDSS]
5 | value:2902
6 |
7 | [AID_VENDOR_RFS]
8 | value:2903
9 |
10 | [AID_VENDOR_RFS_SHARED]
11 | value:2904
12 |
13 | [AID_VENDOR_ADPL_ODL]
14 | value:2905
15 |
16 | [AID_VENDOR_QRTR]
17 | value:2906
18 |
19 | [AID_VENDOR_THERMAL]
20 | value:2907
21 |
22 | [vendor/bin/hw/android.hardware.bluetooth@1.0-service-qti]
23 | mode: 0755
24 | user: AID_BLUETOOTH
25 | group: AID_BLUETOOTH
26 | caps: BLOCK_SUSPEND NET_ADMIN
27 |
28 | [vendor/bin/pm-service]
29 | mode: 0755
30 | user: AID_SYSTEM
31 | group: AID_SYSTEM
32 | caps: NET_BIND_SERVICE SYS_BOOT
33 |
34 | [vendor/bin/pd-mapper]
35 | mode: 0755
36 | user: AID_SYSTEM
37 | group: AID_SYSTEM
38 | caps: NET_BIND_SERVICE
39 |
40 | [vendor/bin/imsdatadaemon]
41 | mode: 0755
42 | user: AID_RADIO
43 | group: AID_RADIO
44 | caps: NET_BIND_SERVICE
45 |
46 | [vendor/bin/ims_rtp_daemon]
47 | mode: 0755
48 | user: AID_RADIO
49 | group: AID_RADIO
50 | caps: NET_BIND_SERVICE
51 |
52 | [vendor/bin/imsrcsd]
53 | mode: 0755
54 | user: AID_RADIO
55 | group: AID_RADIO
56 | caps: WAKE_ALARM
57 |
58 | [vendor/bin/cnd]
59 | mode: 0755
60 | user: AID_SYSTEM
61 | group: AID_SYSTEM
62 | caps: NET_BIND_SERVICE BLOCK_SUSPEND NET_ADMIN
63 |
64 | [vendor/bin/slim_daemon]
65 | mode: 0755
66 | user: AID_GPS
67 | group: AID_GPS
68 | caps: NET_BIND_SERVICE
69 |
70 | [vendor/bin/loc_launcher]
71 | mode: 0755
72 | user: AID_GPS
73 | group: AID_GPS
74 | caps: SETUID SETGID
75 |
76 | [vendor/bin/xtwifi-client]
77 | mode: 0755
78 | user: AID_GPS
79 | group: AID_GPS
80 | caps: NET_BIND_SERVICE BLOCK_SUSPEND WAKE_ALARM
81 |
82 | [vendor/bin/sensors.qti]
83 | mode: 0755
84 | user: AID_SYSTEM
85 | group: AID_SYSTEM
86 | caps: NET_BIND_SERVICE
87 |
88 | [vendor/bin/glgps]
89 | mode: 0755
90 | user: AID_GPS
91 | group: AID_SYSTEM
92 | caps: BLOCK_SUSPEND
93 |
94 | [vendor/bin/ignss_2_0]
95 | mode: 0755
96 | user: AID_GPS
97 | group: AID_SYSTEM
98 | caps: BLOCK_SUSPEND
99 |
100 | [vendor/bin/lhd]
101 | mode: 0755
102 | user: AID_GPS
103 | group: AID_SYSTEM
104 | caps: BLOCK_SUSPEND
105 |
106 | [firmware/]
107 | mode: 0771
108 | user: AID_SYSTEM
109 | group: AID_SYSTEM
110 | caps: 0
111 |
112 | [firmware/image/*]
113 | mode: 0771
114 | user: AID_SYSTEM
115 | group: AID_SYSTEM
116 | caps: 0
117 |
118 | [vendor/firmware_mnt/image/*]
119 | mode: 0771
120 | user: AID_SYSTEM
121 | group: AID_SYSTEM
122 | caps: 0
123 |
124 | [bt_firmware/]
125 | mode: 0771
126 | user: AID_SYSTEM
127 | group: AID_SYSTEM
128 | caps: 0
129 |
130 | [persist/]
131 | mode: 0771
132 | user: AID_SYSTEM
133 | group: AID_SYSTEM
134 | caps: 0
135 |
136 | [dsp/]
137 | mode: 0771
138 | user: AID_MEDIA
139 | group: AID_MEDIA
140 | caps: 0
141 |
--------------------------------------------------------------------------------
/configs/public.libraries.txt:
--------------------------------------------------------------------------------
1 | libadsprpc.so
2 | libcdsprpc.so
3 | libsdsprpc.so
4 | libqvrservice_client.so
5 | libtzcom.so
6 | libfastcvopt.so
7 | liblistenjni.so
8 | liblistensoundmodel2.so
9 | libOpenCL.so
10 | libmpbase.so
11 | libmialgoengine.so
12 | libVDClearShot.so
13 | libVDDualCameraClearShot.so
14 | libHalSuperSensorServer.so
15 | libSuperSensor.so
16 | libSuperSensorCPU.so
17 | libSuperSensor_skel.so
18 | libarcsoft_beautyshot.so
19 | libarcsoft_dualcam_refocus.so
20 | libarcsoft_dualcam_refocus_rear_t.so
21 | libarcsoft_dualcam_refocus_rear_w.so
22 | libarcsoft_dualcam_refocus_front.so
23 | libarcsoft_portrait_lighting.so
24 | libarcsoft_portrait_lighting_c.so
25 | libarcsoft_high_dynamic_range.so
26 | libarcsoft_low_light_hdr.so
27 | libarcsoft_supernight.so
28 | libmisegment_front_845.so
29 | libalCFR.so
30 | libbeauty.so
31 | libprotobuf-cpp-full.so
32 | libprotobuf-cpp-lite.so
33 |
--------------------------------------------------------------------------------
/configs/qti_whitelist.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/configs/system_properties.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/extract-files.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3
2 | #
3 | # SPDX-FileCopyrightText: 2025 The LineageOS Project
4 | # SPDX-License-Identifier: Apache-2.0
5 | #
6 |
7 | from extract_utils.fixups_blob import (
8 | blob_fixup,
9 | blob_fixups_user_type,
10 | )
11 | from extract_utils.fixups_lib import (
12 | lib_fixups,
13 | lib_fixups_user_type,
14 | )
15 | from extract_utils.main import (
16 | ExtractUtils,
17 | ExtractUtilsModule,
18 | )
19 |
20 | namespace_imports = [
21 | 'device/xiaomi/sdm845-common',
22 | 'hardware/qcom-caf/sdm845',
23 | 'hardware/qcom-caf/wlan',
24 | 'hardware/xiaomi',
25 | 'vendor/qcom/opensource/commonsys-intf/display',
26 | 'vendor/qcom/opensource/commonsys/display',
27 | 'vendor/qcom/opensource/dataservices',
28 | 'vendor/qcom/opensource/display',
29 | ]
30 |
31 |
32 | def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs):
33 | return f'{lib}_{partition}' if partition == 'vendor' else None
34 |
35 |
36 | lib_fixups: lib_fixups_user_type = {
37 | **lib_fixups,
38 | (
39 | 'com.qualcomm.qti.dpm.api@1.0',
40 | 'com.qualcomm.qti.imscmservice@1.0',
41 | 'com.qualcomm.qti.imscmservice@2.0',
42 | 'com.qualcomm.qti.imscmservice@2.1',
43 | 'com.qualcomm.qti.imscmservice@2.2',
44 | 'com.qualcomm.qti.uceservice@2.0',
45 | 'com.qualcomm.qti.uceservice@2.1',
46 | 'libmmosal',
47 | 'vendor.qti.hardware.radio.ims@1.0',
48 | 'vendor.qti.hardware.radio.ims@1.1',
49 | 'vendor.qti.hardware.radio.ims@1.2',
50 | 'vendor.qti.hardware.radio.ims@1.3',
51 | 'vendor.qti.hardware.radio.ims@1.4',
52 | 'vendor.qti.hardware.wifidisplaysession@1.0',
53 | 'vendor.qti.ims.callinfo@1.0',
54 | 'vendor.qti.ims.rcsconfig@1.0',
55 | 'vendor.qti.imsrtpservice@2.0',
56 | 'vendor.qti.imsrtpservice@2.1',
57 | ): lib_fixup_vendor_suffix,
58 | }
59 |
60 | blob_fixups: blob_fixups_user_type = {
61 | 'system_ext/bin/wfdservice': blob_fixup()
62 | .add_needed('libwfdservice_shim.so'),
63 | 'system_ext/etc/permissions/qcrilhook.xml': blob_fixup()
64 | .regex_replace('/product/framework/', '/system_ext/framework/'),
65 | 'system_ext/etc/permissions/qti_libpermissions.xml': blob_fixup()
66 | .regex_replace('name="android.hidl.manager-V1.0-java', 'name="android.hidl.manager@1.0-java'),
67 | 'system_ext/lib/libwfdmmsrc_system.so': blob_fixup()
68 | .add_needed('libgui_shim.so'),
69 | 'system_ext/lib/libwfdservice.so': blob_fixup()
70 | .replace_needed('android.media.audio.common.types-V2-cpp.so', 'android.media.audio.common.types-V4-cpp.so'),
71 | 'system_ext/lib64/lib-imsvideocodec.so': blob_fixup()
72 | .add_needed('libgui_shim.so'),
73 | 'system_ext/lib64/libwfdnative.so': blob_fixup()
74 | .add_needed('libbinder_shim.so')
75 | .add_needed('libinput_shim.so'),
76 | 'vendor/bin/pm-service': blob_fixup()
77 | .add_needed('libutils-v33.so'),
78 | ('vendor/lib64/libwvhidl.so', 'vendor/lib64/mediadrm/libwvdrmengine.so'): blob_fixup()
79 | .add_needed('libcrypto_shim.so'),
80 | } # fmt: skip
81 |
82 | module = ExtractUtilsModule(
83 | 'sdm845-common',
84 | 'xiaomi',
85 | blob_fixups=blob_fixups,
86 | lib_fixups=lib_fixups,
87 | namespace_imports=namespace_imports,
88 | )
89 |
90 | if __name__ == '__main__':
91 | utils = ExtractUtils.device(module)
92 | utils.run()
93 |
--------------------------------------------------------------------------------
/init/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 The LineageOS Project
3 | // SPDX-License-Identifier: Apache-2.0
4 | //
5 |
6 | prebuilt_etc {
7 | name: "init.qcom.power.rc",
8 | src: "init.qcom.power.rc",
9 | sub_dir: "init/hw",
10 | soc_specific: true,
11 | }
12 |
13 | prebuilt_etc {
14 | name: "init.qcom.rc",
15 | src: "init.qcom.rc",
16 | sub_dir: "init/hw",
17 | soc_specific: true,
18 | }
19 |
20 | prebuilt_etc {
21 | name: "init.qcom.recovery.rc",
22 | src: "init.qcom.recovery.rc",
23 | sub_dir: "init",
24 | recovery: true,
25 | }
26 |
27 | prebuilt_etc {
28 | name: "ueventd.qcom.rc",
29 | filename: "ueventd.rc",
30 | src: "ueventd.qcom.rc",
31 | soc_specific: true,
32 | }
33 |
34 | sh_binary {
35 | name: "init.qcom.early_boot.sh",
36 | src: "init.qcom.early_boot.sh",
37 | soc_specific: true,
38 | }
39 |
40 | sh_binary {
41 | name: "init.qcom.post_boot.sh",
42 | src: "init.qcom.post_boot.sh",
43 | soc_specific: true,
44 | }
45 |
46 | sh_binary {
47 | name: "init.qcom.sensors.sh",
48 | src: "init.qcom.sensors.sh",
49 | soc_specific: true,
50 | }
51 |
52 | sh_binary {
53 | name: "init.qcom.sh",
54 | src: "init.qcom.sh",
55 | soc_specific: true,
56 | }
57 |
--------------------------------------------------------------------------------
/init/init.qcom.early_boot.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 |
3 | # Copyright (c) 2012-2013,2016,2018 The Linux Foundation. All rights reserved.
4 | #
5 | # Redistribution and use in source and binary forms, with or without
6 | # modification, are permitted provided that the following conditions are met:
7 | # * Redistributions of source code must retain the above copyright
8 | # notice, this list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright
10 | # notice, this list of conditions and the following disclaimer in the
11 | # documentation and/or other materials provided with the distribution.
12 | # * Neither the name of The Linux Foundation nor
13 | # the names of its contributors may be used to endorse or promote
14 | # products derived from this software without specific prior written
15 | # permission.
16 | #
17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 |
30 | export PATH=/vendor/bin
31 |
32 | # Set platform variables
33 | if [ -f /sys/devices/soc0/hw_platform ]; then
34 | soc_hwplatform=`cat /sys/devices/soc0/hw_platform` 2> /dev/null
35 | else
36 | soc_hwplatform=`cat /sys/devices/system/soc/soc0/hw_platform` 2> /dev/null
37 | fi
38 | if [ -f /sys/devices/soc0/soc_id ]; then
39 | soc_hwid=`cat /sys/devices/soc0/soc_id` 2> /dev/null
40 | else
41 | soc_hwid=`cat /sys/devices/system/soc/soc0/id` 2> /dev/null
42 | fi
43 | if [ -f /sys/devices/soc0/platform_version ]; then
44 | soc_hwver=`cat /sys/devices/soc0/platform_version` 2> /dev/null
45 | else
46 | soc_hwver=`cat /sys/devices/system/soc/soc0/platform_version` 2> /dev/null
47 | fi
48 |
49 | if [ -f /sys/class/drm/card0-DSI-1/modes ]; then
50 | echo "detect" > /sys/class/drm/card0-DSI-1/status
51 | mode_file=/sys/class/drm/card0-DSI-1/modes
52 | while read line; do
53 | fb_width=${line%%x*};
54 | break;
55 | done < $mode_file
56 | elif [ -f /sys/class/graphics/fb0/virtual_size ]; then
57 | res=`cat /sys/class/graphics/fb0/virtual_size` 2> /dev/null
58 | fb_width=${res%,*}
59 | fi
60 |
61 | log -t BOOT -p i "MSM target '$1', SoC '$soc_hwplatform', HwID '$soc_hwid', SoC ver '$soc_hwver'"
62 |
63 | # For DRM based display driver
64 | vbfile=/sys/module/drm/parameters/vblankoffdelay
65 | if [ -w $vbfile ]; then
66 | echo -1 > $vbfile
67 | else
68 | log -t DRM_BOOT -p w "file: '$vbfile' or perms doesn't exist"
69 | fi
70 |
71 | function set_density_by_fb() {
72 | #put default density based on width
73 | if [ -z $fb_width ]; then
74 | setprop vendor.display.lcd_density 320
75 | else
76 | if [ $fb_width -ge 1600 ]; then
77 | setprop vendor.display.lcd_density 640
78 | elif [ $fb_width -ge 1440 ]; then
79 | setprop vendor.display.lcd_density 560
80 | elif [ $fb_width -ge 1080 ]; then
81 | setprop vendor.display.lcd_density 480
82 | elif [ $fb_width -ge 720 ]; then
83 | setprop vendor.display.lcd_density 320 #for 720X1280 resolution
84 | elif [ $fb_width -ge 480 ]; then
85 | setprop vendor.display.lcd_density 240 #for 480X854 QRD resolution
86 | else
87 | setprop vendor.display.lcd_density 160
88 | fi
89 | fi
90 | }
91 |
92 | target=`getprop ro.board.platform`
93 | case "$target" in
94 | "sdm845")
95 | case "$soc_hwplatform" in
96 | *)
97 | if [ $fb_width -le 1600 ]; then
98 | setprop vendor.display.lcd_density 560
99 | else
100 | setprop vendor.display.lcd_density 640
101 | fi
102 | ;;
103 | esac
104 | ;;
105 | esac
106 |
107 | # Set default LCD density
108 | # Since LCD density has read only property, it will not overwrite previous set
109 | # property if any target is setting forcefully.
110 | set_density_by_fb
111 |
112 | # Setup display nodes & permissions
113 | # HDMI can be fb1 or fb2
114 | # Loop through the sysfs nodes and determine
115 | # the HDMI(dtv panel)
116 |
117 | function set_perms() {
118 | #Usage set_perms
119 | chown -h $2 $1
120 | chmod $3 $1
121 | }
122 |
123 | # Check for the type of driver FB or DRM
124 | fb_driver=/sys/class/graphics/fb0
125 | if [ -e "$fb_driver" ]
126 | then
127 | # Check for mdp caps
128 | file=/sys/class/graphics/fb0/mdp/caps
129 | if [ -f "$file" ]
130 | then
131 | setprop vendor.gralloc.disable_ubwc 1
132 | cat $file | while read line; do
133 | case "$line" in
134 | *"ubwc"*)
135 | setprop vendor.gralloc.enable_fb_ubwc 1
136 | setprop vendor.gralloc.disable_ubwc 0
137 | esac
138 | done
139 | fi
140 | else
141 | set_perms /sys/devices/virtual/hdcp/msm_hdcp/min_level_change system.graphics 0660
142 | fi
143 |
144 | boot_reason=`cat /proc/sys/kernel/boot_reason`
145 | reboot_reason=`getprop ro.boot.alarmboot`
146 | if [ "$boot_reason" = "3" ] || [ "$reboot_reason" = "true" ]; then
147 | setprop ro.vendor.alarm_boot true
148 | else
149 | setprop ro.vendor.alarm_boot false
150 | fi
151 |
152 | # Copy GPU frequencies to vendor property
153 | if [ -f /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies ]; then
154 | gpu_freq=`cat /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies` 2> /dev/null
155 | setprop vendor.gpu.available_frequencies "$gpu_freq"
156 | fi
157 |
--------------------------------------------------------------------------------
/init/init.qcom.post_boot.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 |
3 | # Copyright (c) 2012-2013, 2016-2018, The Linux Foundation. All rights reserved.
4 | #
5 | # Redistribution and use in source and binary forms, with or without
6 | # modification, are permitted provided that the following conditions are met:
7 | # * Redistributions of source code must retain the above copyright
8 | # notice, this list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright
10 | # notice, this list of conditions and the following disclaimer in the
11 | # documentation and/or other materials provided with the distribution.
12 | # * Neither the name of The Linux Foundation nor
13 | # the names of its contributors may be used to endorse or promote
14 | # products derived from this software without specific prior written
15 | # permission.
16 | #
17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 |
30 | # Let kernel know our image version/variant/crm_version
31 | if [ -f /sys/devices/soc0/select_image ]; then
32 | image_version="10:"
33 | image_version+=`getprop ro.build.id`
34 | image_version+=":"
35 | image_version+=`getprop ro.build.version.incremental`
36 | image_variant=`getprop ro.product.name`
37 | image_variant+="-"
38 | image_variant+=`getprop ro.build.type`
39 | oem_version=`getprop ro.build.version.codename`
40 | echo 10 > /sys/devices/soc0/select_image
41 | echo $image_version > /sys/devices/soc0/image_version
42 | echo $image_variant > /sys/devices/soc0/image_variant
43 | echo $oem_version > /sys/devices/soc0/image_crm_version
44 | fi
45 |
46 | # Parse misc partition path and set property
47 | misc_link=$(ls -l /dev/block/bootdevice/by-name/misc)
48 | real_path=${misc_link##*>}
49 | setprop persist.vendor.mmi.misc_dev_path $real_path
50 |
--------------------------------------------------------------------------------
/init/init.qcom.recovery.rc:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2017-2018,2020-2021 The Linux Foundation. All rights reserved.
2 | #
3 | # Redistribution and use in source and binary forms, with or without
4 | # modification, are permitted provided that the following conditions are met:
5 | # * Redistributions of source code must retain the above copyright
6 | # notice, this list of conditions and the following disclaimer.
7 | # * Redistributions in binary form must reproduce the above copyright
8 | # notice, this list of conditions and the following disclaimer in the
9 | # documentation and/or other materials provided with the distribution.
10 | # * Neither the name of The Linux Foundation nor
11 | # the names of its contributors may be used to endorse or promote
12 | # products derived from this software without specific prior written
13 | # permission.
14 | #
15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | #
27 |
28 | on init
29 | write /sys/class/backlight/panel0-backlight/brightness 200
30 | setprop sys.usb.configfs 1
31 |
32 | on property:ro.boot.usbcontroller=*
33 | setprop sys.usb.controller ${ro.boot.usbcontroller}
34 | wait /sys/bus/platform/devices/${ro.boot.usb.dwc3_msm:-a600000.ssusb}/mode
35 | write /sys/bus/platform/devices/${ro.boot.usb.dwc3_msm:-a600000.ssusb}/mode peripheral
36 | wait /sys/class/udc/${ro.boot.usbcontroller} 1
37 |
38 | on fs
39 | wait /dev/block/platform/soc/${ro.boot.bootdevice}
40 | symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice
41 |
--------------------------------------------------------------------------------
/init/init.qcom.sensors.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 |
3 | # Copyright (c) 2015,2018 The Linux Foundation. All rights reserved.
4 | #
5 | # Redistribution and use in source and binary forms, with or without
6 | # modification, are permitted provided that the following conditions are met:
7 | # * Redistributions of source code must retain the above copyright
8 | # notice, this list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright
10 | # notice, this list of conditions and the following disclaimer in the
11 | # documentation and/or other materials provided with the distribution.
12 | # * Neither the name of The Linux Foundation nor
13 | # the names of its contributors may be used to endorse or promote
14 | # products derived from this software without specific prior written
15 | # permission.
16 | #
17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 |
30 | #
31 | # Function to start sensors for SSC enabled platforms
32 | #
33 | start_sensors()
34 | {
35 |
36 | chmod -h 664 /persist/sensors/sensors_settings
37 | chown -h -R system.system /persist/sensors
38 | start vendor.sensors.qti
39 |
40 | # Only for SLPI
41 | if [ -c /dev/msm_dsps -o -c /dev/sensors ] ; then
42 | start vendor.sensors
43 | fi
44 | }
45 |
46 | start_sensors
47 |
--------------------------------------------------------------------------------
/init/init.qcom.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 |
3 | # Copyright (c) 2009-2016, The Linux Foundation. All rights reserved.
4 | #
5 | # Redistribution and use in source and binary forms, with or without
6 | # modification, are permitted provided that the following conditions are met:
7 | # * Redistributions of source code must retain the above copyright
8 | # notice, this list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright
10 | # notice, this list of conditions and the following disclaimer in the
11 | # documentation and/or other materials provided with the distribution.
12 | # * Neither the name of The Linux Foundation nor
13 | # the names of its contributors may be used to endorse or promote
14 | # products derived from this software without specific prior written
15 | # permission.
16 | #
17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 |
30 | start_msm_irqbalance()
31 | {
32 | if [ -f /vendor/bin/msm_irqbalance ]; then
33 | start vendor.msm_irqbalance
34 | fi
35 | }
36 |
37 | echo 1 > /proc/sys/net/ipv6/conf/default/accept_ra_defrtr
38 |
39 | start_msm_irqbalance
40 |
41 | #
42 | # Make modem config folder and copy firmware config to that folder for RIL
43 | #
44 | if [ -f /data/vendor/modem_config/ver_info.txt ]; then
45 | prev_version_info=`cat /data/vendor/modem_config/ver_info.txt`
46 | else
47 | prev_version_info=""
48 | fi
49 |
50 | cur_version_info=`cat /vendor/firmware_mnt/verinfo/ver_info.txt`
51 | if [ ! -f /vendor/firmware_mnt/verinfo/ver_info.txt -o "$prev_version_info" != "$cur_version_info" ]; then
52 | # add W for group recursively before delete
53 | chmod g+w -R /data/vendor/modem_config/*
54 | rm -rf /data/vendor/modem_config/*
55 | # preserve the read only mode for all subdir and files
56 | cp --preserve=m -dr /vendor/firmware_mnt/image/modem_pr/mcfg/configs/* /data/vendor/modem_config
57 | cp --preserve=m -d /vendor/firmware_mnt/verinfo/ver_info.txt /data/vendor/modem_config/
58 | cp --preserve=m -d /vendor/firmware_mnt/image/modem_pr/mbn_ota.txt /data/vendor/modem_config/
59 | # the group must be root, otherwise this script could not add "W" for group recursively
60 | chown -hR radio.root /data/vendor/modem_config/*
61 | fi
62 | chmod g-w /data/vendor/modem_config
63 | setprop ro.vendor.ril.mbn_copy_completed 1
64 |
65 | # Check build variant for printk logging
66 | # Current default minimum boot-time-default
67 | buildvariant=`getprop ro.build.type`
68 | case "$buildvariant" in
69 | "userdebug" | "eng")
70 | # Set default loglevel to KERN_INFO
71 | echo "6 6 1 7" > /proc/sys/kernel/printk
72 | ;;
73 | *)
74 | # Set default loglevel to KERN_WARNING
75 | echo "4 4 1 4" > /proc/sys/kernel/printk
76 | ;;
77 | esac
78 |
--------------------------------------------------------------------------------
/keylayout/sdm845-tavil-snd-card_Button_Jack.kl:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2014, The Linux Foundation. All rights reserved.
2 | #
3 | # Redistribution and use in source and binary forms, with or without
4 | # modification, are permitted provided that the following conditions are
5 | # met:
6 | # * Redistributions of source code must retain the above copyright
7 | # notice, this list of conditions and the following disclaimer.
8 | # * Redistributions in binary form must reproduce the above
9 | # copyright notice, this list of conditions and the following
10 | # disclaimer in the documentation and/or other materials provided
11 | # with the distribution.
12 | # * Neither the name of The Linux Foundation nor the names of its
13 | # contributors may be used to endorse or promote products derived
14 | # from this software without specific prior written permission.
15 | #
16 | # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 | # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 | key 226 HEADSETHOOK
29 | key 257 VOLUME_UP
30 | key 258 VOLUME_DOWN
31 |
--------------------------------------------------------------------------------
/lineage.dependencies:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "repository": "android_hardware_xiaomi",
4 | "target_path": "hardware/xiaomi"
5 | },
6 | {
7 | "repository": "android_kernel_xiaomi_sdm845",
8 | "target_path": "kernel/xiaomi/sdm845"
9 | }
10 | ]
11 |
--------------------------------------------------------------------------------
/livedisplay/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 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: "vendor.lineage.livedisplay@2.0-service.xiaomi_sdm845",
18 | init_rc: ["vendor.lineage.livedisplay@2.0-service.xiaomi_sdm845.rc"],
19 | defaults: ["hidl_defaults"],
20 | relative_install_path: "hw",
21 | srcs: [
22 | "SunlightEnhancement.cpp",
23 | "service.cpp",
24 | ],
25 | vendor: true,
26 | shared_libs: [
27 | "libbase",
28 | "libbinder",
29 | "libhidlbase",
30 | "libutils",
31 | "vendor.lineage.livedisplay@2.0",
32 | ],
33 | }
34 |
--------------------------------------------------------------------------------
/livedisplay/SunlightEnhancement.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 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 "SunlightEnhancementService"
18 |
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #include "SunlightEnhancement.h"
27 |
28 | namespace vendor {
29 | namespace lineage {
30 | namespace livedisplay {
31 | namespace V2_0 {
32 | namespace implementation {
33 |
34 | static constexpr const char* kDispParamPath =
35 | "/sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/disp_param";
36 | static constexpr const char* kHbmStatusPath =
37 | "/sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/hbm_status";
38 |
39 | static constexpr const char* kDispParamHbmOff = "0xF0000";
40 | static constexpr const char* kDispParamHbmOn = "0x10000";
41 | static constexpr const char* kDispParamHbmFodOff = "0xE0000";
42 | static constexpr const char* kDispParamHbmFodOn = "0x20000";
43 |
44 | bool hasAmoledPanel() {
45 | std::string device = android::base::GetProperty("ro.product.device", "");
46 | return device == "dipper" || device == "equuleus" ||
47 | device == "perseus" || device == "ursa";
48 | }
49 |
50 | bool hasFingerprintOnDisplay() {
51 | std::string device = android::base::GetProperty("ro.product.device", "");
52 | return device == "equuleus" || device == "ursa";
53 | }
54 |
55 | bool SunlightEnhancement::isSupported() {
56 | if (hasAmoledPanel()) {
57 | std::ofstream disp_param_file(kDispParamPath);
58 | std::ifstream hbm_status_file(kHbmStatusPath);
59 | if (!disp_param_file.is_open()) {
60 | LOG(ERROR) << "Failed to open " << kDispParamPath << ", error=" << errno
61 | << " (" << strerror(errno) << ")";
62 | }
63 | if (!hbm_status_file.is_open()) {
64 | LOG(ERROR) << "Failed to open " << kHbmStatusPath << ", error=" << errno
65 | << " (" << strerror(errno) << ")";
66 | }
67 | return !disp_param_file.fail() && !hbm_status_file.fail();
68 | }
69 | return false;
70 | }
71 |
72 | Return SunlightEnhancement::isEnabled() {
73 | std::ifstream hbm_status_file(kHbmStatusPath);
74 | int result = -1;
75 | hbm_status_file >> result;
76 | return !hbm_status_file.fail() && result > 0;
77 | }
78 |
79 | Return SunlightEnhancement::setEnabled(bool enabled) {
80 | std::ofstream disp_param_file(kDispParamPath);
81 | if (hasFingerprintOnDisplay()) {
82 | disp_param_file << (enabled ? kDispParamHbmFodOn : kDispParamHbmFodOff);
83 | } else {
84 | disp_param_file << (enabled ? kDispParamHbmOn : kDispParamHbmOff);
85 | }
86 | LOG(DEBUG) << "setEnabled fail " << disp_param_file.fail();
87 | return !disp_param_file.fail();
88 | }
89 |
90 | } // namespace implementation
91 | } // namespace V2_0
92 | } // namespace livedisplay
93 | } // namespace lineage
94 | } // namespace vendor
95 |
--------------------------------------------------------------------------------
/livedisplay/SunlightEnhancement.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 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 VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H
18 | #define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace vendor {
25 | namespace lineage {
26 | namespace livedisplay {
27 | namespace V2_0 {
28 | namespace implementation {
29 |
30 | using ::android::hardware::Return;
31 | using ::android::hardware::Void;
32 | using ::android::sp;
33 |
34 | class SunlightEnhancement : public ISunlightEnhancement {
35 | public:
36 | bool isSupported();
37 |
38 | // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
39 | Return isEnabled() override;
40 | Return setEnabled(bool enabled) override;
41 | };
42 |
43 | } // namespace implementation
44 | } // namespace V2_0
45 | } // namespace livedisplay
46 | } // namespace lineage
47 | } // namespace vendor
48 |
49 | #endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H
50 |
--------------------------------------------------------------------------------
/livedisplay/service.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 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 "lineage.livedisplay@2.0-service.xiaomi_sdm845"
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include "SunlightEnhancement.h"
24 |
25 | using android::OK;
26 | using android::sp;
27 | using android::status_t;
28 | using android::hardware::configureRpcThreadpool;
29 | using android::hardware::joinRpcThreadpool;
30 |
31 | using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement;
32 | using ::vendor::lineage::livedisplay::V2_0::implementation::SunlightEnhancement;
33 |
34 | int main() {
35 | sp sunlightEnhancement;
36 | status_t status;
37 |
38 | LOG(INFO) << "LiveDisplay HAL custom service is starting.";
39 |
40 | sunlightEnhancement = new SunlightEnhancement();
41 | if (sunlightEnhancement == nullptr) {
42 | LOG(ERROR) << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface,"
43 | << "exiting.";
44 | goto shutdown;
45 | }
46 |
47 | if (!sunlightEnhancement->isSupported()) {
48 | LOG(ERROR) << "SunlightEnhancement Iface is not supported, gracefully bailing out.";
49 | return 1;
50 | }
51 |
52 | configureRpcThreadpool(1, true /*callerWillJoin*/);
53 |
54 | status = sunlightEnhancement->registerAsService();
55 | if (status != OK) {
56 | LOG(ERROR) << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
57 | << status << ")";
58 | goto shutdown;
59 | }
60 |
61 | LOG(INFO) << "LiveDisplay HAL custom service is ready.";
62 | joinRpcThreadpool();
63 | // Should not pass this line
64 |
65 | shutdown:
66 | // In normal operation, we don't expect the thread pool to shutdown
67 | LOG(ERROR) << "LiveDisplay HAL custom service is shutting down.";
68 | return 1;
69 | }
70 |
--------------------------------------------------------------------------------
/livedisplay/vendor.lineage.livedisplay@2.0-service.xiaomi_sdm845.rc:
--------------------------------------------------------------------------------
1 | on boot
2 | chown system system /sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/disp_param
3 | chown system system /sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/hbm_status
4 |
5 | service vendor.livedisplay-hal-2-0 /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.xiaomi_sdm845
6 | class hal
7 | user system
8 | group system
9 |
--------------------------------------------------------------------------------
/odm.prop:
--------------------------------------------------------------------------------
1 | # QC framework value-adds
2 | ro.vendor.qti.va_odm.support=1
3 |
--------------------------------------------------------------------------------
/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 | - restart
23 | - restart_recovery
24 | - restart_bootloader
25 | - restart_fastboot
26 |
27 |
28 |
--------------------------------------------------------------------------------
/overlay-lineage/packages/apps/Dialer/java/com/android/dialer/callrecord/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | true
19 | 4
20 |
21 |
--------------------------------------------------------------------------------
/overlay/frameworks/base/core/res/res/values-mcc302-mnc370/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 | - %s
24 | - %s Wi-Fi
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/overlay/frameworks/base/core/res/res/values-mcc302-mnc720/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 | - %s
24 | - %s Wi-Fi
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | true
22 |
23 |
--------------------------------------------------------------------------------
/overlay/frameworks/base/packages/SystemUI/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
22 |
23 |
24 | true
25 |
26 |
27 |
--------------------------------------------------------------------------------
/overlay/packages/apps/Settings/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
23 |
24 | - 0
25 | - -1
26 | - -1
27 |
28 |
29 |
--------------------------------------------------------------------------------
/overlay/packages/services/Telephony/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
21 |
22 |
24 |
25 |
26 | org.codeaurora.ims
27 |
28 |
29 | org.codeaurora.ims
30 |
31 |
--------------------------------------------------------------------------------
/parts/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2017-2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | android_app {
8 | name: "XiaomiParts",
9 |
10 | srcs: ["src/**/*.java"],
11 | resource_dirs: ["res"],
12 | certificate: "platform",
13 | platform_apis: true,
14 | privileged: true,
15 | system_ext_specific: true,
16 |
17 | static_libs: [
18 | "org.lineageos.settings.resources",
19 | ],
20 |
21 | optimize: {
22 | proguard_flags_files: ["proguard.flags"],
23 | },
24 | }
25 |
--------------------------------------------------------------------------------
/parts/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
49 |
50 |
51 |
52 |
54 |
55 |
56 |
60 |
61 |
62 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
76 |
77 |
78 |
79 |
80 |
83 |
86 |
89 |
92 |
95 |
96 |
97 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/parts/proguard.flags:
--------------------------------------------------------------------------------
1 | -keep class org.lineageos.settings.dirac.* {
2 | *;
3 | }
4 |
5 | -keep class org.lineageos.settings.doze.* {
6 | *;
7 | }
8 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_hand.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_pickup.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_pocket.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_settings_thermal.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_benchmark.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_browser.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_dialer.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_gaming.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/parts/res/drawable/ic_thermal_streaming.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/parts/res/layout/thermal_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
--------------------------------------------------------------------------------
/parts/res/layout/thermal_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
26 |
27 |
34 |
35 |
40 |
41 |
52 |
53 |
57 |
58 |
59 |
60 |
67 |
68 |
--------------------------------------------------------------------------------
/parts/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | - @string/dirac_headset_default
21 | - @string/dirac_headset_earbuds
22 | - @string/dirac_headset_in_ear_2013
23 | - @string/dirac_headset_piston_1
24 | - @string/dirac_headset_general
25 | - @string/dirac_headset_general_inear
26 | - @string/dirac_headset_piston_basic
27 | - @string/dirac_headset_piston_2
28 | - @string/dirac_headset_piston_standard
29 | - @string/dirac_headset_headphone
30 | - @string/dirac_headset_piston_youth
31 | - @string/dirac_headset_piston_color
32 | - @string/dirac_headset_in_ear
33 | - @string/dirac_headset_capsule
34 | - @string/dirac_headset_in_ear_pro
35 | - @string/dirac_headset_comfort
36 | - @string/dirac_headset_reduction_noise
37 | - @string/dirac_headset_cancelling
38 | - @string/dirac_headset_half_in_ear
39 | - @string/dirac_headset_in_ear2
40 | - @string/dirac_headset_earphone_basic
41 | - @string/dirac_headset_earphone
42 |
43 |
44 |
45 | - 0
46 | - 1
47 | - 2
48 | - 3
49 | - 5
50 | - 6
51 | - 7
52 | - 8
53 | - 9
54 | - 10
55 | - 11
56 | - 12
57 | - 13
58 | - 14
59 | - 15
60 | - 16
61 | - 17
62 | - 18
63 | - 19
64 | - 20
65 | - 21
66 | - 22
67 | - 23
68 |
69 |
70 |
71 |
72 | - @string/dirac_preset_default
73 | - @string/dirac_preset_rock
74 | - @string/dirac_preset_jazz
75 | - @string/dirac_preset_pop
76 | - @string/dirac_preset_classical
77 | - @string/dirac_preset_hiphop
78 | - @string/dirac_preset_blues
79 | - @string/dirac_preset_electronic
80 | - @string/dirac_preset_country
81 | - @string/dirac_preset_dance
82 | - @string/dirac_preset_metal
83 |
84 |
85 |
86 | - "0,0,0,0,0,0,0"
87 | - "4,2,-2,0,-2,-2,4"
88 | - "0,0,0,-2,-3,0,0"
89 | - "0,-3,-5,0,0,-3,0"
90 | - "0,0,0,0,3,6,6"
91 | - "3,3,-3,0,-3,0,2"
92 | - "2,4,-6,4,0,1,2"
93 | - "3,3,-1,0,-3,0,0"
94 | - "0,0,-2,-2,2,2,0"
95 | - "0,4,2,0,-2,-2,4"
96 | - "2,0,0,-2,-4,0,0"
97 |
98 |
99 |
--------------------------------------------------------------------------------
/parts/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | Enable dirac
20 | Dirac sound enhancer
21 | Headset type
22 | Sound preset
23 |
24 |
25 | Default
26 | Mi Earbuds
27 | Mi In-Ear (2013)
28 | Mi Piston 1
29 | General Earbuds
30 | General In-Ear
31 | Basic Edition
32 | Mi Piston 2
33 | Mi Piston 3
34 | Mi Headphones
35 | Youth Edition
36 | Color Edition
37 | Mi In-Ear
38 | Mi Capsule
39 | Mi In-Ear Pro
40 | Mi Comfort
41 | Mi Noise Cancelling (Type-C)
42 | Mi Noise Cancelling (3.5mm)
43 | Mi Half In-Ear
44 | Mi In-Ear 2
45 | Mi Earphones Basic
46 | Mi Earphones
47 |
48 |
49 | Default
50 | Rock
51 | Jazz
52 | Pop
53 | Classical
54 | Hip Hop
55 | Blues
56 | Electronic
57 | Country
58 | Dance
59 | Metal
60 |
61 |
62 | Thermal profiles
63 | Adjust per-app thermal profiles for optimum performance
64 | Default
65 | Benchmark
66 | Browser
67 | Camera
68 | Dialer
69 | Gaming
70 | Streaming
71 |
72 |
--------------------------------------------------------------------------------
/parts/res/xml/dirac_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
21 |
25 |
26 |
33 |
34 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/parts/res/xml/doze_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
21 |
22 |
25 |
26 |
30 |
31 |
37 |
38 |
41 |
42 |
48 |
49 |
50 |
51 |
54 |
55 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/BootCompletedReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The CyanogenMod Project
3 | * 2017-2020 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.settings;
19 |
20 | import android.content.BroadcastReceiver;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.util.Log;
24 |
25 | import org.lineageos.settings.dirac.DiracUtils;
26 | import org.lineageos.settings.doze.DozeUtils;
27 | import org.lineageos.settings.thermal.ThermalUtils;
28 |
29 | public class BootCompletedReceiver extends BroadcastReceiver {
30 |
31 | private static final boolean DEBUG = false;
32 | private static final String TAG = "XiaomiParts";
33 |
34 | @Override
35 | public void onReceive(final Context context, Intent intent) {
36 | if (DEBUG) Log.d(TAG, "Received boot completed intent");
37 | DiracUtils.initialize();
38 | DozeUtils.checkDozeService(context);
39 | ThermalUtils.startService(context);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/dirac/DiracActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018,2021-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 org.lineageos.settings.dirac;
18 |
19 | import android.os.Bundle;
20 |
21 | import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
22 |
23 | public class DiracActivity extends CollapsingToolbarBaseActivity {
24 |
25 | private static final String TAG_DIRAC = "dirac";
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 |
31 | getFragmentManager().beginTransaction().replace(
32 | com.android.settingslib.collapsingtoolbar.R.id.content_frame,
33 | new DiracSettingsFragment(), TAG_DIRAC).commit();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/dirac/DiracSettingsFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018,2020-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 | package org.lineageos.settings.dirac;
18 |
19 | import android.os.Bundle;
20 | import android.widget.CompoundButton;
21 |
22 | import androidx.preference.ListPreference;
23 | import androidx.preference.Preference;
24 | import androidx.preference.PreferenceCategory;
25 | import androidx.preference.PreferenceFragment;
26 |
27 | import com.android.settingslib.widget.MainSwitchPreference;
28 |
29 | import org.lineageos.settings.R;
30 |
31 | public class DiracSettingsFragment extends PreferenceFragment implements
32 | Preference.OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener {
33 |
34 | private static final String PREF_ENABLE = "dirac_enable";
35 | private static final String PREF_HEADSET = "dirac_headset_pref";
36 | private static final String PREF_PRESET = "dirac_preset_pref";
37 |
38 | private MainSwitchPreference mSwitchBar;
39 |
40 | private ListPreference mHeadsetType;
41 | private ListPreference mPreset;
42 |
43 | @Override
44 | public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
45 | addPreferencesFromResource(R.xml.dirac_settings);
46 |
47 | DiracUtils.initialize();
48 | boolean enhancerEnabled = DiracUtils.isDiracEnabled(getActivity());
49 |
50 | mSwitchBar = (MainSwitchPreference) findPreference(PREF_ENABLE);
51 | mSwitchBar.addOnSwitchChangeListener(this);
52 | mSwitchBar.setChecked(enhancerEnabled);
53 |
54 | mHeadsetType = (ListPreference) findPreference(PREF_HEADSET);
55 | mHeadsetType.setOnPreferenceChangeListener(this);
56 | mHeadsetType.setEnabled(enhancerEnabled);
57 |
58 | mPreset = (ListPreference) findPreference(PREF_PRESET);
59 | mPreset.setOnPreferenceChangeListener(this);
60 | mPreset.setEnabled(enhancerEnabled);
61 | }
62 |
63 | @Override
64 | public boolean onPreferenceChange(Preference preference, Object newValue) {
65 | switch (preference.getKey()) {
66 | case PREF_HEADSET:
67 | DiracUtils.setHeadsetType(Integer.parseInt(newValue.toString()));
68 | return true;
69 | case PREF_PRESET:
70 | DiracUtils.setLevel(String.valueOf(newValue));
71 | return true;
72 | default:
73 | return false;
74 | }
75 | }
76 |
77 | @Override
78 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
79 | mSwitchBar.setChecked(isChecked);
80 |
81 | DiracUtils.setMusic(isChecked);
82 |
83 | mHeadsetType.setEnabled(isChecked);
84 | mPreset.setEnabled(isChecked);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/dirac/DiracSound.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 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 | package org.lineageos.settings.dirac;
18 |
19 | import android.media.audiofx.AudioEffect;
20 |
21 | import java.util.UUID;
22 |
23 | public class DiracSound extends AudioEffect {
24 |
25 | private static final int DIRACSOUND_PARAM_HEADSET_TYPE = 1;
26 | private static final int DIRACSOUND_PARAM_EQ_LEVEL = 2;
27 | private static final int DIRACSOUND_PARAM_MUSIC = 4;
28 |
29 | private static final UUID EFFECT_TYPE_DIRACSOUND =
30 | UUID.fromString("e069d9e0-8329-11df-9168-0002a5d5c51b");
31 | private static final String TAG = "DiracSound";
32 |
33 | public DiracSound(int priority, int audioSession) {
34 | super(EFFECT_TYPE_NULL, EFFECT_TYPE_DIRACSOUND, priority, audioSession);
35 | }
36 |
37 | public int getMusic() throws IllegalStateException,
38 | IllegalArgumentException, UnsupportedOperationException {
39 | int[] value = new int[1];
40 | checkStatus(getParameter(DIRACSOUND_PARAM_MUSIC, value));
41 | return value[0];
42 | }
43 |
44 | public void setMusic(int enable) throws IllegalStateException,
45 | IllegalArgumentException, UnsupportedOperationException {
46 | checkStatus(setParameter(DIRACSOUND_PARAM_MUSIC, enable));
47 | }
48 |
49 | public int getHeadsetType() throws IllegalStateException,
50 | IllegalArgumentException, UnsupportedOperationException {
51 | int[] value = new int[1];
52 | checkStatus(getParameter(DIRACSOUND_PARAM_HEADSET_TYPE, value));
53 | return value[0];
54 | }
55 |
56 | public void setHeadsetType(int type) throws IllegalStateException,
57 | IllegalArgumentException, UnsupportedOperationException {
58 | checkStatus(setParameter(DIRACSOUND_PARAM_HEADSET_TYPE, type));
59 | }
60 |
61 | public float getLevel(int band) throws IllegalStateException,
62 | IllegalArgumentException, UnsupportedOperationException {
63 | int[] param = new int[2];
64 | byte[] value = new byte[10];
65 | param[0] = DIRACSOUND_PARAM_EQ_LEVEL;
66 | param[1] = band;
67 | checkStatus(getParameter(param, value));
68 | return new Float(new String(value)).floatValue();
69 | }
70 |
71 | public void setLevel(int band, float level) throws IllegalStateException,
72 | IllegalArgumentException, UnsupportedOperationException {
73 | checkStatus(setParameter(new int[]{DIRACSOUND_PARAM_EQ_LEVEL, band},
74 | String.valueOf(level).getBytes()));
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/dirac/DiracUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 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 |
17 | package org.lineageos.settings.dirac;
18 |
19 | import android.content.Context;
20 |
21 | public final class DiracUtils {
22 |
23 | protected static DiracSound mDiracSound;
24 | private static boolean mInitialized;
25 |
26 | public static void initialize() {
27 | if (!mInitialized) {
28 | mDiracSound = new DiracSound(0, 0);
29 | mDiracSound.setMusic(mDiracSound.getMusic());
30 | mDiracSound.setHeadsetType(mDiracSound.getHeadsetType());
31 | setLevel(getLevel());
32 | mInitialized = true;
33 | }
34 | }
35 |
36 | protected static void setMusic(boolean enable) {
37 | mDiracSound.setMusic(enable ? 1 : 0);
38 | }
39 |
40 | protected static boolean isDiracEnabled(Context context) {
41 | return mDiracSound != null && mDiracSound.getMusic() == 1;
42 | }
43 |
44 | protected static void setLevel(String preset) {
45 | String[] level = preset.split("\\s*,\\s*");
46 |
47 | for (int band = 0; band <= level.length - 1; band++) {
48 | mDiracSound.setLevel(band, Float.valueOf(level[band]));
49 | }
50 | }
51 |
52 | protected static String getLevel() {
53 | String selected = "";
54 | for (int band = 0; band <= 6; band++) {
55 | int temp = (int) mDiracSound.getLevel(band);
56 | selected += String.valueOf(temp);
57 | if (band != 6) selected += ",";
58 | }
59 | return selected;
60 | }
61 |
62 | protected static void setHeadsetType(int paramInt) {
63 | mDiracSound.setHeadsetType(paramInt);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/doze/DozeService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The CyanogenMod Project
3 | * 2017-2018 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.settings.doze;
19 |
20 | import android.app.Service;
21 | import android.content.BroadcastReceiver;
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.content.IntentFilter;
25 | import android.os.IBinder;
26 | import android.util.Log;
27 |
28 | public class DozeService extends Service {
29 | private static final String TAG = "DozeService";
30 | private static final boolean DEBUG = false;
31 |
32 | private ProximitySensor mProximitySensor;
33 | private PickupSensor mPickupSensor;
34 |
35 | @Override
36 | public void onCreate() {
37 | if (DEBUG) Log.d(TAG, "Creating service");
38 | mProximitySensor = new ProximitySensor(this);
39 | mPickupSensor = new PickupSensor(this);
40 |
41 | IntentFilter screenStateFilter = new IntentFilter();
42 | screenStateFilter.addAction(Intent.ACTION_SCREEN_ON);
43 | screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
44 | registerReceiver(mScreenStateReceiver, screenStateFilter);
45 | }
46 |
47 | @Override
48 | public int onStartCommand(Intent intent, int flags, int startId) {
49 | if (DEBUG) Log.d(TAG, "Starting service");
50 | return START_STICKY;
51 | }
52 |
53 | @Override
54 | public void onDestroy() {
55 | if (DEBUG) Log.d(TAG, "Destroying service");
56 | super.onDestroy();
57 | this.unregisterReceiver(mScreenStateReceiver);
58 | mProximitySensor.disable();
59 | mPickupSensor.disable();
60 | }
61 |
62 | @Override
63 | public IBinder onBind(Intent intent) {
64 | return null;
65 | }
66 |
67 | private void onDisplayOn() {
68 | if (DEBUG) Log.d(TAG, "Display on");
69 | if (DozeUtils.isPickUpEnabled(this)) {
70 | mPickupSensor.disable();
71 | }
72 | if (DozeUtils.isHandwaveGestureEnabled(this) ||
73 | DozeUtils.isPocketGestureEnabled(this)) {
74 | mProximitySensor.disable();
75 | }
76 | }
77 |
78 | private void onDisplayOff() {
79 | if (DEBUG) Log.d(TAG, "Display off");
80 | if (DozeUtils.isPickUpEnabled(this)) {
81 | mPickupSensor.enable();
82 | }
83 | if (DozeUtils.isHandwaveGestureEnabled(this) ||
84 | DozeUtils.isPocketGestureEnabled(this)) {
85 | mProximitySensor.enable();
86 | }
87 | }
88 |
89 | private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
90 | @Override
91 | public void onReceive(Context context, Intent intent) {
92 | if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
93 | onDisplayOn();
94 | } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
95 | onDisplayOff();
96 | }
97 | }
98 | };
99 | }
100 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/doze/DozeSettingsActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015-2016 The CyanogenMod Project
3 | * 2017,2021-2022 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.settings.doze;
19 |
20 | import android.os.Bundle;
21 |
22 | import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
23 |
24 | public class DozeSettingsActivity extends CollapsingToolbarBaseActivity {
25 |
26 | private static final String TAG_DOZE = "doze";
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 |
32 | getFragmentManager().beginTransaction().replace(
33 | com.android.settingslib.collapsingtoolbar.R.id.content_frame,
34 | new DozeSettingsFragment(), TAG_DOZE).commit();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/doze/PickupSensor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The CyanogenMod Project
3 | * 2017-2018 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.settings.doze;
19 |
20 | import android.content.Context;
21 | import android.hardware.Sensor;
22 | import android.hardware.SensorEvent;
23 | import android.hardware.SensorEventListener;
24 | import android.hardware.SensorManager;
25 | import android.os.SystemClock;
26 | import android.util.Log;
27 |
28 | import java.util.concurrent.ExecutorService;
29 | import java.util.concurrent.Executors;
30 | import java.util.concurrent.Future;
31 |
32 | public class PickupSensor implements SensorEventListener {
33 |
34 | private static final boolean DEBUG = false;
35 | private static final String TAG = "PickupSensor";
36 |
37 | private static final int MIN_PULSE_INTERVAL_MS = 2500;
38 |
39 | private SensorManager mSensorManager;
40 | private Sensor mSensor;
41 | private Context mContext;
42 | private ExecutorService mExecutorService;
43 |
44 | private long mEntryTimestamp;
45 |
46 | public PickupSensor(Context context) {
47 | mContext = context;
48 | mSensorManager = mContext.getSystemService(SensorManager.class);
49 | mSensor = DozeUtils.getSensor(mSensorManager, "xiaomi.sensor.pickup");
50 | mExecutorService = Executors.newSingleThreadExecutor();
51 | }
52 |
53 | private Future> submit(Runnable runnable) {
54 | return mExecutorService.submit(runnable);
55 | }
56 |
57 | @Override
58 | public void onSensorChanged(SensorEvent event) {
59 | if (DEBUG) Log.d(TAG, "Got sensor event: " + event.values[0]);
60 |
61 | long delta = SystemClock.elapsedRealtime() - mEntryTimestamp;
62 | if (delta < MIN_PULSE_INTERVAL_MS) {
63 | return;
64 | }
65 |
66 | mEntryTimestamp = SystemClock.elapsedRealtime();
67 |
68 | if (event.values[0] == 1) {
69 | DozeUtils.launchDozePulse(mContext);
70 | }
71 | }
72 |
73 | @Override
74 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
75 | /* Empty */
76 | }
77 |
78 | protected void enable() {
79 | if (DEBUG) Log.d(TAG, "Enabling");
80 | submit(() -> {
81 | mSensorManager.registerListener(this, mSensor,
82 | SensorManager.SENSOR_DELAY_NORMAL);
83 | mEntryTimestamp = SystemClock.elapsedRealtime();
84 | });
85 | }
86 |
87 | protected void disable() {
88 | if (DEBUG) Log.d(TAG, "Disabling");
89 | submit(() -> {
90 | mSensorManager.unregisterListener(this, mSensor);
91 | });
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/doze/ProximitySensor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The CyanogenMod Project
3 | * 2017-2018 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.settings.doze;
19 |
20 | import android.content.Context;
21 | import android.hardware.Sensor;
22 | import android.hardware.SensorEvent;
23 | import android.hardware.SensorEventListener;
24 | import android.hardware.SensorManager;
25 | import android.util.Log;
26 |
27 | import java.util.concurrent.ExecutorService;
28 | import java.util.concurrent.Executors;
29 | import java.util.concurrent.Future;
30 |
31 | public class ProximitySensor implements SensorEventListener {
32 |
33 | private static final boolean DEBUG = false;
34 | private static final String TAG = "ProximitySensor";
35 |
36 | // Maximum time for the hand to cover the sensor: 1s
37 | private static final int HANDWAVE_MAX_DELTA_NS = 1000 * 1000 * 1000;
38 |
39 | // Minimum time until the device is considered to have been in the pocket: 2s
40 | private static final int POCKET_MIN_DELTA_NS = 2000 * 1000 * 1000;
41 |
42 | private SensorManager mSensorManager;
43 | private Sensor mSensor;
44 | private Context mContext;
45 | private ExecutorService mExecutorService;
46 |
47 | private boolean mSawNear = false;
48 | private long mInPocketTime = 0;
49 |
50 | public ProximitySensor(Context context) {
51 | mContext = context;
52 | mSensorManager = mContext.getSystemService(SensorManager.class);
53 | mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
54 | mExecutorService = Executors.newSingleThreadExecutor();
55 | }
56 |
57 | private Future> submit(Runnable runnable) {
58 | return mExecutorService.submit(runnable);
59 | }
60 |
61 | @Override
62 | public void onSensorChanged(SensorEvent event) {
63 | boolean isNear = event.values[0] < mSensor.getMaximumRange();
64 | if (mSawNear && !isNear) {
65 | if (shouldPulse(event.timestamp)) {
66 | DozeUtils.launchDozePulse(mContext);
67 | }
68 | } else {
69 | mInPocketTime = event.timestamp;
70 | }
71 | mSawNear = isNear;
72 | }
73 |
74 | private boolean shouldPulse(long timestamp) {
75 | long delta = timestamp - mInPocketTime;
76 |
77 | if (DozeUtils.isHandwaveGestureEnabled(mContext) &&
78 | DozeUtils.isPocketGestureEnabled(mContext)) {
79 | return true;
80 | } else if (DozeUtils.isHandwaveGestureEnabled(mContext)) {
81 | return delta < HANDWAVE_MAX_DELTA_NS;
82 | } else if (DozeUtils.isPocketGestureEnabled(mContext)) {
83 | return delta >= POCKET_MIN_DELTA_NS;
84 | }
85 | return false;
86 | }
87 |
88 | @Override
89 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
90 | /* Empty */
91 | }
92 |
93 | protected void enable() {
94 | if (DEBUG) Log.d(TAG, "Enabling");
95 | submit(() -> {
96 | mSensorManager.registerListener(this, mSensor,
97 | SensorManager.SENSOR_DELAY_NORMAL);
98 | });
99 | }
100 |
101 | protected void disable() {
102 | if (DEBUG) Log.d(TAG, "Disabling");
103 | submit(() -> {
104 | mSensorManager.unregisterListener(this, mSensor);
105 | });
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/thermal/ThermalActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-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 org.lineageos.settings.thermal;
18 |
19 | import android.os.Bundle;
20 | import android.view.MenuItem;
21 |
22 | import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
23 |
24 | public class ThermalActivity extends CollapsingToolbarBaseActivity {
25 |
26 | private static final String TAG_THERMAL = "thermal";
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | getFragmentManager().beginTransaction().replace(
32 | com.android.settingslib.collapsingtoolbar.R.id.content_frame,
33 | new ThermalSettingsFragment(), TAG_THERMAL).commit();
34 | }
35 |
36 | @Override
37 | public boolean onOptionsItemSelected(MenuItem item) {
38 | if (item.getItemId() == android.R.id.home) {
39 | onBackPressed();
40 | return true;
41 | }
42 | return false;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/parts/src/org/lineageos/settings/thermal/ThermalService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-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 | package org.lineageos.settings.thermal;
18 |
19 | import android.app.ActivityManager;
20 | import android.app.ActivityTaskManager;
21 | import android.app.ActivityTaskManager.RootTaskInfo;
22 | import android.app.IActivityTaskManager;
23 | import android.app.TaskStackListener;
24 | import android.app.Service;
25 | import android.content.BroadcastReceiver;
26 | import android.content.Context;
27 | import android.content.Intent;
28 | import android.content.IntentFilter;
29 | import android.os.IBinder;
30 | import android.os.RemoteException;
31 | import android.util.Log;
32 |
33 | public class ThermalService extends Service {
34 |
35 | private static final String TAG = "ThermalService";
36 | private static final boolean DEBUG = false;
37 |
38 | private String mPreviousApp;
39 | private ThermalUtils mThermalUtils;
40 |
41 | private IActivityTaskManager mActivityTaskManager;
42 |
43 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
44 | @Override
45 | public void onReceive(Context context, Intent intent) {
46 | mPreviousApp = "";
47 | mThermalUtils.setDefaultThermalProfile();
48 | }
49 | };
50 |
51 | @Override
52 | public void onCreate() {
53 | if (DEBUG) Log.d(TAG, "Creating service");
54 | try {
55 | mActivityTaskManager = ActivityTaskManager.getService();
56 | mActivityTaskManager.registerTaskStackListener(mTaskListener);
57 | } catch (RemoteException e) {
58 | // Do nothing
59 | }
60 | mThermalUtils = new ThermalUtils(this);
61 | registerReceiver();
62 | super.onCreate();
63 | }
64 |
65 | @Override
66 | public int onStartCommand(Intent intent, int flags, int startId) {
67 | if (DEBUG) Log.d(TAG, "Starting service");
68 | return START_STICKY;
69 | }
70 |
71 | @Override
72 | public IBinder onBind(Intent intent) {
73 | return null;
74 | }
75 |
76 | private void registerReceiver() {
77 | IntentFilter filter = new IntentFilter();
78 | filter.addAction(Intent.ACTION_SCREEN_OFF);
79 | this.registerReceiver(mIntentReceiver, filter);
80 | }
81 |
82 | private final TaskStackListener mTaskListener = new TaskStackListener() {
83 | @Override
84 | public void onTaskStackChanged() {
85 | try {
86 | final RootTaskInfo info = mActivityTaskManager.getFocusedRootTaskInfo();
87 | if (info == null || info.topActivity == null) {
88 | return;
89 | }
90 |
91 | String foregroundApp = info.topActivity.getPackageName();
92 | if (!foregroundApp.equals(mPreviousApp)) {
93 | mThermalUtils.setThermalProfile(foregroundApp);
94 | mPreviousApp = foregroundApp;
95 | }
96 | } catch (RemoteException ignored) {
97 | }
98 | }
99 | };
100 | }
101 |
--------------------------------------------------------------------------------
/permissions/privapp-permissions-hotword.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/permissions/system_ext-privapp-permissions-qti.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
23 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/pocketmode/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 The LineageOS Project
3 | // SPDX-License-Identifier: Apache-2.0
4 | //
5 |
6 | android_app {
7 | name: "XiaomiPocketMode",
8 |
9 | srcs: ["src/**/*.java"],
10 |
11 | certificate: "platform",
12 | platform_apis: true,
13 | privileged: true,
14 | system_ext_specific: true,
15 |
16 | optimize: {
17 | proguard_flags_files: ["proguard.flags"],
18 | },
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/pocketmode/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
23 |
24 |
25 |
26 |
31 |
32 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/pocketmode/proguard.flags:
--------------------------------------------------------------------------------
1 | -keep class org.lineageos.pocketmode.* {
2 | *;
3 | }
4 |
--------------------------------------------------------------------------------
/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The CyanogenMod Project
3 | * 2017 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.pocketmode;
19 |
20 | import android.content.BroadcastReceiver;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.os.UserHandle;
24 | import android.util.Log;
25 |
26 | public class BootCompletedReceiver extends BroadcastReceiver {
27 |
28 | private static final String TAG = "XiaomiPocketMode";
29 |
30 | @Override
31 | public void onReceive(Context context, Intent intent) {
32 | Log.d(TAG, "Starting");
33 | context.startServiceAsUser(new Intent(context, PocketModeService.class),
34 | UserHandle.CURRENT);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The CyanogenMod Project
3 | * 2017 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.pocketmode;
19 |
20 | import android.app.Service;
21 | import android.content.BroadcastReceiver;
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.content.IntentFilter;
25 | import android.os.IBinder;
26 | import android.util.Log;
27 |
28 | public class PocketModeService extends Service {
29 | private static final String TAG = "PocketModeService";
30 | private static final boolean DEBUG = false;
31 |
32 | private ProximitySensor mProximitySensor;
33 |
34 | @Override
35 | public void onCreate() {
36 | if (DEBUG) Log.d(TAG, "Creating service");
37 | mProximitySensor = new ProximitySensor(this);
38 |
39 | IntentFilter screenStateFilter = new IntentFilter();
40 | screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
41 | screenStateFilter.addAction(Intent.ACTION_USER_PRESENT);
42 | registerReceiver(mScreenStateReceiver, screenStateFilter);
43 | }
44 |
45 | @Override
46 | public int onStartCommand(Intent intent, int flags, int startId) {
47 | if (DEBUG) Log.d(TAG, "Starting service");
48 | return START_STICKY;
49 | }
50 |
51 | @Override
52 | public void onDestroy() {
53 | if (DEBUG) Log.d(TAG, "Destroying service");
54 | this.unregisterReceiver(mScreenStateReceiver);
55 | mProximitySensor.disable();
56 | super.onDestroy();
57 | }
58 |
59 | @Override
60 | public IBinder onBind(Intent intent) {
61 | return null;
62 | }
63 |
64 | private void onDeviceUnlocked() {
65 | if (DEBUG) Log.d(TAG, "Device unlocked");
66 | mProximitySensor.disable();
67 | }
68 |
69 | private void onDisplayOff() {
70 | if (DEBUG) Log.d(TAG, "Display off");
71 | mProximitySensor.enable();
72 | }
73 |
74 | private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
75 | @Override
76 | public void onReceive(Context context, Intent intent) {
77 | if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
78 | onDeviceUnlocked();
79 | } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
80 | onDisplayOff();
81 | }
82 | }
83 | };
84 | }
85 |
--------------------------------------------------------------------------------
/pocketmode/src/org/lineageos/pocketmode/ProximitySensor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The CyanogenMod Project
3 | * 2017-2019 The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.lineageos.pocketmode;
19 |
20 | import android.content.Context;
21 | import android.hardware.Sensor;
22 | import android.hardware.SensorEvent;
23 | import android.hardware.SensorEventListener;
24 | import android.hardware.SensorManager;
25 | import android.os.FileUtils;
26 | import android.util.Log;
27 |
28 | import java.io.IOException;
29 | import java.util.concurrent.ExecutorService;
30 | import java.util.concurrent.Executors;
31 | import java.util.concurrent.Future;
32 |
33 | public class ProximitySensor implements SensorEventListener {
34 | private static final String TAG = "PocketModeProximity";
35 | private static final boolean DEBUG = false;
36 |
37 | private static final String FP_PROX_NODE =
38 | "/sys/devices/platform/soc/soc:fingerprint_goodix/proximity_state";
39 |
40 | private ExecutorService mExecutorService;
41 | private Context mContext;
42 | private Sensor mSensor;
43 | private SensorManager mSensorManager;
44 |
45 | public ProximitySensor(Context context) {
46 | mContext = context;
47 | mSensorManager = mContext.getSystemService(SensorManager.class);
48 | mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
49 | mExecutorService = Executors.newSingleThreadExecutor();
50 | }
51 |
52 | private Future> submit(Runnable runnable) {
53 | return mExecutorService.submit(runnable);
54 | }
55 |
56 | @Override
57 | public void onSensorChanged(SensorEvent event) {
58 | setFPProximityState(event.values[0] < mSensor.getMaximumRange());
59 | }
60 |
61 | @Override
62 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
63 | /* Empty */
64 | }
65 |
66 | private void setFPProximityState(boolean isNear) {
67 | try {
68 | FileUtils.stringToFile(FP_PROX_NODE, isNear ? "1" : "0");
69 | } catch (IOException e) {
70 | Log.e(TAG, "Failed to write to " + FP_PROX_NODE, e);
71 | }
72 | }
73 |
74 | protected void enable() {
75 | if (DEBUG) Log.d(TAG, "Enabling");
76 | submit(() -> {
77 | mSensorManager.registerListener(this, mSensor,
78 | SensorManager.SENSOR_DELAY_NORMAL);
79 | });
80 | }
81 |
82 | protected void disable() {
83 | if (DEBUG) Log.d(TAG, "Disabling");
84 | submit(() -> {
85 | mSensorManager.unregisterListener(this, mSensor);
86 | });
87 | // Ensure FP is left enabled
88 | setFPProximityState(/* isNear */ false);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/power/Android.bp:
--------------------------------------------------------------------------------
1 | cc_library_static {
2 | name: "libperfmgr-ext-xiaomi",
3 | defaults: [
4 | "android.hardware.power-ndk_shared",
5 | ],
6 | vendor: true,
7 | srcs: [
8 | "power-mode.cpp",
9 | ],
10 | shared_libs: [
11 | "libbase",
12 | ],
13 | }
14 |
--------------------------------------------------------------------------------
/power/power-mode.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 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 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | namespace {
23 | int open_ts_input() {
24 | int fd = -1;
25 | DIR* dir = opendir("/dev/input");
26 |
27 | if (dir != NULL) {
28 | struct dirent* ent;
29 |
30 | while ((ent = readdir(dir)) != NULL) {
31 | if (ent->d_type == DT_CHR) {
32 | char absolute_path[PATH_MAX] = {0};
33 | char name[80] = {0};
34 |
35 | strcpy(absolute_path, "/dev/input/");
36 | strcat(absolute_path, ent->d_name);
37 |
38 | fd = open(absolute_path, O_RDWR);
39 | if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) > 0) {
40 | if (strcmp(name, "atmel_mxt_ts") == 0 || strcmp(name, "fts_ts") == 0 ||
41 | strcmp(name, "fts") == 0 || strcmp(name, "ft5x46") == 0 ||
42 | strcmp(name, "synaptics_dsx") == 0 ||
43 | strcmp(name, "NVTCapacitiveTouchScreen") == 0)
44 | break;
45 | }
46 |
47 | close(fd);
48 | fd = -1;
49 | }
50 | }
51 |
52 | closedir(dir);
53 | }
54 |
55 | return fd;
56 | }
57 | } // anonymous namespace
58 |
59 | namespace aidl {
60 | namespace google {
61 | namespace hardware {
62 | namespace power {
63 | namespace impl {
64 | namespace pixel {
65 |
66 | static constexpr int kInputEventWakeupModeOff = 4;
67 | static constexpr int kInputEventWakeupModeOn = 5;
68 |
69 | using ::aidl::android::hardware::power::Mode;
70 |
71 | bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
72 | switch (type) {
73 | case Mode::DOUBLE_TAP_TO_WAKE:
74 | *_aidl_return = true;
75 | return true;
76 | default:
77 | return false;
78 | }
79 | }
80 |
81 | bool setDeviceSpecificMode(Mode type, bool enabled) {
82 | switch (type) {
83 | case Mode::DOUBLE_TAP_TO_WAKE: {
84 | int fd = open_ts_input();
85 | if (fd == -1) {
86 | LOG(WARNING)
87 | << "DT2W won't work because no supported touchscreen input devices were found";
88 | return false;
89 | }
90 | struct input_event ev;
91 | ev.type = EV_SYN;
92 | ev.code = SYN_CONFIG;
93 | ev.value = enabled ? kInputEventWakeupModeOn : kInputEventWakeupModeOff;
94 | write(fd, &ev, sizeof(ev));
95 | close(fd);
96 | }
97 | return true;
98 | default:
99 | return false;
100 | }
101 | }
102 |
103 | } // namespace pixel
104 | } // namespace impl
105 | } // namespace power
106 | } // namespace hardware
107 | } // namespace google
108 | } // namespace aidl
109 |
--------------------------------------------------------------------------------
/product.prop:
--------------------------------------------------------------------------------
1 | # IMS
2 | ro.telephony.block_binder_thread_on_incoming_calls=false
3 |
4 | # LMKD
5 | ro.lmk.low=1001
6 | ro.lmk.medium=800
7 | ro.lmk.critical=0
8 | ro.lmk.critical_upgrade=false
9 | ro.lmk.upgrade_pressure=100
10 | ro.lmk.downgrade_pressure=100
11 | ro.lmk.kill_heaviest_task=true
12 | ro.lmk.kill_timeout_ms=100
13 | ro.lmk.use_minfree_levels=true
14 | ro.lmk.log_stats=true
15 |
--------------------------------------------------------------------------------
/recovery/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 The LineageOS Project
3 | // SPDX-License-Identifier: Apache-2.0
4 | //
5 |
6 | cc_library_static {
7 | name: "librecovery_updater_xiaomi",
8 | include_dirs: [
9 | "bootable/deprecated-ota/edify/include",
10 | "bootable/recovery",
11 | "bootable/recovery/otautil/include",
12 | ],
13 | srcs: ["recovery_updater.cpp"],
14 | }
15 |
--------------------------------------------------------------------------------
/recovery/recovery_updater.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016, The CyanogenMod Project
3 | * Copyright (C) 2017-2020, The LineageOS Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include
30 | #include
31 |
32 | #include "edify/expr.h"
33 | #include "otautil/error_code.h"
34 |
35 | #define MAX(a, b) (((a) > (b)) ? (a) : (b))
36 |
37 | #define ALPHABET_LEN 256
38 |
39 | #define XBL_PART_PATH "/dev/block/bootdevice/by-name/xbl_a"
40 | #define TZ_VER_STR "QC_IMAGE_VERSION_STRING=TZ."
41 | #define TZ_VER_STR_LEN 27
42 | #define TZ_VER_BUF_LEN 255
43 |
44 | /* Boyer-Moore string search implementation from Wikipedia */
45 |
46 | /* Return longest suffix length of suffix ending at str[p] */
47 | static int max_suffix_len(const char* str, size_t str_len, size_t p) {
48 | uint32_t i;
49 |
50 | for (i = 0; (str[p - i] == str[str_len - 1 - i]) && (i < p);) {
51 | i++;
52 | }
53 |
54 | return i;
55 | }
56 |
57 | /* Generate table of distance between last character of pat and rightmost
58 | * occurrence of character c in pat
59 | */
60 | static void bm_make_delta1(int* delta1, const char* pat, size_t pat_len) {
61 | uint32_t i;
62 | for (i = 0; i < ALPHABET_LEN; i++) {
63 | delta1[i] = pat_len;
64 | }
65 | for (i = 0; i < pat_len - 1; i++) {
66 | uint8_t idx = (uint8_t)pat[i];
67 | delta1[idx] = pat_len - 1 - i;
68 | }
69 | }
70 |
71 | /* Generate table of next possible full match from mismatch at pat[p] */
72 | static void bm_make_delta2(int* delta2, const char* pat, size_t pat_len) {
73 | int p;
74 | uint32_t last_prefix = pat_len - 1;
75 |
76 | for (p = pat_len - 1; p >= 0; p--) {
77 | /* Compare whether pat[p-pat_len] is suffix of pat */
78 | if (strncmp(pat + p, pat, pat_len - p) == 0) {
79 | last_prefix = p + 1;
80 | }
81 | delta2[p] = last_prefix + (pat_len - 1 - p);
82 | }
83 |
84 | for (p = 0; p < (int)pat_len - 1; p++) {
85 | /* Get longest suffix of pattern ending on character pat[p] */
86 | int suf_len = max_suffix_len(pat, pat_len, p);
87 | if (pat[p - suf_len] != pat[pat_len - 1 - suf_len]) {
88 | delta2[pat_len - 1 - suf_len] = pat_len - 1 - p + suf_len;
89 | }
90 | }
91 | }
92 |
93 | static char* bm_search(const char* str, size_t str_len, const char* pat, size_t pat_len) {
94 | int delta1[ALPHABET_LEN];
95 | int delta2[pat_len];
96 | int i;
97 |
98 | bm_make_delta1(delta1, pat, pat_len);
99 | bm_make_delta2(delta2, pat, pat_len);
100 |
101 | if (pat_len == 0) {
102 | return (char*)str;
103 | }
104 |
105 | i = pat_len - 1;
106 | while (i < (int)str_len) {
107 | int j = pat_len - 1;
108 | while (j >= 0 && (str[i] == pat[j])) {
109 | i--;
110 | j--;
111 | }
112 | if (j < 0) {
113 | return (char*)(str + i + 1);
114 | }
115 | i += MAX(delta1[(uint8_t)str[i]], delta2[j]);
116 | }
117 |
118 | return NULL;
119 | }
120 |
121 | static int get_info(char* str, size_t len, char* lookup_str, size_t lookup_str_len,
122 | char* part_path) {
123 | int ret = 0;
124 | int fd;
125 | off64_t size;
126 | char* data = NULL;
127 | char* offset = NULL;
128 |
129 | fd = open(part_path, O_RDONLY);
130 | if (fd < 0) {
131 | ret = errno;
132 | goto err_ret;
133 | }
134 |
135 | size = lseek64(fd, 0, SEEK_END);
136 | if (size == -1) {
137 | ret = errno;
138 | goto err_fd_close;
139 | }
140 |
141 | data = (char*)mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
142 | if (data == (char*)-1) {
143 | ret = errno;
144 | goto err_fd_close;
145 | }
146 |
147 | /* Do Boyer-Moore search across data */
148 | offset = bm_search(data, size, lookup_str, lookup_str_len);
149 | if (offset != NULL) {
150 | snprintf(str, len, "%s", offset + lookup_str_len);
151 | } else {
152 | ret = -ENOENT;
153 | }
154 |
155 | munmap(data, size);
156 | err_fd_close:
157 | close(fd);
158 | err_ret:
159 | return ret;
160 | }
161 |
162 | /* verify_trustzone("TZ_VERSION", "TZ_VERSION", ...) */
163 | Value* VerifyTrustZoneFn(const char* name, State* state,
164 | const std::vector>& argv) {
165 | char current_tz_version[TZ_VER_BUF_LEN];
166 | int ret;
167 |
168 | ret = get_info(current_tz_version, TZ_VER_BUF_LEN, TZ_VER_STR, TZ_VER_STR_LEN,
169 | XBL_PART_PATH);
170 | if (ret) {
171 | return ErrorAbort(state, kFreadFailure,
172 | "%s() failed to read current TZ version: %d", name, ret);
173 | }
174 |
175 | std::vector args;
176 | if (!ReadArgs(state, argv, &args)) {
177 | return ErrorAbort(state, kArgsParsingFailure, "%s() error parsing arguments", name);
178 | }
179 |
180 | ret = 0;
181 | for (auto &tz_version : args) {
182 | if (strncmp(tz_version.c_str(), current_tz_version, tz_version.length()) == 0) {
183 | ret = 1;
184 | break;
185 | }
186 | }
187 |
188 | return StringValue(strdup(ret ? "1" : "0"));
189 | }
190 |
191 | void Register_librecovery_updater_xiaomi() {
192 | RegisterFunction("xiaomi.verify_trustzone", VerifyTrustZoneFn);
193 | }
194 |
--------------------------------------------------------------------------------
/releasetools.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2009 The Android Open Source Project
2 | # Copyright (c) 2011, The Linux Foundation. All rights reserved.
3 | # Copyright (C) 2017-2023 The LineageOS Project
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | import common
18 | import re
19 |
20 | def FullOTA_InstallEnd(info):
21 | OTA_InstallEnd(info)
22 | return
23 |
24 | def IncrementalOTA_InstallEnd(info):
25 | OTA_InstallEnd(info)
26 | return
27 |
28 | def FullOTA_Assertions(info):
29 | AddTrustZoneAssertion(info, info.input_zip)
30 | return
31 |
32 | def IncrementalOTA_Assertions(info):
33 | AddTrustZoneAssertion(info, info.target_zip)
34 | return
35 |
36 | def AddImage(info, basename, dest):
37 | path = "IMAGES/" + basename
38 | if path not in info.input_zip.namelist():
39 | return
40 |
41 | data = info.input_zip.read(path)
42 | common.ZipWriteStr(info.output_zip, basename, data)
43 | info.script.Print("Patching {} image unconditionally...".format(dest.split('/')[-1]))
44 | info.script.AppendExtra('package_extract_file("%s", "%s");' % (basename, dest))
45 |
46 | def OTA_InstallEnd(info):
47 | AddImage(info, "dtbo.img", "/dev/block/bootdevice/by-name/dtbo")
48 | AddImage(info, "vbmeta.img", "/dev/block/bootdevice/by-name/vbmeta")
49 | return
50 |
51 | def AddTrustZoneAssertion(info, input_zip):
52 | android_info = info.input_zip.read("OTA/android-info-extra.txt")
53 | m = re.search(r'require\s+version-trustzone\s*=\s*(\S+)', android_info.decode('utf-8'))
54 | if m:
55 | versions = m.group(1).split('|')
56 | if len(versions) and '*' not in versions:
57 | cmd = 'assert(xiaomi.verify_trustzone(' + ','.join(['"%s"' % tz for tz in versions]) + ') == "1" || abort("ERROR: This package requires firmware from an Android 10 based MIUI build. Please upgrade firmware and retry!"););'
58 | info.script.AppendExtra(cmd)
59 | return
60 |
--------------------------------------------------------------------------------
/rro_overlays/TetheringOverlay/Android.bp:
--------------------------------------------------------------------------------
1 | runtime_resource_overlay {
2 | name: "TetheringConfigOverlay",
3 | theme: "TetheringConfigOverlay",
4 | product_specific: true
5 | }
6 |
--------------------------------------------------------------------------------
/rro_overlays/TetheringOverlay/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/rro_overlays/TetheringOverlay/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
25 |
26 | - "usb\\d"
27 | - "rndis\\d"
28 |
29 |
30 |
33 |
34 | - "wlan\\d"
35 |
36 |
37 |
40 |
41 | - "bnep\\d"
42 | - "bt-pan"
43 |
44 |
45 |
46 |
47 | - 192.168.42.2
48 | - 192.168.42.254
49 | - 192.168.43.2
50 | - 192.168.43.254
51 | - 192.168.44.2
52 | - 192.168.44.254
53 | - 192.168.45.2
54 | - 192.168.45.254
55 | - 192.168.46.2
56 | - 192.168.46.254
57 | - 192.168.47.2
58 | - 192.168.47.254
59 | - 192.168.48.2
60 | - 192.168.48.254
61 | - 192.168.49.2
62 | - 192.168.49.254
63 | - 192.168.50.2
64 | - 192.168.50.254
65 | - 192.168.51.2
66 | - 192.168.51.254
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/rro_overlays/WifiOverlay/Android.bp:
--------------------------------------------------------------------------------
1 | runtime_resource_overlay {
2 | name: "WifiOverlay",
3 | theme: "WifiOverlay",
4 | product_specific: true
5 | }
6 |
--------------------------------------------------------------------------------
/rro_overlays/WifiOverlay/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
21 |
22 |
27 |
28 |
--------------------------------------------------------------------------------
/rro_overlays/WifiOverlay/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
24 |
28 | true
29 |
30 |
31 | true
32 |
33 |
37 | true
38 |
39 |
40 | true
41 |
42 |
44 | 524288,2097152,8388608,262144,524288,4194304
45 |
46 |
47 | true
48 |
49 |
50 | true
51 |
52 |
53 | true
54 |
55 |
56 | true
57 |
58 |
59 | true
60 |
61 |
62 | true
63 |
64 |
65 | true
66 |
67 |
68 | 32
69 |
70 |
71 | true
72 |
73 |
74 | true
75 |
76 |
--------------------------------------------------------------------------------
/seccomp/mediacodec-seccomp.policy:
--------------------------------------------------------------------------------
1 | # device specific syscalls
2 | # extension of services/mediacodec/minijail/seccomp_policy/mediacodec-seccomp-arm.policy
3 | pselect6: 1
4 | eventfd2: 1
5 | sendto: 1
6 | recvfrom: 1
7 | _llseek: 1
8 | sysinfo: 1
9 | getcwd: 1
10 | getdents64: 1
11 | ARM_cacheflush: 1
12 | inotify_init1: 1
13 | inotify_add_watch: 1
14 | inotify_rm_watch: 1
15 | uname: 1
16 | ueventd: 1
17 | timer_create: 1
18 | timer_settime: 1
19 | rt_sigtimedwait: 1
20 |
--------------------------------------------------------------------------------
/sepolicy/private/property_contexts:
--------------------------------------------------------------------------------
1 | # IMEI
2 | persist.radio.imei u:object_r:deviceid_prop:s0
3 | persist.radio.meid u:object_r:deviceid_prop:s0
4 | ro.ril.miui.imei u:object_r:deviceid_prop:s0
5 | ro.ril.oem.imei u:object_r:deviceid_prop:s0
6 | ro.ril.oem.meid u:object_r:deviceid_prop:s0
7 |
8 | # MIUI specific
9 | ro.cust.test u:object_r:exported_system_prop:s0
10 | ro.boot.hwc u:object_r:exported_default_prop:s0
11 | ro.product.mod_device u:object_r:build_prop:s0
12 | ro.miui. u:object_r:exported_system_prop:s0
13 |
14 | # SettingsLib
15 | settingsdebug.instant.packages u:object_r:settingslib_prop:s0
16 |
--------------------------------------------------------------------------------
/sepolicy/private/seapp_contexts:
--------------------------------------------------------------------------------
1 | user=system seinfo=platform name=org.lineageos.pocketmode domain=pocketmode_app type=system_app_data_file
2 | user=system seinfo=platform name=org.lineageos.settings domain=xiaomiparts_app type=system_app_data_file
3 |
--------------------------------------------------------------------------------
/sepolicy/private/system_app.te:
--------------------------------------------------------------------------------
1 | hal_client_domain(system_app, hal_mlipay)
2 |
--------------------------------------------------------------------------------
/sepolicy/private/xiaomiparts_app.te:
--------------------------------------------------------------------------------
1 | type xiaomiparts_app, domain;
2 | typeattribute xiaomiparts_app mlstrustedsubject;
3 |
4 | app_domain(xiaomiparts_app)
5 |
6 | # Access standard system services
7 | allow xiaomiparts_app app_api_service:service_manager find;
8 | allow xiaomiparts_app audioserver_service:service_manager find;
9 |
10 | # Allow reading and writing shared prefs
11 | allow xiaomiparts_app system_app_data_file:dir create_dir_perms;
12 | allow xiaomiparts_app system_app_data_file:{ file lnk_file } create_file_perms;
13 |
14 | # Allow binder communication with gpuservice
15 | binder_call(xiaomiparts_app, gpuservice)
16 |
17 | # Allow XiaomiParts to read and write to cgroup
18 | allow xiaomiparts_app cgroup:file rw_file_perms;
19 |
20 | # Allow XiaomiParts to write to sysfs_thermal
21 | allow xiaomiparts_app sysfs_thermal:file w_file_perms;
22 |
23 | # Allow XiaomiParts to get settingsdebug.instant.packages prop
24 | get_prop(xiaomiparts_app, settingslib_prop)
25 |
--------------------------------------------------------------------------------
/sepolicy/public/attributes:
--------------------------------------------------------------------------------
1 | hal_attribute_lineage(mlipay)
2 |
--------------------------------------------------------------------------------
/sepolicy/public/property.te:
--------------------------------------------------------------------------------
1 | # SettingsLib
2 | system_public_prop(settingslib_prop)
3 |
4 | # IMEI
5 | vendor_public_prop(deviceid_prop)
6 |
--------------------------------------------------------------------------------
/sepolicy/vendor/app.te:
--------------------------------------------------------------------------------
1 | get_prop({ appdomain -isolated_app_all }, vendor_fp_prop)
2 | get_prop({ appdomain -isolated_app_all }, vendor_tee_listener_prop)
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/appdomain.te:
--------------------------------------------------------------------------------
1 | get_prop(appdomain, camera_prop)
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/device.te:
--------------------------------------------------------------------------------
1 | typeattribute system_block_device super_block_device_type;
2 |
3 | type fingerprint_device, dev_type;
4 |
5 | type gps_device, dev_type;
6 |
7 | type sound_device, dev_type;
8 |
9 | type vbmeta_block_device, dev_type;
10 |
--------------------------------------------------------------------------------
/sepolicy/vendor/fastbootd.te:
--------------------------------------------------------------------------------
1 | allow fastbootd {
2 | dtbo_block_device
3 | vbmeta_block_device
4 | }:blk_file { w_file_perms getattr ioctl };
5 |
--------------------------------------------------------------------------------
/sepolicy/vendor/file.te:
--------------------------------------------------------------------------------
1 | type audio_socket, file_type;
2 |
3 | type fingerprint_data_file, data_file_type, file_type;
4 | type gps_data_file, data_file_type, file_type;
5 | type gps_socket, file_type;
6 | type thermal_data_file, data_file_type, file_type;
7 | type vendor_convergence_data_file, data_file_type, file_type;
8 |
9 | type proc_tp, proc_type, fs_type;
10 |
11 | type sysfs_fingerprint, sysfs_type, fs_type;
12 | type sysfs_gps, sysfs_type, fs_type;
13 | type sysfs_wireless_supply, sysfs_type, fs_type;
14 |
15 | type persist_audio_file, file_type, vendor_persist_type;
16 | type persist_camera_file, file_type, vendor_persist_type;
17 |
--------------------------------------------------------------------------------
/sepolicy/vendor/file_contexts:
--------------------------------------------------------------------------------
1 | # Audio devices
2 | /dev/elliptic(.*)? u:object_r:sound_device:s0
3 |
4 | # Block devices
5 | /dev/block/platform/soc/1d84000\.ufshc/by-name/cust u:object_r:system_block_device:s0
6 | /dev/block/platform/soc/1d84000\.ufshc/by-name/dtbo u:object_r:dtbo_block_device:s0
7 | /dev/block/platform/soc/1d84000\.ufshc/by-name/system u:object_r:system_block_device:s0
8 | /dev/block/platform/soc/1d84000\.ufshc/by-name/vbmeta u:object_r:vbmeta_block_device:s0
9 | /dev/block/platform/soc/1d84000\.ufshc/by-name/vendor u:object_r:system_block_device:s0
10 |
11 | # Camera
12 | /(vendor|system/vendor)/bin/remosaic_daemon u:object_r:remosaic_daemon_exec:s0
13 |
14 | # Data files
15 | /data/vendor/fpc(/.*)? u:object_r:fingerprint_data_file:s0
16 | /data/vendor/goodix(/.*)? u:object_r:fingerprint_data_file:s0
17 | /data/vendor/gps(/.*)? u:object_r:gps_data_file:s0
18 | /data/vendor/mac_addr(/.*)? u:object_r:vendor_convergence_data_file:s0
19 | /data/vendor/syna(/.*)? u:object_r:fingerprint_data_file:s0
20 | /data/vendor/thermal(/.*)? u:object_r:thermal_data_file:s0
21 |
22 | # Executables
23 | /vendor/bin/glgps u:object_r:glgps_exec:s0
24 | /vendor/bin/ignss_2_0 u:object_r:hal_gnss_default_exec:s0
25 | /vendor/bin/lhd u:object_r:lhd_exec:s0
26 | /vendor/bin/mlipayd@1\.1 u:object_r:hal_mlipay_default_exec:s0
27 | /vendor/bin/nv_mac u:object_r:wcnss_service_exec:s0
28 |
29 | # Fingerprint devices
30 | /dev/goodix_fp u:object_r:fingerprint_device:s0
31 | /dev/vfsspi u:object_r:fingerprint_device:s0
32 |
33 | # GPS devices
34 | /dev/bbd_control u:object_r:gps_device:s0
35 | /dev/bbd_patch u:object_r:gps_device:s0
36 | /dev/bbd_sensor u:object_r:gps_device:s0
37 | /dev/ttyBCM u:object_r:gps_device:s0
38 |
39 | # GPS nodes
40 | /sys/devices/platform/soc/[0-9]+\.spi/spi_master/spi[0-9]+/spi[0-9]+\.0/nstandby u:object_r:sysfs_gps:s0
41 |
42 | # Graphics nodes
43 | /sys/devices/platform/soc/[a-z0-9]+.qcom,mdss_mdp/drm/card([0-3])+/card([0-3])+-DSI-1/disp_param u:object_r:sysfs_graphics:s0
44 | /sys/devices/platform/soc/[a-z0-9]+.qcom,mdss_mdp/drm/card([0-3])+/card([0-3])+-DSI-1/hbm_status u:object_r:sysfs_graphics:s0
45 | /sys/devices/platform/soc/[a-z0-9]+.qcom,mdss_mdp/drm/card([0-3])+/card([0-3])+-DSI-1/panel_info u:object_r:sysfs_graphics:s0
46 | /sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui u:object_r:sysfs_graphics:s0
47 |
48 | # Leds nodes
49 | /sys/devices/platform/soc/[a-z0-9]+.i2c/i2c-[0-9]/[0-9]-[a-z0-9]+/leds/ir(/.*)? u:object_r:sysfs_leds:s0
50 |
51 | # HALs
52 | /vendor/bin/hw/android\.hardware\.biometrics\.fingerprint-service\.xiaomi u:object_r:hal_fingerprint_default_exec:s0
53 | /vendor/bin/hw/android\.hardware\.neuralnetworks@1\.2-service-qti u:object_r:hal_neuralnetworks_default_exec:s0
54 | /vendor/bin/hw/vendor\.lineage\.livedisplay@2\.0-service\.xiaomi_sdm845 u:object_r:hal_lineage_livedisplay_qti_exec:s0
55 |
56 | # Persist files
57 | /mnt/vendor/persist/audio(/.*)? u:object_r:persist_audio_file:s0
58 | /mnt/vendor/persist/camera(/.*)? u:object_r:persist_camera_file:s0
59 |
60 | # Sensors nodes
61 | /sys/devices/virtual/touch/tp_dev/fp_state u:object_r:sysfs_sensors:s0
62 |
63 | # Sockets
64 | /dev/socket/audio_hw_socket u:object_r:audio_socket:s0
65 | /dev/socket/gps u:object_r:gps_socket:s0
66 |
--------------------------------------------------------------------------------
/sepolicy/vendor/genfs_contexts:
--------------------------------------------------------------------------------
1 | genfscon proc /sys/kernel/sched_autogroup_enabled u:object_r:proc_sched:s0
2 | genfscon proc /sys/kernel/sched_boost u:object_r:proc_sched:s0
3 | genfscon proc /tp_fw_version u:object_r:proc_tp:s0
4 | genfscon proc /tp_lockdown_info u:object_r:proc_tp:s0
5 |
6 | genfscon sysfs /devices/platform/soc/17300000.qcom,lpass/subsys4/restart_level u:object_r:sysfs_ssr_toggle:s0
7 | genfscon sysfs /devices/platform/soc/188101c.qcom,spss/subsys0/restart_level u:object_r:sysfs_ssr_toggle:s0
8 | genfscon sysfs /devices/platform/soc/4080000.qcom,mss/subsys7/restart_level u:object_r:sysfs_ssr_toggle:s0
9 | genfscon sysfs /devices/platform/soc/5c00000.qcom,ssc/subsys5/restart_level u:object_r:sysfs_ssr_toggle:s0
10 | genfscon sysfs /devices/platform/soc/8300000.qcom,turing/subsys6/restart_level u:object_r:sysfs_ssr_toggle:s0
11 | genfscon sysfs /devices/platform/soc/a88000.i2c/i2c-0/0-0061/power_supply/idt u:object_r:sysfs_wireless_supply:s0
12 | genfscon sysfs /devices/platform/soc/aae0000.qcom,venus/subsys1/restart_level u:object_r:sysfs_ssr_toggle:s0
13 | genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/idle_state u:object_r:sysfs_graphics:s0
14 | genfscon sysfs /devices/platform/soc/c440000.qcom,spmi/spmi-0/spmi0-02/c440000.qcom,spmi:qcom,pmi8998@2:qcom,qpnp-smb2/power_supply/wireless u:object_r:sysfs_wireless_supply:s0
15 | genfscon sysfs /devices/platform/soc/c440000.qcom,spmi/spmi-0/spmi0-03/c440000.qcom,spmi:qcom,pmi8998@3:qcom,leds@d000/leds/white u:object_r:sysfs_graphics:s0
16 | genfscon sysfs /devices/platform/soc/soc:fingerprint_fpc/device_prepare u:object_r:sysfs_fingerprint:s0
17 | genfscon sysfs /devices/platform/soc/soc:fingerprint_fpc/fingerdown_wait u:object_r:sysfs_fingerprint:s0
18 | genfscon sysfs /devices/platform/soc/soc:fingerprint_fpc/irq u:object_r:sysfs_fingerprint:s0
19 | genfscon sysfs /devices/platform/soc/soc:fingerprint_fpc/wakeup_enable u:object_r:sysfs_fingerprint:s0
20 | genfscon sysfs /devices/platform/soc/soc:fingerprint_goodix/proximity_state u:object_r:sysfs_fingerprint:s0
21 | genfscon sysfs /devices/platform/soc/soc:qcom,ipa_fws/subsys2/restart_level u:object_r:sysfs_ssr_toggle:s0
22 | genfscon sysfs /devices/platform/soc/soc:qcom,kgsl-hyp/subsys3/restart_level u:object_r:sysfs_ssr_toggle:s0
23 |
24 | genfscon sysfs /devices/platform/vendor/vendor:extcon_usb1/extcon/extcon3/cable.0/ u:object_r:sysfs_extcon:s0
25 | genfscon sysfs /devices/platform/vendor/vendor:extcon_usb1/extcon/extcon3/cable.1/ u:object_r:sysfs_extcon:s0
26 |
--------------------------------------------------------------------------------
/sepolicy/vendor/glgps.te:
--------------------------------------------------------------------------------
1 | type glgps, domain;
2 | type glgps_exec, exec_type, vendor_file_type, file_type;
3 |
4 | init_daemon_domain(glgps)
5 | net_domain(glgps)
6 |
7 | allow glgps fwk_sensor_hwservice:hwservice_manager find;
8 |
9 | allow glgps gps_data_file:dir create_dir_perms;
10 | allow glgps gps_data_file:fifo_file create_file_perms;
11 | allow glgps gps_data_file:file create_file_perms;
12 | allow glgps gps_data_file:lnk_file create_file_perms;
13 | allow glgps gps_data_file:sock_file create_file_perms;
14 |
15 | allow glgps gps_device:chr_file rw_file_perms;
16 |
17 | allow glgps self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
18 | allow glgps gps_socket:sock_file create_file_perms;
19 |
20 | binder_call(glgps, system_server)
21 |
22 | typeattribute glgps halclientdomain;
23 |
24 | wakelock_use(glgps)
25 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_audio_default.te:
--------------------------------------------------------------------------------
1 | allow hal_audio_default mnt_vendor_file:dir search;
2 | r_dir_file(hal_audio_default, persist_audio_file)
3 |
4 | set_prop(hal_audio_default, vendor_audio_prop)
5 |
6 | allow hal_audio_default audio_socket:sock_file rw_file_perms;
7 |
8 | dontaudit hal_audio_default sysfs:dir read;
9 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_bluetooth_qti.te:
--------------------------------------------------------------------------------
1 | r_dir_file(hal_bluetooth_qti, vendor_convergence_data_file)
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_camera_default.te:
--------------------------------------------------------------------------------
1 | allow hal_camera_default gpu_device:chr_file rw_file_perms;
2 |
3 | allow hal_camera_default remosaic_daemon_service:service_manager find;
4 |
5 | allow hal_camera_default sysfs_kgsl:dir search;
6 | allow hal_camera_default sysfs_kgsl:file r_file_perms;
7 |
8 | allow hal_camera_default sysfs_leds:dir r_dir_perms;
9 | allow hal_camera_default sysfs_leds:file rw_file_perms;
10 | allow hal_camera_default sysfs_leds:lnk_file read;
11 |
12 | allow hal_camera_default sysfs_thermal:file w_file_perms;
13 |
14 | r_dir_file(hal_camera_default, persist_camera_file)
15 |
16 | get_prop(hal_camera_default, camera_ro_prop)
17 |
18 | userdebug_or_eng(`
19 | get_prop(hal_camera_default, camera_dbg_prop)
20 | get_prop(hal_camera_default, sensors_dbg_prop)
21 | ')
22 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_fingerprint_default.te:
--------------------------------------------------------------------------------
1 | allow hal_fingerprint_default fingerprint_device:chr_file rw_file_perms;
2 | allow hal_fingerprint_default fingerprint_data_file:dir create_dir_perms;
3 | allow hal_fingerprint_default fingerprint_data_file:file create_file_perms;
4 | allow hal_fingerprint_default self:netlink_socket create_socket_perms_no_ioctl;
5 | allow hal_fingerprint_default sysfs_fingerprint:file rw_file_perms;
6 | allow hal_fingerprint_default tee_device:chr_file rw_file_perms;
7 | allow hal_fingerprint_default uhid_device:chr_file rw_file_perms;
8 | allow hal_fingerprint_default input_device:dir r_dir_perms;
9 | allow hal_fingerprint_default input_device:chr_file rw_file_perms;
10 |
11 | allow hal_fingerprint_default sysfs_graphics:dir search;
12 | allow hal_fingerprint_default sysfs_graphics:file rw_file_perms;
13 |
14 | set_prop(hal_fingerprint_default, vendor_fp_prop)
15 | hal_client_domain(hal_fingerprint_default, hal_perf)
16 |
17 | # Ignore all logging requests
18 | dontaudit hal_fingerprint storage_file:dir search;
19 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_gnss_default.te:
--------------------------------------------------------------------------------
1 | allow hal_gnss_default gps_data_file:dir rw_dir_perms;
2 | allow hal_gnss_default gps_data_file:fifo_file create_file_perms;
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_health_default.te:
--------------------------------------------------------------------------------
1 | allow hal_health_default sysfs_wireless_supply:dir search;
2 | allow hal_health_default sysfs_wireless_supply:file r_file_perms;
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_imsrtp.te:
--------------------------------------------------------------------------------
1 | binder_call(hal_imsrtp, radio)
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_lineage_livedisplay_qti.te:
--------------------------------------------------------------------------------
1 | # Grant LiveDisplay access over the control nodes
2 | allow hal_lineage_livedisplay_qti sysfs_graphics:file rw_file_perms;
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_mlipay.te:
--------------------------------------------------------------------------------
1 | # HwBinder IPC from client to server
2 | binder_call(hal_mlipay_client, hal_mlipay_server)
3 |
4 | add_hwservice(hal_mlipay_server, hal_mlipay_hwservice)
5 | allow hal_mlipay_client hal_mlipay_hwservice:hwservice_manager find;
6 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_mlipay_default.te:
--------------------------------------------------------------------------------
1 | type hal_mlipay_default, domain;
2 | hal_server_domain(hal_mlipay_default, hal_mlipay)
3 |
4 | type hal_mlipay_default_exec, exec_type, vendor_file_type, file_type;
5 |
6 | init_daemon_domain(hal_mlipay_default)
7 |
8 | allow hal_mlipay_default ion_device:chr_file rw_file_perms;
9 | allow hal_mlipay_default tee_device:chr_file rw_file_perms;
10 | r_dir_file(hal_mlipay_default, firmware_file)
11 |
12 | get_prop(hal_mlipay_default, vendor_fp_prop)
13 | set_prop(hal_mlipay_default, vendor_tee_listener_prop)
14 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_power_default.te:
--------------------------------------------------------------------------------
1 | allow hal_power_default input_device:dir r_dir_perms;
2 | allow hal_power_default input_device:chr_file rw_file_perms;
3 |
4 | # To do powerhint on nodes defined in powerhint.json
5 | allow hal_power_default device_latency:chr_file rw_file_perms;
6 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hal_sensors_default.te:
--------------------------------------------------------------------------------
1 | allow hal_sensors_default mnt_vendor_file:file r_file_perms;
2 | allow hal_sensors_default sound_device:chr_file rw_file_perms;
3 |
4 | allow hal_sensors_default audio_socket:sock_file rw_file_perms;
5 | unix_socket_connect(hal_sensors_default, audio, hal_audio_default)
6 |
7 | get_prop(hal_sensors_default, adsprpc_prop)
8 | get_prop(hal_sensors_default, sensors_prop)
9 |
10 | userdebug_or_eng(`
11 | get_prop(hal_sensors_default, sensors_dbg_prop)
12 | ')
13 |
--------------------------------------------------------------------------------
/sepolicy/vendor/healthd.te:
--------------------------------------------------------------------------------
1 | allow healthd sysfs_wireless_supply:file r_file_perms;
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hwservice.te:
--------------------------------------------------------------------------------
1 | type hal_mlipay_hwservice, hwservice_manager_type;
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/hwservice_contexts:
--------------------------------------------------------------------------------
1 | com.fingerprints.extension::IFingerprintEngineering u:object_r:hal_fingerprint_hwservice:s0
2 | com.fingerprints.extension::IFingerprintSensorTest u:object_r:hal_fingerprint_hwservice:s0
3 | com.fingerprints.extension::IFingerprintNavigation u:object_r:hal_fingerprint_hwservice:s0
4 | com.fingerprints.extension::IFingerprintCalibration u:object_r:hal_fingerprint_hwservice:s0
5 | com.fingerprints.extension::IFingerprintSenseTouch u:object_r:hal_fingerprint_hwservice:s0
6 | vendor.goodix.hardware.fingerprintextension::IGoodixBiometricsFingerprint u:object_r:hal_fingerprint_hwservice:s0
7 | vendor.goodix.hardware.biometrics.fingerprint::IGoodixFingerprintDaemon u:object_r:hal_fingerprint_hwservice:s0
8 | vendor.goodix.hardware.biometrics.fingerprint::IGoodixFingerprintDaemonExt u:object_r:hal_fingerprint_hwservice:s0
9 | vendor.synaptics.fingerprints.interfaces.extensions::ISensorTest u:object_r:hal_fingerprint_hwservice:s0
10 | vendor.synaptics.fingerprints.interfaces.extensions::INavigation u:object_r:hal_fingerprint_hwservice:s0
11 | vendor.synaptics.fingerprints.interfaces.extensions::IFpCollection u:object_r:hal_fingerprint_hwservice:s0
12 |
13 | vendor.xiaomi.hardware.mlipay::IMlipayService u:object_r:hal_mlipay_hwservice:s0
14 |
--------------------------------------------------------------------------------
/sepolicy/vendor/init.te:
--------------------------------------------------------------------------------
1 | allow init socket_device:sock_file { unlink setattr create };
2 |
3 | dontaudit init { bt_firmware_file firmware_file }:filesystem getattr;
4 |
--------------------------------------------------------------------------------
/sepolicy/vendor/lhd.te:
--------------------------------------------------------------------------------
1 | type lhd, domain;
2 | type lhd_exec, exec_type, vendor_file_type, file_type;
3 |
4 | init_daemon_domain(lhd)
5 | net_domain(lhd)
6 |
7 | allow lhd gps_data_file:dir create_dir_perms;
8 | allow lhd gps_data_file:fifo_file create_file_perms;
9 | allow lhd gps_data_file:file create_file_perms;
10 |
11 | allow lhd gps_device:chr_file rw_file_perms;
12 | allow lhd sysfs_gps:file rw_file_perms;
13 |
14 | wakelock_use(lhd)
15 |
--------------------------------------------------------------------------------
/sepolicy/vendor/mm-pp-daemon.te:
--------------------------------------------------------------------------------
1 | get_prop(mm-pp-daemon, vendor_dpps_prop)
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/pocketmode_app.te:
--------------------------------------------------------------------------------
1 | type pocketmode_app, domain;
2 |
3 | app_domain(pocketmode_app)
4 |
5 | # Allow pocketmode_app to find app_api_service
6 | allow pocketmode_app app_api_service:service_manager find;
7 |
8 | # Allow pocketmode_app read and write /data/data subdirectory
9 | allow pocketmode_app system_app_data_file:dir create_dir_perms;
10 | allow pocketmode_app system_app_data_file:{ file lnk_file } create_file_perms;
11 |
12 | # Allow pocketmode_app to write to sysfs fingerprint nodes
13 | allow pocketmode_app sysfs_fingerprint:file { w_file_perms getattr };
14 |
--------------------------------------------------------------------------------
/sepolicy/vendor/priv_app.te:
--------------------------------------------------------------------------------
1 | dontaudit priv_app { bt_firmware_file firmware_file }:filesystem getattr;
2 | dontaudit priv_app mnt_vendor_file:dir search;
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/property.te:
--------------------------------------------------------------------------------
1 | vendor_internal_prop(camera_dbg_prop)
2 | vendor_internal_prop(camera_ro_prop)
3 |
4 | vendor_internal_prop(thermal_engine_prop)
5 |
6 | vendor_internal_prop(vendor_dpps_prop)
7 |
8 | vendor_public_prop(vendor_fp_prop)
9 |
--------------------------------------------------------------------------------
/sepolicy/vendor/property_contexts:
--------------------------------------------------------------------------------
1 | # Camera
2 | camera. u:object_r:camera_prop:s0
3 | persist.camera. u:object_r:camera_prop:s0
4 | persist.debug.sf.showfps u:object_r:camera_dbg_prop:s0
5 | persist.vendor.camera. u:object_r:camera_prop:s0
6 | vidhance. u:object_r:camera_prop:s0
7 |
8 | # Display post processing
9 | init.svc.ppd u:object_r:vendor_dpps_prop:s0
10 | ro.vendor.display.ad u:object_r:vendor_dpps_prop:s0
11 | ro.vendor.display.ad.sdr_calib_data u:object_r:vendor_dpps_prop:s0
12 | ro.vendor.display.ad.hdr_calib_data u:object_r:vendor_dpps_prop:s0
13 | ro.vendor.display.sensortype u:object_r:vendor_dpps_prop:s0
14 |
15 | # Fingerprint
16 | fpc_kpi u:object_r:vendor_fp_prop:s0
17 | gf.debug. u:object_r:vendor_fp_prop:s0
18 | persist.sys.fp.goodix. u:object_r:vendor_fp_prop:s0
19 | persist.vendor.sys.fp. u:object_r:vendor_fp_prop:s0
20 | ro.hardware.fp u:object_r:vendor_fp_prop:s0
21 | vendor.fps_hal. u:object_r:vendor_fp_prop:s0
22 |
23 | # Google camera hal read only props
24 | ro.camera.res.fmq.size u:object_r:camera_ro_prop:s0
25 | ro.camera.req.fmq.size u:object_r:camera_ro_prop:s0
26 | ro.vendor.camera. u:object_r:camera_ro_prop:s0
27 |
28 | # MIUI specific
29 | ro.boot.factorybuild u:object_r:exported_default_prop:s0
30 | ro.boot.hwversion u:object_r:exported_default_prop:s0
31 | ro.carrier.name u:object_r:exported_default_prop:s0
32 | ro.miui.cust_variant u:object_r:exported_default_prop:s0
33 |
34 | # Mlipay
35 | persist.vendor.sys.pay.ifaa u:object_r:vendor_tee_listener_prop:s0
36 |
37 | # Sensors
38 | persist.sensor.sardisable u:object_r:sensors_prop:s0
39 |
40 | # Thermal
41 | persist.sys.thermal. u:object_r:thermal_engine_prop:s0
42 | sys.thermal. u:object_r:thermal_engine_prop:s0
43 |
--------------------------------------------------------------------------------
/sepolicy/vendor/radio.te:
--------------------------------------------------------------------------------
1 | allow radio { hal_datafactory_hwservice hal_iwlan_hwservice }:hwservice_manager find;
2 | allow radio { cameraserver_service mediaextractor_service mediaserver_service mediametrics_service drmserver_service audioserver_service }:service_manager find;
3 |
4 | binder_call(radio, cnd)
5 | binder_call(radio, gpuservice)
6 | binder_call(radio, hal_imsrtp)
7 |
8 | get_prop(radio, qcom_ims_prop)
9 |
--------------------------------------------------------------------------------
/sepolicy/vendor/remosaic_daemon.te:
--------------------------------------------------------------------------------
1 | type remosaic_daemon, domain;
2 | type remosaic_daemon_exec, exec_type, vendor_file_type, file_type;
3 |
4 | init_daemon_domain(remosaic_daemon)
5 |
6 | vndbinder_use(remosaic_daemon)
7 |
8 | allow remosaic_daemon remosaic_daemon_service:service_manager add;
9 |
--------------------------------------------------------------------------------
/sepolicy/vendor/rild.te:
--------------------------------------------------------------------------------
1 | dontaudit rild tombstone_data_file:dir search;
2 | dontaudit rild vendor_file:file ioctl;
3 |
4 | set_prop(rild, deviceid_prop)
5 |
--------------------------------------------------------------------------------
/sepolicy/vendor/sensors.te:
--------------------------------------------------------------------------------
1 | allow sensors proc_tp:file r_file_perms;
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/system_server.te:
--------------------------------------------------------------------------------
1 | binder_call(system_server, glgps)
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/tee.te:
--------------------------------------------------------------------------------
1 | allow tee fingerprint_data_file:dir create_dir_perms;
2 | allow tee fingerprint_data_file:file create_file_perms;
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/thermal-engine.te:
--------------------------------------------------------------------------------
1 | allow thermal-engine thermal_data_file:dir rw_dir_perms;
2 | allow thermal-engine thermal_data_file:file create_file_perms;
3 |
4 | allow thermal-engine self:capability { chown fowner };
5 | allow thermal-engine sysfs_devfreq:dir r_dir_perms;
6 |
7 | set_prop(thermal-engine, thermal_engine_prop)
8 |
9 | dontaudit thermal-engine sysfs:dir read;
10 | dontaudit thermal-engine self:capability dac_override;
11 |
--------------------------------------------------------------------------------
/sepolicy/vendor/vendor_init.te:
--------------------------------------------------------------------------------
1 | # Allow vendor_init to write to sysfs_ssr_toggle
2 | allow vendor_init sysfs_ssr_toggle:file w_file_perms;
3 |
4 | allow vendor_init proc_sched:file w_file_perms;
5 | allow vendor_init proc_watermark_scale_factor:file w_file_perms;
6 |
--------------------------------------------------------------------------------
/sepolicy/vendor/vndservice.te:
--------------------------------------------------------------------------------
1 | type remosaic_daemon_service, vndservice_manager_type;
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/vndservice_contexts:
--------------------------------------------------------------------------------
1 | android.IRemosaicDaemon u:object_r:remosaic_daemon_service:s0
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/vold.te:
--------------------------------------------------------------------------------
1 | # For setting read_ahead_kb
2 | allow vold sysfs_mmc_host:file w_file_perms;
3 |
--------------------------------------------------------------------------------
/sepolicy/vendor/vppservice.te:
--------------------------------------------------------------------------------
1 | hal_client_domain(vendor_vppservice, hal_capabilityconfigstore_qti)
2 |
--------------------------------------------------------------------------------
/sepolicy/vendor/wcnss_service.te:
--------------------------------------------------------------------------------
1 | allow wcnss_service vendor_convergence_data_file:dir create_dir_perms;
2 | allow wcnss_service vendor_convergence_data_file:file create_file_perms;
3 |
--------------------------------------------------------------------------------
/setup-makefiles.py:
--------------------------------------------------------------------------------
1 | #!./extract-files.py --regenerate_makefiles
2 |
--------------------------------------------------------------------------------
/system.prop:
--------------------------------------------------------------------------------
1 | # Audio
2 | audio.deep_buffer.media=true
3 | audio.offload.min.duration.secs=30
4 | audio.offload.video=true
5 | ro.af.client_heap_size_kbyte=7168
6 | ro.config.media_vol_steps=25
7 | ro.config.vc_call_vol_steps=11
8 |
9 | # Bluetooth
10 | ro.bluetooth.a2dp_offload.supported=true
11 |
12 | # Camera
13 | camera.disable_zsl_mode=true
14 |
15 | # Data modules
16 | persist.data.df.dev_name=rmnet_usb0
17 | persist.vendor.data.mode=concurrent
18 | ro.vendor.use_data_netmgrd=true
19 |
20 | # Display post-processing
21 | ro.qualcomm.cabl=0
22 | ro.vendor.display.ad=1
23 | ro.vendor.display.ad.hdr_calib_data=/vendor/etc/hdr_config.cfg
24 | ro.vendor.display.ad.sdr_calib_data=/vendor/etc/sdr_config.cfg
25 | ro.vendor.display.sensortype=2
26 |
27 | # fastbootd
28 | ro.fastbootd.available=true
29 |
30 | # Graphics
31 | debug.sf.auto_latch_unsignaled=0
32 | debug.sf.early_app_phase_offset_ns=500000
33 | debug.sf.early_gl_app_phase_offset_ns=15000000
34 | debug.sf.early_gl_phase_offset_ns=3000000
35 | debug.sf.early_phase_offset_ns=500000
36 | debug.sf.enable_hwc_vds=1
37 | debug.sf.latch_unsignaled=1
38 | persist.demo.hdmirotationlock=false
39 | persist.sys.sf.native_mode=0
40 | ro.surface_flinger.enable_frame_rate_override=false
41 | ro.surface_flinger.force_hwc_copy_for_virtual_displays=true
42 | ro.surface_flinger.max_frame_buffer_acquired_buffers=2
43 | ro.surface_flinger.max_virtual_display_dimension=4096
44 | sdm.debug.disable_inline_rotator=1
45 | sdm.debug.disable_inline_rotator_secure=1
46 |
47 | # IMS
48 | persist.vendor.ims.disableUserAgent=0
49 |
50 | # Media
51 | media.settings.xml=/vendor/etc/media_profiles_vendor.xml
52 |
53 | # Memory optimizations
54 | ro.vendor.qti.sys.fw.bservice_enable=true
55 |
56 | # QC framework value-adds
57 | ro.vendor.qti.va_aosp.support=1
58 |
59 | # RCS
60 | persist.rcs.supported=0
61 |
62 | # RIL
63 | DEVICE_PROVISIONED=1
64 | persist.radio.multisim.config=dsds
65 | persist.vendor.radio.apm_sim_not_pwdn=1
66 | persist.vendor.radio.custom_ecc=1
67 | persist.vendor.radio.flexmap_type=none
68 | persist.vendor.radio.force_on_dc=true
69 | persist.vendor.radio.procedure_bytes=SKIP
70 | persist.vendor.radio.rat_on=combine
71 | persist.vendor.radio.report_codec=1
72 | persist.vendor.radio.sib16_support=1
73 | ril.subscription.types=NV,RUIM
74 | ro.com.android.dataroaming=true
75 | ro.telephony.default_network=22,22
76 | telephony.lteOnCdmaDevice=1
77 |
--------------------------------------------------------------------------------
/system_ext.prop:
--------------------------------------------------------------------------------
1 | # DPM
2 | persist.vendor.dpm.feature=11
3 | persist.vendor.dpm.loglevel=0
4 |
--------------------------------------------------------------------------------
/udfps/Android.bp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2022 The LineageOS Project
3 | //
4 | // SPDX-License-Identifier: Apache-2.0
5 | //
6 |
7 | cc_library {
8 | name: "libudfpshandler",
9 | vendor: true,
10 | srcs: ["UdfpsHandler.cpp"],
11 | shared_libs: [
12 | "libbase",
13 | ],
14 | header_libs: [
15 | "//hardware/xiaomi:xiaomifingerprint_headers",
16 | ],
17 | }
18 |
--------------------------------------------------------------------------------
/udfps/UdfpsHandler.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 The LineageOS Project
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | #define LOG_TAG "UdfpsHandler.xiaomi_sdm845"
8 |
9 | #include "UdfpsHandler.h"
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | #define COMMAND_NIT 10
18 | #define PARAM_NIT_FOD 1
19 | #define PARAM_NIT_NONE 0
20 |
21 | #define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui"
22 |
23 | static bool readBool(int fd) {
24 | char c;
25 | int rc;
26 |
27 | rc = lseek(fd, 0, SEEK_SET);
28 | if (rc) {
29 | LOG(ERROR) << "failed to seek fd, err: " << rc;
30 | return false;
31 | }
32 |
33 | rc = read(fd, &c, sizeof(char));
34 | if (rc != 1) {
35 | LOG(ERROR) << "failed to read bool from fd, err: " << rc;
36 | return false;
37 | }
38 |
39 | return c != '0';
40 | }
41 |
42 | class XiaomiUdfpsHander : public UdfpsHandler {
43 | public:
44 | void init(fingerprint_device_t *device) {
45 | mDevice = device;
46 |
47 | std::thread([this]() {
48 | int fd = open(FOD_UI_PATH, O_RDONLY);
49 | if (fd < 0) {
50 | LOG(ERROR) << "failed to open fd, err: " << fd;
51 | return;
52 | }
53 |
54 | struct pollfd fodUiPoll = {
55 | .fd = fd,
56 | .events = POLLERR | POLLPRI,
57 | .revents = 0,
58 | };
59 |
60 | while (true) {
61 | int rc = poll(&fodUiPoll, 1, -1);
62 | if (rc < 0) {
63 | LOG(ERROR) << "failed to poll fd, err: " << rc;
64 | continue;
65 | }
66 |
67 | mDevice->extCmd(mDevice, COMMAND_NIT,
68 | readBool(fd) ? PARAM_NIT_FOD : PARAM_NIT_NONE);
69 | }
70 | }).detach();
71 | }
72 |
73 | void onFingerDown(uint32_t /*x*/, uint32_t /*y*/, float /*minor*/, float /*major*/) {
74 | // nothing
75 | }
76 |
77 | void onFingerUp() {
78 | // nothing
79 | }
80 |
81 | void onAcquired(int32_t /*result*/, int32_t /*vendorCode*/) {
82 | // nothing
83 | }
84 |
85 | void cancel() {
86 | // nothing
87 | }
88 |
89 | private:
90 | fingerprint_device_t *mDevice;
91 | };
92 |
93 | static UdfpsHandler* create() {
94 | return new XiaomiUdfpsHander();
95 | }
96 |
97 | static void destroy(UdfpsHandler* handler) {
98 | delete handler;
99 | }
100 |
101 | extern "C" UdfpsHandlerFactory UDFPS_HANDLER_FACTORY = {
102 | .create = create,
103 | .destroy = destroy,
104 | };
105 |
--------------------------------------------------------------------------------
/wifi/hostapd.accept:
--------------------------------------------------------------------------------
1 | # List of MAC addresses that are allowed to authenticate (IEEE 802.11)
2 | # with the AP. Optional VLAN ID can be assigned for clients based on the
3 | # MAC address if dynamic VLANs (hostapd.conf dynamic_vlan option) are used.
4 |
--------------------------------------------------------------------------------
/wifi/hostapd.deny:
--------------------------------------------------------------------------------
1 | # List of MAC addresses that are not allowed to authenticate (IEEE 802.11)
2 | # with the AP.
3 |
--------------------------------------------------------------------------------
/wifi/p2p_supplicant_overlay.conf:
--------------------------------------------------------------------------------
1 | disable_scan_offload=1
2 | p2p_no_group_iface=1
3 | persistent_reconnect=1
4 | bss_max_count=400
5 |
--------------------------------------------------------------------------------
/wifi/wpa_supplicant_overlay.conf:
--------------------------------------------------------------------------------
1 | disable_scan_offload=1
2 | p2p_disabled=1
3 | tdls_external_control=1
4 | wowlan_triggers=magic_pkt
5 | bss_max_count=400
6 | config_methods=virtual_display virtual_push_button keypad
7 | driver_param=use_p2p_group_interface=1
8 |
--------------------------------------------------------------------------------