From e800469c7810a0655eb940d79b362a86e228e2a4 Mon Sep 17 00:00:00 2001 From: Sai Date: Mon, 28 Oct 2024 12:23:42 -0700 Subject: [PATCH 1/4] Update API where getParcelableExtra method is used --- .../api/sharedutils/IntentExtensions.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt index 6da2cfd204..c1067505ec 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt @@ -10,24 +10,27 @@ import java.io.Serializable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) object IntentExtensions { - + /** Although the newer getParcelableExtra(key, T::class.java) was introduced in Tiramisu (API 33), + there seems to be an issue that throws NPE. See: https://issuetracker.google.com/issues/240585930#comment6 + Suggestion is to use the older API for Tiramisu (API 33) instead. + */ inline fun Intent.parcelable(key: String): T? = when { - SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelableExtra(key, T::class.java) + SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> getParcelableExtra(key, T::class.java) else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T } inline fun Bundle.parcelable(key: String): T? = when { - SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelable(key, T::class.java) + SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> getParcelable(key, T::class.java) else -> @Suppress("DEPRECATION") getParcelable(key) as? T } inline fun Intent.serializable(key: String): T? = when { - SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializableExtra(key, T::class.java) + SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> getSerializableExtra(key, T::class.java) else -> @Suppress("DEPRECATION") getSerializableExtra(key) as? T } inline fun Bundle.serializable(key: String): T? = when { - SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializable(key, T::class.java) + SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> getSerializable(key, T::class.java) else -> @Suppress("DEPRECATION") getSerializable(key) as? T } } From e12d9cb973f994b35804d251adc339c28c2d4f28 Mon Sep 17 00:00:00 2001 From: Sai Date: Tue, 29 Oct 2024 10:52:01 -0700 Subject: [PATCH 2/4] formatting --- .../com/braintreepayments/api/sharedutils/IntentExtensions.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt index c1067505ec..b5ab72b862 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/IntentExtensions.kt @@ -11,8 +11,8 @@ import java.io.Serializable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) object IntentExtensions { /** Although the newer getParcelableExtra(key, T::class.java) was introduced in Tiramisu (API 33), - there seems to be an issue that throws NPE. See: https://issuetracker.google.com/issues/240585930#comment6 - Suggestion is to use the older API for Tiramisu (API 33) instead. + * there seems to be an issue that throws NPE. See: https://issuetracker.google.com/issues/240585930#comment6 + * Suggestion is to use the older APIs for Tiramisu (API 33) instead. */ inline fun Intent.parcelable(key: String): T? = when { SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> getParcelableExtra(key, T::class.java) From 52fce9ec1731de901a92bd89067ebeae673d5c8d Mon Sep 17 00:00:00 2001 From: Sai Date: Tue, 29 Oct 2024 10:58:25 -0700 Subject: [PATCH 3/4] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a805edfe62..37d98cbea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## unreleased +* GooglePay + * Fixing a crash on API 33 devices. It is recommended that merchants not use 5.1.0 for GooglePay. * Shopper Insights (BETA) * For analytics, send `experiment` as a parameter to `getRecommendedPaymentMethods` method * For analytics, send `experiment` and `paymentMethodsDisplayed` analytic metrics to FPTI via the button presented event methods From 6da70f7edbfbdf9bc6fa227f20561df3521b3a48 Mon Sep 17 00:00:00 2001 From: Sai Date: Tue, 29 Oct 2024 13:22:18 -0700 Subject: [PATCH 4/4] update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37d98cbea6..490a577d08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## unreleased * GooglePay - * Fixing a crash on API 33 devices. It is recommended that merchants not use 5.1.0 for GooglePay. + * Fix a crash being caused on API 33 devices. It is recommended that merchants not use 5.1.0 for GooglePay. * Shopper Insights (BETA) * For analytics, send `experiment` as a parameter to `getRecommendedPaymentMethods` method * For analytics, send `experiment` and `paymentMethodsDisplayed` analytic metrics to FPTI via the button presented event methods