Skip to content

Commit

Permalink
wifi方法替换问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Peakmain committed Apr 15, 2022
1 parent 48b62f1 commit afc954a
Show file tree
Hide file tree
Showing 25 changed files with 231 additions and 43 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ monitorPlugin {
"io.github.peakmain",
"com.peakmain.plugin"
]
methodStatus = 1
methodStatus = 2
disableStackMapFrame = false
}
84 changes: 83 additions & 1 deletion app/src/main/java/com/peakmain/asmactualcombat/App.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
package com.peakmain.asmactualcombat;

import android.app.Application;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
import android.util.Log;

import androidx.multidex.MultiDex;

import com.peakmain.sdk.BuildConfig;
import com.peakmain.sdk.SensorsDataAPI;
import com.peakmain.sdk.constants.SensorsDataConstants;
import com.peakmain.sdk.interfaces.OnReplaceMethodListener;
import com.peakmain.sdk.interfaces.OnUploadSensorsDataListener;
import com.peakmain.sdk.utils.SensorsDataUtils;
import com.peakmain.ui.utils.LogUtils;

import java.util.ArrayList;
import java.util.List;

import cn.jpush.android.api.JPushInterface;

Expand Down Expand Up @@ -39,7 +51,7 @@ public void onCreate() {
case SensorsDataConstants.APP_END__EVENT_STATE:
case SensorsDataConstants.APP_VIEW_SCREEN__EVENT_STATE:
if (BuildConfig.DEBUG) {
Log.e("TAG", "埋点\n"+data);
Log.e("TAG", "埋点\n" + data);
}
break;
default:
Expand All @@ -49,5 +61,75 @@ public void onCreate() {
break;
}
});
SensorsDataAPI.getInstance().setOnReplaceMethodListener(new OnReplaceMethodListener() {
@Override
public String onReplaceMethodListener(int telephoneState, TelephonyManager manager, int slotIndex) {
switch (telephoneState) {
case SensorsDataConstants.GET_DEVICE_ID:
LogUtils.e("替换GET_DEVICE_ID");
break;
case SensorsDataConstants.GET_MEID:
LogUtils.e("替换GET_MEID");
break;
case SensorsDataConstants.GET_IMEI:
LogUtils.e("替换GET_IMEI");
break;
case SensorsDataConstants.GET_SUBSCRIBER_ID:
LogUtils.e("替换GET_SUBSCRIBER_ID");
break;
case SensorsDataConstants.GET_SIM_SERIAL_NUMBER:
LogUtils.e("替换GET_SIM_SERIAL_NUMBER");
break;
default:
break;
}
return "";
}

@Override
public String onReplaceMethodListener(int wifiInfoState, WifiInfo wifiInfo) {
switch (wifiInfoState) {
case SensorsDataConstants.GET_MAC_ADDRESS:
LogUtils.e("替换GET_MAC_ADDRESS");
break;
case SensorsDataConstants.GET_SSID:
LogUtils.e("替换GET_SSID");
break;
case SensorsDataConstants.GET_BSSID:
LogUtils.e("替换GET_SSIDGET_BSSID");
break;
case SensorsDataConstants.GET_IP_ADDRESS:
LogUtils.e("替换GET_IP_ADDRESS");
break;
default:
break;
}
return "";
}

@Override
public WifiInfo onReplaceMethodListener(WifiManager wifiManager) {
LogUtils.e("替换WifiManager");
return null;
}

@Override
public String onReplaceMethodListener(SubscriptionInfo subscriptionInfo) {
LogUtils.e("替换SubscriptionInfo");
return "";
}

@Override
public List<PackageInfo> onReplaceMethodListener(PackageManager manager) {
LogUtils.e("替换PackageManager");
return new ArrayList<>();
}

@Override
public String onReplaceMethodListener(ContentResolver resolver, String name) {
LogUtils.e("替换ContentResolver");
return "onReplaceMethodListener";
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.peakmain.basiclibrary.base.activity.BaseActivity
import com.peakmain.asmactualcombat.viewmodel.ClickDealViewModel
import com.peakmain.asmactualcombat.R
import com.peakmain.asmactualcombat.databinding.ActivityMainBinding
import com.peakmain.asmactualcombat.utils.Utils
import com.peakmain.ui.utils.ToastUtils

/**
Expand All @@ -23,7 +24,7 @@ class MainActivity(override val layoutId: Int = R.layout.activity_main) :
}
mBinding.buttonClick1.setOnClickListener {
//startActivity(Intent(this,TestActivity::class.java))
ToastUtils.showLong(c.a(this))
ToastUtils.showLong(Utils.getAndroidId(this))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ public static String getMacDefault(Context context) {
} catch (Exception e) {
e.printStackTrace();
}
/*
if (info == null) return mac;
mac = info.getMacAddress();
if (!TextUtils.isEmpty(mac)) mac = mac.toUpperCase(Locale.ENGLISH);
*/

return mac;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MethodFieldUtils {
static final String NEW_INT_STRING_TELEPHONY_DESC = "(Landroid/telephony/TelephonyManager;I)Ljava/lang/String;"
static String[] EMPTY_INT_RETURN_STRING_DESC = [EMPTY_STRING_DESC, INT_STRING_DESC]
static final String EMPTY_WIFI_INFO_DESC = "()Landroid/net/wifi/WifiInfo;"
static final String EMPTY_WIFI_INFO_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiInfo;)Landroid/net/wifi/WifiInfo;"
static final String EMPTY_WIFI_INFO_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiManager;)Landroid/net/wifi/WifiInfo;"
static String[] EMPTY_RETURN_WIFI_INFO_DESC = [EMPTY_WIFI_INFO_DESC]
static String[] EMPTY_RETURN_STRING_DESC = [EMPTY_STRING_DESC]
static final String EMPTY_INT_DESC = "()I"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3038f0d6e477fea4c3ff4a81ba35a5d4
d698d7e4b72b92112d283f811ca87b4e
Original file line number Diff line number Diff line change
@@ -1 +1 @@
093a48b4e6f3adaa9570d6f811035b97d5f2e373
87364866a4727d0e9200901dcd3add5041daf0fb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d868b08a79e10222df4e2c05678cb590
d1f1c942b7e263b48c96d424045dcb63
Original file line number Diff line number Diff line change
@@ -1 +1 @@
960127ae393bf7a095e32e515ce9af7c5b04e9ef
25b79bf18e7af3fefbd3892545926b707e42dfde
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43f3dd92d16e447e8276b887c9057ef8
19ae7dbab81341432435553d11bcdc82
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ad21229a92926b8bc876e5696c4e188b1f8b750d
dc66163d0fe6a06c1ad752b227a31d7ba441b29a
Binary file modified repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b0226d3b450fa38a92d018d037382516
63b103f70d8001e23b09194c2b2630db
Original file line number Diff line number Diff line change
@@ -1 +1 @@
95f555e2954256301f89be7aab3b466fa5baac9a
fe8a73e051f16c6e49834983ffe0d200dac76ce4
2 changes: 1 addition & 1 deletion repo/com/peakmain/android.plugin/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<versions>
<version>1.0.0</version>
</versions>
<lastUpdated>20220415034510</lastUpdated>
<lastUpdated>20220415083614</lastUpdated>
</versioning>
</metadata>
2 changes: 1 addition & 1 deletion repo/com/peakmain/android.plugin/maven-metadata.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed81f61304e3a466b0478d2d3a1f8a4e
b30a21806cdcda5228800c596c52e633
2 changes: 1 addition & 1 deletion repo/com/peakmain/android.plugin/maven-metadata.xml.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
30dcff78dbd83b3badd1df95afe0f8c1e1bf3008
975cdf0fbc888a767b9e0175318d1cfe2cfacbc3
10 changes: 10 additions & 0 deletions sdk/src/main/java/com/peakmain/sdk/SensorsDataAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import androidx.annotation.Nullable;

import com.peakmain.sdk.constants.SensorsDataConstants;
import com.peakmain.sdk.interfaces.OnReplaceMethodListener;
import com.peakmain.sdk.interfaces.OnUploadSensorsDataListener;
import com.peakmain.sdk.manager.SensorsDataManager;
import com.peakmain.sdk.manager.SensorsDatabaseHelper;
import com.peakmain.sdk.utils.ReplaceMethodUtils;
import com.peakmain.sdk.utils.SensorsDataUtils;

import org.json.JSONObject;
Expand Down Expand Up @@ -54,6 +56,14 @@ public interface OnUserAgreementListener {
boolean onUserAgreement();
}

/**
* 设置方法替换接口
* @param onReplaceMethodListener onReplaceMethodListener
*/
public void setOnReplaceMethodListener(OnReplaceMethodListener onReplaceMethodListener) {
ReplaceMethodUtils.getInstance().setOnReplaceMethodListener(onReplaceMethodListener);
}

public void setOnUserAgreementListener(@Nullable OnUserAgreementListener l) {
getListenerInfo().mOnUserAgreement = l;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ public class SensorsDataConstants {
public static final int GET_SIM_SERIAL_NUMBER = 5;
public static final int GET_MAC_ADDRESS = 6;
public static final int GET_SSID = 7;
public static final int GET_CONNECTION_INFO = 8;
public static final int GET_BSSID = 9;
public static final int GET_BSSID = 8;
public static final int GET_IP_ADDRESS = 9;

@IntDef({GET_DEVICE_ID,GET_MEID,GET_IMEI,GET_SUBSCRIBER_ID,GET_SIM_SERIAL_NUMBER})
@Retention(RetentionPolicy.SOURCE)
public @interface TELEPHONY_STATE{}

@IntDef({GET_MAC_ADDRESS,GET_SSID,GET_BSSID,GET_IP_ADDRESS})
@Retention(RetentionPolicy.SOURCE)
public @interface WIFI_STATE{}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
package com.peakmain.sdk.interfaces;

import android.content.ContentResolver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;

import com.peakmain.sdk.constants.SensorsDataConstants;

import java.util.List;

/**
* author :Peakmain
* createTime:2022/4/15
* mail:2726449200@qq.com
* describe:替换方法监听事件
*/
public interface OnReplaceMethodListener {
String onReplaceMethodListener(TelephonyManager manager);
String onReplaceMethodListener(@SensorsDataConstants.TELEPHONY_STATE int telephoneState, TelephonyManager manager, int slotIndex);

String onReplaceMethodListener(@SensorsDataConstants.WIFI_STATE int wifiInfoState, WifiInfo wifiInfo);

WifiInfo onReplaceMethodListener(WifiManager wifiManager);

String onReplaceMethodListener(SubscriptionInfo subscriptionInfo);

String onReplaceMethodListener(TelephonyManager manager, int slotIndex);
List<PackageInfo> onReplaceMethodListener(PackageManager manager);

String getString(ContentResolver resolver, String name);
String onReplaceMethodListener(ContentResolver resolver, String name);

}
Loading

0 comments on commit afc954a

Please sign in to comment.