version:3.2.0

fix:优化管控逻辑
update:
This commit is contained in:
2024-01-04 11:44:53 +08:00
parent 576419bbf2
commit ac0ec1feee
12 changed files with 541 additions and 136 deletions

View File

@@ -1,4 +1,5 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: "com.tencent.android.tpns"
static def appName() { static def appName() {
return "FLYSN" return "FLYSN"
@@ -73,8 +74,8 @@ android {
official { official {
flavorDimensions "default" flavorDimensions "default"
versionCode 50 versionCode 60
versionName "3.1.0" versionName "3.2.0"
} }
} }
@@ -152,7 +153,7 @@ android {
v2SigningEnabled true v2SigningEnabled true
} }
G10P{ G10P {
storeFile file("keystore/G10PMTK11.jks") storeFile file("keystore/G10PMTK11.jks")
storePassword "123456" storePassword "123456"
keyAlias "G10PMTK11" keyAlias "G10PMTK11"
@@ -161,7 +162,7 @@ android {
v2SigningEnabled true v2SigningEnabled true
} }
Teclast8515{ Teclast8515 {
storeFile file("keystore/Teclast8515.keystore") storeFile file("keystore/Teclast8515.keystore")
storePassword "123456" storePassword "123456"
keyAlias "Teclast8515" keyAlias "Teclast8515"
@@ -484,7 +485,7 @@ dependencies {
//bugly //bugly
implementation 'com.tencent.bugly:crashreport:4.1.9.2' implementation 'com.tencent.bugly:crashreport:4.1.9.2'
//腾讯移动推送 TPNS //腾讯移动推送 TPNS
implementation 'com.tencent.tpns:tpns:1.3.2.0-release' implementation 'com.tencent.tpns:tpns:1.4.3.4-release'
//百度地图 //百度地图
implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8' implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8'
//工具类 //工具类

View File

@@ -28,6 +28,7 @@ import com.blankj.utilcode.util.NetworkUtils;
import com.fuying.sn.BuildConfig; import com.fuying.sn.BuildConfig;
import com.fuying.sn.R; import com.fuying.sn.R;
import com.fuying.sn.base.BaseActivity; import com.fuying.sn.base.BaseActivity;
import com.fuying.sn.bean.AppInfo;
import com.fuying.sn.bean.BaseResponse; import com.fuying.sn.bean.BaseResponse;
import com.fuying.sn.bean.SnInfo; import com.fuying.sn.bean.SnInfo;
import com.fuying.sn.config.CommonConfig; import com.fuying.sn.config.CommonConfig;
@@ -50,6 +51,8 @@ import com.fuying.sn.utils.SPUtils;
import com.fuying.sn.utils.TimeUtils; import com.fuying.sn.utils.TimeUtils;
import com.fuying.sn.utils.ToastUtil; import com.fuying.sn.utils.ToastUtil;
import com.fuying.sn.utils.Utils; import com.fuying.sn.utils.Utils;
import com.trello.rxlifecycle4.RxLifecycle;
import com.trello.rxlifecycle4.android.ActivityEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -58,6 +61,9 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
public class MainActivity extends BaseActivity implements MainAContact.MainView, NetworkUtils.OnNetworkStatusChangedListener { public class MainActivity extends BaseActivity implements MainAContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
private static final String TAG = MainActivity.class.getSimpleName(); private static final String TAG = MainActivity.class.getSimpleName();
@@ -151,12 +157,58 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
tv_update.setOnClickListener(new View.OnClickListener() { tv_update.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
ToastUtil.show("正在检查更新");
mPresenter.getAllApp(); mPresenter.getAllApp();
if (mCheckUpdate) {
ToastUtil.show("您已检查过更新,请稍后再试");
} else {
ToastUtil.show("正在检查更新");
checkUpdate();
}
} }
}); });
} }
private boolean mCheckUpdate = false;
private void checkUpdate() {
NetInterfaceManager.getInstance().getUpdateObservable(BuildConfig.APPLICATION_ID)
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("checkUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
Log.e("checkUpdate", "onSubscribe: " + appInfoBaseResponse);
if (appInfoBaseResponse.code == 200) {
AppInfo appInfo = appInfoBaseResponse.data;
if (appInfo.getApp_version_code() > BuildConfig.VERSION_CODE) {
ToastUtil.show("正在下载更新");
} else {
ToastUtil.show("已是最新版本");
}
} else {
ToastUtil.show("没有找到更新");
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("checkUpdate", "onError: " + e.getMessage());
ToastUtil.show("请稍后重试");
onComplete();
}
@Override
public void onComplete() {
Log.e("checkUpdate", "onComplete: ");
mCheckUpdate = true;
}
});
}
private TimeTask task; private TimeTask task;
private static class TimeTask extends AsyncTask<String, Long, Long> { private static class TimeTask extends AsyncTask<String, Long, Long> {

View File

@@ -29,6 +29,9 @@ public class MachineControl implements Serializable {
/*上学日时间段*/ /*上学日时间段*/
List<PartTime> time_part; List<PartTime> time_part;
/*是否设置了可用时间*/
int is_set;
public int getId() { public int getId() {
return id; return id;
} }
@@ -93,6 +96,14 @@ public class MachineControl implements Serializable {
this.time_part = time_part; this.time_part = time_part;
} }
public int getIs_set() {
return is_set;
}
public void setIs_set(int is_set) {
this.is_set = is_set;
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {

View File

@@ -36,7 +36,6 @@ import com.fuying.sn.bean.MyAppUsageBean;
import com.fuying.sn.bean.PartTime; import com.fuying.sn.bean.PartTime;
import com.fuying.sn.bean.RemainTime; import com.fuying.sn.bean.RemainTime;
import com.fuying.sn.config.CommonConfig; import com.fuying.sn.config.CommonConfig;
import com.fuying.sn.disklrucache.CacheHelper;
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.network.UrlAddress;
@@ -171,9 +170,9 @@ public class RunningAppManager {
// Log.i(TAG, "accept: " + aLong); // Log.i(TAG, "accept: " + aLong);
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = pm.isScreenOn(); boolean isScreenOn = pm.isScreenOn();
if (!isScreenOn) { // if (!isScreenOn) {
return; // return;
} // }
checkForegroundAppName(); checkForegroundAppName();
} }
}); });
@@ -199,8 +198,8 @@ public class RunningAppManager {
@Override @Override
public void onComplete() { public void onComplete() {
Log.i(TAG, "onComplete: "); Log.i(TAG, "onComplete: ");
// NetInterfaceManager.getInstance().getSnTimeControl(); NetInterfaceManager.getInstance().getAppTimeControl();
// NetInterfaceManager.getInstance().getAppTimeControl(); NetInterfaceManager.getInstance().getSnTimeControl();
} }
}); });
NetInterfaceManager.getInstance().getMyAppList(new NetInterfaceManager.MyAppListCallback() { NetInterfaceManager.getInstance().getMyAppList(new NetInterfaceManager.MyAppListCallback() {
@@ -211,7 +210,6 @@ public class RunningAppManager {
}); });
AppUsedTimeUtils.getInstance().setApp_package(topPackage); AppUsedTimeUtils.getInstance().setApp_package(topPackage);
AppUsedTimeUtils.getInstance().setStart_time(System.currentTimeMillis() / 1000); AppUsedTimeUtils.getInstance().setStart_time(System.currentTimeMillis() / 1000);
// NetInterfaceManager.getInstance().sendRunningApp();
} }
} }
mMMKV.encode(RUNNING_APP_PACKAGENAME, ""); mMMKV.encode(RUNNING_APP_PACKAGENAME, "");
@@ -224,7 +222,6 @@ public class RunningAppManager {
recordPackageOpenTime(topPackage); recordPackageOpenTime(topPackage);
AppUsedTimeUtils.getInstance().setApp_package(topPackage); AppUsedTimeUtils.getInstance().setApp_package(topPackage);
AppUsedTimeUtils.getInstance().setStart_time(System.currentTimeMillis() / 1000); AppUsedTimeUtils.getInstance().setStart_time(System.currentTimeMillis() / 1000);
// NetInterfaceManager.getInstance().sendRunningApp();
return; return;
} }
long onClickTime = getOnClickTime(); long onClickTime = getOnClickTime();
@@ -232,7 +229,11 @@ public class RunningAppManager {
if (appPackageName.equals(topPackage)) { if (appPackageName.equals(topPackage)) {
Log.i(TAG, "checkForegroundAppName: 没有切换应用"); Log.i(TAG, "checkForegroundAppName: 没有切换应用");
if (inControlTime(appPackageName)) { if (inControlTime(appPackageName)) {
removeTask(topPackage); Log.i(TAG, "checkForegroundAppName: 没有剩余时间1");
// removeTask(topPackage);
NetInterfaceManager.getInstance().getAppTimeControl();
NetInterfaceManager.getInstance().getSnTimeControl();
JGYUtils.getInstance().killPackage(appPackageName);
killApp(); killApp();
gotoLauncher(); gotoLauncher();
} else { } else {
@@ -244,16 +245,11 @@ public class RunningAppManager {
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.CompleteCallback() { NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.CompleteCallback() {
@Override @Override
public void onComplete() { public void onComplete() {
// NetInterfaceManager.getInstance().getSnTimeControl(); NetInterfaceManager.getInstance().getAppTimeControl();
// NetInterfaceManager.getInstance().getAppTimeControl(); NetInterfaceManager.getInstance().getSnTimeControl();
} }
}); });
// NetInterfaceManager.getInstance().getMyAppList(new NetInterfaceManager.MyAppListCallback() {
// @Override
// public void setMyAppList(List<MyAppUsageBean> myAppList) {
// syncAllAppUsageTime(myAppList);
// }
// });
reduceAppRemainingTime(topPackage, 1); reduceAppRemainingTime(topPackage, 1);
appPackageName = topPackage; appPackageName = topPackage;
AppUsedTimeUtils.getInstance().setApp_package(appPackageName); AppUsedTimeUtils.getInstance().setApp_package(appPackageName);
@@ -262,9 +258,12 @@ public class RunningAppManager {
AppUsedTimeUtils.getInstance().setStart_time(onClickTime); AppUsedTimeUtils.getInstance().setStart_time(onClickTime);
if (inControlTime(appPackageName)) { if (inControlTime(appPackageName)) {
Log.i(TAG, "checkForegroundAppName: 没有剩余时间2"); Log.i(TAG, "checkForegroundAppName: 没有剩余时间2");
removeTask(topPackage); // removeTask(topPackage);
killApp(); killApp();
JGYUtils.getInstance().killPackage(appPackageName);
gotoLauncher(); gotoLauncher();
NetInterfaceManager.getInstance().getAppTimeControl();
NetInterfaceManager.getInstance().getSnTimeControl();
} else { } else {
recordPackageOpenTime(topPackage); recordPackageOpenTime(topPackage);
Log.i(TAG, "checkForegroundAppName: 没有管控2"); Log.i(TAG, "checkForegroundAppName: 没有管控2");
@@ -287,7 +286,7 @@ public class RunningAppManager {
) { ) {
continue; continue;
} }
JGYUtils.getInstance().killBackgroundProcesses(pkg); JGYUtils.getInstance().killPackage(pkg);
} }
} }
@@ -332,7 +331,7 @@ public class RunningAppManager {
public void killBackgroundProcesses(String processName) { public void killBackgroundProcesses(String processName) {
// gotoLauncher(); // gotoLauncher();
// mIsScanning = true; // mIsScanning = true;
removeTask(processName); // removeTask(processName);
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = null; String packageName = null;
try { try {
@@ -583,7 +582,7 @@ public class RunningAppManager {
boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg); boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg);
MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl(); MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl();
Log.e(TAG, "inControlTime: globalRemainingTime = " + globalRemainingTime); Log.e(TAG, "reduceAppRemainingTime: globalRemainingTime = " + globalRemainingTime);
if (globalRemainingTime <= 0) { if (globalRemainingTime <= 0) {
if (machineControl != null) { if (machineControl != null) {
if (machineControl.getIs_part() == 0 && machineControl.getIs_quota() == 0) { if (machineControl.getIs_part() == 0 && machineControl.getIs_quota() == 0) {
@@ -715,20 +714,27 @@ public class RunningAppManager {
* @param pkg * @param pkg
* @return * @return
*/ */
public boolean inControlTime(String pkg) { public boolean inControlTime2(String pkg) {
Log.i(TAG, "inControlTime: pkg = " + pkg);
if (allowPackage.contains(pkg)) { if (allowPackage.contains(pkg)) {
Log.i(TAG, "inControlTime: allow = " + pkg);
return false; return false;
} }
Log.i(TAG, "inControlTime: pkg = " + pkg);
int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1); int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
Log.i(TAG, "inControlTime: isControl = " + isControl); Log.i(TAG, "inControlTime: isControl = " + isControl);
//家长管控关闭始终可用 //家长管控关闭 始终可用
if (isControl == 0) { if (isControl == 0) {
return false; return false;
} }
boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg); boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg);
MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl(); MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl();
long work_time = machineControl.getWork_time();
long rest_time = machineControl.getRest_time();
long today_time = machineControl.getToday_time();
int is_part = machineControl.getIs_part();
int is_set = machineControl.getIs_set();
if (havaConfigure) { if (havaConfigure) {
//有单独设置 不管是分类整机还是其他都是这个设置 //有单独设置 不管是分类整机还是其他都是这个设置
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg); AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
@@ -742,62 +748,96 @@ public class RunningAppManager {
return false; return false;
} }
Log.e(TAG, "inControlTime: globalRemainingTime = " + globalRemainingTime); if (work_time == 0 && rest_time == 0 && is_set == 0 && is_part == 0) {
if (appTimeControl.getTc_use_type() != 3) { //没有整机额度,没有整机时段,没有修改临时时长
if (globalRemainingTime <= 0) { Log.e(TAG, "inControlTime: not set");
if (machineControl != null) { return false;
if (machineControl.getIs_part() == 0 && machineControl.getIs_quota() == 0) { }
Log.e(TAG, "inControlTime: is_part = 0 is_quota = 0");
//整机额度和时间段关闭不管控 if (machineControl.getIs_quota() == 1) {//打开整机额度
Log.e(TAG, "inControlTime: globalRemainingTime = " + globalRemainingTime);
if (appTimeControl.getTc_use_type() != 3) {
if (work_time == 0 && rest_time == 0 && is_set == 0) {
Log.e(TAG, "inControlTime: work_time == 0 rest_time == 0 is_set == 0");
if (appTimeControl.getIs_part() == 1) {//时间段管控打开
boolean inControlTime = inControlTime(machineControl, appTimeControl);
//判断是否在时间段内
if (inControlTime) {
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
ToastUtil.show("该应用" + partTime2String(appTimeControl));
Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
return true;
} else {
Log.e(TAG, "inControlTime: " + "不在管控时间段内");
return false;
}
} else {
Log.e(TAG, "inControlTime: " + "关闭整机和关闭时间段");
return false; return false;
} }
} else { } else {
ToastUtil.show("今日可使用时间已用完"); if (globalRemainingTime <= 0) {//没有剩余时间
return true; ToastUtil.show("今日可使用时间已用完");
return true;
}
} }
} }
}
//打开时间段管控 //打开时间段管控
if (appTimeControl.getIs_part() == 1) { if (appTimeControl.getIs_part() == 1) {
boolean inControlTime = inControlTime(machineControl, appTimeControl); boolean inControlTime = inControlTime(machineControl, appTimeControl);
//判断是否在时间段内 //判断是否在时间段内
if (inControlTime) { if (inControlTime) {
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString()); Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
ToastUtil.show("该应用" + partTime2String(appTimeControl)); ToastUtil.show("该应用" + partTime2String(appTimeControl));
Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl)); Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
return true; return true;
} else { } else {
if (appTimeControl.getIs_quota() == 0) {
//要求设置了管控时间段没有设置使用额度也可以使用 if (getAppRemainingTime(pkg) <= 0) {
return false; //没有剩余时间
ToastUtil.show("该应用今日可使用时间已用完");
Log.e(TAG, "inControlTime: " + "该应用今日可使用时间已用完");
return true;
} else {
return false;
}
} }
} else {
if (getAppRemainingTime(pkg) <= 0) { if (getAppRemainingTime(pkg) <= 0) {
//没有剩余时间 //没有剩余时间
ToastUtil.show("该应用今日可使用时间已用完"); ToastUtil.show("该应用今日可使用时间已用完");
Log.e(TAG, "inControlTime: " + "该应用今日可使用时间已用完"); Log.e(TAG, "inControlTime: " + "该应用今日可使用时间已用完");
return true; return true;
} else { } else {
return false; return false;
} }
} }
} else { } else {//关闭整机额度
//关闭时间段管控关闭额度开关为不管控 //打开时间段管控
if (appTimeControl.getIs_quota() == 0) { if (appTimeControl.getIs_part() == 1) {
Log.e(TAG, "inControlTime: " + "没有使用额度"); boolean inControlTime = inControlTime(machineControl, appTimeControl);
return false; //判断是否在时间段内
} if (inControlTime) {
if (getAppRemainingTime(pkg) <= 0) { Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
//没有剩余时间 ToastUtil.show("该应用" + partTime2String(appTimeControl));
ToastUtil.show("该应用今日可使用时间已用完"); Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
Log.e(TAG, "inControlTime: " + "该应用今日可使用时间已用完"); return true;
return true; } else {
Log.e(TAG, "inControlTime: " + "不在管控时间段内");
return false;
}
} else { } else {
Log.e(TAG, "inControlTime: " + "关闭整机和关闭时间段");
return false; return false;
} }
} }
} else { } else {
//根据整机 //根据整机
if (work_time == 0 && rest_time == 0 && is_set == 0) {
Log.e(TAG, "inControlTime: not set");
return false;
}
if (machineControl == null) { if (machineControl == null) {
return false; return false;
} }
@@ -806,6 +846,8 @@ public class RunningAppManager {
Log.e(TAG, "inControlTime: is_part = 0 is_quota = 0"); Log.e(TAG, "inControlTime: is_part = 0 is_quota = 0");
//整机额度和时间段关闭不管控 //整机额度和时间段关闭不管控
return false; return false;
} else {
return true;
} }
} }
@@ -827,6 +869,251 @@ public class RunningAppManager {
} }
} }
/**
* 是否在管控时间内
*
* @param pkg 包名
* @return 可用返回false不可用返回true
*/
public boolean inControlTime(String pkg) {
Log.e(TAG, "inControlTime: pkg = " + pkg);
if (allowPackage.contains(pkg)) {
Log.e(TAG, "inControlTime: allow = " + pkg);
return false;
}
int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
Log.e(TAG, "inControlTime: isControl = " + isControl);
//只要关闭家长管控开关,相关内容需无效
if (isControl == 0) {
Log.e(TAG, "inControlTime: 管控开关关闭家长");
return false;
}
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: globalRemainingTime = " + globalRemainingTime);
//整机额度开关
int is_quota = machineControl.getIs_quota();
//整机使用时段开关
int is_part = machineControl.getIs_part();
long work_time = machineControl.getWork_time();
long rest_time = machineControl.getRest_time();
long today_time = machineControl.getToday_time();
//是否手动设置临时时间
int is_set = machineControl.getIs_set();
if (havaConfigure) {//app有单独配置的情况
//有单独设置 不管是分类整机还是其他都是这个设置
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
if (appTimeControl.getIs_control() == 0) {//先判断是否被禁用
Log.e(TAG, "inControlTime: appTimeControl " + "应用已被禁用");
ToastUtil.show("应用已被禁用");
return true;
}
if (appTimeControl.getTc_use_type() == 0) {//是否始终可用
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;
}
if (appTimeControl.getIs_quota() == 1) {//app额度打开
Log.e(TAG, "inControlTime: appTimeControl is_quota = 1");
if (appTimeControl.getIs_part() == 1) {//app额度打开 app使用时段打开
Log.e(TAG, "inControlTime: appTimeControl is_quota = 1 is_part = 1");
boolean inControlTime = inControlTime(machineControl, appTimeControl);
//判断是否在时间段内
if (inControlTime) {
Log.e(TAG, "inControlTime: appTimeControl " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
ToastUtil.show("该应用" + partTime2String(appTimeControl));
Log.e(TAG, "inControlTime: appTimeControl " + "该应用" + partTime2String(appTimeControl));
return true;
} else {
if (appTimeControl.getWork_time() == 0 && appTimeControl.getRest_time() == 0) {
Log.e(TAG, "inControlTime: appTimeControl " + "没有设置管控时间");
return false;
} else {
if (getTodayTime(appTimeControl) == 0) {
Log.e(TAG, "inControlTime: appTimeControl " + "对应日期没有设置额度");
return false;
} else {
if (getAppRemainingTime(pkg) <= 0) {
//没有剩余时间
ToastUtil.show("该应用今日可使用时间已用完");
Log.e(TAG, "inControlTime: appTimeControl " + "该应用今日可使用时间已用完");
return true;
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "不在管控时间段,app有剩余时间");
return false;
}
}
}
}
} else {//app额度打开 app使用时段关闭
Log.e(TAG, "inControlTime: appTimeControl is_quota = 1 is_part = 0");
if (appTimeControl.getRest_time() == 0 && appTimeControl.getWork_time() == 0) {//自由配置且没有设置额度
return false;
} else {
if (getTodayTime(appTimeControl) == 0) {
Log.e(TAG, "inControlTime: appTimeControl " + "对应日期没有设置额度");
return false;
} else {
if (getAppRemainingTime(pkg) <= 0) {
//没有剩余时间
ToastUtil.show("该应用今日可使用时间已用完");
Log.e(TAG, "inControlTime: appTimeControl " + "该应用今日可使用时间已用完");
return true;
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "app有剩余时间");
return false;
}
}
}
}
} else {//app额度关闭
Log.e(TAG, "inControlTime: appTimeControl is_quota = 0");
if (appTimeControl.getIs_part() == 1) {//app额度关闭 app使用时段打开
Log.e(TAG, "inControlTime: appTimeControl is_quota = 0 is_part = 1");
boolean inControlTime = inControlTime(machineControl, appTimeControl);
//判断是否在时间段内
if (inControlTime) {
Log.e(TAG, "inControlTime: appTimeControl " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
ToastUtil.show("该应用" + partTime2String(appTimeControl));
Log.e(TAG, "inControlTime: appTimeControl " + "该应用" + partTime2String(appTimeControl));
return true;
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "不在管控时间内");
if (appTimeControl.getRest_time() == 0 && appTimeControl.getWork_time() == 0) {//自由配置且没有设置额度
Log.e(TAG, "inControlTime: appTimeControl " + "自由配置且没有设置额度");
return false;
} else {
//额度关闭时,如果手动设置了时长,用完也不能继续使用
if (is_set == 1) {
if (getAppRemainingTime(pkg) <= 0) {
//没有剩余时间
ToastUtil.show("该应用今日可使用时间已用完");
Log.e(TAG, "inControlTime: appTimeControl " + "该应用今日可使用时间已用完");
return true;
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "该应用手动设置时长,app有剩余时间");
return false;
}
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "app额度关闭");
return false;
}
}
}
} else {//app额度关闭 app使用时段关闭
Log.e(TAG, "inControlTime: appTimeControl is_quota = 0 is_part = 0");
//额度关闭时,如果手动设置了时长,用完也不能继续使用
if (is_set == 1) {
if (getAppRemainingTime(pkg) <= 0) {
//没有剩余时间
ToastUtil.show("该应用今日可使用时间已用完");
Log.e(TAG, "inControlTime: appTimeControl " + "该应用今日可使用时间已用完");
return true;
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "该应用手动设置时长,app有剩余时间");
return false;
}
} else {
Log.e(TAG, "inControlTime: appTimeControl " + "app额度关闭");
return false;
}
}
}
} else {//app没有单独配置的情况
if (is_quota == 1) {//整机额度打开
Log.e(TAG, "inControlTime: machineControl is_quota = 1");
if (is_part == 1) {//整机额度打开 整机使用时段打开
Log.e(TAG, "inControlTime: machineControl is_quota = 1 is_part = 1");
boolean inControlTime = inControlTime(machineControl);
if (inControlTime) {
Log.e(TAG, "inControlTime: machineControl " + "应用在管控时间段不能打开" + machineControl.time_part.toString());
ToastUtil.show("该应用" + partTime2String(machineControl));
return true;
} else {
if (globalRemainingTime <= 0) {
Log.e(TAG, "inControlTime: machineControl globalRemainingTime = 0");
ToastUtil.show("整机可用时间已用完");
return true;
} else {
ToastUtil.show("整机可用时间有剩余");
return false;
}
}
} else {//整机额度打开 整机使用时段关闭
Log.e(TAG, "inControlTime: machineControl is_quota = 1 is_part = 0");
if (globalRemainingTime <= 0) {
Log.e(TAG, "inControlTime: machineControl globalRemainingTime = 0");
ToastUtil.show("整机可用时间已用完");
return true;
} else {
ToastUtil.show("整机可用时间有剩余");
return false;
}
}
} else {//整机额度关闭
Log.e(TAG, "inControlTime: machineControl is_quota = 0");
//额度关闭时,如果手动设置了时长,用完也不能继续使用
if (is_part == 1) {//整机额度关闭 整机使用时段打开
Log.e(TAG, "inControlTime: machineControl is_quota = 0 is_part = 1");
boolean inControlTime = inControlTime(machineControl);
if (inControlTime) {
Log.e(TAG, "inControlTime: machineControl " + "应用在管控时间段不能打开" + machineControl.time_part.toString());
ToastUtil.show("该应用" + partTime2String(machineControl));
return true;
} else {
if (is_set == 1) {
if (globalRemainingTime == 0) {
Log.e(TAG, "inControlTime: machineControl globalRemainingTime = 0");
ToastUtil.show("整机可用时间已用完");
return true;
} else {
Log.e(TAG, "inControlTime: machineControl " + "手动设置时长,有剩余时间");
return false;
}
} else {
Log.e(TAG, "inControlTime: machineControl " + "整机额度关闭");
return false;
}
}
} else {//整机额度关闭 整机使用时段关闭
Log.e(TAG, "inControlTime: machineControl is_quota = 0 is_part = 0");
if (is_set == 1) {
if (globalRemainingTime == 0) {
Log.e(TAG, "inControlTime: machineControl globalRemainingTime = 0");
ToastUtil.show("整机可用时间已用完");
return true;
} else {
Log.e(TAG, "inControlTime: machineControl " + "手动设置时长,有剩余时间");
return false;
}
} else {
Log.e(TAG, "inControlTime: machineControl " + "整机额度关闭");
return false;
}
}
}
}
}
private int getTodayTime(AppTimeControl appTimeControl) {
if (inWeekDay()) {
Log.e(TAG, "getTodayTime: Work");
return (int) appTimeControl.getWork_time();
} else {
Log.e(TAG, "getTodayTime: Rest");
return (int) appTimeControl.getRest_time();
}
}
private String partTime2String(AppTimeControl appTimeControl) { private String partTime2String(AppTimeControl appTimeControl) {
List<PartTime> partTimes = appTimeControl.getTime_part(); List<PartTime> partTimes = appTimeControl.getTime_part();
if (partTimes == null || partTimes.size() == 0) { if (partTimes == null || partTimes.size() == 0) {
@@ -882,37 +1169,13 @@ public class RunningAppManager {
* @return json数据 * @return json数据
*/ */
public String getDisableContent(String pkg) { public String getDisableContent(String pkg) {
// NetInterfaceManager.getInstance().getMyAppList(new NetInterfaceManager.MyAppListCallback() {
// @Override
// public void setMyAppList(List<MyAppUsageBean> myAppList) {
//
// }
// });
RemainTime remainTime = new RemainTime(); RemainTime remainTime = new RemainTime();
remainTime.setPkg(pkg); remainTime.setPkg(pkg);
// if (allowPackage.contains(pkg)) {
// return "";
// }
// Log.i(TAG, "inControlTime: pkg = " + pkg);
// int is_control = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
// Log.i(TAG, "inControlTime: is_control = " + is_control);
//家长管控关闭始终可用
// if (is_control == 0) {
// return "";
// }
boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg); boolean havaConfigure = TimeControlManager.getInstance().havaConfigure(pkg);
MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl(); MachineControl machineControl = TimeControlManager.getInstance().getGlobalMachineControl();
Log.e(TAG, "inControlTime: globalRemainingTime = " + globalRemainingTime); Log.e(TAG, "inControlTime: globalRemainingTime = " + globalRemainingTime);
// if (globalRemainingTime <= 0) {
// if (machineControl != null) {
// if (machineControl.getIs_part() == 0 && machineControl.getIs_quota() == 0) {
// return "";
// }
// } else {
// return "";
// }
// }
if (havaConfigure) { if (havaConfigure) {
//有单独设置 不管是分类整机还是其他都是这个设置 //有单独设置 不管是分类整机还是其他都是这个设置
@@ -927,9 +1190,6 @@ public class RunningAppManager {
remainTime.setContent("应用已被禁用"); remainTime.setContent("应用已被禁用");
return remainTime.toString(); return remainTime.toString();
} }
// if (appTimeControl.getTc_use_type() == 0) {
// return "";
// }
//打开时间段管控 //打开时间段管控
if (appTimeControl.getIs_part() == 1) { if (appTimeControl.getIs_part() == 1) {
boolean inControlTime = inControlTime(machineControl, appTimeControl); boolean inControlTime = inControlTime(machineControl, appTimeControl);
@@ -1131,7 +1391,7 @@ public class RunningAppManager {
// } else { // } else {
// return restTime - todayTime <= 0; // return restTime - todayTime <= 0;
// } // }
Log.i(TAG, "haveUseTime: " + globalRemainingTime); Log.e(TAG, "haveUseTime: " + globalRemainingTime);
return (globalRemainingTime > 0); return (globalRemainingTime > 0);
} }
@@ -1204,6 +1464,9 @@ public class RunningAppManager {
public boolean isControlTime(AppTimeControl appTimeControl) { public boolean isControlTime(AppTimeControl appTimeControl) {
//整机使用时段开关 开启时 //整机使用时段开关 开启时
if (appTimeControl.getIs_part() == 1) { if (appTimeControl.getIs_part() == 1) {
if (appTimeControl.getTime_part() == null || appTimeControl.getTime_part().size() == 0) {
return false;
}
int partType = appTimeControl.getPart_type(); int partType = appTimeControl.getPart_type();
HashMap<Integer, Set<PartTime>> partTimeMap = new HashMap(); HashMap<Integer, Set<PartTime>> partTimeMap = new HashMap();
HashSet<PartTime> weekdayPart = new HashSet(appTimeControl.getTime_part().stream().filter(partTime -> partTime.getDay_type() == 0).collect(Collectors.toList())); HashSet<PartTime> weekdayPart = new HashSet(appTimeControl.getTime_part().stream().filter(partTime -> partTime.getDay_type() == 0).collect(Collectors.toList()));
@@ -1239,7 +1502,7 @@ public class RunningAppManager {
* @return * @return
*/ */
private boolean inControlTime(int partType, Set<PartTime> partTimeHashSet) { private boolean inControlTime(int partType, Set<PartTime> partTimeHashSet) {
if (partTimeHashSet != null) { if (partTimeHashSet != null && partTimeHashSet.size() != 0) {
if (partType == 0) { if (partType == 0) {
List<Boolean> inPartTimes = new ArrayList<>(); List<Boolean> inPartTimes = new ArrayList<>();
for (PartTime partTime : partTimeHashSet) { for (PartTime partTime : partTimeHashSet) {
@@ -1253,11 +1516,15 @@ public class RunningAppManager {
for (PartTime partTime : partTimeHashSet) { for (PartTime partTime : partTimeHashSet) {
if (inControlTime(partTime)) { if (inControlTime(partTime)) {
return false; return false;
} else {
return true;
} }
} }
} }
} else {
return false;
} }
return true; return false;
} }
private boolean inControlTime(PartTime partTime) { private boolean inControlTime(PartTime partTime) {
@@ -1265,7 +1532,7 @@ public class RunningAppManager {
String endTime = partTime.getEnd_time(); String endTime = partTime.getEnd_time();
ContralTime contralTime = new ContralTime(startTime, endTime); ContralTime contralTime = new ContralTime(startTime, endTime);
boolean inControlTime = contralTime.inControlTime(); boolean inControlTime = contralTime.inControlTime();
Log.i(TAG, "inControlTime: " + inControlTime); Log.e(TAG, "inControlTime: PartTime " + inControlTime);
return inControlTime; return inControlTime;
} }
@@ -1338,7 +1605,7 @@ public class RunningAppManager {
//开始时间大于结束时间 列 1600-0100 //开始时间大于结束时间 列 1600-0100
endDate.setTime(endDate.getTime() + dayTime); endDate.setTime(endDate.getTime() + dayTime);
} }
Log.i(TAG, "inControlTime: " + (startDate.getTime() - minuteTime)); Log.e(TAG, "inControlTime: ContralTime " + (startDate.getTime() - minuteTime));
assert nowDate != null; assert nowDate != null;
// if (nowDate.getTime() <= startDate.getTime() - minuteTime || nowDate.getTime() >= endDate.getTime()) { // if (nowDate.getTime() <= startDate.getTime() - minuteTime || nowDate.getTime() >= endDate.getTime()) {
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) { if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
@@ -1369,7 +1636,7 @@ public class RunningAppManager {
public String getDate(long time) { public String getDate(long time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String finaWayDate = sdf.format(time); String finaWayDate = sdf.format(time);
Log.i(TAG, "getDate: " + finaWayDate); Log.e(TAG, "getDate: " + finaWayDate);
return finaWayDate; return finaWayDate;
} }
@@ -1380,7 +1647,7 @@ public class RunningAppManager {
*/ */
public int getWeekDay() { public int getWeekDay() {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
Log.i(TAG, "getWeekDay: " + time); Log.e(TAG, "getWeekDay: " + time);
return getWeekDay(time); return getWeekDay(time);
} }
@@ -1496,7 +1763,7 @@ public class RunningAppManager {
currentClassName = initStat.getPackageName(); currentClassName = initStat.getPackageName();
} }
} }
Log.i(TAG, "getForegroundActivityName: " + currentClassName); Log.e(TAG, "getForegroundActivityName: " + currentClassName);
return currentClassName; return currentClassName;
} }

View File

@@ -98,9 +98,9 @@ public class TimeControlManager {
return null; return null;
} else { } else {
Gson gson = new Gson(); Gson gson = new Gson();
Type Type = new TypeToken<MachineControl>() { Type type = new TypeToken<MachineControl>() {
}.getType(); }.getType();
MachineControl machineControl = gson.fromJson(jsonString, Type); MachineControl machineControl = gson.fromJson(jsonString, type);
return machineControl; return machineControl;
} }
} else { } else {

View File

@@ -659,7 +659,7 @@ public class ControlManager {
public void setDeveloperOptions(SystemSettings systemSettings) { public void setDeveloperOptions(SystemSettings systemSettings) {
int dev_mode = changeNum(systemSettings.getDev_mode()); int dev_mode = changeNum(systemSettings.getDev_mode());
Log.e(TAG, "setDeveloperOptions: " + dev_mode); Log.e(TAG, "setDeveloperOptions: " + dev_mode);
if (!DeviceManager.isDebugMode()) { // if (!DeviceManager.isDebugMode()) {
Settings.System.putInt(mResolver, "qch_Developeroptions", dev_mode); Settings.System.putInt(mResolver, "qch_Developeroptions", dev_mode);
int old_dev_enabled = Settings.Global.getInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0); int old_dev_enabled = Settings.Global.getInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
Log.e(TAG, "setDeveloperOptions: " + old_dev_enabled); Log.e(TAG, "setDeveloperOptions: " + old_dev_enabled);
@@ -680,7 +680,7 @@ public class ControlManager {
Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式"); Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式");
ToastUtil.debugShow("打开开发者模式"); ToastUtil.debugShow("打开开发者模式");
} }
} // }
setUSBstate("usb_mtp"); setUSBstate("usb_mtp");
closeSettingsApp(); closeSettingsApp();
} }
@@ -689,7 +689,7 @@ public class ControlManager {
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
int dev_mode = changeNum(jsonObject.get("dev_mode").getAsInt()); int dev_mode = changeNum(jsonObject.get("dev_mode").getAsInt());
Log.e(TAG, "setDeveloperOptions: " + dev_mode); Log.e(TAG, "setDeveloperOptions: " + dev_mode);
if (!DeviceManager.isDebugMode()) { // if (!DeviceManager.isDebugMode()) {
Settings.System.putInt(mResolver, "qch_Developeroptions", dev_mode); Settings.System.putInt(mResolver, "qch_Developeroptions", dev_mode);
int old_dev_enabled = Settings.Global.getInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0); int old_dev_enabled = Settings.Global.getInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
Log.e(TAG, "setDeveloperOptions: " + old_dev_enabled); Log.e(TAG, "setDeveloperOptions: " + old_dev_enabled);
@@ -710,14 +710,14 @@ public class ControlManager {
Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式"); Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式");
ToastUtil.debugShow("打开开发者模式"); ToastUtil.debugShow("打开开发者模式");
} }
} // }
setUSBstate("usb_mtp"); setUSBstate("usb_mtp");
closeSettingsApp(); closeSettingsApp();
} }
public void setDeveloperOptions(int state) { public void setDeveloperOptions(int state) {
Log.e(TAG, "setDeveloperOptions: " + state); Log.e(TAG, "setDeveloperOptions: " + state);
if (!DeviceManager.isDebugMode()) { // if (!DeviceManager.isDebugMode()) {
Settings.System.putInt(mResolver, "qch_Developeroptions", state); Settings.System.putInt(mResolver, "qch_Developeroptions", state);
int old_dev_enabled = Settings.Global.getInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0); int old_dev_enabled = Settings.Global.getInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
Log.e(TAG, "setDeveloperOptions: " + old_dev_enabled); Log.e(TAG, "setDeveloperOptions: " + old_dev_enabled);
@@ -737,7 +737,7 @@ public class ControlManager {
Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式"); Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式");
// ToastUtil.show("打开开发者模式"); // ToastUtil.show("打开开发者模式");
} }
} // }
closeSettingsApp(); closeSettingsApp();
} }

View File

@@ -117,6 +117,7 @@ import java.util.List;
import java.util.Map; 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.stream.Collectors; import java.util.stream.Collectors;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
@@ -1131,7 +1132,7 @@ public class NetInterfaceManager {
if (packageInfo == null) { if (packageInfo == null) {
//未安装 //未安装
String s = new Gson().toJson(entry.getValue()); String s = new Gson().toJson(entry.getValue());
Log.e(TAG, "getAllAppUpdate: " + s); Log.e(TAG, "getAllAppUpdate: install " + s);
JsonObject jsonObject = GsonUtils.getJsonObject(s); JsonObject jsonObject = GsonUtils.getJsonObject(s);
FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject); FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject);
} else { } else {
@@ -1144,12 +1145,14 @@ public class NetInterfaceManager {
long versionCode = entry.getValue().getApp_version_code(); long versionCode = entry.getValue().getApp_version_code();
//版本升级 //版本升级
if (appVersionCode < versionCode) { if (appVersionCode < versionCode) {
Log.e(TAG, "getAllAppUpdate: upgrade " + entry.getKey());
JsonObject jsonObject = GsonUtils.getJsonObject(new Gson().toJson(entry.getValue())); JsonObject jsonObject = GsonUtils.getJsonObject(new Gson().toJson(entry.getValue()));
FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject); FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), jsonObject);
} else {
Log.e(TAG, "getAllAppUpdate: is up to date" + entry.getKey());
} }
} }
} }
} }
} }
@@ -1951,6 +1954,15 @@ public class NetInterfaceManager {
int code = listBaseResponse.code; int code = listBaseResponse.code;
if (code == 200) { if (code == 200) {
List<AppInfo> appInfos = listBaseResponse.data; List<AppInfo> appInfos = listBaseResponse.data;
if (appInfos != null && appInfos.size() != 0) {
List<AppInfo> temp = appInfos.stream().filter(appInfo -> "com.alibaba.android.rimet".equals(appInfo.getApp_package())).collect(Collectors.toList());
if (temp.size() == 0 && ApkUtils.isAvailable(mContext, "com.alibaba.android.rimet")) {
Log.e("getForceInstall", "onNext: uninstall dingtalk");
ApkUtils.uninstallApp(mContext, "com.alibaba.android.rimet");
}else {
Log.e("getForceInstall", "onNext: dingtalk force");
}
}
mCacheHelper.put(UrlAddress.GET_FORCE_INSTALL, GsonUtils.toJSONString(appInfos)); mCacheHelper.put(UrlAddress.GET_FORCE_INSTALL, GsonUtils.toJSONString(appInfos));
if (null != appInfos && appInfos.size() != 0) { if (null != appInfos && appInfos.size() != 0) {
getForceInstallState(appInfos); getForceInstallState(appInfos);
@@ -3034,7 +3046,6 @@ public class NetInterfaceManager {
} }
private static final int REQUEST_CODE = 12345; private static final int REQUEST_CODE = 12345;
public void getRunLog() { public void getRunLog() {

View File

@@ -11,6 +11,15 @@ import com.fuying.sn.BuildConfig;
import com.fuying.sn.IGetInfoInterface; import com.fuying.sn.IGetInfoInterface;
import com.fuying.sn.config.CommonConfig; import com.fuying.sn.config.CommonConfig;
import com.fuying.sn.desktop.RunningAppManager; 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;
import com.tencent.android.tpush.XGPushManager;
import java.util.ArrayList;
import java.util.List;
public class RemoteService extends Service { public class RemoteService extends Service {
private String TAG = RemoteService.class.getSimpleName(); private String TAG = RemoteService.class.getSimpleName();
@@ -26,8 +35,39 @@ public class RemoteService extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
Log.e(TAG, "onCreate: ");
super.onCreate(); super.onCreate();
Log.e(TAG, "onCreate: ");
tPushInit();
}
private void tPushInit() {
XGPushConfig.enableDebug(this, true);
XGPushManager.registerPush(this, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
//token在设备卸载重装的时候有可能会变
Log.e("TPush", "注册成功设备token为" + data);
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
XGPushManager.upsertAccounts(RemoteService.this, accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
NetInterfaceManager.getInstance().setPushTags();
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
}
});
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
}
});
} }
@Override @Override

View File

@@ -640,7 +640,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
ToastUtil.debugShow("收到推送消息: 强制停止应用"); ToastUtil.debugShow("收到推送消息: 强制停止应用");
JsonObject killJSONObject = GsonUtils.getJsonObject(extras); JsonObject killJSONObject = GsonUtils.getJsonObject(extras);
String packages = killJSONObject.get("app_package").getAsString(); String packages = killJSONObject.get("app_package").getAsString();
JGYUtils.getInstance().killBackgroundProcesses(packages); JGYUtils.getInstance().killPackage(packages);
JGYUtils.getInstance().gotoLauncher(); JGYUtils.getInstance().gotoLauncher();
Log.e(TAG, extras); Log.e(TAG, extras);
break; break;
@@ -784,15 +784,20 @@ public class MessageReceiver extends XGPushBaseReceiver {
setDefaultInputMethod(context, extras); setDefaultInputMethod(context, extras);
break; break;
case ACTION_PARENTAL_CONTROL: case ACTION_PARENTAL_CONTROL:
ToastUtil.debugShow("收到推送消息: 家长管控");
NetInterfaceManager.getInstance().getSystemSettings(); NetInterfaceManager.getInstance().getSystemSettings();
break; break;
case ACTION_WHOLE_MACHINE_QUOTA: case ACTION_WHOLE_MACHINE_QUOTA:
ToastUtil.debugShow("收到推送消息: 整机管控");
NetInterfaceManager.getInstance().getSystemSettings(); NetInterfaceManager.getInstance().getSystemSettings();
NetInterfaceManager.getInstance().getAppTimeControl(); NetInterfaceManager.getInstance().getAppTimeControl();
NetInterfaceManager.getInstance().getSnTimeControl(); NetInterfaceManager.getInstance().getSnTimeControl();
break; break;
case ACTION_APP_CONTROL: case ACTION_APP_CONTROL:
ToastUtil.debugShow("收到推送消息: APP管控");
NetInterfaceManager.getInstance().getSystemSettings();
NetInterfaceManager.getInstance().getAppTimeControl(); NetInterfaceManager.getInstance().getAppTimeControl();
NetInterfaceManager.getInstance().getSnTimeControl();
break; break;
case UPDATE_WHITE_LIST: case UPDATE_WHITE_LIST:
NetInterfaceManager.getInstance().getAllappPackage(); NetInterfaceManager.getInstance().getAllappPackage();

View File

@@ -442,6 +442,7 @@ public class JGYUtils {
} }
public void killPackage(String pkg) { public void killPackage(String pkg) {
Log.e(TAG, "killPackage: " + pkg);
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
manager.killBackgroundProcesses(pkg); manager.killBackgroundProcesses(pkg);
CmdUtil.execute("am force-stop " + pkg); CmdUtil.execute("am force-stop " + pkg);
@@ -611,28 +612,29 @@ public class JGYUtils {
} }
} }
public void killBackgroundProcesses(String processName) { // public void killBackgroundProcesses(String processName) {
// gotoLauncher(); //// gotoLauncher();
// mIsScanning = true; // // mIsScanning = true;
removeTask(processName); // removeTask(processName);
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); // ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = null; // String packageName = null;
try { // try {
if (processName.indexOf(":") == -1) { // if (processName.indexOf(":") == -1) {
packageName = processName; // packageName = processName;
} else { // } else {
packageName = processName.split(":")[0]; // packageName = processName.split(":")[0];
} // }
activityManager.killBackgroundProcesses(packageName); // activityManager.killBackgroundProcesses(packageName);
// // //
Method forceStopPackage = activityManager.getClass() // Method forceStopPackage = activityManager.getClass()
.getDeclaredMethod("forceStopPackage", String.class); // .getDeclaredMethod("forceStopPackage", String.class);
forceStopPackage.setAccessible(true); // forceStopPackage.setAccessible(true);
forceStopPackage.invoke(activityManager, packageName); // forceStopPackage.invoke(activityManager, packageName);
} catch (Exception e) { // Log.e(TAG, "killBackgroundProcesses: " + packageName);
e.printStackTrace(); // } catch (Exception e) {
} // e.printStackTrace();
} // }
// }
/** /**
* 清除所有最近记录 * 清除所有最近记录

14
app/tpns-configs.json Normal file
View File

@@ -0,0 +1,14 @@
{
"tpns": {
"access_id": "1500031216",
"access_key": "A1HBG2922B9Z"
},
"com.fuying.sn": {
"channel": {
"enable": true
}
},
"debug": false,
"version": "1.4.3.4",
"upgrade": false
}

View File

@@ -10,6 +10,8 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.4' classpath 'com.android.tools.build:gradle:3.6.4'
classpath "com.tencent.android.tpns:tpnsplugin:1.8.0"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }