Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
fix: SelectClipboard compatibility before 12.56
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Apr 3, 2024
1 parent f670d10 commit 3e435a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public String key() {
public List<? extends Matcher> matchers() {
return List.of(
new SmaliMatcher("Landroid/text/ClipboardManager;->setText(Ljava/lang/CharSequence;)V",
MatcherProperties.create().useClassMatcher(ClassMatcherUtils.className("com.baidu.tieba.tbadkCore.data.PostData")))
MatcherProperties.create().useClassMatcher(ClassMatcherUtils.invokeMethod("Lcom/baidu/tieba/tbadkCore/data/ThemeBubbleData;-><init>(Ltbclient/ThemeBubble;)V")))
);
}

public void hook() throws Throwable {
AcRules.findRule(matchers(), (matcher, clazz, method) -> {
switch (matcher) {
case "PostData/Landroid/text/ClipboardManager;->setText(Ljava/lang/CharSequence;)V":
case "Lcom/baidu/tieba/tbadkCore/data/ThemeBubbleData;-><init>(Ltbclient/ThemeBubble;)V/Landroid/text/ClipboardManager;->setText(Ljava/lang/CharSequence;)V":
XposedHelpers.findAndHookMethod(clazz, sClassLoader, method, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/gm/tieba/tabswitch/util/ClassMatcherUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gm.tieba.tabswitch.util;

import org.luckypray.dexkit.query.matchers.ClassMatcher;
import org.luckypray.dexkit.query.matchers.MethodMatcher;
import org.luckypray.dexkit.query.matchers.MethodsMatcher;

public class ClassMatcherUtils {
private final ClassMatcher matcher;
Expand All @@ -26,6 +28,14 @@ public static ClassMatcherUtils className(String className) {
return new ClassMatcherUtils(classMatcher, simpleClassName);
}

public static ClassMatcherUtils invokeMethod(String smali) {
MethodMatcher invokeMatcher = MethodMatcher.create().addInvoke(
MethodMatcher.create().descriptor(smali)
);
ClassMatcher classMatcher = ClassMatcher.create().methods(MethodsMatcher.create().add(invokeMatcher));
return new ClassMatcherUtils(classMatcher, smali);
}

public ClassMatcher getMatcher() {
return this.matcher;
}
Expand Down

0 comments on commit 3e435a9

Please sign in to comment.