|
@@ -1,9 +1,12 @@
|
|
|
package com.wdkl.app.ncs.callingdoor.activity
|
|
|
|
|
|
+import android.content.Intent
|
|
|
+import android.os.Build
|
|
|
import android.text.TextUtils
|
|
|
import android.util.Log
|
|
|
import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
|
+import com.example.yf_rk3288_api.YF_RK3288_API_Manager
|
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
|
import com.wdkl.app.ncs.callingdoor.databinding.UpdateLayBinding
|
|
|
import com.wdkl.app.ncs.callingdoor.helper.AppUpdateHelper
|
|
@@ -17,6 +20,7 @@ import com.wdkl.ncs.android.middleware.common.Constant
|
|
|
import com.wdkl.ncs.android.middleware.logic.contract.callingdoor.AppUpdateContract
|
|
|
import com.wdkl.ncs.android.middleware.logic.presenter.callingdoor.AppUpdatePresenter
|
|
|
import kotlinx.android.synthetic.main.update_lay.*
|
|
|
+import java.io.File
|
|
|
|
|
|
@Router(path = "/callingdoor/update")
|
|
|
class AppUpdateActivity :BaseActivity<AppUpdatePresenter, UpdateLayBinding>(), AppUpdateContract.View {
|
|
@@ -33,6 +37,7 @@ class AppUpdateActivity :BaseActivity<AppUpdatePresenter, UpdateLayBinding>(), A
|
|
|
}
|
|
|
|
|
|
override fun init() {
|
|
|
+ Constant.APP_UPDATING = true
|
|
|
if (!TextUtils.isEmpty(Constant.APP_PATH)) {
|
|
|
val downloadPath = urlManager.base + Constant.APP_PATH
|
|
|
Log.e(TAG, "start download: $downloadPath")
|
|
@@ -49,17 +54,36 @@ class AppUpdateActivity :BaseActivity<AppUpdatePresenter, UpdateLayBinding>(), A
|
|
|
fun downLoadAPK(url: String) {
|
|
|
Log.d(TAG, "downLoadAPK url==$url")
|
|
|
activity_appupdate_dialog_progressview.setCurProgress(0)
|
|
|
- HttpHelper.download(url, object : HttpHelper.DownloadListener {
|
|
|
+ activity_update_version.setText(Constant.APP_PATH.substringAfterLast("/"))
|
|
|
+ activity_update_version.setOnLongClickListener {
|
|
|
+ Log.d(TAG, "downLoadAPK cancel...")
|
|
|
+ HttpHelper.cancelRequestByTag(TAG)
|
|
|
+ activity.finish()
|
|
|
+
|
|
|
+ return@setOnLongClickListener true
|
|
|
+ }
|
|
|
+
|
|
|
+ HttpHelper.download(url, TAG, object : HttpHelper.DownloadListener {
|
|
|
override fun onDownloadSuccess() {
|
|
|
Log.d("download", "onDownloadSuccess==" + "成功")
|
|
|
if (Constant.silentUpdate) {
|
|
|
runOnUiThread {
|
|
|
- activity_calling_bed_text_download.text = "正在安装,请稍后..."
|
|
|
+ activity_update_text_download.text = "正在安装,请稍后..."
|
|
|
+ }
|
|
|
+ if ("rk3288".equals(Build.MODEL)) {
|
|
|
+ installApkForRk3288()
|
|
|
+ } else {
|
|
|
+ startInstallApk()
|
|
|
}
|
|
|
- startInstallApk()
|
|
|
} else {
|
|
|
- installApk()
|
|
|
- finish()
|
|
|
+ if ("rk3288".equals(Build.MODEL)) {
|
|
|
+ runOnUiThread {
|
|
|
+ activity_update_text_download.text = "正在安装,请稍后..."
|
|
|
+ }
|
|
|
+ installApkForRk3288()
|
|
|
+ } else {
|
|
|
+ AppUpdateHelper.installAPK(activity)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -99,9 +123,21 @@ class AppUpdateActivity :BaseActivity<AppUpdatePresenter, UpdateLayBinding>(), A
|
|
|
}.start()
|
|
|
}
|
|
|
|
|
|
- //手动升级
|
|
|
- fun installApk() {
|
|
|
- AppUpdateHelper.installAPK(this)
|
|
|
+
|
|
|
+ fun installApkForRk3288() {
|
|
|
+ val path = AppUpdateHelper.FILE_APK_PATH + "/" + AppUpdateHelper.FILE_APK_NAME
|
|
|
+ if (File(path).exists()) {
|
|
|
+ //val yfRk3288ApiManager = YF_RK3288_API_Manager(activity)
|
|
|
+ //yfRk3288ApiManager.yfslientinstallapk(path)
|
|
|
+
|
|
|
+ val intent = Intent("com.android.yf_slient_install")
|
|
|
+ intent.putExtra("path", path) //要静默安装的apk路径
|
|
|
+ intent.putExtra("isboot", true) //安装完成后是否启动
|
|
|
+ sendBroadcast(intent)
|
|
|
+ } else {
|
|
|
+ showMessage("安装文件不存在,升级失败!")
|
|
|
+ finish()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun bindEvent() {
|
|
@@ -109,7 +145,7 @@ class AppUpdateActivity :BaseActivity<AppUpdatePresenter, UpdateLayBinding>(), A
|
|
|
}
|
|
|
|
|
|
override fun destory() {
|
|
|
- //
|
|
|
+ Constant.APP_UPDATING = false
|
|
|
}
|
|
|
|
|
|
//数据加载错误
|