Skip to content

Commit 848281b

Browse files
committed
Remove SMS autofill feature for android
1 parent fa378d5 commit 848281b

File tree

3 files changed

+0
-53
lines changed

3 files changed

+0
-53
lines changed

lib/core/auth/login/two_factor_authentication_page.dart

-45
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
44
import 'package:flutter_form_builder/flutter_form_builder.dart';
55
import 'package:form_builder_validators/form_builder_validators.dart';
66
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
7-
import 'package:alt_sms_autofill/alt_sms_autofill.dart';
87
import 'package:thingsboard_app/core/auth/login/login_page_background.dart';
98
import 'package:thingsboard_app/core/context/tb_context.dart';
109
import 'package:thingsboard_app/core/context/tb_context_widget.dart';
@@ -66,8 +65,6 @@ class TwoFactorAuthenticationPage extends TbPageWidget {
6665

6766
class _TwoFactorAuthenticationPageState
6867
extends TbPageState<TwoFactorAuthenticationPage> {
69-
static RegExp smsCodeRegExp = new RegExp(r"(\d{6})");
70-
7168
final _twoFactorAuthFormKey = GlobalKey<FormBuilderState>();
7269
ValueNotifier<TwoFaProviderType?> _selectedProvider =
7370
ValueNotifier<TwoFaProviderType?>(null);
@@ -80,7 +77,6 @@ class _TwoFactorAuthenticationPageState
8077
Timer? _timer;
8178
Timer? _tooManyRequestsTimer;
8279
ValueNotifier<int> _countDownTime = ValueNotifier<int>(0);
83-
bool _listenForSms = false;
8480

8581
@override
8682
void initState() {
@@ -101,9 +97,6 @@ class _TwoFactorAuthenticationPageState
10197
if (this._selectedProvider.value != TwoFaProviderType.TOTP) {
10298
_sendCode();
10399
_showResendAction.value = true;
104-
if (this._selectedProvider.value == TwoFaProviderType.SMS) {
105-
_startListenForSmsCode();
106-
}
107100
}
108101
_timer = Timer.periodic(Duration(seconds: 1), (timer) {
109102
_updatedTime();
@@ -118,7 +111,6 @@ class _TwoFactorAuthenticationPageState
118111
if (_tooManyRequestsTimer != null) {
119112
_tooManyRequestsTimer!.cancel();
120113
}
121-
_cancelSmsCodeListen();
122114
super.dispose();
123115
}
124116

@@ -378,39 +370,6 @@ class _TwoFactorAuthenticationPageState
378370
labelText: providerFormData.placeholderFunction(context)));
379371
}
380372

381-
Future<void> _startListenForSmsCode() async {
382-
_listenForSms = true;
383-
_listenForSmsCode();
384-
}
385-
386-
Future<void> _listenForSmsCode() async {
387-
String? comingSms;
388-
try {
389-
comingSms = await AltSmsAutofill().listenForSms;
390-
} catch (e) {
391-
_listenForSms = false;
392-
comingSms = null;
393-
}
394-
if (comingSms != null) {
395-
RegExpMatch? match = smsCodeRegExp.firstMatch(comingSms);
396-
if (match != null) {
397-
String? codeStr = match.group(1);
398-
if (codeStr != null) {
399-
_twoFactorAuthFormKey.currentState
400-
?.patchValue({'verificationCode': codeStr});
401-
}
402-
}
403-
}
404-
if (_listenForSms) {
405-
_listenForSmsCode();
406-
}
407-
}
408-
409-
Future<void> _cancelSmsCodeListen() async {
410-
_listenForSms = false;
411-
AltSmsAutofill().unregisterListener();
412-
}
413-
414373
Future<void> _sendVerificationCode(BuildContext context) async {
415374
FocusScope.of(context).unfocus();
416375
if (_twoFactorAuthFormKey.currentState?.saveAndValidate() ?? false) {
@@ -451,7 +410,6 @@ class _TwoFactorAuthenticationPageState
451410
_prevProvider = type == null ? _selectedProvider.value : null;
452411
_selectedProvider.value = type;
453412
_showResendAction.value = false;
454-
await _cancelSmsCodeListen();
455413
if (type != null) {
456414
var providersInfo = tbContext.twoFactorAuthProviders;
457415
var providerConfig =
@@ -462,9 +420,6 @@ class _TwoFactorAuthenticationPageState
462420
_showResendAction.value = true;
463421
_minVerificationPeriod =
464422
providerConfig.minVerificationCodeSendPeriod ?? 30;
465-
if (type == TwoFaProviderType.SMS) {
466-
_startListenForSmsCode();
467-
}
468423
}
469424
}
470425
}

pubspec.lock

-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4-
alt_sms_autofill:
5-
dependency: "direct main"
6-
description:
7-
name: alt_sms_autofill
8-
url: "https://pub.dartlang.org"
9-
source: hosted
10-
version: "1.0.0"
114
archive:
125
dependency: transitive
136
description:

pubspec.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ dependencies:
4747
preload_page_view: ^0.1.6
4848
flutter_localizations:
4949
sdk: flutter
50-
alt_sms_autofill: ^1.0.0
5150

5251
dev_dependencies:
5352
flutter_test:

0 commit comments

Comments
 (0)