-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace retry with exponential backoff with arrow schedule
Also clean up the code related to play purchase verification
- Loading branch information
Showing
15 changed files
with
73 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/PaymentConstant.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package net.mullvad.mullvadvpn.constant | ||
|
||
import kotlin.time.Duration.Companion.seconds | ||
|
||
const val VERIFICATION_MAX_ATTEMPTS = 4 | ||
const val VERIFICATION_INITIAL_BACK_OFF_MILLISECONDS = 3000L | ||
const val VERIFICATION_BACK_OFF_FACTOR = 3L | ||
val VERIFICATION_INITIAL_BACK_OFF_DURATION = 3.seconds | ||
const val VERIFICATION_BACK_OFF_FACTOR = 3.toDouble() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/VerificationResultExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.mullvad.mullvadvpn.util | ||
|
||
import arrow.core.Either | ||
import net.mullvad.mullvadvpn.lib.payment.model.VerificationError | ||
import net.mullvad.mullvadvpn.lib.payment.model.VerificationResult | ||
|
||
fun Either<VerificationError, VerificationResult>.isSuccess() = | ||
getOrNull() == VerificationResult.Success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/VerificationError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package net.mullvad.mullvadvpn.lib.payment.model | ||
|
||
sealed interface VerificationError { | ||
data class BillingError(val exception: Throwable) : VerificationError | ||
|
||
data object PlayVerificationError : VerificationError | ||
} |
14 changes: 1 addition & 13 deletions
14
...ib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/VerificationResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
package net.mullvad.mullvadvpn.lib.payment.model | ||
|
||
sealed interface VerificationResult { | ||
data object FetchingUnfinishedPurchases : VerificationResult | ||
|
||
data object VerificationStarted : VerificationResult | ||
|
||
// No verification was needed as there is no purchases to verify | ||
interface VerificationResult { | ||
data object NothingToVerify : VerificationResult | ||
|
||
data object Success : VerificationResult | ||
|
||
// Generic error, add more cases as needed | ||
sealed interface Error : VerificationResult { | ||
data class BillingError(val exception: Throwable?) : Error | ||
|
||
data class VerificationError(val exception: Throwable?) : Error | ||
} | ||
} |