From 287f60e34fad2c483fad415d0e5fcd741d1d6146 Mon Sep 17 00:00:00 2001 From: pangfan Date: Thu, 26 May 2022 17:10:56 +0800 Subject: [PATCH] =?UTF-8?q?[Bus/Taxi=20driver=20v2.7.0]Bus=EF=BC=9A?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=AD=E9=80=94=E6=8E=A5=E7=AE=A1=E5=90=8E?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E8=87=AA=E9=A9=BE=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/och/bus/constant/BusConst.kt | 2 + .../com/mogo/och/bus/model/BusOrderModel.java | 30 +------ .../mogo/och/bus/presenter/BusPresenter.java | 3 +- .../och/bus/util/BusAnalyticsManager.java | 78 +++++++++++++++++++ .../mogo/och/bus/util/BusAnalyticsUtil.java | 63 --------------- 5 files changed, 86 insertions(+), 90 deletions(-) create mode 100644 OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java delete mode 100644 OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsUtil.java diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt index dab7aa2bbf..84bfc41564 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt @@ -48,6 +48,8 @@ class BusConst { //终点UUID const val BUS_END_MAP_MAKER = "bus_end_map_maker"; + // 埋点key:接管后点击'自动驾驶'按钮启动 + const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot" // 埋点key:开始服务开启自动驾驶(成功/失败) const val EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service" const val EVENT_PARAM_SN = "sn" diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java index 87da0cd87f..2e0e2dbdfa 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java @@ -1,6 +1,5 @@ package com.mogo.och.bus.model; -import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE; import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_OCH_BUS_START_AUTOPILOT; import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_ADAS; import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT; @@ -49,7 +48,7 @@ import com.mogo.och.bus.constant.BusConst; import com.mogo.och.bus.net.BusServiceManager; import com.mogo.och.bus.net.IBusServiceCallback; import com.mogo.och.bus.presenter.BusModelLoopManager; -import com.mogo.och.bus.util.BusAnalyticsUtil; +import com.mogo.och.bus.util.BusAnalyticsManager; import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; import com.mogo.och.common.module.utils.PinYinUtil; import com.mogo.service.statusmanager.IMogoStatusChangedListener; @@ -523,7 +522,7 @@ public class BusOrderModel { +" startLatLon="+currentStation.getName()+",endLatLon="+nextStation.getName()); CallerAutoPilotManager.INSTANCE.startAutoPilot(currentAutopilot); - triggerStartServiceEvent(false); + triggerStartServiceEvent(isRestart, false); if (mControllerStatusCallback != null) { mControllerStatusCallback.startOpenAutopilot(); @@ -739,27 +738,6 @@ public class BusOrderModel { } } - /** - * 重置下一站 - * - * @param lastStopStation - */ - private void resetNextStopStation( int lastStopStation ) { - CallerLogger.INSTANCE.d( M_BUS + TAG, "重置下一站"); - int nextStopStation = getNextStopStation(); - if ( nextStopStation < 0 ) { - return; - } - if ( lastStopStation <= nextStopStation || nextStopStation <= currentStationIndex ) { - return; - } - if ( CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() - == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING ) { - // 自动驾驶中动态设置下一个停靠站点/ - autoDriveToNextStation( true ); - } - } - /** * 根据订单状态、获取下一站靠站的的站点 * @@ -926,13 +904,13 @@ public class BusOrderModel { } } - public void triggerStartServiceEvent(boolean send) { + public void triggerStartServiceEvent(boolean isRestart, boolean send) { if (stationList == null || currentStationIndex >= stationList.size() || currentStationIndex == 0) { return; } BusStationBean currentStation = stationList.get( currentStationIndex -1); BusStationBean nextStation = stationList.get( currentStationIndex); - BusAnalyticsUtil.triggerStartServiceEvent(send, + BusAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, currentStation.getName(), nextStation.getName(), currentLineId); } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index e1b6181a21..8f58e0116d 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -200,7 +200,8 @@ public class BusPresenter extends Presenter currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; // 改变UI自动驾驶状态 runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); - BusOrderModel.getInstance().triggerStartServiceEvent(true); + BusOrderModel.getInstance().triggerStartServiceEvent( + BusOrderModel.getInstance().isGoingToNextStation(), true); } break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java new file mode 100644 index 0000000000..d72d9f0a2f --- /dev/null +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java @@ -0,0 +1,78 @@ +package com.mogo.och.bus.util; + +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.call.analytics.AnalyticsManager; +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 java.util.Map; + +/** + * OCH Bus埋点工具 + * + * Created on 2022/3/24 + */ +public class BusAnalyticsManager { + + private static final class SingletonHolder { + private static final BusAnalyticsManager INSTANCE = new BusAnalyticsManager(); + } + + public static BusAnalyticsManager getInstance() { + return BusAnalyticsManager.SingletonHolder.INSTANCE; + } + + + + private String mStartAutopilotKey; + private Map mStartAutopilotParams = new HashMap<>(); + + private Runnable startAutopilotRunnable = () -> { + // 15s内未开启,上报失败埋点 + mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT, false); + AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); + }; + + /** + * 触发'开启自动驾驶'埋点流程 + * 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点 + * @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); + + if (send) { + // 开启成功,上报埋点 + if (startAutopilotRunnable != null && + UiThreadHandler.getsUiHandler().hasCallbacks(startAutopilotRunnable)) { + UiThreadHandler.removeCallbacks(startAutopilotRunnable); + } + mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT, true); + AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); + } else { + UiThreadHandler.postDelayed(startAutopilotRunnable, BusConst.LOOP_PERIOD_15S); + } + } +} diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsUtil.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsUtil.java deleted file mode 100644 index a663c4a020..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.mogo.och.bus.util; - -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.call.analytics.AnalyticsManager; -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 java.util.Map; - -/** - * OCH Bus埋点工具 - * - * Created on 2022/3/24 - */ -public class BusAnalyticsUtil { - - /** - * 触发'滑动出发'埋点流程: - * 滑动出发(开启自动驾驶)后,15s内成功则发送成功埋点,否则发送失败埋点 - * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) - */ - public static void triggerStartServiceEvent( - boolean send, String startName, String endName, int lineId) { - - String sn = MoGoAiCloudClientConfig.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - Map 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); - - Runnable runnable = () -> { - // 15s内未开启,上报失败埋点 - params.put(BusConst.EVENT_PARAM_START_RESULT, false); - AnalyticsManager.INSTANCE.track(BusConst.EVENT_KEY_START_SERVICE, params); - }; - - if (send) { - // 开启成功,上报埋点 - if (runnable != null && UiThreadHandler.getsUiHandler().hasCallbacks(runnable)) { - UiThreadHandler.removeCallbacks(runnable); - } - params.put(BusConst.EVENT_PARAM_START_RESULT, true); - AnalyticsManager.INSTANCE.track(BusConst.EVENT_KEY_START_SERVICE, params); - } else { - UiThreadHandler.postDelayed(runnable, BusConst.LOOP_PERIOD_15S); - } - } -}