refactor(time): 重构时间管控配置为仓库统一管理
将配置拉取、本地缓存与重试逻辑内聚到 TimeConfigRepository, TimeManager 通过监听回调同步运行时状态,并新增 Room 持久化剩余时长。 同时收敛 UID 重要性回调到主线程,修复应用切换时记录丢失与重复问题。
This commit is contained in:
1 parent
0856c22ce8
commit
d28f9ac288
26 files changed
+1555
-1280
No files matched your search
@@ -1,82 +0,0 @@
|
||||
package com.fuying.sn.service.main;
|
||||
|
||||
import com.fuying.sn.base.mvp.BasePresenter;
|
||||
import com.fuying.sn.base.mvp.BaseView;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
|
||||
public class MainSContact {
|
||||
public interface MainView extends BaseView {
|
||||
|
||||
void setSnInfo(BaseResponse<SnInfo> response);
|
||||
void setLocked(int lockedStatus);
|
||||
void updateInfoFinish();
|
||||
void checkUpdateFinish();
|
||||
void checkFXYUpdateFinish();
|
||||
void getAppAndWhiteFinish();
|
||||
void setOverallApp();
|
||||
void setLockScreenPwd();
|
||||
void setAppInside();
|
||||
void setForceInstall();
|
||||
void setSnBind();
|
||||
void setSystemSettings();
|
||||
void setBrowserLabel();
|
||||
void setBrowserWhiteList();
|
||||
void setAppJump();
|
||||
void setAppStart();
|
||||
void setAppTimeControl();
|
||||
void setSnTimeControl();
|
||||
void setMyAppList();
|
||||
void setScreenLock();
|
||||
}
|
||||
|
||||
interface Presenter extends BasePresenter<MainView> {
|
||||
|
||||
/*更新的*/
|
||||
//获取所有app包名
|
||||
void getAppAndWhite();
|
||||
//检查更新
|
||||
void checkUpdate();
|
||||
//检查扶小鹰App更新
|
||||
void checkFXYUpdate();
|
||||
/*获取所有全局更新*/
|
||||
void getOverallApp();
|
||||
//获取锁屏密码
|
||||
void getLockScreenPwd();
|
||||
|
||||
/*获取上传或下载的*/
|
||||
//获取设备信息
|
||||
void getSnInfo();
|
||||
//获取锁定状态
|
||||
void getLocked();
|
||||
|
||||
//上传设备信息
|
||||
void updateDeviceInfo();
|
||||
|
||||
//获取强制下载
|
||||
void getForceInstall();
|
||||
//获取id管控
|
||||
void getAppInside();
|
||||
//获取设备绑定状态
|
||||
void getSnBind();
|
||||
//获取系统设置
|
||||
void getSystemSettings();
|
||||
//获取浏览器书签
|
||||
void getBrowserLabel();
|
||||
//获取浏览器黑白名单
|
||||
void getBrowserWhiteList();
|
||||
//获取内部网址管控
|
||||
void getAppJump();
|
||||
//应用自启
|
||||
void getAppStart();
|
||||
//获取时间管控
|
||||
void getAppTimeControl();
|
||||
//获取整机管控
|
||||
void getSnTimeControl();
|
||||
//获取所有应用使用时间
|
||||
void getMyAppList();
|
||||
//获取锁屏管控
|
||||
void getScreenLock();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,15 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleService;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelStore;
|
||||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.base.rx.BaseRxService;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
@@ -44,8 +50,6 @@ import com.fuying.sn.utils.TimeUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -56,15 +60,13 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author jgy02
|
||||
*/
|
||||
public class MainService extends BaseRxService implements MainSContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
|
||||
public class MainService extends LifecycleService implements ViewModelStoreOwner, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = "MainService";
|
||||
|
||||
public MainSPresenter mPresenter;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private MainServiceModel mViewModel;
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.e(TAG, "网络未连接");
|
||||
@@ -98,10 +100,11 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
Log.e("onConnected", "onNext: getAppWhiteList");
|
||||
});
|
||||
TimeManager.getInstance().getTimeControl();
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAppAndWhite();
|
||||
mViewModel.getSnInfo();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
// 网络重连后,重新上传本地缓存的应用使用记录
|
||||
NetInterfaceManager.getInstance().reUploadAppUsageRecords();
|
||||
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
}
|
||||
}
|
||||
@@ -113,8 +116,32 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
// NetInterfaceManager.getInstance().getSnTimeControl();
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewModelStore:Service 销毁时自动清空,从而触发 ViewModel.onCleared(),
|
||||
* 保证 ViewModel 内部 RxJava 任务被正确取消,避免内存泄漏。
|
||||
*/
|
||||
private final ViewModelStore mViewModelStore = new ViewModelStore();
|
||||
|
||||
// ============================================================
|
||||
// ViewModelStoreOwner 实现
|
||||
// ============================================================
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewModelStore getViewModelStore() {
|
||||
return mViewModelStore;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Lifecycle getLifecycle() {
|
||||
return super.getLifecycle();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
super.onBind(intent);
|
||||
return mMainBinder;
|
||||
}
|
||||
|
||||
@@ -131,10 +158,9 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
super.onCreate();
|
||||
Log.e(TAG, "onCreate: ");
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
mViewModel = new ViewModelProvider(this, new ViewModelProvider.AndroidViewModelFactory(getApplication())).get(MainServiceModel.class);
|
||||
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
mPresenter.attachView(this);
|
||||
mViewModel.mSnInfoLiveData.observe(this,this::setSnInfo);
|
||||
|
||||
// if (BuildConfig.DEBUG){
|
||||
// Settings.Global.putInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
@@ -160,8 +186,7 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
Log.e("TimeObserver", "onNext: getAppWhiteList");
|
||||
});
|
||||
Log.e(TAG, "getSnInfo1");
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAppAndWhite();
|
||||
mViewModel.getSnInfo();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
}
|
||||
@@ -234,11 +259,19 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
|
||||
// configStart.onstar("onStartCommand");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void startService() {
|
||||
startService(new Intent(this, GuardService.class));
|
||||
startService(new Intent(this, StepService.class));
|
||||
startService(new Intent(this, DownloadService.class));
|
||||
}
|
||||
|
||||
|
||||
private void initConfig() {
|
||||
// Utils.getPublicIP(MainService.this);
|
||||
AmapManager.getInstance().startLocation();
|
||||
@@ -284,15 +317,9 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
mPresenter.detachView();
|
||||
unregisterReceivers();
|
||||
}
|
||||
|
||||
private void startService() {
|
||||
startService(new Intent(this, GuardService.class));
|
||||
startService(new Intent(this, StepService.class));
|
||||
startService(new Intent(this, DownloadService.class));
|
||||
}
|
||||
|
||||
private class NTPTimeTask extends AsyncTask<String, Long, Long> {
|
||||
@Override
|
||||
@@ -310,6 +337,40 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
public void setSnInfo(BaseResponse<SnInfo> response) {
|
||||
if (response != null) {
|
||||
int code = response.code;
|
||||
//设备已经绑定
|
||||
if (code == 200) {
|
||||
TimeManager.getInstance().getTimeControl();
|
||||
mViewModel.getMyAppList();
|
||||
mViewModel.getAppAndWhite();
|
||||
mViewModel.getForceInstall();
|
||||
|
||||
mViewModel.checkUpdate();
|
||||
mViewModel.getOverallApp();
|
||||
mViewModel.getLockScreenPwd();
|
||||
mViewModel.getScreenLock();
|
||||
mViewModel.getAppInside();
|
||||
mViewModel.getSnBind();
|
||||
mViewModel.getSystemSettings();
|
||||
mViewModel.getAppJump();
|
||||
mViewModel.getAppStart();
|
||||
|
||||
mViewModel.updateDeviceInfo();
|
||||
}
|
||||
//设备没有绑定
|
||||
else if (code == 300) {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
//没有授权的设备
|
||||
else if (code == 401) {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerReceivers() {
|
||||
registerWiFiReceiver();
|
||||
@@ -420,7 +481,7 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
switch (action) {
|
||||
case Intent.ACTION_USER_PRESENT:
|
||||
// TODO: 2022/11/3 暂时屏蔽获取
|
||||
// mPresenter.getAppTimeControl();
|
||||
// mViewModel.getAppTimeControl();
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_ON:
|
||||
getAppControl();
|
||||
@@ -452,135 +513,4 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppAndWhiteFinish() {
|
||||
mPresenter.checkUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUpdateFinish() {
|
||||
mPresenter.checkFXYUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkFXYUpdateFinish() {
|
||||
mPresenter.getOverallApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverallApp() {
|
||||
mPresenter.getLockScreenPwd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockScreenPwd() {
|
||||
Log.e(TAG, "setLockScreenPwd: finish");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSnInfo(BaseResponse<SnInfo> response) {
|
||||
if (response != null) {
|
||||
int code = response.code;
|
||||
//设备已经绑定
|
||||
if (code == 200) {
|
||||
mPresenter.getLocked();
|
||||
SnInfo snInfo = response.data;
|
||||
// NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
|
||||
}
|
||||
//设备没有绑定
|
||||
else if (code == 300) {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
//没有授权的设备
|
||||
else if (code == 401) {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocked(int lockedStatus) {
|
||||
Log.e(TAG, "setLocked: " + lockedStatus);
|
||||
switch (lockedStatus) {
|
||||
case 0://没有绑定的
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
break;
|
||||
case 1://绑定了的
|
||||
mPresenter.getForceInstall();
|
||||
break;
|
||||
case 2://sn没有导入后台的
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
mPresenter.updateDeviceInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfoFinish() {
|
||||
mPresenter.getScreenLock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScreenLock() {
|
||||
Log.e(TAG, "setLockScreenPwd: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForceInstall() {
|
||||
mPresenter.getAppInside();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppInside() {
|
||||
mPresenter.getSnBind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnBind() {
|
||||
mPresenter.getSystemSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemSettings() {
|
||||
mPresenter.getBrowserLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrowserLabel() {
|
||||
mPresenter.getBrowserWhiteList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrowserWhiteList() {
|
||||
mPresenter.getAppJump();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppJump() {
|
||||
mPresenter.getAppStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppStart() {
|
||||
mPresenter.getAppTimeControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppTimeControl() {
|
||||
mPresenter.getSnTimeControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnTimeControl() {
|
||||
mPresenter.getMyAppList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMyAppList() {
|
||||
|
||||
}
|
||||
}
|
||||
+89
-165
@@ -1,18 +1,22 @@
|
||||
package com.fuying.sn.service.main;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.MyAppUsageBean;
|
||||
import com.fuying.sn.bean.SnBindState;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
@@ -32,107 +36,27 @@ import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* @author jgy02
|
||||
*/
|
||||
public class MainSPresenter implements MainSContact.Presenter {
|
||||
private static final String TAG = "MainSPresenter";
|
||||
|
||||
private MainSContact.MainView mView;
|
||||
private Context mContext;
|
||||
private CacheHelper mCacheHelper;
|
||||
public class MainServiceModel extends AndroidViewModel {
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
public MainSPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
public MainServiceModel(@androidx.annotation.NonNull Application application) {
|
||||
super(application);
|
||||
}
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
public MutableLiveData<BaseResponse<SnInfo>> mSnInfoLiveData = new MutableLiveData<>();
|
||||
|
||||
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(MainSContact.MainView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppAndWhite() {
|
||||
NetInterfaceManager.getInstance().getAppAndWhite(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.getAppAndWhiteFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUpdate() {
|
||||
NetInterfaceManager.getInstance().checkAllAppUpdate(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.checkUpdateFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkFXYUpdate() {
|
||||
// NetInterfaceManager.getInstance().checkFXYAppUpdate(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// mView.checkFXYUpdateFinish();
|
||||
// }
|
||||
// });
|
||||
mView.checkFXYUpdateFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOverallApp() {
|
||||
NetInterfaceManager.getInstance().getOverallApp(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setOverallApp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLockScreenPwd() {
|
||||
NetInterfaceManager.getInstance().getLockScreenPwd(true, lifecycle, new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setLockScreenPwd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance().getSnInfo(getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
NetInterfaceManager.getInstance().getSnInfo(new NetInterfaceManager.ObserverCallback<SnInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSnInfom", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
public void onNext(BaseResponse<SnInfo> response) {
|
||||
Log.e("getSnInfom", "onNext: " + response);
|
||||
mView.setSnInfo(response);
|
||||
mSnInfoLiveData.setValue(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,23 +71,49 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLocked() {
|
||||
int statu = (int) SPUtils.get(mContext, CommonConfig.isLogined, 2);
|
||||
mView.setLocked(statu);
|
||||
public void getAppAndWhite() {
|
||||
NetInterfaceManager.getInstance().getAppAndWhite(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
NetInterfaceManager.getInstance().checkAllAppUpdate(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getOverallApp() {
|
||||
NetInterfaceManager.getInstance().getOverallApp(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getLockScreenPwd() {
|
||||
NetInterfaceManager.getInstance().getLockScreenPwd(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceInfo() {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
mView.updateInfoFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppInside() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppInsideControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -181,8 +131,8 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
JgyUtils.getInstance().writeDeselectIDtoSystem(ids, packages);
|
||||
} else {
|
||||
Log.e("getAppInside", "onNext: " + baseResponse.msg);
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID_ID, " ");
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID_ARRAY, " ");
|
||||
Settings.System.putString(getApplication().getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID_ID, " ");
|
||||
Settings.System.putString(getApplication().getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID_ARRAY, " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,26 +145,22 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppInside", "onComplete: ");
|
||||
mView.setAppInside();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getForceInstall() {
|
||||
NetInterfaceManager.getInstance().getForceInstall(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
NetInterfaceManager.getInstance().getForceInstall(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setForceInstall();
|
||||
|
||||
Log.e("getForceInstall", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSnBind() {
|
||||
NetInterfaceManager.getInstance().getSnBindObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<SnBindState>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -242,50 +188,34 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSnBind", "onComplete: ");
|
||||
mView.setSnBind();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSystemSettings() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSystemSettings(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
.getSystemSettings(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setSystemSettings();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserLabel() {
|
||||
mView.setBrowserLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览器黑白名单
|
||||
*/
|
||||
@Override
|
||||
public void getBrowserWhiteList() {
|
||||
mView.setBrowserWhiteList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppJump() {
|
||||
NetInterfaceManager.getInstance().getAppJump(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
NetInterfaceManager.getInstance().getAppJump(new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setAppJump();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppStart() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppStartControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppStart>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -313,45 +243,42 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppStart", "onComplete: ");
|
||||
mView.setAppStart();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppTimeControl() {
|
||||
NetInterfaceManager.getInstance().getAppTimeControl(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setAppTimeControl();
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().getAppTimeControlInfo(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setAppTimeControl();
|
||||
}
|
||||
});
|
||||
// NetInterfaceManager.getInstance().getAppTimeControl(new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// NetInterfaceManager.getInstance().getAppTimeControlInfo(new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSnTimeControl() {
|
||||
NetInterfaceManager.getInstance().getMachineTimeControl(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setSnTimeControl();
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().getSnTimeControl(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setSnTimeControl();
|
||||
}
|
||||
});
|
||||
// NetInterfaceManager.getInstance().getMachineTimeControl(new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// NetInterfaceManager.getInstance().getSnTimeControl(new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyAppList() {
|
||||
NetInterfaceManager.getInstance().getMyAppList(new NetInterfaceManager.MyAppListCallback() {
|
||||
@Override
|
||||
@@ -359,19 +286,16 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
if (BuildConfig.VERSION_CODE < 88) {
|
||||
RunningAppManager.getInstance().syncAllAppUsageTime(myAppList);
|
||||
}
|
||||
mView.setMyAppList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getScreenLock() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnControlApi()
|
||||
.getScreenshot(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
|
||||
@Override
|
||||
@@ -386,10 +310,10 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
if (code == 200) {
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(GsonUtils.toJSONString(baseResponse.data));
|
||||
int is_screen_lock = jsonObject.get("is_screen_lock").getAsInt();
|
||||
if (!ServiceAliveUtils.isServiceAlive(mContext, ManagerService.class.getName())) {
|
||||
mContext.startService(new Intent(mContext, ManagerService.class));
|
||||
if (!ServiceAliveUtils.isServiceAlive(getApplication(), ManagerService.class.getName())) {
|
||||
getApplication().startService(new Intent(getApplication(), ManagerService.class));
|
||||
}
|
||||
SPUtils.put(mContext, ManagerService.LOCK_STATE, is_screen_lock);
|
||||
SPUtils.put(getApplication(), ManagerService.LOCK_STATE, is_screen_lock);
|
||||
Intent intent = new Intent();
|
||||
// intent.putExtra("name", name);
|
||||
if (1 == is_screen_lock) {
|
||||
@@ -397,13 +321,13 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
} else if (0 == is_screen_lock) {
|
||||
intent.setAction(ManagerService.ACTION_UNLOCK);
|
||||
}
|
||||
mContext.sendBroadcast(intent);
|
||||
getApplication().sendBroadcast(intent);
|
||||
} else {
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// SPUtils.put(mContext, ManagerService.LOCK_STATE, 1);
|
||||
// SPUtils.put(getApplication(), ManagerService.LOCK_STATE, 1);
|
||||
// Intent intent = new Intent();
|
||||
// intent.setAction(ManagerService.ACTION_LOCK);
|
||||
// mContext.sendBroadcast(intent);
|
||||
// getApplication().sendBroadcast(intent);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -417,8 +341,8 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getScreenLock", "onComplete: ");
|
||||
mView.setScreenLock();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user