refactor(layer): core 层工具类去除对 platform 的反向依赖

新增 AppEnvironment 注入 Application 上下文与调试开关;ToastUtil、DeviceIdUtils、HardwareInfoUtils 改用 core 层实现,JgyUtils 的版本号与设备号逻辑以委托/迁移方式保留;FileUtils 的下载安装逻辑随安装能力迁入 ApkUtils。core/common 已无 platform 依赖,仅剩 BaseApplication 作为组装根。
This commit is contained in:
tongtong committed 2026-11-11 20:09:51 +08:00
1 parent 5dbee71a90
commit bdbd97e113
13 files changed
+292 -179

No files matched your search

@@ -15,6 +15,7 @@ import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.arialyy.aria.core.Aria;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.core.common.sync.DeviceSyncGateways;
import com.fuying.sn.core.common.system.AppEnvironment;
import com.fuying.sn.core.data.repository.DeviceRepository;
import com.fuying.sn.platform.app.RunningAppManager;
import com.fuying.sn.platform.time.TimeControlManager;
@@ -75,6 +76,8 @@ public class BaseApplication extends Application {
public void onCreate() {
super.onCreate();
sInstance = this;
// core 层工具类通过这里获取 Application 上下文,避免 core 反向依赖 platform。
AppEnvironment.init(this);
//非主进程不初始化
if (SystemUtils.isMainProcessName(this, android.os.Process.myPid())) {
if (BuildConfig.DEBUG) {
@@ -9,7 +9,7 @@ import android.telephony.TelephonyManager;
import android.util.Log;
import com.fuying.sn.core.common.io.FileUtils;
import com.fuying.sn.platform.system.JgyUtils;
import com.fuying.sn.core.common.system.AppEnvironment;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
@@ -33,12 +33,40 @@ public class DeviceIdUtils {
* @return
*/
public static String getSerial() {
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G13Platform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.iPlay50SEPlatform
int platformCode = PlatformUtils.getPlatformCode();
if (platformCode == PlatformUtils.G13_PLATFORM
|| platformCode == PlatformUtils.IPLAY50SE_PLATFORM
) {
return getSn();
} else {
return JgyUtils.getInstance().getIMEI();
return getSystemImei(AppEnvironment.getContext());
}
}
/**
* 读取设备号。
*
* <p>逻辑原样迁自 platform 层 JgyUtils#getIMEI:8.0 分支读的是 {@link Settings.System},
* 与 {@link #getIMEI(Context)} 使用的 {@link Settings.Secure} 并不等价,
* 统一改动会导致已有设备的 SN 变化,因此这里保持原样。
*
* @param context 上下文
* @return 设备号,取不到时返回 "-"
*/
private static String getSystemImei(Context context) {
String IMEI = "unknow";
//获取手机设备号
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) {
IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
if (null == IMEI) {
return "-";
} else {
return IMEI.toUpperCase();
}
}
@@ -8,6 +8,8 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.BatteryManager;
@@ -19,7 +21,6 @@ import android.util.Log;
import android.view.WindowManager;
import com.fuying.sn.core.common.system.ReceiverCompat;
import com.fuying.sn.platform.system.JgyUtils;
import com.google.gson.JsonObject;
import java.io.BufferedReader;
@@ -225,8 +226,8 @@ public class HardwareInfoUtils {
String imei = DeviceIdUtils.getIMEI(context);
Log.e(TAG, "getMachine: " + imei);
String system_version = Build.VERSION.RELEASE;
String firmware_version = JgyUtils.getRomVersion();
String rom = JgyUtils.getCustomVersion();
String firmware_version = PlatformUtils.getRomVersion();
String rom = PlatformUtils.getCustomVersion();
String screen_rate = getAndroiodScreenProperty(context);
JsonObject jsonObject = new JsonObject();
@@ -263,7 +264,7 @@ public class HardwareInfoUtils {
jsonObject.addProperty("memory", memory);
jsonObject.addProperty("mac", DeviceIdUtils.getMAC(context));
jsonObject.addProperty("storage", storage);
jsonObject.addProperty("is_wifi", JgyUtils.getInstance().isWifiConnect());
jsonObject.addProperty("is_wifi", isWifiConnect(context));
jsonObject.addProperty("CPU", CPU + "核");
jsonObject.addProperty("use_space", use_space);
jsonObject.addProperty("use_ram", use_ram);
@@ -323,4 +324,24 @@ public class HardwareInfoUtils {
return wifiInfo.getSSID();
}
}
/**
* WiFi 是否已连接。
*
* <p>逻辑原样迁自 platform 层 JgyUtils#isWifiConnect,返回值含义保持 1=已连接、0=未连接。
*
* @param context 上下文
* @return 1 表示已连接,0 表示未连接
*/
private static int isWifiConnect(Context context) {
// 网络管理对象
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// 获取所有类型的链接管理对象
NetworkInfo info = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo.State state = info.getState();
if (NetworkInfo.State.CONNECTED == state) {
return 1;
}
return 0;
}
}
@@ -4,6 +4,8 @@ import android.util.Log;
import com.fuying.sn.BuildConfig;
import java.lang.reflect.Method;
/**
* 机型平台识别。
*
@@ -89,4 +91,60 @@ public final class PlatformUtils {
Log.e(TAG, "getPlatformCode: 没有数据");
return UNKNOWN_PLATFORM;
}
/**
* 读取固件版本号。
*
* <p>展锐与 M40SE 使用 {@code ro.build.id},其余机型使用 {@code ro.build.display.id}。
*
* @return 固件版本号,读取失败时返回“获取失败”
*/
public static String getRomVersion() {
int platformCode = getPlatformCode();
if (platformCode == ZHANRUI_PLATFORM || platformCode == M40SE_PLATFORM) {
return getSystemProperty("ro.build.id", "获取失败");
}
return getSystemProperty("ro.build.display.id", "获取失败");
}
/**
* 读取定制系统版本号。
*
* <p>展锐、M40SE、T30PRO、8515、G13、ipaly50SE、G6、G10J、G12NL 使用
* {@code ro.build.display.id},其余机型使用 {@code ro.custom.build.version}。
*
* @return 定制版本号,读取失败时返回“获取失败”
*/
public static String getCustomVersion() {
int platformCode = getPlatformCode();
if (platformCode == ZHANRUI_PLATFORM
|| platformCode == M40SE_PLATFORM
|| platformCode == T30PRO_PLATFORM
|| platformCode == MTK8515_PLATFORM
|| platformCode == G13_PLATFORM
|| platformCode == IPLAY50SE_PLATFORM
|| platformCode == G6_PLATFORM
|| platformCode == G11J_PLATFORM
|| platformCode == G12NL_PLATFORM) {
return getSystemProperty("ro.build.display.id", "获取失败");
}
return getSystemProperty("ro.custom.build.version", "获取失败");
}
/**
* 反射读取系统属性。
*
* <p>逻辑原样迁自 platform 层 JgyUtils#getProperty,保持反射实现不变。
*/
private static String getSystemProperty(String key, String defaultValue) {
String value = defaultValue;
try {
Class<?> clazz = Class.forName("android.os.SystemProperties");
Method get = clazz.getMethod("get", String.class, String.class);
value = (String) get.invoke(clazz, key, "unknown");
} catch (Exception e) {
Log.e(TAG, "getSystemProperty: 读取 " + key + " 失败, " + e.getMessage());
}
return value;
}
}
@@ -1,26 +1,15 @@
package com.fuying.sn.core.common.io;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.EncryptUtils;
import com.google.gson.JsonObject;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fuying.sn.platform.app.ApkUtils;
import com.fuying.sn.platform.system.JgyUtils;
public class FileUtils {
private static final String TAG = "FileUtils";
private static final String CACHE_DIR_NAME = "cache";
private static final Pattern MD5_PATTERN = Pattern.compile("[0-9a-fA-F]{32}");
/**
* 获取可用的缓存目录,优先应用专属外部缓存,外部存储不可用时回退内部缓存
@@ -67,91 +56,6 @@ public class FileUtils {
return dir.isDirectory() && dir.canWrite();
}
/**
* 从下载地址中取出文件名,自动去掉 ? 之后的查询参数
*
* @param url 下载地址
* @return 文件名,解析失败时返回空串
*/
@Deprecated
public static String getFileNamefromURL(String url) {
if (TextUtils.isEmpty(url)) {
return "";
}
String fileName = Uri.parse(url).getLastPathSegment();
if (TextUtils.isEmpty(fileName)) {
int position = url.lastIndexOf("/");
fileName = url.substring(position + 1);
}
int queryIndex = fileName.indexOf("?");
if (queryIndex >= 0) {
fileName = fileName.substring(0, queryIndex);
}
return fileName;
}
/**
* 从文件名中提取 32 位十六进制 MD5,兼容历史命名里的固定长度前缀
*
* @param fileName 文件名
* @return 提取到的 MD5,未匹配到时返回空串
*/
@Deprecated
public static String getMD5fromFileName(String fileName) {
if (TextUtils.isEmpty(fileName)) {
return "";
}
Matcher matcher = MD5_PATTERN.matcher(fileName);
if (matcher.find()) {
return matcher.group();
}
return "";
}
public static void ariaDownload(Context context, String url, JsonObject jsonObject) {
String fileName = getFileNamefromURL(url);
if (TextUtils.isEmpty(fileName)) {
Log.e(TAG, "ariaDownload: 无法从下载地址解析文件名 " + url);
return;
}
String expectedMD5 = "";
if (jsonObject != null) {
if (jsonObject.has("MD5") && !jsonObject.get("MD5").isJsonNull()) {
expectedMD5 = jsonObject.get("MD5").getAsString();
} else if (jsonObject.has("app_md5") && !jsonObject.get("app_md5").isJsonNull()) {
expectedMD5 = jsonObject.get("app_md5").getAsString();
}
}
//后端还没有完成json字段的MD5,字段缺失或格式不合法时按文件名获取
if (TextUtils.isEmpty(expectedMD5) || !MD5_PATTERN.matcher(expectedMD5).matches()) {
expectedMD5 = getMD5fromFileName(fileName);
}
String extendField = "";
if (jsonObject != null) {
extendField = jsonObject.toString();
}
Log.e(TAG, "ariaDownload: fileName=" + fileName + " expectedMD5=" + expectedMD5);
// 与下载落盘路径保持一致,避免检查公共目录导致已有文件永远命中不了
String downloadPath = JgyUtils.getInstance().getDownLoadPath();
File file = new File(downloadPath, fileName);
if (file.isFile() && !TextUtils.isEmpty(expectedMD5)) {
String fileMD5 = EncryptUtils.encryptMD5File2String(file);
Log.e(TAG, "ariaDownload: fileMD5=" + fileMD5 + " expectedMD5=" + expectedMD5);
if (expectedMD5.equalsIgnoreCase(fileMD5)) {
ApkUtils.installApp(context, file.getAbsolutePath());
return;
}
}
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(file.getAbsolutePath())
.ignoreFilePathOccupy()
.setExtendField(extendField)
.create(); //启动下载
}
/**
* 读取文本文件全部内容。
*
@@ -0,0 +1,53 @@
package com.fuying.sn.core.common.system;
import android.content.Context;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.core.common.config.CommonConfig;
import com.fuying.sn.core.data.local.prefs.SPUtils;
/**
* 应用运行环境。
*
* <p>core 层的工具类(设备标识、调试提示)需要 Application 上下文与调试开关,
* 但不能反向依赖 platform 层的管理器。这里由 BaseApplication 在启动时注入上下文,
* 统一对外提供,使 core 包内不再出现跨层依赖。
*/
public final class AppEnvironment {
private static volatile Context sContext;
private AppEnvironment() {
}
/**
* 注入 Application 上下文,只允许在 Application 启动阶段调用。
*
* @param context Application 上下文
*/
public static void init(Context context) {
sContext = context.getApplicationContext();
}
/**
* 获取 Application 上下文。
*
* @return 已注入的 Application 上下文
*/
public static Context getContext() {
Context context = sContext;
if (context == null) {
throw new IllegalStateException("AppEnvironment must be initialized first");
}
return context;
}
/**
* 是否处于调试模式:编译期调试包,或通过配置项临时开启。
*
* @return 调试模式返回 true
*/
public static boolean isDebugMode() {
return BuildConfig.DEBUG || (boolean) SPUtils.get(getContext(), CommonConfig.EnableDebug, false);
}
}
@@ -7,7 +7,7 @@ import android.view.Gravity;
import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.fuying.sn.R;
import com.fuying.sn.platform.system.DeviceManager;
import com.fuying.sn.core.common.system.AppEnvironment;
public class ToastUtil {
private static final String TAG = "ToastUtil";
@@ -22,7 +22,7 @@ public class ToastUtil {
}
public static void debugShow(final String msg) {
if (DeviceManager.isDebugMode()) {
if (AppEnvironment.isDebugMode()) {
ToastUtils.make()
.setBgColor(ColorUtils.getColor(R.color.toast_color))
.setTextColor(Color.RED)
@@ -13,6 +13,7 @@ import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Environment;
import android.os.RemoteException;
import android.provider.Settings;
import android.text.TextUtils;
@@ -21,10 +22,13 @@ import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.content.FileProvider;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.EncryptUtils;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.core.data.dto.AppInfo;
import com.fuying.sn.core.common.config.CommonConfig;
import com.fuying.sn.core.common.gson.GsonUtils;
import com.google.gson.JsonObject;
import java.io.BufferedReader;
import java.io.File;
@@ -39,6 +43,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
@@ -55,6 +61,7 @@ import com.fuying.sn.platform.system.JgyUtils;
public class ApkUtils {
private static final String TAG = "ApkUtils";
private static final Pattern MD5_PATTERN = Pattern.compile("[0-9a-fA-F]{32}");
private static final long MAX_WAIT_TIME = 60 * 1000;
@@ -604,7 +611,7 @@ public class ApkUtils {
e.printStackTrace();
}
if (packageInfo == null) {
FileUtils.ariaDownload(context, url, GsonUtils.getJsonObject(GsonUtils.toJSONString(appInfo)));
ariaDownload(context, url, GsonUtils.getJsonObject(GsonUtils.toJSONString(appInfo)));
} else {
long appVersionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@@ -613,7 +620,7 @@ public class ApkUtils {
appVersionCode = packageInfo.versionCode;
}
if (appVersionCode < versionCode) {
FileUtils.ariaDownload(context, url, GsonUtils.getJsonObject(GsonUtils.toJSONString(appInfo)));
ariaDownload(context, url, GsonUtils.getJsonObject(GsonUtils.toJSONString(appInfo)));
} else {
Log.e(TAG, "checkUpdate: " + packageName + "\t已经是最新版");
}
@@ -635,4 +642,97 @@ public class ApkUtils {
return "unknown";
}
/**
* 下载应用安装包;本地已有同 MD5 的安装包时直接安装,不再重复下载。
*
* <p>原位于 core 层 FileUtils,因需要安装能力而迁入 platform 层,避免 core 反向依赖 platform。
* 下载落盘路径与应用安装包目录保持一致。
*
* @param context 上下文
* @param url 安装包下载地址
* @param jsonObject 后端下发的应用信息,用于取 MD5 与透传给下载引擎
*/
public static void ariaDownload(Context context, String url, JsonObject jsonObject) {
String fileName = getFileNamefromURL(url);
if (TextUtils.isEmpty(fileName)) {
Log.e(TAG, "ariaDownload: 无法从下载地址解析文件名 " + url);
return;
}
String expectedMD5 = "";
if (jsonObject != null) {
if (jsonObject.has("MD5") && !jsonObject.get("MD5").isJsonNull()) {
expectedMD5 = jsonObject.get("MD5").getAsString();
} else if (jsonObject.has("app_md5") && !jsonObject.get("app_md5").isJsonNull()) {
expectedMD5 = jsonObject.get("app_md5").getAsString();
}
}
// 后端还没有完成 json 字段的 MD5,字段缺失或格式不合法时按文件名获取
if (TextUtils.isEmpty(expectedMD5) || !MD5_PATTERN.matcher(expectedMD5).matches()) {
expectedMD5 = getMD5fromFileName(fileName);
}
String extendField = "";
if (jsonObject != null) {
extendField = jsonObject.toString();
}
Log.e(TAG, "ariaDownload: fileName=" + fileName + " expectedMD5=" + expectedMD5);
String downloadPath = context.getExternalFilesDirs(Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath()
+ File.separator;
File file = new File(downloadPath, fileName);
if (file.isFile() && !TextUtils.isEmpty(expectedMD5)) {
String fileMD5 = EncryptUtils.encryptMD5File2String(file);
Log.e(TAG, "ariaDownload: fileMD5=" + fileMD5 + " expectedMD5=" + expectedMD5);
if (expectedMD5.equalsIgnoreCase(fileMD5)) {
installApp(context, file.getAbsolutePath());
return;
}
}
Aria.download(context)
.load(url) // 读取下载地址
.setFilePath(file.getAbsolutePath())
.ignoreFilePathOccupy()
.setExtendField(extendField)
.create(); // 启动下载
}
/**
* 从下载地址中取出文件名,自动去掉 ? 之后的查询参数。
*
* @param url 下载地址
* @return 文件名,解析失败时返回空串
*/
private static String getFileNamefromURL(String url) {
if (TextUtils.isEmpty(url)) {
return "";
}
String fileName = Uri.parse(url).getLastPathSegment();
if (TextUtils.isEmpty(fileName)) {
int position = url.lastIndexOf("/");
fileName = url.substring(position + 1);
}
int queryIndex = fileName.indexOf("?");
if (queryIndex >= 0) {
fileName = fileName.substring(0, queryIndex);
}
return fileName;
}
/**
* 从文件名中提取 32 位十六进制 MD5,兼容历史命名里的固定长度前缀。
*
* @param fileName 文件名
* @return 提取到的 MD5,未匹配到时返回空串
*/
private static String getMD5fromFileName(String fileName) {
if (TextUtils.isEmpty(fileName)) {
return "";
}
Matcher matcher = MD5_PATTERN.matcher(fileName);
if (matcher.find()) {
return matcher.group();
}
return "";
}
}
@@ -5,9 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.core.common.config.CommonConfig;
import com.fuying.sn.core.data.local.prefs.SPUtils;
import com.fuying.sn.core.common.system.AppEnvironment;
import com.fuying.sn.core.common.ui.ToastUtil;
public class DeviceManager {
@@ -39,7 +37,8 @@ public class DeviceManager {
* @return 是否为debug模式
*/
public static boolean isDebugMode() {
return BuildConfig.DEBUG || (boolean) SPUtils.get(mContext, CommonConfig.EnableDebug, false);
// 调试开关已下沉到 core 层,这里保留原入口供既有调用方使用。
return AppEnvironment.isDebugMode();
}
/**
@@ -414,29 +414,12 @@ public class JgyUtils {
}
public static String getCustomVersion() {
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.ZhanruiPlatform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.M40sePlatform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.T30ProPlatform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.MTK8515Platform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G13Platform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.iPlay50SEPlatform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G6Platform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G11JPlatform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G12NLPlatform
) {
return getProperty("ro.build.display.id", "获取失败");
} else {
return getProperty("ro.custom.build.version", "获取失败");
}
// 版本号读取逻辑已下沉到 core 层 PlatformUtils,这里保留原入口供既有调用方使用。
return PlatformUtils.getCustomVersion();
}
public static String getRomVersion() {
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.ZhanruiPlatform
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.M40sePlatform) {
return getProperty("ro.build.id", "获取失败");
} else {
return getProperty("ro.build.display.id", "获取失败");
}
return PlatformUtils.getRomVersion();
}
/**
@@ -819,38 +802,6 @@ public class JgyUtils {
mContext.sendBroadcast(bootIntent);
}
public String getIMEI() {
if (BuildConfig.DEBUG) {
// return "861918053899168";
}
String IMEI = "unknow";
String IMEI1, IMEI2, IMEI3;
//获取手机设备号
TelephonyManager TelephonyMgr = (TelephonyManager) mContext.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.System.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
}
// Log.e("IMEI:", "IMEI: " + IMEI);
if (null == IMEI) {
return "-";
} else {
return IMEI.toUpperCase();
}
}
public void oneKeyDisconnection() {
List<String> thirdPartyList = ApkUtils.queryFilterAppList(mContext);
thirdPartyList.addAll(fuxiaoyingApp);
@@ -44,7 +44,6 @@ import com.fuying.sn.runtime.sync.PushTagSync;
import com.fuying.sn.runtime.sync.RemoteDiagnostics;
import com.fuying.sn.platform.app.ApkUtils;
import com.fuying.sn.platform.system.CmdUtil;
import com.fuying.sn.core.common.io.FileUtils;
import com.fuying.sn.platform.system.JgyUtils;
import com.fuying.sn.core.data.local.prefs.SPUtils;
import com.fuying.sn.platform.system.SystemUtils;
@@ -1334,7 +1333,7 @@ public class PushManager {
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
FileUtils.ariaDownload(mContext, url, extra);
ApkUtils.ariaDownload(mContext, url, extra);
}
}, delay);
}
@@ -1423,7 +1422,7 @@ public class PushManager {
return;
}
if (!TextUtils.isEmpty(url)) {
FileUtils.ariaDownload(mContext, url, extra);
ApkUtils.ariaDownload(mContext, url, extra);
}
}
@@ -26,7 +26,6 @@ import com.fuying.sn.core.data.remote.BackgroundRequests;
import com.fuying.sn.core.data.remote.UrlAddress;
import com.fuying.sn.runtime.sync.RequestCallbacks.CompleteCallback;
import com.fuying.sn.platform.app.ApkUtils;
import com.fuying.sn.core.common.io.FileUtils;
import com.fuying.sn.platform.system.JgyUtils;
import com.fuying.sn.core.data.local.prefs.SPUtils;
import com.fuying.sn.platform.control.AppWhitelistUtils;
@@ -123,7 +122,7 @@ public final class AppPolicySync {
if (appVersionCode > onlineVersion && appVersionCode != 0) {
ApkUtils.uninstallApp(mContext, pkg);
JsonObject jsonObject = GsonUtils.getJsonObject(info.toString());
FileUtils.ariaDownload(mContext, info.getApp_url(), jsonObject);
ApkUtils.ariaDownload(mContext, info.getApp_url(), jsonObject);
Log.e(TAG, "checkPackageAndVersion: " + pkg + ": 卸载");
} else {
Log.e(TAG, "checkPackageAndVersion: " + pkg + ": 版本正常");
@@ -371,11 +370,11 @@ public final class AppPolicySync {
}
if (appVersionCode < appInfo.getApp_version_code()) {
JsonObject jsonObject = GsonUtils.getJsonObject(appInfo.toString());
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
ApkUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
}
} else {
JsonObject jsonObject = GsonUtils.getJsonObject(appInfo.toString());
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
ApkUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
}
}
String packageList = String.join(",", forceAppSet);
@@ -1,26 +1,24 @@
package com.fuying.sn.runtime.sync;
import static com.fuying.sn.runtime.sync.RequestCallbacks.asRequest;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.core.data.dto.AppInfo;
import com.fuying.sn.core.data.dto.BaseResponse;
import com.fuying.sn.core.data.dto.OverallAppBean;
import com.fuying.sn.core.common.config.CommonConfig;
import com.fuying.sn.core.data.repository.DeviceRepository;
import com.fuying.sn.platform.app.ApkUtils;
import com.fuying.sn.core.data.local.cache.CacheHelper;
import com.fuying.sn.core.common.gson.GsonUtils;
import com.fuying.sn.core.data.remote.BackgroundRequests;
import com.fuying.sn.core.data.remote.UrlAddress;
import com.fuying.sn.runtime.sync.RequestCallbacks.CompleteCallback;
import com.fuying.sn.core.common.io.FileUtils;
import com.fuying.sn.platform.system.JgyUtils;
import com.fuying.sn.platform.control.AppWhitelistUtils;
import com.google.gson.Gson;
@@ -147,7 +145,7 @@ public final class AppUpdateCoordinator {
AppInfo appInfo = appInfoBaseResponse.data;
if (appInfo != null) {
JsonObject jsonObject = GsonUtils.getJsonObject(appInfo.toString());
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
ApkUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
}
Log.e("checkUpdate", "update now");
} else {
@@ -317,7 +315,7 @@ public final class AppUpdateCoordinator {
String s = new Gson().toJson(entry.getValue());
Log.e(TAG, "getAllAppUpdate: install " + s);
JsonObject jsonObject = GsonUtils.getJsonObject(s);
FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject);
ApkUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject);
} else {
long appVersionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@@ -330,7 +328,7 @@ public final class AppUpdateCoordinator {
if (appVersionCode < versionCode) {
Log.e(TAG, "getAllAppUpdate: upgrade " + entry.getKey());
JsonObject jsonObject = GsonUtils.getJsonObject(new Gson().toJson(entry.getValue()));
FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject);
ApkUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject);
} else {
Log.e(TAG, "getAllAppUpdate: is up to date" + entry.getKey());
}
@@ -422,13 +420,13 @@ public final class AppUpdateCoordinator {
}
if (appVersionCode < app_version_code) {
Log.e(TAG, "installOverallApp: " + packages + " need to upgrade");
FileUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
ApkUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
} else {
Log.e(TAG, "installOverallApp: " + packages + " it's up to date , no need upgrade");
}
} else {
Log.e(TAG, "installOverallApp: " + packages + " not installed , upgrade");
FileUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
ApkUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
}
}
}