Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun SharedPreferences.deleteEncryptedSharedPreference(context: Context, filename
val deleted = sharedPrefsFile.delete()
Log.d(tag, "resetStorage() Shared prefs file deleted: $deleted; path: ${sharedPrefsFile.absolutePath}")
} else {
Log.d(tag,"resetStorage() Shared prefs file non-existent; path: ${sharedPrefsFile.absolutePath}")
Log.d(tag, "resetStorage() Shared prefs file non-existent; path: ${sharedPrefsFile.absolutePath}")
}

val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE_NAME)
Expand All @@ -41,7 +41,7 @@ fun SharedPreferences.deleteEncryptedSharedPreference(context: Context, filename

fun createEncryptedSharedPrefKeyStoreWithRetry(context: Context, fileName: String, keystoreAlias: String): SharedPreferences? {
val firstAttempt = createEncryptedSharedPrefsKeyStore(context = context, fileName = fileName, keystoreAlias = keystoreAlias)
return if(firstAttempt != null) {
return if (firstAttempt != null) {
firstAttempt
} else {
context.getSharedPreferences(fileName, Context.MODE_PRIVATE).deleteEncryptedSharedPreference(
Expand All @@ -61,25 +61,26 @@ fun createEncryptedSharedPrefsKeyStore(context: Context, fileName: String, keyst
.setEncryptionPaddings(ENCRYPTION_PADDING_NONE)
.build()

val keys = try {
MasterKeys.getOrCreate(keySpec)
} catch (ex: Exception) {
//clear corrupted store, contents will be lost
context.getSharedPreferences(fileName, Context.MODE_PRIVATE).deleteEncryptedSharedPreference(
context = context,
filename = fileName,
keystoreAlias = keystoreAlias )
MasterKeys.getOrCreate(keySpec)
}
return try {
val keys = try {
MasterKeys.getOrCreate(keySpec)
} catch (ex: Exception) {
//clear corrupted store, contents will be lost
context.getSharedPreferences(fileName, Context.MODE_PRIVATE).deleteEncryptedSharedPreference(
context = context,
filename = fileName,
keystoreAlias = keystoreAlias)
MasterKeys.getOrCreate(keySpec)
}

EncryptedSharedPreferences.create(
fileName,
keys,
context,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
} catch(ex: Exception) {
} catch (ex: Exception) {
null
}
}
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Project Armadillo Release Notes

## 1.6.9
- Improves the crash fix from 1.6.8, so that even retries on EncryptedSharedPreferences does not crash.

## 1.6.8
- Fixes an app startup crash to EncryptedSharedPreference faults.
- Adds resilience to playing unencrypted content if it is optionally drm enabled.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
PACKAGE_NAME=com.scribd.armadillo
GRADLE_PLUGIN_VERSION=7.2.0
LIBRARY_VERSION=1.6.8
LIBRARY_VERSION=1.6.9
EXOPLAYER_VERSION=2.19.1
RXJAVA_VERSION=2.2.4
RXANDROID_VERSION=2.0.1
Expand Down
Loading