手机是moto x 2014,系统是6.0,需要wipe掉data分区
- 先从手机将framework拷到电脑,实际只需要 boot.oat,services.jar,services.odex 这三个文件:
adb pull /system/framework
- 反编译,得到smali文件,用baksmali工具:
java -jar baksmali-2.2.5.jar de -b framework/arm/boot.oat services.odex
将上面framework/arm/boot.oat替换成实际的boot.oat的路径。得到out文件夹。
- 回编译,用smali工具:
java -jar smali-2.2.5.jar as out -o classes.dex
得到classes.dex文件。
- dex转odex
网上搜到的dex转odex方法是用dexopt工具,但是都是几年前的了。
现在用dex2oat工具。
用二进制编辑器打开,ubuntu的话vim上用xxd就行:
vim services.odex
然后按esc到命令模式,输入 “:%! xxd”,往下看到地址00001000的地方,后面一串ascii文本,描述了系统编译时用的参数。
整理得到:
dex2oat \
--runtime-arg -Xms64m \
--runtime-arg -Xmx512m \
--dex-file=services.jar \
--dex-location=/system/framework/services.jar \
--oat-file=services.odex \
--instruction-set=arm \
--instruction-set-variant=krait \
--instruction-set-features=default \
--include-patch-information \
--runtime-arg -Xnorelocate \
--no-generate-debug-info \
--abort-on-hard-verifier-error \
--compile-pic
好,搞清楚了怎么转之后就开始了:
a) 先将上面得到的classes.dex文件加到/system/framework/services.jar里面,这个jar现在应该是没有dex文件的:
zip services.jar -m classes.dex
b) push到手机:
adb push services.jar /data/local/tmp
c) dex2oat:
adb shell
cd /data/local/tmp
dex2oat \
--runtime-arg -Xms64m \
--runtime-arg -Xmx512m \
--dex-file=services.jar \
--dex-location=/system/framework/services.jar \
--oat-file=services.odex \
--instruction-set=arm \
--instruction-set-variant=krait \
--instruction-set-features=default \
--include-patch-information \
--runtime-arg -Xnorelocate \
--no-generate-debug-info \
--abort-on-hard-verifier-error \
--compile-pic
就得到了services.odex。
- 将新的services.odex替换上去:
adb shell
su
mount -o rw,remount /system
cp services.odex /system/framework/oat/arm/services.odex
chmod 644 /system/framework/oat/arm/services.odex
reboot recovery
最后一句是重启到recovery。
- 在recovery中wipe掉data和dalvik-cache和cache,开机,就可以了。
xt1580 - android7.0
KINZIE_RETLA_DS_7.0_NPKS25.200-12-9_cid12_subsidy-DEFAULT_CFC.xml
的dex2oat参数:
dex2oat \
--runtime-arg -Xms64m \
--runtime-arg -Xmx512m \
--runtime-arg -classpath \
--dex-file=services.jar \
--dex-location=/system/framework/services.jar \
--oat-file=services.odex \
--instruction-set=arm64 \
--instruction-set-variant=generic \
--instruction-set-features=default \
--include-patch-information \
--runtime-arg -Xnorelocate \
--no-generate-debug-info \
--no-inline-from=core-oj.jar \
--compile-pic