refactor(package): 工具类按职责分包并拆解 Utils 神类
- core/common/util 按职责拆分:crypto/io/ui/image/system,目录不再承担杂物间角色 - UrlUtils 实为浏览器策略管理,迁入 platform/control - Utils 拆为 DeviceIdUtils、HardwareInfoUtils、AppProcessUtils、AppWhitelistUtils,文件读取并入 FileUtils - 方法体与既有注释逐行保留,仅调整归属类与导入,19 处调用点同步更新 - BaseMvvmFragment 拍平到 core/base/mvvm,删除多余 fragment 子包
This commit is contained in:
1 parent
7b03875151
commit
0a6d170cfc
46 files changed
+831
-755
No files matched your search
@@ -41,7 +41,7 @@ import com.fuying.sn.runtime.sync.TimePolicySync;
|
||||
import com.fuying.sn.platform.app.AppUsedTimeUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -103,7 +103,7 @@ public class BaseApplication extends Application {
|
||||
Toaster.init(this);
|
||||
JgyUtils.init(this);
|
||||
CrashReport.initCrashReport(getApplicationContext(), "e5f026c8d5", false);
|
||||
CrashReport.setDeviceId(this, Utils.getSerial());
|
||||
CrashReport.setDeviceId(this, DeviceIdUtils.getSerial());
|
||||
if (!BuildConfig.DEBUG) {
|
||||
// Bugly 先接管默认异常处理器,兜底处理器才能把子线程异常继续传递给它完成上报
|
||||
catchException();
|
||||
@@ -250,7 +250,7 @@ public class BaseApplication extends Application {
|
||||
public void onSuccess(String response) {
|
||||
Log.e("AliyunPush", "init cloudchannel success");
|
||||
Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
|
||||
String sn = Utils.getSerial();
|
||||
String sn = DeviceIdUtils.getSerial();
|
||||
Log.e(TAG, "AliyunPush: sn=" + sn);
|
||||
if (TextUtils.isEmpty(sn)) {
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.fuying.sn.core.base.BaseTransparentActivity;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
|
||||
/**
|
||||
* MVVM Activity 基类
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.base.mvvm.fragment;
|
||||
package com.fuying.sn.core.base.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
@@ -18,7 +18,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.fuying.sn.core.base.BaseFragment;
|
||||
import com.fuying.sn.core.base.mvvm.IMvvmUiState;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.crypto;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.crypto;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.crypto;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.fuying.sn.core.common.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备唯一标识读取。
|
||||
*
|
||||
* <p>由原 {@code Utils} 按职责拆出:序列号、SN、IMEI、MAC 都属于设备标识,
|
||||
* 与硬件/资源监控({@link HardwareInfoUtils})、进程操作({@code AppProcessUtils})分离。
|
||||
*/
|
||||
public class DeviceIdUtils {
|
||||
private static final String TAG = "DeviceIdUtils";
|
||||
|
||||
/**
|
||||
* 获取设备序列号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getSerial() {
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G13Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.iPlay50SEPlatform
|
||||
) {
|
||||
return getSn();
|
||||
} else {
|
||||
return JgyUtils.getInstance().getIMEI();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSn() {
|
||||
String serial = "unknow";
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
|
||||
serial = Build.getSerial();
|
||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
|
||||
serial = Build.SERIAL;
|
||||
} else {//8.0-
|
||||
Class<?> c = Class.forName("android.os.SystemProperties");
|
||||
Method get = c.getMethod("get", String.class);
|
||||
serial = (String) get.invoke(c, "ro.serialno");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("e", "读取设备序列号异常:" + e);
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
// MD5 设备地址标识
|
||||
public static String getMAC(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // 如果当前设备系统大于等于6.0 使用下面的方法
|
||||
return getMac();
|
||||
} else {
|
||||
try {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
// 获取MAC地址
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
String mac = wifiInfo.getMacAddress();
|
||||
if (null == mac) {
|
||||
// 未获取到
|
||||
mac = "";
|
||||
}
|
||||
return mac;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机的MAC地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getMac() {
|
||||
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);
|
||||
while (null != str) {
|
||||
str = input.readLine();
|
||||
if (str != null) {
|
||||
macSerial = str.trim();// 去空格
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (macSerial == null || "".equals(macSerial)) {
|
||||
try {
|
||||
return FileUtils.loadFileAsString("/sys/class/net/eth0/address")
|
||||
.toUpperCase().substring(0, 17);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
macSerial = getAndroid7MAC();
|
||||
}
|
||||
}
|
||||
return macSerial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容7.0获取不到的问题
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getAndroid7MAC() {
|
||||
try {
|
||||
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
|
||||
for (NetworkInterface nif : all) {
|
||||
if (!"wlan0".equalsIgnoreCase(nif.getName()))
|
||||
continue;
|
||||
byte[] macBytes = nif.getHardwareAddress();
|
||||
if (macBytes == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder res1 = new StringBuilder();
|
||||
for (byte b : macBytes) {
|
||||
res1.append(String.format("%02X:", b));
|
||||
}
|
||||
if (res1.length() > 0) {
|
||||
res1.deleteCharAt(res1.length() - 1);
|
||||
}
|
||||
return res1.toString();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getIMEI(Context context) {
|
||||
String IMEI = "unknow";
|
||||
String IMEI1, IMEI2, IMEI3;
|
||||
//获取手机设备号
|
||||
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
//8.0及以后版本获取
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
IMEI = TelephonyMgr.getDeviceId();
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
// try {
|
||||
// Method method = TelephonyMgr.getClass().getMethod("getImei");
|
||||
// IMEI = (String) method.invoke(TelephonyMgr);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// Log.e("getIMEI", e.getMessage());
|
||||
// }
|
||||
// IMEI = TelephonyMgr.getDeviceId();
|
||||
|
||||
// } else {//9.0到10.0获取
|
||||
IMEI = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
// Log.e("IMEI:", "IMEI: " + IMEI);
|
||||
if (null == IMEI) {
|
||||
return "-";
|
||||
} else {
|
||||
return IMEI.toUpperCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
+326
-614
@@ -1,614 +1,326 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.StatFs;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;␍
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
|
||||
public class Utils {
|
||||
private static final String TAG = "Utils";
|
||||
|
||||
/**
|
||||
* 获取设备序列号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getSerial() {
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G13Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.iPlay50SEPlatform
|
||||
) {
|
||||
return getSn();
|
||||
} else {
|
||||
return JgyUtils.getInstance().getIMEI();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSn() {
|
||||
String serial = "unknow";
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
|
||||
serial = Build.getSerial();
|
||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
|
||||
serial = Build.SERIAL;
|
||||
} else {//8.0-
|
||||
Class<?> c = Class.forName("android.os.SystemProperties");
|
||||
Method get = c.getMethod("get", String.class);
|
||||
serial = (String) get.invoke(c, "ro.serialno");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("e", "读取设备序列号异常:" + e);
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
// MD5 设备地址标识
|
||||
public static String getMAC(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // 如果当前设备系统大于等于6.0 使用下面的方法
|
||||
return getMac();
|
||||
} else {
|
||||
try {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
// 获取MAC地址
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
String mac = wifiInfo.getMacAddress();
|
||||
if (null == mac) {
|
||||
// 未获取到
|
||||
mac = "";
|
||||
}
|
||||
return mac;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机的MAC地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getMac() {
|
||||
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);
|
||||
while (null != str) {
|
||||
str = input.readLine();
|
||||
if (str != null) {
|
||||
macSerial = str.trim();// 去空格
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (macSerial == null || "".equals(macSerial)) {
|
||||
try {
|
||||
return loadFileAsString("/sys/class/net/eth0/address")
|
||||
.toUpperCase().substring(0, 17);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
macSerial = getAndroid7MAC();
|
||||
}
|
||||
}
|
||||
return macSerial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容7.0获取不到的问题
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getAndroid7MAC() {
|
||||
try {
|
||||
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
|
||||
for (NetworkInterface nif : all) {
|
||||
if (!"wlan0".equalsIgnoreCase(nif.getName()))
|
||||
continue;
|
||||
byte[] macBytes = nif.getHardwareAddress();
|
||||
if (macBytes == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder res1 = new StringBuilder();
|
||||
for (byte b : macBytes) {
|
||||
res1.append(String.format("%02X:", b));
|
||||
}
|
||||
if (res1.length() > 0) {
|
||||
res1.deleteCharAt(res1.length() - 1);
|
||||
}
|
||||
return res1.toString();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String loadFileAsString(String fileName) throws Exception {
|
||||
FileReader reader = new FileReader(fileName);
|
||||
String text = loadReaderAsString(reader);
|
||||
reader.close();
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String loadReaderAsString(Reader reader) throws Exception {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
char[] buffer = new char[4096];
|
||||
int readLength = reader.read(buffer);
|
||||
while (readLength >= 0) {
|
||||
builder.append(buffer, 0, readLength);
|
||||
readLength = reader.read(buffer);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新应用白名单禁止升级
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
static synchronized public boolean writeDisableUpdateList(Context context) {
|
||||
//允许安装的app
|
||||
String now = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
||||
//禁止升级的app
|
||||
String upgrade_disallow = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE);
|
||||
//所有app
|
||||
String only_jgy_shortcut_list = Settings.System.getString(context.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST);
|
||||
MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
String overall_app_list = mmkv.decodeString(CommonConfig.AOLE_ACTION_OVERALL_APP, "");
|
||||
Log.e("writeDisableUpdateList", "aole_app_forbid: " + now);
|
||||
HashSet<String> nowList = new HashSet<>();
|
||||
HashSet<String> disallowList = new HashSet<>();
|
||||
HashSet<String> allList = new HashSet<>();
|
||||
HashSet<String> overallList = new HashSet<>();
|
||||
if (!TextUtils.isEmpty(now)) {
|
||||
nowList = new HashSet<>(Arrays.asList(now.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
if (!TextUtils.isEmpty(upgrade_disallow)) {
|
||||
disallowList = new HashSet<>(Arrays.asList(upgrade_disallow.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
|
||||
allList = new HashSet<>(Arrays.asList(only_jgy_shortcut_list.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
if (!TextUtils.isEmpty(overall_app_list)) {
|
||||
overallList = new HashSet<>(Arrays.asList(overall_app_list.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
Log.e("writeDisableUpdateList", "nowList: " + nowList);
|
||||
Log.e("writeDisableUpdateList", "upgrade_disallow: " + disallowList);
|
||||
Log.e("writeDisableUpdateList", "only_jgy_shortcut_list: " + allList);
|
||||
Log.e("writeDisableUpdateList", "overall_app_list: " + overallList);
|
||||
//合并
|
||||
allList.addAll(nowList);
|
||||
allList.addAll(overallList);
|
||||
|
||||
for (String s : disallowList) {
|
||||
if (ApkUtils.isAvailable(context, s)) {
|
||||
if (allList.remove(s)) {
|
||||
Log.e("writeDisableUpdateList", "remove :" + s);
|
||||
} else {
|
||||
Log.e("writeDisableUpdateList", "remove failed:" + s);
|
||||
}
|
||||
//去掉已经安装的
|
||||
} else {
|
||||
allList.add(s);
|
||||
//没有安装就加入进去
|
||||
//没有加入会导致安装后卸载不能再安装的情况
|
||||
}
|
||||
Log.e("writeDisableUpdateList", "allList:" + allList);
|
||||
}
|
||||
boolean writeSucceed = false;
|
||||
if (allList.size() > 0) {
|
||||
Log.e("writeDisableUpdateList", "allList: " + allList);
|
||||
String list = String.join(",", allList);
|
||||
writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, list);
|
||||
Log.e("writeDisableUpdateList", "aole_app_forbid: " + list);
|
||||
} else {
|
||||
writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, "");
|
||||
}
|
||||
return writeSucceed;
|
||||
/*功能和应用安装白名单一样,首先会写入所有的app名单。
|
||||
*如果已经安装就从白名单删除,没有安装的不用删除
|
||||
*不然会出现安装不上的情况
|
||||
*在写入白名单之后和安装完成之后执行
|
||||
*/
|
||||
}
|
||||
|
||||
public static String getIMEI(Context context) {
|
||||
String IMEI = "unknow";
|
||||
String IMEI1, IMEI2, IMEI3;
|
||||
//获取手机设备号
|
||||
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
//8.0及以后版本获取
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
IMEI = TelephonyMgr.getDeviceId();
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
// try {
|
||||
// Method method = TelephonyMgr.getClass().getMethod("getImei");
|
||||
// IMEI = (String) method.invoke(TelephonyMgr);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// Log.e("getIMEI", e.getMessage());
|
||||
// }
|
||||
// IMEI = TelephonyMgr.getDeviceId();
|
||||
|
||||
// } else {//9.0到10.0获取
|
||||
IMEI = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
// Log.e("IMEI:", "IMEI: " + IMEI);
|
||||
if (null == IMEI) {
|
||||
return "-";
|
||||
} else {
|
||||
return IMEI.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAndroiodScreenProperty(Context context) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||
int width = dm.widthPixels; // 屏幕宽度(像素)
|
||||
int height = dm.heightPixels; // 屏幕高度(像素)
|
||||
float density = dm.density; // 屏幕密度(0.75 / 1.0 / 1.5)
|
||||
int densityDpi = dm.densityDpi; // 屏幕密度dpi(120 / 160 / 240)
|
||||
// 屏幕宽度算法:屏幕宽度(像素)/屏幕密度
|
||||
int screenWidth = (int) (width / density); // 屏幕宽度(dp)
|
||||
int screenHeight = (int) (height / density);// 屏幕高度(dp)
|
||||
|
||||
// Log.e("h_bl", "屏幕宽度(像素):" + width);
|
||||
// Log.e("h_bl", "屏幕高度(像素):" + height);
|
||||
// Log.e("h_bl", "屏幕密度(0.75 / 1.0 / 1.5):" + density);
|
||||
// Log.e("h_bl", "屏幕密度dpi(120 / 160 / 240):" + densityDpi);
|
||||
// Log.e("h_bl", "屏幕宽度(dp):" + screenWidth);
|
||||
// Log.e("h_bl", "屏幕高度(dp):" + screenHeight);
|
||||
return width + "×" + height;
|
||||
}
|
||||
|
||||
public static int getBattery(Context context) {
|
||||
try {
|
||||
BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "getBattery" + e.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电池容量
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static double getBatterymAh(Context context) {
|
||||
Object mPowerProfile;
|
||||
double batteryCapacity = 0; //电池的容量mAh
|
||||
final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile";
|
||||
try {
|
||||
mPowerProfile = Class.forName(POWER_PROFILE_CLASS).getConstructor(Context.class).newInstance(context);
|
||||
batteryCapacity = (double) Class.forName(POWER_PROFILE_CLASS).getMethod("getBatteryCapacity").invoke(mPowerProfile);
|
||||
Log.e("getBattery", "battery mAh: " + batteryCapacity);
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "get batteryCapacity mAh error:" + batteryCapacity);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return batteryCapacity;
|
||||
}
|
||||
|
||||
public static int getIsCharging(Context context) {
|
||||
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent batteryStatus = ReceiverCompat.registerReceiver(context, null, ifilter, ReceiverCompat.RECEIVER_NOT_EXPORTED);
|
||||
if (batteryStatus == null) {
|
||||
Log.e(TAG, "getIsCharging: 未获取到电量广播");
|
||||
return 0;
|
||||
}
|
||||
// Are we charging / charged?
|
||||
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
|
||||
// How are we charging?
|
||||
// int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
// boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
|
||||
// boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
|
||||
if (isCharging) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 已经使用
|
||||
*/
|
||||
public static long getUsedMemory(Context context) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
long freeMem = memoryInfo.totalMem - memoryInfo.availMem;
|
||||
// Log.e("getHardware", "getFreeMemory: " + freeMem);
|
||||
return freeMem;
|
||||
}
|
||||
|
||||
public static long getTotalMem(Context context) {
|
||||
// 获取android当前可用内存大小
|
||||
ActivityManager activityManager = (ActivityManager) context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
// 当前系统可用内存 ,将获得的内存大小规格化
|
||||
Log.e(TAG, "getTotalMem: " + memoryInfo.totalMem);
|
||||
return memoryInfo.totalMem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述:总内存.
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static long getTotalMemory(Context context) {
|
||||
// 系统内存信息文件
|
||||
String file = "/proc/meminfo";
|
||||
String memInfo;
|
||||
String[] strs;
|
||||
long memory = 0;
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReader(file);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader, 8192);
|
||||
// 读取meminfo第一行,系统内存大小
|
||||
memInfo = bufferedReader.readLine();
|
||||
strs = memInfo.split("\\s+");
|
||||
// for (String str : strs) {
|
||||
// L.d(AppUtil.class, str + "\t");
|
||||
// }
|
||||
// 获得系统总内存,单位KB
|
||||
memory = Integer.valueOf(strs[1]).intValue();
|
||||
bufferedReader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Byte转位KB或MB
|
||||
return memory * 1024;
|
||||
}
|
||||
|
||||
public static float getUse_space(Context context) {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long availableSize = sf.getAvailableBytes();
|
||||
Log.e(TAG, "getUse_space: availableSize = " + availableSize);
|
||||
long blockSize = sf.getBlockSize();
|
||||
Log.e(TAG, "getUse_space: blockSize = " + blockSize);
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
Log.e(TAG, "getUse_space: totalBlocks = " + totalBlocks);
|
||||
|
||||
return (float) 100.0 * ((blockSize * totalBlocks) - availableSize) / (blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
public static String getUsedSize(Context context) {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long availableSize = sf.getAvailableBytes();
|
||||
long blockSize = sf.getBlockSize();
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks - availableSize);
|
||||
}
|
||||
|
||||
public static String getDataTotalSize(Context context) {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long blockSize = sf.getBlockSize();
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
private static int getNumCores() {
|
||||
// Private Class to display only CPU devices in the directory listing
|
||||
class CpuFilter implements FileFilter {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
// Check if filename is "cpu", followed by a single digit number
|
||||
return Pattern.matches("cpu[0-9]", pathname.getName());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Get directory containing CPU info
|
||||
File dir = new File("/sys/devices/system/cpu/");
|
||||
// Filter to only list the devices we care about
|
||||
File[] files = dir.listFiles(new CpuFilter());
|
||||
// Return the number of cores (virtual CPU devices)
|
||||
return files.length;
|
||||
} catch (Exception e) {
|
||||
// Default to return 1 core
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMachine(Context context) {
|
||||
String device = Build.MODEL;//机型
|
||||
String imei = getIMEI(context);
|
||||
Log.e(TAG, "getMachine: " + imei);
|
||||
String system_version = Build.VERSION.RELEASE;
|
||||
String firmware_version = JgyUtils.getRomVersion();
|
||||
String rom = JgyUtils.getCustomVersion();
|
||||
|
||||
String screen_rate = getAndroiodScreenProperty(context);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("device", device);
|
||||
jsonObject.addProperty("imei", imei);
|
||||
jsonObject.addProperty("system_version", system_version);
|
||||
jsonObject.addProperty("firmware_version", firmware_version);
|
||||
jsonObject.addProperty("rom", rom);
|
||||
jsonObject.addProperty("screen_rate", screen_rate);
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public static String getHardware(Context context) {
|
||||
int electric = getBattery(context);
|
||||
int charging = getIsCharging(context);
|
||||
String memory = Formatter.formatFileSize(context, getUsedMemory(context)) + "\t 已用" + "/" + "共" + Formatter.formatFileSize(context, getTotalMemory(context));
|
||||
Log.e(TAG, "getHardware: memory = " + memory);
|
||||
int use_ram = (int) ((float) (1.0 * getUsedMemory(context)) / (1.0 * getTotalMemory(context)) * 100);
|
||||
Log.e(TAG, "getHardware: use_ram = " + use_ram);
|
||||
String storage = getUsedSize(context) + "/" + getDataTotalSize(context);
|
||||
Log.e(TAG, "getHardware: storage = " + storage);
|
||||
double use_space = getUse_space(context);
|
||||
Log.e(TAG, "getHardware: use_space = " + use_space);
|
||||
long wifi_time = (long) com.fuying.sn.core.data.local.prefs.SPUtils.get(context, "wifi_last_connect_time", 0L) / 1000;
|
||||
Log.e(TAG, "getHardware: wifi_time" + wifi_time);
|
||||
int CPU = getNumCores();
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||
// WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
WifiInfo info = wifiManager.getConnectionInfo();
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("electric", electric);
|
||||
jsonObject.addProperty("charging", charging);
|
||||
jsonObject.addProperty("memory", memory);
|
||||
jsonObject.addProperty("mac", getMAC(context));
|
||||
jsonObject.addProperty("storage", storage);
|
||||
jsonObject.addProperty("is_wifi", JgyUtils.getInstance().isWifiConnect());
|
||||
jsonObject.addProperty("CPU", CPU + "核");
|
||||
jsonObject.addProperty("use_space", use_space);
|
||||
jsonObject.addProperty("use_ram", use_ram);
|
||||
jsonObject.addProperty("wifi_ssid", getWifiSSID(context));
|
||||
jsonObject.addProperty("wifi_time", wifi_time);
|
||||
// jsonObject.addProperty("boot_time", SystemClock.elapsedRealtime());
|
||||
jsonObject.addProperty("boot_time", 0);
|
||||
jsonObject.addProperty("battery_capacity", getBatterymAh(context));
|
||||
// jsonObject.addProperty("wifi_signal", info.getRssi());
|
||||
jsonObject.addProperty("wifi_signal", 0);
|
||||
jsonObject.addProperty("bluetooth", getBluetoothList());
|
||||
Log.e(TAG, "getHardware: " + jsonObject);
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public static String getWifiSSID(Context context) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo != null) {
|
||||
return wifiInfo.getSSID();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getBluetoothList() {
|
||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bluetoothAdapter == null) {
|
||||
return "没有蓝牙设备";
|
||||
} else {
|
||||
if (!bluetoothAdapter.isEnabled())//判断蓝牙设备是否已开起
|
||||
{
|
||||
return "蓝牙未开启";
|
||||
// //开起蓝牙设备
|
||||
// Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||
// context.startActivity(intent);
|
||||
} else {
|
||||
Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Iterator<BluetoothDevice> iterator = devices.iterator(); iterator.hasNext(); ) {
|
||||
BluetoothDevice device = iterator.next();
|
||||
stringBuilder.append(device.getAlias()).append(";");
|
||||
}
|
||||
Log.e(TAG, "getBluetoothList: " + stringBuilder);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void killBackgroundApp(Context context) {
|
||||
List<String> pkgList = ApkUtils.queryFilterAppList(context);
|
||||
for (String pkg : pkgList) {
|
||||
if (runningAppWhitelist.contains(pkg)) continue;
|
||||
SystemUtils.killBackgroundProcesses(context, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> runningAppWhitelist = new ArrayList<String>() {{
|
||||
this.add(BuildConfig.APPLICATION_ID);
|
||||
this.add("com.android.settings");
|
||||
this.add("com.android.launcher3");
|
||||
this.add("com.fuying.appstore");
|
||||
this.add("com.uiui.info");
|
||||
this.add("com.uiui.os");
|
||||
this.add("com.uiui.aios");
|
||||
this.add("com.uiui.browser");
|
||||
this.add("com.uiui.health");
|
||||
}};
|
||||
|
||||
|
||||
|
||||
|
||||
public static String getWifiAlias(Context context) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo.getSSID() == null) {
|
||||
return "WiFi未连接";
|
||||
} else {
|
||||
Log.e(TAG, "getWifiAlias: " + wifiInfo.getSSID());
|
||||
return wifiInfo.getSSID();
|
||||
}
|
||||
}
|
||||
|
||||
/*重启自身*/
|
||||
public static void triggerRebirth(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
|
||||
ComponentName componentName = intent.getComponent();
|
||||
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
|
||||
context.startActivity(mainIntent);
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
}
|
||||
package com.fuying.sn.core.common.device;
|
||||
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.StatFs;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 硬件与资源信息读取。
|
||||
*
|
||||
* <p>由原 {@code Utils} 按职责拆出:屏幕、电池、内存、存储、CPU、WiFi、蓝牙等信息采集,
|
||||
* 与设备标识({@link DeviceIdUtils})分离。
|
||||
*/
|
||||
public class HardwareInfoUtils {
|
||||
private static final String TAG = "HardwareInfoUtils";
|
||||
|
||||
public static String getAndroiodScreenProperty(Context context) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||
int width = dm.widthPixels; // 屏幕宽度(像素)
|
||||
int height = dm.heightPixels; // 屏幕高度(像素)
|
||||
float density = dm.density; // 屏幕密度(0.75 / 1.0 / 1.5)
|
||||
int densityDpi = dm.densityDpi; // 屏幕密度dpi(120 / 160 / 240)
|
||||
// 屏幕宽度算法:屏幕宽度(像素)/屏幕密度
|
||||
int screenWidth = (int) (width / density); // 屏幕宽度(dp)
|
||||
int screenHeight = (int) (height / density);// 屏幕高度(dp)
|
||||
|
||||
// Log.e("h_bl", "屏幕宽度(像素):" + width);
|
||||
// Log.e("h_bl", "屏幕高度(像素):" + height);
|
||||
// Log.e("h_bl", "屏幕密度(0.75 / 1.0 / 1.5):" + density);
|
||||
// Log.e("h_bl", "屏幕密度dpi(120 / 160 / 240):" + densityDpi);
|
||||
// Log.e("h_bl", "屏幕宽度(dp):" + screenWidth);
|
||||
// Log.e("h_bl", "屏幕高度(dp):" + screenHeight);
|
||||
return width + "×" + height;
|
||||
}
|
||||
|
||||
public static int getBattery(Context context) {
|
||||
try {
|
||||
BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "getBattery" + e.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电池容量
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static double getBatterymAh(Context context) {
|
||||
Object mPowerProfile;
|
||||
double batteryCapacity = 0; //电池的容量mAh
|
||||
final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile";
|
||||
try {
|
||||
mPowerProfile = Class.forName(POWER_PROFILE_CLASS).getConstructor(Context.class).newInstance(context);
|
||||
batteryCapacity = (double) Class.forName(POWER_PROFILE_CLASS).getMethod("getBatteryCapacity").invoke(mPowerProfile);
|
||||
Log.e("getBattery", "battery mAh: " + batteryCapacity);
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "get batteryCapacity mAh error:" + batteryCapacity);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return batteryCapacity;
|
||||
}
|
||||
|
||||
public static int getIsCharging(Context context) {
|
||||
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent batteryStatus = ReceiverCompat.registerReceiver(context, null, ifilter, ReceiverCompat.RECEIVER_NOT_EXPORTED);
|
||||
if (batteryStatus == null) {
|
||||
Log.e(TAG, "getIsCharging: 未获取到电量广播");
|
||||
return 0;
|
||||
}
|
||||
// Are we charging / charged?
|
||||
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
|
||||
// How are we charging?
|
||||
// int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
// boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
|
||||
// boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
|
||||
if (isCharging) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 已经使用
|
||||
*/
|
||||
public static long getUsedMemory(Context context) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
long freeMem = memoryInfo.totalMem - memoryInfo.availMem;
|
||||
// Log.e("getHardware", "getFreeMemory: " + freeMem);
|
||||
return freeMem;
|
||||
}
|
||||
|
||||
public static long getTotalMem(Context context) {
|
||||
// 获取android当前可用内存大小
|
||||
ActivityManager activityManager = (ActivityManager) context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
// 当前系统可用内存 ,将获得的内存大小规格化
|
||||
Log.e(TAG, "getTotalMem: " + memoryInfo.totalMem);
|
||||
return memoryInfo.totalMem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述:总内存.
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static long getTotalMemory(Context context) {
|
||||
// 系统内存信息文件
|
||||
String file = "/proc/meminfo";
|
||||
String memInfo;
|
||||
String[] strs;
|
||||
long memory = 0;
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReader(file);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader, 8192);
|
||||
// 读取meminfo第一行,系统内存大小
|
||||
memInfo = bufferedReader.readLine();
|
||||
strs = memInfo.split("\\s+");
|
||||
// for (String str : strs) {
|
||||
// L.d(AppUtil.class, str + "\t");
|
||||
// }
|
||||
// 获得系统总内存,单位KB
|
||||
memory = Integer.valueOf(strs[1]).intValue();
|
||||
bufferedReader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Byte转位KB或MB
|
||||
return memory * 1024;
|
||||
}
|
||||
|
||||
public static float getUse_space(Context context) {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long availableSize = sf.getAvailableBytes();
|
||||
Log.e(TAG, "getUse_space: availableSize = " + availableSize);
|
||||
long blockSize = sf.getBlockSize();
|
||||
Log.e(TAG, "getUse_space: blockSize = " + blockSize);
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
Log.e(TAG, "getUse_space: totalBlocks = " + totalBlocks);
|
||||
|
||||
return (float) 100.0 * ((blockSize * totalBlocks) - availableSize) / (blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
public static String getUsedSize(Context context) {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long availableSize = sf.getAvailableBytes();
|
||||
long blockSize = sf.getBlockSize();
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks - availableSize);
|
||||
}
|
||||
|
||||
public static String getDataTotalSize(Context context) {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long blockSize = sf.getBlockSize();
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
private static int getNumCores() {
|
||||
// Private Class to display only CPU devices in the directory listing
|
||||
class CpuFilter implements FileFilter {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
// Check if filename is "cpu", followed by a single digit number
|
||||
return Pattern.matches("cpu[0-9]", pathname.getName());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Get directory containing CPU info
|
||||
File dir = new File("/sys/devices/system/cpu/");
|
||||
// Filter to only list the devices we care about
|
||||
File[] files = dir.listFiles(new CpuFilter());
|
||||
// Return the number of cores (virtual CPU devices)
|
||||
return files.length;
|
||||
} catch (Exception e) {
|
||||
// Default to return 1 core
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMachine(Context context) {
|
||||
String device = Build.MODEL;//机型
|
||||
String imei = DeviceIdUtils.getIMEI(context);
|
||||
Log.e(TAG, "getMachine: " + imei);
|
||||
String system_version = Build.VERSION.RELEASE;
|
||||
String firmware_version = JgyUtils.getRomVersion();
|
||||
String rom = JgyUtils.getCustomVersion();
|
||||
|
||||
String screen_rate = getAndroiodScreenProperty(context);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("device", device);
|
||||
jsonObject.addProperty("imei", imei);
|
||||
jsonObject.addProperty("system_version", system_version);
|
||||
jsonObject.addProperty("firmware_version", firmware_version);
|
||||
jsonObject.addProperty("rom", rom);
|
||||
jsonObject.addProperty("screen_rate", screen_rate);
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public static String getHardware(Context context) {
|
||||
int electric = getBattery(context);
|
||||
int charging = getIsCharging(context);
|
||||
String memory = Formatter.formatFileSize(context, getUsedMemory(context)) + "\t 已用" + "/" + "共" + Formatter.formatFileSize(context, getTotalMemory(context));
|
||||
Log.e(TAG, "getHardware: memory = " + memory);
|
||||
int use_ram = (int) ((float) (1.0 * getUsedMemory(context)) / (1.0 * getTotalMemory(context)) * 100);
|
||||
Log.e(TAG, "getHardware: use_ram = " + use_ram);
|
||||
String storage = getUsedSize(context) + "/" + getDataTotalSize(context);
|
||||
Log.e(TAG, "getHardware: storage = " + storage);
|
||||
double use_space = getUse_space(context);
|
||||
Log.e(TAG, "getHardware: use_space = " + use_space);
|
||||
long wifi_time = (long) com.fuying.sn.core.data.local.prefs.SPUtils.get(context, "wifi_last_connect_time", 0L) / 1000;
|
||||
Log.e(TAG, "getHardware: wifi_time" + wifi_time);
|
||||
int CPU = getNumCores();
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||
// WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
WifiInfo info = wifiManager.getConnectionInfo();
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("electric", electric);
|
||||
jsonObject.addProperty("charging", charging);
|
||||
jsonObject.addProperty("memory", memory);
|
||||
jsonObject.addProperty("mac", DeviceIdUtils.getMAC(context));
|
||||
jsonObject.addProperty("storage", storage);
|
||||
jsonObject.addProperty("is_wifi", JgyUtils.getInstance().isWifiConnect());
|
||||
jsonObject.addProperty("CPU", CPU + "核");
|
||||
jsonObject.addProperty("use_space", use_space);
|
||||
jsonObject.addProperty("use_ram", use_ram);
|
||||
jsonObject.addProperty("wifi_ssid", getWifiSSID(context));
|
||||
jsonObject.addProperty("wifi_time", wifi_time);
|
||||
// jsonObject.addProperty("boot_time", SystemClock.elapsedRealtime());
|
||||
jsonObject.addProperty("boot_time", 0);
|
||||
jsonObject.addProperty("battery_capacity", getBatterymAh(context));
|
||||
// jsonObject.addProperty("wifi_signal", info.getRssi());
|
||||
jsonObject.addProperty("wifi_signal", 0);
|
||||
jsonObject.addProperty("bluetooth", getBluetoothList());
|
||||
Log.e(TAG, "getHardware: " + jsonObject);
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public static String getWifiSSID(Context context) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo != null) {
|
||||
return wifiInfo.getSSID();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getBluetoothList() {
|
||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bluetoothAdapter == null) {
|
||||
return "没有蓝牙设备";
|
||||
} else {
|
||||
if (!bluetoothAdapter.isEnabled())//判断蓝牙设备是否已开起
|
||||
{
|
||||
return "蓝牙未开启";
|
||||
// //开起蓝牙设备
|
||||
// Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||
// context.startActivity(intent);
|
||||
} else {
|
||||
Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Iterator<BluetoothDevice> iterator = devices.iterator(); iterator.hasNext(); ) {
|
||||
BluetoothDevice device = iterator.next();
|
||||
stringBuilder.append(device.getAlias()).append(";");
|
||||
}
|
||||
Log.e(TAG, "getBluetoothList: " + stringBuilder);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getWifiAlias(Context context) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo.getSSID() == null) {
|
||||
return "WiFi未连接";
|
||||
} else {
|
||||
Log.e(TAG, "getWifiAlias: " + wifiInfo.getSSID());
|
||||
return wifiInfo.getSSID();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import com.bumptech.glide.GlideBuilder;
|
||||
import com.bumptech.glide.annotation.GlideModule;
|
||||
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
|
||||
import com.bumptech.glide.module.AppGlideModule;
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.image;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
+35
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.io;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
@@ -10,6 +10,8 @@ import com.blankj.utilcode.util.EncryptUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.Reader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
@@ -149,4 +151,36 @@ public class FileUtils {
|
||||
.setExtendField(extendField)
|
||||
.create(); //启动下载
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文本文件全部内容。
|
||||
*
|
||||
* <p>原 {@code Utils} 中的文件读取方法,按职责并入本类。
|
||||
*
|
||||
* @param fileName 文件绝对路径
|
||||
* @return 文件文本内容
|
||||
*/
|
||||
public static String loadFileAsString(String fileName) throws Exception {
|
||||
FileReader reader = new FileReader(fileName);
|
||||
String text = loadReaderAsString(reader);
|
||||
reader.close();
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取字符流全部内容。
|
||||
*
|
||||
* @param reader 字符流,由调用方负责关闭
|
||||
* @return 流中的文本内容
|
||||
*/
|
||||
public static String loadReaderAsString(Reader reader) throws Exception {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
char[] buffer = new char[4096];
|
||||
int readLength = reader.read(buffer);
|
||||
while (readLength >= 0) {
|
||||
builder.append(buffer, 0, readLength);
|
||||
readLength = reader.read(buffer);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.system;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.core.common.ui;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
@@ -5,7 +5,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
import com.jakewharton.disklrucache.DiskLruCache;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.fuying.sn.core.data.remote;
|
||||
import android.content.Context;
|
||||
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.fuying.sn.core.data.remote.api.StatisticsApi;
|
||||
import com.fuying.sn.core.data.local.cache.RxCacheManager;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@@ -341,7 +341,7 @@ public final class DeviceRepository {
|
||||
* 设备信息优先使用内存缓存;成功网络响应写入磁盘,其他响应短时缓存并移除磁盘副本。
|
||||
*/
|
||||
public Observable<BaseResponse<SnInfo>> getSnInfoControl() {
|
||||
return withCache(getSnApi().getsninfo(Utils.getSerial()),
|
||||
return withCache(getSnApi().getsninfo(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.SN_INFO,
|
||||
response -> {
|
||||
if (response.code == 200 && response.data != null) {
|
||||
@@ -371,7 +371,7 @@ public final class DeviceRepository {
|
||||
* 页面读取系统设置时复用三秒内存缓存,并在内存未命中时使用磁盘与网络两级数据。
|
||||
*/
|
||||
public Observable<BaseResponse<SystemSettingsSet>> getSettingControl() {
|
||||
return withMultiLevelCache(getSettingsApi().getSetting(Utils.getSerial()),
|
||||
return withMultiLevelCache(getSettingsApi().getSetting(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.GET_SETTINGS, new TypeToken<BaseResponse<SystemSettingsSet>>() {
|
||||
}.getType(),
|
||||
TimeUnit.SECONDS.toMillis(3));
|
||||
@@ -383,7 +383,7 @@ public final class DeviceRepository {
|
||||
public Observable<BaseResponse<SystemSettingsSet>> fetchSystemSettings() {
|
||||
return scheduleForCache(UrlAddress.GET_SETTINGS, Observable.defer(() -> {
|
||||
synchronized (CACHE_LOCK) {
|
||||
return joinInFlight(SYSTEM_SETTINGS_REFRESH, getSettingsApi().getSetting(Utils.getSerial()),
|
||||
return joinInFlight(SYSTEM_SETTINGS_REFRESH, getSettingsApi().getSetting(DeviceIdUtils.getSerial()),
|
||||
response -> {
|
||||
});
|
||||
}
|
||||
@@ -391,23 +391,23 @@ public final class DeviceRepository {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> getForceInstallControl() {
|
||||
return schedule(getAppApi().getForceInstall(Utils.getSerial()));
|
||||
return schedule(getAppApi().getForceInstall(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<BrowserApiData>> getBrowserControl() {
|
||||
return schedule(getSettingsApi().getBrowser(Utils.getSerial()));
|
||||
return schedule(getSettingsApi().getBrowser(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<Label>> getLabelControl() {
|
||||
return schedule(getSettingsApi().getLabel(Utils.getSerial()));
|
||||
return schedule(getSettingsApi().getLabel(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppStart>>> getAppStartControl() {
|
||||
return schedule(getSnControlApi().getAppStatu(Utils.getSerial()));
|
||||
return schedule(getSnControlApi().getAppStatu(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> getQueryAllAppControl() {
|
||||
return schedule(getAppApi().getAllApp(Utils.getSerial()));
|
||||
return schedule(getAppApi().getAllApp(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<AppletQRCode>> getQRCodeApiControl() {
|
||||
@@ -415,11 +415,11 @@ public final class DeviceRepository {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getAppInsideControl() {
|
||||
return schedule(getSettingsApi().getAppInside(Utils.getSerial()));
|
||||
return schedule(getSettingsApi().getAppInside(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<CloudLessonSetting>> getCloudLessonSettingApiControl() {
|
||||
return schedule(getSettingsApi().getCloudLessonSetting(Utils.getSerial()));
|
||||
return schedule(getSettingsApi().getCloudLessonSetting(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<AppInfo>> getUpdateObservable(String packageName) {
|
||||
@@ -433,26 +433,26 @@ public final class DeviceRepository {
|
||||
|
||||
@Deprecated
|
||||
public Observable<BaseResponse<List<AppTimeControl>>> getAppTimeControlObservable() {
|
||||
return schedule(getSettingsApi().getAppTimeControl(Utils.getSerial()));
|
||||
return schedule(getSettingsApi().getAppTimeControl(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Observable<BaseResponse<MachineControl>> getMachineTimeControlObservable() {
|
||||
return schedule(getSettingsApi().getSnTimeControl(Utils.getSerial()));
|
||||
return schedule(getSettingsApi().getSnTimeControl(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getAppUsageRecordObservable(String pkg, String pkgName, Long open_time, Long close_time) {
|
||||
return schedule(getCommonApi().sendAppUsageRecord(Utils.getSerial(), pkg, pkgName, open_time, close_time));
|
||||
return schedule(getCommonApi().sendAppUsageRecord(DeviceIdUtils.getSerial(), pkg, pkgName, open_time, close_time));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<MyAppUsageBean>>> getMyAppListObservable() {
|
||||
return withCache(getAppApi().getMyAppList(Utils.getSerial()),
|
||||
return withCache(getAppApi().getMyAppList(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.GET_MY_APP_LIST,
|
||||
data -> CACHE_MANAGER.saveCache(UrlAddress.GET_MY_APP_LIST, data, CACHE_EXPIRE_ONE_MINUTE * 60));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppJump>>> getAppJumpObservable() {
|
||||
return schedule(getSnControlApi().getSNJump(Utils.getSerial()));
|
||||
return schedule(getSnControlApi().getSNJump(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<BlacklistBean>> getBlacklistObservable() {
|
||||
@@ -460,35 +460,35 @@ public final class DeviceRepository {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> getAdminAppObservable() {
|
||||
return schedule(getCommonApi().getAdminApp(Utils.getSerial()));
|
||||
return schedule(getCommonApi().getAdminApp(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<ScreenPassword>> getLockScreenPwdObservable() {
|
||||
return schedule(getSnControlApi().getLockScreenPwd(Utils.getSerial()));
|
||||
return schedule(getSnControlApi().getLockScreenPwd(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateLockScreenObservable() {
|
||||
return schedule(getSnControlApi().updateLockScreen(Utils.getSerial()));
|
||||
return schedule(getSnControlApi().updateLockScreen(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppAndWhiteBean>>> getAppAndWhiteApiObservable() {
|
||||
return schedule(getCommonApi().getAppAndWhite(Utils.getSerial()));
|
||||
return schedule(getCommonApi().getAppAndWhite(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SnBindState>> getSnBindObservable() {
|
||||
return schedule(getSnApi().getSnBind(Utils.getSerial()));
|
||||
return schedule(getSnApi().getSnBind(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SnRunLog>> getSnRunLogControl() {
|
||||
return schedule(getSnLogApi().getSnRunLog(Utils.getSerial()));
|
||||
return schedule(getSnLogApi().getSnRunLog(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SnTag>> getSnTag() {
|
||||
return schedule(getSnApi().getTag(Utils.getSerial()));
|
||||
return schedule(getSnApi().getTag(DeviceIdUtils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SnTimeControlInfo>> getSnTimeControlObservable() {
|
||||
return withMultiLevelCache(getControlApi().getSnTimeControl(Utils.getSerial()),
|
||||
return withMultiLevelCache(getControlApi().getSnTimeControl(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.SN_TIME_CONTROL,
|
||||
new TypeToken<BaseResponse<SnTimeControlInfo>>() {
|
||||
}.getType(),
|
||||
@@ -497,7 +497,7 @@ public final class DeviceRepository {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppTimeControlInfo>>> getAppTimeControlInfoObservable() {
|
||||
return withMultiLevelCache(getControlApi().getAppTimeControl(Utils.getSerial()),
|
||||
return withMultiLevelCache(getControlApi().getAppTimeControl(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.APP_TIME_CONTROL,
|
||||
new TypeToken<BaseResponse<List<AppTimeControlInfo>>>() {
|
||||
}.getType(),
|
||||
@@ -506,25 +506,25 @@ public final class DeviceRepository {
|
||||
}
|
||||
|
||||
public Observable<DeviceInfo> getDeviceInfoObservable() {
|
||||
return unwrap(schedule(getDeviceInfoApi().getDeviceInfo(Utils.getSerial())));
|
||||
return unwrap(schedule(getDeviceInfoApi().getDeviceInfo(DeviceIdUtils.getSerial())));
|
||||
}
|
||||
|
||||
|
||||
public Observable<BaseResponse> bindDevice(String id, int type) {
|
||||
return schedule(getSnInfoApi().getBindDevices(Utils.getSerial(), id, type));
|
||||
return schedule(getSnInfoApi().getBindDevices(DeviceIdUtils.getSerial(), id, type));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> uploadScreenshot(MultipartBody.Part body) {
|
||||
return schedule(getSnInfoApi().uploadScreenshot(Utils.getSerial(), body));
|
||||
return schedule(getSnInfoApi().uploadScreenshot(DeviceIdUtils.getSerial(), body));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> uploadControlScreenshot(MultipartBody.Part body) {
|
||||
return schedule(getSnInfoApi().getControlScreenshot(Utils.getSerial(), body));
|
||||
return schedule(getSnInfoApi().getControlScreenshot(DeviceIdUtils.getSerial(), body));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getScreenLockState() {
|
||||
return schedule(Observable.defer(() -> joinInFlight("screenLockState",
|
||||
getSnControlApi().getScreenshot(Utils.getSerial()), response -> {
|
||||
getSnControlApi().getScreenshot(DeviceIdUtils.getSerial()), response -> {
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ public final class DeviceRepository {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> reportInstalledApps(String json) {
|
||||
return schedule(getAppApi().installorRemove(Utils.getSerial(), json));
|
||||
return schedule(getAppApi().installorRemove(DeviceIdUtils.getSerial(), json));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<AppInfo>> checkAppUpdate(String packageName, String versionCode) {
|
||||
@@ -543,6 +543,6 @@ public final class DeviceRepository {
|
||||
|
||||
public Observable<BaseResponse> reportDeviceInfo(String address, String machine,
|
||||
String hardware, String software) {
|
||||
return schedule(getSnInfoApi().sendAdminSn(Utils.getSerial(), address, machine, hardware, software));
|
||||
return schedule(getSnInfoApi().sendAdminSn(DeviceIdUtils.getSerial(), address, machine, hardware, software));
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.fuying.sn.core.data.dto.statistics.ControlStatusCombined;
|
||||
import com.fuying.sn.core.data.dto.statistics.ControlStatusInfo;
|
||||
import com.fuying.sn.core.data.dto.statistics.RemainingTimeBean;
|
||||
import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.util.List;
|
||||
@@ -50,7 +50,7 @@ public class StatisticsRepository {
|
||||
|
||||
private Observable<BaseResponse<ControlStatusInfo>> getControlStatusResponse() {
|
||||
return DeviceRepository.getInstance().withMultiLevelCache(
|
||||
DeviceRepository.getInstance().getStatisticsApi().getControlStatus(Utils.getSerial()),
|
||||
DeviceRepository.getInstance().getStatisticsApi().getControlStatus(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.CONTROL_STATUS,
|
||||
new TypeToken<BaseResponse<ControlStatusInfo>>() {
|
||||
}.getType(),
|
||||
@@ -63,7 +63,7 @@ public class StatisticsRepository {
|
||||
|
||||
private Observable<BaseResponse<RemainingTimeBean>> getRemainingTimeResponse() {
|
||||
return DeviceRepository.getInstance().withMultiLevelCache(
|
||||
DeviceRepository.getInstance().getStatisticsApi().getRemainingTime(Utils.getSerial()),
|
||||
DeviceRepository.getInstance().getStatisticsApi().getRemainingTime(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.REMAINING_TIME,
|
||||
new TypeToken<BaseResponse<RemainingTimeBean>>() {
|
||||
}.getType(),
|
||||
@@ -101,7 +101,7 @@ public class StatisticsRepository {
|
||||
// 时间范围和列表范围都影响响应,也必须参与缓存和并发请求合并。
|
||||
String cacheKey = UrlAddress.APP_USE_TIME + "_" + query_type + "_" + is_all;
|
||||
return DeviceRepository.getInstance().withMultiLevelCache(
|
||||
DeviceRepository.getInstance().getStatisticsApi().getAppUseTime(Utils.getSerial(), query_type, is_all),
|
||||
DeviceRepository.getInstance().getStatisticsApi().getAppUseTime(DeviceIdUtils.getSerial(), query_type, is_all),
|
||||
cacheKey,
|
||||
new TypeToken<BaseResponse<AppUseTimeData>>() {
|
||||
}.getType(),
|
||||
@@ -110,7 +110,7 @@ public class StatisticsRepository {
|
||||
|
||||
public Observable<List<AppControlDetail>> getAppControlDetail() {
|
||||
return DeviceRepository.unwrap(DeviceRepository.getInstance().withMultiLevelCache(
|
||||
DeviceRepository.getInstance().getStatisticsApi().getAppControlDetail(Utils.getSerial()),
|
||||
DeviceRepository.getInstance().getStatisticsApi().getAppControlDetail(DeviceIdUtils.getSerial()),
|
||||
UrlAddress.APP_CONTROL_DETAIL,
|
||||
new TypeToken<BaseResponse<List<AppControlDetail>>>() {
|
||||
}.getType(),
|
||||
|
||||
@@ -24,7 +24,7 @@ import androidx.fragment.app.FragmentTransaction;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.core.base.BaseDialogFragment;
|
||||
import com.fuying.sn.databinding.FragmentDialogRestartBinding;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.platform.app.AppProcessUtils;
|
||||
|
||||
public class RestartFragment extends BaseDialogFragment {
|
||||
private static final String TAG = "RestartFragment";
|
||||
@@ -114,7 +114,7 @@ public class RestartFragment extends BaseDialogFragment {
|
||||
}
|
||||
|
||||
public void restart(View view) {
|
||||
Utils.triggerRebirth(mContext);
|
||||
AppProcessUtils.triggerRebirth(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.blankj.utilcode.util.ConvertUtils;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.feature.update.UpdateActivity;
|
||||
import com.fuying.sn.core.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.fuying.sn.core.base.mvvm.BaseMvvmFragment;
|
||||
import com.fuying.sn.core.data.dto.AppInfo;
|
||||
import com.fuying.sn.core.data.dto.DeviceInfo;
|
||||
import com.fuying.sn.core.data.dto.SnInfo;
|
||||
@@ -24,7 +24,8 @@ import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.databinding.FragmentDeviceBinding;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.jakewharton.rxbinding4.view.RxView;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -62,9 +63,9 @@ public class DeviceFragment extends BaseMvvmFragment<DeviceViewModel, FragmentDe
|
||||
|
||||
@Override
|
||||
protected void initView(Bundle bundle) {
|
||||
Log.e(TAG, "initView: byte2MemorySize = " + ConvertUtils.byte2MemorySize(Utils.getTotalMem(mContext), MemoryConstants.GB));
|
||||
Log.e(TAG, "initView: getTotalMem = " + ConvertUtils.byte2FitMemorySize(Utils.getTotalMem(mContext)));
|
||||
Log.e(TAG, "initView: getTotalMemory = " + Formatter.formatFileSize(mContext, Utils.getTotalMemory(mContext)));
|
||||
Log.e(TAG, "initView: byte2MemorySize = " + ConvertUtils.byte2MemorySize(HardwareInfoUtils.getTotalMem(mContext), MemoryConstants.GB));
|
||||
Log.e(TAG, "initView: getTotalMem = " + ConvertUtils.byte2FitMemorySize(HardwareInfoUtils.getTotalMem(mContext)));
|
||||
Log.e(TAG, "initView: getTotalMemory = " + Formatter.formatFileSize(mContext, HardwareInfoUtils.getTotalMemory(mContext)));
|
||||
|
||||
setDeviceInfo();
|
||||
|
||||
@@ -157,10 +158,10 @@ public class DeviceFragment extends BaseMvvmFragment<DeviceViewModel, FragmentDe
|
||||
}
|
||||
|
||||
private void setDeviceInfo() {
|
||||
mViewDataBinding.tvSn.setText(Utils.getSn());
|
||||
mViewDataBinding.tvImei.setText(Utils.getIMEI(mContext));
|
||||
mViewDataBinding.tvMac.setText(Utils.getMAC(mContext));
|
||||
mViewDataBinding.tvRam.setText(Math.ceil(ConvertUtils.byte2MemorySize(Utils.getTotalMem(mContext), MemoryConstants.GB)) + " GB");
|
||||
mViewDataBinding.tvSn.setText(DeviceIdUtils.getSn());
|
||||
mViewDataBinding.tvImei.setText(DeviceIdUtils.getIMEI(mContext));
|
||||
mViewDataBinding.tvMac.setText(DeviceIdUtils.getMAC(mContext));
|
||||
mViewDataBinding.tvRam.setText(Math.ceil(ConvertUtils.byte2MemorySize(HardwareInfoUtils.getTotalMem(mContext), MemoryConstants.GB)) + " GB");
|
||||
mViewDataBinding.tvAndroidVersion.setText("Android " + Build.VERSION.RELEASE);
|
||||
mViewDataBinding.tvBuildVersion.setText("V" + JgyUtils.getRomVersion());
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import com.fuying.sn.R;
|
||||
import com.fuying.sn.core.base.BaseFragment;
|
||||
import com.fuying.sn.core.base.mvvm.BaseMvvmActivity;
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.core.common.util.DebugPasswordVerifier;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.crypto.DebugPasswordVerifier;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.core.data.dto.BaseResponse;
|
||||
import com.fuying.sn.core.data.dto.SnInfo;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
|
||||
@@ -8,9 +8,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.fuying.sn.core.base.mvvm.BaseAndroidViewModel;
|
||||
import com.fuying.sn.core.common.util.BitmapUtils;
|
||||
import com.fuying.sn.core.common.util.CXAESUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.image.BitmapUtils;
|
||||
import com.fuying.sn.core.common.crypto.CXAESUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.data.dto.BaseResponse;
|
||||
import com.fuying.sn.core.data.dto.SnInfo;
|
||||
import com.fuying.sn.core.data.remote.RequestCompletion;
|
||||
@@ -57,7 +57,7 @@ public class HomeViewModel extends BaseAndroidViewModel {
|
||||
public MutableLiveData<Bitmap> mQRCodeData = new MutableLiveData<>();
|
||||
|
||||
public void getQRCode() {
|
||||
String encryptString = CXAESUtil.encrypt(Utils.getIMEI(getApplication()));
|
||||
String encryptString = CXAESUtil.encrypt(DeviceIdUtils.getIMEI(getApplication()));
|
||||
Log.e("getQRCode", "setImageAndText: " + encryptString);
|
||||
Bitmap bitmap = BitmapUtils.createQRImage(encryptString, 400, 400);
|
||||
mQRCodeData.setValue(bitmap);
|
||||
|
||||
@@ -28,10 +28,12 @@ import com.fuying.sn.R;
|
||||
import com.fuying.sn.core.base.mvvm.BaseMvvmActivity;
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.core.common.gson.GsonUtils;
|
||||
import com.fuying.sn.core.common.util.DebugPasswordVerifier;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.crypto.DebugPasswordVerifier;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.fuying.sn.platform.app.AppProcessUtils;
|
||||
import com.fuying.sn.core.data.dto.AppInfo;
|
||||
import com.fuying.sn.core.data.dto.BaseResponse;
|
||||
import com.fuying.sn.core.data.dto.SnInfo;
|
||||
@@ -101,7 +103,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void initView() {
|
||||
Utils.getAndroiodScreenProperty(this);
|
||||
HardwareInfoUtils.getAndroiodScreenProperty(this);
|
||||
|
||||
// Settings.Global.putInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
// Settings.Global.putInt(getContentResolver(), Settings.Global.ADB_ENABLED, 1);
|
||||
@@ -119,9 +121,9 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G13Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.iPlay50SEPlatform
|
||||
) {
|
||||
mViewDataBinding.tvImei.setText("SN:" + Utils.getSerial());
|
||||
mViewDataBinding.tvImei.setText("SN:" + DeviceIdUtils.getSerial());
|
||||
} else {
|
||||
mViewDataBinding.tvImei.setText("IMEI:" + Utils.getIMEI(MainActivity.this));
|
||||
mViewDataBinding.tvImei.setText("IMEI:" + DeviceIdUtils.getIMEI(MainActivity.this));
|
||||
}
|
||||
|
||||
mViewDataBinding.tvAppVersion.setText(BuildConfig.VERSION_NAME);
|
||||
@@ -137,8 +139,8 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
JgyUtils.getInstance().wakeUpAppstore();
|
||||
JgyUtils.getInstance().wakeUpUpdateTools();
|
||||
|
||||
Utils.getBattery(this);
|
||||
Utils.getBatterymAh(this);
|
||||
HardwareInfoUtils.getBattery(this);
|
||||
HardwareInfoUtils.getBatterymAh(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +242,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
Log.e(TAG, "getWeekDay: " + TimeUtils.inWeekDay(1627702095000L));
|
||||
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString());
|
||||
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString(1627702095000L));
|
||||
Log.e(TAG, "initData: sn = " + Utils.getSerial());
|
||||
Log.e(TAG, "initData: sn = " + DeviceIdUtils.getSerial());
|
||||
}
|
||||
if (DeviceManager.isDebugMode()) {
|
||||
Settings.System.putInt(getContentResolver(), CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 0);
|
||||
@@ -467,7 +469,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
}
|
||||
|
||||
public void restart(View view) {
|
||||
// Utils.triggerRebirth(MainActivity.this);
|
||||
// AppProcessUtils.triggerRebirth(MainActivity.this);
|
||||
new RestartFragment().show(getSupportFragmentManager(), "RestartFragment");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.fuying.sn.core.base.mvvm.BaseAndroidViewModel;
|
||||
import com.fuying.sn.core.common.util.BitmapUtils;
|
||||
import com.fuying.sn.core.common.util.CXAESUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.image.BitmapUtils;
|
||||
import com.fuying.sn.core.common.crypto.CXAESUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.data.dto.BaseResponse;
|
||||
import com.fuying.sn.core.data.dto.SnInfo;
|
||||
import com.fuying.sn.core.data.remote.RequestCompletion;
|
||||
@@ -63,7 +63,7 @@ public class MainViewModel extends BaseAndroidViewModel {
|
||||
public MutableLiveData<Bitmap> mQRCodeData = new MutableLiveData<>();
|
||||
|
||||
public void getQRCode() {
|
||||
String encryptString = CXAESUtil.encrypt(Utils.getIMEI(getAppContext()));
|
||||
String encryptString = CXAESUtil.encrypt(DeviceIdUtils.getIMEI(getAppContext()));
|
||||
Log.e("getQRCode", "setImageAndText: " + encryptString);
|
||||
Bitmap bitmap = BitmapUtils.createQRImage(encryptString, 400, 400);
|
||||
mQRCodeData.setValue(bitmap);
|
||||
|
||||
@@ -11,9 +11,9 @@ import android.widget.ImageView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.core.common.util.BitmapUtils;
|
||||
import com.fuying.sn.core.common.util.CXAESUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.image.BitmapUtils;
|
||||
import com.fuying.sn.core.common.crypto.CXAESUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
@@ -70,7 +70,7 @@ public class QRCodeFragment extends Fragment {
|
||||
mView = inflater.inflate(R.layout.fragment_qrcode, container, false);
|
||||
qr_code =mView.findViewById(R.id.qr_code);
|
||||
try {
|
||||
String encryptString = CXAESUtil.encrypt(Utils.getSerial());
|
||||
String encryptString = CXAESUtil.encrypt(DeviceIdUtils.getSerial());
|
||||
Bitmap bitmap = BitmapUtils.createQRImage(encryptString, 300, 300);
|
||||
qr_code.setImageBitmap(bitmap);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.feature.usage.detail.UsageDetailActivity;
|
||||
import com.fuying.sn.feature.usage.adapter.AppControlDetailAdapter;
|
||||
import com.fuying.sn.core.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.fuying.sn.core.base.mvvm.BaseMvvmFragment;
|
||||
import com.fuying.sn.core.data.dto.BaseResponse;
|
||||
import com.fuying.sn.core.data.dto.SystemSettings;
|
||||
import com.fuying.sn.core.data.dto.SystemSettingsSet;
|
||||
@@ -31,10 +31,10 @@ import com.fuying.sn.core.data.dto.statistics.ControlStatusCombined;
|
||||
import com.fuying.sn.core.data.dto.statistics.ControlStatusInfo;
|
||||
import com.fuying.sn.databinding.FragmentUsageBinding;
|
||||
import com.fuying.sn.platform.location.AmapManager;
|
||||
import com.fuying.sn.core.common.util.ScreenUtils;
|
||||
import com.fuying.sn.core.common.ui.ScreenUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
@@ -91,7 +91,7 @@ public class UsageFragment extends BaseMvvmFragment<UsageViewModel, FragmentUsag
|
||||
|
||||
@Override
|
||||
protected void initView(Bundle bundle) {
|
||||
mViewDataBinding.tvSn.setText("SN码:" + Utils.getSerial());
|
||||
mViewDataBinding.tvSn.setText("SN码:" + DeviceIdUtils.getSerial());
|
||||
mAppControlDetailAdapter = new AppControlDetailAdapter();
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getCtx());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
|
||||
@@ -14,8 +14,8 @@ import com.fuying.sn.core.base.mvvm.BaseMvvmActivity;
|
||||
import com.fuying.sn.core.data.dto.statistics.AppUseTimeData;
|
||||
import com.fuying.sn.core.data.dto.statistics.AppUseTimeInfo;
|
||||
import com.fuying.sn.databinding.ActivityUsageDetailBinding;
|
||||
import com.fuying.sn.core.common.util.ScreenUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ScreenUtils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
|
||||
@@ -48,9 +48,9 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.platform.control.AppWhitelistUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
|
||||
|
||||
@@ -518,7 +518,7 @@ public class ApkUtils {
|
||||
Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, String.join(",", factoryAppList));
|
||||
Log.e("writeAppPackageList", "writeAppPackageList is null:");
|
||||
}
|
||||
Utils.writeDisableUpdateList(context);
|
||||
AppWhitelistUtils.writeDisableUpdateList(context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.fuying.sn.platform.app;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用进程操作。
|
||||
*
|
||||
* <p>由原 {@code Utils} 按职责拆出:清理后台应用与重启自身都属于应用生命周期操作,
|
||||
* 与设备信息采集无关。
|
||||
*/
|
||||
public class AppProcessUtils {
|
||||
|
||||
public static void killBackgroundApp(Context context) {
|
||||
List<String> pkgList = ApkUtils.queryFilterAppList(context);
|
||||
for (String pkg : pkgList) {
|
||||
if (runningAppWhitelist.contains(pkg)) continue;
|
||||
SystemUtils.killBackgroundProcesses(context, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> runningAppWhitelist = new ArrayList<String>() {{
|
||||
this.add(BuildConfig.APPLICATION_ID);
|
||||
this.add("com.android.settings");
|
||||
this.add("com.android.launcher3");
|
||||
this.add("com.fuying.appstore");
|
||||
this.add("com.uiui.info");
|
||||
this.add("com.uiui.os");
|
||||
this.add("com.uiui.aios");
|
||||
this.add("com.uiui.browser");
|
||||
this.add("com.uiui.health");
|
||||
}};
|
||||
|
||||
/*重启自身*/
|
||||
public static void triggerRebirth(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
|
||||
ComponentName componentName = intent.getComponent();
|
||||
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
|
||||
context.startActivity(mainIntent);
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
}
|
||||
@@ -43,9 +43,9 @@ import com.fuying.sn.runtime.sync.RequestCallbacks;
|
||||
import com.fuying.sn.runtime.sync.TimePolicySync;
|
||||
import com.fuying.sn.platform.app.AppUsedTimeUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.fuying.sn.platform.control;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* 应用白名单写入。
|
||||
*
|
||||
* <p>由原 {@code Utils} 按职责拆出:写入 {@code aole_app_forbid} 属于管控动作,
|
||||
* 与设备信息读取无关。
|
||||
*/
|
||||
public class AppWhitelistUtils {
|
||||
|
||||
/**
|
||||
* 更新应用白名单禁止升级
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
static synchronized public boolean writeDisableUpdateList(Context context) {
|
||||
//允许安装的app
|
||||
String now = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
||||
//禁止升级的app
|
||||
String upgrade_disallow = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE);
|
||||
//所有app
|
||||
String only_jgy_shortcut_list = Settings.System.getString(context.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST);
|
||||
MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
String overall_app_list = mmkv.decodeString(CommonConfig.AOLE_ACTION_OVERALL_APP, "");
|
||||
Log.e("writeDisableUpdateList", "aole_app_forbid: " + now);
|
||||
HashSet<String> nowList = new HashSet<>();
|
||||
HashSet<String> disallowList = new HashSet<>();
|
||||
HashSet<String> allList = new HashSet<>();
|
||||
HashSet<String> overallList = new HashSet<>();
|
||||
if (!TextUtils.isEmpty(now)) {
|
||||
nowList = new HashSet<>(Arrays.asList(now.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
if (!TextUtils.isEmpty(upgrade_disallow)) {
|
||||
disallowList = new HashSet<>(Arrays.asList(upgrade_disallow.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
|
||||
allList = new HashSet<>(Arrays.asList(only_jgy_shortcut_list.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
if (!TextUtils.isEmpty(overall_app_list)) {
|
||||
overallList = new HashSet<>(Arrays.asList(overall_app_list.trim().replaceAll(" ", "").split(",")));
|
||||
}
|
||||
Log.e("writeDisableUpdateList", "nowList: " + nowList);
|
||||
Log.e("writeDisableUpdateList", "upgrade_disallow: " + disallowList);
|
||||
Log.e("writeDisableUpdateList", "only_jgy_shortcut_list: " + allList);
|
||||
Log.e("writeDisableUpdateList", "overall_app_list: " + overallList);
|
||||
//合并
|
||||
allList.addAll(nowList);
|
||||
allList.addAll(overallList);
|
||||
|
||||
for (String s : disallowList) {
|
||||
if (ApkUtils.isAvailable(context, s)) {
|
||||
if (allList.remove(s)) {
|
||||
Log.e("writeDisableUpdateList", "remove :" + s);
|
||||
} else {
|
||||
Log.e("writeDisableUpdateList", "remove failed:" + s);
|
||||
}
|
||||
//去掉已经安装的
|
||||
} else {
|
||||
allList.add(s);
|
||||
//没有安装就加入进去
|
||||
//没有加入会导致安装后卸载不能再安装的情况
|
||||
}
|
||||
Log.e("writeDisableUpdateList", "allList:" + allList);
|
||||
}
|
||||
boolean writeSucceed = false;
|
||||
if (allList.size() > 0) {
|
||||
Log.e("writeDisableUpdateList", "allList: " + allList);
|
||||
String list = String.join(",", allList);
|
||||
writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, list);
|
||||
Log.e("writeDisableUpdateList", "aole_app_forbid: " + list);
|
||||
} else {
|
||||
writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, "");
|
||||
}
|
||||
return writeSucceed;
|
||||
/*功能和应用安装白名单一样,首先会写入所有的app名单。
|
||||
*如果已经安装就从白名单删除,没有安装的不用删除
|
||||
*不然会出现安装不上的情况
|
||||
*在写入白名单之后和安装完成之后执行
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import com.fuying.sn.core.data.dto.SystemSettings;
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.core.common.gson.GsonUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.platform.system.DeviceManager;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.fuying.sn.core.common.util;
|
||||
package com.fuying.sn.platform.control;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
@@ -8,7 +8,7 @@ import android.os.Build;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
|
||||
public class DeviceManager {
|
||||
private static final String TAG = "DeviceManager";
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.fuying.sn.runtime.sync.AppUsageReporter;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.platform.app.AppUsedTimeUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.hjq.toast.Toaster;
|
||||
|
||||
|
||||
@@ -45,13 +45,14 @@ import com.fuying.sn.runtime.sync.PushTagSync;
|
||||
import com.fuying.sn.runtime.sync.RemoteDiagnostics;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.platform.system.CmdUtil;
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.platform.app.AppProcessUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -1007,7 +1008,7 @@ public class PushManager {
|
||||
|
||||
private void killBackgroundApps() {
|
||||
ToastUtil.debugShow("收到推送消息: 内存优化");
|
||||
Utils.killBackgroundApp(mContext);
|
||||
AppProcessUtils.killBackgroundApp(mContext);
|
||||
}
|
||||
|
||||
private void setSOSPhoneNumber(String extras) {
|
||||
@@ -1553,7 +1554,7 @@ public class PushManager {
|
||||
*/
|
||||
public void doscreenshot() {
|
||||
String filePath = mContext.getExternalFilesDir("db").getAbsolutePath()
|
||||
+ File.separator + Utils.getSerial() + ".png";
|
||||
+ File.separator + DeviceIdUtils.getSerial() + ".png";
|
||||
getScreenshot(filePath)
|
||||
.map(code -> {
|
||||
File file = new File(filePath);
|
||||
|
||||
@@ -8,7 +8,7 @@ import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
|
||||
public class InstallResultReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "InstallResultReceiver";
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.fuying.sn.core.base.BaseService;
|
||||
import com.fuying.sn.core.data.dto.BaseResponse;
|
||||
import com.fuying.sn.core.data.repository.DeviceRepository;
|
||||
import com.fuying.sn.core.data.remote.BackgroundRequests;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -221,9 +221,9 @@ public class LogcatService extends BaseService {
|
||||
}
|
||||
|
||||
if (clear_file) {
|
||||
logFileName = Utils.getSerial() + ".log";
|
||||
logFileName = DeviceIdUtils.getSerial() + ".log";
|
||||
} else {
|
||||
logFileName = Utils.getSerial() + "-" + getTime() + ".log";
|
||||
logFileName = DeviceIdUtils.getSerial() + "-" + getTime() + ".log";
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -264,7 +264,7 @@ public class LogcatService extends BaseService {
|
||||
return;
|
||||
}
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("sn", Utils.getSerial());
|
||||
params.put("sn", DeviceIdUtils.getSerial());
|
||||
MediaType mediaType = MediaType.Companion.parse("text/html");
|
||||
RequestBody fileBody = RequestBody.Companion.create(file, mediaType);
|
||||
//设置一个file文件
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.runtime.push.PushManager;
|
||||
import com.fuying.sn.runtime.receiver.ApkInstallReceiver;
|
||||
import com.fuying.sn.runtime.receiver.BootReceiver;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
@@ -15,10 +15,10 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LifecycleService;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -313,7 +313,7 @@ public class SocketService extends LifecycleService implements NetworkUtils.OnNe
|
||||
}
|
||||
mConnecting = true;
|
||||
mConnectDisposable.set(Single.fromCallable(() -> new Request.Builder()
|
||||
.url(SOCKET_URL + Utils.getSerial())
|
||||
.url(SOCKET_URL + DeviceIdUtils.getSerial())
|
||||
.build())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -371,7 +371,7 @@ public class SocketService extends LifecycleService implements NetworkUtils.OnNe
|
||||
*/
|
||||
private boolean sendMsg(WebSocket webSocket) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("sn", Utils.getSerial());
|
||||
jsonObject.addProperty("sn", DeviceIdUtils.getSerial());
|
||||
jsonObject.addProperty("type", "ping");
|
||||
try {
|
||||
boolean sent = webSocket.send(jsonObject.toString());
|
||||
|
||||
@@ -45,12 +45,13 @@ import com.fuying.sn.runtime.sync.AppUsageReporter;
|
||||
import com.fuying.sn.runtime.sync.DeviceProfileSync;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.common.util.ReceiverCompat;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.util.ToastUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
@@ -106,7 +107,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
Log.e(TAG, "网络已连接");
|
||||
ToastUtil.show("网络已连接");
|
||||
String WiFiAlias = Utils.getWifiAlias(this);
|
||||
String WiFiAlias = HardwareInfoUtils.getWifiAlias(this);
|
||||
Log.e(TAG, "onConnected: WiFiAlias = " + WiFiAlias);
|
||||
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
@@ -220,7 +221,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
scheduleDeviceSync(true);
|
||||
mMMKV.encode(CommonConfig.DEVICES_REBOOT, false);
|
||||
|
||||
Log.e(TAG, "onCreate: IMEI = " + Utils.getIMEI(MainService.this));
|
||||
Log.e(TAG, "onCreate: IMEI = " + DeviceIdUtils.getIMEI(MainService.this));
|
||||
String aole_app_forbid = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
||||
Log.e(TAG, "onCreate: aole_app_forbid = " + aole_app_forbid);
|
||||
if (TextUtils.isEmpty(aole_app_forbid)) {
|
||||
@@ -457,7 +458,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
"connect to: " + newSSID + " time: "
|
||||
+ TimeUtils.transferLongToDate(System.currentTimeMillis()));
|
||||
}
|
||||
mMMKV.encode("WiFiSSID", Utils.getWifiAlias(context));
|
||||
mMMKV.encode("WiFiSSID", HardwareInfoUtils.getWifiAlias(context));
|
||||
}
|
||||
break;
|
||||
//wifi打开与否
|
||||
|
||||
@@ -26,10 +26,10 @@ import com.fuying.sn.core.data.remote.BackgroundRequests;
|
||||
import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.runtime.sync.RequestCallbacks.CompleteCallback;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.platform.control.AppWhitelistUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
@@ -186,7 +186,7 @@ public final class AppPolicySync {
|
||||
Log.e("setAppUpdate", "upgrade_allow: " + upgrade_allow);
|
||||
Log.e("setAppUpdate", "upgrade_disallow: " + upgrade_disallow);
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE, upgrade_disallow);
|
||||
Utils.writeDisableUpdateList(mContext);
|
||||
AppWhitelistUtils.writeDisableUpdateList(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import com.fuying.sn.core.common.gson.GsonUtils;
|
||||
import com.fuying.sn.core.data.remote.BackgroundRequests;
|
||||
import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.runtime.sync.RequestCallbacks.CompleteCallback;
|
||||
import com.fuying.sn.core.common.util.FileUtils;
|
||||
import com.fuying.sn.core.common.io.FileUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.platform.control.AppWhitelistUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@@ -394,7 +394,7 @@ public final class AppUpdateCoordinator {
|
||||
String packageList = overallAppBeanList.stream().map(OverallAppBean::getApp_package).collect(Collectors.joining(","));
|
||||
Log.e(TAG, "installOverallApp: " + packageList);
|
||||
mMMKV.encode(CommonConfig.AOLE_ACTION_OVERALL_APP, packageList);
|
||||
Utils.writeDisableUpdateList(mContext);
|
||||
AppWhitelistUtils.writeDisableUpdateList(mContext);
|
||||
Log.e(TAG, "installOverallApp: " + packageList);
|
||||
for (OverallAppBean overallAppBean : overallAppBeanList) {
|
||||
String packages = overallAppBean.getApp_package();
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.fuying.sn.core.data.dto.browser.BrowserBean;
|
||||
import com.fuying.sn.core.data.repository.DeviceRepository;
|
||||
import com.fuying.sn.core.data.remote.BackgroundRequests;
|
||||
import com.fuying.sn.runtime.sync.RequestCallbacks.CompleteCallback;
|
||||
import com.fuying.sn.core.common.util.UrlUtils;
|
||||
import com.fuying.sn.platform.control.UrlUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.data.local.prefs.SPUtils;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
@@ -162,8 +162,8 @@ public final class DeviceProfileSync {
|
||||
softwareJson.addProperty("desktop_version", ApkUtils.getAPPVersionName(mContext, "com.fuying.fuxiaoying"));
|
||||
|
||||
String addr = jsonObject.toString();
|
||||
String machine = Utils.getMachine(mContext);
|
||||
String hardware = Utils.getHardware(mContext);
|
||||
String machine = HardwareInfoUtils.getMachine(mContext);
|
||||
String hardware = HardwareInfoUtils.getHardware(mContext);
|
||||
String software = softwareJson.toString();
|
||||
JsonObject nowJson = new JsonObject();
|
||||
nowJson.addProperty("address", addr);
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.fuying.sn.core.data.repository.DeviceRepository;
|
||||
import com.fuying.sn.core.data.remote.BackgroundRequests;
|
||||
import com.fuying.sn.runtime.service.LogcatService;
|
||||
import com.fuying.sn.platform.system.CmdUtil;
|
||||
import com.fuying.sn.core.common.util.Utils;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -78,7 +78,7 @@ public final class RemoteDiagnostics {
|
||||
public void screenshot() {
|
||||
// String path = mContext.getExternalFilesDir("db").getAbsolutePath();
|
||||
String path = ContextCompat.getExternalFilesDirs(mContext, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath();
|
||||
String filePath = path + File.separator + Utils.getSerial() + ".png";
|
||||
String filePath = path + File.separator + DeviceIdUtils.getSerial() + ".png";
|
||||
getScreenshot(filePath).concatMap(new Function<Integer, ObservableSource<BaseResponse>>() {
|
||||
@Override
|
||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||
|
||||
Reference in new issue
Block a user