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

Commit 30487e0a authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

AAPT: Fixed split resource dumping

AAPT would not print resource values for splits passed in with the -I
flag. This fix prints out each split separately with the correct type
specs and values.

Bug: 79195967
Test: aapt dump --values -I base-hdpi.apk resources base-master.apk
Change-Id: I223186136e98180fec4a3d96f92f53407db59e2d
parent e4cf8413
Loading
Loading
Loading
Loading
+211 −195
Original line number Diff line number Diff line
@@ -7367,7 +7367,17 @@ void ResTable::print(bool inclValues) const
            printf("\n");
        }

        // Determine the number of resource splits for the resource types in this package.
        // It needs to be done outside of the loop below so all of the information for a
        // is displayed in a single block. Otherwise, a resource split's resource types
        // would be interleaved with other splits.
        size_t splitCount = 0;
        for (size_t typeIndex = 0; typeIndex < pg->types.size(); typeIndex++) {
            splitCount = max(splitCount, pg->types[typeIndex].size());
        }

        int packageId = pg->id;
        for (size_t splitIndex = 0; splitIndex < splitCount; splitIndex++) {
            size_t pkgCount = pg->packages.size();
            for (size_t pkgIndex=0; pkgIndex<pkgCount; pkgIndex++) {
                const Package* pkg = pg->packages[pkgIndex];
@@ -7375,17 +7385,19 @@ void ResTable::print(bool inclValues) const
                // if this package is a shared library.
                packageId = pkg->package->id;
                char16_t tmpName[sizeof(pkg->package->name)/sizeof(pkg->package->name[0])];
            strcpy16_dtoh(tmpName, pkg->package->name, sizeof(pkg->package->name)/sizeof(pkg->package->name[0]));
                strcpy16_dtoh(tmpName, pkg->package->name,
                              sizeof(pkg->package->name)/sizeof(pkg->package->name[0]));
                printf("  Package %d id=0x%02x name=%s\n", (int)pkgIndex,
                        pkg->package->id, String8(tmpName).string());
            }

            for (size_t typeIndex = 0; typeIndex < pg->types.size(); typeIndex++) {
                const TypeList& typeList = pg->types[typeIndex];
            if (typeList.isEmpty()) {
                if (splitIndex >= typeList.size() || typeList.isEmpty()) {
                    // Only dump if the split exists and contains entries for this type
                    continue;
                }
            const Type* typeConfigs = typeList[0];
                const Type* typeConfigs = typeList[splitIndex];
                const size_t NTC = typeConfigs->configs.size();
                printf("    type %d configCount=%d entryCount=%d\n",
                       (int)typeIndex, (int)NTC, (int)typeConfigs->entryCount);
@@ -7452,7 +7464,8 @@ void ResTable::print(bool inclValues) const
                    size_t entryCount = dtohl(type->entryCount);
                    uint32_t entriesStart = dtohl(type->entriesStart);
                    if ((entriesStart&0x3) != 0) {
                    printf("      NON-INTEGER ResTable_type entriesStart OFFSET: 0x%x\n", entriesStart);
                        printf("      NON-INTEGER ResTable_type entriesStart OFFSET: 0x%x\n",
                               entriesStart);
                        continue;
                    }
                    uint32_t typeSize = dtohl(type->header.size);
@@ -7568,14 +7581,16 @@ void ResTable::print(bool inclValues) const
                                const uint32_t parent = dtohl(bagPtr->parent.ident);
                                uint32_t resolvedParent = parent;
                                if (Res_GETPACKAGE(resolvedParent) + 1 == 0) {
                                status_t err = pg->dynamicRefTable.lookupResourceId(&resolvedParent);
                                    status_t err =
                                        pg->dynamicRefTable.lookupResourceId(&resolvedParent);
                                    if (err != NO_ERROR) {
                                        resolvedParent = 0;
                                    }
                                }
                                printf("          Parent=0x%08x(Resolved=0x%08x), Count=%d\n",
                                        parent, resolvedParent, N);
                            for (int i=0; i<N && mapOffset < (typeSize-sizeof(ResTable_map)); i++) {
                                for (int i=0;
                                     i<N && mapOffset < (typeSize-sizeof(ResTable_map)); i++) {
                                    printf("          #%i (Key=0x%08x): ",
                                        i, dtohl(mapPtr->name.ident));
                                    value.copyFrom_dtoh(mapPtr->value);
@@ -7591,5 +7606,6 @@ void ResTable::print(bool inclValues) const
            }
        }
    }
}

}   // namespace android