mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-08 09:18:39 +01:00
Allow different accounts on same Google account to subscribe to backups.
This commit is contained in:
-12
@@ -110,18 +110,6 @@ class MessageBackupsFlowViewModel(
|
|||||||
Log.d(TAG, "Got successful purchase result for purchase at ${result.purchaseTime}")
|
Log.d(TAG, "Got successful purchase result for purchase at ${result.purchaseTime}")
|
||||||
val id = internalStateFlow.value.inAppPayment!!.id
|
val id = internalStateFlow.value.inAppPayment!!.id
|
||||||
|
|
||||||
if (result.isAcknowledged) {
|
|
||||||
Log.w(TAG, "Payment is already acknowledged. Ignoring.")
|
|
||||||
|
|
||||||
internalStateFlow.update {
|
|
||||||
it.copy(
|
|
||||||
stage = MessageBackupsStage.COMPLETED
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return@collect
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Attempting to handle successful purchase.")
|
Log.d(TAG, "Attempting to handle successful purchase.")
|
||||||
|
|
||||||
|
|||||||
@@ -140,8 +140,9 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purchaseToken?.let { hasLocalDevicePurchaseTokenMismatch(purchaseToken) } == true) {
|
val hasTokenMismatch = purchaseToken?.let { hasLocalDevicePurchaseTokenMismatch(purchaseToken) } == true
|
||||||
Log.i(TAG, "Encountered token mismatch. Attempting to redeem.")
|
if (hasActiveSignalSubscription && hasTokenMismatch) {
|
||||||
|
Log.i(TAG, "Encountered token mismatch with an active Signal subscription. Attempting to redeem against latest token.")
|
||||||
enqueueRedemptionForNewToken(purchaseToken, product.price)
|
enqueueRedemptionForNewToken(purchaseToken, product.price)
|
||||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||||
return Result.success()
|
return Result.success()
|
||||||
|
|||||||
@@ -221,9 +221,18 @@ internal class BillingApiImpl(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches the Google Play billing flow.
|
* Launches the Google Play billing flow.
|
||||||
* Returns a billing result if we launched the flow, null otherwise.
|
*
|
||||||
|
* If the user already has an active purchase (purchase exists and autoRenew == true) then we will not
|
||||||
|
* launch and instead immediately post the purchase.
|
||||||
*/
|
*/
|
||||||
override suspend fun launchBillingFlow(activity: Activity) {
|
override suspend fun launchBillingFlow(activity: Activity) {
|
||||||
|
val latestPurchase = queryPurchases()
|
||||||
|
if (latestPurchase is BillingPurchaseResult.Success && latestPurchase.isAutoRenewing) {
|
||||||
|
Log.w(TAG, "Already purchased.")
|
||||||
|
internalResults.emit(latestPurchase)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val productDetails = queryProductsInternal().productDetailsList
|
val productDetails = queryProductsInternal().productDetailsList
|
||||||
if (productDetails.isNullOrEmpty()) {
|
if (productDetails.isNullOrEmpty()) {
|
||||||
Log.w(TAG, "No products are available! Cancelling billing flow launch.")
|
Log.w(TAG, "No products are available! Cancelling billing flow launch.")
|
||||||
|
|||||||
Reference in New Issue
Block a user