diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index 99e1d870b..6c4cae457 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -52,6 +52,8 @@ namespace Bit.Android public override void OnAccessibilityEvent(AccessibilityEvent e) { + Enabled = true; + var eventType = e.EventType; var packageName = e.PackageName; diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index dd025d7b9..6db3f07db 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -98,6 +98,7 @@ namespace Bit.Android private void ReturnCredentials(VaultListPageModel.Login login) { + App.App.FromAutofillService = true; Intent data = new Intent(); if(login == null) { @@ -154,8 +155,12 @@ namespace Bit.Android protected override void OnResume() { - Console.WriteLine("A OnResume"); base.OnResume(); + Console.WriteLine("A OnResume"); + + // workaround for app compat bug + // ref https://bugzilla.xamarin.com/show_bug.cgi?id=36907 + Task.Delay(10).Wait(); } public void RateApp() diff --git a/src/App/App.cs b/src/App/App.cs index 1ba315185..e152c972c 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -33,6 +33,8 @@ namespace Bit.App private readonly ILocalizeService _localizeService; private CancellationTokenSource _setMainPageCancellationTokenSource = null; + public static bool FromAutofillService { get; set; } = false; + public App( string uri, IAuthService authService, @@ -61,6 +63,7 @@ namespace Bit.App SetCulture(); SetStyles(); + FromAutofillService = !string.IsNullOrWhiteSpace(_uri); if(authService.IsAuthenticated && _uri != null) { MainPage = new ExtendedNavigationPage(new VaultAutofillListLoginsPage(_uri)); @@ -111,11 +114,12 @@ namespace Bit.App Debug.WriteLine("OnStart"); } - protected async override void OnSleep() + protected override void OnSleep() { // Handle when your app sleeps Debug.WriteLine("OnSleep"); - + + _setMainPageCancellationTokenSource = SetMainPageFromAutofill(_setMainPageCancellationTokenSource, 500); if(Device.OS == TargetPlatform.Android && !TopPageIsLock()) { _settings.AddOrUpdateValue(Constants.LastActivityDate, DateTime.UtcNow); @@ -153,6 +157,10 @@ namespace Bit.App } previousCts?.Cancel(); + if(!FromAutofillService || string.IsNullOrWhiteSpace(_uri)) + { + return null; + } var cts = new CancellationTokenSource(); Task.Run(async () => @@ -169,6 +177,7 @@ namespace Bit.App }); _uri = null; + FromAutofillService = false; }, cts.Token); return cts;