mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Check whether data has been deleted when resuming from recents. Bug #44.
This commit is contained in:
@@ -11,6 +11,7 @@ import static android.widget.LinearLayout.VERTICAL;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -24,6 +25,7 @@ import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
@@ -55,7 +57,15 @@ public class PasswordActivity extends RoboActivity {
|
||||
|
||||
SharedPreferences prefs = getSharedPreferences("db", MODE_PRIVATE);
|
||||
String hex = prefs.getString("key", null);
|
||||
if(hex == null) throw new IllegalStateException();
|
||||
if(hex == null || !databaseConfig.databaseExists()) {
|
||||
// Storage has been deleted - clean up and return to setup
|
||||
prefs.edit().clear().commit();
|
||||
delete(databaseConfig.getDatabaseDirectory());
|
||||
setResult(RESULT_CANCELED);
|
||||
startActivity(new Intent(this, SetupActivity.class));
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
final byte[] encrypted = StringUtils.fromHexString(hex);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
@@ -107,6 +117,11 @@ public class PasswordActivity extends RoboActivity {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
private void delete(File f) {
|
||||
if(f.isFile()) f.delete();
|
||||
else if(f.isDirectory()) for(File child : f.listFiles()) delete(child);
|
||||
}
|
||||
|
||||
private void validatePassword(final byte[] encrypted, Editable e) {
|
||||
if(enterPassword == null || continueButton == null || progress == null)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user