From 66547716ae1b1f94527ca1c0940692a264a4fc8b Mon Sep 17 00:00:00 2001 From: George Lee Date: Wed, 9 Nov 2022 16:02:40 -0800 Subject: [PATCH 1/3] gs-common: Add BrownoutDetection app This app files bugreport for user-debug build with reboot reason = ocp or uvlo. Removed the dependency on BetterBug. Bug: 237287659 Test: Ensure bugreport is generated under user-debug build with reboot reason = ocp or uvlo. Change-Id: Ieaa4d02ea10413b3b7c0e314b5deb07d38d98a80 Signed-off-by: George Lee --- battery_mitigation/battery_mitigation.rc | 56 +++++++++---------- battery_mitigation/bcl.mk | 5 +- .../sepolicy/battery_mitigation.te | 1 - battery_mitigation/sepolicy/better_bug_app.te | 13 ----- .../sepolicy/brownout_detection_app.te | 9 +++ battery_mitigation/sepolicy/property.te | 2 +- battery_mitigation/sepolicy/property_contexts | 2 +- battery_mitigation/sepolicy/seapp_contexts | 5 +- battery_mitigation/sepolicy/vendor_init.te | 2 +- 9 files changed, 44 insertions(+), 51 deletions(-) delete mode 100644 battery_mitigation/sepolicy/better_bug_app.te create mode 100644 battery_mitigation/sepolicy/brownout_detection_app.te diff --git a/battery_mitigation/battery_mitigation.rc b/battery_mitigation/battery_mitigation.rc index 4c4e2c1..c0c76fb 100644 --- a/battery_mitigation/battery_mitigation.rc +++ b/battery_mitigation/battery_mitigation.rc @@ -4,88 +4,88 @@ on property:vendor.thermal.link_ready=1 start vendor.battery_mitigation on property:ro.boot.bootreason=reboot,uvlo,pmic,if - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "uvlo,pmic,if" on property:ro.boot.bootreason=reboot,ocp,pmic,if - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,pmic,if" on property:ro.boot.bootreason=reboot,uvlo,pmic,main - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "uvlo,pmic,main" on property:ro.boot.bootreason=reboot,uvlo,pmic,sub - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "uvlo,pmic,sub" on property:ro.boot.bootreason=reboot,ocp,buck1m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck1m" on property:ro.boot.bootreason=reboot,ocp,buck2m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck2m" on property:ro.boot.bootreason=reboot,ocp,buck3m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck3m" on property:ro.boot.bootreason=reboot,ocp,buck4m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck4m" on property:ro.boot.bootreason=reboot,ocp,buck5m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck5m" on property:ro.boot.bootreason=reboot,ocp,buck6m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck6m" on property:ro.boot.bootreason=reboot,ocp,buck7m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck7m" on property:ro.boot.bootreason=reboot,ocp,buck8m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck8m" on property:ro.boot.bootreason=reboot,ocp,buck9m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck9m" on property:ro.boot.bootreason=reboot,ocp,buck10m - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck10m" on property:ro.boot.bootreason=reboot,ocp,buck1s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck1s" on property:ro.boot.bootreason=reboot,ocp,buck2s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck2s" on property:ro.boot.bootreason=reboot,ocp,buck3s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck3s" on property:ro.boot.bootreason=reboot,ocp,buck4s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck4s" on property:ro.boot.bootreason=reboot,ocp,buck5s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck5s" on property:ro.boot.bootreason=reboot,ocp,buck6s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck6s" on property:ro.boot.bootreason=reboot,ocp,buck7s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck7s" on property:ro.boot.bootreason=reboot,ocp,buck8s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck8s" on property:ro.boot.bootreason=reboot,ocp,buck9s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck9s" on property:ro.boot.bootreason=reboot,ocp,buck10s - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buck10s" on property:ro.boot.bootreason=reboot,ocp,buckds - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buckds" on property:ro.boot.bootreason=reboot,ocp,buckas - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buckas" on property:ro.boot.bootreason=reboot,ocp,buckcs - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buckcs" on property:ro.boot.bootreason=reboot,ocp,buckbs - setprop vendor.startup_bugreport_requested 1 + setprop vendor.brownout_reason "ocp,buckbs" service vendor.battery_mitigation /vendor/bin/hw/battery_mitigation user system diff --git a/battery_mitigation/bcl.mk b/battery_mitigation/bcl.mk index b804a0c..c74b398 100644 --- a/battery_mitigation/bcl.mk +++ b/battery_mitigation/bcl.mk @@ -1,6 +1,5 @@ -PRODUCT_PACKAGES += battery_mitigation +PRODUCT_PACKAGES += battery_mitigation \ + BrownoutDetection BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/battery_mitigation/sepolicy PRODUCT_SOONG_NAMESPACES += device/google/gs-common/battery_mitigation - -# BetterBug is included in /vendor/google/products/pixel_experience_2017_and_newer.mk diff --git a/battery_mitigation/sepolicy/battery_mitigation.te b/battery_mitigation/sepolicy/battery_mitigation.te index 56b8373..5fecbcb 100644 --- a/battery_mitigation/sepolicy/battery_mitigation.te +++ b/battery_mitigation/sepolicy/battery_mitigation.te @@ -2,7 +2,6 @@ type battery_mitigation, domain; type battery_mitigation_exec, exec_type, vendor_file_type, file_type; init_daemon_domain(battery_mitigation) get_prop(battery_mitigation, boot_status_prop) -get_prop(battery_mitigation, vendor_startup_bugreport_requested_prop) set_prop(battery_mitigation, vendor_mitigation_ready_prop) hal_client_domain(battery_mitigation, hal_thermal); diff --git a/battery_mitigation/sepolicy/better_bug_app.te b/battery_mitigation/sepolicy/better_bug_app.te deleted file mode 100644 index 6813024..0000000 --- a/battery_mitigation/sepolicy/better_bug_app.te +++ /dev/null @@ -1,13 +0,0 @@ -type better_bug_app, domain, coredomain; - -userdebug_or_eng(` - app_domain(better_bug_app) - net_domain(better_bug_app) - allow better_bug_app shell_data_file:file read; - allow better_bug_app app_api_service:service_manager find; - allow better_bug_app system_api_service:service_manager find; - allow better_bug_app privapp_data_file:file execute; - allow better_bug_app mediaserver_service:service_manager find; - get_prop(better_bug_app, default_prop); - get_prop(better_bug_app, vendor_startup_bugreport_requested_prop) -') diff --git a/battery_mitigation/sepolicy/brownout_detection_app.te b/battery_mitigation/sepolicy/brownout_detection_app.te new file mode 100644 index 0000000..6146a74 --- /dev/null +++ b/battery_mitigation/sepolicy/brownout_detection_app.te @@ -0,0 +1,9 @@ +type brownout_detection_app, domain, coredomain; + +userdebug_or_eng(` + app_domain(brownout_detection_app) + net_domain(brownout_detection_app) + allow brownout_detection_app app_api_service:service_manager find; + allow brownout_detection_app system_api_service:service_manager find; + get_prop(brownout_detection_app, vendor_brownout_reason_prop) +') diff --git a/battery_mitigation/sepolicy/property.te b/battery_mitigation/sepolicy/property.te index 2003e18..d750f09 100644 --- a/battery_mitigation/sepolicy/property.te +++ b/battery_mitigation/sepolicy/property.te @@ -1,3 +1,3 @@ # Battery Mitigation vendor_internal_prop(vendor_mitigation_ready_prop) -vendor_public_prop(vendor_startup_bugreport_requested_prop) +vendor_public_prop(vendor_brownout_reason_prop) diff --git a/battery_mitigation/sepolicy/property_contexts b/battery_mitigation/sepolicy/property_contexts index 51f6aed..014cb14 100644 --- a/battery_mitigation/sepolicy/property_contexts +++ b/battery_mitigation/sepolicy/property_contexts @@ -1,3 +1,3 @@ # Battery Mitigation vendor.brownout.mitigation.ready u:object_r:vendor_mitigation_ready_prop:s0 -vendor.startup_bugreport_requested u:object_r:vendor_startup_bugreport_requested_prop:s0 +vendor.brownout_reason u:object_r:vendor_brownout_reason_prop:s0 diff --git a/battery_mitigation/sepolicy/seapp_contexts b/battery_mitigation/sepolicy/seapp_contexts index 14bf1d2..7e5d883 100644 --- a/battery_mitigation/sepolicy/seapp_contexts +++ b/battery_mitigation/sepolicy/seapp_contexts @@ -1,3 +1,2 @@ -# BetterBug -user=_app isPrivApp=true name=com.google.android.apps.internal.betterbug domain=better_bug_app type=app_data_file levelFrom=all - +# BrownoutDetection +user=_app isPrivApp=true name=com.google.android.brownoutdetection domain=brownout_detection_app type=app_data_file levelFrom=all diff --git a/battery_mitigation/sepolicy/vendor_init.te b/battery_mitigation/sepolicy/vendor_init.te index 1c7f90b..b1bc894 100644 --- a/battery_mitigation/sepolicy/vendor_init.te +++ b/battery_mitigation/sepolicy/vendor_init.te @@ -1,2 +1,2 @@ # Battery Mitigation -set_prop(vendor_init, vendor_startup_bugreport_requested_prop) +set_prop(vendor_init, vendor_brownout_reason_prop) From 486bbb92123fdfc105eb101b667e0d64b93fdc47 Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Tue, 15 Nov 2022 14:01:18 +0800 Subject: [PATCH 2/3] create thermal dump in gs-common Bug: 257880034 Test: adb bugreport Change-Id: I0d93796c2639148dfb00b0d739cbae483091bfd4 --- thermal/Android.bp | 10 +++++++ thermal/dump_thermal.sh | 46 ++++++++++++++++++++++++++++++++ thermal/sepolicy/dump_thermal.te | 6 +++++ thermal/sepolicy/file_contexts | 1 + thermal/sepolicy/genfs_contexts | 3 +++ thermal/thermal.mk | 3 +++ 6 files changed, 69 insertions(+) create mode 100644 thermal/Android.bp create mode 100644 thermal/dump_thermal.sh create mode 100644 thermal/sepolicy/dump_thermal.te create mode 100644 thermal/sepolicy/file_contexts create mode 100644 thermal/sepolicy/genfs_contexts create mode 100644 thermal/thermal.mk diff --git a/thermal/Android.bp b/thermal/Android.bp new file mode 100644 index 0000000..70fef5c --- /dev/null +++ b/thermal/Android.bp @@ -0,0 +1,10 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_thermal.sh", + src: "dump_thermal.sh", + vendor: true, + sub_dir: "dump", +} diff --git a/thermal/dump_thermal.sh b/thermal/dump_thermal.sh new file mode 100644 index 0000000..2b87da9 --- /dev/null +++ b/thermal/dump_thermal.sh @@ -0,0 +1,46 @@ +#!/vendor/bin/sh + +echo "Temperatures" +for f in /sys/class/thermal/thermal* ; do + printf "%s: %s\n" `cat $f/type` `cat $f/temp` +done + +echo "Cooling Device Current State" +for f in /sys/class/thermal/cooling* ; do + printf "%s: %s\n" `cat $f/type` `cat $f/cur_state` +done + +echo "Cooling Device User Vote State" +for f in /sys/class/thermal/cooling* ; do + if [ ! -f $f/user_vote ]; then continue; fi; + printf "%s: %s\n" `cat $f/type` `cat $f/user_vote` +done + +echo "Cooling Device Time in State" +for f in /sys/class/thermal/cooling* ; do + printf "%s: %s\n" `cat $f/type` `cat $f/stats/time_in_state_ms` +done + +echo "Cooling Device Trans Table" +for f in /sys/class/thermal/cooling* ; do + printf "%s: %s\n" `cat $f/type` `cat $f/stats/trans_table` +done + +echo "Cooling Device State2Power Table" +for f in /sys/class/thermal/cooling* ; do + if [ ! -f $f/state2power_table ]; then continue; fi; + printf "%s: %s\n" `cat $f/type` `cat $f/state2power_table` +done + +echo "TMU state:" +cat /sys/module/gs_thermal/parameters/tmu_reg_dump_state +echo "TMU current temperature:" +cat /sys/module/gs_thermal/parameters/tmu_reg_dump_current_temp +echo "TMU_TOP rise thresholds:" +cat /sys/module/gs_thermal/parameters/tmu_top_reg_dump_rise_thres +echo "TMU_TOP fall thresholds:" +cat /sys/module/gs_thermal/parameters/tmu_top_reg_dump_fall_thres +echo "TMU_SUB rise thresholds:" +cat /sys/module/gs_thermal/parameters/tmu_sub_reg_dump_rise_thres +echo "TMU_SUB fall thresholds:" +cat /sys/module/gs_thermal/parameters/tmu_sub_reg_dump_fall_thres diff --git a/thermal/sepolicy/dump_thermal.te b/thermal/sepolicy/dump_thermal.te new file mode 100644 index 0000000..2dd6ba4 --- /dev/null +++ b/thermal/sepolicy/dump_thermal.te @@ -0,0 +1,6 @@ +pixel_bugreport(dump_thermal) + +allow dump_thermal sysfs_thermal:dir r_dir_perms; +allow dump_thermal sysfs_thermal:file r_file_perms; +allow dump_thermal sysfs_thermal:lnk_file r_file_perms; +allow dump_thermal vendor_toolbox_exec:file execute_no_trans; diff --git a/thermal/sepolicy/file_contexts b/thermal/sepolicy/file_contexts new file mode 100644 index 0000000..461a07b --- /dev/null +++ b/thermal/sepolicy/file_contexts @@ -0,0 +1 @@ +/vendor/bin/dump/dump_thermal\.sh u:object_r:dump_thermal_exec:s0 diff --git a/thermal/sepolicy/genfs_contexts b/thermal/sepolicy/genfs_contexts new file mode 100644 index 0000000..1422e63 --- /dev/null +++ b/thermal/sepolicy/genfs_contexts @@ -0,0 +1,3 @@ +# thermal sysfs files +genfscon sysfs /module/gs_thermal/parameters u:object_r:sysfs_thermal:s0 + diff --git a/thermal/thermal.mk b/thermal/thermal.mk new file mode 100644 index 0000000..3b3dede --- /dev/null +++ b/thermal/thermal.mk @@ -0,0 +1,3 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/thermal/sepolicy + +PRODUCT_PACKAGES += dump_thermal.sh From a4d16cf5a0a7af315c314eb66d4c38588a20bc6f Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Mon, 7 Nov 2022 13:08:28 +0800 Subject: [PATCH 3/3] create raven touch dump Bug: 256521567 Test: adb bugreport Change-Id: Ibf5d74936605f7b0a3a2124bb7df094c60644c23 --- touch/lsi/Android.bp | 10 +++++++ touch/lsi/dump_lsi.sh | 48 +++++++++++++++++++++++++++++++ touch/lsi/lsi.mk | 3 ++ touch/lsi/sepolicy/dump_lsi.te | 5 ++++ touch/lsi/sepolicy/file_contexts | 2 ++ touch/lsi/sepolicy/genfs_contexts | 2 ++ 6 files changed, 70 insertions(+) create mode 100644 touch/lsi/Android.bp create mode 100644 touch/lsi/dump_lsi.sh create mode 100644 touch/lsi/lsi.mk create mode 100644 touch/lsi/sepolicy/dump_lsi.te create mode 100644 touch/lsi/sepolicy/file_contexts create mode 100644 touch/lsi/sepolicy/genfs_contexts diff --git a/touch/lsi/Android.bp b/touch/lsi/Android.bp new file mode 100644 index 0000000..b0cef6f --- /dev/null +++ b/touch/lsi/Android.bp @@ -0,0 +1,10 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_lsi.sh", + src: "dump_lsi.sh", + vendor: true, + sub_dir: "dump", +} diff --git a/touch/lsi/dump_lsi.sh b/touch/lsi/dump_lsi.sh new file mode 100644 index 0000000..57c7f4d --- /dev/null +++ b/touch/lsi/dump_lsi.sh @@ -0,0 +1,48 @@ +#!/vendor/bin/sh +path="/sys/devices/virtual/sec/tsp" + +echo "--- Force Touch Active ---" +echo "force_touch_active,2,1" > $path/cmd && cat $path/cmd_result + +echo "--- LSI firmware version ---" +cat $path/fw_version + +echo "--- LSI touch status ---" +cat $path/status + +echo "--- Calibration info ---" +echo "get_mis_cal_info" > $path/cmd && cat $path/cmd_result + +echo "--- Mutual Strength ---" +echo "run_delta_read_all" > $path/cmd && cat $path/cmd_result + +echo "--- Self Strength ---" +echo "run_self_delta_read_all" > $path/cmd && cat $path/cmd_result + +echo "--- TYPE_AMBIENT_DATA ---" +echo "run_rawdata_read_type,3" > $path/cmd && cat $path/cmd_result + +echo "--- TYPE_DECODED_DATA ---" +echo "run_rawdata_read_type,5" > $path/cmd && cat $path/cmd_result + +echo "--- TYPE_OFFSET_DATA_SEC ---" +echo "run_rawdata_read_type,19" > $path/cmd && cat $path/cmd_result + +echo "--- TYPE_NOI_P2P_MIN ---" +echo "run_rawdata_read_type,30" > $path/cmd && cat $path/cmd_result + +echo "--- TYPE_NOI_P2P_MAX ---" +echo "run_rawdata_read_type,31" > $path/cmd && cat $path/cmd_result + +echo "--- Mutual Raw Cap ---" +echo "run_rawcap_read_all" > $path/cmd && cat $path/cmd_result + +echo "--- Self Raw Cap ---" +echo "run_self_rawcap_read_all" > $path/cmd && cat $path/cmd_result + +echo "--- CM2 ---" +echo "run_rawcap_high_freq_read_all" > $path/cmd && cat $path/cmd_result + +echo "--- Force Touch Active ---" +echo force_touch_active,2,0 > $path/cmd && cat $path/cmd_result + diff --git a/touch/lsi/lsi.mk b/touch/lsi/lsi.mk new file mode 100644 index 0000000..bcb69bb --- /dev/null +++ b/touch/lsi/lsi.mk @@ -0,0 +1,3 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/touch/lsi/sepolicy + +PRODUCT_PACKAGES += dump_lsi.sh diff --git a/touch/lsi/sepolicy/dump_lsi.te b/touch/lsi/sepolicy/dump_lsi.te new file mode 100644 index 0000000..a2e114d --- /dev/null +++ b/touch/lsi/sepolicy/dump_lsi.te @@ -0,0 +1,5 @@ +pixel_bugreport(dump_lsi) + +allow dump_lsi sysfs_touch:dir r_dir_perms; +allow dump_lsi sysfs_touch:file rw_file_perms; +allow dump_lsi vendor_toolbox_exec:file execute_no_trans; diff --git a/touch/lsi/sepolicy/file_contexts b/touch/lsi/sepolicy/file_contexts new file mode 100644 index 0000000..c1048fa --- /dev/null +++ b/touch/lsi/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/vendor/bin/dump/dump_lsi\.sh u:object_r:dump_lsi_exec:s0 + diff --git a/touch/lsi/sepolicy/genfs_contexts b/touch/lsi/sepolicy/genfs_contexts new file mode 100644 index 0000000..6dce360 --- /dev/null +++ b/touch/lsi/sepolicy/genfs_contexts @@ -0,0 +1,2 @@ +genfscon sysfs /devices/virtual/sec/tsp u:object_r:sysfs_touch:s0 +