我们自己编译的源码刷机ro.debuggable就是为1,这个时候所有的进程都可以远程调试。但是自己编译的源码里面没有GooglePlay,有些应用的部分功能又依赖于GooglePlay。那怎么办呢?
有人发布过工具,通过ptrace方式,动态修改了内存值,将ro.debuggable改为1,那工具在高版本上似乎没有适配不起作用,而且是临时解决方案,重启手机就失效了。
下面说一种通过刷机永久解决方案。
虽然说刷机有风险,但是你要是按照正确的姿势来,也没有那么多风险(注意看完全文再实践)
环境: nexus6p 刷了Google发布的7.1.2(N2G48C)OTA,其他版本也没什么问题。
ro.debuggable的配置位于/default.prop, /default.prop又来源于手机每次启动时boot.img中ramdisk的挂载,所以想要直接通过修改/default.prop是不可行的(被覆盖)。 只有修改boot.img中的内容才可以。
0x01:获取boot.img
我本地就有OTA文件,所以可以直接从里面解压出boot.img,如果没有OTA文件,那就是只能从手机中导出boot.img。
如何导出?
- 首先,手机得root,才能有权限访问,如何root,参考:nexus5 android5.0.1 使用TWRP Recovery安装supersu,其他版本Root搜索 版本+twrp 即可找到解决方案。
- 手机root后,执行
adb root
让adb 运行在root权限下,假如之后的adb shell
没有进入root的shell环境,说明没成功,此时,可以通过安装adbd-insecure来解决,它通过对adbd的一些修改,让adbd能运行在root权限下。 - 查找boot.img位置, 在/dev/block子目录下通过by-name查看,手机不同,具体路径可能会不同。
# ls -al /dev/block/platform/soc.0/f9824900.sdhci/by-name/
total 0
drwxr-xr-x 2 root root 920 1970-03-19 13:19 .
drwxr-xr-x 4 root root 1000 1970-03-19 13:19 ..
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 DDR -> /dev/block/mmcblk0p8
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 aboot -> /dev/block/mmcblk0p10
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 abootbak -> /dev/block/mmcblk0p16
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 apdp -> /dev/block/mmcblk0p22
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 boot -> /dev/block/mmcblk0p34
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 cache -> /dev/block/mmcblk0p38
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 cmnlib -> /dev/block/mmcblk0p25
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 cmnlibbak -> /dev/block/mmcblk0p27
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 devinfo -> /dev/block/mmcblk0p17
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 dpo -> /dev/block/mmcblk0p28
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 frp -> /dev/block/mmcblk0p41
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 fsc -> /dev/block/mmcblk0p29
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 fsg -> /dev/block/mmcblk0p18
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 hyp -> /dev/block/mmcblk0p6
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 hypbak -> /dev/block/mmcblk0p15
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 keymaster -> /dev/block/mmcblk0p24
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 keymasterbak -> /dev/block/mmcblk0p26
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 keystore -> /dev/block/mmcblk0p40
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 limits -> /dev/block/mmcblk0p19
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 metadata -> /dev/block/mmcblk0p33
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 misc -> /dev/block/mmcblk0p39
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 modem -> /dev/block/mmcblk0p1
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 modemst1 -> /dev/block/mmcblk0p20
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 modemst2 -> /dev/block/mmcblk0p21
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 msadp -> /dev/block/mmcblk0p23
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 oem -> /dev/block/mmcblk0p36
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 oeminfo -> /dev/block/mmcblk0p31
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 persist -> /dev/block/mmcblk0p32
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 persistent -> /dev/block/mmcblk0p42
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 pmic -> /dev/block/mmcblk0p7
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 pmicbak -> /dev/block/mmcblk0p11
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 recovery -> /dev/block/mmcblk0p35
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 rpm -> /dev/block/mmcblk0p5
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 rpmbak -> /dev/block/mmcblk0p14
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 sbl1 -> /dev/block/mmcblk0p2
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 sbl1bak -> /dev/block/mmcblk0p12
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 sdi -> /dev/block/mmcblk0p3
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 sec -> /dev/block/mmcblk0p9
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 ssd -> /dev/block/mmcblk0p30
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 system -> /dev/block/mmcblk0p43
lrwxrwxrwx 1 root root 20 1970-03-19 13:19 tz -> /dev/block/mmcblk0p4
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 tzbak -> /dev/block/mmcblk0p13
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 userdata -> /dev/block/mmcblk0p44
lrwxrwxrwx 1 root root 21 1970-03-19 13:19 vendor -> /dev/block/mmcblk0p37
作者:difcareer
链接:https://www.jianshu.com/p/587319a6fa0a
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。