version:3.4.5
fix: update:优化全局网络黑名单和第二天提示整机时间已用完
This commit is contained in:
@@ -74,8 +74,8 @@ android {
|
|||||||
|
|
||||||
official {
|
official {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 80
|
versionCode 85
|
||||||
versionName "3.4.0"
|
versionName "3.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ public class CommonConfig {
|
|||||||
public static final String KEY_IS_CONTROL = "is_control_key";
|
public static final String KEY_IS_CONTROL = "is_control_key";
|
||||||
|
|
||||||
public static final String DEVICES_IS_BIND_KEY = "is_bind_state";
|
public static final String DEVICES_IS_BIND_KEY = "is_bind_state";
|
||||||
|
/*内置应用名单*/
|
||||||
|
public static final String BUILT_IN_APPS = "built_in_apps_key";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备重启标志 重启后请求接口,Service重启不请求
|
* 设备重启标志 重启后请求接口,Service重启不请求
|
||||||
@@ -113,4 +115,8 @@ public class CommonConfig {
|
|||||||
/*WiFi白名单*/
|
/*WiFi白名单*/
|
||||||
public static final String AOLE_ACTION_AOLE_SSID_WHITE_LIST = "aole_ssid_whiteList";
|
public static final String AOLE_ACTION_AOLE_SSID_WHITE_LIST = "aole_ssid_whiteList";
|
||||||
|
|
||||||
|
/*应用动态权限*/
|
||||||
|
public static final String AOLE_APP_PRIVILEGE = "aole_app_privilege";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ 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.Random;
|
||||||
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.function.Predicate;
|
||||||
@@ -63,6 +64,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
import io.reactivex.rxjava3.functions.Consumer;
|
import io.reactivex.rxjava3.functions.Consumer;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
@@ -332,7 +335,29 @@ public class RunningAppManager {
|
|||||||
Log.i(TAG, "TimeChangedReceiver:" + action);
|
Log.i(TAG, "TimeChangedReceiver:" + action);
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
String finaWayDate = sdf.format(time);
|
String finaWayDate = sdf.format(time);
|
||||||
|
Log.e(TAG, "onReceive: finaWayDate = " + finaWayDate);
|
||||||
if ("00:00:00".equals(finaWayDate)) {
|
if ("00:00:00".equals(finaWayDate)) {
|
||||||
|
getConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getConfig() {
|
||||||
|
int min = 300;
|
||||||
|
int max = 1800;
|
||||||
|
Random random = new Random();
|
||||||
|
int randomNumber = random.nextInt(max - min + 1) + min; // 公式:nextInt(范围跨度) + 最小值
|
||||||
|
Observable.timer(randomNumber, TimeUnit.SECONDS)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<Long>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@io.reactivex.rxjava3.annotations.NonNull Long aLong) {
|
||||||
//清除数据保证及时性
|
//清除数据保证及时性
|
||||||
mMMKV.encode(RemainingTimeMap, "");
|
mMMKV.encode(RemainingTimeMap, "");
|
||||||
mMMKV.encode(GlobalUsageTimeMap, "");
|
mMMKV.encode(GlobalUsageTimeMap, "");
|
||||||
@@ -340,8 +365,20 @@ public class RunningAppManager {
|
|||||||
mRemainingTimeMap.clear();
|
mRemainingTimeMap.clear();
|
||||||
mGlobalUsageTime.clear();
|
mGlobalUsageTime.clear();
|
||||||
mAllAppUsageTime.clear();
|
mAllAppUsageTime.clear();
|
||||||
|
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||||
|
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killBackgroundProcesses(String processName) {
|
public void killBackgroundProcesses(String processName) {
|
||||||
@@ -730,6 +767,7 @@ public class RunningAppManager {
|
|||||||
* @param pkg
|
* @param pkg
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean inControlTime2(String pkg) {
|
public boolean inControlTime2(String pkg) {
|
||||||
Log.i(TAG, "inControlTime: pkg = " + pkg);
|
Log.i(TAG, "inControlTime: pkg = " + pkg);
|
||||||
if (allowPackage.contains(pkg)) {
|
if (allowPackage.contains(pkg)) {
|
||||||
@@ -975,6 +1013,11 @@ public class RunningAppManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {//app额度打开 app使用时段关闭
|
} else {//app额度打开 app使用时段关闭
|
||||||
|
if (globalRemainingTime <= 0) {
|
||||||
|
Log.e(TAG, "inControlTime: appTimeControl globalRemainingTime = 0");
|
||||||
|
ToastUtil.show("整机可用时间已用完");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Log.e(TAG, "inControlTime: appTimeControl is_quota = 1 is_part = 0");
|
Log.e(TAG, "inControlTime: appTimeControl is_quota = 1 is_part = 0");
|
||||||
if (appTimeControl.getRest_time() == 0 && appTimeControl.getWork_time() == 0) {//自由配置且没有设置额度
|
if (appTimeControl.getRest_time() == 0 && appTimeControl.getWork_time() == 0) {//自由配置且没有设置额度
|
||||||
return false;
|
return false;
|
||||||
@@ -1009,6 +1052,11 @@ public class RunningAppManager {
|
|||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "inControlTime: appTimeControl " + "不在管控时间内");
|
Log.e(TAG, "inControlTime: appTimeControl " + "不在管控时间内");
|
||||||
if (appTimeControl.getRest_time() == 0 && appTimeControl.getWork_time() == 0) {//自由配置且没有设置额度
|
if (appTimeControl.getRest_time() == 0 && appTimeControl.getWork_time() == 0) {//自由配置且没有设置额度
|
||||||
|
if (globalRemainingTime <= 0) {
|
||||||
|
Log.e(TAG, "inControlTime: appTimeControl globalRemainingTime = 0");
|
||||||
|
ToastUtil.show("整机可用时间已用完");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Log.e(TAG, "inControlTime: appTimeControl " + "自由配置且没有设置额度");
|
Log.e(TAG, "inControlTime: appTimeControl " + "自由配置且没有设置额度");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -1126,11 +1174,13 @@ public class RunningAppManager {
|
|||||||
|
|
||||||
private int getTodayTime(AppTimeControl appTimeControl) {
|
private int getTodayTime(AppTimeControl appTimeControl) {
|
||||||
if (inWeekDay()) {
|
if (inWeekDay()) {
|
||||||
Log.e(TAG, "getTodayTime: Work");
|
int workTime = (int) appTimeControl.getWork_time();
|
||||||
return (int) appTimeControl.getWork_time();
|
Log.e(TAG, "getTodayTime: Work = " + workTime);
|
||||||
|
return workTime;
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "getTodayTime: Rest");
|
int restTime = (int) appTimeControl.getRest_time();
|
||||||
return (int) appTimeControl.getRest_time();
|
Log.e(TAG, "getTodayTime: Rest = " + restTime);
|
||||||
|
return restTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2070,6 +2070,7 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void getSystemSettings(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getSystemSettings(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
@@ -2117,10 +2118,8 @@ public class NetInterfaceManager {
|
|||||||
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
|
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
|
||||||
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
|
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
|
||||||
SPUtils.put(mContext, "is_first_connection", 0);
|
SPUtils.put(mContext, "is_first_connection", 0);
|
||||||
//imei是否绑定
|
|
||||||
int is_bind = mMMKV.decodeInt(CommonConfig.DEVICES_IS_BIND_KEY, 0);
|
|
||||||
int code = systemSettingsBaseResponse.code;
|
int code = systemSettingsBaseResponse.code;
|
||||||
if (is_bind == 1) {
|
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
String data = new Gson().toJson(systemSettingsBaseResponse.data.getUser());
|
String data = new Gson().toJson(systemSettingsBaseResponse.data.getUser());
|
||||||
ControlManager.getInstance().setSystemSetting(data);
|
ControlManager.getInstance().setSystemSetting(data);
|
||||||
@@ -2128,9 +2127,14 @@ public class NetInterfaceManager {
|
|||||||
Settings.System.putInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 0);
|
Settings.System.putInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 0);
|
||||||
ControlManager.getInstance().setDisableSetting();
|
ControlManager.getInstance().setDisableSetting();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ControlManager.getInstance().setDisableSetting();
|
//imei是否绑定
|
||||||
}
|
// int is_bind = mMMKV.decodeInt(CommonConfig.DEVICES_IS_BIND_KEY, 0);
|
||||||
|
// if (is_bind == 1) {
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// ControlManager.getInstance().setDisableSetting();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2783,28 +2787,31 @@ public class NetInterfaceManager {
|
|||||||
// .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
// .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
// .subscribe(getAppJumpObserver(callback));
|
// .subscribe(getAppJumpObserver(callback));
|
||||||
|
|
||||||
Observable.zip(getAppJumpObservable(), getBlacklistObservable(), getBlacklistBiFunction()).subscribeOn(Schedulers.io())
|
Observable.zip(getAppJumpObservable(), getBlacklistObservable(), getBlacklistBiFunction())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
.subscribe(getBlacklistObserver());
|
.subscribe(getBlacklistObserver(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAppJump(CompleteCallback callback) {
|
public void getAppJump(CompleteCallback callback) {
|
||||||
// getAppJumpObservable()
|
// getAppJumpObservable()
|
||||||
// .subscribe(getAppJumpObserver(callback));
|
// .subscribe(getAppJumpObserver(callback));
|
||||||
|
|
||||||
Observable.zip(getAppJumpObservable(), getBlacklistObservable(), getBlacklistBiFunction()).subscribeOn(Schedulers.io())
|
Observable.zip(getAppJumpObservable(), getBlacklistObservable(), getBlacklistBiFunction())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(getBlacklistObserver());
|
.subscribe(getBlacklistObserver(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAppJump() {
|
public void getAppJump() {
|
||||||
// getAppJumpObservable()
|
// getAppJumpObservable()
|
||||||
// .subscribe(getAppJumpObserver(null));
|
// .subscribe(getAppJumpObserver(null));
|
||||||
|
|
||||||
Observable.zip(getAppJumpObservable(), getBlacklistObservable(), getBlacklistBiFunction()).subscribeOn(Schedulers.io())
|
Observable.zip(getAppJumpObservable(), getBlacklistObservable(), getBlacklistBiFunction())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(getBlacklistObserver());
|
.subscribe(getBlacklistObserver(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BiFunction<BaseResponse<List<AppJump>>, BaseResponse<BlacklistBean>, List<String>> getBlacklistBiFunction() {
|
private BiFunction<BaseResponse<List<AppJump>>, BaseResponse<BlacklistBean>, List<String>> getBlacklistBiFunction() {
|
||||||
@@ -2813,7 +2820,7 @@ public class NetInterfaceManager {
|
|||||||
public List<String> apply(BaseResponse<List<AppJump>> listBaseResponse, BaseResponse<BlacklistBean> blacklistBeanBaseResponse) throws Throwable {
|
public List<String> apply(BaseResponse<List<AppJump>> listBaseResponse, BaseResponse<BlacklistBean> blacklistBeanBaseResponse) throws Throwable {
|
||||||
Log.e("getBlacklistBiFunction", "apply: listBaseResponse = " + listBaseResponse);
|
Log.e("getBlacklistBiFunction", "apply: listBaseResponse = " + listBaseResponse);
|
||||||
Log.e("getBlacklistBiFunction", "apply: blacklistBeanBaseResponse = " + blacklistBeanBaseResponse);
|
Log.e("getBlacklistBiFunction", "apply: blacklistBeanBaseResponse = " + blacklistBeanBaseResponse);
|
||||||
List<String> blackListUrls = new ArrayList<>();
|
Set<String> blackListUrls = new HashSet<>();
|
||||||
if (listBaseResponse.code == 200) {
|
if (listBaseResponse.code == 200) {
|
||||||
List<AppJump> appJumpList = listBaseResponse.data;
|
List<AppJump> appJumpList = listBaseResponse.data;
|
||||||
if (appJumpList != null && !appJumpList.isEmpty()) {
|
if (appJumpList != null && !appJumpList.isEmpty()) {
|
||||||
@@ -2833,12 +2840,17 @@ public class NetInterfaceManager {
|
|||||||
blackListUrls.addAll(stringList);
|
blackListUrls.addAll(stringList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return blackListUrls;
|
// if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G12NLPlatform) {
|
||||||
|
blackListUrls.add("com.tencent.wemeet.app.com.tencent.wemeet.sdk.view.OnlyPrivacyBrowserActivity");
|
||||||
|
blackListUrls.add("com.tencent.wemeet.app.com.tencent.wemeet.components.webcore.activity.GestureBrowserActivity");
|
||||||
|
blackListUrls.add("com.tencent.wemeet.components.webcore.activity.GestureBrowserActivity");
|
||||||
|
// }
|
||||||
|
return new ArrayList<>(blackListUrls);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Observer<List<String>> getBlacklistObserver() {
|
private Observer<List<String>> getBlacklistObserver(CompleteCallback callback) {
|
||||||
return new Observer<List<String>>() {
|
return new Observer<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
@@ -2865,6 +2877,7 @@ public class NetInterfaceManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getBlacklistObserver", "onComplete: ");
|
Log.e("getBlacklistObserver", "onComplete: ");
|
||||||
|
if (callback != null) callback.onComplete();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3086,6 +3099,7 @@ public class NetInterfaceManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void getAppAndWhite(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getAppAndWhite(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
@@ -3140,9 +3154,11 @@ public class NetInterfaceManager {
|
|||||||
if (appAndWhiteList != null) {
|
if (appAndWhiteList != null) {
|
||||||
List<String> pkgList = appAndWhiteList.stream().map(AppAndWhiteBean::getApp_package).collect(Collectors.toList());
|
List<String> pkgList = appAndWhiteList.stream().map(AppAndWhiteBean::getApp_package).collect(Collectors.toList());
|
||||||
String pkgString = StringUtils.join(",", pkgList);
|
String pkgString = StringUtils.join(",", pkgList);
|
||||||
mMMKV.encode(UrlAddress.GET_APP_AND_WHITE, pkgString);
|
mMMKV.encode(CommonConfig.BUILT_IN_APPS, pkgString);
|
||||||
Log.e("getAppAndWhite", "onNext: " + pkgString);
|
Log.e("getAppAndWhite", "onNext: " + pkgString);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mMMKV.remove(CommonConfig.BUILT_IN_APPS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3155,6 +3171,7 @@ public class NetInterfaceManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getAppAndWhite", "onComplete: ");
|
Log.e("getAppAndWhite", "onComplete: ");
|
||||||
|
JGYUtils.getInstance().putBuiltInApps();
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onComplete();
|
callback.onComplete();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import android.util.Log;
|
|||||||
import com.fuying.sn.config.CommonConfig;
|
import com.fuying.sn.config.CommonConfig;
|
||||||
import com.fuying.sn.manager.ControlManager;
|
import com.fuying.sn.manager.ControlManager;
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
import com.fuying.sn.network.NetInterfaceManager;
|
||||||
import com.fuying.sn.service.main.MainService;
|
|
||||||
import com.fuying.sn.utils.ApkUtils;
|
|
||||||
import com.fuying.sn.utils.CacheUtils;
|
import com.fuying.sn.utils.CacheUtils;
|
||||||
import com.fuying.sn.utils.JGYUtils;
|
import com.fuying.sn.utils.JGYUtils;
|
||||||
import com.fuying.sn.utils.SPUtils;
|
import com.fuying.sn.utils.SPUtils;
|
||||||
@@ -53,6 +51,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
|||||||
case Intent.ACTION_PACKAGE_ADDED:
|
case Intent.ACTION_PACKAGE_ADDED:
|
||||||
state = "安装了:";
|
state = "安装了:";
|
||||||
JGYUtils.RemoveTask(context, packageName);
|
JGYUtils.RemoveTask(context, packageName);
|
||||||
|
JGYUtils.getInstance().putBuiltInApps();
|
||||||
break;
|
break;
|
||||||
case Intent.ACTION_PACKAGE_REPLACED:
|
case Intent.ACTION_PACKAGE_REPLACED:
|
||||||
cleanLauncher3Cache();
|
cleanLauncher3Cache();
|
||||||
@@ -91,7 +90,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
private static void sendAppInfo() {
|
private static void sendAppInfo() {
|
||||||
Observable.create((ObservableEmitter<String> emitter) -> newAppListener = emitter::onNext)
|
Observable.create((ObservableEmitter<String> emitter) -> newAppListener = emitter::onNext)
|
||||||
.throttleLast(5, TimeUnit.MINUTES)
|
.throttleLast(1, TimeUnit.MINUTES)
|
||||||
.subscribe(new Observer<String>() {
|
.subscribe(new Observer<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getAppAndWhite() {
|
public void getAppAndWhite() {
|
||||||
NetInterfaceManager.getInstance().getAppAndWhite(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
NetInterfaceManager.getInstance().getAppAndWhite(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
mView.getAppAndWhiteFinish();
|
mView.getAppAndWhiteFinish();
|
||||||
@@ -249,7 +249,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
@Override
|
@Override
|
||||||
public void getSystemSettings() {
|
public void getSystemSettings() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getSystemSettings(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
.getSystemSettings(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
mView.setSystemSettings();
|
mView.setSystemSettings();
|
||||||
@@ -319,7 +319,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getAppTimeControl() {
|
public void getAppTimeControl() {
|
||||||
NetInterfaceManager.getInstance().getAppTimeControl(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
NetInterfaceManager.getInstance().getAppTimeControl(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
mView.setAppTimeControl();
|
mView.setAppTimeControl();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.fuying.sn.config.CommonConfig;
|
|||||||
import com.fuying.sn.manager.AmapManager;
|
import com.fuying.sn.manager.AmapManager;
|
||||||
import com.fuying.sn.manager.ControlManager;
|
import com.fuying.sn.manager.ControlManager;
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
import com.fuying.sn.network.NetInterfaceManager;
|
||||||
|
import com.fuying.sn.network.UrlAddress;
|
||||||
import com.fuying.sn.rlog.LogDBManager;
|
import com.fuying.sn.rlog.LogDBManager;
|
||||||
import com.fuying.sn.service.DownloadService;
|
import com.fuying.sn.service.DownloadService;
|
||||||
import com.fuying.sn.service.GuardService;
|
import com.fuying.sn.service.GuardService;
|
||||||
@@ -201,6 +202,8 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
|||||||
registerReceivers();
|
registerReceivers();
|
||||||
startService();
|
startService();
|
||||||
Settings.System.putString(getContentResolver(), CommonConfig.APP_SOURCE_WHITE_LIST, DEFAULT_SOURCE);
|
Settings.System.putString(getContentResolver(), CommonConfig.APP_SOURCE_WHITE_LIST, DEFAULT_SOURCE);
|
||||||
|
|
||||||
|
JGYUtils.getInstance().putBuiltInApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String DEFAULT_SOURCE = "com.fuying.sn,com.fuying.appstore,com.fuying.fuxiaoying";
|
private static final String DEFAULT_SOURCE = "com.fuying.sn,com.fuying.appstore,com.fuying.fuxiaoying";
|
||||||
@@ -466,7 +469,7 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
|||||||
// mPresenter.getAppTimeControl();
|
// mPresenter.getAppTimeControl();
|
||||||
break;
|
break;
|
||||||
case Intent.ACTION_SCREEN_ON:
|
case Intent.ACTION_SCREEN_ON:
|
||||||
|
getAppControl();
|
||||||
break;
|
break;
|
||||||
case Intent.ACTION_SCREEN_OFF:
|
case Intent.ACTION_SCREEN_OFF:
|
||||||
|
|
||||||
@@ -480,6 +483,19 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getAppControl() {
|
||||||
|
Log.e(TAG, "getAppControl: ");
|
||||||
|
long lastTime = mMMKV.decodeLong(UrlAddress.GET_APP_TIME_CONTROL + "_time", System.currentTimeMillis());
|
||||||
|
Log.e(TAG, "getAppControl: lastTime = " + lastTime);
|
||||||
|
Log.e(TAG, "getAppControl: lastTime = " + TimeUtils.getDate(lastTime));
|
||||||
|
if (TimeUtils.isTodayWithJavaTime(lastTime)) {
|
||||||
|
Log.e(TAG, "getAppControl: requests have been made today");
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "getAppControl: getAppTimeControl");
|
||||||
|
mPresenter.getAppTimeControl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getAppAndWhiteFinish() {
|
public void getAppAndWhiteFinish() {
|
||||||
mPresenter.checkUpdate();
|
mPresenter.checkUpdate();
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import com.fuying.sn.R;
|
|||||||
import com.fuying.sn.config.CommonConfig;
|
import com.fuying.sn.config.CommonConfig;
|
||||||
import com.fuying.sn.gson.GsonUtils;
|
import com.fuying.sn.gson.GsonUtils;
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
import com.fuying.sn.network.NetInterfaceManager;
|
||||||
import com.fuying.sn.network.UrlAddress;
|
|
||||||
import com.fuying.sn.receiver.BootReceiver;
|
import com.fuying.sn.receiver.BootReceiver;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
@@ -207,7 +206,7 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<String> getAppAndWhite() {
|
public HashSet<String> getAppAndWhite() {
|
||||||
String pkgString = mMMKV.decodeString(UrlAddress.GET_APP_AND_WHITE, "");
|
String pkgString = mMMKV.decodeString(CommonConfig.BUILT_IN_APPS, "");
|
||||||
if (TextUtils.isEmpty(pkgString)) {
|
if (TextUtils.isEmpty(pkgString)) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
} else {
|
} else {
|
||||||
@@ -215,6 +214,24 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void putBuiltInApps() {
|
||||||
|
String pkgString = mMMKV.decodeString(CommonConfig.BUILT_IN_APPS, "");
|
||||||
|
Set<String> stringSet = new HashSet<>(Arrays.asList(pkgString.split(",")));
|
||||||
|
Set<String> filter = stringSet.stream().filter(new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean test(String s) {
|
||||||
|
return ApkUtils.isAvailable(mContext, s);
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toSet());
|
||||||
|
if (filter.size() != 0) {
|
||||||
|
String pkg = String.join(",", filter);
|
||||||
|
Log.e(TAG, "putBuiltInApps: pkg = " + pkg);
|
||||||
|
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_PRIVILEGE, pkg);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "putBuiltInApps: filter is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private JGYUtils(Context context) {
|
private JGYUtils(Context context) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new RuntimeException("Context is NULL");
|
throw new RuntimeException("Context is NULL");
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ import java.net.InetAddress;
|
|||||||
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.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -275,11 +277,7 @@ public class TimeUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean inWeekDay(long time) {
|
public static boolean inWeekDay(long time) {
|
||||||
int weekDay = getWeekDay(time);
|
int weekDay = getWeekDay(time);
|
||||||
if (weekDay > 5) {
|
return weekDay > 5;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSystemTime(long time) {
|
public static void setSystemTime(long time) {
|
||||||
@@ -356,11 +354,7 @@ public class TimeUtils {
|
|||||||
}
|
}
|
||||||
Log.e(TAG, "inControlTime: " + (startDate.getTime() - minuteTime));
|
Log.e(TAG, "inControlTime: " + (startDate.getTime() - minuteTime));
|
||||||
assert nowDate != null;
|
assert nowDate != null;
|
||||||
if (nowDate.getTime() <= startDate.getTime() - minuteTime || nowDate.getTime() >= endDate.getTime()) {
|
return nowDate.getTime() <= startDate.getTime() - minuteTime || nowDate.getTime() >= endDate.getTime();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -589,4 +583,22 @@ public class TimeUtils {
|
|||||||
buffer[offset++] = (byte) (Math.random() * 255.0);
|
buffer[offset++] = (byte) (Math.random() * 255.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用 Java 8 现代API判断时间戳是否为今天
|
||||||
|
*
|
||||||
|
* @param timestamp 毫秒级时间戳
|
||||||
|
* @return 如果是今天返回 true,否则返回 false
|
||||||
|
*/
|
||||||
|
public static boolean isTodayWithJavaTime(long timestamp) {
|
||||||
|
// 1. 获取系统默认时区下的当前日期
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
// 2. 将时间戳转换为Instant对象,然后结合时区转换为LocalDateTime,再提取日期部分
|
||||||
|
LocalDate dateToCheck = LocalDateTime.ofInstant(
|
||||||
|
Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()
|
||||||
|
).toLocalDate();
|
||||||
|
// 3. 比较两个日期是否相等
|
||||||
|
return today.equals(dateToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user