Merge branch 'lineage-21.0' of https://github.com/LineageOS/android_device_lineage_sepolicy into leaf-3.2

Change-Id: I918e803148dde33494435516a3f5d12a6941454e
diff --git a/common/vendor/file_contexts b/common/vendor/file_contexts
index 8cfc967..a16c5c4 100644
--- a/common/vendor/file_contexts
+++ b/common/vendor/file_contexts
@@ -1,9 +1,6 @@
 # Fingerprint HAL
 /(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.0-service u:object_r:hal_fingerprint_default_exec:s0
 
-# GNSS HAL
-/(vendor|system/vendor)/bin/hw/android\.hardware\.gnss@1\.0-service\.legacy u:object_r:hal_gnss_default_exec:s0
-
 # Health HAL
 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.health-service\.default u:object_r:hal_lineage_health_default_exec:s0
 
@@ -13,6 +10,12 @@
 # LiveDisplay HAL
 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service-sysfs    u:object_r:hal_lineage_livedisplay_sysfs_exec:s0
 
+# Power HAL
+/(vendor|system/vendor)/bin/hw/android\.hardware\.power-service\.lineage-libperfmgr u:object_r:hal_power_default_exec:s0
+
+# RadioConfig HAL
+/(vendor|system/vendor)/bin/hw/android\.hardware\.radio\.config@1\.1-service\.wrapper   u:object_r:hal_radio_config_default_exec:s0
+
 # USB HAL
 /(vendor|system/vendor)/bin/hw/android\.hardware\.usb@1\.3-service\.basic u:object_r:hal_usb_default_exec:s0
 /(vendor|system/vendor)/bin/hw/android\.hardware\.usb@1\.1-service\.typec u:object_r:hal_usb_default_exec:s0
@@ -20,6 +23,3 @@
 
 # Vibrator HAL
 /(vendor|system/vendor)/bin/hw/android\.hardware\.vibrator@1\.0-service\.lineage u:object_r:hal_vibrator_default_exec:s0
-
-# Wi-Fi HAL
-/(vendor|system/vendor)/bin/hw/android\.hardware\.wifi@1\.0-service\.legacy u:object_r:hal_wifi_default_exec:s0
diff --git a/common/vendor/hal_radio_config_default.te b/common/vendor/hal_radio_config_default.te
new file mode 100644
index 0000000..dc9f8f9
--- /dev/null
+++ b/common/vendor/hal_radio_config_default.te
@@ -0,0 +1 @@
+allow hal_radio_config_default hal_lineage_backend_radio_config_hwservice:hwservice_manager find;
diff --git a/common/vendor/hwservice.te b/common/vendor/hwservice.te
new file mode 100644
index 0000000..791f7f4
--- /dev/null
+++ b/common/vendor/hwservice.te
@@ -0,0 +1 @@
+type hal_lineage_backend_radio_config_hwservice, hwservice_manager_type;
diff --git a/common/vendor/hwservice_contexts b/common/vendor/hwservice_contexts
new file mode 100644
index 0000000..492a808
--- /dev/null
+++ b/common/vendor/hwservice_contexts
@@ -0,0 +1,2 @@
+# The following hwservices are supposed to be registered by blobs through hexedit; Keep string length the same.
+lineage.hardware.radio.config::IRadioConfig                             u:object_r:hal_lineage_backend_radio_config_hwservice:s0
diff --git a/common/vendor/rild.te b/common/vendor/rild.te
new file mode 100644
index 0000000..50e5b8d
--- /dev/null
+++ b/common/vendor/rild.te
@@ -0,0 +1 @@
+add_hwservice(rild, hal_lineage_backend_radio_config_hwservice)
diff --git a/common/vendor/vendor_init.te b/common/vendor/vendor_init.te
index 3c8b31f..1514e94 100644
--- a/common/vendor/vendor_init.te
+++ b/common/vendor/vendor_init.te
@@ -1,2 +1,5 @@
 # FM Radio app properties
 set_prop(vendor_init, vendor_fm_radio_app_prop);
+
+# To write to VM nodes
+allow vendor_init proc_dirty:file w_file_perms;
diff --git a/libperfmgr/sepolicy.mk b/libperfmgr/sepolicy.mk
new file mode 100644
index 0000000..46a7497
--- /dev/null
+++ b/libperfmgr/sepolicy.mk
@@ -0,0 +1,2 @@
+BOARD_VENDOR_SEPOLICY_DIRS += \
+    device/lineage/sepolicy/libperfmgr/vendor
diff --git a/libperfmgr/vendor/hal_power_default.te b/libperfmgr/vendor/hal_power_default.te
new file mode 100644
index 0000000..3169237
--- /dev/null
+++ b/libperfmgr/vendor/hal_power_default.te
@@ -0,0 +1,7 @@
+# To do powerhint on nodes defined in powerhint.json
+allow hal_power_default cgroup:dir search;
+allow hal_power_default cgroup:file rw_file_perms;
+allow hal_power_default sysfs_devices_system_cpu:file rw_file_perms;
+
+# To get/set powerhal state property
+set_prop(hal_power_default, vendor_power_prop)
diff --git a/libperfmgr/vendor/property.te b/libperfmgr/vendor/property.te
new file mode 100644
index 0000000..df317c6
--- /dev/null
+++ b/libperfmgr/vendor/property.te
@@ -0,0 +1,2 @@
+# Power HAL
+vendor_public_prop(vendor_power_prop);
diff --git a/libperfmgr/vendor/property_contexts b/libperfmgr/vendor/property_contexts
new file mode 100644
index 0000000..e37ced2
--- /dev/null
+++ b/libperfmgr/vendor/property_contexts
@@ -0,0 +1,2 @@
+# Power HAL
+vendor.powerhal.                   u:object_r:vendor_power_prop:s0
diff --git a/libperfmgr/vendor/vendor_init.te b/libperfmgr/vendor/vendor_init.te
new file mode 100644
index 0000000..f48eff3
--- /dev/null
+++ b/libperfmgr/vendor/vendor_init.te
@@ -0,0 +1,2 @@
+# To set powerhal init property
+set_prop(vendor_init, vendor_power_prop)
diff --git a/qcom/sepolicy.mk b/qcom/sepolicy.mk
index 0398957..def1dd1 100644
--- a/qcom/sepolicy.mk
+++ b/qcom/sepolicy.mk
@@ -32,7 +32,10 @@
     persist_block_device=vendor_persist_block_device \
     qdisplay_service=vendor_qdisplay_service \
     sysfs_battery_supply=vendor_sysfs_battery_supply \
+    sysfs_devfreq=vendor_sysfs_devfreq \
     sysfs_graphics=vendor_sysfs_graphics \
+    sysfs_kgsl=vendor_sysfs_kgsl \
+    sysfs_scsi_host=vendor_sysfs_scsi_host \
     sysfs_socinfo_sensitive=vendor_sysfs_soc_sensitive \
     sysfs_usb_supply=vendor_sysfs_usb_supply
 else
diff --git a/qcom/vendor/file_contexts b/qcom/vendor/file_contexts
index faa5923..27ddd39 100644
--- a/qcom/vendor/file_contexts
+++ b/qcom/vendor/file_contexts
@@ -8,4 +8,5 @@
 # Power
 /(vendor|system/vendor)/bin/hw/android\.hardware\.power-service-qti               u:object_r:hal_power_default_exec:s0
 /sys/devices(/platform)?/soc/[a-f0-9]+.qcom,mdss_mdp/idle_state                   u:object_r:sysfs_graphics:s0
+/sys/devices(/platform)?/soc/[a-f0-9]+.ufshc/clkgate_enable                       u:object_r:sysfs_scsi_host:s0
 /sys/devices/virtual/graphics/fb([0-3])+/idle_state                               u:object_r:sysfs_graphics:s0
diff --git a/qcom/vendor/fm_app.te b/qcom/vendor/fm_app.te
new file mode 100644
index 0000000..c37e8f5
--- /dev/null
+++ b/qcom/vendor/fm_app.te
@@ -0,0 +1 @@
+get_prop(vendor_fm_app, vendor_fm_radio_app_prop)
diff --git a/qcom/vendor/genfs_contexts b/qcom/vendor/genfs_contexts
index 0e1f3a5..2bacfe8 100644
--- a/qcom/vendor/genfs_contexts
+++ b/qcom/vendor/genfs_contexts
@@ -1 +1,2 @@
+genfscon proc /sys/kernel/sched_energy_aware             u:object_r:proc_sched:s0
 genfscon sysfs /devices/soc0/serial_number               u:object_r:sysfs_socinfo_sensitive:s0
diff --git a/qcom/vendor/hal_power_default.te b/qcom/vendor/hal_power_default.te
index 6fd6b4b..969819c 100644
--- a/qcom/vendor/hal_power_default.te
+++ b/qcom/vendor/hal_power_default.te
@@ -1 +1,6 @@
-r_dir_file(hal_power_default, sysfs_graphics)
+# To do powerhint on nodes defined in powerhint.json
+rw_dir_file(hal_power_default, proc_sched)
+rw_dir_file(hal_power_default, sysfs_devfreq)
+rw_dir_file(hal_power_default, sysfs_graphics)
+rw_dir_file(hal_power_default, sysfs_kgsl)
+rw_dir_file(hal_power_default, sysfs_scsi_host)