diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2023-06-01 20:50:52 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-06-04 01:52:57 +0530 |
commit | 3a4e827f1abcb3d77d43dba4f7cf4d9a9c9655f7 (patch) | |
tree | 96b314ed0cb1f62722e6c02336c28c0819673916 /app/src/nonFree | |
parent | 496f421f170f6d437cdef63dc4644bf6b423a547 (diff) |
fix: clear violations of `RawDispatcherUse`
Diffstat (limited to 'app/src/nonFree')
-rw-r--r-- | app/src/nonFree/java/app/passwordstore/autofill/oreo/ui/AutofillSmsActivity.kt | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/src/nonFree/java/app/passwordstore/autofill/oreo/ui/AutofillSmsActivity.kt b/app/src/nonFree/java/app/passwordstore/autofill/oreo/ui/AutofillSmsActivity.kt index 7641ad95..61b42342 100644 --- a/app/src/nonFree/java/app/passwordstore/autofill/oreo/ui/AutofillSmsActivity.kt +++ b/app/src/nonFree/java/app/passwordstore/autofill/oreo/ui/AutofillSmsActivity.kt @@ -18,6 +18,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import app.passwordstore.databinding.ActivityOreoAutofillSmsBinding import app.passwordstore.util.autofill.AutofillResponseBuilder +import app.passwordstore.util.coroutines.DispatcherProvider import app.passwordstore.util.extensions.viewBinding import com.github.androidpasswordstore.autofillparser.AutofillAction import com.github.androidpasswordstore.autofillparser.Credentials @@ -29,11 +30,12 @@ import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import com.google.android.gms.common.api.ResolvableApiException import com.google.android.gms.tasks.Task +import dagger.hilt.android.AndroidEntryPoint import java.util.concurrent.ExecutionException +import javax.inject.Inject import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import logcat.LogPriority.ERROR @@ -51,8 +53,11 @@ suspend fun <T> Task<T>.suspendableAwait() = } } +@AndroidEntryPoint class AutofillSmsActivity : AppCompatActivity() { + @Inject lateinit var dispatcherProvider: DispatcherProvider + companion object { private var fillOtpFromSmsRequestCode = 1 @@ -129,14 +134,16 @@ class AutofillSmsActivity : AppCompatActivity() { private suspend fun waitForSms() { val smsClient = SmsCodeRetriever.getAutofillClient(this@AutofillSmsActivity) runCatching { - withContext(Dispatchers.IO) { smsClient.startSmsCodeRetriever().suspendableAwait() } + withContext(dispatcherProvider.io()) { + smsClient.startSmsCodeRetriever().suspendableAwait() + } } .onFailure { e -> if (e is ResolvableApiException) { e.startResolutionForResult(this@AutofillSmsActivity, 1) } else { logcat(ERROR) { e.asLog() } - withContext(Dispatchers.Main) { finish() } + withContext(dispatcherProvider.main()) { finish() } } } } |