|
@@ -3,6 +3,7 @@ package com.wdkl.app.ncs.application
|
|
|
import android.content.Context
|
|
|
import android.content.res.Configuration
|
|
|
import android.os.Build
|
|
|
+import android.util.Log
|
|
|
import com.enation.javashop.android.jrouter.JRouter
|
|
|
import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
|
import com.enation.javashop.net.engine.config.NetEngineConfig
|
|
@@ -11,6 +12,7 @@ import com.enation.javashop.utils.base.config.BaseConfig
|
|
|
import com.wdkl.app.ncs.callingbed.helper.*
|
|
|
import com.wdkl.app.ncs.callingbed.settings.SettingConfig
|
|
|
import serialporttest.utils.SerialPortUtil
|
|
|
+import java.io.PrintWriter
|
|
|
|
|
|
/**
|
|
|
* @author LDD
|
|
@@ -19,7 +21,9 @@ import serialporttest.utils.SerialPortUtil
|
|
|
* @Note 应用Application
|
|
|
*/
|
|
|
class Application : BaseApplication() {
|
|
|
-
|
|
|
+ private val TAG = "wdkl_app"
|
|
|
+ private val uninstallApk = false
|
|
|
+ private val APP_NAME = "com.wdkl.callingbed2"
|
|
|
|
|
|
/**
|
|
|
* @author LDD
|
|
@@ -83,6 +87,16 @@ class Application : BaseApplication() {
|
|
|
//open serial port
|
|
|
if (Build.MODEL.equals("rk3128")) {
|
|
|
SerialPortUtil.getInstance().openSerialPort()
|
|
|
+
|
|
|
+ //卸载原来二代系统床头分机apk
|
|
|
+ if (uninstallApk) {
|
|
|
+ //卸载老的二代app
|
|
|
+ Thread {
|
|
|
+ if (checkAppExist()) {
|
|
|
+ uninstallApp()
|
|
|
+ }
|
|
|
+ }.start()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -96,6 +110,34 @@ class Application : BaseApplication() {
|
|
|
Utils.checkCameraSupport()
|
|
|
}
|
|
|
|
|
|
+ private fun checkAppExist() : Boolean {
|
|
|
+ val packageInfo = packageManager.getInstalledPackages(0)
|
|
|
+ var appExist = false
|
|
|
+ for (pInfo in packageInfo) {
|
|
|
+ if (APP_NAME == pInfo.packageName) {
|
|
|
+ appExist = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.e(TAG, "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 " + APP_NAME)
|
|
|
+ printWriter.flush()
|
|
|
+ printWriter.close()
|
|
|
+ Log.e(TAG, "uninstall end")
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
+ Log.e(TAG, "uninstall e:" + e.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
override fun attachBaseContext(base: Context) {
|
|
|
val languageId: Int = SettingConfig.getLanguageId(base)
|