Skip to content

Commit 2fa58ed

Browse files
committed
1.07
Signed-off-by: RC1844 <1844766234@qq.com>
1 parent b965ebc commit 2fa58ed

File tree

4 files changed

+82
-41
lines changed

4 files changed

+82
-41
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ Xposed API Version >= 93
2323
## 特别说明
2424

2525
1. 全面屏优化与百度输入法官方版存在兼容问题,这不属于本模块 BUG。
26-
2. 因为本人在用的是 MIUI12.5,所以对于 MIUI12 适配并不完整,存在不可用的可能性。
26+
2. 因为本人在用的是 MIUI12.5、Android11,所以对于其他版本的 MIUI 适配并不完整,存在不可用的可能性。
2727
3. ~~托盘按钮设置为小爱语音输入时,按钮失效不可用,目前未发现原因,但通过长按选择启动小爱似乎没有问题。~~
2828
4. 不接受任何为特定输入法适配 xxx 的请求,这不现实不合理。
29+
5. 使用了小白条沉浸模块的系统,可能在部分输入法上无法使用全面屏优化(郑重声明:这事关我屁事)
2930

3031
## 更新日志
3132

33+
v1.07
34+
35+
增加检查prop ro.miui.support_miui_ime_bottom
36+
底部按钮改为反色按钮
37+
尝试在安卓9使用与安卓10相同的hook方法
38+
3239
v1.06
3340

3441
更换检查MIUI版本为检查Android版本

app/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "com.xposed.miuiime"
1111
minSdkVersion 28
1212
targetSdkVersion 30
13-
versionCode 6
14-
versionName '1.06'
13+
versionCode 7
14+
versionName '1.07'
1515

1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717
}
@@ -26,6 +26,11 @@ android {
2626
sourceCompatibility JavaVersion.VERSION_1_8
2727
targetCompatibility JavaVersion.VERSION_1_8
2828
}
29+
applicationVariants.all { variant ->
30+
variant.outputs.all {
31+
outputFileName = "Unlock_MIUI_IME-${variant.versionName}_${variant.buildType.name}.apk"
32+
}
33+
}
2934
}
3035

3136
dependencies {

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

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import de.robv.android.xposed.XposedHelpers;
1414
import de.robv.android.xposed.callbacks.XC_LoadPackage;
1515

16-
import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
1716
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
1817
import static de.robv.android.xposed.XposedHelpers.findClass;
1918
import 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;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.xposed.miuiime;
2+
3+
import android.annotation.SuppressLint;
4+
5+
import java.lang.reflect.Method;
6+
7+
public class PropertyUtils {
8+
9+
private static volatile Method get = null;
10+
11+
public static String get(String prop, String defaultvalue) {
12+
String value = defaultvalue;
13+
try {
14+
if (null == get) {
15+
synchronized (PropertyUtils.class) {
16+
if (null == get) {
17+
@SuppressLint("PrivateApi") Class<?> cls = Class.forName("android.os.SystemProperties");
18+
get = cls.getDeclaredMethod("get", String.class, String.class);
19+
}
20+
}
21+
}
22+
value = (String) (get.invoke(null, new Object[]{prop, defaultvalue}));
23+
} catch (Throwable e) {
24+
e.printStackTrace();
25+
}
26+
return value;
27+
}
28+
}

0 commit comments

Comments
 (0)