Automation: Enable mobile data

Issue: FP3-A11#130
Change-Id: I21001701b0b8073c7f2131668b95fcc923e44555
diff --git a/automation_setup/automation_setup.sh b/automation_setup/automation_setup.sh
index 744d4ef..4b80fae 100644
--- a/automation_setup/automation_setup.sh
+++ b/automation_setup/automation_setup.sh
@@ -32,4 +32,13 @@
 # Remove trigger so we don't run again
 rm -v /data/userdata_automation/trigger
 
+echo >&2 "+++ AUTOMATION: Waiting for late boot trigger. +++"
+while [ "$(getprop sys.boot_completed)" != "1" ]; do
+    # Full boot can take a while, especially after factory reset.
+    sleep 2
+done
+
+# Enable mobile data. Requires service `phone` to be running.
+svc data enable
+
 echo >&2 "+++ TRIGGERING AUTOMATION SETUP FOR ATS DONE +++"
diff --git a/sepolicy/vendor/automation_setup/automation_setup.te b/sepolicy/vendor/automation_setup/automation_setup.te
index 0590763..1e127a3 100644
--- a/sepolicy/vendor/automation_setup/automation_setup.te
+++ b/sepolicy/vendor/automation_setup/automation_setup.te
@@ -22,6 +22,11 @@
 allow automation_setup adb_keys_file:dir rw_dir_perms;
 allow automation_setup adb_keys_file:file create_file_perms;
 
+# Allow enabling mobile data
+allow automation_setup radio_service:service_manager find;
+binder_call(automation_setup, radio)
+binder_call(radio, automation_setup)
+
 # Allow cmd settings put
 allow automation_setup settings_service:service_manager find;
 binder_call(automation_setup, servicemanager)
diff --git a/sepolicy/vendor/automation_setup/radio.te b/sepolicy/vendor/automation_setup/radio.te
new file mode 100644
index 0000000..c5b2026
--- /dev/null
+++ b/sepolicy/vendor/automation_setup/radio.te
@@ -0,0 +1,10 @@
+#
+# Copyright 2021-2022 Fairphone B.V.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+# automation_setup is logging errors to kmsg via stdio_to_kmsg. It's calling
+# system services that get their stderr redirected to kmsg as well. These
+# service calls would fail if they don't have write access kmsg.
+allow radio kmsg_debug_device:chr_file { ioctl open getattr append write };