|
@@ -0,0 +1,937 @@
|
|
|
+package com.wdkl.app.ncs.callingbed.activity
|
|
|
+
|
|
|
+
|
|
|
+import android.content.*
|
|
|
+import android.content.pm.PackageManager
|
|
|
+import android.graphics.Color
|
|
|
+import android.net.ConnectivityManager
|
|
|
+import android.os.*
|
|
|
+import android.provider.Settings
|
|
|
+import android.text.TextUtils
|
|
|
+import android.util.Log
|
|
|
+import android.view.KeyEvent
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewTreeObserver
|
|
|
+import androidx.fragment.app.Fragment
|
|
|
+import com.alibaba.fastjson.JSON
|
|
|
+import com.alibaba.fastjson.JSONObject
|
|
|
+import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
|
+import com.enation.javashop.net.engine.model.NetState
|
|
|
+import com.google.gson.Gson
|
|
|
+
|
|
|
+import com.wdkl.app.ncs.callingbed.BuildConfig
|
|
|
+import com.wdkl.app.ncs.callingbed.R
|
|
|
+import com.wdkl.app.ncs.callingbed.agreement.CallingbedAgreement
|
|
|
+import com.wdkl.app.ncs.callingbed.bt_gateway.*
|
|
|
+import com.wdkl.app.ncs.callingbed.databinding.CallingbedMainNewBinding
|
|
|
+
|
|
|
+import com.wdkl.app.ncs.callingbed.fragment.*
|
|
|
+import com.wdkl.app.ncs.callingbed.hardware.HardWareFactory
|
|
|
+import com.wdkl.app.ncs.callingbed.helper.*
|
|
|
+import com.wdkl.app.ncs.callingbed.launch.CallingbedLaunch
|
|
|
+import com.wdkl.app.ncs.callingbed.settings.SettingConfig
|
|
|
+import com.wdkl.app.ncs.callingbed.sleep.SleepService
|
|
|
+
|
|
|
+import com.wdkl.ncs.android.lib.base.BaseActivity
|
|
|
+import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
|
+import com.wdkl.ncs.android.lib.core.locale.LocaleMangerUtils
|
|
|
+import com.wdkl.ncs.android.lib.core.locale.SettingConfigNew
|
|
|
+import com.wdkl.ncs.android.lib.utils.*
|
|
|
+import com.wdkl.ncs.android.lib.vo.filter
|
|
|
+import com.wdkl.ncs.android.middleware.common.Constant
|
|
|
+import com.wdkl.ncs.android.middleware.common.MessageEvent
|
|
|
+import com.wdkl.ncs.android.middleware.entity.CallingItem
|
|
|
+import com.wdkl.ncs.android.middleware.logic.contract.callingbed.BedCallingbedActivityContract
|
|
|
+import com.wdkl.ncs.android.middleware.logic.presenter.callingbed.BedCallingbedActivityPresenter
|
|
|
+import com.wdkl.ncs.android.middleware.model.ServerInfo
|
|
|
+import com.wdkl.ncs.android.middleware.model.dos.AppVersionDO
|
|
|
+import com.wdkl.ncs.android.middleware.model.dos.DeviceDO
|
|
|
+import com.wdkl.ncs.android.middleware.model.dos.PartSettingDO
|
|
|
+import com.wdkl.ncs.android.middleware.model.dos.RoleDO
|
|
|
+import com.wdkl.ncs.android.middleware.model.dto.TcpSeverDTO
|
|
|
+import com.wdkl.ncs.android.middleware.model.vo.*
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.channel.*
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.DeviceTypeEnum
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
|
+import com.wdkl.ncs.android.middleware.utils.CommonUtils
|
|
|
+import com.wdkl.ncs.android.middleware.utils.StringUtil
|
|
|
+import com.wdkl.ncs.janus.util.JanusConstant
|
|
|
+import kotlinx.android.synthetic.main.acivity_time_setting.*
|
|
|
+import kotlinx.android.synthetic.main.callingbed_main_new.*
|
|
|
+import kotlinx.android.synthetic.main.callingbed_setting_main.*
|
|
|
+import kotlinx.android.synthetic.main.callingbed_test_main.*
|
|
|
+import kotlinx.android.synthetic.main.view_title_layout.*
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
+import java.io.File
|
|
|
+import java.io.FileOutputStream
|
|
|
+import java.io.InputStream
|
|
|
+import java.util.*
|
|
|
+import kotlin.collections.ArrayList
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Callingbed2Activity :BaseActivity<Callingbed2ActivityPresenter, Callingbed2MainLayBinding>
|
|
|
+ * Callingbed2ActivityPresenter: 位置com.wdkl.ncs.android.middleware.logic.presenter.callingbed2
|
|
|
+ * Callingbed2MainLayBinding: 位置callingbed2_main_lay.xml
|
|
|
+ * Callingbed2ActivityContract: 位置com.wdkl.ncs.android.middleware.logic.contract.callingbed2
|
|
|
+ */
|
|
|
+
|
|
|
+@Router(path = "/callingbed/main")
|
|
|
+class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, CallingbedMainNewBinding>(), BedCallingbedActivityContract.View, CallingbedAgreement {
|
|
|
+
|
|
|
+ var TAG = CallingbedActivity::class.java.getSimpleName()
|
|
|
+
|
|
|
+ private lateinit var receiver: TimeReceiver
|
|
|
+
|
|
|
+ private var curFragment = ""
|
|
|
+ //首页
|
|
|
+ private val mainFragment = "main_fragment"
|
|
|
+ //公寓首页
|
|
|
+ private val apartmentFragment = "apartment_fragment"
|
|
|
+
|
|
|
+ private var initialized :Boolean = false
|
|
|
+ private var tcpConnect: Boolean = false
|
|
|
+ private var loaded: Boolean = false
|
|
|
+
|
|
|
+ //网络异常计数
|
|
|
+ private var netErrCount : Int = 0
|
|
|
+
|
|
|
+ private val handler by lazy { Handler(Looper.getMainLooper()) }
|
|
|
+
|
|
|
+ private var SleepIntent: Intent? = null
|
|
|
+ private var service_sl: SLService? = null
|
|
|
+ private var SleepServiceBinder: SleepService.ServiceBinder? = null
|
|
|
+ private var bindSleepService = false
|
|
|
+
|
|
|
+ private var copyDone = false
|
|
|
+
|
|
|
+ private var language = "zh"
|
|
|
+
|
|
|
+ companion object {
|
|
|
+ //lateinit var instance: CallingbedActivity
|
|
|
+ var sosItemList = ArrayList<CallingItem>()
|
|
|
+ var callingList = ArrayList<CallingItem>()
|
|
|
+
|
|
|
+ fun checkIncomingCall(bedDeviceId: Int?): Boolean {
|
|
|
+ if (callingList.size > 0) {
|
|
|
+ for (item in callingList) {
|
|
|
+ if (item.interactionVO.fromDeviceId == bedDeviceId) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ override fun getLayId(): Int {
|
|
|
+ return R.layout.callingbed_main_new
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun bindDagger() {
|
|
|
+ CallingbedLaunch.component.inject(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun init() {
|
|
|
+ //直接
|
|
|
+ if (!apartmentFragment.equals(curFragment)) {
|
|
|
+ switchFragment(R.id.callingbed_main_frame, apartmentFragment(), apartmentFragment)
|
|
|
+ }
|
|
|
+
|
|
|
+ language = LocaleMangerUtils.getApplicationLocale().language
|
|
|
+
|
|
|
+ //注册广播
|
|
|
+ regReceiver()
|
|
|
+
|
|
|
+ RecordHelper.getInstance().init()
|
|
|
+
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
+
|
|
|
+ SoundPoolManager.getInstance().init()
|
|
|
+
|
|
|
+ //更新状态图标
|
|
|
+ updateNetState()
|
|
|
+
|
|
|
+ //禁止下拉状态栏
|
|
|
+ Utils.setStatusBarDisable(activity, Utils.STATUS_BAR_DISABLE_EXPAND)
|
|
|
+
|
|
|
+ //保持屏幕常亮
|
|
|
+// AppTool.Setting.setScreenOffTimeOut(applicationContext, 35000)
|
|
|
+
|
|
|
+ presenter.loadServerInfo()
|
|
|
+
|
|
|
+ SpeechUtil.getInstance().init(applicationContext)
|
|
|
+ val dm = resources.displayMetrics
|
|
|
+ Constant.DEVICE_WIDTH = dm.widthPixels
|
|
|
+ Constant.DEVICE_HEIGHT = dm.heightPixels
|
|
|
+ Constant.DEVICE_ORIENTATION = resources.configuration.orientation
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private fun switchFragment(id: Int, fragment: Fragment, tag: String) {
|
|
|
+ supportFragmentManager.beginTransaction()
|
|
|
+ .replace(id, fragment, tag)
|
|
|
+ .commitAllowingStateLoss()
|
|
|
+ curFragment = tag
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initDevice() {
|
|
|
+ if (!TextUtils.isEmpty(Constant.DEVICE_REGISTER_ID)) {
|
|
|
+ presenter.loadDeviceInfo(Constant.DEVICE_REGISTER_ID)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ override fun bindEvent() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun checkAppVersion() {
|
|
|
+ Constant.APP_PATH = ""
|
|
|
+ //获取APP版本信息,7寸分机type=204,8寸可视分机用104
|
|
|
+ if (Constant.PART_ID != null) {
|
|
|
+ //判断是不是探视分机 ,伊莱顿类型分机主要用在探视分机,在后台更新项也必须添加到可视类型
|
|
|
+ if (BuildConfig.flag == Constant.DEV_W_YLD) {
|
|
|
+ presenter.getAppVersion(Constant.PART_ID, 104)
|
|
|
+ } else {
|
|
|
+ presenter.getAppVersion(Constant.PART_ID, 204)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.d("AppUpdate", "checkAppVersion =====>> Constant.PART_ID: " + Constant.PART_ID)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ override fun onStart() {
|
|
|
+ super.onStart()
|
|
|
+ //设备已注册,隐藏导航栏
|
|
|
+ if (Constant.DEVICE_ID != -1 && Settings.System.canWrite(this)) {
|
|
|
+ Utils.hideStatusBar(activity, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun destory() {
|
|
|
+ unRegReceiver()
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
+ Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
+
|
|
|
+ HardWareFactory.getHardTools().unInit()
|
|
|
+ handler.removeCallbacksAndMessages(null)
|
|
|
+ SoundPoolManager.getInstance().release()
|
|
|
+
|
|
|
+ stopSLService()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据加载错误
|
|
|
+ override fun onError(message: String, type: Int) {
|
|
|
+ showMessage(message)
|
|
|
+ }
|
|
|
+
|
|
|
+ //没有网络
|
|
|
+ override fun onNoNet() {
|
|
|
+ showMessage("none network")
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据加载完成
|
|
|
+ override fun complete(message: String, type: Int) {
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始获取数据
|
|
|
+ override fun start() {
|
|
|
+ }
|
|
|
+
|
|
|
+ //网络监听
|
|
|
+ override fun networkMonitor(state: NetState) {
|
|
|
+ state.filter(onMobile = {
|
|
|
+
|
|
|
+ }, onWifi = {
|
|
|
+
|
|
|
+ }, offline = {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //显示设备信息
|
|
|
+ override fun showDeviceInfo(deviceInfo: BedDeviceInfoVO) {
|
|
|
+ Constant.SIP_ID = deviceInfo.sipId
|
|
|
+ Constant.DEVICE_ID = deviceInfo.id
|
|
|
+ Constant.PART_ID = deviceInfo.partId
|
|
|
+ Constant.BED_NAME = deviceInfo.fullName
|
|
|
+
|
|
|
+ Constant.DEVICE_CODE = deviceInfo.code
|
|
|
+ Constant.DEVICE_MODEL = deviceInfo.model
|
|
|
+ Constant.DEVICE_SOFT_VER = deviceInfo.softVer
|
|
|
+ Constant.DEVICE_HARD_VER = deviceInfo.hardVer
|
|
|
+ Constant.DEVICE_INFO = Gson().toJson(deviceInfo)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (deviceInfo.status != null) {
|
|
|
+ Constant.DEVICE_STATUS = deviceInfo.status
|
|
|
+ }
|
|
|
+ view_title_layout_tv_hospital_name.text = deviceInfo.partDisplay
|
|
|
+
|
|
|
+ if (deviceInfo.partName != null) {
|
|
|
+ Constant.PART_NAME = deviceInfo.partName
|
|
|
+ }
|
|
|
+ if (deviceInfo.part_union_id != null) {
|
|
|
+ Constant.PART_UNION_ID = deviceInfo.part_union_id
|
|
|
+ }
|
|
|
+
|
|
|
+ view_title_layout_tv_hospital_name.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
|
|
+ override fun onGlobalLayout() {
|
|
|
+ if (view_title_layout_tv_hospital_name.width < view_title_layout_tv_hospital_name.paint.measureText(view_title_layout_tv_hospital_name.text.toString())) {
|
|
|
+ view_title_layout_tv_hospital_name.isSelected = true // 开启跑马灯效果
|
|
|
+ view_title_layout_tv_hospital_name.isFocusable = true
|
|
|
+ view_title_layout_tv_hospital_name.isFocusableInTouchMode = true
|
|
|
+ view_title_layout_tv_hospital_name.requestFocus()
|
|
|
+ } else {
|
|
|
+ view_title_layout_tv_hospital_name.isSelected = false // 关闭跑马灯效果
|
|
|
+ view_title_layout_tv_hospital_name.isFocusable = false
|
|
|
+ view_title_layout_tv_hospital_name.isFocusableInTouchMode = false
|
|
|
+ }
|
|
|
+ view_title_layout_tv_hospital_name.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ view_title_layout_tv_no.text = "ID: " + deviceInfo.id
|
|
|
+ initialized = true
|
|
|
+
|
|
|
+ if (deviceInfo.customerId != null) {
|
|
|
+ Constant.CUSTOM_ID = deviceInfo.customerId
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceInfo.memberId != null) {
|
|
|
+ Constant.MEMBER_ID = deviceInfo.memberId
|
|
|
+ }
|
|
|
+
|
|
|
+ Utils.hideStatusBar(activity, true)
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(Constant.SIP_ID)) {
|
|
|
+ showMessage("SIP ID empty")
|
|
|
+ }
|
|
|
+ if (Constant.DEVICE_STATUS == 0) {
|
|
|
+ showMessage(R.string.device_disable)
|
|
|
+ }
|
|
|
+
|
|
|
+ //加载分机所绑定紧急按钮设备信息
|
|
|
+ if (deviceInfo.frameId != null) {
|
|
|
+ Constant.FRAME_ID = deviceInfo.frameId
|
|
|
+ presenter.getEmergencyDeviceInfo(deviceInfo.frameId)
|
|
|
+ presenter.loadDevicesList(Constant.FRAME_ID)
|
|
|
+ }
|
|
|
+ presenter.loadPartSettings(Constant.PART_ID)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showCustomInfo(customInfo: CustomerInfoVO) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //显示交互记录
|
|
|
+ override fun showCallRecords(record: CallRecordVO) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun setPartSettings(partSetting: PartSettingDO) {
|
|
|
+ try {
|
|
|
+ //设置白昼起止时间
|
|
|
+ SettingConfig.setInitialDayTime(this, partSetting.dayStart.substring(0, 5))
|
|
|
+ SettingConfig.setEndOfDay(this, partSetting.nightStart.substring(0, 5))
|
|
|
+
|
|
|
+ //分机白天夜晚亮度
|
|
|
+ SettingConfig.setExtensionDaytimeBrightness(this, partSetting.dayLight)
|
|
|
+ SettingConfig.setExtensionNightBrightness(this, partSetting.nightLight)
|
|
|
+
|
|
|
+ //分机白天夜晚护理灯 也就是LED灯的亮度
|
|
|
+ SettingConfig.setExtensionDaytimeLEDBrightness(this, partSetting.dayNurseLed)
|
|
|
+ SettingConfig.setExtensionNightLEDBrightness(this, partSetting.nightNurseLed)
|
|
|
+
|
|
|
+ //分机白天夜晚系统音量
|
|
|
+ SettingConfig.setExtensionDaytimeSystemVolume(this, partSetting.dayBedVol)
|
|
|
+ SettingConfig.setExtensionNightSystemVolume(this, partSetting.nightBedVol)
|
|
|
+
|
|
|
+ //分机通话音量 没做白昼区分
|
|
|
+ SettingConfig.setExtensionCallVolume(this, partSetting.dayBedVol)
|
|
|
+
|
|
|
+ SettingConfig.setSipOverTime(this, partSetting.sipOvertime)
|
|
|
+ SettingConfig.setSleepTime(this, partSetting.sleepSecondsBed)
|
|
|
+
|
|
|
+ Constant.doctorTitle = partSetting.doctorTitle
|
|
|
+ Constant.nurseTitle = partSetting.nurseTitle
|
|
|
+ if (partSetting.doctorValid != null) {
|
|
|
+ Constant.doctorValid = partSetting.doctorValid
|
|
|
+ }
|
|
|
+ if (partSetting.nurseValid != null) {
|
|
|
+ Constant.nurseValid = partSetting.nurseValid
|
|
|
+ }
|
|
|
+
|
|
|
+ VoiceManagerUtil.setCallVoice(activity, partSetting.dayBedVol)
|
|
|
+
|
|
|
+ if (partSetting.autoAccept != null && partSetting.autoAccept == 1) {
|
|
|
+ SettingConfig.setAutoAnswer(activity, true)
|
|
|
+ } else {
|
|
|
+ SettingConfig.setAutoAnswer(activity, false)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (partSetting.convenientServiceEnabled != null) {
|
|
|
+ Constant.convenientServiceEnabled = partSetting.convenientServiceEnabled
|
|
|
+ }
|
|
|
+
|
|
|
+ if (partSetting.recordEnabled != null && partSetting.recordEnabled == 1) {
|
|
|
+ SettingConfig.setRecordEnable(activity, true)
|
|
|
+ } else {
|
|
|
+ SettingConfig.setRecordEnable(activity, false)
|
|
|
+ }
|
|
|
+ HardWareFactory.getHardTools().setTime(this, 0, partSetting.time_zone)
|
|
|
+
|
|
|
+ //通过服务端设置语言
|
|
|
+ if (SettingConfigNew.getLanguageMode(activity) == 0) {
|
|
|
+ var needReboot = false
|
|
|
+ if ("cn".equals(partSetting.language)) {
|
|
|
+ //中文
|
|
|
+ if (SettingConfigNew.getLanguageId(activity) != 2) {
|
|
|
+ needReboot = true
|
|
|
+ }
|
|
|
+ SettingConfigNew.setLanguageId(activity, 2)
|
|
|
+ } else if ("en".equals(partSetting.language)) {
|
|
|
+ //英文
|
|
|
+ if (SettingConfigNew.getLanguageId(activity) != 1) {
|
|
|
+ needReboot = true
|
|
|
+ }
|
|
|
+ SettingConfigNew.setLanguageId(activity, 1)
|
|
|
+ } else if ("es".equals(partSetting.language)) {
|
|
|
+ //西班牙语
|
|
|
+ if (SettingConfigNew.getLanguageId(activity) != 3) {
|
|
|
+ needReboot = true
|
|
|
+ }
|
|
|
+ SettingConfigNew.setLanguageId(activity, 3)
|
|
|
+ } else if ("ru".equals(partSetting.language)) {
|
|
|
+ //俄语
|
|
|
+ if (SettingConfigNew.getLanguageId(activity) != 4) {
|
|
|
+ needReboot = true
|
|
|
+ }
|
|
|
+ SettingConfigNew.setLanguageId(activity, 4)
|
|
|
+ }
|
|
|
+ if (needReboot) {
|
|
|
+ handler.postDelayed({
|
|
|
+ AppUpdateHelper.restartApp(activity)
|
|
|
+ }, 10000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (ex: Exception) {
|
|
|
+ showMessage(StringUtil.getResString(R.string.setting_params_error) + ex.message)
|
|
|
+ ex.printStackTrace()
|
|
|
+ }
|
|
|
+
|
|
|
+ updateSettings(true)
|
|
|
+
|
|
|
+ EventBus.getDefault().post(MessageEvent("updateCustom", Constant.EVENT_UPDATE_CUSTOM))
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun setTcpServerHost(tcpSeverDTO: TcpSeverDTO) {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun setServerInfo(data: ServerInfo) {
|
|
|
+ if (loaded) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ loaded = true
|
|
|
+ Constant.TCP_SERVER_URL = data.tcpLocalIp
|
|
|
+ Constant.TCP_PORT = data.tcpPort
|
|
|
+ Constant.TCP_HEART_BEAT = data.tcpIdleSeconds
|
|
|
+ JanusConstant.JANUS_URL = "ws://" + data.rtcLocalIp + ":" + data.rtcPort
|
|
|
+ JanusConstant.STUN_SERVER = arrayOf<String>(data.stunServer)
|
|
|
+ //JanusConstant.TURN_SERVER = data.turnServer
|
|
|
+
|
|
|
+ JanusConstant.Record_Dir = data.recordDir
|
|
|
+
|
|
|
+ if (data.tcpVsPort != null) {
|
|
|
+ Constant.TCP_VS_PORT = data.tcpVsPort
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.httpSystemPort != null) {
|
|
|
+ Constant.HTTP_SERVER_URL = "http://" + data.httpLocalIp + ":" + data.httpSystemPort
|
|
|
+ }
|
|
|
+
|
|
|
+ //开启TCP连接
|
|
|
+ startTcp()
|
|
|
+ showMessage("tcp connect...host: " + Constant.TCP_SERVER_URL + ", port: " + Constant.TCP_PORT)
|
|
|
+
|
|
|
+ SettingConfig.setNetErrResetCount(this, 0)
|
|
|
+ WarningDialogHelper.dismiss()
|
|
|
+
|
|
|
+ if (data.sipIp != null) {
|
|
|
+ Constant.sip_ip = data.sipIp
|
|
|
+ }
|
|
|
+ if (data.sipPort != null) {
|
|
|
+ Constant.sip_port = data.sipPort
|
|
|
+ }
|
|
|
+
|
|
|
+ Thread(Runnable {
|
|
|
+ while (!initialized) {
|
|
|
+ runOnUiThread(Runnable {
|
|
|
+ initDevice()
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ Thread.sleep(20000)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).start()
|
|
|
+
|
|
|
+ if (SettingConfig.getSLEEPGatewayOn(activity)) {
|
|
|
+ //启动床垫服务
|
|
|
+ startSLService()
|
|
|
+ }
|
|
|
+
|
|
|
+ //30s后检查版本
|
|
|
+ handler.postDelayed({
|
|
|
+ //检查版本
|
|
|
+ checkAppVersion()
|
|
|
+ }, 30000)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun loadAppVersion(appInfo: AppVersionDO) {
|
|
|
+ val newAppVersion = appInfo.versionCode.substring(1)
|
|
|
+ Log.d("AppUpdate", "loadAppVersion =====>> newAppVersion: " + newAppVersion + ", curAppVersion: " + BuildConfig.VERSION_NAME + ", path: " + appInfo.appPath)
|
|
|
+ showMessage("current version: " + BuildConfig.VERSION_NAME + "_" + BuildConfig.VERSION_CODE + ", new version: " + newAppVersion + "_" + appInfo.versionNo)
|
|
|
+ var version = BuildConfig.VERSION_CODE.toInt()
|
|
|
+ if (version < appInfo.versionNo) {
|
|
|
+ if (!Constant.APP_UPDATING) {
|
|
|
+ //showMessage("即将升级...")
|
|
|
+ Constant.APP_PATH = appInfo.appPath
|
|
|
+ Constant.APP_UPDATING = true
|
|
|
+
|
|
|
+ UpdateTipsDialogHelper.showDialog(activity)
|
|
|
+ } else {
|
|
|
+ showMessage(R.string.updating)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showMessage(R.string.update_no_required)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showEmergencyInfo(deviceInfo: DeviceDO) {
|
|
|
+ if (deviceInfo.id != null) {
|
|
|
+ Constant.EMERGENCY_ID = deviceInfo.id
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun loadRoles(roles: List<RoleDO>) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun loadCommunicateDevice(communicateDevice: List<BedCommunicateDeviceVO>) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun loadPhoneWhiteList(whiteList: List<String>) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private var allOrders = ArrayList<DeviceLinVo>()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 联动设备信息
|
|
|
+ * */
|
|
|
+ override fun setDevicesList(advices: ArrayList<DeviceLinVo>) {
|
|
|
+ if (advices.size>0) {
|
|
|
+ allOrders = advices
|
|
|
+ for (i in 0 until allOrders.size) {
|
|
|
+ val device = allOrders[i]
|
|
|
+ //是睡眠床垫的话
|
|
|
+ if (device.device_type == DeviceTypeEnum.SLEEPMATTRESS.value()) {
|
|
|
+ Constant.sleep_sn = device.eth_mac
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun startTcp() {
|
|
|
+ if (Constant.TCP_SERVER_URL != null && !tcpConnect) {
|
|
|
+ tcpConnect = true
|
|
|
+ Thread(Runnable { TcpClient.getInstance().init(Constant.TCP_SERVER_URL, Constant.TCP_PORT, Constant.TCP_HEART_BEAT) }).start()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun regReceiver() {
|
|
|
+ receiver = TimeReceiver()
|
|
|
+ var intentFilter = IntentFilter()
|
|
|
+ intentFilter.addAction(Intent.ACTION_TIME_TICK)
|
|
|
+ intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION)
|
|
|
+ intentFilter.addAction(Constant.KEY_CALL_UP)
|
|
|
+ intentFilter.addAction(Constant.KEY_HOME_UP)
|
|
|
+ //卡尔10寸横屏
|
|
|
+ intentFilter.addAction(Constant.HOOK_OFF)
|
|
|
+ intentFilter.addAction(Constant.HOOK_ON)
|
|
|
+
|
|
|
+ registerReceiver(receiver, intentFilter)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun unRegReceiver() {
|
|
|
+ unregisterReceiver(receiver)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ fun onMoonEvent(messageEvent: MessageEvent) {
|
|
|
+ //代码同步
|
|
|
+ synchronized(Unit) {
|
|
|
+ handleTcpModel(messageEvent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun handleTcpModel(messageEvent: MessageEvent) {
|
|
|
+ when (messageEvent.getType()) {
|
|
|
+ //TCP消息处理
|
|
|
+ Constant.EVENT_TCP_MSG -> {
|
|
|
+ if (messageEvent.message is TcpModel) {
|
|
|
+ val tcpModel = messageEvent.message as TcpModel
|
|
|
+ Log.d("TCP", "received tcp action: " + tcpModel.action + ", type: " + tcpModel.type)
|
|
|
+ if (tcpModel.type == TcpType.DEVICE) {
|
|
|
+ //检查APP版本
|
|
|
+ if (tcpModel.getAction() == TcpAction.DeviceAction.APP_UPDATE) {
|
|
|
+ Util.wakeUpAndUnlock()
|
|
|
+ checkAppVersion()
|
|
|
+ } else if (tcpModel.action == TcpAction.DeviceAction.RESTART) {
|
|
|
+ //后台做了重发此消息的机制.防止网络不好的时候没收到app重启,设备信息不刷新
|
|
|
+ if (!TextUtils.isEmpty(tcpModel.tid)) {
|
|
|
+ TcpClient.getInstance().sendMsg(tcpModel.toJson())
|
|
|
+ }
|
|
|
+ Util.wakeUpAndUnlock()
|
|
|
+ //收到重启app指令,若当前处于正常待机状态则直接重启app,否则等待通话结束再重启
|
|
|
+ if (Constant.CALL_STATE == Constant.CALL_STANDBY) {
|
|
|
+ AppUpdateHelper.restartApp(activity)
|
|
|
+ } else {
|
|
|
+ Constant.LATER_RESTART = true
|
|
|
+ }
|
|
|
+ } else if (tcpModel.action == TcpAction.DeviceAction.SYSTEM_SETTING) {
|
|
|
+ presenter.loadPartSettings(Constant.PART_ID)
|
|
|
+ } else if (tcpModel.action == TcpAction.DeviceAction.SERVER_CHANGE) {
|
|
|
+ //服务器地址变更
|
|
|
+ if (tcpModel.data != null) {
|
|
|
+ val json = JSONObject.parseObject(tcpModel.data.toString())
|
|
|
+ val serverIp = json.getString("server_ip")
|
|
|
+ val serverPort = json.getString("server_port")
|
|
|
+ Log.e(TAG, "server ip:$serverIp, server port:$serverPort")
|
|
|
+ CommonUtils.setUrl(activity, serverIp)
|
|
|
+ CommonUtils.setUrlPort(activity, serverPort)
|
|
|
+ AppTool.Time.delay(2000) {
|
|
|
+ AppUpdateHelper.restartApp(activity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (tcpModel.action == TcpAction.DeviceAction.OPEN_DEBUG) {
|
|
|
+ //打开调试
|
|
|
+ AppUtil.openNetworkDebug()
|
|
|
+ } else if (tcpModel.action == TcpAction.DeviceAction.REBOOT) {
|
|
|
+ //设备重启
|
|
|
+ AppUpdateHelper.reboot(activity)
|
|
|
+ }
|
|
|
+ } else if (tcpModel.action == TcpAction.DataAction.REFRESH) {
|
|
|
+ Util.wakeUpAndUnlock()
|
|
|
+ //重新加载数据
|
|
|
+ initDevice()
|
|
|
+ } else if (tcpModel.type == TcpType.TIME) {
|
|
|
+ if (tcpModel.action == TcpAction.TimeAction.SYNC) {
|
|
|
+ var time = 0L
|
|
|
+ var timeZone = "Asia/Shanghai"
|
|
|
+ if (canParseJson(tcpModel.data.toString())) {
|
|
|
+ val json = JSON.parseObject(tcpModel.data.toString())
|
|
|
+ time = json.getLong("time") * 1000
|
|
|
+ timeZone = json.getString("time_zone")
|
|
|
+ } else {
|
|
|
+ time = tcpModel.data.toString().toLong() * 1000
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ HardWareFactory.getHardTools().setTime(this, time, timeZone)
|
|
|
+ Log.d("setTime", "set sys time1: $time, $timeZone")
|
|
|
+ } catch (e: Exception) {
|
|
|
+ //"20211213:092314"
|
|
|
+ val timeStr = TimeHandle.getDateTime(time, "yyyyMMdd.HHmmss", timeZone)
|
|
|
+ AppUtil.setSysTime(timeStr, timeZone)
|
|
|
+ Log.d("setTime", "set sys time2: $timeStr, $timeZone")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TCP连接状态
|
|
|
+ Constant.EVENT_TCP_STATE -> {
|
|
|
+ updateTcpState()
|
|
|
+ }
|
|
|
+
|
|
|
+ Constant.EVENT_RESTART_APP -> {
|
|
|
+ Util.wakeUpAndUnlock()
|
|
|
+ AppUpdateHelper.restartApp(activity)
|
|
|
+ }
|
|
|
+
|
|
|
+ Constant.EVENT_SLEEP_START -> {
|
|
|
+ //启动床垫服务
|
|
|
+ startSLService()
|
|
|
+ }
|
|
|
+
|
|
|
+ Constant.EVENT_SLEEP_STOP -> {
|
|
|
+ //关闭床垫服务
|
|
|
+ stopSLService()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private fun canParseJson(str: String) : Boolean {
|
|
|
+ var result = false
|
|
|
+ try {
|
|
|
+ JSON.parseObject(str)
|
|
|
+ result=true
|
|
|
+ }catch (e: java.lang.Exception){
|
|
|
+ result=false
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private fun checkNet() {
|
|
|
+ /*
|
|
|
+ * 检查网络情况,若tcp断开连接多次且IP也是空的则网络异常,重启设备
|
|
|
+ * 仅对3128设备有效
|
|
|
+ */
|
|
|
+ if (Build.MODEL.equals("rk3128") || BuildConfig.flag == Constant.DEV_W_A133) {
|
|
|
+ Log.e("checkNet", "checkNet --> netErrCount: " + netErrCount + ", IP isEmpty: " + TextUtils.isEmpty(NetHelper.getInstance().localIP))
|
|
|
+ var count = SettingConfig.getNetErrResetCount(this)
|
|
|
+ if (!Constant.TCP_CONNECTED && TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
|
|
|
+ netErrCount++
|
|
|
+ } else {
|
|
|
+ netErrCount = 0
|
|
|
+ if (count > 0) {
|
|
|
+ count = 0
|
|
|
+ SettingConfig.setNetErrResetCount(this, count)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (netErrCount >= 5) {
|
|
|
+ //如果重启次数超过8次还是无网则不再重启
|
|
|
+ if (count < 8) {
|
|
|
+ count++
|
|
|
+ SettingConfig.setNetErrResetCount(this, count)
|
|
|
+ handler.postDelayed({
|
|
|
+ Log.e("reboot", "重启")
|
|
|
+ AppUpdateHelper.reboot(this)
|
|
|
+ }, 5000)
|
|
|
+ } else {
|
|
|
+ runOnUiThread {
|
|
|
+ WarningDialogHelper.showDialog(this@CallingbedActivity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun updateNetState() {
|
|
|
+ if (NetHelper.getInstance().networkType == ConnectivityManager.TYPE_WIFI) {
|
|
|
+ Constant.network_state = 1
|
|
|
+ view_title_layout_iv_wifi.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_wifi.setImageResource(R.mipmap.ic_wifi_success)
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.GONE
|
|
|
+
|
|
|
+ } else if (NetHelper.getInstance().networkType == ConnectivityManager.TYPE_ETHERNET) {
|
|
|
+ Constant.network_state = 2
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_ethernet.setImageResource(R.mipmap.ic_ethernet_success)
|
|
|
+ view_title_layout_iv_wifi.visibility = View.GONE
|
|
|
+ } else if (NetHelper.getInstance().networkType == ConnectivityManager.TYPE_MOBILE) {
|
|
|
+ Constant.network_state = 3
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_ethernet.setImageResource(R.mipmap.net_4g)
|
|
|
+ view_title_layout_iv_wifi.visibility = View.GONE
|
|
|
+ } else {
|
|
|
+ Constant.network_state = 4
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_ethernet.setImageResource(R.mipmap.ic_ethernet_fail)
|
|
|
+ view_title_layout_iv_wifi.visibility = View.GONE
|
|
|
+ }
|
|
|
+ if (NetHelper.isBTConnected()) {
|
|
|
+ Constant.BT_state = 0
|
|
|
+ view_title_layout_iv_bt.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_bt.setImageResource(R.mipmap.ic_bt_success)
|
|
|
+ } else {
|
|
|
+ Constant.BT_state = 1
|
|
|
+ view_title_layout_iv_bt.visibility = View.GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun updateTcpState() {
|
|
|
+ if (Constant.TCP_CONNECTED) {
|
|
|
+ view_title_layout_iv_tcp.setImageResource(R.mipmap.ic_tcp_success)
|
|
|
+ //view_title_layout_tv_point.setBackgroundResource(R.mipmap.sip_b)
|
|
|
+ view_title_layout_tv_sip.setTextColor(Color.DKGRAY)
|
|
|
+ } else {
|
|
|
+ view_title_layout_iv_tcp.setImageResource(R.mipmap.ic_tcp_nor)
|
|
|
+ //view_title_layout_tv_point.setBackgroundResource(R.mipmap.sip_h)
|
|
|
+ view_title_layout_tv_sip.setTextColor(Color.RED)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private fun updateSettings(forceSet: Boolean) {
|
|
|
+ val currentTimestamp = System.currentTimeMillis()
|
|
|
+
|
|
|
+ //白天起始时间戳
|
|
|
+ val date = TimeHandle.getDateTime("yyyy-MM-dd")
|
|
|
+ val dayStartTimeStamp = TimeHandle.dateToStamp(date + " " + SettingConfig.getInitialDayTime(this) + ":00", "yyyy-MM-dd HH:mm:ss")
|
|
|
+ //白天结束时间戳
|
|
|
+ val endOfDayTimeStamp = TimeHandle.dateToStamp(date + " " + SettingConfig.getEndOfDay(this) + ":00", "yyyy-MM-dd HH:mm:ss")
|
|
|
+
|
|
|
+ val curInday = dayStartTimeStamp < currentTimestamp && currentTimestamp < endOfDayTimeStamp
|
|
|
+
|
|
|
+ if (curInday) {
|
|
|
+ //当前是白天并且原来不是白天
|
|
|
+ if (Constant.day_state != 0 || forceSet) {
|
|
|
+ //设置白天亮度
|
|
|
+ ScreenManagerUtil().setScreenBrightness(this, Math.ceil(2.54 * SettingConfig.getExtensionDaytimeBrightness(this)).toInt())
|
|
|
+ //设置白天系统音量和响铃音
|
|
|
+ VoiceManagerUtil.setSystemVoice(this, SettingConfig.getExtensionDaytimeSystemVolume(this))
|
|
|
+ VoiceManagerUtil.setMusicVoice(this, SettingConfig.getExtensionDaytimeSystemVolume(this))
|
|
|
+ view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_daylight)
|
|
|
+ }
|
|
|
+ Constant.day_state = 0
|
|
|
+ } else {
|
|
|
+ //当前是夜晚并且原来不是夜晚
|
|
|
+ if (Constant.day_state != 1 || forceSet) {
|
|
|
+ //设置晚上亮度
|
|
|
+ ScreenManagerUtil().setScreenBrightness(this, Math.ceil(2.54 * SettingConfig.getExtensionNightBrightness(this)).toInt())
|
|
|
+ //设置晚上系统音量和响铃音
|
|
|
+ VoiceManagerUtil.setSystemVoice(this, SettingConfig.getExtensionNightSystemVolume(this))
|
|
|
+ VoiceManagerUtil.setMusicVoice(this, SettingConfig.getExtensionNightSystemVolume(this))
|
|
|
+ view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_night)
|
|
|
+ }
|
|
|
+ Constant.day_state = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onBackPressed() {
|
|
|
+ //
|
|
|
+ }
|
|
|
+
|
|
|
+ //广播
|
|
|
+ inner class TimeReceiver: BroadcastReceiver() {
|
|
|
+ override fun onReceive(context: Context, intent: Intent) {
|
|
|
+ if (intent.action == Intent.ACTION_TIME_TICK) {
|
|
|
+ updateNetState()
|
|
|
+ if (initialized) {
|
|
|
+ updateSettings(false)
|
|
|
+ updateTcpState()
|
|
|
+ if (Constant.LATER_RESTART && Constant.CALL_STATE == Constant.CALL_STANDBY) {
|
|
|
+ Log.e(TAG, "处于延时重启,并且待机状态")
|
|
|
+ AppUpdateHelper.restartApp(activity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkNet()
|
|
|
+ } else if (intent.action == ConnectivityManager.CONNECTIVITY_ACTION) {
|
|
|
+ updateNetState()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun startSLService() {
|
|
|
+ try {
|
|
|
+ SleepIntent = Intent(this, SleepService::class.java)
|
|
|
+ //连接服务
|
|
|
+ service_sl = SLService()
|
|
|
+ bindService(SleepIntent, service_sl!!, Context.BIND_AUTO_CREATE)
|
|
|
+ bindSleepService = true
|
|
|
+ //loopConnection()
|
|
|
+ } catch (ex: Exception) {
|
|
|
+ ex.printStackTrace()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun stopSLService() {
|
|
|
+ try {
|
|
|
+ SleepIntent = Intent(this, SleepService::class.java)
|
|
|
+ //停止并解绑服务
|
|
|
+ stopService(SleepIntent)
|
|
|
+ if (bindSleepService) {
|
|
|
+ unbindService(service_sl!!)
|
|
|
+ }
|
|
|
+ } catch (ex: Exception) {
|
|
|
+ ex.printStackTrace()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ inner class SLService : ServiceConnection {
|
|
|
+ override fun onServiceConnected(componentName: ComponentName, iBinder: IBinder) {
|
|
|
+ SleepServiceBinder = iBinder as SleepService.ServiceBinder
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onServiceDisconnected(componentName: ComponentName) {}
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private fun updateLaunchApk() {
|
|
|
+ Thread {
|
|
|
+ val apkName = "launch.apk"
|
|
|
+ copyAssetsToDst(applicationContext, apkName, Environment.getExternalStorageDirectory().path + "/" + Environment.DIRECTORY_DOWNLOADS)
|
|
|
+ if (copyDone) {
|
|
|
+ val fileName = Environment.getExternalStorageDirectory().path + "/" + Environment.DIRECTORY_DOWNLOADS + "/" + apkName
|
|
|
+ //升级
|
|
|
+ AppUpdateHelper.rootSilenceInstall(fileName)
|
|
|
+ //5分钟后重启设备
|
|
|
+ AppTool.Time.delay(300000) {
|
|
|
+ AppUpdateHelper.reboot(BaseApplication.appContext)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.start()
|
|
|
+ }
|
|
|
+
|
|
|
+ //拷贝assets下面的文件到sd卡
|
|
|
+ private fun copyAssetsToDst(context: Context, fileName: String, dstPath: String) {
|
|
|
+ try {
|
|
|
+ copyDone = false
|
|
|
+ val file = File(dstPath)
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.mkdirs()
|
|
|
+ }
|
|
|
+ val outFile = File("$dstPath/$fileName")
|
|
|
+ val `is` = context.assets.open(fileName)
|
|
|
+ val fos = FileOutputStream(outFile)
|
|
|
+ val buffer = ByteArray(1024)
|
|
|
+ var byteCount: Int
|
|
|
+ while (`is`.read(buffer).also { byteCount = it } != -1) {
|
|
|
+ fos.write(buffer, 0, byteCount)
|
|
|
+ }
|
|
|
+ fos.flush()
|
|
|
+ `is`.close()
|
|
|
+ fos.close()
|
|
|
+ copyDone = true
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
+ copyDone = false
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|