version:3.3

fix:
update:对接最新接口,分管理员配置和用户配置
This commit is contained in:
2022-07-20 15:07:59 +08:00
parent d8422bb824
commit 4521e729a2
12 changed files with 294 additions and 139 deletions

View File

@@ -67,8 +67,8 @@ android {
productFlavors {
beta {
flavorDimensions "default"
versionCode 22
versionName "3.1"
versionCode 24
versionName "3.3"
}
official {

View File

@@ -0,0 +1,27 @@
package com.uiui.sn.bean;
import java.io.Serializable;
public class SystemSettingsSet implements Serializable {
private static final long serialVersionUID = 2102990332552652787L;
SystemSettings user;
SystemSettings admin;
public SystemSettings getUser() {
return user;
}
public void setUser(SystemSettings user) {
this.user = user;
}
public SystemSettings getAdmin() {
return admin;
}
public void setAdmin(SystemSettings admin) {
this.admin = admin;
}
}

View File

@@ -89,6 +89,11 @@ public class ControlManager {
}
}
public void setSystemSetting(SystemSettings userSystemSettings, SystemSettings adminSystemSettings) {
}
public void setSystemSetting(SystemSettings systemSettings) {
if (systemSettings == null) {
Log.e(TAG, "setSystemSetting: SystemSettings is NULL");
@@ -119,8 +124,8 @@ public class ControlManager {
Log.e("setDisableSetting", "Close all settings: ");
setUSBstate(1);
setPhoneList(1);
setBluetooth(1);
setHotspot(1);
setBluetooth(0);
setHotspot(0);
setCamera(1);
setTF(1);
setIcon(1);

View File

@@ -35,6 +35,7 @@ import com.uiui.sn.bean.CloudLessonSetting;
import com.uiui.sn.bean.Label;
import com.uiui.sn.bean.SnInfo;
import com.uiui.sn.bean.SystemSettings;
import com.uiui.sn.bean.SystemSettingsSet;
import com.uiui.sn.bean.UserAvatarInfo;
import com.uiui.sn.bean.browser.BrowserApiData;
import com.uiui.sn.bean.browser.BrowserBean;
@@ -146,6 +147,9 @@ public class NetInterfaceManager {
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
private NetInterfaceManager(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.crv = mContext.getContentResolver();
this.cacheHelper = new CacheHelper(mContext);
@@ -277,7 +281,7 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<SystemSettings>> getsettingControl() {
public Observable<BaseResponse<SystemSettingsSet>> getsettingControl() {
return mRetrofit.create(Setting.class)
.getSetting(Utils.getSerial())
.subscribeOn(Schedulers.io())
@@ -700,13 +704,13 @@ public class NetInterfaceManager {
this.add("com.uiui.health");
this.add("com.uiui.city");
//扶小鹰
this.add("com.fuying.fuxiaoying");
this.add("com.zhiduoke.fxy");
this.add("com.fuying.english");
this.add("com.pengren.growthspace");
this.add("com.moshujiamm.moshujia");
this.add("com.gankao.gkwxhd");
this.add("com.fuying.aobama.pad");
this.add(JGYUtils.gkwxhd);
this.add(JGYUtils.fuxiaoying);
this.add(JGYUtils.moshujia);
this.add(JGYUtils.english);
this.add(JGYUtils.zhiduoke);
this.add(JGYUtils.aobama);
this.add(JGYUtils.growthspace);
}};
public static long getPackageSize(Context context, String filePath) {
@@ -969,6 +973,93 @@ public class NetInterfaceManager {
});
}
public void checkFXYAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
ConnectMode connectMode = ConnectMode.SIX_HOUR;
if (refresh) {
connectMode = ConnectMode.ONE_HOUR;
}
if (ConnectManager.getInstance().isNeedConnect(JGYUtils.FUXIAOYING_KEY, connectMode)) {
checkFXYAppUpdate(lifecycle, callback);
} else {
String jsonString = cacheHelper.getAsString(JGYUtils.FUXIAOYING_KEY);
//为 "" 是已经请求成功的
if (jsonString == null) {
checkFXYAppUpdate(lifecycle, callback);
} else {
Gson gson = new Gson();
Type type = new TypeToken<List<AppInfo>>() {
}.getType();
List<AppInfo> appInfoList = gson.fromJson(jsonString, type);
getAllAppUpdate(appInfoList);
callback.onComplete();
}
}
}
public void checkFXYAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
Observable.zip(
getUpdateObservable(JGYUtils.gkwxhd),
getUpdateObservable(JGYUtils.fuxiaoying),
getUpdateObservable(JGYUtils.moshujia),
getUpdateObservable(JGYUtils.english),
getUpdateObservable(JGYUtils.zhiduoke),
getUpdateObservable(JGYUtils.aobama),
getUpdateObservable(JGYUtils.growthspace),
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7) -> {
List<AppInfo> appInfoList = new ArrayList<>();
if (appInfoBaseResponse.code == 200) {
appInfoList.add(appInfoBaseResponse.data);
}
if (appInfoBaseResponse2.code == 200) {
appInfoList.add(appInfoBaseResponse2.data);
}
if (appInfoBaseResponse3.code == 200) {
appInfoList.add(appInfoBaseResponse3.data);
}
if (appInfoBaseResponse4.code == 200) {
appInfoList.add(appInfoBaseResponse4.data);
}
if (appInfoBaseResponse5.code == 200) {
appInfoList.add(appInfoBaseResponse5.data);
}
if (appInfoBaseResponse6.code == 200) {
appInfoList.add(appInfoBaseResponse6.data);
}
if (appInfoBaseResponse7.code == 200) {
appInfoList.add(appInfoBaseResponse7.data);
}
return appInfoList;
})
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("checkFXYAppUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull List<AppInfo> appInfos) {
Log.e("checkFXYAppUpdate", "onNext: " + appInfos);
cacheHelper.put(JGYUtils.FUXIAOYING_KEY, GsonUtils.toJSONString(appInfos));
getAllAppUpdate(appInfos);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("checkFXYAppUpdate", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("checkFXYAppUpdate", "onComplete: ");
callback.onComplete();
}
});
}
public void getAllAppUpdate(String jsonString) {
if (TextUtils.isEmpty(jsonString)) {
return;
@@ -1864,17 +1955,17 @@ public class NetInterfaceManager {
public void getSystemSettings() {
getsettingControl()
.subscribe(new Observer<BaseResponse<SystemSettings>>() {
.subscribe(new Observer<BaseResponse<SystemSettingsSet>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getSystemSettings", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<SystemSettings> BaseResponse) {
public void onNext(@NonNull BaseResponse<SystemSettingsSet> BaseResponse) {
int code = BaseResponse.code;
if (code == 200) {
String data = new Gson().toJson(BaseResponse.data);
String data = new Gson().toJson(BaseResponse.data.getAdmin());
Log.e("getSystemSettings", "onNext: " + data);
ControlManager.getInstance().setSystemSetting(data);
} else {
@@ -1896,58 +1987,58 @@ public class NetInterfaceManager {
}
public void getTimeControl() {
getTimeControlObservable()
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e(TAG, "onNext: ");
int code = baseResponse.code;
if (code == 200) {
JsonObject jsonObject = GsonUtils.getJsonObject(baseResponse.data.toString());
JsonObject work = jsonObject.get("work").getAsJsonObject();
String work_start_time = work.get("start_time").getAsString();
String work_end_time = work.get("end_time").getAsString();
JsonObject rest = jsonObject.get("rest").getAsJsonObject();
String rest_start_time = rest.get("start_time").getAsString();
String rest_end_time = rest.get("end_time").getAsString();
TimeUtils.ContralTime workingTime = TimeUtils.String2WorkingTime(mContext, work_start_time + "-" + work_end_time);
TimeUtils.ContralTime weekTime = TimeUtils.String2WeekTime(mContext, rest_start_time + "-" + rest_end_time);
if (null != workingTime) {
Log.e("getTimeControlControl", "200:" + workingTime.toString());
}
if (null != weekTime) {
Log.e("getTimeControlControl", "200:" + weekTime.toString());
}
} else {
TimeUtils.setEmpty(mContext);
TimeUtils.ContralTime workingTime = TimeUtils.getWorkingDayContralTime(mContext);
if (null != workingTime) {
Log.e("getTimeControlControl", workingTime.toString());
}
TimeUtils.ContralTime weekTime = TimeUtils.getWeekDayContralTime(mContext);
if (null != weekTime) {
Log.e("getTimeControlControl", weekTime.toString());
}
}
}
@Override
public void onError(Throwable e) {
Log.e("getTimeControlControl", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Intent intent = new Intent();
intent.setAction(ManagerService.ACTION_UPDATE);
mContext.sendBroadcast(intent);
}
});
// getTimeControlObservable()
// .subscribe(new Observer<BaseResponse>() {
// @Override
// public void onSubscribe(Disposable d) {
//
// }
//
// @Override
// public void onNext(BaseResponse baseResponse) {
// Log.e(TAG, "onNext: ");
// int code = baseResponse.code;
// if (code == 200) {
// JsonObject jsonObject = GsonUtils.getJsonObject(baseResponse.data.toString());
// JsonObject work = jsonObject.get("work").getAsJsonObject();
// String work_start_time = work.get("start_time").getAsString();
// String work_end_time = work.get("end_time").getAsString();
// JsonObject rest = jsonObject.get("rest").getAsJsonObject();
// String rest_start_time = rest.get("start_time").getAsString();
// String rest_end_time = rest.get("end_time").getAsString();
// TimeUtils.ContralTime workingTime = TimeUtils.String2WorkingTime(mContext, work_start_time + "-" + work_end_time);
// TimeUtils.ContralTime weekTime = TimeUtils.String2WeekTime(mContext, rest_start_time + "-" + rest_end_time);
// if (null != workingTime) {
// Log.e("getTimeControlControl", "200:" + workingTime.toString());
// }
// if (null != weekTime) {
// Log.e("getTimeControlControl", "200:" + weekTime.toString());
// }
// } else {
// TimeUtils.setEmpty(mContext);
// TimeUtils.ContralTime workingTime = TimeUtils.getWorkingDayContralTime(mContext);
// if (null != workingTime) {
// Log.e("getTimeControlControl", workingTime.toString());
// }
// TimeUtils.ContralTime weekTime = TimeUtils.getWeekDayContralTime(mContext);
// if (null != weekTime) {
// Log.e("getTimeControlControl", weekTime.toString());
// }
// }
// }
//
// @Override
// public void onError(Throwable e) {
// Log.e("getTimeControlControl", "onError: " + e.getMessage());
// }
//
// @Override
// public void onComplete() {
// Intent intent = new Intent();
// intent.setAction(ManagerService.ACTION_UPDATE);
// mContext.sendBroadcast(intent);
// }
// });
}
public void sendRunningApp() {

View File

@@ -2,6 +2,7 @@ package com.uiui.sn.network.api;
import com.uiui.sn.bean.BaseResponse;
import com.uiui.sn.bean.SystemSettings;
import com.uiui.sn.bean.SystemSettingsSet;
import com.uiui.sn.network.UrlAddress;
import io.reactivex.rxjava3.core.Observable;
@@ -10,7 +11,7 @@ import retrofit2.http.Query;
public interface Setting {
@GET(UrlAddress.GET_SETTINGS)
Observable<BaseResponse<SystemSettings>> getSetting(
Observable<BaseResponse<SystemSettingsSet>> getSetting(
@Query("sn") String sn
);
}

View File

@@ -9,8 +9,7 @@ import retrofit2.http.Query;
public interface TimeControl {
@GET(UrlAddress.GET_TIME_CONTROL)
Observable<BaseResponse>
getTimeControl(
Observable<BaseResponse> getTimeControl(
@Query("sn") String sn
);
}

View File

@@ -40,7 +40,7 @@ public class RepeatRequestInterceptor implements Interceptor {
// Response copy = response.newBuilder().body(responseBody).build();
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
if (BuildConfig.DEBUG) {
// Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
}
//相同的请求
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));

View File

@@ -11,6 +11,7 @@ public class MainSContact {
void setLocked(int lockedStatus);
void updateInfoFinish();
void checkUpdateFinish();
void checkFXYUpdateFinish();
void getAllAppFinish();
void setAppInside();
void setForceInstall();
@@ -31,6 +32,8 @@ public class MainSContact {
void updateDeviceInfo();
//检查更新
void checkUpdate();
//检查扶小鹰App更新
void checkFXYUpdate();
//获取所有app包名
void getAllApp();
//获取id管控

View File

@@ -17,6 +17,7 @@ import com.uiui.sn.bean.AppStart;
import com.uiui.sn.bean.BaseResponse;
import com.uiui.sn.bean.Label;
import com.uiui.sn.bean.SystemSettings;
import com.uiui.sn.bean.SystemSettingsSet;
import com.uiui.sn.bean.browser.BrowserApiData;
import com.uiui.sn.bean.browser.BrowserBean;
import com.uiui.sn.config.CommonConfig;
@@ -126,6 +127,16 @@ public class MainSPresenter implements MainSContact.Presenter {
});
}
@Override
public void checkFXYUpdate() {
NetInterfaceManager.getInstance().checkFXYAppUpdate(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
mView.checkFXYUpdateFinish();
}
});
}
@Override
@SuppressLint("NewApi")
public void getAllApp() {
@@ -235,19 +246,19 @@ public class MainSPresenter implements MainSContact.Presenter {
NetInterfaceManager.getInstance()
.getsettingControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<SystemSettings>>() {
.subscribe(new Observer<BaseResponse<SystemSettingsSet>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getSystemSettings", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse<SystemSettings> systemSettingsBaseResponse) {
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
SPUtils.put(mContext, "is_first_connection", 0);
int code = systemSettingsBaseResponse.code;
if (code == 200) {
String data = new Gson().toJson(systemSettingsBaseResponse.data);
String data = new Gson().toJson(systemSettingsBaseResponse.data.getAdmin());
ControlManager.getInstance().setSystemSetting(data);
} else {
ControlManager.getInstance().setDisableSetting();
@@ -440,62 +451,63 @@ public class MainSPresenter implements MainSContact.Presenter {
@Override
public void getTimeControl() {
NetInterfaceManager.getInstance()
.getTimeControlObservable()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getTimeControlControl", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("getTimeControlControl", "onNext: ");
int code = baseResponse.code;
if (code == 200) {
JsonObject jsonObject = GsonUtils.getJsonObject(GsonUtils.toJSONString(baseResponse.data));
JsonObject work = jsonObject.getAsJsonObject("work");
String work_start_time = work.get("start_time").getAsString();
String work_end_time = work.get("end_time").getAsString();
JsonObject rest = jsonObject.getAsJsonObject("rest");
String rest_start_time = rest.get("start_time").getAsString();
String rest_end_time = rest.get("end_time").getAsString();
TimeUtils.ContralTime workingTime = TimeUtils.String2WorkingTime(mContext, work_start_time + "-" + work_end_time);
TimeUtils.ContralTime weekTime = TimeUtils.String2WeekTime(mContext, rest_start_time + "-" + rest_end_time);
if (null != workingTime) {
Log.e("getTimeControlControl", "200:" + workingTime.toString());
}
if (null != weekTime) {
Log.e("getTimeControlControl", "200:" + weekTime.toString());
}
} else {
TimeUtils.setEmpty(mContext);
TimeUtils.ContralTime workingTime = TimeUtils.getWorkingDayContralTime(mContext);
if (null != workingTime) {
Log.e("getTimeControlControl", workingTime.toString());
}
TimeUtils.ContralTime weekTime = TimeUtils.getWeekDayContralTime(mContext);
if (null != weekTime) {
Log.e("getTimeControlControl", weekTime.toString());
}
}
}
@Override
public void onError(Throwable e) {
Log.e("getTimeControlControl", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("getTimeControlControl", "onComplete: ");
Intent intent = new Intent();
intent.setAction(ManagerService.ACTION_UPDATE);
mContext.sendBroadcast(intent);
mView.setTimeControl();
}
});
// NetInterfaceManager.getInstance()
// .getTimeControlObservable()
// .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
// .subscribe(new Observer<BaseResponse>() {
// @Override
// public void onSubscribe(Disposable d) {
// Log.e("getTimeControlControl", "onSubscribe: ");
// }
//
// @Override
// public void onNext(BaseResponse baseResponse) {
// Log.e("getTimeControlControl", "onNext: ");
// int code = baseResponse.code;
// if (code == 200) {
// JsonObject jsonObject = GsonUtils.getJsonObject(GsonUtils.toJSONString(baseResponse.data));
// JsonObject work = jsonObject.getAsJsonObject("work");
// String work_start_time = work.get("start_time").getAsString();
// String work_end_time = work.get("end_time").getAsString();
// JsonObject rest = jsonObject.getAsJsonObject("rest");
// String rest_start_time = rest.get("start_time").getAsString();
// String rest_end_time = rest.get("end_time").getAsString();
// TimeUtils.ContralTime workingTime = TimeUtils.String2WorkingTime(mContext, work_start_time + "-" + work_end_time);
// TimeUtils.ContralTime weekTime = TimeUtils.String2WeekTime(mContext, rest_start_time + "-" + rest_end_time);
// if (null != workingTime) {
// Log.e("getTimeControlControl", "200:" + workingTime.toString());
// }
// if (null != weekTime) {
// Log.e("getTimeControlControl", "200:" + weekTime.toString());
// }
// } else {
// TimeUtils.setEmpty(mContext);
// TimeUtils.ContralTime workingTime = TimeUtils.getWorkingDayContralTime(mContext);
// if (null != workingTime) {
// Log.e("getTimeControlControl", workingTime.toString());
// }
// TimeUtils.ContralTime weekTime = TimeUtils.getWeekDayContralTime(mContext);
// if (null != weekTime) {
// Log.e("getTimeControlControl", weekTime.toString());
// }
// }
// }
//
// @Override
// public void onError(Throwable e) {
// Log.e("getTimeControlControl", "onError: " + e.getMessage());
// }
//
// @Override
// public void onComplete() {
// Log.e("getTimeControlControl", "onComplete: ");
// Intent intent = new Intent();
// intent.setAction(ManagerService.ACTION_UPDATE);
// mContext.sendBroadcast(intent);
//
// }
// });
mView.setTimeControl();
}
@Override

View File

@@ -422,6 +422,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
@Override
public void checkUpdateFinish() {
mPresenter.checkFXYUpdate();
}
@Override
public void checkFXYUpdateFinish() {
mPresenter.getAllApp();
}

View File

@@ -604,7 +604,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case JIGUANG_SYSTEM_SETTING:
ToastUtil.debugShow("收到推送消息: 系统管控");
ControlManager.getInstance().setSystemSetting(extras);
// ControlManager.getInstance().setSystemSetting(extras);
MainService.getPresenter().getSystemSettings();
// if ("com.jiaoguanyi.os".equals(ForegroundAppUtil.getForegroundPackageName(context))) {
// JGYUtils.getInstance().killBackgroundProcesses(context, "com.jiaoguanyi.os");
// Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.jiaoguanyi.os");

View File

@@ -109,15 +109,26 @@ public class JGYUtils {
}};
HashSet<String> fuxiaoyingApp = new HashSet<String>() {{
this.add("com.fuying.fuxiaoying");
this.add("com.zhiduoke.fxy");
this.add("com.fuying.english");
this.add("com.pengren.growthspace");
this.add("com.moshujiamm.moshujia");
this.add("com.gankao.gkwxhd");
this.add("com.fuying.aobama.pad");
this.add(gkwxhd);
this.add(fuxiaoying);
this.add(moshujia);
this.add(english);
this.add(zhiduoke);
this.add(aobama);
this.add(growthspace);
}};
public static final String gkwxhd = "com.gankao.gkwxhd";
public static final String fuxiaoying = "com.fuying.fuxiaoying";
public static final String moshujia = "com.moshujiamm.moshujia";
public static final String english = "com.fuying.english";
public static final String zhiduoke = "com.zhiduoke.fxy";
public static final String aobama = "com.fuying.aobama.pad";
public static final String growthspace = "com.pengren.growthspace";
public static final String FUXIAOYING_KEY = "fuxiaoying_update_key";
public HashSet<String> getOwnApp() {
return ownApp;
}
@@ -1220,7 +1231,7 @@ public class JGYUtils {
}
public String getIMEI() {
public String getIMEI() {
String IMEI = "unknow";
String IMEI1, IMEI2, IMEI3;
//获取手机设备号