Skip to content

Commit

Permalink
Merge branch 'hotfix/5.196.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosholgado committed Apr 10, 2024
2 parents dd6fbf0 + 53ff7f2 commit a02085e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ internal fun String.sanitizeStackTrace(): String {
sanitizedStackTrace = sanitizedStackTrace.replace(ipv4Regex, "[REDACTED_IPV4]")

return sanitizedStackTrace
}.getOrDefault("")
}.getOrDefault(this)
}
12 changes: 6 additions & 6 deletions app/src/main/java/com/duckduckgo/app/global/db/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ class MigrationsProvider(val context: Context, val settingsDataStore: SettingsDa
}
}

/**
* WARNING ⚠️
* This needs to happen because Room doesn't support UNIQUE (...) ON CONFLICT REPLACE when creating the bookmarks table.
* When updating the bookmarks table, you will need to update this creation script in order to properly maintain the above
* constraint.
*/
val BOOKMARKS_DB_ON_CREATE = object : RoomDatabase.Callback() {
override fun onCreate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand All @@ -672,12 +678,6 @@ class MigrationsProvider(val context: Context, val settingsDataStore: SettingsDa
}
}

/**
* WARNING ⚠️
* This needs to happen because Room doesn't support UNIQUE (...) ON CONFLICT REPLACE when creating the bookmarks table.
* When updating the bookmarks table, you will need to update this creation script in order to properly maintain the above
* constraint.
*/
val CHANGE_JOURNAL_ON_OPEN = object : RoomDatabase.Callback() {
override fun onOpen(db: SupportSQLiteDatabase) {
db.query("PRAGMA journal_mode=DELETE;").use { cursor -> cursor.moveToFirst() }
Expand Down
2 changes: 1 addition & 1 deletion app/version/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=5.196.1
VERSION=5.196.2
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ class HttpsUpgraderImpl @Inject constructor(
override fun reloadData() {
logcat { "Reload Https upgrader data" }
bloomReloadLock.lock()
try {
bloomFilter = bloomFactory.create()
} finally {
bloomReloadLock.unlock()
}
bloomFilter = runCatching { bloomFactory.create() }.getOrNull()
bloomReloadLock.unlock()
}

private fun waitForAnyReloadsToComplete() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sealed class PurchasesUpdateResult {

data object PurchaseAbsent : PurchasesUpdateResult()
data object UserCancelled : PurchasesUpdateResult()
data object Failure : PurchasesUpdateResult()
data class Failure(val errorType: String) : PurchasesUpdateResult()
}

enum class BillingError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class RealPlayBillingManager @Inject constructor(
// Handle an error caused by a user cancelling the purchase flow.
}

PurchasesUpdateResult.Failure -> {
pixelSender.reportPurchaseFailureStore()
is PurchasesUpdateResult.Failure -> {
pixelSender.reportPurchaseFailureStore(result.errorType)
_purchaseState.emit(Canceled)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,27 @@ class RealBillingClientAdapter @Inject constructor(
private fun mapToPurchasesUpdateResult(
billingResult: BillingResult,
purchases: List<Purchase>?,
): PurchasesUpdateResult =
when (billingResult.responseCode) {
): PurchasesUpdateResult {
fun Int.asString(): String {
return when (this) {
BillingResponseCode.SERVICE_TIMEOUT -> "SERVICE_TIMEOUT"
BillingResponseCode.FEATURE_NOT_SUPPORTED -> "FEATURE_NOT_SUPPORTED"
BillingResponseCode.SERVICE_DISCONNECTED -> "SERVICE_DISCONNECTED"
BillingResponseCode.OK -> "OK"
BillingResponseCode.USER_CANCELED -> "USER_CANCELED"
BillingResponseCode.SERVICE_UNAVAILABLE -> "SERVICE_UNAVAILABLE"
BillingResponseCode.BILLING_UNAVAILABLE -> "BILLING_UNAVAILABLE"
BillingResponseCode.ITEM_UNAVAILABLE -> "ITEM_UNAVAILABLE"
BillingResponseCode.DEVELOPER_ERROR -> "DEVELOPER_ERROR"
BillingResponseCode.ERROR -> "ERROR"
BillingResponseCode.ITEM_ALREADY_OWNED -> "ITEM_ALREADY_OWNED"
BillingResponseCode.ITEM_NOT_OWNED -> "ITEM_NOT_OWNED"
BillingResponseCode.NETWORK_ERROR -> "NETWORK_ERROR"
else -> "UNKNOWN"
}
}

return when (billingResult.responseCode) {
BillingResponseCode.OK -> {
val purchase = purchases?.lastOrNull { it.purchaseState == PurchaseState.PURCHASED }
if (purchase != null) {
Expand All @@ -190,8 +209,9 @@ class RealBillingClientAdapter @Inject constructor(
}

BillingResponseCode.USER_CANCELED -> PurchasesUpdateResult.UserCancelled
else -> PurchasesUpdateResult.Failure
else -> PurchasesUpdateResult.Failure(billingResult.responseCode.asString())
}
}
}

private fun Int.toBillingError(): BillingError = when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface SubscriptionPixelSender {
fun reportOfferScreenShown()
fun reportOfferSubscribeClick()
fun reportPurchaseFailureOther()
fun reportPurchaseFailureStore()
fun reportPurchaseFailureStore(errorType: String)
fun reportPurchaseFailureBackend()
fun reportPurchaseFailureAccountCreation()
fun reportPurchaseSuccess()
Expand Down Expand Up @@ -109,8 +109,8 @@ class SubscriptionPixelSenderImpl @Inject constructor(
override fun reportPurchaseFailureOther() =
fire(PURCHASE_FAILURE_OTHER)

override fun reportPurchaseFailureStore() =
fire(PURCHASE_FAILURE_STORE)
override fun reportPurchaseFailureStore(errorType: String) =
fire(PURCHASE_FAILURE_STORE, mapOf("errorType" to errorType))

override fun reportPurchaseFailureBackend() =
fire(PURCHASE_FAILURE_BACKEND)
Expand Down Expand Up @@ -199,9 +199,9 @@ class SubscriptionPixelSenderImpl @Inject constructor(
override fun reportPrivacyProRedirect() =
fire(SUBSCRIPTION_PRIVACY_PRO_REDIRECT)

private fun fire(pixel: SubscriptionPixel) {
private fun fire(pixel: SubscriptionPixel, params: Map<String, String> = emptyMap()) {
pixel.getPixelNames().forEach { (pixelType, pixelName) ->
pixelSender.fire(pixelName = pixelName, type = pixelType)
pixelSender.fire(pixelName = pixelName, type = pixelType, parameters = params)
}
}
}

0 comments on commit a02085e

Please sign in to comment.