* The directory hierarchy looks like this: * "outputDir" and "assetRoot" are existing directories. * * On success, "bundle->numPackages" will be the number of Zip packages * we created. */
| 59 | * we created. |
| 60 | */ |
| 61 | status_t writeAPK(Bundle* bundle, const sp<AaptAssets>& assets, |
| 62 | ZipFile* zip, const char* outputFileName, bool isOverlay) |
| 63 | { |
| 64 | status_t result = NO_ERROR; |
| 65 | int count; |
| 66 | |
| 67 | if (bundle->getVerbose()) { |
| 68 | printf("Writing all files...\n"); |
| 69 | } |
| 70 | |
| 71 | count = processAssets(bundle, zip, assets, isOverlay); |
| 72 | if (count < 0) { |
| 73 | fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n", |
| 74 | outputFileName); |
| 75 | result = count; |
| 76 | goto bail; |
| 77 | } |
| 78 | |
| 79 | if (bundle->getVerbose()) { |
| 80 | printf("Generated %d file%s\n", count, (count==1) ? "" : "s"); |
| 81 | } |
| 82 | |
| 83 | if (!isOverlay) { |
| 84 | count = processJarFiles(bundle, zip); |
| 85 | if (count < 0) { |
| 86 | fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n", |
| 87 | outputFileName); |
| 88 | result = count; |
| 89 | goto bail; |
| 90 | } |
| 91 | |
| 92 | if (bundle->getVerbose()) |
| 93 | printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s"); |
| 94 | } |
| 95 | |
| 96 | result = NO_ERROR; |
| 97 | |
| 98 | /* |
| 99 | * Check for cruft. We set the "marked" flag on all entries we created |
| 100 | * or decided not to update. If the entry isn't already slated for |
| 101 | * deletion, remove it now. |
| 102 | */ |
| 103 | { |
| 104 | if (bundle->getVerbose()) |
| 105 | printf("Checking for deleted files\n"); |
| 106 | int i, removed = 0; |
| 107 | for (i = 0; i < zip->getNumEntries(); i++) { |
| 108 | ZipEntry* entry = zip->getEntryByIndex(i); |
| 109 | |
| 110 | if (!entry->getMarked() && entry->getDeleted()) { |
| 111 | if (bundle->getVerbose()) { |
| 112 | printf(" (removing crufty '%s')\n", |
| 113 | entry->getFileName()); |
| 114 | } |
| 115 | zip->remove(entry); |
| 116 | removed++; |
| 117 | } |
| 118 | } |
no test coverage detected