mirror of
https://github.com/bitwarden/android.git
synced 2024-12-26 02:48:29 +03:00
reset lock delay when returning from activity result (#2539)
This commit is contained in:
parent
c7fd113f26
commit
0288a6659c
5 changed files with 16 additions and 6 deletions
|
@ -44,6 +44,7 @@ namespace Bit.Droid
|
||||||
private IAppIdService _appIdService;
|
private IAppIdService _appIdService;
|
||||||
private IEventService _eventService;
|
private IEventService _eventService;
|
||||||
private IPushNotificationListenerService _pushNotificationListenerService;
|
private IPushNotificationListenerService _pushNotificationListenerService;
|
||||||
|
private IVaultTimeoutService _vaultTimeoutService;
|
||||||
private ILogger _logger;
|
private ILogger _logger;
|
||||||
private PendingIntent _eventUploadPendingIntent;
|
private PendingIntent _eventUploadPendingIntent;
|
||||||
private AppOptions _appOptions;
|
private AppOptions _appOptions;
|
||||||
|
@ -68,6 +69,7 @@ namespace Bit.Droid
|
||||||
_appIdService = ServiceContainer.Resolve<IAppIdService>("appIdService");
|
_appIdService = ServiceContainer.Resolve<IAppIdService>("appIdService");
|
||||||
_eventService = ServiceContainer.Resolve<IEventService>("eventService");
|
_eventService = ServiceContainer.Resolve<IEventService>("eventService");
|
||||||
_pushNotificationListenerService = ServiceContainer.Resolve<IPushNotificationListenerService>();
|
_pushNotificationListenerService = ServiceContainer.Resolve<IPushNotificationListenerService>();
|
||||||
|
_vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>();
|
||||||
_logger = ServiceContainer.Resolve<ILogger>("logger");
|
_logger = ServiceContainer.Resolve<ILogger>("logger");
|
||||||
|
|
||||||
TabLayoutResource = Resource.Layout.Tabbar;
|
TabLayoutResource = Resource.Layout.Tabbar;
|
||||||
|
@ -232,6 +234,7 @@ namespace Bit.Droid
|
||||||
|
|
||||||
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
||||||
{
|
{
|
||||||
|
_vaultTimeoutService.ResetTimeoutDelay = true;
|
||||||
if (resultCode == Result.Ok &&
|
if (resultCode == Result.Ok &&
|
||||||
(requestCode == Core.Constants.SelectFileRequestCode || requestCode == Core.Constants.SaveFileRequestCode))
|
(requestCode == Core.Constants.SelectFileRequestCode || requestCode == Core.Constants.SaveFileRequestCode))
|
||||||
{
|
{
|
||||||
|
|
|
@ -297,7 +297,7 @@ namespace Bit.App
|
||||||
{
|
{
|
||||||
await _vaultTimeoutService.CheckVaultTimeoutAsync();
|
await _vaultTimeoutService.CheckVaultTimeoutAsync();
|
||||||
// Reset delay on every start
|
// Reset delay on every start
|
||||||
_vaultTimeoutService.DelayLockAndLogoutMs = null;
|
_vaultTimeoutService.DelayTimeoutMs = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _configService.GetAsync();
|
await _configService.GetAsync();
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace Bit.App.Pages
|
||||||
// Prevent Android from locking if vault timeout set to "immediate"
|
// Prevent Android from locking if vault timeout set to "immediate"
|
||||||
if (Device.RuntimePlatform == Device.Android)
|
if (Device.RuntimePlatform == Device.Android)
|
||||||
{
|
{
|
||||||
_vaultTimeoutService.DelayLockAndLogoutMs = 60000;
|
_vaultTimeoutService.DelayTimeoutMs = 60000;
|
||||||
}
|
}
|
||||||
await _fileService.SelectFileAsync();
|
await _fileService.SelectFileAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ namespace Bit.Core.Abstractions
|
||||||
{
|
{
|
||||||
public interface IVaultTimeoutService
|
public interface IVaultTimeoutService
|
||||||
{
|
{
|
||||||
long? DelayLockAndLogoutMs { get; set; }
|
long? DelayTimeoutMs { get; set; }
|
||||||
|
bool ResetTimeoutDelay { get; set; }
|
||||||
|
|
||||||
Task CheckVaultTimeoutAsync();
|
Task CheckVaultTimeoutAsync();
|
||||||
Task<bool> ShouldTimeoutAsync(string userId = null);
|
Task<bool> ShouldTimeoutAsync(string userId = null);
|
||||||
|
|
|
@ -50,7 +50,8 @@ namespace Bit.Core.Services
|
||||||
_loggedOutCallback = loggedOutCallback;
|
_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)
|
public async Task<bool> IsLockedAsync(string userId = null)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +118,7 @@ namespace Bit.Core.Services
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (vaultTimeoutMinutes == 0 && !DelayLockAndLogoutMs.HasValue)
|
if (vaultTimeoutMinutes == 0 && !DelayTimeoutMs.HasValue)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -127,8 +128,13 @@ namespace Bit.Core.Services
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var diffMs = _platformUtilsService.GetActiveTime() - lastActiveTime;
|
var diffMs = _platformUtilsService.GetActiveTime() - lastActiveTime;
|
||||||
if (DelayLockAndLogoutMs.HasValue && diffMs < DelayLockAndLogoutMs)
|
if (DelayTimeoutMs.HasValue && diffMs < DelayTimeoutMs)
|
||||||
{
|
{
|
||||||
|
if (ResetTimeoutDelay)
|
||||||
|
{
|
||||||
|
DelayTimeoutMs = null;
|
||||||
|
ResetTimeoutDelay = false;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var vaultTimeoutMs = vaultTimeoutMinutes * 60000;
|
var vaultTimeoutMs = vaultTimeoutMinutes * 60000;
|
||||||
|
|
Loading…
Reference in a new issue