@@ -37,16 +37,18 @@ class ConnectivityServiceImpl(
3737 private val requestBuilder : GetRequestBuilder ,
3838 private val walledCheckCache : WalledCheckCache
3939) : ConnectivityService {
40+
4041 private val scope = CoroutineScope (Dispatchers .IO )
42+
4143 private var availabilityCheckJob: Job ? = null
44+ private var notifyJob: Job ? = null
45+
4246 private val connectivityManager = context.getSystemService(Context .CONNECTIVITY_SERVICE ) as ConnectivityManager
4347 private val listeners = mutableSetOf<NetworkChangeListener >()
4448
4549 @Volatile
4650 private var currentConnectivity: Connectivity = Connectivity .DISCONNECTED
4751
48- private var notifyJob: Job ? = null
49-
5052 private val key: ConnectivityKey
5153 get() = ConnectivityKey .getBy(accountManager)
5254
@@ -218,33 +220,31 @@ class ConnectivityServiceImpl(
218220
219221 override fun getConnectivity () = currentConnectivity
220222
221- private fun getWalledValueFromException (e : Exception ): Boolean {
222- return when (e) {
223- is UnknownHostException ,
224- is ConnectException -> {
225- Log_OC .w(TAG , " offline exception (${e::class .simpleName} ), treating as walled" )
226- true
227- }
223+ private fun getWalledValueFromException (e : Exception ): Boolean = when (e) {
224+ is UnknownHostException ,
225+ is ConnectException -> {
226+ Log_OC .w(TAG , " offline exception (${e::class .simpleName} ), treating as walled" )
227+ true
228+ }
228229
229- is SocketTimeoutException -> {
230- Log_OC .w(TAG , " timeout during server check, treating as walled" )
231- true
232- }
230+ is SocketTimeoutException -> {
231+ Log_OC .w(TAG , " timeout during server check, treating as walled" )
232+ true
233+ }
233234
234- is SSLException -> {
235- Log_OC .w(TAG , " SSL exception during server check, assuming reachable" )
236- false
237- }
235+ is SSLException -> {
236+ Log_OC .w(TAG , " SSL exception during server check, assuming reachable" )
237+ false
238+ }
238239
239- is IOException -> {
240- Log_OC .w(TAG , " I/O exception (${e::class .simpleName} ), treating as walled" )
241- true
242- }
240+ is IOException -> {
241+ Log_OC .w(TAG , " I/O exception (${e::class .simpleName} ), treating as walled" )
242+ true
243+ }
243244
244- else -> {
245- Log_OC .e(TAG , " unexpected exception type (${e::class .simpleName} ), using previous state" )
246- currentConnectivity.isServerAvailable?.let { ! it } ? : true
247- }
245+ else -> {
246+ Log_OC .e(TAG , " unexpected exception type (${e::class .simpleName} ), using previous state" )
247+ currentConnectivity.isServerAvailable?.let { ! it } ? : true
248248 }
249249 }
250250
0 commit comments