The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 17 | #include <ctype.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 18 | #include <errno.h> |
| 19 | #include <fcntl.h> |
| 20 | #include <limits.h> |
| 21 | #include <sys/stat.h> |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 22 | #include <sys/wait.h> |
| 23 | #include <unistd.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 24 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 25 | #include "common.h" |
| 26 | #include "install.h" |
| 27 | #include "mincrypt/rsa.h" |
| 28 | #include "minui/minui.h" |
| 29 | #include "minzip/SysUtil.h" |
| 30 | #include "minzip/Zip.h" |
| 31 | #include "mtdutils/mounts.h" |
| 32 | #include "mtdutils/mtdutils.h" |
| 33 | #include "roots.h" |
| 34 | #include "verifier.h" |
| 35 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 36 | #include "firmware.h" |
Koushik K. Dutta | 4c1eed2 | 2010-02-11 18:59:58 -0800 | [diff] [blame] | 37 | #include "legacy.h" |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 38 | |
Koushik K. Dutta | 6060e5c | 2010-02-11 22:27:06 -0800 | [diff] [blame] | 39 | #include "extendedcommands.h" |
| 40 | |
Koushik Dutta | 0eb14b3 | 2010-06-23 17:38:05 -0700 | [diff] [blame] | 41 | |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 42 | #define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary" |
Doug Zongker | d1b19b9 | 2009-04-01 15:48:46 -0700 | [diff] [blame] | 43 | #define PUBLIC_KEYS_FILE "/res/keys" |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 45 | // The update binary ask us to install a firmware file on reboot. Set |
| 46 | // that up. Takes ownership of type and filename. |
| 47 | static int |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 48 | handle_firmware_update(char* type, char* filename, ZipArchive* zip) { |
| 49 | unsigned int data_size; |
| 50 | const ZipEntry* entry = NULL; |
| 51 | |
| 52 | if (strncmp(filename, "PACKAGE:", 8) == 0) { |
| 53 | entry = mzFindZipEntry(zip, filename+8); |
| 54 | if (entry == NULL) { |
| 55 | LOGE("Failed to find \"%s\" in package", filename+8); |
| 56 | return INSTALL_ERROR; |
| 57 | } |
| 58 | data_size = entry->uncompLen; |
| 59 | } else { |
| 60 | struct stat st_data; |
| 61 | if (stat(filename, &st_data) < 0) { |
| 62 | LOGE("Error stat'ing %s: %s\n", filename, strerror(errno)); |
| 63 | return INSTALL_ERROR; |
| 64 | } |
| 65 | data_size = st_data.st_size; |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 68 | LOGI("type is %s; size is %d; file is %s\n", |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 69 | type, data_size, filename); |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 70 | |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 71 | char* data = malloc(data_size); |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 72 | if (data == NULL) { |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 73 | LOGI("Can't allocate %d bytes for firmware data\n", data_size); |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 74 | return INSTALL_ERROR; |
| 75 | } |
| 76 | |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 77 | if (entry) { |
| 78 | if (mzReadZipEntry(zip, entry, data, data_size) == false) { |
| 79 | LOGE("Failed to read \"%s\" from package", filename+8); |
| 80 | return INSTALL_ERROR; |
| 81 | } |
| 82 | } else { |
| 83 | FILE* f = fopen(filename, "rb"); |
| 84 | if (f == NULL) { |
| 85 | LOGE("Failed to open %s: %s\n", filename, strerror(errno)); |
| 86 | return INSTALL_ERROR; |
| 87 | } |
| 88 | if (fread(data, 1, data_size, f) != data_size) { |
| 89 | LOGE("Failed to read firmware data: %s\n", strerror(errno)); |
| 90 | return INSTALL_ERROR; |
| 91 | } |
| 92 | fclose(f); |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 93 | } |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 94 | |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 95 | #ifndef BOARD_HAS_NO_MISC_PARTITION |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 96 | if (remember_firmware_update(type, data, data_size)) { |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 97 | LOGE("Can't store %s image\n", type); |
| 98 | free(data); |
| 99 | return INSTALL_ERROR; |
| 100 | } |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 101 | #endif |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 102 | free(filename); |
| 103 | |
| 104 | return INSTALL_SUCCESS; |
| 105 | } |
| 106 | |
| 107 | // If the package contains an update binary, extract it and run it. |
| 108 | static int |
| 109 | try_update_binary(const char *path, ZipArchive *zip) { |
| 110 | const ZipEntry* binary_entry = |
| 111 | mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME); |
| 112 | if (binary_entry == NULL) { |
Koushik K. Dutta | 581bd86 | 2010-03-20 01:08:55 -0700 | [diff] [blame] | 113 | return INSTALL_UPDATE_BINARY_MISSING; |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | char* binary = "/tmp/update_binary"; |
| 117 | unlink(binary); |
| 118 | int fd = creat(binary, 0755); |
| 119 | if (fd < 0) { |
| 120 | LOGE("Can't make %s\n", binary); |
| 121 | return 1; |
| 122 | } |
| 123 | bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd); |
| 124 | close(fd); |
| 125 | |
| 126 | if (!ok) { |
| 127 | LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME); |
| 128 | return 1; |
| 129 | } |
| 130 | |
| 131 | int pipefd[2]; |
| 132 | pipe(pipefd); |
| 133 | |
| 134 | // When executing the update binary contained in the package, the |
| 135 | // arguments passed are: |
| 136 | // |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 137 | // - the version number for this interface |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 138 | // |
| 139 | // - an fd to which the program can write in order to update the |
| 140 | // progress bar. The program can write single-line commands: |
| 141 | // |
| 142 | // progress <frac> <secs> |
Doug Zongker | fbf3c10 | 2009-06-24 09:36:20 -0700 | [diff] [blame] | 143 | // fill up the next <frac> part of of the progress bar |
| 144 | // over <secs> seconds. If <secs> is zero, use |
| 145 | // set_progress commands to manually control the |
| 146 | // progress of this segment of the bar |
| 147 | // |
| 148 | // set_progress <frac> |
| 149 | // <frac> should be between 0.0 and 1.0; sets the |
| 150 | // progress bar within the segment defined by the most |
| 151 | // recent progress command. |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 152 | // |
| 153 | // firmware <"hboot"|"radio"> <filename> |
| 154 | // arrange to install the contents of <filename> in the |
Doug Zongker | e08991e | 2010-02-02 13:09:52 -0800 | [diff] [blame] | 155 | // given partition on reboot. |
| 156 | // |
| 157 | // (API v2: <filename> may start with "PACKAGE:" to |
| 158 | // indicate taking a file from the OTA package.) |
| 159 | // |
| 160 | // (API v3: this command no longer exists.) |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 161 | // |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 162 | // ui_print <string> |
| 163 | // display <string> on the screen. |
| 164 | // |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 165 | // - the name of the package zip file. |
| 166 | // |
| 167 | |
| 168 | char** args = malloc(sizeof(char*) * 5); |
| 169 | args[0] = binary; |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 170 | args[1] = EXPAND(RECOVERY_API_VERSION); // defined in Android.mk |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 171 | args[2] = malloc(10); |
| 172 | sprintf(args[2], "%d", pipefd[1]); |
| 173 | args[3] = (char*)path; |
| 174 | args[4] = NULL; |
| 175 | |
| 176 | pid_t pid = fork(); |
| 177 | if (pid == 0) { |
| 178 | close(pipefd[0]); |
| 179 | execv(binary, args); |
| 180 | fprintf(stderr, "E:Can't run %s (%s)\n", binary, strerror(errno)); |
| 181 | _exit(-1); |
| 182 | } |
| 183 | close(pipefd[1]); |
| 184 | |
Doug Zongker | 64893cc | 2009-07-14 16:31:56 -0700 | [diff] [blame] | 185 | char buffer[1024]; |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 186 | FILE* from_child = fdopen(pipefd[0], "r"); |
| 187 | while (fgets(buffer, sizeof(buffer), from_child) != NULL) { |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 188 | char* command = strtok(buffer, " \n"); |
| 189 | if (command == NULL) { |
| 190 | continue; |
| 191 | } else if (strcmp(command, "progress") == 0) { |
| 192 | char* fraction_s = strtok(NULL, " \n"); |
| 193 | char* seconds_s = strtok(NULL, " \n"); |
| 194 | |
| 195 | float fraction = strtof(fraction_s, NULL); |
| 196 | int seconds = strtol(seconds_s, NULL, 10); |
| 197 | |
| 198 | ui_show_progress(fraction * (1-VERIFICATION_PROGRESS_FRACTION), |
| 199 | seconds); |
Doug Zongker | fbf3c10 | 2009-06-24 09:36:20 -0700 | [diff] [blame] | 200 | } else if (strcmp(command, "set_progress") == 0) { |
| 201 | char* fraction_s = strtok(NULL, " \n"); |
| 202 | float fraction = strtof(fraction_s, NULL); |
| 203 | ui_set_progress(fraction); |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 204 | } else if (strcmp(command, "ui_print") == 0) { |
| 205 | char* str = strtok(NULL, "\n"); |
| 206 | if (str) { |
| 207 | ui_print(str); |
| 208 | } else { |
| 209 | ui_print("\n"); |
| 210 | } |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 211 | } else { |
| 212 | LOGE("unknown command [%s]\n", command); |
| 213 | } |
| 214 | } |
| 215 | fclose(from_child); |
| 216 | |
| 217 | int status; |
| 218 | waitpid(pid, &status, 0); |
| 219 | if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 220 | LOGE("Error in %s\n(Status %d)\n", path, WEXITSTATUS(status)); |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 221 | return INSTALL_ERROR; |
| 222 | } |
| 223 | |
Doug Zongker | e08991e | 2010-02-02 13:09:52 -0800 | [diff] [blame] | 224 | return INSTALL_SUCCESS; |
Doug Zongker | b2ee920 | 2009-06-04 10:24:53 -0700 | [diff] [blame] | 225 | } |
| 226 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 227 | static int |
Doug Zongker | 54e2e86 | 2009-08-17 13:21:04 -0700 | [diff] [blame] | 228 | handle_update_package(const char *path, ZipArchive *zip) |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 229 | { |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 230 | // Update should take the rest of the progress bar. |
| 231 | ui_print("Installing update...\n"); |
| 232 | |
Koushik K. Dutta | 581bd86 | 2010-03-20 01:08:55 -0700 | [diff] [blame] | 233 | LOGI("Trying update-binary.\n"); |
| 234 | int result = try_update_binary(path, zip); |
| 235 | |
| 236 | if (result == INSTALL_UPDATE_BINARY_MISSING) |
Koushik K. Dutta | e923487 | 2010-02-12 00:43:24 -0800 | [diff] [blame] | 237 | { |
Koushik K. Dutta | 581bd86 | 2010-03-20 01:08:55 -0700 | [diff] [blame] | 238 | register_package_root(NULL, NULL); // Unregister package root |
| 239 | if (register_package_root(zip, path) < 0) { |
| 240 | LOGE("Can't register package root\n"); |
| 241 | return INSTALL_ERROR; |
| 242 | } |
| 243 | const ZipEntry *script_entry; |
| 244 | script_entry = find_update_script(zip); |
| 245 | LOGI("Trying update-script.\n"); |
| 246 | result = handle_update_script(zip, script_entry); |
| 247 | if (result == INSTALL_UPDATE_SCRIPT_MISSING) |
| 248 | result = INSTALL_ERROR; |
Koushik K. Dutta | e923487 | 2010-02-12 00:43:24 -0800 | [diff] [blame] | 249 | } |
| 250 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 251 | register_package_root(NULL, NULL); // Unregister package root |
Doug Zongker | 64893cc | 2009-07-14 16:31:56 -0700 | [diff] [blame] | 252 | return result; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Doug Zongker | d1b19b9 | 2009-04-01 15:48:46 -0700 | [diff] [blame] | 255 | // Reads a file containing one or more public keys as produced by |
| 256 | // DumpPublicKey: this is an RSAPublicKey struct as it would appear |
| 257 | // as a C source literal, eg: |
| 258 | // |
| 259 | // "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" |
| 260 | // |
| 261 | // (Note that the braces and commas in this example are actual |
| 262 | // characters the parser expects to find in the file; the ellipses |
| 263 | // indicate more numbers omitted from this example.) |
| 264 | // |
| 265 | // The file may contain multiple keys in this format, separated by |
| 266 | // commas. The last key must not be followed by a comma. |
| 267 | // |
| 268 | // Returns NULL if the file failed to parse, or if it contain zero keys. |
| 269 | static RSAPublicKey* |
| 270 | load_keys(const char* filename, int* numKeys) { |
| 271 | RSAPublicKey* out = NULL; |
| 272 | *numKeys = 0; |
| 273 | |
| 274 | FILE* f = fopen(filename, "r"); |
| 275 | if (f == NULL) { |
| 276 | LOGE("opening %s: %s\n", filename, strerror(errno)); |
| 277 | goto exit; |
| 278 | } |
| 279 | |
| 280 | int i; |
| 281 | bool done = false; |
| 282 | while (!done) { |
| 283 | ++*numKeys; |
| 284 | out = realloc(out, *numKeys * sizeof(RSAPublicKey)); |
| 285 | RSAPublicKey* key = out + (*numKeys - 1); |
Doug Zongker | aa06253 | 2010-01-28 16:47:20 -0800 | [diff] [blame] | 286 | if (fscanf(f, " { %i , 0x%x , { %u", |
Doug Zongker | d1b19b9 | 2009-04-01 15:48:46 -0700 | [diff] [blame] | 287 | &(key->len), &(key->n0inv), &(key->n[0])) != 3) { |
| 288 | goto exit; |
| 289 | } |
| 290 | if (key->len != RSANUMWORDS) { |
| 291 | LOGE("key length (%d) does not match expected size\n", key->len); |
| 292 | goto exit; |
| 293 | } |
| 294 | for (i = 1; i < key->len; ++i) { |
Doug Zongker | aa06253 | 2010-01-28 16:47:20 -0800 | [diff] [blame] | 295 | if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit; |
Doug Zongker | d1b19b9 | 2009-04-01 15:48:46 -0700 | [diff] [blame] | 296 | } |
Doug Zongker | aa06253 | 2010-01-28 16:47:20 -0800 | [diff] [blame] | 297 | if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit; |
Doug Zongker | d1b19b9 | 2009-04-01 15:48:46 -0700 | [diff] [blame] | 298 | for (i = 1; i < key->len; ++i) { |
Doug Zongker | aa06253 | 2010-01-28 16:47:20 -0800 | [diff] [blame] | 299 | if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit; |
Doug Zongker | d1b19b9 | 2009-04-01 15:48:46 -0700 | [diff] [blame] | 300 | } |
| 301 | fscanf(f, " } } "); |
| 302 | |
| 303 | // if the line ends in a comma, this file has more keys. |
| 304 | switch (fgetc(f)) { |
| 305 | case ',': |
| 306 | // more keys to come. |
| 307 | break; |
| 308 | |
| 309 | case EOF: |
| 310 | done = true; |
| 311 | break; |
| 312 | |
| 313 | default: |
| 314 | LOGE("unexpected character between keys\n"); |
| 315 | goto exit; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | fclose(f); |
| 320 | return out; |
| 321 | |
| 322 | exit: |
| 323 | if (f) fclose(f); |
| 324 | free(out); |
| 325 | *numKeys = 0; |
| 326 | return NULL; |
| 327 | } |
| 328 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 329 | int |
| 330 | install_package(const char *root_path) |
| 331 | { |
| 332 | ui_set_background(BACKGROUND_ICON_INSTALLING); |
| 333 | ui_print("Finding update package...\n"); |
| 334 | ui_show_indeterminate_progress(); |
| 335 | LOGI("Update location: %s\n", root_path); |
| 336 | |
| 337 | if (ensure_root_path_mounted(root_path) != 0) { |
| 338 | LOGE("Can't mount %s\n", root_path); |
| 339 | return INSTALL_CORRUPT; |
| 340 | } |
| 341 | |
| 342 | char path[PATH_MAX] = ""; |
| 343 | if (translate_root_path(root_path, path, sizeof(path)) == NULL) { |
| 344 | LOGE("Bad path %s\n", root_path); |
| 345 | return INSTALL_CORRUPT; |
| 346 | } |
| 347 | |
| 348 | ui_print("Opening update package...\n"); |
| 349 | LOGI("Update file path: %s\n", path); |
| 350 | |
Doug Zongker | 54e2e86 | 2009-08-17 13:21:04 -0700 | [diff] [blame] | 351 | int err; |
Koushik K. Dutta | 6060e5c | 2010-02-11 22:27:06 -0800 | [diff] [blame] | 352 | |
| 353 | if (signature_check_enabled) { |
| 354 | int numKeys; |
| 355 | RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys); |
| 356 | if (loadedKeys == NULL) { |
| 357 | LOGE("Failed to load keys\n"); |
| 358 | return INSTALL_CORRUPT; |
| 359 | } |
| 360 | LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE); |
| 361 | |
| 362 | // Give verification half the progress bar... |
| 363 | ui_print("Verifying update package...\n"); |
| 364 | ui_show_progress( |
| 365 | VERIFICATION_PROGRESS_FRACTION, |
| 366 | VERIFICATION_PROGRESS_TIME); |
| 367 | |
| 368 | err = verify_file(path, loadedKeys, numKeys); |
| 369 | free(loadedKeys); |
| 370 | LOGI("verify_file returned %d\n", err); |
| 371 | if (err != VERIFY_SUCCESS) { |
| 372 | LOGE("signature verification failed\n"); |
| 373 | return INSTALL_CORRUPT; |
| 374 | } |
Doug Zongker | 54e2e86 | 2009-08-17 13:21:04 -0700 | [diff] [blame] | 375 | } |
| 376 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 377 | /* Try to open the package. |
| 378 | */ |
| 379 | ZipArchive zip; |
Doug Zongker | 54e2e86 | 2009-08-17 13:21:04 -0700 | [diff] [blame] | 380 | err = mzOpenZipArchive(path, &zip); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 381 | if (err != 0) { |
| 382 | LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); |
| 383 | return INSTALL_CORRUPT; |
| 384 | } |
| 385 | |
| 386 | /* Verify and install the contents of the package. |
| 387 | */ |
Doug Zongker | 54e2e86 | 2009-08-17 13:21:04 -0700 | [diff] [blame] | 388 | int status = handle_update_package(path, &zip); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 389 | mzCloseZipArchive(&zip); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 390 | return status; |
| 391 | } |