Skip to content

Commit 296ab29

Browse files
[Infra] Improve datastore support (#7277)
Bump the dependency to version 1.1.7 to include the mitigation introduced in https://developer.android.com/jetpack/androidx/releases/datastore#1.1.5 Additionally, a corruption handler has been added to the `JavaDataStorage` class. Include `firebase-sessions` changelog entry so it's released. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 3c6bed3 commit 296ab29

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
package com.google.firebase.datastorage
1818

1919
import android.content.Context
20+
import android.os.Process
21+
import android.util.Log
2022
import androidx.datastore.core.DataStore
23+
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
2124
import androidx.datastore.preferences.SharedPreferencesMigration
2225
import androidx.datastore.preferences.core.MutablePreferences
2326
import androidx.datastore.preferences.core.Preferences
2427
import androidx.datastore.preferences.core.edit
28+
import androidx.datastore.preferences.core.emptyPreferences
2529
import androidx.datastore.preferences.preferencesDataStore
2630
import com.google.firebase.annotations.concurrent.Background
2731
import kotlinx.coroutines.flow.firstOrNull
@@ -60,7 +64,16 @@ class JavaDataStorage(val context: Context, val name: String) {
6064
private val Context.dataStore: DataStore<Preferences> by
6165
preferencesDataStore(
6266
name = name,
63-
produceMigrations = { listOf(SharedPreferencesMigration(it, name)) }
67+
produceMigrations = { listOf(SharedPreferencesMigration(it, name)) },
68+
corruptionHandler =
69+
ReplaceFileCorruptionHandler { ex ->
70+
Log.w(
71+
JavaDataStorage::class.simpleName,
72+
"CorruptionException in ${name} DataStore running in process ${Process.myPid()}",
73+
ex
74+
)
75+
emptyPreferences()
76+
}
6477
)
6578

6679
private val dataStore = context.dataStore

firebase-crashlytics-ndk/CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
2-
2+
* [changed] Updated `firebase-crashlytics` dependency to 20.0.1
33

44
# 20.0.0
55
* [changed] **Breaking Change**: Updated minSdkVersion to API level 23 or higher.
@@ -243,12 +243,12 @@ change. The following release notes describe changes in the new SDK.
243243
<li>If you're using [crashlytics] for NDK crash reporting in your app for
244244
the first time, follow the
245245
<a href="/docs/crashlytics/get-started-new-sdk?platform=android">getting
246-
started instructions</a>.
246+
started instructions</a>.
247247
</li>
248248
<li>If you're upgrading from the legacy Fabric SDK to the
249249
[firebase_crashlytics] SDK for NDK crash reporting, follow the
250250
<a href="/docs/crashlytics/upgrade-sdk?platform=android">upgrade
251-
instructions</a> to update your app with the following SDK changes.
251+
instructions</a> to update your app with the following SDK changes.
252252
</li>
253253
</ul>
254254
</aside>
@@ -259,4 +259,3 @@ change. The following release notes describe changes in the new SDK.
259259
uploading symbol files to [crashlytics] servers. See the
260260
[[crashlytics] Gradle plugin documentation](/docs/crashlytics/ndk-reports-new-sdk)
261261
for more information.
262-

firebase-crashlytics/CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
2-
2+
** [changed] Updated `firebase-sessions` dependency to v3.0.1
33

44
# 20.0.0
55
* [changed] **Breaking Change**: Removed deprecated public constructor `KeyValueBuilder(crashlytics: FirebaseCrashlytics)`
@@ -683,12 +683,12 @@ The following release notes describe changes in the new SDK.
683683
<li>If you're using [crashlytics] for NDK crash reporting in your app for
684684
the first time, follow the
685685
<a href="/docs/crashlytics/get-started-new-sdk?platform=android">getting
686-
started instructions</a>.
686+
started instructions</a>.
687687
</li>
688688
<li>If you're upgrading from the legacy Fabric SDK to the
689689
[firebase_crashlytics] SDK, follow the
690690
<a href="/docs/crashlytics/upgrade-sdk?platform=android">upgrade
691-
instructions</a> to update your app with the following SDK changes.
691+
instructions</a> to update your app with the following SDK changes.
692692
</li>
693693
</ul>
694694
</aside>
@@ -702,4 +702,3 @@ The following release notes describe changes in the new SDK.
702702
from your `AndroidManifest.xml` file.
703703
* [removed] The `fabric.properties` and `crashlytics.properties` files are no
704704
longer supported. Remove them from your app.
705-

firebase-sessions/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
2-
2+
* [fixed] Bumped DataStore dependency to include the mitigation for
3+
`CorruptionException` released in version `1.1.5`. See Jetpacks' DataStore
4+
[release notes](https://developer.android.com/jetpack/androidx/releases/datastore#1.1.5).
35

46
# 3.0.0
57
* [changed] Added internal api for Crashlytics to notify Sessions of crash events
@@ -55,4 +57,3 @@
5557

5658
# 1.0.0
5759
* [feature] Initial Firebase sessions library.
58-

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ constraintlayout = "2.1.4"
1919
coreKtx = "1.12.0"
2020
coroutines = "1.9.0"
2121
dagger = "2.51" # Don't bump above 2.51 as it causes a bug in AppDistro FeedbackSender JPEG code
22-
datastore = "1.1.3"
22+
datastore = "1.1.7"
2323
dexmaker = "2.28.1"
2424
dexmakerVersion = "1.2"
2525
espressoCore = "3.6.1"
@@ -238,4 +238,4 @@ spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
238238
protobuf = { id = "com.google.protobuf", version.ref = "protobufGradlePlugin" }
239239
errorprone = { id = "net.ltgt.errorprone", version.ref = "gradleErrorpronePlugin" }
240240
google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
241-
crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" }
241+
crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" }

0 commit comments

Comments
 (0)