@Test public void testDbKeyIsMigratedFromPreferencesToFile() { context.checking(new Expectations() {{ oneOf(prefs).getString("key", null); will(returnValue(encryptedKeyHex)); oneOf(prefs).edit(); will(returnValue(editor)); oneOf(editor).remove("key"); will(returnValue(editor)); oneOf(editor).commit(); will(returnValue(true)); }}); assertFalse(keyFile.exists()); assertFalse(keyBackupFile.exists()); assertEquals(encryptedKeyHex, accountManager.loadEncryptedDatabaseKey()); assertTrue(keyFile.exists()); assertTrue(keyBackupFile.exists()); }
@Override @Nullable protected String loadEncryptedDatabaseKey() { String key = getDatabaseKeyFromPreferences(); if (key == null) key = super.loadEncryptedDatabaseKey(); else migrateDatabaseKeyToFile(key); return key; }
AndroidAccountManager extends AccountManagerImpl implements AccountManager { @Override @Nullable protected String loadEncryptedDatabaseKey() { String key = getDatabaseKeyFromPreferences(); if (key == null) key = super.loadEncryptedDatabaseKey(); else migrateDatabaseKeyToFile(key); return key; } }
AndroidAccountManager extends AccountManagerImpl implements AccountManager { @Override @Nullable protected String loadEncryptedDatabaseKey() { String key = getDatabaseKeyFromPreferences(); if (key == null) key = super.loadEncryptedDatabaseKey(); else migrateDatabaseKeyToFile(key); return key; } @Inject  AndroidAccountManager(DatabaseConfig databaseConfig,
			CryptoComponent crypto, IdentityManager identityManager,
			SharedPreferences prefs, Application app); }
AndroidAccountManager extends AccountManagerImpl implements AccountManager { @Override @Nullable protected String loadEncryptedDatabaseKey() { String key = getDatabaseKeyFromPreferences(); if (key == null) key = super.loadEncryptedDatabaseKey(); else migrateDatabaseKeyToFile(key); return key; } @Inject  AndroidAccountManager(DatabaseConfig databaseConfig,
			CryptoComponent crypto, IdentityManager identityManager,
			SharedPreferences prefs, Application app); @Override void deleteAccount(); }
AndroidAccountManager extends AccountManagerImpl implements AccountManager { @Override @Nullable protected String loadEncryptedDatabaseKey() { String key = getDatabaseKeyFromPreferences(); if (key == null) key = super.loadEncryptedDatabaseKey(); else migrateDatabaseKeyToFile(key); return key; } @Inject  AndroidAccountManager(DatabaseConfig databaseConfig,
			CryptoComponent crypto, IdentityManager identityManager,
			SharedPreferences prefs, Application app); @Override void deleteAccount();  }