Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/org/commcare/activities/CommCareSetupActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}
if (!fromManager) {
String errors = GlobalErrorUtil.handleGlobalErrors();
String errors = GlobalErrorUtil.getGlobalErrors();
globalError = errors.length() > 0 ? errors : null;

PersonalIdManager.getInstance().init(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ protected LoginMode getLoginMode() {
}

protected void checkForGlobalErrors() {
String errors = GlobalErrorUtil.handleGlobalErrors();
String errors = GlobalErrorUtil.getGlobalErrors();
if(errors.length() > 0) {
errorMessage.setVisibility(View.VISIBLE);
errorMessage.setText(errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import org.commcare.android.database.connect.models.ConnectLinkedAppRecord;
import org.commcare.android.database.connect.models.ConnectUserRecord;
import org.commcare.android.database.global.models.GlobalErrorRecord;
import org.commcare.connect.PersonalIdManager;
import org.commcare.connect.network.SsoToken;
import org.commcare.google.services.analytics.AnalyticsParamValue;
import org.commcare.models.database.AndroidDbHelper;
import org.commcare.models.database.IDatabase;
import org.commcare.models.database.EncryptedDatabaseAdapter;
Expand Down Expand Up @@ -50,7 +52,7 @@ public IDatabase getHandle() {
if (connectDatabase == null || !connectDatabase.isOpen()) {
try {
byte[] passphrase = ConnectDatabaseUtils.getConnectDbPassphrase(context);
if(passphrase == null) {
if(passphrase == null || passphrase.length == 0) {
throw new IllegalStateException("Attempting to access Connect DB without a passphrase");
}

Expand Down Expand Up @@ -83,6 +85,7 @@ public static void crashDb(GlobalErrors error) {

public static void crashDb(GlobalErrors error, Exception ex) {
GlobalErrorUtil.addError(new GlobalErrorRecord(new Date(), error.ordinal()));
PersonalIdManager.getInstance().forgetUser(AnalyticsParamValue.PERSONAL_ID_FORGOT_USER_DB_ERROR);
throw new RuntimeException("Connect database crash: " + error.name(), ex);
}

Expand Down
12 changes: 1 addition & 11 deletions app/src/org/commcare/utils/GlobalErrorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.commcare.CommCareApplication;
import org.commcare.android.database.global.models.GlobalErrorRecord;
import org.commcare.connect.PersonalIdManager;
import org.commcare.google.services.analytics.AnalyticsParamValue;
import org.commcare.models.database.SqlStorage;

import java.util.Vector;
Expand All @@ -13,9 +11,8 @@ public static void addError(GlobalErrorRecord error) {
CommCareApplication.instance().getGlobalStorage(GlobalErrorRecord.class).write(error);
}

public static String handleGlobalErrors() {
public static String getGlobalErrors() {
StringBuilder sb = new StringBuilder();
boolean deleteConnectStorage = false;
SqlStorage<GlobalErrorRecord> storage = CommCareApplication.instance()
.getGlobalStorage(GlobalErrorRecord.class);
Vector<GlobalErrorRecord> errors = storage.getRecordsForValues(new String[]{}, new String[]{});
Expand All @@ -29,13 +26,6 @@ public static String handleGlobalErrors() {
GlobalErrors ge = GlobalErrors.values()[error.getErrorCode()];

sb.append(CommCareApplication.instance().getString(ge.getMessageId()));

deleteConnectStorage |= ge == GlobalErrors.PERSONALID_GENERIC_ERROR
|| ge == GlobalErrors.PERSONALID_LOST_CONFIGURATION_ERROR;
}

if(deleteConnectStorage) {
PersonalIdManager.getInstance().forgetUser(AnalyticsParamValue.PERSONAL_ID_FORGOT_USER_DB_ERROR);
}

//Clear the errors once retrieved
Expand Down