Commit f62e8d62 by YKai

feat: 埋点工具重新封装

parent 871e8507
...@@ -21,6 +21,7 @@ import android.util.Log; ...@@ -21,6 +21,7 @@ import android.util.Log;
import com.tbruyelle.rxpermissions2.RxPermissions; import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.ydlcommon.BuildConfig; import com.ydl.ydlcommon.BuildConfig;
import com.ydl.ydlcommon.base.BaseApp;
import com.yidianling.common.tools.RxTool; import com.yidianling.common.tools.RxTool;
import java.io.BufferedReader; import java.io.BufferedReader;
...@@ -119,28 +120,20 @@ public class DeviceTool { ...@@ -119,28 +120,20 @@ public class DeviceTool {
* *
* @return * @return
*/ */
@SuppressLint("MissingPermission") @SuppressLint({"MissingPermission", "HardwareIds"})
public static final String getIMEI() { public static String getIMEI() {
Activity topTaskActivity = ActivityManager.Companion.getInstance().getTopTaskActivity();
if (!checkHasAgreeSecret()) {
return "";
}
try { try {
String imei = ""; String imei;
RxPermissions rxPermissions = new RxPermissions(topTaskActivity); //实例化TelephonyManager对象
TelephonyManager telephonyManager = (TelephonyManager) BaseApp.instance.getSystemService(Context.TELEPHONY_SERVICE);
if (rxPermissions.isGranted(Manifest.permission.READ_PHONE_STATE)) { if (null == telephonyManager) {
//实例化TelephonyManager对象 return "";
TelephonyManager telephonyManager = (TelephonyManager) topTaskActivity.getSystemService(Context.TELEPHONY_SERVICE); }
if (null == telephonyManager) { //获取IMEI号
return ""; imei = telephonyManager.getDeviceId();
}
//获取IMEI号
imei = telephonyManager.getDeviceId();
if (imei == null) { if (imei == null) {
return ""; return "";
}
} }
return RxTool.Md5(imei); return RxTool.Md5(imei);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -7,11 +7,11 @@ import android.net.NetworkInfo ...@@ -7,11 +7,11 @@ import android.net.NetworkInfo
import android.net.wifi.WifiManager import android.net.wifi.WifiManager
import android.os.Build import android.os.Build
import com.umeng.commonsdk.UMConfigure import com.umeng.commonsdk.UMConfigure
import com.ydl.devicesidlib.Utils
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.api.ApiRequestUtil import com.ydl.ydlcommon.data.http.api.ApiRequestUtil
import com.ydl.ydlcommon.data.http.params.ActionDataBean import com.ydl.ydlcommon.data.http.params.ActionDataBean
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.DeviceTool
import com.yidianling.common.tools.LogUtil import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxDeviceTool import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxTool import com.yidianling.common.tools.RxTool
...@@ -110,7 +110,7 @@ class ActionCountUtils { ...@@ -110,7 +110,7 @@ class ActionCountUtils {
actionDataParams.appVersion(RxDeviceTool.getAppVersionName(BaseApp.getApp())) actionDataParams.appVersion(RxDeviceTool.getAppVersionName(BaseApp.getApp()))
val deviceId = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { val deviceId = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
//获取imei //获取imei
Utils.getIMEI(BaseApp.instance) DeviceTool.getIMEI()
} else { } else {
//android Q及以上取oaid //android Q及以上取oaid
oaId oaId
......
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