From 848281b4817b58c47c9618b860eaa5368e2bc80b Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 5 Sep 2022 16:45:44 +0300 Subject: [PATCH] Remove SMS autofill feature for android --- .../login/two_factor_authentication_page.dart | 45 ------------------- pubspec.lock | 7 --- pubspec.yaml | 1 - 3 files changed, 53 deletions(-) diff --git a/lib/core/auth/login/two_factor_authentication_page.dart b/lib/core/auth/login/two_factor_authentication_page.dart index fc5b6f2..470b500 100644 --- a/lib/core/auth/login/two_factor_authentication_page.dart +++ b/lib/core/auth/login/two_factor_authentication_page.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; -import 'package:alt_sms_autofill/alt_sms_autofill.dart'; import 'package:thingsboard_app/core/auth/login/login_page_background.dart'; import 'package:thingsboard_app/core/context/tb_context.dart'; import 'package:thingsboard_app/core/context/tb_context_widget.dart'; @@ -66,8 +65,6 @@ class TwoFactorAuthenticationPage extends TbPageWidget { class _TwoFactorAuthenticationPageState extends TbPageState { - static RegExp smsCodeRegExp = new RegExp(r"(\d{6})"); - final _twoFactorAuthFormKey = GlobalKey(); ValueNotifier _selectedProvider = ValueNotifier(null); @@ -80,7 +77,6 @@ class _TwoFactorAuthenticationPageState Timer? _timer; Timer? _tooManyRequestsTimer; ValueNotifier _countDownTime = ValueNotifier(0); - bool _listenForSms = false; @override void initState() { @@ -101,9 +97,6 @@ class _TwoFactorAuthenticationPageState if (this._selectedProvider.value != TwoFaProviderType.TOTP) { _sendCode(); _showResendAction.value = true; - if (this._selectedProvider.value == TwoFaProviderType.SMS) { - _startListenForSmsCode(); - } } _timer = Timer.periodic(Duration(seconds: 1), (timer) { _updatedTime(); @@ -118,7 +111,6 @@ class _TwoFactorAuthenticationPageState if (_tooManyRequestsTimer != null) { _tooManyRequestsTimer!.cancel(); } - _cancelSmsCodeListen(); super.dispose(); } @@ -378,39 +370,6 @@ class _TwoFactorAuthenticationPageState labelText: providerFormData.placeholderFunction(context))); } - Future _startListenForSmsCode() async { - _listenForSms = true; - _listenForSmsCode(); - } - - Future _listenForSmsCode() async { - String? comingSms; - try { - comingSms = await AltSmsAutofill().listenForSms; - } catch (e) { - _listenForSms = false; - comingSms = null; - } - if (comingSms != null) { - RegExpMatch? match = smsCodeRegExp.firstMatch(comingSms); - if (match != null) { - String? codeStr = match.group(1); - if (codeStr != null) { - _twoFactorAuthFormKey.currentState - ?.patchValue({'verificationCode': codeStr}); - } - } - } - if (_listenForSms) { - _listenForSmsCode(); - } - } - - Future _cancelSmsCodeListen() async { - _listenForSms = false; - AltSmsAutofill().unregisterListener(); - } - Future _sendVerificationCode(BuildContext context) async { FocusScope.of(context).unfocus(); if (_twoFactorAuthFormKey.currentState?.saveAndValidate() ?? false) { @@ -451,7 +410,6 @@ class _TwoFactorAuthenticationPageState _prevProvider = type == null ? _selectedProvider.value : null; _selectedProvider.value = type; _showResendAction.value = false; - await _cancelSmsCodeListen(); if (type != null) { var providersInfo = tbContext.twoFactorAuthProviders; var providerConfig = @@ -462,9 +420,6 @@ class _TwoFactorAuthenticationPageState _showResendAction.value = true; _minVerificationPeriod = providerConfig.minVerificationCodeSendPeriod ?? 30; - if (type == TwoFaProviderType.SMS) { - _startListenForSmsCode(); - } } } } diff --git a/pubspec.lock b/pubspec.lock index f5e0855..d371ade 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,6 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - alt_sms_autofill: - dependency: "direct main" - description: - name: alt_sms_autofill - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f64253f..6897e4c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,6 @@ dependencies: preload_page_view: ^0.1.6 flutter_localizations: sdk: flutter - alt_sms_autofill: ^1.0.0 dev_dependencies: flutter_test: