logcatd: add stop and clear actions
- add stop and clear (and stop) actions to logcatd.rc
- use stop and clear actions in logpersist script
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
diff --git a/logcat/logpersist b/logcat/logpersist
index c0aa9ea..d1eda37 100755
--- a/logcat/logpersist
+++ b/logcat/logpersist
@@ -73,10 +73,7 @@
current_size="`getprop ${property}.size`"
if [ "${service}" = "`getprop ${property}`" ]; then
if [ "true" = "${clear}" ]; then
- su root stop ${service}
- setprop ${property} ""
- # 20ms done, guarantees content stop before rm
- sleep 1
+ setprop ${property} "clear"
elif [ "${buffer}|${size}" != "${current_buffer}|${current_size}" ]; then
echo "ERROR: Changing existing collection parameters from" >&2
if [ "${buffer}" != "${current_buffer}" ]; then
@@ -98,9 +95,8 @@
echo " To blindly override and retain data, ${progname%.*}.stop first." >&2
exit 1
fi
- fi
- if [ "true" = "${clear}" ]; then
- su logd,misc rm -rf "${data}"
+ elif [ "true" = "${clear}" ]; then
+ setprop ${property} "clear"
fi
if [ -n "${buffer}${current_buffer}" ]; then
setprop ${property}.buffer "${buffer}"
@@ -108,6 +104,9 @@
if [ -n "${size}${current_size}" ]; then
setprop ${property}.size "${size}"
fi
+ while [ "clear" = "`getprop ${property}`" ]; do
+ continue
+ done
# ${service}.rc does the heavy lifting with the following trigger
setprop ${property} ${service}
getprop ${property}
@@ -120,19 +119,20 @@
if [ -n "${size}${buffer}" ]; then
echo "WARNING: Can not use --size or --buffer with ${progname%.*}.stop" >&2
fi
- su root stop ${service}
- setprop ${property} ""
+ if [ "true" = "${clear}" ]; then
+ setprop ${property} "clear"
+ else
+ setprop ${property} "stop"
+ fi
if [ -n "`getprop ${property}.buffer`" ]; then
setprop ${property}.buffer ""
fi
if [ -n "`getprop ${property}.size`" ]; then
setprop ${property}.size ""
fi
- if [ "true" = "${clear}" ]; then
- # 20ms done, guarantees content stop before rm
- sleep 1
- su logd,misc rm -rf "${data}"
- fi
+ while [ "clear" = "`getprop ${property}`" ]; do
+ continue
+ done
;;
*)
echo "ERROR: Unexpected command ${0##*/} ${args}" >&2