展示
从开机的时候,看提示,进入验证启动认知:


流程:

目的
保护系统的安全性。
涉及的范围:从受硬件保护的信任根到引导加载程序,再到启动分区和其他已验证分区(包括 system、vendor 和可选的 oem 分区)的完整信任链。
实现的方式:
1.在设备启动过程中,无论是在哪个阶段,都会在进入下一个阶段之前先验证下一个阶段的完整性和真实性
2.检查是否存在内置了回滚保护的正确 Android 版本
3. Android 设备将其完整性状态传达给用户
理解框架

实战
前言

* Android P + kernel-4.4 or kernel-3.18
- download preloader with verified boot disabled which location is the same as scatter file //preloader_<PROJECT>_SBOOT_DIS.bin
- adb root
- adb disable-verity
- adb reboot
- adb root
- adb remount
* Android P + kernel-4.9 or after
- download preloader with verified boot disabled which location is the same as scatter file. //preloader_<PROJECT>_SBOOT_DIS.bin
- boot to Home Screen
- go to setting -> system -> Developer options -> OEM unlocking
- adb reboot bootloader
- fastboot flashing unlock
- press volume up key
- fastboot reboot
- adb root
- adb disable-verity
- adb reboot
- adb root
- adb remount
实例一:
效果展示:

代码分析:

快速验证方法:

adb shell验证:
getprop ro.oem_unlock_supported
1---代表打开
0---代表关闭

通过如下操作:
- adb reboot bootloader
- fastboot flashing unlock
- press volume up key
- fastboot reboot
之后:
adb shell
解锁成功后检查这两个属性会从
[ro.boot.flash.locked]: [1]
[ro.boot.verifiedbootstate]: [green]
变成
[ro.boot.flash.locked]: [0]
[ro.boot.verifiedbootstate]: [orange]
补充:
ro.boot.flash.locke在哪里进行改变的?
开机启动过程。具体为system/core/init/init.cpp
main(int argc, char** argv) {
·····
export_oem_lock_status();
·····
}
export_oem_lock_status(){
if (!android::base::GetBoolProperty("ro.oem_unlock_supported", false)) {
return;
}
std::string value = GetProperty("ro.boot.verifiedbootstate", "");
if (!value.empty()) {
property_set("ro.boot.flash.locked", value == "orange" ? "0" : "1");
}
}
实例二:
效果展示:

怎么让禁止解锁变成可以解锁的状态?
代码分析为什么变成禁止解锁状态?

具体方法:
1.直接操作/data/system/users/0.xml中的值:
UserManagerService.java中有对/data/system/users/0.xml进行处理
eg:
灰色的值:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<user id="0" serialNumber="0" flags="19" created="0" lastLoggedIn="0" profileBadge="0">
<restrictions no_oem_unlock="true" />
</user>
正常的值:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<user id="0" serialNumber="0" flags="19" created="0" lastLoggedIn="1548122734879" lastLoggedInFingerprint="alps//full_k61v1_64_bsp:9/PPR1.180610.011/1548115520:user/release-keys" profileBadge="0">
<restrictions />
</user>
即:
adb root
adb pull /data/system/users/0.xml 本地路径
修改0.xml中的值
adb push 本地修改之后的文件 /data/system/users/
adb reboot
就可以满足要求
2.代码实现的方式:
修改配置文件
UserManagerService.java的构建方法中:
UserManagerService(......)-->readUserListLP()--->fallbackToSingleUserLP()
详解:
fallbackToSingleUserLP(){
***********
Bundle restrictions = new Bundle();
try {
final String[] defaultFirstUserRestrictions = mContext.getResources().getStringArray(
com.android.internal.R.array.config_defaultFirstUserRestrictions);
for (String userRestriction : defaultFirstUserRestrictions) {
if (UserRestrictionsUtils.isValidRestriction(userRestriction)) {
restrictions.putBoolean(userRestriction, true);
}
}
} catch (Resources.NotFoundException e) {
Log.e(LOG_TAG, "Couldn't find resource: config_defaultFirstUserRestrictions", e);
}
********
}
原生为:
frameworks/base/core/res/res/values/config.xml
<string-array translatable="false" name="config_defaultFirstUserRestrictions">
</string-array>
gms包中overlay为:
gms_overlay/frameworks/base/core/res/res/values/config.xml
<string-array translatable="false" name="config_defaultFirstUserRestrictions">
<item>"no_oem_unlock"</item>
</string-array>
参考学习
https://source.android.com/security/verifiedboot/index.html
https://source.android.com/security/verifiedboot/verified-boot.html
https://source.android.com/security/verifiedboot/dm-verity.html
https://gitlab.com/cryptsetup/cryptsetup/wikis/DMVerity
https://blog.csdn.net/sinat_34606064/article/details/77920700
网友评论