11package com .xposed .miuiime ;
22
3+ import android .os .Build ;
34import android .view .inputmethod .InputMethodManager ;
45
56import java .util .Arrays ;
1920
2021public class MainHook implements IXposedHookLoadPackage {
2122 final static List <String > miuiImeList = Arrays .asList ("com.iflytek.inputmethod.miui" , "com.sohu.inputmethod.sogou.xiaomi" , "com.baidu.input_mi" , "com.miui.catcherpatch" );
22- boolean isMIUI12 ;
23- boolean isMIUI125 ;
23+ boolean isA10 ;
24+ boolean isA11 ;
2425
2526 @ Override
2627 public void handleLoadPackage (final XC_LoadPackage .LoadPackageParam lpparam ) {
2728 findAndHookMethod ("android.inputmethodservice.InputMethodService" , lpparam .classLoader , "initViews" , new XC_MethodHook () {
2829 @ Override
2930 protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
30- isMIUI ();
31- if (isMIUI12 || isMIUI125 ) {
32- final boolean isNonCustom = !miuiImeList .contains (lpparam .packageName );
33- if (isNonCustom ) {
31+ checkVersion ();
32+ if (isA10 || isA11 ) {
33+ final boolean isNonCustomize = !miuiImeList .contains (lpparam .packageName );
34+ if (isNonCustomize ) {
3435 XposedBridge .log ("Hook ServiceInjector: " + lpparam .packageName );
3536 Class <?> clazz = findClass ("android.inputmethodservice.InputMethodServiceInjector" , lpparam .classLoader );
3637 setsIsImeSupport (clazz );
37- if (isMIUI12 )
38+ if (isA10 )
3839 findAndHookMethod (clazz , "isXiaoAiEnable" , XC_MethodReplacement .returnConstant (false ));
3940// findAndHookMethod(clazz, "isImeSupport", Context.class, setsIsImeSupport(clazz));
4041// else
@@ -49,7 +50,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
4950 }
5051 });
5152 }
52- if (isMIUI12 ) {
53+ if (isA10 ) {
5354 findAndHookMethod ("android.inputmethodservice.InputMethodServiceInjector$MiuiSwitchInputMethodListener" , lpparam .classLoader , "deleteNotSupportIme" , XC_MethodReplacement .returnConstant (null ));
5455 } else {
5556 InputMethodManager mImm = (InputMethodManager ) getObjectField (param .thisObject , "mImm" );
@@ -58,7 +59,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
5859 protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
5960 XposedBridge .log ("Hook MiuiBottomView: " + lpparam .packageName );
6061 final Class <?> clazz = findClass ("com.miui.inputmethod.InputMethodBottomManager" , (ClassLoader ) param .args [0 ]);
61- if (isNonCustom ) {
62+ if (isNonCustomize ) {
6263 setsIsImeSupport (clazz );
6364 findAndHookMethod (clazz , "isXiaoAiEnable" , XC_MethodReplacement .returnConstant (false ));
6465// findAndHookMethod(clazz, "checkMiuiBottomSupport", setsIsImeSupport(clazz));
@@ -79,19 +80,19 @@ private void setsIsImeSupport(Class<?> clazz) {
7980 XposedHelpers .setStaticIntField (clazz , "sIsImeSupport" , 1 );
8081 }
8182
82- public void isMIUI () {
83- switch (PropertyUtils . get ( "ro.miui.ui.version.name" , "" ) ) {
84- case "V125" :
85- isMIUI12 = false ;
86- isMIUI125 = true ;
83+ public void checkVersion () {
84+ switch (Build . VERSION . SDK_INT ) {
85+ case 30 :
86+ isA10 = false ;
87+ isA11 = true ;
8788 break ;
88- case "V12" :
89- isMIUI12 = true ;
90- isMIUI125 = false ;
89+ case 29 :
90+ isA10 = true ;
91+ isA11 = false ;
9192 break ;
9293 default :
93- isMIUI12 = false ;
94- isMIUI125 = false ;
94+ isA10 = false ;
95+ isA11 = false ;
9596 }
9697 }
9798}
0 commit comments