PayloadLoaderInstaller/source/ApplicationState.cpp

431 lines
20 KiB
C++
Raw Normal View History

2020-10-14 13:54:25 +02:00
#include "ApplicationState.h"
2022-07-24 17:07:42 +02:00
#include "../build/safe_payload.h"
#include "utils/ScreenUtils.h"
#include "utils/StringTools.h"
2022-07-24 17:07:42 +02:00
#include "utils/WiiUScreen.h"
2020-10-14 13:54:25 +02:00
#include <iosuhax.h>
2022-07-24 17:07:42 +02:00
#include <sysapp/launch.h>
2020-10-14 13:54:25 +02:00
extern "C" void OSShutdown();
2020-12-02 15:57:13 +01:00
void ApplicationState::changeState(eGameState newState) {
this->state = newState;
2020-10-14 13:54:25 +02:00
2020-12-02 15:57:13 +01:00
menu.clear();
2020-10-14 13:54:25 +02:00
if (this->state == STATE_ERROR) {
2020-12-02 15:57:13 +01:00
menu.addText("The installation failed:");
menu.addText();
menu.addText("Error: " + ErrorMessage());
menu.addText("Description: " + ErrorDescription());
menu.addText();
menu.addText();
menu.addOption("Press A to return to the Wii U Menu.", STATE_EXIT_SYSMENU);
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_WELCOME_SCREEN) {
menu.addText("Welcome to the Payload-Loader Installer!");
2020-12-02 15:57:13 +01:00
menu.addText("Do you want to check if an installation is possible?");
menu.addText();
menu.addOption("Check", STATE_GET_APP_INFORMATION);
menu.addOption("Exit", STATE_EXIT_SYSMENU);
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_GET_APP_INFORMATION) {
2020-12-02 15:57:13 +01:00
menu.addText("Getting app information");
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_CHECK_PATCH_POSSIBLE) {
2020-12-02 15:57:13 +01:00
menu.addText("Check if console can be patched.");
} else if (this->state == STATE_CHECK_COLDBOOT_STATUS) {
menu.addText("Check if coldboot can be enabled.");
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_CHECK_REMOVAL_POSSIBLE) {
menu.addText("Check if Payload-Loader can be removed.");
2020-12-02 15:57:13 +01:00
} else if (this->state == STATE_APP_INCOMPATIBLE) {
menu.addText("Sorry, Payload-Loader cannot be safely installed to:");
2020-12-02 15:57:13 +01:00
menu.addText(std::string(appInfo->appName));
menu.addText();
menu.addText("Additional informations:");
2021-10-17 15:28:14 +02:00
auto showCheckResult = [&](const std::string &name, bool canPatch, bool patched) {
2020-12-02 15:57:13 +01:00
if (patched) {
2020-12-04 10:39:36 +01:00
menu.addText("[ X ] " + name + " is already patched!");
2020-12-02 15:57:13 +01:00
} else if (canPatch) {
2020-12-04 10:39:36 +01:00
menu.addText("[ X ] " + name + " can be patched!");
2020-12-01 02:05:24 +01:00
} else {
2020-12-04 10:39:36 +01:00
menu.addText("[ ] " + name + " can NOT be patched!");
2020-10-14 13:54:25 +02:00
}
2020-12-02 15:57:13 +01:00
};
2020-12-02 16:19:23 +01:00
if (this->tmdValid) {
menu.addText("[ X ] title.tmd is valid!");
} else {
menu.addText("[ ] title.tmd is NOT valid!");
}
2020-12-02 15:57:13 +01:00
showCheckResult("title.fst", this->fstPatchPossible, this->fstAlreadyPatched);
showCheckResult("cos.xml", this->cosPatchPossible, this->cosAlreadyPatched);
showCheckResult("safe.rpx", true, this->rpxAlreadyPatched);
menu.addText();
menu.addOption("Exit", STATE_EXIT_SYSMENU);
} else if (this->state == STATE_MAIN_MENU) {
menu.addText("Payload-Loader " + std::string(this->alreadyInstalledAndUpdated ? "is" : "can be") + " installed to:");
2020-12-02 15:57:13 +01:00
menu.addText(std::string(appInfo->appName));
menu.addText();
menu.addOption("Install / Update", STATE_INSTALL_CONFIRM_DIALOG);
2020-12-02 15:57:13 +01:00
menu.addOption("Boot options", STATE_BOOT_MENU);
if (this->removalPossible) {
menu.addOption("Remove", STATE_REMOVE_CONFIRM_DIALOG);
2020-10-14 13:54:25 +02:00
}
2020-12-02 15:57:13 +01:00
menu.addOption("Exit", STATE_EXIT_SYSMENU);
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_CONFIRM_DIALOG) {
if (this->alreadyInstalledAndUpdated) {
menu.addText("Everything is already up to date.");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
} else {
if (this->coldbootTitleId == this->appInfo->titleId) {
menu.addText("Before you can install/update Payload-Loader you need to change");
menu.addText("the coldboot title back to Wii U Menu");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
} else {
menu.addText("Are you REALLY sure you want to install Payload-Loader?");
menu.addText("Installing could permanently damage your console");
menu.addText();
menu.addText("After the installation the following app will turn into");
menu.addText("a payload.elf loader. Loading it without a sd card will");
menu.addText("ALWAYS open the Wii U Menu");
menu.addText("- " + std::string(appInfo->appName));
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
menu.addOption("Install", STATE_INSTALL_STARTED);
}
}
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_STARTED) {
2020-12-02 15:57:13 +01:00
menu.addText("Installing...");
2020-12-03 23:01:55 +01:00
} else if (this->state == STATE_INSTALL_BACKUP) {
menu.addText("... backing up files");
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_FST) {
2020-12-02 15:57:13 +01:00
menu.addText("... patching title.fst");
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_COS) {
2020-12-02 15:57:13 +01:00
menu.addText("... patching cos.xml");
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_RPX) {
2020-12-02 15:57:13 +01:00
menu.addText("... install safe.rpx");
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_SUCCESS) {
menu.addText("Payload-Loader was successfully installed");
2020-12-02 15:57:13 +01:00
menu.addText();
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_REMOVE_CONFIRM_DIALOG) {
if (this->systemXMLAlreadyPatched) {
menu.addText("Before you can remove Payload-Loader you need to switch");
menu.addText("the system boot title back to the Wii U Menu");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
} else {
menu.addText("Are you REALLY sure you want to remove Payload-Loader?");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
menu.addOption("Remove", STATE_REMOVE_STARTED);
}
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_REMOVE_STARTED) {
2020-12-02 15:57:13 +01:00
menu.addText("Removing...");
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_REMOVE_COLDBOOT) {
2020-12-02 15:57:13 +01:00
menu.addText("... remove system.xml coldboot patches");
2021-12-26 15:03:22 +01:00
} else if (this->state == STATE_REMOVE_PAYLOAD_LOADER) {
menu.addText("... remove Payload-Loader application patches");
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_REMOVE_SUCCESS) {
menu.addText("Payload-Loader was successfully removed");
2020-12-02 15:57:13 +01:00
menu.addText();
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
} else if (this->state == STATE_BOOT_MENU) {
menu.addText("System is currently booting into: ");
2022-07-24 17:07:42 +02:00
std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId);
std::string titleName = this->coldbootTitle ? std::string(this->coldbootTitle->name) : "Unknown title";
2020-12-02 15:57:13 +01:00
menu.addText(titleId + " (" + titleName + ")");
menu.addText();
if (this->systemXMLRestorePossible && this->systemXMLAlreadyPatched) {
menu.addText("If you have modified the Wii U Menu this could make");
menu.addText("your console unusable");
menu.addText();
menu.addOption("Switch back to Wii U Menu", STATE_BOOT_SWITCH_SYSMENU);
2020-12-02 15:57:13 +01:00
} else if (this->systemXMLPatchAllowed) {
menu.addOption("Switch to Payload-Loader", STATE_BOOT_SWITCH_PAYLOAD_LOADER);
} else if (this->systemXMLPatchAllowedButNoRPXCheck) {
menu.addText("Your RPX is not as expected. You probably");
menu.addText("need to update or re-install Payload-Loader first.");
menu.addText();
2020-12-02 15:57:13 +01:00
} else if (this->systemXMLPatchPossible) {
menu.addText("To change the system boot title to Payload-Loader, you need to");
menu.addText("launch this installer from an already running Payload-Loader");
2020-12-02 15:57:13 +01:00
menu.addText("instance, in order to verify that the installation");
menu.addText("is working properly.");
menu.addText();
menu.addText("After installing Payload-Loader, reboot the console, open the");
menu.addText("Health & Safety app and relaunch the Payload-Loader installer.");
2020-12-02 15:57:13 +01:00
menu.addText();
} else {
menu.addText("Sorry, your system.xml file has not yet been tested");
menu.addText("with this tool. Boot options cannot be modified.");
menu.addText();
}
menu.addOption("Back", STATE_MAIN_MENU);
2021-12-26 15:03:22 +01:00
} else if (this->state == STATE_BOOT_SWITCH_PAYLOAD_LOADER) {
2020-12-02 15:57:13 +01:00
menu.addText("Changing system.xml to boot " + std::string(this->appInfo->appName) + " ...");
} else if (this->state == STATE_BOOT_SWITCH_SYSMENU) {
menu.addText("Changing system.xml to boot System Menu ...");
} else if (this->state == STATE_BOOT_SWITCH_SUCCESS) {
menu.addText("Boot title successfully updated!");
menu.addText();
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
2020-10-14 13:54:25 +02:00
}
2020-12-02 15:57:13 +01:00
this->state = newState;
}
void ApplicationState::render() {
menu.render();
2020-10-14 13:54:25 +02:00
}
void ApplicationState::update(Input *input) {
if (this->state == STATE_ERROR) {
OSEnableHomeButtonMenu(true);
} else if (this->state == STATE_GET_APP_INFORMATION) {
getAppInformation();
} else if (this->state == STATE_CHECK_PATCH_POSSIBLE) {
checkPatchPossible();
2020-12-02 15:57:13 +01:00
} else if (this->state == STATE_CHECK_COLDBOOT_STATUS) {
checkColdbootStatus();
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_CHECK_REMOVAL_POSSIBLE) {
checkRemovalPossible();
2020-12-02 15:57:13 +01:00
} else if (this->state == STATE_COMPATIBILITY_RESULTS) {
if (this->installPossible) {
changeState(STATE_MAIN_MENU);
2020-10-14 13:54:25 +02:00
} else {
2020-12-02 15:57:13 +01:00
changeState(STATE_APP_INCOMPATIBLE);
2020-10-14 13:54:25 +02:00
}
} else if (this->state == STATE_INSTALL_STARTED) {
2020-12-02 15:57:13 +01:00
OSEnableHomeButtonMenu(false);
changeState(STATE_INSTALL_BACKUP);
} else if (this->state == STATE_INSTALL_BACKUP) {
auto result = InstallerService::backupAppFiles(this->appInfo->path);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
2020-12-02 15:57:13 +01:00
setError(ERROR_INSTALLER_ERROR);
} else {
2020-12-02 15:57:13 +01:00
changeState(STATE_INSTALL_FST);
}
2020-10-14 13:54:25 +02:00
} else if (this->state == STATE_INSTALL_FST) {
2022-07-24 17:07:42 +02:00
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
2020-10-14 13:54:25 +02:00
if (result != InstallerService::SUCCESS) {
this->installerError = result;
2020-12-02 15:57:13 +01:00
setError(ERROR_INSTALLER_ERROR);
2020-10-14 13:54:25 +02:00
} else {
2020-12-02 15:57:13 +01:00
changeState(STATE_INSTALL_COS);
2020-10-14 13:54:25 +02:00
}
} else if (this->state == STATE_INSTALL_COS) {
2022-07-24 17:07:42 +02:00
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
2020-10-14 13:54:25 +02:00
if (result != InstallerService::SUCCESS) {
this->installerError = result;
2020-12-02 15:57:13 +01:00
setError(ERROR_INSTALLER_ERROR);
2020-10-14 13:54:25 +02:00
} else {
2020-12-02 15:57:13 +01:00
changeState(STATE_INSTALL_RPX);
2020-10-14 13:54:25 +02:00
}
} else if (this->state == STATE_INSTALL_RPX) {
auto result = InstallerService::copyRPX(this->appInfo->path, root_rpx, root_rpx_size, RPX_HASH);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);
} else {
2020-12-02 15:57:13 +01:00
changeState(STATE_INSTALL_SUCCESS);
2020-12-01 02:05:24 +01:00
}
} else if (this->state == STATE_REMOVE_STARTED) {
2020-12-02 15:57:13 +01:00
OSEnableHomeButtonMenu(false);
2020-12-02 15:57:13 +01:00
if (this->systemXMLAlreadyPatched) {
// It's only possible to remove aroma when it's not coldbooting into aroma.
// changeState(STATE_REMOVE_COLDBOOT);
setError(ERROR_INSTALLER_ERROR);
2020-12-02 15:57:13 +01:00
} else {
2021-12-26 15:03:22 +01:00
changeState(STATE_REMOVE_PAYLOAD_LOADER);
2020-12-02 15:57:13 +01:00
}
2020-12-01 02:05:24 +01:00
} else if (this->state == STATE_REMOVE_COLDBOOT) {
2020-12-02 15:57:13 +01:00
auto result = InstallerService::setBootTitle(*this->systemMenuTitleId);
2020-12-01 02:05:24 +01:00
if (result != InstallerService::SUCCESS) {
this->installerError = result;
2020-12-02 15:57:13 +01:00
setError(ERROR_INSTALLER_ERROR);
2020-12-01 02:05:24 +01:00
} else {
2021-12-26 15:03:22 +01:00
changeState(STATE_REMOVE_PAYLOAD_LOADER);
2020-12-01 02:05:24 +01:00
}
2021-12-26 15:03:22 +01:00
} else if (this->state == STATE_REMOVE_PAYLOAD_LOADER) {
2020-12-01 02:05:24 +01:00
auto result = InstallerService::restoreAppFiles(this->appInfo->path);
if (result != InstallerService::SUCCESS) {
2020-12-02 15:57:13 +01:00
this->installerError = result;
2020-12-01 02:05:24 +01:00
setError(ERROR_INSTALLER_ERROR);
2020-12-02 15:57:13 +01:00
} else {
changeState(STATE_REMOVE_SUCCESS);
}
} else if (this->state == STATE_BOOT_SWITCH_SYSMENU) {
OSEnableHomeButtonMenu(false);
auto result = InstallerService::setBootTitle(*this->systemMenuTitleId);
if (result != InstallerService::SUCCESS) {
2020-12-01 02:05:24 +01:00
this->installerError = result;
2020-12-02 15:57:13 +01:00
setError(ERROR_INSTALLER_ERROR);
2020-12-01 02:05:24 +01:00
} else {
2020-12-02 15:57:13 +01:00
changeState(STATE_BOOT_SWITCH_SUCCESS);
2020-12-01 02:05:24 +01:00
}
2021-12-26 15:03:22 +01:00
} else if (this->state == STATE_BOOT_SWITCH_PAYLOAD_LOADER) {
2020-12-02 15:57:13 +01:00
OSEnableHomeButtonMenu(false);
auto result = InstallerService::setBootTitle(this->appInfo->titleId);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);
} else {
changeState(STATE_BOOT_SWITCH_SUCCESS);
2020-12-01 02:05:24 +01:00
}
2020-12-02 15:57:13 +01:00
} else if (this->state == STATE_EXIT_SYSMENU) {
SYSLaunchMenu();
} else if (this->state == STATE_EXIT_SHUTDOWN) {
OSShutdown();
2020-10-14 13:54:25 +02:00
}
2020-12-02 15:57:13 +01:00
menu.update(input);
2020-10-14 13:54:25 +02:00
}
ApplicationState::ApplicationState() {
menu.setOptionsCallback([this](auto &&newState) { changeState(std::forward<decltype(newState)>(newState)); });
menu.setHeader("Payload-Loader Installer");
2021-12-26 15:03:30 +01:00
menu.setFooter("By Maschell, rw-r-r-0644, GaryOderNichts");
2020-12-02 15:57:13 +01:00
changeState(STATE_WELCOME_SCREEN);
2020-10-14 13:54:25 +02:00
DEBUG_FUNCTION_LINE("State has changed to \"STATE_WELCOME_SCREEN\"");
}
void ApplicationState::checkPatchPossible() {
DEBUG_FUNCTION_LINE("Check patch possible");
this->fstAlreadyPatched = (InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash) == InstallerService::SUCCESS);
this->rpxAlreadyPatched = (InstallerService::checkRPXAlreadyValid(this->appInfo->path, RPX_HASH) == InstallerService::SUCCESS);
this->cosAlreadyPatched = (InstallerService::checkCOSAlreadyValid(this->appInfo->path, this->appInfo->cosHash) == InstallerService::SUCCESS);
2022-07-24 17:07:42 +02:00
this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS);
2020-10-14 13:54:25 +02:00
InstallerService::eResults result;
2020-10-14 13:54:25 +02:00
this->fstPatchPossible = ((result = InstallerService::checkFST(this->appInfo->path, this->appInfo->fstHash)) == InstallerService::SUCCESS);
if (result != InstallerService::SUCCESS) {
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
}
this->cosPatchPossible = ((result = InstallerService::checkCOS(this->appInfo->path, this->appInfo->cosHash)) == InstallerService::SUCCESS);
if (result != InstallerService::SUCCESS) {
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
}
2020-12-02 15:57:13 +01:00
2022-07-24 17:07:42 +02:00
this->installPossible = this->fstPatchPossible && this->cosPatchPossible && this->tmdValid;
this->alreadyInstalledAndUpdated = this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && this->rpxAlreadyPatched;
2020-12-02 15:57:13 +01:00
changeState(STATE_CHECK_COLDBOOT_STATUS);
}
void ApplicationState::checkColdbootStatus() {
DEBUG_FUNCTION_LINE("Check coldboot status");
// Read the current coldboot title from the system.xml
2020-12-02 15:57:13 +01:00
this->coldbootTitleId = InstallerService::getColdbootTitleId("storage_slc_installer:/config");
// Try getting more information about the current coldboot title.
2020-12-02 15:57:13 +01:00
this->coldbootTitle = nullptr;
for (int i = 0; GameList[i].tid != 0; i++) {
if (GameList[i].tid == this->coldbootTitleId) {
this->coldbootTitle = &GameList[i];
break;
}
}
InstallerService::eResults result;
this->systemMenuTitleId = InstallerService::getSystemMenuTitleId();
// Check if setting the title id to H&S results in a hash we are expecting
2020-10-14 13:54:25 +02:00
this->systemXMLPatchPossible = ((result = InstallerService::checkSystemXML("storage_slc_installer:/config", this->appInfo->titleId)) == InstallerService::SUCCESS);
if (result != InstallerService::SUCCESS) {
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
}
2020-12-02 15:57:13 +01:00
if (this->systemMenuTitleId) {
// Check if setting the title id back to Wii U menu results in a hash we are expecting
2020-12-02 15:57:13 +01:00
this->systemXMLRestorePossible = ((result = InstallerService::checkSystemXML("storage_slc_installer:/config", *this->systemMenuTitleId)) == InstallerService::SUCCESS);
if (result != InstallerService::SUCCESS) {
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
}
2020-12-01 02:05:24 +01:00
} else {
2020-12-02 15:57:13 +01:00
this->systemXMLRestorePossible = false;
2020-12-01 02:05:24 +01:00
}
2020-12-02 15:57:13 +01:00
if (this->systemMenuTitleId) {
// If we are not booting into the Wii U menu, we know it's already patched.
this->systemXMLAlreadyPatched = (this->coldbootTitleId != *this->systemMenuTitleId);
} else {
// If we for some fail to get the "systemMenuTitleId" we can still if the system.xml is patched
// by comparing with the H&S title id
this->systemXMLAlreadyPatched = (this->coldbootTitleId == this->appInfo->titleId);
}
2020-12-02 15:57:13 +01:00
2022-07-24 17:07:42 +02:00
this->systemXMLPatchAllowed = this->systemXMLPatchPossible && this->alreadyInstalledAndUpdated && InstallerService::isColdBootAllowed();
this->systemXMLPatchAllowedButNoRPXCheck = this->systemXMLPatchPossible && this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && InstallerService::isColdBootAllowed();
2020-12-02 15:57:13 +01:00
changeState(STATE_CHECK_REMOVAL_POSSIBLE);
2020-12-01 02:05:24 +01:00
}
void ApplicationState::checkRemovalPossible() {
2020-12-02 15:57:13 +01:00
DEBUG_FUNCTION_LINE("Check removal possible");
2020-12-01 02:05:24 +01:00
// We can only restore if a restore of the system.xml is possible or it isn't patched at all.
this->removalPossible = !this->systemXMLAlreadyPatched || this->systemXMLRestorePossible;
// And we can only install if we have a backup.
2020-12-02 15:57:13 +01:00
if (this->removalPossible) {
2020-12-01 02:05:24 +01:00
this->removalPossible &= InstallerService::isBackupAvailable(this->appInfo->path);
}
2020-12-02 15:57:13 +01:00
changeState(STATE_COMPATIBILITY_RESULTS);
2020-10-14 13:54:25 +02:00
}
void ApplicationState::getAppInformation() {
DEBUG_FUNCTION_LINE("About to call getInstalledAppInformation");
this->appInfo = InstallerService::getInstalledAppInformation();
if (!this->appInfo) {
DEBUG_FUNCTION_LINE("ERROR =(");
2020-12-02 15:57:13 +01:00
setError(ERROR_NO_APP_INSTALLED);
2020-10-14 13:54:25 +02:00
} else {
DEBUG_FUNCTION_LINE("WORKED!");
2020-12-02 15:57:13 +01:00
changeState(STATE_CHECK_PATCH_POSSIBLE);
2020-10-14 13:54:25 +02:00
}
}
std::string ApplicationState::ErrorMessage() {
if (this->error == ERROR_NONE) {
return "NONE";
} else if (this->error == ERROR_NO_APP_INSTALLED) {
return "ERROR_NO_APP_INSTALLED";
} else if (this->error == ERROR_IOSUHAX_FAILED) {
return "ERROR_IOSUHAX_FAILED";
} else if (this->error == ERROR_INSTALLER_ERROR) {
return InstallerService::ErrorMessage(this->installerError);
} else if (this->error == ERROR_UNEXPECTED_STATE) {
return "ERROR_UNEXPECTED_STATE";
2020-10-14 13:54:25 +02:00
}
return "UNKNOWN_ERROR";
}
std::string ApplicationState::ErrorDescription() {
if (this->error == ERROR_NONE) {
return "-";
} else if (this->error == ERROR_NO_APP_INSTALLED) {
return "No compatible application is installed. A safe installation is not possible.";
} else if (this->error == ERROR_INSTALLER_ERROR) {
return InstallerService::ErrorDescription(this->installerError);
} else if (this->error == ERROR_IOSUHAX_FAILED) {
return "Failed to init IOSUHAX.";
} else if (this->error == ERROR_UNEXPECTED_STATE) {
return "ERROR_UNEXPECTED_STATE";
2020-10-14 13:54:25 +02:00
}
return "UNKNOWN_ERROR";
}
void ApplicationState::setError(eErrorState err) {
this->error = err;
OSEnableHomeButtonMenu(true);
2020-12-02 15:57:13 +01:00
changeState(STATE_ERROR);
2020-10-14 13:54:25 +02:00
}