From 3b7078e5653ebab338f8932e2cdad635923f5138 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 5 Jun 2019 08:24:47 -0400 Subject: [PATCH] try/catch on autofill service detection --- src/Android/Services/DeviceActionService.cs | 28 +++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index b749a2012..23e7d0c4d 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -323,10 +323,17 @@ namespace Bit.Droid.Services { return false; } - var activity = (MainActivity)CrossCurrentActivity.Current.Activity; - var type = Java.Lang.Class.FromType(typeof(AutofillManager)); - var manager = activity.GetSystemService(type) as AutofillManager; - return manager.IsAutofillSupported; + try + { + var activity = (MainActivity)CrossCurrentActivity.Current.Activity; + var type = Java.Lang.Class.FromType(typeof(AutofillManager)); + var manager = activity.GetSystemService(type) as AutofillManager; + return manager.IsAutofillSupported; + } + catch + { + return false; + } } public int SystemMajorVersion() @@ -514,9 +521,16 @@ namespace Bit.Droid.Services { return false; } - var activity = (MainActivity)CrossCurrentActivity.Current.Activity; - var afm = (AutofillManager)activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager))); - return afm.IsEnabled && afm.HasEnabledAutofillServices; + try + { + var activity = (MainActivity)CrossCurrentActivity.Current.Activity; + var afm = (AutofillManager)activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager))); + return afm.IsEnabled && afm.HasEnabledAutofillServices; + } + catch + { + return false; + } } public void OpenAccessibilitySettings()