增加一键断网
This commit is contained in:
@@ -67,8 +67,8 @@ android {
|
|||||||
productFlavors {
|
productFlavors {
|
||||||
beta {
|
beta {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 30
|
versionCode 32
|
||||||
versionName "3.9"
|
versionName "4.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
official {
|
official {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public class RemainTime implements Serializable {
|
|||||||
int disableType;
|
int disableType;
|
||||||
/*禁用提示*/
|
/*禁用提示*/
|
||||||
String content;
|
String content;
|
||||||
|
/*总时间*/
|
||||||
|
long totalTime;
|
||||||
/*应用设置的可用时间*/
|
/*应用设置的可用时间*/
|
||||||
long availableTime;
|
long availableTime;
|
||||||
/*app使用时间*/
|
/*app使用时间*/
|
||||||
@@ -54,6 +56,14 @@ public class RemainTime implements Serializable {
|
|||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTotalTime() {
|
||||||
|
return totalTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalTime(long totalTime) {
|
||||||
|
this.totalTime = totalTime;
|
||||||
|
}
|
||||||
|
|
||||||
public long getAvailableTime() {
|
public long getAvailableTime() {
|
||||||
return availableTime;
|
return availableTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.google.gson.JsonParser;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class SystemSettings implements Serializable {
|
public class SystemSettings implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -7763589370400496883L;
|
private static final long serialVersionUID = -7763589370400496883L;
|
||||||
|
|
||||||
int setting_call;
|
int setting_call;
|
||||||
@@ -47,6 +46,7 @@ public class SystemSettings implements Serializable {
|
|||||||
String browser_app;
|
String browser_app;
|
||||||
String typewriting_app;
|
String typewriting_app;
|
||||||
int is_control;
|
int is_control;
|
||||||
|
int is_network;
|
||||||
|
|
||||||
int setting_rotation;
|
int setting_rotation;
|
||||||
int setting_airplane;
|
int setting_airplane;
|
||||||
@@ -345,6 +345,14 @@ public class SystemSettings implements Serializable {
|
|||||||
this.is_control = is_control;
|
this.is_control = is_control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIs_network() {
|
||||||
|
return is_network;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIs_network(int is_network) {
|
||||||
|
this.is_network = is_network;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSetting_rotation() {
|
public int getSetting_rotation() {
|
||||||
return setting_rotation;
|
return setting_rotation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public class CommonConfig {
|
|||||||
/*USB模式-MIDI*/
|
/*USB模式-MIDI*/
|
||||||
public final static String AOLE_ACTION_USB_USB_MIDI = "aole_action_usb_usb_midi";
|
public final static String AOLE_ACTION_USB_USB_MIDI = "aole_action_usb_usb_midi";
|
||||||
|
|
||||||
|
public final static String AOLE_ACTION_SCREEN_SHARE = "aole_app_screen_share";
|
||||||
|
|
||||||
/*应用安装白名单*/
|
/*应用安装白名单*/
|
||||||
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
|
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
|
||||||
/*强制安装应用,禁止卸载*/
|
/*强制安装应用,禁止卸载*/
|
||||||
|
|||||||
@@ -43,19 +43,16 @@ import java.lang.reflect.Type;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Predicate;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
@@ -73,23 +70,20 @@ public class RunningAppManager {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||||
|
|
||||||
|
|
||||||
public static final String RemainingTimeMap = "RemainingTimeMap_KEY";
|
public static final String RemainingTimeMap = "RemainingTimeMap_KEY";
|
||||||
|
|
||||||
public static final String GlobalUsageTimeMap = "GlobalUsageTimeMap_KEY";
|
public static final String GlobalUsageTimeMap = "GlobalUsageTimeMap_KEY";
|
||||||
|
|
||||||
|
public static final String AllApplUsageTimeMap = "AllAppUsageTimeMap_KEY";
|
||||||
|
|
||||||
//剩余时间
|
//剩余时间
|
||||||
private long globalRemainingTime = 0L;
|
private long globalRemainingTime = 0L;
|
||||||
|
|
||||||
//存储每个单独有配置app剩余时间
|
//存储每个单独有配置app剩余时间
|
||||||
private HashMap<String, AppRunTimeBean> mRemainingTimeMap = new HashMap<>();
|
private HashMap<String, AppRunTimeBean> mRemainingTimeMap = new HashMap<>();
|
||||||
|
|
||||||
//存储整机配置app使用时间
|
//存储整机配置app使用时间
|
||||||
private HashMap<String, AppUsageTime> mGlobalUsageTime = new HashMap<>();
|
private HashMap<String, AppUsageTime> mGlobalUsageTime = new HashMap<>();
|
||||||
|
//存储所有app使用时间
|
||||||
|
private HashMap<String, AppUsageTime> mAllAppUsageTime = new HashMap<>();
|
||||||
//存储每个分类剩余时间
|
|
||||||
HashMap<Integer, AppRunTimeBean> mClassifyTimeMap = new HashMap<>();
|
|
||||||
|
|
||||||
public static long minuteTime = 60 * 1000;
|
public static long minuteTime = 60 * 1000;
|
||||||
public static long dayTime = minuteTime * 60 * 24;
|
public static long dayTime = minuteTime * 60 * 24;
|
||||||
@@ -129,6 +123,16 @@ public class RunningAppManager {
|
|||||||
if (appUsageTimeHashMap != null) {
|
if (appUsageTimeHashMap != null) {
|
||||||
mGlobalUsageTime = appUsageTimeHashMap;
|
mGlobalUsageTime = appUsageTimeHashMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String allAppUsageTimeJson = mMMKV.decodeString(AllApplUsageTimeMap, "");
|
||||||
|
Log.i(TAG, "allAppUsageTimeJson: " + globalUsageTimeJson);
|
||||||
|
Type allAppUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||||
|
}.getType();
|
||||||
|
HashMap<String, AppUsageTime> allAppUsageTimeHashMap = gson.fromJson(allAppUsageTimeJson, allAppUsageTimeType);
|
||||||
|
if (allAppUsageTimeHashMap != null) {
|
||||||
|
mAllAppUsageTime = allAppUsageTimeHashMap;
|
||||||
|
}
|
||||||
|
|
||||||
inInterval();
|
inInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,6 +205,7 @@ public class RunningAppManager {
|
|||||||
Log.i(TAG, "checkForegroundAppName: 没有切换应用");
|
Log.i(TAG, "checkForegroundAppName: 没有切换应用");
|
||||||
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
||||||
removeTask(topPackage);
|
removeTask(topPackage);
|
||||||
|
JGYUtils.getInstance().killBackgroundProcesses(topPackage);
|
||||||
gotoLauncher();
|
gotoLauncher();
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "checkForegroundAppName: 没有管控");
|
Log.i(TAG, "checkForegroundAppName: 没有管控");
|
||||||
@@ -221,6 +226,7 @@ public class RunningAppManager {
|
|||||||
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
||||||
Log.i(TAG, "checkForegroundAppName: 没有剩余时间2");
|
Log.i(TAG, "checkForegroundAppName: 没有剩余时间2");
|
||||||
removeTask(topPackage);
|
removeTask(topPackage);
|
||||||
|
JGYUtils.getInstance().killBackgroundProcesses(topPackage);
|
||||||
gotoLauncher();
|
gotoLauncher();
|
||||||
} else {
|
} else {
|
||||||
RunningAppManager.getInstance().recordPackageOpenTime(topPackage);
|
RunningAppManager.getInstance().recordPackageOpenTime(topPackage);
|
||||||
@@ -433,6 +439,8 @@ public class RunningAppManager {
|
|||||||
mMMKV.encode(RemainingTimeMap, jsonString);
|
mMMKV.encode(RemainingTimeMap, jsonString);
|
||||||
String timeString = GsonUtils.toJSONString(mGlobalUsageTime);
|
String timeString = GsonUtils.toJSONString(mGlobalUsageTime);
|
||||||
mMMKV.encode(GlobalUsageTimeMap, timeString);
|
mMMKV.encode(GlobalUsageTimeMap, timeString);
|
||||||
|
String singleString = GsonUtils.toJSONString(mAllAppUsageTime);
|
||||||
|
mMMKV.encode(AllApplUsageTimeMap, singleString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getAppTodayRunTime(String pkg) {
|
private long getAppTodayRunTime(String pkg) {
|
||||||
@@ -493,6 +501,7 @@ public class RunningAppManager {
|
|||||||
MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl();
|
MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl();
|
||||||
if (havaConfigure) {
|
if (havaConfigure) {
|
||||||
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
||||||
|
//全局配置的
|
||||||
if (appTimeControl.getTc_use_type() == 2) {
|
if (appTimeControl.getTc_use_type() == 2) {
|
||||||
AppUsageTime appUsageTime;
|
AppUsageTime appUsageTime;
|
||||||
if (mGlobalUsageTime.get(pkg) == null) {
|
if (mGlobalUsageTime.get(pkg) == null) {
|
||||||
@@ -508,6 +517,18 @@ public class RunningAppManager {
|
|||||||
} else {
|
} else {
|
||||||
mGlobalUsageTime.remove(pkg);
|
mGlobalUsageTime.remove(pkg);
|
||||||
}
|
}
|
||||||
|
//单个app的
|
||||||
|
AppUsageTime singleAppUsageTime;
|
||||||
|
if (mAllAppUsageTime.get(pkg) == null) {
|
||||||
|
singleAppUsageTime = new AppUsageTime();
|
||||||
|
singleAppUsageTime.setPkg(pkg);
|
||||||
|
singleAppUsageTime.setAppName(getAppName(pkg));
|
||||||
|
singleAppUsageTime.setUsageTime(1);
|
||||||
|
} else {
|
||||||
|
singleAppUsageTime = mAllAppUsageTime.get(pkg);
|
||||||
|
singleAppUsageTime.setUsageTime(singleAppUsageTime.getUsageTime() + 1);
|
||||||
|
}
|
||||||
|
mAllAppUsageTime.put(pkg, singleAppUsageTime);
|
||||||
Log.i(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
Log.i(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
||||||
long remainingTime = appTimeControl.getToday_time() - time;
|
long remainingTime = appTimeControl.getToday_time() - time;
|
||||||
if (remainingTime < 0) {
|
if (remainingTime < 0) {
|
||||||
@@ -717,6 +738,11 @@ public class RunningAppManager {
|
|||||||
if (havaConfigure) {
|
if (havaConfigure) {
|
||||||
//有单独设置 不管是分类整机还是其他都是这个设置
|
//有单独设置 不管是分类整机还是其他都是这个设置
|
||||||
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
||||||
|
if (inWeekDay()) {
|
||||||
|
remainTime.setTotalTime(appTimeControl.getWork_time());
|
||||||
|
} else {
|
||||||
|
remainTime.setTotalTime(appTimeControl.getRest_time());
|
||||||
|
}
|
||||||
if (appTimeControl.getIs_control() == 0) {
|
if (appTimeControl.getIs_control() == 0) {
|
||||||
remainTime.setDisableType(1);
|
remainTime.setDisableType(1);
|
||||||
remainTime.setContent("应用已被禁用");
|
remainTime.setContent("应用已被禁用");
|
||||||
@@ -749,7 +775,7 @@ public class RunningAppManager {
|
|||||||
//分类没有时间
|
//分类没有时间
|
||||||
if (appTimeControl.getTc_use_type() == 1) {
|
if (appTimeControl.getTc_use_type() == 1) {
|
||||||
remainTime.setDisableType(5);
|
remainTime.setDisableType(5);
|
||||||
remainTime.setAppUsageTimes(getAppClassificationTime(appTimeControl.getTc_class_id()));
|
remainTime.setAppUsageTimes(getClassAppUsageTime(appTimeControl.getTc_class_id()));
|
||||||
} else if (appTimeControl.getTc_use_type() == 2) {
|
} else if (appTimeControl.getTc_use_type() == 2) {
|
||||||
remainTime.setDisableType(4);
|
remainTime.setDisableType(4);
|
||||||
remainTime.setAppUsageTimes(getMachineTime());
|
remainTime.setAppUsageTimes(getMachineTime());
|
||||||
@@ -769,7 +795,7 @@ public class RunningAppManager {
|
|||||||
//没有剩余时间
|
//没有剩余时间
|
||||||
if (appTimeControl.getTc_use_type() == 1) {
|
if (appTimeControl.getTc_use_type() == 1) {
|
||||||
remainTime.setDisableType(5);
|
remainTime.setDisableType(5);
|
||||||
remainTime.setAppUsageTimes(getAppClassificationTime(appTimeControl.getTc_class_id()));
|
remainTime.setAppUsageTimes(getClassAppUsageTime(appTimeControl.getTc_class_id()));
|
||||||
} else if (appTimeControl.getTc_use_type() == 2) {
|
} else if (appTimeControl.getTc_use_type() == 2) {
|
||||||
remainTime.setDisableType(4);
|
remainTime.setDisableType(4);
|
||||||
remainTime.setAppUsageTimes(getMachineTime());
|
remainTime.setAppUsageTimes(getMachineTime());
|
||||||
@@ -786,6 +812,11 @@ public class RunningAppManager {
|
|||||||
if (machineControl == null) {
|
if (machineControl == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
if (inWeekDay()) {
|
||||||
|
remainTime.setTotalTime(machineControl.getWork_time());
|
||||||
|
} else {
|
||||||
|
remainTime.setTotalTime(machineControl.getRest_time());
|
||||||
|
}
|
||||||
if (machineControl.is_quota == 1) {
|
if (machineControl.is_quota == 1) {
|
||||||
if (haveUseTime(machineControl.getWork_time(), machineControl.getRest_time(), machineControl.getToday_time())) {
|
if (haveUseTime(machineControl.getWork_time(), machineControl.getRest_time(), machineControl.getToday_time())) {
|
||||||
return "";
|
return "";
|
||||||
@@ -806,9 +837,72 @@ public class RunningAppManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取id对应分类每个app的时间
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<AppUsageTime> getClassAppUsageTime(int id) {
|
||||||
|
List<AppUsageTime> appUsageTimes = new ArrayList<>();
|
||||||
|
HashMap<String, AppTimeControl> appTimeControlHashMap = TimeControlManager.getInstance().getAppTimeControlMap();
|
||||||
|
if (appTimeControlHashMap == null || appTimeControlHashMap.size() == 0) {
|
||||||
|
return appUsageTimes;
|
||||||
|
}
|
||||||
|
appTimeControlHashMap.entrySet().stream().forEach((entry) -> {
|
||||||
|
if (entry.getValue().getTc_class_id() == id) {
|
||||||
|
String pkg = entry.getKey();
|
||||||
|
if (TextUtils.isEmpty(pkg)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AppUsageTime appUsageTime = mAllAppUsageTime.get(pkg);
|
||||||
|
if (appUsageTime != null) {
|
||||||
|
appUsageTimes.add(appUsageTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (appUsageTimes.size() == 0) {
|
||||||
|
return appUsageTimes;
|
||||||
|
}
|
||||||
|
//时间补偿 防止以后每个应用加起来时间不对的问题
|
||||||
|
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(appUsageTimes.get(0).getPkg());
|
||||||
|
long allTime = 0;
|
||||||
|
if (inWeekDay()) {
|
||||||
|
allTime = appTimeControl.getWork_time();
|
||||||
|
} else {
|
||||||
|
allTime = appTimeControl.getRest_time();
|
||||||
|
}
|
||||||
|
long tempTime = 0;
|
||||||
|
for (AppUsageTime appUsageTime : appUsageTimes) {
|
||||||
|
tempTime += appUsageTime.getUsageTime();
|
||||||
|
}
|
||||||
|
appUsageTimes.sort(new Comparator<AppUsageTime>() {
|
||||||
|
@Override
|
||||||
|
public int compare(AppUsageTime o1, AppUsageTime o2) {
|
||||||
|
if (o1.getUsageTime() > o2.getUsageTime()) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (tempTime < allTime) {
|
||||||
|
AppUsageTime lastAppUsageTime = appUsageTimes.get(appUsageTimes.size() - 1);
|
||||||
|
appUsageTimes.get(appUsageTimes.size() - 1).setUsageTime(lastAppUsageTime.getUsageTime() + (allTime - tempTime));
|
||||||
|
} else if (tempTime > allTime) {
|
||||||
|
AppUsageTime lastAppUsageTime = appUsageTimes.get(appUsageTimes.size() - 1);
|
||||||
|
appUsageTimes.get(appUsageTimes.size() - 1).setUsageTime(lastAppUsageTime.getUsageTime() - (tempTime - allTime));
|
||||||
|
}
|
||||||
|
return appUsageTimes;
|
||||||
|
}
|
||||||
|
|
||||||
private List<AppUsageTime> getAppClassificationTime(int id) {
|
private List<AppUsageTime> getAppClassificationTime(int id) {
|
||||||
List<AppUsageTime> appUsageTimes = new ArrayList<>();
|
List<AppUsageTime> appUsageTimes = new ArrayList<>();
|
||||||
TimeControlManager.getInstance().getAppTimeControlMap().entrySet().stream().forEach((entry) -> {
|
HashMap<String, AppTimeControl> appTimeControlHashMap = TimeControlManager.getInstance().getAppTimeControlMap();
|
||||||
|
if (appTimeControlHashMap == null || appTimeControlHashMap.size() == 0) {
|
||||||
|
return appUsageTimes;
|
||||||
|
}
|
||||||
|
appTimeControlHashMap.entrySet().stream().forEach((entry) -> {
|
||||||
if (entry.getValue().getTc_class_id() == id) {
|
if (entry.getValue().getTc_class_id() == id) {
|
||||||
String pkg = entry.getKey();
|
String pkg = entry.getKey();
|
||||||
if (TextUtils.isEmpty(pkg)) {
|
if (TextUtils.isEmpty(pkg)) {
|
||||||
@@ -819,6 +913,7 @@ public class RunningAppManager {
|
|||||||
appUsageTime.setAppName(getAppName(pkg));
|
appUsageTime.setAppName(getAppName(pkg));
|
||||||
AppRunTimeBean appRunTimeBean = mRemainingTimeMap.get(pkg);
|
AppRunTimeBean appRunTimeBean = mRemainingTimeMap.get(pkg);
|
||||||
long usageTime = appRunTimeBean.getAppRunTime();
|
long usageTime = appRunTimeBean.getAppRunTime();
|
||||||
|
Log.e(TAG, "getAppClassificationTime: " + pkg + ": usageTime = " + usageTime);
|
||||||
long time;
|
long time;
|
||||||
if (inWeekDay()) {
|
if (inWeekDay()) {
|
||||||
time = entry.getValue().getWork_time() - usageTime;
|
time = entry.getValue().getWork_time() - usageTime;
|
||||||
@@ -1201,7 +1296,6 @@ public class RunningAppManager {
|
|||||||
ActivityManager.RunningAppProcessInfo topAppProcess = (ActivityManager.RunningAppProcessInfo) pis.get(0);
|
ActivityManager.RunningAppProcessInfo topAppProcess = (ActivityManager.RunningAppProcessInfo) pis.get(0);
|
||||||
if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||||
return topAppProcess.processName;
|
return topAppProcess.processName;
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//getRunningTasks() is deprecated since API Level 21 (Android 5.0)
|
//getRunningTasks() is deprecated since API Level 21 (Android 5.0)
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ public class ControlManager {
|
|||||||
}
|
}
|
||||||
SystemSettings systemSettings = GsonUtils.toJavaObject(jsonString, SystemSettings.class);
|
SystemSettings systemSettings = GsonUtils.toJavaObject(jsonString, SystemSettings.class);
|
||||||
if (null != systemSettings) {
|
if (null != systemSettings) {
|
||||||
setUSBstate(systemSettings);
|
// setUSBstate(systemSettings);
|
||||||
|
ControlPanelManager.getInstance().setUsbStatus(systemSettings.getSetting_usb());
|
||||||
setPhoneList(systemSettings);
|
setPhoneList(systemSettings);
|
||||||
setBluetooth(systemSettings);
|
setBluetooth(systemSettings);
|
||||||
setHotspot(systemSettings);
|
setHotspot(systemSettings);
|
||||||
@@ -99,7 +100,8 @@ public class ControlManager {
|
|||||||
Log.e(TAG, "setSystemSetting: SystemSettings is NULL");
|
Log.e(TAG, "setSystemSetting: SystemSettings is NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setUSBstate(systemSettings);
|
// setUSBstate(systemSettings);
|
||||||
|
ControlPanelManager.getInstance().setUsbStatus(systemSettings.getSetting_usb());
|
||||||
setPhoneList(systemSettings);
|
setPhoneList(systemSettings);
|
||||||
setBluetooth(systemSettings);
|
setBluetooth(systemSettings);
|
||||||
setHotspot(systemSettings);
|
setHotspot(systemSettings);
|
||||||
@@ -729,7 +731,8 @@ public class ControlManager {
|
|||||||
//仅充电:usb_charge
|
//仅充电:usb_charge
|
||||||
//MTP模式:usb_mtp
|
//MTP模式:usb_mtp
|
||||||
//Midi模式:usb_midi
|
//Midi模式:usb_midi
|
||||||
String setting_usb = Settings.System.getString(mResolver, "qch_usb_choose");
|
// String setting_usb = Settings.System.getString(mResolver, "qch_usb_choose");
|
||||||
|
String setting_usb = MMKV.defaultMMKV().decodeString(ControlPanelManager.KEY_USB_STATUS, "usb_charge");
|
||||||
Log.e("SystemSetting", "setting_usb:" + setting_usb);
|
Log.e("SystemSetting", "setting_usb:" + setting_usb);
|
||||||
String usbStatus = "";
|
String usbStatus = "";
|
||||||
if (TextUtils.isEmpty(setting_usb)) {
|
if (TextUtils.isEmpty(setting_usb)) {
|
||||||
|
|||||||
@@ -2013,10 +2013,10 @@ public class NetInterfaceManager {
|
|||||||
public void onNext(@NonNull BaseResponse<SystemSettingsSet> BaseResponse) {
|
public void onNext(@NonNull BaseResponse<SystemSettingsSet> BaseResponse) {
|
||||||
int code = BaseResponse.code;
|
int code = BaseResponse.code;
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
String data = new Gson().toJson(BaseResponse.data.getAdmin());
|
String data = new Gson().toJson(BaseResponse.data.getUser());
|
||||||
Log.e("getSystemSettings", "onNext: " + data);
|
Log.e("getSystemSettings", "onNext: " + data);
|
||||||
ControlManager.getInstance().setSystemSetting(data);
|
ControlManager.getInstance().setSystemSetting(data);
|
||||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(BaseResponse.data.getAdmin()));
|
mCacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(BaseResponse.data.getUser()));
|
||||||
} else {
|
} else {
|
||||||
ControlManager.getInstance().setDisableSetting();
|
ControlManager.getInstance().setDisableSetting();
|
||||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
||||||
|
|||||||
@@ -146,16 +146,16 @@ public class DownloadService extends Service {
|
|||||||
|
|
||||||
@Download.onTaskFail
|
@Download.onTaskFail
|
||||||
void taskFail(DownloadTask task, Exception e) {
|
void taskFail(DownloadTask task, Exception e) {
|
||||||
Aria.download(this).resumeAllTask();
|
// Aria.download(this).resumeAllTask();
|
||||||
final String filepath = task.getFilePath();
|
final String filepath = task.getFilePath();
|
||||||
final String packageName = task.getExtendField();
|
final String packageName = task.getExtendField();
|
||||||
try {
|
try {
|
||||||
Log.e(TAG, "taskFail: " + "Exception: " + e.getLocalizedMessage());
|
Log.e(TAG, "taskFail: " + "Exception: " + e.getMessage());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
Log.e(TAG, "taskFail: Exception = " + e.getMessage());
|
||||||
}
|
}
|
||||||
Log.e(TAG, "taskFail: " + packageName + "filepath: " + filepath);
|
Log.e(TAG, "taskFail: " + packageName + "filepath: " + filepath);
|
||||||
|
Aria.download(this).load(task.getDownloadEntity().getId()).cancel(true);
|
||||||
// Aria.download(this)
|
// Aria.download(this)
|
||||||
// .load(task.getDownloadEntity().getRealUrl()) //读取下载地址
|
// .load(task.getDownloadEntity().getRealUrl()) //读取下载地址
|
||||||
// .setFilePath(task.getFilePath())
|
// .setFilePath(task.getFilePath())
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
SPUtils.put(mContext, "is_first_connection", 0);
|
SPUtils.put(mContext, "is_first_connection", 0);
|
||||||
int code = systemSettingsBaseResponse.code;
|
int code = systemSettingsBaseResponse.code;
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
String data = new Gson().toJson(systemSettingsBaseResponse.data.getAdmin());
|
String data = new Gson().toJson(systemSettingsBaseResponse.data.getUser());
|
||||||
ControlManager.getInstance().setSystemSetting(data);
|
ControlManager.getInstance().setSystemSetting(data);
|
||||||
} else {
|
} else {
|
||||||
ControlManager.getInstance().setDisableSetting();
|
ControlManager.getInstance().setDisableSetting();
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -24,8 +22,6 @@ import android.view.WindowManager;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.internal.view.RotationPolicy;
|
import com.android.internal.view.RotationPolicy;
|
||||||
import com.arialyy.aria.core.Aria;
|
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
@@ -487,7 +483,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
private static final String ACTION_APP_CONTROL = "81";
|
private static final String ACTION_APP_CONTROL = "81";
|
||||||
/*更新白名单*/
|
/*更新白名单*/
|
||||||
private static final String UPDATE_WHITE_LIST = "83";
|
private static final String UPDATE_WHITE_LIST = "83";
|
||||||
|
/*一键断网*/
|
||||||
|
private static final String ACTION_DISABLE_NETWORK = "85";
|
||||||
|
|
||||||
private void processCustomMessage(Context context, XGPushTextMessage message) {
|
private void processCustomMessage(Context context, XGPushTextMessage message) {
|
||||||
if (context == null || message == null) {
|
if (context == null || message == null) {
|
||||||
@@ -797,6 +794,10 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
case UPDATE_WHITE_LIST:
|
case UPDATE_WHITE_LIST:
|
||||||
NetInterfaceManager.getInstance().getAllappPackage();
|
NetInterfaceManager.getInstance().getAllappPackage();
|
||||||
break;
|
break;
|
||||||
|
case ACTION_DISABLE_NETWORK:
|
||||||
|
ToastUtil.debugShow("收到推送消息: 一键断网");
|
||||||
|
oneKeyNetwork(context, extras);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1561,4 +1562,14 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
String packeges = jsonObject.get("typewriting_app").getAsString();
|
String packeges = jsonObject.get("typewriting_app").getAsString();
|
||||||
JGYUtils.getInstance().setDefaultInputMethod(packeges);
|
JGYUtils.getInstance().setDefaultInputMethod(packeges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void oneKeyNetwork(Context context, String extras) {
|
||||||
|
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
|
||||||
|
int is_network = jsonObject.get("is_network").getAsInt();
|
||||||
|
if (is_network==1){
|
||||||
|
JGYUtils.getInstance().oneKeyDisconnection();
|
||||||
|
}else {
|
||||||
|
JGYUtils.getInstance().restorrNetwork();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import com.uiui.sn.BuildConfig;
|
|||||||
import com.uiui.sn.R;
|
import com.uiui.sn.R;
|
||||||
import com.uiui.sn.config.CommonConfig;
|
import com.uiui.sn.config.CommonConfig;
|
||||||
import com.uiui.sn.gson.GsonUtils;
|
import com.uiui.sn.gson.GsonUtils;
|
||||||
|
import com.uiui.sn.network.NetInterfaceManager;
|
||||||
import com.uiui.sn.receiver.BootReceiver;
|
import com.uiui.sn.receiver.BootReceiver;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -61,6 +62,8 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||||
|
|
||||||
@@ -1265,4 +1268,25 @@ public class JGYUtils {
|
|||||||
return IMEI.toUpperCase();
|
return IMEI.toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void oneKeyDisconnection() {
|
||||||
|
List<String> thirdPartyList = ApkUtils.queryFilterAppList(mContext);
|
||||||
|
thirdPartyList.addAll(fuxiaoyingApp);
|
||||||
|
thirdPartyList.removeIf(TextUtils::isEmpty);
|
||||||
|
HashSet<String> packageSet = thirdPartyList.stream().filter(new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean test(String s) {
|
||||||
|
return !BuildConfig.APPLICATION_ID.equals(s);
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
String disString = String.join(",", packageSet);
|
||||||
|
Log.e(TAG, "oneKeyDisconnection: " + disString);
|
||||||
|
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, disString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restorrNetwork() {
|
||||||
|
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, "");
|
||||||
|
NetInterfaceManager.getInstance().getAllappPackage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user