diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2014-11-08 15:13:40 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2014-11-08 15:13:40 +0100 |
commit | a2dc2f22d07cf408f7a8a42a6c9243c775b00593 (patch) | |
tree | 3d92dd86b451c029529d0442fab589312f895c8d /gui | |
parent | Release map after zip install (diff) | |
download | android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.tar android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.tar.gz android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.tar.bz2 android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.tar.lz android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.tar.xz android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.tar.zst android_bootable_recovery-a2dc2f22d07cf408f7a8a42a6c9243c775b00593.zip |
Diffstat (limited to 'gui')
-rw-r--r-- | gui/Android.mk | 2 | ||||
-rw-r--r-- | gui/pages.cpp | 27 |
2 files changed, 25 insertions, 4 deletions
diff --git a/gui/Android.mk b/gui/Android.mk index 96b2fee49..9cc043170 100644 --- a/gui/Android.mk +++ b/gui/Android.mk @@ -33,7 +33,7 @@ else LOCAL_SRC_FILES += hardwarekeyboard.cpp endif -LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ +LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libminzip LOCAL_MODULE := libguitwrp # Use this flag to create a build that simulates threaded actions like installing zips, backups, restores, and wipes for theme testing diff --git a/gui/pages.cpp b/gui/pages.cpp index 4df6a181f..bea39e902 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -32,12 +32,15 @@ #include <time.h> #include <unistd.h> #include <stdlib.h> +#include "../twrp-functions.hpp" #include <string> extern "C" { #include "../twcommon.h" #include "../minuitwrp/minui.h" +#include "../minzip/SysUtil.h" +#include "../minzip/Zip.h" } #include "rapidxml.hpp" @@ -918,11 +921,13 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string char* xmlFile = NULL; PageSet* pageSet = NULL; int ret; + MemMapping map; // Open the XML file LOGINFO("Loading package: %s (%s)\n", name.c_str(), package.c_str()); - if (1 || mzOpenZipArchive(package.c_str(), &zip)) + if (package.size() > 4 && package.substr(package.size() - 4) != ".zip") { + LOGINFO("Load XML directly\n"); // We can try to load the XML directly... struct stat st; if(stat(package.c_str(),&st) != 0) @@ -942,6 +947,18 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string } else { + LOGINFO("Loading zip theme\n"); + if (!TWFunc::Path_Exists(package)) + return -1; + if (sysMapFile(package.c_str(), &map) != 0) { + LOGERR("Failed to map '%s'\n", package.c_str()); + return -1; + } + if (mzOpenZipArchive(map.addr, map.length, &zip)) { + LOGERR("Unable to open zip archive '%s'\n", package.c_str()); + sysReleaseMap(&map); + return -1; + } pZip = &zip; const ZipEntry* ui_xml = mzFindZipEntry(&zip, "ui.xml"); if (ui_xml == NULL) @@ -987,14 +1004,18 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string mCurrentSet = pageSet; - if (pZip) + if (pZip) { mzCloseZipArchive(pZip); + sysReleaseMap(&map); + } return ret; error: LOGERR("An internal error has occurred.\n"); - if (pZip) + if (pZip) { mzCloseZipArchive(pZip); + sysReleaseMap(&map); + } if (xmlFile) free(xmlFile); return -1; |