Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
dc2117e2
Commit
dc2117e2
authored
Jun 23, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 合规整改、新ffrom支持
parent
21405993
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
375 additions
and
582 deletions
+375
-582
config.gradle
config.gradle
+8
-8
NetworkUtil.java
m-im/src/main/java/com/yidianling/avchatkit/common/util/NetworkUtil.java
+6
-10
NimSDKOptionConfig.java
m-im/src/main/java/com/yidianling/im/config/NimSDKOptionConfig.java
+1
-1
WxPayParam.java
ydl-pay/src/main/java/com/yidianling/ydl_pay/common/bean/params/WxPayParam.java
+3
-2
RxDeviceTool.java
ydl-pay/src/main/java/com/yidianling/ydl_pay/common/http/utils/RxDeviceTool.java
+0
-150
WXRechargeIdParam.java
ydl-pay/src/main/java/com/yidianling/ydl_pay/pay/bean/WXRechargeIdParam.java
+3
-2
YdlRepository.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/app/YdlRepository.kt
+0
-2
YDLConstants.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/YDLConstants.kt
+3
-1
DeviceTool.java
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/DeviceTool.java
+284
-290
YdlBuryPointUtil.java
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/YdlBuryPointUtil.java
+10
-3
ActionCountUtils.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/actionutil/ActionCountUtils.kt
+57
-44
RxDeviceTool.java
ydl-utils/src/main/java/com/yidianling/common/tools/RxDeviceTool.java
+0
-69
No files found.
config.gradle
View file @
dc2117e2
...
@@ -10,7 +10,7 @@ ext {
...
@@ -10,7 +10,7 @@ ext {
"m-fm"
:
"0.0.30.09"
,
"m-fm"
:
"0.0.30.09"
,
"m-user"
:
"0.0.62.55"
,
"m-user"
:
"0.0.62.55"
,
"m-home"
:
"0.0.23.95"
,
"m-home"
:
"0.0.23.95"
,
"m-im"
:
"0.0.21.6
0
"
,
"m-im"
:
"0.0.21.6
1
"
,
"m-dynamic"
:
"0.0.7.74"
,
"m-dynamic"
:
"0.0.7.74"
,
"m-article"
:
"0.0.0.10"
,
"m-article"
:
"0.0.0.10"
,
"m-muse"
:
"0.0.28.81"
,
"m-muse"
:
"0.0.28.81"
,
...
@@ -23,12 +23,12 @@ ext {
...
@@ -23,12 +23,12 @@ ext {
//mdt 组件
//mdt 组件
"ydl-tuicore"
:
"0.0.25"
,
"ydl-tuicore"
:
"0.0.25"
,
//第一步
//第一步
"ydl-platform"
:
"0.0.41.4
1
"
,
"ydl-platform"
:
"0.0.41.4
4
"
,
//第二步 若干
//第二步 若干
"ydl-webview"
:
"0.0.38.94"
,
"ydl-webview"
:
"0.0.38.94"
,
"ydl-media"
:
"0.0.21.52"
,
"ydl-media"
:
"0.0.21.52"
,
"ydl-pay"
:
"0.0.18.
19
"
,
"ydl-pay"
:
"0.0.18.
21
"
,
"m-audioim"
:
"0.0.49.30.23"
,
"m-audioim"
:
"0.0.49.30.23"
,
"ydl-flutter-base"
:
"0.0.14.38"
,
"ydl-flutter-base"
:
"0.0.14.38"
,
...
@@ -36,7 +36,7 @@ ext {
...
@@ -36,7 +36,7 @@ ext {
//以下 几乎不会动
//以下 几乎不会动
"router"
:
"0.0.1"
,
"router"
:
"0.0.1"
,
"ydl-net"
:
"0.0.3.94"
,
"ydl-net"
:
"0.0.3.94"
,
"ydl-utils"
:
"0.0.3.
8
"
,
"ydl-utils"
:
"0.0.3.
12
"
,
//-------------- 业务模块 API 层 --------------
//-------------- 业务模块 API 层 --------------
...
@@ -96,7 +96,7 @@ ext {
...
@@ -96,7 +96,7 @@ ext {
"m-fm"
:
"0.0.30.09"
,
"m-fm"
:
"0.0.30.09"
,
"m-user"
:
"0.0.62.55"
,
"m-user"
:
"0.0.62.55"
,
"m-home"
:
"0.0.23.95"
,
"m-home"
:
"0.0.23.95"
,
"m-im"
:
"0.0.21.6
0
"
,
"m-im"
:
"0.0.21.6
1
"
,
"m-dynamic"
:
"0.0.7.74"
,
"m-dynamic"
:
"0.0.7.74"
,
"m-article"
:
"0.0.0.10"
,
"m-article"
:
"0.0.0.10"
,
...
@@ -110,19 +110,19 @@ ext {
...
@@ -110,19 +110,19 @@ ext {
//mdt 组件
//mdt 组件
"ydl-tuicore"
:
"0.0.25"
,
"ydl-tuicore"
:
"0.0.25"
,
//第一步
//第一步
"ydl-platform"
:
"0.0.41.4
1
"
,
"ydl-platform"
:
"0.0.41.4
4
"
,
//第二步 若干
//第二步 若干
"ydl-webview"
:
"0.0.38.94"
,
"ydl-webview"
:
"0.0.38.94"
,
"ydl-media"
:
"0.0.21.52"
,
"ydl-media"
:
"0.0.21.52"
,
"ydl-pay"
:
"0.0.18.
19
"
,
"ydl-pay"
:
"0.0.18.
21
"
,
"m-audioim"
:
"0.0.49.30.23"
,
"m-audioim"
:
"0.0.49.30.23"
,
"ydl-flutter-base"
:
"0.0.14.38"
,
"ydl-flutter-base"
:
"0.0.14.38"
,
//以下 几乎不会动
//以下 几乎不会动
"router"
:
"0.0.1"
,
"router"
:
"0.0.1"
,
"ydl-net"
:
"0.0.3.94"
,
"ydl-net"
:
"0.0.3.94"
,
"ydl-utils"
:
"0.0.3.
8
"
,
"ydl-utils"
:
"0.0.3.
12
"
,
//-------------- 业务模块 API 层 --------------
//-------------- 业务模块 API 层 --------------
"m-audioim-api"
:
"0.0.6"
,
"m-audioim-api"
:
"0.0.6"
,
...
...
m-im/src/main/java/com/yidianling/avchatkit/common/util/NetworkUtil.java
View file @
dc2117e2
...
@@ -544,17 +544,13 @@ public class NetworkUtil {
...
@@ -544,17 +544,13 @@ public class NetworkUtil {
*/
*/
public
static
String
getActiveMacAddress
(
Context
context
)
{
public
static
String
getActiveMacAddress
(
Context
context
)
{
if
(!
DeviceTool
.
checkHasAgreeSecret
())
{
if
(
DeviceTool
.
checkHasAgreeSecret
())
{
return
""
;
WifiManager
wifi
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
}
WifiInfo
info
=
wifi
.
getConnectionInfo
();
WifiManager
wifi
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
if
(
info
!=
null
)
{
return
info
.
getMacAddress
();
WifiInfo
info
=
wifi
.
getConnectionInfo
();
}
if
(
info
!=
null
)
{
return
info
.
getMacAddress
();
}
}
return
""
;
return
""
;
}
}
...
...
m-im/src/main/java/com/yidianling/im/config/NimSDKOptionConfig.java
View file @
dc2117e2
...
@@ -236,7 +236,7 @@ class NimSDKOptionConfig {
...
@@ -236,7 +236,7 @@ class NimSDKOptionConfig {
}
else
{
}
else
{
String
appFrom
=
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppFrom
();
String
appFrom
=
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppFrom
();
if
(
YDLConstants
.
FROM_YDL
.
equals
(
appFrom
))
{
if
(
YDLConstants
.
FROM_YDL
.
equals
(
appFrom
)
||
YDLConstants
.
FROM_YDL2
.
equals
(
appFrom
)
)
{
// 小米推送
// 小米推送
config
.
xmAppId
=
"2882303761517432980"
;
config
.
xmAppId
=
"2882303761517432980"
;
config
.
xmAppKey
=
"5241743243980"
;
config
.
xmAppKey
=
"5241743243980"
;
...
...
ydl-pay/src/main/java/com/yidianling/ydl_pay/common/bean/params/WxPayParam.java
View file @
dc2117e2
...
@@ -18,9 +18,10 @@ public class WxPayParam extends CommonPayParam {
...
@@ -18,9 +18,10 @@ public class WxPayParam extends CommonPayParam {
if
(!
TextUtils
.
isEmpty
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
()))
{
if
(!
TextUtils
.
isEmpty
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
()))
{
type
=
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
();
type
=
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
();
}
else
{
}
else
{
if
(
YDLConstants
.
FROM_XLZX
.
equals
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppFrom
()))
{
String
appFrom
=
BaseApp
.
instance
.
getGlobalConfig
().
getAppFrom
();
if
(
YDLConstants
.
FROM_XLZX
.
equals
(
appFrom
))
{
type
=
"wxapp_consult"
;
type
=
"wxapp_consult"
;
}
else
if
(
YDLConstants
.
FROM_YDL
.
equals
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppFrom
()
))
{
}
else
if
(
YDLConstants
.
FROM_YDL
.
equals
(
appFrom
)
||
YDLConstants
.
FROM_YDL2
.
equals
(
appFrom
))
{
type
=
"wxapp_hz"
;
type
=
"wxapp_hz"
;
}
}
}
}
...
...
ydl-pay/src/main/java/com/yidianling/ydl_pay/common/http/utils/RxDeviceTool.java
View file @
dc2117e2
...
@@ -122,80 +122,12 @@ public class RxDeviceTool {
...
@@ -122,80 +122,12 @@ public class RxDeviceTool {
}
}
/**
/**
* IMEI (唯一标识序列号)
* <p>需与{@link #isPhone(Context)}一起使用</p>
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @param context 上下文
* @return IMEI
*/
// public static String getIMEI(Context context) {
// String deviceId;
// if (isPhone(context)) {
// deviceId = getDeviceIdIMEI(context);
// } else {
// deviceId = getAndroidId(context);
// }
// return deviceId;
// }
/**
* 获取设备的IMSI
*
* @param context
* @return
*/
// public static String getIMSI(Context context) {
// return getSubscriberId(context);
// }
/**
* 获取设备的IMEI
*
* @param context
* @return
*/
// public static String getDeviceIdIMEI(Context context) {
// String id;
// //android.telephony.TelephonyManager
// TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// if (mTelephony.getDeviceId() != null) {
// id = mTelephony.getDeviceId();
// } else {
// //android.provider.Settings;
// id = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
// }
// return id;
// }
/**
* 获取设备的软件版本号
*
* @param context
* @return
*/
// public static String getDeviceSoftwareVersion(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm.getDeviceSoftwareVersion();
// }
/**
* 获取android系统版本号
* 获取android系统版本号
*/
*/
public
static
String
getOsBuileVersion
()
{
public
static
String
getOsBuileVersion
()
{
return
Build
.
VERSION
.
RELEASE
;
return
Build
.
VERSION
.
RELEASE
;
}
}
/**
* 获取手机号
*
* @param context
* @return
*/
// public static String getLine1Number(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm.getLine1Number();
// }
/**
/**
* 获取ISO标准的国家码,即国际长途区号
* 获取ISO标准的国家码,即国际长途区号
...
@@ -308,28 +240,6 @@ public class RxDeviceTool {
...
@@ -308,28 +240,6 @@ public class RxDeviceTool {
}
}
/**
/**
* 获取唯一的用户ID
*
* @param context
* @return
*/
// public static String getSubscriberId(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm.getSubscriberId();
// }
/**
* 获取语音邮件号码
*
* @param context
* @return
*/
// public static String getVoiceMailNumber(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm.getVoiceMailNumber();
// }
/**
* 获取ANDROID ID
* 获取ANDROID ID
*
*
* @param context
* @param context
...
@@ -449,66 +359,6 @@ public class RxDeviceTool {
...
@@ -449,66 +359,6 @@ public class RxDeviceTool {
return
result
;
return
result
;
}
}
/**
* 获取设备信息
*
* @param context
* @return
*/
// public static String getDeviceInfo(Context context) {
// try {
// org.json.JSONObject json = new org.json.JSONObject();
// TelephonyManager tm = (TelephonyManager) context
// .getSystemService(Context.TELEPHONY_SERVICE);
// String device_id = null;
// if (checkPermission(context, Manifest.permission.READ_PHONE_STATE)) {
// device_id = getDeviceIdIMEI(context);
// }
// String mac = null;
// FileReader fstream = null;
// try {
// fstream = new FileReader("/sys/class/net/wlan0/address");
// } catch (FileNotFoundException e) {
// fstream = new FileReader("/sys/class/net/eth0/address");
// }
// BufferedReader in = null;
// if (fstream != null) {
// try {
// in = new BufferedReader(fstream, 1024);
// mac = in.readLine();
// } catch (IOException e) {
// } finally {
// if (fstream != null) {
// try {
// fstream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
// json.put("mac", mac);
// if (TextUtils.isEmpty(device_id)) {
// device_id = mac;
// }
// if (TextUtils.isEmpty(device_id)) {
// device_id = Settings.Secure.getString(context.getContentResolver(),
// Settings.Secure.ANDROID_ID);
// }
// json.put("device_id", device_id);
// return json.toString();
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
/**
/**
...
...
ydl-pay/src/main/java/com/yidianling/ydl_pay/pay/bean/WXRechargeIdParam.java
View file @
dc2117e2
...
@@ -22,9 +22,10 @@ public class WXRechargeIdParam extends BaseCommand {
...
@@ -22,9 +22,10 @@ public class WXRechargeIdParam extends BaseCommand {
if
(!
TextUtils
.
isEmpty
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
()))
{
if
(!
TextUtils
.
isEmpty
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
()))
{
type
=
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
();
type
=
BaseApp
.
instance
.
getGlobalConfig
().
getAppWxPayType
();
}
else
{
}
else
{
if
(
YDLConstants
.
FROM_XLZX
.
equals
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppFrom
()))
{
String
appFrom
=
BaseApp
.
instance
.
getGlobalConfig
().
getAppFrom
();
if
(
YDLConstants
.
FROM_XLZX
.
equals
(
appFrom
))
{
type
=
"wxapp_consult"
;
type
=
"wxapp_consult"
;
}
else
if
(
YDLConstants
.
FROM_YDL
.
equals
(
BaseApp
.
instance
.
getGlobalConfig
().
getAppFrom
()
))
{
}
else
if
(
YDLConstants
.
FROM_YDL
.
equals
(
appFrom
)
||
YDLConstants
.
FROM_YDL2
.
equals
(
appFrom
))
{
type
=
"wxapp_hz"
;
type
=
"wxapp_hz"
;
}
}
}
}
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/app/YdlRepository.kt
View file @
dc2117e2
...
@@ -6,10 +6,8 @@ import android.os.Build
...
@@ -6,10 +6,8 @@ import android.os.Build
import
com.alibaba.android.arouter.launcher.ARouter
import
com.alibaba.android.arouter.launcher.ARouter
import
com.bun.miitmdid.core.JLibrary
import
com.bun.miitmdid.core.JLibrary
import
com.tencent.mmkv.MMKV
import
com.tencent.mmkv.MMKV
import
com.ydl.devicesidlib.DeviceIDHelper
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.data.http.UpLoadLogUtils
import
com.ydl.ydlcommon.data.http.UpLoadLogUtils
import
com.ydl.ydlcommon.utils.AppProgressUtils
import
com.ydl.ydlcommon.utils.BuryPointUtils
import
com.ydl.ydlcommon.utils.BuryPointUtils
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlcommon.utils.log.LogHelper
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/YDLConstants.kt
View file @
dc2117e2
...
@@ -17,10 +17,12 @@ object YDLConstants {
...
@@ -17,10 +17,12 @@ object YDLConstants {
const
val
BUNDLE
=
"bundle"
const
val
BUNDLE
=
"bundle"
const
val
FROM_YDL
=
"android"
const
val
FROM_YDL
=
"android"
//壹点灵sem渠道ffrom
const
val
FROM_YDL2
=
"BaiduSem"
const
val
FROM_XLZX
=
"ATK_7_android"
const
val
FROM_XLZX
=
"ATK_7_android"
//自定义注解,限制入参类型
//自定义注解,限制入参类型
@StringDef
(
FROM_YDL
,
FROM_XLZX
)
@StringDef
(
FROM_YDL
,
FROM_XLZX
,
FROM_YDL2
)
annotation
class
AppFrom
annotation
class
AppFrom
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/DeviceTool.java
View file @
dc2117e2
...
@@ -20,8 +20,8 @@ import android.text.TextUtils;
...
@@ -20,8 +20,8 @@ import android.text.TextUtils;
import
android.util.Log
;
import
android.util.Log
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.yidianling.common.tools.RxTool
;
import
com.ydl.ydlcommon.BuildConfig
;
import
com.ydl.ydlcommon.BuildConfig
;
import
com.yidianling.common.tools.RxTool
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.FileReader
;
import
java.io.FileReader
;
...
@@ -122,32 +122,32 @@ public class DeviceTool {
...
@@ -122,32 +122,32 @@ public class DeviceTool {
@SuppressLint
(
"MissingPermission"
)
@SuppressLint
(
"MissingPermission"
)
public
static
final
String
getIMEI
()
{
public
static
final
String
getIMEI
()
{
Activity
topTaskActivity
=
ActivityManager
.
Companion
.
getInstance
().
getTopTaskActivity
();
Activity
topTaskActivity
=
ActivityManager
.
Companion
.
getInstance
().
getTopTaskActivity
();
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
""
;
try
{
}
String
imei
=
""
;
try
{
RxPermissions
rxPermissions
=
new
RxPermissions
(
topTaskActivity
);
String
imei
=
""
;
RxPermissions
rxPermissions
=
new
RxPermissions
(
topTaskActivity
);
if
(
rxPermissions
.
isGranted
(
Manifest
.
permission
.
READ_PHONE_STATE
))
{
//实例化TelephonyManager对象
if
(
rxPermissions
.
isGranted
(
Manifest
.
permission
.
READ_PHONE_STATE
))
{
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
topTaskActivity
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
//实例化TelephonyManager对象
if
(
null
==
telephonyManager
)
{
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
topTaskActivity
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
return
""
;
if
(
null
==
telephonyManager
){
}
return
""
;
//获取IMEI号
}
imei
=
telephonyManager
.
getDeviceId
();
//获取IMEI号
imei
=
telephonyManager
.
getDeviceId
();
if
(
imei
==
null
)
{
if
(
imei
==
null
)
{
return
""
;
return
""
;
}
}
}
return
RxTool
.
Md5
(
imei
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
""
;
}
}
return
RxTool
.
Md5
(
imei
);
}
else
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
""
;
return
""
;
}
}
}
}
/**
/**
* 检查是否同意隐私协议
* 检查是否同意隐私协议
...
@@ -162,30 +162,35 @@ public class DeviceTool {
...
@@ -162,30 +162,35 @@ public class DeviceTool {
public
static
String
getEncryptionAndroidID
()
{
public
static
String
getEncryptionAndroidID
()
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
""
;
try
{
}
@SuppressLint
(
"HardwareIds"
)
String
id
=
Settings
.
Secure
.
getString
(
try
{
RxTool
.
getContext
().
getContentResolver
(),
@SuppressLint
(
"HardwareIds"
)
String
id
=
Settings
.
Secure
.
getString
(
Settings
.
Secure
.
ANDROID_ID
RxTool
.
getContext
().
getContentResolver
(),
);
Settings
.
Secure
.
ANDROID_ID
return
TextUtils
.
isEmpty
(
id
)
?
""
:
id
;
);
}
catch
(
Exception
e
)
{
return
TextUtils
.
isEmpty
(
id
)
?
""
:
id
;
return
""
;
}
catch
(
Exception
e
)
{
}
}
else
{
return
""
;
return
""
;
}
}
}
}
public
static
String
getAndroidID
()
{
public
static
String
getAndroidID
()
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
""
;
try
{
}
@SuppressLint
(
"HardwareIds"
)
String
id
=
Settings
.
Secure
.
getString
(
try
{
RxTool
.
getContext
().
getContentResolver
(),
@SuppressLint
(
"HardwareIds"
)
String
id
=
Settings
.
Secure
.
getString
(
Settings
.
Secure
.
ANDROID_ID
RxTool
.
getContext
().
getContentResolver
(),
);
Settings
.
Secure
.
ANDROID_ID
return
TextUtils
.
isEmpty
(
id
)
?
""
:
RxTool
.
Md5
(
id
);
);
}
catch
(
Exception
e
)
{
return
TextUtils
.
isEmpty
(
id
)
?
""
:
RxTool
.
Md5
(
id
);
return
""
;
}
catch
(
Exception
e
)
{
}
}
else
{
return
""
;
return
""
;
}
}
}
}
...
@@ -269,65 +274,65 @@ public class DeviceTool {
...
@@ -269,65 +274,65 @@ public class DeviceTool {
}
}
public
static
String
getMac
(
Context
context
)
{
public
static
String
getMac
(
Context
context
)
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
"02:00:00:00:00:00"
;
String
strMac
=
null
;
}
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
String
strMac
=
null
;
strMac
=
getLocalMacAddressFromWifiInfo
(
context
);
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
strMac
=
getLocalMacAddressFromWifiInfo
(
context
);
return
strMac
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
strMac
=
getMacAddress
(
context
);
return
strMac
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
if
(!
TextUtils
.
isEmpty
(
getMacAddress
()))
{
strMac
=
getMacAddress
();
return
strMac
;
return
strMac
;
}
else
if
(!
TextUtils
.
isEmpty
(
getMachineHardwareAddress
()))
{
}
else
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
strMac
=
getMachineHardwareAddress
();
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
return
strMac
;
strMac
=
getMacAddress
(
context
);
}
else
{
strMac
=
getLocalMacAddressFromBusybox
();
return
strMac
;
return
strMac
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
if
(!
TextUtils
.
isEmpty
(
getMacAddress
()))
{
strMac
=
getMacAddress
();
return
strMac
;
}
else
if
(!
TextUtils
.
isEmpty
(
getMachineHardwareAddress
()))
{
strMac
=
getMachineHardwareAddress
();
return
strMac
;
}
else
{
strMac
=
getLocalMacAddressFromBusybox
();
return
strMac
;
}
}
}
}
}
return
"02:00:00:00:00:00"
;
return
"02:00:00:00:00:00"
;
}
}
/*
/*
* 获取MAC地址
* 获取MAC地址
*GPRS链接和WIFI链接返回同一个MAC地址
*GPRS链接和WIFI链接返回同一个MAC地址
* */
* */
public
static
String
getMacFromHardware
()
{
public
static
String
getMacFromHardware
()
{
if
(
!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
"02:00:00:00:00:00"
;
try
{
}
List
<
NetworkInterface
>
all
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
try
{
for
(
NetworkInterface
nif
:
all
)
{
List
<
NetworkInterface
>
all
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
if
(!
nif
.
getName
().
equalsIgnoreCase
(
"wlan0"
))
{
for
(
NetworkInterface
nif
:
all
)
{
continue
;
if
(!
nif
.
getName
().
equalsIgnoreCase
(
"wlan0"
))
continue
;
}
byte
[]
macBytes
=
nif
.
getHardwareAddress
();
byte
[]
macBytes
=
nif
.
getHardwareAddress
();
if
(
macBytes
==
null
)
{
if
(
macBytes
==
null
)
{
return
""
;
return
""
;
}
}
StringBuilder
res1
=
new
StringBuilder
();
StringBuilder
res1
=
new
StringBuilder
();
for
(
byte
b
:
macBytes
)
{
for
(
byte
b
:
macBytes
)
{
res1
.
append
(
String
.
format
(
"%02X:"
,
b
));
res1
.
append
(
String
.
format
(
"%02X:"
,
b
));
}
}
if
(
res1
.
length
()
>
0
)
{
if
(
res1
.
length
()
>
0
)
{
res1
.
deleteCharAt
(
res1
.
length
()
-
1
);
res1
.
deleteCharAt
(
res1
.
length
()
-
1
);
}
return
res1
.
toString
();
}
}
return
res1
.
toString
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
"02:00:00:00:00:00"
;
return
"02:00:00:00:00:00"
;
}
}
/**
/**
*
*
...
@@ -351,40 +356,41 @@ public class DeviceTool {
...
@@ -351,40 +356,41 @@ public class DeviceTool {
* @return
* @return
*/
*/
public
static
String
getLocalWifiIpAddress
(
Context
context
)
{
public
static
String
getLocalWifiIpAddress
(
Context
context
)
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
try
{
WifiManager
wifiManager
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
WifiInfo
wifiInfo
=
wifiManager
.
getConnectionInfo
();
int
i
=
wifiInfo
.
getIpAddress
();
return
int2ip
(
i
);
}
catch
(
Exception
ex
)
{
return
" 获取IP出错鸟!!!!请保证是WIFI,或者请重新打开网络!\n"
+
ex
.
getMessage
();
}
}
else
{
return
"隐私协议未同意,不让获取"
;
return
"隐私协议未同意,不让获取"
;
}
}
try
{
WifiManager
wifiManager
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
WifiInfo
wifiInfo
=
wifiManager
.
getConnectionInfo
();
int
i
=
wifiInfo
.
getIpAddress
();
return
int2ip
(
i
);
}
catch
(
Exception
ex
)
{
return
" 获取IP出错鸟!!!!请保证是WIFI,或者请重新打开网络!\n"
+
ex
.
getMessage
();
}
// return null;
}
}
//GPRS连接下的ip
/**
* GPRS连接下的ip
* */
public
static
String
getLocalGPRSIpAddress
()
{
public
static
String
getLocalGPRSIpAddress
()
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
null
;
try
{
}
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
try
{
NetworkInterface
intf
=
en
.
nextElement
();
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
NetworkInterface
intf
=
en
.
nextElement
();
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
if
(!
inetAddress
.
isLoopbackAddress
())
{
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
return
inetAddress
.
getHostAddress
().
toString
();
if
(!
inetAddress
.
isLoopbackAddress
())
{
}
return
inetAddress
.
getHostAddress
().
toString
();
}
}
}
}
}
catch
(
SocketException
ex
)
{
Log
.
e
(
"WifiPreferenceIpAddress"
,
ex
.
toString
());
}
}
}
catch
(
SocketException
ex
)
{
Log
.
e
(
"WifiPreferenceIpAddress"
,
ex
.
toString
());
}
}
return
null
;
return
null
;
}
}
...
@@ -393,137 +399,127 @@ public class DeviceTool {
...
@@ -393,137 +399,127 @@ public class DeviceTool {
* @return
* @return
*/
*/
public
static
String
getNewMac
()
{
public
static
String
getNewMac
()
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
null
;
try
{
}
List
<
NetworkInterface
>
all
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
try
{
for
(
NetworkInterface
nif
:
all
)
{
List
<
NetworkInterface
>
all
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
if
(!
nif
.
getName
().
equalsIgnoreCase
(
"wlan0"
))
continue
;
for
(
NetworkInterface
nif
:
all
)
{
if
(!
nif
.
getName
().
equalsIgnoreCase
(
"wlan0"
))
continue
;
byte
[]
macBytes
=
nif
.
getHardwareAddress
();
byte
[]
macBytes
=
nif
.
getHardwareAddress
();
if
(
macBytes
==
null
)
{
if
(
macBytes
==
null
)
{
return
null
;
return
null
;
}
}
StringBuilder
res1
=
new
StringBuilder
();
StringBuilder
res1
=
new
StringBuilder
();
for
(
byte
b
:
macBytes
)
{
for
(
byte
b
:
macBytes
)
{
res1
.
append
(
String
.
format
(
"%02X:"
,
b
));
res1
.
append
(
String
.
format
(
"%02X:"
,
b
));
}
}
if
(
res1
.
length
()
>
0
)
{
if
(
res1
.
length
()
>
0
)
{
res1
.
deleteCharAt
(
res1
.
length
()
-
1
);
res1
.
deleteCharAt
(
res1
.
length
()
-
1
);
}
return
res1
.
toString
();
}
}
return
res1
.
toString
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
}
return
null
;
return
null
;
}
}
public
static
String
getLocalMacAddressFromWifiInfo
(
Context
context
)
{
public
static
String
getLocalMacAddressFromWifiInfo
(
Context
context
)
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
WifiManager
wifi
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
WifiInfo
winfo
=
wifi
.
getConnectionInfo
();
String
mac
=
winfo
.
getMacAddress
();
return
mac
;
}
else
{
return
null
;
return
null
;
}
}
WifiManager
wifi
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
WifiInfo
winfo
=
wifi
.
getConnectionInfo
();
String
mac
=
winfo
.
getMacAddress
();
return
mac
;
}
}
/*
/*
* 获取IPV6地址
* 获取IPV6地址
* */
* */
public
static
String
getLocalIpV6
()
{
public
static
String
getLocalIpV6
()
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
null
;
try
{
}
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
try
{
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
NetworkInterface
intf
=
en
.
nextElement
();
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
NetworkInterface
intf
=
en
.
nextElement
();
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
if
(!
inetAddress
.
isLoopbackAddress
()
&&
inetAddress
instanceof
Inet6Address
)
{
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
return
inetAddress
.
getHostAddress
();
// logger.error("ip1 " + inetAddress);
}
/* logger.error("getHostName " + inetAddress.getHostName());
logger.error("getCanonicalHostName " + inetAddress.getCanonicalHostName());
logger.error("getAddress " + Arrays.toString(inetAddress.getAddress()));
logger.error("getHostAddress " + inetAddress.getHostAddress());*/
if
(!
inetAddress
.
isLoopbackAddress
()
&&
inetAddress
instanceof
Inet6Address
)
{
return
inetAddress
.
getHostAddress
();
}
}
}
}
}
catch
(
Exception
ex
)
{
Log
.
e
(
"IP Address"
,
ex
.
toString
());
}
}
}
catch
(
Exception
ex
)
{
Log
.
e
(
"IP Address"
,
ex
.
toString
());
}
}
return
null
;
return
null
;
}
}
public
static
String
getMacAddress
(
Context
context
)
{
public
static
String
getMacAddress
(
Context
context
)
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
null
;
// 如果是6.0以下,直接通过wifimanager获取
}
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
// 如果是6.0以下,直接通过wifimanager获取
String
macAddress0
=
getMacAddress0
(
context
);
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
if
(!
TextUtils
.
isEmpty
(
macAddress0
))
{
String
macAddress0
=
getMacAddress0
(
context
);
return
macAddress0
;
if
(!
TextUtils
.
isEmpty
(
macAddress0
))
{
return
macAddress0
;
}
}
String
str
=
""
;
String
macSerial
=
""
;
try
{
Process
pp
=
Runtime
.
getRuntime
().
exec
(
"cat /sys/class/net/wlan0/address"
);
InputStreamReader
ir
=
new
InputStreamReader
(
pp
.
getInputStream
());
LineNumberReader
input
=
new
LineNumberReader
(
ir
);
for
(;
null
!=
str
;
)
{
str
=
input
.
readLine
();
if
(
str
!=
null
)
{
macSerial
=
str
.
trim
();
// 去空格
break
;
}
}
}
}
}
catch
(
Exception
ex
)
{
String
str
=
""
;
Log
.
e
(
"----->"
+
"NetInfoManager"
,
"getMacAddress:"
+
ex
.
toString
());
String
macSerial
=
""
;
}
if
(
macSerial
==
null
||
""
.
equals
(
macSerial
))
{
try
{
try
{
return
loadFileAsString
(
"/sys/class/net/eth0/address"
)
Process
pp
=
Runtime
.
getRuntime
().
exec
(
.
toUpperCase
().
substring
(
0
,
17
);
"cat /sys/class/net/wlan0/address"
);
}
catch
(
Exception
e
)
{
InputStreamReader
ir
=
new
InputStreamReader
(
pp
.
getInputStream
());
e
.
printStackTrace
();
LineNumberReader
input
=
new
LineNumberReader
(
ir
);
Log
.
e
(
"----->"
+
"NetInfoManager"
,
for
(;
null
!=
str
;
)
{
"getMacAddress:"
+
e
.
toString
());
str
=
input
.
readLine
();
if
(
str
!=
null
)
{
macSerial
=
str
.
trim
();
// 去空格
break
;
}
}
}
catch
(
Exception
ex
)
{
Log
.
e
(
"----->"
+
"NetInfoManager"
,
"getMacAddress:"
+
ex
.
toString
());
}
}
if
(
macSerial
==
null
||
""
.
equals
(
macSerial
))
{
try
{
return
loadFileAsString
(
"/sys/class/net/eth0/address"
)
.
toUpperCase
().
substring
(
0
,
17
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
e
(
"----->"
+
"NetInfoManager"
,
"getMacAddress:"
+
e
.
toString
());
}
}
return
macSerial
;
}
else
{
return
null
;
}
}
return
macSerial
;
}
}
private
static
String
getMacAddress0
(
Context
context
)
{
private
static
String
getMacAddress0
(
Context
context
)
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
null
;
if
(
isAccessWifiStateAuthorized
(
context
))
{
}
WifiManager
wifiMgr
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
if
(
isAccessWifiStateAuthorized
(
context
))
{
WifiInfo
wifiInfo
=
null
;
WifiManager
wifiMgr
=
(
WifiManager
)
context
try
{
.
getSystemService
(
Context
.
WIFI_SERVICE
);
wifiInfo
=
wifiMgr
.
getConnectionInfo
();
WifiInfo
wifiInfo
=
null
;
return
wifiInfo
.
getMacAddress
();
try
{
}
catch
(
Exception
e
)
{
wifiInfo
=
wifiMgr
.
getConnectionInfo
();
Log
.
e
(
"----->"
+
"NetInfoManager"
,
return
wifiInfo
.
getMacAddress
();
"getMacAddress0:"
+
e
.
toString
());
}
catch
(
Exception
e
)
{
}
Log
.
e
(
"----->"
+
"NetInfoManager"
,
"getMacAddress0:"
+
e
.
toString
());
}
}
}
}
return
""
;
return
""
;
}
}
/**
/**
...
@@ -567,25 +563,25 @@ public class DeviceTool {
...
@@ -567,25 +563,25 @@ public class DeviceTool {
* @return
* @return
*/
*/
public
static
String
getMacAddress
()
{
public
static
String
getMacAddress
()
{
if
(!
checkHasAgreeSecret
())
{
return
null
;
}
String
strMacAddr
=
null
;
String
strMacAddr
=
null
;
try
{
if
(
checkHasAgreeSecret
())
{
// 获得IpD地址
try
{
InetAddress
ip
=
getLocalInetAddress
();
// 获得IpD地址
byte
[]
b
=
NetworkInterface
.
getByInetAddress
(
ip
)
InetAddress
ip
=
getLocalInetAddress
();
.
getHardwareAddress
();
byte
[]
b
=
NetworkInterface
.
getByInetAddress
(
ip
)
StringBuffer
buffer
=
new
StringBuffer
();
.
getHardwareAddress
();
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++)
{
StringBuffer
buffer
=
new
StringBuffer
();
if
(
i
!=
0
)
{
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++)
{
buffer
.
append
(
':'
);
if
(
i
!=
0
)
{
buffer
.
append
(
':'
);
}
String
str
=
Integer
.
toHexString
(
b
[
i
]
&
0xFF
);
buffer
.
append
(
str
.
length
()
==
1
?
0
+
str
:
str
);
}
}
String
str
=
Integer
.
toHexString
(
b
[
i
]
&
0xFF
);
strMacAddr
=
buffer
.
toString
().
toUpperCase
();
buffer
.
append
(
str
.
length
()
==
1
?
0
+
str
:
str
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
strMacAddr
=
buffer
.
toString
().
toUpperCase
();
}
catch
(
Exception
e
)
{
}
}
return
strMacAddr
;
return
strMacAddr
;
}
}
...
@@ -595,34 +591,34 @@ public class DeviceTool {
...
@@ -595,34 +591,34 @@ public class DeviceTool {
* @return
* @return
*/
*/
private
static
InetAddress
getLocalInetAddress
()
{
private
static
InetAddress
getLocalInetAddress
()
{
if
(!
checkHasAgreeSecret
())
{
return
null
;
}
InetAddress
ip
=
null
;
InetAddress
ip
=
null
;
try
{
if
(
checkHasAgreeSecret
())
{
// 列举
try
{
Enumeration
<
NetworkInterface
>
en_netInterface
=
NetworkInterface
// 列举
.
getNetworkInterfaces
();
Enumeration
<
NetworkInterface
>
en_netInterface
=
NetworkInterface
while
(
en_netInterface
.
hasMoreElements
())
{
// 是否还有元素
.
getNetworkInterfaces
();
NetworkInterface
ni
=
(
NetworkInterface
)
en_netInterface
while
(
en_netInterface
.
hasMoreElements
())
{
// 是否还有元素
.
nextElement
();
// 得到下一个元素
NetworkInterface
ni
=
(
NetworkInterface
)
en_netInterface
Enumeration
<
InetAddress
>
en_ip
=
ni
.
getInetAddresses
();
// 得到一个ip地址的列举
.
nextElement
();
// 得到下一个元素
while
(
en_ip
.
hasMoreElements
())
{
Enumeration
<
InetAddress
>
en_ip
=
ni
.
getInetAddresses
();
// 得到一个ip地址的列举
ip
=
en_ip
.
nextElement
();
while
(
en_ip
.
hasMoreElements
())
{
if
(!
ip
.
isLoopbackAddress
()
ip
=
en_ip
.
nextElement
();
&&
ip
.
getHostAddress
().
indexOf
(
":"
)
==
-
1
)
if
(!
ip
.
isLoopbackAddress
()
&&
ip
.
getHostAddress
().
indexOf
(
":"
)
==
-
1
)
{
break
;
}
else
{
ip
=
null
;
}
}
if
(
ip
!=
null
)
{
break
;
break
;
else
}
ip
=
null
;
}
}
}
catch
(
SocketException
e
)
{
if
(
ip
!=
null
)
{
e
.
printStackTrace
();
break
;
}
}
}
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
}
}
return
ip
;
return
ip
;
}
}
...
@@ -633,51 +629,50 @@ public class DeviceTool {
...
@@ -633,51 +629,50 @@ public class DeviceTool {
* @return
* @return
*/
*/
public
static
String
getLocalIpAddress
()
{
public
static
String
getLocalIpAddress
()
{
if
(!
checkHasAgreeSecret
())
{
if
(
checkHasAgreeSecret
())
{
return
null
;
try
{
}
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
try
{
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
NetworkInterface
intf
=
en
.
nextElement
();
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
NetworkInterface
intf
=
en
.
nextElement
();
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
if
(!
inetAddress
.
isLoopbackAddress
())
{
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
return
inetAddress
.
getHostAddress
().
toString
();
if
(!
inetAddress
.
isLoopbackAddress
())
{
}
return
inetAddress
.
getHostAddress
().
toString
();
}
}
}
}
}
catch
(
SocketException
ex
)
{
ex
.
printStackTrace
();
}
}
}
catch
(
SocketException
ex
)
{
ex
.
printStackTrace
();
}
}
return
null
;
return
null
;
}
}
public
static
String
getMachineHardwareAddress
()
{
public
static
String
getMachineHardwareAddress
()
{
if
(!
checkHasAgreeSecret
())
{
return
null
;
}
Enumeration
<
NetworkInterface
>
interfaces
=
null
;
try
{
interfaces
=
NetworkInterface
.
getNetworkInterfaces
();
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
}
String
hardWareAddress
=
null
;
String
hardWareAddress
=
null
;
NetworkInterface
iF
=
null
;
if
(
checkHasAgreeSecret
())
{
if
(
interfaces
==
null
)
{
Enumeration
<
NetworkInterface
>
interfaces
=
null
;
return
null
;
}
while
(
interfaces
.
hasMoreElements
())
{
iF
=
interfaces
.
nextElement
();
try
{
try
{
hardWareAddress
=
bytesToString
(
iF
.
getHardwareAddress
());
interfaces
=
NetworkInterface
.
getNetworkInterfaces
();
if
(
hardWareAddress
!=
null
)
break
;
}
catch
(
SocketException
e
)
{
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
NetworkInterface
iF
=
null
;
if
(
interfaces
==
null
)
{
return
null
;
}
while
(
interfaces
.
hasMoreElements
())
{
iF
=
interfaces
.
nextElement
();
try
{
hardWareAddress
=
bytesToString
(
iF
.
getHardwareAddress
());
if
(
hardWareAddress
!=
null
)
break
;
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
}
}
}
}
return
hardWareAddress
;
return
hardWareAddress
;
}
}
...
@@ -703,22 +698,21 @@ public class DeviceTool {
...
@@ -703,22 +698,21 @@ public class DeviceTool {
}
}
public
static
String
getLocalMacAddressFromBusybox
()
{
public
static
String
getLocalMacAddressFromBusybox
()
{
if
(!
checkHasAgreeSecret
())
{
return
""
;
}
String
result
=
""
;
String
result
=
""
;
String
Mac
=
""
;
if
(
checkHasAgreeSecret
())
{
result
=
callCmd
(
"busybox ifconfig"
,
"HWaddr"
);
String
Mac
=
""
;
// 如果返回的result == null,则说明网络不可取
result
=
callCmd
(
"busybox ifconfig"
,
"HWaddr"
);
if
(
result
==
null
)
{
// 如果返回的result == null,则说明网络不可取
return
"网络异常"
;
if
(
result
==
null
)
{
}
return
"网络异常"
;
// 对该行数据进行解析
}
// 例如:eth0 Link encap:Ethernet HWaddr 00:16:E8:3E:DF:67
// 对该行数据进行解析
if
(
result
.
length
()
>
0
&&
result
.
contains
(
"HWaddr"
)
==
true
)
{
// 例如:eth0 Link encap:Ethernet HWaddr 00:16:E8:3E:DF:67
Mac
=
result
.
substring
(
result
.
indexOf
(
"HWaddr"
)
+
6
,
if
(
result
.
length
()
>
0
&&
result
.
contains
(
"HWaddr"
)
==
true
)
{
result
.
length
()
-
1
);
Mac
=
result
.
substring
(
result
.
indexOf
(
"HWaddr"
)
+
6
,
result
=
Mac
;
result
.
length
()
-
1
);
result
=
Mac
;
}
}
}
return
result
;
return
result
;
}
}
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/YdlBuryPointUtil.java
View file @
dc2117e2
...
@@ -5,7 +5,6 @@ import android.util.Log;
...
@@ -5,7 +5,6 @@ import android.util.Log;
import
com.umeng.analytics.MobclickAgent
;
import
com.umeng.analytics.MobclickAgent
;
import
com.ydl.burypointlib.BuryPointHelper
;
import
com.ydl.burypointlib.BuryPointHelper
;
//import com.ydl.devicesidlib.DemoHelper;
import
com.ydl.devicesidlib.DeviceIDHelper
;
import
com.ydl.devicesidlib.DeviceIDHelper
;
import
com.ydl.pushserver.pushagent.YdlPushAgent
;
import
com.ydl.pushserver.pushagent.YdlPushAgent
;
import
com.ydl.pushserver.pushagent.common.listener.IYDLPushListener
;
import
com.ydl.pushserver.pushagent.common.listener.IYDLPushListener
;
...
@@ -18,6 +17,8 @@ import com.yidianling.common.tools.RxAppTool;
...
@@ -18,6 +17,8 @@ import com.yidianling.common.tools.RxAppTool;
import
com.yidianling.common.tools.RxDeviceTool
;
import
com.yidianling.common.tools.RxDeviceTool
;
import
com.yidianling.common.tools.RxNetTool
;
import
com.yidianling.common.tools.RxNetTool
;
import
static
com
.
ydl
.
ydlcommon
.
utils
.
DeviceTool
.
checkHasAgreeSecret
;
//import static com.bun.miitmdid.content.ContextKeeper.getApplicationContext;
//import static com.bun.miitmdid.content.ContextKeeper.getApplicationContext;
//import com.ydl.burypointlib.BuryPointHelper;
//import com.ydl.burypointlib.BuryPointHelper;
...
@@ -43,7 +44,10 @@ public class YdlBuryPointUtil {
...
@@ -43,7 +44,10 @@ public class YdlBuryPointUtil {
RegisterEventBean
registerEventBean
=
new
RegisterEventBean
();
RegisterEventBean
registerEventBean
=
new
RegisterEventBean
();
registerEventBean
.
setAppId
(
context
.
getPackageName
());
registerEventBean
.
setAppId
(
context
.
getPackageName
());
registerEventBean
.
setAppVersion
(
RxAppTool
.
getAppVersionName
(
context
));
registerEventBean
.
setAppVersion
(
RxAppTool
.
getAppVersionName
(
context
));
String
deviceId
=
DeviceIDHelper
.
getInstance
().
getDeviceId
();
String
deviceId
=
""
;
if
(
checkHasAgreeSecret
())
{
deviceId
=
DeviceIDHelper
.
getInstance
().
getDeviceId
();
}
registerEventBean
.
setDeviceId
(
deviceId
);
registerEventBean
.
setDeviceId
(
deviceId
);
registerEventBean
.
setManufacturer
(
RxDeviceTool
.
getBuildMANUFACTURER
());
registerEventBean
.
setManufacturer
(
RxDeviceTool
.
getBuildMANUFACTURER
());
registerEventBean
.
setChannel
(
YdlCommonOut
.
Companion
.
getChannelName
());
registerEventBean
.
setChannel
(
YdlCommonOut
.
Companion
.
getChannelName
());
...
@@ -92,7 +96,10 @@ public class YdlBuryPointUtil {
...
@@ -92,7 +96,10 @@ public class YdlBuryPointUtil {
RegisterEventBean
registerEventBean
=
new
RegisterEventBean
();
RegisterEventBean
registerEventBean
=
new
RegisterEventBean
();
registerEventBean
.
setAppId
(
context
.
getPackageName
());
registerEventBean
.
setAppId
(
context
.
getPackageName
());
registerEventBean
.
setAppVersion
(
RxAppTool
.
getAppVersionName
(
context
));
registerEventBean
.
setAppVersion
(
RxAppTool
.
getAppVersionName
(
context
));
String
deviceId
=
DeviceIDHelper
.
getInstance
().
getDeviceId
();
String
deviceId
=
""
;
if
(
checkHasAgreeSecret
())
{
deviceId
=
DeviceIDHelper
.
getInstance
().
getDeviceId
();
}
registerEventBean
.
setDeviceId
(
deviceId
);
registerEventBean
.
setDeviceId
(
deviceId
);
registerEventBean
.
setManufacturer
(
RxDeviceTool
.
getBuildMANUFACTURER
());
registerEventBean
.
setManufacturer
(
RxDeviceTool
.
getBuildMANUFACTURER
());
registerEventBean
.
setChannel
(
YdlCommonOut
.
Companion
.
getChannelName
());
registerEventBean
.
setChannel
(
YdlCommonOut
.
Companion
.
getChannelName
());
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/actionutil/ActionCountUtils.kt
View file @
dc2117e2
...
@@ -151,14 +151,17 @@ class ActionCountUtils {
...
@@ -151,14 +151,17 @@ class ActionCountUtils {
* 第一次安装获取失败,第二次打开就能成功
* 第一次安装获取失败,第二次打开就能成功
* 所以Utils.getIMEI(topTaskActivity)传入activity解决这个问题
* 所以Utils.getIMEI(topTaskActivity)传入activity解决这个问题
* */
* */
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
if
(
DeviceTool
.
checkHasAgreeSecret
()){
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
//获取imei
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
Utils
.
getIMEI
(
topTaskActivity
)
//获取imei
}
else
{
Utils
.
getIMEI
(
topTaskActivity
)
//android Q及以上取oaid
}
else
{
DeviceIDHelper
.
getInstance
().
deviceId
//android Q及以上取oaid
DeviceIDHelper
.
getInstance
().
deviceId
}
}
}
actionDataParams
.
deviceId
(
deviceId
)
actionDataParams
.
deviceId
(
deviceId
)
signs
.
forEachIndexed
{
index
,
s
->
signs
.
forEachIndexed
{
index
,
s
->
//拓展参数个数确定,暂不使用反射调用
//拓展参数个数确定,暂不使用反射调用
...
@@ -266,14 +269,18 @@ class ActionCountUtils {
...
@@ -266,14 +269,18 @@ class ActionCountUtils {
* 第一次安装获取失败,第二次打开就能成功
* 第一次安装获取失败,第二次打开就能成功
* 所以Utils.getIMEI(topTaskActivity)传入activity解决这个问题
* 所以Utils.getIMEI(topTaskActivity)传入activity解决这个问题
* */
* */
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
DeviceTool
.
checkHasAgreeSecret
()){
//获取imei
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
Utils
.
getIMEI
(
topTaskActivity
)
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
}
else
{
//获取imei
//android Q及以上取oaid
Utils
.
getIMEI
(
topTaskActivity
)
DeviceIDHelper
.
getInstance
().
deviceId
}
else
{
//android Q及以上取oaid
DeviceIDHelper
.
getInstance
().
deviceId
}
}
}
baiduActionDataParams
.
deviceId
(
deviceId
)
baiduActionDataParams
.
deviceId
(
deviceId
)
baiduActionDataParams
.
convertType
(
convertType
)
baiduActionDataParams
.
convertType
(
convertType
)
baiduActionDataParams
.
convertTime
(
System
.
currentTimeMillis
()
/
1000
)
baiduActionDataParams
.
convertTime
(
System
.
currentTimeMillis
()
/
1000
)
...
@@ -342,14 +349,18 @@ class ActionCountUtils {
...
@@ -342,14 +349,18 @@ class ActionCountUtils {
actionDataParams
.
sign2
=
sign2
actionDataParams
.
sign2
=
sign2
actionDataParams
.
api
=
api
actionDataParams
.
api
=
api
actionDataParams
.
appVersion
(
RxDeviceTool
.
getAppVersionName
(
BaseApp
.
getApp
()))
actionDataParams
.
appVersion
(
RxDeviceTool
.
getAppVersionName
(
BaseApp
.
getApp
()))
val
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
var
deviceId
=
""
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
DeviceTool
.
checkHasAgreeSecret
()){
//获取imei
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
Utils
.
getIMEI
(
topTaskActivity
)
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
}
else
{
//获取imei
//android Q及以上取oaid
Utils
.
getIMEI
(
topTaskActivity
)
DeviceIDHelper
.
getInstance
().
deviceId
}
else
{
//android Q及以上取oaid
DeviceIDHelper
.
getInstance
().
deviceId
}
}
}
actionDataParams
.
deviceId
=
deviceId
actionDataParams
.
deviceId
=
deviceId
actionDataParams
.
time
(
System
.
currentTimeMillis
())
actionDataParams
.
time
(
System
.
currentTimeMillis
())
...
@@ -388,15 +399,18 @@ class ActionCountUtils {
...
@@ -388,15 +399,18 @@ class ActionCountUtils {
actionDataParams
.
sign2
=
sign2
actionDataParams
.
sign2
=
sign2
actionDataParams
.
sign3
=
sign3
actionDataParams
.
sign3
=
sign3
actionDataParams
.
appVersion
(
RxDeviceTool
.
getAppVersionName
(
BaseApp
.
getApp
()))
actionDataParams
.
appVersion
(
RxDeviceTool
.
getAppVersionName
(
BaseApp
.
getApp
()))
val
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
var
deviceId
=
""
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
DeviceTool
.
checkHasAgreeSecret
())
{
//获取imei
deviceId
=
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
P
)
{
Utils
.
getIMEI
(
topTaskActivity
)
val
topTaskActivity
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
}
else
{
//获取imei
//android Q及以上取oaid
Utils
.
getIMEI
(
topTaskActivity
)
DeviceIDHelper
.
getInstance
().
deviceId
}
else
{
//android Q及以上取oaid
DeviceIDHelper
.
getInstance
().
deviceId
}
}
}
actionDataParams
.
deviceId
=
deviceId
actionDataParams
.
deviceId
=
deviceId
actionDataParams
.
time
(
System
.
currentTimeMillis
())
actionDataParams
.
time
(
System
.
currentTimeMillis
())
actionDataParams
.
appId
(
appId
)
actionDataParams
.
appId
(
appId
)
...
@@ -434,22 +448,21 @@ class ActionCountUtils {
...
@@ -434,22 +448,21 @@ class ActionCountUtils {
* @return
* @return
*/
*/
fun
getIpAddress
(
context
:
Context
):
String
{
fun
getIpAddress
(
context
:
Context
):
String
{
if
(
DeviceTool
.
checkHasAgreeSecret
())
{
if
(!
DeviceTool
.
checkHasAgreeSecret
())
{
// 获取WiFi服务
return
""
val
wifiManager
=
context
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
}
// 判断WiFi是否开启
// 获取WiFi服务
if
(
wifiManager
.
isWifiEnabled
)
{
val
wifiManager
=
context
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
// 已经开启了WiFi
// 判断WiFi是否开启
val
wifiInfo
=
wifiManager
.
connectionInfo
if
(
wifiManager
.
isWifiEnabled
)
{
val
ipAddress
=
wifiInfo
.
ipAddress
// 已经开启了WiFi
return
intToIp
(
ipAddress
)
val
wifiInfo
=
wifiManager
.
connectionInfo
}
else
{
val
ipAddress
=
wifiInfo
.
ipAddress
// 未开启WiFi
return
intToIp
(
ipAddress
)
return
getIpAddress
()
}
else
{
}
// 未开启WiFi
return
getIpAddress
()
}
}
return
""
}
}
private
fun
intToIp
(
ipAddress
:
Int
):
String
{
private
fun
intToIp
(
ipAddress
:
Int
):
String
{
...
...
ydl-utils/src/main/java/com/yidianling/common/tools/RxDeviceTool.java
View file @
dc2117e2
...
@@ -161,64 +161,6 @@ public class RxDeviceTool {
...
@@ -161,64 +161,6 @@ public class RxDeviceTool {
}
}
/**
/**
* IMEI (唯一标识序列号)
* <p>需与{@link #isPhone(Context)}一起使用</p>
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @param context 上下文
* @return IMEI
*/
// public static String getIMEI(Context context) {
// String deviceId;
// if (isPhone(context)) {
// deviceId = getDeviceIdIMEI(context);
// } else {
// deviceId = getAndroidId(context);
// }
// return deviceId;
// }
/**
* 获取设备的IMSI
*
* @param context
* @return
*/
// public static String getIMSI(Context context) {
// return getSubscriberId(context);
// }
/**
* 获取设备的IMEI
*
* @param context
* @return
*/
// public static String getDeviceIdIMEI(Context context) {
// String id;
// //android.telephony.TelephonyManager
// TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// if (mTelephony.getDeviceId() != null) {
// id = mTelephony.getDeviceId();
// } else {
// //android.provider.Settings;
// id = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
// }
// return id;
// }
/**
* 获取设备的软件版本号
*
* @param context
* @return
*/
// public static String getDeviceSoftwareVersion(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm.getDeviceSoftwareVersion();
// }
/**
* 获取android系统版本号
* 获取android系统版本号
*/
*/
public
static
String
getOsBuileVersion
(){
public
static
String
getOsBuileVersion
(){
...
@@ -226,17 +168,6 @@ public class RxDeviceTool {
...
@@ -226,17 +168,6 @@ public class RxDeviceTool {
}
}
/**
/**
* 获取手机号
*
* @param context
* @return
*/
// public static String getLine1Number(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm.getLine1Number();
// }
/**
* 获取ISO标准的国家码,即国际长途区号
* 获取ISO标准的国家码,即国际长途区号
*
*
* @param context
* @param context
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment