diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index dd238eb26..03103868c 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -17,7 +17,7 @@ Off Properties\AndroidManifest.xml True - v6.0 + v7.1 armeabi,armeabi-v7a,x86 diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index 8647c694c..878a18f71 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -53,76 +53,76 @@ namespace Bit.Android public override void OnAccessibilityEvent(AccessibilityEvent e) { - var root = RootInActiveWindow; - if(e == null || root == null || string.IsNullOrWhiteSpace(e.PackageName) || - e.PackageName == SystemUiPackage || root.PackageName != e.PackageName) + try { - return; - } + var root = RootInActiveWindow; + if(e == null || root == null || string.IsNullOrWhiteSpace(e.PackageName) || + e.PackageName == SystemUiPackage || root.PackageName != e.PackageName) + { + return; + } - /* - var testNodes = GetWindowNodes(root, e, n => n.ViewIdResourceName != null && n.Text != null, false); - var testNodesData = testNodes.Select(n => new { id = n.ViewIdResourceName, text = n.Text }); - testNodes.Dispose(); - */ + /* + var testNodes = GetWindowNodes(root, e, n => n.ViewIdResourceName != null && n.Text != null, false); + var testNodesData = testNodes.Select(n => new { id = n.ViewIdResourceName, text = n.Text }); + testNodes.Dispose(); + */ - var notificationManager = (NotificationManager)GetSystemService(NotificationService); - switch(e.EventType) - { - case EventTypes.WindowContentChanged: - case EventTypes.WindowStateChanged: - var cancelNotification = true; + var notificationManager = (NotificationManager)GetSystemService(NotificationService); + switch(e.EventType) + { + case EventTypes.WindowContentChanged: + case EventTypes.WindowStateChanged: + var cancelNotification = true; - if(e.PackageName == BitwardenPackage) - { - notificationManager?.Cancel(AutoFillNotificationId); - break; - } - - var passwordNodes = GetWindowNodes(root, e, n => n.Password, false); - if(passwordNodes.Count > 0) - { - var uri = GetUri(root); - if(uri != null && !uri.Contains(BitwardenWebsite)) + if(e.PackageName == BitwardenPackage) { - if(NeedToAutofill(AutofillActivity.LastCredentials, uri)) - { - var allEditTexts = GetWindowNodes(root, e, n => EditText(n), false); - var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault(); - FillCredentials(usernameEditText, passwordNodes); - - allEditTexts.Dispose(); - //allEditTexts = null; - usernameEditText.Dispose(); - //usernameEditText = null; - } - else - { - NotifyToAutofill(uri, notificationManager); - cancelNotification = false; - } + notificationManager?.Cancel(AutoFillNotificationId); + break; } - AutofillActivity.LastCredentials = null; - } + var passwordNodes = GetWindowNodes(root, e, n => n.Password, false); + if(passwordNodes.Count > 0) + { + var uri = GetUri(root); + if(uri != null && !uri.Contains(BitwardenWebsite)) + { + if(NeedToAutofill(AutofillActivity.LastCredentials, uri)) + { + var allEditTexts = GetWindowNodes(root, e, n => EditText(n), false); + var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault(); + FillCredentials(usernameEditText, passwordNodes); - passwordNodes.Dispose(); - //passwordNodes = null; + allEditTexts.Dispose(); + usernameEditText.Dispose(); + } + else + { + NotifyToAutofill(uri, notificationManager); + cancelNotification = false; + } + } - if(cancelNotification) - { - notificationManager?.Cancel(AutoFillNotificationId); - } - break; - default: - break; + AutofillActivity.LastCredentials = null; + } + + passwordNodes.Dispose(); + + if(cancelNotification) + { + notificationManager?.Cancel(AutoFillNotificationId); + } + break; + default: + break; + } + + notificationManager?.Dispose(); + root.Dispose(); + e.Dispose(); } - - notificationManager?.Dispose(); - //notificationManager = null; - root.Dispose(); - //root = null; - e.Dispose(); + // Some unknown condition is causing NullReferenceException's in production. Suppress it for now. + catch(NullReferenceException) { } } public override void OnInterrupt() @@ -141,7 +141,6 @@ namespace Bit.Android { uri = ExtractUri(uri, addressNode, SupportedBrowsers[root.PackageName]); addressNode.Dispose(); - //addressNode = null; } } @@ -233,7 +232,6 @@ namespace Bit.Android notificationManager.Notify(AutoFillNotificationId, builder.Build()); builder.Dispose(); - //builder = null; } private void FillCredentials(AccessibilityNodeInfo usernameNode, IEnumerable passwordNodes) diff --git a/src/Android/Properties/AndroidManifest.xml b/src/Android/Properties/AndroidManifest.xml index e64a69c91..469dc538e 100644 --- a/src/Android/Properties/AndroidManifest.xml +++ b/src/Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/src/App/Pages/Vault/VaultEditLoginPage.cs b/src/App/Pages/Vault/VaultEditLoginPage.cs index 42b97432a..9e78b408b 100644 --- a/src/App/Pages/Vault/VaultEditLoginPage.cs +++ b/src/App/Pages/Vault/VaultEditLoginPage.cs @@ -213,29 +213,49 @@ namespace Bit.App.Pages AlertNoConnection(); } - PasswordCell.InitEvents(); - UsernameCell.InitEvents(); - UriCell.InitEvents(); - NameCell.InitEvents(); - NotesCell.InitEvents(); - FolderCell.InitEvents(); - PasswordCell.Button.Clicked += PasswordButton_Clicked; - GenerateCell.Tapped += GenerateCell_Tapped; - DeleteCell.Tapped += DeleteCell_Tapped; + PasswordCell?.InitEvents(); + UsernameCell?.InitEvents(); + UriCell?.InitEvents(); + NameCell?.InitEvents(); + NotesCell?.InitEvents(); + FolderCell?.InitEvents(); + + if(PasswordCell?.Button != null) + { + PasswordCell.Button.Clicked += PasswordButton_Clicked; + } + if(GenerateCell != null) + { + GenerateCell.Tapped += GenerateCell_Tapped; + } + if(DeleteCell != null) + { + DeleteCell.Tapped += DeleteCell_Tapped; + } } protected override void OnDisappearing() { base.OnDisappearing(); - PasswordCell.Dispose(); - UsernameCell.Dispose(); - UriCell.Dispose(); - NameCell.Dispose(); - NotesCell.Dispose(); - FolderCell.Dispose(); - PasswordCell.Button.Clicked -= PasswordButton_Clicked; - GenerateCell.Tapped -= GenerateCell_Tapped; - DeleteCell.Tapped -= DeleteCell_Tapped; + PasswordCell?.Dispose(); + UsernameCell?.Dispose(); + UriCell?.Dispose(); + NameCell?.Dispose(); + NotesCell?.Dispose(); + FolderCell?.Dispose(); + + if(PasswordCell?.Button != null) + { + PasswordCell.Button.Clicked -= PasswordButton_Clicked; + } + if(GenerateCell != null) + { + GenerateCell.Tapped -= GenerateCell_Tapped; + } + if(DeleteCell != null) + { + DeleteCell.Tapped -= DeleteCell_Tapped; + } } private void PasswordButton_Clicked(object sender, EventArgs e) diff --git a/test/Android.Test/Android.Test.csproj b/test/Android.Test/Android.Test.csproj index a58c27213..7bf17e30d 100644 --- a/test/Android.Test/Android.Test.csproj +++ b/test/Android.Test/Android.Test.csproj @@ -16,7 +16,7 @@ Resources\Resource.Designer.cs Off True - v6.0 + v7.1 Properties\AndroidManifest.xml