常用的几个adb命令

常用的几个adb命令:

1 抓取指定关键字的log:

adb shell "logcat -b all | grep 关键字"

还可以用下面的命令:

adb logcat | find "com.ljt.camera" >c:/1.log

2 查看当前窗口应用包名和activity名:

  adb shell "dumpsys activity | grep -i run"

3 启动指定的activity

adb shell am start -n 包名/.activity名

如:adb shell am start -n com.android.calendar/.AllInOneActivity

4 查看版本编译时间

 adb shell "getprop | grep ro.build.date"

5 seLinux问题确认

如果怀疑是seLinux权限导致了bug可以按照如下方法确认:

  • 抓取seLinux相关的log
    1.抓kernel的log
    adb shell dmesg
    

    还可以使用以下命令:

    adb shell "cat /proc/kmsg | grep avc" >avc_log.txt  
    
    2.抓logcat的log
    adb logcat –b events | find "avc: denied"
    

    如:

    02-03 09:43:59.858 18875 18875 I ndroid.settings: type=1400 audit(0.0:22265): avc: denied { read }  for name="pagetypeinfo" dev="proc" ino=4026532108 scontext=u:r:system_app:s0 tcontext=u:object_r:proc_pagetypeinfo:s0 tclass=file permissive=1
    
    3.注意下面的关键字:
    关键字说明
    ndroid.settings应用名称
    avc: denied { read }操作
    tcontext=u:object_r:proc_pagetypeinfo目标
    tclass=file操作对象的类型
  • 查看seLinux的状态
    adb shell getenforce
    

    返回Enforcing:seLinux已经打开;
    返回Permissive:seLinux已经关闭;

    从log也可以看出,如果permissive=1说明seLinux已经关闭了,permissive=0,说明seLinux已经开启了

  • 关闭seLinux
    adb root & adb shell setenforce 0
    

    最好在刚开机以后开机动画开始播放之后就运行,否则还是可能会出现大量权限相关的问题。

    如果后续的测试未出现严重的系统性问题,说明与seLinux有关。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值