1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-01 08:03:37 +00:00

Better way of checking for autofill sevrice running

This commit is contained in:
Kyle Spearrin
2017-02-17 23:22:02 -05:00
parent b435256911
commit d53ea584ba
2 changed files with 12 additions and 16 deletions

View File

@@ -1,4 +1,6 @@
using Bit.App.Abstractions;
using Android.App;
using Bit.App.Abstractions;
using System.Linq;
using AndroidApp = Android.App.Application;
namespace Bit.Android.Services
@@ -11,6 +13,14 @@ namespace Bit.Android.Services
public string Build => AndroidApp.Context.ApplicationContext.PackageManager
.GetPackageInfo(AndroidApp.Context.PackageName, 0).VersionCode.ToString();
public bool AutofillServiceEnabled => AutofillService.Enabled;
public bool AutofillServiceEnabled => AutofillRunning();
private bool AutofillRunning()
{
var manager = ((ActivityManager)Xamarin.Forms.Forms.Context.GetSystemService("activity"));
var services = manager.GetRunningServices(int.MaxValue);
return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") &&
s.Service.ClassName.ToLowerInvariant().Contains("autofill"));
}
}
}