type catlog, domain;
type catlog_exec, exec_type, file_type;
allow init catlog_exec:file { execute getattr read open };
allow init catlog:process { transition };
allow init catlog:process { rlimitinh siginh noatsecure };
allow catlog kernel:system { syslog_mod };
allow catlog catlog:capability { dac_override sys_nice };
allow catlog catlog:capability2 { syslog };
allow catlog catlog_exec:file { execute entrypoint read open };
allow catlog shell_exec:file { getattr read };
allow catlog rootfs:lnk_file { getattr };
allow catlog proc:file { write open read };
allow catlog tmpfs:lnk_file { read };
allow catlog storage_file:dir { search };
allow catlog storage_file:lnk_file { read };
allow catlog mnt_user_file:dir { search };
allow catlog mnt_user_file:lnk_file { read };
allow catlog fuse:dir { search getattr create write read open add_name rename remove_name };
allow catlog fuse:file { getattr create write open rename append };
allow catlog toolbox_exec:file { execute read open getattr execute_no_trans };
allow catlog logdr_socket:sock_file { write };
allow catlog logd:unix_stream_socket { connectto };
allow catlog logcat_exec:file { execute read open execute_no_trans getattr };
2.添加cat_log.sh脚本
#!/system/bin/sh
在init.方案.rc下加入如下语句
service catlog /system/bin/busybox sh /system/bin/cat_log.sh
d
《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整资料开源分享
isabled
oneshot
on property:sys.boot_completed=1
start catlog
function enable_log()
{
LOG_FILE="/data/tool.log"
exec 2>> $LOG_FILE
exec 1>> $LOG_FILE
echo “----------------------------------”
echo “para: $*”
}
enable_log $* ; set -x
echo 1 > /proc/sys/kernel/panic
#命名文件夹名字e5_log,也可以自己更改
ENABLE_LOG_FILE="/mnt/sdcard/.enable_logsave"
LOG_DIR="/mnt/sdcard/LOGSAVE"
LAST_LOG_DIR="/mnt/sdcard/LOGSAVE/last"
SAVE_LOG_COUNT=5 # 保存上5次的log,值最小为1;例为5,则last.1为最后一次重启前的log;last.5为最老的log
#echo “save last_time ${SAVE_LOG_COUNT} log”
#if [ ! -f “$ENABLE_LOG_FILE” ];then
echo “disable logsave”
exit
#fi
#echo “enable logsave”
if [ ! -d “$LOG_DIR” ];then
mkdir $LOG_DIR
fi
if [ -d “ L A S T L O G D I R . LAST_LOG_DIR. LASTLOGDIR.SAVE_LOG_COUNT” ];then
rm -r “ L A S T L O G D I R . LAST_LOG_DIR. LAST