try/catch on autofill service detection

This commit is contained in:
Kyle Spearrin 2019-06-05 08:24:47 -04:00
parent e59ac5d65d
commit 3b7078e565

View file

@ -323,10 +323,17 @@ namespace Bit.Droid.Services
{ {
return false; return false;
} }
var activity = (MainActivity)CrossCurrentActivity.Current.Activity; try
var type = Java.Lang.Class.FromType(typeof(AutofillManager)); {
var manager = activity.GetSystemService(type) as AutofillManager; var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
return manager.IsAutofillSupported; var type = Java.Lang.Class.FromType(typeof(AutofillManager));
var manager = activity.GetSystemService(type) as AutofillManager;
return manager.IsAutofillSupported;
}
catch
{
return false;
}
} }
public int SystemMajorVersion() public int SystemMajorVersion()
@ -514,9 +521,16 @@ namespace Bit.Droid.Services
{ {
return false; return false;
} }
var activity = (MainActivity)CrossCurrentActivity.Current.Activity; try
var afm = (AutofillManager)activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager))); {
return afm.IsEnabled && afm.HasEnabledAutofillServices; 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() public void OpenAccessibilitySettings()