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

Commit 6994c912 authored by Alexandria Cornwall's avatar Alexandria Cornwall Committed by Android (Google) Code Review
Browse files

Merge "AAPT2: Merge binary XML file attributes"

parents 005499ed f6762fc2
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -388,8 +388,10 @@ bool ResourceFileFlattener::linkAndVersionXmlFile(const ResourceEntry* entry,

        // Find the first SDK level used that is higher than this defined config and
        // not superseded by a lower or equal SDK level resource.
        const int minSdkVersion = mContext->getMinSdkVersion();
        for (int sdkLevel : xmlLinker.getSdkLevels()) {
            if (sdkLevel > outFileOp->xmlToFlatten->file.config.sdkVersion) {
            if (sdkLevel > minSdkVersion
                    && sdkLevel > outFileOp->xmlToFlatten->file.config.sdkVersion) {
                if (!shouldGenerateVersionedResource(entry, outFileOp->xmlToFlatten->file.config,
                                                     sdkLevel)) {
                    // If we shouldn't generate a versioned resource, stop checking.
@@ -498,7 +500,10 @@ bool ResourceFileFlattener::flatten(ResourceTable* table, IArchiveWriter* archiv
                if (fileOp.xmlToFlatten) {
                    Maybe<size_t> maxSdkLevel;
                    if (!mOptions.noAutoVersion && !fileOp.skipVersion) {
                        maxSdkLevel = std::max<size_t>(config.sdkVersion, 1u);
                        maxSdkLevel =
                                std::max<size_t>(
                                        std::max<size_t>(config.sdkVersion, 1u),
                                        mContext->getMinSdkVersion());
                    }

                    bool result = flattenXml(fileOp.xmlToFlatten.get(), fileOp.dstPath, maxSdkLevel,
@@ -1388,6 +1393,17 @@ public:
            return 1;
        }

        // Must come before ResourceFileFlattener as ResourceFileFlattener
        // relies on the minSdkVersion to properly flatten files.
        Maybe<AppInfo> maybeAppInfo = extractAppInfoFromManifest(manifestXml.get(),
                                                                 mContext->getDiagnostics());
        if (maybeAppInfo && maybeAppInfo.value().minSdkVersion) {
            if (Maybe<int> maybeMinSdkVersion =
                    ResourceUtils::tryParseSdkVersion(maybeAppInfo.value().minSdkVersion.value())) {
                mContext->setMinSdkVersion(maybeMinSdkVersion.value());
            }
        }

        ResourceFileFlattenerOptions fileFlattenerOptions;
        fileFlattenerOptions.keepRawValues = mOptions.staticLib;
        fileFlattenerOptions.doNotCompressAnything = mOptions.doNotCompressAnything;
@@ -1411,15 +1427,6 @@ public:
            }
        }

        Maybe<AppInfo> maybeAppInfo = extractAppInfoFromManifest(manifestXml.get(),
                                                                 mContext->getDiagnostics());
        if (maybeAppInfo && maybeAppInfo.value().minSdkVersion) {
            if (Maybe<int> maybeMinSdkVersion =
                    ResourceUtils::tryParseSdkVersion(maybeAppInfo.value().minSdkVersion.value())) {
                mContext->setMinSdkVersion(maybeMinSdkVersion.value());
            }
        }

        if (!mOptions.staticLib && mContext->getMinSdkVersion() > 0) {
            if (mContext->verbose()) {
                mContext->getDiagnostics()->note(