Skip to content

Commit

Permalink
try to fix: Clipboard list crash
Browse files Browse the repository at this point in the history
我他妈就不明白了 一个字不落的复制过来怎么轮到我运行就crash
  • Loading branch information
Sevtinge committed Dec 21, 2024
1 parent a150263 commit f9bf39e
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
import com.hchen.database.HookBase;
import com.sevtinge.hyperceiler.module.base.BaseModule;
import com.sevtinge.hyperceiler.module.hook.various.CollapseMiuiTitle;
import com.sevtinge.hyperceiler.module.hook.various.DialogCustom;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.LoadInputMethodDex;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.NewClipboardList;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.NewUnPhraseLimit;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.NewUnlockIme;
import com.sevtinge.hyperceiler.module.hook.various.dialog.DialogCustom;
import com.sevtinge.hyperceiler.module.hook.various.MiuiAppNoOverScroll;

import org.luckypray.dexkit.DexKitBridge;

import java.util.Arrays;
import java.util.HashSet;

Expand All @@ -38,6 +44,15 @@ public void handleLoadPackage() {
mPackageName = mLoadPackageParam.packageName;
isMiuiApps = mPackageName.startsWith("com.miui") || mPackageName.startsWith("com.xiaomi") || miuiDialogCustomApps.contains(mPackageName);

if (mPrefsMap.getBoolean("various_phrase_clipboardlist")) {
if (mPackageName.equals("com.miui.phrase")) {
System.loadLibrary("dexkit");
DexKitBridge dexKitBridge = DexKitBridge.create(mLoadPackageParam.appInfo.sourceDir);
new NewUnPhraseLimit(dexKitBridge).onLoadPackage();
dexKitBridge.close();
return;
}
}
initHook(new MiuiAppNoOverScroll(), isMiuiOverScrollApps());
initHook(new DialogCustom(), isMiuiDialogCustom());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import com.sevtinge.hyperceiler.module.base.tool.OtherTool;
import com.sevtinge.hyperceiler.module.hook.clipboard.BaiduClipboard;
import com.sevtinge.hyperceiler.module.hook.clipboard.SoGouClipboard;
import com.sevtinge.hyperceiler.module.hook.various.ClearClipboard;
import com.sevtinge.hyperceiler.module.hook.various.ClipboardList;
import com.sevtinge.hyperceiler.module.hook.various.LoadInputMethodDex;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.ClearClipboard;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.LoadInputMethodDex;
import com.sevtinge.hyperceiler.module.hook.various.MusicHooks;
import com.sevtinge.hyperceiler.module.hook.various.NewClipboardList;
import com.sevtinge.hyperceiler.module.hook.various.NewUnPhraseLimit;
import com.sevtinge.hyperceiler.module.hook.various.UnlockIme;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.NewClipboardList;
import com.sevtinge.hyperceiler.module.hook.various.clipboard.UnlockIme;
import com.sevtinge.hyperceiler.utils.log.XposedLogUtils;

import org.luckypray.dexkit.DexKitBridge;
Expand All @@ -54,19 +52,12 @@ public void handleLoadPackage() {
}
mPackageName = mLoadPackageParam.packageName;
if (mPrefsMap.getBoolean("various_phrase_clipboardlist")) {
if (mPackageName.equals("com.miui.phrase")) {
System.loadLibrary("dexkit");
DexKitBridge dexKitBridge = DexKitBridge.create(mLoadPackageParam.appInfo.sourceDir);
new NewUnPhraseLimit(dexKitBridge).onLoadPackage();
dexKitBridge.close();
return;
}
if (isInputMethod(mPackageName)) {
initHook(new UnlockIme(), mPrefsMap.getBoolean("various_unlock_ime"));
initHook(new UnlockIme());
new LoadInputMethodDex(new NewClipboardList()).onLoadPackage();
}
}
initHook(new UnlockIme(), mPrefsMap.getBoolean("various_unlock_ime") && isInputMethod(mPackageName));
initHook(new UnlockIme(), mPrefsMap.getBoolean("various_unlock_ime") && isInputMethod(mPackageName) && !mPrefsMap.getBoolean("various_phrase_clipboardlist"));
initHook(new SoGouClipboard(), mPrefsMap.getBoolean("sogou_xiaomi_clipboard") &&
("com.sohu.inputmethod.sogou.xiaomi".equals(mPackageName) || "com.sohu.inputmethod.sogou".equals(mPackageName)));
initHook(new BaiduClipboard(), mPrefsMap.getBoolean("sogou_xiaomi_clipboard") &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/
package com.sevtinge.hyperceiler.module.hook.various
package com.sevtinge.hyperceiler.module.hook.various.clipboard

import android.graphics.drawable.*
import android.view.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
/*
* This file is part of HyperCeiler.
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/
package com.sevtinge.hyperceiler.module.hook.various;
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/
package com.sevtinge.hyperceiler.module.hook.various.clipboard;

import static com.hchen.hooktool.tool.CoreTool.getStaticField;
import static com.sevtinge.hyperceiler.utils.Helpers.getPackageVersionCode;

import static de.robv.android.xposed.XposedHelpers.getObjectField;

import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;

import com.sevtinge.hyperceiler.module.base.BaseHook;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.various;
package com.sevtinge.hyperceiler.module.hook.various.clipboard;

import com.hchen.hooktool.BaseHC;
import com.hchen.hooktool.hook.IHook;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.various;
package com.sevtinge.hyperceiler.module.hook.various.clipboard;

import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logD;
import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logE;
Expand All @@ -36,18 +36,11 @@
import com.hchen.hooktool.BaseHC;
import com.hchen.hooktool.hook.IHook;
import com.hchen.hooktool.tool.ParamTool;
import com.hchen.hooktool.tool.CoreTool;
import com.sevtinge.hyperceiler.utils.ContentModel;
import com.sevtinge.hyperceiler.utils.FileHelper;

import java.util.ArrayList;
import java.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
* 解除常用语剪贴板时间限制,条数限制和字数限制。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.various;
package com.sevtinge.hyperceiler.module.hook.various.clipboard;

import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logE;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.various.clipboard;

import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logE;

import android.content.Context;

import com.sevtinge.hyperceiler.module.hook.various.clipboard.LoadInputMethodDex;
import com.hchen.hooktool.BaseHC;
import com.hchen.hooktool.hook.IHook;
import com.hchen.hooktool.tool.additional.SystemPropTool;

import java.util.Arrays;
import java.util.List;

public class NewUnlockIme extends BaseHC implements LoadInputMethodDex.OnInputMethodDexLoad {
private boolean shouldHook = false;

private static final String[] miuiImeList = new String[]{
"com.iflytek.inputmethod.miui",
"com.sohu.inputmethod.sogou.xiaomi",
"com.baidu.input_mi",
"com.miui.catcherpatch"
};

private int navBarColor = 0;

@Override
public void load(ClassLoader classLoader) {
fakeSupportImeList(classLoader);
notDeleteNotSupportIme("com.miui.inputmethod.InputMethodBottomManager$MiuiSwitchInputMethodListener", classLoader);
if (!shouldHook) return;
Class<?> InputMethodBottomManager = findClass("com.miui.inputmethod.InputMethodBottomManager", classLoader).get();
if (InputMethodBottomManager != null) {
fakeIsSupportIme(InputMethodBottomManager);
fakeIsXiaoAiEnable(InputMethodBottomManager);
} else {
logE(TAG, "Class not found: com.miui.inputmethod.InputMethodBottomManager");
}
}

@Override
public void init() {
if (SystemPropTool.getProp("ro.miui.support_miui_ime_bottom", "0").equals("1")) {
startHook();
}
}

private void startHook() {
// 检查是否为小米定制输入法
if (Arrays.stream(miuiImeList).anyMatch(s -> s.equals(lpparam.packageName))) return;
shouldHook = true;
Class<?> sInputMethodServiceInjector = findClass("android.inputmethodservice.InputMethodServiceInjector").get();
if (sInputMethodServiceInjector == null)
sInputMethodServiceInjector = findClass("android.inputmethodservice.InputMethodServiceStubImpl").get();
if (sInputMethodServiceInjector != null) {
fakeIsSupportIme(sInputMethodServiceInjector);
fakeIsXiaoAiEnable(sInputMethodServiceInjector);
setPhraseBgColor(sInputMethodServiceInjector);
} else {
logE(TAG, "Class not found: InputMethodServiceInjector");
}

notDeleteNotSupportIme("android.inputmethodservice.InputMethodServiceInjector$MiuiSwitchInputMethodListener", classLoader);
}

/**
* 跳过包名检查,直接开启输入法优化
*/
private void fakeIsSupportIme(Class<?> clazz) {
setStaticField(clazz, "sIsImeSupport", 1);
hookMethod(clazz, "isImeSupport", Context.class, returnResult(true));
}

/**
* 小爱语音输入按钮失效修复
*/
private void fakeIsXiaoAiEnable(Class<?> clazz) {
hookMethod(clazz, "isXiaoAiEnable", returnResult(false));
}

/**
* 在适当的时机修改抬高区域背景颜色
*/
private void setPhraseBgColor(Class<?> clazz) {
hookMethod("com.android.internal.policy.PhoneWindow",
"setNavigationBarColor", int.class,
new IHook() {
@Override
public void after() {
if ((int) getArgs(0) == 0) return;
navBarColor = (int) getArgs(0);
customizeBottomViewColor(clazz);
}
}
);

hookAllMethod(clazz, "addMiuiBottomView",
new IHook() {
@Override
public void after() {
customizeBottomViewColor(clazz);
}
}
);
}

/**
* 将导航栏颜色赋值给输入法优化的底图
*/
private void customizeBottomViewColor(Class<?> clazz) {
if (navBarColor != 0) {
int color = -0x1 - navBarColor;
callStaticMethod(clazz, "customizeBottomViewColor", true, navBarColor, color | -0x1000000, color | 0x66000000);
}
}

/**
* 针对A10的修复切换输入法列表
*/
private void notDeleteNotSupportIme(String className, ClassLoader classLoader) {
hookMethod(className, classLoader, "deleteNotSupportIme", doNothing());
}

/**
* 使切换输入法界面显示第三方输入法
*/
private void fakeSupportImeList(ClassLoader classLoader) {
hookMethod("com.miui.inputmethod.InputMethodBottomManager", classLoader, "getSupportIme",
new IHook() {
@Override
public void before() {
List<?> mEnabledInputMethodList = (List<?>) callMethod(getField(getStaticField(
"com.miui.inputmethod.InputMethodBottomManager", classLoader,
"sBottomViewHelper"), "mImm"), "getEnabledInputMethodList");
setResult(mEnabledInputMethodList);
}
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/
package com.sevtinge.hyperceiler.module.hook.various;
package com.sevtinge.hyperceiler.module.hook.various.clipboard;

import static com.sevtinge.hyperceiler.module.base.tool.OtherTool.getProp;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* This file is part of HyperCeiler.
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/
package com.sevtinge.hyperceiler.module.hook.various;
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/
package com.sevtinge.hyperceiler.module.hook.various.dialog;

import android.os.Build;
import android.view.View;
Expand Down
Loading

0 comments on commit f9bf39e

Please sign in to comment.