问题现象
adb shell getprop ro.boot.verifiedbootstate 返回值为 orange
期望返回值为green
与测试沟通后,得到的反馈是测试用例中要求的检查项。
问题分析
1,对此属性不了解,因此在代码中搜寻关键字以确认所述功能块,检索关键字“ro.boot.verifiedbootstate”所得结果仅两条, 得到两条信息:
(1)在export_oem_lock_status中被调用,说明,和oem lock有关;
(2)从搜索的两条结果均为GetProperty的调用,哪里赋值green才能符合期望值呢;
2,精简检索关键字“verifiedbootstate”,检索结果多了一些,7条,从中可以看到和verified-boot有关,尤其是verified-boot.jd中的信息,其中介绍了返回值的具体意义
Kernel command line parameter | Description |
---|---|
androidboot.verifiedbootstate=green | Device has booted into GREEN boot state. Boot partition has been verified using the OEM key and it’s valid. |
androidboot.verifiedbootstate=yellow | Device has booted into YELLOW boot state. Boot partition has been verified using the certificate embedded into the signature and it’s valid. |
androidboot.verifiedbootstate=orange | Device has booted into ORANGE boot state. The device is unlocked and no verification has been performed. |
Note: The device cannot boot into kernel when in the RED boot state, and therefore the kernel command line never includes the parameter androidboot.verifiedbootstate=red
.
至此,我们知道了可能和oem lock有关,接下来验证推测
3,找同型号测试机下载相同软件尝试复现
下载后软件后,我的测试机得到的结果如下
adb shell getprop ro.boot.verifiedbootstate
green
adb shell getprop ro.boot.flash.locked
1
adb shell getprop ro.boot.veritymode
enforcing
再执行adb reboot bootloader
进入fastboot模式,
然后执行sudo fastboot oem device-info
检查device信息
得到如下结果
(bootloader) Device tampered: false
(bootloader) Device unlocked: false
(bootloader) Device critical unlocked: false
(bootloader) Charger screen enabled: false
(bootloader) Display panel:
OKAY [ 0.007s]
finished. total time: 0.007s
证明当前我的测试机是符合要求,verified boot打开,lock状态正确
4,验证unlock的情况
先power on 测试机,在开发者选项中打开菜单允许执行oem unlock
之后执行adb reboot bootloader
进入fastboot模式
再执行sudo fastboot oem unlock
进行解锁
备注:如果执行提示错误,按提示换用sudo fastboot oem unlock-go
之后再次按上述方法检查各项值,结果如
adb shell getprop ro.boot.verifiedbootstate
orange
adb shell getprop ro.boot.flash.locked
0
adb shell getprop ro.boot.veritymode
enforcing
//执行sudo fastboot oem device-info命令的结果
(bootloader) Device tampered: false
(bootloader) Device unlocked: true
(bootloader) Device critical unlocked: false
(bootloader) Charger screen enabled: false
(bootloader) Display panel:
OKAY [ 0.007s]
finished. total time: 0.007s
可以看到Device unlocked: true
时和测试手中的测试机ro.boot.verifiedbootstate 为 orange
是对应的。
证明测试手中的测试机应是为单独更新image做过oem unlock操作,同时,此unlock操作即使更新版本也无法恢复。
解决方法
将此手机重新lock
adb reboot bootloader
sudo fastboot oem lock
其他知识
移步下方链接,详细了解一下何谓Veified Boot吧 :)
https://lwn.net/Articles/638627/