EFI_STATUS SettingsMenuShow ( VOID ) { MENU_ENTRY *Entry; MENU_OPTION* Menu; // create menu Menu = MenuCreate(); Menu->Title = AsciiStrDup("Settings"); Menu->BackCallback = SettingsMenuBackCallback; // file explorer Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show File Explorer"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-file-explorer"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowFileExplorerCallback; MenuAddEntry(Menu, Entry); MenuStackPush(Menu); return EFI_SUCCESS; }
STATIC EFI_STATUS FastbootCallback ( IN MENU_ENTRY* This ) { mFastbootMenu->Selection = 0; MenuStackPush(mFastbootMenu); return EFI_SUCCESS; }
EFI_STATUS SettingsMenuShow ( VOID ) { MENU_ENTRY *Entry; MENU_OPTION* Menu; // create menu Menu = MenuCreate(); Menu->Title = AsciiStrDup("Settings"); Menu->BackCallback = SettingsMenuBackCallback; // UEFI options Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show UEFI boot options"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-uefi-options"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowUEFIOptionsCallback; MenuAddEntry(Menu, Entry); // file explorer Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show File Explorer"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-file-explorer"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowFileExplorerCallback; MenuAddEntry(Menu, Entry); // fastboot Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show Fastboot"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-fastboot"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowFastbootCallback; MenuAddEntry(Menu, Entry); // fastboot Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Force selinux to permissive"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("boot-force-permissive"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowPermissiveCallback; MenuAddEntry(Menu, Entry); MenuStackPush(Menu); return EFI_SUCCESS; }
INT32 main ( IN INT32 Argc, IN CHAR8 **Argv ) { EFI_STATUS Status; MENU_ENTRY *Entry; // get LKAPi mLKApi = GetLKApi(); // init fastboot #if defined (MDE_CPU_ARM) FastbootCommandsAdd(); #endif // init libboot libboot_init(); Status = gBS->LocateProtocol ( &gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&gEfiDevicePathToTextProtocol ); if (EFI_ERROR (Status)) { return -1; } Status = gBS->LocateProtocol ( &gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&gEfiDevicePathFromTextProtocol ); if (EFI_ERROR (Status)) { return -1; } // set default values if(!UtilVariableExists(L"multiboot-debuglevel", &gEFIDroidVariableGuid)) UtilSetEFIDroidVariable("multiboot-debuglevel", "4"); if(!UtilVariableExists(L"fastboot-enable-boot-patch", &gEFIDroidVariableGuid)) UtilSetEFIDroidVariable("fastboot-enable-boot-patch", "1"); if(!UtilVariableExists(L"ui-show-file-explorer", &gEFIDroidVariableGuid)) SettingBoolSet("ui-show-file-explorer", FALSE); if(!UtilVariableExists(L"ui-show-uefi-options", &gEFIDroidVariableGuid)) SettingBoolSet("ui-show-uefi-options", FALSE); if(!UtilVariableExists(L"ui-show-fastboot", &gEFIDroidVariableGuid)) SettingBoolSet("ui-show-fastboot", TRUE); if(!UtilVariableExists(L"boot-force-permissive", &gEFIDroidVariableGuid)) SettingBoolSet("boot-force-permissive", FALSE); // init UI Status = MenuInit(); if (EFI_ERROR (Status)) { #if defined (MDE_CPU_ARM) FastbootInit(); #endif return -1; } // create menus mBootMenuMain = MenuCreate(); mPowerMenu = MenuCreate(); mPowerMenu->BackCallback = PowerMenuBackCallback; mPowerMenu->HideBackIcon = TRUE; #if defined (MDE_CPU_ARM) mFastbootMenu = MenuCreate(); mFastbootMenu->Title = AsciiStrDup("Please Select OS"); mFastbootMenu->BackCallback = FastbootBackCallback; #endif mBootMenuMain->Title = AsciiStrDup("Please Select OS"); mBootMenuMain->ActionIcon = libaroma_stream_ramdisk("icons/ic_settings_black_24dp.png"); mBootMenuMain->ActionCallback = MainMenuActionCallback; mBootMenuMain->ItemFlags = MENU_ITEM_FLAG_SEPARATOR_ALIGN_TEXT; #if defined (MDE_CPU_ARM) // add android options AndroidLocatorInit(); AndroidLocatorAddItems(); #endif // add default EFI options AddEfiBootOptions(); // GROUP: Tools Entry = MenuCreateGroupEntry(); Entry->Name = AsciiStrDup("Tools"); MenuAddEntry(mBootMenuMain, Entry); // add file explorer option Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/fileexplorer.png"); Entry->Name = AsciiStrDup("File Explorer"); Entry->Callback = FileExplorerCallback; Entry->HideBootMessage = TRUE; Entry->Update = FileExplorerUpdate; MenuAddEntry(mBootMenuMain, Entry); #if defined (MDE_CPU_ARM) // add fastboot option Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/android.png"); Entry->Name = AsciiStrDup("Fastboot"); Entry->Callback = FastbootCallback; Entry->HideBootMessage = TRUE; Entry->Update = FastbootMenuEntryUpdate; MenuAddEntry(mBootMenuMain, Entry); #endif // add reboot option Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot.png"); Entry->Name = AsciiStrDup("Reboot"); Entry->Callback = RebootCallback; Entry->Private = NULL; Entry->LongPressCallback = RebootLongPressCallback; MenuAddEntry(mBootMenuMain, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/power_off.png"); Entry->Name = AsciiStrDup("Power Off"); Entry->Callback = PowerOffCallback; MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot.png"); Entry->Name = AsciiStrDup("Reboot"); Entry->Callback = RebootCallback; Entry->Private = NULL; MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot_recovery.png"); Entry->Name = AsciiStrDup("Reboot to Recovery"); Entry->Callback = RebootCallback; Entry->Private = UnicodeStrDup(L"recovery"); MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot_bootloader.png"); Entry->Name = AsciiStrDup("Reboot to Bootloader"); Entry->Callback = RebootCallback; Entry->Private = UnicodeStrDup(L"bootloader"); MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/download_mode.png"); Entry->Name = AsciiStrDup("Enter Download Mode"); Entry->Callback = RebootCallback; Entry->Private = UnicodeStrDup(L"download"); MenuAddEntry(mPowerMenu, Entry); // show previous boot error CHAR8* EFIDroidErrorStr = UtilGetEFIDroidVariable("EFIDroidErrorStr"); if (EFIDroidErrorStr != NULL) { MenuShowMessage("Previous boot failed", EFIDroidErrorStr); // delete variable UtilSetEFIDroidVariable("EFIDroidErrorStr", NULL); // backup variable UtilSetEFIDroidVariable("EFIDroidErrorStrPrev", EFIDroidErrorStr); // free pool FreePool(EFIDroidErrorStr); } // get last boot entry LAST_BOOT_ENTRY* LastBootEntry = UtilGetEFIDroidDataVariable(L"LastBootEntry"); if(LastBootEntry) UtilSetEFIDroidDataVariable(L"LastBootEntry", NULL, 0); #if defined (MDE_CPU_ARM) // run recovery mode handler if (mLKApi) { if(!AsciiStrCmp(mLKApi->platform_get_uefi_bootpart(), "recovery") || mLKApi->platform_get_uefi_bootmode()==LKAPI_UEFI_BM_RECOVERY) { AndroidLocatorHandleRecoveryMode(LastBootEntry); } } #endif // free last boot entry if(LastBootEntry) FreePool(LastBootEntry); // clear the watchdog timer gBS->SetWatchdogTimer (0, 0, 0, NULL); // first boot? UINTN* LastBootVersion = UtilGetEFIDroidDataVariable(L"last-boot-version"); if(LastBootVersion==NULL) { UINTN NewValue = 1; UtilSetEFIDroidDataVariable(L"last-boot-version", &NewValue, sizeof(NewValue)); MenuShowTutorial(); } // show main menu MenuStackPush(mBootMenuMain); MenuEnter (0, TRUE); MenuDeInit(); return 0; }