Commit e5396cd1 authored by steve's avatar steve

新增取得 context 方式

parent 07480384
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -34,7 +34,6 @@ object LogSaveUnit { ...@@ -34,7 +34,6 @@ object LogSaveUnit {
} }
/** /**
* android 版本 0..28(小於29) * android 版本 0..28(小於29)
* 檢查文件是否存在 * 檢查文件是否存在
......
package com.go.hookNotify.xp.code; package com.go.hookNotify.xp.code;
import android.app.AndroidAppHelper;
import android.app.Notification; import android.app.Notification;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import com.go.hookNotify.units.LogSaveUnit; import com.go.hookNotify.units.LogSaveUnit;
...@@ -16,24 +18,33 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage; ...@@ -16,24 +18,33 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class HookGlobalNotify implements IXposedHookLoadPackage { public class HookGlobalNotify implements IXposedHookLoadPackage {
private final String[] mAryStrBlackList = new String[]{"com.ucloudlink.simbox"}; private final String[] mAryStrBlackList = new String[]{"com.ucloudlink.simbox"};
private Context mContext = null;
@Override @Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
final Class clazz = XposedHelpers.findClass("android.app.NotificationManager", lpparam.classLoader); final Class clazz = XposedHelpers.findClass("android.app.NotificationManager", lpparam.classLoader);
XPoseDebugUnit.xPoseLogInfo("android hook NotificationManager start init!!" + clazz.getName()); XPoseDebugUnit.xPoseLogInfo("android hook NotificationManager start init!!" + clazz.getName());
XposedHelpers.findAndHookMethod(clazz, "notify", String.class, int.class, Notification.class, new XC_MethodHook() { XposedHelpers.findAndHookMethod(clazz, "notify", String.class, int.class, Notification.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
mContext = AndroidAppHelper.currentApplication();
XPoseDebugUnit.xPoseLogInfo(mContext.toString());
super.beforeHookedMethod(param);
}
@Override @Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable { protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param); super.afterHookedMethod(param);
if (lpparam == null) return; if (lpparam == null) return;
if (checkBlackList(lpparam.packageName)) { if (checkBlackList(lpparam.packageName)) {
XPoseDebugUnit.xPoseLogInfo("黑名单: " + lpparam.packageName); XPoseDebugUnit.xPoseLogInfo("黑名单: " + lpparam.packageName);
return; return;
} }
XPoseDebugUnit.xPoseLogInfo("非黑名单: " + lpparam.packageName); XPoseDebugUnit.xPoseLogInfo("非黑名单: " + lpparam.packageName);
Notification notification = (Notification) param.args[2]; Notification notification = (Notification) param.args[2];
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -53,7 +64,7 @@ public class HookGlobalNotify implements IXposedHookLoadPackage { ...@@ -53,7 +64,7 @@ public class HookGlobalNotify implements IXposedHookLoadPackage {
// String content = notification.extras.getString("android.text", ""); // String content = notification.extras.getString("android.text", "");
String documentName = "log/" + title; String documentName = "log/" + title;
LogSaveUnit.INSTANCE.saveLogFile(documentName, sb.toString()); // LogSaveUnit.INSTANCE.saveLogFile(documentName, sb.toString());
} }
}); });
} }
......
package com.go.hookNotify.xp.code; package com.go.hookNotify.xp.code;
import android.app.AndroidAppHelper;
import android.content.ContentValues; import android.content.ContentValues;
import com.go.hookNotify.units.LogSaveUnit; import com.go.hookNotify.units.LogSaveUnit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment