15
15
import de .robv .android .xposed .XposedBridge ;
16
16
17
17
import static de .robv .android .xposed .XposedHelpers .findClass ;
18
- import static de .robv .android .xposed .XposedHelpers .findField ;
19
- import static de .robv .android .xposed .XposedHelpers .findMethodExact ;
18
+ import static de .robv .android .xposed .XposedHelpers .findFieldIfExists ;
19
+ import static de .robv .android .xposed .XposedHelpers .findMethodExactIfExists ;
20
20
import static de .robv .android .xposed .XposedHelpers .getObjectField ;
21
21
import static de .robv .android .xposed .XposedHelpers .newInstance ;
22
22
@@ -30,28 +30,17 @@ public final class AndroidAppHelper {
30
30
private AndroidAppHelper () {}
31
31
32
32
private static final Class <?> CLASS_RESOURCES_KEY ;
33
- private static boolean HAS_IS_THEMEABLE = false ;
34
- private static boolean HAS_THEME_CONFIG_PARAMETER = false ;
33
+ private static final boolean HAS_IS_THEMEABLE ;
34
+ private static final boolean HAS_THEME_CONFIG_PARAMETER ;
35
35
36
36
static {
37
37
CLASS_RESOURCES_KEY = (Build .VERSION .SDK_INT < 19 ) ?
38
38
findClass ("android.app.ActivityThread$ResourcesKey" , null )
39
39
: findClass ("android.content.res.ResourcesKey" , null );
40
40
41
- try {
42
- // T-Mobile theming engine (CyanogenMod etc.)
43
- findField (CLASS_RESOURCES_KEY , "mIsThemeable" );
44
- HAS_IS_THEMEABLE = true ;
45
- } catch (NoSuchFieldError ignored ) {
46
- } catch (Throwable t ) { XposedBridge .log (t ); }
47
-
48
- if (HAS_IS_THEMEABLE && Build .VERSION .SDK_INT >= 21 ) {
49
- try {
50
- findMethodExact ("android.app.ResourcesManager" , null , "getThemeConfig" );
51
- HAS_THEME_CONFIG_PARAMETER = true ;
52
- } catch (NoSuchMethodError ignored ) {
53
- } catch (Throwable t ) { XposedBridge .log (t ); }
54
- }
41
+ HAS_IS_THEMEABLE = findFieldIfExists (CLASS_RESOURCES_KEY , "mIsThemeable" ) != null ;
42
+ HAS_THEME_CONFIG_PARAMETER = HAS_IS_THEMEABLE && Build .VERSION .SDK_INT >= 21
43
+ && findMethodExactIfExists ("android.app.ResourcesManager" , null , "getThemeConfig" ) != null ;
55
44
}
56
45
57
46
@ SuppressWarnings ({ "unchecked" , "rawtypes" })
0 commit comments