From 24aea5dae55c318218468d28b1ca79e27bfac54a Mon Sep 17 00:00:00 2001 From: Maurice Lam Date: Mon, 8 Oct 2018 19:29:03 -0700 Subject: [PATCH] Remove hacks to access framework private resources ag/5200295 now allows framework private resources to be resolved. Test: atest RunSettingsRoboTests Change-Id: Idaf2144bea6d3b44ec133e48d89e6674256b4cbe --- .../testutils/shadow/SettingsShadowResources.java | 42 ---------------------- 1 file changed, 42 deletions(-) diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java index a68c5d38ba..bd21cdc3cb 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java +++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java @@ -30,18 +30,12 @@ import org.robolectric.android.XmlResourceParserImpl; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; -import org.robolectric.res.StyleData; -import org.robolectric.res.StyleResolver; -import org.robolectric.res.ThemeStyleSet; import org.robolectric.shadows.ShadowAssetManager; import org.robolectric.shadows.ShadowResources; import org.robolectric.util.ReflectionHelpers; import org.robolectric.util.ReflectionHelpers.ClassParameter; import org.w3c.dom.Node; -import java.util.List; -import java.util.Map; - /** * Shadow Resources and Theme classes to handle resource references that Robolectric shadows cannot * handle because they are too new or private. @@ -207,44 +201,8 @@ public class SettingsShadowResources extends ShadowResources { if (attributeValue.contains("attr/fingerprint_layout_theme")) { // Workaround for https://github.com/robolectric/robolectric/issues/2641 node.setNodeValue("@style/FingerprintLayoutTheme"); - } else if (attributeValue.startsWith("@*android:string")) { - node.setNodeValue("PLACEHOLDER"); - } else if (attributeValue.startsWith("@*android:dimen")) { - node.setNodeValue("321dp"); - } else if (attributeValue.startsWith("@*android:drawable")) { - node.setNodeValue(""); - } - } - } - } - - // Track down all styles and remove all inheritance from private styles. - final Map appliedStylesList = - ReflectionHelpers.getField(mAssetManager, "nativeThemes"); - synchronized (appliedStylesList) { - for (Long idx : appliedStylesList.keySet()) { - final ThemeStyleSet appliedStyles = ReflectionHelpers.getField( - appliedStylesList.get(idx), "themeStyleSet"); - // The Object's below are actually ShadowAssetManager.OverlayedStyle. - // We can't use - - // it here because it's private. - final List overlayedStyles = - ReflectionHelpers.getField(appliedStyles, "styles"); - for (Object appliedStyle : overlayedStyles) { - final StyleResolver styleResolver = ReflectionHelpers.getField(appliedStyle, - "style"); - final List styleDatas = - ReflectionHelpers.getField(styleResolver, "styles"); - for (StyleData styleData : styleDatas) { - if (styleData.getParent() != null && - styleData.getParent().startsWith("@*android:style")) { - ReflectionHelpers.setField(StyleData.class, styleData, "parent", - null); - } } } - } } return super.obtainStyledAttributes(set, attrs, defStyleAttr, defStyleRes); -- 2.11.0