增加全局更新
This commit is contained in:
@@ -67,8 +67,8 @@ android {
|
||||
productFlavors {
|
||||
beta {
|
||||
flavorDimensions "default"
|
||||
versionCode 28
|
||||
versionName "3.7"
|
||||
versionCode 29
|
||||
versionName "3.8"
|
||||
}
|
||||
|
||||
official {
|
||||
|
||||
@@ -19,6 +19,8 @@ public class MainAContact {
|
||||
void checkUpdate();
|
||||
/*获取强制下载*/
|
||||
void getForceInstall();
|
||||
/*获取所有全局更新*/
|
||||
void getOverallApp();
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
@@ -27,5 +29,6 @@ public class MainAContact {
|
||||
void setQRCode(Bitmap bitmap);
|
||||
void checkUpdateFinish();
|
||||
void setForceInstall();
|
||||
void setOverallApp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
Log.e(TAG, "onNext: " + response);
|
||||
Log.e("getSnInfo", "onNext: " + response);
|
||||
mView.setSnInfo(response);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,17 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getForceInstall", "onComplete: ");
|
||||
mView.setForceInstall();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOverallApp() {
|
||||
NetInterfaceManager.getInstance().getOverallApp(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setOverallApp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -419,6 +419,11 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
|
||||
@Override
|
||||
public void setForceInstall() {
|
||||
mPresenter.getOverallApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverallApp() {
|
||||
Log.e(TAG, "SettingFinish: " + (System.currentTimeMillis() - timeMillis) + " ms");
|
||||
}
|
||||
}
|
||||
|
||||
109
app/src/main/java/com/uiui/sn/bean/OverallAppBean.java
Normal file
109
app/src/main/java/com/uiui/sn/bean/OverallAppBean.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.uiui.sn.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OverallAppBean implements Serializable {
|
||||
private static final long serialVersionUID = -1802437374155952676L;
|
||||
|
||||
String app_name;
|
||||
String app_package;
|
||||
String app_version_name;
|
||||
long app_version_code;
|
||||
long app_size;
|
||||
String app_url;
|
||||
String app_img;
|
||||
String app_md5;
|
||||
String app_desc;
|
||||
int platform;
|
||||
|
||||
public String getApp_name() {
|
||||
return app_name;
|
||||
}
|
||||
|
||||
public void setApp_name(String app_name) {
|
||||
this.app_name = app_name;
|
||||
}
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
}
|
||||
|
||||
public void setApp_package(String app_package) {
|
||||
this.app_package = app_package;
|
||||
}
|
||||
|
||||
public String getApp_version_name() {
|
||||
return app_version_name;
|
||||
}
|
||||
|
||||
public void setApp_version_name(String app_version_name) {
|
||||
this.app_version_name = app_version_name;
|
||||
}
|
||||
|
||||
public long getApp_version_code() {
|
||||
return app_version_code;
|
||||
}
|
||||
|
||||
public void setApp_version_code(long app_version_code) {
|
||||
this.app_version_code = app_version_code;
|
||||
}
|
||||
|
||||
public long getApp_size() {
|
||||
return app_size;
|
||||
}
|
||||
|
||||
public void setApp_size(long app_size) {
|
||||
this.app_size = app_size;
|
||||
}
|
||||
|
||||
public String getApp_url() {
|
||||
return app_url;
|
||||
}
|
||||
|
||||
public void setApp_url(String app_url) {
|
||||
this.app_url = app_url;
|
||||
}
|
||||
|
||||
public String getApp_img() {
|
||||
return app_img;
|
||||
}
|
||||
|
||||
public void setApp_img(String app_img) {
|
||||
this.app_img = app_img;
|
||||
}
|
||||
|
||||
public String getApp_md5() {
|
||||
return app_md5;
|
||||
}
|
||||
|
||||
public void setApp_md5(String app_md5) {
|
||||
this.app_md5 = app_md5;
|
||||
}
|
||||
|
||||
public String getApp_desc() {
|
||||
return app_desc;
|
||||
}
|
||||
|
||||
public void setApp_desc(String app_desc) {
|
||||
this.app_desc = app_desc;
|
||||
}
|
||||
|
||||
public int getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(int platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,10 @@ public class CommonConfig {
|
||||
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
|
||||
/*强制安装应用,禁止卸载*/
|
||||
public final static String AOLE_ACTION_FORCE_APP = "aole_force_app";
|
||||
/*禁止升级的应用列表*/
|
||||
public final static String AOLE_ACTION_DISALLOW_UPGRADE = "upgrade_disallow";
|
||||
/*全局 更新获取的包名*/
|
||||
public final static String AOLE_ACTION_OVERALL_APP = "overall_app_packages";
|
||||
|
||||
/*应用ID管控*/
|
||||
public final static String AOLE_ACTION_APP_FORBID_ID = "aole_app_forbid_id";
|
||||
|
||||
@@ -110,7 +110,7 @@ public class RunningAppManager {
|
||||
registerTimeReceiver(mContext);
|
||||
|
||||
String remainsTimeJson = mMMKV.decodeString(RemainingTimeMap, "");
|
||||
Log.e(TAG, "remainsTimeJson: " + remainsTimeJson);
|
||||
Log.i(TAG, "remainsTimeJson: " + remainsTimeJson);
|
||||
Gson gson = new Gson();
|
||||
Type remainsTimeType = new TypeToken<HashMap<String, AppRunTimeBean>>() {
|
||||
}.getType();
|
||||
@@ -120,7 +120,7 @@ public class RunningAppManager {
|
||||
}
|
||||
|
||||
String globalUsageTimeJson = mMMKV.decodeString(GlobalUsageTimeMap, "");
|
||||
Log.e(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
||||
Log.i(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
||||
Type globalUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||
}.getType();
|
||||
HashMap<String, AppUsageTime> appUsageTimeHashMap = gson.fromJson(globalUsageTimeJson, globalUsageTimeType);
|
||||
@@ -153,7 +153,7 @@ public class RunningAppManager {
|
||||
.subscribe(new Consumer<Long>() {
|
||||
@Override
|
||||
public void accept(Long aLong) throws Throwable {
|
||||
// Log.e(TAG, "accept: " + aLong);
|
||||
// Log.i(TAG, "accept: " + aLong);
|
||||
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
boolean isScreenOn = pm.isScreenOn();
|
||||
if (!isScreenOn) {
|
||||
@@ -169,7 +169,7 @@ public class RunningAppManager {
|
||||
*/
|
||||
private void checkForegroundAppName() {
|
||||
String topPackage = getTopActivityInfo();
|
||||
Log.e(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||
Log.i(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||
String appPackageName = getAppPackageName();
|
||||
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
||||
if (allowPackage.contains(topPackage)) {
|
||||
@@ -178,7 +178,7 @@ public class RunningAppManager {
|
||||
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG, "onComplete: ");
|
||||
Log.i(TAG, "onComplete: ");
|
||||
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||
}
|
||||
@@ -194,18 +194,18 @@ public class RunningAppManager {
|
||||
return;
|
||||
}
|
||||
long onClickTime = getOnClickTime();
|
||||
Log.e(TAG, "checkForegroundAppName: getAppPackageName = " + appPackageName);
|
||||
Log.i(TAG, "checkForegroundAppName: getAppPackageName = " + appPackageName);
|
||||
if (appPackageName.equals(topPackage)) {
|
||||
Log.e(TAG, "checkForegroundAppName: 没有切换应用");
|
||||
Log.i(TAG, "checkForegroundAppName: 没有切换应用");
|
||||
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
||||
removeTask(topPackage);
|
||||
gotoLauncher();
|
||||
} else {
|
||||
Log.e(TAG, "checkForegroundAppName: 没有管控");
|
||||
Log.i(TAG, "checkForegroundAppName: 没有管控");
|
||||
reduceAppRemainingTime(topPackage, 1);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "checkForegroundAppName: 切换应用:" + topPackage);
|
||||
Log.i(TAG, "checkForegroundAppName: 切换应用:" + topPackage);
|
||||
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@@ -217,12 +217,12 @@ public class RunningAppManager {
|
||||
appPackageName = topPackage;
|
||||
onClickTime = System.currentTimeMillis() / 1000;
|
||||
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
||||
Log.e(TAG, "checkForegroundAppName: 没有剩余时间2");
|
||||
Log.i(TAG, "checkForegroundAppName: 没有剩余时间2");
|
||||
removeTask(topPackage);
|
||||
gotoLauncher();
|
||||
} else {
|
||||
RunningAppManager.getInstance().recordPackageOpenTime(topPackage);
|
||||
Log.e(TAG, "checkForegroundAppName: 没有管控2");
|
||||
Log.i(TAG, "checkForegroundAppName: 没有管控2");
|
||||
}
|
||||
}
|
||||
saveAppRemainingTime();
|
||||
@@ -251,7 +251,7 @@ public class RunningAppManager {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e(TAG, "TimeChangedReceiver:" + action);
|
||||
Log.i(TAG, "TimeChangedReceiver:" + action);
|
||||
long time = System.currentTimeMillis();
|
||||
String finaWayDate = sdf.format(time);
|
||||
if ("00:00:00".equals(finaWayDate)) {
|
||||
@@ -294,7 +294,7 @@ public class RunningAppManager {
|
||||
|
||||
for (ActivityManager.RecentTaskInfo info : list) {
|
||||
if (info.realActivity != null) {
|
||||
Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
Log.i(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
//排除自身
|
||||
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
||||
continue;
|
||||
@@ -304,7 +304,7 @@ public class RunningAppManager {
|
||||
ActivityManagerNative.getDefault().removeTask(info.id);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "removeAllTask: " + e.getMessage());
|
||||
Log.i(TAG, "removeAllTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,9 +319,9 @@ public class RunningAppManager {
|
||||
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
Log.i(TAG, "removeTask: " + e.getMessage());
|
||||
} catch (NullPointerException e) {
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
Log.i(TAG, "removeTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ public class RunningAppManager {
|
||||
return ActivityTaskManager.getService().getRecentTasks(numTasks,
|
||||
RECENT_IGNORE_UNAVAILABLE, userId).getList();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to get recent tasks " + e);
|
||||
Log.i(TAG, "Failed to get recent tasks " + e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -420,7 +420,7 @@ public class RunningAppManager {
|
||||
appRunTimeBean.setAppRunTime(appTimeControl.getToday_time());
|
||||
mRemainingTimeMap.put(appTimeControl.getApp_package(), appRunTimeBean);
|
||||
}
|
||||
Log.e(TAG, "syncAppRemainingTime: Finish" + mRemainingTimeMap);
|
||||
Log.i(TAG, "syncAppRemainingTime: Finish" + mRemainingTimeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,7 +482,7 @@ public class RunningAppManager {
|
||||
return;
|
||||
}
|
||||
int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||
Log.e(TAG, "reduceAppRemainingTime: isControl = " + isControl);
|
||||
Log.i(TAG, "reduceAppRemainingTime: isControl = " + isControl);
|
||||
//家长管控关闭始终可用
|
||||
if (isControl == 0) {
|
||||
return;
|
||||
@@ -505,7 +505,7 @@ public class RunningAppManager {
|
||||
} else {
|
||||
mGlobalUsageTime.remove(pkg);
|
||||
}
|
||||
Log.e(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
||||
Log.i(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
||||
long remainingTime = appTimeControl.getToday_time() - time;
|
||||
if (remainingTime < 0) {
|
||||
remainingTime = 0;
|
||||
@@ -516,7 +516,10 @@ public class RunningAppManager {
|
||||
appTimeControl.setToday_time(remainingTime);
|
||||
TimeControlManager.getInstance().setAppTimeControl(pkg, appTimeControl);
|
||||
} else {
|
||||
Log.e(TAG, "reduceAppRemainingTime: " + machineControl.getToday_time());
|
||||
if (machineControl==null){
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "reduceAppRemainingTime: " + machineControl.getToday_time());
|
||||
long remainingTime = machineControl.getToday_time() - time;
|
||||
if (remainingTime < 0) {
|
||||
remainingTime = 0;
|
||||
@@ -551,9 +554,9 @@ public class RunningAppManager {
|
||||
if (allowPackage.contains(pkg)) {
|
||||
return false;
|
||||
}
|
||||
Log.e(TAG, "inControlTime: pkg = " + pkg);
|
||||
Log.i(TAG, "inControlTime: pkg = " + pkg);
|
||||
int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||
Log.e(TAG, "inControlTime: isControl = " + isControl);
|
||||
Log.i(TAG, "inControlTime: isControl = " + isControl);
|
||||
//家长管控关闭始终可用
|
||||
if (isControl == 0) {
|
||||
return false;
|
||||
@@ -576,7 +579,7 @@ public class RunningAppManager {
|
||||
boolean inControlTime = inControlTime(machineControl, appTimeControl);
|
||||
//判断是否在时间段内
|
||||
if (inControlTime) {
|
||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
|
||||
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
||||
return true;
|
||||
} else {
|
||||
@@ -616,7 +619,7 @@ public class RunningAppManager {
|
||||
} else {
|
||||
boolean inControlTime = inControlTime(machineControl);
|
||||
if (inControlTime) {
|
||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + machineControl.time_part.toString());
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + machineControl.time_part.toString());
|
||||
ToastUtil.show("该应用" + partTime2String(machineControl));
|
||||
}
|
||||
return inControlTime;
|
||||
@@ -684,9 +687,9 @@ public class RunningAppManager {
|
||||
// if (allowPackage.contains(pkg)) {
|
||||
// return "";
|
||||
// }
|
||||
// Log.e(TAG, "inControlTime: pkg = " + pkg);
|
||||
// Log.i(TAG, "inControlTime: pkg = " + pkg);
|
||||
// int is_control = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||
// Log.e(TAG, "inControlTime: is_control = " + is_control);
|
||||
// Log.i(TAG, "inControlTime: is_control = " + is_control);
|
||||
//家长管控关闭始终可用
|
||||
// if (is_control == 0) {
|
||||
// return "";
|
||||
@@ -832,7 +835,7 @@ public class RunningAppManager {
|
||||
// } else {
|
||||
// return restTime - todayTime <= 0;
|
||||
// }
|
||||
Log.e(TAG, "haveUseTime: " + globalRemainingTime);
|
||||
Log.i(TAG, "haveUseTime: " + globalRemainingTime);
|
||||
return !(globalRemainingTime > 0);
|
||||
}
|
||||
|
||||
@@ -965,7 +968,7 @@ public class RunningAppManager {
|
||||
String endTime = partTime.getEnd_time();
|
||||
ContralTime contralTime = new ContralTime(startTime, endTime);
|
||||
boolean inControlTime = contralTime.inControlTime();
|
||||
Log.e(TAG, "inControlTime: " + inControlTime);
|
||||
Log.i(TAG, "inControlTime: " + inControlTime);
|
||||
return inControlTime;
|
||||
}
|
||||
|
||||
@@ -1038,7 +1041,7 @@ public class RunningAppManager {
|
||||
//开始时间大于结束时间 列 16:00-01:00
|
||||
endDate.setTime(endDate.getTime() + dayTime);
|
||||
}
|
||||
Log.e(TAG, "inControlTime: " + (startDate.getTime() - minuteTime));
|
||||
Log.i(TAG, "inControlTime: " + (startDate.getTime() - minuteTime));
|
||||
assert nowDate != null;
|
||||
// if (nowDate.getTime() <= startDate.getTime() - minuteTime || nowDate.getTime() >= endDate.getTime()) {
|
||||
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
|
||||
@@ -1069,7 +1072,7 @@ public class RunningAppManager {
|
||||
public String getDate(long time) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String finaWayDate = sdf.format(time);
|
||||
Log.e(TAG, "getDate: " + finaWayDate);
|
||||
Log.i(TAG, "getDate: " + finaWayDate);
|
||||
return finaWayDate;
|
||||
}
|
||||
|
||||
@@ -1080,7 +1083,7 @@ public class RunningAppManager {
|
||||
*/
|
||||
public int getWeekDay() {
|
||||
long time = System.currentTimeMillis();
|
||||
Log.e(TAG, "getWeekDay: " + time);
|
||||
Log.i(TAG, "getWeekDay: " + time);
|
||||
return getWeekDay(time);
|
||||
}
|
||||
|
||||
@@ -1165,10 +1168,10 @@ public class RunningAppManager {
|
||||
|
||||
public void checkTopAppPackageName() {
|
||||
String topPackage = getTopActivityInfo();
|
||||
Log.e(TAG, "onReceive: " + topPackage);
|
||||
// Log.e(TAG, "onReceive: getWeekDay: " + getWeekDay());
|
||||
// Log.e(TAG, "onReceive: getWeekDayString: " + getWeekDayString());
|
||||
// Log.e(TAG, "onReceive: inWeekDay: " + inWeekDay());
|
||||
Log.i(TAG, "onReceive: " + topPackage);
|
||||
// Log.i(TAG, "onReceive: getWeekDay: " + getWeekDay());
|
||||
// Log.i(TAG, "onReceive: getWeekDayString: " + getWeekDayString());
|
||||
// Log.i(TAG, "onReceive: inWeekDay: " + inWeekDay());
|
||||
}
|
||||
|
||||
|
||||
@@ -1204,7 +1207,7 @@ public class RunningAppManager {
|
||||
currentClassName = initStat.getPackageName();
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "getForegroundActivityName: " + currentClassName);
|
||||
Log.i(TAG, "getForegroundActivityName: " + currentClassName);
|
||||
return currentClassName;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class CacheHelper {
|
||||
// =======================================
|
||||
|
||||
public void put(String key, String value) {
|
||||
Log.e(TAG, "put: key = " + key + " value = " + value);
|
||||
// Log.e(TAG, "put: key = " + key + " value = " + value);
|
||||
mMMKV.encode(key, System.currentTimeMillis());
|
||||
mMMKV.encode(key + "_mmkv", value);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class CacheHelper {
|
||||
}
|
||||
|
||||
public String getAsString(String key) {
|
||||
Log.e(TAG, "getAsString: " + key);
|
||||
// Log.e(TAG, "getAsString: " + key);
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
//write READ
|
||||
@@ -435,7 +435,7 @@ public class CacheHelper {
|
||||
DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key));
|
||||
if (snapshot == null) //not find entry , or entry.readable = false
|
||||
{
|
||||
Log.e(TAG, "not find entry , or entry.readable = false");
|
||||
// Log.e(TAG, "not find entry , or entry.readable = false");
|
||||
return null;
|
||||
}
|
||||
//write READ
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.sn.BuildConfig;
|
||||
import com.uiui.sn.bean.AppInfo;
|
||||
import com.uiui.sn.bean.AppStart;
|
||||
import com.uiui.sn.bean.OverallAppBean;
|
||||
import com.uiui.sn.desktop.AppTimeControl;
|
||||
import com.uiui.sn.bean.AppUploadInfo;
|
||||
import com.uiui.sn.bean.AppletQRCode;
|
||||
@@ -63,6 +64,7 @@ import com.uiui.sn.network.api.GetGuideApi;
|
||||
import com.uiui.sn.network.api.GetPublicIPApi;
|
||||
import com.uiui.sn.network.api.MachineTimeControlApi;
|
||||
import com.uiui.sn.network.api.NewestAppUpdate;
|
||||
import com.uiui.sn.network.api.OverallAppByPlatformApi;
|
||||
import com.uiui.sn.network.api.QRCodeApi;
|
||||
import com.uiui.sn.network.api.QueryAllApp;
|
||||
import com.uiui.sn.network.api.QueryAppInside;
|
||||
@@ -389,6 +391,25 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<OverallAppBean>>> getOverallAppObservable() {
|
||||
int platformCode = 0;
|
||||
String platform = BuildConfig.platform;
|
||||
switch (platform) {
|
||||
case "ZhanRui":
|
||||
platformCode = 2;
|
||||
break;
|
||||
case "MTK":
|
||||
platformCode = 1;
|
||||
break;
|
||||
default:
|
||||
platformCode = 3;
|
||||
}
|
||||
return getOverallAppByPlatformControl()
|
||||
.getOverallApp(platformCode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* API
|
||||
@@ -415,6 +436,10 @@ public class NetInterfaceManager {
|
||||
return mRetrofit.create(NewestAppUpdate.class);
|
||||
}
|
||||
|
||||
public OverallAppByPlatformApi getOverallAppByPlatformControl() {
|
||||
return mRetrofit.create(OverallAppByPlatformApi.class);
|
||||
}
|
||||
|
||||
public UploadScreenshot getUploadScreenshotControl() {
|
||||
return mRetrofit.create(UploadScreenshot.class);
|
||||
}
|
||||
@@ -1598,7 +1623,7 @@ public class NetInterfaceManager {
|
||||
String upgrade_allow = String.join(",", allowApp);
|
||||
Log.e("setAppUpdate", "upgrade_allow: " + upgrade_allow);
|
||||
Log.e("setAppUpdate", "upgrade_disallow: " + upgrade_disallow);
|
||||
Settings.System.putString(crv, "upgrade_disallow", upgrade_disallow);
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE, upgrade_disallow);
|
||||
Utils.writeDisableUpdateList(mContext);
|
||||
}
|
||||
}
|
||||
@@ -2427,5 +2452,119 @@ public class NetInterfaceManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void getOverallApp(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GE_TOVERALL_APPBYPLATFORM, connectMode)) {
|
||||
getOverallApp(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GE_TOVERALL_APPBYPLATFORM);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getOverallApp(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<OverallAppBean>>() {
|
||||
}.getType();
|
||||
List<OverallAppBean> overallAppBeanList = gson.fromJson(jsonString, type);
|
||||
installOverallApp(overallAppBeanList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getOverallApp(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||
getOverallAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getOverallAppObserver(callback));
|
||||
}
|
||||
|
||||
public void getOverallApp(onCompleteCallback callback) {
|
||||
getOverallAppObservable()
|
||||
.subscribe(getOverallAppObserver(callback));
|
||||
}
|
||||
|
||||
public void getOverallApp() {
|
||||
getOverallAppObservable()
|
||||
.subscribe(getOverallAppObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<List<OverallAppBean>>> getOverallAppObserver(onCompleteCallback callback) {
|
||||
return new Observer<BaseResponse<List<OverallAppBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getOverallApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<OverallAppBean>> baseResponse) {
|
||||
Log.e("getOverallApp", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
List<OverallAppBean> overallAppBeanList = baseResponse.data;
|
||||
mCacheHelper.put(UrlAddress.GE_TOVERALL_APPBYPLATFORM, GsonUtils.toJSONString(overallAppBeanList));
|
||||
installOverallApp(overallAppBeanList);
|
||||
} else {
|
||||
mCacheHelper.put(UrlAddress.GE_TOVERALL_APPBYPLATFORM, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getOverallApp", "onError: ");
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getOverallApp", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void installOverallApp(List<OverallAppBean> overallAppBeanList) {
|
||||
if (overallAppBeanList == null || overallAppBeanList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
String packageList = overallAppBeanList.stream().map(OverallAppBean::getApp_package).collect(Collectors.joining(","));
|
||||
Log.e(TAG, "installOverallApp: " + packageList);
|
||||
mMMKV.encode(CommonConfig.AOLE_ACTION_OVERALL_APP, packageList);
|
||||
Utils.writeDisableUpdateList(mContext);
|
||||
Log.e(TAG, "installOverallApp: " + packageList);
|
||||
for (OverallAppBean overallAppBean : overallAppBeanList) {
|
||||
String packages = overallAppBean.getApp_package();
|
||||
String url = overallAppBean.getApp_url();
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
continue;
|
||||
}
|
||||
long app_version_code = overallAppBean.getApp_version_code();
|
||||
PackageInfo info = null;
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
try {
|
||||
info = pm.getPackageInfo(packages, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != info) {
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = info.versionCode;
|
||||
}
|
||||
if (appVersionCode < app_version_code) {
|
||||
Log.e(TAG, "installOverallApp: " + "need to upgrade");
|
||||
FileUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
|
||||
} else {
|
||||
Log.e(TAG, "installOverallApp: " + "it's up to date , no need upgrade");
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "installOverallApp: " + "not installed , upgrade");
|
||||
FileUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public class UrlAddress {
|
||||
public final static String UPDATE_SNINFO = "sn/updateAdminSn";
|
||||
/*根据包名获取更新*/
|
||||
public final static String GET_NEWESTAPPUPDATE = "app/newestAppUpdate";
|
||||
/*获取所有全局更新*/
|
||||
public final static String GE_TOVERALL_APPBYPLATFORM = "app/overallAppByPlatform";
|
||||
/*上传屏幕截图*/
|
||||
public final static String UPLOAD_SCREEN_SNAPSHOT = "sn/uploadScreenshot";
|
||||
/*获取屏幕管控*/
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.uiui.sn.network.api;
|
||||
|
||||
import com.uiui.sn.bean.BaseResponse;
|
||||
import com.uiui.sn.bean.OverallAppBean;
|
||||
import com.uiui.sn.network.UrlAddress;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface OverallAppByPlatformApi {
|
||||
@GET(UrlAddress.GE_TOVERALL_APPBYPLATFORM)
|
||||
Observable<BaseResponse<List<OverallAppBean>>> getOverallApp(
|
||||
@Query("platform") int platform
|
||||
);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
// Response copy = response.newBuilder().body(responseBody).build();
|
||||
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
|
||||
// Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: " + content);
|
||||
}
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||
|
||||
@@ -104,6 +104,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
||||
NetInterfaceManager.getInstance().getForceInstall();
|
||||
NetInterfaceManager.getInstance().getAllappPackage();
|
||||
NetInterfaceManager.getInstance().getAppInside();
|
||||
NetInterfaceManager.getInstance().getOverallApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ public class MainSContact {
|
||||
void checkUpdateFinish();
|
||||
void checkFXYUpdateFinish();
|
||||
void getAllAppFinish();
|
||||
void setOverallApp();
|
||||
void setAppInside();
|
||||
void setForceInstall();
|
||||
void setSystemSettings();
|
||||
@@ -37,6 +38,8 @@ public class MainSContact {
|
||||
void checkFXYUpdate();
|
||||
//获取所有app包名
|
||||
void getAllApp();
|
||||
/*获取所有全局更新*/
|
||||
void getOverallApp();
|
||||
//获取id管控
|
||||
void getAppInside();
|
||||
//获取强制下载
|
||||
|
||||
@@ -188,6 +188,16 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOverallApp() {
|
||||
NetInterfaceManager.getInstance().getOverallApp(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setOverallApp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppInside() {
|
||||
NetInterfaceManager.getInstance()
|
||||
|
||||
@@ -118,6 +118,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
SPUtils.put(this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
}
|
||||
mPresenter.checkUpdate();
|
||||
mPresenter.getAllApp();
|
||||
TimeTask task = new TimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
}
|
||||
@@ -432,6 +433,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
|
||||
@Override
|
||||
public void getAllAppFinish() {
|
||||
mPresenter.getOverallApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverallApp() {
|
||||
mPresenter.getAppInside();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
@@ -51,6 +53,7 @@ import com.uiui.sn.utils.ApkUtils;
|
||||
import com.uiui.sn.utils.CacheUtils;
|
||||
import com.uiui.sn.utils.CmdUtil;
|
||||
import com.uiui.sn.gson.GsonUtils;
|
||||
import com.uiui.sn.utils.FileUtils;
|
||||
import com.uiui.sn.utils.JGYUtils;
|
||||
import com.uiui.sn.utils.SPUtils;
|
||||
import com.uiui.sn.utils.ServiceAliveUtils;
|
||||
@@ -553,8 +556,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
case JIGUANG_FORCE_INSTALLAPK:
|
||||
ToastUtil.debugShow("收到推送消息: 强制安装应用");
|
||||
NetInterfaceManager.getInstance().getAllappPackage();
|
||||
NetInterfaceManager.getInstance().getForceInstall();
|
||||
// intallApk(context, extras);
|
||||
NetInterfaceManager.getInstance().getOverallApp();
|
||||
intallApk(context, extras);
|
||||
break;
|
||||
case JIGUANG_FORCE_UNINSTALLAPK:
|
||||
ToastUtil.debugShow("收到推送消息: 强制卸载应用");
|
||||
@@ -998,35 +1001,41 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
//静默安装应用,使用okgo,断网会出现问题,等待修改使用aria
|
||||
synchronized private void intallApk(Context context, String jsonString) {
|
||||
private void intallApk(Context context, String jsonString) {
|
||||
if (TextUtils.isEmpty(jsonString)) {
|
||||
return;
|
||||
}
|
||||
// NetInterfaceManager.getInstance().getAllAppPackageName(context);
|
||||
JsonObject extra = GsonUtils.getJsonObject(jsonString);
|
||||
final String packages = extra.get("package").getAsString();
|
||||
String packages = extra.get("package").getAsString();
|
||||
ToastUtil.debugShow("收到应用安装消息:包名" + packages);
|
||||
String url = extra.get("url").getAsString();
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
if (Aria.download(this).taskExists(url)) {
|
||||
|
||||
List<DownloadEntity> entity = Aria.download(this).getDownloadEntity(url);
|
||||
for (DownloadEntity downloadEntity : entity) {
|
||||
Aria.download(this).load(downloadEntity.getId()).cancel(true);
|
||||
}
|
||||
long app_version_code = extra.get("app_version_code").getAsLong();
|
||||
PackageInfo info = null;
|
||||
PackageManager pm = context.getPackageManager();
|
||||
try {
|
||||
info = pm.getPackageInfo(packages, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != info) {
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = info.versionCode;
|
||||
}
|
||||
if (appVersionCode < app_version_code) {
|
||||
Log.e(TAG, "intallApk: " + "need to upgrade");
|
||||
FileUtils.ariaDownload(context, url, extra);
|
||||
} else
|
||||
Log.e(TAG, "intallApk: " + "it's up to date , no need upgrade");
|
||||
} else {
|
||||
Log.e(TAG, "intallApk: " + "not installed , upgrade");
|
||||
FileUtils.ariaDownload(context, url, extra);
|
||||
}
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/apk");
|
||||
file.mkdirs();
|
||||
Aria.download(this)
|
||||
.load(url)
|
||||
.setFilePath(JGYUtils.getInstance().getDownLoadPath() + packages + ".apk")
|
||||
.ignoreFilePathOccupy()
|
||||
.setExtendField(packages).create();
|
||||
Aria.download(this).resumeAllTask();
|
||||
|
||||
}
|
||||
|
||||
synchronized private void unintallApk(Context context, String jsonString) {
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.sn.BuildConfig;
|
||||
import com.uiui.sn.R;
|
||||
import com.uiui.sn.Statistics.AppInformation;
|
||||
@@ -869,13 +870,15 @@ public class Utils {
|
||||
//允许安装的app
|
||||
String now = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
||||
//禁止升级的app
|
||||
String upgrade_disallow = Settings.System.getString(context.getContentResolver(), "upgrade_disallow");
|
||||
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);
|
||||
String overall_app_list = MMKV.defaultMMKV().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(",")));
|
||||
}
|
||||
@@ -885,11 +888,16 @@ public class Utils {
|
||||
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)) {
|
||||
|
||||
Reference in New Issue
Block a user