From a70ee251272d61352d5ba14d471f24d9bab49397 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期三, 11 九月 2024 15:46:58 +0800
Subject: [PATCH] 0312 加入facebook
---
SdkProject/library/src/main/java/com/secondworld/sdk/utils/DeviceUtil.java | 78 +++-----------------------------------
1 files changed, 7 insertions(+), 71 deletions(-)
diff --git a/SdkProject/library/src/main/java/com/secondworld/sdk/utils/DeviceUtil.java b/SdkProject/library/src/main/java/com/secondworld/sdk/utils/DeviceUtil.java
index b7263f5..66812a4 100644
--- a/SdkProject/library/src/main/java/com/secondworld/sdk/utils/DeviceUtil.java
+++ b/SdkProject/library/src/main/java/com/secondworld/sdk/utils/DeviceUtil.java
@@ -9,7 +9,7 @@
import android.os.Build;
import android.provider.Settings;
-import com.secondworld.sdk.GameApp;
+import com.secondworld.sdk.GameAppProxy;
import java.net.NetworkInterface;
import java.util.Enumeration;
@@ -21,12 +21,13 @@
public static final String FAKE_MAC = "02:00:00:00:00:00";
+
public static long getVersionCode() {
long appVersionCode = 0;
try {
- PackageInfo packageInfo = GameApp.I.getApplicationContext()
+ PackageInfo packageInfo = GameAppProxy.app.getApplicationContext()
.getPackageManager()
- .getPackageInfo(GameApp.I.getPackageName(), 0);
+ .getPackageInfo(GameAppProxy.app.getPackageName(), 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
appVersionCode = packageInfo.getLongVersionCode();
} else {
@@ -42,9 +43,9 @@
public static String getVersionName() {
String appVersionName = "";
try {
- PackageInfo packageInfo = GameApp.I.getApplicationContext()
+ PackageInfo packageInfo = GameAppProxy.app.getApplicationContext()
.getPackageManager()
- .getPackageInfo(GameApp.I.getPackageName(), 0);
+ .getPackageInfo(GameAppProxy.app.getPackageName(), 0);
appVersionName = packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
LogUtil.e("getAppVersionName", e);
@@ -59,18 +60,12 @@
* @return
*/
public static long getTotalRAMSize() {
- ActivityManager manager = (ActivityManager) GameApp.I.getSystemService(Context.ACTIVITY_SERVICE);
+ ActivityManager manager = (ActivityManager) GameAppProxy.app.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
manager.getMemoryInfo(info);
return info.totalMem;
}
- public static String getAndroidId() {
- String ANDROID_ID = Settings.System.getString(GameApp.I.getContentResolver(), Settings.System.ANDROID_ID);
- if (ANDROID_ID == null || ANDROID_ID.equals("9774d56d682e549c"))
- return "";
- return ANDROID_ID;
- }
/**
* 鍞竴鏍囪瘑
@@ -81,7 +76,6 @@
String uniqueID = SPUtils.get().getString(SPUtils.UNIQUE_ID, "");
if (!uniqueID.trim().isEmpty())
return uniqueID;
- uniqueID = getAndroidId() + getLocalMac();
//鑷繁鐢熸垚鐨剈id
if (uniqueID.trim().isEmpty())
uniqueID = UUID.randomUUID().toString();
@@ -95,63 +89,5 @@
return uniqueID;
}
-
- /**
- * mac 鍦板潃
- *
- * @return
- */
- public static String getLocalMac() {
- String mac = SPUtils.get().getString(SPUtils.MAC, "");
- if (!mac.trim().isEmpty())
- return mac;
- try {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- String interfaceName = "wlan0";
- Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
- NetworkInterface intf = null;
- while (interfaces.hasMoreElements()) {
- intf = interfaces.nextElement();
- if (!intf.getName().equalsIgnoreCase(interfaceName))
- continue;
- byte[] addresses = intf.getHardwareAddress();
- if (mac != null) {
- StringBuilder buf = new StringBuilder();
- for (byte aMac : addresses) {
- buf.append(String.format("%02X:", aMac));
- }
- if (buf.length() > 0) {
- buf.deleteCharAt(buf.length() - 1);
- }
- mac = buf.toString();
- }
- break;
- }
- } else {
- WifiManager wifi = (WifiManager) GameApp.I.getSystemService(Context.WIFI_SERVICE);
- if (wifi != null) {
- WifiInfo wifiInfo = wifi.getConnectionInfo();
- if (wifiInfo != null) {
- mac = wifiInfo.getMacAddress();
- }
- }
- }
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- mac = mac.toUpperCase(Locale.ENGLISH);
-
- if (mac.equals(FAKE_MAC))
- mac = "";
-
- SPUtils.get()
- .edit()
- .putString(SPUtils.MAC, mac.trim())
- .apply();
-
- return mac;
- }
-
}
--
Gitblit v1.8.0