version:4.2
fix:修复不能自动下载强制应用,锁定状态显示问题,增加打开主页判断是否在请求 update:
This commit is contained in:
@@ -16,12 +16,10 @@ public class GsonUtils {
|
||||
}
|
||||
|
||||
// TODO: 2022/3/31 暂时没有实现
|
||||
public static <E> E getJsonFromType(String jsonString) {
|
||||
public static <T> T getJsonFromType(String jsonString, Class clazz) {
|
||||
Gson gson = new Gson();
|
||||
Type Type = new TypeToken<E>() {
|
||||
}.getType();
|
||||
E e = gson.fromJson(jsonString, Type);
|
||||
return e;
|
||||
T t = (T) gson.fromJson(jsonString, clazz);
|
||||
return t;
|
||||
}
|
||||
|
||||
public static String toJsonString(Object o) {
|
||||
|
||||
@@ -35,6 +35,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.comm.PackageNames;
|
||||
import com.aoleyun.sn.disklrucache.CacheHelper;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
import com.aoleyun.sn.network.UrlAddress;
|
||||
import com.aoleyun.sn.receiver.BootReceiver;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.google.gson.Gson;
|
||||
@@ -106,6 +109,9 @@ public class JGYUtils {
|
||||
public static String ZhanruiTag = "展锐cube";
|
||||
public static String Other = "其他";
|
||||
|
||||
private CacheHelper cacheHelper;
|
||||
|
||||
|
||||
static {
|
||||
System.loadLibrary("jgy");
|
||||
}
|
||||
@@ -115,7 +121,7 @@ public class JGYUtils {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
|
||||
this.cacheHelper = new CacheHelper(context);
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
@@ -173,6 +179,11 @@ public class JGYUtils {
|
||||
return path + File.separator;
|
||||
}
|
||||
|
||||
public boolean getDeviceIsLocked() {
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
|
||||
return locked == JGYActions.FRAME_CODE_LOCKED;
|
||||
}
|
||||
|
||||
public int getBatteryLevel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
BatteryManager batteryManager = (BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE);
|
||||
@@ -325,8 +336,6 @@ public class JGYUtils {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@@ -958,11 +967,26 @@ public class JGYUtils {
|
||||
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
|
||||
}
|
||||
|
||||
public void checkForceDownload() {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL_LIST);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
NetInterfaceManager.getInstance().getForceDownload();
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<ForceDownloadData>>() {
|
||||
}.getType();
|
||||
List<ForceDownloadData> forceDownloadData = gson.fromJson(jsonString, listType);
|
||||
if (forceDownloadData != null) {
|
||||
JGYUtils.getInstance().forceDownload(forceDownloadData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forceDownload(List<ForceDownloadData> data) {
|
||||
if (data == null || data.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
getSelfDownload(data);
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
ForceDownloadData forceDownloadData = data.get(i);
|
||||
@@ -1008,31 +1032,8 @@ public class JGYUtils {
|
||||
Utils.ariaDownload(mContext, app_url, jsonObject);
|
||||
}
|
||||
}
|
||||
SaveListUtils.setList(list);
|
||||
SaveListUtils.sendForceAPP(mContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取教管壹下载,没什么用了
|
||||
*
|
||||
* @param forceDownloadDataList
|
||||
*/
|
||||
private void getSelfDownload(List<ForceDownloadData> forceDownloadDataList) {
|
||||
for (ForceDownloadData forceDownloadData : forceDownloadDataList) {
|
||||
if (PackageNames.OLD_APPSTORE.equals(forceDownloadData.getApp_package())) {
|
||||
if (!ApkUtils.isAvailable(mContext, PackageNames.OLD_APPSTORE)) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("app_name", forceDownloadData.getApp_name());
|
||||
jsonObject.put("app_package", forceDownloadData.getApp_package());
|
||||
Utils.ariaDownload(mContext, forceDownloadData.getApp_url(), jsonObject);
|
||||
}
|
||||
} else {
|
||||
// Log.e("fht", "未上传应用");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param jsonObject 安装应用
|
||||
*/
|
||||
@@ -1150,14 +1151,10 @@ public class JGYUtils {
|
||||
versionCode = info.versionCode;
|
||||
}
|
||||
if (app_version_code > versionCode) {
|
||||
if (!SaveListUtils.isDownLoading(app_url)) {
|
||||
Utils.ariaDownload(mContext, app_url, jsonObject);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!SaveListUtils.isDownLoading(app_url)) {
|
||||
Utils.ariaDownload(mContext, app_url, jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.aoleyun.sn.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.blankj.utilcode.util.SPStaticUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SaveListUtils {
|
||||
private static List<String> downLoadList = new ArrayList<>();
|
||||
private static List<String> forceList = new ArrayList<>();
|
||||
|
||||
public static List<String> getList() {
|
||||
String data = SPStaticUtils.getString(CommonConfig.FORCE_INSTALL);
|
||||
Log.e("SaveListUtils", data);
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<String>>() {
|
||||
}.getType();
|
||||
List<String> list = gson.fromJson(data, listType);
|
||||
if (list != null && list.size() > 0) {
|
||||
Log.e("fht", "getList:" + list.toString());
|
||||
} else {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void addToList(String data) {
|
||||
List<String> list = getList();
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
if (!list.contains(data)) {
|
||||
list.add(data);
|
||||
Gson gson = new Gson();
|
||||
String gsonData = gson.toJson(list);
|
||||
SPStaticUtils.put(CommonConfig.FORCE_INSTALL, gsonData);
|
||||
}
|
||||
Log.e("fht", "addToList:" + list.toString());
|
||||
}
|
||||
|
||||
|
||||
public static void setList(List<String> strings) {
|
||||
forceList.clear();
|
||||
forceList = strings;
|
||||
for (String pkg : ApkUtils.desktopAPP) {
|
||||
if (!forceList.contains(pkg)) {
|
||||
forceList.add(pkg);
|
||||
}
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
String gsonData = gson.toJson(forceList);
|
||||
SPStaticUtils.put(CommonConfig.FORCE_INSTALL, gsonData);
|
||||
Log.e("fht", "setList:" + forceList.toString());
|
||||
|
||||
}
|
||||
|
||||
public static void addList(String s) {
|
||||
if (!forceList.contains(s)) {
|
||||
forceList.add(s);
|
||||
}
|
||||
Log.e("fht", "addList:" + forceList.toString());
|
||||
|
||||
}
|
||||
|
||||
public static void setList() {
|
||||
Gson gson = new Gson();
|
||||
String gsonData = gson.toJson(forceList);
|
||||
SPStaticUtils.put(CommonConfig.FORCE_INSTALL, gsonData);
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getlist() {
|
||||
return forceList;
|
||||
}
|
||||
|
||||
|
||||
public static void sendForceAPP(Context context) {
|
||||
StringBuilder txtBuilder = new StringBuilder();
|
||||
for (String s : forceList) {
|
||||
if (txtBuilder.length() > 0) {
|
||||
txtBuilder.append(",");
|
||||
}
|
||||
txtBuilder.append(s);
|
||||
}
|
||||
String txt = txtBuilder.toString();
|
||||
if (txt.length() > 0) {
|
||||
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_force_app", txt);
|
||||
Log.e("fht", "qch_force_app:" + qch_force_app + ":" + txt);
|
||||
} else {
|
||||
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_force_app", "invalid");
|
||||
Log.e("fht", "qch_force_app:" + qch_force_app + ":" + txt);
|
||||
}
|
||||
setList();
|
||||
}
|
||||
|
||||
public static List<String> getDownLoadList() {
|
||||
|
||||
return downLoadList;
|
||||
}
|
||||
|
||||
public static void addDownLoadList(String packageName) {
|
||||
if (downLoadList == null) {
|
||||
downLoadList = new ArrayList<>();
|
||||
downLoadList.add(packageName);
|
||||
} else {
|
||||
if (!downLoadList.contains(packageName)) {
|
||||
downLoadList.add(packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDownLoading(String packageName) {
|
||||
if (downLoadList.contains(packageName)) {
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
}
|
||||
@@ -1038,7 +1038,6 @@ public class Utils {
|
||||
.ignoreFilePathOccupy()
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
// SaveListUtils.addDownLoadList(app_package);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user