version:2.6
fix:更新retrofit,优化请求次数 update:
This commit is contained in:
1 parent
7d50cb709b
commit
3c45ccc7b1
76 files changed
+1130
-1705
No files matched your search
@@ -21,47 +21,47 @@ import androidx.annotation.Nullable;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.KeepAliveConnection;
|
||||
import com.aoleyun.sn.base.BaseApplication;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.PackageNames;
|
||||
import com.aoleyun.sn.manager.AmapManager;
|
||||
import com.aoleyun.sn.network.HTTPInterface;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
import com.aoleyun.sn.network.api.newapi.GetLockStateApi;
|
||||
import com.aoleyun.sn.network.api.newapi.SendScreenStatusApi;
|
||||
import com.aoleyun.sn.receiver.BootReceiver;
|
||||
import com.aoleyun.sn.receiver.NewAppReceiver;
|
||||
import com.aoleyun.sn.rlog.LogDBManager;
|
||||
import com.aoleyun.sn.service.main.MainService;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.SPUtils;
|
||||
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
||||
import com.aoleyun.sn.utils.ToastUtil;
|
||||
import com.aoleyun.sn.utils.Utils;
|
||||
import com.aoleyun.sn.utils.XAPKUtils;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.manager.AmapManager;
|
||||
import com.aoleyun.sn.network.HTTPInterface;
|
||||
import com.aoleyun.sn.network.api.newapi.GetLockStateApi;
|
||||
import com.aoleyun.sn.receiver.BootReceiver;
|
||||
import com.aoleyun.sn.receiver.NewAppReceiver;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.SPUtils;
|
||||
import com.aoleyun.sn.utils.XAPKUtils;
|
||||
import com.aoleyun.sn.KeepAliveConnection;
|
||||
import com.aoleyun.sn.base.BaseApplication;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
||||
import com.aoleyun.sn.utils.ToastUtil;
|
||||
import com.aoleyun.sn.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
|
||||
@@ -247,29 +247,17 @@ public class GuardService extends Service {
|
||||
aMapLocationClient.stopLocation();
|
||||
aMapLocationClient.startLocation();
|
||||
getLockState("2", String.valueOf(time));
|
||||
// if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
||||
// String statusbarStatus = "qch_hide_statusBar";
|
||||
// Intent navIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||
// context.sendBroadcast(navIntent);
|
||||
// }
|
||||
sendScreenStatus(1);
|
||||
}
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_OFF: {
|
||||
HTTPInterface.getAppLimit(GuardService.this);
|
||||
// HTTPInterface.getAppLimit(GuardService.this);
|
||||
long time = System.currentTimeMillis();
|
||||
getLockState("1", String.valueOf(time));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
intent1.setComponent(new ComponentName(PackageNames.APPSTORE, PackageNames.APP_STORE_BOOTRECEIVER));
|
||||
sendBroadcast(intent1);
|
||||
JGYUtils.getInstance().wakeUpAppstore();
|
||||
JGYUtils.getInstance().deleteScreenshots();
|
||||
}
|
||||
// if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
||||
// String statusbarStatus = "qch_show_statusBar";
|
||||
// Intent navIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||
// context.sendBroadcast(navIntent);
|
||||
// }
|
||||
sendScreenStatus(2);
|
||||
}
|
||||
break;
|
||||
@@ -322,7 +310,7 @@ public class GuardService extends Service {
|
||||
.client(NetInterfaceManager.getInstance().getOkHttpClient())
|
||||
.baseUrl(BuildConfig.SCREEN_BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||
.build();
|
||||
SendScreenStatusApi sendScreenStatusApi = retrofit.create(SendScreenStatusApi.class);
|
||||
sendScreenStatusApi.sendScreenStatus(NetInterfaceManager.HTTP_KEY, Utils.getSerial(), status)
|
||||
@@ -355,8 +343,9 @@ public class GuardService extends Service {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
return;
|
||||
}
|
||||
GetLockStateApi getLockState = NetInterfaceManager.getInstance().getLockState();
|
||||
getLockState.getLockState(Utils.getSerial(), status, time)
|
||||
NetInterfaceManager.getInstance()
|
||||
.getLockState()
|
||||
.getLockState(Utils.getSerial(), status, time)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
|
||||
@@ -25,10 +25,10 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.aoleyun.sn.service.main;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.aoleyun.sn.base.BasePresenter;
|
||||
@@ -9,12 +8,10 @@ import com.google.gson.JsonObject;
|
||||
|
||||
public class MainSContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
//设置二维码
|
||||
void getQRImage(String mac);
|
||||
//获取学生信息
|
||||
void getStudesInfo();
|
||||
//获取设备锁定状态
|
||||
void getLockedState();
|
||||
void getLockedState(String key);
|
||||
//是否第一次联网
|
||||
void getFirstConnect();
|
||||
//关闭所有功能
|
||||
@@ -27,7 +24,7 @@ public class MainSContact {
|
||||
void getSnTimeControl();
|
||||
//获取电子书包激活码
|
||||
void getEBagCode();
|
||||
//设置击关推送别名
|
||||
//设置极光推送别名
|
||||
void setJpushAlias();
|
||||
//设置极光推送平台标签
|
||||
void setJpushPlatformTags(int platform);
|
||||
@@ -96,18 +93,6 @@ public class MainSContact {
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
//获取二维码
|
||||
void setQRImage(Bitmap qrImage);
|
||||
//设置批次信息
|
||||
void setBatchText(String text, int visibility);
|
||||
//设置班级信息
|
||||
void setClassText(String text, int visibility);
|
||||
//设置学号信息
|
||||
void setNumberText(String text, int visibility);
|
||||
//设置姓名信息
|
||||
void setNameText(String text, int visibility);
|
||||
//设置头像
|
||||
void setHead(String url);
|
||||
//获取设备锁定状态
|
||||
void setLockedState(boolean loocked);
|
||||
//是否第一次联网
|
||||
@@ -120,7 +105,7 @@ public class MainSContact {
|
||||
void getSnTimeControlFinish();
|
||||
//获取电子书包激活码
|
||||
void getEBagCodeFinish();
|
||||
//设置击关推送别名
|
||||
//设置极光推送别名
|
||||
void setAliasFinish();
|
||||
//设置极光推送平台标签
|
||||
void setJpushPlatformTagsFinish();
|
||||
|
||||
@@ -48,8 +48,8 @@ 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.rxlifecycle2.LifecycleProvider;
|
||||
import com.trello.rxlifecycle2.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -58,11 +58,12 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
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;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
|
||||
@@ -77,6 +78,8 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
private static final String TAG = MainSPresenter.class.getSimpleName();
|
||||
private MainSContact.MainView mView;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
|
||||
public static final String GET_SETTING_FINISH_TIME = "GET_SETTING_FINISH_TIME";
|
||||
|
||||
@@ -85,14 +88,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
private final String DEFAULT_INFO = "暂无信息";
|
||||
private final int OK = 200;
|
||||
|
||||
private LifecycleProvider<ActivityEvent> provider;
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
public void setProvider(LifecycleProvider<ActivityEvent> provider) {
|
||||
this.provider = provider;
|
||||
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public LifecycleProvider<ActivityEvent> getProvider() {
|
||||
return provider;
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
public MainSPresenter(Context context) {
|
||||
@@ -114,35 +117,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
String key = "0123456789ABCDEF";
|
||||
|
||||
@Override
|
||||
public void getQRImage(String mac) {
|
||||
Log.e(TAG, "getQRImage: " + mac);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("sn", Utils.getSerial());
|
||||
jsonObject.addProperty("mac", mac);
|
||||
String json = jsonObject.toString();
|
||||
String content = mac;
|
||||
try {
|
||||
content = CXAESUtil.encrypt(key, json);
|
||||
Log.e(TAG, "getQRImage: " + content);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getQRImage: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
mView.setQRImage(JGYUtils.getInstance().createQRImage(content, 300, 300));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过sn获取用户信息
|
||||
*/
|
||||
@Override
|
||||
public void getStudesInfo() {
|
||||
setState();
|
||||
NetInterfaceManager.getInstance()
|
||||
.getStudesInfoObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<StudentsInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -160,38 +142,28 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
String batch = studentsInfoBaseResponse.data.getBatch();
|
||||
String head_img = studentsInfoBaseResponse.data.getHead_img();
|
||||
if (TextUtils.isEmpty(sno)) {
|
||||
mView.setNumberText("", View.GONE);
|
||||
SPUtils.put(mContext, CommonConfig.STUDENT_ID, DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setNumberText(sno, View.VISIBLE);
|
||||
SPUtils.put(mContext, CommonConfig.STUDENT_ID, sno);
|
||||
}
|
||||
if (TextUtils.isEmpty(realname)) {
|
||||
mView.setNameText("", View.GONE);
|
||||
SPUtils.put(mContext, CommonConfig.REALNAME, DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setNameText(realname, View.VISIBLE);
|
||||
SPUtils.put(mContext, CommonConfig.REALNAME, realname);
|
||||
}
|
||||
if (TextUtils.isEmpty(classes)) {
|
||||
mView.setClassText("", View.GONE);
|
||||
SPUtils.put(mContext, CommonConfig.CLASS_NAME, DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setClassText(classes, View.VISIBLE);
|
||||
SPUtils.put(mContext, CommonConfig.CLASS_NAME, classes);
|
||||
}
|
||||
if (TextUtils.isEmpty(batch)) {
|
||||
mView.setBatchText("", View.GONE);
|
||||
SPUtils.put(mContext, CommonConfig.BATCH_NAME, DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setBatchText(batch, View.VISIBLE);
|
||||
SPUtils.put(mContext, CommonConfig.BATCH_NAME, batch);
|
||||
}
|
||||
if (TextUtils.isEmpty(head_img)) {
|
||||
mView.setHead("");
|
||||
SPUtils.put(mContext, CommonConfig.HEAD_IMG, "");
|
||||
} else {
|
||||
mView.setHead(head_img);
|
||||
SPUtils.put(mContext, CommonConfig.HEAD_IMG, head_img);
|
||||
}
|
||||
|
||||
@@ -207,76 +179,21 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG + ":" + "getStudesInfo", "onError: " + e.getMessage());
|
||||
setState();
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
//如果是解锁状态就隐藏,锁定就显示缓存
|
||||
if (Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, 0) == 1) {
|
||||
mView.setNumberText("", View.GONE);
|
||||
mView.setNameText("", View.GONE);
|
||||
mView.setClassText("", View.GONE);
|
||||
mView.setBatchText("", View.GONE);
|
||||
}
|
||||
Log.e(TAG + ":" + "getStudesInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setState() {
|
||||
String batch = (String) SPUtils.get(mContext, CommonConfig.BATCH_NAME, DEFAULT_INFO);
|
||||
if (TextUtils.isEmpty(batch) || batch.equalsIgnoreCase(DEFAULT_INFO)) {
|
||||
mView.setBatchText("", View.GONE);
|
||||
} else {
|
||||
mView.setBatchText(batch, View.VISIBLE);
|
||||
}
|
||||
|
||||
String classes = (String) SPUtils.get(mContext, CommonConfig.CLASS_NAME, DEFAULT_INFO);
|
||||
if (TextUtils.isEmpty(classes) || classes.equalsIgnoreCase(DEFAULT_INFO)) {
|
||||
mView.setClassText("", View.GONE);
|
||||
} else {
|
||||
mView.setClassText(classes, View.VISIBLE);
|
||||
}
|
||||
|
||||
String sno = (String) SPUtils.get(mContext, CommonConfig.STUDENT_ID, DEFAULT_INFO);
|
||||
if (TextUtils.isEmpty(sno) || sno.equalsIgnoreCase(DEFAULT_INFO)) {
|
||||
mView.setNumberText("", View.GONE);
|
||||
} else {
|
||||
mView.setNumberText(sno, View.VISIBLE);
|
||||
}
|
||||
String realname = (String) SPUtils.get(mContext, CommonConfig.REALNAME, DEFAULT_INFO);
|
||||
if (TextUtils.isEmpty(realname) || realname.equalsIgnoreCase(DEFAULT_INFO)) {
|
||||
mView.setNameText("", View.GONE);
|
||||
} else {
|
||||
mView.setNameText(realname, View.VISIBLE);
|
||||
}
|
||||
String head_img = (String) SPUtils.get(mContext, CommonConfig.HEAD_IMG, DEFAULT_INFO);
|
||||
if (TextUtils.isEmpty(head_img) || head_img.equalsIgnoreCase(DEFAULT_INFO)) {
|
||||
mView.setHead("");
|
||||
} else {
|
||||
mView.setHead(head_img);
|
||||
}
|
||||
}
|
||||
|
||||
private long lastgetLockedTime;
|
||||
private long one_minute = 1000 * 60;
|
||||
|
||||
@Override
|
||||
public void getLockedState() {
|
||||
MMKV mmkv = MMKV.defaultMMKV();
|
||||
lastgetLockedTime = mmkv.decodeLong(MainSPresenter.GET_SETTING_FINISH_TIME);
|
||||
Log.e(TAG, "getLockedState: " + lastgetLockedTime);
|
||||
if (System.currentTimeMillis() - lastgetLockedTime < one_minute) {
|
||||
Log.e(TAG, "getLockedState: lastgetLockedTime = " + lastgetLockedTime);
|
||||
return;
|
||||
}
|
||||
|
||||
// lastgetLockedTime = System.currentTimeMillis();
|
||||
public void getLockedState(String key) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getDevicesLockedStateObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -285,6 +202,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse response) {
|
||||
mMMKV.encode(key, System.currentTimeMillis());
|
||||
requestSucceeded = true;
|
||||
Log.e(TAG + ":" + "getLockedState", "onNext: " + JSONObject.toJSONString(response));
|
||||
if (response.code == OK) {
|
||||
@@ -302,7 +220,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, 0);
|
||||
} else {
|
||||
// SysSettingUtils.setEnableSetting(mContext);
|
||||
Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, 1);
|
||||
}
|
||||
mView.setLockedState(locked == 1);
|
||||
@@ -326,7 +243,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
Log.e(TAG + ":" + "getLockedState", "onComplete: ");
|
||||
}
|
||||
});
|
||||
// lastgetLockedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +283,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
NetInterfaceManager.getInstance()
|
||||
.sendMACAddressObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -406,57 +322,27 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
mView.updateDeviceInfoFinish();
|
||||
return;
|
||||
}
|
||||
updateDevicesInfo(mContext);
|
||||
mView.updateDeviceInfoFinish();
|
||||
}
|
||||
NetInterfaceManager.getInstance().updateDeviceInfo(new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
synchronized private void updateDevicesInfo(Context context) {
|
||||
String address = String.valueOf(SPUtils.get(context, "AmapAddress", "-"));
|
||||
if ("-".equals(address)) {
|
||||
address = (String) SPUtils.get(context, "AmapError", "-");
|
||||
}
|
||||
String longitude = String.valueOf(SPUtils.get(context, "longitude", "0"));
|
||||
String latitude = String.valueOf(SPUtils.get(context, "latitude", "0"));
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("address", address);
|
||||
jsonObject.addProperty("longitude", longitude);
|
||||
jsonObject.addProperty("latitude", latitude);
|
||||
String add = jsonObject.toString();
|
||||
Log.e(TAG, "updateDevicesInfo: " + add);
|
||||
NetInterfaceManager.getInstance().getUpdateDeviceInfo()
|
||||
.updateDeviceInfo(
|
||||
Utils.getSerial(),
|
||||
NetInterfaceManager.HTTP_KEY,
|
||||
Utils.getMachine(context),
|
||||
Utils.getHardware(context),
|
||||
add)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e(TAG + ":" + "updateDevicesInfo", "onSubscribe: ");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
requestSucceeded = true;
|
||||
Log.e(TAG + ":" + "updateDevicesInfo", "onNext: " + baseResponse);
|
||||
}
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
requestSucceeded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG + ":" + "updateDevicesInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":" + "updateDevicesInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.updateDeviceInfoFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -467,7 +353,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnTimeObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -518,7 +404,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getEBagCode() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getEBagCodeControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -555,30 +441,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setJpushAlias() {
|
||||
// JPushInterface.init(mContext);
|
||||
// SetAlias();
|
||||
// String rid = JPushInterface.getRegistrationID(mContext);
|
||||
// if (!TextUtils.isEmpty(rid)) {
|
||||
// Log.e(TAG + ":" + "setJpushAlias", "RegId:" + rid);
|
||||
// }
|
||||
// JPushInterface.getAlias(mContext, new Random().nextInt(100));
|
||||
mView.setAliasFinish();
|
||||
}
|
||||
|
||||
// private void SetAlias() {
|
||||
// TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||
// tagAliasBean.action = ACTION_SET;
|
||||
// sequence++;
|
||||
// tagAliasBean.alias = Utils.getSerial();
|
||||
// tagAliasBean.isAliasAction = true;
|
||||
// TagAliasOperatorHelper.getInstance().handleAction(mContext, sequence, tagAliasBean);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setPushTags() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getJpushTagsObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -648,15 +518,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
mView.setJpushPlatformTagsFinish();
|
||||
}
|
||||
|
||||
// private void setTag(Set set) {
|
||||
// TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||
// tagAliasBean.action = ACTION_SET;
|
||||
// sequence++;
|
||||
// tagAliasBean.tags = set;
|
||||
// tagAliasBean.isAliasAction = false;
|
||||
// TagAliasOperatorHelper.getInstance().handleAction(mContext, sequence, tagAliasBean);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void checkStoreUpdate() {
|
||||
checkUpdateStore();
|
||||
@@ -669,7 +530,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -712,7 +573,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -753,7 +614,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -794,7 +655,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -835,7 +696,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -868,68 +729,9 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
long buttonCheckUpdateTime = 0;
|
||||
|
||||
@Override
|
||||
public void buttonCheckUpdate(View view) {
|
||||
// if ((System.currentTimeMillis() - buttonCheckUpdateTime) < 10000) {
|
||||
// buttonCheckUpdateTime = System.currentTimeMillis();
|
||||
// ToastUtil.show("正在检查更新");
|
||||
// } else {
|
||||
// ToastUtil.show("你已经过检查,请稍后再来");
|
||||
// }
|
||||
checkUpdateInfo();
|
||||
}
|
||||
|
||||
private void checkUpdateInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getUpdateApi()
|
||||
.getUpdate(BuildConfig.APPLICATION_ID,
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e(TAG + ":" + "checkUpdateInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse response) {
|
||||
requestSucceeded = true;
|
||||
Log.e(TAG + ":" + "checkUpdateInfo", "onNext: " + response);
|
||||
if (response.code == OK) {
|
||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
||||
long versionCode = jsonObject.get("version_code").getAsLong();
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = pm.getPackageInfo(BuildConfig.APPLICATION_ID, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null == info || info.versionCode < versionCode) {
|
||||
mView.buttonCheckUpdateFinish(true, jsonObject);
|
||||
} else {
|
||||
mView.buttonCheckUpdateFinish(false, null);
|
||||
}
|
||||
} else {
|
||||
mView.buttonCheckUpdateFinish(false, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG + ":" + "checkUpdateInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":" + "checkUpdateInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -939,7 +741,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void checkTestUpdate() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getTestUpdateObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ForceDownloadData>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -985,7 +787,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getAppLimit() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppLimitObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1037,60 +839,11 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getDeviceBatch(String packageList) {
|
||||
// if (JGYUtils.isOfficialVersion() || TextUtils.isEmpty(packageList)) {
|
||||
// mView.getDeviceBatchFinished();
|
||||
// return;
|
||||
// }
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, 0);
|
||||
Log.e(TAG, "getDeviceBatch: " + locked);
|
||||
if (locked == 0) {
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getBatchObservable()
|
||||
// .observeOn(Schedulers.io())
|
||||
// .subscribe(new Observer<ResponseBody>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull ResponseBody responseBody) {
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "onNext: ");
|
||||
// try {
|
||||
// String respons = responseBody.string();
|
||||
// JSONObject jsonObject = JSON.parseObject(respons);
|
||||
// int code = jsonObject.getInteger("code");
|
||||
// if (code == OK) {
|
||||
// String data = jsonObject.getString("data");
|
||||
// List<Batch> batchList = JSON.parseArray(data, Batch.class);
|
||||
// if (null != batchList && batchList.size() > 1) {
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "onNext: " + "deleteOtherApp");
|
||||
// if (!BuildConfig.DEBUG) {
|
||||
JGYUtils.getInstance().deleteOtherApp();
|
||||
// }
|
||||
// } else {
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "批次为空");
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "onNext: respons:" + respons);
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e(TAG+":"+"getDeviceBatch", "onComplete: ");
|
||||
mView.getDeviceBatchFinish();
|
||||
// }
|
||||
// });
|
||||
// mView.getDeviceBatchFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1098,7 +851,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getForceDownload() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getForceDownloadObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<ForceDownloadBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1147,286 +900,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2021/6/8 使用现有代码会影响浏览器主页管控
|
||||
// @Override
|
||||
// public void getBrowserList() {
|
||||
//// if (JGYUtils.isOfficialVersion()) {
|
||||
// SetBrowserList();
|
||||
//// } else {
|
||||
//// NewSetBrowserList();
|
||||
//// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void getBrowserList() {
|
||||
// NetInterfaceManager.getInstance()
|
||||
//// .getBrowserListSettingObservable()
|
||||
//// .observeOn(Schedulers.io())
|
||||
//// .subscribe(new Observer<BaseResponse<BrowserData>>() {
|
||||
//// @Override
|
||||
//// public void onSubscribe(@NonNull Disposable d) {
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "onSubscribe: ");
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "onNext: ");
|
||||
//// if (browserDataBaseResponse.code == OK) {
|
||||
//// String white = browserDataBaseResponse.data.getWhite();
|
||||
////
|
||||
//// if (!TextUtils.isEmpty(white)) {
|
||||
//// String homePage = Settings.System.getString(mContext.getContentResolver(), "homepagURL");
|
||||
//// if (!TextUtils.isEmpty(homePage) && !white.contains(homePage)) {
|
||||
//// white += "," + homePage;
|
||||
//// }
|
||||
//// boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
//// mView.getBrowserListFinished(white);
|
||||
//// } else {
|
||||
//// Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
//// mView.getBrowserListFinished("");
|
||||
//// }
|
||||
//// String black = browserDataBaseResponse.data.getBlack();
|
||||
//// if (!TextUtils.isEmpty(black)) {
|
||||
//// boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", black);
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "setBrowserList black: " + black + ":" + blackList);
|
||||
//// } else {
|
||||
//// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
//// }
|
||||
//// } else {
|
||||
//// mView.getBrowserListFinished("");
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void onError(@NonNull Throwable e) {
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "onError: " + e.getMessage());
|
||||
//// String whiteURLList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "whiteURLList: " + whiteURLList);
|
||||
//// mView.getBrowserListFinished(whiteURLList);
|
||||
//// onComplete();
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void onComplete() {
|
||||
//// Log.e(TAG + ":" + "getBrowserList", "onComplete: ");
|
||||
//// }
|
||||
//// });
|
||||
// //获取书签后会获取黑白名单
|
||||
Log.e(TAG, "getBrowserList: ");
|
||||
mView.getBrowserListFinish("");
|
||||
}
|
||||
|
||||
// private void NewSetBrowserList() {
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getBrowserListSettingObservable()
|
||||
// .observeOn(Schedulers.io())
|
||||
// .compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<BrowserData>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e(TAG + ":" + "NewSetBrowserList", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
|
||||
// Log.e(TAG + ":" + "NewSetBrowserList", "onNext: ");
|
||||
// if (browserDataBaseResponse.code == OK) {
|
||||
// String white = browserDataBaseResponse.data.getWhite();
|
||||
// String black = browserDataBaseResponse.data.getBlack();
|
||||
// if (!TextUtils.isEmpty(white) && !TextUtils.isEmpty(black)) {
|
||||
// Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
// Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", " ");
|
||||
// //黑白名单同时存在时由以前的逻辑管控
|
||||
// boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
|
||||
// Log.e(TAG + ":" + "setBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
// boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", black);
|
||||
// Log.e(TAG + ":" + "setBrowserList", "setBrowserList black: " + black + ":" + blackList);
|
||||
// mView.getBrowserListFinished(white);
|
||||
// } else if (TextUtils.isEmpty(white)) {
|
||||
// //设置黑名单
|
||||
// Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 1);
|
||||
// Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", black);
|
||||
// //白名单为空由新的管控执行
|
||||
// mView.getBrowserListFinished("");
|
||||
// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
// } else if (TextUtils.isEmpty(black)) {
|
||||
// Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
// Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", " ");
|
||||
// //黑名单为空由旧的管控执行
|
||||
// mView.getBrowserListFinished(white);
|
||||
// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
// }
|
||||
// } else {
|
||||
// //所有置空
|
||||
// Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
// Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", " ");
|
||||
// mView.getBrowserListFinished("");
|
||||
// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e(TAG + ":" + "NewSetBrowserList", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e(TAG + ":" + "NewSetBrowserList", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private void SetBrowserList() {
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getBrowserListSettingObservable()
|
||||
// .observeOn(Schedulers.io())
|
||||
// .compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<BrowserData>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
|
||||
// Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "onNext: ");
|
||||
// if (browserDataBaseResponse.code == OK) {
|
||||
// //白名单
|
||||
// String white = browserDataBaseResponse.data.getWhite();
|
||||
// if (!TextUtils.isEmpty(white)) {
|
||||
// String homePage = Settings.System.getString(mContext.getContentResolver(), "homepagURL");
|
||||
// if (!TextUtils.isEmpty(homePage) && !white.contains(homePage)) {
|
||||
// white += "," + homePage;
|
||||
// }
|
||||
// boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "setBrowserList white: " + white + " :" + whiteList);
|
||||
// String black = Settings.System.getString(mContext.getContentResolver(), "qch_webblack_url");
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "getBrowserList black: " + black);
|
||||
// mView.getBrowserListFinished(white);
|
||||
// } else {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
// mView.getBrowserListFinished("");
|
||||
// }
|
||||
// //黑名单
|
||||
// String black = browserDataBaseResponse.data.getBlack();
|
||||
// if (!TextUtils.isEmpty(black)) {
|
||||
// boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", black);
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "setBrowserList black: " + black + " :" + blackList);
|
||||
// String whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "getBrowserList white: " + whiteList);
|
||||
// } else {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
// }
|
||||
// } else {
|
||||
// mView.getBrowserListFinished("");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "onError: " + e.getMessage());
|
||||
// String whiteURLList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "whiteURLList: " + whiteURLList);
|
||||
// mView.getBrowserListFinished(whiteURLList);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e(TAG + ":" + "SetBrowserList", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void getBrowserBookmarks(String whitelist) {
|
||||
// Log.e(TAG, "getBrowserBookmarks: " + "whitelist: " + whitelist);
|
||||
// List<String> whiteLists = Arrays.asList(whitelist.split(","));
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getBrowserBookmarksObservable()
|
||||
// .observeOn(Schedulers.io())
|
||||
// .subscribe(new Observer<BaseResponse<BrowserBookmarks>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e(TAG+":"+"getBrowserBookmarks", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<BrowserBookmarks> browserBookmarksBaseResponse) {
|
||||
// Log.e(TAG+":"+"getBrowserBookmarks", "onNext: ");
|
||||
// StringBuilder whiteString = new StringBuilder(whitelist);
|
||||
// if (browserBookmarksBaseResponse.code == OK) {
|
||||
// //主页不包含白名单添加进去
|
||||
// String homepagURL = browserBookmarksBaseResponse.data.getHomepage();
|
||||
//// boolean home = Settings.System.putString(mContext.getContentResolver(), "homepagURL", homepagURL);
|
||||
//// Log.e(TAG+":"+"getBrowserBookmarks", "onNext: homepagURL: save homepagURL = " + homepagURL);
|
||||
// if (whiteLists.size() <= 0 || !whiteLists.contains(homepagURL)) {
|
||||
// whiteString.append(",").append(homepagURL);
|
||||
// Log.e(TAG+":"+"getBrowserBookmarks ", "homepagURL: " + homepagURL);
|
||||
// boolean white = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", whiteString.toString());
|
||||
// Log.e(TAG+":"+"getBrowserBookmarks", "onNext: homepagURL: add to whiteList = " + whiteString + "write: " + white);
|
||||
// }
|
||||
// //主页
|
||||
// Intent homepag = new Intent("qch_app_brower_homepage");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// homepag.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(homepagURL)) {
|
||||
// homepag.putExtra("homepage", homepagURL);
|
||||
// } else {
|
||||
// homepag.putExtra("homepage", "Invalid");
|
||||
// }
|
||||
// mContext.sendBroadcast(homepag);
|
||||
//
|
||||
// //书签
|
||||
// String labelpage = browserBookmarksBaseResponse.data.getLabelpage();
|
||||
// Intent websiteBookMark = new Intent("qch_app_brower_website");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// websiteBookMark.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(labelpage)) {
|
||||
// websiteBookMark.putExtra("websiteBookMark", labelpage);
|
||||
// } else {
|
||||
// websiteBookMark.putExtra("websiteBookMark", "Invalid");
|
||||
// }
|
||||
// mContext.sendBroadcast(websiteBookMark);
|
||||
// } else {
|
||||
// Intent intent1 = new Intent("qch_app_brower_homepage");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// intent1.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// intent1.putExtra("homepage", "Invalid");
|
||||
// mContext.sendBroadcast(intent1);
|
||||
//
|
||||
// Settings.System.putString(mContext.getContentResolver(), "homepagURL", "");
|
||||
// Intent intent2 = new Intent("qch_app_brower_website");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// intent2.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// intent2.putExtra("websiteBookMark", "Invalid");
|
||||
// mContext.sendBroadcast(intent2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e(TAG+":"+"getBrowserBookmarks", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e(TAG+":"+"getBrowserBookmarks", "onComplete: ");
|
||||
// mView.getBrowserBookmarksFinished();
|
||||
// }
|
||||
// });
|
||||
HTTPInterface.getHomePageBookmarks(mContext, new HTTPInterface.BookmarksCallback() {
|
||||
@Override
|
||||
public void onSubscribe() {
|
||||
@@ -1447,15 +928,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":" + "getBrowserBookmarks", "onComplete: ");
|
||||
// String homepagURL = Settings.System.getString(mContext.getContentResolver(), "homepagURL");
|
||||
// HashSet<String> hashSet = new HashSet<>(Arrays.asList(whitelist.split(",")));
|
||||
// hashSet.add(homepagURL);
|
||||
// String DeselectBrowserArray = String.join(",", hashSet);
|
||||
// if (Utils.isEmpty(DeselectBrowserArray)) {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
// } else {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", DeselectBrowserArray);
|
||||
// }
|
||||
if (mView != null) {
|
||||
mView.getBrowserBookmarksFinish();
|
||||
}
|
||||
@@ -1487,7 +959,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getDesktopIconObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1551,7 +1023,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
.getAppAutoStartUpdateAndNetObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<NetAndLaunchBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1588,7 +1060,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppIDControlObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1657,7 +1129,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSystemSettingObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1715,7 +1187,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getDefaultApp() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getDefaultAppApi()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<DefaultApp>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -1760,7 +1232,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
.getROMApp(NetInterfaceManager.HTTP_KEY, customVersion)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -1800,7 +1272,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getDeveloper() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getDeveloperControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -1848,7 +1320,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getLogoImgObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<LogoImg>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1898,7 +1370,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getTopAppControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -1953,7 +1425,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getScreenLockObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -2002,7 +1474,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getDesktopObservable()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -2058,7 +1530,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getPoweroffTime() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getPoweroffTimeControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<PoweroffBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -2067,14 +1539,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<List<PoweroffBean>> listBaseResponse) {
|
||||
requestSucceeded = true;
|
||||
Log.e("getPoweroffTime", "onNext: " + listBaseResponse);
|
||||
MMKV mmkv = MMKV.defaultMMKV();
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<PoweroffBean> poweroffBeanList = listBaseResponse.data;
|
||||
String poweroffTime = new Gson().toJson(poweroffBeanList);
|
||||
mmkv.encode("poweroffTime", poweroffTime);
|
||||
mMMKV.encode("poweroffTime", poweroffTime);
|
||||
} else {
|
||||
mmkv.encode("PoweroffTime", "");
|
||||
mMMKV.encode("PoweroffTime", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2095,7 +1567,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getWiFiPasswd() {
|
||||
NetInterfaceManager.getInstance().getWiFiControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<WiFiAlias>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -2107,11 +1579,11 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
Log.e("getWiFiPasswd", "onNext: ");
|
||||
if (listBaseResponse.code == 200) {
|
||||
WiFiUtils.saveWiFiPasswd(listBaseResponse.data);
|
||||
MMKV.defaultMMKV().encode("WiFiPassword", JsonParser.parseString(new Gson().toJson(listBaseResponse.data)).toString());
|
||||
mMMKV.encode("WiFiPassword", JsonParser.parseString(new Gson().toJson(listBaseResponse.data)).toString());
|
||||
} else {
|
||||
Log.e("getWiFiPasswd", "onNext: msg = " + listBaseResponse.msg);
|
||||
WiFiUtils.saveWiFiPasswd(listBaseResponse.data);
|
||||
MMKV.defaultMMKV().encode("WiFiPassword", "");
|
||||
mMMKV.encode("WiFiPassword", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.aoleyun.sn.bean.PoweroffBean;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.comm.PackageNames;
|
||||
import com.aoleyun.sn.manager.ConnectManager;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
import com.aoleyun.sn.receiver.BootReceiver;
|
||||
import com.aoleyun.sn.rlog.LogDBManager;
|
||||
@@ -59,11 +60,11 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle2.LifecycleProvider;
|
||||
import com.trello.rxlifecycle2.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle2.RxLifecycle;
|
||||
import com.trello.rxlifecycle2.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -73,17 +74,19 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.subjects.BehaviorSubject;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class MainService extends Service implements MainSContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
|
||||
private static final String TAG = MainService.class.getSimpleName();
|
||||
private String connectKey;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static MainSPresenter mPresenter;
|
||||
private static final String TAG = MainService.class.getSimpleName();
|
||||
public static boolean netWorkIsRunning = false;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
@@ -96,9 +99,33 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
ToastUtil.betaShow("网络已连接");
|
||||
Log.e("OnNetworkStatusChanged", "onConnected: " + Utils.getWifiAlias(this));
|
||||
start.onstar(SystemClock.elapsedRealtime());
|
||||
String WiFiAlias = Utils.getWifiAlias(this);
|
||||
Log.e("OnNetworkStatusChanged", "onConnected: " + WiFiAlias);
|
||||
Utils.getPublicIP(this);
|
||||
if (ConnectManager.getInstance().isWiFiFistConnect()) {
|
||||
start.onstar(ConnectManager.WIFI_LAST_CONNECT_TIME);
|
||||
} else {
|
||||
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(WiFiAlias)) {
|
||||
start.onstar(WiFiAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
@Override
|
||||
public Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LifecycleTransformer<T> bindUntilEvent(ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
private WifiReceiver mWifiReceiver;
|
||||
@@ -134,7 +161,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
|
||||
Log.e(TAG, "wifi断开");
|
||||
LogDBManager.getInstance().creatNetChangeLog("wifi断开", Utils.transferLongToDate(System.currentTimeMillis()));
|
||||
LogDBManager.getInstance().creatNetChangeLog("wifi断开", TimeUtils.transferLongToDate(System.currentTimeMillis()));
|
||||
} else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
@@ -145,13 +172,14 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Log.e(TAG, "连接到网络 " + newSSID);
|
||||
if (!oldSSID.equals(newSSID)) {
|
||||
LogDBManager.getInstance().creatNetChangeLog("", oldSSID + " change to: " + newSSID);
|
||||
runningTime = SystemClock.elapsedRealtime();
|
||||
//直接获取数据
|
||||
mPresenter.getLockedState();
|
||||
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(newSSID)) {
|
||||
start.onstar(newSSID);
|
||||
}
|
||||
} else {
|
||||
LogDBManager.getInstance().creatNetChangeLog("接入WiFi",
|
||||
"connect to: " + newSSID + " time: "
|
||||
+ Utils.transferLongToDate(System.currentTimeMillis()));
|
||||
+ TimeUtils.transferLongToDate(System.currentTimeMillis()));
|
||||
}
|
||||
mMMKV.encode("WiFiSSID", Utils.getWifiAlias(context));
|
||||
}
|
||||
@@ -170,48 +198,32 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
}
|
||||
|
||||
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
@Override
|
||||
public Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LifecycleTransformer<T> bindUntilEvent(ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
private interface Start {
|
||||
void onstar(long time);
|
||||
void onstar(String key);
|
||||
}
|
||||
|
||||
private Start start;
|
||||
|
||||
private ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
|
||||
private ObservableOnSubscribe<String> subscribe = new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Long> emitter) throws Exception {
|
||||
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
start = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> timeObserver = new Observer<Long>() {
|
||||
private Observer<String> timeObserver = new Observer<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("TimeObserver", "onNext: " + aLong);
|
||||
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
public void onNext(String string) {
|
||||
connectKey = string;
|
||||
Log.e("TimeObserver", "onNext: " + string);
|
||||
mPresenter.getFirstConnect();
|
||||
mPresenter.getLockedState();
|
||||
mPresenter.getLockedState(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,10 +249,17 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.e(TAG, "onCreate: ");
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setProvider(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(1, TimeUnit.MINUTES)
|
||||
.subscribe(timeObserver);
|
||||
Observable.create(timeChangedSubscribe)
|
||||
.throttleFirst(3, TimeUnit.HOURS)
|
||||
.subscribe(timeChangedObserver);
|
||||
if ((int) SPUtils.get(this, CommonConfig.JGY_FIRST_CONNECT, 0) == 0) {
|
||||
// TODO: 2021/5/26 待底层修改,临时解决办法
|
||||
Log.e(TAG, "onCreate: " + "Disable All Settings");
|
||||
@@ -250,29 +269,29 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
if (oldVersionCode < BuildConfig.VERSION_CODE) {
|
||||
Log.e(TAG, "onCreate: " + "upgrade successful");
|
||||
} else {
|
||||
mPresenter.getFirstConnect();
|
||||
mPresenter.getLockedState();
|
||||
if (ConnectManager.getInstance().isRebootFistConnect()) {
|
||||
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
|
||||
}
|
||||
}
|
||||
SPUtils.put(this, CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
|
||||
registerReceivers();
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
addShortcut();
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(3, TimeUnit.HOURS)
|
||||
.subscribe(timeObserver);
|
||||
Observable.create(timeChangedSubscribe)
|
||||
.throttleFirst(3, TimeUnit.HOURS)
|
||||
.subscribe(timeChangedObserver);
|
||||
// cleanLauncherCache();
|
||||
timeChangedStart.onstar(System.currentTimeMillis());
|
||||
setStatusbar();
|
||||
//发送设备mac地址和信息
|
||||
mPresenter.sendMACAddress();
|
||||
setFloatingWindow(this);
|
||||
createNotificationChannel();
|
||||
sendSimpleNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
JGYUtils.getInstance().wakeUpAppstore();
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -282,24 +301,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
mPresenter.detachView();
|
||||
}
|
||||
|
||||
//执行所有请求的时间
|
||||
long runningTime;
|
||||
|
||||
//MainService上次执行时间
|
||||
long startCommandTime = 0;
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
bootIntent.setComponent(new ComponentName(PackageNames.APPSTORE, PackageNames.APP_STORE_BOOTRECEIVER));
|
||||
sendBroadcast(bootIntent);
|
||||
// mPresenter.getFirstConnect();
|
||||
// mPresenter.getLockedState();
|
||||
start.onstar(SystemClock.elapsedRealtime());
|
||||
Log.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime) + "ms");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void createNotificationChannel() {
|
||||
// Create the NotificationChannel, but only on API 26+ because
|
||||
// the NotificationChannel class is new and not in the support library
|
||||
@@ -703,36 +704,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQRImage(Bitmap qrImage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBatchText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNumberText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNameText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHead(String url) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockedState(boolean loocked) {
|
||||
Log.e(TAG, "netWorkIsRunning: " + netWorkIsRunning);
|
||||
@@ -865,7 +836,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
if (noTag) {
|
||||
Log.e(TAG, "setTagsFinished: " + "not set tag");
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime()) + " ms");
|
||||
} else {
|
||||
mPresenter.getSystemSettingbegin();
|
||||
}
|
||||
@@ -967,7 +938,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
public void setWiFiPasswd() {
|
||||
MMKV.defaultMMKV().encode(MainAPresenter.GET_SETTING_FINISH_TIME, System.currentTimeMillis());
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime()) + " ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user