Android允许解锁设备获得Root权限,这是官方Root方法,至少对 Pixel 设备有效。
需要在RamDisk中加入3个文件:
/force_debuggable 空文件,这是开关;/adb_debug.prop,设置需要的属性,例如:ro.adb.secure=0
ro.debuggable=1
ro.force.debuggable=1
/userdebug_plat_sepolicy.cil,设置需要的SELinux政策。开机时,init会检查开关然后读取并加载属性和政策,开机后可以使用adb root获得root权限。
你可以使用MagiskBoot工具重新打包RamDisk,不过SELinux政策需要自行编写。