Allow to start secondary heapprofd.

This is useful for profiling heapprofd itself on rooted phones.

Change-Id: I6e1854dbaa0f67d854582c2d4e41cbb529987c12
diff --git a/heapprofd.rc b/heapprofd.rc
index dd96325..bf313b1 100644
--- a/heapprofd.rc
+++ b/heapprofd.rc
@@ -25,6 +25,21 @@
     # permission is userdebug_or_eng only.
     capabilities KILL DAC_READ_SEARCH
 
+# Allow to start a second heapprofd. We can use that one to profile the
+# primary one. See src/memory/profiling/README.md.
+service heapprofd_secondary /system/bin/heapprofd
+    disabled
+    oneshot
+    socket heapprofd stream 0666 root root
+    user nobody
+    group nobody readproc
+    # By default, this  daemon is idle. When profiling an app, we should unwind
+    # as fast as possible in the interest of the app being profiled.
+    writepid /dev/cpuset/foreground/tasks
+    # DAC_READ_SEARCH is denied by SELinux on user builds because the SELinux
+    # permission is userdebug_or_eng only.
+    capabilities KILL DAC_READ_SEARCH
+
 on property:persist.heapprofd.enable=1
     start heapprofd