Allow ignoring system connection status

This commit is contained in:
Jonas Lochmann 2019-10-07 00:00:00 +00:00
parent 674420f8c9
commit 827b42b37a
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
6 changed files with 16 additions and 1 deletions

View file

@ -194,4 +194,5 @@ object ExperimentalFlags {
const val SYSTEM_LEVEL_BLOCKING = 2L
const val MANIPULATION_ANNOY_USER_ONLY = 4L
const val MANIPULATION_ANNOY_USER = MANIPULATION_ANNOY_USER_ONLY or DISABLE_BLOCK_ON_MANIPULATION // otherwise there would be a conflict between both features
const val IGNORE_SYSTEM_CONNECTION_STATUS = 8L
}

View file

@ -20,6 +20,7 @@ import androidx.lifecycle.MutableLiveData
import io.timelimit.android.BuildConfig
import io.timelimit.android.coroutines.runAsync
import io.timelimit.android.coroutines.runAsyncExpectForever
import io.timelimit.android.data.model.ExperimentalFlags
import io.timelimit.android.data.model.UserType
import io.timelimit.android.livedata.*
import io.timelimit.android.sync.websocket.NetworkStatus
@ -53,7 +54,7 @@ class WebsocketClientLogic(
val okFromNetworkStatus = appLogic.networkStatus.map { networkStatus ->
networkStatus == NetworkStatus.Online
}
}.or(appLogic.database.config().isExperimentalFlagsSetAsync(ExperimentalFlags.IGNORE_SYSTEM_CONNECTION_STATUS))
okForCurrentUser.and(okFromNetworkStatus)
} else {
@ -93,6 +94,7 @@ class WebsocketClientLogic(
// shutdown any current connection
currentWebsocketClient?.shutdown()
currentWebsocketClient = null
isConnectedInternal.postValue(false)
if (deviceAuthToken.isNotEmpty()) {
val serverConfig = appLogic.serverLogic.getServerConfigCoroutine()

View file

@ -67,6 +67,10 @@ class SocketIoWebsocketClient(serverUrl: String, private val deviceAuthTokenToCo
listener.onConnectionLost()
}
client.on(Socket.EVENT_RECONNECT) {
listener.onConnectionLost()
}
client.on("should sync") {
val params = it[0] as JSONObject

View file

@ -116,6 +116,12 @@ data class DiagnoseExperimentalFlagItem(
enableFlags = ExperimentalFlags.MANIPULATION_ANNOY_USER,
disableFlags = ExperimentalFlags.MANIPULATION_ANNOY_USER_ONLY,
enable = { !BuildConfig.storeCompilant }
),
DiagnoseExperimentalFlagItem(
label = R.string.diagnose_exf_isc,
enableFlags = ExperimentalFlags.IGNORE_SYSTEM_CONNECTION_STATUS,
disableFlags = ExperimentalFlags.IGNORE_SYSTEM_CONNECTION_STATUS,
enable = { true }
)
)
}

View file

@ -56,6 +56,7 @@
<string name="diagnose_exf_lom">Sperrung nach Manipulationen deaktivieren</string>
<string name="diagnose_exf_slb">Apps auf Systemebene sperren</string>
<string name="diagnose_exf_mau">Nutzer nach Manipulation nerven</string>
<string name="diagnose_exf_isc">Systemverbindungsstatus ignorieren</string>
<string name="diagnose_bg_task_loop_ex">Hintergrundaufgabenschleifenfehler</string>
</resources>

View file

@ -56,6 +56,7 @@
<string name="diagnose_exf_lom">Disable locking after manipulations</string>
<string name="diagnose_exf_slb">Block Apps at system level</string>
<string name="diagnose_exf_mau">Annoy user after manipulation</string>
<string name="diagnose_exf_isc">Ignore system connection status</string>
<string name="diagnose_bg_task_loop_ex">Background task loop exception</string>
</resources>