mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Change to fail state if no backup found
This commit is contained in:
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
|||||||
import org.briarproject.briar.android.account.DozeHelper;
|
import org.briarproject.briar.android.account.DozeHelper;
|
||||||
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
||||||
import org.briarproject.briar.android.viewmodel.MutableLiveEvent;
|
import org.briarproject.briar.android.viewmodel.MutableLiveEvent;
|
||||||
|
import org.briarproject.briar.api.socialbackup.SocialBackup;
|
||||||
import org.briarproject.briar.api.socialbackup.recovery.RestoreAccount;
|
import org.briarproject.briar.api.socialbackup.recovery.RestoreAccount;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@@ -107,7 +108,12 @@ class RestoreAccountViewModel extends AndroidViewModel {
|
|||||||
// if (authorName == null) throw new IllegalStateException();
|
// if (authorName == null) throw new IllegalStateException();
|
||||||
if (password == null) throw new IllegalStateException();
|
if (password == null) throw new IllegalStateException();
|
||||||
isCreatingAccount.setValue(true);
|
isCreatingAccount.setValue(true);
|
||||||
Identity identity = restoreAccount.getSocialBackup().getIdentity();
|
SocialBackup socialBackup = restoreAccount.getSocialBackup();
|
||||||
|
if (socialBackup == null) {
|
||||||
|
LOG.warning("Cannot retrieve social backup");
|
||||||
|
state.postEvent(State.FAILED);
|
||||||
|
}
|
||||||
|
Identity identity = socialBackup.getIdentity();
|
||||||
ioExecutor.execute(() -> {
|
ioExecutor.execute(() -> {
|
||||||
if (accountManager.restoreAccount(identity, password)) {
|
if (accountManager.restoreAccount(identity, password)) {
|
||||||
LOG.info("Restore account");
|
LOG.info("Restore account");
|
||||||
|
|||||||
@@ -7,9 +7,14 @@ import org.briarproject.briar.api.socialbackup.SocialBackup;
|
|||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
|
|
||||||
public interface RestoreAccount {
|
public interface RestoreAccount {
|
||||||
|
|
||||||
int getNumberOfShards();
|
int getNumberOfShards();
|
||||||
boolean addReturnShardPayload(ReturnShardPayload toadd);
|
|
||||||
|
boolean addReturnShardPayload(ReturnShardPayload toAdd);
|
||||||
|
|
||||||
boolean canRecover();
|
boolean canRecover();
|
||||||
|
|
||||||
int recover() throws FormatException, GeneralSecurityException;
|
int recover() throws FormatException, GeneralSecurityException;
|
||||||
|
|
||||||
SocialBackup getSocialBackup();
|
SocialBackup getSocialBackup();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user