summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2016-03-22 20:23:28 +0100
committerDees Troy <dees_troy@teamw.in>2016-03-29 20:41:48 +0200
commit20eb0bc2d1f814a58c1859b88657392f1b6cfba2 (patch)
tree2e7b1d553ab3c63a17aefb9ada1821ba98340f9d
parentgui: rewrite theme loading code (diff)
downloadandroid_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.tar
android_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.tar.gz
android_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.tar.bz2
android_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.tar.lz
android_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.tar.xz
android_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.tar.zst
android_bootable_recovery-20eb0bc2d1f814a58c1859b88657392f1b6cfba2.zip
-rw-r--r--twinstall.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/twinstall.cpp b/twinstall.cpp
index a2eb72530..f512e278c 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2012 bigbiff/Dees_Troy TeamWin
+ Copyright 2012 to 2016 bigbiff/Dees_Troy TeamWin
This file is part of TWRP/TeamWin Recovery Project.
TWRP is free software: you can redistribute it and/or modify
@@ -41,6 +41,7 @@
#include "twrpDigest.hpp"
#include "twrp-functions.hpp"
#include "gui/gui.hpp"
+#include "gui/pages.hpp"
extern "C" {
#include "gui/gui.h"
#include "legacy_property_service.h"
@@ -93,6 +94,36 @@ static int switch_to_new_properties()
return 0;
}
+static int Install_Theme(const char* path, ZipArchive *Zip) {
+#ifdef TW_OEM_BUILD // We don't do custom themes in OEM builds
+ mzCloseZipArchive(Zip);
+ return INSTALL_CORRUPT;
+#else
+ const ZipEntry* xml_location = mzFindZipEntry(Zip, "ui.xml");
+
+ mzCloseZipArchive(Zip);
+ if (xml_location == NULL) {
+ return INSTALL_CORRUPT;
+ }
+ if (!PartitionManager.Mount_Settings_Storage(true))
+ return INSTALL_ERROR;
+ string theme_path = DataManager::GetSettingsStoragePath();
+ theme_path += "/TWRP/theme";
+ if (!TWFunc::Path_Exists(theme_path)) {
+ if (!TWFunc::Recursive_Mkdir(theme_path)) {
+ return INSTALL_ERROR;
+ }
+ }
+ theme_path += "/ui.zip";
+ if (TWFunc::copy_file(path, theme_path, 0644) != 0) {
+ return INSTALL_ERROR;
+ }
+ LOGINFO("Installing custom theme '%s' to '%s'\n", path, theme_path.c_str());
+ PageManager::RequestReload();
+ return INSTALL_SUCCESS;
+#endif
+}
+
static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache) {
const ZipEntry* binary_location = mzFindZipEntry(Zip, ASSUMED_UPDATE_BINARY_NAME);
string Temp_Binary = "/tmp/updater"; // Note: AOSP names it /tmp/update_binary (yes, with "_")
@@ -102,8 +133,6 @@ static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache)
FILE* child_data;
if (binary_location == NULL) {
- mzCloseZipArchive(Zip);
- gui_msg(Msg(msg::kError, "no_updater_binary=Could not find '{1}' in the zip file.")(ASSUMED_UPDATE_BINARY_NAME));
return INSTALL_CORRUPT;
}
@@ -300,6 +329,12 @@ extern "C" int TWinstall_zip(const char* path, int* wipe_cache) {
return INSTALL_CORRUPT;
}
ret_val = Run_Update_Binary(path, &Zip, wipe_cache);
+ if (ret_val == INSTALL_CORRUPT) {
+ // If no updater binary is found, check for ui.xml
+ ret_val = Install_Theme(path, &Zip);
+ if (ret_val == INSTALL_CORRUPT)
+ gui_msg(Msg(msg::kError, "no_updater_binary=Could not find '{1}' in the zip file.")(ASSUMED_UPDATE_BINARY_NAME));
+ }
sysReleaseMap(&map);
return ret_val;
}