iorap: Change the init config of iorapd.

Only start iorapd when either prefetching or tracing is enabled.

Bug: 176037717
Test: atest CtsStagedInstallHostTestCases:
com.android.tests.stagedinstall.host.StagedInstallTest#testInstallStagedApexAndApk

Change-Id: Iea419aa40124e79595d4f4da35c4856a9fdc9608
diff --git a/iorapd.rc b/iorapd.rc
index c9f8e0b..cb887ac 100644
--- a/iorapd.rc
+++ b/iorapd.rc
@@ -14,11 +14,11 @@
 
 service iorapd /system/bin/iorapd
     class main
+    disabled
     user iorapd
     group iorapd
     capabilities DAC_READ_SEARCH
     writepid /dev/cpuset/system-background/tasks
-    oneshot
 # TODO: should this be something else like performance/tasks?
 # the main 'activity hint' thread needs to be fairly high priority to kick off
 # tracing or prefetching asap.
@@ -29,3 +29,10 @@
 on post-fs-data
     # Create directory for iorapd (see iorapd_data_file in selinux file_contexts).
     mkdir /data/misc/iorapd/ 0750 iorapd system
+
+# Start iorapd when either prefetching or tracing is enabled.
+on property:persist.device_config.runtime_native_boot.iorap_perfetto_enable=true && property:ro.iorapd.enable=true
+    start iorapd
+
+on property:persist.device_config.runtime_native_boot.iorap_readahead_enable=true && property:ro.iorapd.enable=true
+    start iorapd