[automerger skipped] Merge 10952656 am: 6249b6ee2f -s ours am: 82f78d8789 -s ours

am skip reason: Merged-In Id486c53997b232c2b02d18d1c7a6d773f1319110 with SHA-1 9c567b3d76 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/device/google/gs101/+/25092553

Change-Id: I1f043924d2bf3af64d36ad88fb8fe6db8abe728a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk
index 70e9d64..d94a619 100644
--- a/BoardConfig-common.mk
+++ b/BoardConfig-common.mk
@@ -200,7 +200,7 @@
 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 68657e8..feed301 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,4 +2,4 @@
 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/conf/init.gs101.rc b/conf/init.gs101.rc
index 9b0e133..7c4c2f2 100644
--- a/conf/init.gs101.rc
+++ b/conf/init.gs101.rc
@@ -23,30 +23,30 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 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 @@
     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 @@
     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 @@
     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
@@ -983,8 +959,8 @@
     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 @@
     # 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/ueventd.gs101.rc b/conf/ueventd.gs101.rc
index 5e0b58e..3a8e39d 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.mk b/device.mk
index 6db1d36..3dc715a 100644
--- a/device.mk
+++ b/device.mk
@@ -21,7 +21,8 @@
 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
@@ -200,6 +201,7 @@
 
 $(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 +255,9 @@
 	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)
 # ####################
 
@@ -846,10 +851,6 @@
 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,10 +893,8 @@
 
 $(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
@@ -969,9 +968,6 @@
 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 +1034,6 @@
 	libgc2_utils
 
 # Thermal HAL
-include hardware/google/pixel/thermal/device.mk
 PRODUCT_PROPERTY_OVERRIDES += persist.vendor.enable.thermal.genl=true
 
 # EdgeTPU
@@ -1132,9 +1127,5 @@
 # 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 732338c..5f8e283 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,6 +69,14 @@
         </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>
         <interface>
@@ -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 e6fdb01..43eaeaa 100644
--- a/dumpstate/dump_gs101.sh
+++ b/dumpstate/dump_gs101.sh
@@ -35,7 +35,11 @@
 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 @@
 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 @@
 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 5808856..0000000
--- 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 de831e4..0000000
--- 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 c8203b1..0000000
--- 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 e42448f..0000000
--- 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/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 32adb01..b016d52 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -280,4 +280,17 @@
 
     <!-- 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.google.android.youtube: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>
+  </resources>
diff --git a/preinstalled-packages-product-gs101-device-debug.xml b/preinstalled-packages-product-gs101-device-debug.xml
index 64524bc..88204bc 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 961857d..fda6c3e 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/usb/gadget/UsbGadget.cpp b/usb/gadget/UsbGadget.cpp
index 9b68e2c..64fd17b 100644
--- a/usb/gadget/UsbGadget.cpp
+++ b/usb/gadget/UsbGadget.cpp
@@ -38,38 +38,18 @@
 
 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 @@
 }
 
 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 @@
     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 @@
     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 @@
         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 a6b63bd..e483a91 100644
--- a/usb/gadget/UsbGadget.h
+++ b/usb/gadget/UsbGadget.h
@@ -119,7 +119,12 @@
     // 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 ba7d5f6..456bffc 100644
--- a/usb/gadget/android.hardware.usb.gadget-service.rc
+++ b/usb/gadget/android.hardware.usb.gadget-service.rc
@@ -2,21 +2,3 @@
     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 1530db5..1f81899 100644
--- a/usb/usb/Android.bp
+++ b/usb/usb/Android.bp
@@ -46,10 +46,10 @@
         "android.hardware.usb.gadget@1.0",
         "android.hardware.usb-V2-ndk",
         "libcutils",
-        "android.frameworks.stats-V1-ndk",
+        "android.frameworks.stats-V2-ndk",
         "pixelatoms-cpp",
         "libbinder_ndk",
-
+        "libprotobuf-cpp-lite",
     ],
     static_libs: [
         "libpixelusb",
@@ -57,7 +57,7 @@
         "libthermalutils",
     ],
     export_shared_lib_headers: [
-        "android.frameworks.stats-V1-ndk",
+        "android.frameworks.stats-V2-ndk",
         "pixelatoms-cpp",
     ],
 }
diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp
index 7a14888..8588935 100644
--- a/usb/usb/Usb.cpp
+++ b/usb/usb/Usb.cpp
@@ -39,6 +39,7 @@
 #include "Usb.h"
 
 #include <aidl/android/frameworks/stats/IStats.h>
+#include <pixelusb/CommonUtils.h>
 #include <pixelusb/UsbGadgetCommon.h>
 #include <pixelstats/StatsHelper.h>
 
@@ -49,6 +50,9 @@
 using android::hardware::google::pixel::getStatsService;
 using android::hardware::google::pixel::PixelAtoms::VendorUsbPortOverheat;
 using android::hardware::google::pixel::reportUsbPortOverheat;
+using android::hardware::google::pixel::PixelAtoms::VendorUsbDataSessionEvent;
+using android::hardware::google::pixel::reportUsbDataSessionEvent;
+using android::hardware::google::pixel::usb::BuildVendorUsbDataSessionEvent;
 
 namespace aidl {
 namespace android {
@@ -59,17 +63,18 @@
 
 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 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,9 +86,16 @@
 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 kUdcState[] = "/sys/devices/platform/11110000.usb/11110000.dwc3/udc/11110000.dwc3/state";
+// xhci-hcd-exynos and usb device numbering could vary on different platforms
+constexpr char kHostUeventRegex[] = "^(bind|unbind)@(/devices/platform/11110000\\.usb/11110000\\.dwc3/xhci-hcd-exynos\\.[0-9]\\.auto/)usb([0-9])/[0-9]-0:1\\.0";
 constexpr int kSamplingIntervalSec = 5;
 void queryVersionHelper(android::hardware::usb::Usb *usb,
                         std::vector<PortStatus> *currentPortStatus);
+void queryUsbDataSession(android::hardware::usb::Usb *usb,
+                         std::vector<PortStatus> *currentPortStatus);
+
+#define USB_STATE_MAX_LEN 20
 
 ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable,
         int64_t in_transactionId) {
@@ -215,8 +227,15 @@
     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 +243,65 @@
 
         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;
 }
 
-Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus) {
-    string enabled, status, path, DetectedPath;
+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(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 +310,12 @@
     (*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 +323,7 @@
 
     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;
@@ -455,7 +521,9 @@
                           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 +602,38 @@
         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 +652,17 @@
     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;
@@ -818,9 +898,10 @@
     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);
@@ -907,17 +988,194 @@
     }
 }
 
-struct data {
-    int uevent_fd;
-    ::aidl::android::hardware::usb::Usb *usb;
-};
+void report_usb_data_session_event(android::hardware::usb::Usb *usb) {
+    std::vector<VendorUsbDataSessionEvent> events;
 
-static void uevent_event(uint32_t /*epevents*/, struct data *payload) {
+    if (usb->mDataRole == PortDataRole::DEVICE) {
+        VendorUsbDataSessionEvent event;
+        BuildVendorUsbDataSessionEvent(false /* is_host */, std::chrono::steady_clock::now(),
+                                       usb->mDataSessionStart, &usb->mDeviceState.states,
+                                       &usb->mDeviceState.timestamps, &event);
+        events.push_back(event);
+    } else if (usb->mDataRole == PortDataRole::HOST) {
+        bool empty = true;
+        for (auto &entry : usb->mHostStateMap) {
+            // Host port will at least get an not_attached event after enablement,
+            // skip upload if no additional state is added.
+            if (entry.second.states.size() > 1) {
+                VendorUsbDataSessionEvent event;
+                BuildVendorUsbDataSessionEvent(true /* is_host */, std::chrono::steady_clock::now(),
+                                               usb->mDataSessionStart, &entry.second.states,
+                                               &entry.second.timestamps, &event);
+                events.push_back(event);
+                empty = false;
+            }
+        }
+        // All host ports have no state update, upload an event to reflect it
+        if (empty && usb->mHostStateMap.size() > 0) {
+            VendorUsbDataSessionEvent event;
+            BuildVendorUsbDataSessionEvent(true /* is_host */, std::chrono::steady_clock::now(),
+                                           usb->mDataSessionStart,
+                                           &usb->mHostStateMap.begin()->second.states,
+                                           &usb->mHostStateMap.begin()->second.timestamps,
+                                           &event);
+            events.push_back(event);
+        }
+    } else {
+        return;
+    }
+
+    const 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);
+    }
+}
+
+static void unregisterEpollEntry(Usb *usb, std::string name) {
+    std::map<std::string, struct Usb::epollEntry> *map;
+    int fd;
+
+    map = &usb->mEpollEntries;
+    auto it = map->find(name);
+    if (it != map->end()) {
+        ALOGI("epoll unregister %s", name.c_str());
+        fd = it->second.payload.fd;
+        epoll_ctl(usb->mEpollFd, EPOLL_CTL_DEL, fd, NULL);
+        close(fd);
+        map->erase(it);
+    }
+}
+
+static void unregisterEpollEntries(Usb *usb) {
+    std::map<std::string, struct Usb::epollEntry> *map;
+    std::string name;
+
+    map = &usb->mEpollEntries;
+    for (auto it = map->begin(); it != map->end();) {
+        name = it->first;
+        it++;
+        unregisterEpollEntry(usb, name);
+    }
+}
+
+static int registerEpollEntry(Usb *usb, std::string name, int fd, int flags,
+                              void (*func)(uint32_t, struct Usb::payload*)) {
+    std::map<std::string, struct Usb::epollEntry> *map;
+    struct Usb::epollEntry *entry;
+    struct epoll_event ev;
+
+    map = &usb->mEpollEntries;
+    if (map->find(name) != map->end()) {
+        ALOGE("%s already registered", name.c_str());
+        unregisterEpollEntry(usb, name);
+    }
+
+    entry = &(*map)[name];
+    entry->payload.fd = fd;
+    entry->payload.name = name;
+    entry->payload.usb = usb;
+    entry->cb = std::bind(func, std::placeholders::_1, &entry->payload);
+
+    ev.events = flags;
+    ev.data.ptr = (void *)&entry->cb;
+
+    if (epoll_ctl(usb->mEpollFd, EPOLL_CTL_ADD, fd, &ev) != 0) {
+        ALOGE("epoll_ctl failed; errno=%d", errno);
+        unregisterEpollEntry(usb, name);
+        return -1;
+    }
+
+    ALOGI("epoll register %s", name.c_str());
+
+    return 0;
+}
+
+static int registerEpollEntryByFile(Usb *usb, std::string name, int flags,
+                              void (*func)(uint32_t, struct Usb::payload*)) {
+    int fd;
+
+    fd = open(name.c_str(), O_RDONLY);
+    if (fd < 0) {
+        ALOGE("Cannot open %s", name.c_str());
+        return -1;
+    }
+
+    return registerEpollEntry(usb, name, fd, flags, func);
+}
+
+static void clearUsbDeviceState(struct Usb::usbDeviceState *device) {
+    device->states.clear();
+    device->timestamps.clear();
+    device->portResetCount = 0;
+}
+
+static void updateUsbDeviceState(struct Usb::usbDeviceState *device, char *state) {
+    ALOGI("Update USB device state: %s", state);
+
+    device->states.push_back(state);
+    device->timestamps.push_back(std::chrono::steady_clock::now());
+
+    if (!std::strcmp(state, "configured\n")) {
+        device->portResetCount = 0;
+    } else if (!std::strcmp(state, "default\n")) {
+        device->portResetCount++;
+    }
+}
+
+static void host_event(uint32_t /*epevents*/, struct Usb::payload *payload) {
+    int n;
+    char state[USB_STATE_MAX_LEN] = {0};
+    struct Usb::usbDeviceState *device;
+
+    lseek(payload->fd, 0, SEEK_SET);
+    n = read(payload->fd, &state, USB_STATE_MAX_LEN);
+
+    updateUsbDeviceState(&payload->usb->mHostStateMap[payload->name], state);
+}
+
+void queryUsbDataSession(android::hardware::usb::Usb *usb,
+                          std::vector<PortStatus> *currentPortStatus) {
+    PortDataRole newDataRole = (*currentPortStatus)[0].currentDataRole;
+    PowerBrickStatus newPowerBrickStatus = (*currentPortStatus)[0].powerBrickStatus;
+
+    if (newDataRole != usb->mDataRole) {
+        // Upload metrics for the last non-powerbrick data session that has ended
+        if (usb->mDataRole != PortDataRole::NONE && !usb->mIsPowerBrickConnected) {
+            report_usb_data_session_event(usb);
+       }
+
+        // Set up for the new data session
+        usb->mDataRole = newDataRole;
+        usb->mDataSessionStart = std::chrono::steady_clock::now();
+        usb->mIsPowerBrickConnected = (newPowerBrickStatus == PowerBrickStatus::CONNECTED);
+        if (newDataRole == PortDataRole::DEVICE) {
+            clearUsbDeviceState(&usb->mDeviceState);
+        } else if (newDataRole == PortDataRole::HOST) {
+            for (auto &entry : usb->mHostStateMap) {
+                clearUsbDeviceState(&entry.second);
+            }
+        }
+    }
+
+    // PowerBrickStatus could flip from DISCONNECTED to CONNECTED during the same data
+    // session when BC1.2 SDP times out and falls back to DCP
+    if (newPowerBrickStatus == PowerBrickStatus::CONNECTED) {
+        usb->mIsPowerBrickConnected = true;
+    }
+}
+
+static void uevent_event(uint32_t /*epevents*/, struct Usb::payload *payload) {
     char msg[UEVENT_MSG_LEN + 2];
     char *cp;
     int n;
+    std::cmatch match;
 
-    n = uevent_kernel_multicast_recv(payload->uevent_fd, msg, UEVENT_MSG_LEN);
+    n = uevent_kernel_multicast_recv(payload->fd, msg, UEVENT_MSG_LEN);
     if (n <= 0)
         return;
     if (n >= UEVENT_MSG_LEN) /* overflow -- discard */
@@ -963,6 +1221,28 @@
         } else if (!strncmp(cp, kOverheatStatsDev, strlen(kOverheatStatsDev))) {
             ALOGV("Overheat Cooling device suez update");
             report_overheat_event(payload->usb);
+        } else if (std::regex_match(cp, match, std::regex(kHostUeventRegex))) {
+            /*
+             * Matched strings:
+             * 1st: entire string
+             * 2nd: uevent action, either "bind" or "unbind"
+             * 3rd: xhci device path, e.g. devices/platform/11210000.usb/11210000.dwc3/xhci-hcd-exynos.4.auto
+             * 4th: usb device number, e.g. 1 for usb1
+             *
+             * The strings are used to composed usb device state path, e.g.
+             * /sys/devices/platform/11210000.usb/11210000.dwc3/xhci-hcd-exynos.4.auto/usb2/2-0:1.0/usb2-port1/state
+             */
+            if (match.size() == 4) {
+                std::string action = match[1].str();
+                std::string id = match[3].str();
+                std::string path = "/sys" + match[2].str() + "usb" + id + "/" +
+                                   id + "-0:1.0/usb" + id + "-port1/state";
+                if (action == "bind") {
+                    registerEpollEntryByFile(payload->usb, path, EPOLLPRI, host_event);
+                } else if (action == "unbind") {
+                    unregisterEpollEntry(payload->usb, path);
+                }
+            }
         }
         /* advance to after the next \0 */
         while (*cp++) {
@@ -970,37 +1250,46 @@
     }
 }
 
+static void udc_event(uint32_t /*epevents*/, struct Usb::payload *payload) {
+    int n;
+    char state[USB_STATE_MAX_LEN] = {0};
+
+    lseek(payload->fd, 0, SEEK_SET);
+    n = read(payload->fd, &state, USB_STATE_MAX_LEN);
+
+    updateUsbDeviceState(&payload->usb->mDeviceState, state);
+}
+
 void *work(void *param) {
     int epoll_fd, uevent_fd;
-    struct epoll_event ev;
     int nevents = 0;
-    struct data payload;
+    Usb *usb = (Usb *)param;
 
     ALOGE("creating thread");
 
-    uevent_fd = uevent_open_socket(64 * 1024, true);
-
-    if (uevent_fd < 0) {
-        ALOGE("uevent_init: uevent_open_socket failed\n");
-        return NULL;
-    }
-
-    payload.uevent_fd = uevent_fd;
-    payload.usb = (::aidl::android::hardware::usb::Usb *)param;
-
-    fcntl(uevent_fd, F_SETFL, O_NONBLOCK);
-
-    ev.events = EPOLLIN;
-    ev.data.ptr = (void *)uevent_event;
-
     epoll_fd = epoll_create(64);
     if (epoll_fd == -1) {
         ALOGE("epoll_create failed; errno=%d", errno);
+        return NULL;
+    }
+    usb->mEpollFd = epoll_fd;
+
+    // Monitor uevent
+    uevent_fd = uevent_open_socket(64 * 1024, true);
+    if (uevent_fd < 0) {
+        ALOGE("uevent_init: uevent_open_socket failed");
+        goto error;
+    }
+    fcntl(uevent_fd, F_SETFL, O_NONBLOCK);
+
+    if (registerEpollEntry(usb, "uevent", uevent_fd, EPOLLIN, uevent_event)) {
+        ALOGE("failed to monitor uevent");
         goto error;
     }
 
-    if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, uevent_fd, &ev) == -1) {
-        ALOGE("epoll_ctl failed; errno=%d", errno);
+    // Monitor udc state
+    if (registerEpollEntryByFile(usb, kUdcState, EPOLLPRI, udc_event)) {
+        ALOGE("failed to monitor udc state");
         goto error;
     }
 
@@ -1017,14 +1306,15 @@
 
         for (int n = 0; n < nevents; ++n) {
             if (events[n].data.ptr)
-                (*(void (*)(int, struct data *payload))events[n].data.ptr)(events[n].events,
-                                                                           &payload);
+                (*(std::function<void(uint32_t)>*)events[n].data.ptr)(events[n].events);
         }
     }
 
     ALOGI("exiting worker thread");
 error:
-    close(uevent_fd);
+    unregisterEpollEntries(usb);
+
+    usb->mEpollFd = -1;
 
     if (epoll_fd >= 0)
         close(epoll_fd);
diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h
index 1a93e19..1e06082 100644
--- a/usb/usb/Usb.h
+++ b/usb/usb/Usb.h
@@ -19,6 +19,7 @@
 #include <android-base/file.h>
 #include <aidl/android/hardware/usb/BnUsb.h>
 #include <aidl/android/hardware/usb/BnUsbCallback.h>
+#include <chrono>
 #include <pixelusb/UsbOverheatEvent.h>
 #include <utils/Log.h>
 
@@ -89,8 +90,43 @@
     float mPluggedTemperatureCelsius;
     // Usb Data status
     bool mUsbDataEnabled;
+
+    // USB device state monitoring
+    struct usbDeviceState {
+        // Usb device state raw strings read from sysfs
+        std::vector<std::string> states;
+        // Timestamps of when the usb device states were captured
+        std::vector<std::chrono::steady_clock::time_point> timestamps;
+        int portResetCount;
+    };
+    struct usbDeviceState mDeviceState;
+    // Map host device path name to usbDeviceState
+    std::map<std::string, struct usbDeviceState> mHostStateMap;
+    // Cache relevant info for USB data session metrics collection when a session starts, including
+    // the data role, power brick status and the time when the session starts.
+    PortDataRole mDataRole;
+    bool mIsPowerBrickConnected;
+    std::chrono::steady_clock::time_point mDataSessionStart;
+
+    // File monitoring through epoll
+    int mEpollFd;
+    struct payload {
+        int fd;
+        std::string name;
+        Usb *usb;
+     };
+    struct epollEntry {
+         struct payload payload;
+         std::function<void(uint32_t)> cb;
+    };
+    std::map<std::string, struct epollEntry> mEpollEntries;
+    int getI2cBusNumber();
+    std::string_view getI2cClientPath();
+
   private:
     pthread_t mPoll;
+    int mI2cBusNumber;
+    std::string mI2cClientPath;
 };
 
 } // namespace usb
diff --git a/usb/usb/android.hardware.usb-service.rc b/usb/usb/android.hardware.usb-service.rc
index d236bd5..cb28caf 100644
--- a/usb/usb/android.hardware.usb-service.rc
+++ b/usb/usb/android.hardware.usb-service.rc
@@ -3,159 +3,3 @@
     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