custom theme: fix libziparchive loading of custom themes
Change-Id: Ia23a9dcd24fcbb61cb5e1df366a4325d20d777b2
This commit is contained in:
+5
-7
@@ -1225,15 +1225,13 @@ char* PageManager::LoadFileToBuffer(std::string filename, ZipArchiveHandle packa
|
||||
} else {
|
||||
LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' from zip\n", filename.c_str());
|
||||
ZipEntry binary_entry;
|
||||
if (FindEntry(package, filename, &binary_entry) == 0) {
|
||||
// if (!package->EntryExists(filename)) {
|
||||
if (FindEntry(package, filename, &binary_entry) != 0) {
|
||||
LOGERR("Unable to locate '%s' in zip file\n", filename.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Allocate the buffer for the file
|
||||
len = binary_entry.uncompressed_length;
|
||||
// len = package->GetUncompressedSize(filename);
|
||||
buffer = (char*) malloc(len + 1);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
@@ -1241,7 +1239,6 @@ char* PageManager::LoadFileToBuffer(std::string filename, ZipArchiveHandle packa
|
||||
int32_t err =
|
||||
ExtractToMemory(package, &binary_entry, reinterpret_cast<uint8_t*>(buffer), len);
|
||||
if (err != 0) {
|
||||
// if (!package->ExtractToBuffer(filename, (unsigned char*) buffer)) {
|
||||
LOGERR("Unable to extract '%s'\n", filename.c_str());
|
||||
free(buffer);
|
||||
return NULL;
|
||||
@@ -1311,7 +1308,7 @@ void PageManager::LoadLanguageList(ZipArchiveHandle package) {
|
||||
TWFunc::removeDir(TWRES "customlanguages", true);
|
||||
if (package) {
|
||||
TWFunc::Recursive_Mkdir(TWRES "customlanguages");
|
||||
ExtractPackageRecursive(package, "", TWRES "customlanguages", nullptr, nullptr);
|
||||
ExtractPackageRecursive(package, "/", TWRES "customlanguages", nullptr, nullptr);
|
||||
|
||||
// package->ExtractRecursive("languages", TWRES "customlanguages/");
|
||||
LoadLanguageListDir(TWRES "customlanguages/");
|
||||
@@ -1374,15 +1371,16 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
|
||||
tw_y_offset = 0;
|
||||
tw_w_offset = 0;
|
||||
tw_h_offset = 0;
|
||||
if (!TWFunc::Path_Exists(package))
|
||||
if (!TWFunc::Path_Exists(package)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ZipArchiveHandle Zip;
|
||||
int err = OpenArchive(package.c_str(), &Zip);
|
||||
|
||||
if (err != 0)
|
||||
return -1;
|
||||
|
||||
|
||||
ctx.zip = Zip;
|
||||
mainxmlfilename = "ui.xml";
|
||||
LoadLanguageList(ctx.zip);
|
||||
|
||||
+1
-2
@@ -58,13 +58,12 @@ int Resource::ExtractResource(ZipArchiveHandle pZip, std::string folderName, std
|
||||
|
||||
std::string src = folderName + "/" + fileName + fileExtn;
|
||||
ZipEntry binary_entry;
|
||||
if (FindEntry(pZip, src, &binary_entry) != 0) {
|
||||
if (FindEntry(pZip, src, &binary_entry) == 0) {
|
||||
android::base::unique_fd fd(
|
||||
open(destFile.c_str(), O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, 0666));
|
||||
if (fd == -1) {
|
||||
return -1;
|
||||
}
|
||||
// if (!pZip->ExtractEntry(src, destFile, 0666))
|
||||
int32_t err = ExtractEntryToFile(pZip, &binary_entry, fd);
|
||||
if (err != 0)
|
||||
return -1;
|
||||
|
||||
+2
-1
@@ -54,9 +54,10 @@ bool ExtractPackageRecursive(ZipArchiveHandle zip, const std::string& zip_path,
|
||||
if (!zip_path.empty() && zip_path.back() != '/') {
|
||||
prefix_path += '/';
|
||||
}
|
||||
const std::string zip_prefix(prefix_path.c_str());
|
||||
|
||||
const std::string zip_prefix(prefix_path.c_str());
|
||||
int ret = StartIteration(zip, &cookie, zip_prefix, nullptr);
|
||||
|
||||
if (ret != 0) {
|
||||
LOG(ERROR) << "failed to start iterating zip entries.";
|
||||
return false;
|
||||
|
||||
@@ -85,15 +85,10 @@ static void Decrypt_Page(bool SkipDecryption, bool datamedia) {
|
||||
DataManager::SetValue("tw_crypto_user_id", "0");
|
||||
if (gui_startPage("decrypt", 1, 1) != 0) {
|
||||
LOGERR("Failed to start decrypt GUI page.\n");
|
||||
} else {
|
||||
// Check for and load custom theme if present
|
||||
TWFunc::check_selinux_support();
|
||||
gui_loadCustomResources();
|
||||
}
|
||||
}
|
||||
} else if (datamedia) {
|
||||
PartitionManager.Update_System_Details();
|
||||
TWFunc::check_selinux_support();
|
||||
if (tw_get_default_metadata(DataManager::GetSettingsStoragePath().c_str()) != 0) {
|
||||
LOGINFO("Failed to get default contexts and file mode for storage files.\n");
|
||||
} else {
|
||||
@@ -221,6 +216,9 @@ static void process_recovery_mode(twrpAdbBuFifo* adb_bu_fifo, bool skip_decrypti
|
||||
#endif
|
||||
|
||||
Decrypt_Page(skip_decryption, datamedia);
|
||||
// Check for and load custom theme if present
|
||||
TWFunc::check_selinux_support();
|
||||
gui_loadCustomResources();
|
||||
PartitionManager.Output_Partition_Logging();
|
||||
|
||||
// Fixup the RTC clock on devices which require it
|
||||
|
||||
Reference in New Issue
Block a user