From cf50da57422f70059a928f34ca731f18f569eab9 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 12 Jan 2015 21:59:07 -0600 Subject: Fix handling of custom themes after decrypt Loading a custom theme from the decrypt action was preventing the runPage function from exiting. This moves the loading of a custom theme out of the action. Change-Id: I86904b63a67a25ded56e3e1e569fe906264dc055 --- gui/gui.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gui/gui.cpp') diff --git a/gui/gui.cpp b/gui/gui.cpp index edf2d7671..61e5de1fb 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -805,6 +805,38 @@ error: return -1; } +extern "C" int gui_loadCustomResources(void) +{ +#ifndef TW_OEM_BUILD + if (!PartitionManager.Mount_Settings_Storage(false)) { + LOGERR("Unable to mount settings storage during GUI startup.\n"); + return -1; + } + + std::string theme_path = DataManager::GetSettingsStoragePath(); + theme_path += "/TWRP/theme/ui.zip"; + // Check for a custom theme + if (TWFunc::Path_Exists(theme_path)) { + // There is a custom theme, try to load it + if (PageManager::ReloadPackage("TWRP", theme_path)) { + // Custom theme failed to load, try to load stock theme + if (PageManager::ReloadPackage("TWRP", "/res/ui.xml")) { + LOGERR("Failed to load base packages.\n"); + goto error; + } + } + } + // Set the default package + PageManager::SelectPackage("TWRP"); +#endif + return 0; + +error: + LOGERR("An internal error has occurred: unable to load theme.\n"); + gGuiInitialized = 0; + return -1; +} + extern "C" int gui_start(void) { if (!gGuiInitialized) -- cgit v1.2.3