Skip to content

Commit 08a58a7

Browse files
authored
Merge 832f808 into aad3da8
2 parents aad3da8 + 832f808 commit 08a58a7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

firebase-installations/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
2-
2+
* [fixed] Mitigated FIS ID duplication issue from backup data. (#7025)
33

44
# 18.0.0
55
* [changed] Bump internal dependencies

firebase-installations/src/main/java/com/google/firebase/installations/local/PersistedInstallation.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.installations.local;
1616

17+
import android.util.Log;
1718
import androidx.annotation.NonNull;
1819
import com.google.firebase.FirebaseApp;
1920
import java.io.ByteArrayOutputStream;
@@ -33,6 +34,7 @@
3334
public class PersistedInstallation {
3435
private File dataFile;
3536
@NonNull private final FirebaseApp firebaseApp;
37+
private static final String TAG = "PersistedInstallation";
3638

3739
// Registration Status of each persisted fid entry
3840
// NOTE: never change the ordinal of the enum values because the enum values are written to
@@ -81,16 +83,33 @@ public PersistedInstallation(@NonNull FirebaseApp firebaseApp) {
8183
}
8284

8385
private File getDataFile() {
84-
8586
if (dataFile == null) {
8687
synchronized (this) {
8788
if (dataFile == null) {
8889
// Different FirebaseApp in the same Android application should have the same application
8990
// context and same dir path
9091
dataFile =
92+
new File(
93+
firebaseApp.getApplicationContext().getNoBackupFilesDir(),
94+
SETTINGS_FILE_NAME_PREFIX + "." + firebaseApp.getPersistenceKey() + ".json");
95+
if (dataFile.exists()) {
96+
return dataFile;
97+
}
98+
// Data associated with FID shouldn't be stored in backup directory. Hence if the FID data
99+
// is present in the backup directory you move it to the non backup directory.
100+
File dataFileBackup =
91101
new File(
92102
firebaseApp.getApplicationContext().getFilesDir(),
93103
SETTINGS_FILE_NAME_PREFIX + "." + firebaseApp.getPersistenceKey() + ".json");
104+
if (dataFileBackup.exists()) {
105+
if (!dataFileBackup.renameTo(dataFile)) {
106+
Log.e(
107+
TAG,
108+
"Unable to move the file from back up to non back up directory",
109+
new IOException("Unable to move the file from back up to non back up directory"));
110+
return dataFileBackup;
111+
}
112+
}
94113
}
95114
}
96115
}

0 commit comments

Comments
 (0)