|
@@ -56,6 +56,8 @@ import serialporttest.utils.SerialPort485Util
|
|
|
import serialporttest.utils.SerialPortUtil
|
|
|
import java.io.DataOutputStream
|
|
|
import java.io.IOException
|
|
|
+import java.io.PrintWriter
|
|
|
+import java.lang.Process
|
|
|
import java.util.*
|
|
|
import kotlin.collections.ArrayList
|
|
|
|
|
@@ -104,6 +106,8 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
|
|
|
private var serverIp = ""
|
|
|
|
|
|
+ private val uninstallApk = false
|
|
|
+
|
|
|
override fun getLayId(): Int {
|
|
|
return R.layout.main_activity_layout;
|
|
|
}
|
|
@@ -153,12 +157,51 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
startRs485()
|
|
|
}.start()*/
|
|
|
|
|
|
+ //卸载原来二代系统apk
|
|
|
+ if (uninstallApk) {
|
|
|
+ //卸载老的5寸分机app
|
|
|
+ Thread {
|
|
|
+ if (checkAppExist()) {
|
|
|
+ uninstallApp()
|
|
|
+ }
|
|
|
+ }.start()
|
|
|
+ }
|
|
|
+
|
|
|
//打开网络调试
|
|
|
AppTool.Time.delay(120000) {
|
|
|
openNetwrokDebug()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun checkAppExist() : Boolean {
|
|
|
+ val packageInfo = packageManager.getInstalledPackages(0)
|
|
|
+ var appExist = false
|
|
|
+ for (pInfo in packageInfo) {
|
|
|
+ val appName = "com.wdkl.tradition"
|
|
|
+ if (appName == pInfo.packageName) {
|
|
|
+ appExist = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.e("callingbed", "callingbed app exist: " + appExist)
|
|
|
+ return appExist
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun uninstallApp() {
|
|
|
+ val process: Process
|
|
|
+ val printWriter: PrintWriter
|
|
|
+ try {
|
|
|
+ process = Runtime.getRuntime().exec("su")
|
|
|
+ printWriter = PrintWriter(process.outputStream)
|
|
|
+ printWriter.println("pm uninstall com.wdkl.tradition")
|
|
|
+ printWriter.flush()
|
|
|
+ printWriter.close()
|
|
|
+ Log.e("uninstall", "uninstall end")
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
+ Log.e("uninstall", "uninstall e:" + e.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//开启网络调试
|
|
|
private fun openNetwrokDebug() {
|
|
|
val commands = arrayListOf(
|