Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Haocen2004 committed Jan 19, 2022
2 parents e7ef2dc + aecef09 commit 159378a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ android {
applicationId "xyz.hellocraft.portalhook"
minSdk 21
targetSdk 32
versionCode 4
versionCode 5
// versionCode Integer.parseInt(System.currentTimeMillis().toString()[7..12])
versionName "1.1.1"
versionName "1.1.2"
signingConfig signingConfigs.releaseSign
}

Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/xyz/hellocraft/portalhook/hook/PortalHook.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.hellocraft.portalhook.hook;

import android.content.Intent;
import android.content.Context;
import android.net.Uri;

import de.robv.android.xposed.XC_MethodReplacement;
Expand All @@ -26,5 +27,25 @@ protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return intent;
}
});

XposedHelpers.findAndHookMethod(clazz, "openGlobalSearch", Context.class, String.class, String.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("Hook到全局搜索打开,关键词:"+param.args[1].toString()+",来源:"+param.args[2].toString());
try {
String targetUrl = "https://www.baidu.com/s?word=" + param.args[1].toString();
// TODO: 自定义搜索引擎
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri uri = Uri.parse(targetUrl);
intent.setData(uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
((Context) param.args[0]).startActivity(intent);
} catch (Exception e) {
XposedBridge.log(e);
}
return null;
}
});
}
}

0 comments on commit 159378a

Please sign in to comment.