mirror of
https://github.com/bitwarden/android.git
synced 2025-03-28 00:29:24 +03:00
check installed launchers to skip
This commit is contained in:
parent
9dbb1f15a4
commit
dfd39ebc95
1 changed files with 27 additions and 2 deletions
|
@ -64,6 +64,7 @@ namespace Bit.Android
|
||||||
new Browser("com.duckduckgo.mobile.android", "omnibarTextInput")
|
new Browser("com.duckduckgo.mobile.android", "omnibarTextInput")
|
||||||
}.ToDictionary(n => n.PackageName);
|
}.ToDictionary(n => n.PackageName);
|
||||||
|
|
||||||
|
// Known packages to skip
|
||||||
private static HashSet<string> FilteredPackageNames => new HashSet<string>
|
private static HashSet<string> FilteredPackageNames => new HashSet<string>
|
||||||
{
|
{
|
||||||
SystemUiPackage,
|
SystemUiPackage,
|
||||||
|
@ -86,6 +87,9 @@ namespace Bit.Android
|
||||||
private readonly IAppSettingsService _appSettings;
|
private readonly IAppSettingsService _appSettings;
|
||||||
private long _lastNotificationTime = 0;
|
private long _lastNotificationTime = 0;
|
||||||
private string _lastNotificationUri = null;
|
private string _lastNotificationUri = null;
|
||||||
|
private HashSet<string> _launcherPackageNames = null;
|
||||||
|
private DateTime? _lastLauncherSetBuilt = null;
|
||||||
|
private TimeSpan _rebuildLauncherSpan = TimeSpan.FromHours(1);
|
||||||
|
|
||||||
public AutofillService()
|
public AutofillService()
|
||||||
{
|
{
|
||||||
|
@ -106,8 +110,7 @@ namespace Bit.Android
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(string.IsNullOrWhiteSpace(e?.PackageName) || FilteredPackageNames.Contains(e.PackageName) ||
|
if(SkipPackage(e?.PackageName))
|
||||||
e.PackageName.Contains("launcher"))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -465,6 +468,28 @@ namespace Bit.Android
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool SkipPackage(string eventPackageName)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(eventPackageName) || FilteredPackageNames.Contains(eventPackageName)
|
||||||
|
|| eventPackageName.Contains("launcher"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_launcherPackageNames == null || _lastLauncherSetBuilt == null ||
|
||||||
|
(DateTime.Now - _lastLauncherSetBuilt.Value) > _rebuildLauncherSpan)
|
||||||
|
{
|
||||||
|
// refresh launcher list every now and then
|
||||||
|
_lastLauncherSetBuilt = DateTime.Now;
|
||||||
|
var intent = new Intent(Intent.ActionMain);
|
||||||
|
intent.AddCategory(Intent.CategoryHome);
|
||||||
|
var resolveInfo = PackageManager.QueryIntentActivities(intent, 0);
|
||||||
|
_launcherPackageNames = resolveInfo.Select(ri => ri.ActivityInfo.PackageName).ToHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _launcherPackageNames.Contains(eventPackageName);
|
||||||
|
}
|
||||||
|
|
||||||
public class Browser
|
public class Browser
|
||||||
{
|
{
|
||||||
public Browser(string packageName, string uriViewId)
|
public Browser(string packageName, string uriViewId)
|
||||||
|
|
Loading…
Add table
Reference in a new issue