From 1e63cc3ce7e93f585c10bb1814195d0e19cdda3f Mon Sep 17 00:00:00 2001 From: Timur Tharkahov Date: Wed, 12 Jul 2023 12:24:59 +0300 Subject: [PATCH] fix: possible crash on second received code and on timeout (#57) * fix: possible crash - unstable crash on second received code - unstable crash on timeout * feat(version): added fvm usage * feat(version): updated usage for future workflow usage * feat(version): read version from fvm config * fix(version): pick flutter version from fvm config * fix(version): up surf_lint_rules to evade invariant_booleans rule * fix(version): up surf_lint_rules to evade invariant_booleans rule * fix(example): fix example to comply analyzer --------- Co-authored-by: Podushkin Vitaliy --- .../main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt index 5f3f2d4..e533455 100644 --- a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt +++ b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt @@ -123,6 +123,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi // Get SMS message content val message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE) lastResult?.success(message) + lastResult = null } else { // Consent denied. User can type OTC manually. } @@ -130,6 +131,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi val phoneNumber = Identity.getSignInClient(context!!).getPhoneNumberFromIntent(data) lastResult?.success(phoneNumber) + lastResult = null } } return true @@ -170,6 +172,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi override fun onFailure() { lastResult?.error("408", "Timeout exception", null) + lastResult = null } } } @@ -182,11 +185,15 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi smsRetrieverBroadcastReceiver = SmsRetrieverReceiver().also { it.smsBroadcastReceiverListener = object : SmsRetrieverReceiver.SmsRetrieverBroadcastReceiverListener { override fun onSuccess(sms: String?) { - sms?.let { it -> lastResult?.success(it) } + sms?.let { it -> + lastResult?.success(it) + lastResult = null + } } override fun onFailure() { lastResult?.error("408", "Timeout exception", null) + lastResult = null } } }