Execute SEService initialization on the handler thread
This (hopefully) eliminates a race condition where the connected listenr is called before the service variable is assigned.
This commit is contained in:
parent
d6a3cc820c
commit
c3f4770108
|
@ -34,9 +34,11 @@ class EuiccChannelManager(private val context: Context) {
|
||||||
private val handler = Handler(HandlerThread("EuiccChannelManager").also { it.start() }.looper)
|
private val handler = Handler(HandlerThread("EuiccChannelManager").also { it.start() }.looper)
|
||||||
|
|
||||||
private suspend fun connectSEService(): SEService = suspendCoroutine { cont ->
|
private suspend fun connectSEService(): SEService = suspendCoroutine { cont ->
|
||||||
var service: SEService? = null
|
handler.post {
|
||||||
service = SEService(context, { handler.post(it) }) {
|
var service: SEService? = null
|
||||||
cont.resume(service!!)
|
service = SEService(context, { handler.post(it) }) {
|
||||||
|
cont.resume(service!!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue