静安做网站的公司,app推广方案,室内设计效果图的网站,信息化项目建设背景项目需要在android user版本增加手动触发dump方法#xff0c;用以确认user版本发生dump后系统是重启还是真正发生dump卡机#xff01; 本文以qcom平台项目为例描述所做的修改#xff0c;留下足迹以备后忘。
闲言少叙#xff0c;开整上干货#xff1a;
一、修改bin文件 …项目需要在android user版本增加手动触发dump方法用以确认user版本发生dump后系统是重启还是真正发生dump卡机 本文以qcom平台项目为例描述所做的修改留下足迹以备后忘。
闲言少叙开整上干货
一、修改bin文件 本文以qcom 平台./vendor/bin/test_diag 为例 文件路径 android/vendor/qcom/proprietary/diag/test/Android.mk android/vendor/qcom/proprietary/diag/test/test_diag.c 修改内容 Android.mk LOCAL_SHARED_LIBRARIES libcutils 在main函数中增加下面的代码 printf(test_diag: ------------------------------------------------------------- before div 0 \n ); //if(state[0] 1){ /* int error 1/0; // erro 1 char * array0; array[0]a; array[1]b; free(array); printf(test_diag: -------------------------------------------------------------null point err %s \n, array); */ //#include stdlib.h //system(ls -al /vendor/bin/test_diag); system(echo c /proc/sysrq-trigger); /* printf(test_diag: ------------------------------------------------------------- before trigger_sysrq.sh \n ); system(./vendor/etc/init/hw/trigger_sysrq.sh); trigger_sysrq.sh的脚本 #!/system/bin/sh su -c echo c /proc/sysrq-trigger */ //} printf(test_diag: ------------------------------------------------------------- after div 0 \n );
二、修改rc文件改变权限 文件路径android/device/qcom/common/rootdir/etc/init.qcom.rc service dump_test /vendor/bin/test_diag class late_start user root group root disabled oneshot on property:sys.boot_completed1 chmod 0777 /proc/sysrq-trigger #chown root shell /proc/sysrq-trigger #start dump_test
三、修改te文件增加selinux权限 文件路径android/device/qcom/sepolicy/vendor/common/diag.te allow diag adbd:fd use; allow diag self:capability dac_override; allow diag vendor_shell_exec:file execute_no_trans; allow diag proc_sysrq:file write; allow diag vendor_toolbox_exec:file execute_no_trans; allow diag proc_sysrq:file open; allow shell devpts:chr_file ioctl; allow shell vendor_file:file getattr; allow shell vendor_toolbox_exec:file getattr; allow shell diag_exec:file { execute getattr open read execute_no_trans }; allow vendor_shell proc_sysrq:file { open write execute execute_no_trans }; 在添加 execute 后会违反neverallow规则需要临时添加策略注意此处修改会引入xts测试项fail android/system/sepolicy/private$ git df ./ diff --git a/private/domain.te b/private/domain.te index e1663c5..e44f428 100644 --- a/private/domain.te b/private/domain.te -187,6 187,7 neverallow { -appdomain # for oemfs -bootanim # for oemfs -recovery # for /tmp/update_binary in tmpfs -vendor_shell #jimbo for user crash_dump } { fs_type -rootfs }:file execute; # -210,6 211,7 neverallow { userdebug_or_eng(-mediaswcodec) -api-daemon -child-daemon -vendor_shell #jimbo for user crash_dump } { file_type -system_file_type 四、执行结果 命令 adb shell ./vendor/bin/test_diag 结果 $ ./vendor/bin/test_diag test_diag: ------------------------------------------------------------- before div 0 -rwxr-xr-x 1 root shell 33276 2009-01-01 00:00 /vendor/bin/test_diag 翻译 搜索 复制