Allow GoogleBattery HAL AIDL to run on pixel devices
Bug: 232461104
Test: Ensure Adaptive Charging/Battery health flags works as expected
Ignore-AOSP-First: GoogleBattery AIDL changes can only be merged in master
Change-Id: I25b50a5df368f50e9b888eeef4b9a7493e795ccf
diff --git a/googlebattery/dumpstate.te b/googlebattery/dumpstate.te
new file mode 100644
index 0000000..b84095c
--- /dev/null
+++ b/googlebattery/dumpstate.te
@@ -0,0 +1,6 @@
+userdebug_or_eng(`
+ # To find and bind Google Battery HAL
+ allow dumpstate hal_googlebattery_service:service_manager find;
+ binder_call(dumpstate, hal_googlebattery)
+')
+
diff --git a/googlebattery/file_contexts b/googlebattery/file_contexts
index 9e247bb..efd6cc5 100644
--- a/googlebattery/file_contexts
+++ b/googlebattery/file_contexts
@@ -1 +1 @@
-/vendor/bin/hw/vendor\.google\.google_battery@1\.2-service-vendor u:object_r:hal_googlebattery_exec:s0
+/vendor/bin/hw/vendor\.google\.google_battery-service u:object_r:hal_googlebattery_exec:s0
diff --git a/googlebattery/hal_googlebattery.te b/googlebattery/hal_googlebattery.te
index cd1253b..7c6ccf8 100644
--- a/googlebattery/hal_googlebattery.te
+++ b/googlebattery/hal_googlebattery.te
@@ -13,6 +13,5 @@
set_prop(hal_googlebattery, vendor_battery_defender_prop)
-hwbinder_use(hal_googlebattery)
-add_hwservice(hal_googlebattery, hal_googlebattery_hwservice)
-get_prop(hal_googlebattery, hwservicemanager_prop)
+binder_call(hal_googlebattery, servicemanager)
+add_service(hal_googlebattery, hal_googlebattery_service)
diff --git a/googlebattery/hwservice.te b/googlebattery/hwservice.te
deleted file mode 100644
index 40323ef..0000000
--- a/googlebattery/hwservice.te
+++ /dev/null
@@ -1 +0,0 @@
-type hal_googlebattery_hwservice, hwservice_manager_type;
diff --git a/googlebattery/hwservice_contexts b/googlebattery/hwservice_contexts
deleted file mode 100644
index 40f1526..0000000
--- a/googlebattery/hwservice_contexts
+++ /dev/null
@@ -1 +0,0 @@
-vendor.google.google_battery::IGoogleBattery u:object_r:hal_googlebattery_hwservice:s0
diff --git a/googlebattery/platform_app.te b/googlebattery/platform_app.te
index 0ee586f..39d4e5e 100644
--- a/googlebattery/platform_app.te
+++ b/googlebattery/platform_app.te
@@ -1,3 +1,3 @@
# allow SystemUI to find and bind Google Battery HAL
-allow platform_app hal_googlebattery_hwservice:hwservice_manager find;
+allow platform_app hal_googlebattery_service:service_manager find;
binder_call(platform_app, hal_googlebattery)
diff --git a/googlebattery/service.te b/googlebattery/service.te
new file mode 100644
index 0000000..c363681
--- /dev/null
+++ b/googlebattery/service.te
@@ -0,0 +1 @@
+type hal_googlebattery_service, vendor_service, service_manager_type;
diff --git a/googlebattery/service_contexts b/googlebattery/service_contexts
new file mode 100644
index 0000000..93954c7
--- /dev/null
+++ b/googlebattery/service_contexts
@@ -0,0 +1 @@
+vendor.google.google_battery.IGoogleBattery/default u:object_r:hal_googlebattery_service:s0
diff --git a/googlebattery/system_app.te b/googlebattery/system_app.te
index 05723bf..7854a1d 100644
--- a/googlebattery/system_app.te
+++ b/googlebattery/system_app.te
@@ -1,3 +1,3 @@
# To allow Settings to find and bind Google Battery HAL
-allow system_app hal_googlebattery_hwservice:hwservice_manager find;
+allow system_app hal_googlebattery_service:service_manager find;
binder_call(system_app, hal_googlebattery)
diff --git a/googlebattery/turbo_adapter.te b/googlebattery/turbo_adapter.te
index 33f99cd..2794fd1 100644
--- a/googlebattery/turbo_adapter.te
+++ b/googlebattery/turbo_adapter.te
@@ -1,3 +1,3 @@
# To find and bind Google Battery HAL
-allow turbo_adapter hal_googlebattery_hwservice:hwservice_manager find;
+allow turbo_adapter hal_googlebattery_service:service_manager find;
binder_call(turbo_adapter, hal_googlebattery)