bcl: Add Mitigation Logger - sepolicy

Mitigation Logger logs battery related information for 1 second when it
is triggered by under voltage or over current interrupts.  Information
collected is to help debug system brownout.

Bug: 228383769
Test: Boot and Test
Signed-off-by: George Lee <geolee@google.com>
Change-Id: I9ac873d03d57d9a6db8d9233f25c8fabdfc399a5
diff --git a/whitechapel_pro/battery_mitigation.te b/whitechapel_pro/battery_mitigation.te
new file mode 100644
index 0000000..59af9d5
--- /dev/null
+++ b/whitechapel_pro/battery_mitigation.te
@@ -0,0 +1,16 @@
+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)
+
+hal_client_domain(battery_mitigation, hal_thermal);
+hal_client_domain(battery_mitigation, hal_health);
+
+r_dir_file(battery_mitigation, sysfs_batteryinfo)
+r_dir_file(battery_mitigation, sysfs_iio_devices)
+r_dir_file(battery_mitigation, sysfs_thermal)
+r_dir_file(battery_mitigation, thermal_link_device)
+r_dir_file(battery_mitigation, sysfs_odpm)
+allow battery_mitigation sysfs_thermal:lnk_file r_file_perms;
+allow battery_mitigation mitigation_vendor_data_file:dir rw_dir_perms;
+allow battery_mitigation mitigation_vendor_data_file:file create_file_perms;
diff --git a/whitechapel_pro/file.te b/whitechapel_pro/file.te
index a9f3896..9ec8628 100644
--- a/whitechapel_pro/file.te
+++ b/whitechapel_pro/file.te
@@ -15,6 +15,7 @@
 type uwb_vendor_data_file, file_type, data_file_type, app_data_file_type;
 type uwb_data_vendor, file_type, data_file_type;
 type powerstats_vendor_data_file, file_type, data_file_type;
+type mitigation_vendor_data_file, file_type, data_file_type;
 userdebug_or_eng(`
   typeattribute tcpdump_vendor_data_file mlstrustedobject;
   typeattribute vendor_slog_file mlstrustedobject;
diff --git a/whitechapel_pro/file_contexts b/whitechapel_pro/file_contexts
index adba027..09b2825 100644
--- a/whitechapel_pro/file_contexts
+++ b/whitechapel_pro/file_contexts
@@ -41,6 +41,7 @@
 /vendor/bin/hw/android\.hardware\.qorvo\.uwb\.service                       u:object_r:hal_uwb_vendor_default_exec:s0
 /vendor/bin/rlsservice                                                      u:object_r:rlsservice_exec:s0
 /vendor/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service\.fpc u:object_r:fingerprint_factory_service_exec:s0
+/vendor/bin/hw/battery_mitigation                                           u:object_r:battery_mitigation_exec:s0
 
 # Vendor Firmwares
 /vendor/firmware(/.*)?                                                      u:object_r:vendor_fw_file:s0
@@ -207,6 +208,7 @@
 /data/vendor/uwb(/.*)?                                                      u:object_r:uwb_data_vendor:s0
 /dev/battery_history                                                        u:object_r:battery_history_device:s0
 /data/vendor/powerstats(/.*)?                                               u:object_r:powerstats_vendor_data_file:s0
+/data/vendor/mitigation(/.*)?                                               u:object_r:mitigation_vendor_data_file:s0
 
 # Persist
 /mnt/vendor/persist/battery(/.*)?                                           u:object_r:persist_battery_file:s0