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