编译Xposed并魔改去特征

环境

ubuntu 16.04

aosp7.1.2r8源码

编译Xposed

首先需要将xposed相关项目都clone到本地

https://github.com/rovo89/Xposed.git

https://github.com/rovo89/XposedBridge.git

https://github.com/rovo89/android_art.git

https://github.com/rovo89/XposedTools.git

https://github.com/rovo89/XposedInstaller.git

XposedBridge

使用AS打开XposedBridge项目,直接build,在项目的app/build/outputs/apk下将app-release-unsigned.apk重命名为XposedBridge.jar

将这个jar包放在aosp源码目录下的/out/target/product/sailfish/system/framework/目录下。

/out/java/

android_art

将该项目直接替换源码目录的art目录

Xposed

将xposed目录复制到aosp712r8/frameworks/base/cmds/目录下

XposedTools

复制build.conf.sample并重命名为build.conf

修改其中内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[General]
outdir = /home/tg/Desktop/COMPILE/aosp712r8/out
javadir = /home/tg/Desktop/COMPILE/aosp712r8/out/java

[Build]
# Please keep the base version number and add your custom suffix
version = 89 (custom build by TG / %s)
# makeflags = -j4

[GPG]
sign = release
user = 852109AA!

# Root directories of the AOSP source tree per SDK version
[AospDir]
25 = /home/tg/Desktop/COMPILE/aosp712r8
# SDKs to be used for compiling BusyBox
# Needs https://github.com/rovo89/android_external_busybox
[BusyBox]
arm = 25
x86 = 25
armv5 = 25

outdir指向的路径是xposed编译之后生成的文件的存放路径。
version的值和后边的参数是自己设置的。编译之后会写入到xposed.prop文件中。
makeflags是设置在后边编译过程中使用的线程数。
AospDir指向的路径是android源码存放的路径,前边的值是源码对应的SDK的版本号。这里我指向的是android5.1.1的源码,对应的android sdk的版本是22。

修改完之后需要下载一些perl的库。

sudo apt-get install libauthen-ntlm-perl libclass-load-perl libcrypt-ssleay-perl libdata-uniqid-perl libdigest-hmac-perl libdist-checkconflicts-perl libfile-copy-recursive-perl libfile-tail-perl

perl -MCPAN -e ‘install File::ReadBackwards’

使用build.pl进行编译./build.pl -t arm:25

将生成的xposed.zip发布到web上,以供XposedInstall安装使用。

XposedInstall

修改de.robv.android.xppsed.installer.util.DownloadsUtil其中的setUrl函数

1
2
3
4
5
6
7
public Builder setUrl(String url) {
//mUrl = url;
// 改成XposedTools生成的XPosed.zip
mUrl = "";
return this;
}

然后安装,installXposed即可。

魔改去特征

XposedInstall

直接修改包名即可。

全局替换de.robv.android.xposed.installer,改为de.robv.android.xppsed.installer

1
2
3
4
5
private static final String[] XPOSED_PROP_FILES = new String[]{
"/su/xposed/xppsed.prop", // official systemless
"/system/xppsed.prop", // classical
};

再build->clean project。

XposedBridge-art.jar

替换包名为de.robv.android.xppsed,全局替换de.robv.android.xposed,改为de.robv.android.xppsed`。

生成出来的jar包也改为XppsedBridge.jar

gradle使用jarStubsSorcejarStubs生产api.jar包,给自己编写Xposed插件使用。

Xposed

libxposed_art.cpp改为libxppxosed_art.cpp

xposed.h

1
2
3
4
5
6
#define XPOSED_PROP_FILE "/system/xppsed.prop"
#define XPOSED_LIB_ART XPOSED_LIB_DIR "libxppsed_art.so"

...
#define XPOSED_CLASS_DOTS_ZYGOTE "de.robv.android.xppsed.XposedBridge"
#define XPOSED_CLASS_DOTS_TOOLS "de.robv.android.xppsed.XposedBridge$ToolEntryPoint"

libxposed_common.h

1
2
3
4
5
#define CLASS_XPOSED_BRIDGE  "de/robv/android/xppsed/XposedBridge"
...
#define CLASS_ZYGOTE_SERVICE "de/robv/android/xppsed/services/ZygoteService"
#define CLASS_FILE_RESULT "de/robv/android/xppsed/services/FileResult"

xposed_service.cpp

1
IMPLEMENT_META_INTERFACE(XposedService, "de.robv.android.xppsed.IXposedService");

xposed_shared.h

1
2
3
4
5
6
#define XPOSED_DIR "/data/user_de/0/de.robv.android.xppsed.installer/"

...

#define XPOSED_DIR "/data/data/de.robv.android.xppsed.installer/"

ART.mk

1
2
3
4
5
6
7
LOCAL_SRC_FILES += \
libxposed_common.cpp \
libxppsed_art.cpp

...
LOCAL_MODULE := libxppsed_art

并将libxposed_art.cpp文件名改为libxppsed_art.cpp

XposedTools

build.pl中的xposed.prop改为xpposed.prop,将libxposed_art改为libxppsed_art,将XposedBridge.jar改为XppsedBridge.jar

zipstatic/_all/META-INF/com/google/android/flash-script.sh中将xposed.prop改为xpposed.prop,将libxposed_art改为libxppsed_art,将XposedBridge.jar改为XppsedBridge.jar

参考