Fully check result code when processing purchase results.

This commit is contained in:
Alex Hart
2025-10-01 09:50:42 -03:00
committed by Michelle Tang
parent 76448f5426
commit 87535a917a
3 changed files with 98 additions and 93 deletions

View File

@@ -252,7 +252,10 @@ class BackupStateObserver(
if (SignalStore.backup.subscriptionStateMismatchDetected) {
Log.d(TAG, "[getNetworkBackupState][subscriptionStateMismatchDetected] A mismatch was detected.")
val hasActiveGooglePlayBillingSubscription = when (val purchaseResult = AppDependencies.billingApi.queryPurchases()) {
val purchaseResult = AppDependencies.billingApi.queryPurchases()
Log.d(TAG, "[getNetworkBackupState][subscriptionStateMismatchDetected] queryPurchase result: $purchaseResult")
val hasActiveGooglePlayBillingSubscription = when (purchaseResult) {
is BillingPurchaseResult.Success -> {
Log.d(TAG, "[getNetworkBackupState][subscriptionStateMismatchDetected] Found a purchase: $purchaseResult")
purchaseResult.isAcknowledged && purchaseResult.isAutoRenewing

View File

@@ -118,6 +118,12 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
val purchase: BillingPurchaseResult = AppDependencies.billingApi.queryPurchases()
Log.i(TAG, "Retrieved purchase result from Billing api: $purchase", true)
if (purchase !is BillingPurchaseResult.Success && purchase !is BillingPurchaseResult.None) {
Log.w(TAG, "Possible error when grabbing purchase from billing API. Clearing mismatch and exiting.")
SignalStore.backup.subscriptionStateMismatchDetected = false
return Result.success()
}
val hasActivePurchase = purchase is BillingPurchaseResult.Success && purchase.isAcknowledged
val product: BillingProduct? = AppDependencies.billingApi.queryProduct()