Skip to content
Open
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
1 change: 1 addition & 0 deletions app/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
<string name="personalid_biometric_error_lockout_permanent">Demasiados intentos fallidos. Por favor, desbloquee su dispositivo e inténtelo de nuevo.</string>
<string name="personalid_biometric_error_timeout">La operación biométrica ha expirado. Por favor, póngase en contacto con el soporte técnico si el problema persiste.</string>
<string name="personalid_biometric_error_cannot_configure">No pudimos configurar los datos biométricos en su dispositivo. Por favor, póngase en contacto con el soporte técnico si el problema persiste.</string>
<string name="personalid_no_connect_database_error">No hay ninguna cuenta de PersonalID presente, por favor vuelva a iniciar sesión en su cuenta de PersonalID e inténtelo de nuevo.</string>

<string name="connect_complete_by">La tarea termina el %s</string>
<string name="connect_expired_on">La tarea terminó el %s</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ License.
<string name="personalid_biometric_error_lockout_permanent">Trop de tentatives infructueuses. Veuillez déverrouiller votre appareil et réessayer.</string>
<string name="personalid_biometric_error_timeout">L\'opération biométrique a expiré. Veuillez contacter le support client si le problème persiste.</string>
<string name="personalid_biometric_error_cannot_configure">Nous n\'avons pas pu configurer la biométrie sur votre appareil. Veuillez contacter le support client si le problème persiste.</string>
<string name="personalid_no_connect_database_error">Aucun compte PersonalID n\'est présent, veuillez vous reconnecter à votre compte PersonalID et réessayer.</string>

<string name="connect_complete_by">La tâche se termine le %s</string>
<string name="connect_expired_on">La tâche s\'est terminée le %s</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-ha/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ Don cikakken aiki na wurin zama na aikace-aikace da yawa, da fatan za a yi sabon
<string name="personalid_biometric_error_lockout_permanent">Gwaje-gwaje da yawa sun gaza. Da fatan za a buɗe na\'urarka ka sake gwadawa.</string>
<string name="personalid_biometric_error_timeout">Aikin biometric ya ƙare. Da fatan za a tuntuɓi tallafin abokin ciniki idan matsalar ta ci gaba.</string>
<string name="personalid_biometric_error_cannot_configure">Ba za mu iya saita yanayin halittu a na\'urarka ba. Da fatan za a tuntuɓi tallafin abokin ciniki idan matsalar ta ci gaba.</string>
<string name="personalid_no_connect_database_error">Babu asusun PersonalID da ke nan, don Allah sake shiga asusunka na PersonalID kuma a sake gwadawa.</string>
<string name="connect_complete_by">Aiki yana ƙarewa akan %s</string>
<string name="connect_expired_on">Aiki ya ƙare a kan %s</string>
<string name="connect_job_preview_start">Fara</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ License.
<string name="personalid_biometric_error_lockout_permanent">बहुत अधिक असफल प्रयास। कृपया अपने डिवाइस को अनलॉक करें और पुनः प्रयास करें।</string>
<string name="personalid_biometric_error_timeout">बायोमेट्रिक ऑपरेशन का समय समाप्त हो गया। यदि समस्या बनी रहती है तो कृपया ग्राहक सहायता से संपर्क करें।</string>
<string name="personalid_biometric_error_cannot_configure">हम आपके डिवाइस पर बायोमेट्रिक्स कॉन्फ़िगर नहीं कर सके। यदि समस्या बनी रहती है तो कृपया ग्राहक सहायता से संपर्क करें।</string>
<string name="personalid_no_connect_database_error">कोई PersonalID खाता मौजूद नहीं है, कृपया अपने PersonalID खाते में फिर से लॉगिन करें और पुनः प्रयास करें।</string>

<string name="connect_complete_by">कार्य %s को समाप्त होती है</string>
<string name="connect_expired_on">कार्य %s को समाप्त हुई</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
<string name="personalid_biometric_error_lockout_permanent">Per daug nepavykusių bandymų. Atrakinkite įrenginį ir bandykite dar kartą.</string>
<string name="personalid_biometric_error_timeout">Baigėsi biometrinės operacijos laikas. Jei problema išlieka, susisiekite su klientų aptarnavimo tarnyba.</string>
<string name="personalid_biometric_error_cannot_configure">Nepavyko sukonfigūruoti biometrinių duomenų jūsų įrenginyje. Jei problema išlieka, susisiekite su klientų aptarnavimo tarnyba.</string>
<string name="personalid_no_connect_database_error">Nėra PersonalID paskyros, prašome iš naujo prisijungti prie savo PersonalID paskyros ir bandyti dar kartą.</string>
<string name="personalid_work_history_no_records_available">Šiuo metu nėra jokių darbo įrašų. Spustelėkite atnaujinti arba patikrinkite vėliau.</string>
<string name="pn_no_notification_available">Pranešimų nėra</string>
<string name="connect_no_jobs">Jūs dar nebuvote pakviestas į jokias galimybes. Kai būsite pakviestas į galimybę, ji atsiras šiame sąraše.</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-no/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<string name="personalid_biometric_error_lockout_permanent">For mange mislykkede forsøk. Lås opp enheten og prøv igjen.</string>
<string name="personalid_biometric_error_timeout">Biometrisk operasjon ble tidsavbrutt. Kontakt kundestøtte hvis problemet vedvarer.</string>
<string name="personalid_biometric_error_cannot_configure">Vi kunne ikke konfigurere biometri på enheten din. Kontakt kundestøtte hvis problemet vedvarer.</string>
<string name="personalid_no_connect_database_error">Ingen PersonalID-konto er til stede. Logg inn på PersonalID-kontoen din på nytt, og prøv igjen.</string>
<string name="personalid_work_history_no_records_available">Ingen arbeidslogger er tilgjengelige for øyeblikket. Klikk på Oppdater, eller kom tilbake senere.</string>
<string name="pn_no_notification_available">Ingen varsler tilgjengelig</string>
<string name="connect_no_jobs">Du har ikke blitt invitert til noen muligheter ennå. Når du har blitt invitert til en mulighet, vil den vises i denne listen.</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
<string name="personalid_biometric_error_lockout_permanent">Muitas tentativas falhadas. Por favor, desbloqueie o seu dispositivo e tente novamente.</string>
<string name="personalid_biometric_error_timeout">A operação biométrica expirou. Por favor, contacte o apoio ao cliente se o problema persistir.</string>
<string name="personalid_biometric_error_cannot_configure">Não foi possível configurar a biometria no seu dispositivo. Por favor, contacte o apoio ao cliente se o problema persistir.</string>
<string name="personalid_no_connect_database_error">Nenhuma conta PersonalID está presente, por favor volte a iniciar sessão na sua conta PersonalID e tente novamente.</string>

<string name="connect_complete_by">A tarefa termina em %s</string>
<string name="connect_expired_on">A tarefa terminou em %s</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-sw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@
<string name="personalid_biometric_error_lockout_permanent">Majaribio mengi mno yameshindikana. Tafadhali fungua kifaa chako na ujaribu tena.</string>
<string name="personalid_biometric_error_timeout">Muda wa utendakazi wa kibayometri umekwisha. Tafadhali wasiliana na usaidizi kwa wateja ikiwa tatizo litaendelea.</string>
<string name="personalid_biometric_error_cannot_configure">Hatukuweza kusanidi bayometriki kwenye kifaa chako. Tafadhali wasiliana na usaidizi kwa wateja ikiwa tatizo litaendelea.</string>
<string name="personalid_no_connect_database_error">Hakuna akaunti ya PersonalID iliyopo, tafadhali ingia tena katika akaunti yako ya PersonalID na ujaribu tena.</string>

<string name="connect_complete_by">Kazi inaisha tarehe %s</string>
<string name="connect_expired_on">Kazi iliisha tarehe %s</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values-ti/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@
<string name="personalid_biometric_error_lockout_permanent">በዝሒ ዝፈሸለ ፈተነታት። በጃኻ ንመሳርሒኻ ክፈቶ እሞ እንደገና ፈትን።</string>
<string name="personalid_biometric_error_timeout">ናይ ባዮሜትሪክ ኦፕሬሽን ግዜኡ ተወዲኡ። እቲ ጸገም እንተቀጺሉ በጃኻ ንደገፍ ዓማዊል ተወከስ።</string>
<string name="personalid_biometric_error_cannot_configure">ኣብ መሳርሒኻ ባዮሜትሪክ ክንቃኔ ኣይከኣልናን። እቲ ጸገም እንተቀጺሉ በጃኻ ንደገፍ ዓማዊል ተወከስ።</string>
<string name="personalid_no_connect_database_error">ናይ PersonalID ሕሳብ የለን፣ በጃኻ ናብ ናይ PersonalID ሕሳብካ እንደገና እቶ ከምኡ\'ውን እንደገና ፈትን።</string>

<string name="connect_complete_by">ዕዮ ኣብ %s ይወዳእ</string>
<string name="connect_expired_on">ዕዮ ኣብ %s ተወዲኡ</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@
<string name="personalid_biometric_error_lockout_permanent">Too many failed attempts. Please unlock your device and try again.</string>
<string name="personalid_biometric_error_timeout">Biometric operation timed out. Please contact customer support if the problem persists.</string>
<string name="personalid_biometric_error_cannot_configure">We couldn’t configure biometrics on your device. Please contact customer support if the problem persists.</string>
<string name="personalid_no_connect_database_error">No PersonalID account present, please re-login into your PersonalID account and try again.</string>

<string name="connect_complete_by">Task ends on %s</string>
<string name="connect_expired_on">Task ended on %s</string>
Expand Down
14 changes: 10 additions & 4 deletions app/src/org/commcare/connect/database/ConnectDatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ public IDatabase getHandle() {
try {
connectDatabase = CommCareApplication.instance().getConnectDbOpenHelper(context);
} catch (Exception e) {
//Flag the DB as broken if we hit an error opening it (usually means corrupted or bad encryption)
dbBroken = true;
Logger.exception("Error opening Connect DB", e);
GlobalErrorUtil.triggerGlobalError(GlobalErrors.PERSONALID_GENERIC_ERROR);
if (!dbExists()) {
ConnectDatabaseNotFoundException dbNotFound = new ConnectDatabaseNotFoundException();
Logger.exception("Error opening Connect DB", dbNotFound);
throw dbNotFound;
Comment on lines +57 to +59

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, ConnectDatabaseNotFoundException is only handled at the BaseApi layer under the assumption that it originates from API calls only. However, if it gets thrown during DB operations (like in this case), it will have not exception catching and crash the app. Should we add this exception at CommCareExceptionHandler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think that would make sense to me, but I am not clear around what would we do after catching it ? Should we still handle it as a global error or something else ?

In general, I would not expect this to happen for any Synchronous calls and think API calls are probably the largest surface area this issue would happen. So think it might still be ok crashing in other scenarios with the assumption that we don't expect those crashes to surface in other places, although I would definitely be interested in seeing this bubble in Crashlytics to decide if we need to handle it at other places in the code and with what priority.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think I would not want us to handle it as Global error as that would be equal to hiding this issue under global error umbrella (which was the earlier behaviour here as well and think why we didn't knew about this issue sooner).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your reasoning here. I think we can move ahead with this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused as to what the difference would be since a global error crashes the app anyway. Is it just a matter of whether we show an error message when the app restarts after crashing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise that global error always crashes the app. I think majorly I would like to see this crash appearing in Crashlytics as a standalone crash rather than being burried into some other error factor and I am not sure if that's the behaviour with Global errors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, a LoginInvalidatedException gets thrown from here and crashes the app. I put together a query here showing recent occurrences of four possible reasons that are still being observed in the recent past (the ...DB_UPGRADE_ERROR case hasn't occurred recently).

My take is that almost all of these errors (excluding ...LOGIN_FROM_DIFFERENT_DEVICE) are ones that should never happen and we should treat with equal importance as bugs. But given that the excluded case is one we know will keep happening for the foreseeable future, maybe it's worth separating out LoginInvalidatedExceptions that are user-caused vs. bugs so we can have better visibility of "the bad ones".

} else {
//Flag the DB as broken if we hit an error opening it (usually means corrupted or bad encryption)
dbBroken = true;
Logger.exception("Error opening Connect DB", e);
GlobalErrorUtil.triggerGlobalError(GlobalErrors.PERSONALID_GENERIC_ERROR);
}
}
}
return connectDatabase;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.commcare.connect.database;

/**
* Exception thrown when the Connect database file does not exist.
*/
public class ConnectDatabaseNotFoundException extends RuntimeException {
public ConnectDatabaseNotFoundException() {
super("Connect database file does not exist");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class ConnectDatabaseUtils {
// the value of the key should not be renamed due to backward compatibility
private static final String SECRET_NAME = "secret";
public static void storeConnectDbPassphrase(@NotNull Context context, byte[] passphrase) {
private static void storeConnectDbPassphrase(@NotNull Context context, byte[] passphrase) {
try {
if (passphrase == null || passphrase.length == 0) {
throw new IllegalArgumentException("Passphrase must not be null or empty");
Expand Down
1 change: 1 addition & 0 deletions app/src/org/commcare/connect/network/IApiCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public interface IApiCallback {
void processOldApiError();
void processTokenUnavailableError();
void processTokenRequestDeniedError();
void noConnectDatabaseError();
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static String handle(
return context.getString(R.string.personalid_network_response_parsing_error);
case EMAIL_ALREADY_IN_USE_ERROR:
return context.getString(R.string.personalid_email_already_in_use);
case NO_CONNECT_DATABASE_ERROR:
return context.getString(R.string.personalid_no_connect_database_error);
default:
if (t != null) {
Logger.exception("Unhandled throwable passed with API error code: " + errorCode, t);
Expand Down
3 changes: 3 additions & 0 deletions app/src/org/commcare/connect/network/base/BaseApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Handler
import okhttp3.ResponseBody
import org.commcare.activities.CommCareActivity
import org.commcare.connect.ConnectConstants
import org.commcare.connect.database.ConnectDatabaseNotFoundException
import org.commcare.connect.network.IApiCallback
import org.commcare.connect.network.NetworkUtils
import org.commcare.connect.network.NetworkUtils.getErrorCodes
Expand Down Expand Up @@ -43,6 +44,8 @@ class BaseApi {
Logger.exception("Error reading response stream", e)
// Handle error when reading the stream
callback.processFailure(response.code(), endPoint, "", e)
} catch (_: ConnectDatabaseNotFoundException){
callback.noConnectDatabaseError()
}
} else {
val stream =
Expand Down
7 changes: 7 additions & 0 deletions app/src/org/commcare/connect/network/base/BaseApiCallback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ abstract class BaseApiCallback<T>(
null,
)
}

override fun noConnectDatabaseError() {
baseApiHandler.stopLoadingAndInformError(
PersonalIdOrConnectApiErrorCodes.NO_CONNECT_DATABASE_ERROR,
null,
)
}
}
4 changes: 4 additions & 0 deletions app/src/org/commcare/connect/network/base/BaseApiHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ abstract class BaseApiHandler<T>(
// The verified email is already tied to another active account.
EMAIL_ALREADY_IN_USE_ERROR,

// We were not able to find any existing database for the user locally
// Can typically happen if another process or user cleaned up their account from the phone.
NO_CONNECT_DATABASE_ERROR,

;

fun shouldAllowRetry(): Boolean =
Expand Down
Loading