desc:有无网络通过socket连接公网8.8.8.8DNS服务来判断,通过收发包的快慢模拟信号变化

main
xiaowusky 1 year ago
parent 97bd74cc25
commit 8b33fb15e7

@ -15,6 +15,7 @@ import android.widget.TextView
import androidx.appcompat.content.res.AppCompatResources
import com.yinuo.safetywatcher.R
import com.yinuo.safetywatcher.databinding.LayoutTopbarBinding
import com.yinuo.safetywatcher.watcher.AppData
import com.yinuo.safetywatcher.watcher.utils.BatteryHelper
import com.yinuo.safetywatcher.watcher.utils.SimHelper
import com.yinuo.safetywatcher.watcher.utils.WifiHelper
@ -95,19 +96,27 @@ class CommonTopBar : LinearLayout {
private val simCallback = object : SimHelper.OnSimLevelCallback {
override fun onEnable(enable: Boolean) {
Log.i(this@CommonTopBar.javaClass.name, "simCallback onEnable = $enable")
mBinding?.fourG?.post {
mBinding?.root?.post {
if (enable) {
mBinding?.fourG?.visibility = VISIBLE
if (mBinding?.fourG?.visibility != VISIBLE) {
mBinding?.fourG?.visibility = VISIBLE
}
} else {
mBinding?.fourG?.visibility = GONE
if (mBinding?.fourG?.visibility != GONE) {
mBinding?.fourG?.visibility = GONE
}
}
}
}
override fun onLevel(level: Int) {
Log.i(this@CommonTopBar.javaClass.name, "simCallback onLevel = $level")
mBinding?.fourG?.post {
val showLevel = (level + 1) * 20
mBinding?.root?.post {
var showLevel =
if (AppData.hasCameraData()) (level / 15 + 1) * 20 else (level + 1) * 20
if (showLevel > 100) {
showLevel = 100
}
mBinding?.fourG?.setImageLevel(showLevel)
}
}

@ -138,7 +138,7 @@ object SimHelper {
val txOffset = totalTxBytes - lastTxBytes
Log.i(
"setNetStatus",
"txbyte = $totalTxBytes rxbyte = $totalRxBytes timeOffset = $timeOffset"
"txbyte = $txOffset rxbyte = $rxOffset timeOffset = $timeOffset"
)
lastTime = currentTimeMillis

Loading…
Cancel
Save