blob: 70eb7efe55ccb91369d444543c90b1400132a528 [file] [log] [blame]
Dees Troy3be70a82013-10-22 14:25:12 +00001/*
Ethan Yonker20eb0bc2016-03-22 14:23:28 -05002 Copyright 2012 to 2016 bigbiff/Dees_Troy TeamWin
Dees Troy3be70a82013-10-22 14:25:12 +00003 This file is part of TWRP/TeamWin Recovery Project.
4
5 TWRP is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 TWRP is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
17*/
Dees_Troy32c8eb82012-09-11 15:28:06 -040018
19#include <ctype.h>
20#include <errno.h>
21#include <fcntl.h>
22#include <limits.h>
23#include <sys/stat.h>
24#include <sys/wait.h>
25#include <unistd.h>
26
27#include <string.h>
28#include <stdio.h>
29
Dees_Troy2673cec2013-04-02 20:22:16 +000030#include "twcommon.h"
Ethan Yonker75bf0412014-11-21 13:54:27 -060031#include "mtdutils/mounts.h"
32#include "mtdutils/mtdutils.h"
Ethan Yonker8373cfe2017-09-08 06:50:54 -050033
34#ifdef USE_MINZIP
Dees_Troy32c8eb82012-09-11 15:28:06 -040035#include "minzip/SysUtil.h"
Ethan Yonker8373cfe2017-09-08 06:50:54 -050036#else
37#include "otautil/SysUtil.h"
38#include <ziparchive/zip_archive.h>
39#endif
40#include "zipwrap.hpp"
Ethan Yonkerf1179622016-08-25 15:32:21 -050041#ifdef USE_OLD_VERIFIER
Ethan Yonker4bf259f2016-08-29 11:50:34 -050042#include "verifier24/verifier.h"
Ethan Yonkerf1179622016-08-25 15:32:21 -050043#else
Ethan Yonker75bf0412014-11-21 13:54:27 -060044#include "verifier.h"
Ethan Yonkerf1179622016-08-25 15:32:21 -050045#endif
Dees_Troy32c8eb82012-09-11 15:28:06 -040046#include "variables.h"
47#include "data.hpp"
48#include "partitions.hpp"
bigbiff bigbiff56cf5642016-08-19 17:43:45 -040049#include "twrpDigestDriver.hpp"
50#include "twrpDigest/twrpDigest.hpp"
51#include "twrpDigest/twrpMD5.hpp"
Dees_Troy38bd7602012-09-14 13:33:53 -040052#include "twrp-functions.hpp"
Ethan Yonker74db1572015-10-28 12:44:49 -050053#include "gui/gui.hpp"
Ethan Yonker20eb0bc2016-03-22 14:23:28 -050054#include "gui/pages.hpp"
Ethan Yonkerf1179622016-08-25 15:32:21 -050055#include "legacy_property_service.h"
Ethan Yonker941a8992016-12-05 09:04:30 -060056#include "twinstall.h"
57#include "installcommand.h"
Dees_Troy2673cec2013-04-02 20:22:16 +000058extern "C" {
59 #include "gui/gui.h"
that7e303cf2014-03-06 07:57:43 +010060}
61
Ethan Yonker941a8992016-12-05 09:04:30 -060062#define AB_OTA "payload_properties.txt"
Ethan Yonker8373cfe2017-09-08 06:50:54 -050063//#define TW_NO_LEGACY_PROPS 1
Ethan Yonker941a8992016-12-05 09:04:30 -060064
that7e303cf2014-03-06 07:57:43 +010065static const char* properties_path = "/dev/__properties__";
66static const char* properties_path_renamed = "/dev/__properties_kk__";
Matt Mowercdd3b332014-03-27 14:38:48 -050067static bool legacy_props_env_initd = false;
68static bool legacy_props_path_modified = false;
that7e303cf2014-03-06 07:57:43 +010069
Ethan Yonker941a8992016-12-05 09:04:30 -060070enum zip_type {
71 UNKNOWN_ZIP_TYPE = 0,
72 UPDATE_BINARY_ZIP_TYPE,
73 AB_OTA_ZIP_TYPE,
74 TWRP_THEME_ZIP_TYPE
75};
76
that50640482015-08-30 12:08:05 +020077// to support pre-KitKat update-binaries that expect properties in the legacy format
Matt Mowercdd3b332014-03-27 14:38:48 -050078static int switch_to_legacy_properties()
that7e303cf2014-03-06 07:57:43 +010079{
Matt Mowercdd3b332014-03-27 14:38:48 -050080 if (!legacy_props_env_initd) {
81 if (legacy_properties_init() != 0)
82 return -1;
83
84 char tmp[32];
85 int propfd, propsz;
86 legacy_get_property_workspace(&propfd, &propsz);
87 sprintf(tmp, "%d,%d", dup(propfd), propsz);
88 setenv("ANDROID_PROPERTY_WORKSPACE", tmp, 1);
89 legacy_props_env_initd = true;
90 }
that7e303cf2014-03-06 07:57:43 +010091
92 if (TWFunc::Path_Exists(properties_path)) {
93 // hide real properties so that the updater uses the envvar to find the legacy format properties
Matt Mowercdd3b332014-03-27 14:38:48 -050094 if (rename(properties_path, properties_path_renamed) != 0) {
95 LOGERR("Renaming %s failed: %s\n", properties_path, strerror(errno));
96 return -1;
97 } else {
98 legacy_props_path_modified = true;
99 }
that7e303cf2014-03-06 07:57:43 +0100100 }
Matt Mowercdd3b332014-03-27 14:38:48 -0500101
102 return 0;
that7e303cf2014-03-06 07:57:43 +0100103}
104
Matt Mowercdd3b332014-03-27 14:38:48 -0500105static int switch_to_new_properties()
that7e303cf2014-03-06 07:57:43 +0100106{
107 if (TWFunc::Path_Exists(properties_path_renamed)) {
Matt Mowercdd3b332014-03-27 14:38:48 -0500108 if (rename(properties_path_renamed, properties_path) != 0) {
109 LOGERR("Renaming %s failed: %s\n", properties_path_renamed, strerror(errno));
110 return -1;
111 } else {
112 legacy_props_path_modified = false;
113 }
that7e303cf2014-03-06 07:57:43 +0100114 }
Matt Mowercdd3b332014-03-27 14:38:48 -0500115
116 return 0;
Dees_Troy2673cec2013-04-02 20:22:16 +0000117}
Dees_Troy32c8eb82012-09-11 15:28:06 -0400118
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500119static int Install_Theme(const char* path, ZipWrap *Zip) {
Ethan Yonker20eb0bc2016-03-22 14:23:28 -0500120#ifdef TW_OEM_BUILD // We don't do custom themes in OEM builds
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500121 Zip->Close();
Ethan Yonker20eb0bc2016-03-22 14:23:28 -0500122 return INSTALL_CORRUPT;
123#else
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500124 if (!Zip->EntryExists("ui.xml")) {
Ethan Yonker20eb0bc2016-03-22 14:23:28 -0500125 return INSTALL_CORRUPT;
126 }
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500127 Zip->Close();
Ethan Yonker20eb0bc2016-03-22 14:23:28 -0500128 if (!PartitionManager.Mount_Settings_Storage(true))
129 return INSTALL_ERROR;
130 string theme_path = DataManager::GetSettingsStoragePath();
131 theme_path += "/TWRP/theme";
132 if (!TWFunc::Path_Exists(theme_path)) {
133 if (!TWFunc::Recursive_Mkdir(theme_path)) {
134 return INSTALL_ERROR;
135 }
136 }
137 theme_path += "/ui.zip";
138 if (TWFunc::copy_file(path, theme_path, 0644) != 0) {
139 return INSTALL_ERROR;
140 }
141 LOGINFO("Installing custom theme '%s' to '%s'\n", path, theme_path.c_str());
142 PageManager::RequestReload();
143 return INSTALL_SUCCESS;
144#endif
145}
146
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500147static int Prepare_Update_Binary(const char *path, ZipWrap *Zip, int* wipe_cache) {
148 if (!Zip->ExtractEntry(ASSUMED_UPDATE_BINARY_NAME, TMP_UPDATER_BINARY_PATH, 0755)) {
149 Zip->Close();
Dees_Troy2673cec2013-04-02 20:22:16 +0000150 LOGERR("Could not extract '%s'\n", ASSUMED_UPDATE_BINARY_NAME);
151 return INSTALL_ERROR;
152 }
Dees_Troy32c8eb82012-09-11 15:28:06 -0400153
Dees_Troy512376c2013-09-03 19:39:41 +0000154 // If exists, extract file_contexts from the zip file
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500155 if (!Zip->EntryExists("file_contexts")) {
156 Zip->Close();
Dees_Troy512376c2013-09-03 19:39:41 +0000157 LOGINFO("Zip does not contain SELinux file_contexts file in its root.\n");
158 } else {
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500159 const string output_filename = "/file_contexts";
Dees_Troy512376c2013-09-03 19:39:41 +0000160 LOGINFO("Zip contains SELinux file_contexts file in its root. Extracting to %s\n", output_filename.c_str());
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500161 if (!Zip->ExtractEntry("file_contexts", output_filename, 0644)) {
162 Zip->Close();
that50640482015-08-30 12:08:05 +0200163 LOGERR("Could not extract '%s'\n", output_filename.c_str());
Dees_Troy512376c2013-09-03 19:39:41 +0000164 return INSTALL_ERROR;
165 }
166 }
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500167 Zip->Close();
Ethan Yonker941a8992016-12-05 09:04:30 -0600168 return INSTALL_SUCCESS;
169}
170
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500171static int Run_Update_Binary(const char *path, ZipWrap *Zip, int* wipe_cache, zip_type ztype) {
Ethan Yonker941a8992016-12-05 09:04:30 -0600172 int ret_val, pipe_fd[2], status, zip_verify;
173 char buffer[1024];
174 FILE* child_data;
Dees_Troy512376c2013-09-03 19:39:41 +0000175
Matt Mower6883d732014-03-20 17:28:13 -0500176#ifndef TW_NO_LEGACY_PROPS
Matt Mowercdd3b332014-03-27 14:38:48 -0500177 /* Set legacy properties */
178 if (switch_to_legacy_properties() != 0) {
179 LOGERR("Legacy property environment did not initialize successfully. Properties may not be detected.\n");
180 } else {
181 LOGINFO("Legacy property environment initialized.\n");
182 }
Matt Mower6883d732014-03-20 17:28:13 -0500183#endif
Matt Mowercdd3b332014-03-27 14:38:48 -0500184
Dees_Troy2673cec2013-04-02 20:22:16 +0000185 pipe(pipe_fd);
Dees_Troy32c8eb82012-09-11 15:28:06 -0400186
Ethan Yonker941a8992016-12-05 09:04:30 -0600187 std::vector<std::string> args;
188 if (ztype == UPDATE_BINARY_ZIP_TYPE) {
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500189 ret_val = update_binary_command(path, 0, pipe_fd[1], &args);
Ethan Yonker941a8992016-12-05 09:04:30 -0600190 } else if (ztype == AB_OTA_ZIP_TYPE) {
191 ret_val = abupdate_binary_command(path, Zip, 0, pipe_fd[1], &args);
192 } else {
193 LOGERR("Unknown zip type %i\n", ztype);
194 ret_val = INSTALL_CORRUPT;
195 }
196 if (ret_val) {
197 close(pipe_fd[0]);
198 close(pipe_fd[1]);
199 return ret_val;
200 }
201
202 // Convert the vector to a NULL-terminated char* array suitable for execv.
203 const char* chr_args[args.size() + 1];
204 chr_args[args.size()] = NULL;
205 for (size_t i = 0; i < args.size(); i++)
206 chr_args[i] = args[i].c_str();
Dees_Troy32c8eb82012-09-11 15:28:06 -0400207
Dees_Troy2673cec2013-04-02 20:22:16 +0000208 pid_t pid = fork();
209 if (pid == 0) {
210 close(pipe_fd[0]);
Ethan Yonker941a8992016-12-05 09:04:30 -0600211 execve(chr_args[0], const_cast<char**>(chr_args), environ);
212 printf("E:Can't execute '%s': %s\n", chr_args[0], strerror(errno));
Dees_Troy2673cec2013-04-02 20:22:16 +0000213 _exit(-1);
214 }
215 close(pipe_fd[1]);
Dees_Troy32c8eb82012-09-11 15:28:06 -0400216
Dees_Troy2673cec2013-04-02 20:22:16 +0000217 *wipe_cache = 0;
Dees_Troy32c8eb82012-09-11 15:28:06 -0400218
Dees_Troy2673cec2013-04-02 20:22:16 +0000219 DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
220 child_data = fdopen(pipe_fd[0], "r");
221 while (fgets(buffer, sizeof(buffer), child_data) != NULL) {
222 char* command = strtok(buffer, " \n");
Vojtech Bocekfafb0c52013-07-25 22:53:02 +0200223 if (command == NULL) {
224 continue;
225 } else if (strcmp(command, "progress") == 0) {
226 char* fraction_char = strtok(NULL, " \n");
227 char* seconds_char = strtok(NULL, " \n");
Dees_Troy32c8eb82012-09-11 15:28:06 -0400228
Vojtech Bocekfafb0c52013-07-25 22:53:02 +0200229 float fraction_float = strtof(fraction_char, NULL);
230 int seconds_float = strtol(seconds_char, NULL, 10);
Dees_Troy32c8eb82012-09-11 15:28:06 -0400231
Vojtech Bocekfafb0c52013-07-25 22:53:02 +0200232 if (zip_verify)
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500233 DataManager::ShowProgress(fraction_float * (1 - VERIFICATION_PROGRESS_FRAC), seconds_float);
Dees_Troy2673cec2013-04-02 20:22:16 +0000234 else
235 DataManager::ShowProgress(fraction_float, seconds_float);
Vojtech Bocekfafb0c52013-07-25 22:53:02 +0200236 } else if (strcmp(command, "set_progress") == 0) {
237 char* fraction_char = strtok(NULL, " \n");
238 float fraction_float = strtof(fraction_char, NULL);
239 DataManager::SetProgress(fraction_float);
240 } else if (strcmp(command, "ui_print") == 0) {
241 char* display_value = strtok(NULL, "\n");
242 if (display_value) {
243 gui_print("%s", display_value);
244 } else {
245 gui_print("\n");
246 }
247 } else if (strcmp(command, "wipe_cache") == 0) {
248 *wipe_cache = 1;
249 } else if (strcmp(command, "clear_display") == 0) {
250 // Do nothing, not supported by TWRP
Ethan Yonker072c8d82016-08-26 22:22:24 -0500251 } else if (strcmp(command, "log") == 0) {
252 printf("%s\n", strtok(NULL, "\n"));
Vojtech Bocekfafb0c52013-07-25 22:53:02 +0200253 } else {
254 LOGERR("unknown command [%s]\n", command);
255 }
Dees_Troy2673cec2013-04-02 20:22:16 +0000256 }
257 fclose(child_data);
Dees_Troy32c8eb82012-09-11 15:28:06 -0400258
that50640482015-08-30 12:08:05 +0200259 int waitrc = TWFunc::Wait_For_Child(pid, &status, "Updater");
Matt Mowercdd3b332014-03-27 14:38:48 -0500260
Matt Mower6883d732014-03-20 17:28:13 -0500261#ifndef TW_NO_LEGACY_PROPS
Matt Mowercdd3b332014-03-27 14:38:48 -0500262 /* Unset legacy properties */
263 if (legacy_props_path_modified) {
264 if (switch_to_new_properties() != 0) {
265 LOGERR("Legacy property environment did not disable successfully. Legacy properties may still be in use.\n");
266 } else {
267 LOGINFO("Legacy property environment disabled.\n");
268 }
269 }
Matt Mower6883d732014-03-20 17:28:13 -0500270#endif
Matt Mowercdd3b332014-03-27 14:38:48 -0500271
that50640482015-08-30 12:08:05 +0200272 if (waitrc != 0)
Dees_Troy2673cec2013-04-02 20:22:16 +0000273 return INSTALL_ERROR;
Dees_Troy32c8eb82012-09-11 15:28:06 -0400274
Dees_Troy2673cec2013-04-02 20:22:16 +0000275 return INSTALL_SUCCESS;
Dees_Troy32c8eb82012-09-11 15:28:06 -0400276}
277
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500278int TWinstall_zip(const char* path, int* wipe_cache) {
that50640482015-08-30 12:08:05 +0200279 int ret_val, zip_verify = 1;
Dees_Troy32c8eb82012-09-11 15:28:06 -0400280
Ethan Yonker24813422014-11-07 17:19:07 -0600281 if (strcmp(path, "error") == 0) {
282 LOGERR("Failed to get adb sideload file: '%s'\n", path);
Dees_Troy32c8eb82012-09-11 15:28:06 -0400283 return INSTALL_CORRUPT;
Matt Mowerd5c1a922014-04-15 12:50:58 -0500284 }
Dees_Troy32c8eb82012-09-11 15:28:06 -0400285
Ethan Yonker74db1572015-10-28 12:44:49 -0500286 gui_msg(Msg("installing_zip=Installing zip file '{1}'")(path));
Ethan Yonker24813422014-11-07 17:19:07 -0600287 if (strlen(path) < 9 || strncmp(path, "/sideload", 9) != 0) {
bigbiff bigbiff56cf5642016-08-19 17:43:45 -0400288 string digest_str;
289 string Full_Filename = path;
290 string digest_file = path;
291 digest_file += ".md5";
292
293 gui_msg("check_for_digest=Checking for Digest file...");
294 if (!TWFunc::Path_Exists(digest_file)) {
295 gui_msg("no_digest=Skipping Digest check: no Digest file found");
296 }
297 else {
298 if (TWFunc::read_file(digest_file, digest_str) != 0) {
299 LOGERR("Skipping MD5 check: MD5 file unreadable\n");
300 }
301 else {
302 twrpDigest *digest = new twrpMD5();
303 if (!twrpDigestDriver::stream_file_to_digest(Full_Filename, digest)) {
304 delete digest;
305 return INSTALL_CORRUPT;
306 }
307 string digest_check = digest->return_digest_string();
308 if (digest_str == digest_check) {
309 gui_msg(Msg("digest_matched=Digest matched for '{1}'.")(path));
310 }
311 else {
312 LOGERR("Aborting zip install: Digest verification failed\n");
313 delete digest;
314 return INSTALL_CORRUPT;
315 }
316 delete digest;
317 }
Ethan Yonker24813422014-11-07 17:19:07 -0600318 }
319 }
320
Ethan Yonkerd5801c52014-04-14 08:59:35 -0500321#ifndef TW_OEM_BUILD
Dees_Troy32c8eb82012-09-11 15:28:06 -0400322 DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
Ethan Yonkerd5801c52014-04-14 08:59:35 -0500323#endif
Dees_Troy2673cec2013-04-02 20:22:16 +0000324 DataManager::SetProgress(0);
Ethan Yonkerf96087e2014-11-07 10:38:51 -0600325
326 MemMapping map;
327 if (sysMapFile(path, &map) != 0) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500328 gui_msg(Msg(msg::kError, "fail_sysmap=Failed to map file '{1}'")(path));
that50640482015-08-30 12:08:05 +0200329 return -1;
330 }
Ethan Yonkerf96087e2014-11-07 10:38:51 -0600331
Dees_Troy32c8eb82012-09-11 15:28:06 -0400332 if (zip_verify) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500333 gui_msg("verify_zip_sig=Verifying zip signature...");
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500334#ifdef USE_OLD_VERIFIER
Ethan Yonkerf96087e2014-11-07 10:38:51 -0600335 ret_val = verify_file(map.addr, map.length);
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500336#else
337 std::vector<Certificate> loadedKeys;
338 if (!load_keys("/res/keys", loadedKeys)) {
339 LOGINFO("Failed to load keys");
340 gui_err("verify_zip_fail=Zip signature verification failed!");
341 return -1;
342 }
343 ret_val = verify_file(map.addr, map.length, loadedKeys, std::bind(&DataManager::SetProgress, std::placeholders::_1));
344#endif
Dees_Troy2673cec2013-04-02 20:22:16 +0000345 if (ret_val != VERIFY_SUCCESS) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500346 LOGINFO("Zip signature verification failed: %i\n", ret_val);
347 gui_err("verify_zip_fail=Zip signature verification failed!");
Ethan Yonkerf9796a42014-11-08 07:28:03 -0600348 sysReleaseMap(&map);
Dees_Troy32c8eb82012-09-11 15:28:06 -0400349 return -1;
Ethan Yonker738be7a2014-12-10 11:40:43 -0600350 } else {
Ethan Yonker74db1572015-10-28 12:44:49 -0500351 gui_msg("verify_zip_done=Zip signature verified successfully.");
Dees_Troy32c8eb82012-09-11 15:28:06 -0400352 }
353 }
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500354 ZipWrap Zip;
355 if (!Zip.Open(path, &map)) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500356 gui_err("zip_corrupt=Zip file is corrupt!");
Ethan Yonkerf9796a42014-11-08 07:28:03 -0600357 sysReleaseMap(&map);
Dees_Troy2673cec2013-04-02 20:22:16 +0000358 return INSTALL_CORRUPT;
359 }
Ethan Yonker941a8992016-12-05 09:04:30 -0600360
Ethan Yonker072c8d82016-08-26 22:22:24 -0500361 time_t start, stop;
362 time(&start);
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500363 if (Zip.EntryExists(ASSUMED_UPDATE_BINARY_NAME)) {
Ethan Yonker941a8992016-12-05 09:04:30 -0600364 LOGINFO("Update binary zip\n");
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500365 // Additionally verify the compatibility of the package.
366 if (!verify_package_compatibility(&Zip)) {
367 gui_err("zip_compatible_err=Zip Treble compatibility error!");
368 sysReleaseMap(&map);
369 Zip.Close();
370 ret_val = INSTALL_CORRUPT;
371 } else {
372 ret_val = Prepare_Update_Binary(path, &Zip, wipe_cache);
373 if (ret_val == INSTALL_SUCCESS)
374 ret_val = Run_Update_Binary(path, &Zip, wipe_cache, UPDATE_BINARY_ZIP_TYPE);
375 }
Ethan Yonker941a8992016-12-05 09:04:30 -0600376 } else {
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500377 if (Zip.EntryExists(AB_OTA)) {
Ethan Yonker941a8992016-12-05 09:04:30 -0600378 LOGINFO("AB zip\n");
379 ret_val = Run_Update_Binary(path, &Zip, wipe_cache, AB_OTA_ZIP_TYPE);
380 } else {
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500381 if (Zip.EntryExists("ui.xml")) {
Ethan Yonker941a8992016-12-05 09:04:30 -0600382 LOGINFO("TWRP theme zip\n");
383 ret_val = Install_Theme(path, &Zip);
384 } else {
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500385 Zip.Close();
Ethan Yonker941a8992016-12-05 09:04:30 -0600386 ret_val = INSTALL_CORRUPT;
387 }
388 }
389 }
Ethan Yonker072c8d82016-08-26 22:22:24 -0500390 time(&stop);
391 int total_time = (int) difftime(stop, start);
Ethan Yonker20eb0bc2016-03-22 14:23:28 -0500392 if (ret_val == INSTALL_CORRUPT) {
Ethan Yonker941a8992016-12-05 09:04:30 -0600393 gui_err("invalid_zip_format=Invalid zip file format!");
Ethan Yonker072c8d82016-08-26 22:22:24 -0500394 } else {
395 LOGINFO("Install took %i second(s).\n", total_time);
Ethan Yonker20eb0bc2016-03-22 14:23:28 -0500396 }
Ethan Yonkerf9796a42014-11-08 07:28:03 -0600397 sysReleaseMap(&map);
398 return ret_val;
Dees_Troy32c8eb82012-09-11 15:28:06 -0400399}