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

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

Merge "AAPT2: Fix overlay support"

parents 457ef13c a6fe345b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ sources := \
	flatten/Archive.cpp \
	flatten/TableFlattener.cpp \
	flatten/XmlFlattener.cpp \
	io/FileSystem.cpp \
	io/ZipArchive.cpp \
	link/AutoVersioner.cpp \
	link/ManifestFixer.cpp \
	link/PrivateAttributeMover.cpp \
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public:
        };
    }

    bool shouldMangle(const std::u16string& package) {
    bool shouldMangle(const std::u16string& package) const {
        if (package.empty() || mPolicy.targetPackageName == package) {
            return false;
        }
+8 −0
Original line number Diff line number Diff line
@@ -85,4 +85,12 @@ const ResourceType* parseResourceType(const StringPiece16& str) {
    return &iter->second;
}

bool operator<(const ResourceKey& a, const ResourceKey& b) {
    return std::tie(a.name, a.config) < std::tie(b.name, b.config);
}

bool operator<(const ResourceKeyRef& a, const ResourceKeyRef& b) {
    return std::tie(a.name, a.config) < std::tie(b.name, b.config);
}

} // namespace aapt
+30 −0
Original line number Diff line number Diff line
@@ -165,6 +165,36 @@ struct ResourceFile {
    std::vector<SourcedResourceName> exportedSymbols;
};

/**
 * Useful struct used as a key to represent a unique resource in associative containers.
 */
struct ResourceKey {
    ResourceName name;
    ConfigDescription config;
};

bool operator<(const ResourceKey& a, const ResourceKey& b);

/**
 * Useful struct used as a key to represent a unique resource in associative containers.
 * Holds a reference to the name, so that name better live longer than this key!
 */
struct ResourceKeyRef {
    ResourceNameRef name;
    ConfigDescription config;

    ResourceKeyRef() = default;
    ResourceKeyRef(const ResourceNameRef& n, const ConfigDescription& c) : name(n), config(c) {
    }

    /**
     * Prevent taking a reference to a temporary. This is bad.
     */
    ResourceKeyRef(ResourceName&& n, const ConfigDescription& c) = delete;
};

bool operator<(const ResourceKeyRef& a, const ResourceKeyRef& b);

//
// ResourceId implementation.
//
+23 −6
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ struct ParsedResource {
    ResourceName name;
    Source source;
    ResourceId id;
    SymbolState symbolState = SymbolState::kUndefined;
    Maybe<SymbolState> symbolState;
    std::u16string comment;
    std::unique_ptr<Value> value;
    std::list<ParsedResource> childResources;
@@ -182,9 +182,9 @@ struct ParsedResource {
// Recursively adds resources to the ResourceTable.
static bool addResourcesToTable(ResourceTable* table, const ConfigDescription& config,
                                IDiagnostics* diag, ParsedResource* res) {
    if (res->symbolState != SymbolState::kUndefined) {
    if (res->symbolState) {
        Symbol symbol;
        symbol.state = res->symbolState;
        symbol.state = res->symbolState.value();
        symbol.source = res->source;
        symbol.comment = res->comment;
        if (!table->setSymbolState(res->name, res->id, symbol, diag)) {
@@ -325,6 +325,8 @@ bool ResourceParser::parseResources(xml::XmlPullParser* parser) {
            result = parseSymbol(parser, &parsedResource);
        } else if (elementName == u"public-group") {
            result = parsePublicGroup(parser, &parsedResource);
        } else if (elementName == u"add-resource") {
            result = parseAddResource(parser, &parsedResource);
        } else {
            // Try parsing the elementName (or type) as a resource. These shall only be
            // resources like 'layout' or 'xml' and they can only be references.
@@ -643,7 +645,7 @@ bool ResourceParser::parsePublicGroup(xml::XmlPullParser* parser, ParsedResource
    return !error;
}

bool ResourceParser::parseSymbol(xml::XmlPullParser* parser, ParsedResource* outResource) {
bool ResourceParser::parseSymbolImpl(xml::XmlPullParser* parser, ParsedResource* outResource) {
    const Source source = mSource.withLine(parser->getLineNumber());

    Maybe<StringPiece16> maybeType = xml::findNonEmptyAttribute(parser, u"type");
@@ -661,9 +663,24 @@ bool ResourceParser::parseSymbol(xml::XmlPullParser* parser, ParsedResource* out
    }

    outResource->name.type = *parsedType;
    return true;
}

bool ResourceParser::parseSymbol(xml::XmlPullParser* parser, ParsedResource* outResource) {
    if (parseSymbolImpl(parser, outResource)) {
        outResource->symbolState = SymbolState::kPrivate;
        return true;
    }
    return false;
}

bool ResourceParser::parseAddResource(xml::XmlPullParser* parser, ParsedResource* outResource) {
    if (parseSymbolImpl(parser, outResource)) {
        outResource->symbolState = SymbolState::kUndefined;
        return true;
    }
    return false;
}

static uint32_t parseFormatType(const StringPiece16& piece) {
    if (piece == u"reference")      return android::ResTable_map::TYPE_REFERENCE;
@@ -870,7 +887,7 @@ Maybe<Attribute::Symbol> ResourceParser::parseEnumOrFlagItem(xml::XmlPullParser*
    }

    return Attribute::Symbol{
            Reference(ResourceName({}, ResourceType::kId, maybeName.value().toString())),
            Reference(ResourceNameRef({}, ResourceType::kId, maybeName.value())),
            val.data };
}

Loading