fix: plain SharedPreferences for credentials (EncryptedSharedPreferences crashed on Pixel)
- CredentialStore now uses getSharedPreferences instead of EncryptedSharedPreferences - Still sandboxed by Android app isolation (other apps can't read it)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package com.yarisobd.app.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import androidx.security.crypto.MasterKey
|
||||
|
||||
object CredentialStore {
|
||||
private const val PREFS = "yaris_creds"
|
||||
@@ -10,12 +8,8 @@ object CredentialStore {
|
||||
private const val KEY_DEVICE_NAME = "device_name"
|
||||
private const val KEY_API_KEY = "api_key"
|
||||
|
||||
private fun prefs(context: Context) = EncryptedSharedPreferences.create(
|
||||
context, PREFS,
|
||||
MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build(),
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
)
|
||||
private fun prefs(context: Context) =
|
||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
|
||||
fun getServerUrl(context: Context): String = prefs(context).getString(KEY_SERVER_URL, "") ?: ""
|
||||
fun getDeviceName(context: Context): String = prefs(context).getString(KEY_DEVICE_NAME, "") ?: ""
|
||||
|
||||
Reference in New Issue
Block a user