|
@@ -1,6 +1,7 @@
|
|
package com.wdkl.app.ncs.callingdoor.activity
|
|
package com.wdkl.app.ncs.callingdoor.activity
|
|
|
|
|
|
import android.content.*
|
|
import android.content.*
|
|
|
|
+import android.content.pm.PackageManager
|
|
import android.net.ConnectivityManager
|
|
import android.net.ConnectivityManager
|
|
import android.os.*
|
|
import android.os.*
|
|
import android.text.TextUtils
|
|
import android.text.TextUtils
|
|
@@ -13,6 +14,7 @@ import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
import com.google.gson.reflect.TypeToken
|
|
import com.google.gson.reflect.TypeToken
|
|
|
|
+import com.lztek.toolkit.Lztek
|
|
import com.wdkl.app.ncs.callingdoor.BuildConfig
|
|
import com.wdkl.app.ncs.callingdoor.BuildConfig
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
import com.wdkl.app.ncs.callingdoor.agreement.CallingdoorAgreement
|
|
import com.wdkl.app.ncs.callingdoor.agreement.CallingdoorAgreement
|
|
@@ -243,6 +245,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
|
|
|
if ("rk3128".equals(Build.MODEL)) {
|
|
if ("rk3128".equals(Build.MODEL)) {
|
|
checkLaunch()
|
|
checkLaunch()
|
|
|
|
+ } else if (BuildConfig.flag.equals(Constant.DEV_W_DX)) {
|
|
|
|
+ //启动监听app安装完成服务
|
|
|
|
+ startYunpaiPlugin()
|
|
}
|
|
}
|
|
|
|
|
|
val dm = resources.displayMetrics
|
|
val dm = resources.displayMetrics
|
|
@@ -318,6 +323,81 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun startYunpaiPlugin() {
|
|
|
|
+ try {
|
|
|
|
+ val packageInfos = packageManager.getInstalledPackages(
|
|
|
|
+ PackageManager.GET_ACTIVITIES or
|
|
|
|
+ PackageManager.GET_SERVICES
|
|
|
|
+ )
|
|
|
|
+ var needInstall = false
|
|
|
|
+ for (info in packageInfos) {
|
|
|
|
+ val pkg = info.packageName
|
|
|
|
+ if (pkg.equals("com.wd.app")) {
|
|
|
|
+ //启动云派app升级监听服务
|
|
|
|
+ val intent = Intent()
|
|
|
|
+ intent.setClassName("com.wd.app", "com.wd.app.MyService")
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
+ //android8.0以上通过startForegroundService启动service
|
|
|
|
+ startForegroundService(intent)
|
|
|
|
+ } else {
|
|
|
|
+ startService(intent)
|
|
|
|
+ }
|
|
|
|
+ Constant.yunpai_plugin = true
|
|
|
|
+ needInstall = false
|
|
|
|
+ break
|
|
|
|
+ } else {
|
|
|
|
+ needInstall = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (needInstall) {
|
|
|
|
+ //拷贝并安装云派app升级服务apk
|
|
|
|
+ Log.d(TAG,"准备安装升级服务apk")
|
|
|
|
+ Thread{
|
|
|
|
+ try {
|
|
|
|
+ val fileName = "wd_update_plugin.apk"
|
|
|
|
+ val dstPath = Environment.getExternalStorageDirectory().path + "/Download"
|
|
|
|
+ val file = File(dstPath)
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
+ file.mkdirs()
|
|
|
|
+ }
|
|
|
|
+ val filePath = dstPath + "/" + fileName
|
|
|
|
+ val outFile = File(filePath)
|
|
|
|
+ if (outFile.exists()) {
|
|
|
|
+ outFile.delete()
|
|
|
|
+ }
|
|
|
|
+ val inputStream: InputStream = getAssets().open(fileName)
|
|
|
|
+ val fos = FileOutputStream(outFile)
|
|
|
|
+ val buffer = ByteArray(1024)
|
|
|
|
+ var byteCount = 0
|
|
|
|
+ while (inputStream.read(buffer).also { byteCount = it } != -1) {
|
|
|
|
+ fos.write(buffer, 0, byteCount)
|
|
|
|
+ }
|
|
|
|
+ fos.flush()
|
|
|
|
+ inputStream.close()
|
|
|
|
+ fos.close()
|
|
|
|
+
|
|
|
|
+ if (BuildConfig.flag.equals(Constant.DEV_W_DX)) {
|
|
|
|
+ val lztek = Lztek.create(BaseApplication.appContext)
|
|
|
|
+ lztek.installApplication(filePath)
|
|
|
|
+ } else {
|
|
|
|
+ AppUpdateHelper.rootSilenceInstall(filePath)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ showMessage(R.string.plugin_update_tips)
|
|
|
|
+ }
|
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
|
+ e.printStackTrace()
|
|
|
|
+ }
|
|
|
|
+ }.start()
|
|
|
|
+ }
|
|
|
|
+ } catch (t: Throwable) {
|
|
|
|
+ t.printStackTrace()
|
|
|
|
+ showMessage(StringUtil.getResString(R.string.plugin_start_failed) + t.message)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
private fun startScheduledExecutor() {
|
|
private fun startScheduledExecutor() {
|