From 17b582507f405ad7bf7da6c349c62e6af2106390 Mon Sep 17 00:00:00 2001 From: Godfather <981964879@qq.com> Date: Wed, 20 Apr 2022 16:41:05 +0800 Subject: [PATCH] =?UTF-8?q?version:1.9=20fix:=20add:=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 40 +- .../uiui/sn/activity/main/MainAPresenter.java | 44 +- .../uiui/sn/activity/main/MainActivity.java | 3 + .../com/uiui/sn/base/BaseApplication.java | 1 - .../main/java/com/uiui/sn/bean/AppInfo.java | 12 + .../java/com/uiui/sn/bean/AppletQRCode.java | 16 + .../main/java/com/uiui/sn/bean/BatchID.java | 17 + .../com/uiui/sn/bean/CloudLessonSetting.java | 52 + .../java/com/uiui/sn/config/CommonConfig.java | 6 +- .../com/uiui/sn/disklrucache/CacheHelper.java | 461 ++++++ .../sn/disklrucache/DiskLruCacheHelper.java | 427 +++++ .../java/com/uiui/sn/disklrucache/Utils.java | 101 ++ .../sn/fragment/AppletQRCodeFragment.java | 41 - .../com/uiui/sn/manager/ConnectManager.java | 59 +- .../java/com/uiui/sn/manager/ConnectMode.java | 12 + .../com/uiui/sn/network/HTTPInterface.java | 1023 ------------ .../uiui/sn/network/NetInterfaceManager.java | 1431 +++++++++++++++-- .../java/com/uiui/sn/network/UrlAddress.java | 4 +- .../sn/network/api/CloudLessonSettingApi.java | 16 + .../com/uiui/sn/network/api/GetBatchApi.java | 3 +- .../com/uiui/sn/network/api/QRCodeApi.java | 3 +- .../interceptor/PostCacheInterceptor.java | 276 ++++ .../interceptor/RepeatRequestInterceptor.java | 69 + .../uiui/sn/receiver/APKinstallReceiver.java | 9 +- .../com/uiui/sn/receiver/BootReceiver.java | 4 +- .../com/uiui/sn/receiver/MyJPushReceiver.java | 43 +- .../uiui/sn/service/main/MainSPresenter.java | 61 +- .../com/uiui/sn/service/main/MainService.java | 21 +- .../com/uiui/sn/tpush/MessageReceiver.java | 37 +- .../java/com/uiui/sn/utils/FileUtils.java | 17 +- .../java/com/uiui/sn/utils/GsonUtils.java | 29 + .../main/java/com/uiui/sn/utils/JGYUtils.java | 18 + .../main/java/com/uiui/sn/utils/Utils.java | 28 +- 33 files changed, 2991 insertions(+), 1393 deletions(-) create mode 100644 app/src/main/java/com/uiui/sn/bean/AppletQRCode.java create mode 100644 app/src/main/java/com/uiui/sn/bean/BatchID.java create mode 100644 app/src/main/java/com/uiui/sn/bean/CloudLessonSetting.java create mode 100644 app/src/main/java/com/uiui/sn/disklrucache/CacheHelper.java create mode 100644 app/src/main/java/com/uiui/sn/disklrucache/DiskLruCacheHelper.java create mode 100644 app/src/main/java/com/uiui/sn/disklrucache/Utils.java create mode 100644 app/src/main/java/com/uiui/sn/manager/ConnectMode.java delete mode 100644 app/src/main/java/com/uiui/sn/network/HTTPInterface.java create mode 100644 app/src/main/java/com/uiui/sn/network/api/CloudLessonSettingApi.java create mode 100644 app/src/main/java/com/uiui/sn/network/interceptor/PostCacheInterceptor.java create mode 100644 app/src/main/java/com/uiui/sn/network/interceptor/RepeatRequestInterceptor.java create mode 100644 app/src/main/java/com/uiui/sn/utils/GsonUtils.java diff --git a/app/build.gradle b/app/build.gradle index 2b02488..5e23364 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -208,18 +208,21 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + //BindView + implementation 'com.jakewharton:butterknife:10.2.3' +// If you are using Kotlin, replace annotationProcessor with kapt. +// annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] + annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' //极光推送 implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.8.6 版本为例。 implementation 'cn.jiguang.sdk:jcore:2.6.0' // 此处以JCore 2.6.0 版本为例。 - //动态权限框架 - implementation 'com.hjq:xxpermissions:6.0' + //okhttp implementation 'com.squareup.okhttp3:okhttp:4.9.3' //Retrofit implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0' - //RxJava implementation 'io.reactivex.rxjava3:rxjava:3.0.0' implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' @@ -229,19 +232,23 @@ dependencies { implementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2' implementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2' implementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2' - + //Google implementation 'com.google.code.gson:gson:2.9.0' implementation 'com.google.zxing:core:3.4.1' - - implementation 'com.alibaba:fastjson:1.2.76' - - //implementation 'com.blankj:utilcode:1.26.0' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.13.1' + annotationProcessor 'com.github.bumptech.glide:compiler:4.13.1' + //磁盘缓存 + implementation 'com.jakewharton:disklrucache:2.0.2' + //fastjson + implementation 'com.alibaba:fastjson:1.2.80' + //Aria implementation 'com.arialyy.aria:core:3.8.15' annotationProcessor 'com.arialyy.aria:compiler:3.8.15' - - implementation "org.java-websocket:Java-WebSocket:1.4.1" + //Java WebSocket + implementation "org.java-websocket:Java-WebSocket:1.5.2" //MMKV - implementation 'com.tencent:mmkv-static:1.2.12' + implementation 'com.tencent:mmkv-static:1.2.13' //腾讯移动推送 TPNS implementation 'com.tencent.tpns:tpns:1.3.2.0-release' //高德地图定位 @@ -252,18 +259,11 @@ dependencies { //https://github.com/JessYanCoding/AndroidAutoSize //implementation 'me.jessyan:autosize:1.2.1' implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' - implementation 'com.github.chrisbanes:PhotoView:2.0.0' - - implementation 'com.github.bumptech.glide:glide:4.13.1' - annotationProcessor 'com.github.bumptech.glide:compiler:4.13.1' - - implementation 'com.jakewharton:butterknife:10.2.1' -// If you are using Kotlin, replace annotationProcessor with kapt. -// annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] - annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1' //沉浸状态栏 implementation 'com.gitee.zackratos:UltimateBarX:0.8.0' + //动态权限框架 +// implementation 'com.hjq:xxpermissions:6.0' } preBuild { diff --git a/app/src/main/java/com/uiui/sn/activity/main/MainAPresenter.java b/app/src/main/java/com/uiui/sn/activity/main/MainAPresenter.java index 56c8225..704d583 100644 --- a/app/src/main/java/com/uiui/sn/activity/main/MainAPresenter.java +++ b/app/src/main/java/com/uiui/sn/activity/main/MainAPresenter.java @@ -1,10 +1,7 @@ package com.uiui.sn.activity.main; -import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; -import android.provider.Settings; -import android.text.TextUtils; import android.util.Log; import com.alibaba.fastjson.JSON; @@ -12,18 +9,14 @@ import com.alibaba.fastjson.JSONObject; import com.trello.rxlifecycle4.RxLifecycle; import com.trello.rxlifecycle4.android.ActivityEvent; import com.uiui.sn.bean.AppInfo; +import com.uiui.sn.bean.AppletQRCode; import com.uiui.sn.bean.BaseResponse; -import com.uiui.sn.bean.SnInfo; import com.uiui.sn.config.CommonConfig; -import com.uiui.sn.network.HTTPInterface; import com.uiui.sn.network.NetInterfaceManager; -import com.uiui.sn.utils.ApkUtils; import com.uiui.sn.utils.CXAESUtil; import com.uiui.sn.utils.JGYUtils; -import com.uiui.sn.utils.SPUtils; import com.uiui.sn.utils.Utils; -import java.util.HashSet; import java.util.List; import io.reactivex.rxjava3.core.Observer; @@ -66,7 +59,7 @@ public class MainAPresenter implements MainAContact.Presenter { @Override public void getSnInfo() { NetInterfaceManager.getInstance() - .getSnInfo(lifecycle, new NetInterfaceManager.ObserverCallback() { + .getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() { @Override public void onSubscribe(Disposable d) { @@ -92,36 +85,15 @@ public class MainAPresenter implements MainAContact.Presenter { @Override public void getAppletQRCode() { NetInterfaceManager.getInstance() - .getQRCodeApiControl() - .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY)) - .subscribe(new Observer() { + .getQRCodeURL(true, getLifecycle(), new NetInterfaceManager.onNextCallback() { @Override - public void onSubscribe(Disposable d) { - Log.e("getAppletQRCode", "onSubscribe: "); - } - - @Override - public void onNext(BaseResponse baseResponse) { - Log.e("getAppletQRCode", "onNext: "); - if (baseResponse.code == 200) { - JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data); - String url = jsonObject.getString("file"); - mView.setAppletQRCode(url); - } else { - mView.setAppletQRCode(""); - } - } - - @Override - public void onError(Throwable e) { - Log.e("getAppletQRCode", "onError: " + e.getMessage()); - mView.setAppletQRCode(""); - onComplete(); + public void onNext(Object o) { + mView.setAppletQRCode((String) o); } @Override public void onComplete() { - Log.e("getAppletQRCode", "onComplete: "); + } }); } @@ -143,7 +115,7 @@ public class MainAPresenter implements MainAContact.Presenter { public void getForceInstall() { NetInterfaceManager.getInstance() .getForceInstallControl() - .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY)) + .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY)) .subscribe(new Observer>>() { @Override public void onSubscribe(Disposable d) { @@ -157,7 +129,7 @@ public class MainAPresenter implements MainAContact.Presenter { if (code == 200) { List appInfos = listBaseResponse.data; if (null != appInfos && appInfos.size() != 0) { - HTTPInterface.getForceInstallState(mContext, appInfos); + NetInterfaceManager.getInstance().getForceInstallState(appInfos); } } else { boolean qch_force_app = JGYUtils.putString(mContext.getContentResolver(), "qch_force_app", "invalid"); diff --git a/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java b/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java index d5ff8b5..b3efb82 100644 --- a/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java +++ b/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java @@ -120,6 +120,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, } JGYUtils.getInstance().wakeUpAppstore(); JGYUtils.getInstance().wakeUpUpdateTools(); + + Utils.getBattery(this); + Utils.getBatterymAh(this); } private TimeTask task; diff --git a/app/src/main/java/com/uiui/sn/base/BaseApplication.java b/app/src/main/java/com/uiui/sn/base/BaseApplication.java index 0b36466..2dc3255 100644 --- a/app/src/main/java/com/uiui/sn/base/BaseApplication.java +++ b/app/src/main/java/com/uiui/sn/base/BaseApplication.java @@ -20,7 +20,6 @@ import com.uiui.sn.manager.ControlPanelManager; import com.uiui.sn.network.NetInterfaceManager; import com.uiui.sn.manager.ControlManager; import com.uiui.sn.manager.DeviceManager; -import com.uiui.sn.network.HTTPInterface; import com.uiui.sn.network.UrlAddress; import com.uiui.sn.rlog.LogDBManager; import com.uiui.sn.utils.AppUsedTimeUtils; diff --git a/app/src/main/java/com/uiui/sn/bean/AppInfo.java b/app/src/main/java/com/uiui/sn/bean/AppInfo.java index f75fb83..269e759 100644 --- a/app/src/main/java/com/uiui/sn/bean/AppInfo.java +++ b/app/src/main/java/com/uiui/sn/bean/AppInfo.java @@ -1,9 +1,15 @@ package com.uiui.sn.bean; +import androidx.annotation.NonNull; + +import com.google.gson.Gson; +import com.google.gson.JsonParser; + import java.io.Serializable; public class AppInfo implements Serializable { private static final long serialVersionUID = 423463220624853188L; + private int app_id; private String app_name; private String app_package; @@ -220,4 +226,10 @@ public class AppInfo implements Serializable { public void setApp_md5(String app_md5) { this.app_md5 = app_md5; } + + @NonNull + @Override + public String toString() { + return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString(); + } } diff --git a/app/src/main/java/com/uiui/sn/bean/AppletQRCode.java b/app/src/main/java/com/uiui/sn/bean/AppletQRCode.java new file mode 100644 index 0000000..398122a --- /dev/null +++ b/app/src/main/java/com/uiui/sn/bean/AppletQRCode.java @@ -0,0 +1,16 @@ +package com.uiui.sn.bean; + +import java.io.Serializable; + +public class AppletQRCode implements Serializable { + private static final long serialVersionUID = -8881030834624940282L; + String file; + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } +} diff --git a/app/src/main/java/com/uiui/sn/bean/BatchID.java b/app/src/main/java/com/uiui/sn/bean/BatchID.java new file mode 100644 index 0000000..41cce85 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/bean/BatchID.java @@ -0,0 +1,17 @@ +package com.uiui.sn.bean; + +import java.io.Serializable; + +public class BatchID implements Serializable { + private static final long serialVersionUID = -2320968190625923242L; + + String batch_id; + + public String getBatch_id() { + return batch_id; + } + + public void setBatch_id(String batch_id) { + this.batch_id = batch_id; + } +} diff --git a/app/src/main/java/com/uiui/sn/bean/CloudLessonSetting.java b/app/src/main/java/com/uiui/sn/bean/CloudLessonSetting.java new file mode 100644 index 0000000..dcf3377 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/bean/CloudLessonSetting.java @@ -0,0 +1,52 @@ +package com.uiui.sn.bean; + +import java.io.Serializable; + +public class CloudLessonSetting implements Serializable { + private static final long serialVersionUID = 4065637781427268046L; + int id; + String is_lesson; + String start_time; + String end_time; + String is_monitor; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getIs_lesson() { + return is_lesson; + } + + public void setIs_lesson(String is_lesson) { + this.is_lesson = is_lesson; + } + + public String getStart_time() { + return start_time; + } + + public void setStart_time(String start_time) { + this.start_time = start_time; + } + + public String getEnd_time() { + return end_time; + } + + public void setEnd_time(String end_time) { + this.end_time = end_time; + } + + public String getIs_monitor() { + return is_monitor; + } + + public void setIs_monitor(String is_monitor) { + this.is_monitor = is_monitor; + } +} diff --git a/app/src/main/java/com/uiui/sn/config/CommonConfig.java b/app/src/main/java/com/uiui/sn/config/CommonConfig.java index 3befc45..416f5c9 100644 --- a/app/src/main/java/com/uiui/sn/config/CommonConfig.java +++ b/app/src/main/java/com/uiui/sn/config/CommonConfig.java @@ -9,10 +9,8 @@ public class CommonConfig { public final static String ONLY_SHORTCUT_LIST = "only_jgy_shortcut_list"; /*底层白名单*/ public final static String QCH_APP_FORBID = "qch_app_forbid"; - /*所有app更新*/ - public final static String ALL_APP_UPDATE = "AllAppUpdate"; - /*上次检查更新时间*/ - public final static String LAST_CHECK_ALL_UPDATE_TIME = "lastCheckAllUpdateTime"; + /*获取设备的标签*/ + public final static String DEVICES_TAG = "DEVICES_TAG"; public static String isLogined = "isLogined"; public static String AES_KEY = "0123456789ABCDEF"; diff --git a/app/src/main/java/com/uiui/sn/disklrucache/CacheHelper.java b/app/src/main/java/com/uiui/sn/disklrucache/CacheHelper.java new file mode 100644 index 0000000..6146b3f --- /dev/null +++ b/app/src/main/java/com/uiui/sn/disklrucache/CacheHelper.java @@ -0,0 +1,461 @@ +package com.uiui.sn.disklrucache; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; +import android.os.Environment; +import android.util.Log; + +import com.jakewharton.disklrucache.DiskLruCache; +import com.tencent.mmkv.MMKV; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Serializable; + +/** + * 磁盘缓存帮助类 + */ +public class CacheHelper { + private static final String TAG = "DiskLruCacheHelper"; + + private MMKV mMMKV = MMKV.defaultMMKV(); + + private static final String DIR_NAME = "diskCache"; + private static final int MAX_COUNT = 5 * 1024 * 1024; + private static final int DEFAULT_APP_VERSION = 1; + + private DiskLruCache mDiskLruCache; + + public CacheHelper(Context context) { + mDiskLruCache = generateCache(context, DIR_NAME, MAX_COUNT); + } + + public CacheHelper(Context context, String dirName) { + mDiskLruCache = generateCache(context, dirName, MAX_COUNT); + } + + public CacheHelper(Context context, String dirName, int maxCount) { + mDiskLruCache = generateCache(context, dirName, maxCount); + } + + //custom cache dir + public CacheHelper(File dir) { + mDiskLruCache = generateCache(null, dir, MAX_COUNT); + } + + public CacheHelper(Context context, File dir) { + mDiskLruCache = generateCache(context, dir, MAX_COUNT); + } + + public CacheHelper(Context context, File dir, int maxCount) { + mDiskLruCache = generateCache(context, dir, maxCount); + } + + private DiskLruCache generateCache(Context context, File dir, int maxCount) { + if (!dir.exists() || !dir.isDirectory()) { + throw new IllegalArgumentException( + dir + " is not a directory or does not exists. "); + } + + int appVersion = context == null ? DEFAULT_APP_VERSION : Utils.getAppVersion(context); + + DiskLruCache diskLruCache = null; + try { + diskLruCache = DiskLruCache.open( + dir, + appVersion, + DEFAULT_APP_VERSION, + maxCount); + } catch (IOException e) { + e.printStackTrace(); + } + return diskLruCache; + } + + private DiskLruCache generateCache(Context context, String dirName, int maxCount) { + DiskLruCache diskLruCache = null; + try { + diskLruCache = DiskLruCache.open( + getDiskCacheDir(context, dirName), + Utils.getAppVersion(context), + DEFAULT_APP_VERSION, + maxCount); + } catch (IOException e) { + e.printStackTrace(); + } + return diskLruCache; + } + + // ======================================= + // ============== String 数据 读写 ============= + // ======================================= + + public void put(String key, String value) { + Log.e(TAG, "put: " + key); + mMMKV.encode(key, System.currentTimeMillis()); + + DiskLruCache.Editor edit = null; + BufferedWriter bw = null; + try { + edit = editor(key); + if (edit == null) { + return; + } + OutputStream os = edit.newOutputStream(0); + bw = new BufferedWriter(new OutputStreamWriter(os)); + bw.write(value); + edit.commit();//write CLEAN + } catch (IOException e) { + e.printStackTrace(); + try { + //s + edit.abort();//write REMOVE + } catch (IOException e1) { + e1.printStackTrace(); + } + } finally { + try { + if (bw != null) { + bw.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public String getAsString(String key) { + Log.e(TAG, "getAsString: " + key); + InputStream inputStream = null; + try { + //write READ + inputStream = get(key); + if (inputStream == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + int len = 0; + byte[] buf = new byte[128]; + while ((len = inputStream.read(buf)) != -1) { + sb.append(new String(buf, 0, len)); + } + return sb.toString(); + + + } catch (IOException e) { + e.printStackTrace(); + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + return null; + } + + + public void put(String key, JSONObject jsonObject) { + put(key, jsonObject.toString()); + } + + public JSONObject getAsJson(String key) { + String val = getAsString(key); + try { + if (val != null) { + return new JSONObject(val); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return null; + } + + // ======================================= + // ============ JSONArray 数据 读写 ============= + // ======================================= + + public void put(String key, JSONArray jsonArray) { + put(key, jsonArray.toString()); + } + + public JSONArray getAsJSONArray(String key) { + String JSONString = getAsString(key); + try { + JSONArray obj = new JSONArray(JSONString); + return obj; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + // ======================================= + // ============== byte 数据 读写 ============= + // ======================================= + + /** + * 保存 byte数据 到 缓存中 + * + * @param key 保存的key + * @param value 保存的数据 + */ + public void put(String key, byte[] value) { + OutputStream out = null; + DiskLruCache.Editor editor = null; + try { + editor = editor(key); + if (editor == null) { + return; + } + out = editor.newOutputStream(0); + out.write(value); + out.flush(); + editor.commit();//write CLEAN + } catch (Exception e) { + e.printStackTrace(); + try { + editor.abort();//write REMOVE + } catch (IOException e1) { + e1.printStackTrace(); + } + + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + public byte[] getAsBytes(String key) { + byte[] res = null; + InputStream is = get(key); + if (is == null) { + return null; + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + byte[] buf = new byte[256]; + int len = 0; + while ((len = is.read(buf)) != -1) { + baos.write(buf, 0, len); + } + res = baos.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + } + return res; + } + + + // ======================================= + // ============== 序列化 数据 读写 ============= + // ======================================= + public void put(String key, Serializable value) { + DiskLruCache.Editor editor = editor(key); + ObjectOutputStream oos = null; + if (editor == null) { + return; + } + try { + OutputStream os = editor.newOutputStream(0); + oos = new ObjectOutputStream(os); + oos.writeObject(value); + oos.flush(); + editor.commit(); + } catch (IOException e) { + e.printStackTrace(); + try { + editor.abort(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } finally { + try { + if (oos != null) { + oos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public T getAsSerializable(String key) { + T t = null; + InputStream is = get(key); + ObjectInputStream ois = null; + if (is == null) { + return null; + } + try { + ois = new ObjectInputStream(is); + t = (T) ois.readObject(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (ois != null) { + ois.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return t; + } + + // ======================================= + // ============== bitmap 数据 读写 ============= + // ======================================= + public void put(String key, Bitmap bitmap) { + put(key, Utils.bitmap2Bytes(bitmap)); + } + + public Bitmap getAsBitmap(String key) { + byte[] bytes = getAsBytes(key); + if (bytes == null) { + return null; + } + return Utils.bytes2Bitmap(bytes); + } + + // ======================================= + // ============= drawable 数据 读写 ============= + // ======================================= + public void put(String key, Drawable value) { + put(key, Utils.drawable2Bitmap(value)); + } + + public Drawable getAsDrawable(String key) { + byte[] bytes = getAsBytes(key); + if (bytes == null) { + return null; + } + return Utils.bitmap2Drawable(Utils.bytes2Bitmap(bytes)); + } + + // ======================================= + // ============= other methods ============= + // ======================================= + public boolean remove(String key) { + try { + key = Utils.hashKeyForDisk(key); + return mDiskLruCache.remove(key); + } catch (IOException e) { + e.printStackTrace(); + } + return false; + } + + public void close() throws IOException { + mDiskLruCache.close(); + } + + public void delete() throws IOException { + mDiskLruCache.delete(); + } + + public void flush() throws IOException { + mDiskLruCache.flush(); + } + + public boolean isClosed() { + return mDiskLruCache.isClosed(); + } + + public long size() { + return mDiskLruCache.size(); + } + + public void setMaxSize(long maxSize) { + mDiskLruCache.setMaxSize(maxSize); + } + + public File getDirectory() { + return mDiskLruCache.getDirectory(); + } + + public long getMaxSize() { + return mDiskLruCache.getMaxSize(); + } + + + // ======================================= + // ===遇到文件比较大的,可以直接通过流读写 ===== + // ======================================= + //basic editor + public DiskLruCache.Editor editor(String key) { + try { + key = Utils.hashKeyForDisk(key); + //wirte DIRTY + DiskLruCache.Editor edit = mDiskLruCache.edit(key); + //edit maybe null :the entry is editing + if (edit == null) { + Log.w(TAG, "the entry spcified key:" + key + " is editing by other . "); + } + return edit; + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + + //basic get + public InputStream get(String key) { + try { + DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key)); + if (snapshot == null) //not find entry , or entry.readable = false + { + Log.e(TAG, "not find entry , or entry.readable = false"); + return null; + } + //write READ + return snapshot.getInputStream(0); + + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + } + + + // ======================================= + // ============== 序列化 数据 读写 ============= + // ======================================= + + private File getDiskCacheDir(Context context, String uniqueName) { + String cachePath; + if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) + || !Environment.isExternalStorageRemovable()) { + cachePath = context.getExternalCacheDir().getPath(); + } else { + cachePath = context.getCacheDir().getPath(); + } + return new File(cachePath + File.separator + uniqueName); + } + +} diff --git a/app/src/main/java/com/uiui/sn/disklrucache/DiskLruCacheHelper.java b/app/src/main/java/com/uiui/sn/disklrucache/DiskLruCacheHelper.java new file mode 100644 index 0000000..d2d98c1 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/disklrucache/DiskLruCacheHelper.java @@ -0,0 +1,427 @@ +package com.uiui.sn.disklrucache; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; +import android.os.Environment; +import android.util.Log; + +import com.jakewharton.disklrucache.DiskLruCache; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Serializable; + +/** + * 磁盘缓存帮助类 + */ +public class DiskLruCacheHelper { + private static final String DIR_NAME = "diskCache"; + private static final int MAX_COUNT = 5 * 1024 * 1024; + private static final int DEFAULT_APP_VERSION = 1; + + private static final String TAG = "DiskLruCacheHelper"; + + private DiskLruCache mDiskLruCache; + + public DiskLruCacheHelper(Context context) throws IOException { + mDiskLruCache = generateCache(context, DIR_NAME, MAX_COUNT); + } + + public DiskLruCacheHelper(Context context, String dirName) throws IOException { + mDiskLruCache = generateCache(context, dirName, MAX_COUNT); + } + + public DiskLruCacheHelper(Context context, String dirName, int maxCount) throws IOException { + mDiskLruCache = generateCache(context, dirName, maxCount); + } + + //custom cache dir + public DiskLruCacheHelper(File dir) throws IOException { + mDiskLruCache = generateCache(null, dir, MAX_COUNT); + } + + public DiskLruCacheHelper(Context context, File dir) throws IOException { + mDiskLruCache = generateCache(context, dir, MAX_COUNT); + } + + public DiskLruCacheHelper(Context context, File dir, int maxCount) throws IOException { + mDiskLruCache = generateCache(context, dir, maxCount); + } + + private DiskLruCache generateCache(Context context, File dir, int maxCount) throws IOException { + if (!dir.exists() || !dir.isDirectory()) { + throw new IllegalArgumentException( + dir + " is not a directory or does not exists. "); + } + + int appVersion = context == null ? DEFAULT_APP_VERSION : Utils.getAppVersion(context); + + DiskLruCache diskLruCache = DiskLruCache.open( + dir, + appVersion, + DEFAULT_APP_VERSION, + maxCount); + + return diskLruCache; + } + + private DiskLruCache generateCache(Context context, String dirName, int maxCount) throws IOException { + DiskLruCache diskLruCache = DiskLruCache.open( + getDiskCacheDir(context, dirName), + Utils.getAppVersion(context), + DEFAULT_APP_VERSION, + maxCount); + return diskLruCache; + } + // ======================================= + // ============== String 数据 读写 ============= + // ======================================= + + public void put(String key, String value) { + DiskLruCache.Editor edit = null; + BufferedWriter bw = null; + try { + edit = editor(key); + if (edit == null) return; + OutputStream os = edit.newOutputStream(0); + bw = new BufferedWriter(new OutputStreamWriter(os)); + bw.write(value); + edit.commit();//write CLEAN + } catch (IOException e) { + e.printStackTrace(); + try { + //s + edit.abort();//write REMOVE + } catch (IOException e1) { + e1.printStackTrace(); + } + } finally { + try { + if (bw != null) + bw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public String getAsString(String key) { + InputStream inputStream = null; + try { + //write READ + inputStream = get(key); + if (inputStream == null) return null; + StringBuilder sb = new StringBuilder(); + int len = 0; + byte[] buf = new byte[128]; + while ((len = inputStream.read(buf)) != -1) { + sb.append(new String(buf, 0, len)); + } + return sb.toString(); + + + } catch (IOException e) { + e.printStackTrace(); + if (inputStream != null) + try { + inputStream.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + return null; + } + + + public void put(String key, JSONObject jsonObject) { + put(key, jsonObject.toString()); + } + + public JSONObject getAsJson(String key) { + String val = getAsString(key); + try { + if (val != null) + return new JSONObject(val); + } catch (JSONException e) { + e.printStackTrace(); + } + return null; + } + + // ======================================= + // ============ JSONArray 数据 读写 ============= + // ======================================= + + public void put(String key, JSONArray jsonArray) { + put(key, jsonArray.toString()); + } + + public JSONArray getAsJSONArray(String key) { + String JSONString = getAsString(key); + try { + JSONArray obj = new JSONArray(JSONString); + return obj; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + // ======================================= + // ============== byte 数据 读写 ============= + // ======================================= + + /** + * 保存 byte数据 到 缓存中 + * + * @param key 保存的key + * @param value 保存的数据 + */ + public void put(String key, byte[] value) { + OutputStream out = null; + DiskLruCache.Editor editor = null; + try { + editor = editor(key); + if (editor == null) { + return; + } + out = editor.newOutputStream(0); + out.write(value); + out.flush(); + editor.commit();//write CLEAN + } catch (Exception e) { + e.printStackTrace(); + try { + editor.abort();//write REMOVE + } catch (IOException e1) { + e1.printStackTrace(); + } + + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + public byte[] getAsBytes(String key) { + byte[] res = null; + InputStream is = get(key); + if (is == null) return null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + byte[] buf = new byte[256]; + int len = 0; + while ((len = is.read(buf)) != -1) { + baos.write(buf, 0, len); + } + res = baos.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + } + return res; + } + + + // ======================================= + // ============== 序列化 数据 读写 ============= + // ======================================= + public void put(String key, Serializable value) { + DiskLruCache.Editor editor = editor(key); + ObjectOutputStream oos = null; + if (editor == null) return; + try { + OutputStream os = editor.newOutputStream(0); + oos = new ObjectOutputStream(os); + oos.writeObject(value); + oos.flush(); + editor.commit(); + } catch (IOException e) { + e.printStackTrace(); + try { + editor.abort(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } finally { + try { + if (oos != null) + oos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public T getAsSerializable(String key) { + T t = null; + InputStream is = get(key); + ObjectInputStream ois = null; + if (is == null) return null; + try { + ois = new ObjectInputStream(is); + t = (T) ois.readObject(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (ois != null) + ois.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return t; + } + + // ======================================= + // ============== bitmap 数据 读写 ============= + // ======================================= + public void put(String key, Bitmap bitmap) { + put(key, Utils.bitmap2Bytes(bitmap)); + } + + public Bitmap getAsBitmap(String key) { + byte[] bytes = getAsBytes(key); + if (bytes == null) return null; + return Utils.bytes2Bitmap(bytes); + } + + // ======================================= + // ============= drawable 数据 读写 ============= + // ======================================= + public void put(String key, Drawable value) { + put(key, Utils.drawable2Bitmap(value)); + } + + public Drawable getAsDrawable(String key) { + byte[] bytes = getAsBytes(key); + if (bytes == null) { + return null; + } + return Utils.bitmap2Drawable(Utils.bytes2Bitmap(bytes)); + } + + // ======================================= + // ============= other methods ============= + // ======================================= + public boolean remove(String key) { + try { + key = Utils.hashKeyForDisk(key); + return mDiskLruCache.remove(key); + } catch (IOException e) { + e.printStackTrace(); + } + return false; + } + + public void close() throws IOException { + mDiskLruCache.close(); + } + + public void delete() throws IOException { + mDiskLruCache.delete(); + } + + public void flush() throws IOException { + mDiskLruCache.flush(); + } + + public boolean isClosed() { + return mDiskLruCache.isClosed(); + } + + public long size() { + return mDiskLruCache.size(); + } + + public void setMaxSize(long maxSize) { + mDiskLruCache.setMaxSize(maxSize); + } + + public File getDirectory() { + return mDiskLruCache.getDirectory(); + } + + public long getMaxSize() { + return mDiskLruCache.getMaxSize(); + } + + + // ======================================= + // ===遇到文件比较大的,可以直接通过流读写 ===== + // ======================================= + //basic editor + public DiskLruCache.Editor editor(String key) { + try { + key = Utils.hashKeyForDisk(key); + //wirte DIRTY + DiskLruCache.Editor edit = mDiskLruCache.edit(key); + //edit maybe null :the entry is editing + if (edit == null) { + Log.w(TAG, "the entry spcified key:" + key + " is editing by other . "); + } + return edit; + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + + //basic get + public InputStream get(String key) { + try { + DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key)); + if (snapshot == null) //not find entry , or entry.readable = false + { + Log.e(TAG, "not find entry , or entry.readable = false"); + return null; + } + //write READ + return snapshot.getInputStream(0); + + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + } + + + // ======================================= + // ============== 序列化 数据 读写 ============= + // ======================================= + + private File getDiskCacheDir(Context context, String uniqueName) { + String cachePath; + if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) + || !Environment.isExternalStorageRemovable()) { + cachePath = context.getExternalCacheDir().getPath(); + } else { + cachePath = context.getCacheDir().getPath(); + } + return new File(cachePath + File.separator + uniqueName); + } + +} diff --git a/app/src/main/java/com/uiui/sn/disklrucache/Utils.java b/app/src/main/java/com/uiui/sn/disklrucache/Utils.java new file mode 100644 index 0000000..05ac824 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/disklrucache/Utils.java @@ -0,0 +1,101 @@ +package com.uiui.sn.disklrucache; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.PixelFormat; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; + +import java.io.ByteArrayOutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Utils { + public static int getAppVersion(Context context) { + try { + PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); + return info.versionCode; + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return 1; + } + + + public static String hashKeyForDisk(String key) { + String cacheKey; + try { + final MessageDigest mDigest = MessageDigest.getInstance("MD5"); + mDigest.update(key.getBytes()); + cacheKey = bytesToHexString(mDigest.digest()); + } catch (NoSuchAlgorithmException e) { + cacheKey = String.valueOf(key.hashCode()); + } + return cacheKey; + } + + public static String bytesToHexString(byte[] bytes) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + String hex = Integer.toHexString(0xFF & bytes[i]); + if (hex.length() == 1) { + sb.append('0'); + } + sb.append(hex); + } + return sb.toString(); + } + + public static byte[] bitmap2Bytes(Bitmap bm) { + if (bm == null) { + return null; + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + bm.compress(Bitmap.CompressFormat.PNG, 100, baos); + return baos.toByteArray(); + } + + public static Bitmap bytes2Bitmap(byte[] bytes) { + return BitmapFactory.decodeByteArray(bytes, 0, bytes.length); + } + + + /** + * Drawable → Bitmap + */ + public static Bitmap drawable2Bitmap(Drawable drawable) { + if (drawable == null) { + return null; + } + // 取 drawable 的长宽 + int w = drawable.getIntrinsicWidth(); + int h = drawable.getIntrinsicHeight(); + // 取 drawable 的颜色格式 + Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; + // 建立对应 bitmap + Bitmap bitmap = Bitmap.createBitmap(w, h, config); + // 建立对应 bitmap 的画布 + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, w, h); + // 把 drawable 内容画到画布中 + drawable.draw(canvas); + return bitmap; + } + + /* + * Bitmap → Drawable + */ + @SuppressWarnings("deprecation") + public static Drawable bitmap2Drawable(Bitmap bm) { + if (bm == null) { + return null; + } + BitmapDrawable bd = new BitmapDrawable(bm); + bd.setTargetDensity(bm.getDensity()); + return new BitmapDrawable(bm); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/uiui/sn/fragment/AppletQRCodeFragment.java b/app/src/main/java/com/uiui/sn/fragment/AppletQRCodeFragment.java index 701231d..28a757a 100644 --- a/app/src/main/java/com/uiui/sn/fragment/AppletQRCodeFragment.java +++ b/app/src/main/java/com/uiui/sn/fragment/AppletQRCodeFragment.java @@ -79,47 +79,6 @@ public class AppletQRCodeFragment extends Fragment { } private void getQRCodeURL() { - NetInterfaceManager.getInstance() - .getQRCodeApiControl() - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { - Log.e("getQRCodeURL", "onSubscribe: "); - } - @Override - public void onNext(BaseResponse baseResponse) { - Log.e("getQRCodeURL", "onNext: "); - if (baseResponse.code == 200) { - JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data); - String url = jsonObject.getString("file"); - if (!TextUtils.isEmpty(url)) { - if (getActivity() != null && !getActivity().isDestroyed()) { - Glide.with(qr_code) - .load(url) - .dontAnimate() - .placeholder(getActivity().getDrawable(R.drawable.applet_qrcode)) - .into(qr_code); - } - } else { - qr_code.setImageDrawable(getActivity().getDrawable(R.drawable.applet_qrcode)); - } - } else { - qr_code.setImageDrawable(getActivity().getDrawable(R.drawable.applet_qrcode)); - } - } - - @Override - public void onError(Throwable e) { - Log.e("getQRCodeURL", "onError: " + e.getMessage()); - } - - @Override - public void onComplete() { - Log.e("getQRCodeURL", "onComplete: "); - } - }); } - - } diff --git a/app/src/main/java/com/uiui/sn/manager/ConnectManager.java b/app/src/main/java/com/uiui/sn/manager/ConnectManager.java index 419be29..6d33276 100644 --- a/app/src/main/java/com/uiui/sn/manager/ConnectManager.java +++ b/app/src/main/java/com/uiui/sn/manager/ConnectManager.java @@ -10,6 +10,15 @@ import com.uiui.sn.utils.TimeUtils; public class ConnectManager { private static final String TAG = ConnectManager.class.getSimpleName(); + + public static final long ONE_MINUTES_TIME = 60 * 1000; + public static final long FIFTEEN_MINUTES_TIME = ONE_MINUTES_TIME * 15; + public static final long HALF_HOUR_TIME = FIFTEEN_MINUTES_TIME * 2; + public static final long ONE_HOUR_TIME = HALF_HOUR_TIME * 2; + public static final long SIX_HOUR_TIME = ONE_HOUR_TIME * 6; + public static final long HALF_DAY_TIME = SIX_HOUR_TIME * 2; + public static final long ONE_DAY_TIME = HALF_DAY_TIME * 2; + /*重启后连接成功的时间*/ public static final String REBOOT_LAST_ONNECT_TIME = "reboot_last_connect_time"; /*WiFi连接后连接成功的时间*/ @@ -45,13 +54,55 @@ public class ConnectManager { return sInstance; } + public long getConnectModeTime(ConnectMode connectMode) { + long time = 0; + switch (connectMode) { + case DEFAULT: + time = 0; + break; + case ONE_MINUTE: + time = ONE_MINUTES_TIME; + break; + case FIFTEEN_MINUTES: + time = FIFTEEN_MINUTES_TIME; + break; + case HALF_HOUR: + time = HALF_HOUR_TIME; + break; + case ONE_HOUR: + time = ONE_HOUR_TIME; + break; + case SIX_HOUR: + time = SIX_HOUR_TIME; + break; + case HALF_DAY: + time = HALF_DAY_TIME; + break; + case ONE_DAY: + time = ONE_DAY_TIME; + break; + default: + } + return time; + } + + public boolean isNeedConnect(String key, ConnectMode connectMode) { + long nowTime = System.currentTimeMillis(); + long lastTime = mMMKV.decodeLong(key, 0); + long intervalTime = getConnectModeTime(connectMode); + //防止一分钟内重复请求 + return nowTime - lastTime > intervalTime && nowTime - lastTime > ONE_MINUTES_TIME; + } + /** - * @return 今天重启后是否连接 + * @return 重启后是否连接 */ public boolean isRebootFistConnect() { - long time = mMMKV.decodeLong(REBOOT_LAST_ONNECT_TIME, 0); - return !TimeUtils.isTodayTime(time); + long rebootTime = mMMKV.decodeLong(REBOOT_LAST_ONNECT_TIME, 0); + //只在开机后15内连接,其他情况为service重启 + long time = System.currentTimeMillis() - rebootTime; + return time < 15 * 1000; } /** @@ -78,4 +129,6 @@ public class ConnectManager { long time = mMMKV.decodeLong(WiFiAlias, 0); return !TimeUtils.isTodayTime(time); } + + } diff --git a/app/src/main/java/com/uiui/sn/manager/ConnectMode.java b/app/src/main/java/com/uiui/sn/manager/ConnectMode.java new file mode 100644 index 0000000..18e8565 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/manager/ConnectMode.java @@ -0,0 +1,12 @@ +package com.uiui.sn.manager; + +public enum ConnectMode { + DEFAULT, + ONE_MINUTE, + FIFTEEN_MINUTES, + HALF_HOUR, + ONE_HOUR, + SIX_HOUR, + HALF_DAY, + ONE_DAY, +} \ No newline at end of file diff --git a/app/src/main/java/com/uiui/sn/network/HTTPInterface.java b/app/src/main/java/com/uiui/sn/network/HTTPInterface.java deleted file mode 100644 index d2f743a..0000000 --- a/app/src/main/java/com/uiui/sn/network/HTTPInterface.java +++ /dev/null @@ -1,1023 +0,0 @@ -package com.uiui.sn.network; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.os.Build; -import android.os.Environment; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.Log; - -import androidx.core.content.ContextCompat; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.uiui.sn.BuildConfig; -import com.uiui.sn.bean.AppInfo; -import com.uiui.sn.bean.AppStart; -import com.uiui.sn.bean.AppUploadInfo; -import com.uiui.sn.bean.BaseResponse; -import com.uiui.sn.bean.Label; -import com.uiui.sn.bean.browser.BrowserApiData; -import com.uiui.sn.bean.browser.BrowserBean; -import com.uiui.sn.config.CommonConfig; -import com.uiui.sn.manager.ControlManager; -import com.uiui.sn.network.api.NewestAppUpdate; -import com.uiui.sn.network.api.UpdateAdminSn; -import com.uiui.sn.service.ManagerService; -import com.uiui.sn.utils.ApkUtils; -import com.uiui.sn.utils.AppUsedTimeUtils; -import com.uiui.sn.utils.CmdUtil; -import com.uiui.sn.utils.FileUtils; -import com.uiui.sn.utils.JGYUtils; -import com.uiui.sn.utils.SPUtils; -import com.uiui.sn.utils.TimeUtils; -import com.uiui.sn.utils.URLUtils; -import com.uiui.sn.utils.Utils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.stream.Collectors; - -import cn.jpush.android.api.JPushInterface; -import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; -import io.reactivex.rxjava3.annotations.NonNull; -import io.reactivex.rxjava3.core.Observable; -import io.reactivex.rxjava3.core.ObservableEmitter; -import io.reactivex.rxjava3.core.ObservableOnSubscribe; -import io.reactivex.rxjava3.core.ObservableSource; -import io.reactivex.rxjava3.core.Observer; -import io.reactivex.rxjava3.disposables.Disposable; -import io.reactivex.rxjava3.functions.BiFunction; -import io.reactivex.rxjava3.functions.Function; -import io.reactivex.rxjava3.schedulers.Schedulers; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -public class HTTPInterface { - private static String TAG = HTTPInterface.class.getSimpleName(); - - - public static void setBrowserWhiteList(Context context) { - Observable.zip(NetInterfaceManager.getInstance().getLabelControl(), - NetInterfaceManager.getInstance().getBrowserControl(), - new BiFunction, BaseResponse, HashSet>() { - @Override - public HashSet apply(BaseResponse