Merge "gs-common: Add BrownoutDetection app"
diff --git a/aoc/sepolicy/genfs_contexts b/aoc/sepolicy/genfs_contexts
index 331b67a..1df3116 100644
--- a/aoc/sepolicy/genfs_contexts
+++ b/aoc/sepolicy/genfs_contexts
@@ -9,4 +9,5 @@
genfscon sysfs /devices/platform/audiometrics/codec_crashed_counter u:object_r:sysfs_pixelstats:s0
genfscon sysfs /devices/platform/audiometrics/hwinfo_part_number u:object_r:sysfs_pixelstats:s0
genfscon sysfs /devices/platform/audiometrics/ams_rate_read_once u:object_r:sysfs_pixelstats:s0
+genfscon sysfs /devices/platform/audiometrics/cca_rate_read_once u:object_r:sysfs_pixelstats:s0
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
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
+