logcatd: add stop and clear actions

(cherry pick from commit cd5118bf1edc257cfd4ff02ea1145b5d7b3153d9)

- add stop and clear (and stop) actions to logcatd.rc
- use stop and clear actions in logpersist script

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Id05118fb51e40609fd7b3a934cf9302f67ef6d1d
diff --git a/logcat/logcatd.rc b/logcat/logcatd.rc
index 70d1dd4..7d70dd9 100644
--- a/logcat/logcatd.rc
+++ b/logcat/logcatd.rc
@@ -5,6 +5,16 @@
     exec - logd log -- /system/bin/logcat -L -b ${persist.logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 1024 -n ${persist.logd.logpersistd.size:-256}
     start logcatd
 
+on property:persist.logd.logpersistd=clear
+    stop logcatd
+    # logd for clear of only our files in /data/misc/logd
+    exec - logd log -- /system/bin/logcat -c -f /data/misc/logd/logcat -n ${persist.logd.logpersistd.size:-256}
+    setprop persist.logd.logpersistd ""
+
+on property:persist.logd.logpersistd=stop
+    stop logcatd
+    setprop persist.logd.logpersistd ""
+
 service logcatd /system/bin/logcat -b ${persist.logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 1024 -n ${persist.logd.logpersistd.size:-256}
     class late_start
     disabled