Skip to content

Commit

Permalink
1.06
Browse files Browse the repository at this point in the history
Signed-off-by: RC1844 <1844766234@qq.com>
  • Loading branch information
RC1844 committed Mar 28, 2021
1 parent 99981b0 commit b965ebc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Xposed API Version >= 93

## 更新日志

v1.06

更换检查MIUI版本为检查Android版本
删除旧方法依赖的代码

v1.05

感谢 @ketal178 帮忙删除无用的代码
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.xposed.miuiime"
minSdkVersion 28
targetSdkVersion 30
versionCode 5
versionName '1.05'
versionCode 6
versionName '1.06'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
39 changes: 20 additions & 19 deletions app/src/main/java/com/xposed/miuiime/MainHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xposed.miuiime;

import android.os.Build;
import android.view.inputmethod.InputMethodManager;

import java.util.Arrays;
Expand All @@ -19,22 +20,22 @@

public class MainHook implements IXposedHookLoadPackage {
final static List<String> miuiImeList = Arrays.asList("com.iflytek.inputmethod.miui", "com.sohu.inputmethod.sogou.xiaomi", "com.baidu.input_mi", "com.miui.catcherpatch");
boolean isMIUI12;
boolean isMIUI125;
boolean isA10;
boolean isA11;

@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) {
findAndHookMethod("android.inputmethodservice.InputMethodService", lpparam.classLoader, "initViews", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
isMIUI();
if (isMIUI12 || isMIUI125) {
final boolean isNonCustom = !miuiImeList.contains(lpparam.packageName);
if (isNonCustom) {
checkVersion();
if (isA10 || isA11) {
final boolean isNonCustomize = !miuiImeList.contains(lpparam.packageName);
if (isNonCustomize) {
XposedBridge.log("Hook ServiceInjector: " + lpparam.packageName);
Class<?> clazz = findClass("android.inputmethodservice.InputMethodServiceInjector", lpparam.classLoader);
setsIsImeSupport(clazz);
if (isMIUI12)
if (isA10)
findAndHookMethod(clazz, "isXiaoAiEnable", XC_MethodReplacement.returnConstant(false));
// findAndHookMethod(clazz, "isImeSupport", Context.class, setsIsImeSupport(clazz));
// else
Expand All @@ -49,7 +50,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});
}
if (isMIUI12) {
if (isA10) {
findAndHookMethod("android.inputmethodservice.InputMethodServiceInjector$MiuiSwitchInputMethodListener", lpparam.classLoader, "deleteNotSupportIme", XC_MethodReplacement.returnConstant(null));
} else {
InputMethodManager mImm = (InputMethodManager) getObjectField(param.thisObject, "mImm");
Expand All @@ -58,7 +59,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("Hook MiuiBottomView: " + lpparam.packageName);
final Class<?> clazz = findClass("com.miui.inputmethod.InputMethodBottomManager", (ClassLoader) param.args[0]);
if (isNonCustom) {
if (isNonCustomize) {
setsIsImeSupport(clazz);
findAndHookMethod(clazz, "isXiaoAiEnable", XC_MethodReplacement.returnConstant(false));
// findAndHookMethod(clazz, "checkMiuiBottomSupport", setsIsImeSupport(clazz));
Expand All @@ -79,19 +80,19 @@ private void setsIsImeSupport(Class<?> clazz) {
XposedHelpers.setStaticIntField(clazz, "sIsImeSupport", 1);
}

public void isMIUI() {
switch (PropertyUtils.get("ro.miui.ui.version.name", "")) {
case "V125":
isMIUI12 = false;
isMIUI125 = true;
public void checkVersion() {
switch (Build.VERSION.SDK_INT) {
case 30:
isA10 = false;
isA11 = true;
break;
case "V12":
isMIUI12 = true;
isMIUI125 = false;
case 29:
isA10 = true;
isA11 = false;
break;
default:
isMIUI12 = false;
isMIUI125 = false;
isA10 = false;
isA11 = false;
}
}
}

0 comments on commit b965ebc

Please sign in to comment.