优化白名单
1.3
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.fuying.sn.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AppInfo implements Serializable {
|
||||
private static final long serialVersionUID = 423463220624853188L;
|
||||
@@ -227,6 +229,21 @@ public class AppInfo implements Serializable {
|
||||
this.app_md5 = app_md5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof AppInfo))
|
||||
return false;
|
||||
AppInfo appInfo = (AppInfo) obj;
|
||||
|
||||
return Objects.equals(appInfo.getApp_package(), this.app_package)
|
||||
&& Objects.equals(appInfo.getApp_url(), this.app_url)
|
||||
&& Objects.equals(appInfo.getApp_version_name(), this.app_version_name)
|
||||
&& appInfo.getApp_id() == this.app_id
|
||||
&& appInfo.getApp_size() == this.app_size
|
||||
&& appInfo.getApp_version_code() == this.app_version_code
|
||||
;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -707,6 +707,7 @@ public class RunningAppManager {
|
||||
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
||||
if (appTimeControl.getIs_control() == 0) {
|
||||
ToastUtil.show("应用已被禁用");
|
||||
Log.e(TAG, "inControlTime: " + "应用已被禁用");
|
||||
return true;
|
||||
}
|
||||
if (appTimeControl.getTc_use_type() == 0) {
|
||||
@@ -719,6 +720,8 @@ public class RunningAppManager {
|
||||
if (inControlTime) {
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.time_part.toString());
|
||||
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
||||
Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (appTimeControl.getIs_quota() == 0) {
|
||||
@@ -728,6 +731,8 @@ public class RunningAppManager {
|
||||
if (getAppRemainingTime(pkg) <= 0) {
|
||||
//没有剩余时间
|
||||
ToastUtil.show("该应用今日可使用时间已用完");
|
||||
Log.e(TAG, "inControlTime: " + "该应用今日可使用时间已用完");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -735,12 +740,14 @@ public class RunningAppManager {
|
||||
}
|
||||
} else {
|
||||
if (appTimeControl.getIs_quota() == 0) {
|
||||
// ToastUtil.show("没有使用额度");
|
||||
ToastUtil.show("没有使用额度");
|
||||
Log.e(TAG, "inControlTime: " + "没有使用额度");
|
||||
return false;
|
||||
}
|
||||
if (getAppRemainingTime(pkg) <= 0) {
|
||||
//没有剩余时间
|
||||
ToastUtil.show("该应用今日可使用时间已用完");
|
||||
Log.e(TAG, "inControlTime: " + "该应用今日可使用时间已用完");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -15,35 +15,26 @@ import android.util.Log;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.bean.AppInfo;
|
||||
import com.fuying.sn.bean.AppJump;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
import com.fuying.sn.bean.MyAppUsageBean;
|
||||
import com.fuying.sn.bean.OverallAppBean;
|
||||
import com.fuying.sn.desktop.AppTimeControl;
|
||||
import com.fuying.sn.bean.AppUploadInfo;
|
||||
import com.fuying.sn.bean.AppletQRCode;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.BatchID;
|
||||
import com.fuying.sn.bean.CloudLessonSetting;
|
||||
import com.fuying.sn.bean.Label;
|
||||
import com.fuying.sn.desktop.MachineControl;
|
||||
import com.fuying.sn.bean.MyAppUsageBean;
|
||||
import com.fuying.sn.bean.OverallAppBean;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
import com.fuying.sn.bean.SystemSettingsSet;
|
||||
import com.fuying.sn.bean.UserAvatarInfo;
|
||||
import com.fuying.sn.bean.browser.BrowserApiData;
|
||||
import com.fuying.sn.bean.browser.BrowserBean;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.desktop.AppTimeControl;
|
||||
import com.fuying.sn.desktop.MachineControl;
|
||||
import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.desktop.TimeControlManager;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
@@ -60,6 +51,7 @@ import com.fuying.sn.network.api.Browser;
|
||||
import com.fuying.sn.network.api.BrowserLabel;
|
||||
import com.fuying.sn.network.api.CloudLessonSettingApi;
|
||||
import com.fuying.sn.network.api.ForceInstall;
|
||||
import com.fuying.sn.network.api.GetAdminAppApi;
|
||||
import com.fuying.sn.network.api.GetBatchApi;
|
||||
import com.fuying.sn.network.api.GetControlScreenshotApi;
|
||||
import com.fuying.sn.network.api.GetGuideApi;
|
||||
@@ -91,6 +83,15 @@ import com.fuying.sn.utils.MD5Util;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.URLUtils;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -494,6 +495,14 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> getAdminAppObservable() {
|
||||
return mRetrofit.create(GetAdminAppApi.class)
|
||||
.getAdminApp(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* execution
|
||||
@@ -1246,7 +1255,7 @@ public class NetInterfaceManager {
|
||||
}.getType();
|
||||
AppletQRCode appletQRCode = gson.fromJson(jsonString, type);
|
||||
String url = "";
|
||||
if (appletQRCode == null) {
|
||||
if (appletQRCode != null) {
|
||||
url = appletQRCode.getFile();
|
||||
}
|
||||
callback.onNext(url);
|
||||
@@ -1507,8 +1516,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void setAppState(List<AppStart> list) {
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, "null");
|
||||
// setAppAutoStart( list);
|
||||
setAppNetwork(list);
|
||||
// setAppNetwork(list);
|
||||
setAppUpdate(list);
|
||||
setAppSlide(list);
|
||||
setAppHide(list);
|
||||
@@ -1859,49 +1869,55 @@ public class NetInterfaceManager {
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public void getAllappPackage() {
|
||||
getQueryAllAppControl()
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAllappPackage", "onSubscribe: ");
|
||||
}
|
||||
getAppWhiteList(new WhiteListCallback() {
|
||||
@Override
|
||||
public void onComplet() {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
Log.e("getAllappPackage", "onNext: " + listBaseResponse);
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
if (null != appInfoList && appInfoList.size() != 0) {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfoList));
|
||||
HashSet<String> allAppPkg = new HashSet<>();
|
||||
for (AppInfo appInfo : appInfoList) {
|
||||
allAppPkg.add(appInfo.getApp_package());
|
||||
}
|
||||
String allPkgSet = String.join(",", allAppPkg);
|
||||
Settings.System.putString(crv, CommonConfig.ONLY_SHORTCUT_LIST, allPkgSet);
|
||||
ApkUtils.writeAppPackageList(mContext, allPkgSet);
|
||||
getAppStart(appInfoList);
|
||||
} else {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
ApkUtils.writeAppPackageList(mContext, "");
|
||||
}
|
||||
} else {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
ApkUtils.writeAppPackageList(mContext, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAllappPackage", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAllappPackage", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// getQueryAllAppControl()
|
||||
// .subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e("getAllappPackage", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
// int code = listBaseResponse.code;
|
||||
// if (code == 200) {
|
||||
// Log.e("getAllappPackage", "onNext: " + listBaseResponse);
|
||||
// List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
// if (null != appInfoList && appInfoList.size() != 0) {
|
||||
// mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfoList));
|
||||
// HashSet<String> allAppPkg = new HashSet<>();
|
||||
// for (AppInfo appInfo : appInfoList) {
|
||||
// allAppPkg.add(appInfo.getApp_package());
|
||||
// }
|
||||
// String allPkgSet = String.join(",", allAppPkg);
|
||||
// Settings.System.putString(crv, CommonConfig.ONLY_SHORTCUT_LIST, allPkgSet);
|
||||
// ApkUtils.writeAppPackageList(mContext, allPkgSet);
|
||||
// getAppStart(appInfoList);
|
||||
// } else {
|
||||
// mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
// ApkUtils.writeAppPackageList(mContext, "");
|
||||
// }
|
||||
// } else {
|
||||
// mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
// ApkUtils.writeAppPackageList(mContext, "");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e("getAllappPackage", "onError: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getAllappPackage", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public void getForceInstall(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
@@ -2662,6 +2678,98 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppJump", "onComplete: ");
|
||||
completeCallback.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void getAdminApp() {
|
||||
getAdminAppObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAdminApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> baseResponse) {
|
||||
Log.e("getAdminApp", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAdminApp", "onError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAdminApp", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface WhiteListCallback {
|
||||
void onComplet();
|
||||
}
|
||||
|
||||
public void getAppWhiteList(WhiteListCallback callback) {
|
||||
Observable.zip(getQueryAllAppControl(), getAdminAppObservable(), new BiFunction<BaseResponse<List<AppInfo>>, BaseResponse<List<AppInfo>>, HashSet<AppInfo>>() {
|
||||
@Override
|
||||
public HashSet<AppInfo> apply(BaseResponse<List<AppInfo>> listBaseResponse1, BaseResponse<List<AppInfo>> listBaseResponse2) throws Throwable {
|
||||
HashSet<AppInfo> appInfos = new HashSet<>();
|
||||
int code1 = listBaseResponse1.code;
|
||||
if (code1 == 200) {
|
||||
List<AppInfo> appInfos1 = listBaseResponse1.data;
|
||||
if (appInfos1 != null && appInfos1.size() != 0) {
|
||||
appInfos.addAll(appInfos1);
|
||||
List<String> allPkgSet = appInfos1.stream().map(AppInfo::getApp_package).collect(Collectors.toList());
|
||||
String allPkgString = String.join(",", allPkgSet);
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||
Log.e("getAppWhiteList", "onNext: " + allPkgString);
|
||||
}
|
||||
}
|
||||
int code2 = listBaseResponse2.code;
|
||||
if (code2 == 200) {
|
||||
List<AppInfo> appInfos2 = listBaseResponse2.data;
|
||||
if (appInfos2 != null) {
|
||||
appInfos.addAll(appInfos2);
|
||||
}
|
||||
}
|
||||
return appInfos;
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<HashSet<AppInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAppWhiteList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull HashSet<AppInfo> appInfos) {
|
||||
Log.e("getAppWhiteList", "onNext: " + appInfos);
|
||||
if (appInfos.size() == 0) {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
ApkUtils.writeAppPackageList(mContext, "");
|
||||
} else {
|
||||
HashSet<String> pkgList = new HashSet<>(appInfos.stream().map(AppInfo::getApp_package).collect(Collectors.toSet()));
|
||||
String pkgListString = String.join(",", pkgList);
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfos));
|
||||
ApkUtils.writeAppPackageList(mContext, pkgListString);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAppWhiteList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppWhiteList", "onComplete: ");
|
||||
callback.onComplet();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public class UrlAddress {
|
||||
public final static String SEND_DRIVE_STATE = "Online/online";
|
||||
/*获取所有应用*/
|
||||
public final static String GET_ALL_PACKAGE = "app/queryAllApp";
|
||||
/*获取管理员上传的应用*/
|
||||
public final static String GET_ADMIN_APP = "getAdminApp";
|
||||
/*绑定设备消息*/
|
||||
public final static String BIND_DEVICES = "sn/bindSn";
|
||||
/*获取系统设置*/
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.fuying.sn.network.api;
|
||||
|
||||
import com.fuying.sn.bean.AppInfo;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetAdminAppApi {
|
||||
@GET(UrlAddress.GET_ADMIN_APP)
|
||||
Observable<BaseResponse<List<AppInfo>>> getAdminApp(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.fuying.sn.bean.AppInfo;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.Label;
|
||||
@@ -26,9 +25,7 @@ import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.utils.ApkUtils;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
@@ -36,7 +33,6 @@ import com.fuying.sn.utils.ServiceAliveUtils;
|
||||
import com.fuying.sn.utils.URLUtils;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -146,55 +142,62 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
@SuppressLint("NewApi")
|
||||
public void getAllApp() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryAllAppControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getAllApp", "onSubscribe: ");
|
||||
}
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getQueryAllAppControl()
|
||||
// .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// Log.e("getAllApp", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
// Log.e("getAllApp", "onNext: " + listBaseResponse);
|
||||
// int code = listBaseResponse.code;
|
||||
// if (code == 200) {
|
||||
// List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
// if (appInfoList == null || appInfoList.size() == 0) {
|
||||
// mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
// ApkUtils.writeAppPackageList(mContext, "");
|
||||
// } else {
|
||||
// mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfoList));
|
||||
// HashSet allPkgSet = new HashSet<String>();
|
||||
// for (AppInfo pkg : appInfoList) {
|
||||
// allPkgSet.add(pkg.getApp_package());
|
||||
// }
|
||||
// String allPkgString = String.join(",", allPkgSet);
|
||||
// Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||
// Log.e("getAllApp", "onNext: " + allPkgString);
|
||||
// ApkUtils.writeAppPackageList(mContext, allPkgString);
|
||||
// NetInterfaceManager.getInstance().getAppStart(appInfoList);
|
||||
// }
|
||||
// JGYUtils.getInstance().deleteOtherApp();
|
||||
// } else {
|
||||
// mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
// ApkUtils.writeAppPackageList(mContext, "");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.e("getAllApp", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getAllApp", "onComplete: ");
|
||||
// mView.getAllAppFinish();
|
||||
// }
|
||||
// });
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
Log.e("getAllApp", "onNext: " + listBaseResponse);
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
if (appInfoList == null || appInfoList.size() == 0) {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
ApkUtils.writeAppPackageList(mContext, "");
|
||||
} else {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfoList));
|
||||
HashSet allPkgSet = new HashSet<String>();
|
||||
for (AppInfo pkg : appInfoList) {
|
||||
allPkgSet.add(pkg.getApp_package());
|
||||
}
|
||||
String allPkgString = String.join(",", allPkgSet);
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||
Log.e("getAllApp", "onNext: " + allPkgString);
|
||||
ApkUtils.writeAppPackageList(mContext, allPkgString);
|
||||
NetInterfaceManager.getInstance().getAppStart(appInfoList);
|
||||
}
|
||||
JGYUtils.getInstance().deleteOtherApp();
|
||||
} else {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
ApkUtils.writeAppPackageList(mContext, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getAllApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAllApp", "onComplete: ");
|
||||
mView.getAllAppFinish();
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(new NetInterfaceManager.WhiteListCallback() {
|
||||
@Override
|
||||
public void onComplet() {
|
||||
mView.getAllAppFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user