在自定义镜像中使用 Xposed 在 Google Android 模拟器内运行

4

问题描述:

我需要在预定义参数的特定Android镜像上使droidmon工作。安装Xposed框架时出现错误,要求获得root权限。

环境:

Google Android模拟器运行自定义的已Root的Android 4.4.2 x86镜像,内核版本为3.4.67+(但是我在3.10+上也遇到了同样的问题)使用的参数(+与Android无关的额外参数):

  • -avd
  • -kernel
  • -ramdisk
  • -no-cache
  • -selinux permissive
  • -no-snapstorage
  • -verbose
  • -show-kernel

SDK-Tools-Version: 25.2.2

SDK-Platform-Tools: 24.0.3

Android已配置允许未知来源的APK

已尝试:

  1. 重新挂载/system RW
  2. 使用-selinux disabled(但是xposed要求-selinux permissive)
  3. 从xposed中提取update-binary并使用su运行脚本

当前状态:

如果我尝试安装Xposed,则模拟器会显示以下日志消息:

[  355.372965] type=1400 audit(1477138733.355:23): avc:  denied  { execute } for  pid=2796 comm="posed.installer" name="app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.372984] type=1400 audit(1477138733.355:24): avc:  denied  { execute_no_trans } for  pid=2796 comm="posed.installer" path="/data/data/de.robv.android.xposed.installer/cache/app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.440354] type=1400 audit(1477138733.415:25): avc:  denied  { read } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440410] type=1400 audit(1477138733.415:26): avc:  denied  { open } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440450] type=1400 audit(1477138733.415:27): avc:  denied  { getattr } for  pid=2769 comm="posed.installer" path="/system/bin/app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  365.476143] type=1400 audit(1477138743.455:28): avc:  denied  { execute } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476280] type=1400 audit(1477138743.455:29): avc:  denied  { read open } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476371] type=1400 audit(1477138743.455:30): avc:  denied  { execute_no_trans } for  pid=2805 comm="Thread-110" path="/system/xbin/su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1

状态更新:

据我所知,镜像没有被正确地root。我使用SuperSU-2.78中打包的su二进制文件重新root了这个镜像。我将system.img挂载到我的Linux机器上的一个文件夹并添加了su和daemonsu(基本上是复制并重命名的su)到/system/xbin/,并将两个文件的权限改为6755。此外,我还在/etc/init.goldfish.sh的末尾添加了两行代码。

#remount /system rw
mount -o rw,remount /system

#start daemonsu as auto-daemon
/system/xbin/daemonsu --auto-daemon

在安装了SuperSU的Superuser.apk和合适的Xposed版本之后,Xposed首先会安装,但重新启动后会导致libdvm.so中的segfaults。
1个回答

1

最终成功让它工作了(需要较旧的sdk版本(2016年11月之前))

如上所述,仍需使用SuperSU

内核镜像低于3.10版本(kernel-qemu或engine classic)

  1. 以详细模式启动模拟器
  2. 注意用于在qemu内部挂载/system的临时文件
  3. 安装Xposed但取消重启
  4. 将临时system.img从/tmp/android-{username}/emulator-{random chars}复制到您的主目录下
  5. 关闭模拟器
  6. 用来自主目录的那个覆盖现有的system.img
  7. 再次启动模拟器
  8. Xposed现在应该正在运行

内核版本3.10+(kernel-ranchu或真正隔离的模拟器)

不幸的是,目前还没有已知的方法可以在ranchu模拟器内修改system.img,ranchu似乎会阻止每个写操作。 被阻止的操作使系统认为分区已损坏,因此系统将分区重新挂载为只读模式以进行安全回退。

两种发现的解决方法:

1.) 在启动模拟器时使用参数 -engine classic(强制使用 kernel-qemu),您可以使用上述步骤进行更改。

2.) 使用低于 3.10 版本的内核映像以避免模拟器 ranchu。您可以使用上述步骤,在应用更改后再次使用先前的内核映像。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接