From 1d52126d568706db965d366806c62f7230b872fb Mon Sep 17 00:00:00 2001 From: d067928 Date: Tue, 2 Jun 2020 10:58:12 +0200 Subject: [PATCH] Add Commit Flag to ensure synchronous consistent Updates to Disk Signed-off-by: d067928 --- .../de/rki/coronawarnapp/storage/LocalData.kt | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/LocalData.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/LocalData.kt index 7c05737b92b..11c6e2f0171 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/LocalData.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/LocalData.kt @@ -38,7 +38,7 @@ object LocalData { * * @param value boolean if onboarding was completed */ - fun isOnboarded(value: Boolean) = getSharedPreferenceInstance().edit { + fun isOnboarded(value: Boolean) = getSharedPreferenceInstance().edit(true) { putBoolean( CoronaWarnApplication.getAppContext() .getString(R.string.preference_onboarding_completed), value @@ -73,7 +73,7 @@ object LocalData { * @param value timestamp in ms */ fun initialTracingActivationTimestamp(value: Long) = - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putLong( CoronaWarnApplication.getAppContext() .getString(R.string.preference_initial_tracing_activation_time), @@ -106,7 +106,7 @@ object LocalData { * * @param value timestamp in ms */ - fun lastNonActiveTracingTimestamp(value: Long?) = getSharedPreferenceInstance().edit { + fun lastNonActiveTracingTimestamp(value: Long?) = getSharedPreferenceInstance().edit(true) { // TODO need this for nullable ref, shout not be goto for nullable storage putLong( CoronaWarnApplication.getAppContext().getString( @@ -139,7 +139,7 @@ object LocalData { */ fun totalNonActiveTracing(value: Long?) { // TODO need this for nullable ref, shout not be goto for nullable storage - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putLong( CoronaWarnApplication.getAppContext() .getString(R.string.preference_total_non_active_tracing), @@ -180,7 +180,7 @@ object LocalData { */ fun lastTimeDiagnosisKeysFromServerFetch(value: Date?) { // TODO need this for nullable ref, shout not be goto for nullable storage - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putLong( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_timestamp_diagnosis_keys_fetch), @@ -205,7 +205,7 @@ object LocalData { * Sets the last timestamp the user manually triggered the key retrieval process */ fun lastTimeManualDiagnosisKeysRetrieved(value: Long) = - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putLong( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_timestamp_manual_diagnosis_keys_retrieval), @@ -234,7 +234,7 @@ object LocalData { * * @param value UUID as string */ - fun googleApiToken(value: String?) = getSharedPreferenceInstance().edit { + fun googleApiToken(value: String?) = getSharedPreferenceInstance().edit(true) { putString( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_string_google_api_token), @@ -262,7 +262,7 @@ object LocalData { * Toggles the user decision if notification should be enabled for a risk change * */ - fun toggleNotificationsRiskEnabled() = getSharedPreferenceInstance().edit { + fun toggleNotificationsRiskEnabled() = getSharedPreferenceInstance().edit(true) { putBoolean( CoronaWarnApplication.getAppContext() .getString(R.string.preference_notifications_risk_enabled), @@ -277,7 +277,7 @@ object LocalData { true ) - fun toggleNotificationsTestEnabled() = getSharedPreferenceInstance().edit { + fun toggleNotificationsTestEnabled() = getSharedPreferenceInstance().edit(true) { putBoolean( CoronaWarnApplication.getAppContext() .getString(R.string.preference_notifications_test_enabled), @@ -300,7 +300,7 @@ object LocalData { * Toggles the decision if background jobs are enabled * */ - fun toggleBackgroundJobEnabled() = getSharedPreferenceInstance().edit { + fun toggleBackgroundJobEnabled() = getSharedPreferenceInstance().edit(true) { putBoolean( CoronaWarnApplication.getAppContext() .getString(R.string.preference_background_job_allowed), @@ -323,7 +323,7 @@ object LocalData { * Toggles the boolean if the user has mobile data enabled * */ - fun toggleMobileDataEnabled() = getSharedPreferenceInstance().edit { + fun toggleMobileDataEnabled() = getSharedPreferenceInstance().edit(true) { putBoolean( CoronaWarnApplication.getAppContext() .getString(R.string.preference_mobile_data_allowed), @@ -353,7 +353,7 @@ object LocalData { * @param value registration token as string */ fun registrationToken(value: String?) { - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putString( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_registration_token), @@ -364,7 +364,7 @@ object LocalData { } fun inititalTestResultReceivedTimestamp(value: Long) = - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putLong( CoronaWarnApplication.getAppContext() .getString(R.string.preference_initial_result_received_time), @@ -387,7 +387,7 @@ object LocalData { } fun numberOfSuccessfulSubmissions(value: Int) = - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putInt( CoronaWarnApplication.getAppContext() .getString(R.string.preference_number_successful_submissions), @@ -411,7 +411,7 @@ object LocalData { ) fun testGUID(value: String?) { - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putString( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_test_guid), @@ -428,7 +428,7 @@ object LocalData { ) fun authCode(value: String?) { - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putString( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_auth_code), @@ -439,7 +439,7 @@ object LocalData { } fun isAllowedToSubmitDiagnosisKeys(isAllowedToSubmitDiagnosisKeys: Boolean) { - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putBoolean( CoronaWarnApplication.getAppContext() .getString(R.string.preference_m_is_allowed_to_submit_diagnosis_keys), @@ -457,7 +457,7 @@ object LocalData { ) } - fun teletan(value: String?) = getSharedPreferenceInstance().edit { + fun teletan(value: String?) = getSharedPreferenceInstance().edit(true) { putString( CoronaWarnApplication.getAppContext().getString(R.string.preference_teletan), value @@ -480,7 +480,7 @@ object LocalData { )?.toCharArray() fun databasePassword(password: CharArray) { - getSharedPreferenceInstance().edit { + getSharedPreferenceInstance().edit(true) { putString( CoronaWarnApplication.getAppContext() .getString(R.string.preference_database_password),