优化白名单
1.3
This commit is contained in:
@@ -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