diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-24 01:13:18 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-24 01:13:18 +0000 |
commit | 91ac2ddc2f728ebc8a3d94214d87337b3f587e68 (patch) | |
tree | e20f570e8af60efe09fe64fb0a98cc27fa6dec66 | |
parent | e724313cf8b3a6d060637b25388bd1b15dfab13a (diff) | |
parent | 33ee1972a92d8822f8d3026325bff3b60b965fc7 (diff) | |
download | robolectric-shadows-android13-d4-s1-release.tar.gz |
Snap for 9100386 from 33ee1972a92d8822f8d3026325bff3b60b965fc7 to tm-d4-releaseandroid-13.0.0_r48android-13.0.0_r47android-13.0.0_r46android13-d4-s2-releaseandroid13-d4-s1-releaseandroid13-d4-release
Change-Id: Ib775e905218d4426479513428752c22813bb3d13
3 files changed, 15 insertions, 17 deletions
diff --git a/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java b/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java index 9767b9a5e..b79f70a62 100644 --- a/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java +++ b/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java @@ -395,15 +395,17 @@ public class LoadedArsc { // }); ResTable_sparseTypeEntry result = null; for (int i = 0; i < entry_count; i++) { - ResTable_sparseTypeEntry entry = new ResTable_sparseTypeEntry(type_chunk.myBuf(), - type_chunk.myOffset() + offsets_offset); - if (entry.idxOrOffset >= entry_index) { + ResTable_sparseTypeEntry entry = + new ResTable_sparseTypeEntry( + type_chunk.myBuf(), + type_chunk.myOffset() + offsets_offset + i * ResTable_sparseTypeEntry.SIZEOF); + if (entry.idx >= entry_index) { result = entry; break; } } - if (result == null || dtohs(result.idxOrOffset) != entry_index) { + if (result == null || dtohs(result.idx) != entry_index) { // No entry found. return ResTable_type.NO_ENTRY; } @@ -411,7 +413,7 @@ public class LoadedArsc { // Extract the offset from the entry. Each offset must be a multiple of 4 so we store it as // the real offset divided by 4. // return int{dtohs(result.offset)} * 4u; - return dtohs(result.idxOrOffset) * 4; + return dtohs(result.offset) * 4; } // This type is encoded as a dense array. diff --git a/resources/src/main/java/org/robolectric/res/android/ResTable.java b/resources/src/main/java/org/robolectric/res/android/ResTable.java index dbb2c6fc1..2176cafab 100644 --- a/resources/src/main/java/org/robolectric/res/android/ResTable.java +++ b/resources/src/main/java/org/robolectric/res/android/ResTable.java @@ -630,18 +630,18 @@ public class ResTable { sparseIndices, new ResTable_sparseTypeEntry(buf, sparseIndices.myOffset() + dtohl(thisType.entryCount)), new ResTable_sparseTypeEntry(buf, realEntryIndex), - (a, b) -> dtohs(a.idxOrOffset) < dtohs(b.idxOrOffset)); + (a, b) -> dtohs(a.idx) < dtohs(b.idx)); // if (result == sparseIndices + dtohl(thisType.entryCount) // || dtohs(result.idx) != realEntryIndex) { if (result.myOffset() == sparseIndices.myOffset() + dtohl(thisType.entryCount) - || dtohs(result.idxOrOffset) != realEntryIndex) { + || dtohs(result.idx) != realEntryIndex) { // No entry found. continue; } // Extract the offset from the entry. Each offset must be a multiple of 4 // so we store it as the real offset divided by 4. // thisOffset = dtohs(result->offset) * 4u; - thisOffset = dtohs(result.idxOrOffset) * 4; + thisOffset = dtohs(result.offset) * 4; } else { if (realEntryIndex >= dtohl(thisType.entryCount)) { // Entry does not exist. @@ -986,11 +986,6 @@ public class ResTable { } Type t = typeList.get(typeList.size() - 1); - if (newEntryCount != t.entryCount) { - ALOGE("ResTable_type entry count inconsistent: given %d, previously %d", - (int) newEntryCount, (int) t.entryCount); - return (mError = BAD_TYPE); - } if (t._package_ != _package) { ALOGE("No TypeSpec for type %d", type.id); diff --git a/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java b/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java index ffd482715..7e802e12d 100644 --- a/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java +++ b/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java @@ -1246,12 +1246,13 @@ public static class ResTable_ref * An entry in a ResTable_type with the flag `FLAG_SPARSE` set. */ static class ResTable_sparseTypeEntry extends WithOffset { - public static final int SIZEOF = 6; + public static final int SIZEOF = 4; // Holds the raw uint32_t encoded value. Do not read this. int entry; - short idxOrOffset; + short idx; + short offset; // struct { // The index of the entry. // uint16_t idx; @@ -1263,8 +1264,8 @@ public static class ResTable_ref public ResTable_sparseTypeEntry(ByteBuffer buf, int offset) { super(buf, offset); - entry = buf.getInt(offset); - idxOrOffset = buf.getShort(offset + 4); + this.idx = buf.getShort(offset); + this.offset = buf.getShort(offset + 2); } }; |