2 Commits

23 changed files with 1052 additions and 596 deletions

View File

@@ -29,8 +29,8 @@ android {
defaultConfig {
applicationId "com.aoleyun.sn"
versionCode 216
versionName "1.6.0507"
versionCode 226
versionName "1.6.05263"
//There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature.
minSdkVersion 24

View File

@@ -81,7 +81,7 @@
<!-- 允许访问振动设备 -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- 允许使用PowerManager的 WakeLocks保持进程在休眠时从屏幕消失 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 允许程序读取或写入系统设置 -->
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- android 9.0上使用前台服务,需要添加权限 -->

View File

@@ -21,6 +21,7 @@ import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.databinding.ActivityMainBinding;
import com.aoleyun.sn.gson.GsonUtils;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.network.UrlAddress;
import com.aoleyun.sn.utils.AES.CXAESUtil;
import com.aoleyun.sn.utils.JgyUtils;
import com.aoleyun.sn.utils.Utils;
@@ -58,6 +59,7 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
checkTestUpdate();
getDefaultDesktop();
getDefaultApp();
getAllInfoAndSetting();
}
public MutableLiveData<Boolean> mLockedData = new MutableLiveData<>();
@@ -81,6 +83,7 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
* 通过sn获取用户信息
*/
public void getStudesInfo() {
NetInterfaceManager.removeCache(UrlAddress.GET_STUDENTS_INFO);
NetInterfaceManager.getInstance().getStudesInfo(getLifecycle(), new NetInterfaceManager.StudesInfoListener() {
@Override
public void setStudentsInfo(StudentsInfo studentsInfo) {
@@ -240,6 +243,9 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
});
}
public void getAllInfoAndSetting() {
NetInterfaceManager.getInstance().getAllInfoAndSetting(getLifecycle());
}
public MutableLiveData<Bitmap> mQrCodeData = new MutableLiveData<>();
@@ -344,7 +350,7 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
}
public void getPushTags() {
NetInterfaceManager.getInstance().setPushTags(getLifecycle(), new NetInterfaceManager.PushTagCallback() {
NetInterfaceManager.getInstance().getPushAndPubAppTag(getLifecycle(), new NetInterfaceManager.PushTagCallback() {
@Override
public void setPushTag(String tag) {

View File

@@ -320,7 +320,7 @@ public class BaseApplication extends MultiDexApplication {
aliyunPushInit();
break;
default:
NetInterfaceManager.getInstance().setPushTags();
NetInterfaceManager.getInstance().getPushAndPubAppTag();
}
}

View File

@@ -14,6 +14,8 @@ public class ForceDownloadData implements Serializable {
String app_id;
String app_md5;
long app_version_code;
int allow_install_app;
public String getApp_package() {
return app_package;
@@ -63,6 +65,14 @@ public class ForceDownloadData implements Serializable {
this.app_md5 = app_md5;
}
public int getAllow_install_app() {
return allow_install_app;
}
public void setAllow_install_app(int allow_install_app) {
this.allow_install_app = allow_install_app;
}
@Override
public String toString() {
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();

View File

@@ -1,48 +0,0 @@
package com.aoleyun.sn.bean;
import com.google.gson.Gson;
import com.google.gson.JsonParser;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.util.List;
public class NetAndLaunchBean implements Serializable {
private static final long serialVersionUID = -5029848848935111774L;
private int code;
private String msg;
private List<NetAndLaunchData> data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<NetAndLaunchData> getData() {
return data;
}
public void setData(List<NetAndLaunchData> data) {
this.data = data;
}
@NotNull
@Override
public String toString() {
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
}
}

View File

@@ -17,6 +17,7 @@ public class NetAndLaunchData implements Serializable {
int is_appstore;
int is_notification;
int is_dynamic_perm;
int allow_install_app;
public int getIs_slide() {
@@ -93,6 +94,14 @@ public class NetAndLaunchData implements Serializable {
this.is_dynamic_perm = is_dynamic_perm;
}
public int getAllow_install_app() {
return allow_install_app;
}
public void setAllow_install_app(int allow_install_app) {
this.allow_install_app = allow_install_app;
}
@Override
public String toString() {
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();

View File

@@ -0,0 +1,26 @@
package com.aoleyun.sn.bean;
import java.io.Serializable;
public class PushTag implements Serializable {
private static final long serialVersionUID = 4259225499869024039L;
String tag;
String tag_type;
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getTag_type() {
return tag_type;
}
public void setTag_type(String tag_type) {
this.tag_type = tag_type;
}
}

View File

@@ -1,13 +1,28 @@
package com.aoleyun.sn.bean;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.JsonParser;
import java.io.Serializable;
import java.util.List;
public class TimeControlData implements Serializable {
private static final long serialVersionUID = 8902745668847718218L;
//1不能使用,0可用
int use_ctrl;
List<TimeControlInfo> periods;
public int getUse_ctrl() {
return use_ctrl;
}
public void setUse_ctrl(int use_ctrl) {
this.use_ctrl = use_ctrl;
}
public List<TimeControlInfo> getPeriods() {
return periods;
}
@@ -15,4 +30,10 @@ public class TimeControlData implements Serializable {
public void setPeriods(List<TimeControlInfo> periods) {
this.periods = periods;
}
@NonNull
@Override
public String toString() {
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
}
}

View File

@@ -67,6 +67,8 @@ public class CommonConfig {
public final static String DEVICES_TAG = "Aoleyun_devices_tpush_tag";
/*分组标签*/
public final static String DEVICES_GROUP_TAG = "Aoleyun_devices_tpush_group_tag";
/*公共应用标签*/
public final static String SN_PUBLIC_APP_TAG = "Aoleyun_sn_public_app_tag";
/*上次获取标签的时间*/
public final static String GET_DEVICES_TAG_LASTTIME = "Aoleyun_devices_tag_last_time";
/*专注模式刷新*/
@@ -115,11 +117,11 @@ public class CommonConfig {
public final static String AOLE_APP_ALLOW_INSTALL = "aole_app_allow_install";
/*应用安装白名单*/
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
/*公共应用白名单*/
public final static String AOLE_PUBLIC_APP_INSTALL_WHITELIST = "aole_public_app_install_whitelist_set";
/*强制安装应用,禁止卸载*/
public final static String AOLE_ACTION_FORCE_APP = "aole_force_app";
/*指定应用安装源 非指定包名不能安装apk*/
public static final String SEEWO_APP_SOURCE_INSTALL_WHITELIST = "seewo_app_source_install_whitelist";
/*指定应用安装源 非指定包名不能安装apk*/
public static final String APP_SOURCE_WHITE_LIST = "app_source_white_list";
/*应用ID管控*/
@@ -185,7 +187,11 @@ public class CommonConfig {
public final static String AOLE_ACTION_RESTORE_FORBID_ON = "aole_restore_forbid_on";
public final static String AOLE_ACTION_DISABLE_APP = "aole_disable_app_list";
/*公共应用白名单*/
public final static String AOLE_PUBLIC_APP_INSTALL_WHITELIST = "aole_public_app_install_whitelist_set";
/*分组应用白名单*/
public final static String AOLE_GROUP_APP_INSTALL_WHITELIST = "aole_group_app_install_whitelist_set";
/*所有白名单应用*/
public final static String AOLE_ALL_APP_WHITE_LIST_KEY = "aole_all_app_white_list";
/*系统设置菜单选项*/
public final static String AOLE_SETTINGS_DISALLOW = "aole_settings_disallow";

View File

@@ -13,6 +13,8 @@ public class UrlAddress {
public static final String GET_DEVICES_LOCKED = "lock/index";
/*获取设备标签*/
public static final String GET_DEVICES_TAGS = "Sn/getSnTag";
/*获取公共应用推送标签*/
public static final String GET_PUSH_TAG = "sn/get-push-tag";
/*通过sn获取信息*/
public static final String GET_STUDENTS_INFO = "Sn/getStudent";
/*获取霸屏状态*/
@@ -149,7 +151,6 @@ public class UrlAddress {
public static final String GET_DEFAULT_APP = "app/getDefaultApp";
/**
* log相关
*/

View File

@@ -4,7 +4,7 @@ import com.aoleyun.sn.bean.AppAttr;
import com.aoleyun.sn.bean.AppID;
import com.aoleyun.sn.bean.Appground;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.bean.NetAndLaunchBean;
import com.aoleyun.sn.bean.NetAndLaunchData;
import com.aoleyun.sn.bean.TopApp;
import com.aoleyun.sn.network.UrlAddress;
@@ -20,7 +20,7 @@ import retrofit2.http.Query;
public interface AppControlApi {
@FormUrlEncoded
@POST(UrlAddress.NET_AND_LAUNCH_API)
Observable<NetAndLaunchBean> getNetAndLaunchApi(
Observable<BaseResponse<List<NetAndLaunchData>>> getNetAndLaunchApi(
@Field("key") String key,
@Field("sn") String sn
);

View File

@@ -4,6 +4,7 @@ import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.bean.Batch;
import com.aoleyun.sn.bean.DeveloperBean;
import com.aoleyun.sn.bean.EBagCode;
import com.aoleyun.sn.bean.PushTag;
import com.aoleyun.sn.bean.ScreenLockState;
import com.aoleyun.sn.bean.StudentsInfo;
import com.aoleyun.sn.network.UrlAddress;
@@ -23,10 +24,16 @@ public interface DevicesStatusApi {
);
@GET(UrlAddress.GET_DEVICES_TAGS)
Observable<BaseResponse<Batch>> getPushTags(
Observable<BaseResponse<Batch>> getSnTag(
@Query("sn") String sn
);
@GET(UrlAddress.GET_PUSH_TAG)
Observable<BaseResponse<PushTag>> getPushTag(
@Query("sn") String sn,
@Query("tag_type") int tag_type
);
@FormUrlEncoded
@POST(UrlAddress.GET_STUDENTS_INFO)
Observable<BaseResponse<StudentsInfo>> getStudentsInfo(

View File

@@ -48,6 +48,7 @@ public interface SystemSettingApi {
);
@GET(UrlAddress.GET_SN_TIME_CONTROL)
@Deprecated
Observable<BaseResponse<SnTimeControl>> getSnTimeControl(
@Query("sn") String sn
);

View File

@@ -41,6 +41,7 @@ import com.aoleyun.sn.gson.NullStringToEmptyAdapterFactory;
import com.aoleyun.sn.manager.MapManager;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.network.RetryCallback;
import com.aoleyun.sn.network.UrlAddress;
import com.aoleyun.sn.service.main.MainService;
import com.aoleyun.sn.utils.ApkUtils;
import com.aoleyun.sn.utils.BatteryUtils;
@@ -202,6 +203,8 @@ public class PushManager {
private static final String UPDATE_BATCH = "37";
/*添加wifi*/
private static final String UPDATE_WIFI_PW = "38";
/*应用密码锁*/
private static final String APP_LOCK_PASSWD = "39";
/*远程关机*/
private static final String DEVICES_SHUTDOWN_NOW = "40";
/*远程定时关机*/
@@ -267,6 +270,12 @@ public class PushManager {
private static final String GROUP_APP_UNINSTALL = "81";
/*电子围栏*/
private static final String ELECTRONIC_FENCE = "82";
/*发出声音*/
private static final String PLAY_SOUND2 = "89";
/*更新公共应用设置,不安装*/
private static final String PUBLIC_APP_SETTING = "91";
/*公共应用卸载*/
private static final String PUBLIC_APP_UNINSTALL = "92";
public void setPushContent(String title, String extras) {
@@ -310,21 +319,30 @@ public class PushManager {
mMMKV.clearAll();
JgyUtils.getInstance().cleanAoleAppCache();
JgyUtils.getInstance().wakeUpAoleyunAPP();
NetInterfaceManager.getInstance().setPushTags();
NetInterfaceManager.getInstance().getPushAndPubAppTag();
NetInterfaceManager.clearAllCache();
sendRefreshBroadcast(mContext);
break;
case MSG_INSTALL:
Toaster.debugShow("收到管控:应用安装");
doDownloadAndInstall(extras);
NetInterfaceManager.removeCache(UrlAddress.GET_FORCE_INSTALL_LIST);
NetInterfaceManager.removeCache(UrlAddress.GROUP_APP_INSTALL_LIST);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
NetInterfaceManager.getInstance().getAppLimit();
NetInterfaceManager.getInstance().getDesktopIcon();
NetInterfaceManager.getInstance().getDefaultDesktop();
NetInterfaceManager.getInstance().getNetAndLaunchSetting();
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
}
}, 1234);
}, 2345);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
doDownloadAndInstall(extras);
}
}, 4321);
mContext.sendBroadcast(new Intent(AOLEYUN_REFRESH_DESKTOP));
break;
case MSG_LOCK:
@@ -349,7 +367,25 @@ public class PushManager {
case GET_FORCEDOWNLOADURL:
case GROUP_APP_INSTALL:
Toaster.debugShow("收到管控:应用强制安装");
downloadForceInstallApk(extras);
NetInterfaceManager.removeCache(UrlAddress.GET_FORCE_INSTALL_LIST);
NetInterfaceManager.removeCache(UrlAddress.GROUP_APP_INSTALL_LIST);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
NetInterfaceManager.getInstance().getAppLimit();
NetInterfaceManager.getInstance().getDesktopIcon();
NetInterfaceManager.getInstance().getDefaultDesktop();
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
}
}, 2345);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
downloadForceInstallApk(extras);
}
}, 4321);
mContext.sendBroadcast(new Intent(AOLEYUN_REFRESH_DESKTOP));
break;
case SET_HOMEPAG_TAG:
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@@ -522,6 +558,7 @@ public class PushManager {
setDefalutApp(extras);
break;
case PLAY_SOUND:
case PLAY_SOUND2:
Toaster.debugShow("收到管控:查找设备");
playSound(extras);
break;
@@ -551,7 +588,7 @@ public class PushManager {
break;
case UPDATE_CHILD_BATCH:
Toaster.debugShow("收到管控:更换批次不恢复出厂设置");
NetInterfaceManager.getInstance().setPushTags();
NetInterfaceManager.getInstance().getPushAndPubAppTag();
Aria.download(this).removeAllTask(true);
JgyUtils.getInstance().cleanAoleAppCache();
try {
@@ -565,6 +602,9 @@ public class PushManager {
case UPDATE_WIFI_PW:
NetInterfaceManager.getInstance().getWiFiPasswd();
break;
case APP_LOCK_PASSWD:
mContext.sendBroadcast(new Intent(AOLEYUN_REFRESH_DESKTOP));
break;
case DEVICES_SHUTDOWN_NOW:
JgyUtils.getInstance().shutdown();
break;
@@ -682,6 +722,12 @@ public class PushManager {
}
case ELECTRONIC_FENCE:
break;
case PUBLIC_APP_SETTING:
updatePublicAppSettings(extras);
break;
case PUBLIC_APP_UNINSTALL:
uninstallPublicApp(extras);
break;
default:
}
@@ -734,7 +780,7 @@ public class PushManager {
public void run() {
NetInterfaceManager.getInstance().getDesktopIcon();
NetInterfaceManager.getInstance().getDefaultDesktop();
NetInterfaceManager.getInstance().getNetAndLaunchSetting();
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
}
}, 1234);
}
@@ -1108,7 +1154,7 @@ public class PushManager {
}
private void getTimeControl(String extras) {
NetInterfaceManager.getInstance().getSnTimeControl();
// NetInterfaceManager.getInstance().getSnTimeControl();
NetInterfaceManager.getInstance().getTimeControl();
}
@@ -1553,4 +1599,30 @@ public class PushManager {
ApkUtils.openPackage(mContext, app_package);
}
public void updatePublicAppSettings(String extras) {
Toaster.debugShow("收到管控:应用公共设置");
if (TextUtils.isEmpty(extras)) {
Log.e(TAG, "updatePublicAppSettings: extras is null");
return;
}
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
NetInterfaceManager.getInstance().getAppLimit();
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
}
}, 2345);
ApkInfoPush apkInfoPush = GsonUtils.toJavaObject(extras, ApkInfoPush.class);
}
public void uninstallPublicApp(String extras) {
Toaster.debugShow("收到管控:应用公共删除");
if (!TextUtils.isEmpty(extras)) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String pkg = jsonObject.get("package_name").getAsString();
deleteApp(pkg);
}
}
}

View File

@@ -103,7 +103,7 @@ public class NewAppReceiver extends BroadcastReceiver {
private static void sendAppInfo() {
Observable.create((ObservableEmitter<String> emitter) -> {
newAppListener = emitter::onNext;
}).throttleLast(5, TimeUnit.MINUTES)
}).throttleLast(1, TimeUnit.MINUTES)
//这句很关键这是RxJava中的操作符在规定时间内观察者不在接收被观察者发送的事件
.subscribe(new Observer<String>() {
@Override
@@ -118,7 +118,7 @@ public class NewAppReceiver extends BroadcastReceiver {
NetInterfaceManager.getInstance().getForceDownload();
NetInterfaceManager.getInstance().getAppLimit();
// NetInterfaceManager.getInstance().getDefaultDesktop();
NetInterfaceManager.getInstance().getNetAndLaunchSetting();
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
NetInterfaceManager.getInstance().getDesktopIcon();
NetInterfaceManager.getInstance().sendInstalledAppInfo(new NetInterfaceManager.onCompleteCallback() {
@Override

View File

@@ -96,6 +96,7 @@ public class MainService extends BaseService implements NetworkUtils.OnNetworkSt
public void onDisconnected() {
Log.e("OnNetworkStatusChanged", "onDisconnected: ");
Toaster.debugShow("网络断开连接");
NetInterfaceManager.clearAllCache();
}
@Override
@@ -475,6 +476,11 @@ public class MainService extends BaseService implements NetworkUtils.OnNetworkSt
.subscribe(networkObserver);
JgyUtils.getInstance().checkAoleyunApp();
String allowAppList = Settings.System.getString(getContentResolver(), CommonConfig.SEEWO_APP_SOURCE_INSTALL_WHITELIST);
if (TextUtils.isEmpty(allowAppList)) {
Settings.System.putString(getContentResolver(), CommonConfig.SEEWO_APP_SOURCE_INSTALL_WHITELIST, String.join(",", JgyUtils.DEFAULT_APP_SOURCE_WHITE_LIST));
}
}
private void initLiveData() {
@@ -515,6 +521,7 @@ public class MainService extends BaseService implements NetworkUtils.OnNetworkSt
mServiceModel.getAllAppList();
mServiceModel.getBrowserBookmarks();
mServiceModel.getDesktopIcon();
mServiceModel.getAllInfoAndSetting();
mServiceModel.getAppAutoStartUpdateAndNet();
mServiceModel.setAppinsideWeb();
mServiceModel.getAppIdControl();

View File

@@ -3,7 +3,6 @@ package com.aoleyun.sn.service.main;
import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -32,7 +31,6 @@ import com.trello.rxlifecycle4.android.ActivityEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -94,22 +92,22 @@ public class MainServiceModel extends ViewModel {
public MutableLiveData<String> mTagData = new MutableLiveData<>();
public void setPushTags() {
NetInterfaceManager.getInstance().setPushTags(getLifecycle(), new NetInterfaceManager.PushTagCallback() {
NetInterfaceManager.getInstance().getPushAndPubAppTag(getLifecycle(), new NetInterfaceManager.PushTagCallback() {
@Override
public void setPushTag(String tag) {
mTagData.postValue(tag);
}
});
String tagSets = mMMKV.decodeString(CommonConfig.DEVICES_TAG);
Log.e(TAG, "setPushTags: tagSets =" + tagSets);
Set<String> groupTagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_GROUP_TAG, new HashSet<>());
Log.e(TAG, "setPushTags: groupTagSets = " + groupTagSets);
Set<String> tags = new HashSet<>();
tags.addAll(groupTagSets);
if (!TextUtils.isEmpty(tagSets)) {
tags.add(tagSets);
}
NetInterfaceManager.getInstance().clearAndAppendTags(tags);
// String tagSets = mMMKV.decodeString(CommonConfig.DEVICES_TAG);
// Log.e(TAG, "setPushTags: tagSets =" + tagSets);
// Set<String> groupTagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_GROUP_TAG, new HashSet<>());
// Log.e(TAG, "setPushTags: groupTagSets = " + groupTagSets);
// Set<String> tags = new HashSet<>();
// tags.addAll(groupTagSets);
// if (!TextUtils.isEmpty(tagSets)) {
// tags.add(tagSets);
// }
// NetInterfaceManager.getInstance().clearAndAppendTags(tags);
}
private void setpushTag(Set<String> tagSets) {
@@ -301,23 +299,21 @@ public class MainServiceModel extends ViewModel {
}
public void getAppLimit() {
NetInterfaceManager.getInstance()
.getAppLimit(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
NetInterfaceManager.getInstance().getAppLimit(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
}
});
}
});
}
public void getForceDownload() {
NetInterfaceManager.getInstance()
.getForceDownload(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
NetInterfaceManager.getInstance().getForceDownload(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
}
});
}
});
}
public void getDefaultDesktop() {
@@ -394,6 +390,10 @@ public class MainServiceModel extends ViewModel {
});
}
public void getAllInfoAndSetting() {
NetInterfaceManager.getInstance().getAllInfoAndSetting(getLifecycle());
}
public void getAppAutoStartUpdateAndNet() {
NetInterfaceManager.getInstance()
.getAppAutoStartUpdateAndNet(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@@ -475,13 +475,13 @@ public class MainServiceModel extends ViewModel {
}
public void getSnTimeControl() {
NetInterfaceManager.getInstance()
.getSnTimeControl(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
}
});
// NetInterfaceManager.getInstance()
// .getSnTimeControl(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
// @Override
// public void onComplete() {
//
// }
// });
NetInterfaceManager.getInstance()
.getTimeControl(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override

View File

@@ -52,10 +52,10 @@ import com.aoleyun.sn.bean.Appground;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.bean.ForceDownloadData;
import com.aoleyun.sn.bean.LessonJson;
import com.aoleyun.sn.bean.NetAndLaunchBean;
import com.aoleyun.sn.bean.NetAndLaunchData;
import com.aoleyun.sn.bean.TTAppground;
import com.aoleyun.sn.bean.TimeControlApp;
import com.aoleyun.sn.bean.TimeControlData;
import com.aoleyun.sn.bean.TimeControlInfo;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
@@ -64,7 +64,6 @@ import com.aoleyun.sn.disklrucache.CacheHelper;
import com.aoleyun.sn.gson.GsonUtils;
import com.aoleyun.sn.manager.AllwinnerCubeMdmManager;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.network.UrlAddress;
import com.aoleyun.sn.receiver.BootReceiver;
import com.aoleyun.sn.service.GuardService;
import com.aoleyun.sn.service.StepService;
@@ -148,6 +147,9 @@ public class JgyUtils {
private LessonJson mLessonJson;
private TimeUtils.ContralTime mContralTime;
//1不能使用,0可用
private int mUseCtrl = 1;
private List<TimeControlInfo> mAppPeriods;
public static final int UnknowPlatform = 0;
@@ -581,62 +583,50 @@ public class JgyUtils {
/**
* 应用自启升级和网络权限管理
*
* @param netAndLaunchBean
* @param dataList
*/
public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean, List<AppListInfo> appListInfos) {
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Log.e(TAG, "setNetAndlaunch: ");
HashSet<String> autoLaunchApp = new HashSet<>();//开机自启app
HashSet<String> allowNetApp = new HashSet<>();//允许联网
HashSet<String> disallowNetApp = new HashSet<>();//禁止联网
HashSet<String> allowUpgrade = new HashSet<>();//允许升级
HashSet<String> disallowUpgrade = new HashSet<>();//禁止升级
HashSet<String> allowSlide = new HashSet<>();//允许滑动
HashSet<String> disallowSlide = new HashSet<>();//禁止滑动
public void setNetAndlaunch(List<NetAndLaunchData> dataList, List<AppListInfo> appListInfos) {
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + dataList.toString());
List<NetAndLaunchData> data = netAndLaunchBean.getData();
for (NetAndLaunchData netAndLaunchData : data) {
String app_package = netAndLaunchData.getApp_package();
int is_auto = netAndLaunchData.getIs_auto();
int is_network = netAndLaunchData.getIs_network();
int is_upgrade = netAndLaunchData.getIs_upgrade();
int is_slide = netAndLaunchData.getIs_slide();
if (is_auto == 1) {
autoLaunchApp.add(app_package);
}
if (is_network == 1) {
allowNetApp.add(app_package);
} else {
disallowNetApp.add(app_package);
}
if (is_upgrade == 1) {
allowUpgrade.add(app_package);
} else {
disallowUpgrade.add(app_package);
}
if (is_slide == 1) {
allowSlide.add(app_package);
} else {
disallowSlide.add(app_package);
}
}
//开机自启app
HashSet<String> autoLaunchApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_auto() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许联网
HashSet<String> allowNetApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_network() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止联网
HashSet<String> disallowNetApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_network() == 0).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许升级
HashSet<String> allowUpgrade = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_upgrade() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止升级
HashSet<String> disallowUpgrade = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_upgrade() == 0).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许滑动
HashSet<String> allowSlide = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_slide() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止滑动
HashSet<String> disallowSlide = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_slide() == 0).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止通知栏显示通知
List<String> disallowNotification = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_notification() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toList());
//默认给所有权限
HashSet<String> allowPermissions = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_dynamic_perm() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许应用安装其他应用
HashSet<String> allowInstallApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getAllow_install_app() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, slide_not);
Log.e("fht", "aole_disable_slide=" + writeSucceed + ":" + slide_not);
Log.e("setNetAndlaunch", "aole_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, "Invalid");
Log.e("fht", "aole_disable_slide ok=" + writeSucceed + ":" + slide_ok);
Log.e("setNetAndlaunch", "aole_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
String[] upgrade_ok = new String[allowUpgrade.size()];
allowUpgrade.toArray(upgrade_ok);
checkPackageAndVersion(disallowUpgrade, appListInfos);
String[] upgrade_not = new String[disallowUpgrade.size()];
disallowUpgrade.toArray(upgrade_not);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
String aole_app_power_on = String.join(",", autoLaunchApp);
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on);
if (TextUtils.isEmpty(aole_app_power_on)) {
@@ -653,6 +643,94 @@ public class JgyUtils {
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(disallowNetApp, allowNetApp);
setAppSourceInstallWhiteList(allowInstallApp);
}
public void setNetAndlaunch(List<NetAndLaunchData> dataList) {
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + dataList.toString());
//开机自启app
HashSet<String> autoLaunchApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_auto() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许联网
HashSet<String> allowNetApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_network() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止联网
HashSet<String> disallowNetApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_network() == 0).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许升级
HashSet<String> allowUpgrade = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_upgrade() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止升级
HashSet<String> disallowUpgrade = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_upgrade() == 0).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许滑动
HashSet<String> allowSlide = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_slide() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止滑动
HashSet<String> disallowSlide = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_slide() == 0).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//禁止通知栏显示通知
HashSet<String> disallowNotification = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_notification() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//默认给所有权限
HashSet<String> allowPermissions = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getIs_dynamic_perm() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
//允许应用安装其他应用
HashSet<String> allowInstallApp = dataList.stream().filter(netAndLaunchData -> netAndLaunchData.getAllow_install_app() == 1).map(NetAndLaunchData::getApp_package).collect(Collectors.toCollection(HashSet::new));
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, slide_not);
Log.e("setNetAndlaunch", "aole_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, "Invalid");
Log.e("setNetAndlaunch", "aole_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
String[] upgrade_ok = new String[allowUpgrade.size()];
allowUpgrade.toArray(upgrade_ok);
String[] upgrade_not = new String[disallowUpgrade.size()];
disallowUpgrade.toArray(upgrade_not);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
String aole_app_power_on = String.join(",", autoLaunchApp);
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on);
if (TextUtils.isEmpty(aole_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, "Invalid");
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + "Invalid");
} else {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, aole_app_power_on);
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(crv, "aole_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(disallowNetApp, allowNetApp);
setDisallowNotificationPackage(mContext, disallowNotification);
mMMKV.encode("aole_app_privilege", allowPermissions);
setAllowPermissionsPackage();
setAppSourceInstallWhiteList(allowInstallApp);
}
public static final List<String> DEFAULT_APP_SOURCE_WHITE_LIST = new ArrayList<String>() {{
this.add("com.aoleyun.sn");
this.add("com.aoleyun.appstore");
this.add("com.aoleyun.browser");
this.add("com.aoleyun.info");
this.add("com.aoleyun.os");
this.add("com.aoleyun.audos");
this.add("com.books.wisdom");
this.add("com.japanese_books.wisdom");
}};
public void setAppSourceInstallWhiteList(HashSet<String> allowInstallApp) {
if (allowInstallApp == null || allowInstallApp.isEmpty()) {
Log.e(TAG, "setAppSourceInstallWhiteList: allowInstallApp size = 0");
Settings.System.putString(crv, CommonConfig.SEEWO_APP_SOURCE_INSTALL_WHITELIST, String.join(",", DEFAULT_APP_SOURCE_WHITE_LIST));
} else {
allowInstallApp.addAll(DEFAULT_APP_SOURCE_WHITE_LIST);
List<String> allowList = new ArrayList<>(allowInstallApp);
Settings.System.putString(crv, CommonConfig.SEEWO_APP_SOURCE_INSTALL_WHITELIST, String.join(",", allowList));
}
Log.e(TAG, "setAppSourceInstallWhiteList: getString = " + Settings.System.getString(crv, CommonConfig.SEEWO_APP_SOURCE_INSTALL_WHITELIST));
}
public void onBootOpenApp() {
@@ -716,93 +794,6 @@ public class JgyUtils {
}
}
public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean) {
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Log.e(TAG, "setNetAndlaunch: ");
HashSet<String> autoLaunchApp = new HashSet<>();//开机自启app
HashSet<String> allowNetApp = new HashSet<>();//允许联网
HashSet<String> disallowNetApp = new HashSet<>();//禁止联网
HashSet<String> allowUpgrade = new HashSet<>();//允许升级
HashSet<String> disallowUpgrade = new HashSet<>();//禁止升级
HashSet<String> allowSlide = new HashSet<>();//允许滑动
HashSet<String> disallowSlide = new HashSet<>();//禁止滑动
HashSet<String> disallowNotification = new HashSet<>();//禁止通知栏显示通知
HashSet<String> allowPermissions = new HashSet<>();//默认给所有权限
List<NetAndLaunchData> data = netAndLaunchBean.getData();
for (NetAndLaunchData netAndLaunchData : data) {
String app_package = netAndLaunchData.getApp_package();
int is_auto = netAndLaunchData.getIs_auto();
int is_network = netAndLaunchData.getIs_network();
int is_upgrade = netAndLaunchData.getIs_upgrade();
int is_slide = netAndLaunchData.getIs_slide();
int is_notification = netAndLaunchData.getIs_notification();
int is_dynamic_perm = netAndLaunchData.getIs_dynamic_perm();
if (is_auto == 1) {
autoLaunchApp.add(app_package);
}
if (is_network == 1) {
allowNetApp.add(app_package);
} else {
disallowNetApp.add(app_package);
}
if (is_upgrade == 1) {
allowUpgrade.add(app_package);
} else {
disallowUpgrade.add(app_package);
}
if (is_slide == 1) {
allowSlide.add(app_package);
} else {
disallowSlide.add(app_package);
}
if (is_notification == 0) {
disallowNotification.add(app_package);
}
if (is_dynamic_perm == 1) {
allowPermissions.add(app_package);
}
}
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, slide_not);
Log.e("fht", "aole_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, "Invalid");
Log.e("fht", "aole_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
String[] upgrade_ok = new String[allowUpgrade.size()];
allowUpgrade.toArray(upgrade_ok);
String[] upgrade_not = new String[disallowUpgrade.size()];
disallowUpgrade.toArray(upgrade_not);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
String aole_app_power_on = String.join(",", autoLaunchApp);
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on);
if (TextUtils.isEmpty(aole_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, "Invalid");
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + "Invalid");
} else {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, aole_app_power_on);
Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(crv, "aole_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(disallowNetApp, allowNetApp);
setDisallowNotificationPackage(mContext, disallowNotification);
mMMKV.encode("aole_app_privilege", allowPermissions);
setAllowPermissionsPackage();
}
private void setDisallowNotificationPackage(Context context, HashSet<String> pkgSet) {
Log.e(TAG, "setDisallowNotificationPackage: " + pkgSet);
if (pkgSet.size() == 0) {
@@ -862,8 +853,8 @@ public class JgyUtils {
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控 blackList =" + blackList);
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控 whiteList =" + whiteList);
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL)) {
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL) || "G128A".equals(Build.MODEL)) {
Log.e(TAG, "setAppNetwork: Ebox201 skip delete");
} else {
try {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, null);
@@ -904,7 +895,8 @@ public class JgyUtils {
pkgs.addAll(DEFAULT_ALLOW_NETWORK_APP_SET);
List<String> filterList = pkgs.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toList());
Log.e(TAG, "setAppNetwork: filterList = " + filterList);
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL)) {
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL) || "G128A".equals(Build.MODEL)) {
if (filterList.size() == 0) {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, null);
} else {
@@ -923,11 +915,11 @@ public class JgyUtils {
*/
public void updateNetworkWhiteList() {
Log.e(TAG, "updateNetworkWhiteList: ");
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL)) {
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL) || "G128A".equals(Build.MODEL)) {
} else {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, null);
try {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, null);
CmdUtil.Result result = CmdUtil.execute(" settings delete system aole_network_allow");
Log.e(TAG, "updateNetworkWhiteList: " + result);
} catch (Exception e) {
@@ -935,11 +927,11 @@ public class JgyUtils {
}
}
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL)) {
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL) || "G128A".equals(Build.MODEL)) {
} else {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_WEB_BLACK_LIST, null);
try {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_WEB_BLACK_LIST, null);
CmdUtil.Result result = CmdUtil.execute(" settings delete system app_web_black_list");
Log.e(TAG, "updateNetworkWhiteList: " + result);
} catch (Exception e) {
@@ -947,13 +939,13 @@ public class JgyUtils {
}
}
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL)) {
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL) || "G128A".equals(Build.MODEL)) {
} else {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_WEB_WHITE_LIST, null);
try {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_WEB_WHITE_LIST, null);
CmdUtil.Result result = CmdUtil.execute(" settings delete system app_web_white_list");
Log.e(TAG, "getWhiteList: " + result);
Log.e(TAG, "updateNetworkWhiteList: " + result);
} catch (Exception e) {
e.printStackTrace();
}
@@ -973,7 +965,7 @@ public class JgyUtils {
List<String> filterList = whiteList.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toList());
Log.e(TAG, "updateNetworkWhiteList: filterList = " + filterList);
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL)) {
if ("Ebox201W".equals(Build.MODEL) || "Ebox201".equals(Build.MODEL) || "G128A".equals(Build.MODEL)) {
if (filterList.size() == 0) {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, null);
} else {
@@ -1014,7 +1006,7 @@ public class JgyUtils {
}
public void writeDeselectIDtoSystem(List<AppID> appIDList) {
if (!"Ebox201".equals(Build.MODEL) && !"Ebox201W".equals(Build.MODEL)) {
if (!"Ebox201".equals(Build.MODEL) && !"Ebox201W".equals(Build.MODEL) && !"G128A".equals(Build.MODEL)) {
Log.e(TAG, "writeDeselectIDtoSystem: not match Ebox201 or Ebox201W");
return;
}
@@ -1547,6 +1539,7 @@ public class JgyUtils {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
}
@Deprecated
public void checkForceDownload() {
// String jsonString = cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL_LIST);
// //为 "" 是已经请求成功的
@@ -2986,25 +2979,6 @@ public class JgyUtils {
}
}
@Deprecated
public List<String> getHidePackage() {
String jsonString = cacheHelper.getAsString(UrlAddress.GET_HIDE_DESKTOPICON);
//为 "" 是已经请求成功的
if (jsonString == null) {
return new ArrayList<>();
} else {
Gson gson = new Gson();
Type type = new TypeToken<List<String>>() {
}.getType();
List<String> list = gson.fromJson(jsonString, type);
if (list == null) {
return new ArrayList<>();
} else {
return list;
}
}
}
public List<String> getDisablePackage() {
List<String> list = new ArrayList<>();
if (Settings.System.getInt(crv, "qch_app_camera", 0) == 1) {
@@ -3943,14 +3917,17 @@ public class JgyUtils {
return;
}
Gson gson = new Gson();
Type type = new TypeToken<List<TimeControlInfo>>() {
Type type = new TypeToken<TimeControlData>() {
}.getType();
try {
mAppPeriods = gson.fromJson(jsonString, type);
TimeControlData timeControlData = gson.fromJson(jsonString, type);
mAppPeriods = timeControlData.getPeriods();
mUseCtrl = timeControlData.getUse_ctrl();
Log.e(TAG, "checkTimePeriod: periods = " + mAppPeriods);
checkTimePeriod();
} catch (Exception e) {
Log.e(TAG, "checkTimePeriod: Exception = " + e.getMessage());
mMMKV.remove(CommonConfig.TIME_CONTROL_DATA_KEY);
}
}
@@ -3988,7 +3965,12 @@ public class JgyUtils {
if (packageNames.contains(foregroundPackage)) {
Log.e(TAG, "checkTimePeriod: " + foregroundPackage + " skip");
} else {
gotoLauncher();
Log.e(TAG, "checkTimePeriod: " + mUseCtrl);
if (mUseCtrl != 0) {
gotoLauncher();
} else {
Log.d(TAG, "checkTimePeriod: allowed app start");
}
}
}
@@ -4029,7 +4011,8 @@ public class JgyUtils {
if (packageNames.contains(pkgName)) {
return true;
} else {
return false;
Log.e(TAG, "checkTimePeriod: " + mUseCtrl);
return mUseCtrl == 0;
}
}

View File

@@ -3,13 +3,16 @@ package com.aoleyun.sn.utils;
import android.annotation.SuppressLint;
import android.app.StatusBarManager;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.activity.EyeProtectionActivity;
import com.aoleyun.sn.activity.main.MainActivity;
import com.aoleyun.sn.bean.BluetoothType;
import com.aoleyun.sn.bean.SnSetting;
@@ -73,7 +76,7 @@ public class SysSettingUtils {
setPanelShow(context, jsonObject);
setDisAllowCamera(context, jsonObject);
setSettingsMenuShow(context, jsonObject);
setEyeProtectionModeEntrance(context, jsonObject);
}
/**
@@ -109,7 +112,7 @@ public class SysSettingUtils {
setSystemAppDisable(context, 0);
setNotification(context, 0);
setSettingsMenuShow(context);
setEyeProtectionModeEntrance(context, 0);
}
/**
@@ -138,6 +141,7 @@ public class SysSettingUtils {
setAdminApp(context, 0);
setSystemAppDisable(context, 0);
setNotification(context, 1);
setEyeProtectionModeEntrance(context, 1);
}
public static void openMtp(Context context) {
@@ -1365,4 +1369,43 @@ public class SysSettingUtils {
private static void setSettingsMenuShow(Context context) {
Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_SETTINGS_DISALLOW, "");
}
private static void setEyeProtectionModeEntrance(Context context, JsonObject jsonObject) {
Log.e(TAG, "setEyeProtectionModeEntrance: " + jsonObject);
if (jsonObject.has("eye_protection_mode_entrance")) {
int app_management_general = jsonObject.get("eye_protection_mode_entrance").getAsInt();
if (app_management_general == 0) {
// 禁用 Launcher 入口
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
} else {
// 启用 Launcher 入口
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
} else {
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
}
}
private static void setEyeProtectionModeEntrance(Context context, int status) {
Log.e(TAG, "setEyeProtectionModeEntrance: status = " + status);
if (status == 0) {
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
} else {
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
}
private static boolean setComponentEnabledSetting(Context context, int componentState) {
Log.e(TAG, "setComponentEnabledSetting: componentState = " + componentState);
PackageManager pm = context.getPackageManager();
ComponentName componentName = new ComponentName(context, EyeProtectionActivity.class);
try {
pm.setComponentEnabledSetting(componentName, componentState, PackageManager.DONT_KILL_APP);
return true;
} catch (Exception e) {
Log.e(TAG, "setComponentEnabledSetting: " + e.getMessage());
}
return false;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -6,6 +6,7 @@ buildscript {
// mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://developer.huawei.com/repo/' }
maven { url 'https://developer.hihonor.com/repo' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/public' }
@@ -31,6 +32,7 @@ allprojects {
// mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://developer.huawei.com/repo/' }
maven { url 'https://developer.hihonor.com/repo' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/public' }