needs migration flag

This commit is contained in:
Kyle Spearrin 2019-05-30 15:11:22 -04:00
parent c7b62c8551
commit 419cfceef1
4 changed files with 20 additions and 9 deletions

View file

@ -43,6 +43,11 @@ namespace Bit.Droid
private void RegisterLocalServices()
{
var settingsShim = new App.Migration.SettingsShim();
ServiceContainer.Register("settingsShim", settingsShim);
App.Utilities.AppHelpers.NeedsMigration =
settingsShim.GetValueOrDefault(Constants.OldLastActivityKey, DateTime.MinValue) > DateTime.MinValue;
Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init();
// Note: This might cause a race condition. Investigate more.
Task.Run(() =>

View file

@ -12,6 +12,7 @@ using Java.Util;
using Javax.Crypto.Spec;
using Android.Preferences;
using Bit.App.Migration;
using Bit.Core.Utilities;
namespace Bit.Droid.Migration
{
@ -39,7 +40,7 @@ namespace Bit.Droid.Migration
_oldAndroid = Build.VERSION.SdkInt < BuildVersionCodes.M;
_rsaMode = _oldAndroid ? "RSA/ECB/PKCS1Padding" : "RSA/ECB/OAEPWithSHA-1AndMGF1Padding";
_settings = new SettingsShim();
_settings = ServiceContainer.Resolve<SettingsShim>("settingsShim");
_keyStore = KeyStore.GetInstance(AndroidKeyStore);
_keyStore.Load(null);

View file

@ -13,6 +13,8 @@ namespace Bit.App.Utilities
{
public static class AppHelpers
{
public static bool NeedsMigration = false;
public static async Task<string> CipherListOptions(ContentPage page, CipherView cipher)
{
var platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
@ -114,17 +116,19 @@ namespace Bit.App.Utilities
public static async Task<bool> PerformUpdateTasksAsync(ISyncService syncService,
IDeviceActionService deviceActionService, IStorageService storageService)
{
var lastSync = await syncService.GetLastSyncAsync();
var currentBuild = deviceActionService.GetBuildNumber();
var lastBuild = await storageService.GetAsync<string>(Constants.LastBuildKey);
if(lastBuild == null)
if(!NeedsMigration)
{
// Installed
}
else if(lastBuild != currentBuild)
{
// Updated
var tasks = Task.Run(() => syncService.FullSyncAsync(true));
if(lastBuild == null)
{
// Installed
}
else if(lastBuild != currentBuild)
{
// Updated
var tasks = Task.Run(() => syncService.FullSyncAsync(true));
}
}
if(lastBuild != currentBuild)
{

View file

@ -24,6 +24,7 @@
public static string ClearClipboardKey = "clearClipboard";
public static string LastClipboardValueKey = "lastClipboardValue";
public static string LastBuildKey = "lastBuild";
public static string OldLastActivityKey = "other:lastActivityDate";
public const int SelectFileRequestCode = 42;
public const int SelectFilePermissionRequestCode = 43;
}