diff --git a/app/build.gradle b/app/build.gradle index 5affa32..8946cd6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,6 +61,6 @@ monitorPlugin { "com.peakmain.asmactualcombat.utils.TestUtils", "com.peakmain.plugin" ] - methodStatus = 3 + methodStatus = 2 disableStackMapFrame = false } diff --git a/app/src/main/java/com/peakmain/asmactualcombat/utils/Utils.java b/app/src/main/java/com/peakmain/asmactualcombat/utils/Utils.java index d300107..00b36c3 100644 --- a/app/src/main/java/com/peakmain/asmactualcombat/utils/Utils.java +++ b/app/src/main/java/com/peakmain/asmactualcombat/utils/Utils.java @@ -1,12 +1,16 @@ package com.peakmain.asmactualcombat.utils; import android.content.Context; +import android.net.ConnectivityManager; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.util.Log; + +import com.peakmain.ui.utils.LogUtils; import java.util.Locale; @@ -17,6 +21,14 @@ * describe: */ public class Utils { + Context mContext; + WifiManager mWifiManager; + + public Utils(Context context, WifiManager wifiManager) { + this.mContext = context; + this.mWifiManager = wifiManager; + } + public static String getDeviceId(Context context) { String tac = ""; TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); @@ -61,6 +73,53 @@ public static String getMacDefault(Context context) { return mac; } + public final WifiInfo getConnectionInfo() { + try { + try { + return mWifiManager.getConnectionInfo(); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (Throwable var1) { + } + + return null; + } + + public final WifiInfo getConnectionInfo1() { + try { + try { + if (mWifiManager.getConnectionInfo() != null) { + LogUtils.e("not null"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } catch (Throwable var1) { + } + + return null; + } + + public final boolean a(ConnectivityManager var1) { + WifiManager var2; + if ((var2 = this.mWifiManager) == null) { + return false; + } else { + boolean var3 = false; + + try { + if (var2.getConnectionInfo()!=null) { + var3 = true; + } + } catch (Throwable var4) { + } + + return var3; + } + } + + public static String getAndroidId(Context context) { return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } diff --git a/plugin/src/main/groovy/com/peakmain/analytics/plugin/ext/MonitorConfig.groovy b/plugin/src/main/groovy/com/peakmain/analytics/plugin/ext/MonitorConfig.groovy index 71447d9..34fd5f7 100644 --- a/plugin/src/main/groovy/com/peakmain/analytics/plugin/ext/MonitorConfig.groovy +++ b/plugin/src/main/groovy/com/peakmain/analytics/plugin/ext/MonitorConfig.groovy @@ -22,9 +22,8 @@ class MonitorConfig { public ArrayList whiteList = [] /** * 隐私方法方法的状态 - * @params 1 代表清空方法体 - * @params 2 代表替换方法体 - * @params 其他都代表 正常情况 + * @params 0 代表正常 + * @params 其他都代表 替换 */ public int methodStatus = 0 private MethodFieldUtils.StatusEnum statusEnum = MethodFieldUtils.StatusEnum.METHOD_STATE_NORMAL @@ -34,7 +33,7 @@ class MonitorConfig { 'android.support.v4.app.NotificationManagerCompat'] HashSet exceptSet = new HashSet<>() /** - * 是否禁用开启堆栈分析,默认是禁用com.atour.atourlife + * 是否禁用开启堆栈分析,默认是禁用 */ public boolean disableStackMapFrame = true public String interceptPackageName = "com/atour" @@ -47,10 +46,8 @@ class MonitorConfig { for (int i = 0; i < whiteList.size(); i++) { whiteList.set(i, whiteList.get(i).replace(".", "/")) } - println(methodStatus) - if (methodStatus == MethodFieldUtils.StatusEnum.METHOD_STATE_CLEAR.value) { - statusEnum = MethodFieldUtils.StatusEnum.METHOD_STATE_CLEAR - } else if (methodStatus == MethodFieldUtils.StatusEnum.METHOD_STATE_REPLACE.value) { + println("当前方法的Status:" + methodStatus) + if (methodStatus == MethodFieldUtils.StatusEnum.METHOD_STATE_REPLACE.value) { statusEnum = MethodFieldUtils.StatusEnum.METHOD_STATE_REPLACE } else { statusEnum = MethodFieldUtils.StatusEnum.METHOD_STATE_NORMAL diff --git a/plugin/src/main/groovy/com/peakmain/analytics/plugin/utils/MethodFieldUtils.groovy b/plugin/src/main/groovy/com/peakmain/analytics/plugin/utils/MethodFieldUtils.groovy index 923416c..6ddeb1c 100644 --- a/plugin/src/main/groovy/com/peakmain/analytics/plugin/utils/MethodFieldUtils.groovy +++ b/plugin/src/main/groovy/com/peakmain/analytics/plugin/utils/MethodFieldUtils.groovy @@ -5,9 +5,8 @@ import org.objectweb.asm.Opcodes class MethodFieldUtils { public static final String PLUGIN_VERSION = "1.0.8" enum StatusEnum { - METHOD_STATE_NORMAL(1), - METHOD_STATE_CLEAR(2), - METHOD_STATE_REPLACE(3) + METHOD_STATE_NORMAL(0), + METHOD_STATE_REPLACE(1) private int value StatusEnum(int value) { diff --git a/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledClearAdapter.groovy b/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledClearAdapter.groovy index 1efde9b..45c0f1b 100644 --- a/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledClearAdapter.groovy +++ b/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledClearAdapter.groovy @@ -20,6 +20,7 @@ class MonitorMethodCalledClearAdapter extends MonitorDefalutMethodAdapter { private int mAccess private MonitorConfig monitorConfig + private String mDesc /** * Constructs a new {@link MonitorMethodCalledClearAdapter}. * @@ -32,6 +33,7 @@ class MonitorMethodCalledClearAdapter extends MonitorDefalutMethodAdapter { super(mv, access, name, desc) mClassName = className mAccess = access + mDesc = desc this.monitorConfig = monitorConfig } @@ -39,16 +41,18 @@ class MonitorMethodCalledClearAdapter extends MonitorDefalutMethodAdapter { void visitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface) { HashMap methodCalledBeans = MonitorHookMethodConfig.methodCalledBeans if (!monitorConfig.whiteList.contains(mClassName) && !monitorConfig.exceptSet.contains(mClassName) && methodCalledBeans.containsKey(owner + name + descriptor)) { - //println("调用方法的class:" + mClassName + ",方法的名字:" + name + ",方法的描述符:" + descriptor) - clearMethodBody(mv, mClassName, access, name, descriptor) + println("调用方法的class:" + mClassName + ",方法的名字:" + name + ",方法的描述符:" + descriptor) + clearMethodBody(mv, mClassName, access, name, descriptor,mDesc) return } super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface); } - static void clearMethodBody(MethodVisitor mv, String className, int access, String name, String descriptor) { + static void clearMethodBody(MethodVisitor mv, String className, int access, String name, String descriptor,String methodDescriptor) { Type type = Type.getType(descriptor) + Type methodType = Type.getType(methodDescriptor) + Type methodReturnType = methodType.getReturnType() Type[] argumentsType = type.getArgumentTypes() Type returnType = type.getReturnType() int stackSize = returnType.getSize() @@ -57,12 +61,12 @@ class MonitorMethodCalledClearAdapter extends MonitorDefalutMethodAdapter { localSize += argType.size } mv.visitCode() - if (returnType.getSort() == Type.VOID) { + if (methodReturnType.getSort() == Type.VOID) { mv.visitInsn(RETURN) - } else if (returnType.getSort() >= Type.BOOLEAN && returnType.getSort() <= Type.DOUBLE) { - mv.visitInsn(returnType.getOpcode(ICONST_1)) - mv.visitInsn(returnType.getOpcode(IRETURN)) - } else if (returnType.getInternalName() == "java/lang/String") { + } else if (methodReturnType.getSort() >= Type.BOOLEAN && methodReturnType.getSort() <= Type.DOUBLE) { + mv.visitInsn(methodReturnType.getOpcode(ICONST_1)) + mv.visitInsn(methodReturnType.getOpcode(IRETURN)) + } else if (methodReturnType.getInternalName() == "java/lang/String") { mv.visitLdcInsn("") mv.visitInsn(ARETURN) } else { diff --git a/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledReplaceAdapter.groovy b/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledReplaceAdapter.groovy index 5850d9b..76e328c 100644 --- a/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledReplaceAdapter.groovy +++ b/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/MonitorMethodCalledReplaceAdapter.groovy @@ -40,6 +40,7 @@ class MonitorMethodCalledReplaceAdapter extends MonitorDefalutMethodAdapter { HashMap methodReplaceBeans = MonitorHookMethodConfig.methodCalledBeans String desc = owner + name + descriptor if (!monitorConfig.whiteList.contains(mClassName) && !monitorConfig.exceptSet.contains(mClassName)&&methodReplaceBeans.containsKey(desc)) { + println("调用方法的class:" + mClassName + ",方法的名字:" + name + ",方法的描述符:" + descriptor) MethodCalledBean bean = methodReplaceBeans.get(desc) super.visitMethodInsn(bean.newOpcode, bean.newMethodOwner, bean.newMethodName, bean.newMethodDescriptor.get(descriptor), false) } else { diff --git a/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/PeakmainVisitor.groovy b/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/PeakmainVisitor.groovy index ddb9726..dac70d6 100644 --- a/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/PeakmainVisitor.groovy +++ b/plugin/src/main/groovy/com/peakmain/analytics/plugin/visitor/PeakmainVisitor.groovy @@ -56,9 +56,7 @@ class PeakmainVisitor extends ClassVisitor { MethodVisitor methodVisitor = super.visitMethod(access, name, descriptor, signature, exceptions) methodVisitor = new MonitorClickAdapter(methodVisitor, access, name, descriptor, mMethodCells, mInterfaces,mMonitorConfig,mClassName) methodVisitor = new MonitorPrintParametersReturnValueAdapter(methodVisitor, access, name, descriptor, mClassName, classVisitor) - if (mMonitorConfig.getStatusEnum() == MethodFieldUtils.StatusEnum.METHOD_STATE_CLEAR) - methodVisitor = new MonitorMethodCalledClearAdapter(methodVisitor, access, name, descriptor, mClassName, mMonitorConfig) - else if (mMonitorConfig.getStatusEnum() == MethodFieldUtils.StatusEnum.METHOD_STATE_REPLACE) { + if (mMonitorConfig.getStatusEnum() != MethodFieldUtils.StatusEnum.METHOD_STATE_NORMAL) { methodVisitor = new MonitorMethodCalledReplaceAdapter(methodVisitor, access, name, descriptor, classVisitor,mClassName,mMonitorConfig) } if (!mMonitorConfig.disableStackMapFrame) diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar index a4aafdf..4e59c74 100644 Binary files a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar and b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar differ diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.md5 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.md5 index 36254a8..91cb09c 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.md5 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.md5 @@ -1 +1 @@ -260e793fe7290d33b63458d18ae4579b \ No newline at end of file +aa3d302743bf0d0125e80c7933e12ef3 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.sha1 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.sha1 index ee18d5e..404ce47 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.sha1 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-groovydoc.jar.sha1 @@ -1 +1 @@ -0469062f62f7e4723a55c41c4596e43917503709 \ No newline at end of file +bb33bdf0292444a4f68911b2e81aeb6b166710b2 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar index 101bb30..ba3038a 100644 Binary files a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar and b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar differ diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.md5 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.md5 index 70e98a9..1cb84a0 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.md5 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.md5 @@ -1 +1 @@ -5397cdde9ede71935afdb78c2267d978 \ No newline at end of file +9ffd4220993e477a9fc630bfebc781c9 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.sha1 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.sha1 index 54686f3..9256381 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.sha1 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-javadoc.jar.sha1 @@ -1 +1 @@ -3ad27a8dc00f94cc5b40ecc1385edca4d01386f9 \ No newline at end of file +1477c6e37ceff13ffd3ac10822e53cc1ac6337b6 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar index da9a734..f661ecb 100644 Binary files a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar and b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar differ diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.md5 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.md5 index 11aed7c..12e200f 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.md5 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.md5 @@ -1 +1 @@ -f3ccb3f78f2beae7638dc4ad78f1dc6b \ No newline at end of file +cac97c3ae5be0ec78f886f3cb968286a \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.sha1 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.sha1 index 225cfba..e9bd0f3 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.sha1 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0-sources.jar.sha1 @@ -1 +1 @@ -fd5854720b2060019f78227b803b69a29c92e748 \ No newline at end of file +eef649de0f4810ba60c657dba1d8595e63a03ccd \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar index 169bfc2..7b5f6b0 100644 Binary files a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar and b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar differ diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.md5 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.md5 index 4c42c16..3708d59 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.md5 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.md5 @@ -1 +1 @@ -8ba7250e2778fc021b4da67909cea5e3 \ No newline at end of file +71c760bab10c33f06b2a44b960682d88 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.sha1 b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.sha1 index 78f2463..5828291 100644 --- a/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.sha1 +++ b/repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar.sha1 @@ -1 +1 @@ -7d4af61b767637024eb5446b4158daeb979dfbac \ No newline at end of file +d67a3ab5517114e573367604d41fcb8bbaec0c81 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/maven-metadata.xml b/repo/com/peakmain/android.plugin/maven-metadata.xml index 30224cb..c4d4074 100644 --- a/repo/com/peakmain/android.plugin/maven-metadata.xml +++ b/repo/com/peakmain/android.plugin/maven-metadata.xml @@ -7,6 +7,6 @@ 1.0.0 - 20220518024611 + 20220518064857 diff --git a/repo/com/peakmain/android.plugin/maven-metadata.xml.md5 b/repo/com/peakmain/android.plugin/maven-metadata.xml.md5 index f0cd524..4094688 100644 --- a/repo/com/peakmain/android.plugin/maven-metadata.xml.md5 +++ b/repo/com/peakmain/android.plugin/maven-metadata.xml.md5 @@ -1 +1 @@ -0dbc7d90b85a4b7207ce3d98438054dd \ No newline at end of file +fa781a6335847929e9b713610faab9d7 \ No newline at end of file diff --git a/repo/com/peakmain/android.plugin/maven-metadata.xml.sha1 b/repo/com/peakmain/android.plugin/maven-metadata.xml.sha1 index fc2f03a..d9f5bce 100644 --- a/repo/com/peakmain/android.plugin/maven-metadata.xml.sha1 +++ b/repo/com/peakmain/android.plugin/maven-metadata.xml.sha1 @@ -1 +1 @@ -e93efc87ab92469dc8c44e401bb3a87322b80650 \ No newline at end of file +a18657fdc1e3e97eb0e5a22a5e2ce0348ca52083 \ No newline at end of file