From 2260099ad39288cc8ea29f0973a0e972acf8c8dc Mon Sep 17 00:00:00 2001 From: George Lee Date: Wed, 5 Oct 2022 14:03:34 -0700 Subject: [PATCH] bcl: Add mitigation ready device sepolicy Instead of relying on vendor.thermal.link_ready property to gate write to BCL's SYSFS node, adding mitigation ready SYSFS so that writes to BCL's SYSFS node would not cause NULL pointer dereference. Bug: 249130916 Test: Confirm property vendor.brownout.mitigation.ready is set Signed-off-by: George Lee Change-Id: I1b21a1c745e7e17f78e9d4c001032dd2c46673cf --- whitechapel_pro/battery_mitigation.te | 4 ++++ whitechapel_pro/property.te | 3 +++ whitechapel_pro/property_contexts | 3 +++ 3 files changed, 10 insertions(+) diff --git a/whitechapel_pro/battery_mitigation.te b/whitechapel_pro/battery_mitigation.te index 59af9d53..5fecbcba 100644 --- a/whitechapel_pro/battery_mitigation.te +++ b/whitechapel_pro/battery_mitigation.te @@ -2,6 +2,7 @@ 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) +set_prop(battery_mitigation, vendor_mitigation_ready_prop) hal_client_domain(battery_mitigation, hal_thermal); hal_client_domain(battery_mitigation, hal_health); @@ -11,6 +12,9 @@ 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_bcl:dir r_dir_perms; +allow battery_mitigation sysfs_bcl:file r_file_perms; +allow battery_mitigation sysfs_bcl:lnk_file r_file_perms; 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/property.te b/whitechapel_pro/property.te index ec7d84ed..b88506be 100644 --- a/whitechapel_pro/property.te +++ b/whitechapel_pro/property.te @@ -36,3 +36,6 @@ vendor_internal_prop(vendor_dynamic_sensor_prop) # Telephony debug app vendor_internal_prop(vendor_telephony_app_prop) + +# Battery Mitigation +vendor_internal_prop(vendor_mitigation_ready_prop) diff --git a/whitechapel_pro/property_contexts b/whitechapel_pro/property_contexts index 98a7980a..f4c5eeb0 100644 --- a/whitechapel_pro/property_contexts +++ b/whitechapel_pro/property_contexts @@ -106,3 +106,6 @@ persist.vendor.ims. u:object_r:vendor_imssvc_prop:s0 # for vendor telephony debug app vendor.config.debug. u:object_r:vendor_telephony_app_prop:s0 + +# Battery Mitigation +vendor.brownout.mitigation.ready u:object_r:vendor_mitigation_ready_prop:s0