当前位置: 首页 > news >正文

android user 版本如何手动触发dump

项目需要在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 * array=0;
        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_completed=1
        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
 

http://www.lryc.cn/news/407866.html

相关文章:

  • RedHat Linux 7.5 安装 mssql-server
  • Vue的SSR和预渲染:提升首屏加载速度与SEO效果
  • 若依ruoyi+AI项目二次开发(智能售货机运营管理系统)
  • 【SpringBoot】 4 Thymeleaf
  • 动静资源的转发操作
  • Windows系统安全加固方案:快速上手系统加固指南(上)
  • git连接远程仓库
  • 算法-----递归~~搜索~~回溯(宏观认识)
  • 【云原生】Docker搭建知识库文档协作平台Confluence
  • 序列化与反序列化的本质
  • 飞牛爬虫FlyBullSpider 一款简单方便强大的爬虫,限时免费 特别适合小白!用它爬下Boss的2024年7月底Java岗位,分析一下程序员就业市场行情
  • EXCEL 排名(RANK,COUNTIFS)
  • 【踩坑系列-JS】iframe中的url参数获取
  • 测试工作中常听到的名词解释 : )
  • Linux内网离线用rsync和inotify-tools实现文件夹文件单向同步和双向同步
  • Spring Security学习笔记(二)Spring Security认证和鉴权
  • 产品经理NPDP好考吗?
  • 【C++】:红黑树的应用 --- 封装map和set
  • unity美术资源优化(资源冗余,主界面图集过多)
  • 【git】github中的Pull Request是什么
  • gitlab查询分支API显示不全,只有20个问题
  • vue3+vite 实现动态引入某个文件夹下的组件 - glob-import的使用
  • hhhhh
  • 扫雷小游戏纯后端版
  • RuoYi-Vue-Plus(动态添加移除数据源)
  • idea启动项目报:the command line via JAR manifest or via a classpath file and rerun.
  • vue3 + ts中有哪些类型是由vue3提供的?
  • 【Linux】远程连接Linux虚拟机(MobaXterm)
  • LeetCode Hot100 生成特殊数字的最少操作
  • Spring MVC 应用分层