diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index f4fc640d0..566ff378f 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -44,6 +44,7 @@ namespace Bit.Droid private IAppIdService _appIdService; private IEventService _eventService; private IPushNotificationListenerService _pushNotificationListenerService; + private IVaultTimeoutService _vaultTimeoutService; private ILogger _logger; private PendingIntent _eventUploadPendingIntent; private AppOptions _appOptions; @@ -68,6 +69,7 @@ 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; @@ -232,6 +234,7 @@ 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 aa839370b..a3deede96 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.DelayLockAndLogoutMs = null; + _vaultTimeoutService.DelayTimeoutMs = null; } await _configService.GetAsync(); diff --git a/src/App/Pages/Vault/AttachmentsPageViewModel.cs b/src/App/Pages/Vault/AttachmentsPageViewModel.cs index 02e9b2ae6..253e2c2c6 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.DelayLockAndLogoutMs = 60000; + _vaultTimeoutService.DelayTimeoutMs = 60000; } await _fileService.SelectFileAsync(); } diff --git a/src/Core/Abstractions/IVaultTimeoutService.cs b/src/Core/Abstractions/IVaultTimeoutService.cs index c74001b17..8c20a5d17 100644 --- a/src/Core/Abstractions/IVaultTimeoutService.cs +++ b/src/Core/Abstractions/IVaultTimeoutService.cs @@ -6,7 +6,8 @@ namespace Bit.Core.Abstractions { public interface IVaultTimeoutService { - long? DelayLockAndLogoutMs { get; set; } + long? DelayTimeoutMs { get; set; } + bool ResetTimeoutDelay { get; set; } Task CheckVaultTimeoutAsync(); Task ShouldTimeoutAsync(string userId = null); diff --git a/src/Core/Services/VaultTimeoutService.cs b/src/Core/Services/VaultTimeoutService.cs index f5bd7d4bd..c61a77aad 100644 --- a/src/Core/Services/VaultTimeoutService.cs +++ b/src/Core/Services/VaultTimeoutService.cs @@ -50,7 +50,8 @@ namespace Bit.Core.Services _loggedOutCallback = loggedOutCallback; } - public long? DelayLockAndLogoutMs { get; set; } + public long? DelayTimeoutMs { get; set; } + public bool ResetTimeoutDelay { get; set; } public async Task IsLockedAsync(string userId = null) { @@ -117,7 +118,7 @@ namespace Bit.Core.Services { return false; } - if (vaultTimeoutMinutes == 0 && !DelayLockAndLogoutMs.HasValue) + if (vaultTimeoutMinutes == 0 && !DelayTimeoutMs.HasValue) { return true; } @@ -127,8 +128,13 @@ namespace Bit.Core.Services return false; } var diffMs = _platformUtilsService.GetActiveTime() - lastActiveTime; - if (DelayLockAndLogoutMs.HasValue && diffMs < DelayLockAndLogoutMs) + if (DelayTimeoutMs.HasValue && diffMs < DelayTimeoutMs) { + if (ResetTimeoutDelay) + { + DelayTimeoutMs = null; + ResetTimeoutDelay = false; + } return false; } var vaultTimeoutMs = vaultTimeoutMinutes * 60000;