@@ -26,11 +26,13 @@ import im.vector.app.core.resources.StringProvider
26
26
import im.vector.app.core.utils.getApplicationLabel
27
27
import org.matrix.android.sdk.api.Matrix
28
28
import org.matrix.android.sdk.api.cache.CacheStrategy
29
+ import org.matrix.android.sdk.api.failure.Failure
29
30
import org.matrix.android.sdk.api.util.MatrixJsonParser
30
31
import org.unifiedpush.android.connector.UnifiedPush
31
32
import timber.log.Timber
32
33
import java.net.URL
33
34
import javax.inject.Inject
35
+ import javax.net.ssl.SSLHandshakeException
34
36
35
37
class UnifiedPushHelper @Inject constructor(
36
38
private val context : Context ,
@@ -104,7 +106,11 @@ class UnifiedPushHelper @Inject constructor(
104
106
// else, unifiedpush, and pushkey is an endpoint
105
107
val gateway = stringProvider.getString(R .string.default_push_gateway_http_url)
106
108
val parsed = URL (endpoint)
107
- val port = if (parsed.port != - 1 ) { " :${parsed.port} " } else { " " }
109
+ val port = if (parsed.port != - 1 ) {
110
+ " :${parsed.port} "
111
+ } else {
112
+ " "
113
+ }
108
114
val custom = " ${parsed.protocol} ://${parsed.host}${port} /_matrix/push/v1/notify"
109
115
Timber .i(" Testing $custom " )
110
116
try {
@@ -120,7 +126,13 @@ class UnifiedPushHelper @Inject constructor(
120
126
}
121
127
}
122
128
} catch (e: Throwable ) {
123
- Timber .d(e, " Cannot try custom gateway" )
129
+ Timber .e(e, " Cannot try custom gateway" )
130
+ if (e is Failure .NetworkConnection && e.ioException is SSLHandshakeException ) {
131
+ Timber .w(e, " SSLHandshakeException, ignore this error" )
132
+ unifiedPushStore.storePushGateway(custom)
133
+ onDoneRunnable?.run ()
134
+ return
135
+ }
124
136
}
125
137
unifiedPushStore.storePushGateway(gateway)
126
138
onDoneRunnable?.run ()
0 commit comments