Browse Source

更新版本信息显示方式

wbspool 1 year ago
parent
commit
25671ebd24

+ 15 - 1
BusinessCommon/src/main/java/com/develop/common/food_sdk/ProtocolListener.kt

@@ -3,8 +3,9 @@ package com.develop.common.food_sdk
 import android.serialport.SerialPort
 import android.util.Log
 import com.kuyuntech.cofarcooking.device.sdk.protocol.core.BaseDecoder
+import com.kuyuntech.cofarcooking.device.sdk.protocol.core.cmd.ShakeHandsCmd
 import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
-import java.util.*
+import com.kuyuntech.cofarcooking.device.sdk.util.core.Converter
 
 
 class ProtocolListener(private val serialPort: SerialPort) : Runnable {
@@ -30,6 +31,19 @@ class ProtocolListener(private val serialPort: SerialPort) : Runnable {
                                 }
                                 val baseDecoder = BaseDecoder(cmd)
                                 Log.i("mcu2dev:", baseDecoder.escapeBytesStr())
+                                if ("0001" == baseDecoder.protocol) {
+                                    Log.i("ShakeHandsCmd:", baseDecoder.escapeBytesStr())
+
+                                    val cmd = ShakeHandsCmd(baseDecoder)
+                                    CofarSDK.updateVersionInfo(
+                                        Converter.hexToShort(cmd.manufacturer),
+                                        Converter.hexToShort(cmd.haradware),
+                                        Converter.hexToShort(cmd.software),
+                                        Converter.hexToByte(cmd.protocol),
+                                        Converter.hexToByte(cmd.devType)
+                                    )
+
+                                }
                                 CofarSDK.post2Dev(baseDecoder.baseBody)
                                 bytes.clear()
                             } catch (e: Exception) {

+ 1 - 0
BusinessCommon/src/main/java/com/develop/common/food_sdk/SerialPortUtils.kt

@@ -39,6 +39,7 @@ object SerialPortUtils {
             val protocolListener = ProtocolListener(serialPort)
             thread = Thread(protocolListener)
             thread?.start()
+            CofarSDK.versionQuery()
         } catch (e: Exception) {
             e.printStackTrace()
         }

+ 2 - 2
BusinessCommon/src/main/res/values-en/strings.xml

@@ -84,9 +84,9 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="update_the_recipes">Update the recipes</string>
     <string name="apk">APK</string>
     <string name="mcu">MCU</string>
-    <string name="tp">TP</string>
+    <string name="tp">FIRMWARE</string>
     <string name="serial_number">Serial number</string>
-    <string name="standby_time">Standby time</string>
+    <string name="standby_time">MODEL</string>
     <string name="update">Update</string>
     <string name="About">About</string>
     <string name="are_you_sure_to_restore_factory_settings">Are you sure to restore factory settings?</string>

+ 2 - 2
BusinessCommon/src/main/res/values-fr/strings.xml

@@ -84,9 +84,9 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="update_the_recipes">Update the recipes</string>
     <string name="apk">APK</string>
     <string name="mcu">MCU</string>
-    <string name="tp">TP</string>
+    <string name="tp">FIRMWARE</string>
     <string name="serial_number">Serial number</string>
-    <string name="standby_time">Standby time</string>
+    <string name="standby_time">MODEL</string>
     <string name="update">Update</string>
     <string name="About">About</string>
     <string name="are_you_sure_to_restore_factory_settings">Are you sure to restore factory settings?</string>

+ 2 - 2
BusinessCommon/src/main/res/values-ja/strings.xml

@@ -80,9 +80,9 @@
     <string name="update_the_recipes">Update the recipes</string>
     <string name="apk">APK</string>
     <string name="mcu">MCU</string>
-    <string name="tp">TP</string>
+    <string name="tp">FIRMWARE</string>
     <string name="serial_number">Serial number</string>
-    <string name="standby_time">Standby time</string>
+    <string name="standby_time">MODEL</string>
     <string name="update">Update</string>
     <string name="About">About</string>
     <string name="are_you_sure_to_restore_factory_settings">Are you sure to restore factory settings?</string>

+ 2 - 2
BusinessCommon/src/main/res/values-zh-rCN/strings.xml

@@ -80,9 +80,9 @@
     <string name="update_the_recipes">Update the recipes</string>
     <string name="apk">APK</string>
     <string name="mcu">MCU</string>
-    <string name="tp">TP</string>
+    <string name="tp">FIRMWARE</string>
     <string name="serial_number">Serial number</string>
-    <string name="standby_time">Standby time</string>
+    <string name="standby_time">MODEL</string>
     <string name="update">Update</string>
     <string name="About">About</string>
     <string name="are_you_sure_to_restore_factory_settings">Are you sure to restore factory settings?</string>

+ 2 - 2
BusinessCommon/src/main/res/values/strings.xml

@@ -84,9 +84,9 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="update_the_recipes">Update the recipes</string>
     <string name="apk">APK</string>
     <string name="mcu">MCU</string>
-    <string name="tp">TP</string>
+    <string name="tp">FIRMWARE</string>
     <string name="serial_number">Serial number</string>
-    <string name="standby_time">Standby time</string>
+    <string name="standby_time">MODEL</string>
     <string name="update">Update</string>
     <string name="About">About</string>
     <string name="are_you_sure_to_restore_factory_settings">Are you sure to restore factory settings?</string>

+ 92 - 5
BusinessSetting/src/main/java/com/develop/setting/ui/AboutActivity.kt

@@ -1,22 +1,28 @@
 package com.develop.setting.ui
 
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
+import android.os.Build
 import android.os.Bundle
+import android.provider.Settings
 import android.view.LayoutInflater
 import android.view.View
+import android.widget.Toast
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.azhon.appupdate.listener.OnDownloadListener
 import com.blankj.utilcode.util.AppUtils
 import com.develop.base.ext.getSN
 import com.develop.base.ext.updateText
 import com.develop.base.util.GlobalToast
-import com.develop.common.food_sdk.GlobalDevEvent
-import com.develop.common.router.Screens
-import com.develop.common.ui.CommonBVMActivity
-import com.develop.common.utils.UpdateUtil
 import com.develop.common.dialog.CancelConfirmDialog
 import com.develop.common.dialog.CommonDialog
 import com.develop.common.dialog.RecipeUpdateDialog
+import com.develop.common.food_sdk.GlobalDevEvent
+import com.develop.common.router.Screens
+import com.develop.common.ui.CommonBVMActivity
 import com.develop.common.utils.AppVersionUtil
+import com.develop.common.utils.UpdateUtil
 import com.develop.setting.databinding.ActivityAboutBinding
 import com.develop.setting.ui.viewmodel.AboutViewModel
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
@@ -25,6 +31,7 @@ import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
 import org.greenrobot.eventbus.Subscribe
 import java.io.File
 
+
 @Route(path = Screens.Setting.ABOUT)
 class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>() {
     override fun createViewBinding(inflater: LayoutInflater): ActivityAboutBinding {
@@ -37,7 +44,11 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
     private var updateApkUrl = ""
 
-    private var weightAlignCount = 0;
+    private var weightAlignCount = 0
+
+    private var adbCount = 0
+
+    private var testCount = 0
 
     private val cancelConfirmDialog by lazy {
         CancelConfirmDialog()
@@ -66,6 +77,14 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
         binding.devSn.text = getSN()
 
+        CofarSDK.devInfo().let {
+            binding.tvMcuVersion.text = (it.manufacturer.toString() + "M" + it.haradware.toString() + "H" + it.software.toString()) + "S" + it.protocol + "P" + it.devType + "D"
+        }
+
+        binding.tvFirmware.text = Build.DISPLAY
+
+        binding.model.text = getSN().substring(4,8)
+
         recipeUpdateDialog.onDialogClickListener =
             object : RecipeUpdateDialog.OnDialogClickListener {
                 override fun onConfirm() {
@@ -171,6 +190,41 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
             cancelConfirmDialog.showDialog(supportFragmentManager, "cancelConfirmDialog")
         }
 
+        binding.tvAppVersion.setOnClickListener{
+            adbCount++
+            if (adbCount >= 7) {
+                adbCount = 0
+                if(isAdbDebuggingEnabled(this)){
+                    Toast.makeText(this, "adb disable", Toast.LENGTH_SHORT).show()
+                    toggleAdbDebugging(this,false)
+                }else{
+                    Toast.makeText(this, "adb enable", Toast.LENGTH_SHORT).show()
+                    toggleAdbDebugging(this,true)
+                }
+
+            }
+        }
+
+
+
+
+        binding.devSn.setOnClickListener{
+            testCount++
+            if (testCount >= 7) {
+                testCount = 0
+                // 创建启动目标活动的Intent
+                val intent = Intent()
+                intent.component = ComponentName(
+                    "com.zavier.androidrk3326functiontest",
+                    "com.zavier.androidrk3326functiontest.MainFunctionActivity"
+                )
+
+                // 启动目标活动
+                startActivity(intent)
+
+            }
+        }
+
         binding.tvAppName.text = AppUtils.getAppName()
         binding.tvAppVersion.text = "v${AppUtils.getAppVersionName()}"
 
@@ -185,6 +239,39 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
     }
 
+
+    fun toggleAdbDebugging(context: Context, enable: Boolean) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+            Settings.Secure.putInt(
+                context.contentResolver,
+                Settings.Global.ADB_ENABLED,
+                if (enable) 1 else 0
+            )
+        } else {
+            Settings.Secure.putInt(
+                context.contentResolver,
+                Settings.Secure.ADB_ENABLED,
+                if (enable) 1 else 0
+            )
+        }
+    }
+
+    fun isAdbDebuggingEnabled(context: Context): Boolean {
+        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+            Settings.Secure.getInt(
+                context.contentResolver,
+                Settings.Global.ADB_ENABLED,
+                0
+            ) != 0
+        } else {
+            Settings.Secure.getInt(
+                context.contentResolver,
+                Settings.Secure.ADB_ENABLED,
+                0
+            ) != 0
+        }
+    }
+
     override fun onResume() {
         super.onResume()
         viewModel.getDevInfo()

+ 4 - 1
BusinessSetting/src/main/res/layout/activity_about.xml

@@ -148,6 +148,7 @@
                 android:textSize="@dimen/convert_30px" />
 
             <androidx.appcompat.widget.AppCompatTextView
+                android:id="@+id/tv_mcu_version"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
@@ -178,6 +179,7 @@
                 android:textSize="@dimen/convert_30px" />
 
             <androidx.appcompat.widget.AppCompatTextView
+                android:id="@+id/tv_firmware"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
@@ -239,12 +241,13 @@
                 android:textSize="@dimen/convert_30px" />
 
             <androidx.appcompat.widget.AppCompatTextView
+                android:id="@+id/model"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
                 android:layout_centerVertical="true"
                 android:layout_marginEnd="@dimen/convert_33px"
-                android:text="2022-5-20"
+                android:text=""
                 android:textColor="@color/color_B1B2B2"
                 android:textSize="@dimen/convert_30px" />
         </RelativeLayout>

+ 2 - 2
app/build.gradle

@@ -8,8 +8,8 @@ plugins {
 
 ext{
 
-    versionCode=230523141
-    brandCode="030A"
+    versionCode=230531110
+    brandCode="010A"
     brandVersionCode=versionCode
     model="1039"
 }

+ 2 - 0
libBase/src/main/AndroidManifest.xml

@@ -2,4 +2,6 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.develop.base">
 
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />
 </manifest>

+ 25 - 2
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -1,7 +1,9 @@
 package com.develop.base.ext
 
+import android.Manifest
 import android.annotation.SuppressLint
 import android.app.Application
+import android.content.Context
 import android.content.pm.PackageManager
 import android.content.res.Resources
 import android.graphics.Bitmap
@@ -9,11 +11,14 @@ import android.graphics.BitmapFactory
 import android.graphics.Color
 import android.graphics.drawable.ColorDrawable
 import android.graphics.drawable.Drawable
+import android.net.wifi.WifiInfo
+import android.net.wifi.WifiManager
 import android.os.Build
 import android.text.TextUtils
 import android.util.Patterns
 import android.widget.ImageView
 import androidx.annotation.DimenRes
+import androidx.core.app.ActivityCompat
 import androidx.core.content.ContextCompat
 import com.bumptech.glide.Glide
 import com.bumptech.glide.load.engine.DiskCacheStrategy
@@ -148,6 +153,24 @@ fun GlobalApp(): Application {
     return BaseApp.application
 }
 
+
+fun getWifiMacAddress(context: Context): String {
+    // 检查是否具有读取Wi-Fi状态的权限
+    if (ActivityCompat.checkSelfPermission(
+            context,
+            Manifest.permission.ACCESS_WIFI_STATE
+        ) != PackageManager.PERMISSION_GRANTED
+    ) {
+        // 无权限,请求权限
+        // 这里需要您自行实现权限请求的逻辑
+        return ""
+    }
+
+    val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
+    val wifiInfo: WifiInfo? = wifiManager.connectionInfo
+    return if(wifiInfo != null) wifiInfo.macAddress else ""
+}
+
 /**
  * 获取SN
  * @return
@@ -162,8 +185,8 @@ fun getSN(): String {
     var vi = plInfo.versionName.split(".");
     append = (vi[1] + vi[0])
     try {
-        serial = Build.SERIAL
-        return if (serial != "" && serial != "unknown") "${append}$serial" else "${append}8888"
+        serial = getWifiMacAddress(globalApp().applicationContext)
+        return if (serial != "" && serial != "unknown") "${append}${serial.replace(":","")}" else "${append}8888"
     } catch (e: java.lang.Exception) {
         serial = "${append}8888"
     }

BIN
libThirdPart/libs/cofar-cooking-device-sdk-0.0.1-SNAPSHOT.jar