Skip to content

Commit 3a9a280

Browse files
committed
Update MainHook
1 parent 4ebf6cf commit 3a9a280

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

app/src/main/java/com/xposed/miuiime/MainHook.kt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ class MainHook : IXposedHookLoadPackage {
3838
}
3939
}
4040
//针对A10的修复切换输入法列表
41-
findAndHookMethod(
42-
"android.inputmethodservice.InputMethodServiceInjector\$MiuiSwitchInputMethodListener",
43-
lpparam.classLoader, "deleteNotSupportIme",
44-
XC_MethodReplacement.returnConstant(null)
45-
)
41+
findClass("android.inputmethodservice.InputMethodServiceInjector\$MiuiSwitchInputMethodListener",
42+
lpparam.classLoader)?.let {
43+
hookDeleteNotSupportIme(it)
44+
}
4645

4746
//获取常用语的ClassLoader
4847
findAndHookMethod("android.inputmethodservice.InputMethodModuleManager",
@@ -73,6 +72,12 @@ class MainHook : IXposedHookLoadPackage {
7372
}
7473
})
7574
}
75+
findClass(
76+
"com.miui.inputmethod.InputMethodBottomManager\$MiuiSwitchInputMethodListener",
77+
param.args[0] as ClassLoader
78+
)?.let {
79+
hookDeleteNotSupportIme(it)
80+
}
7681
}
7782
})
7883
XposedBridge.log("Hook MIUI IME Success")
@@ -106,6 +111,18 @@ class MainHook : IXposedHookLoadPackage {
106111
)
107112
}
108113

114+
/**
115+
* 修复切换输入法列表
116+
*
117+
* @param clazz 声明或继承方法的类
118+
*/
119+
fun hookDeleteNotSupportIme(clazz: Class<*>) {
120+
findAndHookMethod(
121+
clazz, "deleteNotSupportIme",
122+
XC_MethodReplacement.returnConstant(null)
123+
)
124+
}
125+
109126
fun findAndHookMethod(
110127
clazz: Class<*>,
111128
methodName: String,

app/src/main/java/com/xposed/miuiime/PropertyUtils.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import java.lang.reflect.Method
77
object PropertyUtils {
88
private var get: Method? = null
99

10-
operator fun get(prop: String?, defaultvalue: String?): String? {
11-
var value = defaultvalue
10+
operator fun get(prop: String?, defaultValue: String?): String? {
11+
var value = defaultValue
1212
try {
1313
if (null == get) {
1414
synchronized(PropertyUtils::class.java) {
@@ -19,7 +19,7 @@ object PropertyUtils {
1919
}
2020
}
2121
}
22-
value = get!!.invoke(null, prop, defaultvalue) as String
22+
value = get!!.invoke(null, prop, defaultValue) as String
2323
} catch (e: Exception) {
2424
XposedBridge.log(e)
2525
}

0 commit comments

Comments
 (0)