Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f032431 authored by Adam Lesinski's avatar Adam Lesinski Committed by Android (Google) Code Review
Browse files

Merge "AAPT2: Accept empty zip files"

parents 7f193c5b c446a733
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -75,11 +75,19 @@ ZipFileCollection::ZipFileCollection() : mHandle(nullptr) {

std::unique_ptr<ZipFileCollection> ZipFileCollection::create(const StringPiece& path,
                                                             std::string* outError) {
    constexpr static const int32_t kEmptyArchive = -6;

    std::unique_ptr<ZipFileCollection> collection = std::unique_ptr<ZipFileCollection>(
            new ZipFileCollection());

    int32_t result = OpenArchive(path.data(), &collection->mHandle);
    if (result != 0) {
        // If a zip is empty, result will be an error code. This is fine and we should
        // return an empty ZipFileCollection.
        if (result == kEmptyArchive) {
            return collection;
        }

        if (outError) *outError = ErrorCodeString(result);
        return {};
    }
+5 −4
Original line number Diff line number Diff line
@@ -551,14 +551,15 @@ public:
            if (resourceFile) {
                return mergeCompiledFile(file, std::move(resourceFile), override);
            }
        } else {
            // Ignore non .flat files. This could be classes.dex or something else that happens
            // to be in an archive.
        }

            return false;
        }

        // Ignore non .flat files. This could be classes.dex or something else that happens
        // to be in an archive.
        return true;
    }

    int run(const std::vector<std::string>& inputFiles) {
        // Load the AndroidManifest.xml
        std::unique_ptr<xml::XmlResource> manifestXml = loadXml(mOptions.manifestPath,