version:2.3
fix:优化上传请求 update:增加获取内置应用白名单
This commit is contained in:
17
app/src/main/java/com/fuying/sn/bean/AppAndWhiteBean.java
Normal file
17
app/src/main/java/com/fuying/sn/bean/AppAndWhiteBean.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.fuying.sn.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppAndWhiteBean implements Serializable {
|
||||
private static final long serialVersionUID = 3896715165027188298L;
|
||||
|
||||
String app_package;
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
}
|
||||
|
||||
public void setApp_package(String app_package) {
|
||||
this.app_package = app_package;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import android.util.Log;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.bean.AppAndWhiteBean;
|
||||
import com.fuying.sn.bean.AppInfo;
|
||||
import com.fuying.sn.bean.AppJump;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
@@ -53,6 +54,7 @@ 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.GetAppAndWhiteApi;
|
||||
import com.fuying.sn.network.api.GetBatchApi;
|
||||
import com.fuying.sn.network.api.GetControlScreenshotApi;
|
||||
import com.fuying.sn.network.api.GetGuideApi;
|
||||
@@ -519,6 +521,13 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppAndWhiteBean>>> getAppAndWhiteApiObservable() {
|
||||
return mRetrofit.create(GetAppAndWhiteApi.class)
|
||||
.getAppAndWhite(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* execution
|
||||
@@ -793,16 +802,16 @@ public class NetInterfaceManager {
|
||||
this.add("com.fuying.sn");
|
||||
this.add("com.uiui.health");
|
||||
this.add("com.uiui.city");
|
||||
//扶小鹰
|
||||
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);
|
||||
}};
|
||||
|
||||
private Set<String> getShowPackages() {
|
||||
HashSet<String> pkgSet = new HashSet<>();
|
||||
pkgSet.addAll(showPackages);
|
||||
pkgSet.addAll(JGYUtils.getInstance().getFXYApp());
|
||||
pkgSet.addAll(JGYUtils.getInstance().getAppAndWhite());
|
||||
return pkgSet;
|
||||
}
|
||||
|
||||
public static long getPackageSize(Context context, String filePath) {
|
||||
long size = new File(filePath).length();
|
||||
return size;
|
||||
@@ -826,14 +835,21 @@ public class NetInterfaceManager {
|
||||
pkgs.add(info.activityInfo.packageName);
|
||||
}
|
||||
Log.e("SendAppInstallInfo", "pkgs: " + pkgs);
|
||||
Set<String> showPkg = getShowPackages();
|
||||
Log.e("SendAppInstallInfo", "showPkg: " + showPkg);
|
||||
for (PackageInfo info : list) {
|
||||
//排除掉部分系统应用
|
||||
if (ApkUtils.isSystemApp(mContext, info.packageName) && !showPackages.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
//排除掉没有图标的应用
|
||||
if (!pkgs.contains(info.packageName)) {
|
||||
continue;
|
||||
if (ApkUtils.isSystemApp(mContext, info.packageName)) {
|
||||
if (!showPkg.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!showPkg.contains(info.packageName)) {
|
||||
//排除掉没有图标的应用
|
||||
if (!pkgs.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
AppUploadInfo uploadInfo = new AppUploadInfo();
|
||||
uploadInfo.setApp_name(info.applicationInfo.loadLabel(pm).toString());
|
||||
@@ -1106,7 +1122,9 @@ public class NetInterfaceManager {
|
||||
getUpdateObservable(JGYUtils.zhiduoke),
|
||||
getUpdateObservable(JGYUtils.aobama),
|
||||
getUpdateObservable(JGYUtils.growthspace),
|
||||
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7) -> {
|
||||
getUpdateObservable(JGYUtils.pandaabc),
|
||||
getUpdateObservable(JGYUtils.qibenyi),
|
||||
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7, appInfoBaseResponse8, appInfoBaseResponse9) -> {
|
||||
List<AppInfo> appInfoList = new ArrayList<>();
|
||||
if (appInfoBaseResponse.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse.data);
|
||||
@@ -1129,6 +1147,12 @@ public class NetInterfaceManager {
|
||||
if (appInfoBaseResponse7.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
if (appInfoBaseResponse8.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
if (appInfoBaseResponse9.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
return appInfoList;
|
||||
})
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
@@ -2921,8 +2945,7 @@ public class NetInterfaceManager {
|
||||
@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) {
|
||||
if (listBaseResponse1.code == 200) {
|
||||
List<AppInfo> appInfos1 = listBaseResponse1.data;
|
||||
if (appInfos1 != null && appInfos1.size() != 0) {
|
||||
appInfos.addAll(appInfos1);
|
||||
@@ -2932,8 +2955,7 @@ public class NetInterfaceManager {
|
||||
Log.e("getAppWhiteList", "onNext: " + allPkgString);
|
||||
}
|
||||
}
|
||||
int code2 = listBaseResponse2.code;
|
||||
if (code2 == 200) {
|
||||
if (listBaseResponse2.code == 200) {
|
||||
List<AppInfo> appInfos2 = listBaseResponse2.data;
|
||||
if (appInfos2 != null) {
|
||||
appInfos.addAll(appInfos2);
|
||||
|
||||
@@ -16,6 +16,8 @@ public class UrlAddress {
|
||||
//不需要在后台添加sn的接口
|
||||
/*获取所有全局更新*/
|
||||
public final static String GE_TOVERALL_APPBYPLATFORM = "app/overallAppByPlatform";
|
||||
/*获取应用内置白名单*/
|
||||
public static final String GET_APP_AND_WHITE = "getAppAndWhite";
|
||||
/*获取管理员上传的应用*/
|
||||
public final static String GET_ADMIN_APP = "getAdminApp";
|
||||
/*根据包名获取更新*/
|
||||
@@ -90,9 +92,7 @@ public class UrlAddress {
|
||||
/*在线状态*/
|
||||
@Deprecated
|
||||
public final static String SEND_DRIVE_STATE = "Online/online";
|
||||
/*获取应用白名单*/
|
||||
@Deprecated
|
||||
public static final String GET_APP_AND_WHITE = "getAppAndWhite";
|
||||
|
||||
|
||||
/*获取公网IP*/
|
||||
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.fuying.sn.network.api;
|
||||
|
||||
import com.fuying.sn.bean.AppAndWhiteBean;
|
||||
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 GetAppAndWhiteApi {
|
||||
@GET(UrlAddress.GET_APP_AND_WHITE)
|
||||
Observable<BaseResponse<List<AppAndWhiteBean>>> getAppAndWhite(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
||||
NetInterfaceManager.getInstance().getAppInside();
|
||||
}
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
MainService.getPresenter().getAllApp();
|
||||
MainService.getPresenter().getAppAndWhite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ public class MainSContact {
|
||||
void updateInfoFinish();
|
||||
void checkUpdateFinish();
|
||||
void checkFXYUpdateFinish();
|
||||
void getAllAppFinish();
|
||||
void getAppAndWhiteFinish();
|
||||
void setOverallApp();
|
||||
void setAppInside();
|
||||
void setForceInstall();
|
||||
@@ -33,7 +33,7 @@ public class MainSContact {
|
||||
|
||||
/*更新的*/
|
||||
//获取所有app包名
|
||||
void getAllApp();
|
||||
void getAppAndWhite();
|
||||
//检查更新
|
||||
void checkUpdate();
|
||||
//检查扶小鹰App更新
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.fuying.sn.service.main;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.bean.AppAndWhiteBean;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.MyAppUsageBean;
|
||||
@@ -16,10 +16,12 @@ import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
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.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.ServiceAliveUtils;
|
||||
import com.fuying.sn.utils.StringUtils;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -28,8 +30,10 @@ import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
@@ -73,9 +77,40 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressLint("NewApi")
|
||||
public void getAllApp() {
|
||||
mView.getAllAppFinish();
|
||||
public void getAppAndWhite() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppAndWhiteApiObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppAndWhiteBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAppAndWhite", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppAndWhiteBean>> baseResponse) {
|
||||
Log.e("getAppAndWhite", "onSubscribe: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
List<AppAndWhiteBean> appAndWhiteList = baseResponse.data;
|
||||
if (appAndWhiteList != null) {
|
||||
List<String> pkgList = appAndWhiteList.stream().map(AppAndWhiteBean::getApp_package).collect(Collectors.toList());
|
||||
String pkgString = StringUtils.join(",", pkgList);
|
||||
mMMKV.encode(UrlAddress.GET_APP_AND_WHITE, pkgString);
|
||||
Log.e("getAppAndWhite", "onNext: " + pkgString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAppAndWhite", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppAndWhite", "onComplete: ");
|
||||
}
|
||||
});
|
||||
mView.getAppAndWhiteFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -128,7 +128,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
public void run() {
|
||||
if ((int) SPUtils.get(MainService.this, CommonConfig.JGY_FIRST_BOOT, 0) == 0) {
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAllApp();
|
||||
mPresenter.getAppAndWhite();
|
||||
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
public void run() {
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
mPresenter.getAllApp();
|
||||
mPresenter.getAppAndWhite();
|
||||
}
|
||||
}, 20000);
|
||||
|
||||
@@ -547,7 +547,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
};
|
||||
|
||||
@Override
|
||||
public void getAllAppFinish() {
|
||||
public void getAppAndWhiteFinish() {
|
||||
mPresenter.checkUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -706,7 +706,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
break;
|
||||
case JIGUANG_BIND_UNBIND:
|
||||
ToastUtil.debugShow("老师授权/取消授权");
|
||||
MainService.getPresenter().getAllApp();
|
||||
MainService.getPresenter().getAppAndWhite();
|
||||
MainService.getPresenter().getForceInstall();
|
||||
try {
|
||||
mCacheHelper.delete();
|
||||
@@ -879,7 +879,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
if (JGYUtils.getInstance().isScreenOn()) {
|
||||
NetInterfaceManager.getInstance().screenshot();
|
||||
}
|
||||
MainService.getPresenter().getAllApp();
|
||||
MainService.getPresenter().getAppAndWhite();
|
||||
MainService.getPresenter().getSnInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -860,6 +860,8 @@ public class ApkUtils {
|
||||
HashSet<String> factoryAppList = new HashSet<>();
|
||||
factoryAppList.addAll(JGYUtils.getInstance().getOwnApp());
|
||||
factoryAppList.addAll(JGYUtils.getInstance().getFXYApp());
|
||||
factoryAppList.addAll(JGYUtils.getInstance().getAppAndWhite());
|
||||
Log.e("writeAppPackageList", "factoryAppList: " + factoryAppList);
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
HashSet<String> writeAppSet = new HashSet<>(Arrays.asList(result.split(",")));
|
||||
writeAppSet.addAll(factoryAppList);
|
||||
|
||||
@@ -47,9 +47,11 @@ import com.fuying.sn.R;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.receiver.BootReceiver;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -86,6 +88,7 @@ public class JGYUtils {
|
||||
private static JGYUtils sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver resolver;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
public static int MTKPlatform = 1;
|
||||
public static int ZhanruiPlatform = 2;
|
||||
@@ -159,6 +162,15 @@ public class JGYUtils {
|
||||
return fuxiaoyingApp;
|
||||
}
|
||||
|
||||
public HashSet<String> getAppAndWhite() {
|
||||
String pkgString = mMMKV.decodeString(UrlAddress.GET_APP_AND_WHITE, "");
|
||||
if(TextUtils.isEmpty(pkgString)){
|
||||
return new HashSet<>();
|
||||
}else {
|
||||
return new HashSet<>(Arrays.asList(pkgString.split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
private JGYUtils(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
|
||||
Reference in New Issue
Block a user