version:zhanrui 6.3.3,MTK 2.3.3
fix: update:重置只请求一次接口,增加网络波动记录接口
This commit is contained in:
@@ -82,16 +82,16 @@ android {
|
||||
//酷比魔方
|
||||
cube {
|
||||
flavorDimensions "default"
|
||||
versionCode 71
|
||||
versionName "6.3.1"
|
||||
versionCode 73
|
||||
versionName "6.3.3"
|
||||
buildConfigField "String", "platform", '"ZhanRuiCube"'
|
||||
}
|
||||
|
||||
//MTK
|
||||
MTKnewly {
|
||||
flavorDimensions "default"
|
||||
versionCode 41
|
||||
versionName "2.3.1"
|
||||
versionCode 43
|
||||
versionName "2.3.3"
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ dependencies {
|
||||
|
||||
implementation 'com.squareup.moshi:moshi:1.9.3'
|
||||
//OkHttp
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
||||
//Retrofit
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
|
||||
@@ -84,6 +84,7 @@ import com.aoleyun.sn.network.api.post.GetUploadIsLogApi;
|
||||
import com.aoleyun.sn.network.api.post.GetUploadLogApi;
|
||||
import com.aoleyun.sn.network.api.post.MACAddressApi;
|
||||
import com.aoleyun.sn.network.api.post.NetAndLaunchApi;
|
||||
import com.aoleyun.sn.network.api.post.NetworkConnectApi;
|
||||
import com.aoleyun.sn.network.api.post.NewAppinsideWebApi;
|
||||
import com.aoleyun.sn.network.api.post.SendDownloadInfoApi;
|
||||
import com.aoleyun.sn.network.api.post.SendDownloadTimesApi;
|
||||
@@ -589,6 +590,13 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> GetNetworkConnectControl() {
|
||||
return mRetrofit.create(NetworkConnectApi.class)
|
||||
.sendNetwork(Utils.getSerial(mContext))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* API
|
||||
@@ -715,7 +723,7 @@ public class NetInterfaceManager {
|
||||
Type listType = new TypeToken<List<AppUpdateInfo>>() {
|
||||
}.getType();
|
||||
List<AppUpdateInfo> appUpdateInfos = gson.fromJson(jsonString, listType);
|
||||
if (appUpdateInfos!=null&&appUpdateInfos.size()!=0) {
|
||||
if (appUpdateInfos != null && appUpdateInfos.size() != 0) {
|
||||
for (AppUpdateInfo info : appUpdateInfos) {
|
||||
JsonObject jsonObject = parseString(new Gson().toJson(info)).getAsJsonObject();
|
||||
JGYUtils.getInstance().installAPK(jsonObject);
|
||||
@@ -938,7 +946,7 @@ public class NetInterfaceManager {
|
||||
public void onNext(@NonNull BaseResponse<List<ForceDownloadData>> forceDownloadBean) {
|
||||
Log.e("getForceDownload", "onNext: " + forceDownloadBean);
|
||||
if (forceDownloadBean.code == OK) {
|
||||
Log.e("getForceDownload", "onNext: getAsString: "+cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL_LIST) );
|
||||
Log.e("getForceDownload", "onNext: getAsString: " + cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL_LIST));
|
||||
List<ForceDownloadData> forceDownloadData = forceDownloadBean.data;
|
||||
cacheHelper.put(UrlAddress.GET_FORCE_INSTALL_LIST, GsonUtils.toJSONString(forceDownloadData));
|
||||
Aria.download(this).resumeAllTask();
|
||||
@@ -1835,6 +1843,7 @@ public class NetInterfaceManager {
|
||||
}.getType();
|
||||
StudentsInfo studentsInfo = gson.fromJson(jsonString, Type);
|
||||
studesInfoListener.setStudentsInfo(studentsInfo);
|
||||
studesInfoListener.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2023,7 +2032,7 @@ public class NetInterfaceManager {
|
||||
if (jsonString == null) {
|
||||
setPushTags(lifecycle, callback);
|
||||
} else {
|
||||
Set tagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_TAG);
|
||||
Set tagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_TAG + "pushset");
|
||||
Log.e("setPushTags", "tagSets: " + tagSets);
|
||||
clearAndAppendTags(tagSets);
|
||||
callback.onComplete();
|
||||
@@ -2074,7 +2083,7 @@ public class NetInterfaceManager {
|
||||
cacheHelper.put(UrlAddress.GET_DEVICES_TAGS, "");
|
||||
Log.e(TAG + ":" + "setPushTags", "onNext: " + response.toString());
|
||||
}
|
||||
mMMKV.encode(CommonConfig.DEVICES_TAG, set);
|
||||
mMMKV.encode(CommonConfig.DEVICES_TAG + "pushset", set);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,6 +70,9 @@ public class UrlAddress {
|
||||
public static final String GET_LOCK_SCREEN_STATE = "Sn/getSnScreen";
|
||||
/*上传电池信息*/
|
||||
public static final String SEND_BATTERY_INFO = "And/sn/updateBatteryInfo";
|
||||
public static final String NETWORK_CONNECT = "And/network";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 系统策略相关
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.aoleyun.sn.network.api.post;
|
||||
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface NetworkConnectApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.NETWORK_CONNECT)
|
||||
Observable<BaseResponse> sendNetwork(
|
||||
@Field("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -168,6 +168,42 @@ public class GuardService extends Service {
|
||||
}
|
||||
};
|
||||
|
||||
private interface ResetStart {
|
||||
void onstar(long time);
|
||||
}
|
||||
|
||||
private ResetStart resetStart;
|
||||
|
||||
private ObservableOnSubscribe<Long> restSubscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Long> emitter) throws Exception {
|
||||
resetStart = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> resetObserver = new Observer<Long>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("restSubscribe", "onNext: " + aLong);
|
||||
sendRestoreTimes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@@ -181,6 +217,10 @@ public class GuardService extends Service {
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(10, TimeUnit.MINUTES)
|
||||
.subscribe(timeObserver);
|
||||
|
||||
Observable.create(restSubscribe)
|
||||
.throttleFirst(1, TimeUnit.MINUTES)
|
||||
.subscribe(resetObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,7 +342,7 @@ public class GuardService extends Service {
|
||||
case Intent.ACTION_MASTER_CLEAR:
|
||||
case Intent.ACTION_MASTER_CLEAR_NOTIFICATION:
|
||||
case "android.intent.action.FORCE_FACTORY_RESET":
|
||||
sendRestoreTimes();
|
||||
resetStart.onstar(System.currentTimeMillis());
|
||||
Log.e("PresentReceiver", "MASTER_CLEAR");
|
||||
// android.os.Process.killProcess(android.os.Process.myPid());
|
||||
// System.exit(0);
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.aoleyun.sn.base.BaseView;
|
||||
|
||||
public class MainSContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
|
||||
void sendNetwork();
|
||||
/*分支1*/
|
||||
/*获取设备锁定状态*/
|
||||
void getLockedState(String key);
|
||||
@@ -86,6 +86,7 @@ public class MainSContact {
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
void sendNetworkFinish();
|
||||
|
||||
/*获取设备锁定状态*/
|
||||
void setLockedState(boolean loocked);
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.bean.StudentsInfo;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
@@ -17,10 +18,14 @@ import com.aoleyun.sn.utils.URLUtils;
|
||||
import com.aoleyun.sn.utils.Utils;
|
||||
import com.arialyy.aria.orm.annotation.Ignore;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
@@ -76,6 +81,33 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
public long responseTime;
|
||||
|
||||
@Override
|
||||
public void sendNetwork() {
|
||||
NetInterfaceManager.getInstance().GetNetworkConnectControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("sendNetwork", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("sendNetwork", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("sendNetwork", "onError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendNetwork", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 1
|
||||
*/
|
||||
@@ -105,16 +137,11 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setPushTags() {
|
||||
NetInterfaceManager.getInstance().setPushTags(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Set tagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_TAG);
|
||||
Log.e("setPushTags", "onComplete: tagSets =" + tagSets);
|
||||
String tags = cacheHelper.getAsString(CommonConfig.DEVICES_TAG);
|
||||
Log.e("setPushTags", "onComplete: tags = " + tags);
|
||||
mView.setTagsFinish(tagSets == null || tagSets.size() < 2);
|
||||
}
|
||||
});
|
||||
Set tagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_TAG + "pushset");
|
||||
Log.e("setPushTags", "onComplete: tagSets =" + tagSets);
|
||||
String tags = cacheHelper.getAsString(CommonConfig.DEVICES_TAG);
|
||||
Log.e("setPushTags", "onComplete: tags = " + tags);
|
||||
mView.setTagsFinish(tagSets == null || tagSets.size() < 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +181,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setStudesInfo();
|
||||
// mView.setStudesInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -251,7 +278,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getDefaultDesktop() {
|
||||
Log.e(TAG, "getDefaultDesktop: " );
|
||||
Log.e(TAG, "getDefaultDesktop: ");
|
||||
if (JGYUtils.isOfficialVersion() || !JGYUtils.getInstance().getDeviceIsLocked()) {
|
||||
mView.getDefaultDesktopFinish();
|
||||
} else {
|
||||
|
||||
@@ -110,13 +110,16 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Utils.getPublicIP(this);
|
||||
TimeTask task = new TimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
mPresenter.getLockedState("onConnected");
|
||||
|
||||
if (mMMKV.decodeInt(CommonConfig.DEVICES_FRIST_START, 1) == 1) {
|
||||
mPresenter.sendNetwork();
|
||||
if (JGYUtils.getInstance().isScreenOn()) {
|
||||
mPresenter.getLockedState("onConnected");
|
||||
}
|
||||
// if (mMMKV.decodeInt(CommonConfig.DEVICES_FRIST_START, 1) == 1) {
|
||||
// Intent intent = new Intent(this, CheckNetActivity.class);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// startActivity(intent);
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private class TimeTask extends AsyncTask<String, Long, Long> {
|
||||
@@ -153,6 +156,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||
NetInterfaceManager.getInstance().setPushTags(false, lifecycleSubject, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,12 +176,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().setPushTags(false, lifecycleSubject, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
@@ -840,6 +843,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendNetworkFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockedState(boolean loocked) {
|
||||
Log.e(TAG, "setLockedState: " + loocked);
|
||||
|
||||
@@ -2364,4 +2364,10 @@ public class JGYUtils {
|
||||
public static boolean isCubeDevice() {
|
||||
return getHardware().startsWith(UNISOC_HARDWARE) && Build.BRAND.equalsIgnoreCase(CUBE_BRAND);
|
||||
}
|
||||
|
||||
public boolean isScreenOn() {
|
||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
//true为打开,false为关闭
|
||||
return powerManager.isInteractive();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user