mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
ClearExtensionCiphersCache
This commit is contained in:
parent
a8c18cf83a
commit
3b9f4433ad
9 changed files with 43 additions and 4 deletions
|
@ -70,5 +70,6 @@ namespace Bit.Android.Services
|
|||
var adapter = manager.DefaultAdapter;
|
||||
return adapter != null && adapter.IsEnabled;
|
||||
}
|
||||
public bool IsExtension => false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Bit.App.Abstractions
|
|||
string IdentityUrl { get; set; }
|
||||
string IconsUrl { get; set; }
|
||||
bool ClearCiphersCache { get; set; }
|
||||
bool ClearExtensionCiphersCache { get; set; }
|
||||
bool OrganizationGivesPremium { get; set; }
|
||||
}
|
||||
}
|
|
@ -10,5 +10,6 @@
|
|||
bool HasCamera { get; }
|
||||
bool AutofillServiceSupported { get; }
|
||||
bool HasFaceIdSupport { get; }
|
||||
bool IsExtension { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
public const string IconsUrl = "other:iconsUrl";
|
||||
public const string FailedPinAttempts = "other:failedPinAttempts";
|
||||
public const string ClearCiphersCache = "other:clearCiphersCache";
|
||||
public const string ClearExtensionCiphersCache = "other:clearExtensionCiphersCache";
|
||||
public const string OrgGivesPremium = "other:orgGivesPremium";
|
||||
|
||||
public const int SelectFileRequestCode = 42;
|
||||
|
|
|
@ -209,6 +209,18 @@ namespace Bit.App.Services
|
|||
}
|
||||
}
|
||||
|
||||
public bool ClearExtensionCiphersCache
|
||||
{
|
||||
get
|
||||
{
|
||||
return _settings.GetValueOrDefault(Constants.ClearExtensionCiphersCache, false);
|
||||
}
|
||||
set
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.ClearExtensionCiphersCache, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool OrganizationGivesPremium
|
||||
{
|
||||
get
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Bit.App.Services
|
|||
private readonly ISettingsService _settingsService;
|
||||
private readonly ICryptoService _cryptoService;
|
||||
private readonly IAppSettingsService _appSettingsService;
|
||||
private readonly IDeviceInfoService _deviceInfoService;
|
||||
|
||||
public CipherService(
|
||||
ICipherRepository cipherRepository,
|
||||
|
@ -36,7 +37,8 @@ namespace Bit.App.Services
|
|||
ICipherApiRepository cipherApiRepository,
|
||||
ISettingsService settingsService,
|
||||
ICryptoService cryptoService,
|
||||
IAppSettingsService appSettingsService)
|
||||
IAppSettingsService appSettingsService,
|
||||
IDeviceInfoService deviceInfoService)
|
||||
{
|
||||
_cipherRepository = cipherRepository;
|
||||
_cipherCollectionRepository = cipherCollectionRepository;
|
||||
|
@ -46,6 +48,7 @@ namespace Bit.App.Services
|
|||
_settingsService = settingsService;
|
||||
_cryptoService = cryptoService;
|
||||
_appSettingsService = appSettingsService;
|
||||
_deviceInfoService = deviceInfoService;
|
||||
}
|
||||
|
||||
public async Task<Cipher> GetByIdAsync(string id)
|
||||
|
@ -63,12 +66,18 @@ namespace Bit.App.Services
|
|||
|
||||
public async Task<IEnumerable<Cipher>> GetAllAsync()
|
||||
{
|
||||
if(_appSettingsService.ClearCiphersCache)
|
||||
if(!_deviceInfoService.IsExtension && _appSettingsService.ClearCiphersCache)
|
||||
{
|
||||
CachedCiphers = null;
|
||||
_appSettingsService.ClearCiphersCache = false;
|
||||
}
|
||||
|
||||
if(_deviceInfoService.IsExtension && _appSettingsService.ClearExtensionCiphersCache)
|
||||
{
|
||||
CachedCiphers = null;
|
||||
_appSettingsService.ClearExtensionCiphersCache = false;
|
||||
}
|
||||
|
||||
if(CachedCiphers != null)
|
||||
{
|
||||
return CachedCiphers;
|
||||
|
@ -272,6 +281,7 @@ namespace Bit.App.Services
|
|||
await _cipherRepository.UpsertAsync(cipher);
|
||||
CachedCiphers = null;
|
||||
_appSettingsService.ClearCiphersCache = true;
|
||||
_appSettingsService.ClearExtensionCiphersCache = true;
|
||||
if(sendMessage && Application.Current != null)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "UpsertedCipher",
|
||||
|
@ -308,6 +318,7 @@ namespace Bit.App.Services
|
|||
await _cipherRepository.DeleteAsync(id);
|
||||
CachedCiphers = null;
|
||||
_appSettingsService.ClearCiphersCache = true;
|
||||
_appSettingsService.ClearExtensionCiphersCache = true;
|
||||
}
|
||||
|
||||
public async Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, CipherString key, string orgId = null)
|
||||
|
@ -383,6 +394,7 @@ namespace Bit.App.Services
|
|||
}
|
||||
CachedCiphers = null;
|
||||
_appSettingsService.ClearCiphersCache = true;
|
||||
_appSettingsService.ClearExtensionCiphersCache = true;
|
||||
}
|
||||
|
||||
public async Task<ApiResult> DeleteAttachmentAsync(Cipher cipher, string attachmentId)
|
||||
|
@ -406,6 +418,7 @@ namespace Bit.App.Services
|
|||
await _attachmentRepository.DeleteAsync(attachmentId);
|
||||
CachedCiphers = null;
|
||||
_appSettingsService.ClearCiphersCache = true;
|
||||
_appSettingsService.ClearExtensionCiphersCache = true;
|
||||
}
|
||||
|
||||
private Tuple<string, string[]> InfoFromMobileAppUri(string mobileAppUriString)
|
||||
|
|
|
@ -327,7 +327,7 @@ namespace Bit.iOS.Autofill
|
|||
container.RegisterSingleton<ILockService, LockService>();
|
||||
container.RegisterSingleton<IAppInfoService, AppInfoService>();
|
||||
container.RegisterSingleton<IGoogleAnalyticsService, GoogleAnalyticsService>();
|
||||
container.RegisterSingleton<IDeviceInfoService, DeviceInfoService>();
|
||||
container.RegisterInstance<IDeviceInfoService>(new DeviceInfoService(true));
|
||||
container.RegisterSingleton<ILocalizeService, LocalizeService>();
|
||||
container.RegisterSingleton<ILogService, LogService>();
|
||||
container.RegisterSingleton<IHttpService, HttpService>();
|
||||
|
|
|
@ -7,6 +7,15 @@ namespace Bit.iOS.Core.Services
|
|||
{
|
||||
public class DeviceInfoService : IDeviceInfoService
|
||||
{
|
||||
public DeviceInfoService()
|
||||
: this(false)
|
||||
{ }
|
||||
|
||||
public DeviceInfoService(bool isExtension)
|
||||
{
|
||||
IsExtension = isExtension;
|
||||
}
|
||||
|
||||
public string Type => Xamarin.Forms.Device.iOS;
|
||||
public string Model => UIDevice.CurrentDevice.Model;
|
||||
public int Version
|
||||
|
@ -45,5 +54,6 @@ namespace Bit.iOS.Core.Services
|
|||
return context.BiometryType == LABiometryType.FaceId;
|
||||
}
|
||||
}
|
||||
public bool IsExtension { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ namespace Bit.iOS.Extension
|
|||
container.RegisterSingleton<ILockService, LockService>();
|
||||
container.RegisterSingleton<IAppInfoService, AppInfoService>();
|
||||
container.RegisterSingleton<IGoogleAnalyticsService, GoogleAnalyticsService>();
|
||||
container.RegisterSingleton<IDeviceInfoService, DeviceInfoService>();
|
||||
container.RegisterInstance<IDeviceInfoService>(new DeviceInfoService(true));
|
||||
container.RegisterSingleton<ILocalizeService, LocalizeService>();
|
||||
container.RegisterSingleton<ILogService, LogService>();
|
||||
container.RegisterSingleton<IHttpService, HttpService>();
|
||||
|
|
Loading…
Reference in a new issue