软件平台:Android13
硬件平台:高通SM6115
需求:Android进入recovery的菜单页面,只保留重启等两三个选项。
1、菜单页面是在recovery/recovery_ui/device.cpp里边定义的,内容如下:
cpp
static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions{
{ "Reboot system now", Device::REBOOT },
{ "Reboot to bootloader", Device::REBOOT_BOOTLOADER },
{ "Enter fastboot", Device::ENTER_FASTBOOT },
{ "Apply update from ADB", Device::APPLY_ADB_SIDELOAD },
{ "Apply update from SD card", Device::APPLY_SDCARD },
{ "Wipe data/factory reset", Device::WIPE_DATA },
{ "Wipe cache partition", Device::WIPE_CACHE },
{ "Mount /system", Device::MOUNT_SYSTEM },
{ "View recovery logs", Device::VIEW_RECOVERY_LOGS },
{ "Run graphics test", Device::RUN_GRAPHICS_TEST },
{ "Run locale test", Device::RUN_LOCALE_TEST },
{ "Enter rescue", Device::ENTER_RESCUE },
{ "Power off", Device::SHUTDOWN },
};
2、删除操作却是在recovery_main.cpp中,这里要先确认当下默认的菜单页有哪些,只能删除加载的项,否则会黑屏异常
cpp
diff --git a/recovery_main.cpp b/recovery_main.cpp
index 9a358aba..56b43321 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -448,6 +448,18 @@ int main(int argc, char** argv) {
device->RemoveMenuItemForAction(Device::ENTER_RESCUE);
}
+ // yfd remove those menus
+ device->RemoveMenuItemForAction(Device::REBOOT_BOOTLOADER);
+ device->RemoveMenuItemForAction(Device::ENTER_FASTBOOT);
+ device->RemoveMenuItemForAction(Device::APPLY_ADB_SIDELOAD);
+ device->RemoveMenuItemForAction(Device::MOUNT_SYSTEM);
+ device->RemoveMenuItemForAction(Device::VIEW_RECOVERY_LOGS);
+ device->RemoveMenuItemForAction(Device::RUN_GRAPHICS_TEST);
+ device->RemoveMenuItemForAction(Device::RUN_LOCALE_TEST);
+ device->RemoveMenuItemForAction(Device::APPLY_SDCARD);
+ device->RemoveMenuItemForAction(Device::ENTER_RESCUE);
+ device->RemoveMenuItemForAction(Device::SHUTDOWN);
+
ui->SetBackground(RecoveryUI::NONE);
if (show_text) ui->ShowText(true);
注意:第二条,如何选择要删除的菜单项,否则删除本身就已经清除或者不加载的项,直接就会黑屏,这里比较麻烦,如果此时黑屏,看问题就得recovery接串口看了。
如上~~Mark。