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,11 +34,13 @@ class EuiccChannelManager(private val context: Context) {
|
|||
private val handler = Handler(HandlerThread("EuiccChannelManager").also { it.start() }.looper)
|
||||
|
||||
private suspend fun connectSEService(): SEService = suspendCoroutine { cont ->
|
||||
handler.post {
|
||||
var service: SEService? = null
|
||||
service = SEService(context, { handler.post(it) }) {
|
||||
cont.resume(service!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun ensureSEService() {
|
||||
if (seService == null) {
|
||||
|
|
Loading…
Reference in a new issue