Mark all clients of Allocator HAL
This change associates all domains which are clients of Allocator HAL
with hal_allocator_client and the, required for all HAL client
domains, halclientdomain.
This enables this commit to remove the now unnecessary hwallocator_use
macro because its binder_call(..., hal_allocator_server) is covered by
binder_call(hal_allocator_client, hal_allocator_server) added in this
commit.
Unfortunately apps, except isolated app, are clients of Allocator HAL
as well. This makes it hard to use the hal_client_domain(...,
hal_allocator) macro because it translates into "typeattribute" which
currently does not support being provided with a set of types, such as
{ appdomain -isolated_app }. As a workaround, hopefully until
typeattribute is improved, this commit expresses the necessary
association operation in CIL. private/technical_debt.cil introduced by
this commit is appended into the platform policy CIL file, thus
ensuring that the hack has effect on the final monolithic policy.
P. S. This change also removes Allocator HAL access from isolated_app.
Isolated app shouldn't have access to this HAL anyway.
Test: Google Play Music plays back radios
Test: Google Camera records video with sound and that video is then
successfully played back with sound
Test: YouTube app plays back clips with sound
Test: YouTube in Chrome plays back clips with sound
Bug: 34170079
Change-Id: Id00bba6fde83e7cf04fb58bc1c353c2f66333f92
diff --git a/private/app.te b/private/app.te
index c5943dd..81de403 100644
--- a/private/app.te
+++ b/private/app.te
@@ -155,7 +155,6 @@
# hidl access for mediacodec
# TODO(b/34454312): only allow getting and talking to mediacodec service
hwbinder_use(appdomain)
-hwallocator_use(appdomain)
# Already connected, unnamed sockets being passed over some other IPC
# hence no sock_file or connectto permission. This appears to be how
diff --git a/private/audioserver.te b/private/audioserver.te
index a6253f2..61ccefc 100644
--- a/private/audioserver.te
+++ b/private/audioserver.te
@@ -12,10 +12,9 @@
binder_call(audioserver, appdomain)
binder_service(audioserver)
+hal_client_domain(audioserver, hal_allocator)
hal_client_domain(audioserver, hal_audio)
-allow audioserver system_file:dir r_dir_perms;
-
userdebug_or_eng(`
# used for TEE sink - pcm capture for debug.
allow audioserver media_data_file:dir create_dir_perms;
diff --git a/private/system_server.te b/private/system_server.te
index da1c625..af1e918 100644
--- a/private/system_server.te
+++ b/private/system_server.te
@@ -168,7 +168,7 @@
# Perform HwBinder IPC.
hwbinder_use(system_server)
-hwallocator_use(system_server)
+hal_client_domain(system_server, hal_allocator)
binder_call(system_server, hal_contexthub)
hal_client_domain(system_server, hal_contexthub)
hal_client_domain(system_server, hal_fingerprint)
diff --git a/private/technical_debt.cil b/private/technical_debt.cil
new file mode 100644
index 0000000..2d9ec8b
--- /dev/null
+++ b/private/technical_debt.cil
@@ -0,0 +1,13 @@
+; THIS IS A WORKAROUND for the current limitations of the module policy language
+; This should be used sparingly until we figure out a saner way to achieve the
+; stuff below, for example, by improving typeattribute statement of module
+; language.
+;
+; NOTE: This file has no effect on recovery policy.
+
+; Apps, except isolated apps, are clients of Allocator HAL
+; Unfortunately, we can't currently express this in module policy language:
+; typeattribute { appdomain -isolated_app } hal_allocator_client;
+; typeattribute hal_allocator_client halclientdomain;
+(typeattributeset hal_allocator_client ((and (appdomain) ((not (isolated_app))))))
+(typeattributeset halclientdomain (hal_allocator_client))