summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2024-01-17 22:12:35 -0800
committerXin Li <delphij@google.com>2024-01-17 22:12:35 -0800
commit04ea7c073b3100a3fbe4662c18c55d27776fea97 (patch)
tree9c992ceedf2e048b9ff350f924fde87218eecb06
parentf8305476c5dfcc1824be86111e89bca46da73cf2 (diff)
parent93d9eb0a8f74ce233918f591a2eb022c3e1a9a56 (diff)
downloadgs101-temp_319669529.tar.gz
Merge Android 24Q1 Release (ab/11220357)temp_319669529
Bug: 319669529 Merged-In: I29c352696cd9d31168a8eac8c58d23adb484f5d0 Change-Id: Id43ef0c972cab098f056e418cee940b702a1f251
-rw-r--r--BoardConfig-common.mk2
-rw-r--r--OWNERS2
-rw-r--r--PREUPLOAD.cfg2
-rw-r--r--conf/init.gs101.rc194
-rw-r--r--conf/init.gs101.usb.rc2
-rw-r--r--conf/ueventd.gs101.rc29
-rw-r--r--device-common.mk1
-rw-r--r--device.mk31
-rw-r--r--device_framework_matrix_product.xml23
-rw-r--r--dumpstate/dump_gs101.sh61
-rw-r--r--fingerprint/udfps_common.mk35
-rw-r--r--fingerprint/udfps_factory.mk25
-rw-r--r--fingerprint/udfps_shipping.mk21
-rw-r--r--fingerprint/vendor.goodix.hardware.biometrics.fingerprint@2.1-service.xml11
-rw-r--r--interfaces/boot/1.0/Android.bp66
-rw-r--r--interfaces/boot/1.0/BootControl.cpp272
-rw-r--r--interfaces/boot/1.0/BootControl.h59
-rw-r--r--interfaces/boot/1.0/GptUtils.cpp199
-rw-r--r--interfaces/boot/1.0/GptUtils.h79
-rw-r--r--interfaces/boot/1.0/android.hardware.boot@1.0-service-gs101.rc4
-rw-r--r--interfaces/boot/1.0/service.cpp47
-rw-r--r--interfaces/boot/1.2/Android.bp81
-rw-r--r--interfaces/boot/1.2/BootControl.cpp437
-rw-r--r--interfaces/boot/1.2/BootControl.h69
-rw-r--r--interfaces/boot/1.2/DevInfo.h61
-rw-r--r--interfaces/boot/1.2/GptUtils.cpp193
-rw-r--r--interfaces/boot/1.2/GptUtils.h79
-rw-r--r--interfaces/boot/1.2/android.hardware.boot@1.2-service-gs101.rc7
-rw-r--r--interfaces/boot/1.2/service.cpp50
-rw-r--r--manifest.xml5
-rw-r--r--manifest_64.xml5
-rw-r--r--media_codecs_performance_c2.xml6
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml31
-rw-r--r--pixelstats/service.cpp1
-rw-r--r--preinstalled-packages-product-gs101-device-debug.xml10
-rw-r--r--task_profiles.json52
-rw-r--r--tts/de-de/de-de-x-multi-r43.zvoicebin13656899 -> 0 bytes
-rw-r--r--tts/es-es/es-es-x-multi-r43.zvoicebin6980057 -> 0 bytes
-rw-r--r--tts/fr-fr/fr-fr-x-multi-r44.zvoicebin15235885 -> 0 bytes
-rw-r--r--tts/it-it/it-it-x-multi-r40.zvoicebin9236946 -> 0 bytes
-rw-r--r--tts/ja-jp/ja-jp-x-multi-r42.zvoicebin23955700 -> 0 bytes
-rw-r--r--tts/voice_packs.mk22
-rw-r--r--usb/gadget/UsbGadget.cpp136
-rw-r--r--usb/gadget/UsbGadget.h5
-rw-r--r--usb/gadget/android.hardware.usb.gadget-service.rc18
-rw-r--r--usb/usb/Android.bp17
-rw-r--r--usb/usb/Usb.cpp214
-rw-r--r--usb/usb/Usb.h8
-rw-r--r--usb/usb/UsbDataSessionMonitor.cpp420
-rw-r--r--usb/usb/UsbDataSessionMonitor.h114
-rw-r--r--usb/usb/android.hardware.usb-service.rc156
-rw-r--r--usb/usb/android.hardware.usb-service.xml2
52 files changed, 1061 insertions, 2303 deletions
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk
index 70e9d648..d94a6190 100644
--- a/BoardConfig-common.mk
+++ b/BoardConfig-common.mk
@@ -200,7 +200,7 @@ $(call soong_config_set,aoc_audio_func,ext_hidl,true)
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
$(call soong_config_set,aoc_audio_func,dump_usecase_data,true)
$(call soong_config_set,aoc_audio_func,hal_socket_control,true)
-$(call soong_config_set,aoc_audio_func,record_tunning_keys,true)
+$(call soong_config_set,aoc_audio_func,record_tuning_keys,true)
endif
ifneq (,$(filter aosp_%,$(TARGET_PRODUCT)))
diff --git a/OWNERS b/OWNERS
index 68657e89..feed301f 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,4 +2,4 @@ per-file powerhint.json = wvw@google.com,joaodias@google.com,jenhaochen@google.c
per-file powerhint.json = wvw@google.com,joaodias@google.com,jenhaochen@google.com,rkganesh@google.com,jychen@google.com
# per-file for Pixel device makefiles, see go/pixel-device-mk-owner-checklist for details.
-per-file *.mk=file:device/google/gs-common:master:/OWNERS
+per-file *.mk=file:device/google/gs-common:main:/OWNERS
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 00000000..37ebb5e7
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,2 @@
+[Builtin Hooks]
+jsonlint = true
diff --git a/conf/init.gs101.rc b/conf/init.gs101.rc
index 9b0e1338..13a01b27 100644
--- a/conf/init.gs101.rc
+++ b/conf/init.gs101.rc
@@ -23,30 +23,30 @@ on init
write /dev/sys/fs/by-name/userdata/data_io_flag 56
write /dev/sys/fs/by-name/userdata/node_io_flag 56
- chown system system /proc/vendor_sched/set_task_group_bg
- chown system system /proc/vendor_sched/set_task_group_cam
- chown system system /proc/vendor_sched/set_task_group_fg
- chown system system /proc/vendor_sched/set_task_group_nnapi
- chown system system /proc/vendor_sched/set_task_group_sys
- chown system system /proc/vendor_sched/set_task_group_sysbg
- chown system system /proc/vendor_sched/set_task_group_ta
- chown system system /proc/vendor_sched/set_task_group_rt
- chown system system /proc/vendor_sched/set_task_group_sf
- chown system system /proc/vendor_sched/set_task_group_dex2oat
- chown system system /proc/vendor_sched/set_task_group_cam_power
- chown system system /proc/vendor_sched/set_task_group_ota
- chown system system /proc/vendor_sched/set_proc_group_bg
- chown system system /proc/vendor_sched/set_proc_group_cam
- chown system system /proc/vendor_sched/set_proc_group_fg
- chown system system /proc/vendor_sched/set_proc_group_nnapi
- chown system system /proc/vendor_sched/set_proc_group_sys
- chown system system /proc/vendor_sched/set_proc_group_sysbg
- chown system system /proc/vendor_sched/set_proc_group_ta
- chown system system /proc/vendor_sched/set_proc_group_rt
- chown system system /proc/vendor_sched/set_proc_group_sf
- chown system system /proc/vendor_sched/set_proc_group_dex2oat
- chown system system /proc/vendor_sched/set_proc_group_cam_power
- chown system system /proc/vendor_sched/set_proc_group_ota
+ chown system system /proc/vendor_sched/groups/bg/set_task_group
+ chown system system /proc/vendor_sched/groups/cam/set_task_group
+ chown system system /proc/vendor_sched/groups/fg/set_task_group
+ chown system system /proc/vendor_sched/groups/nnapi/set_task_group
+ chown system system /proc/vendor_sched/groups/sys/set_task_group
+ chown system system /proc/vendor_sched/groups/sys_bg/set_task_group
+ chown system system /proc/vendor_sched/groups/ta/set_task_group
+ chown system system /proc/vendor_sched/groups/rt/set_task_group
+ chown system system /proc/vendor_sched/groups/sf/set_task_group
+ chown system system /proc/vendor_sched/groups/dex2oat/set_task_group
+ chown system system /proc/vendor_sched/groups/cam_power/set_task_group
+ chown system system /proc/vendor_sched/groups/ota/set_task_group
+ chown system system /proc/vendor_sched/groups/bg/set_proc_group
+ chown system system /proc/vendor_sched/groups/cam/set_proc_group
+ chown system system /proc/vendor_sched/groups/fg/set_proc_group
+ chown system system /proc/vendor_sched/groups/nnapi/set_proc_group
+ chown system system /proc/vendor_sched/groups/sys/set_proc_group
+ chown system system /proc/vendor_sched/groups/sys_bg/set_proc_group
+ chown system system /proc/vendor_sched/groups/ta/set_proc_group
+ chown system system /proc/vendor_sched/groups/rt/set_proc_group
+ chown system system /proc/vendor_sched/groups/sf/set_proc_group
+ chown system system /proc/vendor_sched/groups/dex2oat/set_proc_group
+ chown system system /proc/vendor_sched/groups/cam_power/set_proc_group
+ chown system system /proc/vendor_sched/groups/ota/set_proc_group
chown system system /proc/vendor_sched/prefer_idle_set
chown system system /proc/vendor_sched/prefer_idle_clear
chown system system /proc/vendor_sched/pmu_poll_enable
@@ -72,30 +72,30 @@ on init
chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware
chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware
- chmod 0220 /proc/vendor_sched/set_task_group_bg
- chmod 0220 /proc/vendor_sched/set_task_group_cam
- chmod 0220 /proc/vendor_sched/set_task_group_fg
- chmod 0220 /proc/vendor_sched/set_task_group_nnapi
- chmod 0220 /proc/vendor_sched/set_task_group_sys
- chmod 0220 /proc/vendor_sched/set_task_group_sysbg
- chmod 0220 /proc/vendor_sched/set_task_group_ta
- chmod 0220 /proc/vendor_sched/set_task_group_rt
- chmod 0220 /proc/vendor_sched/set_task_group_sf
- chmod 0220 /proc/vendor_sched/set_task_group_dex2oat
- chmod 0220 /proc/vendor_sched/set_task_group_cam_power
- chmod 0220 /proc/vendor_sched/set_task_group_ota
- chmod 0220 /proc/vendor_sched/set_proc_group_bg
- chmod 0220 /proc/vendor_sched/set_proc_group_cam
- chmod 0220 /proc/vendor_sched/set_proc_group_fg
- chmod 0220 /proc/vendor_sched/set_proc_group_nnapi
- chmod 0220 /proc/vendor_sched/set_proc_group_sys
- chmod 0220 /proc/vendor_sched/set_proc_group_sysbg
- chmod 0220 /proc/vendor_sched/set_proc_group_ta
- chmod 0220 /proc/vendor_sched/set_proc_group_rt
- chmod 0220 /proc/vendor_sched/set_proc_group_sf
- chmod 0220 /proc/vendor_sched/set_proc_group_dex2oat
- chmod 0220 /proc/vendor_sched/set_proc_group_cam_power
- chmod 0220 /proc/vendor_sched/set_proc_group_ota
+ chmod 0220 /proc/vendor_sched/groups/bg/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/cam/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/fg/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/nnapi/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/sys/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/sys_bg/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/ta/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/rt/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/sf/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/dex2oat/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/cam_power/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/ota/set_task_group
+ chmod 0220 /proc/vendor_sched/groups/bg/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/cam/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/fg/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/nnapi/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/sys/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/sys_bg/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/ta/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/rt/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/sf/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/dex2oat/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/cam_power/set_proc_group
+ chmod 0220 /proc/vendor_sched/groups/ota/set_proc_group
chmod 0220 /proc/vendor_sched/prefer_idle_set
chmod 0220 /proc/vendor_sched/prefer_idle_clear
chmod 0220 /proc/vendor_sched/pmu_poll_enable
@@ -161,12 +161,12 @@ on init
mkdir /dev/socket/pdx/system/vr/sensors 0775 system system
# Boot time 183626384
- write /proc/vendor_sched/ta_uclamp_min 161
- write /proc/vendor_sched/ta_prefer_idle 1
- write /proc/vendor_sched/fg_uclamp_min 161
- write /proc/vendor_sched/fg_prefer_idle 1
- write /proc/vendor_sched/sys_uclamp_min 161
- write /proc/vendor_sched/sys_prefer_idle 1
+ write /proc/vendor_sched/groups/ta/uclamp_min 161
+ write /proc/vendor_sched/groups/ta/prefer_idle 1
+ write /proc/vendor_sched/groups/fg/uclamp_min 161
+ write /proc/vendor_sched/groups/fg/prefer_idle 1
+ write /proc/vendor_sched/groups/sys/uclamp_min 161
+ write /proc/vendor_sched/groups/sys/prefer_idle 1
# governor setting
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor sched_pixel
@@ -217,8 +217,8 @@ on init
chown system system /dev/cpuset/camera-daemon-mid-high-group/tasks
chmod 0664 /dev/cpuset/camera-daemon-mid-high-group/tasks
- write /proc/vendor_sched/cam_prefer_idle 1
- write /proc/vendor_sched/cam_uclamp_min 1
+ write /proc/vendor_sched/groups/cam/prefer_idle 1
+ write /proc/vendor_sched/groups/cam/uclamp_min 1
chown system system /dev/cpuset/cgroup.procs
@@ -252,14 +252,6 @@ on init
chown system system /sys/class/power_supply/maxfg/m5_model_state
chown system system /sys/class/power_supply/maxfg_base/m5_model_state
- # Dump eeprom
- chown system system /sys/devices/platform/10970000.hsi2c/i2c-8/8-0050/eeprom
- chown system system /sys/devices/platform/10970000.hsi2c/i2c-7/7-0050/eeprom
- chown system system /sys/devices/platform/10970000.hsi2c/i2c-6/6-0050/eeprom
- chown system system /sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom
- chown system system /sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom
- chown system system /dev/battery_history
-
# Modem temperature driver
chown radio system /sys/devices/platform/cp-tm1/cp_temp
@@ -342,8 +334,8 @@ on init
chown system system /dev/bbd_pwrstat
# Add a boost for NNAPI HAL
- write /proc/vendor_sched/nnapi_prefer_idle 0
- write /proc/vendor_sched/nnapi_uclamp_min 512
+ write /proc/vendor_sched/groups/nnapi/prefer_idle 0
+ write /proc/vendor_sched/groups/nnapi/uclamp_min 512
# Add memlat governor settings
write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/polling_interval 10
@@ -467,7 +459,7 @@ on post-fs-data
on zygote-start
# For PixelLogger configuration file.
chmod 0771 /data/vendor/wifi
- write /proc/vendor_sched/sys_uclamp_min 0
+ write /proc/vendor_sched/groups/sys/uclamp_min 0
on post-fs-data
# Create the directories used by the Wireless subsystem
@@ -614,6 +606,7 @@ on fs
chown system system /sys/devices/platform/exynos-drm/primary-panel/idle_delay_ms
chown system system /sys/devices/platform/exynos-drm/primary-panel/panel_need_handle_idle_exit
chown system system /sys/module/drm/parameters/vblankoffdelay
+ chown system system /sys/module/drm/parameters/debug
chown system system /sys/class/dqe0/atc/ambient_light
chown system system /sys/class/dqe0/atc/st
chown system system /sys/class/dqe0/atc/en
@@ -745,25 +738,25 @@ on property:sys.boot_completed=1
setprop vendor.powerhal.init 1
# Setup final cpu.uclamp
- write /proc/vendor_sched/ta_uclamp_min 1
- write /proc/vendor_sched/fg_uclamp_min 0
- write /proc/vendor_sched/sys_prefer_idle 0
+ write /proc/vendor_sched/groups/ta/uclamp_min 1
+ write /proc/vendor_sched/groups/fg/uclamp_min 0
+ write /proc/vendor_sched/groups/sys/prefer_idle 0
# Set ug group
- write /proc/vendor_sched/bg_ug 0
- write /proc/vendor_sched/sysbg_ug 0
- write /proc/vendor_sched/ota_ug 0
- write /proc/vendor_sched/dex2oat_ug 1
- write /proc/vendor_sched/ta_ug 1
+ write /proc/vendor_sched/groups/bg/ug 0
+ write /proc/vendor_sched/groups/sys_bg/ug 0
+ write /proc/vendor_sched/groups/ota/ug 0
+ write /proc/vendor_sched/groups/dex2oat/ug 1
+ write /proc/vendor_sched/groups/ta/ug 1
# Set bg group throttle
write /proc/vendor_sched/ug_bg_group_throttle ${persist.device_config.vendor_system_native.ug_bg_group_throttle:-308}
# Set uclamp.max for some groups, which could indicate cpu importance used in scheduling
- write /proc/vendor_sched/bg_uclamp_max 512
- write /proc/vendor_sched/sysbg_uclamp_max 512
- write /proc/vendor_sched/ota_uclamp_max 512
- write /proc/vendor_sched/dex2oat_uclamp_max 615
+ write /proc/vendor_sched/groups/bg/uclamp_max 512
+ write /proc/vendor_sched/groups/sys_bg/uclamp_max 512
+ write /proc/vendor_sched/groups/ota/uclamp_max 512
+ write /proc/vendor_sched/groups/dex2oat/uclamp_max 615
# Set PMU freq limit parameters
write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/lcpi_threshold 2
@@ -880,23 +873,6 @@ on post-fs-data
chown bluetooth system /proc/bluetooth/sleep/btwrite
mkdir /data/vendor/bluetooth 0770 bluetooth system
-# ODPM
-on fs
- chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-0/i2c-s2mpg10mfd/s2mpg10-meter/s2mpg10-odpm/iio:device1/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-0/0-001f/s2mpg10-meter/s2mpg10-odpm/iio:device1/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-1/i2c-s2mpg11mfd/s2mpg11-meter/s2mpg11-odpm/iio:device0/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-1/1-002f/s2mpg11-meter/s2mpg11-odpm/iio:device0/enabled_rails
-
- chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-6/i2c-s2mpg10mfd/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-6/6-001f/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-7/i2c-s2mpg11mfd/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-7/7-002f/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails
-
- chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-7/i2c-s2mpg10mfd/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-7/7-001f/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-8/i2c-s2mpg11mfd/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails
- chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-8/8-002f/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails
-
on post-fs-data
mkdir /data/vendor/powerstats 0771 system system
chown system system /data/vendor/powerstats
@@ -906,11 +882,11 @@ on post-fs-data
on property:vendor.thermal.link_ready=1
# BCL
- write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_light_clk_ratio 0xfff041c5
- write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_light_clk_ratio 0xfff041c5
- write /sys/devices/virtual/pmic/mitigation/clock_ratio/gpu_heavy_clk_ratio 0xfff04385
- write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_heavy_clk_ratio 0xfff041c3
- write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_heavy_clk_ratio 0xfff041c3
+ write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_light_clk_ratio 0x80041c3
+ write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_light_clk_ratio 0xfff041c3
+ write /sys/devices/virtual/pmic/mitigation/clock_ratio/gpu_heavy_clk_ratio 0xfff04381
+ write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_heavy_clk_ratio 0xfff041c1
+ write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_heavy_clk_ratio 0xfff041c0
write /dev/thermal/tz-by-name/smpl_gm/policy user_space
write /dev/thermal/tz-by-name/vdroop1/policy user_space
write /dev/thermal/tz-by-name/vdroop2/policy user_space
@@ -983,8 +959,8 @@ on property:vendor.thermal.link_ready=1
chown system system /dev/thermal/cdev-by-name/usbc-port/cur_state
on charger
- write /proc/vendor_sched/sys_uclamp_min 0
- write /proc/vendor_sched/sys_prefer_idle 0
+ write /proc/vendor_sched/groups/sys/uclamp_min 0
+ write /proc/vendor_sched/groups/sys/prefer_idle 0
# Use charger thermal config
setprop vendor.thermal.config "thermal_info_config_charge.json"
@@ -1011,12 +987,12 @@ on charger
# Cancel boot devfreq and uclamp
write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1
write /sys/devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int/exynos_data/cancel_boot_freq 1
- write /proc/vendor_sched/ta_uclamp_min 0
- write /proc/vendor_sched/ta_prefer_idle 0
- write /proc/vendor_sched/fg_uclamp_min 0
- write /proc/vendor_sched/fg_prefer_idle 0
- write /proc/vendor_sched/sys_uclamp_min 0
- write /proc/vendor_sched/sys_prefer_idle 0
+ write /proc/vendor_sched/groups/ta/uclamp_min 0
+ write /proc/vendor_sched/groups/ta/prefer_idle 0
+ write /proc/vendor_sched/groups/fg/uclamp_min 0
+ write /proc/vendor_sched/groups/fg/prefer_idle 0
+ write /proc/vendor_sched/groups/sys/uclamp_min 0
+ write /proc/vendor_sched/groups/sys/prefer_idle 0
# Enable SICD
write /sys/devices/system/cpu/cpupm/cpupm/sicd 1
diff --git a/conf/init.gs101.usb.rc b/conf/init.gs101.usb.rc
index 724019e2..69bbf493 100644
--- a/conf/init.gs101.usb.rc
+++ b/conf/init.gs101.usb.rc
@@ -368,6 +368,8 @@ on boot
write /config/usb_gadget/g1/bcdDevice 0x0510
# Use USB Gadget HAL
setprop sys.usb.configfs 2
+ # Enable in-kernel media-presence polling for SD cards
+ write /sys/module/block/parameters/events_dfl_poll_msecs 2000
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
write /config/usb_gadget/g1/idProduct 0x4EE7
diff --git a/conf/ueventd.gs101.rc b/conf/ueventd.gs101.rc
index 5e0b58ea..3a8e39d0 100644
--- a/conf/ueventd.gs101.rc
+++ b/conf/ueventd.gs101.rc
@@ -220,3 +220,32 @@
/sys/devices/platform/11110000.usb/11110000.dwc3/xhci-hcd-exynos.4.auto/usb2/2-1/*/*/leds/* brightness 0664 system system
/sys/devices/platform/11110000.usb/11110000.dwc3/xhci-hcd-exynos.4.auto/usb2/2-1/*/*/leds/* multi_intensity 0664 system system
+# Dump Battery EEPROM history for pixelstats
+/sys/devices/platform/10970000.hsi2c/i2c-7/7-0050 eeprom 0644 system system
+/dev/battery_history 0644 system system
+
+# ODPM
+/sys/bus/iio/devices/iio:device* enabled_rails 0660 system system
+
+# USB
+/sys/class/typec/port0 power_role 664 root system
+/sys/class/typec/port0 data_role 664 root system
+/sys/class/typec/port0 port_type 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc contaminant_detection 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc usb_limit_accessory_current 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc usb_limit_accessory_enable 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc usb_limit_sink_current 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc usb_limit_sink_enable 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc usb_limit_source_enable 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc update_sdp_enum_timeout 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 contaminant_detection 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 usb_limit_accessory_current 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 usb_limit_accessory_enable 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 usb_limit_sink_current 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 usb_limit_sink_enable 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 usb_limit_source_enable 664 root system
+/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025 update_sdp_enum_timeout 664 root system
+/sys/devices/platform/11110000.usb dwc3_exynos_otg_b_sess 664 root system
+/sys/devices/platform/11110000.usb dwc3_exynos_otg_id 664 root system
+/sys/devices/platform/11110000.usb usb_data_enabled 664 root system
+/sys/devices/platform/google,pogo move_data_to_usb 664 root system
diff --git a/device-common.mk b/device-common.mk
index ef90ca1a..4c925e59 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -18,7 +18,6 @@ ifneq ($(BOARD_WITHOUT_RADIO),true)
-include vendor/google_devices/gs101/proprietary/telephony/device-vendor.mk
endif
include device/google/gs101/device.mk
-include device/google/gs101/tts/voice_packs.mk
ifneq ($(BOARD_WITHOUT_RADIO),true)
# Telephony
diff --git a/device.mk b/device.mk
index 6db1d367..fe6fbbed 100644
--- a/device.mk
+++ b/device.mk
@@ -21,7 +21,8 @@ include device/google/gs-common/soc/soc.mk
include device/google/gs-common/soc/freq.mk
include device/google/gs-common/modem/modem.mk
include device/google/gs-common/aoc/aoc.mk
-include device/google/gs-common/thermal/thermal.mk
+include device/google/gs-common/thermal/dump/thermal.mk
+include device/google/gs-common/thermal/thermal_hal/device.mk
include device/google/gs-common/pixel_metrics/pixel_metrics.mk
include device/google/gs-common/performance/perf.mk
include device/google/gs-common/display/dump.mk
@@ -34,6 +35,7 @@ include device/google/gs-common/widevine/widevine.mk
include device/google/gs-common/sota_app/factoryota.mk
include device/google/gs-common/misc_writer/misc_writer.mk
include device/google/gs-common/gyotaku_app/gyotaku.mk
+include device/google/gs-common/bootctrl/bootctrl_aidl.mk
TARGET_BOARD_PLATFORM := gs101
DEVICE_IS_64BIT_ONLY ?= $(if $(filter %_64,$(TARGET_PRODUCT)),true,false)
@@ -200,6 +202,7 @@ PRODUCT_SOONG_NAMESPACES += \
$(call soong_config_set,pixel_mali,soc,$(TARGET_BOARD_PLATFORM))
+include device/google/gs-common/gpu/gpu.mk
PRODUCT_PACKAGES += \
libGLES_mali \
vulkan.mali \
@@ -253,6 +256,9 @@ PRODUCT_VENDOR_PROPERTIES += \
graphics.gpu.profiler.support=true \
debug.renderengine.backend=skiaglthreaded
+# b/295257834 Add HDR shaders to SurfaceFlinger's pre-warming cache
+PRODUCT_VENDOR_PROPERTIES += ro.surface_flinger.prime_shader_cache.ultrahdr=1
+
# GRAPHICS - GPU (end)
# ####################
@@ -505,7 +511,7 @@ PRODUCT_PACKAGES += \
# for now include gralloc here. should come from hardware/google_devices/exynos5
PRODUCT_PACKAGES += \
android.hardware.graphics.mapper@4.0-impl \
- android.hardware.graphics.allocator-V1-service
+ android.hardware.graphics.allocator-V2-service
PRODUCT_PACKAGES += \
android.hardware.memtrack-service.pixel \
@@ -846,10 +852,6 @@ PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_PRODUCT_PROPERTIES += \
persist.sys.fuse.passthrough.enable=true
-# Use FUSE BPF
-PRODUCT_PRODUCT_PROPERTIES += \
- ro.fuse.bpf.enabled=true
-
# Use /product/etc/fstab.postinstall to mount system_other
PRODUCT_PRODUCT_PROPERTIES += \
ro.postinstall.fstab.prefix=/product
@@ -892,19 +894,12 @@ PRODUCT_PACKAGES += ShannonIms
$(call inherit-product-if-exists, vendor/samsung_slsi/telephony/$(BOARD_USES_SHARED_VENDOR_TELEPHONY)/shannon-iwlan/device-vendor.mk)
-#RCS Test Messaging App
PRODUCT_PACKAGES_DEBUG += \
- preinstalled-packages-product-gs101-device-debug.xml \
- TestRcsApp
+ preinstalled-packages-product-gs101-device-debug.xml
PRODUCT_PACKAGES += ShannonRcs
endif
-# Boot Control HAL
-PRODUCT_PACKAGES += \
- android.hardware.boot@1.2-impl-gs101 \
- android.hardware.boot@1.2-service-gs101
-
# Exynos RIL and telephony
# Multi SIM(DSDS)
SIM_COUNT := 2
@@ -969,9 +964,6 @@ PRODUCT_COPY_FILES += \
PRODUCT_COPY_FILES += \
device/google/gs101/radio/gnss_blanking.csv:$(TARGET_COPY_OUT_VENDOR)/etc/modem/gnss_blanking.csv
-# ARM NN files
-ARMNN_COMPUTE_CL_ENABLE := 1
-
# Vibrator Diag
PRODUCT_PACKAGES_DEBUG += \
diag-vibrator \
@@ -1038,7 +1030,6 @@ PRODUCT_PACKAGES += \
libgc2_utils
# Thermal HAL
-include hardware/google/pixel/thermal/device.mk
PRODUCT_PROPERTY_OVERRIDES += persist.vendor.enable.thermal.genl=true
# EdgeTPU
@@ -1132,9 +1123,5 @@ PRODUCT_PROPERTY_OVERRIDES += \
# Call deleteAllKeys if vold detects a factory reset
PRODUCT_VENDOR_PROPERTIES += ro.crypto.metadata_init_delete_all_keys.enabled=true
-# Increase lmkd aggressiveness
-PRODUCT_PROPERTY_OVERRIDES += \
- ro.lmk.swap_free_low_percentage=100
-
# Hardware Info Collection
include hardware/google/pixel/HardwareInfo/HardwareInfo.mk
diff --git a/device_framework_matrix_product.xml b/device_framework_matrix_product.xml
index 732338c0..0533fb62 100644
--- a/device_framework_matrix_product.xml
+++ b/device_framework_matrix_product.xml
@@ -42,7 +42,7 @@
</hal>
<hal format="aidl" optional="true">
<name>com.google.face.debug</name>
- <version>4</version>
+ <version>3-4</version>
<interface>
<name>IDebugHost</name>
<instance>default</instance>
@@ -69,8 +69,16 @@
</interface>
</hal>
<hal format="aidl" optional="true">
+ <name>com.google.edgetpu.tachyon</name>
+ <version>1</version>
+ <interface>
+ <name>IComputeService</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="aidl" optional="true">
<name>com.google.hardware.pixel.display</name>
- <version>9</version>
+ <version>10</version>
<interface>
<name>IDisplay</name>
<instance>default</instance>
@@ -102,7 +110,7 @@
</hal>
<hal format="aidl" optional="true">
<name>vendor.google.google_battery</name>
- <version>2</version>
+ <version>2-3</version>
<interface>
<name>IGoogleBattery</name>
<instance>default</instance>
@@ -118,7 +126,7 @@
</hal>
<hal format="aidl" optional="true">
<name>vendor.google.wifi_ext</name>
- <version>1</version>
+ <version>2-3</version>
<interface>
<name>IWifiExt</name>
<instance>default</instance>
@@ -134,6 +142,13 @@
<instance>sced0</instance>
</interface>
</hal>
+ <hal format="aidl" optional="true">
+ <name>com.google.pixel.modem.logmasklibrary</name>
+ <interface>
+ <name>ILiboemserviceProxy</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<hal format="hidl" optional="true">
<name>vendor.samsung_slsi.telephony.hardware.radioExternal</name>
<version>1.1</version>
diff --git a/dumpstate/dump_gs101.sh b/dumpstate/dump_gs101.sh
index e6fdb015..43eaeaa1 100644
--- a/dumpstate/dump_gs101.sh
+++ b/dumpstate/dump_gs101.sh
@@ -35,7 +35,11 @@ cat "/sys/class/power_supply/main-charger/uevent"
echo "\n------ Power supply property pca9486-mains ------"
cat "/sys/class/power_supply/pca9468-mains/uevent"
echo "\n------ Power supply property tcpm ------"
-cat "/sys/class/power_supply/tcpm-source-psy-i2c-max77759tcpc/uevent"
+if [ -e "/sys/class/power_supply/tcpm-source-psy-i2c-max77759tcpc/uevent" ]; then
+ cat "/sys/class/power_supply/tcpm-source-psy-i2c-max77759tcpc/uevent"
+elif [ -e "/sys/class/power_supply/tcpm-source-psy-8-0025/uevent" ]; then
+ cat "/sys/class/power_supply/tcpm-source-psy-8-0025/uevent"
+fi
echo "\n------ Power supply property usb ------"
cat "/sys/class/power_supply/usb/uevent"
echo "\n------ Power supply property wireless ------"
@@ -89,23 +93,24 @@ then
fi
echo "\n------ TCPC ------"
-for f in /sys/devices/platform/10d50000.hsi2c/i2c-*/i2c-max77759tcpc
-do
- echo "registers:"
- cat $f/registers
- echo "frs:"
- cat $f/frs
- echo "auto_discharge:"
- cat $f/auto_discharge
- echo "bc12_enabled:"
- cat $f/bc12_enabled
- echo "cc_toggle_enable:"
- cat $f/cc_toggle_enable
- echo "contaminant_detection:"
- cat $f/contaminant_detection
- echo "contaminant_detection_status:"
- cat $f/contaminant_detection_status
-done
+max77759tcpc_path="/sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc"
+if [ -e "/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025" ]; then
+ max77759tcpc_path="/sys/devices/platform/10d50000.hsi2c/i2c-8/8-0025"
+fi
+echo "registers:"
+cat $max77759tcpc_path/registers
+echo "frs:"
+cat $max77759tcpc_path/frs
+echo "auto_discharge:"
+cat $max77759tcpc_path/auto_discharge
+echo "bc12_enabled:"
+cat $max77759tcpc_path/bc12_enabled
+echo "cc_toggle_enable:"
+cat $max77759tcpc_path/cc_toggle_enable
+echo "contaminant_detection:"
+cat $max77759tcpc_path/contaminant_detection
+echo "contaminant_detection_status:"
+cat $max77759tcpc_path/contaminant_detection_status
echo "\n------ PD Engine ------"
cat "/dev/logbuffer_usbpd"
@@ -199,26 +204,6 @@ then
fi
echo "\n------ Battery EEPROM ------"
-if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom" ]
-then
- xxd /sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom
-fi
-
-if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom" ]
-then
- xxd /sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom
-fi
-
-if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-6/6-0050/eeprom" ]
-then
- xxd /sys/devices/platform/10970000.hsi2c/i2c-6/6-0050/eeprom
-fi
-
-if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-7/7-0050/eeprom" ]
-then
- xxd /sys/devices/platform/10970000.hsi2c/i2c-7/7-0050/eeprom
-fi
-
if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-7/7-0050/eeprom" ]
then
xxd /sys/devices/platform/10970000.hsi2c/i2c-7/7-0050/eeprom
diff --git a/fingerprint/udfps_common.mk b/fingerprint/udfps_common.mk
deleted file mode 100644
index 58088568..00000000
--- a/fingerprint/udfps_common.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2020 The Android Open-Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Fingerprint manifest
-ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
-DEVICE_MANIFEST_FILE += \
- device/google/gs101/fingerprint/vendor.goodix.hardware.biometrics.fingerprint@2.1-service.xml
-endif
-
-# Include the Goodix AIDL HAL namespaces.
-PRODUCT_SOONG_NAMESPACES += vendor/goodix/udfps/fp_utils
-ifeq ($(GOODIX_CONFIG_BUILD_VERSION), g6_trusty)
-PRODUCT_SOONG_NAMESPACES += vendor/goodix/udfps/g6_trusty
-PRODUCT_SOONG_NAMESPACES += vendor/goodix/udfps/g6_aidl_trusty
-else ifeq ($(GOODIX_CONFIG_BUILD_VERSION), g7_trusty)
-PRODUCT_SOONG_NAMESPACES += vendor/goodix/udfps/g7_trusty
-PRODUCT_SOONG_NAMESPACES += vendor/goodix/udfps/g7_aidl_trusty
-else
-$(error Invalid udfps build version)
-endif
-
-$(call soong_config_set,fp_hal_feature,biometric_suez_support,true)
diff --git a/fingerprint/udfps_factory.mk b/fingerprint/udfps_factory.mk
deleted file mode 100644
index de831e4c..00000000
--- a/fingerprint/udfps_factory.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2020 The Android Open-Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-PRODUCT_PACKAGES += \
- android.hardware.biometrics.fingerprint@2.1-service.goodix \
- GF_delmar_factory \
- udfps_test
-
-DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs101/fingerprint/compatibility_matrix_factory.xml
-
-PRODUCT_PROPERTY_OVERRIDES += \
- gf.debug.dump_data=1
diff --git a/fingerprint/udfps_shipping.mk b/fingerprint/udfps_shipping.mk
deleted file mode 100644
index c8203b18..00000000
--- a/fingerprint/udfps_shipping.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2021 The Android Open-Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-PRODUCT_COPY_FILES += \
- frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml
-
-PRODUCT_PACKAGES += \
- android.hardware.biometrics.fingerprint-service.goodix
diff --git a/fingerprint/vendor.goodix.hardware.biometrics.fingerprint@2.1-service.xml b/fingerprint/vendor.goodix.hardware.biometrics.fingerprint@2.1-service.xml
deleted file mode 100644
index e42448fa..00000000
--- a/fingerprint/vendor.goodix.hardware.biometrics.fingerprint@2.1-service.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest version="1.0" type="device">
- <hal format="hidl">
- <name>vendor.goodix.hardware.biometrics.fingerprint</name>
- <transport>hwbinder</transport>
- <version>2.1</version>
- <interface>
- <name>IGoodixFingerprintDaemon</name>
- <instance>default</instance>
- </interface>
- </hal>
-</manifest>
diff --git a/interfaces/boot/1.0/Android.bp b/interfaces/boot/1.0/Android.bp
deleted file mode 100644
index 179a6f95..00000000
--- a/interfaces/boot/1.0/Android.bp
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "//device/google/gs101:device_google_gs101_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: [
- "//device/google/gs101:device_google_gs101_license",
- ],
-}
-
-cc_binary {
- name: "android.hardware.boot@1.0-service-gs101",
- defaults: ["hidl_defaults"],
- relative_install_path: "hw",
- vendor: true,
- init_rc: ["android.hardware.boot@1.0-service-gs101.rc"],
- srcs: [
- "BootControl.cpp",
- "GptUtils.cpp",
- "service.cpp"
- ],
- shared_libs: [
- "libbase",
- "liblog",
- "libhidlbase",
- "libutils",
- "libcutils",
- "libz",
- "android.hardware.boot@1.0",
- ],
-}
-
-cc_library {
- name: "android.hardware.boot@1.0-impl-gs101",
- recovery: true,
- srcs: [
- "BootControl.cpp",
- "GptUtils.cpp",
- ],
- relative_install_path: "hw",
- shared_libs: [
- "libbase",
- "liblog",
- "libhidlbase",
- "libutils",
- "libcutils",
- "libz",
- "android.hardware.boot@1.0",
- ],
-}
diff --git a/interfaces/boot/1.0/BootControl.cpp b/interfaces/boot/1.0/BootControl.cpp
deleted file mode 100644
index 1f155c9d..00000000
--- a/interfaces/boot/1.0/BootControl.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "bootcontrolhal"
-
-#include "BootControl.h"
-#include "GptUtils.h"
-
-#include <android-base/file.h>
-#include <cutils/properties.h>
-#include <log/log.h>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_0 {
-namespace implementation {
-
-namespace {
-
-#define BOOT_A_PATH "/dev/block/by-name/boot_a"
-#define BOOT_B_PATH "/dev/block/by-name/boot_b"
-
-// slot flags
-#define AB_ATTR_PRIORITY_SHIFT 52
-#define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT)
-#define AB_ATTR_ACTIVE_SHIFT 54
-#define AB_ATTR_ACTIVE (1UL << AB_ATTR_ACTIVE_SHIFT)
-#define AB_ATTR_RETRY_COUNT_SHIFT (55)
-#define AB_ATTR_RETRY_COUNT_MASK (7UL << AB_ATTR_RETRY_COUNT_SHIFT)
-#define AB_ATTR_SUCCESSFUL (1UL << 58)
-#define AB_ATTR_UNBOOTABLE (1UL << 59)
-
-#define AB_ATTR_MAX_PRIORITY 3UL
-#define AB_ATTR_MAX_RETRY_COUNT 3UL
-
-static std::string getDevPath(uint32_t slot) {
- char real_path[PATH_MAX];
-
- const char *path = slot == 0 ? BOOT_A_PATH : BOOT_B_PATH;
-
- int ret = readlink(path, real_path, sizeof real_path);
- if (ret < 0) {
- ALOGE("readlink failed for boot device %s\n", strerror(errno));
- return std::string();
- }
-
- std::string dp(real_path);
- // extract /dev/sda.. part
- return dp.substr(0, sizeof "/dev/block/sdX" - 1);
-}
-
-static bool isSlotFlagSet(uint32_t slot, uint64_t flag) {
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- ALOGI("Could not get device path for slot %d\n", slot);
- return false;
- }
-
- GptUtils gpt(dev_path);
- if (gpt.Load()) {
- ALOGI("failed to load gpt data\n");
- return false;
- }
-
- gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
- if (e == nullptr) {
- ALOGI("failed to get gpt entry\n");
- return false;
- }
-
- return !!(e->attr & flag);
-}
-
-static int setSlotFlag(uint32_t slot, uint64_t flag) {
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- ALOGI("Could not get device path for slot %d\n", slot);
- return -1;
- }
-
- GptUtils gpt(dev_path);
- if (gpt.Load()) {
- ALOGI("failed to load gpt data\n");
- return -1;
- }
-
- gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
- if (e == nullptr) {
- ALOGI("failed to get gpt entry\n");
- return -1;
- }
-
- e->attr |= flag;
- gpt.Sync();
-
- return 0;
-}
-
-}
-
-// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
-Return<uint32_t> BootControl::getNumberSlots() {
- uint32_t slots = 0;
-
- if (access(BOOT_A_PATH, F_OK) == 0)
- slots++;
-
- if (access(BOOT_B_PATH, F_OK) == 0)
- slots++;
-
- return slots;
-}
-
-Return<uint32_t> BootControl::getCurrentSlot() {
- char suffix[PROPERTY_VALUE_MAX];
- property_get("ro.boot.slot_suffix", suffix, "_a");
- return std::string(suffix) == "_b" ? 1 : 0;
-}
-
-Return<void> BootControl::markBootSuccessful(markBootSuccessful_cb _hidl_cb) {
- if (getNumberSlots() == 0) {
- // no slots, just return true otherwise Android keeps trying
- _hidl_cb({true, ""});
- return Void();
- }
- int ret = setSlotFlag(getCurrentSlot(), AB_ATTR_SUCCESSFUL);
- ret ? _hidl_cb({false, "Failed to set successfull flag"}) : _hidl_cb({true, ""});
- return Void();
-}
-
-Return<void> BootControl::setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) {
- if (slot >= 2) {
- _hidl_cb({false, "Invalid slot"});
- return Void();
- }
-
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- _hidl_cb({false, "Could not get device path for slot"});
- return Void();
- }
-
- GptUtils gpt(dev_path);
- if (gpt.Load()) {
- _hidl_cb({false, "failed to load gpt data"});
- return Void();
- }
-
- gpt_entry *active_entry = gpt.GetPartitionEntry(slot == 0 ? "boot_a" : "boot_b");
- gpt_entry *inactive_entry = gpt.GetPartitionEntry(slot == 0 ? "boot_b" : "boot_a");
- if (active_entry == nullptr || inactive_entry == nullptr) {
- _hidl_cb({false, "failed to get entries for boot partitions"});
- return Void();
- }
-
- ALOGV("slot active attributes %lx\n", active_entry->attr);
- ALOGV("slot inactive attributes %lx\n", inactive_entry->attr);
-
- char boot_dev[PROPERTY_VALUE_MAX];
- property_get("ro.boot.bootdevice", boot_dev, "");
- if (boot_dev[0] == '\0') {
- _hidl_cb({false, "invalid ro.boot.bootdevice prop"});
- return Void();
- }
-
- std::string boot_lun_path = std::string("/sys/devices/platform/") +
- boot_dev + "/pixel/boot_lun_enabled";
- int fd = open(boot_lun_path.c_str(), O_RDWR);
- if (fd < 0) {
- // Try old path for kernels < 5.4
- // TODO: remove once kernel 4.19 support is deprecated
- std::string boot_lun_path = std::string("/sys/devices/platform/") +
- boot_dev + "/attributes/boot_lun_enabled";
- fd = open(boot_lun_path.c_str(), O_RDWR);
- if (fd < 0) {
- _hidl_cb({false, "failed to open ufs attr boot_lun_enabled"});
- return Void();
- }
- }
-
- // update attributes for active and inactive
- inactive_entry->attr &= ~AB_ATTR_ACTIVE;
- active_entry->attr = AB_ATTR_ACTIVE | (AB_ATTR_MAX_PRIORITY << AB_ATTR_PRIORITY_SHIFT) |
- (AB_ATTR_MAX_RETRY_COUNT << AB_ATTR_RETRY_COUNT_SHIFT);
-
- //
- // bBootLunEn
- // 0x1 => Boot LU A = enabled, Boot LU B = disable
- // 0x2 => Boot LU A = disable, Boot LU B = enabled
- //
- int ret = android::base::WriteStringToFd(slot == 0 ? "1" : "2", fd);
- close(fd);
- if (ret < 0) {
- _hidl_cb({false, "faied to write boot_lun_enabled attribute"});
- return Void();
- }
-
- _hidl_cb({true, ""});
- return Void();
-}
-
-Return<void> BootControl::setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) {
- if (slot >= 2) {
- _hidl_cb({false, "Invalid slot"});
- return Void();
- }
-
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- _hidl_cb({false, "Could not get device path for slot"});
- return Void();
- }
-
- GptUtils gpt(dev_path);
- gpt.Load();
-
- gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
- e->attr |= AB_ATTR_UNBOOTABLE;
-
- gpt.Sync();
-
- _hidl_cb({true, ""});
- return Void();
-}
-
-Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotBootable(uint32_t slot) {
- if (getNumberSlots() == 0)
- return BoolResult::FALSE;
- if (slot >= getNumberSlots())
- return BoolResult::INVALID_SLOT;
- return isSlotFlagSet(slot, AB_ATTR_UNBOOTABLE) ? BoolResult::FALSE : BoolResult::TRUE;
-}
-
-Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotMarkedSuccessful(uint32_t slot) {
- if (getNumberSlots() == 0) {
- // just return true so that we don't we another call trying to mark it as successful
- // when there is no slots
- return BoolResult::TRUE;
- }
- if (slot >= getNumberSlots())
- return BoolResult::INVALID_SLOT;
- return isSlotFlagSet(slot, AB_ATTR_SUCCESSFUL) ? BoolResult::TRUE : BoolResult::FALSE;
-}
-
-Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) {
- _hidl_cb(slot == 0 ? "_a" : slot == 1 ? "_b" : "");
- return Void();
-}
-
-extern "C" IBootControl* HIDL_FETCH_IBootControl(const char*) {
- return new BootControl();
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.0/BootControl.h b/interfaces/boot/1.0/BootControl.h
deleted file mode 100644
index eb81cb07..00000000
--- a/interfaces/boot/1.0/BootControl.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <android/hardware/boot/1.0/IBootControl.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-struct BootControl : public IBootControl {
- // Methods from ::android::hardware::boot::V1_0::IBootControl follow.
- Return<uint32_t> getNumberSlots() override;
- Return<uint32_t> getCurrentSlot() override;
- Return<void> markBootSuccessful(markBootSuccessful_cb _hidl_cb) override;
- Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) override;
- Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) override;
- Return<::android::hardware::boot::V1_0::BoolResult> isSlotBootable(uint32_t slot) override;
- Return<::android::hardware::boot::V1_0::BoolResult> isSlotMarkedSuccessful(uint32_t slot) override;
- Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) override;
-
- // Methods from ::android::hidl::base::V1_0::IBase follow.
-
-};
-
-// FIXME: most likely delete, this is only for passthrough implementations
-extern "C" IBootControl* HIDL_FETCH_IBootControl(const char* name);
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.0/GptUtils.cpp b/interfaces/boot/1.0/GptUtils.cpp
deleted file mode 100644
index f8936175..00000000
--- a/interfaces/boot/1.0/GptUtils.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "bootcontrolhal"
-
-#include "GptUtils.h"
-
-#include <errno.h>
-#include <log/log.h>
-#include <android-base/file.h>
-#include <linux/fs.h>
-#include <zlib.h>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_0 {
-namespace implementation {
-
-namespace {
-
-static int ValidateGptHeader(gpt_header *gpt)
-{
- if (gpt->signature != GPT_SIGNATURE) {
- ALOGE("invalid gpt signature 0x%lx\n", gpt->signature);
- return -1;
- }
-
- if (gpt->header_size != sizeof(gpt_header)) {
- ALOGE("invalid gpt header size %u\n", gpt->header_size);
- return -1;
- }
-
- if (gpt->entry_size != sizeof(gpt_entry)) {
- ALOGE("invalid gpt entry size %u\n", gpt->entry_size);
- return -1;
- }
-
- return 0;
-}
-
-}
-
-GptUtils::GptUtils(const std::string dev_path) : dev_path(dev_path), fd(0) {}
-
-int GptUtils::Load(void)
-{
- fd = open(dev_path.c_str(), O_RDWR);
- if (fd < 0) {
- ALOGE("failed to open block dev %s, %d\n", dev_path.c_str(), errno);
- return -1;
- }
-
- int ret = ioctl(fd, BLKSSZGET, &block_size);
- if (ret < 0) {
- ALOGE("failed to get block size %d\n", errno);
- return -1;
- }
-
- // read primary header
- lseek64(fd, block_size, SEEK_SET);
- ret = read(fd, &gpt_primary, sizeof gpt_primary);
- if (ret < 0) {
- ALOGE("failed to read gpt primary header %d\n", errno);
- return -1;
- }
-
- if (ValidateGptHeader(&gpt_primary)) {
- ALOGE("error validating gpt header\n");
- return -1;
- }
-
- // read partition entries
- entry_array.resize(gpt_primary.entry_count);
- uint32_t entries_size = gpt_primary.entry_size * gpt_primary.entry_count;
- lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
- ret = read(fd, entry_array.data(), entries_size);
- if (ret < 0) {
- ALOGE("failed to read gpt partition entries %d\n", errno);
- return -1;
- }
-
- // read gpt back header
- lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
- ret = read(fd, &gpt_backup, sizeof gpt_backup);
- if (ret < 0) {
- ALOGE("failed to read gpt backup header %d\n", errno);
- return -1;
- }
-
- if (ValidateGptHeader(&gpt_backup)) {
- ALOGW("error validating gpt backup\n"); // just warn about it, not fail
- }
-
- // Create map <partition name, gpt_entry pointer>
- auto get_name = [](const uint16_t *efi_name) {
- char name[37] = {};
- for (int i = 0; efi_name[i] && i < sizeof name - 1; ++i)
- name[i] = efi_name[i];
- return std::string(name);
- };
-
- for (auto const &e: entry_array) {
- if (e.name[0] == 0)
- break; // stop at the first partition with no name
- std::string s = get_name(e.name);
- entries[s] = const_cast<gpt_entry *>(&e);
- }
-
- return 0;
-}
-
-gpt_entry *GptUtils::GetPartitionEntry(std::string name)
-{
- return entries.find(name) != entries.end() ? entries[name] : nullptr;
-}
-
-int GptUtils::Sync(void)
-{
- if (!fd)
- return -1;
-
- // calculate crc and check if we need to update gpt
- gpt_primary.entries_crc32 = crc32(0, reinterpret_cast<uint8_t *>(entry_array.data()),
- entry_array.size() * sizeof(gpt_entry));
-
- // save old crc
- uint32_t crc = gpt_primary.crc32;
- gpt_primary.crc32 = 0;
-
- gpt_primary.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_primary), sizeof gpt_primary);
- if (crc == gpt_primary.crc32)
- return 0; // nothing to do (no changes)
-
- ALOGI("updating GPT\n");
-
- lseek64(fd, block_size * gpt_primary.current_lba, SEEK_SET);
- int ret = write(fd, &gpt_primary, sizeof gpt_primary);
- if (ret < 0) {
- ALOGE("failed to write gpt primary header %d\n", errno);
- return -1;
- }
-
- lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
- ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
- if (ret < 0) {
- ALOGE("failed to write gpt partition entries %d\n", errno);
- return -1;
- }
-
- //update GPT backup entries and backup
- lseek64(fd, block_size * gpt_backup.start_lba, SEEK_SET);
- ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
- if (ret < 0) {
- ALOGE("failed to write gpt backup partition entries %d\n", errno);
- return -1;
- }
-
- gpt_backup.entries_crc32 = gpt_primary.entries_crc32;
- gpt_backup.crc32 = 0;
- gpt_backup.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_backup), sizeof gpt_backup);
- lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
- ret = write(fd, &gpt_backup, sizeof gpt_backup);
- if (ret < 0) {
- ALOGE("failed to write gpt backup header %d\n", errno);
- return -1;
- }
-
- fsync(fd);
-
- return 0;
-}
-
-GptUtils::~GptUtils()
-{
- if (fd) {
- Sync();
- close(fd);
- }
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.0/GptUtils.h b/interfaces/boot/1.0/GptUtils.h
deleted file mode 100644
index d969d9d8..00000000
--- a/interfaces/boot/1.0/GptUtils.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <string>
-#include <vector>
-#include <map>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_0 {
-namespace implementation {
-
-#define GPT_SIGNATURE 0x5452415020494645UL
-
-typedef struct {
- uint8_t type_guid[16];
- uint8_t guid[16];
- uint64_t first_lba;
- uint64_t last_lba;
- uint64_t attr;
- uint16_t name[36];
-} __attribute__((packed)) gpt_entry;
-
-typedef struct {
- uint64_t signature;
- uint32_t revision;
- uint32_t header_size;
- uint32_t crc32;
- uint32_t reserved;
- uint64_t current_lba;
- uint64_t backup_lba;
- uint64_t first_usable_lba;
- uint64_t last_usable_lba;
- uint8_t disk_guid[16];
- uint64_t start_lba;
- uint32_t entry_count;
- uint32_t entry_size;
- uint32_t entries_crc32;
-} __attribute__((packed)) gpt_header;
-
-class GptUtils {
- public:
- GptUtils(const std::string dev_path);
- int Load(void);
- gpt_entry *GetPartitionEntry(std::string name);
- int Sync(void);
- ~GptUtils();
-
- private:
- std::string dev_path;
- int fd;
- uint32_t block_size;
- gpt_header gpt_primary;
- gpt_header gpt_backup;
- std::vector<gpt_entry> entry_array;
- std::map<std::string, gpt_entry *>entries;
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.0/android.hardware.boot@1.0-service-gs101.rc b/interfaces/boot/1.0/android.hardware.boot@1.0-service-gs101.rc
deleted file mode 100644
index 24a4b451..00000000
--- a/interfaces/boot/1.0/android.hardware.boot@1.0-service-gs101.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service vendor.boot-hal-1-0 /vendor/bin/hw/android.hardware.boot@1.0-service-gs101
- class early_hal
- user root
- group root
diff --git a/interfaces/boot/1.0/service.cpp b/interfaces/boot/1.0/service.cpp
deleted file mode 100644
index 9dcd78cc..00000000
--- a/interfaces/boot/1.0/service.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#define LOG_TAG "android.hardware.boot@1.0-service"
-
-#include <log/log.h>
-#include <hidl/HidlTransportSupport.h>
-#include <hidl/Status.h>
-#include <android/hardware/boot/1.0/IBootControl.h>
-#include "BootControl.h"
-
-using ::android::status_t;
-
-using ::android::hardware::boot::V1_0::IBootControl;
-
-using ::android::hardware::boot::V1_0::implementation::BootControl;
-
-int main (int /* argc */, char * /* argv */ []) {
- // This function must be called before you join to ensure the proper
- // number of threads are created. The threadpool will never exceed
- // size one because of this call.
- ::android::hardware::configureRpcThreadpool(1 /*threads*/, true /*willJoin*/);
-
- ::android::sp bootctrl = new BootControl();
- const status_t status = bootctrl->registerAsService();
- if (status != ::android::OK) {
- return 1; // or handle error
- }
-
- // Adds this thread to the threadpool, resulting in one total
- // thread in the threadpool. We could also do other things, but
- // would have to specify 'false' to willJoin in configureRpcThreadpool.
- ::android::hardware::joinRpcThreadpool();
- return 1; // joinRpcThreadpool should never return
-}
diff --git a/interfaces/boot/1.2/Android.bp b/interfaces/boot/1.2/Android.bp
deleted file mode 100644
index 982a543a..00000000
--- a/interfaces/boot/1.2/Android.bp
+++ /dev/null
@@ -1,81 +0,0 @@
-//
-// Copyright (C) 2020 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "//device/google/gs101:device_google_gs101_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: [
- "//device/google/gs101:device_google_gs101_license",
- ],
-}
-
-cc_binary {
- name: "android.hardware.boot@1.2-service-gs101",
- defaults: ["hidl_defaults"],
- relative_install_path: "hw",
- vendor: true,
- init_rc: ["android.hardware.boot@1.2-service-gs101.rc"],
- srcs: [
- "BootControl.cpp",
- "GptUtils.cpp",
- "service.cpp"
- ],
- shared_libs: [
- "libbase",
- "liblog",
- "libhidlbase",
- "libutils",
- "libcutils",
- "libz",
- "android.hardware.boot@1.0",
- "android.hardware.boot@1.1",
- "android.hardware.boot@1.2",
- ],
- static_libs: [
- "libboot_control",
- "libbootloader_message_vendor",
- "libfstab",
- ],
-}
-
-cc_library {
- name: "android.hardware.boot@1.2-impl-gs101",
- stem: "android.hardware.boot@1.0-impl-1.2-impl-gs101",
- recovery: true,
- srcs: [
- "BootControl.cpp",
- "GptUtils.cpp",
- ],
- relative_install_path: "hw",
- shared_libs: [
- "libbase",
- "liblog",
- "libhidlbase",
- "libutils",
- "libcutils",
- "libz",
- "android.hardware.boot@1.0",
- "android.hardware.boot@1.1",
- "android.hardware.boot@1.2",
- ],
- static_libs: [
- "libboot_control",
- "libbootloader_message_vendor",
- "libfstab",
- ],
-}
diff --git a/interfaces/boot/1.2/BootControl.cpp b/interfaces/boot/1.2/BootControl.cpp
deleted file mode 100644
index 6c480bb6..00000000
--- a/interfaces/boot/1.2/BootControl.cpp
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "bootcontrolhal"
-
-#include "BootControl.h"
-
-#include <android-base/file.h>
-#include <android-base/unique_fd.h>
-#include <bootloader_message/bootloader_message.h>
-#include <cutils/properties.h>
-#include <libboot_control/libboot_control.h>
-#include <log/log.h>
-
-#include "DevInfo.h"
-#include "GptUtils.h"
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_2 {
-namespace implementation {
-
-using android::bootable::GetMiscVirtualAbMergeStatus;
-using android::bootable::InitMiscVirtualAbMessageIfNeeded;
-using android::bootable::SetMiscVirtualAbMergeStatus;
-using android::hardware::boot::V1_0::BoolResult;
-using android::hardware::boot::V1_0::CommandResult;
-using android::hardware::boot::V1_1::MergeStatus;
-
-namespace {
-
-// clang-format off
-
-#define BOOT_A_PATH "/dev/block/by-name/boot_a"
-#define BOOT_B_PATH "/dev/block/by-name/boot_b"
-#define DEVINFO_PATH "/dev/block/by-name/devinfo"
-
-#define BLOW_AR_PATH "/sys/kernel/boot_control/blow_ar"
-
-// slot flags
-#define AB_ATTR_PRIORITY_SHIFT 52
-#define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT)
-#define AB_ATTR_ACTIVE_SHIFT 54
-#define AB_ATTR_ACTIVE (1UL << AB_ATTR_ACTIVE_SHIFT)
-#define AB_ATTR_RETRY_COUNT_SHIFT (55)
-#define AB_ATTR_RETRY_COUNT_MASK (7UL << AB_ATTR_RETRY_COUNT_SHIFT)
-#define AB_ATTR_SUCCESSFUL (1UL << 58)
-#define AB_ATTR_UNBOOTABLE (1UL << 59)
-
-#define AB_ATTR_MAX_PRIORITY 3UL
-#define AB_ATTR_MAX_RETRY_COUNT 3UL
-
-// clang-format on
-
-static std::string getDevPath(uint32_t slot) {
- char real_path[PATH_MAX];
-
- const char *path = slot == 0 ? BOOT_A_PATH : BOOT_B_PATH;
-
- int ret = readlink(path, real_path, sizeof real_path);
- if (ret < 0) {
- ALOGE("readlink failed for boot device %s\n", strerror(errno));
- return std::string();
- }
-
- std::string dp(real_path);
- // extract /dev/sda.. part
- return dp.substr(0, sizeof "/dev/block/sdX" - 1);
-}
-
-static bool isSlotFlagSet(uint32_t slot, uint64_t flag) {
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- ALOGI("Could not get device path for slot %d\n", slot);
- return false;
- }
-
- GptUtils gpt(dev_path);
- if (gpt.Load()) {
- ALOGI("failed to load gpt data\n");
- return false;
- }
-
- gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
- if (e == nullptr) {
- ALOGI("failed to get gpt entry\n");
- return false;
- }
-
- return !!(e->attr & flag);
-}
-
-static bool setSlotFlag(uint32_t slot, uint64_t flag) {
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- ALOGI("Could not get device path for slot %d\n", slot);
- return false;
- }
-
- GptUtils gpt(dev_path);
- if (gpt.Load()) {
- ALOGI("failed to load gpt data\n");
- return false;
- }
-
- gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
- if (e == nullptr) {
- ALOGI("failed to get gpt entry\n");
- return false;
- }
-
- e->attr |= flag;
- gpt.Sync();
-
- return true;
-}
-
-static bool is_devinfo_valid;
-static bool is_devinfo_initialized;
-static std::mutex devinfo_lock;
-static devinfo_t devinfo;
-
-static bool isDevInfoValid() {
- const std::lock_guard<std::mutex> lock(devinfo_lock);
-
- if (is_devinfo_initialized) {
- return is_devinfo_valid;
- }
-
- is_devinfo_initialized = true;
-
- android::base::unique_fd fd(open(DEVINFO_PATH, O_RDONLY));
- android::base::ReadFully(fd, &devinfo, sizeof devinfo);
-
- if (devinfo.magic != DEVINFO_MAGIC) {
- return is_devinfo_valid;
- }
-
- uint32_t version = ((uint32_t)devinfo.ver_major << 16) | devinfo.ver_minor;
- // only version 3.3+ supports A/B data
- if (version >= 0x0003'0003) {
- is_devinfo_valid = true;
- }
-
- return is_devinfo_valid;
-}
-
-static bool DevInfoSync() {
- if (!isDevInfoValid()) {
- return false;
- }
-
- android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY | O_DSYNC));
- return android::base::WriteFully(fd, &devinfo, sizeof devinfo);
-}
-
-static void DevInfoInitSlot(devinfo_ab_slot_data_t &slot_data) {
- slot_data.retry_count = AB_ATTR_MAX_RETRY_COUNT;
- slot_data.unbootable = 0;
- slot_data.successful = 0;
- slot_data.active = 1;
- slot_data.fastboot_ok = 0;
-}
-
-static bool blowAR() {
- android::base::unique_fd fd(open(BLOW_AR_PATH, O_WRONLY | O_DSYNC));
- return android::base::WriteStringToFd("1", fd);
-}
-
-} // namespace
-
-// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
-Return<uint32_t> BootControl::getNumberSlots() {
- uint32_t slots = 0;
-
- if (access(BOOT_A_PATH, F_OK) == 0)
- slots++;
-
- if (access(BOOT_B_PATH, F_OK) == 0)
- slots++;
-
- return slots;
-}
-
-Return<uint32_t> BootControl::getCurrentSlot() {
- char suffix[PROPERTY_VALUE_MAX];
- property_get("ro.boot.slot_suffix", suffix, "_a");
- return std::string(suffix) == "_b" ? 1 : 0;
-}
-
-Return<void> BootControl::markBootSuccessful(markBootSuccessful_cb _hidl_cb) {
- if (getNumberSlots() == 0) {
- // no slots, just return true otherwise Android keeps trying
- _hidl_cb({true, ""});
- return Void();
- }
-
- bool ret;
- if (isDevInfoValid()) {
- auto const slot = getCurrentSlot();
- devinfo.ab_data.slots[slot].successful = 1;
- ret = DevInfoSync();
- } else {
- ret = setSlotFlag(getCurrentSlot(), AB_ATTR_SUCCESSFUL);
- }
-
- if (!ret) {
- _hidl_cb({false, "Failed to set successful flag"});
- return Void();
- }
-
- if (!blowAR()) {
- ALOGE("Failed to blow anti-rollback counter");
- // Ignore the error, since ABL will re-trigger it on reboot
- }
-
- _hidl_cb({true, ""});
- return Void();
-}
-
-Return<void> BootControl::setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) {
- if (slot >= 2) {
- _hidl_cb({false, "Invalid slot"});
- return Void();
- }
-
- if (isDevInfoValid()) {
- auto &active_slot_data = devinfo.ab_data.slots[slot];
- auto &inactive_slot_data = devinfo.ab_data.slots[!slot];
-
- inactive_slot_data.active = 0;
- DevInfoInitSlot(active_slot_data);
-
- if (!DevInfoSync()) {
- _hidl_cb({false, "Could not update DevInfo data"});
- return Void();
- }
- } else {
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- _hidl_cb({false, "Could not get device path for slot"});
- return Void();
- }
-
- GptUtils gpt(dev_path);
- if (gpt.Load()) {
- _hidl_cb({false, "failed to load gpt data"});
- return Void();
- }
-
- gpt_entry *active_entry = gpt.GetPartitionEntry(slot == 0 ? "boot_a" : "boot_b");
- gpt_entry *inactive_entry = gpt.GetPartitionEntry(slot == 0 ? "boot_b" : "boot_a");
- if (active_entry == nullptr || inactive_entry == nullptr) {
- _hidl_cb({false, "failed to get entries for boot partitions"});
- return Void();
- }
-
- ALOGV("slot active attributes %lx\n", active_entry->attr);
- ALOGV("slot inactive attributes %lx\n", inactive_entry->attr);
-
- // update attributes for active and inactive
- inactive_entry->attr &= ~AB_ATTR_ACTIVE;
- active_entry->attr = AB_ATTR_ACTIVE | (AB_ATTR_MAX_PRIORITY << AB_ATTR_PRIORITY_SHIFT) |
- (AB_ATTR_MAX_RETRY_COUNT << AB_ATTR_RETRY_COUNT_SHIFT);
- }
-
- char boot_dev[PROPERTY_VALUE_MAX];
- property_get("ro.boot.bootdevice", boot_dev, "");
- if (boot_dev[0] == '\0') {
- _hidl_cb({false, "invalid ro.boot.bootdevice prop"});
- return Void();
- }
-
- std::string boot_lun_path =
- std::string("/sys/devices/platform/") + boot_dev + "/pixel/boot_lun_enabled";
- int fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
- if (fd < 0) {
- // Try old path for kernels < 5.4
- // TODO: remove once kernel 4.19 support is deprecated
- std::string boot_lun_path =
- std::string("/sys/devices/platform/") + boot_dev + "/attributes/boot_lun_enabled";
- fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
- if (fd < 0) {
- _hidl_cb({false, "failed to open ufs attr boot_lun_enabled"});
- return Void();
- }
- }
-
- //
- // bBootLunEn
- // 0x1 => Boot LU A = enabled, Boot LU B = disable
- // 0x2 => Boot LU A = disable, Boot LU B = enabled
- //
- int ret = android::base::WriteStringToFd(slot == 0 ? "1" : "2", fd);
- close(fd);
- if (ret < 0) {
- _hidl_cb({false, "faied to write boot_lun_enabled attribute"});
- return Void();
- }
-
- _hidl_cb({true, ""});
- return Void();
-}
-
-Return<void> BootControl::setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) {
- if (slot >= 2) {
- _hidl_cb({false, "Invalid slot"});
- return Void();
- }
-
- if (isDevInfoValid()) {
- auto &slot_data = devinfo.ab_data.slots[slot];
- slot_data.unbootable = 1;
- if (!DevInfoSync()) {
- _hidl_cb({false, "Could not update DevInfo data"});
- return Void();
- }
- } else {
- std::string dev_path = getDevPath(slot);
- if (dev_path.empty()) {
- _hidl_cb({false, "Could not get device path for slot"});
- return Void();
- }
-
- GptUtils gpt(dev_path);
- gpt.Load();
-
- gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
- e->attr |= AB_ATTR_UNBOOTABLE;
-
- gpt.Sync();
- }
-
- _hidl_cb({true, ""});
- return Void();
-}
-
-Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotBootable(uint32_t slot) {
- if (getNumberSlots() == 0)
- return BoolResult::FALSE;
- if (slot >= getNumberSlots())
- return BoolResult::INVALID_SLOT;
-
- bool unbootable;
- if (isDevInfoValid()) {
- auto &slot_data = devinfo.ab_data.slots[slot];
- unbootable = !!slot_data.unbootable;
- } else {
- unbootable = isSlotFlagSet(slot, AB_ATTR_UNBOOTABLE);
- }
-
- return unbootable ? BoolResult::FALSE : BoolResult::TRUE;
-}
-
-Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotMarkedSuccessful(
- uint32_t slot) {
- if (getNumberSlots() == 0) {
- // just return true so that we don't we another call trying to mark it as successful
- // when there is no slots
- return BoolResult::TRUE;
- }
- if (slot >= getNumberSlots())
- return BoolResult::INVALID_SLOT;
-
- bool successful;
- if (isDevInfoValid()) {
- auto &slot_data = devinfo.ab_data.slots[slot];
- successful = !!slot_data.successful;
- } else {
- successful = isSlotFlagSet(slot, AB_ATTR_SUCCESSFUL);
- }
-
- return successful ? BoolResult::TRUE : BoolResult::FALSE;
-}
-
-Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) {
- _hidl_cb(slot == 0 ? "_a" : slot == 1 ? "_b" : "");
- return Void();
-}
-
-// Methods from ::android::hardware::boot::V1_1::IBootControl follow.
-bool BootControl::Init() {
- return InitMiscVirtualAbMessageIfNeeded();
-}
-
-Return<bool> BootControl::setSnapshotMergeStatus(
- ::android::hardware::boot::V1_1::MergeStatus status) {
- return SetMiscVirtualAbMergeStatus(getCurrentSlot(), status);
-}
-
-Return<::android::hardware::boot::V1_1::MergeStatus> BootControl::getSnapshotMergeStatus() {
- MergeStatus status;
- if (!GetMiscVirtualAbMergeStatus(getCurrentSlot(), &status)) {
- return MergeStatus::UNKNOWN;
- }
- return status;
-}
-
-// Methods from ::android::hardware::boot::V1_2::IBootControl follow.
-Return<uint32_t> BootControl::getActiveBootSlot() {
- if (getNumberSlots() == 0)
- return 0;
-
- if (isDevInfoValid())
- return devinfo.ab_data.slots[1].active ? 1 : 0;
- return isSlotFlagSet(1, AB_ATTR_ACTIVE) ? 1 : 0;
-}
-
-// Methods from ::android::hidl::base::V1_0::IBase follow.
-
-IBootControl *HIDL_FETCH_IBootControl(const char * /* name */) {
- auto module = new BootControl();
-
- module->Init();
-
- return module;
-}
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.2/BootControl.h b/interfaces/boot/1.2/BootControl.h
deleted file mode 100644
index 17b5f0fb..00000000
--- a/interfaces/boot/1.2/BootControl.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <android/hardware/boot/1.2/IBootControl.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_2 {
-namespace implementation {
-
-using ::android::sp;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
-struct BootControl : public IBootControl {
- bool Init();
-
- // Methods from ::android::hardware::boot::V1_0::IBootControl follow.
- Return<uint32_t> getNumberSlots() override;
- Return<uint32_t> getCurrentSlot() override;
- Return<void> markBootSuccessful(markBootSuccessful_cb _hidl_cb) override;
- Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) override;
- Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) override;
- Return<::android::hardware::boot::V1_0::BoolResult> isSlotBootable(uint32_t slot) override;
- Return<::android::hardware::boot::V1_0::BoolResult> isSlotMarkedSuccessful(
- uint32_t slot) override;
- Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) override;
-
- // Methods from ::android::hardware::boot::V1_1::IBootControl follow.
- Return<bool> setSnapshotMergeStatus(
- ::android::hardware::boot::V1_1::MergeStatus status) override;
- Return<::android::hardware::boot::V1_1::MergeStatus> getSnapshotMergeStatus() override;
-
- // Methods from ::android::hardware::boot::V1_2::IBootControl follow.
- Return<uint32_t> getActiveBootSlot() override;
-
- // Methods from ::android::hidl::base::V1_0::IBase follow.
-};
-
-// FIXME: most likely delete, this is only for passthrough implementations
-extern "C" IBootControl *HIDL_FETCH_IBootControl(const char *name);
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.2/DevInfo.h b/interfaces/boot/1.2/DevInfo.h
deleted file mode 100644
index a09a83a2..00000000
--- a/interfaces/boot/1.2/DevInfo.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_2 {
-namespace implementation {
-
-//
-// definitions taken from ABL code
-//
-
-constexpr uint32_t DEVINFO_MAGIC = 0x49564544;
-constexpr size_t DEVINFO_AB_SLOT_COUNT = 2;
-
-struct devinfo_ab_slot_data_t {
- uint8_t retry_count;
- uint8_t unbootable : 1;
- uint8_t successful : 1;
- uint8_t active : 1;
- uint8_t fastboot_ok : 1;
- uint8_t : 4;
- uint8_t unused[2];
-} __attribute__((packed));
-
-typedef struct {
- devinfo_ab_slot_data_t slots[DEVINFO_AB_SLOT_COUNT];
-} __attribute__((packed)) devinfo_ab_data_t;
-
-struct devinfo_t {
- uint32_t magic;
- uint16_t ver_major;
- uint16_t ver_minor;
- uint8_t unused[40];
- devinfo_ab_data_t ab_data;
- uint8_t unused1[72]; // use remaining up to complete 128 bytes
-} __attribute__((packed));
-
-static_assert(sizeof(devinfo_t) == 128, "invalid devinfo struct size");
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.2/GptUtils.cpp b/interfaces/boot/1.2/GptUtils.cpp
deleted file mode 100644
index 25088e79..00000000
--- a/interfaces/boot/1.2/GptUtils.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "bootcontrolhal"
-
-#include "GptUtils.h"
-
-#include <android-base/file.h>
-#include <errno.h>
-#include <linux/fs.h>
-#include <log/log.h>
-#include <zlib.h>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_2 {
-namespace implementation {
-
-namespace {
-
-static int ValidateGptHeader(gpt_header *gpt) {
- if (gpt->signature != GPT_SIGNATURE) {
- ALOGE("invalid gpt signature 0x%lx\n", gpt->signature);
- return -1;
- }
-
- if (gpt->header_size != sizeof(gpt_header)) {
- ALOGE("invalid gpt header size %u\n", gpt->header_size);
- return -1;
- }
-
- if (gpt->entry_size != sizeof(gpt_entry)) {
- ALOGE("invalid gpt entry size %u\n", gpt->entry_size);
- return -1;
- }
-
- return 0;
-}
-
-} // namespace
-
-GptUtils::GptUtils(const std::string dev_path) : dev_path(dev_path), fd(0) {}
-
-int GptUtils::Load(void) {
- fd = open(dev_path.c_str(), O_RDWR);
- if (fd < 0) {
- ALOGE("failed to open block dev %s, %d\n", dev_path.c_str(), errno);
- return -1;
- }
-
- int ret = ioctl(fd, BLKSSZGET, &block_size);
- if (ret < 0) {
- ALOGE("failed to get block size %d\n", errno);
- return -1;
- }
-
- // read primary header
- lseek64(fd, block_size, SEEK_SET);
- ret = read(fd, &gpt_primary, sizeof gpt_primary);
- if (ret < 0) {
- ALOGE("failed to read gpt primary header %d\n", errno);
- return -1;
- }
-
- if (ValidateGptHeader(&gpt_primary)) {
- ALOGE("error validating gpt header\n");
- return -1;
- }
-
- // read partition entries
- entry_array.resize(gpt_primary.entry_count);
- uint32_t entries_size = gpt_primary.entry_size * gpt_primary.entry_count;
- lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
- ret = read(fd, entry_array.data(), entries_size);
- if (ret < 0) {
- ALOGE("failed to read gpt partition entries %d\n", errno);
- return -1;
- }
-
- // read gpt back header
- lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
- ret = read(fd, &gpt_backup, sizeof gpt_backup);
- if (ret < 0) {
- ALOGE("failed to read gpt backup header %d\n", errno);
- return -1;
- }
-
- if (ValidateGptHeader(&gpt_backup)) {
- ALOGW("error validating gpt backup\n"); // just warn about it, not fail
- }
-
- // Create map <partition name, gpt_entry pointer>
- auto get_name = [](const uint16_t *efi_name) {
- char name[37] = {};
- for (int i = 0; efi_name[i] && i < sizeof name - 1; ++i) name[i] = efi_name[i];
- return std::string(name);
- };
-
- for (auto const &e : entry_array) {
- if (e.name[0] == 0)
- break; // stop at the first partition with no name
- std::string s = get_name(e.name);
- entries[s] = const_cast<gpt_entry *>(&e);
- }
-
- return 0;
-}
-
-gpt_entry *GptUtils::GetPartitionEntry(std::string name) {
- return entries.find(name) != entries.end() ? entries[name] : nullptr;
-}
-
-int GptUtils::Sync(void) {
- if (!fd)
- return -1;
-
- // calculate crc and check if we need to update gpt
- gpt_primary.entries_crc32 = crc32(0, reinterpret_cast<uint8_t *>(entry_array.data()),
- entry_array.size() * sizeof(gpt_entry));
-
- // save old crc
- uint32_t crc = gpt_primary.crc32;
- gpt_primary.crc32 = 0;
-
- gpt_primary.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_primary), sizeof gpt_primary);
- if (crc == gpt_primary.crc32)
- return 0; // nothing to do (no changes)
-
- ALOGI("updating GPT\n");
-
- lseek64(fd, block_size * gpt_primary.current_lba, SEEK_SET);
- int ret = write(fd, &gpt_primary, sizeof gpt_primary);
- if (ret < 0) {
- ALOGE("failed to write gpt primary header %d\n", errno);
- return -1;
- }
-
- lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
- ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
- if (ret < 0) {
- ALOGE("failed to write gpt partition entries %d\n", errno);
- return -1;
- }
-
- // update GPT backup entries and backup
- lseek64(fd, block_size * gpt_backup.start_lba, SEEK_SET);
- ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
- if (ret < 0) {
- ALOGE("failed to write gpt backup partition entries %d\n", errno);
- return -1;
- }
-
- gpt_backup.entries_crc32 = gpt_primary.entries_crc32;
- gpt_backup.crc32 = 0;
- gpt_backup.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_backup), sizeof gpt_backup);
- lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
- ret = write(fd, &gpt_backup, sizeof gpt_backup);
- if (ret < 0) {
- ALOGE("failed to write gpt backup header %d\n", errno);
- return -1;
- }
-
- fsync(fd);
-
- return 0;
-}
-
-GptUtils::~GptUtils() {
- if (fd) {
- Sync();
- close(fd);
- }
-}
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.2/GptUtils.h b/interfaces/boot/1.2/GptUtils.h
deleted file mode 100644
index a2bed334..00000000
--- a/interfaces/boot/1.2/GptUtils.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <map>
-#include <string>
-#include <vector>
-
-namespace android {
-namespace hardware {
-namespace boot {
-namespace V1_2 {
-namespace implementation {
-
-#define GPT_SIGNATURE 0x5452415020494645UL
-
-typedef struct {
- uint8_t type_guid[16];
- uint8_t guid[16];
- uint64_t first_lba;
- uint64_t last_lba;
- uint64_t attr;
- uint16_t name[36];
-} __attribute__((packed)) gpt_entry;
-
-typedef struct {
- uint64_t signature;
- uint32_t revision;
- uint32_t header_size;
- uint32_t crc32;
- uint32_t reserved;
- uint64_t current_lba;
- uint64_t backup_lba;
- uint64_t first_usable_lba;
- uint64_t last_usable_lba;
- uint8_t disk_guid[16];
- uint64_t start_lba;
- uint32_t entry_count;
- uint32_t entry_size;
- uint32_t entries_crc32;
-} __attribute__((packed)) gpt_header;
-
-class GptUtils {
- public:
- GptUtils(const std::string dev_path);
- int Load(void);
- gpt_entry *GetPartitionEntry(std::string name);
- int Sync(void);
- ~GptUtils();
-
- private:
- std::string dev_path;
- int fd;
- uint32_t block_size;
- gpt_header gpt_primary;
- gpt_header gpt_backup;
- std::vector<gpt_entry> entry_array;
- std::map<std::string, gpt_entry *> entries;
-};
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace boot
-} // namespace hardware
-} // namespace android
diff --git a/interfaces/boot/1.2/android.hardware.boot@1.2-service-gs101.rc b/interfaces/boot/1.2/android.hardware.boot@1.2-service-gs101.rc
deleted file mode 100644
index b0b14dc3..00000000
--- a/interfaces/boot/1.2/android.hardware.boot@1.2-service-gs101.rc
+++ /dev/null
@@ -1,7 +0,0 @@
-service vendor.boot-hal-1-2 /vendor/bin/hw/android.hardware.boot@1.2-service-gs101
- interface android.hardware.boot@1.0::IBootControl default
- interface android.hardware.boot@1.1::IBootControl default
- interface android.hardware.boot@1.2::IBootControl default
- class early_hal
- user root
- group root
diff --git a/interfaces/boot/1.2/service.cpp b/interfaces/boot/1.2/service.cpp
deleted file mode 100644
index f07682e9..00000000
--- a/interfaces/boot/1.2/service.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "android.hardware.boot@1.2-service"
-
-#include <android/hardware/boot/1.2/IBootControl.h>
-#include <hidl/HidlTransportSupport.h>
-#include <hidl/Status.h>
-#include <log/log.h>
-
-#include "BootControl.h"
-
-using ::android::status_t;
-
-using ::android::hardware::boot::V1_2::IBootControl;
-
-using ::android::hardware::boot::V1_2::implementation::BootControl;
-// using ::android::hardware::boot::implementation::BootControl;
-
-int main(int /* argc */, char * /* argv */[]) {
- // This function must be called before you join to ensure the proper
- // number of threads are created. The threadpool will never exceed
- // size one because of this call.
- ::android::hardware::configureRpcThreadpool(1 /*threads*/, true /*willJoin*/);
-
- ::android::sp bootctrl = new BootControl();
- const status_t status = bootctrl->registerAsService();
- if (status != ::android::OK) {
- return 1; // or handle error
- }
-
- // Adds this thread to the threadpool, resulting in one total
- // thread in the threadpool. We could also do other things, but
- // would have to specify 'false' to willJoin in configureRpcThreadpool.
- ::android::hardware::joinRpcThreadpool();
- return 1; // joinRpcThreadpool should never return
-}
diff --git a/manifest.xml b/manifest.xml
index 303ed2ca..fdc85f37 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -30,10 +30,9 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="hidl">
+ <hal format="aidl">
<name>android.hardware.boot</name>
- <transport>hwbinder</transport>
- <fqname>@1.2::IBootControl/default</fqname>
+ <fqname>IBootControl/default</fqname>
</hal>
<hal format="aidl">
<name>com.google.input</name>
diff --git a/manifest_64.xml b/manifest_64.xml
index 115357d6..5f6d83ae 100644
--- a/manifest_64.xml
+++ b/manifest_64.xml
@@ -17,10 +17,9 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="hidl">
+ <hal format="aidl">
<name>android.hardware.boot</name>
- <transport>hwbinder</transport>
- <fqname>@1.2::IBootControl/default</fqname>
+ <fqname>IBootControl/default</fqname>
</hal>
<hal format="hidl">
<name>android.hardware.neuralnetworks</name>
diff --git a/media_codecs_performance_c2.xml b/media_codecs_performance_c2.xml
index 358586ea..fc03c53d 100644
--- a/media_codecs_performance_c2.xml
+++ b/media_codecs_performance_c2.xml
@@ -174,6 +174,12 @@
<Limit name="measured-frame-rate-720x480" range="101-129" />
<Limit name="measured-frame-rate-1280x720" range="38-40" />
</MediaCodec>
+ <MediaCodec name="c2.android.av1-dav1d.decoder" type="video/av01" update="true">
+ <Limit name="measured-frame-rate-352x288" range="353-362" />
+ <Limit name="measured-frame-rate-640x360" range="178-210" />
+ <Limit name="measured-frame-rate-720x480" range="101-129" />
+ <Limit name="measured-frame-rate-1280x720" range="38-40" />
+ </MediaCodec>
</Decoders>
<Encoders>
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 32adb013..bd9ebd61 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -203,7 +203,7 @@
<!-- Default color temperature, in Kelvin, to tint the screen when night display is
activated. -->
- <integer name="config_nightDisplayColorTemperatureDefault">3339</integer>
+ <integer name="config_nightDisplayColorTemperatureDefault">4000</integer>
<!-- Whether the device enable the standalone (SA) mode of 5G NR.-->
<bool name="config_telephony5gStandalone">true</bool>
@@ -240,6 +240,9 @@
<!-- Should the pinner service pin the Home application? -->
<bool name="config_pinnerHomeApp">true</bool>
+ <!-- Bytes that the PinnerService will pin for WebView -->
+ <integer name="config_pinnerWebviewPinBytes">20971520</integer>
+
<!-- The default intensity level for alarm vibrations. See
Settings.System.ALARM_VIBRATION_INTENSITY more details on the constant values and
meanings. -->
@@ -280,4 +283,28 @@
<!-- Enable variable refresh rate when typing. -->
<bool name="config_variableRefreshRateTypingSupported">false</bool>
-</resources>
+
+ <!-- The list of packages to automatically opt in of fresh rate suppressing by small area
+ detection. Format of this array should be packageName:threshold and threshold value should
+ be between 0 to 1-->
+ <string-array name="config_smallAreaDetectionAllowlist" translatable="false">
+ <!-- Add packages:threshold here -->
+ <item>com.tencent.mm:0.07</item>
+ <item>com.facebook.katana:0.07</item>
+ <item>com.instagram.android:0.07</item>
+ <item>com.spotify.music:0.05</item>
+ <item>com.reddit.frontpage:0.07</item>
+ <item>com.zhiliaoapp.musically:0.07</item>
+ <item>com.bilibili.app.in:0.07</item>
+ <item>com.twitter.android:0.07</item>
+ </string-array>
+
+ <!-- Pre-scale volume at volume step 1 for Absolute Volume -->
+ <fraction name="config_prescaleAbsoluteVolume_index1">100%</fraction>
+
+ <!-- Pre-scale volume at volume step 2 for Absolute Volume -->
+ <fraction name="config_prescaleAbsoluteVolume_index2">100%</fraction>
+
+ <!-- Pre-scale volume at volume step 3 for Absolute Volume -->
+ <fraction name="config_prescaleAbsoluteVolume_index3">100%</fraction>
+ </resources>
diff --git a/pixelstats/service.cpp b/pixelstats/service.cpp
index 35d0abfe..a9397403 100644
--- a/pixelstats/service.cpp
+++ b/pixelstats/service.cpp
@@ -69,6 +69,7 @@ const struct SysfsCollector::SysfsPaths sysfs_paths = {
"/sys/kernel/metrics/thermal/tr_by_group/spmic/stats_reset"
}
},
+ .GMSRPath = "/sys/class/power_supply/maxfg/gmsr"
};
const struct UeventListener::UeventPaths ueventPaths = {
diff --git a/preinstalled-packages-product-gs101-device-debug.xml b/preinstalled-packages-product-gs101-device-debug.xml
index 64524bcd..88204bca 100644
--- a/preinstalled-packages-product-gs101-device-debug.xml
+++ b/preinstalled-packages-product-gs101-device-debug.xml
@@ -22,14 +22,6 @@
<install-in user-type="FULL" />
<install-in user-type="PROFILE" />
<do-not-install-in user-type="android.os.usertype.profile.CLONE" />
- </install-in-user-type>
-
- <!-- RCS - Rich Communication Services (TestRcsApp)
- TODO(b/259401601): Check if this should be preinstalled for SYSTEM user -->
- <install-in-user-type package="com.google.android.sample.rcsclient">
- <install-in user-type="SYSTEM" />
- <install-in user-type="FULL" />
- <install-in user-type="PROFILE" />
- <do-not-install-in user-type="android.os.usertype.profile.CLONE" />
+ <do-not-install-in user-type="android.os.usertype.profile.PRIVATE" />
</install-in-user-type>
</config>
diff --git a/task_profiles.json b/task_profiles.json
index 961857de..fda6c3ea 100644
--- a/task_profiles.json
+++ b/task_profiles.json
@@ -7,8 +7,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_ta",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_ta",
+ "FilePath": "/proc/vendor_sched/groups/ta/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/ta/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -22,8 +22,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_cam",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_cam",
+ "FilePath": "/proc/vendor_sched/groups/cam/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/cam/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -37,8 +37,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_cam_power",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_cam_power",
+ "FilePath": "/proc/vendor_sched/groups/cam_power/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/cam_power/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -52,8 +52,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_dex2oat",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_dex2oat",
+ "FilePath": "/proc/vendor_sched/groups/dex2oat/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/dex2oat/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -67,8 +67,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_ota",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_ota",
+ "FilePath": "/proc/vendor_sched/groups/ota/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/ota/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -121,8 +121,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_bg",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_bg",
+ "FilePath": "/proc/vendor_sched/groups/bg/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/bg/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -136,8 +136,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_sys",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_sys",
+ "FilePath": "/proc/vendor_sched/groups/sys/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/sys/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -151,8 +151,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_fg",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_fg",
+ "FilePath": "/proc/vendor_sched/groups/fg/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/fg/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -166,8 +166,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_ta",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_ta",
+ "FilePath": "/proc/vendor_sched/groups/ta/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/ta/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -181,8 +181,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_nnapi",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_nnapi",
+ "FilePath": "/proc/vendor_sched/groups/nnapi/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/nnapi/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -196,8 +196,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_sysbg",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_sysbg",
+ "FilePath": "/proc/vendor_sched/groups/sys_bg/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/sys_bg/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -219,8 +219,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_sf",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_sf",
+ "FilePath": "/proc/vendor_sched/groups/sf/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/sf/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
@@ -242,8 +242,8 @@
"Name": "WriteFile",
"Params":
{
- "FilePath": "/proc/vendor_sched/set_task_group_rt",
- "ProcFilePath": "/proc/vendor_sched/set_proc_group_rt",
+ "FilePath": "/proc/vendor_sched/groups/rt/set_task_group",
+ "ProcFilePath": "/proc/vendor_sched/groups/rt/set_proc_group",
"Value": "<pid>",
"LogFailures": "false"
}
diff --git a/tts/de-de/de-de-x-multi-r43.zvoice b/tts/de-de/de-de-x-multi-r43.zvoice
deleted file mode 100644
index 5c3afdb9..00000000
--- a/tts/de-de/de-de-x-multi-r43.zvoice
+++ /dev/null
Binary files differ
diff --git a/tts/es-es/es-es-x-multi-r43.zvoice b/tts/es-es/es-es-x-multi-r43.zvoice
deleted file mode 100644
index 2cebf9fd..00000000
--- a/tts/es-es/es-es-x-multi-r43.zvoice
+++ /dev/null
Binary files differ
diff --git a/tts/fr-fr/fr-fr-x-multi-r44.zvoice b/tts/fr-fr/fr-fr-x-multi-r44.zvoice
deleted file mode 100644
index 7cf7f42a..00000000
--- a/tts/fr-fr/fr-fr-x-multi-r44.zvoice
+++ /dev/null
Binary files differ
diff --git a/tts/it-it/it-it-x-multi-r40.zvoice b/tts/it-it/it-it-x-multi-r40.zvoice
deleted file mode 100644
index fe10249c..00000000
--- a/tts/it-it/it-it-x-multi-r40.zvoice
+++ /dev/null
Binary files differ
diff --git a/tts/ja-jp/ja-jp-x-multi-r42.zvoice b/tts/ja-jp/ja-jp-x-multi-r42.zvoice
deleted file mode 100644
index 7225ef01..00000000
--- a/tts/ja-jp/ja-jp-x-multi-r42.zvoice
+++ /dev/null
Binary files differ
diff --git a/tts/voice_packs.mk b/tts/voice_packs.mk
deleted file mode 100644
index 395ffb17..00000000
--- a/tts/voice_packs.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Copyright (C) 2022 The Android Open-Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Voice packs for Text-To-Speech
-PRODUCT_COPY_FILES += \
- device/google/gs101/tts/ja-jp/ja-jp-x-multi-r42.zvoice:product/tts/google/ja-jp/ja-jp-x-multi-r42.zvoice\
- device/google/gs101/tts/fr-fr/fr-fr-x-multi-r44.zvoice:product/tts/google/fr-fr/fr-fr-x-multi-r44.zvoice\
- device/google/gs101/tts/de-de/de-de-x-multi-r43.zvoice:product/tts/google/de-de/de-de-x-multi-r43.zvoice\
- device/google/gs101/tts/it-it/it-it-x-multi-r40.zvoice:product/tts/google/it-it/it-it-x-multi-r40.zvoice\
- device/google/gs101/tts/es-es/es-es-x-multi-r43.zvoice:product/tts/google/es-es/es-es-x-multi-r43.zvoice
diff --git a/usb/gadget/UsbGadget.cpp b/usb/gadget/UsbGadget.cpp
index 9b68e2c4..64fd17b0 100644
--- a/usb/gadget/UsbGadget.cpp
+++ b/usb/gadget/UsbGadget.cpp
@@ -38,38 +38,18 @@ namespace gadget {
string enabledPath;
constexpr char kHsi2cPath[] = "/sys/devices/platform/10d50000.hsi2c";
-constexpr char kI2CPath[] = "/sys/devices/platform/10d50000.hsi2c/i2c-";
-constexpr char kAccessoryLimitCurrent[] = "i2c-max77759tcpc/usb_limit_accessory_current";
-constexpr char kAccessoryLimitCurrentEnable[] = "i2c-max77759tcpc/usb_limit_accessory_enable";
-constexpr char kUpdateSdpEnumTimeout[] = "i2c-max77759tcpc/update_sdp_enum_timeout";
+constexpr char kMax77759TcpcDevName[] = "i2c-max77759tcpc";
+constexpr unsigned int kMax77759TcpcClientId = 0x25;
+constexpr char kAccessoryLimitCurrent[] = "usb_limit_accessory_current";
+constexpr char kAccessoryLimitCurrentEnable[] = "usb_limit_accessory_enable";
+constexpr char kUpdateSdpEnumTimeout[] = "update_sdp_enum_timeout";
using ::android::base::GetBoolProperty;
using ::android::hardware::google::pixel::usb::kUvcEnabled;
-Status getI2cBusHelper(string *name) {
- DIR *dp;
-
- dp = opendir(kHsi2cPath);
- if (dp != NULL) {
- struct dirent *ep;
-
- while ((ep = readdir(dp))) {
- if (ep->d_type == DT_DIR) {
- if (string::npos != string(ep->d_name).find("i2c-")) {
- std::strtok(ep->d_name, "-");
- *name = std::strtok(NULL, "-");
- }
- }
- }
- closedir(dp);
- return Status::SUCCESS;
- }
-
- ALOGE("Failed to open %s", kHsi2cPath);
- return Status::ERROR;
-}
-
-UsbGadget::UsbGadget() : mGadgetIrqPath("") {
+UsbGadget::UsbGadget() : mGadgetIrqPath(""),
+ mI2cBusNumber(-1),
+ mI2cClientPath("") {
if (access(OS_DESC_PATH, R_OK) != 0) {
ALOGE("configfs setup not done yet");
abort();
@@ -389,14 +369,16 @@ ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback> &callback,
}
void UsbGadget::updateSdpEnumTimeout() {
- string i2c_node, update_sdp_enum_timeout_path;
+ string update_sdp_enum_timeout_path;
+ std::string_view i2cPath;
- Status status = getI2cBusHelper(&i2c_node);
- if (status != Status::SUCCESS) {
+ i2cPath = getI2cClientPath();
+ if (i2cPath.empty()) {
ALOGE("%s: Unable to locate i2c bus node", __func__);
+ return;
}
- update_sdp_enum_timeout_path = kI2CPath + i2c_node + "/" + kUpdateSdpEnumTimeout;
+ update_sdp_enum_timeout_path = std::string{i2cPath} + "/" + kUpdateSdpEnumTimeout;
if (!WriteStringToFile("1", update_sdp_enum_timeout_path)) {
ALOGE("%s: Unable to write to %s.", __func__, update_sdp_enum_timeout_path.c_str());
} else {
@@ -483,6 +465,75 @@ Status UsbGadget::setupFunctions(long functions,
return Status::SUCCESS;
}
+int UsbGadget::getI2cBusNumber() {
+ DIR *dp;
+ unsigned int busNumber;
+
+ // Since the i2c bus number doesn't change after boot, we only need to get
+ // it once.
+ if (mI2cBusNumber >= 0) {
+ return mI2cBusNumber;
+ }
+
+ dp = opendir(kHsi2cPath);
+ if (dp != NULL) {
+ struct dirent *ep;
+
+ while ((ep = readdir(dp))) {
+ if (ep->d_type == DT_DIR) {
+ if (sscanf(ep->d_name, "i2c-%u", &busNumber) == 1) {
+ mI2cBusNumber = busNumber;
+ break;
+ }
+ }
+ }
+ closedir(dp);
+ }
+
+ if (mI2cBusNumber < 0) {
+ ALOGE("Failed to open %s", kHsi2cPath);
+ }
+ return mI2cBusNumber;
+}
+
+std::string_view UsbGadget::getI2cClientPath() {
+ DIR *dp;
+ char i2cClientPathLabeled[PATH_MAX];
+ char i2cClientPathUnLabeled[PATH_MAX];
+
+ // Since the I2C client path doesn't change after boot, we only need to get
+ // it once.
+ if (!mI2cClientPath.empty()) {
+ return mI2cClientPath;
+ }
+
+ if (getI2cBusNumber() < 0) {
+ return std::string_view{""};
+ }
+
+ snprintf(i2cClientPathLabeled, sizeof(i2cClientPathLabeled),
+ "%s/i2c-%d/%s", kHsi2cPath, mI2cBusNumber, kMax77759TcpcDevName);
+ snprintf(i2cClientPathUnLabeled, sizeof(i2cClientPathUnLabeled),
+ "%s/i2c-%d/%d-%04x", kHsi2cPath, mI2cBusNumber, mI2cBusNumber,
+ kMax77759TcpcClientId);
+
+ dp = opendir(i2cClientPathLabeled);
+ if (dp != NULL) {
+ mI2cClientPath.assign(i2cClientPathLabeled);
+ closedir(dp);
+ return mI2cClientPath;
+ }
+
+ dp = opendir(i2cClientPathUnLabeled);
+ if (dp != NULL) {
+ mI2cClientPath.assign(i2cClientPathUnLabeled);
+ closedir(dp);
+ return mI2cClientPath;
+ }
+
+ ALOGE("Failed to find the i2c client path under %s", kHsi2cPath);
+ return std::string_view{""};
+}
ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
const shared_ptr<IUsbGadgetCallback> &callback,
@@ -492,14 +543,19 @@ ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
std::string current_usb_power_operation_mode, current_usb_type;
std::string usb_limit_sink_enable;
- string accessoryCurrentLimitEnablePath, accessoryCurrentLimitPath, path;
+ string accessoryCurrentLimitEnablePath, accessoryCurrentLimitPath;
+ std::string_view i2cPath;
mCurrentUsbFunctions = functions;
mCurrentUsbFunctionsApplied = false;
- getI2cBusHelper(&path);
- accessoryCurrentLimitPath = kI2CPath + path + "/" + kAccessoryLimitCurrent;
- accessoryCurrentLimitEnablePath = kI2CPath + path + "/" + kAccessoryLimitCurrentEnable;
+ i2cPath = getI2cClientPath();
+ if (!i2cPath.empty()) {
+ accessoryCurrentLimitPath = std::string{i2cPath} + "/" + kAccessoryLimitCurrent;
+ accessoryCurrentLimitEnablePath = std::string{i2cPath} + "/" + kAccessoryLimitCurrentEnable;
+ } else {
+ ALOGE("%s: Unable to locate i2c bus node", __func__);
+ }
// Get the gadget IRQ number before tearDownGadget()
if (mGadgetIrqPath.empty())
@@ -560,15 +616,17 @@ ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
current_usb_type == "Unknown SDP [CDP] DCP" &&
(current_usb_power_operation_mode == "default" ||
current_usb_power_operation_mode == "1.5A")) {
- if (!WriteStringToFile("1300000", accessoryCurrentLimitPath)) {
+ if (accessoryCurrentLimitPath.empty() || !WriteStringToFile("1300000", accessoryCurrentLimitPath)) {
ALOGI("Write 1.3A to limit current fail");
} else {
- if (!WriteStringToFile("1", accessoryCurrentLimitEnablePath)) {
+ if (accessoryCurrentLimitEnablePath.empty() ||
+ !WriteStringToFile("1", accessoryCurrentLimitEnablePath)) {
ALOGI("Enable limit current fail");
}
}
} else {
- if (!WriteStringToFile("0", accessoryCurrentLimitEnablePath))
+ if (accessoryCurrentLimitEnablePath.empty() ||
+ !WriteStringToFile("0", accessoryCurrentLimitEnablePath))
ALOGI("unvote accessory limit current failed");
}
diff --git a/usb/gadget/UsbGadget.h b/usb/gadget/UsbGadget.h
index a6b63bdb..e483a912 100644
--- a/usb/gadget/UsbGadget.h
+++ b/usb/gadget/UsbGadget.h
@@ -119,7 +119,12 @@ struct UsbGadget : public BnUsbGadget {
// set SDP timeout to a lower value.
void updateSdpEnumTimeout();
+ int getI2cBusNumber();
+ std::string_view getI2cClientPath();
+
private:
+ int mI2cBusNumber;
+ std::string mI2cClientPath;
Status tearDownGadget();
Status getUsbGadgetIrqPath();
Status setupFunctions(long functions, const shared_ptr<IUsbGadgetCallback> &callback,
diff --git a/usb/gadget/android.hardware.usb.gadget-service.rc b/usb/gadget/android.hardware.usb.gadget-service.rc
index ba7d5f69..456bffc3 100644
--- a/usb/gadget/android.hardware.usb.gadget-service.rc
+++ b/usb/gadget/android.hardware.usb.gadget-service.rc
@@ -2,21 +2,3 @@ service vendor.usb-gadget-hal /vendor/bin/hw/android.hardware.usb.gadget-service
class hal
user system
group system shell mtp
-
-on post-fs
- chown root system /sys/class/typec/port0/power_role
- chown root system /sys/class/typec/port0/data_role
- chown root system /sys/class/typec/port0/port_type
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess
- chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id
- chown root system /sys/devices/platform/11110000.usb/usb_data_enabled
- chmod 664 /sys/class/typec/port0/power_role
- chmod 664 /sys/class/typec/port0/data_role
- chmod 664 /sys/class/typec/port0/port_type
- chmod 664 /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess
- chmod 664 /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id
- chmod 664 /sys/devices/platform/11110000.usb/usb_data_enabled
diff --git a/usb/usb/Android.bp b/usb/usb/Android.bp
index 1530db58..5afdcc66 100644
--- a/usb/usb/Android.bp
+++ b/usb/usb/Android.bp
@@ -32,6 +32,7 @@ cc_binary {
srcs: [
"service.cpp",
"Usb.cpp",
+ "UsbDataSessionMonitor.cpp",
],
shared_libs: [
"libbase",
@@ -44,20 +45,28 @@ cc_binary {
"android.hardware.thermal@2.0",
"android.hardware.thermal-V1-ndk",
"android.hardware.usb.gadget@1.0",
- "android.hardware.usb-V2-ndk",
+ "android.hardware.usb-V3-ndk",
"libcutils",
- "android.frameworks.stats-V1-ndk",
+ "android.frameworks.stats-V2-ndk",
"pixelatoms-cpp",
"libbinder_ndk",
-
+ "libprotobuf-cpp-lite",
+ "server_configurable_flags",
],
static_libs: [
"libpixelusb",
"libpixelstats",
"libthermalutils",
+ "android.hardware.usb.flags-aconfig-c-lib",
],
export_shared_lib_headers: [
- "android.frameworks.stats-V1-ndk",
+ "android.frameworks.stats-V2-ndk",
"pixelatoms-cpp",
],
}
+
+cc_aconfig_library {
+ name: "android.hardware.usb.flags-aconfig-c-lib",
+ vendor: true,
+ aconfig_declarations: "android.hardware.usb.flags-aconfig",
+}
diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp
index 7a148887..a898b053 100644
--- a/usb/usb/Usb.cpp
+++ b/usb/usb/Usb.cpp
@@ -26,7 +26,6 @@
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
-#include <chrono>
#include <regex>
#include <thread>
#include <unordered_map>
@@ -39,9 +38,12 @@
#include "Usb.h"
#include <aidl/android/frameworks/stats/IStats.h>
+#include <android_hardware_usb_flags.h>
#include <pixelusb/UsbGadgetCommon.h>
#include <pixelstats/StatsHelper.h>
+namespace usb_flags = android::hardware::usb::flags;
+
using aidl::android::frameworks::stats::IStats;
using android::base::GetProperty;
using android::base::Tokenize;
@@ -59,17 +61,19 @@ volatile bool destroyThread;
string enabledPath;
constexpr char kHsi2cPath[] = "/sys/devices/platform/10d50000.hsi2c";
-constexpr char kI2CPath[] = "/sys/devices/platform/10d50000.hsi2c/i2c-";
constexpr char kComplianceWarningsPath[] = "device/non_compliant_reasons";
constexpr char kComplianceWarningBC12[] = "bc12";
constexpr char kComplianceWarningDebugAccessory[] = "debug-accessory";
constexpr char kComplianceWarningMissingRp[] = "missing_rp";
constexpr char kComplianceWarningOther[] = "other";
-constexpr char kContaminantDetectionPath[] = "i2c-max77759tcpc/contaminant_detection";
-constexpr char kStatusPath[] = "i2c-max77759tcpc/contaminant_detection_status";
-constexpr char kSinkLimitEnable[] = "i2c-max77759tcpc/usb_limit_sink_enable";
-constexpr char kSourceLimitEnable[] = "i2c-max77759tcpc/usb_limit_source_enable";
-constexpr char kSinkLimitCurrent[] = "i2c-max77759tcpc/usb_limit_sink_current";
+constexpr char kComplianceWarningInputPowerLimited[] = "input_power_limited";
+constexpr char kMax77759TcpcDevName[] = "i2c-max77759tcpc";
+constexpr unsigned int kMax77759TcpcClientId = 0x25;
+constexpr char kContaminantDetectionPath[] = "contaminant_detection";
+constexpr char kStatusPath[] = "contaminant_detection_status";
+constexpr char kSinkLimitEnable[] = "usb_limit_sink_enable";
+constexpr char kSourceLimitEnable[] = "usb_limit_source_enable";
+constexpr char kSinkLimitCurrent[] = "usb_limit_sink_current";
constexpr char kTypecPath[] = "/sys/class/typec";
constexpr char kDisableContatminantDetection[] = "vendor.usb.contaminantdisable";
constexpr char kOverheatStatsPath[] = "/sys/devices/platform/google,usbc_port_cooling_dev/";
@@ -81,6 +85,17 @@ constexpr char kThermalZoneForTempReadSecondary2[] = "qi_therm";
constexpr char kPogoUsbActive[] = "/sys/devices/platform/google,pogo/pogo_usb_active";
constexpr char KPogoMoveDataToUsb[] = "/sys/devices/platform/google,pogo/move_data_to_usb";
constexpr char kPowerSupplyUsbType[] = "/sys/class/power_supply/usb/usb_type";
+constexpr char kUdcUeventRegex[] =
+ "/devices/platform/11110000.usb/11110000.dwc3/udc/11110000.dwc3";
+constexpr char kUdcStatePath[] =
+ "/sys/devices/platform/11110000.usb/11110000.dwc3/udc/11110000.dwc3/state";
+constexpr char kHost1UeventRegex[] =
+ "/devices/platform/11110000.usb/11110000.dwc3/xhci-hcd-exynos.[0-9].auto/usb2/2-0:1.0";
+constexpr char kHost1StatePath[] = "/sys/bus/usb/devices/usb2/2-0:1.0/usb2-port1/state";
+constexpr char kHost2UeventRegex[] =
+ "/devices/platform/11110000.usb/11110000.dwc3/xhci-hcd-exynos.[0-9].auto/usb3/3-0:1.0";
+constexpr char kHost2StatePath[] = "/sys/bus/usb/devices/usb3/3-0:1.0/usb3-port1/state";
+constexpr char kDataRolePath[] = "/sys/devices/platform/11110000.usb/new_data_role";
constexpr int kSamplingIntervalSec = 5;
void queryVersionHelper(android::hardware::usb::Usb *usb,
std::vector<PortStatus> *currentPortStatus);
@@ -215,8 +230,15 @@ ScopedAStatus Usb::resetUsbPort(const std::string& in_portName, int64_t in_trans
return ::ndk::ScopedAStatus::ok();
}
-Status getI2cBusHelper(string *name) {
+int Usb::getI2cBusNumber() {
DIR *dp;
+ unsigned int busNumber;
+
+ // Since the i2c bus number doesn't change after boot, we only need to get
+ // it once.
+ if (mI2cBusNumber >= 0) {
+ return mI2cBusNumber;
+ }
dp = opendir(kHsi2cPath);
if (dp != NULL) {
@@ -224,22 +246,65 @@ Status getI2cBusHelper(string *name) {
while ((ep = readdir(dp))) {
if (ep->d_type == DT_DIR) {
- if (string::npos != string(ep->d_name).find("i2c-")) {
- std::strtok(ep->d_name, "-");
- *name = std::strtok(NULL, "-");
+ if (sscanf(ep->d_name, "i2c-%u", &busNumber) == 1) {
+ mI2cBusNumber = busNumber;
+ break;
}
}
}
closedir(dp);
- return Status::SUCCESS;
}
- ALOGE("Failed to open %s", kHsi2cPath);
- return Status::ERROR;
+ if (mI2cBusNumber < 0) {
+ ALOGE("Failed to open %s", kHsi2cPath);
+ }
+ return mI2cBusNumber;
+}
+
+std::string_view Usb::getI2cClientPath() {
+ DIR *dp;
+ char i2cClientPathLabeled[PATH_MAX];
+ char i2cClientPathUnLabeled[PATH_MAX];
+
+ // Since the I2C client path doesn't change after boot, we only need to get
+ // it once.
+ if (!mI2cClientPath.empty()) {
+ return mI2cClientPath;
+ }
+
+ if (getI2cBusNumber() < 0) {
+ return std::string_view{""};
+ }
+
+ snprintf(i2cClientPathLabeled, sizeof(i2cClientPathLabeled),
+ "%s/i2c-%d/%s", kHsi2cPath, mI2cBusNumber, kMax77759TcpcDevName);
+ snprintf(i2cClientPathUnLabeled, sizeof(i2cClientPathUnLabeled),
+ "%s/i2c-%d/%d-%04x", kHsi2cPath, mI2cBusNumber, mI2cBusNumber,
+ kMax77759TcpcClientId);
+
+ dp = opendir(i2cClientPathLabeled);
+ if (dp != NULL) {
+ mI2cClientPath.assign(i2cClientPathLabeled);
+ closedir(dp);
+ return mI2cClientPath;
+ }
+
+ dp = opendir(i2cClientPathUnLabeled);
+ if (dp != NULL) {
+ mI2cClientPath.assign(i2cClientPathUnLabeled);
+ closedir(dp);
+ return mI2cClientPath;
+ }
+
+ ALOGE("Failed to find the i2c client path under %s", kHsi2cPath);
+ return std::string_view{""};
}
-Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus) {
- string enabled, status, path, DetectedPath;
+Status queryMoistureDetectionStatus(android::hardware::usb::Usb *usb,
+ std::vector<PortStatus> *currentPortStatus)
+{
+ string enabled, status, DetectedPath;
+ std::string_view i2cPath;
(*currentPortStatus)[0].supportedContaminantProtectionModes
.push_back(ContaminantProtectionMode::FORCE_DISABLE);
@@ -248,8 +313,12 @@ Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus)
(*currentPortStatus)[0].supportsEnableContaminantPresenceDetection = true;
(*currentPortStatus)[0].supportsEnableContaminantPresenceProtection = false;
- getI2cBusHelper(&path);
- enabledPath = kI2CPath + path + "/" + kContaminantDetectionPath;
+ i2cPath = usb->getI2cClientPath();
+ if (i2cPath.empty()) {
+ ALOGE("%s: Unable to locate i2c bus node", __func__);
+ return Status::ERROR;
+ }
+ enabledPath = std::string{i2cPath} + "/" + kContaminantDetectionPath;
if (!ReadFileToString(enabledPath, &enabled)) {
ALOGE("Failed to open moisture_detection_enabled");
return Status::ERROR;
@@ -257,7 +326,7 @@ Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus)
enabled = Trim(enabled);
if (enabled == "1") {
- DetectedPath = kI2CPath + path + "/" + kStatusPath;
+ DetectedPath = std::string{i2cPath} + "/" + kStatusPath;
if (!ReadFileToString(DetectedPath, &status)) {
ALOGE("Failed to open moisture_detected");
return Status::ERROR;
@@ -307,9 +376,20 @@ Status queryNonCompliantChargerStatus(std::vector<PortStatus> *currentPortStatus
continue;
}
if (!strncmp(reason.c_str(), kComplianceWarningOther,
- strlen(kComplianceWarningOther))) {
- (*currentPortStatus)[i].complianceWarnings.push_back(ComplianceWarning::OTHER);
- continue;
+ strlen(kComplianceWarningOther)) ||
+ !strncmp(reason.c_str(), kComplianceWarningInputPowerLimited,
+ strlen(kComplianceWarningInputPowerLimited))) {
+ if (usb_flags::enable_usb_data_compliance_warning() &&
+ usb_flags::enable_input_power_limited_warning()) {
+ ALOGI("Report through INPUT_POWER_LIMITED warning");
+ (*currentPortStatus)[i].complianceWarnings.push_back(
+ ComplianceWarning::INPUT_POWER_LIMITED);
+ continue;
+ } else {
+ (*currentPortStatus)[i].complianceWarnings.push_back(
+ ComplianceWarning::OTHER);
+ continue;
+ }
}
}
if ((*currentPortStatus)[i].complianceWarnings.size() > 0 &&
@@ -442,11 +522,20 @@ bool switchMode(const string &portName, const PortRole &in_role, struct Usb *usb
return roleSwitch;
}
+void updatePortStatus(android::hardware::usb::Usb *usb) {
+ std::vector<PortStatus> currentPortStatus;
+
+ queryVersionHelper(usb, &currentPortStatus);
+}
+
Usb::Usb()
: mLock(PTHREAD_MUTEX_INITIALIZER),
mRoleSwitchLock(PTHREAD_MUTEX_INITIALIZER),
mPartnerLock(PTHREAD_MUTEX_INITIALIZER),
mPartnerUp(false),
+ mUsbDataSessionMonitor(kUdcUeventRegex, kUdcStatePath, kHost1UeventRegex, kHost1StatePath,
+ kHost2UeventRegex, kHost2StatePath, kDataRolePath,
+ std::bind(&updatePortStatus, this)),
mOverheat(ZoneInfo(TemperatureType::USB_PORT, kThermalZoneForTrip,
ThrottlingSeverity::CRITICAL),
{ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadPrimary,
@@ -455,7 +544,9 @@ Usb::Usb()
ThrottlingSeverity::NONE),
ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadSecondary2,
ThrottlingSeverity::NONE)}, kSamplingIntervalSec),
- mUsbDataEnabled(true) {
+ mUsbDataEnabled(true),
+ mI2cBusNumber(-1),
+ mI2cClientPath("") {
pthread_condattr_t attr;
if (pthread_condattr_init(&attr)) {
ALOGE("pthread_condattr_init failed: %s", strerror(errno));
@@ -534,32 +625,38 @@ ScopedAStatus Usb::limitPowerTransfer(const string& in_portName, bool in_limit,
int64_t in_transactionId) {
bool sessionFail = false, success;
std::vector<PortStatus> currentPortStatus;
- string path, sinkLimitEnablePath, currentLimitPath, sourceLimitEnablePath;
-
- getI2cBusHelper(&path);
- sinkLimitEnablePath = kI2CPath + path + "/" + kSinkLimitEnable;
- sourceLimitEnablePath = kI2CPath + path + "/" + kSourceLimitEnable;
- currentLimitPath = kI2CPath + path + "/" + kSinkLimitCurrent;
+ string sinkLimitEnablePath, currentLimitPath, sourceLimitEnablePath;
+ std::string_view i2cPath;
pthread_mutex_lock(&mLock);
- if (in_limit) {
- success = WriteStringToFile("0", currentLimitPath);
+ i2cPath = getI2cClientPath();
+ if (!i2cPath.empty()) {
+ sinkLimitEnablePath = std::string{i2cPath} + "/" + kSinkLimitEnable;
+ sourceLimitEnablePath = std::string{i2cPath} + "/" + kSourceLimitEnable;
+ currentLimitPath = std::string{i2cPath} + "/" + kSinkLimitCurrent;
+
+ if (in_limit) {
+ success = WriteStringToFile("0", currentLimitPath);
+ if (!success) {
+ ALOGE("Failed to set sink current limit");
+ sessionFail = true;
+ }
+ }
+ success = WriteStringToFile(in_limit ? "1" : "0", sinkLimitEnablePath);
if (!success) {
- ALOGE("Failed to set sink current limit");
+ ALOGE("Failed to %s sink current limit: %s", in_limit ? "enable" : "disable",
+ sinkLimitEnablePath.c_str());
sessionFail = true;
}
- }
- success = WriteStringToFile(in_limit ? "1" : "0", sinkLimitEnablePath);
- if (!success) {
- ALOGE("Failed to %s sink current limit: %s", in_limit ? "enable" : "disable",
- sinkLimitEnablePath.c_str());
+ success = WriteStringToFile(in_limit ? "1" : "0", sourceLimitEnablePath);
+ if (!success) {
+ ALOGE("Failed to %s source current limit: %s", in_limit ? "enable" : "disable",
+ sourceLimitEnablePath.c_str());
+ sessionFail = true;
+ }
+ } else {
sessionFail = true;
- }
- success = WriteStringToFile(in_limit ? "1" : "0", sourceLimitEnablePath);
- if (!success) {
- ALOGE("Failed to %s source current limit: %s", in_limit ? "enable" : "disable",
- sourceLimitEnablePath.c_str());
- sessionFail = true;
+ ALOGE("%s: Unable to locate i2c bus node", __func__);
}
ALOGI("limitPowerTransfer limit:%c opId:%ld", in_limit ? 'y' : 'n', in_transactionId);
if (mCallback != NULL && in_transactionId >= 0) {
@@ -578,11 +675,17 @@ ScopedAStatus Usb::limitPowerTransfer(const string& in_portName, bool in_limit,
return ScopedAStatus::ok();
}
-Status queryPowerTransferStatus(std::vector<PortStatus> *currentPortStatus) {
- string limitedPath, enabled, path;
+Status queryPowerTransferStatus(android::hardware::usb::Usb *usb,
+ std::vector<PortStatus> *currentPortStatus) {
+ string limitedPath, enabled;
+ std::string_view i2cPath;
- getI2cBusHelper(&path);
- limitedPath = kI2CPath + path + "/" + kSinkLimitEnable;
+ i2cPath = usb->getI2cClientPath();
+ if (i2cPath.empty()) {
+ ALOGE("%s: Unable to locate i2c bus node", __func__);
+ return Status::ERROR;
+ }
+ limitedPath = std::string{i2cPath} + "/" + kSinkLimitEnable;
if (!ReadFileToString(limitedPath, &enabled)) {
ALOGE("Failed to open limit_sink_enable");
return Status::ERROR;
@@ -813,14 +916,27 @@ done:
return Status::ERROR;
}
+void queryUsbDataSession(android::hardware::usb::Usb *usb,
+ std::vector<PortStatus> *currentPortStatus) {
+ std::vector<ComplianceWarning> warnings;
+
+ usb->mUsbDataSessionMonitor.getComplianceWarnings(
+ (*currentPortStatus)[0].currentDataRole, &warnings);
+ (*currentPortStatus)[0].complianceWarnings.insert(
+ (*currentPortStatus)[0].complianceWarnings.end(),
+ warnings.begin(),
+ warnings.end());
+}
+
void queryVersionHelper(android::hardware::usb::Usb *usb,
std::vector<PortStatus> *currentPortStatus) {
Status status;
pthread_mutex_lock(&usb->mLock);
status = getPortStatusHelper(usb, currentPortStatus);
- queryMoistureDetectionStatus(currentPortStatus);
- queryPowerTransferStatus(currentPortStatus);
+ queryMoistureDetectionStatus(usb, currentPortStatus);
+ queryPowerTransferStatus(usb, currentPortStatus);
queryNonCompliantChargerStatus(currentPortStatus);
+ queryUsbDataSession(usb, currentPortStatus);
if (usb->mCallback != NULL) {
ScopedAStatus ret = usb->mCallback->notifyPortStatusChange(*currentPortStatus,
status);
diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h
index 1a93e191..facc328e 100644
--- a/usb/usb/Usb.h
+++ b/usb/usb/Usb.h
@@ -21,6 +21,7 @@
#include <aidl/android/hardware/usb/BnUsbCallback.h>
#include <pixelusb/UsbOverheatEvent.h>
#include <utils/Log.h>
+#include <UsbDataSessionMonitor.h>
#define UEVENT_MSG_LEN 2048
// The type-c stack waits for 4.5 - 5.5 secs before declaring a port non-pd.
@@ -83,14 +84,21 @@ struct Usb : public BnUsb {
// Variable to signal partner coming back online after type switch
bool mPartnerUp;
+ // Report usb data session event and data incompliance warnings
+ UsbDataSessionMonitor mUsbDataSessionMonitor;
// Usb Overheat object for push suez event
UsbOverheatEvent mOverheat;
// Temperature when connected
float mPluggedTemperatureCelsius;
// Usb Data status
bool mUsbDataEnabled;
+ int getI2cBusNumber();
+ std::string_view getI2cClientPath();
+
private:
pthread_t mPoll;
+ int mI2cBusNumber;
+ std::string mI2cClientPath;
};
} // namespace usb
diff --git a/usb/usb/UsbDataSessionMonitor.cpp b/usb/usb/UsbDataSessionMonitor.cpp
new file mode 100644
index 00000000..77defb30
--- /dev/null
+++ b/usb/usb/UsbDataSessionMonitor.cpp
@@ -0,0 +1,420 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.hardware.usb.aidl-service.UsbDataSessionMonitor"
+
+#include "UsbDataSessionMonitor.h"
+
+#include <aidl/android/frameworks/stats/IStats.h>
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android_hardware_usb_flags.h>
+#include <cutils/uevent.h>
+#include <pixelstats/StatsHelper.h>
+#include <pixelusb/CommonUtils.h>
+#include <sys/epoll.h>
+#include <utils/Log.h>
+
+#include <regex>
+
+namespace usb_flags = android::hardware::usb::flags;
+
+using aidl::android::frameworks::stats::IStats;
+using android::base::ReadFileToString;
+using android::hardware::google::pixel::getStatsService;
+using android::hardware::google::pixel::reportUsbDataSessionEvent;
+using android::hardware::google::pixel::PixelAtoms::VendorUsbDataSessionEvent;
+using android::hardware::google::pixel::usb::addEpollFd;
+using android::hardware::google::pixel::usb::BuildVendorUsbDataSessionEvent;
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace usb {
+
+#define UEVENT_MSG_LEN 2048
+#define USB_STATE_MAX_LEN 20
+#define DATA_ROLE_MAX_LEN 10
+
+constexpr char kUdcConfigfsPath[] = "/config/usb_gadget/g1/UDC";
+constexpr char kNotAttachedState[] = "not attached\n";
+constexpr char kAttachedState[] = "attached\n";
+constexpr char kPoweredState[] = "powered\n";
+constexpr char kDefaultState[] = "default\n";
+constexpr char kAddressedState[] = "addressed\n";
+constexpr char kConfiguredState[] = "configured\n";
+constexpr char kSuspendedState[] = "suspended\n";
+const std::set<std::string> kValidStates = {kNotAttachedState, kAttachedState, kPoweredState,
+ kDefaultState, kAddressedState, kConfiguredState,
+ kSuspendedState};
+
+static int addEpollFile(const int &epollFd, const std::string &filePath, unique_fd &fileFd) {
+ struct epoll_event ev;
+
+ unique_fd fd(open(filePath.c_str(), O_RDONLY));
+
+ if (fd.get() == -1) {
+ ALOGI("Cannot open %s", filePath.c_str());
+ return -1;
+ }
+
+ ev.data.fd = fd.get();
+ ev.events = EPOLLPRI;
+
+ if (epoll_ctl(epollFd, EPOLL_CTL_ADD, fd.get(), &ev) != 0) {
+ ALOGE("epoll_ctl failed; errno=%d", errno);
+ return -1;
+ }
+
+ fileFd = std::move(fd);
+ ALOGI("epoll registered %s", filePath.c_str());
+ return 0;
+}
+
+static void removeEpollFile(const int &epollFd, const std::string &filePath, unique_fd &fileFd) {
+ epoll_ctl(epollFd, EPOLL_CTL_DEL, fileFd.get(), NULL);
+ fileFd.release();
+
+ ALOGI("epoll unregistered %s", filePath.c_str());
+}
+
+UsbDataSessionMonitor::UsbDataSessionMonitor(
+ const std::string &deviceUeventRegex, const std::string &deviceStatePath,
+ const std::string &host1UeventRegex, const std::string &host1StatePath,
+ const std::string &host2UeventRegex, const std::string &host2StatePath,
+ const std::string &dataRolePath, std::function<void()> updatePortStatusCb) {
+ struct epoll_event ev;
+ std::string udc;
+
+ unique_fd epollFd(epoll_create(8));
+ if (epollFd.get() == -1) {
+ ALOGE("epoll_create failed; errno=%d", errno);
+ abort();
+ }
+
+ unique_fd ueventFd(uevent_open_socket(64 * 1024, true));
+ if (ueventFd.get() == -1) {
+ ALOGE("uevent_open_socket failed");
+ abort();
+ }
+ fcntl(ueventFd, F_SETFL, O_NONBLOCK);
+
+ if (addEpollFd(epollFd, ueventFd))
+ abort();
+
+ if (addEpollFile(epollFd.get(), dataRolePath, mDataRoleFd) != 0) {
+ ALOGE("monitor data role failed");
+ abort();
+ }
+
+ /*
+ * The device state file could be absent depending on the current data role
+ * and driver architecture. It's ok for addEpollFile to fail here, the file
+ * will be monitored later when its presence is detected by uevent.
+ */
+ mDeviceState.filePath = deviceStatePath;
+ mDeviceState.ueventRegex = deviceUeventRegex;
+ addEpollFile(epollFd.get(), mDeviceState.filePath, mDeviceState.fd);
+
+ mHost1State.filePath = host1StatePath;
+ mHost1State.ueventRegex = host1UeventRegex;
+ addEpollFile(epollFd.get(), mHost1State.filePath, mHost1State.fd);
+
+ mHost2State.filePath = host2StatePath;
+ mHost2State.ueventRegex = host2UeventRegex;
+ addEpollFile(epollFd.get(), mHost2State.filePath, mHost2State.fd);
+
+ mEpollFd = std::move(epollFd);
+ mUeventFd = std::move(ueventFd);
+ mUpdatePortStatusCb = updatePortStatusCb;
+
+ if (ReadFileToString(kUdcConfigfsPath, &udc) && !udc.empty())
+ mUdcBind = true;
+ else
+ mUdcBind = false;
+
+ if (pthread_create(&mMonitor, NULL, this->monitorThread, this)) {
+ ALOGE("pthread creation failed %d", errno);
+ abort();
+ }
+}
+
+UsbDataSessionMonitor::~UsbDataSessionMonitor() {}
+
+void UsbDataSessionMonitor::reportUsbDataSessionMetrics() {
+ std::vector<VendorUsbDataSessionEvent> events;
+
+ if (mDataRole == PortDataRole::DEVICE) {
+ VendorUsbDataSessionEvent event;
+ BuildVendorUsbDataSessionEvent(false /* is_host */, boot_clock::now(), mDataSessionStart,
+ &mDeviceState.states, &mDeviceState.timestamps, &event);
+ events.push_back(event);
+ } else if (mDataRole == PortDataRole::HOST) {
+ bool empty = true;
+ for (auto e : {&mHost1State, &mHost2State}) {
+ /*
+ * Host port will at least get an not_attached event after enablement,
+ * skip upload if no additional state is added.
+ */
+ if (e->states.size() > 1) {
+ VendorUsbDataSessionEvent event;
+ BuildVendorUsbDataSessionEvent(true /* is_host */, boot_clock::now(),
+ mDataSessionStart, &e->states, &e->timestamps,
+ &event);
+ events.push_back(event);
+ empty = false;
+ }
+ }
+ // All host ports have no state update, upload an event to reflect it
+ if (empty) {
+ VendorUsbDataSessionEvent event;
+ BuildVendorUsbDataSessionEvent(true /* is_host */, boot_clock::now(), mDataSessionStart,
+ &mHost1State.states, &mHost1State.timestamps, &event);
+ events.push_back(event);
+ }
+ } else {
+ return;
+ }
+
+ const std::shared_ptr<IStats> stats_client = getStatsService();
+ if (!stats_client) {
+ ALOGE("Unable to get AIDL Stats service");
+ return;
+ }
+
+ for (auto &event : events) {
+ reportUsbDataSessionEvent(stats_client, event);
+ }
+}
+
+void UsbDataSessionMonitor::getComplianceWarnings(const PortDataRole &role,
+ std::vector<ComplianceWarning> *warnings) {
+ if (!usb_flags::enable_report_usb_data_compliance_warning())
+ return;
+
+ if (role != mDataRole || role == PortDataRole::NONE)
+ return;
+
+ for (auto w : mWarningSet) {
+ warnings->push_back(w);
+ }
+}
+
+void UsbDataSessionMonitor::notifyComplianceWarning() {
+ if (!usb_flags::enable_report_usb_data_compliance_warning())
+ return;
+
+ if (mUpdatePortStatusCb)
+ mUpdatePortStatusCb();
+}
+
+void UsbDataSessionMonitor::evaluateComplianceWarning() {
+ std::set<ComplianceWarning> newWarningSet;
+
+ // TODO: add heuristics and update newWarningSet
+ if (mDataRole == PortDataRole::DEVICE && mUdcBind) {
+ } else if (mDataRole == PortDataRole::HOST) {
+ }
+
+ if (newWarningSet != mWarningSet) {
+ mWarningSet = newWarningSet;
+ notifyComplianceWarning();
+ }
+}
+
+void UsbDataSessionMonitor::clearDeviceStateEvents(struct usbDeviceState *deviceState) {
+ deviceState->states.clear();
+ deviceState->timestamps.clear();
+}
+
+void UsbDataSessionMonitor::handleDeviceStateEvent(struct usbDeviceState *deviceState) {
+ int n;
+ char state[USB_STATE_MAX_LEN] = {0};
+
+ lseek(deviceState->fd.get(), 0, SEEK_SET);
+ n = read(deviceState->fd.get(), &state, USB_STATE_MAX_LEN);
+
+ if (kValidStates.find(state) == kValidStates.end()) {
+ ALOGE("Invalid state %s", state);
+ return;
+ }
+
+ ALOGI("Update USB device state: %s", state);
+
+ deviceState->states.push_back(state);
+ deviceState->timestamps.push_back(boot_clock::now());
+ evaluateComplianceWarning();
+}
+
+void UsbDataSessionMonitor::handleDataRoleEvent() {
+ int n;
+ PortDataRole newDataRole;
+ char role[DATA_ROLE_MAX_LEN] = {0};
+
+ lseek(mDataRoleFd.get(), 0, SEEK_SET);
+ n = read(mDataRoleFd.get(), &role, DATA_ROLE_MAX_LEN);
+
+ ALOGI("Update USB data role %s", role);
+
+ if (!std::strcmp(role, "host")) {
+ newDataRole = PortDataRole::HOST;
+ } else if (!std::strcmp(role, "device")) {
+ newDataRole = PortDataRole::DEVICE;
+ } else {
+ newDataRole = PortDataRole::NONE;
+ }
+
+ if (newDataRole != mDataRole) {
+ // Upload metrics for the last data session that has ended
+ if (mDataRole == PortDataRole::HOST || (mDataRole == PortDataRole::DEVICE && mUdcBind)) {
+ reportUsbDataSessionMetrics();
+ }
+
+ // Set up for the new data session
+ mWarningSet.clear();
+ mDataRole = newDataRole;
+ mDataSessionStart = boot_clock::now();
+
+ if (newDataRole == PortDataRole::DEVICE) {
+ clearDeviceStateEvents(&mDeviceState);
+ } else if (newDataRole == PortDataRole::HOST) {
+ clearDeviceStateEvents(&mHost1State);
+ clearDeviceStateEvents(&mHost2State);
+ }
+ }
+}
+
+void UsbDataSessionMonitor::updateUdcBindStatus(const std::string &devname) {
+ std::string function;
+ bool newUdcBind;
+
+ /*
+ * /sys/class/udc/<udc>/function prints out name of currently running USB gadget driver
+ * Ref: https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-udc
+ * Empty name string means the udc device is not bound and gadget is pulldown.
+ */
+ if (!ReadFileToString("/sys" + devname + "/function", &function))
+ return;
+
+ if (function == "")
+ newUdcBind = false;
+ else
+ newUdcBind = true;
+
+ if (newUdcBind == mUdcBind)
+ return;
+
+ if (mDataRole == PortDataRole::DEVICE) {
+ if (mUdcBind && !newUdcBind) {
+ /*
+ * Gadget soft pulldown: report metrics as the end of a data session and
+ * re-evaluate compliance warnings to clear existing warnings if any.
+ */
+ reportUsbDataSessionMetrics();
+ evaluateComplianceWarning();
+
+ } else if (!mUdcBind && newUdcBind) {
+ // Gadget soft pullup: reset and start accounting for a new data session.
+ clearDeviceStateEvents(&mDeviceState);
+ mDataSessionStart = boot_clock::now();
+ }
+ }
+
+ ALOGI("Udc bind status changes from %b to %b", mUdcBind, newUdcBind);
+ mUdcBind = newUdcBind;
+}
+
+void UsbDataSessionMonitor::handleUevent() {
+ char msg[UEVENT_MSG_LEN + 2];
+ char *cp;
+ int n;
+
+ n = uevent_kernel_multicast_recv(mUeventFd.get(), msg, UEVENT_MSG_LEN);
+ if (n <= 0)
+ return;
+ if (n >= UEVENT_MSG_LEN)
+ return;
+
+ msg[n] = '\0';
+ msg[n + 1] = '\0';
+ cp = msg;
+
+ while (*cp) {
+ for (auto e : {&mHost1State, &mHost2State}) {
+ if (std::regex_search(cp, std::regex(e->ueventRegex))) {
+ if (!strncmp(cp, "bind@", strlen("bind@"))) {
+ addEpollFile(mEpollFd.get(), e->filePath, e->fd);
+ } else if (!strncmp(cp, "unbind@", strlen("unbind@"))) {
+ removeEpollFile(mEpollFd.get(), e->filePath, e->fd);
+ }
+ }
+ }
+
+ // TODO: support bind@ unbind@ to detect dynamically allocated udc device
+ if (std::regex_search(cp, std::regex(mDeviceState.ueventRegex))) {
+ if (!strncmp(cp, "change@", strlen("change@"))) {
+ char *devname = cp + strlen("change@");
+ /*
+ * Udc device emits a KOBJ_CHANGE event on configfs driver bind and unbind.
+ * TODO: upstream udc driver emits KOBJ_CHANGE event BEFORE unbind is actually
+ * executed. Add a short delay to get the correct state while working on a fix
+ * upstream.
+ */
+ usleep(50000);
+ updateUdcBindStatus(devname);
+ }
+ }
+ /* advance to after the next \0 */
+ while (*cp++) {
+ }
+ }
+}
+
+void *UsbDataSessionMonitor::monitorThread(void *param) {
+ UsbDataSessionMonitor *monitor = (UsbDataSessionMonitor *)param;
+ struct epoll_event events[64];
+ int nevents = 0;
+
+ while (true) {
+ nevents = epoll_wait(monitor->mEpollFd.get(), events, 64, -1);
+ if (nevents == -1) {
+ if (errno == EINTR)
+ continue;
+ ALOGE("usb epoll_wait failed; errno=%d", errno);
+ break;
+ }
+
+ for (int n = 0; n < nevents; ++n) {
+ if (events[n].data.fd == monitor->mUeventFd.get()) {
+ monitor->handleUevent();
+ } else if (events[n].data.fd == monitor->mDataRoleFd.get()) {
+ monitor->handleDataRoleEvent();
+ } else if (events[n].data.fd == monitor->mDeviceState.fd.get()) {
+ monitor->handleDeviceStateEvent(&monitor->mDeviceState);
+ } else if (events[n].data.fd == monitor->mHost1State.fd.get()) {
+ monitor->handleDeviceStateEvent(&monitor->mHost1State);
+ } else if (events[n].data.fd == monitor->mHost2State.fd.get()) {
+ monitor->handleDeviceStateEvent(&monitor->mHost2State);
+ }
+ }
+ }
+ return NULL;
+}
+
+} // namespace usb
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/usb/usb/UsbDataSessionMonitor.h b/usb/usb/UsbDataSessionMonitor.h
new file mode 100644
index 00000000..596f378f
--- /dev/null
+++ b/usb/usb/UsbDataSessionMonitor.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/usb/ComplianceWarning.h>
+#include <aidl/android/hardware/usb/PortDataRole.h>
+#include <android-base/chrono_utils.h>
+#include <android-base/unique_fd.h>
+
+#include <set>
+#include <string>
+#include <vector>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace usb {
+
+using ::aidl::android::hardware::usb::ComplianceWarning;
+using ::aidl::android::hardware::usb::PortDataRole;
+using ::android::base::boot_clock;
+using ::android::base::unique_fd;
+
+/*
+ * UsbDataSessionMonitor monitors the usb device state sysfs of 3 different usb devices
+ * including device mode (udc), host mode high-speed port and host mode super-speed port. It
+ * reports Suez metrics for each data session and also provides API to query the compliance
+ * warnings detected in the current usb data session.
+ */
+class UsbDataSessionMonitor {
+ public:
+ /*
+ * The host mode high-speed port and super-speed port can be assigned to either host1 or
+ * host2 without affecting functionality.
+ *
+ * UeventRegex: name regex of the device that's being monitored. The regex is matched against
+ * uevent to detect dynamic creation/deletion/change of the device.
+ * StatePath: usb device state sysfs path of the device, monitored by epoll.
+ * dataRolePath: path to the usb data role sysfs, monitored by epoll.
+ * updatePortStatusCb: the callback is invoked when the compliance warings changes.
+ */
+ UsbDataSessionMonitor(const std::string &deviceUeventRegex, const std::string &deviceStatePath,
+ const std::string &host1UeventRegex, const std::string &host1StatePath,
+ const std::string &host2UeventRegex, const std::string &host2StatePath,
+ const std::string &dataRolePath,
+ std::function<void()> updatePortStatusCb);
+ ~UsbDataSessionMonitor();
+ // Returns the compliance warnings detected in the current data session.
+ void getComplianceWarnings(const PortDataRole &role, std::vector<ComplianceWarning> *warnings);
+
+ private:
+ struct usbDeviceState {
+ unique_fd fd;
+ std::string filePath;
+ std::string ueventRegex;
+ // Usb device states reported by state sysfs
+ std::vector<std::string> states;
+ // Timestamps of when the usb device states were captured
+ std::vector<boot_clock::time_point> timestamps;
+ };
+
+ static void *monitorThread(void *param);
+ void handleUevent();
+ void handleDataRoleEvent();
+ void handleDeviceStateEvent(struct usbDeviceState *deviceState);
+ void clearDeviceStateEvents(struct usbDeviceState *deviceState);
+ void reportUsbDataSessionMetrics();
+ void evaluateComplianceWarning();
+ void notifyComplianceWarning();
+ void updateUdcBindStatus(const std::string &devname);
+
+ pthread_t mMonitor;
+ unique_fd mEpollFd;
+ unique_fd mUeventFd;
+ unique_fd mDataRoleFd;
+ struct usbDeviceState mDeviceState;
+ struct usbDeviceState mHost1State;
+ struct usbDeviceState mHost2State;
+ std::set<ComplianceWarning> mWarningSet;
+ // Callback function to notify the caller when there's a change in compliance warnings.
+ std::function<void()> mUpdatePortStatusCb;
+ /*
+ * Cache relevant info for a USB data session when one starts, including
+ * the data role and the time when the session starts.
+ */
+ PortDataRole mDataRole;
+ boot_clock::time_point mDataSessionStart;
+ /*
+ * In gadget mode: this indicates whether the udc device is bound to the configfs driver, which
+ * is done by userspace writing the udc device name to /config/usb_gadget/g1/UDC. When unbound,
+ * the gadget is in soft pulldown state and is expected not to enumerate. During gadget
+ * function switch, the udc device usually go through unbind and bind.
+ */
+ bool mUdcBind;
+};
+
+} // namespace usb
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/usb/usb/android.hardware.usb-service.rc b/usb/usb/android.hardware.usb-service.rc
index d236bd54..cb28caf2 100644
--- a/usb/usb/android.hardware.usb-service.rc
+++ b/usb/usb/android.hardware.usb-service.rc
@@ -3,159 +3,3 @@ service vendor.usb /vendor/bin/hw/android.hardware.usb-service.gs101
user system
group system shell wakelock
capabilities WAKE_ALARM BLOCK_SUSPEND
-
-on post-fs
- chown root system /sys/class/typec/port0/power_role
- chown root system /sys/class/typec/port0/data_role
- chown root system /sys/class/typec/port0/port_type
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/contaminant_detection
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_current
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_source_enable
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/update_sdp_enum_timeout
- chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess
- chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id
- chown root system /sys/devices/platform/11110000.usb/usb_data_enabled
- chown root system /sys/devices/platform/google,pogo/move_data_to_usb
- chmod 664 /sys/class/typec/port0/power_role
- chmod 664 /sys/class/typec/port0/data_role
- chmod 664 /sys/class/typec/port0/port_type
- chmod 664 /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess
- chmod 664 /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id
- chmod 664 /sys/devices/platform/11110000.usb/usb_data_enabled
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/contaminant_detection
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_accessory_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_current
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_sink_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/usb_limit_source_enable
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-0/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-1/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-2/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-3/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-4/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-7/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-8/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/10d50000.hsi2c/i2c-9/i2c-max77759tcpc/update_sdp_enum_timeout
- chmod 664 /sys/devices/platform/google,pogo/move_data_to_usb
diff --git a/usb/usb/android.hardware.usb-service.xml b/usb/usb/android.hardware.usb-service.xml
index c3f07f52..7ac20679 100644
--- a/usb/usb/android.hardware.usb-service.xml
+++ b/usb/usb/android.hardware.usb-service.xml
@@ -1,7 +1,7 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.usb</name>
- <version>2</version>
+ <version>3</version>
<interface>
<name>IUsb</name>
<instance>default</instance>