1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-25 12:43:39 +00:00

update tasks and sync on app start

This commit is contained in:
Kyle Spearrin
2019-05-30 14:13:02 -04:00
parent dc7b37c8f2
commit 6d51864873
7 changed files with 98 additions and 4 deletions

View File

@@ -1,6 +1,10 @@
using System;
using Android.App;
using Android.Content;
using Bit.App.Abstractions;
using Bit.App.Utilities;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
namespace Bit.Droid.Receivers
{
@@ -8,9 +12,11 @@ namespace Bit.Droid.Receivers
[IntentFilter(new[] { Intent.ActionMyPackageReplaced })]
public class PackageReplacedReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
public override async void OnReceive(Context context, Intent intent)
{
System.Diagnostics.Debug.WriteLine("PackageReplacedReceiver OnReceive");
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
await AppHelpers.PerformUpdateTasksAsync(ServiceContainer.Resolve<ISyncService>("syncService"),
ServiceContainer.Resolve<IDeviceActionService>("deviceActionService"), storageService);
}
}
}

View File

@@ -293,6 +293,12 @@ namespace Bit.Droid.Services
}
}
public string GetBuildNumber()
{
return Application.Context.ApplicationContext.PackageManager.GetPackageInfo(
Application.Context.PackageName, 0).VersionCode.ToString();
}
public bool SupportsFaceId()
{
return false;
@@ -486,6 +492,26 @@ namespace Bit.Droid.Services
}
}
public bool AutofillAccessibilityServiceRunning()
{
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
var manager = activity.GetSystemService(Context.ActivityService) as ActivityManager;
var services = manager.GetRunningServices(int.MaxValue);
return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") &&
s.Service.ClassName.ToLowerInvariant().Contains("autofill"));
}
private bool AutofillServiceEnabled()
{
if(Build.VERSION.SdkInt < BuildVersionCodes.O)
{
return false;
}
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
var afm = (AutofillManager)activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager)));
return afm.IsEnabled && afm.HasEnabledAutofillServices;
}
private bool DeleteDir(Java.IO.File dir)
{
if(dir != null && dir.IsDirectory)