|
16 | 16 |
|
17 | 17 | package com.duckduckgo.pir.impl.store.secure |
18 | 18 |
|
19 | | -import android.content.Context |
20 | 19 | import android.content.SharedPreferences |
21 | 20 | import androidx.core.content.edit |
22 | | -import androidx.security.crypto.EncryptedSharedPreferences |
23 | | -import androidx.security.crypto.MasterKey |
24 | 21 | import com.duckduckgo.app.di.AppCoroutineScope |
25 | 22 | import com.duckduckgo.common.utils.DispatcherProvider |
| 23 | +import com.duckduckgo.data.store.api.SharedPreferencesProvider |
26 | 24 | import com.duckduckgo.di.scopes.AppScope |
27 | 25 | import com.squareup.anvil.annotations.ContributesBinding |
28 | 26 | import dagger.SingleInstanceIn |
@@ -62,9 +60,9 @@ interface PirSecureStorageKeyStore { |
62 | 60 | boundType = PirSecureStorageKeyStore::class, |
63 | 61 | ) |
64 | 62 | class RealPirSecureStorageKeyStore @Inject constructor( |
65 | | - private val context: Context, |
66 | 63 | @AppCoroutineScope private val coroutineScope: CoroutineScope, |
67 | 64 | private val dispatcherProvider: DispatcherProvider, |
| 65 | + private val sharedPreferencesProvider: SharedPreferencesProvider, |
68 | 66 | ) : PirSecureStorageKeyStore { |
69 | 67 |
|
70 | 68 | private val mutex: Mutex = Mutex() |
@@ -108,14 +106,9 @@ class RealPirSecureStorageKeyStore @Inject constructor( |
108 | 106 | private suspend fun createEncryptedPreferences(): SharedPreferences? { |
109 | 107 | return try { |
110 | 108 | mutex.withLock { |
111 | | - EncryptedSharedPreferences.create( |
112 | | - context, |
113 | | - FILENAME, |
114 | | - MasterKey.Builder(context) |
115 | | - .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) |
116 | | - .build(), |
117 | | - EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, |
118 | | - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, |
| 109 | + sharedPreferencesProvider.getEncryptedSharedPreferences( |
| 110 | + name = FILENAME, |
| 111 | + multiprocess = true, |
119 | 112 | ) |
120 | 113 | } |
121 | 114 | } catch (_: Exception) { |
|
0 commit comments