mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-07 09:20:04 +01:00
Better way of checking for autofill sevrice running
This commit is contained in:
parent
b435256911
commit
d53ea584ba
@ -19,7 +19,6 @@ namespace Bit.Android
|
|||||||
private const string BitwardenPackage = "com.x8bit.bitwarden";
|
private const string BitwardenPackage = "com.x8bit.bitwarden";
|
||||||
private const string BitwardenWebsite = "bitwarden.com";
|
private const string BitwardenWebsite = "bitwarden.com";
|
||||||
|
|
||||||
public static bool Enabled { get; set; } = false;
|
|
||||||
private static Dictionary<string, Browser> SupportedBrowsers => new List<Browser>
|
private static Dictionary<string, Browser> SupportedBrowsers => new List<Browser>
|
||||||
{
|
{
|
||||||
new Browser("com.android.chrome", "url_bar"),
|
new Browser("com.android.chrome", "url_bar"),
|
||||||
@ -54,7 +53,6 @@ namespace Bit.Android
|
|||||||
|
|
||||||
public override void OnAccessibilityEvent(AccessibilityEvent e)
|
public override void OnAccessibilityEvent(AccessibilityEvent e)
|
||||||
{
|
{
|
||||||
Enabled = true;
|
|
||||||
var root = RootInActiveWindow;
|
var root = RootInActiveWindow;
|
||||||
if(string.IsNullOrWhiteSpace(e.PackageName) || e.PackageName == SystemUiPackage ||
|
if(string.IsNullOrWhiteSpace(e.PackageName) || e.PackageName == SystemUiPackage ||
|
||||||
root?.PackageName != e.PackageName)
|
root?.PackageName != e.PackageName)
|
||||||
@ -116,18 +114,6 @@ namespace Bit.Android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnServiceConnected()
|
|
||||||
{
|
|
||||||
base.OnServiceConnected();
|
|
||||||
Enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDestroy()
|
|
||||||
{
|
|
||||||
base.OnDestroy();
|
|
||||||
Enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CancelNotification()
|
private void CancelNotification()
|
||||||
{
|
{
|
||||||
var notificationManager = ((NotificationManager)GetSystemService(NotificationService));
|
var notificationManager = ((NotificationManager)GetSystemService(NotificationService));
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using Bit.App.Abstractions;
|
using Android.App;
|
||||||
|
using Bit.App.Abstractions;
|
||||||
|
using System.Linq;
|
||||||
using AndroidApp = Android.App.Application;
|
using AndroidApp = Android.App.Application;
|
||||||
|
|
||||||
namespace Bit.Android.Services
|
namespace Bit.Android.Services
|
||||||
@ -11,6 +13,14 @@ namespace Bit.Android.Services
|
|||||||
public string Build => AndroidApp.Context.ApplicationContext.PackageManager
|
public string Build => AndroidApp.Context.ApplicationContext.PackageManager
|
||||||
.GetPackageInfo(AndroidApp.Context.PackageName, 0).VersionCode.ToString();
|
.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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user