diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 566ff378f..f4fc640d0 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -44,7 +44,6 @@ namespace Bit.Droid private IAppIdService _appIdService; private IEventService _eventService; private IPushNotificationListenerService _pushNotificationListenerService; - private IVaultTimeoutService _vaultTimeoutService; private ILogger _logger; private PendingIntent _eventUploadPendingIntent; private AppOptions _appOptions; @@ -69,7 +68,6 @@ namespace Bit.Droid _appIdService = ServiceContainer.Resolve("appIdService"); _eventService = ServiceContainer.Resolve("eventService"); _pushNotificationListenerService = ServiceContainer.Resolve(); - _vaultTimeoutService = ServiceContainer.Resolve(); _logger = ServiceContainer.Resolve("logger"); TabLayoutResource = Resource.Layout.Tabbar; @@ -234,7 +232,6 @@ namespace Bit.Droid protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { - _vaultTimeoutService.ResetTimeoutDelay = true; if (resultCode == Result.Ok && (requestCode == Core.Constants.SelectFileRequestCode || requestCode == Core.Constants.SaveFileRequestCode)) { diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index a3deede96..aa839370b 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -297,7 +297,7 @@ namespace Bit.App { await _vaultTimeoutService.CheckVaultTimeoutAsync(); // Reset delay on every start - _vaultTimeoutService.DelayTimeoutMs = null; + _vaultTimeoutService.DelayLockAndLogoutMs = null; } await _configService.GetAsync(); diff --git a/src/App/Pages/Vault/AttachmentsPageViewModel.cs b/src/App/Pages/Vault/AttachmentsPageViewModel.cs index 253e2c2c6..02e9b2ae6 100644 --- a/src/App/Pages/Vault/AttachmentsPageViewModel.cs +++ b/src/App/Pages/Vault/AttachmentsPageViewModel.cs @@ -156,7 +156,7 @@ namespace Bit.App.Pages // Prevent Android from locking if vault timeout set to "immediate" if (Device.RuntimePlatform == Device.Android) { - _vaultTimeoutService.DelayTimeoutMs = 60000; + _vaultTimeoutService.DelayLockAndLogoutMs = 60000; } await _fileService.SelectFileAsync(); } diff --git a/src/Core/Abstractions/IVaultTimeoutService.cs b/src/Core/Abstractions/IVaultTimeoutService.cs index 8c20a5d17..c74001b17 100644 --- a/src/Core/Abstractions/IVaultTimeoutService.cs +++ b/src/Core/Abstractions/IVaultTimeoutService.cs @@ -6,8 +6,7 @@ namespace Bit.Core.Abstractions { public interface IVaultTimeoutService { - long? DelayTimeoutMs { get; set; } - bool ResetTimeoutDelay { get; set; } + long? DelayLockAndLogoutMs { get; set; } Task CheckVaultTimeoutAsync(); Task ShouldTimeoutAsync(string userId = null); diff --git a/src/Core/Services/VaultTimeoutService.cs b/src/Core/Services/VaultTimeoutService.cs index c61a77aad..f5bd7d4bd 100644 --- a/src/Core/Services/VaultTimeoutService.cs +++ b/src/Core/Services/VaultTimeoutService.cs @@ -50,8 +50,7 @@ namespace Bit.Core.Services _loggedOutCallback = loggedOutCallback; } - public long? DelayTimeoutMs { get; set; } - public bool ResetTimeoutDelay { get; set; } + public long? DelayLockAndLogoutMs { get; set; } public async Task IsLockedAsync(string userId = null) { @@ -118,7 +117,7 @@ namespace Bit.Core.Services { return false; } - if (vaultTimeoutMinutes == 0 && !DelayTimeoutMs.HasValue) + if (vaultTimeoutMinutes == 0 && !DelayLockAndLogoutMs.HasValue) { return true; } @@ -128,13 +127,8 @@ namespace Bit.Core.Services return false; } var diffMs = _platformUtilsService.GetActiveTime() - lastActiveTime; - if (DelayTimeoutMs.HasValue && diffMs < DelayTimeoutMs) + if (DelayLockAndLogoutMs.HasValue && diffMs < DelayLockAndLogoutMs) { - if (ResetTimeoutDelay) - { - DelayTimeoutMs = null; - ResetTimeoutDelay = false; - } return false; } var vaultTimeoutMs = vaultTimeoutMinutes * 60000;