diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 3ea651dfb..39541c4f1 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -118,7 +118,6 @@ - diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 722e198c4..9be66fd8e 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -51,7 +51,6 @@ namespace Bit.Droid private IAppIdService _appIdService; private IStorageService _storageService; private IEventService _eventService; - private PendingIntent _vaultTimeoutAlarmPendingIntent; private PendingIntent _clearClipboardPendingIntent; private PendingIntent _eventUploadPendingIntent; private AppOptions _appOptions; @@ -64,9 +63,6 @@ namespace Bit.Droid var eventUploadIntent = new Intent(this, typeof(EventUploadReceiver)); _eventUploadPendingIntent = PendingIntent.GetBroadcast(this, 0, eventUploadIntent, PendingIntentFlags.UpdateCurrent); - var alarmIntent = new Intent(this, typeof(LockAlarmReceiver)); - _vaultTimeoutAlarmPendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, - PendingIntentFlags.UpdateCurrent); var clearClipboardIntent = new Intent(this, typeof(ClearClipboardAlarmReceiver)); _clearClipboardPendingIntent = PendingIntent.GetBroadcast(this, 0, clearClipboardIntent, PendingIntentFlags.UpdateCurrent); @@ -104,20 +100,7 @@ namespace Bit.Droid _broadcasterService.Subscribe(_activityKey, (message) => { - if (message.Command == "scheduleVaultTimeoutTimer") - { - var alarmManager = GetSystemService(AlarmService) as AlarmManager; - var vaultTimeoutMinutes = (int)message.Data; - var vaultTimeoutMs = vaultTimeoutMinutes * 60000; - var triggerMs = Java.Lang.JavaSystem.CurrentTimeMillis() + vaultTimeoutMs + 10; - alarmManager.Set(AlarmType.RtcWakeup, triggerMs, _vaultTimeoutAlarmPendingIntent); - } - else if (message.Command == "cancelVaultTimeoutTimer") - { - var alarmManager = GetSystemService(AlarmService) as AlarmManager; - alarmManager.Cancel(_vaultTimeoutAlarmPendingIntent); - } - else if (message.Command == "startEventTimer") + if (message.Command == "startEventTimer") { StartEventAlarm(); } diff --git a/src/Android/Receivers/LockAlarmReceiver.cs b/src/Android/Receivers/LockAlarmReceiver.cs deleted file mode 100644 index e774a367b..000000000 --- a/src/Android/Receivers/LockAlarmReceiver.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Android.Content; -using Bit.Core.Abstractions; -using Bit.Core.Utilities; - -namespace Bit.Droid.Receivers -{ - [BroadcastReceiver(Name = "com.x8bit.bitwarden.LockAlarmReceiver", Exported = false)] - public class LockAlarmReceiver : BroadcastReceiver - { - public async override void OnReceive(Context context, Intent intent) - { - var vaultTimeoutService = ServiceContainer.Resolve("vaultTimeoutService"); - await vaultTimeoutService.CheckVaultTimeoutAsync(); - } - } -} diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 70714f83c..d1c138271 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -178,6 +178,10 @@ namespace Bit.App SyncIfNeeded(); } } + if (Device.RuntimePlatform == Device.Android) + { + await _vaultTimeoutService.CheckVaultTimeoutAsync(); + } _messagingService.Send("startEventTimer"); } @@ -216,7 +220,6 @@ namespace Bit.App private async void ResumedAsync() { await _vaultTimeoutService.CheckVaultTimeoutAsync(); - _messagingService.Send("cancelVaultTimeoutTimer"); _messagingService.Send("startEventTimer"); await ClearCacheIfNeededAsync(); Prime(); @@ -313,11 +316,7 @@ namespace Bit.App vaultTimeout = await _storageService.GetAsync(Constants.VaultTimeoutKey); } vaultTimeout = vaultTimeout.GetValueOrDefault(-1); - if (vaultTimeout > 0) - { - _messagingService.Send("scheduleVaultTimeoutTimer", vaultTimeout.Value); - } - else if (vaultTimeout == 0) + if (vaultTimeout == 0) { var action = await _storageService.GetAsync(Constants.VaultTimeoutActionKey); if (action == "logOut")