增加全局更新
This commit is contained in:
@@ -67,8 +67,8 @@ android {
|
|||||||
productFlavors {
|
productFlavors {
|
||||||
beta {
|
beta {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 28
|
versionCode 29
|
||||||
versionName "3.7"
|
versionName "3.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
official {
|
official {
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class MainAContact {
|
|||||||
void checkUpdate();
|
void checkUpdate();
|
||||||
/*获取强制下载*/
|
/*获取强制下载*/
|
||||||
void getForceInstall();
|
void getForceInstall();
|
||||||
|
/*获取所有全局更新*/
|
||||||
|
void getOverallApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface MainView extends BaseView {
|
public interface MainView extends BaseView {
|
||||||
@@ -27,5 +29,6 @@ public class MainAContact {
|
|||||||
void setQRCode(Bitmap bitmap);
|
void setQRCode(Bitmap bitmap);
|
||||||
void checkUpdateFinish();
|
void checkUpdateFinish();
|
||||||
void setForceInstall();
|
void setForceInstall();
|
||||||
|
void setOverallApp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class MainAPresenter implements MainAContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(BaseResponse response) {
|
public void onNext(BaseResponse response) {
|
||||||
Log.e(TAG, "onNext: " + response);
|
Log.e("getSnInfo", "onNext: " + response);
|
||||||
mView.setSnInfo(response);
|
mView.setSnInfo(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +136,17 @@ public class MainAPresenter implements MainAContact.Presenter {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getForceInstall", "onComplete: ");
|
Log.e("getForceInstall", "onComplete: ");
|
||||||
|
mView.setForceInstall();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getOverallApp() {
|
||||||
|
NetInterfaceManager.getInstance().getOverallApp(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
mView.setOverallApp();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -419,6 +419,11 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setForceInstall() {
|
public void setForceInstall() {
|
||||||
|
mPresenter.getOverallApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOverallApp() {
|
||||||
Log.e(TAG, "SettingFinish: " + (System.currentTimeMillis() - timeMillis) + " ms");
|
Log.e(TAG, "SettingFinish: " + (System.currentTimeMillis() - timeMillis) + " ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
109
app/src/main/java/com/uiui/sn/bean/OverallAppBean.java
Normal file
109
app/src/main/java/com/uiui/sn/bean/OverallAppBean.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package com.uiui.sn.bean;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class OverallAppBean implements Serializable {
|
||||||
|
private static final long serialVersionUID = -1802437374155952676L;
|
||||||
|
|
||||||
|
String app_name;
|
||||||
|
String app_package;
|
||||||
|
String app_version_name;
|
||||||
|
long app_version_code;
|
||||||
|
long app_size;
|
||||||
|
String app_url;
|
||||||
|
String app_img;
|
||||||
|
String app_md5;
|
||||||
|
String app_desc;
|
||||||
|
int platform;
|
||||||
|
|
||||||
|
public String getApp_name() {
|
||||||
|
return app_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_name(String app_name) {
|
||||||
|
this.app_name = app_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp_package() {
|
||||||
|
return app_package;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_package(String app_package) {
|
||||||
|
this.app_package = app_package;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp_version_name() {
|
||||||
|
return app_version_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_version_name(String app_version_name) {
|
||||||
|
this.app_version_name = app_version_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getApp_version_code() {
|
||||||
|
return app_version_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_version_code(long app_version_code) {
|
||||||
|
this.app_version_code = app_version_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getApp_size() {
|
||||||
|
return app_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_size(long app_size) {
|
||||||
|
this.app_size = app_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp_url() {
|
||||||
|
return app_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_url(String app_url) {
|
||||||
|
this.app_url = app_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp_img() {
|
||||||
|
return app_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_img(String app_img) {
|
||||||
|
this.app_img = app_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp_md5() {
|
||||||
|
return app_md5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_md5(String app_md5) {
|
||||||
|
this.app_md5 = app_md5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp_desc() {
|
||||||
|
return app_desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_desc(String app_desc) {
|
||||||
|
this.app_desc = app_desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlatform() {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlatform(int platform) {
|
||||||
|
this.platform = platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,6 +43,10 @@ public class CommonConfig {
|
|||||||
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
|
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
|
||||||
/*强制安装应用,禁止卸载*/
|
/*强制安装应用,禁止卸载*/
|
||||||
public final static String AOLE_ACTION_FORCE_APP = "aole_force_app";
|
public final static String AOLE_ACTION_FORCE_APP = "aole_force_app";
|
||||||
|
/*禁止升级的应用列表*/
|
||||||
|
public final static String AOLE_ACTION_DISALLOW_UPGRADE = "upgrade_disallow";
|
||||||
|
/*全局 更新获取的包名*/
|
||||||
|
public final static String AOLE_ACTION_OVERALL_APP = "overall_app_packages";
|
||||||
|
|
||||||
/*应用ID管控*/
|
/*应用ID管控*/
|
||||||
public final static String AOLE_ACTION_APP_FORBID_ID = "aole_app_forbid_id";
|
public final static String AOLE_ACTION_APP_FORBID_ID = "aole_app_forbid_id";
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class RunningAppManager {
|
|||||||
registerTimeReceiver(mContext);
|
registerTimeReceiver(mContext);
|
||||||
|
|
||||||
String remainsTimeJson = mMMKV.decodeString(RemainingTimeMap, "");
|
String remainsTimeJson = mMMKV.decodeString(RemainingTimeMap, "");
|
||||||
Log.e(TAG, "remainsTimeJson: " + remainsTimeJson);
|
Log.i(TAG, "remainsTimeJson: " + remainsTimeJson);
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Type remainsTimeType = new TypeToken<HashMap<String, AppRunTimeBean>>() {
|
Type remainsTimeType = new TypeToken<HashMap<String, AppRunTimeBean>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
@@ -120,7 +120,7 @@ public class RunningAppManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String globalUsageTimeJson = mMMKV.decodeString(GlobalUsageTimeMap, "");
|
String globalUsageTimeJson = mMMKV.decodeString(GlobalUsageTimeMap, "");
|
||||||
Log.e(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
Log.i(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
||||||
Type globalUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
Type globalUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
HashMap<String, AppUsageTime> appUsageTimeHashMap = gson.fromJson(globalUsageTimeJson, globalUsageTimeType);
|
HashMap<String, AppUsageTime> appUsageTimeHashMap = gson.fromJson(globalUsageTimeJson, globalUsageTimeType);
|
||||||
@@ -153,7 +153,7 @@ public class RunningAppManager {
|
|||||||
.subscribe(new Consumer<Long>() {
|
.subscribe(new Consumer<Long>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(Long aLong) throws Throwable {
|
public void accept(Long aLong) throws Throwable {
|
||||||
// Log.e(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) {
|
||||||
@@ -169,7 +169,7 @@ public class RunningAppManager {
|
|||||||
*/
|
*/
|
||||||
private void checkForegroundAppName() {
|
private void checkForegroundAppName() {
|
||||||
String topPackage = getTopActivityInfo();
|
String topPackage = getTopActivityInfo();
|
||||||
Log.e(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
Log.i(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||||
String appPackageName = getAppPackageName();
|
String appPackageName = getAppPackageName();
|
||||||
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
||||||
if (allowPackage.contains(topPackage)) {
|
if (allowPackage.contains(topPackage)) {
|
||||||
@@ -178,7 +178,7 @@ public class RunningAppManager {
|
|||||||
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.onCompleteCallback() {
|
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.onCompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e(TAG, "onComplete: ");
|
Log.i(TAG, "onComplete: ");
|
||||||
NetInterfaceManager.getInstance().getSnTimeControl();
|
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||||
}
|
}
|
||||||
@@ -194,18 +194,18 @@ public class RunningAppManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long onClickTime = getOnClickTime();
|
long onClickTime = getOnClickTime();
|
||||||
Log.e(TAG, "checkForegroundAppName: getAppPackageName = " + appPackageName);
|
Log.i(TAG, "checkForegroundAppName: getAppPackageName = " + appPackageName);
|
||||||
if (appPackageName.equals(topPackage)) {
|
if (appPackageName.equals(topPackage)) {
|
||||||
Log.e(TAG, "checkForegroundAppName: 没有切换应用");
|
Log.i(TAG, "checkForegroundAppName: 没有切换应用");
|
||||||
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
||||||
removeTask(topPackage);
|
removeTask(topPackage);
|
||||||
gotoLauncher();
|
gotoLauncher();
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "checkForegroundAppName: 没有管控");
|
Log.i(TAG, "checkForegroundAppName: 没有管控");
|
||||||
reduceAppRemainingTime(topPackage, 1);
|
reduceAppRemainingTime(topPackage, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "checkForegroundAppName: 切换应用:" + topPackage);
|
Log.i(TAG, "checkForegroundAppName: 切换应用:" + topPackage);
|
||||||
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.onCompleteCallback() {
|
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.onCompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
@@ -217,12 +217,12 @@ public class RunningAppManager {
|
|||||||
appPackageName = topPackage;
|
appPackageName = topPackage;
|
||||||
onClickTime = System.currentTimeMillis() / 1000;
|
onClickTime = System.currentTimeMillis() / 1000;
|
||||||
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
if (RunningAppManager.getInstance().inControlTime(appPackageName)) {
|
||||||
Log.e(TAG, "checkForegroundAppName: 没有剩余时间2");
|
Log.i(TAG, "checkForegroundAppName: 没有剩余时间2");
|
||||||
removeTask(topPackage);
|
removeTask(topPackage);
|
||||||
gotoLauncher();
|
gotoLauncher();
|
||||||
} else {
|
} else {
|
||||||
RunningAppManager.getInstance().recordPackageOpenTime(topPackage);
|
RunningAppManager.getInstance().recordPackageOpenTime(topPackage);
|
||||||
Log.e(TAG, "checkForegroundAppName: 没有管控2");
|
Log.i(TAG, "checkForegroundAppName: 没有管控2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveAppRemainingTime();
|
saveAppRemainingTime();
|
||||||
@@ -251,7 +251,7 @@ public class RunningAppManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
Log.e(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);
|
||||||
if ("00:00:00".equals(finaWayDate)) {
|
if ("00:00:00".equals(finaWayDate)) {
|
||||||
@@ -294,7 +294,7 @@ public class RunningAppManager {
|
|||||||
|
|
||||||
for (ActivityManager.RecentTaskInfo info : list) {
|
for (ActivityManager.RecentTaskInfo info : list) {
|
||||||
if (info.realActivity != null) {
|
if (info.realActivity != null) {
|
||||||
Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
Log.i(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||||
//排除自身
|
//排除自身
|
||||||
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
||||||
continue;
|
continue;
|
||||||
@@ -304,7 +304,7 @@ public class RunningAppManager {
|
|||||||
ActivityManagerNative.getDefault().removeTask(info.id);
|
ActivityManagerNative.getDefault().removeTask(info.id);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.e(TAG, "removeAllTask: " + e.getMessage());
|
Log.i(TAG, "removeAllTask: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -319,9 +319,9 @@ public class RunningAppManager {
|
|||||||
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
Log.i(TAG, "removeTask: " + e.getMessage());
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
Log.i(TAG, "removeTask: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ public class RunningAppManager {
|
|||||||
return ActivityTaskManager.getService().getRecentTasks(numTasks,
|
return ActivityTaskManager.getService().getRecentTasks(numTasks,
|
||||||
RECENT_IGNORE_UNAVAILABLE, userId).getList();
|
RECENT_IGNORE_UNAVAILABLE, userId).getList();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to get recent tasks " + e);
|
Log.i(TAG, "Failed to get recent tasks " + e);
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,7 +420,7 @@ public class RunningAppManager {
|
|||||||
appRunTimeBean.setAppRunTime(appTimeControl.getToday_time());
|
appRunTimeBean.setAppRunTime(appTimeControl.getToday_time());
|
||||||
mRemainingTimeMap.put(appTimeControl.getApp_package(), appRunTimeBean);
|
mRemainingTimeMap.put(appTimeControl.getApp_package(), appRunTimeBean);
|
||||||
}
|
}
|
||||||
Log.e(TAG, "syncAppRemainingTime: Finish" + mRemainingTimeMap);
|
Log.i(TAG, "syncAppRemainingTime: Finish" + mRemainingTimeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -482,7 +482,7 @@ public class RunningAppManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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.e(TAG, "reduceAppRemainingTime: isControl = " + isControl);
|
Log.i(TAG, "reduceAppRemainingTime: isControl = " + isControl);
|
||||||
//家长管控关闭始终可用
|
//家长管控关闭始终可用
|
||||||
if (isControl == 0) {
|
if (isControl == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -505,7 +505,7 @@ public class RunningAppManager {
|
|||||||
} else {
|
} else {
|
||||||
mGlobalUsageTime.remove(pkg);
|
mGlobalUsageTime.remove(pkg);
|
||||||
}
|
}
|
||||||
Log.e(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
Log.i(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
||||||
long remainingTime = appTimeControl.getToday_time() - time;
|
long remainingTime = appTimeControl.getToday_time() - time;
|
||||||
if (remainingTime < 0) {
|
if (remainingTime < 0) {
|
||||||
remainingTime = 0;
|
remainingTime = 0;
|
||||||
@@ -516,7 +516,10 @@ public class RunningAppManager {
|
|||||||
appTimeControl.setToday_time(remainingTime);
|
appTimeControl.setToday_time(remainingTime);
|
||||||
TimeControlManager.getInstance().setAppTimeControl(pkg, appTimeControl);
|
TimeControlManager.getInstance().setAppTimeControl(pkg, appTimeControl);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "reduceAppRemainingTime: " + machineControl.getToday_time());
|
if (machineControl==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.i(TAG, "reduceAppRemainingTime: " + machineControl.getToday_time());
|
||||||
long remainingTime = machineControl.getToday_time() - time;
|
long remainingTime = machineControl.getToday_time() - time;
|
||||||
if (remainingTime < 0) {
|
if (remainingTime < 0) {
|
||||||
remainingTime = 0;
|
remainingTime = 0;
|
||||||
@@ -551,9 +554,9 @@ public class RunningAppManager {
|
|||||||
if (allowPackage.contains(pkg)) {
|
if (allowPackage.contains(pkg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log.e(TAG, "inControlTime: pkg = " + pkg);
|
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.e(TAG, "inControlTime: isControl = " + isControl);
|
Log.i(TAG, "inControlTime: isControl = " + isControl);
|
||||||
//家长管控关闭始终可用
|
//家长管控关闭始终可用
|
||||||
if (isControl == 0) {
|
if (isControl == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -576,7 +579,7 @@ public class RunningAppManager {
|
|||||||
boolean inControlTime = inControlTime(machineControl, appTimeControl);
|
boolean inControlTime = inControlTime(machineControl, appTimeControl);
|
||||||
//判断是否在时间段内
|
//判断是否在时间段内
|
||||||
if (inControlTime) {
|
if (inControlTime) {
|
||||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
|
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
|
||||||
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -616,7 +619,7 @@ public class RunningAppManager {
|
|||||||
} else {
|
} else {
|
||||||
boolean inControlTime = inControlTime(machineControl);
|
boolean inControlTime = inControlTime(machineControl);
|
||||||
if (inControlTime) {
|
if (inControlTime) {
|
||||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + machineControl.time_part.toString());
|
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + machineControl.time_part.toString());
|
||||||
ToastUtil.show("该应用" + partTime2String(machineControl));
|
ToastUtil.show("该应用" + partTime2String(machineControl));
|
||||||
}
|
}
|
||||||
return inControlTime;
|
return inControlTime;
|
||||||
@@ -684,9 +687,9 @@ public class RunningAppManager {
|
|||||||
// if (allowPackage.contains(pkg)) {
|
// if (allowPackage.contains(pkg)) {
|
||||||
// return "";
|
// return "";
|
||||||
// }
|
// }
|
||||||
// Log.e(TAG, "inControlTime: pkg = " + pkg);
|
// Log.i(TAG, "inControlTime: pkg = " + pkg);
|
||||||
// int is_control = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
// int is_control = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||||
// Log.e(TAG, "inControlTime: is_control = " + is_control);
|
// Log.i(TAG, "inControlTime: is_control = " + is_control);
|
||||||
//家长管控关闭始终可用
|
//家长管控关闭始终可用
|
||||||
// if (is_control == 0) {
|
// if (is_control == 0) {
|
||||||
// return "";
|
// return "";
|
||||||
@@ -832,7 +835,7 @@ public class RunningAppManager {
|
|||||||
// } else {
|
// } else {
|
||||||
// return restTime - todayTime <= 0;
|
// return restTime - todayTime <= 0;
|
||||||
// }
|
// }
|
||||||
Log.e(TAG, "haveUseTime: " + globalRemainingTime);
|
Log.i(TAG, "haveUseTime: " + globalRemainingTime);
|
||||||
return !(globalRemainingTime > 0);
|
return !(globalRemainingTime > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -965,7 +968,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.e(TAG, "inControlTime: " + inControlTime);
|
Log.i(TAG, "inControlTime: " + inControlTime);
|
||||||
return inControlTime;
|
return inControlTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1038,7 +1041,7 @@ public class RunningAppManager {
|
|||||||
//开始时间大于结束时间 列 16:00-01:00
|
//开始时间大于结束时间 列 16:00-01:00
|
||||||
endDate.setTime(endDate.getTime() + dayTime);
|
endDate.setTime(endDate.getTime() + dayTime);
|
||||||
}
|
}
|
||||||
Log.e(TAG, "inControlTime: " + (startDate.getTime() - minuteTime));
|
Log.i(TAG, "inControlTime: " + (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()) {
|
||||||
@@ -1069,7 +1072,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.e(TAG, "getDate: " + finaWayDate);
|
Log.i(TAG, "getDate: " + finaWayDate);
|
||||||
return finaWayDate;
|
return finaWayDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +1083,7 @@ public class RunningAppManager {
|
|||||||
*/
|
*/
|
||||||
public int getWeekDay() {
|
public int getWeekDay() {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
Log.e(TAG, "getWeekDay: " + time);
|
Log.i(TAG, "getWeekDay: " + time);
|
||||||
return getWeekDay(time);
|
return getWeekDay(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1165,10 +1168,10 @@ public class RunningAppManager {
|
|||||||
|
|
||||||
public void checkTopAppPackageName() {
|
public void checkTopAppPackageName() {
|
||||||
String topPackage = getTopActivityInfo();
|
String topPackage = getTopActivityInfo();
|
||||||
Log.e(TAG, "onReceive: " + topPackage);
|
Log.i(TAG, "onReceive: " + topPackage);
|
||||||
// Log.e(TAG, "onReceive: getWeekDay: " + getWeekDay());
|
// Log.i(TAG, "onReceive: getWeekDay: " + getWeekDay());
|
||||||
// Log.e(TAG, "onReceive: getWeekDayString: " + getWeekDayString());
|
// Log.i(TAG, "onReceive: getWeekDayString: " + getWeekDayString());
|
||||||
// Log.e(TAG, "onReceive: inWeekDay: " + inWeekDay());
|
// Log.i(TAG, "onReceive: inWeekDay: " + inWeekDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1204,7 +1207,7 @@ public class RunningAppManager {
|
|||||||
currentClassName = initStat.getPackageName();
|
currentClassName = initStat.getPackageName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.e(TAG, "getForegroundActivityName: " + currentClassName);
|
Log.i(TAG, "getForegroundActivityName: " + currentClassName);
|
||||||
return currentClassName;
|
return currentClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class CacheHelper {
|
|||||||
// =======================================
|
// =======================================
|
||||||
|
|
||||||
public void put(String key, String value) {
|
public void put(String key, String value) {
|
||||||
Log.e(TAG, "put: key = " + key + " value = " + value);
|
// Log.e(TAG, "put: key = " + key + " value = " + value);
|
||||||
mMMKV.encode(key, System.currentTimeMillis());
|
mMMKV.encode(key, System.currentTimeMillis());
|
||||||
mMMKV.encode(key + "_mmkv", value);
|
mMMKV.encode(key + "_mmkv", value);
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public class CacheHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getAsString(String key) {
|
public String getAsString(String key) {
|
||||||
Log.e(TAG, "getAsString: " + key);
|
// Log.e(TAG, "getAsString: " + key);
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
//write READ
|
//write READ
|
||||||
@@ -435,7 +435,7 @@ public class CacheHelper {
|
|||||||
DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key));
|
DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key));
|
||||||
if (snapshot == null) //not find entry , or entry.readable = false
|
if (snapshot == null) //not find entry , or entry.readable = false
|
||||||
{
|
{
|
||||||
Log.e(TAG, "not find entry , or entry.readable = false");
|
// Log.e(TAG, "not find entry , or entry.readable = false");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//write READ
|
//write READ
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.trello.rxlifecycle4.android.ActivityEvent;
|
|||||||
import com.uiui.sn.BuildConfig;
|
import com.uiui.sn.BuildConfig;
|
||||||
import com.uiui.sn.bean.AppInfo;
|
import com.uiui.sn.bean.AppInfo;
|
||||||
import com.uiui.sn.bean.AppStart;
|
import com.uiui.sn.bean.AppStart;
|
||||||
|
import com.uiui.sn.bean.OverallAppBean;
|
||||||
import com.uiui.sn.desktop.AppTimeControl;
|
import com.uiui.sn.desktop.AppTimeControl;
|
||||||
import com.uiui.sn.bean.AppUploadInfo;
|
import com.uiui.sn.bean.AppUploadInfo;
|
||||||
import com.uiui.sn.bean.AppletQRCode;
|
import com.uiui.sn.bean.AppletQRCode;
|
||||||
@@ -63,6 +64,7 @@ import com.uiui.sn.network.api.GetGuideApi;
|
|||||||
import com.uiui.sn.network.api.GetPublicIPApi;
|
import com.uiui.sn.network.api.GetPublicIPApi;
|
||||||
import com.uiui.sn.network.api.MachineTimeControlApi;
|
import com.uiui.sn.network.api.MachineTimeControlApi;
|
||||||
import com.uiui.sn.network.api.NewestAppUpdate;
|
import com.uiui.sn.network.api.NewestAppUpdate;
|
||||||
|
import com.uiui.sn.network.api.OverallAppByPlatformApi;
|
||||||
import com.uiui.sn.network.api.QRCodeApi;
|
import com.uiui.sn.network.api.QRCodeApi;
|
||||||
import com.uiui.sn.network.api.QueryAllApp;
|
import com.uiui.sn.network.api.QueryAllApp;
|
||||||
import com.uiui.sn.network.api.QueryAppInside;
|
import com.uiui.sn.network.api.QueryAppInside;
|
||||||
@@ -389,6 +391,25 @@ public class NetInterfaceManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Observable<BaseResponse<List<OverallAppBean>>> getOverallAppObservable() {
|
||||||
|
int platformCode = 0;
|
||||||
|
String platform = BuildConfig.platform;
|
||||||
|
switch (platform) {
|
||||||
|
case "ZhanRui":
|
||||||
|
platformCode = 2;
|
||||||
|
break;
|
||||||
|
case "MTK":
|
||||||
|
platformCode = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
platformCode = 3;
|
||||||
|
}
|
||||||
|
return getOverallAppByPlatformControl()
|
||||||
|
.getOverallApp(platformCode)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* API
|
* API
|
||||||
@@ -415,6 +436,10 @@ public class NetInterfaceManager {
|
|||||||
return mRetrofit.create(NewestAppUpdate.class);
|
return mRetrofit.create(NewestAppUpdate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OverallAppByPlatformApi getOverallAppByPlatformControl() {
|
||||||
|
return mRetrofit.create(OverallAppByPlatformApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
public UploadScreenshot getUploadScreenshotControl() {
|
public UploadScreenshot getUploadScreenshotControl() {
|
||||||
return mRetrofit.create(UploadScreenshot.class);
|
return mRetrofit.create(UploadScreenshot.class);
|
||||||
}
|
}
|
||||||
@@ -1598,7 +1623,7 @@ public class NetInterfaceManager {
|
|||||||
String upgrade_allow = String.join(",", allowApp);
|
String upgrade_allow = String.join(",", allowApp);
|
||||||
Log.e("setAppUpdate", "upgrade_allow: " + upgrade_allow);
|
Log.e("setAppUpdate", "upgrade_allow: " + upgrade_allow);
|
||||||
Log.e("setAppUpdate", "upgrade_disallow: " + upgrade_disallow);
|
Log.e("setAppUpdate", "upgrade_disallow: " + upgrade_disallow);
|
||||||
Settings.System.putString(crv, "upgrade_disallow", upgrade_disallow);
|
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE, upgrade_disallow);
|
||||||
Utils.writeDisableUpdateList(mContext);
|
Utils.writeDisableUpdateList(mContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2427,5 +2452,119 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getOverallApp(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||||
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
|
if (refresh) {
|
||||||
|
connectMode = ConnectMode.DEFAULT;
|
||||||
|
}
|
||||||
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GE_TOVERALL_APPBYPLATFORM, connectMode)) {
|
||||||
|
getOverallApp(lifecycle, callback);
|
||||||
|
} else {
|
||||||
|
String jsonString = mCacheHelper.getAsString(UrlAddress.GE_TOVERALL_APPBYPLATFORM);
|
||||||
|
//为 "" 是已经请求成功的
|
||||||
|
if (jsonString == null) {
|
||||||
|
getOverallApp(lifecycle, callback);
|
||||||
|
} else {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Type type = new TypeToken<List<OverallAppBean>>() {
|
||||||
|
}.getType();
|
||||||
|
List<OverallAppBean> overallAppBeanList = gson.fromJson(jsonString, type);
|
||||||
|
installOverallApp(overallAppBeanList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getOverallApp(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||||
|
getOverallAppObservable()
|
||||||
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
|
.subscribe(getOverallAppObserver(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getOverallApp(onCompleteCallback callback) {
|
||||||
|
getOverallAppObservable()
|
||||||
|
.subscribe(getOverallAppObserver(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getOverallApp() {
|
||||||
|
getOverallAppObservable()
|
||||||
|
.subscribe(getOverallAppObserver(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Observer<BaseResponse<List<OverallAppBean>>> getOverallAppObserver(onCompleteCallback callback) {
|
||||||
|
return new Observer<BaseResponse<List<OverallAppBean>>>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
Log.e("getOverallApp", "onSubscribe: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseResponse<List<OverallAppBean>> baseResponse) {
|
||||||
|
Log.e("getOverallApp", "onNext: " + baseResponse);
|
||||||
|
if (baseResponse.code == 200) {
|
||||||
|
List<OverallAppBean> overallAppBeanList = baseResponse.data;
|
||||||
|
mCacheHelper.put(UrlAddress.GE_TOVERALL_APPBYPLATFORM, GsonUtils.toJSONString(overallAppBeanList));
|
||||||
|
installOverallApp(overallAppBeanList);
|
||||||
|
} else {
|
||||||
|
mCacheHelper.put(UrlAddress.GE_TOVERALL_APPBYPLATFORM, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
Log.e("getOverallApp", "onError: ");
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.e("getOverallApp", "onComplete: ");
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void installOverallApp(List<OverallAppBean> overallAppBeanList) {
|
||||||
|
if (overallAppBeanList == null || overallAppBeanList.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String packageList = overallAppBeanList.stream().map(OverallAppBean::getApp_package).collect(Collectors.joining(","));
|
||||||
|
Log.e(TAG, "installOverallApp: " + packageList);
|
||||||
|
mMMKV.encode(CommonConfig.AOLE_ACTION_OVERALL_APP, packageList);
|
||||||
|
Utils.writeDisableUpdateList(mContext);
|
||||||
|
Log.e(TAG, "installOverallApp: " + packageList);
|
||||||
|
for (OverallAppBean overallAppBean : overallAppBeanList) {
|
||||||
|
String packages = overallAppBean.getApp_package();
|
||||||
|
String url = overallAppBean.getApp_url();
|
||||||
|
if (TextUtils.isEmpty(url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
long app_version_code = overallAppBean.getApp_version_code();
|
||||||
|
PackageInfo info = null;
|
||||||
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
try {
|
||||||
|
info = pm.getPackageInfo(packages, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (null != info) {
|
||||||
|
long appVersionCode;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
appVersionCode = info.getLongVersionCode();
|
||||||
|
} else {
|
||||||
|
appVersionCode = info.versionCode;
|
||||||
|
}
|
||||||
|
if (appVersionCode < app_version_code) {
|
||||||
|
Log.e(TAG, "installOverallApp: " + "need to upgrade");
|
||||||
|
FileUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "installOverallApp: " + "it's up to date , no need upgrade");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "installOverallApp: " + "not installed , upgrade");
|
||||||
|
FileUtils.ariaDownload(mContext, url, GsonUtils.getJsonObject(overallAppBean.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public class UrlAddress {
|
|||||||
public final static String UPDATE_SNINFO = "sn/updateAdminSn";
|
public final static String UPDATE_SNINFO = "sn/updateAdminSn";
|
||||||
/*根据包名获取更新*/
|
/*根据包名获取更新*/
|
||||||
public final static String GET_NEWESTAPPUPDATE = "app/newestAppUpdate";
|
public final static String GET_NEWESTAPPUPDATE = "app/newestAppUpdate";
|
||||||
|
/*获取所有全局更新*/
|
||||||
|
public final static String GE_TOVERALL_APPBYPLATFORM = "app/overallAppByPlatform";
|
||||||
/*上传屏幕截图*/
|
/*上传屏幕截图*/
|
||||||
public final static String UPLOAD_SCREEN_SNAPSHOT = "sn/uploadScreenshot";
|
public final static String UPLOAD_SCREEN_SNAPSHOT = "sn/uploadScreenshot";
|
||||||
/*获取屏幕管控*/
|
/*获取屏幕管控*/
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.uiui.sn.network.api;
|
||||||
|
|
||||||
|
import com.uiui.sn.bean.BaseResponse;
|
||||||
|
import com.uiui.sn.bean.OverallAppBean;
|
||||||
|
import com.uiui.sn.network.UrlAddress;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
|
public interface OverallAppByPlatformApi {
|
||||||
|
@GET(UrlAddress.GE_TOVERALL_APPBYPLATFORM)
|
||||||
|
Observable<BaseResponse<List<OverallAppBean>>> getOverallApp(
|
||||||
|
@Query("platform") int platform
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
|||||||
// Response copy = response.newBuilder().body(responseBody).build();
|
// Response copy = response.newBuilder().body(responseBody).build();
|
||||||
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
|
// Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: " + content);
|
||||||
}
|
}
|
||||||
//相同的请求
|
//相同的请求
|
||||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
|||||||
NetInterfaceManager.getInstance().getForceInstall();
|
NetInterfaceManager.getInstance().getForceInstall();
|
||||||
NetInterfaceManager.getInstance().getAllappPackage();
|
NetInterfaceManager.getInstance().getAllappPackage();
|
||||||
NetInterfaceManager.getInstance().getAppInside();
|
NetInterfaceManager.getInstance().getAppInside();
|
||||||
|
NetInterfaceManager.getInstance().getOverallApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class MainSContact {
|
|||||||
void checkUpdateFinish();
|
void checkUpdateFinish();
|
||||||
void checkFXYUpdateFinish();
|
void checkFXYUpdateFinish();
|
||||||
void getAllAppFinish();
|
void getAllAppFinish();
|
||||||
|
void setOverallApp();
|
||||||
void setAppInside();
|
void setAppInside();
|
||||||
void setForceInstall();
|
void setForceInstall();
|
||||||
void setSystemSettings();
|
void setSystemSettings();
|
||||||
@@ -37,6 +38,8 @@ public class MainSContact {
|
|||||||
void checkFXYUpdate();
|
void checkFXYUpdate();
|
||||||
//获取所有app包名
|
//获取所有app包名
|
||||||
void getAllApp();
|
void getAllApp();
|
||||||
|
/*获取所有全局更新*/
|
||||||
|
void getOverallApp();
|
||||||
//获取id管控
|
//获取id管控
|
||||||
void getAppInside();
|
void getAppInside();
|
||||||
//获取强制下载
|
//获取强制下载
|
||||||
|
|||||||
@@ -188,6 +188,16 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getOverallApp() {
|
||||||
|
NetInterfaceManager.getInstance().getOverallApp(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
mView.setOverallApp();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getAppInside() {
|
public void getAppInside() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
SPUtils.put(this, CommonConfig.JGY_FIRST_BOOT, 1);
|
SPUtils.put(this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||||
}
|
}
|
||||||
mPresenter.checkUpdate();
|
mPresenter.checkUpdate();
|
||||||
|
mPresenter.getAllApp();
|
||||||
TimeTask task = new TimeTask();
|
TimeTask task = new TimeTask();
|
||||||
task.execute("ntp.aliyun.com");
|
task.execute("ntp.aliyun.com");
|
||||||
}
|
}
|
||||||
@@ -432,6 +433,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getAllAppFinish() {
|
public void getAllAppFinish() {
|
||||||
|
mPresenter.getOverallApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOverallApp() {
|
||||||
mPresenter.getAppInside();
|
mPresenter.getAppInside();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -51,6 +53,7 @@ import com.uiui.sn.utils.ApkUtils;
|
|||||||
import com.uiui.sn.utils.CacheUtils;
|
import com.uiui.sn.utils.CacheUtils;
|
||||||
import com.uiui.sn.utils.CmdUtil;
|
import com.uiui.sn.utils.CmdUtil;
|
||||||
import com.uiui.sn.gson.GsonUtils;
|
import com.uiui.sn.gson.GsonUtils;
|
||||||
|
import com.uiui.sn.utils.FileUtils;
|
||||||
import com.uiui.sn.utils.JGYUtils;
|
import com.uiui.sn.utils.JGYUtils;
|
||||||
import com.uiui.sn.utils.SPUtils;
|
import com.uiui.sn.utils.SPUtils;
|
||||||
import com.uiui.sn.utils.ServiceAliveUtils;
|
import com.uiui.sn.utils.ServiceAliveUtils;
|
||||||
@@ -553,8 +556,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
case JIGUANG_FORCE_INSTALLAPK:
|
case JIGUANG_FORCE_INSTALLAPK:
|
||||||
ToastUtil.debugShow("收到推送消息: 强制安装应用");
|
ToastUtil.debugShow("收到推送消息: 强制安装应用");
|
||||||
NetInterfaceManager.getInstance().getAllappPackage();
|
NetInterfaceManager.getInstance().getAllappPackage();
|
||||||
NetInterfaceManager.getInstance().getForceInstall();
|
NetInterfaceManager.getInstance().getOverallApp();
|
||||||
// intallApk(context, extras);
|
intallApk(context, extras);
|
||||||
break;
|
break;
|
||||||
case JIGUANG_FORCE_UNINSTALLAPK:
|
case JIGUANG_FORCE_UNINSTALLAPK:
|
||||||
ToastUtil.debugShow("收到推送消息: 强制卸载应用");
|
ToastUtil.debugShow("收到推送消息: 强制卸载应用");
|
||||||
@@ -998,35 +1001,41 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//静默安装应用,使用okgo,断网会出现问题,等待修改使用aria
|
private void intallApk(Context context, String jsonString) {
|
||||||
synchronized private void intallApk(Context context, String jsonString) {
|
|
||||||
if (TextUtils.isEmpty(jsonString)) {
|
if (TextUtils.isEmpty(jsonString)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// NetInterfaceManager.getInstance().getAllAppPackageName(context);
|
|
||||||
JsonObject extra = GsonUtils.getJsonObject(jsonString);
|
JsonObject extra = GsonUtils.getJsonObject(jsonString);
|
||||||
final String packages = extra.get("package").getAsString();
|
String packages = extra.get("package").getAsString();
|
||||||
ToastUtil.debugShow("收到应用安装消息:包名" + packages);
|
ToastUtil.debugShow("收到应用安装消息:包名" + packages);
|
||||||
String url = extra.get("url").getAsString();
|
String url = extra.get("url").getAsString();
|
||||||
if (TextUtils.isEmpty(url)) {
|
if (TextUtils.isEmpty(url)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Aria.download(this).taskExists(url)) {
|
long app_version_code = extra.get("app_version_code").getAsLong();
|
||||||
|
PackageInfo info = null;
|
||||||
List<DownloadEntity> entity = Aria.download(this).getDownloadEntity(url);
|
PackageManager pm = context.getPackageManager();
|
||||||
for (DownloadEntity downloadEntity : entity) {
|
try {
|
||||||
Aria.download(this).load(downloadEntity.getId()).cancel(true);
|
info = pm.getPackageInfo(packages, 0);
|
||||||
}
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (null != info) {
|
||||||
|
long appVersionCode;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
appVersionCode = info.getLongVersionCode();
|
||||||
|
} else {
|
||||||
|
appVersionCode = info.versionCode;
|
||||||
|
}
|
||||||
|
if (appVersionCode < app_version_code) {
|
||||||
|
Log.e(TAG, "intallApk: " + "need to upgrade");
|
||||||
|
FileUtils.ariaDownload(context, url, extra);
|
||||||
|
} else
|
||||||
|
Log.e(TAG, "intallApk: " + "it's up to date , no need upgrade");
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "intallApk: " + "not installed , upgrade");
|
||||||
|
FileUtils.ariaDownload(context, url, extra);
|
||||||
}
|
}
|
||||||
File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/apk");
|
|
||||||
file.mkdirs();
|
|
||||||
Aria.download(this)
|
|
||||||
.load(url)
|
|
||||||
.setFilePath(JGYUtils.getInstance().getDownLoadPath() + packages + ".apk")
|
|
||||||
.ignoreFilePathOccupy()
|
|
||||||
.setExtendField(packages).create();
|
|
||||||
Aria.download(this).resumeAllTask();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized private void unintallApk(Context context, String jsonString) {
|
synchronized private void unintallApk(Context context, String jsonString) {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import com.google.zxing.WriterException;
|
|||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.uiui.sn.BuildConfig;
|
import com.uiui.sn.BuildConfig;
|
||||||
import com.uiui.sn.R;
|
import com.uiui.sn.R;
|
||||||
import com.uiui.sn.Statistics.AppInformation;
|
import com.uiui.sn.Statistics.AppInformation;
|
||||||
@@ -869,13 +870,15 @@ public class Utils {
|
|||||||
//允许安装的app
|
//允许安装的app
|
||||||
String now = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
String now = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
||||||
//禁止升级的app
|
//禁止升级的app
|
||||||
String upgrade_disallow = Settings.System.getString(context.getContentResolver(), "upgrade_disallow");
|
String upgrade_disallow = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE);
|
||||||
//所有app
|
//所有app
|
||||||
String only_jgy_shortcut_list = Settings.System.getString(context.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST);
|
String only_jgy_shortcut_list = Settings.System.getString(context.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST);
|
||||||
|
String overall_app_list = MMKV.defaultMMKV().decodeString(CommonConfig.AOLE_ACTION_OVERALL_APP, "");
|
||||||
Log.e("writeDisableUpdateList", "aole_app_forbid: " + now);
|
Log.e("writeDisableUpdateList", "aole_app_forbid: " + now);
|
||||||
HashSet<String> nowList = new HashSet<>();
|
HashSet<String> nowList = new HashSet<>();
|
||||||
HashSet<String> disallowList = new HashSet<>();
|
HashSet<String> disallowList = new HashSet<>();
|
||||||
HashSet<String> allList = new HashSet<>();
|
HashSet<String> allList = new HashSet<>();
|
||||||
|
HashSet<String> overallList = new HashSet<>();
|
||||||
if (!TextUtils.isEmpty(now)) {
|
if (!TextUtils.isEmpty(now)) {
|
||||||
nowList = new HashSet<>(Arrays.asList(now.trim().replaceAll(" ", "").split(",")));
|
nowList = new HashSet<>(Arrays.asList(now.trim().replaceAll(" ", "").split(",")));
|
||||||
}
|
}
|
||||||
@@ -885,11 +888,16 @@ public class Utils {
|
|||||||
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
|
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
|
||||||
allList = new HashSet<>(Arrays.asList(only_jgy_shortcut_list.trim().replaceAll(" ", "").split(",")));
|
allList = new HashSet<>(Arrays.asList(only_jgy_shortcut_list.trim().replaceAll(" ", "").split(",")));
|
||||||
}
|
}
|
||||||
|
if (!TextUtils.isEmpty(overall_app_list)) {
|
||||||
|
overallList = new HashSet<>(Arrays.asList(overall_app_list.trim().replaceAll(" ", "").split(",")));
|
||||||
|
}
|
||||||
Log.e("writeDisableUpdateList", "nowList: " + nowList);
|
Log.e("writeDisableUpdateList", "nowList: " + nowList);
|
||||||
Log.e("writeDisableUpdateList", "upgrade_disallow: " + disallowList);
|
Log.e("writeDisableUpdateList", "upgrade_disallow: " + disallowList);
|
||||||
Log.e("writeDisableUpdateList", "only_jgy_shortcut_list: " + allList);
|
Log.e("writeDisableUpdateList", "only_jgy_shortcut_list: " + allList);
|
||||||
|
Log.e("writeDisableUpdateList", "overall_app_list: " + overallList);
|
||||||
//合并
|
//合并
|
||||||
allList.addAll(nowList);
|
allList.addAll(nowList);
|
||||||
|
allList.addAll(overallList);
|
||||||
|
|
||||||
for (String s : disallowList) {
|
for (String s : disallowList) {
|
||||||
if (ApkUtils.isAvailable(context, s)) {
|
if (ApkUtils.isAvailable(context, s)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user