mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-25 16:47:55 +01:00
reset lock delay when returning from activity result (#2539)
This commit is contained in:
parent
c7fd113f26
commit
0288a6659c
@ -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<IAppIdService>("appIdService");
|
||||
_eventService = ServiceContainer.Resolve<IEventService>("eventService");
|
||||
_pushNotificationListenerService = ServiceContainer.Resolve<IPushNotificationListenerService>();
|
||||
_vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>();
|
||||
_logger = ServiceContainer.Resolve<ILogger>("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))
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ namespace Bit.App
|
||||
{
|
||||
await _vaultTimeoutService.CheckVaultTimeoutAsync();
|
||||
// Reset delay on every start
|
||||
_vaultTimeoutService.DelayLockAndLogoutMs = null;
|
||||
_vaultTimeoutService.DelayTimeoutMs = null;
|
||||
}
|
||||
|
||||
await _configService.GetAsync();
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<bool> ShouldTimeoutAsync(string userId = null);
|
||||
|
@ -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<bool> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user