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

Commit 4ca56978 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

AAPT2: Add workaround for non-standard package IDs

The dynamic ref table used to map build-time IDs to runtime IDs
is mainly used for shared resource libraries and has a few built-in
mappings (app 0x7f and framework 0x01).

Using a non-standard package ID like 0x80 causes a failure in package ID
lookup. The solution is to ship the dynamic_ref_table with an identity mapping
with any resource table that uses a non-standard package ID.

Adds some tests to ensure this works correctly.

Bug: 37498913
Test: make libandroidfw_tests
Test: make aapt2_tests
Change-Id: Ic3f67942384d34e7fdcbc94ded360e940e3ebc8a
parent 9e55fcbd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21067,7 +21067,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @Nullable
    public final <T extends View> T findViewById(@IdRes int id) {
        if (id < 0) {
        if (id == NO_ID) {
            return null;
        }
        return findViewTraversal(id);
+4 −0
Original line number Diff line number Diff line
@@ -6664,6 +6664,10 @@ status_t DynamicRefTable::addMapping(const String16& packageName, uint8_t packag
    return NO_ERROR;
}

void DynamicRefTable::addMapping(uint8_t buildPackageId, uint8_t runtimePackageId) {
    mLookupTable[buildPackageId] = runtimePackageId;
}

status_t DynamicRefTable::lookupResourceId(uint32_t* resId) const {
    uint32_t res = *resId;
    size_t packageId = Res_GETPACKAGE(res) + 1;
+2 −0
Original line number Diff line number Diff line
@@ -1610,6 +1610,8 @@ public:
    // the given package.
    status_t addMapping(const String16& packageName, uint8_t packageId);

    void addMapping(uint8_t buildPackageId, uint8_t runtimePackageId);

    // Performs the actual conversion of build-time resource ID to run-time
    // resource ID.
    status_t lookupResourceId(uint32_t* resId) const;
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.test.split.feature"
    featureName="feature1">
    featureSplit="feature1">

    <uses-sdk android:minSdkVersion="21" />

+5 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
Loading