mirror of
https://github.com/bitwarden/mobile
synced 2025-12-31 07:33:46 +00:00
Use monotonic clock for vault timeout (#1175)
* Use monotonic clock for vault timeout * free memory * removed vault timeout timers and added crash logging to iOS clock hack
This commit is contained in:
@@ -43,5 +43,6 @@ namespace Bit.App.Abstractions
|
||||
void OpenAccessibilityOverlayPermissionSettings();
|
||||
void OpenAutofillSettings();
|
||||
bool UsingDarkTheme();
|
||||
long GetActiveTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Bit.App
|
||||
var isLocked = await _vaultTimeoutService.IsLockedAsync();
|
||||
if (!isLocked)
|
||||
{
|
||||
await _storageService.SaveAsync(Constants.LastActiveKey, DateTime.UtcNow);
|
||||
await _storageService.SaveAsync(Constants.LastActiveKey, _deviceActionService.GetActiveTime());
|
||||
}
|
||||
SetTabsPageFromAutofill(isLocked);
|
||||
await SleptAsync();
|
||||
@@ -210,7 +210,7 @@ namespace Bit.App
|
||||
|
||||
private async void ResumedAsync()
|
||||
{
|
||||
_messagingService.Send("cancelVaultTimeoutTimer");
|
||||
await _vaultTimeoutService.CheckVaultTimeoutAsync();
|
||||
_messagingService.Send("startEventTimer");
|
||||
await ClearCacheIfNeededAsync();
|
||||
Prime();
|
||||
@@ -302,11 +302,7 @@ namespace Bit.App
|
||||
vaultTimeout = await _storageService.GetAsync<int?>(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<string>(Constants.VaultTimeoutActionKey);
|
||||
if (action == "logOut")
|
||||
|
||||
@@ -3,6 +3,7 @@ using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
@@ -12,6 +13,7 @@ namespace Bit.App.Pages
|
||||
public class BaseContentPage : ContentPage
|
||||
{
|
||||
private IStorageService _storageService;
|
||||
private IDeviceActionService _deviceActionService;
|
||||
|
||||
protected int ShowModalAnimationDelay = 400;
|
||||
protected int ShowPageAnimationDelay = 100;
|
||||
@@ -101,18 +103,22 @@ namespace Bit.App.Pages
|
||||
});
|
||||
}
|
||||
|
||||
private void SetStorageService()
|
||||
private void SetServices()
|
||||
{
|
||||
if (_storageService == null)
|
||||
{
|
||||
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
}
|
||||
if (_deviceActionService == null)
|
||||
{
|
||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveActivity()
|
||||
{
|
||||
SetStorageService();
|
||||
_storageService.SaveAsync(Constants.LastActiveKey, DateTime.UtcNow);
|
||||
SetServices();
|
||||
_storageService.SaveAsync(Constants.LastActiveKey, _deviceActionService.GetActiveTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,5 +241,10 @@ namespace Bit.App.Services
|
||||
catch { }
|
||||
return false;
|
||||
}
|
||||
|
||||
public long GetActiveTime()
|
||||
{
|
||||
return _deviceActionService.GetActiveTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user