version:3.3.8
fix:修复没有设置管控时间无法管控问题 update:
This commit is contained in:
@@ -74,8 +74,8 @@ android {
|
||||
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 74
|
||||
versionName "3.3.4"
|
||||
versionCode 78
|
||||
versionName "3.3.8"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
@@ -15,6 +12,9 @@ import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.utils.CXAESUtil;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
@Override
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
.getSnInfo(getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSnInfo", "onSubscribe: ");
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.app.ActivityTaskManager;
|
||||
import android.app.usage.UsageStats;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -24,9 +25,6 @@ import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.Statistics.AppInformation;
|
||||
import com.fuying.sn.Statistics.StatisticsInfo;
|
||||
@@ -42,6 +40,9 @@ import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.utils.AppUsedTimeUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -906,7 +907,7 @@ public class RunningAppManager {
|
||||
boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg);
|
||||
Log.e(TAG, "inControlTime: havaConfigure = " + havaConfigure);
|
||||
MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl();
|
||||
Log.e(TAG, "inControlTime: inControlTime = " + machineControl);
|
||||
Log.e(TAG, "inControlTime: machineControl = " + machineControl);
|
||||
if (machineControl == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -924,6 +925,7 @@ public class RunningAppManager {
|
||||
if (havaConfigure) {//app有单独配置的情况
|
||||
//有单独设置 不管是分类整机还是其他都是这个设置
|
||||
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
||||
Log.d(TAG, "inControlTime: appTimeControl = " + appTimeControl);
|
||||
if (appTimeControl.getIs_control() == 0) {//先判断是否被禁用
|
||||
Log.e(TAG, "inControlTime: appTimeControl " + "应用已被禁用");
|
||||
ToastUtil.show("应用已被禁用");
|
||||
@@ -933,11 +935,12 @@ public class RunningAppManager {
|
||||
Log.e(TAG, "inControlTime: appTimeControl " + "应用始终可用");
|
||||
return false;
|
||||
}
|
||||
if (work_time == 0 && rest_time == 0 && is_set == 0 && is_part == 0) {
|
||||
//没有整机额度,没有整机时段,没有修改临时时长
|
||||
Log.e(TAG, "inControlTime: appTimeControl not set");
|
||||
return false;
|
||||
}
|
||||
// TODO: 2025/6/24 没有整机额度也能管控
|
||||
// if (work_time == 0 && rest_time == 0 && is_set == 0 && is_part == 0) {
|
||||
// //没有整机额度,没有整机时段,没有修改临时时长
|
||||
// Log.e(TAG, "inControlTime: appTimeControl not set");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (appTimeControl.getIs_quota() == 1) {//app额度打开
|
||||
Log.e(TAG, "inControlTime: appTimeControl is_quota = 1");
|
||||
@@ -1625,11 +1628,7 @@ public class RunningAppManager {
|
||||
Log.e(TAG, "inControlTime: ContralTime " + (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()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1740,11 +1739,7 @@ public class RunningAppManager {
|
||||
*/
|
||||
public boolean inWeekDay(long time) {
|
||||
int weekDay = getWeekDay(time);
|
||||
if (weekDay > 5) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return weekDay <= 5;
|
||||
}
|
||||
|
||||
private String getTopActivityInfo() {
|
||||
@@ -1762,8 +1757,15 @@ public class RunningAppManager {
|
||||
// return localRunningTaskInfo.topActivity.getPackageName();
|
||||
// }
|
||||
ActivityManager manager = (ActivityManager) mContext.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
String currentClassName = manager.getRunningTasks(1).get(0).topActivity.getPackageName();
|
||||
return currentClassName;
|
||||
List<ActivityManager.RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1);
|
||||
if (runningTaskInfos != null && !runningTaskInfos.isEmpty()) {
|
||||
ComponentName componentName = runningTaskInfos.get(0).topActivity;
|
||||
if (componentName != null) {
|
||||
String currentClassName = componentName.getPackageName();
|
||||
return currentClassName;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,10 +5,10 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
@@ -161,6 +161,7 @@ public class TimeControlManager {
|
||||
*/
|
||||
public void setAppTimeControlMap(List<AppTimeControl> appTimeControlList) {
|
||||
if (appTimeControlList == null || appTimeControlList.size() == 0) {
|
||||
Log.e(TAG, "setAppTimeControlMap: appTimeControlList is empty");
|
||||
return;
|
||||
}
|
||||
HashMap<Integer, AppTimeControl> classifyTimeControlHashMap = new HashMap<>();
|
||||
|
||||
@@ -594,6 +594,7 @@ public class NetInterfaceManager {
|
||||
void onComplete();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getSnInfo(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
@@ -2538,7 +2539,8 @@ public class NetInterfaceManager {
|
||||
int isLogined = (int) SPUtils.get(mContext, CommonConfig.isLogined, 2);
|
||||
if (isLogined != 1) {
|
||||
Log.e(TAG, "sendCloseApp: 没有绑定");
|
||||
return;
|
||||
// TODO: 2025/6/13 延迟获取不了数据
|
||||
// return;
|
||||
}
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageInfo appInfo = null;
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.fuying.sn.IGetInfoInterface;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.service.main.MainService;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
@@ -92,8 +91,9 @@ public class RemoteService extends Service {
|
||||
|
||||
@Override
|
||||
public boolean inControl(String pkg) throws RemoteException {
|
||||
Log.e(TAG, "inControl: " + RunningAppManager.getInstance().inControlTime(pkg));
|
||||
return RunningAppManager.getInstance().inControlTime(pkg);
|
||||
boolean control = RunningAppManager.getInstance().inControlTime(pkg);
|
||||
Log.e(TAG, "inControl: " + control);
|
||||
return control;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -122,7 +122,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance().getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
NetInterfaceManager.getInstance().getSnInfo(getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSnInfom", "onSubscribe: ");
|
||||
@@ -329,7 +329,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getSnTimeControl() {
|
||||
NetInterfaceManager.getInstance().getSnTimeControl(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
NetInterfaceManager.getInstance().getSnTimeControl(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setSnTimeControl();
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.os.AsyncTask;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
@@ -92,10 +93,9 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
//第一次开机联网后直接连接
|
||||
// TODO: 2022/11/21 有些设备联网了但是立刻请求还是失败
|
||||
Log.e(TAG, "onConnected run: 15秒后请求网络");
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
// if (JGYUtils.getInstance().isScreenOn()) {
|
||||
Log.e(TAG, "getSnInfo1");
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
|
||||
@@ -103,6 +103,8 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
});
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAppAndWhite();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
tPushInit();
|
||||
// }
|
||||
@@ -150,7 +152,7 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
Log.e(TAG, "onCreate: networkConnected = " + networkConnected);
|
||||
// if (networkConnected && reboot) {
|
||||
Log.e(TAG, "onCreate run: 20秒后请求网络");
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e("TimeObserver", "run: " + NetStateUtils.isNetworkConnected(MainService.this));
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -538,7 +539,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().setBrowserWhiteList();
|
||||
@@ -548,7 +549,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
case JIGUANG_APP_NETWORKSTATE:
|
||||
ToastUtil.debugShow("收到推送消息: 应用联网管控");
|
||||
setAppNetworkstate(context, extras);
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getAppInside();
|
||||
@@ -600,7 +601,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
break;
|
||||
case JIGUANG_APP_NET_AUTO:
|
||||
ToastUtil.debugShow("收到推送消息: APP联网自启管控");
|
||||
Handler.getMain().postDelayed(() -> NetInterfaceManager.getInstance().getAllappPackage(), 2000);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> NetInterfaceManager.getInstance().getAllappPackage(), 2000);
|
||||
break;
|
||||
case JIGUANG_BROWSER_LABEL:
|
||||
ToastUtil.debugShow("收到推送消息: 浏览器书签");
|
||||
@@ -610,7 +611,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//延时2秒执行,以防收到推送数据库还没有生效
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getBrowserWhiteList();
|
||||
@@ -621,7 +622,6 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
case JIGUANG_SYSTEM_SETTING:
|
||||
ToastUtil.debugShow("收到推送消息: 系统管控");
|
||||
// ControlManager.getInstance().setSystemSetting(extras);
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
// if ("com.jiaoguanyi.os".equals(ForegroundAppUtil.getForegroundPackageName(context))) {
|
||||
// JGYUtils.getInstance().killBackgroundProcesses(context, "com.jiaoguanyi.os");
|
||||
// Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.jiaoguanyi.os");
|
||||
@@ -629,7 +629,9 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
// context.startActivity(intent);
|
||||
// } else {
|
||||
// JGYUtils.getInstance().killBackgroundProcesses(context, "com.jiaoguanyi.os");
|
||||
|
||||
// }
|
||||
updateUserSettings();
|
||||
break;
|
||||
case JIGUANG_RESET_DEVICES:
|
||||
ToastUtil.debugShow("收到推送消息: 设备恢复出厂设置");
|
||||
@@ -642,7 +644,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
break;
|
||||
case JIGUANG_APP_SETTING:
|
||||
ToastUtil.debugShow("收到推送消息: 获取app管控设置");
|
||||
Handler.getMain().postDelayed(() -> NetInterfaceManager.getInstance().getAllappPackage(), 2000);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> NetInterfaceManager.getInstance().getAllappPackage(), 2000);
|
||||
break;
|
||||
case JIGUANG_FORCE_KILL:
|
||||
ToastUtil.debugShow("收到推送消息: 强制停止应用");
|
||||
@@ -793,19 +795,16 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
break;
|
||||
case ACTION_PARENTAL_CONTROL:
|
||||
ToastUtil.debugShow("收到推送消息: 家长管控");
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
updateUserSettings();
|
||||
break;
|
||||
case ACTION_WHOLE_MACHINE_QUOTA:
|
||||
ToastUtil.debugShow("收到推送消息: 整机管控");
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||
|
||||
updateUserSettings();
|
||||
break;
|
||||
case ACTION_APP_CONTROL:
|
||||
ToastUtil.debugShow("收到推送消息: APP管控");
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||
updateUserSettings();
|
||||
break;
|
||||
case UPDATE_WHITE_LIST:
|
||||
NetInterfaceManager.getInstance().getAllappPackage();
|
||||
@@ -830,12 +829,24 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUserSettings() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getSnInfo();
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||
}
|
||||
}, 2345);
|
||||
}
|
||||
|
||||
private void addApkToWhiteList(String extras) {
|
||||
Random random = new Random();
|
||||
//避免同时请求
|
||||
int number = random.nextInt(10000);
|
||||
Log.e(TAG, "addApkToWhiteList: Random " + number);
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(new NetInterfaceManager.WhiteListCallback() {
|
||||
|
||||
Reference in New Issue
Block a user