diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/driver/video/DriveSeatVideoProviderImpl.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/driver/video/DriveSeatVideoProviderImpl.kt index af4af7a3a6..0669d5e034 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/driver/video/DriveSeatVideoProviderImpl.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/driver/video/DriveSeatVideoProviderImpl.kt @@ -143,7 +143,7 @@ class DriveSeatVideoProviderImpl : IDriveSeatVideoProvider { } - override fun getLastData(): VideoUrlData? { + override fun getLatestData(): VideoUrlData? { return data } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt index 54cb70b3ce..58ccc03f81 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt @@ -21,6 +21,7 @@ import androidx.preference.SwitchPreferenceCompat import androidx.preference.TwoStatePreference import androidx.preference.forEach import androidx.recyclerview.widget.RecyclerView +import com.mogo.commons.utils.MogoAnalyticUtils import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig @@ -798,36 +799,42 @@ class OperatePanelLayout : LinearLayout { "01" -> { //关闭成功 Log.d(TAG, "-- 驾驶位视频流关闭成功 --") + ToastUtils.showShort("驾驶位视频流功能已关闭") FunctionBuildConfig.isDriveSeatVideoStream = false - preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.also { changeValue(it, false) } + lastTimeOnSendDriveVideo = 0L + preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.also { it.isChecked = false } } "11" -> { //打开成功 Log.d(TAG, "-- 驾驶位视频流打开成功 --") + ToastUtils.showShort("驾驶位视频流功能已开启") FunctionBuildConfig.isDriveSeatVideoStream = true - preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.also { changeValue(it, true) } + lastTimeOnSendDriveVideo = 0L + preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.also { it.isChecked = true } } else -> { - if ("0" == s) { - Log.d(TAG, "-- 设备下线 --") - FunctionBuildConfig.isDriveSeatVideoStream = false - // 设备下线 - preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.also { - it.isChecked = false - it.isEnabled = false + when (s) { + "0" -> { + Log.d(TAG, "-- 设备下线 --") + FunctionBuildConfig.isDriveSeatVideoStream = false // 设备下线 + ToastUtils.showShort("驾驶位视频流功能因设备下线已关闭") + preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.also { + it.isChecked = false + it.isEnabled = false + } + } + "1" -> { // 设备在线 + Log.d(TAG, "-- 设备上线 --") + preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.isEnabled = true + } + "000" -> { // 查询乘客屏播放状态-未播放 + Log.d(TAG, "-- 乘客屏当前处于未播放状态 --") + preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.isChecked = false + } + "111" -> { // 查询乘客屏播放状态-正在播放 + Log.d(TAG, "-- 乘客屏当前处于播放状态 --") + preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.isChecked = true } - } else if ("1" == s) { - // 设备在线 - Log.d(TAG, "-- 设备上线 --") - preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.isEnabled = true - } else if ("000" == s) { - // 查询乘客屏播放状态-未播放 - Log.d(TAG, "-- 乘客屏当前处于未播放状态 --") - preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.isChecked = false - } else if ("111" == s) { - // 查询乘客屏播放状态-正在播放 - Log.d(TAG, "-- 乘客屏当前处于播放状态 --") - preferenceScreen.findPreferenceReal(KEY_DRIVE_SEAT_VIDEO_STREAM)?.isChecked = true } } } @@ -926,17 +933,35 @@ class OperatePanelLayout : LinearLayout { return true } KEY_DRIVE_SEAT_VIDEO_STREAM -> { - if (lastTimeOnSendDriveVideo != 0L && SystemClock.elapsedRealtime() - lastTimeOnSendDriveVideo <= TimeUnit.SECONDS.toMillis(10)) { - ToastUtils.showShort("未收到乘客屏响应,一会儿再试~") + if (lastTimeOnSendDriveVideo > 0L) { + val interval = SystemClock.elapsedRealtime() - lastTimeOnSendDriveVideo + if (interval <= TimeUnit.SECONDS.toMillis(10)) { + val seconds = TimeUnit.MILLISECONDS.toSeconds(interval) + ToastUtils.showShort("未收到乘客屏响应,${ if (seconds >= 1) "请${seconds}秒后再试" else "请稍候再试"}") + } return false } lastTimeOnSendDriveVideo = SystemClock.elapsedRealtime() val isChecked = newValue as? Boolean ?: false + ToastUtils.showShort(if (isChecked) "驾驶位视频流功能开启指令已发送,等待乘客端响应" else "驾驶位视频流功能关闭指令已发送,等待乘客端响应") clickEventAnalytics("视频流驾驶位开关", isChecked) val map = HashMap() map["open"] = if (isChecked) "1" else "0" - val playUrl = CallerDevaToolsManager.driveSeatVideoProvider()?.getLastData()?.livePlayUrl ?: "" - map["playUrl"] = playUrl + if (isChecked) { + val playUrl = CallerDevaToolsManager.driveSeatVideoProvider()?.getLatestData()?.livePlayUrl ?: "" + map["playUrl"] = playUrl + MogoAnalyticUtils.track("DriveSeatVideoStream", HashMap().also { + it["open"] = 1 + it["playUrl"] = playUrl + it["isDriver"] = 1 + }) + } else { + MogoAnalyticUtils.track("DriveSeatVideoStream", HashMap().also { + it["playUrl"] = "" + it["isDriver"] = 1 + it["open"] = 0 + }) + } CallerTelematicManager.sendMsgToAllClients(TelematicConstant.DRIVE_SEAT_VIDEO_STREAM_REQ, toJson(map).toByteArray()) return false } @@ -948,17 +973,17 @@ class OperatePanelLayout : LinearLayout { setPreferencesFromResource(R.xml.operate_panel_preference_details_business, rootKey) } - private fun showVideoView(target: View) { - val activity = AppStateManager.currentActivity() ?: return - MoGoPopWindow.Builder() - .attachToActivity(activity) - .contentView(target) - .draggable(false) - .width(AutoSizeUtils.dp2px(activity, 640.0f)) - .height(AutoSizeUtils.dp2px(activity, 480.0f)) - .gravityInActivity(Gravity.CENTER) - .build().show() - } +// private fun showVideoView(target: View) { +// val activity = AppStateManager.currentActivity() ?: return +// MoGoPopWindow.Builder() +// .attachToActivity(activity) +// .contentView(target) +// .draggable(false) +// .width(AutoSizeUtils.dp2px(activity, 640.0f)) +// .height(AutoSizeUtils.dp2px(activity, 480.0f)) +// .gravityInActivity(Gravity.CENTER) +// .build().show() +// } } class MoFangPreferenceFragmentCompat : OperatePanelDetailBase(), IMoGoMoFangProvider.OnMoFangStatusListener { diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/driver/video/IDriveSeatVideoProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/driver/video/IDriveSeatVideoProvider.kt index 9adf3511e5..5e10c2a4e7 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/driver/video/IDriveSeatVideoProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/driver/video/IDriveSeatVideoProvider.kt @@ -21,7 +21,7 @@ interface IDriveSeatVideoProvider { /** * 获取最新的视频数据 */ - fun getLastData(): VideoUrlData? + fun getLatestData(): VideoUrlData? /**