diff --git a/platform/jvm/gradle-test-app/src/main/java/io/bitdrift/gradletestapp/FatalIssueGenerator.kt b/platform/jvm/gradle-test-app/src/main/java/io/bitdrift/gradletestapp/FatalIssueGenerator.kt index 53dc696c5..d5b6470b6 100644 --- a/platform/jvm/gradle-test-app/src/main/java/io/bitdrift/gradletestapp/FatalIssueGenerator.kt +++ b/platform/jvm/gradle-test-app/src/main/java/io/bitdrift/gradletestapp/FatalIssueGenerator.kt @@ -34,6 +34,7 @@ import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import java.util.UUID /** @@ -92,18 +93,13 @@ internal object FatalIssueGenerator { } fun forceCoroutinesAnr() { - CoroutineScope(Dispatchers.Main).launch { - (1..Int.MAX_VALUE).asFlow() - .onEach { - Thread.sleep(1) - } - .collect { - Log.i(TAG_NAME, "Item received: $it") - } + callOnMainThread { + Log.i(TAG_NAME, "forceCoroutinesAnr. Getting device") + val deviceId = DeviceFetcher.getDeviceId() + Log.d(TAG_NAME, "forceCoroutinesAnr. Device ID: $deviceId") } } - fun forceCoroutinesCrash(){ CoroutineScope(Dispatchers.IO).launch { throw RuntimeException("Coroutine background thread crash") @@ -195,4 +191,22 @@ internal object FatalIssueGenerator { return "Task ID [$id] completed with a $duration of milliseconds" } } + + object DeviceFetcher { + + private suspend fun fetchDeviceId(): String { + delay(20000) + return "Device ID: ${UUID.randomUUID()}" + } + + /** + * This call will block caller thread until fetchDeviceId completes + */ + fun getDeviceId(): String { + return runBlocking { + Log.i("DeviceScopeRegistry", "getDevice") + fetchDeviceId() + } + } + } } \ No newline at end of file