浏览代码

7寸月子中心版本修改断网重启

weizhengliang 2 年之前
父节点
当前提交
2c5fe24e34

+ 1 - 1
android_bed/src/main/h7_z_3128_2/java/com/wdkl/app/ncs/callingbed/activity/CallingbedActivity.kt

@@ -1280,7 +1280,7 @@ class CallingbedActivity : BaseActivity<CallingbedActivityPresenter, Callingbed2
         if (Build.MODEL.equals("rk3128")) {
         if (Build.MODEL.equals("rk3128")) {
             Log.e(TAG, "checkNet --> netErrCount: " + netErrCount + ", IP isEmpty: " + TextUtils.isEmpty(NetHelper.getInstance().localIP))
             Log.e(TAG, "checkNet --> netErrCount: " + netErrCount + ", IP isEmpty: " + TextUtils.isEmpty(NetHelper.getInstance().localIP))
             var count = SettingConfig.getNetErrResetCount(activity)
             var count = SettingConfig.getNetErrResetCount(activity)
-            if (!Constant.TCP_CONNECTED && TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
+            if (TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
                 netErrCount++
                 netErrCount++
             } else {
             } else {
                 netErrCount = 0
                 netErrCount = 0

+ 4 - 48
android_bed/src/main/h7_z_3128_2/java/com/wdkl/app/ncs/callingbed/activity/InitActivity.kt

@@ -28,10 +28,7 @@ import com.google.gson.JsonObject
 import com.wdkl.app.ncs.callingbed.BuildConfig
 import com.wdkl.app.ncs.callingbed.BuildConfig
 import com.wdkl.app.ncs.callingbed.R
 import com.wdkl.app.ncs.callingbed.R
 import com.wdkl.app.ncs.callingbed.databinding.ActivityInitBinding
 import com.wdkl.app.ncs.callingbed.databinding.ActivityInitBinding
-import com.wdkl.app.ncs.callingbed.helper.NetHelper
-import com.wdkl.app.ncs.callingbed.helper.PasswordDialogHelper
-import com.wdkl.app.ncs.callingbed.helper.ServerConfigDialogHelper
-import com.wdkl.app.ncs.callingbed.helper.SoundPoolManager
+import com.wdkl.app.ncs.callingbed.helper.*
 import com.wdkl.app.ncs.callingbed.launch.CallingbedLaunch
 import com.wdkl.app.ncs.callingbed.launch.CallingbedLaunch
 import com.wdkl.app.ncs.callingbed.service.APPService
 import com.wdkl.app.ncs.callingbed.service.APPService
 import com.wdkl.app.ncs.callingbed.settings.SettingConfig
 import com.wdkl.app.ncs.callingbed.settings.SettingConfig
@@ -207,17 +204,7 @@ class InitActivity :BaseActivity<WelcomePresenter, ActivityInitBinding>(), Welco
                     count++
                     count++
                     SettingConfig.setNetErrResetCount(activity, count)
                     SettingConfig.setNetErrResetCount(activity, count)
                     AppTool.Time.delay(5000) {
                     AppTool.Time.delay(5000) {
-                        try {
-                            val intent = Intent(Intent.ACTION_REBOOT)
-                            intent.putExtra("nowait", 1)
-                            intent.putExtra("interval", 1)
-                            intent.putExtra("window", 0)
-                            sendBroadcast(intent)
-                        } catch (e: java.lang.Exception) {
-                            e.printStackTrace()
-                        }
-
-                        SerialPortUtil.getInstance().sendCommand(SerialPortUtil.NET_STATUS, "1", "F")
+                        AppUpdateHelper.reboot(activity, true)
                     }
                     }
                 } else {
                 } else {
                     runOnUiThread {
                     runOnUiThread {
@@ -323,7 +310,7 @@ class InitActivity :BaseActivity<WelcomePresenter, ActivityInitBinding>(), Welco
                         showMsgMain("restart...")
                         showMsgMain("restart...")
                         handler.postDelayed({
                         handler.postDelayed({
                             if (!cancelRestart) {
                             if (!cancelRestart) {
-                                reboot()
+                                AppUpdateHelper.reboot(activity, true)
                             }
                             }
                         }, 10000)
                         }, 10000)
                     }
                     }
@@ -551,7 +538,7 @@ class InitActivity :BaseActivity<WelcomePresenter, ActivityInitBinding>(), Welco
 
 
     override fun bindEvent() {
     override fun bindEvent() {
         btn_reboot.setOnClickListener {
         btn_reboot.setOnClickListener {
-            reboot()
+            AppUpdateHelper.reboot(activity, true)
         }
         }
 
 
         btn_reload.setOnClickListener {
         btn_reload.setOnClickListener {
@@ -601,37 +588,6 @@ class InitActivity :BaseActivity<WelcomePresenter, ActivityInitBinding>(), Welco
         }
         }
     }
     }
 
 
-    private fun reboot() {
-        if (Build.MODEL == "rk3128") {
-            try {
-                val intent = Intent(Intent.ACTION_REBOOT)
-                intent.putExtra("nowait", 1)
-                intent.putExtra("interval", 1)
-                intent.putExtra("window", 0)
-                sendBroadcast(intent)
-            } catch (e: java.lang.Exception) {
-                e.printStackTrace()
-            }
-
-            SerialPortUtil.getInstance().sendCommand(SerialPortUtil.NET_STATUS, "1", "F")
-        } else if (Build.MODEL == "rk3288") {
-            val process: Process
-            val printWriter: PrintWriter
-            try {
-                process = Runtime.getRuntime().exec("su")
-                printWriter = PrintWriter(process.outputStream)
-                printWriter.println("reboot")
-                printWriter.flush()
-                printWriter.close()
-                process.waitFor()
-            } catch (e: java.lang.Exception) {
-                e.printStackTrace()
-            }
-        } else {
-            restart()
-        }
-    }
-
     private fun restart() {
     private fun restart() {
         //停止服务
         //停止服务
         val serviceIntent = Intent(BaseApplication.appContext, APPService::class.java)
         val serviceIntent = Intent(BaseApplication.appContext, APPService::class.java)