common: Add sepolicy rules for Lineage Health HAL and service

Change-Id: I436aa3e23c765d09c6cb220524fb821c66b40065
diff --git a/common/dynamic/hal_lineage_health.te b/common/dynamic/hal_lineage_health.te
new file mode 100644
index 0000000..3ba6b68
--- /dev/null
+++ b/common/dynamic/hal_lineage_health.te
@@ -0,0 +1,5 @@
+# HwBinder IPC from client to server
+binder_call(hal_lineage_health_client, hal_lineage_health_server)
+
+add_service(hal_lineage_health_server, hal_lineage_health_service)
+allow hal_lineage_health_client hal_lineage_health_service:service_manager find;
diff --git a/common/dynamic/service.te b/common/dynamic/service.te
new file mode 100644
index 0000000..1016a18
--- /dev/null
+++ b/common/dynamic/service.te
@@ -0,0 +1 @@
+type hal_lineage_health_service, vendor_service, hal_service_type, service_manager_type;
diff --git a/common/dynamic/service_contexts b/common/dynamic/service_contexts
new file mode 100644
index 0000000..9d0d2a6
--- /dev/null
+++ b/common/dynamic/service_contexts
@@ -0,0 +1 @@
+vendor.lineage.health.IChargingControl/default        u:object_r:hal_lineage_health_service:s0
diff --git a/common/private/service.te b/common/private/service.te
index 053d448..86f6e4c 100644
--- a/common/private/service.te
+++ b/common/private/service.te
@@ -1,5 +1,6 @@
 type adbroot_service,                   service_manager_type;
 type lineage_hardware_service, system_api_service, system_server_service, service_manager_type;
+type lineage_health_interface_service, system_api_service, system_server_service, service_manager_type;
 type lineage_globalactions_service, system_api_service, system_server_service, service_manager_type;
 type lineage_livedisplay_service, system_api_service, system_server_service, service_manager_type;
 type lineage_profile_service, system_api_service, system_server_service, service_manager_type;
diff --git a/common/private/service_contexts b/common/private/service_contexts
index 633c6ac..cd984cb 100644
--- a/common/private/service_contexts
+++ b/common/private/service_contexts
@@ -1,5 +1,6 @@
 lineageglobalactions                      u:object_r:lineage_globalactions_service:s0
 lineagehardware                           u:object_r:lineage_hardware_service:s0
+lineagehealth                             u:object_r:lineage_health_interface_service:s0
 lineagelivedisplay                        u:object_r:lineage_livedisplay_service:s0
 lineagetrust                              u:object_r:lineage_trust_service:s0
 profile                                   u:object_r:lineage_profile_service:s0
diff --git a/common/private/system_server.te b/common/private/system_server.te
index 84c9185..e396fa5 100644
--- a/common/private/system_server.te
+++ b/common/private/system_server.te
@@ -4,6 +4,7 @@
 
 # Use HALs
 hal_client_domain(system_server, hal_lineage_fastcharge)
+hal_client_domain(system_server, hal_lineage_health)
 hal_client_domain(system_server, hal_lineage_livedisplay)
 hal_client_domain(system_server, hal_lineage_touch)
 hal_client_domain(system_server, hal_lineage_trust)
diff --git a/common/public/attributes b/common/public/attributes
index 76a373d..8a98193 100644
--- a/common/public/attributes
+++ b/common/public/attributes
@@ -1,6 +1,7 @@
 # HALs
 hal_attribute_lineage(lineage_camera_motor)
 hal_attribute_lineage(lineage_fastcharge)
+hal_attribute_lineage(lineage_health)
 hal_attribute_lineage(lineage_livedisplay)
 hal_attribute_lineage(lineage_touch)
 hal_attribute_lineage(lineage_trust)
diff --git a/common/vendor/file_contexts b/common/vendor/file_contexts
index 0565b00..fd4174d 100644
--- a/common/vendor/file_contexts
+++ b/common/vendor/file_contexts
@@ -4,6 +4,9 @@
 # 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
+
 # Light HAL
 /(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service\.aw2013 u:object_r:hal_light_default_exec:s0
 
diff --git a/common/vendor/hal_lineage_health_default.te b/common/vendor/hal_lineage_health_default.te
new file mode 100644
index 0000000..243a1ac
--- /dev/null
+++ b/common/vendor/hal_lineage_health_default.te
@@ -0,0 +1,7 @@
+type hal_lineage_health_default, domain;
+hal_server_domain(hal_lineage_health_default, hal_lineage_health)
+
+type hal_lineage_health_default_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(hal_lineage_health_default)
+
+binder_call(hal_lineage_health_default, servicemanager);
diff --git a/qcom/vendor/hal_lineage_health_default.te b/qcom/vendor/hal_lineage_health_default.te
new file mode 100644
index 0000000..26de236
--- /dev/null
+++ b/qcom/vendor/hal_lineage_health_default.te
@@ -0,0 +1,2 @@
+rw_dir_file(hal_lineage_health_default, sysfs_battery_supply)
+rw_dir_file(hal_lineage_health_default, sysfs_usb_supply)