1313import de .robv .android .xposed .XposedHelpers ;
1414import de .robv .android .xposed .callbacks .XC_LoadPackage ;
1515
16- import static de .robv .android .xposed .XposedHelpers .callStaticMethod ;
1716import static de .robv .android .xposed .XposedHelpers .findAndHookMethod ;
1817import static de .robv .android .xposed .XposedHelpers .findClass ;
1918import static de .robv .android .xposed .XposedHelpers .getObjectField ;
@@ -25,68 +24,70 @@ public class MainHook implements IXposedHookLoadPackage {
2524
2625 @ Override
2726 public void handleLoadPackage (final XC_LoadPackage .LoadPackageParam lpparam ) {
27+ if (!PropertyUtils .get ("ro.miui.support_miui_ime_bottom" , "0" ).equals ("1" )) return ;
28+ checkVersion ();
2829 findAndHookMethod ("android.inputmethodservice.InputMethodService" , lpparam .classLoader , "initViews" , new XC_MethodHook () {
2930 @ Override
3031 protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
31- checkVersion ();
32- if (isA10 || isA11 ) {
33- final boolean isNonCustomize = !miuiImeList .contains (lpparam .packageName );
34- if (isNonCustomize ) {
35- XposedBridge .log ("Hook ServiceInjector: " + lpparam .packageName );
36- Class <?> clazz = findClass ("android.inputmethodservice.InputMethodServiceInjector" , lpparam .classLoader );
37- setsIsImeSupport (clazz );
38- if (isA10 )
39- findAndHookMethod (clazz , "isXiaoAiEnable" , XC_MethodReplacement .returnConstant (false ));
40- // findAndHookMethod(clazz, "isImeSupport", Context.class, setsIsImeSupport(clazz));
41- // else
42- // findAndHookMethod(clazz, "isCanLoadPlugin", Context.class, setsIsImeSupport(clazz));
43-
44- findAndHookMethod ("com.android.internal.policy.PhoneWindow" , lpparam .classLoader , "setNavigationBarColor" , int .class , new XC_MethodHook () {
45- @ Override
46- protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
47- // 0xFF141414,0xFFA1A1A1,0x66A1A1A1
48- // 0xFFE7E8EB,0x66000000,0x80000000
49- callStaticMethod (clazz , "customizeBottomViewColor" , true , param .args [0 ], 0xff747474 , 0x66747474 );
50- }
51- });
52- }
32+ final boolean isNonCustomize = !miuiImeList .contains (lpparam .packageName );
33+ if (isNonCustomize ) {
34+ XposedBridge .log ("Hook ServiceInjector: " + lpparam .packageName );
35+ Class <?> clazz = findClass ("android.inputmethodservice.InputMethodServiceInjector" , lpparam .classLoader );
36+ hookSIsImeSupport (clazz );
5337 if (isA10 ) {
54- findAndHookMethod ( "android.inputmethodservice.InputMethodServiceInjector$MiuiSwitchInputMethodListener" , lpparam . classLoader , "deleteNotSupportIme" , XC_MethodReplacement . returnConstant ( null ) );
38+ hookIsXiaoAiEnable ( clazz );
5539 } else {
56- InputMethodManager mImm = (InputMethodManager ) getObjectField (param .thisObject , "mImm" );
57- findAndHookMethod ("android.inputmethodservice.InputMethodModuleManager" , lpparam .classLoader , "loadDex" , ClassLoader .class , String .class , new XC_MethodHook () {
40+ findAndHookMethod ("com.android.internal.policy.PhoneWindow" , lpparam .classLoader , "setNavigationBarColor" , int .class , new XC_MethodHook () {
5841 @ Override
5942 protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
60- XposedBridge .log ("Hook MiuiBottomView: " + lpparam .packageName );
61- final Class <?> clazz = findClass ("com.miui.inputmethod.InputMethodBottomManager" , (ClassLoader ) param .args [0 ]);
62- if (isNonCustomize ) {
63- setsIsImeSupport (clazz );
64- findAndHookMethod (clazz , "isXiaoAiEnable" , XC_MethodReplacement .returnConstant (false ));
65- // findAndHookMethod(clazz, "checkMiuiBottomSupport", setsIsImeSupport(clazz));
66- }
67- if (mImm != null ) {
68- XposedBridge .log ("Hook getSupportIme Method: " + lpparam .packageName );
69- findAndHookMethod (clazz , "getSupportIme" , XC_MethodReplacement .returnConstant (mImm .getEnabledInputMethodList ()));
70- }
43+ // 0xff747474, 0x66747474
44+ int color = 0xFFFFFFFF - (int ) param .args [0 ];
45+ XposedHelpers .callStaticMethod (clazz , "customizeBottomViewColor" , true , param .args [0 ], color | 0xFF000000 , color | 0x66000000 );
7146 }
7247 });
7348 }
7449 }
50+ if (isA10 ) {
51+ findAndHookMethod ("android.inputmethodservice.InputMethodServiceInjector$MiuiSwitchInputMethodListener" , lpparam .classLoader , "deleteNotSupportIme" , XC_MethodReplacement .returnConstant (null ));
52+ } else {
53+ InputMethodManager mImm = (InputMethodManager ) getObjectField (param .thisObject , "mImm" );
54+ findAndHookMethod ("android.inputmethodservice.InputMethodModuleManager" , lpparam .classLoader , "loadDex" , ClassLoader .class , String .class , new XC_MethodHook () {
55+ @ Override
56+ protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
57+ XposedBridge .log ("Hook MiuiBottomView: " + lpparam .packageName );
58+ final Class <?> clazz = findClass ("com.miui.inputmethod.InputMethodBottomManager" , (ClassLoader ) param .args [0 ]);
59+ if (isNonCustomize ) {
60+ hookSIsImeSupport (clazz );
61+ hookIsXiaoAiEnable (clazz );
62+ }
63+ if (mImm != null ) {
64+ XposedBridge .log ("Hook getSupportIme Method: " + lpparam .packageName );
65+ findAndHookMethod (clazz , "getSupportIme" , XC_MethodReplacement .returnConstant (mImm .getEnabledInputMethodList ()));
66+ }
67+ }
68+ });
69+ }
70+
7571 }
7672 });
7773 }
7874
79- private void setsIsImeSupport (Class <?> clazz ) {
75+ private void hookSIsImeSupport (Class <?> clazz ) {
8076 XposedHelpers .setStaticIntField (clazz , "sIsImeSupport" , 1 );
8177 }
8278
79+ private void hookIsXiaoAiEnable (Class <?> clazz ) {
80+ findAndHookMethod (clazz , "isXiaoAiEnable" , XC_MethodReplacement .returnConstant (false ));
81+ }
82+
8383 public void checkVersion () {
8484 switch (Build .VERSION .SDK_INT ) {
8585 case 30 :
8686 isA10 = false ;
8787 isA11 = true ;
8888 break ;
8989 case 29 :
90+ case 28 :
9091 isA10 = true ;
9192 isA11 = false ;
9293 break ;
0 commit comments