mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Clear partially recovered shards from shared preferences when recovered
This commit is contained in:
@@ -156,13 +156,6 @@ class OwnerReturnShardViewModel extends AndroidViewModel
|
|||||||
ioExecutor.execute(() -> {
|
ioExecutor.execute(() -> {
|
||||||
task.start(this, getWifiIpv4Address());
|
task.start(this, getWifiIpv4Address());
|
||||||
});
|
});
|
||||||
// KeyAgreementTask oldTask = task;
|
|
||||||
// KeyAgreementTask newTask = keyAgreementTaskProvider.get();
|
|
||||||
// task = newTask;
|
|
||||||
// ioExecutor.execute(() -> {
|
|
||||||
// if (oldTask != null) oldTask.stopListening();
|
|
||||||
// newTask.listen();
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@@ -230,9 +223,7 @@ class OwnerReturnShardViewModel extends AndroidViewModel
|
|||||||
this.state.postValue(state);
|
this.state.postValue(state);
|
||||||
});
|
});
|
||||||
} else if (state instanceof SecretOwnerTask.State.Success) {
|
} else if (state instanceof SecretOwnerTask.State.Success) {
|
||||||
// startClicked.setEvent(true);
|
|
||||||
this.state.postValue(state);
|
this.state.postValue(state);
|
||||||
// TODO do same for failure
|
|
||||||
} else {
|
} else {
|
||||||
this.state.postValue(state);
|
this.state.postValue(state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.briarproject.briar.android.socialbackup.recover;
|
package org.briarproject.briar.android.socialbackup.recover;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.account.AccountManager;
|
import org.briarproject.bramble.api.account.AccountManager;
|
||||||
import org.briarproject.bramble.api.contact.ContactManager;
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
@@ -45,27 +47,27 @@ class RestoreAccountViewModel extends AndroidViewModel {
|
|||||||
new MutableLiveData<>(false);
|
new MutableLiveData<>(false);
|
||||||
|
|
||||||
private final AccountManager accountManager;
|
private final AccountManager accountManager;
|
||||||
private final ContactManager contactManager;
|
|
||||||
private final Executor ioExecutor;
|
private final Executor ioExecutor;
|
||||||
private final PasswordStrengthEstimator strengthEstimator;
|
private final PasswordStrengthEstimator strengthEstimator;
|
||||||
private final DozeHelper dozeHelper;
|
private final DozeHelper dozeHelper;
|
||||||
private final RestoreAccount restoreAccount;
|
private final RestoreAccount restoreAccount;
|
||||||
|
private final SharedPreferences prefs;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RestoreAccountViewModel(Application app,
|
RestoreAccountViewModel(Application app,
|
||||||
AccountManager accountManager,
|
AccountManager accountManager,
|
||||||
ContactManager contactManager,
|
|
||||||
RestoreAccount restoreAccount,
|
RestoreAccount restoreAccount,
|
||||||
@IoExecutor Executor ioExecutor,
|
@IoExecutor Executor ioExecutor,
|
||||||
PasswordStrengthEstimator strengthEstimator,
|
PasswordStrengthEstimator strengthEstimator,
|
||||||
DozeHelper dozeHelper) {
|
DozeHelper dozeHelper) {
|
||||||
super(app);
|
super(app);
|
||||||
this.accountManager = accountManager;
|
this.accountManager = accountManager;
|
||||||
this.contactManager = contactManager;
|
|
||||||
this.ioExecutor = ioExecutor;
|
this.ioExecutor = ioExecutor;
|
||||||
this.strengthEstimator = strengthEstimator;
|
this.strengthEstimator = strengthEstimator;
|
||||||
this.dozeHelper = dozeHelper;
|
this.dozeHelper = dozeHelper;
|
||||||
this.restoreAccount = restoreAccount;
|
this.restoreAccount = restoreAccount;
|
||||||
|
this.prefs = app.getSharedPreferences("account-recovery",
|
||||||
|
Context.MODE_PRIVATE);
|
||||||
|
|
||||||
ioExecutor.execute(() -> {
|
ioExecutor.execute(() -> {
|
||||||
if (accountManager.accountExists()) {
|
if (accountManager.accountExists()) {
|
||||||
@@ -123,6 +125,10 @@ class RestoreAccountViewModel extends AndroidViewModel {
|
|||||||
LOG.warning("Cannot retrieve social backup");
|
LOG.warning("Cannot retrieve social backup");
|
||||||
state.postEvent(State.FAILED);
|
state.postEvent(State.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove partial recovery from shared preferences
|
||||||
|
prefs.edit().clear().apply();
|
||||||
|
|
||||||
state.postEvent(State.CREATED);
|
state.postEvent(State.CREATED);
|
||||||
} else {
|
} else {
|
||||||
LOG.warning("Failed to create account");
|
LOG.warning("Failed to create account");
|
||||||
|
|||||||
Reference in New Issue
Block a user