diff --git a/app/src/main/java/org/unifiedpush/distributor/sunup/api/ServerConnection.kt b/app/src/main/java/org/unifiedpush/distributor/sunup/api/ServerConnection.kt index ad9b8c3..9f33fff 100644 --- a/app/src/main/java/org/unifiedpush/distributor/sunup/api/ServerConnection.kt +++ b/app/src/main/java/org/unifiedpush/distributor/sunup/api/ServerConnection.kt @@ -87,6 +87,7 @@ class ServerConnection(private val context: Context, private val releaseLock: () private fun onHello(ws: WebSocket, message: ServerMessage.Hello) { Log.d(TAG, "Hello") + FailureCounter.debugStarted() ApiUrlCandidate.finish()?.let { store.apiUrl = it Log.d(TAG, "Successfully using $it") @@ -122,7 +123,7 @@ class ServerConnection(private val context: Context, private val releaseLock: () } private fun onPing(ws: WebSocket) { - FailureCounter.newPing(context) + FailureCounter.debugNewPing(context) if (!waitingPong.getAndSet(false)) { Log.d(TAG, "Sending Pong") ClientMessage.Ping.send(ws) @@ -199,7 +200,7 @@ class ServerConnection(private val context: Context, private val releaseLock: () Log.d(TAG, "StartService not started") return false } - if (!NetworkCallbackFactory.hasInternet) { + if (!NetworkCallbackFactory.hasInternet()) { Log.d(TAG, "No Internet: do not restart") // It will be restarted when Internet is back return false diff --git a/app/src/main/java/org/unifiedpush/distributor/sunup/callback/BatteryCallbackFactory.kt b/app/src/main/java/org/unifiedpush/distributor/sunup/callback/BatteryCallbackFactory.kt index ca7c2a9..075b744 100644 --- a/app/src/main/java/org/unifiedpush/distributor/sunup/callback/BatteryCallbackFactory.kt +++ b/app/src/main/java/org/unifiedpush/distributor/sunup/callback/BatteryCallbackFactory.kt @@ -1,6 +1,7 @@ package org.unifiedpush.distributor.sunup.callback import android.content.Context +import java.util.concurrent.atomic.AtomicBoolean import org.unifiedpush.distributor.callback.BatteryCallback import org.unifiedpush.distributor.callback.CallbackFactory import org.unifiedpush.distributor.sunup.BuildConfig @@ -10,6 +11,7 @@ import org.unifiedpush.distributor.sunup.api.data.ClientMessage object BatteryCallbackFactory : CallbackFactory() { class MainBatteryCallback : BatteryCallback() { + override val lowBattery = BatteryCallbackFactory.lowBattery override fun onBatteryLow(context: Context) { if (BuildConfig.URGENCY) { @@ -44,5 +46,9 @@ object BatteryCallbackFactory : CallbackFactory() { class MainNetworkCallback(val context: Context) : NetworkCallback() { + override val hasInternet = NetworkCallbackFactory.hasInternet override val failureCounter = FailureCounter override val registrationCounter = MainRegistrationCounter override val worker = RestartWorker.Companion @@ -21,5 +23,9 @@ object NetworkCallbackFactory : CallbackFactory