From 81a8d8702520cb70c5d7b58d4cc9b91e76f1df37 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Thu, 6 Jun 2024 20:04:24 +0900 Subject: [PATCH] Make it as singleton and create setScope and start function. Change-Id: I842554dfa2884942a0c74a2ecd0645020238f237 --- .../apps/nowinandroid/util/ProfileVerifierLogger.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/util/ProfileVerifierLogger.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/util/ProfileVerifierLogger.kt index 9794a7b9e..4b7e59827 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/util/ProfileVerifierLogger.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/util/ProfileVerifierLogger.kt @@ -46,14 +46,15 @@ import kotlinx.coroutines.launch * * @see androidx.profileinstaller.ProfileVerifier.CompilationStatus.ResultCode */ -class ProfileVerifierLogger ( - private val scope: CoroutineScope, -) { - companion object { - private const val TAG = "ProfileInstaller" +object ProfileVerifierLogger { + private const val TAG = "ProfileInstaller" + private var scope: CoroutineScope? = null + + fun setScope(scope: CoroutineScope) { + this.scope = scope } - operator fun invoke() = scope.launch { + fun start() = scope?.launch { val status = ProfileVerifier.getCompilationStatusAsync().await() Log.d(TAG, "Status code: ${status.profileInstallResultCode}") Log.d(