From 164394e727f3375bd0af4e3b41b5fcc0fc77f9d7 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Thu, 27 Jul 2023 20:05:14 +0800 Subject: [PATCH] =?UTF-8?q?[bugfix]=20[bus]=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 --- .../com/mogo/och/bus/model/OrderModel.java | 13 +- .../mogo/och/bus/util/BusAnalyticsManager.kt | 186 +++++++----------- 2 files changed, 84 insertions(+), 115 deletions(-) diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java index 5153efce75..bb99b9c96c 100644 --- a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java @@ -380,7 +380,7 @@ public class OrderModel { private final OchAdasStartFailureCallback mAdasStartFailureListener = new OchAdasStartFailureCallback() { @Override public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { - BusAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); + BusAnalyticsManager.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ CallerLogger.INSTANCE.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); mADASStatusCallback.onStartAdasFailure(); @@ -661,6 +661,13 @@ public class OrderModel { CallerLogger.INSTANCE.e(M_BUS + TAG, "isPassStartAutopilotCommand = " + FunctionBuildConfig.isPassStartAutopilotCommand); + if(CallerAutoPilotStatusListenerManager.INSTANCE.getState() + == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ + ToastUtils.showShort("自驾中、请勿重复启动"); + return; + } + + if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) { ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试"); @@ -1190,7 +1197,7 @@ public class OrderModel { } BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - BusAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, + BusAnalyticsManager.INSTANCE.triggerStartAutopilotEvent(isRestart, send, currentStation.getName(), nextStation.getName(), currentLineId); } @@ -1200,7 +1207,7 @@ public class OrderModel { } BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - BusAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( + BusAnalyticsManager.INSTANCE.triggerUnableStartAPReasonEvent( currentStation.getName(), nextStation.getName(), currentLineId, OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt index 947adbfc0c..d43c83be61 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt @@ -1,82 +1,51 @@ -package com.mogo.och.bus.util; +package com.mogo.och.bus.util -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; - -import android.text.TextUtils; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.commons.debug.DebugConfig; -import com.mogo.eagle.core.data.app.AppConfigInfo; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; -import com.mogo.commons.utils.MogoAnalyticUtils; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.util.DateTimeUtils; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.bus.constant.BusConst; - -import java.util.HashMap; +import android.text.TextUtils +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.debug.DebugConfig +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 +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.util.DateTimeUtils +import com.mogo.och.bus.constant.BusConst +import com.mogo.och.common.module.utils.RxUtils +import io.reactivex.disposables.Disposable /** * OCH Bus埋点工具 * * Created on 2022/3/24 */ -public class BusAnalyticsManager { +object BusAnalyticsManager { - private static final class SingletonHolder { - private static final BusAnalyticsManager INSTANCE = new BusAnalyticsManager(); + private var mStartAutopilotKey: String? = null + private val mStartAutopilotParams = HashMap() + + var startAutopiloTimeOut: Disposable? = null + + fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String) { + RxUtils.disposeSubscribe(startAutopiloTimeOut) + triggerStartAutopilotFailureEvent(failCode, failMsg) } - public static BusAnalyticsManager getInstance() { - return BusAnalyticsManager.SingletonHolder.INSTANCE; + private fun clearStartAutopilotParams() { + mStartAutopilotParams.clear() } - private String mStartAutopilotKey; - private HashMap mStartAutopilotParams = new HashMap<>(); - - private Runnable startAutopilotRunnable = () -> { - // 15s内未开启,上报失败埋点 - triggerStartAutopilotFailureEvent("", "15s后app等待超时"); - }; - - public void triggerStartAutopilotFailureEventByAdas(String failCode, String failMsg){ - removeWaitingCallback(); - triggerStartAutopilotFailureEvent(failCode, failMsg); - } - - private void triggerStartAutopilotFailureEvent(String failCode, String failMsg){ - if (mStartAutopilotParams.isEmpty()) return; - - CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg ); - - if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() != - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, failCode); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, failMsg); + private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String) { + if (mStartAutopilotParams.isEmpty()) return + CallerLogger.e(SceneConstant.M_BUS + "triggerStartAutopilotFailureEvent", failMsg) + if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_CODE] = failCode + mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_MSG] = failMsg } - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT - , CallerAutoPilotStatusListenerManager.INSTANCE.getState() == - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); - - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 - } - - private void removeWaitingCallback() { - if (startAutopilotRunnable != null) { - UiThreadHandler.removeCallbacks(startAutopilotRunnable); - } - } - - public void clearStartAutopilotFailureMSG(){ - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, ""); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, ""); - } - - private void clearStartAutopilotParams(){ - mStartAutopilotParams.clear(); + mStartAutopilotParams[BusConst.EVENT_PARAM_START_RESULT] = + CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) + clearStartAutopilotParams() //清空参数数据,防止误传 } /** @@ -85,35 +54,32 @@ public class BusAnalyticsManager { * @param restart false(点击'滑动出发'启动)/true(接管后点击'自动驾驶'按钮启动) * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) */ - public void triggerStartAutopilotEvent( - boolean restart, boolean send, String startName, String endName, int lineId) { - mStartAutopilotKey = restart ? - BusConst.EVENT_KEY_RESTART_AUTOPILOT : BusConst.EVENT_KEY_START_SERVICE; - String sn = MoGoAiCloudClientConfig.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - mStartAutopilotParams.put(BusConst.EVENT_PARAM_SN, sn); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_TIME, dateTime); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_NAME, startName); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_END_NAME, endName); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_LINE_ID, lineId); - + fun triggerStartAutopilotEvent( + restart: Boolean, send: Boolean, startName: String, endName: String, lineId: Int + ) { + mStartAutopilotKey = if (restart) BusConst.EVENT_KEY_RESTART_AUTOPILOT else BusConst.EVENT_KEY_START_SERVICE if (send) { - if (mStartAutopilotParams.isEmpty()) return; + if (mStartAutopilotParams.isEmpty()) return // 开启成功,上报埋点 - clearStartAutopilotFailureMSG(); - removeWaitingCallback(); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT, true); - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 + mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_CODE] = "" + mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_MSG] = "" + RxUtils.disposeSubscribe(startAutopiloTimeOut) + mStartAutopilotParams[BusConst.EVENT_PARAM_START_RESULT] = true + MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) + clearStartAutopilotParams() //清空参数数据,防止误传 } else { - UiThreadHandler.postDelayed(startAutopilotRunnable, BusConst.LOOP_PERIOD_15S); + val plateNum = AppConfigInfo.plateNumber + mStartAutopilotParams[BusConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn + mStartAutopilotParams[BusConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum + mStartAutopilotParams[BusConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE + mStartAutopilotParams[BusConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) + mStartAutopilotParams[BusConst.EVENT_PARAM_START_NAME] = startName + mStartAutopilotParams[BusConst.EVENT_PARAM_END_NAME] = endName + mStartAutopilotParams[BusConst.EVENT_PARAM_LINE_ID] = lineId + startAutopiloTimeOut = RxUtils.createSubscribeOnOwnThread(BusConst.LOOP_PERIOD_15S) { + // 15s内未开启,上报失败埋点 + triggerStartAutopilotFailureEvent("", "15s后app等待超时") + } } } @@ -123,24 +89,20 @@ public class BusAnalyticsManager { * @param endName * @param lineId */ - public void triggerUnableStartAPReasonEvent(String startName, String endName, int lineId, - String reason) { - String sn = MoGoAiCloudClientConfig.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - HashMap params = new HashMap<>(); - - params.put(BusConst.EVENT_PARAM_SN, sn); - params.put(BusConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - params.put(BusConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - params.put(BusConst.EVENT_PARAM_TIME, dateTime); - params.put(BusConst.EVENT_PARAM_START_NAME, startName); - params.put(BusConst.EVENT_PARAM_END_NAME, endName); - params.put(BusConst.EVENT_PARAM_LINE_ID, lineId); - params.put(BusConst.EVENT_PARAM_UNABLE_START_REASON, reason); - MogoAnalyticUtils.INSTANCE.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params); + fun triggerUnableStartAPReasonEvent( + startName: String, endName: String, lineId: Int, + reason: String + ) { + val plateNum = AppConfigInfo.plateNumber + val params = HashMap() + params[BusConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn + params[BusConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum + params[BusConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE + params[BusConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) + params[BusConst.EVENT_PARAM_START_NAME] = startName + params[BusConst.EVENT_PARAM_END_NAME] = endName + params[BusConst.EVENT_PARAM_LINE_ID] = lineId + params[BusConst.EVENT_PARAM_UNABLE_START_REASON] = reason + MogoAnalyticUtils.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params) } -} +} \ No newline at end of file