Android 13 使能user版本进recovery
在 debug 版本上,可以在关机状态下,同时按 电源键 和 音量加键 进 recovery 。
user 版本上不行。
参考 使用 build 变体
debug 版本和 user 版本的差别之一就是 ro.debuggable
属性不同。
顺着这个思路追踪,找到 bootable/recovery/recovery.cpp
,
添加如下修改即可,
--- a/bootable/recovery/recovery.cpp
+++ b/bootable/recovery/recovery.cpp
@@ -130,6 +130,10 @@ static bool IsRoDebuggable() {return android::base::GetBoolProperty("ro.debuggable", false);}+// refer to device.mk , we have set user.enable.recovery=true
+static bool IsUserEnableRecovery() {
+ return android::base::GetBoolProperty("user.enable.recovery", false);
+}// Clear the recovery command and prepare to boot a (hopefully working) system,// copy our log file to cache as well (for the system to read). This function is
@@ -1272,7 +1276,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri// If this is an eng or userdebug build, then automatically// turn the text display on if the script fails so the error// message is visible.
- if (IsRoDebuggable()) {
+ if (IsRoDebuggable() || IsUserEnableRecovery()) {ui->ShowText(true);}}else{
@@ -1389,7 +1393,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri// If this is an eng or userdebug build, automatically turn on the text display if no command// is specified. Note that this should be called before setting the background to avoid// flickering the background image.
- if (IsRoDebuggable()) {
+ if (IsRoDebuggable() || IsUserEnableRecovery()) {ui->ShowText(true);}status = INSTALL_NONE; // No command specified
为了不同 device 可复用,根据属性判断,如果其他客户也需要,在对应的 device.mk 里加上该属性就行。