package pxds.lmmd.zmwf

import android.net.TrafficStats
import android.os.SystemClock
import android.util.Log
import com.test.basd.supercleanermax.R
import pxds.lmmd.zmwf.Khko.string

object Qwcj {

    var monitorSwitch = false

    fun startMoritor() {
        monitorSwitch = true
        if (preElapsedRealtime == 0L) {
            preElapsedRealtime = SystemClock.elapsedRealtime()
            totalRxBytes = TrafficStats.getTotalRxBytes()
            totalTxBytes = TrafficStats.getTotalTxBytes()
        }
        while (monitorSwitch) {
            try {
                val totalRxBytes = TrafficStats.getTotalRxBytes()
                val totalTxBytes = TrafficStats.getTotalTxBytes()

                val elapsedRealtime = SystemClock.elapsedRealtime()
                val j10 = (elapsedRealtime - preElapsedRealtime) / 1000
                val totalTxSpeed = ((totalTxBytes - this.totalTxBytes) / j10)
                val totalRxSpeed = ((totalRxBytes - this.totalRxBytes) / j10)
                this.totalRxBytes = totalRxBytes
                this.totalTxBytes = totalTxBytes
                this.totalTxSpeed = totalTxSpeed
                this.totalRxSpeed = totalRxSpeed
                preElapsedRealtime = elapsedRealtime
                Log.i(R.string.ގޤޝޢމ_D.string(), R.string.ޞހފތޣ_D.string((totalTxSpeed).toString(), (totalRxSpeed).toString()))
            } catch (e10: Exception) {
            }
            waitAMoment(4000L)
        }
    }

    @Volatile
    var totalTxSpeed: Long = 0

    @Volatile
    var totalTxBytes: Long = 0

    fun stopMonitor() {
        monitorSwitch = false
    }

    fun waitAMoment(j10: Long) {
        try {
            Thread.sleep(j10)
        } catch (e10: InterruptedException) {
        }
    }

    @Volatile
    var totalRxSpeed: Long = 0

    @Volatile
    var totalRxBytes: Long = 0

    @Volatile
    var preElapsedRealtime: Long = 0
}