[6.9.0]
[fea] [driver] [没有任务的情况下1分钟提示1次]
This commit is contained in:
@@ -3,6 +3,7 @@ package com.mogo.och.biz.time
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.commons.env.ProjectUtils
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OCHCOMMON
|
||||
import com.mogo.och.biz.time.bean.TimeRespBean
|
||||
@@ -12,6 +13,7 @@ import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
|
||||
/**
|
||||
@@ -46,6 +48,8 @@ class TimeProvider : TimeService {
|
||||
|
||||
private var netTime = Long.MAX_VALUE
|
||||
|
||||
private var nextGetTime: Disposable? = null
|
||||
|
||||
override fun loadNewTime() {
|
||||
OchChainLogManager.writeChainLogTime("时间同步", "开始时间同步")
|
||||
d(TAG, "时间同步_开始时间同步")
|
||||
@@ -59,12 +63,16 @@ class TimeProvider : TimeService {
|
||||
var delay = 0L
|
||||
data?.data?.let { T3 ->
|
||||
delay = (T4 - T1) / 2
|
||||
val currentNetTime = (T4-T1)
|
||||
if(currentNetTime>netTime){
|
||||
val currentNetTime = (T4 - T1)
|
||||
if (currentNetTime > netTime) {
|
||||
OchChainLogManager.writeChainLogTime(
|
||||
"时间信息",
|
||||
"时间延迟较上次大 放弃此次同步${currentNetTime}___上次同步网络延迟${netTime}"
|
||||
)
|
||||
d(
|
||||
TAG,
|
||||
"时间信息_时间延迟较上次大 放弃此次同步${currentNetTime}___上次同步网络延迟${netTime}___时间差是:${offset}"
|
||||
)
|
||||
return
|
||||
}
|
||||
netTime = currentNetTime
|
||||
@@ -77,14 +85,20 @@ class TimeProvider : TimeService {
|
||||
"时间信息",
|
||||
"请求时间信息成功:${data};时间差是:${offset}"
|
||||
)
|
||||
d(TAG, "时间同步_请求时间信息成功:${data};时间差是:${offset}_路上的时间:${delay}")
|
||||
if(netTime>3_000){
|
||||
d(
|
||||
TAG,
|
||||
"时间同步_请求时间信息成功:${data};时间差是:${offset}_路上的时间:${delay}"
|
||||
)
|
||||
|
||||
if (netTime > 3_000 || FunctionBuildConfig.isOffLine) {
|
||||
// 网络延迟大 10s 同步一次
|
||||
RxUtils.createSubscribeOnOwnThread(30_000) {
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribeOnOwnThread(30_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
}else{
|
||||
RxUtils.createSubscribeOnOwnThread(30*60_000) {
|
||||
} else {
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribeOnOwnThread(30 * 60_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
}
|
||||
@@ -98,7 +112,8 @@ class TimeProvider : TimeService {
|
||||
"请求时间信息网络失败5s后重试"
|
||||
)
|
||||
d(TAG, "时间同步_请求时间信息网络失败5s后重试")
|
||||
RxUtils.createSubscribe(5_000) {
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribe(5_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
}
|
||||
@@ -109,7 +124,8 @@ class TimeProvider : TimeService {
|
||||
"请求时间信息网络失败5s后重试"
|
||||
)
|
||||
d(TAG, "时间同步_请求时间信息网络失败5s后重试")
|
||||
RxUtils.createSubscribe(5_000) {
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribe(5_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
}
|
||||
@@ -120,7 +136,7 @@ class TimeProvider : TimeService {
|
||||
}
|
||||
|
||||
override fun getCurrentTimeStamp(): Long {
|
||||
d(TAG,"获取时间_${System.currentTimeMillis() + offset}")
|
||||
d(TAG, "获取时间_${System.currentTimeMillis() + offset}")
|
||||
return System.currentTimeMillis() + offset
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,18 @@ import com.mogo.och.weaknet.repository.db.exception.NetDataException
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableSource
|
||||
import io.reactivex.functions.Function
|
||||
import kotlin.math.max
|
||||
|
||||
|
||||
class OchCommonNet<T:BaseData>(val apiName:String, val writeLog:Boolean) : Function<T?, ObservableSource<T?>> {
|
||||
|
||||
companion object {
|
||||
const val TAG = "CommonNet"
|
||||
var lastSuccessTime = 0L
|
||||
|
||||
fun getLastNetSuccessTime():Long{
|
||||
return max(lastSuccessTime,OchCommonSubscribeImpl.lastSuccessTime)
|
||||
}
|
||||
}
|
||||
|
||||
private var tag:Long = System.currentTimeMillis()
|
||||
@@ -37,6 +43,7 @@ class OchCommonNet<T:BaseData>(val apiName:String, val writeLog:Boolean) : Funct
|
||||
}
|
||||
|
||||
fun onSuccess(o: T) {
|
||||
lastSuccessTime = System.currentTimeMillis()
|
||||
CallerLogger.d("$flavorTag${TAG}", "$apiName: onSuccess() ${o.msg}")
|
||||
if(writeLog) {
|
||||
OchChainLogManager.writeChainLogNet(false,"接口:${apiName}", "请求成功:${o}_${tag}")
|
||||
@@ -44,6 +51,9 @@ class OchCommonNet<T:BaseData>(val apiName:String, val writeLog:Boolean) : Funct
|
||||
}
|
||||
|
||||
fun onError(message: String, code: Int) {
|
||||
if(code>0) {
|
||||
lastSuccessTime = System.currentTimeMillis()
|
||||
}
|
||||
CallerLogger.e("$flavorTag${TAG}", "$apiName: onError() code = $code; message = $message")
|
||||
if(writeLog) {
|
||||
OchChainLogManager.writeChainLogNet(
|
||||
|
||||
@@ -17,6 +17,7 @@ class OchCommonSubscribeImpl<T : BaseData>(
|
||||
|
||||
companion object {
|
||||
const val TAG = "OchCommonSubscribeImpl"
|
||||
var lastSuccessTime = 0L
|
||||
}
|
||||
|
||||
private var tag:Long = System.currentTimeMillis()
|
||||
@@ -30,6 +31,7 @@ class OchCommonSubscribeImpl<T : BaseData>(
|
||||
|
||||
override fun onSuccess(o: T) {
|
||||
super.onSuccess(o)
|
||||
lastSuccessTime = System.currentTimeMillis()
|
||||
CallerLogger.d("$flavorTag$TAG", "$apiName: onSuccess() ${o.msg}")
|
||||
if(writeLog) {
|
||||
OchChainLogManager.writeChainLogNet(false,"接口:${apiName}", "请求成功:${o}_${tag}")
|
||||
@@ -49,6 +51,9 @@ class OchCommonSubscribeImpl<T : BaseData>(
|
||||
|
||||
override fun onError(message: String, code: Int) {
|
||||
super.onError(message, code)
|
||||
if(code>0) {
|
||||
lastSuccessTime = System.currentTimeMillis()
|
||||
}
|
||||
CallerLogger.e("$flavorTag$TAG", "$apiName: onError() code = $code; message = $message")
|
||||
if(writeLog) {
|
||||
OchChainLogManager.writeChainLogNet(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.och.offline">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<application>
|
||||
|
||||
</application>
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.provider.CommonServiceImpl
|
||||
import com.mogo.och.bridge.autopilot.autopilot.OchAutopilotAnalytics
|
||||
import com.mogo.och.bridge.ui.autopilot.AutopilotState
|
||||
import com.mogo.och.common.module.biz.time.TimeManager
|
||||
import com.mogo.och.offline.model.LineModel
|
||||
import com.mogo.och.offline.ui.bizswitch.SwitchBizView
|
||||
import com.mogo.och.offline.ui.fragment.OfflineFragment
|
||||
@@ -39,6 +40,7 @@ class ShuttleDriverProvider : CommonServiceImpl() {
|
||||
OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager.getInstance()
|
||||
OffLineTrajectoryManager.load()
|
||||
LineModel.init()
|
||||
TimeManager.loadNewTime()
|
||||
return busFragment!!
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OFFLINE
|
||||
import com.mogo.och.common.module.biz.time.TimeManager
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.network.OchCommonNet
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import com.mogo.och.offline.callback.IBusLinesCallback
|
||||
import com.mogo.och.offline.model.LineModel
|
||||
@@ -30,6 +31,10 @@ class GoLoginModel : ViewModel(), IBusLinesCallback {
|
||||
|
||||
private var countDownDisposable: Disposable? = null
|
||||
|
||||
// 10s后关闭蓝牙
|
||||
private var time60_000: Disposable? = null
|
||||
|
||||
|
||||
override fun onCleared() {
|
||||
d(TAG,"onCleared")
|
||||
LineModel.setBusLinesCallback(TAG,null)
|
||||
@@ -63,15 +68,37 @@ class GoLoginModel : ViewModel(), IBusLinesCallback {
|
||||
|
||||
override fun onCompleteTask() {
|
||||
super.onCompleteTask()
|
||||
createTimelater()
|
||||
}
|
||||
|
||||
override fun onNoRunningTask() {
|
||||
super.onNoRunningTask()
|
||||
createTimelater()
|
||||
}
|
||||
|
||||
fun createTimelater(){
|
||||
d(TAG,"开始检查是否展示登录页面")
|
||||
if(FunctionBuildConfig.isOffLine){
|
||||
if(System.currentTimeMillis()-TimeManager.getSynServerTime()<60*2*1000
|
||||
&& TimeManager.getTimeStampDiff()!=0L
|
||||
){
|
||||
BizLoopManager.runInMainThread{
|
||||
this.viewCallback?.showView()
|
||||
// 2分钟内有网络成功过
|
||||
if(System.currentTimeMillis()- OchCommonNet.getLastNetSuccessTime()<60*1000){
|
||||
if (NetworkUtils.isConnected()) {
|
||||
BizLoopManager.runInMainThread{
|
||||
this.viewCallback?.showView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RxUtils.disposeSubscribe(time60_000)
|
||||
time60_000 = RxUtils.createSubscribeOnOwnThread(60_000) {
|
||||
// 检测是否需要展示
|
||||
createTimelater()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRunningTask() {
|
||||
super.onRunningTask()
|
||||
// 有订单开始取消
|
||||
RxUtils.disposeSubscribe(time60_000)
|
||||
}
|
||||
|
||||
interface GoLoginViewCallback{
|
||||
|
||||
Reference in New Issue
Block a user