天天看點

ro.boot.verifiedbootstate 為 orange

問題現象

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                                        


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 [  s]
finished. total time: s
           

證明目前我的測試機是符合要求,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                                        


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 [  s]
finished. total time: s
           

可以看到

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/

繼續閱讀