magisk及模块编写介绍【转】
1.启动过程中magisk所做的事情:
1.准备阶段,将会把/data/magisk.img 挂到/magisk。同时它会遍历magisk⽬录中的模块是否为启⽤状态,并且记录。
2.创建⾻架system⽂件系统(由于bind mount 必须要有⼀个⽬标⽂件才能进⾏bind mount),全部由mkdir 和touch构建
3.将每个标记为启⽤的/magisk/$MODID/system中⽂件bind mount到⾻架系统
4.执⾏⾃定义模块中的脚本
5.遍历⾻架中剩余没有被mount的⽂件,通过真正的system⽂件进⾏bind mount。
2.Magisk功能
1.集成了类似SuperSU的root管理功能(MagiskSU)
2.类似于Xposed,可以安装使⽤Magisk相关模块
3.Magisk Hide(对单个应⽤隐藏 Magisk 的 root 权限)
4.⽇志功能
5.Systemless hosts(为⼴告屏蔽应⽤提供Systemless hosts⽀持)
6.SafetyNet 检查功能
3.⼀个完整的magisk模块整体如下:
➜ tree MagiskTrustUserCerts
MagiskTrustUserCerts
├── META-INF
│└── com
│└── google
│└── android
│├── update-binary
│└── updater-script
├── common
│├── post-fs-data.sh
│├── service.sh
│└── system.prop
xposed
├── config.sh
└── module.prop
4.总结模块的编写流程:
# 1. Place your files into system folder (delete the placeholder file)
# 2. Fill in your module's info into module.prop
# 3. Configure the settings in this file (common/config.sh)
# 4. For advanced features, add shell commands into the script files under common:
# post-fs-data.sh, service.sh
# 5. For changing props, add your additional/modified props into common/system.prop