Eliminated redundant link properties changed log messages
This commit is contained in:
@ -130,6 +130,7 @@ class BaresipService: Service() {
|
|||||||
private var linkAddresses = mutableMapOf<String, String>()
|
private var linkAddresses = mutableMapOf<String, String>()
|
||||||
private var activeNetwork: Network? = null
|
private var activeNetwork: Network? = null
|
||||||
private var allNetworks = mutableSetOf<Network>()
|
private var allNetworks = mutableSetOf<Network>()
|
||||||
|
private var lastLinkProperties = mutableMapOf<Network, LinkProperties>()
|
||||||
private var hotSpotIsEnabled = false
|
private var hotSpotIsEnabled = false
|
||||||
private var hotSpotAddresses = mapOf<String, String>()
|
private var hotSpotAddresses = mapOf<String, String>()
|
||||||
private var mediaPlayer: MediaPlayer? = null
|
private var mediaPlayer: MediaPlayer? = null
|
||||||
@ -141,6 +142,7 @@ class BaresipService: Service() {
|
|||||||
private var isNotificationInCall = false
|
private var isNotificationInCall = false
|
||||||
private var isServiceClean = false
|
private var isServiceClean = false
|
||||||
private var cleanupRunnable: Runnable? = null
|
private var cleanupRunnable: Runnable? = null
|
||||||
|
private var previousMobileServiceState = -1
|
||||||
|
|
||||||
@SuppressLint("WakelockTimeout")
|
@SuppressLint("WakelockTimeout")
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
@ -228,6 +230,8 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
override fun onLinkPropertiesChanged(network: Network, props: LinkProperties) {
|
override fun onLinkPropertiesChanged(network: Network, props: LinkProperties) {
|
||||||
super.onLinkPropertiesChanged(network, props)
|
super.onLinkPropertiesChanged(network, props)
|
||||||
|
if (Utils.linkPropertiesEqual(props, lastLinkProperties[network])) return
|
||||||
|
lastLinkProperties[network] = props
|
||||||
Log.d(TAG, "Network $network link properties changed: $props")
|
Log.d(TAG, "Network $network link properties changed: $props")
|
||||||
synchronized(allNetworks) {
|
synchronized(allNetworks) {
|
||||||
if (network !in allNetworks)
|
if (network !in allNetworks)
|
||||||
@ -2323,6 +2327,8 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMobileStatusFromServiceState(state: Int) {
|
private fun updateMobileStatusFromServiceState(state: Int) {
|
||||||
|
if (state == previousMobileServiceState) return
|
||||||
|
previousMobileServiceState = state
|
||||||
val isAirplaneModeOn = Utils.isAirplaneModeOn(this)
|
val isAirplaneModeOn = Utils.isAirplaneModeOn(this)
|
||||||
val status = if (state == ServiceState.STATE_IN_SERVICE)
|
val status = if (state == ServiceState.STATE_IN_SERVICE)
|
||||||
circleGreen.getValue(colorblind)
|
circleGreen.getValue(colorblind)
|
||||||
|
|||||||
@ -1502,4 +1502,14 @@ object Utils {
|
|||||||
}
|
}
|
||||||
Log.e(TAG, "--------------------------------------")
|
Log.e(TAG, "--------------------------------------")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun linkPropertiesEqual(p1: android.net.LinkProperties?, p2: android.net.LinkProperties?): Boolean {
|
||||||
|
if (p1 === p2) return true
|
||||||
|
if (p1 == null || p2 == null) return false
|
||||||
|
if (p1.interfaceName != p2.interfaceName) return false
|
||||||
|
if (p1.linkAddresses != p2.linkAddresses) return false
|
||||||
|
if (p1.dnsServers != p2.dnsServers) return false
|
||||||
|
if (p1.routes != p2.routes) return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user