From 28ecb37103df49693118046babbccb1a19af20b7 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Wed, 14 May 2025 10:43:03 -0300 Subject: [PATCH] Add additional logging for stopped processing. --- .../remote/RemoteBackupsSettingsViewModel.kt | 14 ++++++++++++-- .../main/java/org/signal/billing/BillingApiImpl.kt | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/backups/remote/RemoteBackupsSettingsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/backups/remote/RemoteBackupsSettingsViewModel.kt index 3788e9e144..cfaf1ecaea 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/backups/remote/RemoteBackupsSettingsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/backups/remote/RemoteBackupsSettingsViewModel.kt @@ -55,7 +55,7 @@ import kotlin.time.Duration.Companion.seconds class RemoteBackupsSettingsViewModel : ViewModel() { companion object { - private val TAG = Log.tag(RemoteBackupsSettingsFragment::class) + private val TAG = Log.tag(RemoteBackupsSettingsViewModel::class) } private val _state = MutableStateFlow( @@ -214,6 +214,15 @@ class RemoteBackupsSettingsViewModel : ViewModel() { } private suspend fun refreshState(lastPurchase: InAppPaymentTable.InAppPayment?) { + try { + performStateRefresh(lastPurchase) + } catch (e: Exception) { + Log.w(TAG, "State refresh failed", e) + throw e + } + } + + private suspend fun performStateRefresh(lastPurchase: InAppPaymentTable.InAppPayment?) { val tier = SignalStore.backup.latestBackupTier _state.update { @@ -269,7 +278,7 @@ class RemoteBackupsSettingsViewModel : ViewModel() { it.copy( backupState = RemoteBackupsSettingsState.BackupState.SubscriptionMismatchMissingGooglePlay( messageBackupsType = type, - renewalTime = activeSubscription!!.activeSubscription.endOfCurrentPeriod.seconds + renewalTime = activeSubscription.activeSubscription.endOfCurrentPeriod.seconds ) ) } @@ -302,6 +311,7 @@ class RemoteBackupsSettingsViewModel : ViewModel() { BackupRepository.getBackupsType(tier) as MessageBackupsType.Paid } + Log.d(TAG, "Attempting to retrieve current subscription...") val activeSubscription = withContext(Dispatchers.IO) { RecurringInAppPaymentRepository.getActiveSubscriptionSync(InAppPaymentSubscriberRecord.Type.BACKUP) } diff --git a/billing/src/main/java/org/signal/billing/BillingApiImpl.kt b/billing/src/main/java/org/signal/billing/BillingApiImpl.kt index 556fb14aa0..27b4a37512 100644 --- a/billing/src/main/java/org/signal/billing/BillingApiImpl.kt +++ b/billing/src/main/java/org/signal/billing/BillingApiImpl.kt @@ -181,8 +181,10 @@ internal class BillingApiImpl( Log.d(TAG, "No pricing available.") null } else { + val price = FiatMoney(BigDecimal.valueOf(pricing.priceAmountMicros, 6), Currency.getInstance(pricing.priceCurrencyCode)) + Log.d(TAG, "Found product pricing: $price") BillingProduct( - price = FiatMoney(BigDecimal.valueOf(pricing.priceAmountMicros, 6), Currency.getInstance(pricing.priceCurrencyCode)) + price = price ) } } catch (e: BillingError) {