本文主要介绍华为荣耀4a(scl-tl00h)的root与xposed安装过程

用到的资源有:

解锁并刷入三方recovery

首先需要解锁bootloader,否则无法刷入三方recovery。笔者几年前就已经解锁了,解锁过程忘记了,且解锁链接www.emui.com/plugin.php?id=unlock已经失效。

将下载的twrp-3.1.1.img镜像重命名为recovery.img,开启usb调试并将手机通过usb连接电脑,使用如下命令刷入recovery镜像

  1. 进入fastboot模式
    adb reboot bootloader
    使用fastboot devices查看是否已连接

  2. 将recovery.img刷入recovery分区
    fastboot flash recovery recovery.img
    出现如下结果即为安装成功

  3. 重启
    fastboot reboot

root

将下载的SuperSU.zip发送到sd卡adb push SuperSU.zip /mnt/sdcard/,手机关机后按住音量+与电源键,进入recovery模式。点击install,在sdcard下选择SuperSU.zip,安装成功后重启即可。

安装xposed framework

安卓5以上版本下安装xposed需要卡刷xposed-vXX-sdkXX-XXX.zip,下载地址https://dl-xda.xposed.info/framework/

  • vXX代表xposed framework版本号
  • sdkXX代表安卓系统api级别, sdk21代表5.0系统;sdk22代表5.1系统;sdk23代表6.0系统
  • XXX代表设备cpu架构,笔者手机为arm。

将下载的zip文件(华为4a对应的zip文件是xposed-v86-sdk22-arm.zip)发送到sd卡根目录下,使用与安装SuperSU.zip相同的步骤安装。安装完成后下载安装xposed-installer.apk即可。
安装xposed成功

启用调试(安卓5.1.1无效)

修改/system/build.prop,添加ro.secure=0, ro.debuggable=1
adb shell进入设备

1
2
3
4
# mount -o rw,remount /system
# echo '\nro.secure=0\nro.debuggable=1\n' >> /system/build.prop
# mount -o ro,remount /system
# reboot

启用hierachyViewer

安装并激活xinstaller模块,打开调试应用选项。
如果hierachy viewer报如下错误

1
2
3
[2018-05-11 18:04:57 - ViewServerDevice]Unable to debug device: scl_tl00h-JTJ4C15717045443
[2018-05-11 18:04:57 - hierarchyviewer]Missing forwarded port for JTJ4C15717045443
[2018-05-11 18:04:57 - hierarchyviewer]Unable to get the focused window from device JTJ4C15717045443

或者调试程序时报如下错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ adb shell am start -D -n com.tencent.mm/com.tencent.mm.ui.LauncherUI
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String android.os.SystemProperties.native_get(java.lang.String, java.lang.String) (tried Java_android_os_SystemProperties_native_1get and Java_android_os_SystemProperties_native_1get__Ljava_lang_String_2Ljava_lang_String_2)
at android.os.SystemProperties.native_get(Native Method)
at android.os.SystemProperties.get(SystemProperties.java:64)
at android.os.Environment$UserEnvironment.<init>(Environment.java:169)
at android.os.Environment.initForCurrentUser(Environment.java:107)
at android.os.Environment.<clinit>(Environment.java:83)
at android.os.Environment.getLegacyExternalStorageDirectory(Environment.java:468)
at android.os.Debug.<clinit>(Debug.java:96)
at android.ddm.DdmHandleHello.handleHELO(DdmHandleHello.java:164)
at android.ddm.DdmHandleHello.handleChunk(DdmHandleHello.java:91)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java:171)
java.lang.UnsatisfiedLinkError: android.os.Debug
at android.ddm.DdmHandleHello.handleFEAT(DdmHandleHello.java:176)
at android.ddm.DdmHandleHello.handleChunk(DdmHandleHello.java:93)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java:171)
java.lang.UnsatisfiedLinkError: android.os.Debug
at android.ddm.DdmHandleProfiling.handleMPRQ(DdmHandleProfiling.java:187)
at android.ddm.DdmHandleProfiling.handleChunk(DdmHandleProfiling.java:88)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java:171)
monks-MacBook-Pro:base monk$ export ANDROID_HVPROTO=ddm
monks-MacBook-Pro:base monk$ adb shell am start -D -n com.tencent.mm/com.tencent.mm.ui.LauncherUI
Starting: Intent { cmp=com.tencent.mm/.ui.LauncherUI }

关闭android studio与其他ddms进程

1
2
$ export ANDROID_HVPROTO=ddm
$ /Opt/tools/android-sdk/tools/monitor

引用自Profile Your Layout with Hierarchy Viewer

  1. Enable Developer Options on your device.
  2. Set the environment variable ANDROID_HVPROTO=ddm on your development machine.
    This variable tells Hierarchy Viewer to connect to the device using the ddm protocol, which is the same as the DDMS protocol. The caveat is that there can be only one process on the host that connects to the device, so you must kill any other DDMS session to run Hierarchy Viewer.

就是说使hierachy viewer通过ddm协议连接设备,但只能有一个进程与设备连接,所以需要关闭其他ddms会话。