Fix copying/indices logic in getBagLocked.
Remove redundant ShadowResourcesTests already present in
ShadowThemeTest.
Eliminate multiple reads of app arsc resources.
diff --git a/resources/src/main/java/org/robolectric/res/android/CppAssetManager.java b/resources/src/main/java/org/robolectric/res/android/CppAssetManager.java
index 609497e..940fafe 100644
--- a/resources/src/main/java/org/robolectric/res/android/CppAssetManager.java
+++ b/resources/src/main/java/org/robolectric/res/android/CppAssetManager.java
@@ -542,16 +542,21 @@
   }
 
   boolean appendPathToResTable(final asset_path ap, boolean appAsLib) {
-    URL resource = getClass().getResource("/resources.ap_"); // todo get this from asset_path
-    System.out.println("Reading ARSC file  from " + resource);
-    LOG_FATAL_IF(resource == null, "Could not find resources.ap_");
-    try {
-      ZipFile zipFile = new ZipFile(resource.getFile());
-      ZipEntry arscEntry = zipFile.getEntry("resources.arsc");
-      InputStream inputStream = zipFile.getInputStream(arscEntry);
-      mResources.add(inputStream, mResources.getTableCount() + 1);
-    } catch (IOException e) {
-      throw new RuntimeException(e);
+    // TODO: properly handle reading system resources
+    if (ap.path.string().endsWith("resources.ap_")) {
+      URL resource = getClass().getResource("/resources.ap_"); // todo get this from asset_path
+      // System.out.println("Reading ARSC file  from " + resource);
+      LOG_FATAL_IF(resource == null, "Could not find resources.ap_");
+      try {
+        ZipFile zipFile = new ZipFile(resource.getFile());
+        ZipEntry arscEntry = zipFile.getEntry("resources.arsc");
+        InputStream inputStream = zipFile.getInputStream(arscEntry);
+        mResources.add(inputStream, mResources.getTableCount() + 1);
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    } else {
+
     }
     return false;
 
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 0a5d1d1..47a66cd 100644
--- a/resources/src/main/java/org/robolectric/res/android/ResTable.java
+++ b/resources/src/main/java/org/robolectric/res/android/ResTable.java
@@ -1169,12 +1169,11 @@
     // Bag not found, we need to compute it!
     if (!isTruthy(typeSet)) {
       typeSet = new bag_set[NENTRY]; // (bag_set**)calloc(NENTRY, sizeof(bag_set*));
-      //if (!typeSet) return NO_MEMORY;
       //cacheEntry.cachedBags = typeSet;
     }
 //
 //    // Mark that we are currently working on this one.
-////    typeSet[e] = (bag_set*)0xFFFFFFFF;
+//    typeSet[e] = (bag_set*)0xFFFFFFFF;
 //    typeSet[e] = SENTINEL_BAG_SET;
 
     if (kDebugTableNoisy) {
@@ -1205,7 +1204,7 @@
     }
 
     // This is what we are building.
-    Ref<bag_set> setRef = new Ref<>(null);
+    bag_set set;
 
     if (isTruthy(parent)) {
       Ref<Integer> resolvedParent = new Ref<>(parent);
@@ -1224,14 +1223,8 @@
       final Ref<Integer> parentTypeSpecFlags = new Ref<>(0);
       final int NP = getBagLocked(resolvedParent.get(), parentBag, parentTypeSpecFlags);
       final int NT = ((NP >= 0) ? NP : 0) + N;
-//      set = (bag_set *) malloc(sizeof(bag_set) + sizeof(bag_entry) * NT);
-      bag_set set = new bag_set(NT);
-      setRef.set(set);
-//      if (setRef.get() == NULL) {
-//        return NO_MEMORY;
-//      }
+      set = new bag_set(NT);
       if (NP > 0) {
-//        memcpy(set + 1, parentBag, NP * sizeof(bag_entry));
         set.copyFrom(parentBag.get(), NP);
         set.numAttrs = NP;
         if (kDebugTableNoisy) {
@@ -1246,23 +1239,19 @@
       set.availAttrs = NT;
       set.typeSpecFlags = parentTypeSpecFlags.get();
     } else {
-//      set = (bag_set *) malloc(sizeof(bag_set) + sizeof(bag_entry) * N);
-      bag_set set = new bag_set(N);
-      setRef.set(set);
-//      if (set == NULL) {
-//        return NO_MEMORY;
-//      }
+      set = new bag_set(N);
       set.numAttrs = 0;
       set.availAttrs = N;
       set.typeSpecFlags = 0;
     }
 
-    bag_set set = setRef.get();
     set.typeSpecFlags |= entry.specFlags;
 
     // Now merge in the new attributes...
 //    int curOff = (reinterpret_cast<uintptr_t>(entry.entry) - reinterpret_cast<uintptr_t>(entry.type))
 //        + dtohs(entry.entry.size);
+    // use curOff as an index instead of as a pointer offset
+    int curOff = 0;
     ResTableMap map;
 //    bag_entry* entries = (bag_entry*)(set+1);
     bag_entry[] entries = set.bag_entries;
@@ -1283,7 +1272,10 @@
 //        return BAD_TYPE;
 //      }
 //      map = (final ResTable_map*)(((final uint8_t*)entry.type) + curOff);
-      map = ((MapEntry) entry).nameValuePairs[curEntry];
+      if (curOff >= ((MapEntry) entry).nameValuePairs.length) {
+        return BAD_TYPE;
+      }
+      map = ((MapEntry) entry).nameValuePairs[curOff];
       N++;
 
       Ref<Integer> newName = new Ref<>(htodl(map.nameIdent));
@@ -1317,9 +1309,6 @@
 //              sizeof(bag_set)
 //                  + sizeof(bag_entry)*newAvail);
           set.resizeBagEntries(newAvail);
-          if (set == NULL) {
-            return NO_MEMORY;
-          }
           set.availAttrs = newAvail;
 //          entries = (bag_entry*)(set+1);
           entries = set.bag_entries;
@@ -1370,6 +1359,7 @@
       pos++;
 //        final int size = dtohs(map.value.size);
 //      curOff += size + sizeof(*map)-sizeof(map.value);
+      curOff++;
     };
 
     if (curEntry > set.numAttrs) {
diff --git a/robolectric/src/test/java/org/robolectric/R.java b/robolectric/src/test/java/org/robolectric/R.java
index ea8f03b..141eaac 100644
--- a/robolectric/src/test/java/org/robolectric/R.java
+++ b/robolectric/src/test/java/org/robolectric/R.java
@@ -34,7 +34,7 @@
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int anAttribute=0x7f010017;
+        public static final int anAttribute=0x7f010018;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
@@ -62,7 +62,7 @@
 "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
 containing a value of this type.
          */
-        public static final int attr2FromLib1=0x7f010024;
+        public static final int attr2FromLib1=0x7f010025;
         /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -70,7 +70,7 @@
 "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
 containing a value of this type.
          */
-        public static final int attrFromLib1=0x7f010023;
+        public static final int attrFromLib1=0x7f010024;
         /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -78,17 +78,17 @@
 "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
 containing a value of this type.
          */
-        public static final int attrFromLib2=0x7f010022;
+        public static final int attrFromLib2=0x7f010023;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int attributeReferencingAnAttribute=0x7f010018;
+        public static final int attributeReferencingAnAttribute=0x7f010019;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
 <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int averageSheepWidth=0x7f01001b;
+        public static final int averageSheepWidth=0x7f01001c;
         /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -97,10 +97,18 @@
 containing a value of this type.
          */
         public static final int child_string=0x7f010013;
+        /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+         */
+        public static final int child_string2=0x7f010014;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int circularReference=0x7f010019;
+        public static final int circularReference=0x7f01001a;
         /** <p>Must be one or more (separated by '|') of the following constant values.</p>
 <table>
 <colgroup align="left" />
@@ -115,7 +123,7 @@
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int isSugary=0x7f01001c;
+        public static final int isSugary=0x7f01001d;
         /** <p>Must be one of the following constant values.</p>
 <table>
 <colgroup align="left" />
@@ -141,11 +149,11 @@
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int logoHeight=0x7f01001d;
+        public static final int logoHeight=0x7f01001e;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int logoWidth=0x7f01001e;
+        public static final int logoWidth=0x7f01001f;
         /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -173,7 +181,7 @@
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int parentStyleReference=0x7f010014;
+        public static final int parentStyleReference=0x7f010015;
         /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -209,7 +217,7 @@
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int snail=0x7f010021;
+        public static final int snail=0x7f010022;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
@@ -225,7 +233,7 @@
 "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
 containing a value of this type.
          */
-        public static final int stateFoo=0x7f01001a;
+        public static final int stateFoo=0x7f01001b;
         /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -253,19 +261,19 @@
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int stringReference=0x7f010016;
+        public static final int stringReference=0x7f010017;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int styleNotSpecifiedInAnyTheme=0x7f010015;
+        public static final int styleNotSpecifiedInAnyTheme=0x7f010016;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int styleReference=0x7f01001f;
+        public static final int styleReference=0x7f010020;
         /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
 or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
          */
-        public static final int styleReferenceWithoutExplicitType=0x7f010020;
+        public static final int styleReferenceWithoutExplicitType=0x7f010021;
         /** <p>Must be an integer value, such as "<code>100</code>".
 <p>This may also be a reference to a resource (in the form
 "<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
@@ -593,7 +601,7 @@
            @see #CustomStateView_stateFoo
          */
         public static final int[] CustomStateView = {
-            0x7f01001a
+            0x7f01001b
         };
         /**
           <p>This symbol is the offset where the {@link org.robolectric.R.attr#stateFoo}
@@ -651,7 +659,7 @@
             0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003,
             0x7f010004, 0x7f010005, 0x7f010006, 0x7f010007,
             0x7f010008, 0x7f010009, 0x7f01000a, 0x7f01000b,
-            0x7f01000c, 0x7f01000d, 0x7f010022
+            0x7f01000c, 0x7f01000d, 0x7f010023
         };
         /**
           <p>This symbol is the offset where the {@link org.robolectric.R.attr#animalStyle}
@@ -887,7 +895,7 @@
            @see #Lib1Styleable_attrFromLib1
          */
         public static final int[] Lib1Styleable = {
-            0x7f010023, 0x7f010024
+            0x7f010024, 0x7f010025
         };
         /**
           <p>This symbol is the offset where the {@link org.robolectric.R.attr#attr2FromLib1}
@@ -940,8 +948,8 @@
            @see #Theme_AnotherTheme_Attributes_styleReferenceWithoutExplicitType
          */
         public static final int[] Theme_AnotherTheme_Attributes = {
-            0x7f01001b, 0x7f01001c, 0x7f01001d, 0x7f01001e,
-            0x7f01001f, 0x7f010020, 0x7f010021
+            0x7f01001c, 0x7f01001d, 0x7f01001e, 0x7f01001f,
+            0x7f010020, 0x7f010021, 0x7f010022
         };
         /**
           <p>This symbol is the offset where the {@link org.robolectric.R.attr#averageSheepWidth}
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowResourcesTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowResourcesTest.java
index 4d36058..fac56a6 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowResourcesTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowResourcesTest.java
@@ -757,73 +757,6 @@
   }
 
   @Test
-  public void applyStyleForced() {
-    final Resources.Theme theme = resources.newTheme();
-
-    theme.applyStyle(R.style.MyBlackTheme, true);
-    TypedArray arr = theme.obtainStyledAttributes(new int[]{android.R.attr.windowBackground, android.R.attr.textColorHint});
-
-    final TypedValue blackBackgroundColor = new TypedValue();
-    arr.getValue(0, blackBackgroundColor);
-    assertThat(blackBackgroundColor.resourceId).isEqualTo(android.R.color.black);
-    arr.recycle();
-
-    theme.applyStyle(R.style.MyBlueTheme, true);
-    arr = theme.obtainStyledAttributes(new int[]{android.R.attr.windowBackground, android.R.attr.textColor, android.R.attr.textColorHint});
-
-    final TypedValue blueBackgroundColor = new TypedValue();
-    arr.getValue(0, blueBackgroundColor);
-    assertThat(blueBackgroundColor.resourceId).isEqualTo(R.color.blue);
-
-    final TypedValue blueTextColor = new TypedValue();
-    arr.getValue(1, blueTextColor);
-    assertThat(blueTextColor.resourceId).isEqualTo(R.color.white);
-
-    final TypedValue blueTextColorHint = new TypedValue();
-    arr.getValue(2, blueTextColorHint);
-    assertThat(blueTextColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
-
-    arr.recycle();
-  }
-
-  @Test
-  public void applyStyleNotForced() {
-    final Resources.Theme theme = resources.newTheme();
-
-    // Apply black theme
-    theme.applyStyle(R.style.MyBlackTheme, true);
-    TypedArray arr = theme.obtainStyledAttributes(new int[]{android.R.attr.windowBackground, android.R.attr.textColorHint});
-
-    final TypedValue blackBackgroundColor = new TypedValue();
-    arr.getValue(0, blackBackgroundColor);
-    assertThat(blackBackgroundColor.resourceId).isEqualTo(android.R.color.black);
-
-    final TypedValue blackTextColorHint = new TypedValue();
-    arr.getValue(1, blackTextColorHint);
-    assertThat(blackTextColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
-
-    arr.recycle();
-
-    // Apply blue theme
-    theme.applyStyle(R.style.MyBlueTheme, false);
-    arr = theme.obtainStyledAttributes(new int[]{android.R.attr.windowBackground, android.R.attr.textColor, android.R.attr.textColorHint});
-
-    final TypedValue blueBackgroundColor = new TypedValue();
-    arr.getValue(0, blueBackgroundColor);
-    assertThat(blueBackgroundColor.resourceId).isEqualTo(android.R.color.black);
-
-    final TypedValue blueTextColor = new TypedValue();
-    arr.getValue(1, blueTextColor);
-    assertThat(blueTextColor.resourceId).isEqualTo(R.color.white);
-
-    final TypedValue blueTextColorHint = new TypedValue();
-    arr.getValue(2, blueTextColorHint);
-    assertThat(blueTextColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
-
-    arr.recycle();
-  }
-
-  @Test
   public void getValueShouldClearTypedArrayBetweenCalls() throws Exception {
     TypedValue outValue = new TypedValue();
 
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowThemeTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowThemeTest.java
index ea3a350..89ee4a5 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowThemeTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowThemeTest.java
@@ -25,7 +25,7 @@
 import static org.robolectric.Shadows.shadowOf;
 
 @RunWith(TestRunners.MultiApiSelfTest.class)
-@Config(sdk = VERSION_CODES.N_MR1) // TODO: unpin sdk
+@Config(sdk = VERSION_CODES.O) // TODO: unpin sdk
 public class ShadowThemeTest {
 
   private Resources resources;
diff --git a/robolectric/src/test/resources/res/values/attrs.xml b/robolectric/src/test/resources/res/values/attrs.xml
index e6d6bac..8844cd5 100644
--- a/robolectric/src/test/resources/res/values/attrs.xml
+++ b/robolectric/src/test/resources/res/values/attrs.xml
@@ -53,6 +53,7 @@
   <attr name="string3" format="string"/>
   <attr name="parent_string" format="string"/>
   <attr name="child_string" format="string"/>
+  <attr name="child_string2" format="string"/>
   <attr name="parentStyleReference" format="reference"/>
   <attr name="styleNotSpecifiedInAnyTheme" format="reference"/>
   <attr name="stringReference" format="reference"/>
diff --git a/robolectric/src/test/resources/res/values/themes.xml b/robolectric/src/test/resources/res/values/themes.xml
index 37b5e41..619c901 100644
--- a/robolectric/src/test/resources/res/values/themes.xml
+++ b/robolectric/src/test/resources/res/values/themes.xml
@@ -106,6 +106,7 @@
 
   <style name="SimpleChildWithAdditionalAttributes" parent="@style/SimpleParent">
     <item name="child_string">child string</item>
+    <item name="child_string2">child string2</item>
   </style>
 
   <style name="StyleA">
diff --git a/robolectric/src/test/resources/resources.ap_ b/robolectric/src/test/resources/resources.ap_
index 54b665c..70feecf 100644
--- a/robolectric/src/test/resources/resources.ap_
+++ b/robolectric/src/test/resources/resources.ap_
Binary files differ
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java
index d7de705..76701e1 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java
@@ -4,6 +4,9 @@
 import static android.os.Build.VERSION_CODES.LOLLIPOP;
 import static org.robolectric.res.android.Errors.BAD_INDEX;
 import static org.robolectric.res.android.Errors.NO_ERROR;
+import static org.robolectric.res.android.Util.ALOGI;
+import static org.robolectric.res.android.Util.ALOGV;
+import static org.robolectric.res.android.Util.isTruthy;
 import static org.robolectric.shadow.api.Shadow.directlyOn;
 import static org.robolectric.shadow.api.Shadow.invokeConstructor;
 
@@ -1105,14 +1108,7 @@
   @HiddenApi
   @Implementation(maxSdk = KITKAT_WATCH)
   public static void applyThemeStyle(int themePtr, int styleRes, boolean force) {
-    if (shouldDelegateToLegacyShadow(themePtr)) {
-      ShadowAssetManager.applyThemeStyle(themePtr, styleRes, force);
-    } else {
-      directlyOn(AssetManager.class, "applyThemeStyle",
-          ClassParameter.from(int.class, themePtr),
-          ClassParameter.from(int.class, styleRes),
-          ClassParameter.from(boolean.class, force));
-    }
+    applyThemeStyle((long)themePtr, styleRes, force);
   }
 
   @HiddenApi
@@ -1387,8 +1383,7 @@
 
   @HiddenApi
   @Implementation
-  public int getStringBlockCount()
-  {
+  public int getStringBlockCount() {
     CppAssetManager am = assetManagerForJavaObject();
     if (am == null) {
       return 0;
@@ -1396,36 +1391,10 @@
     return am.getResources().getTableCount();
   }
 
-
   private CppAssetManager assetManagerForJavaObject() {
     if (cppAssetManager == null) {
       cppAssetManager = new CppAssetManager();
     }
     return cppAssetManager;
   }
-
-
-  public static boolean isTruthy(int i) {
-    return i != 0;
-  }
-
-  public static boolean isTruthy(Object o) {
-    return o != null;
-  }
-
-  static void ALOGW(String message, Object... args) {
-    System.out.println("WARN: " + String.format(message, args));
-  }
-
-  public static void ALOGV(String message, Object... args) {
-    System.out.println("VERBOSE: " + String.format(message, args));
-  }
-
-  static void ALOGI(String message, Object... args) {
-    System.out.println("INFO: " + String.format(message, args));
-  }
-
-  static void ALOGE(String message, Object... args) {
-    System.out.println("ERROR: " + String.format(message, args));
-  }
 }