Skip to content

Conversation

@kabliz
Copy link
Contributor

@kabliz kabliz commented Oct 23, 2024

The earlier failsafe does not protect against the app crashing on startup. This time, the exception is caught and the SecureStorage can handle the SharedPref being null.

issue for EncryptedSharedPreferences
https://issuetracker.google.com/issues/176215143?pli=1

The earlier failsafe does not protect against the app crashing on startup. This time, the exception is caught and the SecureStorage can handle the SharedPref being null.
@rubeus90 rubeus90 self-assigned this Oct 23, 2024
Armadillo to simply took the DRMInfo passed into it for granted without checking whether the content even needed a key to play. Exoplayer can raise an exception on its own and didn't need the DrmMediaSourceHelper to throw its own exceptions separately.
@griffinfscribd griffinfscribd self-assigned this Oct 23, 2024
val alias = getDrmDownloadAlias(id, drmDownload.drmType)
val value = Base64.encodeToString(Json.encodeToString(drmDownload).toByteArray(StandardCharsets.UTF_8), Base64.NO_WRAP)
secureDrmStorage.edit().putString(alias, value).apply()
secureDrmStorage?.edit()?.putString(alias, value)?.apply()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to put it in legacy if secure doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be failing insecure.

val tag = "DeletingSharedPrefs"
try {
val sharedPrefsFile = File(
(context.filesDir.getParent()?.plus("/shared_prefs/")) + filename + ".xml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth adding a comment that this file is only a guess at the filepath, and may not actually exist depending on SDK version and OEM, and what happens if we do/don't delete it.

import java.io.File
import java.security.KeyStore

fun SharedPreferences.deleteSharedPreference(context: Context, filename: String, keystoreAlias: String) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be named specific to the encryption prefs, since it also does things with the keystore.

Ignore flaky test that was already hard to write. Have to go back later for it.
@kschults kschults merged commit 2841758 into main Oct 24, 2024
4 checks passed
@kschults kschults deleted the kabliz/APT-10658 branch October 24, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants