Xposed 拦截系统通知栏消息

public class NotificationHook {
    private static final String TAG = "NotificationHook";

    public static void hook(XC_LoadPackage.LoadPackageParam lpparam) {
        Log.e(TAG, "NotificationHook start");
        try {
            final Class clazz = XposedHelpers.findClass("android.app.NotificationManager", lpparam.classLoader);
            XposedHelpers.findAndHookMethod(clazz, "notify", String.class, int.class, Notification.class, new XC_MethodHook() {
                @RequiresApi(api = Build.VERSION_CODES.KITKAT)
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    Log.e(TAG, "MethodHookParam:" + param.toString());
                    Object[] args = param.args;
                    Notification notification = (Notification) param.args[2];
                    Log.e(TAG, "notification:" + notification.toString());
                    CharSequence tickerText = notification.tickerText;
                    Log.e(TAG, "notification.tickerText:" + tickerText);
                    //获得包名 wx的contentView ==null
//                    String aPackage = notification.contentView.getPackage();
//                    Log.e(TAG,"notification.contentView.getPackage:"+aPackage);
                    Bundle extras = notification.extras;
                    String title = (String) extras.get("android.title");
                    String text = (String) extras.get("android.text");
                    Log.e(TAG, "notification.extras:title=" + title + " text:" + text);
                    param.setResult(null);
                    super.beforeHookedMethod(param);
                }

                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
                }
            });
        } catch (Throwable e) {
            Log.e(TAG, "hook: ", e);
        }
        Log.e(TAG, "NotificationHook end");
    }
}

在这里插入图片描述
如图:接收到对应的消息,但是不会有通知栏提示。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用Xposed拦截OkHttp的URL请求,您需要编写一个Xposed模块。以下是一些大致步骤: 1. 创建一个Xposed模块项目 2. 在AndroidManifest.xml文件中声明您的模块作为Xposed模块 3. 在您的模块主类中,使用Xposed框架的“findAndHookMethod”方法来Hook OkHttp的“newCall”方法,并获取Request请求对象 4. 在获取请求对象后,您可以使用OkHttp的“url”方法获取请求的URL 5. 您可以在此处进行您的拦截逻辑,并阻止/修改请求,或者您可以将请求传递给原始的“newCall”方法 以下是一个简单的示例代码,演示如何使用Xposed拦截OkHttp的URL请求: ```java public class MyModule implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { // Only hook into the package containing OkHttp if (lpparam.packageName.equals("com.squareup.okhttp")) { XposedHelpers.findAndHookMethod("com.squareup.okhttp.OkHttpClient", lpparam.classLoader, "newCall", Request.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // Get the request object Request request = (Request) param.args[0]; // Get the URL from the request object String url = request.url().toString(); // Do your interception logic here // ... // Call the original method super.beforeHookedMethod(param); } }); } } } ``` 请注意,这只是一个简单的示例代码,并且您需要根据您的需求进行自定义。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值