Commit 437a6678 authored by steve's avatar steve

完成-适配 android 11 储存空间

parent 204240a5
...@@ -2,8 +2,10 @@ package com.go.hookNotify ...@@ -2,8 +2,10 @@ package com.go.hookNotify
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.go.hookNotify.databinding.ActivityMainBinding import com.go.hookNotify.databinding.ActivityMainBinding
import com.go.hookNotify.units.HookTestUnit
class MainActivity : AppCompatActivity(), View.OnClickListener { class MainActivity : AppCompatActivity(), View.OnClickListener {
...@@ -18,11 +20,12 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { ...@@ -18,11 +20,12 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
override fun onClick(view: View?) { override fun onClick(view: View?) {
when (view) { when (view) {
mBinding.btnChange -> { mBinding.btnChange -> {
mBinding.tvTitle.text = "OK2"
if (HookTestUnit.toMessage())
Toast.makeText(this, getString(R.string.share_hook_suc), Toast.LENGTH_SHORT).show()
else
Toast.makeText(this, getString(R.string.share_hook_failure), Toast.LENGTH_SHORT).show()
mBinding.tvTitle.text = "OK"
} }
} }
} }
......
package com.go.hookNotify.units
import java.text.SimpleDateFormat
import java.util.*
object DateUnit {
fun getNowTime(sTimeFormat: String = "yyyy-MM-dd HH-mm-ss"): String {
val sdf = SimpleDateFormat(sTimeFormat, Locale.getDefault())
val calendar = Calendar.getInstance()
val data = calendar.time
return sdf.format(data)
}
}
\ No newline at end of file
...@@ -4,7 +4,6 @@ import com.go.hookNotify.units.XPoseDebugUnit ...@@ -4,7 +4,6 @@ import com.go.hookNotify.units.XPoseDebugUnit
import com.go.hookNotify.xp.code.HookGlobalNotify import com.go.hookNotify.xp.code.HookGlobalNotify
import com.go.hookNotify.xp.code.HookSimBoxNotify import com.go.hookNotify.xp.code.HookSimBoxNotify
import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XposedBridge
import de.robv.android.xposed.callbacks.XC_LoadPackage import de.robv.android.xposed.callbacks.XC_LoadPackage
class Hook : IXposedHookLoadPackage { class Hook : IXposedHookLoadPackage {
...@@ -17,7 +16,7 @@ class Hook : IXposedHookLoadPackage { ...@@ -17,7 +16,7 @@ class Hook : IXposedHookLoadPackage {
xPosedHook(packageName, lpparam) xPosedHook(packageName, lpparam)
} }
private fun androidSystemHook(loadPackageParam: XC_LoadPackage.LoadPackageParam?){ private fun androidSystemHook(loadPackageParam: XC_LoadPackage.LoadPackageParam?) {
XPoseDebugUnit.xPoseLogDebug("android system start") XPoseDebugUnit.xPoseLogDebug("android system start")
HookGlobalNotify().handleLoadPackage(loadPackageParam) HookGlobalNotify().handleLoadPackage(loadPackageParam)
} }
......
...@@ -5,13 +5,18 @@ import android.app.Notification; ...@@ -5,13 +5,18 @@ import android.app.Notification;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import com.go.hookNotify.units.DateUnit;
import com.go.hookNotify.units.LogSaveUnit; import com.go.hookNotify.units.LogSaveUnit;
import com.go.hookNotify.units.XPoseDebugUnit; import com.go.hookNotify.units.XPoseDebugUnit;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage; import de.robv.android.xposed.callbacks.XC_LoadPackage;
...@@ -48,9 +53,10 @@ public class HookGlobalNotify implements IXposedHookLoadPackage { ...@@ -48,9 +53,10 @@ public class HookGlobalNotify implements IXposedHookLoadPackage {
Notification notification = (Notification) param.args[2]; Notification notification = (Notification) param.args[2];
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("\n").append("==============================================================================").append("\n");
sb.append(DateUnit.INSTANCE.getNowTime("yyyy-MM-dd HH-mm-ss"));
sb.append("\n").append("object notification: ").append(notification.toString()).append("\n"); sb.append("\n").append("object notification: ").append(notification.toString()).append("\n");
sb.append("object bundle:").append("\n"); sb.append("object bundle:").append("\n");
Bundle bundle = notification.extras; Bundle bundle = notification.extras;
if (bundle != null) { if (bundle != null) {
Set<String> keys = bundle.keySet(); Set<String> keys = bundle.keySet();
...@@ -63,8 +69,11 @@ public class HookGlobalNotify implements IXposedHookLoadPackage { ...@@ -63,8 +69,11 @@ public class HookGlobalNotify implements IXposedHookLoadPackage {
String title = notification.extras.getString("android.title", "no Title"); String title = notification.extras.getString("android.title", "no Title");
// String content = notification.extras.getString("android.text", ""); // String content = notification.extras.getString("android.text", "");
String documentName = "log/" + title; String documentPath = "logGlobal/" + title;
// LogSaveUnit.INSTANCE.saveLogFile(documentName, sb.toString()); String fileName = "GlobalLog_" + DateUnit.INSTANCE.getNowTime("yyyy-MM-dd HH-mm-ss")+".txt";
LogSaveUnit.INSTANCE.saveLogFile(mContext, documentPath, fileName, sb.toString());
} }
}); });
} }
......
package com.go.hookNotify.xp.code; package com.go.hookNotify.xp.code;
import android.app.AndroidAppHelper; import android.app.AndroidAppHelper;
import android.app.Notification;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context;
import android.os.Bundle;
import com.go.hookNotify.units.DateUnit;
import com.go.hookNotify.units.LogSaveUnit; import com.go.hookNotify.units.LogSaveUnit;
import com.go.hookNotify.units.XPoseDebugUnit; import com.go.hookNotify.units.XPoseDebugUnit;
import com.go.hookNotify.xp.Constants; import com.go.hookNotify.xp.Constants;
import java.util.Map; import java.util.Map;
import java.util.Set;
import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodHook;
...@@ -34,10 +39,11 @@ public class HookSimBoxNotify implements IXposedHookLoadPackage { ...@@ -34,10 +39,11 @@ public class HookSimBoxNotify implements IXposedHookLoadPackage {
private final String mCountryCode = "countryCode"; private final String mCountryCode = "countryCode";
private final String mNormalizedNumber = "normalizedNumber"; private final String mNormalizedNumber = "normalizedNumber";
private Context mContext = null;
@Override @Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (!lpparam.processName.equals(Constants.SIMBOX_NAME)) return; if (!lpparam.processName.equals(Constants.SIMBOX_NAME)) return;
XPoseDebugUnit.xPoseLogInfo("simBox start init!!"); XPoseDebugUnit.xPoseLogInfo("simBox start init!!");
...@@ -46,6 +52,9 @@ public class HookSimBoxNotify implements IXposedHookLoadPackage { ...@@ -46,6 +52,9 @@ public class HookSimBoxNotify implements IXposedHookLoadPackage {
ContentValues.class, String.class, Map.class, String.class, boolean.class, boolean.class, boolean.class, new XC_MethodHook() { ContentValues.class, String.class, Map.class, String.class, boolean.class, boolean.class, boolean.class, new XC_MethodHook() {
@Override @Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
mContext = AndroidAppHelper.currentApplication();
XPoseDebugUnit.xPoseLogInfo("Success Hook Method"); XPoseDebugUnit.xPoseLogInfo("Success Hook Method");
ContentValues contentValues = (ContentValues) param.args[0]; ContentValues contentValues = (ContentValues) param.args[0];
...@@ -79,12 +88,13 @@ public class HookSimBoxNotify implements IXposedHookLoadPackage { ...@@ -79,12 +88,13 @@ public class HookSimBoxNotify implements IXposedHookLoadPackage {
mExt + ": " + ext + "\n" + mExt + ": " + ext + "\n" +
mCountryCode + ": " + countryCode + "\n" + mCountryCode + ": " + countryCode + "\n" +
mNormalizedNumber + ": " + normalizedNumber + "\n"; mNormalizedNumber + ": " + normalizedNumber + "\n";
XPoseDebugUnit.xPoseLogInfo(sMsg); XPoseDebugUnit.xPoseLogInfo(sMsg);
String documentName = "log2/" + number + "-" + imsi;
LogSaveUnit.INSTANCE.saveLogFile(documentName, sMsg); //存在手机的外部空间
super.beforeHookedMethod(param);
String documentPath = "logSimbox/" + number + "-" + imsi;
String fileName = "SimBoxLog_" + DateUnit.INSTANCE.getNowTime("yyyy-MM-dd HH-mm-ss") + ".txt";
LogSaveUnit.INSTANCE.saveLogFile(mContext, documentPath, fileName, sMsg); //存在手机外部空间
super.beforeHookedMethod(param);
} }
}); });
} }
......
<resources> <resources>
<string name="app_name">HookNotify</string> <string name="app_name">HookNotify</string>
<!--share-->
<string name="share_hook_test">Hook 測試</string>
<string name="share_hook_suc">Hook 成功</string>
<string name="share_hook_failure">Hook 失敗</string>
</resources> </resources>
\ No newline at end of file
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