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

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

Merge "Fix assumption about DynamicRefTable in aapt" into lmp-dev

parents 336eaae1 2cb761e3
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.StrictMode;
import android.os.Trace;
import android.os.UserHandle;
import android.util.AndroidRuntimeException;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.view.DisplayAdjustments;
@@ -643,8 +644,17 @@ public final class LoadedApk {
    }

    private void rewriteRValues(ClassLoader cl, String packageName, int id) {
        final Class<?> rClazz;
        try {
            rClazz = cl.loadClass(packageName + ".R");
        } catch (ClassNotFoundException e) {
            // This is not necessarily an error, as some packages do not ship with resources
            // (or they do not need rewriting).
            Log.i(TAG, "Could not find R class for package '" + packageName + "'");
            return;
        }

        try {
            final Class<?> rClazz = cl.loadClass(packageName + ".R");
            Class<?>[] declaredClasses = rClazz.getDeclaredClasses();
            for (Class<?> clazz : declaredClasses) {
                try {
+0 −5
Original line number Diff line number Diff line
@@ -6212,11 +6212,6 @@ void ResTable::print(bool inclValues) const
    if (mError != 0) {
        printf("mError=0x%x (%s)\n", mError, strerror(mError));
    }
#if 0
    char localeStr[RESTABLE_MAX_LOCALE_LEN];
    mParams.getBcp47Locale(localeStr);
    printf("mParams=%s,\n" localeStr);
#endif
    size_t pgCount = mPackageGroups.size();
    printf("Package Groups (%d)\n", (int)pgCount);
    for (size_t pgIndex=0; pgIndex<pgCount; pgIndex++) {
+16 −0
Original line number Diff line number Diff line
@@ -195,4 +195,20 @@ TEST(ResTableTest, resourceIsOverridenWithBetterConfig) {
    ASSERT_EQ(uint32_t(400), val.data);
}

TEST(ResTableTest, emptyTableHasSensibleDefaults) {
    const int32_t assetCookie = 1;

    ResTable table;
    ASSERT_EQ(NO_ERROR, table.addEmpty(assetCookie));

    // Adding an empty table gives us one table!
    ASSERT_EQ(uint32_t(1), table.getTableCount());

    // Adding an empty table doesn't mean we get packages.
    ASSERT_EQ(uint32_t(0), table.getBasePackageCount());

    Res_value val;
    ASSERT_LT(table.getResource(base::R::integer::number1, &val, MAY_NOT_BE_BAG), 0);
}

}
+2 −5
Original line number Diff line number Diff line
@@ -764,12 +764,9 @@ int doDump(Bundle* bundle)
        return 1;
    }

    // The dynamicRefTable can be null if there are no resources for this asset cookie.
    // This fine.
    const DynamicRefTable* dynamicRefTable = res.getDynamicRefTableForCookie(assetsCookie);
    if (dynamicRefTable == NULL) {
        fprintf(stderr, "ERROR: failed to find dynamic reference table for asset cookie %d\n",
                assetsCookie);
        return 1;
    }

    Asset* asset = NULL;