From e98bef4e3bc3d0ab06c8b9c4e1f2c8d860797519 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Thu, 27 Jul 2023 19:43:58 +0800 Subject: [PATCH] =?UTF-8?q?[bugfix]=20[=E8=87=AA=E9=A9=BE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=90=AF=E5=8A=A8=E8=87=AA=E9=A9=BE=E5=9F=8B=E7=82=B9?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E3=80=81=E4=B8=AD=E9=80=94=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E5=BA=94=E7=94=A8=20=E4=B8=8A=E6=8A=A5=E8=87=AA=E9=A9=BE?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=88=90=E5=8A=9F]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/och/common/module/utils/RxUtils.kt | 6 ++ .../com/mogo/och/taxi/model/TaxiModel.java | 6 ++ .../och/taxi/utils/TaxiAnalyticsManager.kt | 86 +++++++++---------- 3 files changed, 55 insertions(+), 43 deletions(-) diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/RxUtils.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/RxUtils.kt index de7a436527..8d41c08fec 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/RxUtils.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/RxUtils.kt @@ -29,6 +29,12 @@ object RxUtils { function.invoke() } } + fun createSubscribeOnOwnThread(delay: Long=2000, function: () -> Unit): Disposable? { + return Observable.timer(delay, TimeUnit.MILLISECONDS) + .subscribe { + function.invoke() + } + } fun isDisposed(disposable: Disposable?):Boolean{ if(disposable!=null){ diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java index ae64bc37a1..a8f1bb625a 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java @@ -928,6 +928,12 @@ public class TaxiModel { return; } + if(CallerAutoPilotStatusListenerManager.INSTANCE.getState() + == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ + ToastUtils.showShort("自驾中、请勿重复启动"); + return; + } + CallerLogger.INSTANCE.e(M_TAXI + TAG, "isPassStartAutopilotCommand = " + FunctionBuildConfig.isPassStartAutopilotCommand); diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt index bea19e850a..22e0c765d4 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt @@ -3,15 +3,16 @@ package com.mogo.och.taxi.utils import android.text.TextUtils import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.commons.debug.DebugConfig -import com.mogo.commons.utils.MogoAnalyticUtils.track -import com.mogo.eagle.core.data.app.AppConfigInfo.plateNumber +import com.mogo.commons.utils.MogoAnalyticUtils +import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI import com.mogo.eagle.core.utilcode.util.DateTimeUtils -import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.common.module.utils.RxUtils import com.mogo.och.taxi.constant.TaxiConst +import io.reactivex.disposables.Disposable /** * OCH Taxi埋点工具 @@ -21,22 +22,23 @@ import com.mogo.och.taxi.constant.TaxiConst object TaxiAnalyticsManager { + /** + * @see TaxiConst.EVENT_KEY_RESTART_AUTOPILOT + * @see TaxiConst.EVENT_KEY_START_SERVICE + */ private var mStartAutopilotKey: String? = null private val mStartAutopilotParams = HashMap() - private val startAutopilotRunnable: Runnable = Runnable { - // 15s内未开启,上报失败埋点 - triggerStartAutopilotFailureEvent("", "15s后app等待超时") - } + + var startAutopiloTimeOut: Disposable? = null + fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String) { - removeWaitingCallback() + RxUtils.disposeSubscribe(startAutopiloTimeOut) triggerStartAutopilotFailureEvent(failCode, failMsg) } - private fun removeWaitingCallback() { - if (startAutopilotRunnable != null) { - UiThreadHandler.removeCallbacks(startAutopilotRunnable) - } + private fun clearStartAutopilotParams() { + mStartAutopilotParams.clear() } /** @@ -46,27 +48,22 @@ object TaxiAnalyticsManager { */ private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String) { if (mStartAutopilotParams.isEmpty()) return - e(SceneConstant.M_TAXI + "triggerStartAutopilotFailureEvent", failMsg) + CallerLogger.e(M_TAXI + "triggerStartAutopilotFailureEvent", failMsg) if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_CODE] = failCode mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_MSG] = failMsg } mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] = CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - track(mStartAutopilotKey, mStartAutopilotParams) + MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) clearStartAutopilotParams() //清空参数数据,防止误传 } - private fun clearStartAutopilotParams() { - mStartAutopilotParams.clear() - } - - fun clearStartAutopilotFailureMSG() { - mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_CODE] = "" - mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_MSG] = "" - } /** + * + * ① 自检完成后 启动自驾 + * ② 自驾由其他状态转换到自驾中回调 * 触发'开启自动驾驶'埋点流程 * 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点 * @param restart false(点击'开始服务'启动)/true(接管后点击'自动驾驶'按钮启动) @@ -83,28 +80,32 @@ object TaxiAnalyticsManager { orderNo: String ) { mStartAutopilotKey = if (restart) TaxiConst.EVENT_KEY_RESTART_AUTOPILOT else TaxiConst.EVENT_KEY_START_SERVICE - val plateNum = plateNumber - val dateTime = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) - mStartAutopilotParams[TaxiConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn - mStartAutopilotParams[TaxiConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum - mStartAutopilotParams[TaxiConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE - mStartAutopilotParams[TaxiConst.EVENT_PARAM_TIME] = dateTime - mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_NAME] = startName - mStartAutopilotParams[TaxiConst.EVENT_PARAM_END_NAME] = endName - mStartAutopilotParams[TaxiConst.EVENT_PARAM_LINE_ID] = lineId - mStartAutopilotParams[TaxiConst.EVENT_PARAM_ORDER_NUMBER] = orderNo // CallerLogger.INSTANCE.d(M_TAXI + "埋点==","restart = "+restart+", send= "+send); if (send) { if (mStartAutopilotParams.isEmpty()) return // 开启成功,上报埋点 - clearStartAutopilotFailureMSG() - removeWaitingCallback() - mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] = true - track(mStartAutopilotKey, mStartAutopilotParams) + mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_CODE] = ""//启动自驾失败code + mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_MSG] = "" //启动自驾失败原因 + // 取消15s超时 + RxUtils.disposeSubscribe(startAutopiloTimeOut) + mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] = true // 自动驾驶状态 + MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) clearStartAutopilotParams() //清空参数数据,防止误传 } else { - UiThreadHandler.postDelayed(startAutopilotRunnable, TaxiConst.LOOP_PERIOD_15S) + val plateNum = AppConfigInfo.plateNumber + mStartAutopilotParams[TaxiConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn + mStartAutopilotParams[TaxiConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum + mStartAutopilotParams[TaxiConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE + mStartAutopilotParams[TaxiConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) + mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_NAME] = startName + mStartAutopilotParams[TaxiConst.EVENT_PARAM_END_NAME] = endName + mStartAutopilotParams[TaxiConst.EVENT_PARAM_LINE_ID] = lineId + mStartAutopilotParams[TaxiConst.EVENT_PARAM_ORDER_NUMBER] = orderNo + startAutopiloTimeOut = RxUtils.createSubscribeOnOwnThread(TaxiConst.LOOP_PERIOD_15S) { + // 15s内未开启,上报失败埋点 + triggerStartAutopilotFailureEvent("", "15s后app等待超时") + } } } @@ -116,17 +117,16 @@ object TaxiAnalyticsManager { * @param orderNo */ fun triggerUnableStartAPReasonEvent(startName: String, endName: String, orderNo: String, reason: String) { - val plateNum = plateNumber - val dateTime = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) + val plateNum = AppConfigInfo.plateNumber val params = HashMap() params[TaxiConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn params[TaxiConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum params[TaxiConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE - params[TaxiConst.EVENT_PARAM_TIME] = dateTime + params[TaxiConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) params[TaxiConst.EVENT_PARAM_START_NAME] = startName params[TaxiConst.EVENT_PARAM_END_NAME] = endName params[TaxiConst.EVENT_PARAM_ORDER_NUMBER] = orderNo params[TaxiConst.EVENT_PARAM_UNABLE_START_REASON] = reason - track(TaxiConst.EVENT_KEY_AP_UNABLE_START_REASON, params) + MogoAnalyticUtils.track(TaxiConst.EVENT_KEY_AP_UNABLE_START_REASON, params) } } \ No newline at end of file