Android 7,apk瘦身工具

本文介绍了如何在Android 7中实现apk瘦身,并提供了cat_log.sh脚本的添加和使用方法,该脚本用于在设备启动时收集系统日志。通过修改init方案rc文件和服务配置,实现日志保存到外部存储,并限制保存数量,便于分析和调试。同时,文章提及了Android学习资料与面试指导。
摘要由CSDN通过智能技术生成

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值