diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt
index b3e3f2cb4c..ef69fb5d4a 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt
+++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt
@@ -20,7 +20,6 @@ import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import androidx.annotation.RequiresApi
-import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.ListPopupWindow
import androidx.appcompat.widget.PopupMenu
import androidx.constraintlayout.widget.ConstraintLayout
@@ -336,7 +335,7 @@ import kotlin.collections.component4
import kotlin.collections.set
import kotlin.math.abs
import kotlin.system.exitProcess
-import com.mogo.eagle.core.function.hmi.ui.tools.ShowVersionDialog
+import com.mogo.eagle.core.function.hmi.ui.tools.ShowDevicesManagerStateDialog
/**
@@ -1339,13 +1338,7 @@ internal class DebugSettingView @JvmOverloads constructor(
tvHardwareDeviceBindState.text =
getBindDeviceServiceState(DevicesManager.getServiceBindState())
tvHardwareDeviceBindState.setOnClickListener {
- var msg =
- "${getBindDeviceServiceState(DevicesManager.getServiceBindState(), false)}\n"
- msg += "客户端SDK版本:${DevicesManager.getSDKVersion() ?: "未知"}\n"
- msg += "客户端SDK AIDL版本:${DevicesManager.getSDKAIDLVersion() ?: "未知"}\n"
- msg += "硬件服务端APP版本:${DevicesManager.getServerVersion() ?: "未知"}\n"
- msg += "硬件服务端APP AIDL版本:${DevicesManager.getServerAIDLVersion() ?: "未知"}"
- ShowVersionDialog(context, "硬件服务绑定", msg).show()
+ ShowDevicesManagerStateDialog(context).show()
}
}
@@ -2750,7 +2743,7 @@ internal class DebugSettingView @JvmOverloads constructor(
}
}
- private fun getBindDeviceServiceState(state: Int, isUseTitle: Boolean = true): CharSequence {
+ private fun getBindDeviceServiceState(state: Int): CharSequence {
val msg = when (state) {
0 -> {
"绑定成功"
@@ -2772,15 +2765,10 @@ internal class DebugSettingView @JvmOverloads constructor(
"未初始化"
}
}
- val title = if (isUseTitle) {
- "硬件服务绑定"
- } else {
- ""
- }
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- Html.fromHtml("${title}状态:${msg}", Html.FROM_HTML_MODE_LEGACY)
+ Html.fromHtml("硬件服务绑定状态:${msg}", Html.FROM_HTML_MODE_LEGACY)
} else {
- Html.fromHtml("${title}状态:${msg}")
+ Html.fromHtml("硬件服务绑定状态:${msg}")
}
}
}
\ No newline at end of file
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/ShowDevicesManagerStateDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/ShowDevicesManagerStateDialog.kt
new file mode 100644
index 0000000000..47d136e74a
--- /dev/null
+++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/ShowDevicesManagerStateDialog.kt
@@ -0,0 +1,94 @@
+package com.mogo.eagle.core.function.hmi.ui.tools
+
+import android.content.Context
+import android.os.Build
+import android.text.Html
+import android.widget.TextView
+import com.mogo.eagle.core.function.hmi.R
+import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
+import com.mogo.eagle.core.utilcode.util.UiThreadHandler
+import com.mogo.support.device.DevicesManager
+import com.mogo.support.device.IBindStateChangeListener
+
+
+/**
+ * 硬件服务绑定状态 版本弹窗
+ */
+class ShowDevicesManagerStateDialog(context: Context) :
+ BaseFloatDialog(context, TAG), IBindStateChangeListener {
+
+ companion object {
+ private const val TAG = "ShowDevicesManagerStateDialog"
+ }
+
+ private var tvTitle: TextView? = null
+ private var tvMsg: TextView? = null
+ private var okView: TextView? = null
+
+
+ init {
+ setContentView(R.layout.dialog_show_devices_manager_state)
+ setCanceledOnTouchOutside(true)
+ setCancelable(true)
+ initView()
+ DevicesManager.addBindStateChangeListener(TAG, this)
+ }
+
+ private fun initView() {
+ tvTitle = findViewById(R.id.tv_title)
+ tvMsg = findViewById(R.id.tv_msg)
+ okView = findViewById(R.id.tv_ok)
+ tvTitle?.text = "硬件服务绑定"
+
+ okView?.setOnClickListener {
+ dismiss()
+ }
+ }
+
+
+ override fun dismiss() {
+ super.dismiss()
+ DevicesManager.removeBindStateChangeListener(TAG)
+ }
+
+ override fun onServiceState(state: Int) {
+ UiThreadHandler.post {
+ var msg =
+ "${getBindDeviceServiceState(state)}\n"
+ msg += "客户端SDK版本:${DevicesManager.getSDKVersion() ?: "未知"}\n"
+ msg += "客户端SDK AIDL版本:${DevicesManager.getSDKAIDLVersion() ?: "未知"}\n"
+ msg += "硬件服务端APP版本:${DevicesManager.getServerVersion() ?: "未知"}\n"
+ msg += "硬件服务端APP AIDL版本:${DevicesManager.getServerAIDLVersion() ?: "未知"}"
+ tvMsg?.text = msg
+ }
+ }
+
+ private fun getBindDeviceServiceState(state: Int): CharSequence {
+ val msg = when (state) {
+ 0 -> {
+ "绑定成功"
+ }
+
+ 1 -> {
+ "绑定失败,未安装“硬件服务”APP"
+ }
+
+ 2 -> {
+ "绑定失败,没有绑定权限或找不到服务"
+ }
+
+ 3 -> {
+ "绑定失败,服务被异常销毁"
+ }
+
+ else -> {
+ "未初始化"
+ }
+ }
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ Html.fromHtml("状态:${msg}", Html.FROM_HTML_MODE_LEGACY)
+ } else {
+ Html.fromHtml("状态:${msg}")
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/ShowVersionDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/ShowVersionDialog.kt
deleted file mode 100644
index 54baff053f..0000000000
--- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/ShowVersionDialog.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.mogo.eagle.core.function.hmi.ui.tools
-
-import android.content.Context
-import android.widget.TextView
-import com.mogo.eagle.core.function.hmi.R
-import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
-import com.mogo.support.device.DevicesManager
-
-
-/**
- * 离线地图缓存
- */
-class ShowVersionDialog(context: Context, val title: String, val msg: String) :
- BaseFloatDialog(context, TAG) {
-
- companion object {
- private const val TAG = "ShowVersionDialog"
- }
-
- private var tvTitle: TextView? = null
- private var tvMsg: TextView? = null
- private var okView: TextView? = null
-
-
- init {
- setContentView(R.layout.dialog_show_version)
- setCanceledOnTouchOutside(true)
- setCancelable(true)
- initView()
- }
-
- private fun initView() {
- tvTitle = findViewById(R.id.tv_title)
- tvMsg = findViewById(R.id.tv_msg)
- okView = findViewById(R.id.tv_ok)
- tvTitle?.text = title
- tvMsg?.text = msg
-
- okView?.setOnClickListener {
- dismiss()
- }
- }
-
-
- override fun dismiss() {
- super.dismiss()
-
- }
-}
\ No newline at end of file
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_show_version.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_show_devices_manager_state.xml
similarity index 100%
rename from core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_show_version.xml
rename to core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_show_devices_manager_state.xml