|
@@ -62,6 +62,8 @@ import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
import serialporttest.utils.SerialPort485Util
|
|
|
import serialporttest.utils.SerialPortUtil
|
|
|
+import java.io.DataOutputStream
|
|
|
+import java.io.IOException
|
|
|
import java.util.*
|
|
|
import java.util.UUID
|
|
|
import kotlin.collections.ArrayList
|
|
@@ -161,6 +163,9 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
/*Thread {
|
|
|
startRs485()
|
|
|
}.start()*/
|
|
|
+
|
|
|
+ //打开网络调试
|
|
|
+ openNetwrokDebug()
|
|
|
}
|
|
|
|
|
|
override fun userLogin() {
|
|
@@ -182,6 +187,39 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //开启网络调试
|
|
|
+ private fun openNetwrokDebug() {
|
|
|
+ val commands = arrayListOf(
|
|
|
+ "/system/bin/sh",
|
|
|
+ "setprop service.adb.tcp.port 5555",
|
|
|
+ "stop adbd",
|
|
|
+ "start adbd"
|
|
|
+ )
|
|
|
+ try {
|
|
|
+ RunAsRoot(commands)
|
|
|
+ } catch (e: IOException) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private fun RunAsRoot(cmds: ArrayList<String>) {
|
|
|
+ val p = Runtime.getRuntime().exec("su")
|
|
|
+ val os = DataOutputStream(p.outputStream)
|
|
|
+ for (tmpCmd in cmds) {
|
|
|
+ os.writeBytes(
|
|
|
+ """
|
|
|
+ $tmpCmd
|
|
|
+
|
|
|
+ """.trimIndent()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ os.writeBytes("exit\n")
|
|
|
+ os.flush()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
fun switchFragment(id: Int, fragment: Fragment, tag: String) {
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
.replace(id, fragment, tag)
|