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