Merge branch 'social-backup-poc' into remote-wipe-poc

* social-backup-poc:
  Dont accept shards from mismatched sets - all muss match the first shard received
  Change wording on shard notification messages
  Change message on success fragments
This commit is contained in:
ameba23
2021-06-22 16:27:08 +02:00
9 changed files with 39 additions and 29 deletions

View File

@@ -13,6 +13,7 @@ import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BaseActivity;
import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.api.socialbackup.ReturnShardPayload;
import org.briarproject.briar.api.socialbackup.recovery.RestoreAccount;
import org.briarproject.briar.api.socialbackup.recovery.SecretOwnerTask;
import java.security.GeneralSecurityException;
@@ -146,9 +147,16 @@ public class OwnerReturnShardActivity extends BaseActivity
if (state instanceof SecretOwnerTask.State.Success) {
ReturnShardPayload shardPayload =
((SecretOwnerTask.State.Success) state).getRemotePayload();
boolean added = viewModel.addToShardSet(shardPayload);
RestoreAccount.AddReturnShardPayloadResult result = viewModel.addToShardSet(shardPayload);
if (result == RestoreAccount.AddReturnShardPayloadResult.MISMATCH) {
// TODO improve this
Toast.makeText(this,
"WARNING: Mismatched backup piece!",
Toast.LENGTH_LONG).show();
}
boolean added = (result != RestoreAccount.AddReturnShardPayloadResult.DUPLICATE) ? true : false;
Toast.makeText(this,
"Success - got shard" + (added ? "" : " duplicate"),
"Success - got backup piece" + (added ? "" : " duplicate"),
Toast.LENGTH_SHORT).show();
if (added && viewModel.canRecover()) {
LOG.info("Secret key recovered");
@@ -173,19 +181,10 @@ public class OwnerReturnShardActivity extends BaseActivity
}
onBackPressed();
} else if (state instanceof SecretOwnerTask.State.Failure) {
// Toast.makeText(this,
// "Shard return failed!",
// Toast.LENGTH_SHORT).show();
// onBackPressed();
showNextFragment(new OwnerRecoveryModeErrorFragment());
}
}
// private void showErrorFragment() {
// // TODO change this for an appropriate error message fragment
// showNextFragment(new AddNearbyContactErrorFragment());
// }
@Override
@Deprecated
public void runOnDbThread(Runnable runnable) {

View File

@@ -226,8 +226,7 @@ class OwnerReturnShardViewModel extends AndroidViewModel
}
}
// TODO figure out how to actually use a hash set for these objects
public boolean addToShardSet(ReturnShardPayload toAdd) {
public RestoreAccount.AddReturnShardPayloadResult addToShardSet(ReturnShardPayload toAdd) {
return restoreAccount.addReturnShardPayload(toAdd);
}

View File

@@ -15,7 +15,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/backup_done_dismiss"
android:text="@string/ok"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -15,7 +15,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/backup_done_dismiss"
android:text="@string/ok"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -15,7 +15,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/backup_done_dismiss"
android:text="@string/ok"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -15,7 +15,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/backup_done_dismiss"
android:text="@string/ok"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -669,7 +669,6 @@
<string name="threshold_m_of_n">%d of %d contacts needed to recover your account</string>
<string name="backup_done_info">Backup pieces sent to trusted contacts</string>
<string name="backup_done_dismiss">Got it</string>
<string name="backup_created">Backup created 1/6/2020</string>
@@ -723,8 +722,8 @@
<string name="activity_name_restore_account">Restore Account</string>
<!-- conversation -->
<string name="social_backup_shard_received">%1$s has sent you a social backup shard.</string>
<string name="social_backup_shard_sent">You have sent a social backup shard to %1$s.</string>
<string name="social_backup_shard_received">%1$s has sent you a social backup piece.</string>
<string name="social_backup_shard_sent">You have sent a social backup piece to %1$s.</string>
<string name="activity_name_new_or_recover_account">Create new account or recover existing account</string>
<string name="activity_name_recovery">Recover Account</string>