Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StrictMode DiskReadViolation in StripePaymentController #2572

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import java.security.cert.CertificateException
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
* A controller responsible for confirming and authenticating payment (typically through resolving
Expand Down Expand Up @@ -595,31 +596,45 @@ internal class StripePaymentController internal constructor(
config.stripe3ds2Config.uiCustomization.uiCustomization
)

val areqParams = transaction.authenticationRequestParameters
val timeout = config.stripe3ds2Config.timeout
val authParams = Stripe3ds2AuthParams(
stripe3ds2Fingerprint.source,
areqParams.sdkAppId,
areqParams.sdkReferenceNumber,
areqParams.sdkTransactionId,
areqParams.deviceData,
areqParams.sdkEphemeralPublicKey,
areqParams.messageVersion,
timeout,
// We do not currently have a fallback url
// TODO(smaskell-stripe): Investigate more robust error handling
returnUrl = null
)
stripeRepository.start3ds2Auth(
authParams,
stripeIntent.id.orEmpty(),
requestOptions,
Stripe3ds2AuthCallback(
host, stripeRepository, transaction, timeout,
stripeIntent, stripe3ds2Fingerprint.source, requestOptions,
analyticsRequestExecutor, analyticsDataFactory,
challengeFlowStarter, enableLogging)
)
workScope.launch {
// call `authenticationRequestParameters` on background thread to avoid StrictMode
// DiskReadViolation
val areqParams = transaction.authenticationRequestParameters

val timeout = config.stripe3ds2Config.timeout
val authParams = Stripe3ds2AuthParams(
stripe3ds2Fingerprint.source,
areqParams.sdkAppId,
areqParams.sdkReferenceNumber,
areqParams.sdkTransactionId,
areqParams.deviceData,
areqParams.sdkEphemeralPublicKey,
areqParams.messageVersion,
timeout,
// We do not currently have a fallback url
// TODO(smaskell-stripe): Investigate more robust error handling
returnUrl = null
)

stripeRepository.start3ds2Auth(
authParams,
stripeIntent.id.orEmpty(),
requestOptions,
Stripe3ds2AuthCallback(
host,
stripeRepository,
transaction,
timeout,
stripeIntent,
stripe3ds2Fingerprint.source,
requestOptions,
analyticsRequestExecutor,
analyticsDataFactory,
challengeFlowStarter,
enableLogging
)
)
}
}

private class ConfirmStripeIntentTask(
Expand Down