Allow installd to delete directories in staging dir

In order to support deleting session files after a staged session reaches
a final state, installd will need to delete the session directories from
/data/staging.

Bug: 123624108
Test: triggered 2 flows in which a staged session reaches a final state
and made sure installd can delete the session files

Change-Id: I76a7d4252d1e033791f67f268cf941672c5e6a3a
diff --git a/private/domain.te b/private/domain.te
index 8b502f3..5ca2441 100644
--- a/private/domain.te
+++ b/private/domain.te
@@ -154,9 +154,9 @@
 # that these files cannot be accessed by other domains to ensure that the files
 # do not change between system_server staging the files and apexd processing
 # the files.
-neverallow { domain -init -system_server -apexd } staging_data_file:dir *;
-neverallow { domain -init -system_server -apexd -kernel } staging_data_file:file *;
-neverallow { domain -init -system_server } staging_data_file:dir no_w_dir_perms;
+neverallow { domain -init -system_server -apexd -installd} staging_data_file:dir *;
+neverallow { domain -init -system_server -apexd -kernel -installd } staging_data_file:file *;
+neverallow { domain -init -system_server -installd} staging_data_file:dir no_w_dir_perms;
 # apexd needs the link and unlink permissions, so list every `no_w_file_perms`
 # except for `link` and `unlink`.
 neverallow { domain -init -system_server } staging_data_file:file
diff --git a/private/installd.te b/private/installd.te
index 77889a3..0550274 100644
--- a/private/installd.te
+++ b/private/installd.te
@@ -34,3 +34,8 @@
 
 # Allow installd to access the runtime feature flag properties.
 get_prop(installd, device_config_runtime_native_prop)
+
+# Allow installd to delete files in /data/staging
+allow installd staging_data_file:file unlink;
+allow installd staging_data_file:dir { open read remove_name rmdir search write };
+