From 58aa37bf8e89ddf3a60d825c706a5d02efdb9e31 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 1 Aug 2018 15:45:32 -0400 Subject: [PATCH] catch EnableForegroundDispatch exception. disable back button on yubikey 2fa. --- src/Android/MainActivity.cs | 8 ++++++-- src/App/Pages/LoginTwoFactorPage.cs | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 91b17141f..2f5dfa298 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -233,8 +233,12 @@ namespace Bit.Android ndef.AddDataScheme("https"); var filters = new IntentFilter[] { ndef }; - // register for foreground dispatch so we'll receive tags according to our intent filters - adapter.EnableForegroundDispatch(this, pendingIntent, filters, null); + try + { + // register for foreground dispatch so we'll receive tags according to our intent filters + adapter.EnableForegroundDispatch(this, pendingIntent, filters, null); + } + catch { } } else { diff --git a/src/App/Pages/LoginTwoFactorPage.cs b/src/App/Pages/LoginTwoFactorPage.cs index c045afe1b..ad7135580 100644 --- a/src/App/Pages/LoginTwoFactorPage.cs +++ b/src/App/Pages/LoginTwoFactorPage.cs @@ -335,6 +335,17 @@ namespace Bit.App.Pages MessagingCenter.Unsubscribe(Application.Current, "ResumeYubiKey"); } + protected override bool OnBackButtonPressed() + { + // ref: https://github.com/bitwarden/mobile/issues/350 + if(Device.RuntimePlatform == Device.Android && _providerType.HasValue && + _providerType.Value == TwoFactorProviderType.YubiKey) + { + return true; + } + return base.OnBackButtonPressed(); + } + private async void AnotherMethodAsync() { var beforeProviderType = _providerType;