mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Add BackupSubscriptionCheckJob.
This commit is contained in:
committed by
Greyson Parrelli
parent
24209756e3
commit
5bc8435d25
@@ -27,7 +27,7 @@ interface BillingApi {
|
||||
* Queries the user's current purchases. This enqueues a check and will
|
||||
* propagate it to the normal callbacks in the api.
|
||||
*/
|
||||
suspend fun queryPurchases() = Unit
|
||||
suspend fun queryPurchases(): BillingPurchaseResult = BillingPurchaseResult.None
|
||||
|
||||
suspend fun launchBillingFlow(activity: Activity) = Unit
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
package org.signal.core.util.billing
|
||||
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
* Sealed class hierarchy representing the different success
|
||||
* and error states of google play billing purchases.
|
||||
@@ -13,8 +16,21 @@ sealed interface BillingPurchaseResult {
|
||||
data class Success(
|
||||
val purchaseToken: String,
|
||||
val isAcknowledged: Boolean,
|
||||
val purchaseTime: Long
|
||||
) : BillingPurchaseResult
|
||||
val purchaseTime: Long,
|
||||
val isAutoRenewing: Boolean
|
||||
) : BillingPurchaseResult {
|
||||
|
||||
/**
|
||||
* @return true if purchaseTime is within the last month.
|
||||
*/
|
||||
fun isWithinTheLastMonth(): Boolean {
|
||||
val now = System.currentTimeMillis().milliseconds
|
||||
val oneMonthAgo = now - 31.days
|
||||
val purchaseTime = this.purchaseTime.milliseconds
|
||||
|
||||
return oneMonthAgo >= purchaseTime
|
||||
}
|
||||
}
|
||||
data object UserCancelled : BillingPurchaseResult
|
||||
data object None : BillingPurchaseResult
|
||||
data object TryAgainLater : BillingPurchaseResult
|
||||
|
||||
Reference in New Issue
Block a user