@@ -42,17 +42,15 @@ public static Object invokeMethod(Object target, String className, String method
42
42
}
43
43
44
44
@ SuppressWarnings ("rawtypes" )
45
- public static Object getFieldObject (Object target , String className , String fieldName ) {
46
- Class clazz = null ;
45
+ public static Object getFieldObject (Object target , Class clazz , String fieldName ) {
47
46
try {
48
- clazz = Class .forName (className );
49
47
Field field = clazz .getDeclaredField (fieldName );
50
48
field .setAccessible (true );
51
49
return field .get (target );
52
50
} catch (SecurityException e ) {
53
51
e .printStackTrace ();
54
52
} catch (NoSuchFieldException e ) {
55
- //try supper for Miui, Miui has a class named MiuiPhoneWindow
53
+ // try supper for Miui, Miui has a class named MiuiPhoneWindow
56
54
try {
57
55
Field field = clazz .getSuperclass ().getDeclaredField (fieldName );
58
56
field .setAccessible (true );
@@ -65,6 +63,17 @@ public static Object getFieldObject(Object target, String className, String fiel
65
63
e .printStackTrace ();
66
64
} catch (IllegalAccessException e ) {
67
65
e .printStackTrace ();
66
+ }
67
+ return null ;
68
+
69
+ }
70
+
71
+ @ SuppressWarnings ("rawtypes" )
72
+ public static Object getFieldObject (Object target , String className , String fieldName ) {
73
+ Class clazz = null ;
74
+ try {
75
+ clazz = Class .forName (className );
76
+ return getFieldObject (target , clazz , fieldName );
68
77
} catch (ClassNotFoundException e ) {
69
78
e .printStackTrace ();
70
79
}
@@ -88,7 +97,7 @@ public static void setFieldObject(Object target, String className, String fieldN
88
97
} catch (SecurityException e ) {
89
98
e .printStackTrace ();
90
99
} catch (NoSuchFieldException e ) {
91
- //try supper for Miui, Miui has a class named MiuiPhoneWindow
100
+ // try supper for Miui, Miui has a class named MiuiPhoneWindow
92
101
try {
93
102
Field field = clazz .getSuperclass ().getDeclaredField (fieldName );
94
103
field .setAccessible (true );
0 commit comments