Snap for 13025264 from e4283b4128
to mainline-tzdata6-release
Change-Id: Ic39548a7d6ceec26fc8ddad7f4942870c8a46a43
This commit is contained in:
commit
d425f90c01
17 changed files with 73 additions and 847 deletions
10
Android.bp
10
Android.bp
|
@ -41,13 +41,3 @@ sh_binary {
|
||||||
vendor: true,
|
vendor: true,
|
||||||
sub_dir: "hw",
|
sub_dir: "hw",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filesystem: Copy the content of the efs/efs_backup/modem_userdata/persist
|
|
||||||
// partitions to /data partition so that they can be accessed by 16kb kernels.
|
|
||||||
// By default, these partitions are F2FS formatted with 4kb block size,
|
|
||||||
// which can't be mounted by 16kb kernels.
|
|
||||||
sh_binary {
|
|
||||||
name: "copy_efs_files_to_data",
|
|
||||||
src: "copy_efs_files_to_data.sh",
|
|
||||||
vendor: true,
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,4 +16,35 @@
|
||||||
|
|
||||||
ifeq ($(TARGET_BOOTS_16K),true)
|
ifeq ($(TARGET_BOOTS_16K),true)
|
||||||
BOARD_F2FS_BLOCKSIZE := 16384
|
BOARD_F2FS_BLOCKSIZE := 16384
|
||||||
|
# Configures the 16kb kernel directory.
|
||||||
|
TARGET_KERNEL_DIR := $(TARGET_KERNEL_DIR)/16kb
|
||||||
|
|
||||||
|
else ifeq ($(PRODUCT_16K_DEVELOPER_OPTION),true)
|
||||||
|
# Configures the 16kb kernel and modules for OTA updates.
|
||||||
|
TARGET_KERNEL_DIR_16K := $(TARGET_KERNEL_DIR)/16kb
|
||||||
|
BOARD_KERNEL_PATH_16K := $(TARGET_KERNEL_DIR_16K)/Image.lz4
|
||||||
|
|
||||||
|
BOARD_KERNEL_MODULES_16K += $(file < $(TARGET_KERNEL_DIR_16K)/vendor_kernel_boot.modules.load)
|
||||||
|
BOARD_KERNEL_MODULES_16K += $(file < $(TARGET_KERNEL_DIR_16K)/system_dlkm.modules.load)
|
||||||
|
BOARD_KERNEL_MODULES_16K += $(file < $(TARGET_KERNEL_DIR_16K)/vendor_dlkm.modules.load)
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(foreach module,$(BOARD_KERNEL_MODULES_16K),$(TARGET_KERNEL_DIR_16K)/$(notdir $(module)))
|
||||||
|
BOARD_PREBUILT_DTBOIMAGE_16KB := $(TARGET_KERNEL_DIR_16K)/dtbo.img
|
||||||
|
|
||||||
|
# The 16kb mode does not use these modules.
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/bcm_dbg.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/zram.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/aoc_unit_test_dev.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/gs-panel-common-test.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/mali_kutf.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/mali_kutf_clk_rate_trace_test_portal.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/panel-gs-tk4c-test.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/pwm-exynos.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/rt4539_bl.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/sec_touch.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/sscoredump_sample_test.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_16K := $(filter-out %/sscoredump_test.ko,$(BOARD_KERNEL_MODULES_16K))
|
||||||
|
BOARD_KERNEL_MODULES_LOAD_16K := $(foreach module,$(BOARD_KERNEL_MODULES_16K),$(notdir $(module)))
|
||||||
|
|
||||||
|
BOARD_16K_OTA_USE_INCREMENTAL := true
|
||||||
|
BOARD_16K_OTA_MOVE_VENDOR := true
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -17,7 +17,9 @@ include build/make/target/board/BoardConfigMainlineCommon.mk
|
||||||
include build/make/target/board/BoardConfigPixelCommon.mk
|
include build/make/target/board/BoardConfigPixelCommon.mk
|
||||||
|
|
||||||
# Include settings for 16k page size kernel if enabled.
|
# Include settings for 16k page size kernel if enabled.
|
||||||
|
ifneq ($(wildcard $(TARGET_KERNEL_DIR)/16kb/),)
|
||||||
include device/google/zumapro/BoardConfig-16k-common.mk
|
include device/google/zumapro/BoardConfig-16k-common.mk
|
||||||
|
endif
|
||||||
|
|
||||||
# HACK : To fix up after bring up multimedia devices.
|
# HACK : To fix up after bring up multimedia devices.
|
||||||
TARGET_SOC := zumapro
|
TARGET_SOC := zumapro
|
||||||
|
@ -34,7 +36,6 @@ TARGET_CPU_VARIANT := cortex-a55
|
||||||
BOARD_KERNEL_CMDLINE += dyndbg=\"func alloc_contig_dump_pages +p\"
|
BOARD_KERNEL_CMDLINE += dyndbg=\"func alloc_contig_dump_pages +p\"
|
||||||
BOARD_KERNEL_CMDLINE += earlycon=exynos4210,0x10870000 console=ttySAC0,115200 androidboot.console=ttySAC0 printk.devkmsg=on
|
BOARD_KERNEL_CMDLINE += earlycon=exynos4210,0x10870000 console=ttySAC0,115200 androidboot.console=ttySAC0 printk.devkmsg=on
|
||||||
BOARD_KERNEL_CMDLINE += cma_sysfs.experimental=Y
|
BOARD_KERNEL_CMDLINE += cma_sysfs.experimental=Y
|
||||||
BOARD_KERNEL_CMDLINE += cgroup_disable=memory
|
|
||||||
BOARD_KERNEL_CMDLINE += cgroup.memory=nokmem
|
BOARD_KERNEL_CMDLINE += cgroup.memory=nokmem
|
||||||
BOARD_KERNEL_CMDLINE += rcupdate.rcu_expedited=1 rcu_nocbs=all rcutree.enable_rcu_lazy
|
BOARD_KERNEL_CMDLINE += rcupdate.rcu_expedited=1 rcu_nocbs=all rcutree.enable_rcu_lazy
|
||||||
BOARD_KERNEL_CMDLINE += swiotlb=noforce
|
BOARD_KERNEL_CMDLINE += swiotlb=noforce
|
||||||
|
|
|
@ -60,14 +60,6 @@ on init
|
||||||
write /sys/class/net/rmnet6/queues/rx-0/rps_cpus fe
|
write /sys/class/net/rmnet6/queues/rx-0/rps_cpus fe
|
||||||
write /sys/class/net/rmnet7/queues/rx-0/rps_cpus fe
|
write /sys/class/net/rmnet7/queues/rx-0/rps_cpus fe
|
||||||
|
|
||||||
# RT uclamp setting
|
|
||||||
write /proc/sys/kernel/sched_util_clamp_min_rt_default 0
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# nanohub sensor
|
# nanohub sensor
|
||||||
chmod 0664 /dev/nanohub
|
chmod 0664 /dev/nanohub
|
||||||
chmod 0664 /dev/nanohub_comms
|
chmod 0664 /dev/nanohub_comms
|
||||||
|
@ -80,10 +72,6 @@ on init
|
||||||
# Power Stats HAL
|
# Power Stats HAL
|
||||||
chown system system /dev/bbd_pwrstat
|
chown system system /dev/bbd_pwrstat
|
||||||
|
|
||||||
# Add a boost for NNAPI HAL
|
|
||||||
write /proc/vendor_sched/groups/nnapi/prefer_idle 0
|
|
||||||
write /proc/vendor_sched/groups/nnapi/uclamp_min 512
|
|
||||||
|
|
||||||
# Set boost_adpf_prio, -1 by default
|
# Set boost_adpf_prio, -1 by default
|
||||||
write /proc/vendor_sched/boost_adpf_prio ${persist.device_config.vendor_system_native_boot.boost_adpf_prio:--1}
|
write /proc/vendor_sched/boost_adpf_prio ${persist.device_config.vendor_system_native_boot.boost_adpf_prio:--1}
|
||||||
|
|
||||||
|
@ -420,27 +408,6 @@ on property:sys.boot_completed=1
|
||||||
# Cancel boot devfreq
|
# Cancel boot devfreq
|
||||||
write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1
|
write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1
|
||||||
|
|
||||||
# Setup scheduler parameters
|
|
||||||
write /proc/vendor_sched/min_granularity_ns 1000000
|
|
||||||
write /proc/vendor_sched/latency_ns 8000000
|
|
||||||
write /proc/vendor_sched/max_load_balance_interval 1
|
|
||||||
write /proc/vendor_sched/enable_hrtick 1
|
|
||||||
|
|
||||||
# Setup final cpu.uclamp
|
|
||||||
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/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
|
# Set uclamp.max for some groups, which could indicate cpu importance used in scheduling
|
||||||
write /proc/vendor_sched/auto_uclamp_max "130 130 130 130 512 512 512 670"
|
write /proc/vendor_sched/auto_uclamp_max "130 130 130 130 512 512 512 670"
|
||||||
write /proc/vendor_sched/groups/bg/uclamp_max 130
|
write /proc/vendor_sched/groups/bg/uclamp_max 130
|
||||||
|
@ -459,18 +426,6 @@ on property:sys.boot_completed=1
|
||||||
write /sys/devices/platform/10840000.pinctrl/power/async "enabled"
|
write /sys/devices/platform/10840000.pinctrl/power/async "enabled"
|
||||||
write /sys/devices/platform/13060000.pinctrl/power/async "enabled"
|
write /sys/devices/platform/13060000.pinctrl/power/async "enabled"
|
||||||
|
|
||||||
# Setup cpu.shares to throttle background groups (bg ~ 5% sysbg ~ 5% dex2oat ~2.5%)
|
|
||||||
write /dev/cpuctl/background/cpu.shares 1024
|
|
||||||
write /dev/cpuctl/system-background/cpu.shares 1024
|
|
||||||
write /dev/cpuctl/dex2oat/cpu.shares 512
|
|
||||||
write /dev/cpuctl/system/cpu.shares 20480
|
|
||||||
# We only have system and background groups holding tasks and the groups below are empty
|
|
||||||
write /dev/cpuctl/camera-daemon/cpu.shares 20480
|
|
||||||
write /dev/cpuctl/foreground/cpu.shares 20480
|
|
||||||
write /dev/cpuctl/nnapi-hal/cpu.shares 20480
|
|
||||||
write /dev/cpuctl/rt/cpu.shares 20480
|
|
||||||
write /dev/cpuctl/top-app/cpu.shares 20480
|
|
||||||
|
|
||||||
# gvotables for dumpstate
|
# gvotables for dumpstate
|
||||||
chown system system /sys/kernel/debug/gvotables
|
chown system system /sys/kernel/debug/gvotables
|
||||||
|
|
||||||
|
@ -590,6 +545,8 @@ on post-fs-data
|
||||||
|
|
||||||
on property:vendor.thermal.link_ready=1
|
on property:vendor.thermal.link_ready=1
|
||||||
# Thermal
|
# Thermal
|
||||||
|
chown system system /dev/thermal/tz-by-name/flash_therm/trip_point_0_temp
|
||||||
|
chown system system /dev/thermal/tz-by-name/flash_therm/trip_point_0_hyst
|
||||||
chown system system /dev/thermal/tz-by-name/disp_therm/trip_point_0_temp
|
chown system system /dev/thermal/tz-by-name/disp_therm/trip_point_0_temp
|
||||||
chown system system /dev/thermal/tz-by-name/disp_therm/trip_point_0_hyst
|
chown system system /dev/thermal/tz-by-name/disp_therm/trip_point_0_hyst
|
||||||
chown system system /dev/thermal/tz-by-name/north_therm/trip_point_0_temp
|
chown system system /dev/thermal/tz-by-name/north_therm/trip_point_0_temp
|
||||||
|
@ -627,6 +584,14 @@ on property:vendor.thermal.link_ready=1
|
||||||
chown system system /dev/thermal/cdev-by-name/thermal-uclamp-4/cur_state
|
chown system system /dev/thermal/cdev-by-name/thermal-uclamp-4/cur_state
|
||||||
chown system system /dev/thermal/cdev-by-name/thermal-uclamp-7/cur_state
|
chown system system /dev/thermal/cdev-by-name/thermal-uclamp-7/cur_state
|
||||||
|
|
||||||
|
on property:vendor.thermal.link_ready=1 && property:vendor.pixel.system.phenotype.Thermal__shutdown_exp_enabled=true
|
||||||
|
setprop vendor.thermal.config "thermal_info_config_lpm.json"
|
||||||
|
restart vendor.thermal-hal
|
||||||
|
|
||||||
|
on property:vendor.thermal.link_ready=1 && property:vendor.pixel.system.phenotype.Thermal__shutdown_exp_enabled=false
|
||||||
|
setprop vendor.thermal.config "thermal_info_config.json"
|
||||||
|
restart vendor.thermal-hal
|
||||||
|
|
||||||
on charger
|
on charger
|
||||||
# Use charger thermal config
|
# Use charger thermal config
|
||||||
setprop vendor.thermal.config "thermal_info_config_charge.json"
|
setprop vendor.thermal.config "thermal_info_config_charge.json"
|
||||||
|
@ -683,11 +648,4 @@ on property:vendor.all.modules.ready=1
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/default/f0_comp_enable
|
chown system system /sys/bus/i2c/devices/9-0043/default/f0_comp_enable
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/default/redc_comp_enable
|
chown system system /sys/bus/i2c/devices/9-0043/default/redc_comp_enable
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/default/delay_before_stop_playback_us
|
chown system system /sys/bus/i2c/devices/9-0043/default/delay_before_stop_playback_us
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/dbc/dbc_env_rel_coef
|
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/dbc/dbc_rise_headroom
|
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/dbc/dbc_fall_headroom
|
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/dbc/dbc_enable
|
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/dbc/dbc_tx_lvl_thresh_fs
|
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/dbc/dbc_tx_lvl_hold_off_ms
|
|
||||||
chown system system /sys/bus/i2c/devices/9-0043/default/pm_active_timeout_ms
|
|
||||||
enable vendor.vibrator.cs40l26
|
enable vendor.vibrator.cs40l26
|
||||||
|
|
|
@ -30,35 +30,6 @@ on init
|
||||||
# Make sure little core don't go below 820MHz
|
# Make sure little core don't go below 820MHz
|
||||||
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 820000
|
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 820000
|
||||||
|
|
||||||
write /proc/vendor_sched/groups/bg/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/cam/rampup_multiplier 1
|
|
||||||
write /proc/vendor_sched/groups/cam_power/rampup_multiplier 1
|
|
||||||
write /proc/vendor_sched/groups/dex2oat/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/fg/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/fg_wi/rampup_multiplier 1
|
|
||||||
write /proc/vendor_sched/groups/nnapi/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/ota/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/rt/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/sf/rampup_multiplier 1
|
|
||||||
write /proc/vendor_sched/groups/sys/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/sys_bg/rampup_multiplier 0
|
|
||||||
write /proc/vendor_sched/groups/ta/rampup_multiplier 1
|
|
||||||
write /proc/vendor_sched/adpf_rampup_multiplier 2
|
|
||||||
|
|
||||||
write /proc/vendor_sched/groups/bg/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/cam/disable_util_est 0
|
|
||||||
write /proc/vendor_sched/groups/cam_power/disable_util_est 0
|
|
||||||
write /proc/vendor_sched/groups/dex2oat/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/fg/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/fg_wi/disable_util_est 0
|
|
||||||
write /proc/vendor_sched/groups/nnapi/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/ota/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/rt/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/sf/disable_util_est 0
|
|
||||||
write /proc/vendor_sched/groups/sys/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/sys_bg/disable_util_est 1
|
|
||||||
write /proc/vendor_sched/groups/ta/disable_util_est 0
|
|
||||||
|
|
||||||
# memlat cpuidle awareness setting
|
# memlat cpuidle awareness setting
|
||||||
# FIXME(b/301212469) these nodes missing on zuma pro
|
# FIXME(b/301212469) these nodes missing on zuma pro
|
||||||
# TODO(b/308973423) these values need to be tuned
|
# TODO(b/308973423) these values need to be tuned
|
||||||
|
@ -71,12 +42,6 @@ on init
|
||||||
write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware 2
|
write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware 2
|
||||||
write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware 2
|
write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware 2
|
||||||
|
|
||||||
# change permissions and default values for camera-daemon cpu controller
|
|
||||||
chown system system /dev/cpuctl/camera-daemon/cpu.uclamp.min
|
|
||||||
chown system system /dev/cpuctl/camera-daemon/cpu.uclamp.max
|
|
||||||
chown root root /dev/cpuctl/camera-daemon/cpu.uclamp.latency_sensitive
|
|
||||||
chown system system /dev/cpuctl/camera-daemon/cgroup.procs
|
|
||||||
|
|
||||||
mkdir /dev/cpuset/camera-daemon-high-group
|
mkdir /dev/cpuset/camera-daemon-high-group
|
||||||
write /dev/cpuset/camera-daemon-high-group/cpus 0-7
|
write /dev/cpuset/camera-daemon-high-group/cpus 0-7
|
||||||
write /dev/cpuset/camera-daemon-high-group/mems 0
|
write /dev/cpuset/camera-daemon-high-group/mems 0
|
||||||
|
@ -213,16 +178,6 @@ on property:sys.boot_completed=1
|
||||||
write /sys/devices/system/cpu/cpufreq/policy7/sched_pixel/limit_frequency 2363000
|
write /sys/devices/system/cpu/cpufreq/policy7/sched_pixel/limit_frequency 2363000
|
||||||
write /proc/vendor_sched/pmu_poll_time 10
|
write /proc/vendor_sched/pmu_poll_time 10
|
||||||
|
|
||||||
# Disable PMU freq limit
|
|
||||||
write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/pmu_limit_enable 1
|
|
||||||
write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/pmu_limit_enable 1
|
|
||||||
write /sys/devices/system/cpu/cpufreq/policy7/sched_pixel/pmu_limit_enable 1
|
|
||||||
write /proc/vendor_sched/pmu_poll_enable 0
|
|
||||||
|
|
||||||
# Set priority task name and boost value
|
|
||||||
write /proc/vendor_sched/priority_task_name "ExoPlayer:Place"
|
|
||||||
write /proc/vendor_sched/priority_task_boost_value 742
|
|
||||||
|
|
||||||
# To be removed after InputDispatche and InputReader become ADPF
|
# To be removed after InputDispatche and InputReader become ADPF
|
||||||
write /proc/vendor_sched/prefer_idle_task_name "InputDispatcher,InputReader"
|
write /proc/vendor_sched/prefer_idle_task_name "InputDispatcher,InputReader"
|
||||||
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/vendor/bin/sh
|
|
||||||
|
|
||||||
CHECKPOINT_DIR=/data/vendor/copied
|
|
||||||
|
|
||||||
export BIN_DIR=/vendor/bin
|
|
||||||
|
|
||||||
$BIN_DIR/mkdir -p $CHECKPOINT_DIR
|
|
||||||
|
|
||||||
function copy_files_to_data()
|
|
||||||
{
|
|
||||||
block_device=$1
|
|
||||||
partition_name=$(basename $1)
|
|
||||||
mount_point=$2
|
|
||||||
tmpdir=$CHECKPOINT_DIR/$partition_name.img
|
|
||||||
build_checkpoint=$CHECKPOINT_DIR/$partition_name
|
|
||||||
if [ ! -e $build_checkpoint ]; then
|
|
||||||
$BIN_DIR/rm -rf $tmpdir
|
|
||||||
$BIN_DIR/mkdir -p $tmpdir
|
|
||||||
$BIN_DIR/dump.f2fs -rfPo $tmpdir $block_device
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to $BIN_DIR/dump.f2fs -rfPo $tmpdir $block_device"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
$BIN_DIR/mv $tmpdir $build_checkpoint
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "mv $tmpdir $build_checkpoint"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
$BIN_DIR/fsync `dirname $build_checkpoint`
|
|
||||||
fi
|
|
||||||
echo "Successfully copied $mount_point to $build_checkpoint"
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_files_to_data "/dev/block/by-name/efs" "/mnt/vendor/efs"
|
|
||||||
copy_files_to_data "/dev/block/by-name/efs_backup" "/mnt/vendor/efs_backup"
|
|
||||||
copy_files_to_data "/dev/block/by-name/modem_userdata" "/mnt/vendor/modem_userdata"
|
|
||||||
copy_files_to_data "/dev/block/by-name/persist" "/mnt/vendor/persist"
|
|
||||||
|
|
||||||
$BIN_DIR/fsync /data/vendor/copied
|
|
|
@ -60,6 +60,9 @@ PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.app.com.android.se=off
|
||||||
PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.app.com.google.android.bluetooth=off
|
PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.app.com.google.android.bluetooth=off
|
||||||
PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.app.com.android.nfc=off
|
PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.app.com.android.nfc=off
|
||||||
PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.system_server=off
|
PRODUCT_PRODUCT_PROPERTIES += persist.arm64.memtag.system_server=off
|
||||||
|
# Also enable the system property that would turn on MTE when Android Advanced
|
||||||
|
# Protection Mode is turned on.
|
||||||
|
PRODUCT_PRODUCT_PROPERTIES += ro.arm64.memtag.bootctl_device_policy_manager=true
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
17
device.mk
17
device.mk
|
@ -45,6 +45,7 @@ include device/google/gs-common/bootctrl/bootctrl_aidl.mk
|
||||||
include device/google/gs-common/betterbug/betterbug.mk
|
include device/google/gs-common/betterbug/betterbug.mk
|
||||||
include device/google/gs-common/recorder/recorder.mk
|
include device/google/gs-common/recorder/recorder.mk
|
||||||
include device/google/gs-common/fingerprint/fingerprint.mk
|
include device/google/gs-common/fingerprint/fingerprint.mk
|
||||||
|
include device/google/gs-common/16kb/16kb.mk
|
||||||
|
|
||||||
include device/google/zumapro/dumpstate/item.mk
|
include device/google/zumapro/dumpstate/item.mk
|
||||||
|
|
||||||
|
@ -221,6 +222,10 @@ PRODUCT_PROPERTY_OVERRIDES += \
|
||||||
persist.vendor.usb.displayport.enabled=1
|
persist.vendor.usb.displayport.enabled=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Enable Settings 2-pane optimization for devices supporting display ports.
|
||||||
|
PRODUCT_SYSTEM_PROPERTIES += \
|
||||||
|
persist.settings.large_screen_opt_for_dp.enabled=true
|
||||||
|
|
||||||
PRODUCT_PROPERTY_OVERRIDES += \
|
PRODUCT_PROPERTY_OVERRIDES += \
|
||||||
persist.sys.hdcp_checking=drm-only
|
persist.sys.hdcp_checking=drm-only
|
||||||
|
|
||||||
|
@ -310,6 +315,9 @@ PRODUCT_PROPERTY_OVERRIDES += \
|
||||||
ro.vendor.uses_google_dialer_carrier_settings=1
|
ro.vendor.uses_google_dialer_carrier_settings=1
|
||||||
# GoogleDialer in PDK build with "USES_GOOGLE_DIALER_CARRIER_SETTINGS=true"
|
# GoogleDialer in PDK build with "USES_GOOGLE_DIALER_CARRIER_SETTINGS=true"
|
||||||
PRODUCT_SOONG_NAMESPACES += vendor/google_devices/zumapro/proprietary/GoogleDialer
|
PRODUCT_SOONG_NAMESPACES += vendor/google_devices/zumapro/proprietary/GoogleDialer
|
||||||
|
|
||||||
|
# Use prebuilt PixelImsMediaFramework.jar for PDK build
|
||||||
|
PRODUCT_SOONG_NAMESPACES += vendor/google_devices/gs-common/prebuilts/ImsMedia
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(USES_GOOGLE_PREBUILT_MODEM_SVC),true)
|
ifeq ($(USES_GOOGLE_PREBUILT_MODEM_SVC),true)
|
||||||
|
@ -406,8 +414,8 @@ PRODUCT_COPY_FILES += \
|
||||||
frameworks/native/data/etc/android.hardware.vulkan.version-1_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
|
frameworks/native/data/etc/android.hardware.vulkan.version-1_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
|
||||||
frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
|
frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
|
||||||
frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.compute.xml \
|
frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.compute.xml \
|
||||||
frameworks/native/data/etc/android.software.vulkan.deqp.level-2024-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \
|
frameworks/native/data/etc/android.software.vulkan.deqp.level-2025-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \
|
||||||
frameworks/native/data/etc/android.software.opengles.deqp.level-2024-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml
|
frameworks/native/data/etc/android.software.opengles.deqp.level-2025-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -491,7 +499,6 @@ PRODUCT_COPY_FILES += \
|
||||||
device/google/zumapro/conf/init.efs.16k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.efs.rc \
|
device/google/zumapro/conf/init.efs.16k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.efs.rc \
|
||||||
device/google/zumapro/conf/fstab.efs.from_data:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.efs.from_data
|
device/google/zumapro/conf/fstab.efs.from_data:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.efs.from_data
|
||||||
|
|
||||||
PRODUCT_PACKAGES += copy_efs_files_to_data
|
|
||||||
PRODUCT_PACKAGES += fsck.f2fs.vendor
|
PRODUCT_PACKAGES += fsck.f2fs.vendor
|
||||||
else
|
else
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
|
@ -874,10 +881,6 @@ PRODUCT_PROPERTY_OVERRIDES += \
|
||||||
debug.sf.enable_sdr_dimming=1 \
|
debug.sf.enable_sdr_dimming=1 \
|
||||||
debug.sf.dim_in_gamma_in_enhanced_screenshots=1
|
debug.sf.dim_in_gamma_in_enhanced_screenshots=1
|
||||||
|
|
||||||
# Camera
|
|
||||||
PRODUCT_PROPERTY_OVERRIDES += \
|
|
||||||
vendor.camera.multicam.enable_p23_multicam=true
|
|
||||||
|
|
||||||
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += debug.sf.use_phase_offsets_as_durations=1
|
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += debug.sf.use_phase_offsets_as_durations=1
|
||||||
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += debug.sf.late.sf.duration=10500000
|
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += debug.sf.late.sf.duration=10500000
|
||||||
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += debug.sf.late.app.duration=16600000
|
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += debug.sf.late.app.duration=16600000
|
||||||
|
|
|
@ -172,10 +172,11 @@
|
||||||
<Limit name="measured-frame-rate-1280x720" range="86-185" />
|
<Limit name="measured-frame-rate-1280x720" range="86-185" />
|
||||||
</MediaCodec>
|
</MediaCodec>
|
||||||
<MediaCodec name="c2.android.av1-dav1d.decoder" type="video/av01" update="true">
|
<MediaCodec name="c2.android.av1-dav1d.decoder" type="video/av01" update="true">
|
||||||
<Limit name="measured-frame-rate-352x288" range="689-881" />
|
<!-- b/388044420 -->
|
||||||
<Limit name="measured-frame-rate-640x360" range="763-845" />
|
<Limit name="measured-frame-rate-352x288" range="315-526" />
|
||||||
<Limit name="measured-frame-rate-720x480" range="727-746" />
|
<Limit name="measured-frame-rate-640x360" range="271-485" />
|
||||||
<Limit name="measured-frame-rate-1280x720" range="348-358" />
|
<Limit name="measured-frame-rate-720x480" range="210-369" />
|
||||||
|
<Limit name="measured-frame-rate-1280x720" range="195-322" />
|
||||||
</MediaCodec>
|
</MediaCodec>
|
||||||
</Decoders>
|
</Decoders>
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
<!-- disable bluetooth and wifi during satellite -->
|
<!-- disable bluetooth, nfc and wifi during satellite -->
|
||||||
<string name="def_satellite_mode_radios">bluetooth,wifi</string>
|
<string name="def_satellite_mode_radios">bluetooth,nfc,wifi</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -31,4 +31,7 @@
|
||||||
|
|
||||||
<!-- String indicating the package name of the device GbaService implementation. -->
|
<!-- String indicating the package name of the device GbaService implementation. -->
|
||||||
<string name="config_gba_package" translatable="false">com.shannon.rcsservice</string>
|
<string name="config_gba_package" translatable="false">com.shannon.rcsservice</string>
|
||||||
|
|
||||||
|
<!-- Whether to turn off non-emergency nb iot ntn satellite for emergency call -->
|
||||||
|
<bool name="config_turn_off_non_emergency_nb_iot_ntn_satellite_for_emergency_call">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -154,7 +154,9 @@ const struct SysfsCollector::SysfsPaths sysfs_paths = {
|
||||||
const struct UeventListener::UeventPaths ueventPaths = {
|
const struct UeventListener::UeventPaths ueventPaths = {
|
||||||
.AudioUevent = "/devices/virtual/amcs/amcs",
|
.AudioUevent = "/devices/virtual/amcs/amcs",
|
||||||
.TypeCPartnerUevent = "PRODUCT_TYPE=",
|
.TypeCPartnerUevent = "PRODUCT_TYPE=",
|
||||||
.FwUpdatePath = "/sys/devices/platform/maxim,max77779fwu/update_stats",
|
.FwUpdatePath = {
|
||||||
|
"/dev/logbuffer_max77779_fwupdate",
|
||||||
|
},
|
||||||
.FGAbnlPath = {
|
.FGAbnlPath = {
|
||||||
"/dev/logbuffer_max77779fg_monitor",
|
"/dev/logbuffer_max77779fg_monitor",
|
||||||
"/dev/logbuffer_maxfg_base_monitor",
|
"/dev/logbuffer_maxfg_base_monitor",
|
||||||
|
|
|
@ -461,34 +461,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"Name": "ResetUclampGrp",
|
|
||||||
"Actions": [
|
|
||||||
{
|
|
||||||
"Name": "WriteFile",
|
|
||||||
"Params":
|
|
||||||
{
|
|
||||||
"FilePath": "/proc/vendor_sched/uclamp_fork_reset_set",
|
|
||||||
"Value": "<pid>",
|
|
||||||
"LogFailures": "false"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "NoResetUclampGrp",
|
|
||||||
"Actions": [
|
|
||||||
{
|
|
||||||
"Name": "WriteFile",
|
|
||||||
"Params":
|
|
||||||
{
|
|
||||||
"FilePath": "/proc/vendor_sched/uclamp_fork_reset_clear",
|
|
||||||
"Value": "<pid>",
|
|
||||||
"LogFailures": "false"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"Name": "HighestCfsPrioScheduling",
|
"Name": "HighestCfsPrioScheduling",
|
||||||
"Actions": [
|
"Actions": [
|
||||||
|
|
|
@ -33,7 +33,6 @@ cc_binary {
|
||||||
srcs: [
|
srcs: [
|
||||||
"service.cpp",
|
"service.cpp",
|
||||||
"Usb.cpp",
|
"Usb.cpp",
|
||||||
"UsbDataSessionMonitor.cpp",
|
|
||||||
],
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libbase",
|
"libbase",
|
||||||
|
@ -59,9 +58,10 @@ cc_binary {
|
||||||
],
|
],
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"libpixelusb-aidl",
|
"libpixelusb-aidl",
|
||||||
|
"libpixelusb-datasession",
|
||||||
"libpixelstats",
|
"libpixelstats",
|
||||||
"libthermalutils",
|
"libthermalutils",
|
||||||
"android.hardware.usb.flags-aconfig-c-lib",
|
"android.hardware.usb.flags-aconfig-cc-lib",
|
||||||
],
|
],
|
||||||
export_shared_lib_headers: [
|
export_shared_lib_headers: [
|
||||||
"android.frameworks.stats-V2-ndk",
|
"android.frameworks.stats-V2-ndk",
|
||||||
|
@ -84,9 +84,3 @@ prebuilt_etc {
|
||||||
src: "android.hardware.usb-service-i2c11.rc",
|
src: "android.hardware.usb-service-i2c11.rc",
|
||||||
sub_dir: "init",
|
sub_dir: "init",
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_aconfig_library {
|
|
||||||
name: "android.hardware.usb.flags-aconfig-c-lib",
|
|
||||||
vendor: true,
|
|
||||||
aconfig_declarations: "android.hardware.usb.flags-aconfig",
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <aidl/android/hardware/usb/BnUsb.h>
|
#include <aidl/android/hardware/usb/BnUsb.h>
|
||||||
#include <aidl/android/hardware/usb/BnUsbCallback.h>
|
#include <aidl/android/hardware/usb/BnUsbCallback.h>
|
||||||
|
#include <pixelusb/UsbDataSessionMonitor.h>
|
||||||
#include <pixelusb/UsbOverheatEvent.h>
|
#include <pixelusb/UsbOverheatEvent.h>
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
#include <UsbDataSessionMonitor.h>
|
|
||||||
|
|
||||||
#define UEVENT_MSG_LEN 2048
|
#define UEVENT_MSG_LEN 2048
|
||||||
// The type-c stack waits for 4.5 - 5.5 secs before declaring a port non-pd.
|
// The type-c stack waits for 4.5 - 5.5 secs before declaring a port non-pd.
|
||||||
|
@ -50,6 +50,7 @@ using ::aidl::android::hardware::usb::PortRole;
|
||||||
using ::android::base::ReadFileToString;
|
using ::android::base::ReadFileToString;
|
||||||
using ::android::base::WriteStringToFile;
|
using ::android::base::WriteStringToFile;
|
||||||
using ::android::base::unique_fd;
|
using ::android::base::unique_fd;
|
||||||
|
using ::android::hardware::google::pixel::usb::UsbDataSessionMonitor;
|
||||||
using ::android::hardware::google::pixel::usb::UsbOverheatEvent;
|
using ::android::hardware::google::pixel::usb::UsbOverheatEvent;
|
||||||
using ::android::hardware::google::pixel::usb::ZoneInfo;
|
using ::android::hardware::google::pixel::usb::ZoneInfo;
|
||||||
using ::android::hardware::thermal::V2_0::TemperatureType;
|
using ::android::hardware::thermal::V2_0::TemperatureType;
|
||||||
|
|
|
@ -1,528 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <sys/timerfd.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
|
|
||||||
#define WARNING_SURFACE_DELAY_SEC 5
|
|
||||||
#define ENUM_FAIL_DEFAULT_COUNT_THRESHOLD 3
|
|
||||||
#define DEVICE_FLAKY_CONNECTION_CONFIGURED_COUNT_THRESHOLD 5
|
|
||||||
|
|
||||||
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;
|
|
||||||
int pipefds[2];
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
unique_fd timerFd(timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK));
|
|
||||||
if (timerFd.get() == -1) {
|
|
||||||
ALOGE("create timerFd failed");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addEpollFd(epollFd, timerFd))
|
|
||||||
abort();
|
|
||||||
|
|
||||||
if (addEpollFile(epollFd.get(), dataRolePath, mDataRoleFd) != 0) {
|
|
||||||
ALOGE("monitor data role failed");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe(pipefds);
|
|
||||||
mPipefd0.reset(pipefds[0]);
|
|
||||||
mPipefd1.reset(pipefds[1]);
|
|
||||||
if (addEpollFd(epollFd, mPipefd0))
|
|
||||||
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.name = "udc";
|
|
||||||
mDeviceState.filePath = deviceStatePath;
|
|
||||||
mDeviceState.ueventRegex = deviceUeventRegex;
|
|
||||||
addEpollFile(epollFd.get(), mDeviceState.filePath, mDeviceState.fd);
|
|
||||||
|
|
||||||
mHost1State.name = "host1";
|
|
||||||
mHost1State.filePath = host1StatePath;
|
|
||||||
mHost1State.ueventRegex = host1UeventRegex;
|
|
||||||
addEpollFile(epollFd.get(), mHost1State.filePath, mHost1State.fd);
|
|
||||||
|
|
||||||
mHost2State.name = "host2";
|
|
||||||
mHost2State.filePath = host2StatePath;
|
|
||||||
mHost2State.ueventRegex = host2UeventRegex;
|
|
||||||
addEpollFile(epollFd.get(), mHost2State.filePath, mHost2State.fd);
|
|
||||||
|
|
||||||
mEpollFd = std::move(epollFd);
|
|
||||||
mUeventFd = std::move(ueventFd);
|
|
||||||
mTimerFd = std::move(timerFd);
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
ALOGI("feature flag enable_report_usb_data_compliance_warning: %d",
|
|
||||||
usb_flags::enable_report_usb_data_compliance_warning());
|
|
||||||
}
|
|
||||||
|
|
||||||
UsbDataSessionMonitor::~UsbDataSessionMonitor() {
|
|
||||||
/*
|
|
||||||
* Write a character to the pipe to signal the monitor thread to exit.
|
|
||||||
* The character is not important, it can be any value.
|
|
||||||
*/
|
|
||||||
int c = 'q';
|
|
||||||
write(mPipefd1, &c, 1);
|
|
||||||
pthread_join(mMonitor, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
int elapsedTimeSec;
|
|
||||||
|
|
||||||
elapsedTimeSec =
|
|
||||||
std::chrono::duration_cast<std::chrono::seconds>(boot_clock::now() - mDataSessionStart)
|
|
||||||
.count();
|
|
||||||
|
|
||||||
if (elapsedTimeSec >= WARNING_SURFACE_DELAY_SEC) {
|
|
||||||
if (mDataRole == PortDataRole::DEVICE && mUdcBind) {
|
|
||||||
int configuredCount = std::count(mDeviceState.states.begin(),
|
|
||||||
mDeviceState.states.end(), kConfiguredState);
|
|
||||||
int defaultCount =
|
|
||||||
std::count(mDeviceState.states.begin(), mDeviceState.states.end(), kDefaultState);
|
|
||||||
|
|
||||||
if (configuredCount == 0 && defaultCount > ENUM_FAIL_DEFAULT_COUNT_THRESHOLD)
|
|
||||||
newWarningSet.insert(ComplianceWarning::ENUMERATION_FAIL);
|
|
||||||
|
|
||||||
if (configuredCount > DEVICE_FLAKY_CONNECTION_CONFIGURED_COUNT_THRESHOLD)
|
|
||||||
newWarningSet.insert(ComplianceWarning::FLAKY_CONNECTION);
|
|
||||||
} else if (mDataRole == PortDataRole::HOST) {
|
|
||||||
int host1StateCount = mHost1State.states.size();
|
|
||||||
int host1ConfiguredCount =
|
|
||||||
std::count(mHost1State.states.begin(), mHost1State.states.end(), kConfiguredState);
|
|
||||||
int host1DefaultCount =
|
|
||||||
std::count(mHost1State.states.begin(), mHost1State.states.end(), kDefaultState);
|
|
||||||
int host2StateCount = mHost2State.states.size();
|
|
||||||
int host2ConfiguredCount =
|
|
||||||
std::count(mHost2State.states.begin(), mHost2State.states.end(), kConfiguredState);
|
|
||||||
int host2DefaultCount =
|
|
||||||
std::count(mHost2State.states.begin(), mHost2State.states.end(), kDefaultState);
|
|
||||||
|
|
||||||
if (host1ConfiguredCount == 0 && host2ConfiguredCount == 0 &&
|
|
||||||
(host1DefaultCount > ENUM_FAIL_DEFAULT_COUNT_THRESHOLD ||
|
|
||||||
host2DefaultCount > ENUM_FAIL_DEFAULT_COUNT_THRESHOLD))
|
|
||||||
newWarningSet.insert(ComplianceWarning::ENUMERATION_FAIL);
|
|
||||||
|
|
||||||
if (host1StateCount == 1 && mHost1State.states.front() == kNotAttachedState &&
|
|
||||||
host2StateCount == 1 && mHost2State.states.front() == kNotAttachedState)
|
|
||||||
newWarningSet.insert(ComplianceWarning::MISSING_DATA_LINES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newWarningSet != mWarningSet) {
|
|
||||||
std::string newWarningString;
|
|
||||||
|
|
||||||
for (auto e : newWarningSet) {
|
|
||||||
newWarningString += toString(e) + " ";
|
|
||||||
}
|
|
||||||
ALOGI("Usb data compliance warning changed to: %s", newWarningString.c_str());
|
|
||||||
|
|
||||||
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: %s", deviceState->name.c_str(), state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ALOGI("Update device state %s: %s", deviceState->name.c_str(), state);
|
|
||||||
|
|
||||||
deviceState->states.push_back(state);
|
|
||||||
deviceState->timestamps.push_back(boot_clock::now());
|
|
||||||
evaluateComplianceWarning();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UsbDataSessionMonitor::setupNewSession() {
|
|
||||||
mWarningSet.clear();
|
|
||||||
mDataSessionStart = boot_clock::now();
|
|
||||||
|
|
||||||
if (mDataRole == PortDataRole::DEVICE) {
|
|
||||||
clearDeviceStateEvents(&mDeviceState);
|
|
||||||
} else if (mDataRole == PortDataRole::HOST) {
|
|
||||||
clearDeviceStateEvents(&mHost1State);
|
|
||||||
clearDeviceStateEvents(&mHost2State);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mDataRole != PortDataRole::NONE) {
|
|
||||||
struct itimerspec delay = itimerspec();
|
|
||||||
delay.it_value.tv_sec = WARNING_SURFACE_DELAY_SEC;
|
|
||||||
int ret = timerfd_settime(mTimerFd.get(), 0, &delay, NULL);
|
|
||||||
if (ret < 0)
|
|
||||||
ALOGE("timerfd_settime failed err:%d", errno);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
mDataRole = newDataRole;
|
|
||||||
setupNewSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
|
|
||||||
setupNewSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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::handleTimerEvent() {
|
|
||||||
int byteRead;
|
|
||||||
uint64_t numExpiration;
|
|
||||||
|
|
||||||
byteRead = read(mTimerFd.get(), &numExpiration, sizeof(numExpiration));
|
|
||||||
|
|
||||||
if (byteRead != sizeof(numExpiration)) {
|
|
||||||
ALOGE("incorrect read size");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numExpiration != 1) {
|
|
||||||
ALOGE("incorrect expiration count");
|
|
||||||
}
|
|
||||||
|
|
||||||
evaluateComplianceWarning();
|
|
||||||
}
|
|
||||||
|
|
||||||
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->mPipefd0.get()) {
|
|
||||||
return NULL;
|
|
||||||
} else if (events[n].data.fd == monitor->mUeventFd.get()) {
|
|
||||||
monitor->handleUevent();
|
|
||||||
} else if (events[n].data.fd == monitor->mTimerFd.get()) {
|
|
||||||
monitor->handleTimerEvent();
|
|
||||||
} 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
|
|
|
@ -1,121 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 {
|
|
||||||
// The name of the usb device, e.g. udc, host1, host2.
|
|
||||||
std::string name;
|
|
||||||
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 handleTimerEvent();
|
|
||||||
void handleDataRoleEvent();
|
|
||||||
void handleDeviceStateEvent(struct usbDeviceState *deviceState);
|
|
||||||
void clearDeviceStateEvents(struct usbDeviceState *deviceState);
|
|
||||||
void setupNewSession();
|
|
||||||
void reportUsbDataSessionMetrics();
|
|
||||||
void evaluateComplianceWarning();
|
|
||||||
void notifyComplianceWarning();
|
|
||||||
void updateUdcBindStatus(const std::string &devname);
|
|
||||||
|
|
||||||
pthread_t mMonitor;
|
|
||||||
unique_fd mPipefd0;
|
|
||||||
unique_fd mPipefd1;
|
|
||||||
unique_fd mEpollFd;
|
|
||||||
unique_fd mUeventFd;
|
|
||||||
unique_fd mTimerFd;
|
|
||||||
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
|
|
Loading…
Add table
Add a link
Reference in a new issue