desc:新平台代码 to rtsp

# Conflicts:
#	app/src/main/java/com/yinuo/safetywatcher/watcher/utils/LztekUtil.kt
main
xiaowusky 2 years ago
parent b4b896bc3a
commit 725640f1b9

@ -2,10 +2,12 @@ package com.yinuo.safetywatcher
import android.content.Context
import android.content.Intent
import android.media.MediaCodecList
import android.net.Uri
import android.os.Build
import android.os.FileUtils
import android.provider.Settings
import android.util.Log
import com.common.commonlib.db.DBUtils
import com.common.commonlib.db.entity.Gas
import com.common.commonlib.db.entity.Video
@ -29,6 +31,7 @@ object TestUtils {
fun insertData() {
getSupportCodec()
PushHelper.setPushUrl("rtsp://192.168.5.17:554/123")
GlobalScope.launch() {
// 构造气体数据
@ -187,4 +190,14 @@ object TestUtils {
}
loadingDialog?.dismiss()
}
fun getSupportCodec() {
val list = MediaCodecList(MediaCodecList.ALL_CODECS)
val codecs = list.codecInfos
Log.d("cyy", "Decoders:")
for (i in codecs.indices) {
val codec = codecs[i]
Log.d("cyy", codec.name)
}
}
}

@ -9,10 +9,11 @@ import com.yinuo.safetywatcher.watcher.constant.CAMERA_GATEWAY
import com.yinuo.safetywatcher.watcher.constant.CAMERA_IP
import com.yinuo.safetywatcher.watcher.constant.CAMERA_NETMASK
import com.yinuo.safetywatcher.watcher.port.cmd.GasPortStatus
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
import com.yinuo.safetywatcher.watcher.utils.PlatformUtils
import com.yinuo.safetywatcher.watcher.wifi.WiFiConfig
import com.yinuo.safetywatcher.watcher.wifi.WiFiModule
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
@ -38,14 +39,17 @@ class App : CommonApplication() {
}
private fun ipConfig() {
LztekUtil.getLztek()
?.setEthIpAddress(CAMERA_IP, CAMERA_NETMASK, CAMERA_GATEWAY, CAMERA_DNS)
// LztekUtil.getLztek()
// ?.setEthIpAddress(CAMERA_IP, CAMERA_NETMASK, CAMERA_GATEWAY, CAMERA_DNS)
PlatformUtils.setEthIpAddress(CAMERA_IP, CAMERA_NETMASK, CAMERA_GATEWAY, CAMERA_DNS)
PlatformUtils.hideNavigation()
PlatformUtils.hideStatusBar()
}
private fun tryFixDbData() {
GlobalScope.launch {
GlobalScope.launch(Dispatchers.IO) {
// 修复告警数据
async {
val warningAsync = async(Dispatchers.IO) {
val warningDao = DBUtils.warningDao()
val warningList = warningDao.queryWarningsNoEndTime()
warningList?.apply {
@ -54,10 +58,10 @@ class App : CommonApplication() {
}
warningDao.updateAll(warningList)
}
}.await()
}
// 修复视频数据
async {
val videoAsync = async(Dispatchers.IO) {
val videoDao = DBUtils.videoDao()
val videoList = videoDao.getAll()
videoList.onEach { video ->
@ -65,17 +69,20 @@ class App : CommonApplication() {
videoDao.delete(video)
}
}
}.await()
}
// 初始时,所以串口连接状态都应该是未连接
async {
val gasAsync = async(Dispatchers.IO) {
val gasTypeDao = DBUtils.gasTypeDao()
val all = gasTypeDao.getAll()
all.onEach { gasType ->
gasType.status = GasPortStatus.OUTLINE
gasTypeDao.insert(gasType)
}
}.await()
}
warningAsync.await()
videoAsync.await()
gasAsync.await()
}
}

@ -18,6 +18,7 @@ import com.yinuo.safetywatcher.watcher.port.cmd.O2
import com.yinuo.safetywatcher.watcher.port.cmd.ResponseHelper
import com.yinuo.safetywatcher.watcher.port.cmd.getGasTypeByCode
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.easydarwin.TxtOverlay
@ -148,7 +149,7 @@ object ParseHelper {
* 插入气体数据
*/
private fun insertGasData(gasType: String, value: Float, unit: String) {
GlobalScope.launch {
GlobalScope.launch(Dispatchers.IO) {
// 阈值范围
val min = getGasLowThreshold(gasType, unit)
val max = getGasHighThreshold(gasType, unit)

@ -279,4 +279,8 @@ class HomeActivity : NoOptionsActivity() {
super.onResume()
mClient?.resume()
}
override fun onBackPressed() {
// super.onBackPressed()
}
}

@ -7,6 +7,7 @@ import com.yinuo.safetywatcher.R
import com.yinuo.safetywatcher.databinding.ActivityTimeSettingBinding
import com.yinuo.safetywatcher.watcher.base.NoOptionsActivity
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
import com.yinuo.safetywatcher.watcher.utils.PlatformUtils
import java.text.SimpleDateFormat
import java.util.Locale
@ -44,7 +45,8 @@ class TimeSettingActivity : NoOptionsActivity() {
}
mBingding.tvConfirm.setOnClickListener {
if (changeTime > 0) {
LztekUtil.getLztek()?.setSystemTime(changeTime)
// LztekUtil.getLztek()?.setSystemTime(changeTime)
PlatformUtils.setSystemTime(changeTime)
}
onBackPressed()
}

@ -25,22 +25,24 @@ object LztekUtil {
fun getSn(): String {
if (sn == null) {
val mac = getLztek()?.ethMac ?: "unKnow"
val md = MessageDigest.getInstance("MD5") // 生成一个MD5加密计算摘要
md.update(mac.toByteArray()) // 计算md5函数
/**
* digest()最后确定返回md5 hash值返回值为8位字符串
* 因为md5 hash值是16位的hex值实际上就是8位的字符
* BigInteger函数则将8位的字符串转换成16位hex值用字符串来表示得到字符串形式的hash值
* 一个byte是八位二进制也就是2位十六进制字符2的8次方等于16的2次方
*/
/**
* digest()最后确定返回md5 hash值返回值为8位字符串
* 因为md5 hash值是16位的hex值实际上就是8位的字符
* BigInteger函数则将8位的字符串转换成16位hex值用字符串来表示得到字符串形式的hash值
* 一个byte是八位二进制也就是2位十六进制字符2的8次方等于16的2次方
*/
sn = BigInteger(1, md.digest()).toString(16) // 16是表示转换为16进制数
// val mac = getLztek()?.ethMac ?: "unKnow"
// val md = MessageDigest.getInstance("MD5") // 生成一个MD5加密计算摘要
// md.update(mac.toByteArray()) // 计算md5函数
// /**
// * digest()最后确定返回md5 hash值返回值为8位字符串。
// * 因为md5 hash值是16位的hex值实际上就是8位的字符
// * BigInteger函数则将8位的字符串转换成16位hex值用字符串来表示得到字符串形式的hash值
// * 一个byte是八位二进制也就是2位十六进制字符2的8次方等于16的2次方
// */
// /**
// * digest()最后确定返回md5 hash值返回值为8位字符串。
// * 因为md5 hash值是16位的hex值实际上就是8位的字符
// * BigInteger函数则将8位的字符串转换成16位hex值用字符串来表示得到字符串形式的hash值
// * 一个byte是八位二进制也就是2位十六进制字符2的8次方等于16的2次方
// */
// sn = BigInteger(1, md.digest()).toString(16) // 16是表示转换为16进制数
val deviceSN = SnUtils.getDeviceSN()
sn = deviceSN
}
return sn!!
}

@ -0,0 +1,62 @@
package com.yinuo.safetywatcher.watcher.utils
import android.content.Intent
import com.common.commonlib.CommonApplication
import java.text.SimpleDateFormat
import java.util.Locale
object PlatformUtils {
val format: SimpleDateFormat by lazy {
SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT)
}
fun setEthIpAddress(ip: String, netmask: String, gateway: String, dns: String) {
val intent = Intent("android.ido.intent.action.ethernet")
intent.putExtra("mode", "Static")
intent.putExtra("iface", "eth0")
intent.putExtra("ipAddr", ip)
intent.putExtra("netmask", netmask)
intent.putExtra("gateway", gateway)
intent.putExtra("dns1", dns)
intent.putExtra("dns2", dns) //如果只有一个dns可将dns2设置为和dns1一样
CommonApplication.getContext()?.sendBroadcast(intent)
}
fun operateWifi(enable: Boolean) {
val intent = Intent("android.ido.intent.action.wifionoff")
intent.putExtra("enable", enable) //true开启; false关闭
CommonApplication.getContext()?.sendBroadcast(intent)
}
fun setSystemTime(timeMs: Long) {
val formatTime = format.format(timeMs)
val strings = formatTime.split("-")
val times = strings.map {
it.toInt()
}.toTypedArray().toIntArray()
// val time = intArrayOf(2022, 9, 30, 18, 0, 0)
val intent = Intent("android.ido.intent.action.settime")
intent.putExtra("time", times)
CommonApplication.getContext()?.sendBroadcast(intent)
}
fun hideStatusBar(hide: Boolean = true) {
val action =
if (hide) "android.ido.intent.action.statusbar.HIDE"
else "android.ido.intent.action.statusbar.HIDE"
val intent = Intent(action)
intent.putExtra("save", true) //true,断电保存false断电不保存
CommonApplication.getContext()?.sendBroadcast(intent)
}
fun hideNavigation(hide: Boolean = true) {
val action =
if (hide) "android.ido.intent.action.navigation.HIDE"
else "android.ido.intent.action.navigation.SHOW"
val intent = Intent(action)
intent.putExtra("save", true) //true,断电保存false断电不保存
CommonApplication.getContext()?.sendBroadcast(intent)
}
}

@ -0,0 +1,17 @@
package com.yinuo.safetywatcher.watcher.utils;
import java.lang.reflect.Method;
public class SnUtils {
public static String getDeviceSN() {
String serial = null;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
} catch (Exception e) {
e.printStackTrace();
}
return serial;
}
}

@ -13,6 +13,7 @@ import com.yinuo.safetywatcher.R
import com.yinuo.safetywatcher.databinding.ActivityMonitorBinding
import com.yinuo.safetywatcher.watcher.base.NoOptionsActivity
import com.yinuo.safetywatcher.watcher.ui.view.ConfirmDialog
import com.yinuo.safetywatcher.watcher.utils.PlatformUtils
import com.yinuo.safetywatcher.watcher.wifi.WiFiModule
import com.yinuo.safetywatcher.watcher.wifi.info.WiFiRemoveStatusInfo
import com.yinuo.safetywatcher.watcher.wifi.info.WiFiScanInfo
@ -56,9 +57,11 @@ class GlobalMonitorActivity : NoOptionsActivity() {
private fun initEvents() {
mBinding.wifiSwitch!!.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
PlatformUtils.operateWifi(true)
WiFiModule.getInstance().startScan(scanActionListener)
} else {
WiFiModule.getInstance().disableWifi()
// WiFiModule.getInstance().disableWifi()
PlatformUtils.operateWifi(false)
mData!!.clear()
mAdapter?.setData(mData!!)
mBinding.tvStatus.text = "WiFi已关闭"

@ -7,7 +7,7 @@
<color name="white">#ffffff</color>
<color name="white_20">#33ffffff</color>
<color name="white_30">#4Cffffff</color>
<color name="colorTheme">#1ED5CA</color>
<color name="colorTheme">#242F4D</color>
<color name="black_overlay">#66000000</color>

@ -1,8 +1,8 @@
project.ext {
sign = [
keystore_path : "../innovationapp.jks",
keystore_path : "../sbc3566.jks",
keystore_pwd : "123456",
keystore_alias: "yinuo"
keystore_alias: "sbc3566"
]
compileOptions = [

Binary file not shown.
Loading…
Cancel
Save