fix: replace EncryptedSharedPreferences with plain MODE_PRIVATE for update survival
This commit is contained in:
parent
348c55d830
commit
42b8092807
1 changed files with 1 additions and 19 deletions
|
|
@ -3,10 +3,7 @@ package com.eddy.atomrelay
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Log
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
|
||||||
import androidx.security.crypto.MasterKey
|
|
||||||
|
|
||||||
object PrefsHelper {
|
object PrefsHelper {
|
||||||
|
|
||||||
|
|
@ -29,21 +26,6 @@ object PrefsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPrefs(context: Context): SharedPreferences {
|
fun getPrefs(context: Context): SharedPreferences {
|
||||||
return try {
|
return context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||||
val masterKey = MasterKey.Builder(context)
|
|
||||||
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
EncryptedSharedPreferences.create(
|
|
||||||
context,
|
|
||||||
PREFS_NAME,
|
|
||||||
masterKey,
|
|
||||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
||||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Failed to create EncryptedSharedPreferences", e)
|
|
||||||
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue