|  |  | @ -22,15 +22,20 @@ import com.yinuo.safetywatcher.watcher.constant.DELAY_TIME_CHECK_SENSOR | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.yinuo.safetywatcher.watcher.constant.DELAY_TIME_OPEN_CAMERA |  |  |  | import com.yinuo.safetywatcher.watcher.constant.DELAY_TIME_OPEN_CAMERA | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.yinuo.safetywatcher.watcher.port.GasUtils |  |  |  | import com.yinuo.safetywatcher.watcher.port.GasUtils | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.yinuo.safetywatcher.watcher.services.HeartbeatService |  |  |  | import com.yinuo.safetywatcher.watcher.services.HeartbeatService | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.yinuo.safetywatcher.watcher.ui.view.ConfirmDialog | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.yinuo.safetywatcher.watcher.utils.BatteryHelper |  |  |  | import com.yinuo.safetywatcher.watcher.utils.BatteryHelper | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.yinuo.safetywatcher.watcher.utils.LztekUtil | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.yinuo.safetywatcher.watcher.utils.SimHelper |  |  |  | import com.yinuo.safetywatcher.watcher.utils.SimHelper | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.yinuo.safetywatcher.watcher.utils.WifiHelper |  |  |  | import com.yinuo.safetywatcher.watcher.utils.WifiHelper | 
			
		
	
		
		
			
				
					
					|  |  |  | import kotlinx.coroutines.Dispatchers |  |  |  | import kotlinx.coroutines.Dispatchers | 
			
		
	
		
		
			
				
					
					|  |  |  | import kotlinx.coroutines.GlobalScope |  |  |  | import kotlinx.coroutines.GlobalScope | 
			
		
	
		
		
			
				
					
					|  |  |  | import kotlinx.coroutines.launch |  |  |  | import kotlinx.coroutines.launch | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.io.File | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | class HomeActivity : NoOptionsActivity() { |  |  |  | class HomeActivity : NoOptionsActivity() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private var warnDialog: ConfirmDialog? = null | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private val mBinding: ActivityHomeBinding by lazy { |  |  |  |     private val mBinding: ActivityHomeBinding by lazy { | 
			
		
	
		
		
			
				
					
					|  |  |  |         ActivityHomeBinding.inflate(layoutInflater) |  |  |  |         ActivityHomeBinding.inflate(layoutInflater) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -78,6 +83,16 @@ class HomeActivity : NoOptionsActivity() { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 itemSetting.requestFocus() |  |  |  |                 itemSetting.requestFocus() | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         val cardAvailableSize = LztekUtil.getCardAvailableSize() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (cardAvailableSize < 30) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             warnDialog = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 ConfirmDialog("检测倒系统剩余存储空间较小,将影响视频录制,是否删除部分早期录像腾出空间?") { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     warnDialog?.dismiss() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     delSomeVideo() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             warnDialog?.show(supportFragmentManager, "warn") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
	
		
		
			
				
					|  |  | @ -210,6 +225,20 @@ class HomeActivity : NoOptionsActivity() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         SimHelper.init(this@HomeActivity) |  |  |  |         SimHelper.init(this@HomeActivity) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private fun delSomeVideo() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         GlobalScope.launch { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             val videoDao = DBUtils.videoDao() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             val oldVideo = videoDao.getOldVideo() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             try { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 oldVideo?.forEach { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     File(it.path).delete() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } catch (e: Exception) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 LogUtils.v("delSomeVideo error, ${e.message}") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     override fun onDestroy() { |  |  |  |     override fun onDestroy() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         super.onDestroy() |  |  |  |         super.onDestroy() | 
			
		
	
		
		
			
				
					
					|  |  |  |         BatteryHelper.release(this@HomeActivity) |  |  |  |         BatteryHelper.release(this@HomeActivity) | 
			
		
	
	
		
		
			
				
					|  |  | @ -217,6 +246,7 @@ class HomeActivity : NoOptionsActivity() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         SimHelper.release(this@HomeActivity) |  |  |  |         SimHelper.release(this@HomeActivity) | 
			
		
	
		
		
			
				
					
					|  |  |  |         mBinding.root?.removeCallbacks(reStartCamera) |  |  |  |         mBinding.root?.removeCallbacks(reStartCamera) | 
			
		
	
		
		
			
				
					
					|  |  |  |         mRender?.onDestoryed() |  |  |  |         mRender?.onDestoryed() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         warnDialog?.dismiss() | 
			
		
	
		
		
			
				
					
					|  |  |  |         Process.killProcess(Process.myPid()) |  |  |  |         Process.killProcess(Process.myPid()) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |