From 193befec8c93ce1bad08c5d961d72b7866e37abb Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Tue, 2 Apr 2019 16:01:31 -0500 Subject: Extract arch-specific updater binary if present Check for and extract arch specific updater binary based on ro.product.cpu.abilist and use ro.product.cpu.abi as a fall back. If no arch specific updater binary is present then use the regular update-binary file. Note that a file named update-binary must be present in the zip still even if it is a 0 byte file. Change-Id: Iabb2156e68d40c5b99d55ea8e4a9a553eb26600a --- twinstall.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/twinstall.cpp b/twinstall.cpp index e4b11a7b6..8bbafca30 100755 --- a/twinstall.cpp +++ b/twinstall.cpp @@ -32,6 +32,7 @@ #include #include +#include #include "twcommon.h" #include "mtdutils/mounts.h" @@ -154,7 +155,24 @@ static int Install_Theme(const char* path, ZipWrap *Zip) { } static int Prepare_Update_Binary(const char *path, ZipWrap *Zip, int* wipe_cache) { - if (!Zip->ExtractEntry(ASSUMED_UPDATE_BINARY_NAME, TMP_UPDATER_BINARY_PATH, 0755)) { + char arches[PATH_MAX]; + std::string binary_name = ASSUMED_UPDATE_BINARY_NAME; + property_get("ro.product.cpu.abilist", arches, "error"); + if (strcmp(arches, "error") == 0) + property_get("ro.product.cpu.abi", arches, "error"); + vector split = TWFunc::split_string(arches, ',', true); + std::vector::iterator arch; + std::string base_name = binary_name; + base_name += "-"; + for (arch = split.begin(); arch != split.end(); arch++) { + std::string temp = base_name + *arch; + if (Zip->EntryExists(temp)) { + binary_name = temp; + break; + } + } + LOGINFO("Extracting updater binary '%s'\n", binary_name.c_str()); + if (!Zip->ExtractEntry(binary_name.c_str(), TMP_UPDATER_BINARY_PATH, 0755)) { Zip->Close(); LOGERR("Could not extract '%s'\n", ASSUMED_UPDATE_BINARY_NAME); return INSTALL_ERROR; -- cgit v1.2.3