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

Commit 1201ca70 authored by Winson's avatar Winson
Browse files

Skip idmap1 generation if target defines overlayable

Since idmap1 can't enforce policy restrictions, we can't allow it
to generate an idmap that might get used.

Migrating to idmap2 is too difficult for now as it requires a lot
of PackageManager infrastructure to validate policies, and none of
that is available during manifest parsing, which is where idmap1
is currently used.

Bug: b/130260055

Test: manual test BT issue from b/130260055
Test: manual test app with test overlay toggling Activity enabled

Change-Id: I5e7e321d27aab9be360a5e8be77d804ad3f66336
parent 5a8b95c3
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3510,6 +3510,7 @@ struct ResTable::Package
    ResStringPool                   keyStrings;

    size_t                          typeIdOffset;
    bool                            definesOverlayable = false;
};

// A group of objects describing a particular resource package.
@@ -6861,6 +6862,10 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
                ALOGW("Found multiple library tables, ignoring...");
            }
        } else {
            if (ctype == RES_TABLE_OVERLAYABLE_TYPE) {
                package->definesOverlayable = true;
            }

            status_t err = validate_chunk(chunk, sizeof(ResChunk_header),
                                          endPos, "ResTable_package:unknown");
            if (err != NO_ERROR) {
@@ -7138,6 +7143,11 @@ status_t ResTable::createIdmap(const ResTable& targetResTable,
        return UNKNOWN_ERROR;
    }

    // Idmap is not aware of overlayable, exit since policy checks can't be done
    if (targetResTable.mPackageGroups[0]->packages[0]->definesOverlayable) {
        return UNKNOWN_ERROR;
    }

    const ResTable_package* targetPackageStruct =
        targetResTable.mPackageGroups[0]->packages[0]->package;
    const size_t tmpNameSize = arraysize(targetPackageStruct->name);