Merge 28ed3e08a4c9e47e864a267c3aaaba2641050763 on remote branch

Change-Id: I625b514887ae657a412a7af88b91996faa92c443
diff --git a/Android.bp b/Android.bp
index 774c382..bcfb03e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -105,6 +105,7 @@
         "services.accessibility",
         "telephony-common",
         "android.car",
+        "android.car.builtin",
     ],
 }
 
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 9767b9a..b79f70a 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 @@
         // });
         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 @@
         // 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 dbb2c6f..2176caf 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 @@
               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 @@
           }
 
           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 ffd4827..7e802e1 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 @@
    * 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 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);
     }
   };
 
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManagerGlobal.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManagerGlobal.java
index b9691d1..8f730a9 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManagerGlobal.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManagerGlobal.java
@@ -81,7 +81,7 @@
     }
 
     // @Override // todo: use @Implements/@Implementation for signature checking
-    public int[] getDisplayIds(boolean includeDisabledDisplays) throws RemoteException {
+    public int[] getDisplayIds() throws RemoteException {
       int[] ids = new int[displayInfos.size()];
       int i = 0;
       for (Integer displayId : displayInfos.keySet()) {