From b9aa010089a0ac75c694c8abf956a2b77ef9c59c Mon Sep 17 00:00:00 2001
From: Yifan Hong <elsk@google.com>
Date: Mon, 25 Sep 2017 19:40:59 -0700
Subject: [PATCH] healthd provides health@2.0 service.

* remove binder calls to healthd (storaged, system_server)
* Allow healthd to serve health HAL

Bug: 62229583
Test: no health related denials
Test: VTS health test
Test: BatteryManagerTest

Change-Id: I0cf1872c0ba69e7de7c3f529d548f9ffe39812ac
---
 private/healthd.te  | 4 ++--
 private/storaged.te | 4 +---
 public/healthd.te   | 5 -----
 3 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/private/healthd.te b/private/healthd.te
index 0693a3a68..20d079173 100644
--- a/private/healthd.te
+++ b/private/healthd.te
@@ -2,5 +2,5 @@ typeattribute healthd coredomain;
 
 init_daemon_domain(healthd)
 
-# Allow callback to storaged batteryproperties listener
-binder_call(healthd, storaged)
+# Allow healthd to serve health HAL
+hal_server_domain(healthd, hal_health)
diff --git a/private/storaged.te b/private/storaged.te
index 8da1f26d8..96d59d978 100644
--- a/private/storaged.te
+++ b/private/storaged.te
@@ -40,9 +40,7 @@ add_service(storaged, storaged_service)
 binder_use(storaged)
 binder_call(storaged, system_server)
 
-# use batteryproperties service
-allow storaged batteryproperties_service:service_manager find;
-binder_call(storaged, healthd)
+hal_client_domain(storaged, hal_health)
 
 # Implements a dumpsys interface.
 allow storaged dumpstate:fd use;
diff --git a/public/healthd.te b/public/healthd.te
index c0a7bec7b..7f99c9f7d 100644
--- a/public/healthd.te
+++ b/public/healthd.te
@@ -21,9 +21,6 @@ allow healthd self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
 
 wakelock_use(healthd)
 
-binder_use(healthd)
-binder_service(healthd)
-binder_call(healthd, system_server)
 hal_client_domain(healthd, hal_health)
 
 # Write to state file.
@@ -56,8 +53,6 @@ allow healthd ashmem_device:chr_file execute;
 allow healthd self:process execmem;
 allow healthd proc_sysrq:file rw_file_perms;
 
-add_service(healthd, batteryproperties_service)
-
 # Healthd needs to tell init to continue the boot
 # process when running in charger mode.
 set_prop(healthd, system_prop)
-- 
GitLab