- device mk脚本中添加logcatd默认配置
device/qcom/sdm845/sdm845.mk
+PRODUCT_PACKAGES += logcatd
----------------------------------------------------------------
PRODUCT_PROPERTY_OVERRIDES
PRODUCT_DEFAULT_PROPERTY_OVERRUDES += \
persist.logd.logpersisted=logcatd \
persist.logd.logpersisted.size=40 \
persist.logd.logpersisted.buffer=main,system,crash
配置使用logcatd服务保存日志,最多保存40+1个文件,同时抓取main,system,crash缓冲区的数据至文件。
- system/core/logcat/Android.mk中修改eng版本也编译logcatd
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := optional
- system/core/logcat/logcat.cpp日志文件创建时新增log组用户可以读
- return open(pathname, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
+ return open(pathname, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP);
- system/core/logcat/logcatd.rc
on property:logd.logpersistd.enable=true && property:logd.logpersistd=logcatd
# all exec/services are called with umask(077), so no gain beyond 0700
mkdir /data/misc/logd 0777 root shell --->root shell
chmod 0777 /data/misc/logd/ --->root shell
start logcatd
- system/core/logcat/logcat_main.cpp
+#include <sys/stat.h>
+#include <sys/types.h>
int main(int argc, char** argv, char** envp) {
+ umask(000);//修改用户组文件默认权限
android_logcat_context ctx = create_android_logcat();
下面主要考虑user 版本
type xxx_logcat, domain;
type xxx_logcat_exec, exec_type, file_type, vendor_file_type;
init_daemon_domain(xxx_logcat)
not_full_treble(`allow xxx_logcat shell_exec:file rx_file_perms;')
full_treble_only(`allow xxx_logcat vendor_shell_exec:file rx_file_perms;')
原文链接:https://blog.csdn.net/shusuanly/article/details/80577306
网友评论