Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Oct 31, 2023
1 parent 0031499 commit 4764f17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions messagingpush/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Prevent EncryptedSharedPreferences file from being backed up -->
<!-- Encrypted preferences should not be backed up as the key used to encrypt it will no
longer be present when backup is restored -->
<exclude
domain="sharedpref"
path="io.customer.sdk.SECURE_PREFERENCE_FILE_KEY.xml" />
path="io.customer.sdk.EncryptedConfigCache.xml" />
</full-backup-content>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import android.content.SharedPreferences
internal abstract class BasePreferenceRepository(val context: Context) {

abstract val prefsName: String

// Making this abstract so base class has option to use encrypted shared prefs
internal abstract val prefs: SharedPreferences

// this would clear the prefs asynchronously
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ internal interface SharedPreferenceRepository {
internal class SharedPreferenceRepositoryImp(context: Context) : SharedPreferenceRepository,
BasePreferenceRepository(context) {

// The file name used for storing shared preferences.
// This preference file should not be included in Auto Backup.
// Upon restoration, the encryption key originally used may no longer be present.
// To prevent this, ensure the file name matches the one excluded in backup_rules.xml.
// Read more: https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences
override val prefsName: String by lazy {
"io.customer.sdk.SECURE_PREFERENCE_FILE_KEY"
"io.customer.sdk.EncryptedConfigCache"
}

override val prefs: SharedPreferences
Expand Down

0 comments on commit 4764f17

Please sign in to comment.