Skip to content

Commit

Permalink
Fix prefs privacy filter for new consents mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKaN committed Aug 5, 2024
1 parent 565d4f3 commit 8cc70eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
# Plugins
kotlin = "1.9.23"
android = "8.3.2"
android = "8.4.2"
binaryCompatibility = "0.14.0"
versionUpdater = "0.51.0"
ktlint = "12.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ public class PrivacyModesStorage internal constructor(
prefsStorage.privacyStorageFilter = ::isFeatureAllowed
}
private fun isFeatureAllowed(privacyStorageFeature: PrivacyStorageFeature): Boolean {
val isNotForbidden = PrivacyStorageFeature.ALL !in cachedMode.forbiddenStorageFeatures ||
privacyStorageFeature !in cachedMode.forbiddenStorageFeatures
val isAllowed = PrivacyStorageFeature.ALL in cachedMode.allowedStorageFeatures ||
privacyStorageFeature in cachedMode.allowedStorageFeatures
val privacyMode = if (consentsEnabled) consentsCurrentMode else cachedMode
val isNotForbidden = PrivacyStorageFeature.ALL !in privacyMode.forbiddenStorageFeatures ||
privacyStorageFeature !in privacyMode.forbiddenStorageFeatures
val isAllowed = PrivacyStorageFeature.ALL in privacyMode.allowedStorageFeatures ||
privacyStorageFeature in privacyMode.allowedStorageFeatures
return isNotForbidden && isAllowed
}

private val consentsCurrentMode
get() = pianoConsents?.let {
it.consents[it.productsToPurposesMapping[Product.PA]]?.mode
}?.toPrivacyMode() ?: PrivacyMode.NO_CONSENT

/**
* All registered privacy modes. Add a [PrivacyMode] instance into [allModes] for registering it
*/
Expand All @@ -49,9 +55,7 @@ public class PrivacyModesStorage internal constructor(
public var currentMode: PrivacyMode = configuration.defaultPrivacyMode
get() {
if (consentsEnabled) {
return pianoConsents?.let {
it.consents[it.productsToPurposesMapping[Product.PA]]?.mode
}?.toPrivacyMode() ?: PrivacyMode.NO_CONSENT
return consentsCurrentMode
}
if (field != PrivacyMode.NO_CONSENT && field != PrivacyMode.NO_STORAGE) {
if (prefsStorage.privacyExpirationTimestamp in 1..System.currentTimeMillis()) {
Expand Down

0 comments on commit 8cc70eb

Please sign in to comment.