Edify简介
Android的刷机包文件解压,会有这样的目录:/META-INF/com/google/android/,该目录下有两个文件update-binary和updater-script。updater-script是用Edify语言写成的文本文件,update-binary是源码下/bootable/recovery/updater目录下文件编译生成的二进制可执行文件,用来解析updater-script中的内容。所以安卓的刷机过程其实就是执行updater-script脚本的过程。
Edify 命令
在update-binary的main函数中有如下调用
RegisterBuiltins();
RegisterInstallFunctions();
RegisterBlockImageFunctions();
RegisterDeviceExtensions();
其中重点是RegisterBuiltins和RegisterInstallFunctions,前者注册了一些表达式,后者注册了安装包用的函数。
void RegisterBuiltins() {
RegisterFunction("ifelse", IfElseFn);
RegisterFunction("abort", AbortFn);
RegisterFunction("assert", AssertFn);
RegisterFunction("concat", ConcatFn);
RegisterFunction("is_substring", SubstringFn);
RegisterFunction("stdout", StdoutFn);
RegisterFunction("sleep", SleepFn);
RegisterFunction("less_than_int", LessThanIntFn);
RegisterFunction("greater_than_int", GreaterThanIntFn);
}
void RegisterInstallFunctions() {
RegisterFunction("mount", MountFn);
RegisterFunction("is_mounted", IsMountedFn);
RegisterFunction("unmount", UnmountFn);
RegisterFunction("format", FormatFn);
RegisterFunction("show_progress", ShowProgressFn);
RegisterFunction("set_progress", SetProgressFn);
Reg