OSDN Git Service

Restore getAccessibleMethod in the preferences inflater
authorDiego Perez <diegoperez@google.com>
Fri, 15 Jul 2016 10:37:34 +0000 (11:37 +0100)
committerDiego Perez <diegoperez@google.com>
Tue, 19 Jul 2016 15:43:25 +0000 (15:43 +0000)
It turns out that although the method was public, the class is package
protected and hence the "Accessible" call

Change-Id: Iec69ad15db4c22d472a941dd335b6cf7789eea09
(cherry picked from commit ff78c344e63c8665ab7b0773b91e473b4fe650ff)

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/SupportPreferencesUtil.java

index 0124e83..6ad9efc 100644 (file)
@@ -41,6 +41,7 @@ import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 
+import static com.android.layoutlib.bridge.util.ReflectionUtils.getAccessibleMethod;
 import static com.android.layoutlib.bridge.util.ReflectionUtils.getClassInstance;
 import static com.android.layoutlib.bridge.util.ReflectionUtils.getMethod;
 import static com.android.layoutlib.bridge.util.ReflectionUtils.invoke;
@@ -93,9 +94,10 @@ public class SupportPreferencesUtil {
         Object preferenceInflater = instantiateClass(callback, PREFERENCE_INFLATER,
           new Class[]{Context.class, preferenceManager.getClass()},
           new Object[]{context, preferenceManager});
-        Object inflatedPreference = invoke(
-          getMethod(preferenceInflater.getClass(), "inflate", XmlPullParser.class,
-            preferenceGroupClass), preferenceInflater, parser, null);
+        Object inflatedPreference =
+                invoke(getAccessibleMethod(preferenceInflater.getClass(), "inflate",
+                        XmlPullParser.class, preferenceGroupClass), preferenceInflater, parser,
+                        null);
 
         if (inflatedPreference == null) {
             throw new ReflectionException("inflate method returned null");