From f71322cd333085393f19af08a864814ce36b0359 Mon Sep 17 00:00:00 2001 From: Adam Vongrej Date: Sun, 14 Apr 2024 13:49:20 +0200 Subject: [PATCH 1/4] Introduced new ReplacementMode for Android's billing client --- .../in_app_purchase_android/CHANGELOG.md | 4 + .../plugins/inapppurchase/Messages.java | 447 +++++++----------- .../inapppurchase/MethodCallHandlerImpl.java | 40 +- .../inapppurchase/MethodCallHandlerTest.java | 94 ++++ .../billing_client_wrapper.dart | 75 ++- .../billing_client_wrapper.g.dart | 9 + .../src/in_app_purchase_android_platform.dart | 3 +- .../lib/src/messages.g.dart | 268 ++++------- .../src/types/change_subscription_param.dart | 10 +- .../pigeons/messages.dart | 2 + 10 files changed, 498 insertions(+), 454 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md index c77ce6fbc98..d548c5cbfd2 100644 --- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.4 + +* Introduces new ReplacementMode for Android's billing client + ## 0.3.3+1 * Moves alternative billing listener creation to BillingClientFactoryImpl. diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java index 6a465b4bb2c..ab8e97c3b66 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v17.1.2), do not edit directly. +// Autogenerated from Pigeon (v17.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package io.flutter.plugins.inapppurchase; @@ -21,8 +21,11 @@ import java.lang.annotation.Target; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) @@ -37,7 +40,8 @@ public static class FlutterError extends RuntimeException { /** The error details. Must be a datatype supported by the api codec. */ public final Object details; - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) + { super(message); this.code = code; this.details = details; @@ -56,15 +60,14 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { errorList.add(exception.toString()); errorList.add(exception.getClass().getSimpleName()); errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); } return errorList; } @NonNull protected static FlutterError createConnectionError(@NonNull String channelName) { - return new FlutterError( - "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); + return new FlutterError("channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); } @Target(METHOD) @@ -88,7 +91,7 @@ public enum PlatformBillingChoiceMode { /** * Billing through google play. * - *

Default state. + * Default state. */ PLAY_BILLING_ONLY(0), /** Billing through app provided flow. */ @@ -132,7 +135,7 @@ private PlatformRecurrenceMode(final int index) { /** * Pigeon version of Java QueryProductDetailsParams.Product. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformQueryProduct { private @NonNull String productId; @@ -211,7 +214,7 @@ ArrayList toList() { /** * Pigeon version of Java AccountIdentifiers. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformAccountIdentifiers { private @Nullable String obfuscatedAccountId; @@ -281,7 +284,7 @@ ArrayList toList() { /** * Pigeon version of Java BillingResult. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformBillingResult { private @NonNull Long responseCode; @@ -350,10 +353,7 @@ ArrayList toList() { static @NonNull PlatformBillingResult fromList(@NonNull ArrayList list) { PlatformBillingResult pigeonResult = new PlatformBillingResult(); Object responseCode = list.get(0); - pigeonResult.setResponseCode( - (responseCode == null) - ? null - : ((responseCode instanceof Integer) ? (Integer) responseCode : (Long) responseCode)); + pigeonResult.setResponseCode((responseCode == null) ? null : ((responseCode instanceof Integer) ? (Integer) responseCode : (Long) responseCode)); Object debugMessage = list.get(1); pigeonResult.setDebugMessage((String) debugMessage); return pigeonResult; @@ -363,7 +363,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails.OneTimePurchaseOfferDetails. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformOneTimePurchaseOfferDetails { private @NonNull Long priceAmountMicros; @@ -435,8 +435,7 @@ public static final class Builder { } public @NonNull PlatformOneTimePurchaseOfferDetails build() { - PlatformOneTimePurchaseOfferDetails pigeonReturn = - new PlatformOneTimePurchaseOfferDetails(); + PlatformOneTimePurchaseOfferDetails pigeonReturn = new PlatformOneTimePurchaseOfferDetails(); pigeonReturn.setPriceAmountMicros(priceAmountMicros); pigeonReturn.setFormattedPrice(formattedPrice); pigeonReturn.setPriceCurrencyCode(priceCurrencyCode); @@ -456,12 +455,7 @@ ArrayList toList() { static @NonNull PlatformOneTimePurchaseOfferDetails fromList(@NonNull ArrayList list) { PlatformOneTimePurchaseOfferDetails pigeonResult = new PlatformOneTimePurchaseOfferDetails(); Object priceAmountMicros = list.get(0); - pigeonResult.setPriceAmountMicros( - (priceAmountMicros == null) - ? null - : ((priceAmountMicros instanceof Integer) - ? (Integer) priceAmountMicros - : (Long) priceAmountMicros)); + pigeonResult.setPriceAmountMicros((priceAmountMicros == null) ? null : ((priceAmountMicros instanceof Integer) ? (Integer) priceAmountMicros : (Long) priceAmountMicros)); Object formattedPrice = list.get(1); pigeonResult.setFormattedPrice((String) formattedPrice); Object priceCurrencyCode = list.get(2); @@ -473,7 +467,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformProductDetails { private @NonNull String description; @@ -547,8 +541,7 @@ public void setTitle(@NonNull String setterArg) { return oneTimePurchaseOfferDetails; } - public void setOneTimePurchaseOfferDetails( - @Nullable PlatformOneTimePurchaseOfferDetails setterArg) { + public void setOneTimePurchaseOfferDetails(@Nullable PlatformOneTimePurchaseOfferDetails setterArg) { this.oneTimePurchaseOfferDetails = setterArg; } @@ -558,8 +551,7 @@ public void setOneTimePurchaseOfferDetails( return subscriptionOfferDetails; } - public void setSubscriptionOfferDetails( - @Nullable List setterArg) { + public void setSubscriptionOfferDetails(@Nullable List setterArg) { this.subscriptionOfferDetails = setterArg; } @@ -611,8 +603,7 @@ public static final class Builder { private @Nullable PlatformOneTimePurchaseOfferDetails oneTimePurchaseOfferDetails; @CanIgnoreReturnValue - public @NonNull Builder setOneTimePurchaseOfferDetails( - @Nullable PlatformOneTimePurchaseOfferDetails setterArg) { + public @NonNull Builder setOneTimePurchaseOfferDetails(@Nullable PlatformOneTimePurchaseOfferDetails setterArg) { this.oneTimePurchaseOfferDetails = setterArg; return this; } @@ -620,8 +611,7 @@ public static final class Builder { private @Nullable List subscriptionOfferDetails; @CanIgnoreReturnValue - public @NonNull Builder setSubscriptionOfferDetails( - @Nullable List setterArg) { + public @NonNull Builder setSubscriptionOfferDetails(@Nullable List setterArg) { this.subscriptionOfferDetails = setterArg; return this; } @@ -647,8 +637,7 @@ ArrayList toList() { toListResult.add(productId); toListResult.add(productType == null ? null : productType.index); toListResult.add(title); - toListResult.add( - (oneTimePurchaseOfferDetails == null) ? null : oneTimePurchaseOfferDetails.toList()); + toListResult.add((oneTimePurchaseOfferDetails == null) ? null : oneTimePurchaseOfferDetails.toList()); toListResult.add(subscriptionOfferDetails); return toListResult; } @@ -666,23 +655,18 @@ ArrayList toList() { Object title = list.get(4); pigeonResult.setTitle((String) title); Object oneTimePurchaseOfferDetails = list.get(5); - pigeonResult.setOneTimePurchaseOfferDetails( - (oneTimePurchaseOfferDetails == null) - ? null - : PlatformOneTimePurchaseOfferDetails.fromList( - (ArrayList) oneTimePurchaseOfferDetails)); + pigeonResult.setOneTimePurchaseOfferDetails((oneTimePurchaseOfferDetails == null) ? null : PlatformOneTimePurchaseOfferDetails.fromList((ArrayList) oneTimePurchaseOfferDetails)); Object subscriptionOfferDetails = list.get(6); - pigeonResult.setSubscriptionOfferDetails( - (List) subscriptionOfferDetails); + pigeonResult.setSubscriptionOfferDetails((List) subscriptionOfferDetails); return pigeonResult; } } /** - * Pigeon version of ProductDetailsResponseWrapper, which contains the components of the Java - * ProductDetailsResponseListener callback. + * Pigeon version of ProductDetailsResponseWrapper, which contains the + * components of the Java ProductDetailsResponseListener callback. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformProductDetailsResponse { private @NonNull PlatformBillingResult billingResult; @@ -751,10 +735,7 @@ ArrayList toList() { static @NonNull PlatformProductDetailsResponse fromList(@NonNull ArrayList list) { PlatformProductDetailsResponse pigeonResult = new PlatformProductDetailsResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult( - (billingResult == null) - ? null - : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); Object productDetails = list.get(1); pigeonResult.setProductDetails((List) productDetails); return pigeonResult; @@ -762,10 +743,11 @@ ArrayList toList() { } /** - * Pigeon version of AlternativeBillingOnlyReportingDetailsWrapper, which contains the components - * of the Java AlternativeBillingOnlyReportingDetailsListener callback. + * Pigeon version of AlternativeBillingOnlyReportingDetailsWrapper, which + * contains the components of the Java + * AlternativeBillingOnlyReportingDetailsListener callback. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformAlternativeBillingOnlyReportingDetailsResponse { private @NonNull PlatformBillingResult billingResult; @@ -816,8 +798,7 @@ public static final class Builder { } public @NonNull PlatformAlternativeBillingOnlyReportingDetailsResponse build() { - PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonReturn = - new PlatformAlternativeBillingOnlyReportingDetailsResponse(); + PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonReturn = new PlatformAlternativeBillingOnlyReportingDetailsResponse(); pigeonReturn.setBillingResult(billingResult); pigeonReturn.setExternalTransactionToken(externalTransactionToken); return pigeonReturn; @@ -832,15 +813,10 @@ ArrayList toList() { return toListResult; } - static @NonNull PlatformAlternativeBillingOnlyReportingDetailsResponse fromList( - @NonNull ArrayList list) { - PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonResult = - new PlatformAlternativeBillingOnlyReportingDetailsResponse(); + static @NonNull PlatformAlternativeBillingOnlyReportingDetailsResponse fromList(@NonNull ArrayList list) { + PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonResult = new PlatformAlternativeBillingOnlyReportingDetailsResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult( - (billingResult == null) - ? null - : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); Object externalTransactionToken = list.get(1); pigeonResult.setExternalTransactionToken((String) externalTransactionToken); return pigeonResult; @@ -848,10 +824,10 @@ ArrayList toList() { } /** - * Pigeon version of BillingConfigWrapper, which contains the components of the Java - * BillingConfigResponseListener callback. + * Pigeon version of BillingConfigWrapper, which contains the components of the + * Java BillingConfigResponseListener callback. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformBillingConfigResponse { private @NonNull PlatformBillingResult billingResult; @@ -920,10 +896,7 @@ ArrayList toList() { static @NonNull PlatformBillingConfigResponse fromList(@NonNull ArrayList list) { PlatformBillingConfigResponse pigeonResult = new PlatformBillingConfigResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult( - (billingResult == null) - ? null - : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); Object countryCode = list.get(1); pigeonResult.setCountryCode((String) countryCode); return pigeonResult; @@ -933,7 +906,7 @@ ArrayList toList() { /** * Pigeon version of Java BillingFlowParams. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformBillingFlowParams { private @NonNull String product; @@ -962,6 +935,19 @@ public void setProrationMode(@NonNull Long setterArg) { this.prorationMode = setterArg; } + private @NonNull Long replacementMode; + + public @NonNull Long getReplacementMode() { + return replacementMode; + } + + public void setReplacementMode(@NonNull Long setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"replacementMode\" is null."); + } + this.replacementMode = setterArg; + } + private @Nullable String offerToken; public @Nullable String getOfferToken() { @@ -1033,6 +1019,14 @@ public static final class Builder { return this; } + private @Nullable Long replacementMode; + + @CanIgnoreReturnValue + public @NonNull Builder setReplacementMode(@NonNull Long setterArg) { + this.replacementMode = setterArg; + return this; + } + private @Nullable String offerToken; @CanIgnoreReturnValue @@ -1077,6 +1071,7 @@ public static final class Builder { PlatformBillingFlowParams pigeonReturn = new PlatformBillingFlowParams(); pigeonReturn.setProduct(product); pigeonReturn.setProrationMode(prorationMode); + pigeonReturn.setReplacementMode(replacementMode); pigeonReturn.setOfferToken(offerToken); pigeonReturn.setAccountId(accountId); pigeonReturn.setObfuscatedProfileId(obfuscatedProfileId); @@ -1088,9 +1083,10 @@ public static final class Builder { @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(7); + ArrayList toListResult = new ArrayList(8); toListResult.add(product); toListResult.add(prorationMode); + toListResult.add(replacementMode); toListResult.add(offerToken); toListResult.add(accountId); toListResult.add(obfuscatedProfileId); @@ -1104,21 +1100,18 @@ ArrayList toList() { Object product = list.get(0); pigeonResult.setProduct((String) product); Object prorationMode = list.get(1); - pigeonResult.setProrationMode( - (prorationMode == null) - ? null - : ((prorationMode instanceof Integer) - ? (Integer) prorationMode - : (Long) prorationMode)); - Object offerToken = list.get(2); + pigeonResult.setProrationMode((prorationMode == null) ? null : ((prorationMode instanceof Integer) ? (Integer) prorationMode : (Long) prorationMode)); + Object replacementMode = list.get(2); + pigeonResult.setReplacementMode((replacementMode == null) ? null : ((replacementMode instanceof Integer) ? (Integer) replacementMode : (Long) replacementMode)); + Object offerToken = list.get(3); pigeonResult.setOfferToken((String) offerToken); - Object accountId = list.get(3); + Object accountId = list.get(4); pigeonResult.setAccountId((String) accountId); - Object obfuscatedProfileId = list.get(4); + Object obfuscatedProfileId = list.get(5); pigeonResult.setObfuscatedProfileId((String) obfuscatedProfileId); - Object oldProduct = list.get(5); + Object oldProduct = list.get(6); pigeonResult.setOldProduct((String) oldProduct); - Object purchaseToken = list.get(6); + Object purchaseToken = list.get(7); pigeonResult.setPurchaseToken((String) purchaseToken); return pigeonResult; } @@ -1127,7 +1120,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails.PricingPhase. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPricingPhase { private @NonNull Long billingCycleCount; @@ -1288,21 +1281,11 @@ ArrayList toList() { static @NonNull PlatformPricingPhase fromList(@NonNull ArrayList list) { PlatformPricingPhase pigeonResult = new PlatformPricingPhase(); Object billingCycleCount = list.get(0); - pigeonResult.setBillingCycleCount( - (billingCycleCount == null) - ? null - : ((billingCycleCount instanceof Integer) - ? (Integer) billingCycleCount - : (Long) billingCycleCount)); + pigeonResult.setBillingCycleCount((billingCycleCount == null) ? null : ((billingCycleCount instanceof Integer) ? (Integer) billingCycleCount : (Long) billingCycleCount)); Object recurrenceMode = list.get(1); pigeonResult.setRecurrenceMode(PlatformRecurrenceMode.values()[(int) recurrenceMode]); Object priceAmountMicros = list.get(2); - pigeonResult.setPriceAmountMicros( - (priceAmountMicros == null) - ? null - : ((priceAmountMicros instanceof Integer) - ? (Integer) priceAmountMicros - : (Long) priceAmountMicros)); + pigeonResult.setPriceAmountMicros((priceAmountMicros == null) ? null : ((priceAmountMicros instanceof Integer) ? (Integer) priceAmountMicros : (Long) priceAmountMicros)); Object billingPeriod = list.get(3); pigeonResult.setBillingPeriod((String) billingPeriod); Object formattedPrice = list.get(4); @@ -1316,9 +1299,9 @@ ArrayList toList() { /** * Pigeon version of Java Purchase. * - *

See also PurchaseWrapper on the Dart side. + * See also PurchaseWrapper on the Dart side. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchase { private @Nullable String orderId; @@ -1588,8 +1571,7 @@ public static final class Builder { private @Nullable PlatformAccountIdentifiers accountIdentifiers; @CanIgnoreReturnValue - public @NonNull Builder setAccountIdentifiers( - @Nullable PlatformAccountIdentifiers setterArg) { + public @NonNull Builder setAccountIdentifiers(@Nullable PlatformAccountIdentifiers setterArg) { this.accountIdentifiers = setterArg; return this; } @@ -1639,10 +1621,7 @@ ArrayList toList() { Object packageName = list.get(1); pigeonResult.setPackageName((String) packageName); Object purchaseTime = list.get(2); - pigeonResult.setPurchaseTime( - (purchaseTime == null) - ? null - : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); + pigeonResult.setPurchaseTime((purchaseTime == null) ? null : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); Object purchaseToken = list.get(3); pigeonResult.setPurchaseToken((String) purchaseToken); Object signature = list.get(4); @@ -1658,17 +1637,11 @@ ArrayList toList() { Object isAcknowledged = list.get(9); pigeonResult.setIsAcknowledged((Boolean) isAcknowledged); Object quantity = list.get(10); - pigeonResult.setQuantity( - (quantity == null) - ? null - : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); + pigeonResult.setQuantity((quantity == null) ? null : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); Object purchaseState = list.get(11); pigeonResult.setPurchaseState(PlatformPurchaseState.values()[(int) purchaseState]); Object accountIdentifiers = list.get(12); - pigeonResult.setAccountIdentifiers( - (accountIdentifiers == null) - ? null - : PlatformAccountIdentifiers.fromList((ArrayList) accountIdentifiers)); + pigeonResult.setAccountIdentifiers((accountIdentifiers == null) ? null : PlatformAccountIdentifiers.fromList((ArrayList) accountIdentifiers)); return pigeonResult; } } @@ -1676,9 +1649,9 @@ ArrayList toList() { /** * Pigeon version of PurchaseHistoryRecord. * - *

See also PurchaseHistoryRecordWrapper on the Dart side. + * See also PurchaseHistoryRecordWrapper on the Dart side. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchaseHistoryRecord { private @NonNull Long quantity; @@ -1859,15 +1832,9 @@ ArrayList toList() { static @NonNull PlatformPurchaseHistoryRecord fromList(@NonNull ArrayList list) { PlatformPurchaseHistoryRecord pigeonResult = new PlatformPurchaseHistoryRecord(); Object quantity = list.get(0); - pigeonResult.setQuantity( - (quantity == null) - ? null - : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); + pigeonResult.setQuantity((quantity == null) ? null : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); Object purchaseTime = list.get(1); - pigeonResult.setPurchaseTime( - (purchaseTime == null) - ? null - : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); + pigeonResult.setPurchaseTime((purchaseTime == null) ? null : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); Object developerPayload = list.get(2); pigeonResult.setDeveloperPayload((String) developerPayload); Object originalJson = list.get(3); @@ -1883,10 +1850,10 @@ ArrayList toList() { } /** - * Pigeon version of PurchasesHistoryResult, which contains the components of the Java - * PurchaseHistoryResponseListener callback. + * Pigeon version of PurchasesHistoryResult, which contains the components of + * the Java PurchaseHistoryResponseListener callback. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchaseHistoryResponse { private @NonNull PlatformBillingResult billingResult; @@ -1955,10 +1922,7 @@ ArrayList toList() { static @NonNull PlatformPurchaseHistoryResponse fromList(@NonNull ArrayList list) { PlatformPurchaseHistoryResponse pigeonResult = new PlatformPurchaseHistoryResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult( - (billingResult == null) - ? null - : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); Object purchases = list.get(1); pigeonResult.setPurchases((List) purchases); return pigeonResult; @@ -1966,10 +1930,10 @@ ArrayList toList() { } /** - * Pigeon version of PurchasesResultWrapper, which contains the components of the Java - * PurchasesResponseListener callback. + * Pigeon version of PurchasesResultWrapper, which contains the components of + * the Java PurchasesResponseListener callback. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchasesResponse { private @NonNull PlatformBillingResult billingResult; @@ -2038,10 +2002,7 @@ ArrayList toList() { static @NonNull PlatformPurchasesResponse fromList(@NonNull ArrayList list) { PlatformPurchasesResponse pigeonResult = new PlatformPurchasesResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult( - (billingResult == null) - ? null - : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); Object purchases = list.get(1); pigeonResult.setPurchases((List) purchases); return pigeonResult; @@ -2051,7 +2012,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails.SubscriptionOfferDetails. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformSubscriptionOfferDetails { private @NonNull String basePlanId; @@ -2202,7 +2163,7 @@ ArrayList toList() { /** * Pigeon version of UserChoiceDetailsWrapper and Java UserChoiceDetails. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformUserChoiceDetails { private @Nullable String originalExternalTransactionId; @@ -2303,7 +2264,7 @@ ArrayList toList() { /** * Pigeon version of UserChoiseDetails.Product. * - *

Generated class from Pigeon that represents data sent in messages. + * Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformUserChoiceProduct { private @NonNull String id; @@ -2437,8 +2398,7 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { case (byte) 128: return PlatformAccountIdentifiers.fromList((ArrayList) readValue(buffer)); case (byte) 129: - return PlatformAlternativeBillingOnlyReportingDetailsResponse.fromList( - (ArrayList) readValue(buffer)); + return PlatformAlternativeBillingOnlyReportingDetailsResponse.fromList((ArrayList) readValue(buffer)); case (byte) 130: return PlatformBillingConfigResponse.fromList((ArrayList) readValue(buffer)); case (byte) 131: @@ -2446,8 +2406,7 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { case (byte) 132: return PlatformBillingResult.fromList((ArrayList) readValue(buffer)); case (byte) 133: - return PlatformOneTimePurchaseOfferDetails.fromList( - (ArrayList) readValue(buffer)); + return PlatformOneTimePurchaseOfferDetails.fromList((ArrayList) readValue(buffer)); case (byte) 134: return PlatformPricingPhase.fromList((ArrayList) readValue(buffer)); case (byte) 135: @@ -2478,8 +2437,7 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { writeValue(stream, ((PlatformAccountIdentifiers) value).toList()); } else if (value instanceof PlatformAlternativeBillingOnlyReportingDetailsResponse) { stream.write(129); - writeValue( - stream, ((PlatformAlternativeBillingOnlyReportingDetailsResponse) value).toList()); + writeValue(stream, ((PlatformAlternativeBillingOnlyReportingDetailsResponse) value).toList()); } else if (value instanceof PlatformBillingConfigResponse) { stream.write(130); writeValue(stream, ((PlatformBillingConfigResponse) value).toList()); @@ -2528,77 +2486,47 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface InAppPurchaseApi { /** Wraps BillingClient#isReady. */ - @NonNull + @NonNull Boolean isReady(); /** Wraps BillingClient#startConnection(BillingClientStateListener). */ - void startConnection( - @NonNull Long callbackHandle, - @NonNull PlatformBillingChoiceMode billingMode, - @NonNull Result result); + void startConnection(@NonNull Long callbackHandle, @NonNull PlatformBillingChoiceMode billingMode, @NonNull Result result); /** Wraps BillingClient#endConnection(BillingClientStateListener). */ void endConnection(); - /** - * Wraps BillingClient#getBillingConfigAsync(GetBillingConfigParams, - * BillingConfigResponseListener). - */ + /** Wraps BillingClient#getBillingConfigAsync(GetBillingConfigParams, BillingConfigResponseListener). */ void getBillingConfigAsync(@NonNull Result result); /** Wraps BillingClient#launchBillingFlow(Activity, BillingFlowParams). */ - @NonNull + @NonNull PlatformBillingResult launchBillingFlow(@NonNull PlatformBillingFlowParams params); - /** - * Wraps BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, - * AcknowledgePurchaseResponseListener). - */ - void acknowledgePurchase( - @NonNull String purchaseToken, @NonNull Result result); + /** Wraps BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, AcknowledgePurchaseResponseListener). */ + void acknowledgePurchase(@NonNull String purchaseToken, @NonNull Result result); /** Wraps BillingClient#consumeAsync(ConsumeParams, ConsumeResponseListener). */ void consumeAsync(@NonNull String purchaseToken, @NonNull Result result); /** Wraps BillingClient#queryPurchasesAsync(QueryPurchaseParams, PurchaseResponseListener). */ - void queryPurchasesAsync( - @NonNull PlatformProductType productType, - @NonNull Result result); - /** - * Wraps BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, - * PurchaseHistoryResponseListener). - */ - void queryPurchaseHistoryAsync( - @NonNull PlatformProductType productType, - @NonNull Result result); - /** - * Wraps BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, - * ProductDetailsResponseListener). - */ - void queryProductDetailsAsync( - @NonNull List products, - @NonNull Result result); + void queryPurchasesAsync(@NonNull PlatformProductType productType, @NonNull Result result); + /** Wraps BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, PurchaseHistoryResponseListener). */ + void queryPurchaseHistoryAsync(@NonNull PlatformProductType productType, @NonNull Result result); + /** Wraps BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, ProductDetailsResponseListener). */ + void queryProductDetailsAsync(@NonNull List products, @NonNull Result result); /** Wraps BillingClient#isFeatureSupported(String). */ - @NonNull + @NonNull Boolean isFeatureSupported(@NonNull String feature); /** Wraps BillingClient#isAlternativeBillingOnlyAvailableAsync(). */ void isAlternativeBillingOnlyAvailableAsync(@NonNull Result result); /** Wraps BillingClient#showAlternativeBillingOnlyInformationDialog(). */ void showAlternativeBillingOnlyInformationDialog(@NonNull Result result); - /** - * Wraps - * BillingClient#createAlternativeBillingOnlyReportingDetailsAsync(AlternativeBillingOnlyReportingDetailsListener). - */ - void createAlternativeBillingOnlyReportingDetailsAsync( - @NonNull Result result); + /** Wraps BillingClient#createAlternativeBillingOnlyReportingDetailsAsync(AlternativeBillingOnlyReportingDetailsListener). */ + void createAlternativeBillingOnlyReportingDetailsAsync(@NonNull Result result); /** The codec used by InAppPurchaseApi. */ static @NonNull MessageCodec getCodec() { return InAppPurchaseApiCodec.INSTANCE; } - /** - * Sets up an instance of `InAppPurchaseApi` to handle messages through the `binaryMessenger`. - */ + /**Sets up an instance of `InAppPurchaseApi` to handle messages through the `binaryMessenger`. */ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable InAppPurchaseApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2606,7 +2534,8 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable InAppPurch try { Boolean output = api.isReady(); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2619,17 +2548,14 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable InAppPurch { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; Number callbackHandleArg = (Number) args.get(0); - PlatformBillingChoiceMode billingModeArg = - PlatformBillingChoiceMode.values()[(int) args.get(1)]; + PlatformBillingChoiceMode billingModeArg = PlatformBillingChoiceMode.values()[(int) args.get(1)]; Result resultCallback = new Result() { public void success(PlatformBillingResult result) { @@ -2643,10 +2569,7 @@ public void error(Throwable error) { } }; - api.startConnection( - (callbackHandleArg == null) ? null : callbackHandleArg.longValue(), - billingModeArg, - resultCallback); + api.startConnection((callbackHandleArg == null) ? null : callbackHandleArg.longValue(), billingModeArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -2655,9 +2578,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2665,7 +2586,8 @@ public void error(Throwable error) { try { api.endConnection(); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2678,9 +2600,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2707,9 +2627,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2719,7 +2637,8 @@ public void error(Throwable error) { try { PlatformBillingResult output = api.launchBillingFlow(paramsArg); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2732,9 +2651,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2763,9 +2680,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2794,16 +2709,13 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - PlatformProductType productTypeArg = - PlatformProductType.values()[(int) args.get(0)]; + PlatformProductType productTypeArg = PlatformProductType.values()[(int) args.get(0)]; Result resultCallback = new Result() { public void success(PlatformPurchasesResponse result) { @@ -2826,16 +2738,13 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - PlatformProductType productTypeArg = - PlatformProductType.values()[(int) args.get(0)]; + PlatformProductType productTypeArg = PlatformProductType.values()[(int) args.get(0)]; Result resultCallback = new Result() { public void success(PlatformPurchaseHistoryResponse result) { @@ -2858,9 +2767,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2889,9 +2796,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2901,7 +2806,8 @@ public void error(Throwable error) { try { Boolean output = api.isFeatureSupported(featureArg); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2914,9 +2820,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2943,9 +2847,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2972,17 +2874,14 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); Result resultCallback = new Result() { - public void success( - PlatformAlternativeBillingOnlyReportingDetailsResponse result) { + public void success(PlatformAlternativeBillingOnlyReportingDetailsResponse result) { wrapped.add(0, result); reply.reply(wrapped); } @@ -3003,8 +2902,7 @@ public void error(Throwable error) { } private static class InAppPurchaseCallbackApiCodec extends StandardMessageCodec { - public static final InAppPurchaseCallbackApiCodec INSTANCE = - new InAppPurchaseCallbackApiCodec(); + public static final InAppPurchaseCallbackApiCodec INSTANCE = new InAppPurchaseCallbackApiCodec(); private InAppPurchaseCallbackApiCodec() {} @@ -3062,87 +2960,72 @@ public InAppPurchaseCallbackApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ /** The codec used by InAppPurchaseCallbackApi. */ static @NonNull MessageCodec getCodec() { return InAppPurchaseCallbackApiCodec.INSTANCE; } /** Called for BillingClientStateListener#onBillingServiceDisconnected(). */ - public void onBillingServiceDisconnected( - @NonNull Long callbackHandleArg, @NonNull VoidResult result) { - final String channelName = - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected"; + public void onBillingServiceDisconnected(@NonNull Long callbackHandleArg, @NonNull VoidResult result) { + final String channelName = "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected"; BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>( + binaryMessenger, channelName, getCodec()); channel.send( new ArrayList(Collections.singletonList(callbackHandleArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error( - new FlutterError( - (String) listReply.get(0), - (String) listReply.get(1), - (String) listReply.get(2))); + result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), (String) listReply.get(2))); } else { result.success(); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } /** Called for PurchasesUpdatedListener#onPurchasesUpdated(BillingResult, List). */ - public void onPurchasesUpdated( - @NonNull PlatformPurchasesResponse updateArg, @NonNull VoidResult result) { - final String channelName = - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated"; + public void onPurchasesUpdated(@NonNull PlatformPurchasesResponse updateArg, @NonNull VoidResult result) { + final String channelName = "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated"; BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>( + binaryMessenger, channelName, getCodec()); channel.send( new ArrayList(Collections.singletonList(updateArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error( - new FlutterError( - (String) listReply.get(0), - (String) listReply.get(1), - (String) listReply.get(2))); + result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), (String) listReply.get(2))); } else { result.success(); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } /** Called for UserChoiceBillingListener#userSelectedAlternativeBilling(UserChoiceDetails). */ - public void userSelectedalternativeBilling( - @NonNull PlatformUserChoiceDetails detailsArg, @NonNull VoidResult result) { - final String channelName = - "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling"; + public void userSelectedalternativeBilling(@NonNull PlatformUserChoiceDetails detailsArg, @NonNull VoidResult result) { + final String channelName = "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling"; BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>( + binaryMessenger, channelName, getCodec()); channel.send( new ArrayList(Collections.singletonList(detailsArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error( - new FlutterError( - (String) listReply.get(0), - (String) listReply.get(1), - (String) listReply.get(2))); + result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), (String) listReply.get(2))); } else { result.success(); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } } diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java index 11ea6da2195..08a794f5f67 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java @@ -18,9 +18,11 @@ import android.content.Context; import android.os.Bundle; import android.util.Log; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; + import com.android.billingclient.api.AcknowledgePurchaseParams; import com.android.billingclient.api.BillingClient; import com.android.billingclient.api.BillingClientStateListener; @@ -33,6 +35,7 @@ import com.android.billingclient.api.QueryProductDetailsParams; import com.android.billingclient.api.QueryPurchaseHistoryParams; import com.android.billingclient.api.QueryPurchasesParams; + import io.flutter.plugins.inapppurchase.Messages.FlutterError; import io.flutter.plugins.inapppurchase.Messages.InAppPurchaseApi; import io.flutter.plugins.inapppurchase.Messages.InAppPurchaseCallbackApi; @@ -45,6 +48,7 @@ import io.flutter.plugins.inapppurchase.Messages.PlatformPurchasesResponse; import io.flutter.plugins.inapppurchase.Messages.PlatformQueryProduct; import io.flutter.plugins.inapppurchase.Messages.Result; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -60,6 +64,11 @@ class MethodCallHandlerImpl implements Application.ActivityLifecycleCallbacks, I com.android.billingclient.api.BillingFlowParams.ProrationMode .UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY; + @VisibleForTesting + static final int REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = + com.android.billingclient.api.BillingFlowParams.SubscriptionUpdateParams.ReplacementMode + .UNKNOWN_REPLACEMENT_MODE; + private static final String TAG = "InAppPurchasePlugin"; private static final String LOAD_PRODUCT_DOC_URL = "https://github.com/flutter/packages/blob/main/packages/in_app_purchase/in_app_purchase/README.md#loading-products-for-sale"; @@ -285,9 +294,20 @@ public void queryProductDetailsAsync( } } + if (params.getProrationMode() != PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY + && params.getReplacementMode() + != REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) { + throw new FlutterError( + "IN_APP_PURCHASE_CONFLICT_PRORATION_MODE_REPLACEMENT_MODE", + "launchBillingFlow failed because you provided both prorationMode and replacementMode. You can only provide one of them.", + null); + } + if (params.getOldProduct() == null - && params.getProrationMode() - != PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) { + && (params.getProrationMode() + != PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY + || params.getReplacementMode() + != REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY)) { throw new FlutterError( "IN_APP_PURCHASE_REQUIRE_OLD_PRODUCT", "launchBillingFlow failed because oldProduct is null. You must provide a valid oldProduct in order to use a proration mode.", @@ -336,9 +356,16 @@ public void queryProductDetailsAsync( && !params.getOldProduct().isEmpty() && params.getPurchaseToken() != null) { subscriptionUpdateParamsBuilder.setOldPurchaseToken(params.getPurchaseToken()); - // Set the prorationMode using a helper to minimize impact of deprecation warning suppression. - setReplaceProrationMode( - subscriptionUpdateParamsBuilder, params.getProrationMode().intValue()); + if (params.getProrationMode() + != PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) { + setReplaceProrationMode( + subscriptionUpdateParamsBuilder, params.getProrationMode().intValue()); + } + if (params.getReplacementMode() + != REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + params.getReplacementMode().intValue()); + } paramsBuilder.setSubscriptionUpdateParams(subscriptionUpdateParamsBuilder.build()); } return fromBillingResult(billingClient.launchBillingFlow(activity, paramsBuilder.build())); @@ -385,7 +412,8 @@ public void queryPurchasesAsync( } try { - // Like in our connect call, consider the billing client responding a "success" here regardless + // Like in our connect call, consider the billing client responding a "success" here + // regardless // of status code. QueryPurchasesParams.Builder paramsBuilder = QueryPurchasesParams.newBuilder(); paramsBuilder.setProductType(toProductTypeString(productType)); diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java b/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java index ca428910868..210981c5bb2 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java @@ -6,6 +6,7 @@ import static io.flutter.plugins.inapppurchase.MethodCallHandlerImpl.ACTIVITY_UNAVAILABLE; import static io.flutter.plugins.inapppurchase.MethodCallHandlerImpl.PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY; +import static io.flutter.plugins.inapppurchase.MethodCallHandlerImpl.REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableList; @@ -28,6 +29,7 @@ import android.app.Activity; import android.content.Context; + import com.android.billingclient.api.AcknowledgePurchaseParams; import com.android.billingclient.api.AcknowledgePurchaseResponseListener; import com.android.billingclient.api.AlternativeBillingOnlyAvailabilityListener; @@ -53,6 +55,7 @@ import com.android.billingclient.api.QueryProductDetailsParams; import com.android.billingclient.api.QueryPurchaseHistoryParams; import com.android.billingclient.api.QueryPurchasesParams; + import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; import io.flutter.plugins.inapppurchase.Messages.FlutterError; import io.flutter.plugins.inapppurchase.Messages.InAppPurchaseCallbackApi; @@ -66,12 +69,14 @@ import io.flutter.plugins.inapppurchase.Messages.PlatformPurchaseHistoryResponse; import io.flutter.plugins.inapppurchase.Messages.PlatformPurchasesResponse; import io.flutter.plugins.inapppurchase.Messages.PlatformQueryProduct; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -556,6 +561,8 @@ public void launchBillingFlow_null_AccountId_do_not_crash() { paramsBuilder.setProduct(productId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -581,6 +588,8 @@ public void launchBillingFlow_ok_null_OldProduct() { paramsBuilder.setAccountId(accountId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -610,6 +619,8 @@ public void launchBillingFlow_ok_null_Activity() { paramsBuilder.setAccountId(accountId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Assert that the synchronous call throws an exception. FlutterError exception = @@ -633,6 +644,8 @@ public void launchBillingFlow_ok_oldProduct() { paramsBuilder.setOldProduct(oldProductId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -660,6 +673,8 @@ public void launchBillingFlow_ok_AccountId() { paramsBuilder.setAccountId(accountId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -695,6 +710,8 @@ public void launchBillingFlow_ok_Proration() { paramsBuilder.setOldProduct(oldProductId); paramsBuilder.setPurchaseToken(purchaseToken); paramsBuilder.setProrationMode((long) prorationMode); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -728,6 +745,8 @@ public void launchBillingFlow_ok_Proration_with_null_OldProduct() { paramsBuilder.setAccountId(accountId); paramsBuilder.setOldProduct(null); paramsBuilder.setProrationMode((long) prorationMode); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -744,6 +763,73 @@ public void launchBillingFlow_ok_Proration_with_null_OldProduct() { .contains("launchBillingFlow failed because oldProduct is null")); } + @Test + @SuppressWarnings(value = "deprecation") + public void launchBillingFlow_ok_Replacement_with_null_OldProduct() { + // Fetch the product details first and query the method call + String productId = "foo"; + String accountId = "account"; + String queryOldProductId = "oldFoo"; + int replacementMode = + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE; + queryForProducts(unmodifiableList(asList(productId, queryOldProductId))); + PlatformBillingFlowParams.Builder paramsBuilder = new PlatformBillingFlowParams.Builder(); + paramsBuilder.setProduct(productId); + paramsBuilder.setAccountId(accountId); + paramsBuilder.setOldProduct(null); + paramsBuilder.setProrationMode( + (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode((long) replacementMode); + + // Launch the billing flow + BillingResult billingResult = buildBillingResult(); + when(mockBillingClient.launchBillingFlow(any(), any())).thenReturn(billingResult); + + // Assert that the synchronous call throws an exception. + FlutterError exception = + assertThrows( + FlutterError.class, + () -> methodChannelHandler.launchBillingFlow(paramsBuilder.build())); + assertEquals("IN_APP_PURCHASE_REQUIRE_OLD_PRODUCT", exception.code); + assertTrue( + Objects.requireNonNull(exception.getMessage()) + .contains("launchBillingFlow failed because oldProduct is null")); + } + + @Test + @SuppressWarnings(value = "deprecation") + public void launchBillingFlow_ok_Proration_and_Replacement_conflict() { + // Fetch the product details first and query the method call + String productId = "foo"; + String accountId = "account"; + String queryOldProductId = "oldFoo"; + int prorationMode = BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE; + int replacementMode = + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE; + queryForProducts(unmodifiableList(asList(productId, queryOldProductId))); + PlatformBillingFlowParams.Builder paramsBuilder = new PlatformBillingFlowParams.Builder(); + paramsBuilder.setProduct(productId); + paramsBuilder.setAccountId(accountId); + paramsBuilder.setOldProduct(queryOldProductId); + paramsBuilder.setProrationMode((long) prorationMode); + paramsBuilder.setReplacementMode((long) replacementMode); + + // Launch the billing flow + BillingResult billingResult = buildBillingResult(); + when(mockBillingClient.launchBillingFlow(any(), any())).thenReturn(billingResult); + + // Assert that the synchronous call throws an exception. + FlutterError exception = + assertThrows( + FlutterError.class, + () -> methodChannelHandler.launchBillingFlow(paramsBuilder.build())); + assertEquals("IN_APP_PURCHASE_CONFLICT_PRORATION_MODE_REPLACEMENT_MODE", exception.code); + assertTrue( + Objects.requireNonNull(exception.getMessage()) + .contains( + "launchBillingFlow failed because you provided both prorationMode and replacementMode. You can only provide one of them.")); + } + // TODO(gmackall): Replace uses of deprecated ProrationMode enum values with new // ReplacementMode enum values. // https://github.com/flutter/flutter/issues/128957. @@ -763,6 +849,8 @@ public void launchBillingFlow_ok_Full() { paramsBuilder.setOldProduct(oldProductId); paramsBuilder.setPurchaseToken(purchaseToken); paramsBuilder.setProrationMode((long) prorationMode); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Launch the billing flow BillingResult billingResult = buildBillingResult(); @@ -790,6 +878,8 @@ public void launchBillingFlow_clientDisconnected() { paramsBuilder.setAccountId(accountId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Assert that the synchronous call throws an exception. FlutterError exception = @@ -811,6 +901,8 @@ public void launchBillingFlow_productNotFound() { paramsBuilder.setAccountId(accountId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Assert that the synchronous call throws an exception. FlutterError exception = @@ -835,6 +927,8 @@ public void launchBillingFlow_oldProductNotFound() { paramsBuilder.setOldProduct(oldProductId); paramsBuilder.setProrationMode( (long) PRORATION_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); + paramsBuilder.setReplacementMode( + (long) REPLACEMENT_MODE_UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY); // Assert that the synchronous call throws an exception. FlutterError exception = diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.dart index b9417c6b25e..3f7bd499bbf 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.dart @@ -190,7 +190,8 @@ class BillingClient { String? obfuscatedProfileId, String? oldProduct, String? purchaseToken, - ProrationMode? prorationMode}) async { + ProrationMode? prorationMode, + ReplacementMode? replacementMode}) async { assert((oldProduct == null) == (purchaseToken == null), 'oldProduct and purchaseToken must both be set, or both be null.'); return resultWrapperFromPlatform( @@ -198,6 +199,8 @@ class BillingClient { product: product, prorationMode: const ProrationModeConverter().toJson(prorationMode ?? ProrationMode.unknownSubscriptionUpgradeDowngradePolicy), + replacementMode: const ReplacementModeConverter() + .toJson(replacementMode ?? ReplacementMode.unknownReplacementMode), offerToken: offerToken, accountId: accountId, obfuscatedProfileId: obfuscatedProfileId, @@ -622,6 +625,76 @@ class ProrationModeConverter implements JsonConverter { int toJson(ProrationMode object) => _$ProrationModeEnumMap[object]!; } +/// Enum representing the replacement mode. +/// +/// When upgrading or downgrading a subscription, set this mode to provide details +/// about the replacement that will be applied when the subscription changes. +/// +/// Wraps [`BillingFlowParams.SubscriptionUpdateParams.ReplacementMode`](https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.SubscriptionUpdateParams.ReplacementMode) +/// See the linked documentation for an explanation of the different constants. +@JsonEnum(alwaysCreate: true) +enum ReplacementMode { +// WARNING: Changes to this class need to be reflected in our generated code. +// Run `flutter packages pub run build_runner watch` to rebuild and watch for +// further changes. + + /// Unknown upgrade or downgrade policy. + @JsonValue(0) + unknownReplacementMode, + + /// Replacement takes effect immediately, and the remaining time will be prorated + /// and credited to the user. + /// + /// This is the current default behavior. + @JsonValue(1) + withTimeProration, + + /// Replacement takes effect immediately, and the billing cycle remains the same. + /// + /// The price for the remaining period will be charged. + /// This option is only available for subscription upgrade. + @JsonValue(2) + chargeProratedPrice, + + /// Replacement takes effect immediately, and the new price will be charged on next + /// recurrence time. + /// + /// The billing cycle stays the same. + @JsonValue(3) + withoutProration, + + /// Replacement takes effect when the old plan expires, and the new price will + /// be charged at the same time. + @JsonValue(6) + deferred, + + /// Replacement takes effect immediately, and the user is charged full price + /// of new plan and is given a full billing cycle of subscription, plus + /// remaining prorated time from the old plan. + @JsonValue(5) + chargeFullPrice, +} + +/// Serializer for [ReplacementMode]. +/// +/// Use these in `@JsonSerializable()` classes by annotating them with +/// `@ReplacementModeConverter()`. +class ReplacementModeConverter implements JsonConverter { + /// Default const constructor. + const ReplacementModeConverter(); + + @override + ReplacementMode fromJson(int? json) { + if (json == null) { + return ReplacementMode.unknownReplacementMode; + } + return $enumDecode(_$ReplacementModeEnumMap, json); + } + + @override + int toJson(ReplacementMode object) => _$ReplacementModeEnumMap[object]!; +} + /// Features/capabilities supported by [BillingClient.isFeatureSupported()](https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType). @JsonEnum(alwaysCreate: true) enum BillingClientFeature { diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.g.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.g.dart index 0768c35deec..eb0033193d9 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.g.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.g.dart @@ -42,6 +42,15 @@ const _$ProrationModeEnumMap = { ProrationMode.immediateAndChargeFullPrice: 5, }; +const _$ReplacementModeEnumMap = { + ReplacementMode.unknownReplacementMode: 0, + ReplacementMode.withTimeProration: 1, + ReplacementMode.chargeProratedPrice: 2, + ReplacementMode.withoutProration: 3, + ReplacementMode.deferred: 6, + ReplacementMode.chargeFullPrice: 5, +}; + const _$BillingClientFeatureEnumMap = { BillingClientFeature.inAppItemsOnVR: 'inAppItemsOnVr', BillingClientFeature.priceChangeConfirmation: 'priceChangeConfirmation', diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart index 9663aa414d5..92fca72efce 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart @@ -161,7 +161,8 @@ class InAppPurchaseAndroidPlatform extends InAppPurchasePlatform { oldProduct: changeSubscriptionParam?.oldPurchaseDetails.productID, purchaseToken: changeSubscriptionParam ?.oldPurchaseDetails.verificationData.serverVerificationData, - prorationMode: changeSubscriptionParam?.prorationMode), + prorationMode: changeSubscriptionParam?.prorationMode, + replacementMode: changeSubscriptionParam?.replacementMode), ); return billingResultWrapper.responseCode == BillingResponse.ok; } diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart index 1b5753f8006..d66806017e5 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v17.1.2), do not edit directly. +// Autogenerated from Pigeon (v17.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -18,8 +18,7 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse( - {Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -41,10 +40,8 @@ enum PlatformBillingChoiceMode { /// /// Default state. playBillingOnly, - /// Billing through app provided flow. alternativeBillingOnly, - /// Users can choose Play billing or alternative billing. userChoiceBilling, } @@ -223,11 +220,9 @@ class PlatformProductDetails { productType: PlatformProductType.values[result[3]! as int], title: result[4]! as String, oneTimePurchaseOfferDetails: result[5] != null - ? PlatformOneTimePurchaseOfferDetails.decode( - result[5]! as List) + ? PlatformOneTimePurchaseOfferDetails.decode(result[5]! as List) : null, - subscriptionOfferDetails: (result[6] as List?) - ?.cast(), + subscriptionOfferDetails: (result[6] as List?)?.cast(), ); } } @@ -255,8 +250,7 @@ class PlatformProductDetailsResponse { result as List; return PlatformProductDetailsResponse( billingResult: PlatformBillingResult.decode(result[0]! as List), - productDetails: - (result[1] as List?)!.cast(), + productDetails: (result[1] as List?)!.cast(), ); } } @@ -281,8 +275,7 @@ class PlatformAlternativeBillingOnlyReportingDetailsResponse { ]; } - static PlatformAlternativeBillingOnlyReportingDetailsResponse decode( - Object result) { + static PlatformAlternativeBillingOnlyReportingDetailsResponse decode(Object result) { result as List; return PlatformAlternativeBillingOnlyReportingDetailsResponse( billingResult: PlatformBillingResult.decode(result[0]! as List), @@ -324,6 +317,7 @@ class PlatformBillingFlowParams { PlatformBillingFlowParams({ required this.product, required this.prorationMode, + required this.replacementMode, this.offerToken, this.accountId, this.obfuscatedProfileId, @@ -335,6 +329,8 @@ class PlatformBillingFlowParams { int prorationMode; + int replacementMode; + String? offerToken; String? accountId; @@ -349,6 +345,7 @@ class PlatformBillingFlowParams { return [ product, prorationMode, + replacementMode, offerToken, accountId, obfuscatedProfileId, @@ -362,11 +359,12 @@ class PlatformBillingFlowParams { return PlatformBillingFlowParams( product: result[0]! as String, prorationMode: result[1]! as int, - offerToken: result[2] as String?, - accountId: result[3] as String?, - obfuscatedProfileId: result[4] as String?, - oldProduct: result[5] as String?, - purchaseToken: result[6] as String?, + replacementMode: result[2]! as int, + offerToken: result[3] as String?, + accountId: result[4] as String?, + obfuscatedProfileId: result[5] as String?, + oldProduct: result[6] as String?, + purchaseToken: result[7] as String?, ); } } @@ -581,8 +579,7 @@ class PlatformPurchaseHistoryResponse { result as List; return PlatformPurchaseHistoryResponse( billingResult: PlatformBillingResult.decode(result[0]! as List), - purchases: - (result[1] as List?)!.cast(), + purchases: (result[1] as List?)!.cast(), ); } } @@ -652,8 +649,7 @@ class PlatformSubscriptionOfferDetails { offerId: result[1] as String?, offerToken: result[2]! as String, offerTags: (result[3] as List?)!.cast(), - pricingPhases: - (result[4] as List?)!.cast(), + pricingPhases: (result[4] as List?)!.cast(), ); } } @@ -685,8 +681,7 @@ class PlatformUserChoiceDetails { return PlatformUserChoiceDetails( originalExternalTransactionId: result[0] as String?, externalTransactionToken: result[1]! as String, - products: - (result[2] as List?)!.cast(), + products: (result[2] as List?)!.cast(), ); } } @@ -730,8 +725,7 @@ class _InAppPurchaseApiCodec extends StandardMessageCodec { if (value is PlatformAccountIdentifiers) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value - is PlatformAlternativeBillingOnlyReportingDetailsResponse) { + } else if (value is PlatformAlternativeBillingOnlyReportingDetailsResponse) { buffer.putUint8(129); writeValue(buffer, value.encode()); } else if (value is PlatformBillingConfigResponse) { @@ -781,36 +775,35 @@ class _InAppPurchaseApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return PlatformAccountIdentifiers.decode(readValue(buffer)!); - case 129: - return PlatformAlternativeBillingOnlyReportingDetailsResponse.decode( - readValue(buffer)!); - case 130: + case 129: + return PlatformAlternativeBillingOnlyReportingDetailsResponse.decode(readValue(buffer)!); + case 130: return PlatformBillingConfigResponse.decode(readValue(buffer)!); - case 131: + case 131: return PlatformBillingFlowParams.decode(readValue(buffer)!); - case 132: + case 132: return PlatformBillingResult.decode(readValue(buffer)!); - case 133: + case 133: return PlatformOneTimePurchaseOfferDetails.decode(readValue(buffer)!); - case 134: + case 134: return PlatformPricingPhase.decode(readValue(buffer)!); - case 135: + case 135: return PlatformProductDetails.decode(readValue(buffer)!); - case 136: + case 136: return PlatformProductDetailsResponse.decode(readValue(buffer)!); - case 137: + case 137: return PlatformPurchase.decode(readValue(buffer)!); - case 138: + case 138: return PlatformPurchaseHistoryRecord.decode(readValue(buffer)!); - case 139: + case 139: return PlatformPurchaseHistoryResponse.decode(readValue(buffer)!); - case 140: + case 140: return PlatformPurchasesResponse.decode(readValue(buffer)!); - case 141: + case 141: return PlatformQueryProduct.decode(readValue(buffer)!); - case 142: + case 142: return PlatformSubscriptionOfferDetails.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -826,15 +819,12 @@ class InAppPurchaseApi { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = - _InAppPurchaseApiCodec(); + static const MessageCodec pigeonChannelCodec = _InAppPurchaseApiCodec(); /// Wraps BillingClient#isReady. Future isReady() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -860,18 +850,15 @@ class InAppPurchaseApi { } /// Wraps BillingClient#startConnection(BillingClientStateListener). - Future startConnection( - int callbackHandle, PlatformBillingChoiceMode billingMode) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future startConnection(int callbackHandle, PlatformBillingChoiceMode billingMode) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([callbackHandle, billingMode.index]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([callbackHandle, billingMode.index]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -892,10 +879,8 @@ class InAppPurchaseApi { /// Wraps BillingClient#endConnection(BillingClientStateListener). Future endConnection() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -917,10 +902,8 @@ class InAppPurchaseApi { /// Wraps BillingClient#getBillingConfigAsync(GetBillingConfigParams, BillingConfigResponseListener). Future getBillingConfigAsync() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -946,12 +929,9 @@ class InAppPurchaseApi { } /// Wraps BillingClient#launchBillingFlow(Activity, BillingFlowParams). - Future launchBillingFlow( - PlatformBillingFlowParams params) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future launchBillingFlow(PlatformBillingFlowParams params) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -977,12 +957,9 @@ class InAppPurchaseApi { } /// Wraps BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, AcknowledgePurchaseResponseListener). - Future acknowledgePurchase( - String purchaseToken) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future acknowledgePurchase(String purchaseToken) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1009,10 +986,8 @@ class InAppPurchaseApi { /// Wraps BillingClient#consumeAsync(ConsumeParams, ConsumeResponseListener). Future consumeAsync(String purchaseToken) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1038,18 +1013,15 @@ class InAppPurchaseApi { } /// Wraps BillingClient#queryPurchasesAsync(QueryPurchaseParams, PurchaseResponseListener). - Future queryPurchasesAsync( - PlatformProductType productType) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future queryPurchasesAsync(PlatformProductType productType) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([productType.index]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([productType.index]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1069,18 +1041,15 @@ class InAppPurchaseApi { } /// Wraps BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, PurchaseHistoryResponseListener). - Future queryPurchaseHistoryAsync( - PlatformProductType productType) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future queryPurchaseHistoryAsync(PlatformProductType productType) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([productType.index]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([productType.index]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1100,12 +1069,9 @@ class InAppPurchaseApi { } /// Wraps BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, ProductDetailsResponseListener). - Future queryProductDetailsAsync( - List products) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future queryProductDetailsAsync(List products) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1132,10 +1098,8 @@ class InAppPurchaseApi { /// Wraps BillingClient#isFeatureSupported(String). Future isFeatureSupported(String feature) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1162,10 +1126,8 @@ class InAppPurchaseApi { /// Wraps BillingClient#isAlternativeBillingOnlyAvailableAsync(). Future isAlternativeBillingOnlyAvailableAsync() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1191,12 +1153,9 @@ class InAppPurchaseApi { } /// Wraps BillingClient#showAlternativeBillingOnlyInformationDialog(). - Future - showAlternativeBillingOnlyInformationDialog() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future showAlternativeBillingOnlyInformationDialog() async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1222,12 +1181,9 @@ class InAppPurchaseApi { } /// Wraps BillingClient#createAlternativeBillingOnlyReportingDetailsAsync(AlternativeBillingOnlyReportingDetailsListener). - Future - createAlternativeBillingOnlyReportingDetailsAsync() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future createAlternativeBillingOnlyReportingDetailsAsync() async { + const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1248,8 +1204,7 @@ class InAppPurchaseApi { message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] - as PlatformAlternativeBillingOnlyReportingDetailsResponse?)!; + return (__pigeon_replyList[0] as PlatformAlternativeBillingOnlyReportingDetailsResponse?)!; } } } @@ -1284,17 +1239,17 @@ class _InAppPurchaseCallbackApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return PlatformAccountIdentifiers.decode(readValue(buffer)!); - case 129: + case 129: return PlatformBillingResult.decode(readValue(buffer)!); - case 130: + case 130: return PlatformPurchase.decode(readValue(buffer)!); - case 131: + case 131: return PlatformPurchasesResponse.decode(readValue(buffer)!); - case 132: + case 132: return PlatformUserChoiceDetails.decode(readValue(buffer)!); - case 133: + case 133: return PlatformUserChoiceProduct.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1303,8 +1258,7 @@ class _InAppPurchaseCallbackApiCodec extends StandardMessageCodec { } abstract class InAppPurchaseCallbackApi { - static const MessageCodec pigeonChannelCodec = - _InAppPurchaseCallbackApiCodec(); + static const MessageCodec pigeonChannelCodec = _InAppPurchaseCallbackApiCodec(); /// Called for BillingClientStateListener#onBillingServiceDisconnected(). void onBillingServiceDisconnected(int callbackHandle); @@ -1315,20 +1269,17 @@ abstract class InAppPurchaseCallbackApi { /// Called for UserChoiceBillingListener#userSelectedAlternativeBilling(UserChoiceDetails). void userSelectedalternativeBilling(PlatformUserChoiceDetails details); - static void setup(InAppPurchaseCallbackApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(InAppPurchaseCallbackApi? api, {BinaryMessenger? binaryMessenger}) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected was null.'); final List args = (message as List?)!; final int? arg_callbackHandle = (args[0] as int?); assert(arg_callbackHandle != null, @@ -1338,28 +1289,24 @@ abstract class InAppPurchaseCallbackApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated was null.'); final List args = (message as List?)!; - final PlatformPurchasesResponse? arg_update = - (args[0] as PlatformPurchasesResponse?); + final PlatformPurchasesResponse? arg_update = (args[0] as PlatformPurchasesResponse?); assert(arg_update != null, 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated was null, expected non-null PlatformPurchasesResponse.'); try { @@ -1367,28 +1314,24 @@ abstract class InAppPurchaseCallbackApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling was null.'); final List args = (message as List?)!; - final PlatformUserChoiceDetails? arg_details = - (args[0] as PlatformUserChoiceDetails?); + final PlatformUserChoiceDetails? arg_details = (args[0] as PlatformUserChoiceDetails?); assert(arg_details != null, 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling was null, expected non-null PlatformUserChoiceDetails.'); try { @@ -1396,9 +1339,8 @@ abstract class InAppPurchaseCallbackApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/types/change_subscription_param.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/types/change_subscription_param.dart index 1099da3bf15..f76fc3e9005 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/types/change_subscription_param.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/types/change_subscription_param.dart @@ -10,7 +10,8 @@ class ChangeSubscriptionParam { /// Creates a new change subscription param object with given data ChangeSubscriptionParam({ required this.oldPurchaseDetails, - this.prorationMode, + @Deprecated('Use replacementMode instead') this.prorationMode, + this.replacementMode, }); /// The purchase object of the existing subscription that the user needs to @@ -21,5 +22,12 @@ class ChangeSubscriptionParam { /// /// This is an optional parameter that indicates how to handle the existing /// subscription when the new subscription comes into effect. + @Deprecated('Use replacementMode instead') final ProrationMode? prorationMode; + + /// The replacement mode. + /// + /// This is an optional parameter that indicates how to handle the existing + /// subscription when the new subscription comes into effect. + final ReplacementMode? replacementMode; } diff --git a/packages/in_app_purchase/in_app_purchase_android/pigeons/messages.dart b/packages/in_app_purchase/in_app_purchase_android/pigeons/messages.dart index 2921c0907ca..d0bbc51e973 100644 --- a/packages/in_app_purchase/in_app_purchase_android/pigeons/messages.dart +++ b/packages/in_app_purchase/in_app_purchase_android/pigeons/messages.dart @@ -118,6 +118,7 @@ class PlatformBillingFlowParams { PlatformBillingFlowParams({ required this.product, required this.prorationMode, + required this.replacementMode, required this.offerToken, required this.accountId, required this.obfuscatedProfileId, @@ -130,6 +131,7 @@ class PlatformBillingFlowParams { // to constants on the Java side, but it's deprecated anyway so that will be // resolved during the update to the new API. final int prorationMode; + final int replacementMode; final String? offerToken; final String? accountId; final String? obfuscatedProfileId; From 24d12b0e34a550d683ca65c225824640f66c27b5 Mon Sep 17 00:00:00 2001 From: Adam Vongrej Date: Sun, 14 Apr 2024 15:32:44 +0200 Subject: [PATCH 2/4] Bump version to 0.3.4 --- packages/in_app_purchase/in_app_purchase_android/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml index 4d5f491d3fa..b4ba2b2380d 100644 --- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase_android description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 0.3.3+1 +version: 0.3.4 environment: sdk: ^3.1.0 From 993b624b6db9b03fa2fe08c15956ed35bd140963 Mon Sep 17 00:00:00 2001 From: Adam Vongrej Date: Sun, 14 Apr 2024 17:43:21 +0200 Subject: [PATCH 3/4] Fixed code formatting --- .../plugins/inapppurchase/Messages.java | 415 ++++++++++++------ .../inapppurchase/MethodCallHandlerImpl.java | 4 - .../inapppurchase/MethodCallHandlerTest.java | 4 - .../lib/src/messages.g.dart | 251 +++++++---- 4 files changed, 438 insertions(+), 236 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java index ab8e97c3b66..0602260e72f 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/Messages.java @@ -21,11 +21,8 @@ import java.lang.annotation.Target; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) @@ -40,8 +37,7 @@ public static class FlutterError extends RuntimeException { /** The error details. Must be a datatype supported by the api codec. */ public final Object details; - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) - { + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { super(message); this.code = code; this.details = details; @@ -60,14 +56,15 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { errorList.add(exception.toString()); errorList.add(exception.getClass().getSimpleName()); errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); } return errorList; } @NonNull protected static FlutterError createConnectionError(@NonNull String channelName) { - return new FlutterError("channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); + return new FlutterError( + "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); } @Target(METHOD) @@ -91,7 +88,7 @@ public enum PlatformBillingChoiceMode { /** * Billing through google play. * - * Default state. + *

Default state. */ PLAY_BILLING_ONLY(0), /** Billing through app provided flow. */ @@ -135,7 +132,7 @@ private PlatformRecurrenceMode(final int index) { /** * Pigeon version of Java QueryProductDetailsParams.Product. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformQueryProduct { private @NonNull String productId; @@ -214,7 +211,7 @@ ArrayList toList() { /** * Pigeon version of Java AccountIdentifiers. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformAccountIdentifiers { private @Nullable String obfuscatedAccountId; @@ -284,7 +281,7 @@ ArrayList toList() { /** * Pigeon version of Java BillingResult. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformBillingResult { private @NonNull Long responseCode; @@ -353,7 +350,10 @@ ArrayList toList() { static @NonNull PlatformBillingResult fromList(@NonNull ArrayList list) { PlatformBillingResult pigeonResult = new PlatformBillingResult(); Object responseCode = list.get(0); - pigeonResult.setResponseCode((responseCode == null) ? null : ((responseCode instanceof Integer) ? (Integer) responseCode : (Long) responseCode)); + pigeonResult.setResponseCode( + (responseCode == null) + ? null + : ((responseCode instanceof Integer) ? (Integer) responseCode : (Long) responseCode)); Object debugMessage = list.get(1); pigeonResult.setDebugMessage((String) debugMessage); return pigeonResult; @@ -363,7 +363,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails.OneTimePurchaseOfferDetails. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformOneTimePurchaseOfferDetails { private @NonNull Long priceAmountMicros; @@ -435,7 +435,8 @@ public static final class Builder { } public @NonNull PlatformOneTimePurchaseOfferDetails build() { - PlatformOneTimePurchaseOfferDetails pigeonReturn = new PlatformOneTimePurchaseOfferDetails(); + PlatformOneTimePurchaseOfferDetails pigeonReturn = + new PlatformOneTimePurchaseOfferDetails(); pigeonReturn.setPriceAmountMicros(priceAmountMicros); pigeonReturn.setFormattedPrice(formattedPrice); pigeonReturn.setPriceCurrencyCode(priceCurrencyCode); @@ -455,7 +456,12 @@ ArrayList toList() { static @NonNull PlatformOneTimePurchaseOfferDetails fromList(@NonNull ArrayList list) { PlatformOneTimePurchaseOfferDetails pigeonResult = new PlatformOneTimePurchaseOfferDetails(); Object priceAmountMicros = list.get(0); - pigeonResult.setPriceAmountMicros((priceAmountMicros == null) ? null : ((priceAmountMicros instanceof Integer) ? (Integer) priceAmountMicros : (Long) priceAmountMicros)); + pigeonResult.setPriceAmountMicros( + (priceAmountMicros == null) + ? null + : ((priceAmountMicros instanceof Integer) + ? (Integer) priceAmountMicros + : (Long) priceAmountMicros)); Object formattedPrice = list.get(1); pigeonResult.setFormattedPrice((String) formattedPrice); Object priceCurrencyCode = list.get(2); @@ -467,7 +473,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformProductDetails { private @NonNull String description; @@ -541,7 +547,8 @@ public void setTitle(@NonNull String setterArg) { return oneTimePurchaseOfferDetails; } - public void setOneTimePurchaseOfferDetails(@Nullable PlatformOneTimePurchaseOfferDetails setterArg) { + public void setOneTimePurchaseOfferDetails( + @Nullable PlatformOneTimePurchaseOfferDetails setterArg) { this.oneTimePurchaseOfferDetails = setterArg; } @@ -551,7 +558,8 @@ public void setOneTimePurchaseOfferDetails(@Nullable PlatformOneTimePurchaseOffe return subscriptionOfferDetails; } - public void setSubscriptionOfferDetails(@Nullable List setterArg) { + public void setSubscriptionOfferDetails( + @Nullable List setterArg) { this.subscriptionOfferDetails = setterArg; } @@ -603,7 +611,8 @@ public static final class Builder { private @Nullable PlatformOneTimePurchaseOfferDetails oneTimePurchaseOfferDetails; @CanIgnoreReturnValue - public @NonNull Builder setOneTimePurchaseOfferDetails(@Nullable PlatformOneTimePurchaseOfferDetails setterArg) { + public @NonNull Builder setOneTimePurchaseOfferDetails( + @Nullable PlatformOneTimePurchaseOfferDetails setterArg) { this.oneTimePurchaseOfferDetails = setterArg; return this; } @@ -611,7 +620,8 @@ public static final class Builder { private @Nullable List subscriptionOfferDetails; @CanIgnoreReturnValue - public @NonNull Builder setSubscriptionOfferDetails(@Nullable List setterArg) { + public @NonNull Builder setSubscriptionOfferDetails( + @Nullable List setterArg) { this.subscriptionOfferDetails = setterArg; return this; } @@ -637,7 +647,8 @@ ArrayList toList() { toListResult.add(productId); toListResult.add(productType == null ? null : productType.index); toListResult.add(title); - toListResult.add((oneTimePurchaseOfferDetails == null) ? null : oneTimePurchaseOfferDetails.toList()); + toListResult.add( + (oneTimePurchaseOfferDetails == null) ? null : oneTimePurchaseOfferDetails.toList()); toListResult.add(subscriptionOfferDetails); return toListResult; } @@ -655,18 +666,23 @@ ArrayList toList() { Object title = list.get(4); pigeonResult.setTitle((String) title); Object oneTimePurchaseOfferDetails = list.get(5); - pigeonResult.setOneTimePurchaseOfferDetails((oneTimePurchaseOfferDetails == null) ? null : PlatformOneTimePurchaseOfferDetails.fromList((ArrayList) oneTimePurchaseOfferDetails)); + pigeonResult.setOneTimePurchaseOfferDetails( + (oneTimePurchaseOfferDetails == null) + ? null + : PlatformOneTimePurchaseOfferDetails.fromList( + (ArrayList) oneTimePurchaseOfferDetails)); Object subscriptionOfferDetails = list.get(6); - pigeonResult.setSubscriptionOfferDetails((List) subscriptionOfferDetails); + pigeonResult.setSubscriptionOfferDetails( + (List) subscriptionOfferDetails); return pigeonResult; } } /** - * Pigeon version of ProductDetailsResponseWrapper, which contains the - * components of the Java ProductDetailsResponseListener callback. + * Pigeon version of ProductDetailsResponseWrapper, which contains the components of the Java + * ProductDetailsResponseListener callback. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformProductDetailsResponse { private @NonNull PlatformBillingResult billingResult; @@ -735,7 +751,10 @@ ArrayList toList() { static @NonNull PlatformProductDetailsResponse fromList(@NonNull ArrayList list) { PlatformProductDetailsResponse pigeonResult = new PlatformProductDetailsResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult( + (billingResult == null) + ? null + : PlatformBillingResult.fromList((ArrayList) billingResult)); Object productDetails = list.get(1); pigeonResult.setProductDetails((List) productDetails); return pigeonResult; @@ -743,11 +762,10 @@ ArrayList toList() { } /** - * Pigeon version of AlternativeBillingOnlyReportingDetailsWrapper, which - * contains the components of the Java - * AlternativeBillingOnlyReportingDetailsListener callback. + * Pigeon version of AlternativeBillingOnlyReportingDetailsWrapper, which contains the components + * of the Java AlternativeBillingOnlyReportingDetailsListener callback. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformAlternativeBillingOnlyReportingDetailsResponse { private @NonNull PlatformBillingResult billingResult; @@ -798,7 +816,8 @@ public static final class Builder { } public @NonNull PlatformAlternativeBillingOnlyReportingDetailsResponse build() { - PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonReturn = new PlatformAlternativeBillingOnlyReportingDetailsResponse(); + PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonReturn = + new PlatformAlternativeBillingOnlyReportingDetailsResponse(); pigeonReturn.setBillingResult(billingResult); pigeonReturn.setExternalTransactionToken(externalTransactionToken); return pigeonReturn; @@ -813,10 +832,15 @@ ArrayList toList() { return toListResult; } - static @NonNull PlatformAlternativeBillingOnlyReportingDetailsResponse fromList(@NonNull ArrayList list) { - PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonResult = new PlatformAlternativeBillingOnlyReportingDetailsResponse(); + static @NonNull PlatformAlternativeBillingOnlyReportingDetailsResponse fromList( + @NonNull ArrayList list) { + PlatformAlternativeBillingOnlyReportingDetailsResponse pigeonResult = + new PlatformAlternativeBillingOnlyReportingDetailsResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult( + (billingResult == null) + ? null + : PlatformBillingResult.fromList((ArrayList) billingResult)); Object externalTransactionToken = list.get(1); pigeonResult.setExternalTransactionToken((String) externalTransactionToken); return pigeonResult; @@ -824,10 +848,10 @@ ArrayList toList() { } /** - * Pigeon version of BillingConfigWrapper, which contains the components of the - * Java BillingConfigResponseListener callback. + * Pigeon version of BillingConfigWrapper, which contains the components of the Java + * BillingConfigResponseListener callback. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformBillingConfigResponse { private @NonNull PlatformBillingResult billingResult; @@ -896,7 +920,10 @@ ArrayList toList() { static @NonNull PlatformBillingConfigResponse fromList(@NonNull ArrayList list) { PlatformBillingConfigResponse pigeonResult = new PlatformBillingConfigResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult( + (billingResult == null) + ? null + : PlatformBillingResult.fromList((ArrayList) billingResult)); Object countryCode = list.get(1); pigeonResult.setCountryCode((String) countryCode); return pigeonResult; @@ -906,7 +933,7 @@ ArrayList toList() { /** * Pigeon version of Java BillingFlowParams. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformBillingFlowParams { private @NonNull String product; @@ -1100,9 +1127,19 @@ ArrayList toList() { Object product = list.get(0); pigeonResult.setProduct((String) product); Object prorationMode = list.get(1); - pigeonResult.setProrationMode((prorationMode == null) ? null : ((prorationMode instanceof Integer) ? (Integer) prorationMode : (Long) prorationMode)); + pigeonResult.setProrationMode( + (prorationMode == null) + ? null + : ((prorationMode instanceof Integer) + ? (Integer) prorationMode + : (Long) prorationMode)); Object replacementMode = list.get(2); - pigeonResult.setReplacementMode((replacementMode == null) ? null : ((replacementMode instanceof Integer) ? (Integer) replacementMode : (Long) replacementMode)); + pigeonResult.setReplacementMode( + (replacementMode == null) + ? null + : ((replacementMode instanceof Integer) + ? (Integer) replacementMode + : (Long) replacementMode)); Object offerToken = list.get(3); pigeonResult.setOfferToken((String) offerToken); Object accountId = list.get(4); @@ -1120,7 +1157,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails.PricingPhase. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPricingPhase { private @NonNull Long billingCycleCount; @@ -1281,11 +1318,21 @@ ArrayList toList() { static @NonNull PlatformPricingPhase fromList(@NonNull ArrayList list) { PlatformPricingPhase pigeonResult = new PlatformPricingPhase(); Object billingCycleCount = list.get(0); - pigeonResult.setBillingCycleCount((billingCycleCount == null) ? null : ((billingCycleCount instanceof Integer) ? (Integer) billingCycleCount : (Long) billingCycleCount)); + pigeonResult.setBillingCycleCount( + (billingCycleCount == null) + ? null + : ((billingCycleCount instanceof Integer) + ? (Integer) billingCycleCount + : (Long) billingCycleCount)); Object recurrenceMode = list.get(1); pigeonResult.setRecurrenceMode(PlatformRecurrenceMode.values()[(int) recurrenceMode]); Object priceAmountMicros = list.get(2); - pigeonResult.setPriceAmountMicros((priceAmountMicros == null) ? null : ((priceAmountMicros instanceof Integer) ? (Integer) priceAmountMicros : (Long) priceAmountMicros)); + pigeonResult.setPriceAmountMicros( + (priceAmountMicros == null) + ? null + : ((priceAmountMicros instanceof Integer) + ? (Integer) priceAmountMicros + : (Long) priceAmountMicros)); Object billingPeriod = list.get(3); pigeonResult.setBillingPeriod((String) billingPeriod); Object formattedPrice = list.get(4); @@ -1299,9 +1346,9 @@ ArrayList toList() { /** * Pigeon version of Java Purchase. * - * See also PurchaseWrapper on the Dart side. + *

See also PurchaseWrapper on the Dart side. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchase { private @Nullable String orderId; @@ -1571,7 +1618,8 @@ public static final class Builder { private @Nullable PlatformAccountIdentifiers accountIdentifiers; @CanIgnoreReturnValue - public @NonNull Builder setAccountIdentifiers(@Nullable PlatformAccountIdentifiers setterArg) { + public @NonNull Builder setAccountIdentifiers( + @Nullable PlatformAccountIdentifiers setterArg) { this.accountIdentifiers = setterArg; return this; } @@ -1621,7 +1669,10 @@ ArrayList toList() { Object packageName = list.get(1); pigeonResult.setPackageName((String) packageName); Object purchaseTime = list.get(2); - pigeonResult.setPurchaseTime((purchaseTime == null) ? null : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); + pigeonResult.setPurchaseTime( + (purchaseTime == null) + ? null + : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); Object purchaseToken = list.get(3); pigeonResult.setPurchaseToken((String) purchaseToken); Object signature = list.get(4); @@ -1637,11 +1688,17 @@ ArrayList toList() { Object isAcknowledged = list.get(9); pigeonResult.setIsAcknowledged((Boolean) isAcknowledged); Object quantity = list.get(10); - pigeonResult.setQuantity((quantity == null) ? null : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); + pigeonResult.setQuantity( + (quantity == null) + ? null + : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); Object purchaseState = list.get(11); pigeonResult.setPurchaseState(PlatformPurchaseState.values()[(int) purchaseState]); Object accountIdentifiers = list.get(12); - pigeonResult.setAccountIdentifiers((accountIdentifiers == null) ? null : PlatformAccountIdentifiers.fromList((ArrayList) accountIdentifiers)); + pigeonResult.setAccountIdentifiers( + (accountIdentifiers == null) + ? null + : PlatformAccountIdentifiers.fromList((ArrayList) accountIdentifiers)); return pigeonResult; } } @@ -1649,9 +1706,9 @@ ArrayList toList() { /** * Pigeon version of PurchaseHistoryRecord. * - * See also PurchaseHistoryRecordWrapper on the Dart side. + *

See also PurchaseHistoryRecordWrapper on the Dart side. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchaseHistoryRecord { private @NonNull Long quantity; @@ -1832,9 +1889,15 @@ ArrayList toList() { static @NonNull PlatformPurchaseHistoryRecord fromList(@NonNull ArrayList list) { PlatformPurchaseHistoryRecord pigeonResult = new PlatformPurchaseHistoryRecord(); Object quantity = list.get(0); - pigeonResult.setQuantity((quantity == null) ? null : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); + pigeonResult.setQuantity( + (quantity == null) + ? null + : ((quantity instanceof Integer) ? (Integer) quantity : (Long) quantity)); Object purchaseTime = list.get(1); - pigeonResult.setPurchaseTime((purchaseTime == null) ? null : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); + pigeonResult.setPurchaseTime( + (purchaseTime == null) + ? null + : ((purchaseTime instanceof Integer) ? (Integer) purchaseTime : (Long) purchaseTime)); Object developerPayload = list.get(2); pigeonResult.setDeveloperPayload((String) developerPayload); Object originalJson = list.get(3); @@ -1850,10 +1913,10 @@ ArrayList toList() { } /** - * Pigeon version of PurchasesHistoryResult, which contains the components of - * the Java PurchaseHistoryResponseListener callback. + * Pigeon version of PurchasesHistoryResult, which contains the components of the Java + * PurchaseHistoryResponseListener callback. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchaseHistoryResponse { private @NonNull PlatformBillingResult billingResult; @@ -1922,7 +1985,10 @@ ArrayList toList() { static @NonNull PlatformPurchaseHistoryResponse fromList(@NonNull ArrayList list) { PlatformPurchaseHistoryResponse pigeonResult = new PlatformPurchaseHistoryResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult( + (billingResult == null) + ? null + : PlatformBillingResult.fromList((ArrayList) billingResult)); Object purchases = list.get(1); pigeonResult.setPurchases((List) purchases); return pigeonResult; @@ -1930,10 +1996,10 @@ ArrayList toList() { } /** - * Pigeon version of PurchasesResultWrapper, which contains the components of - * the Java PurchasesResponseListener callback. + * Pigeon version of PurchasesResultWrapper, which contains the components of the Java + * PurchasesResponseListener callback. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformPurchasesResponse { private @NonNull PlatformBillingResult billingResult; @@ -2002,7 +2068,10 @@ ArrayList toList() { static @NonNull PlatformPurchasesResponse fromList(@NonNull ArrayList list) { PlatformPurchasesResponse pigeonResult = new PlatformPurchasesResponse(); Object billingResult = list.get(0); - pigeonResult.setBillingResult((billingResult == null) ? null : PlatformBillingResult.fromList((ArrayList) billingResult)); + pigeonResult.setBillingResult( + (billingResult == null) + ? null + : PlatformBillingResult.fromList((ArrayList) billingResult)); Object purchases = list.get(1); pigeonResult.setPurchases((List) purchases); return pigeonResult; @@ -2012,7 +2081,7 @@ ArrayList toList() { /** * Pigeon version of Java ProductDetails.SubscriptionOfferDetails. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformSubscriptionOfferDetails { private @NonNull String basePlanId; @@ -2163,7 +2232,7 @@ ArrayList toList() { /** * Pigeon version of UserChoiceDetailsWrapper and Java UserChoiceDetails. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformUserChoiceDetails { private @Nullable String originalExternalTransactionId; @@ -2264,7 +2333,7 @@ ArrayList toList() { /** * Pigeon version of UserChoiseDetails.Product. * - * Generated class from Pigeon that represents data sent in messages. + *

Generated class from Pigeon that represents data sent in messages. */ public static final class PlatformUserChoiceProduct { private @NonNull String id; @@ -2398,7 +2467,8 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { case (byte) 128: return PlatformAccountIdentifiers.fromList((ArrayList) readValue(buffer)); case (byte) 129: - return PlatformAlternativeBillingOnlyReportingDetailsResponse.fromList((ArrayList) readValue(buffer)); + return PlatformAlternativeBillingOnlyReportingDetailsResponse.fromList( + (ArrayList) readValue(buffer)); case (byte) 130: return PlatformBillingConfigResponse.fromList((ArrayList) readValue(buffer)); case (byte) 131: @@ -2406,7 +2476,8 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { case (byte) 132: return PlatformBillingResult.fromList((ArrayList) readValue(buffer)); case (byte) 133: - return PlatformOneTimePurchaseOfferDetails.fromList((ArrayList) readValue(buffer)); + return PlatformOneTimePurchaseOfferDetails.fromList( + (ArrayList) readValue(buffer)); case (byte) 134: return PlatformPricingPhase.fromList((ArrayList) readValue(buffer)); case (byte) 135: @@ -2437,7 +2508,8 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { writeValue(stream, ((PlatformAccountIdentifiers) value).toList()); } else if (value instanceof PlatformAlternativeBillingOnlyReportingDetailsResponse) { stream.write(129); - writeValue(stream, ((PlatformAlternativeBillingOnlyReportingDetailsResponse) value).toList()); + writeValue( + stream, ((PlatformAlternativeBillingOnlyReportingDetailsResponse) value).toList()); } else if (value instanceof PlatformBillingConfigResponse) { stream.write(130); writeValue(stream, ((PlatformBillingConfigResponse) value).toList()); @@ -2486,47 +2558,77 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface InAppPurchaseApi { /** Wraps BillingClient#isReady. */ - @NonNull + @NonNull Boolean isReady(); /** Wraps BillingClient#startConnection(BillingClientStateListener). */ - void startConnection(@NonNull Long callbackHandle, @NonNull PlatformBillingChoiceMode billingMode, @NonNull Result result); + void startConnection( + @NonNull Long callbackHandle, + @NonNull PlatformBillingChoiceMode billingMode, + @NonNull Result result); /** Wraps BillingClient#endConnection(BillingClientStateListener). */ void endConnection(); - /** Wraps BillingClient#getBillingConfigAsync(GetBillingConfigParams, BillingConfigResponseListener). */ + /** + * Wraps BillingClient#getBillingConfigAsync(GetBillingConfigParams, + * BillingConfigResponseListener). + */ void getBillingConfigAsync(@NonNull Result result); /** Wraps BillingClient#launchBillingFlow(Activity, BillingFlowParams). */ - @NonNull + @NonNull PlatformBillingResult launchBillingFlow(@NonNull PlatformBillingFlowParams params); - /** Wraps BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, AcknowledgePurchaseResponseListener). */ - void acknowledgePurchase(@NonNull String purchaseToken, @NonNull Result result); + /** + * Wraps BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, + * AcknowledgePurchaseResponseListener). + */ + void acknowledgePurchase( + @NonNull String purchaseToken, @NonNull Result result); /** Wraps BillingClient#consumeAsync(ConsumeParams, ConsumeResponseListener). */ void consumeAsync(@NonNull String purchaseToken, @NonNull Result result); /** Wraps BillingClient#queryPurchasesAsync(QueryPurchaseParams, PurchaseResponseListener). */ - void queryPurchasesAsync(@NonNull PlatformProductType productType, @NonNull Result result); - /** Wraps BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, PurchaseHistoryResponseListener). */ - void queryPurchaseHistoryAsync(@NonNull PlatformProductType productType, @NonNull Result result); - /** Wraps BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, ProductDetailsResponseListener). */ - void queryProductDetailsAsync(@NonNull List products, @NonNull Result result); + void queryPurchasesAsync( + @NonNull PlatformProductType productType, + @NonNull Result result); + /** + * Wraps BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, + * PurchaseHistoryResponseListener). + */ + void queryPurchaseHistoryAsync( + @NonNull PlatformProductType productType, + @NonNull Result result); + /** + * Wraps BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, + * ProductDetailsResponseListener). + */ + void queryProductDetailsAsync( + @NonNull List products, + @NonNull Result result); /** Wraps BillingClient#isFeatureSupported(String). */ - @NonNull + @NonNull Boolean isFeatureSupported(@NonNull String feature); /** Wraps BillingClient#isAlternativeBillingOnlyAvailableAsync(). */ void isAlternativeBillingOnlyAvailableAsync(@NonNull Result result); /** Wraps BillingClient#showAlternativeBillingOnlyInformationDialog(). */ void showAlternativeBillingOnlyInformationDialog(@NonNull Result result); - /** Wraps BillingClient#createAlternativeBillingOnlyReportingDetailsAsync(AlternativeBillingOnlyReportingDetailsListener). */ - void createAlternativeBillingOnlyReportingDetailsAsync(@NonNull Result result); + /** + * Wraps + * BillingClient#createAlternativeBillingOnlyReportingDetailsAsync(AlternativeBillingOnlyReportingDetailsListener). + */ + void createAlternativeBillingOnlyReportingDetailsAsync( + @NonNull Result result); /** The codec used by InAppPurchaseApi. */ static @NonNull MessageCodec getCodec() { return InAppPurchaseApiCodec.INSTANCE; } - /**Sets up an instance of `InAppPurchaseApi` to handle messages through the `binaryMessenger`. */ + /** + * Sets up an instance of `InAppPurchaseApi` to handle messages through the `binaryMessenger`. + */ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable InAppPurchaseApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2534,8 +2636,7 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable InAppPurch try { Boolean output = api.isReady(); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2548,14 +2649,17 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable InAppPurch { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; Number callbackHandleArg = (Number) args.get(0); - PlatformBillingChoiceMode billingModeArg = PlatformBillingChoiceMode.values()[(int) args.get(1)]; + PlatformBillingChoiceMode billingModeArg = + PlatformBillingChoiceMode.values()[(int) args.get(1)]; Result resultCallback = new Result() { public void success(PlatformBillingResult result) { @@ -2569,7 +2673,10 @@ public void error(Throwable error) { } }; - api.startConnection((callbackHandleArg == null) ? null : callbackHandleArg.longValue(), billingModeArg, resultCallback); + api.startConnection( + (callbackHandleArg == null) ? null : callbackHandleArg.longValue(), + billingModeArg, + resultCallback); }); } else { channel.setMessageHandler(null); @@ -2578,7 +2685,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2586,8 +2695,7 @@ public void error(Throwable error) { try { api.endConnection(); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2600,7 +2708,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2627,7 +2737,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2637,8 +2749,7 @@ public void error(Throwable error) { try { PlatformBillingResult output = api.launchBillingFlow(paramsArg); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2651,7 +2762,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2680,7 +2793,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2709,13 +2824,16 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - PlatformProductType productTypeArg = PlatformProductType.values()[(int) args.get(0)]; + PlatformProductType productTypeArg = + PlatformProductType.values()[(int) args.get(0)]; Result resultCallback = new Result() { public void success(PlatformPurchasesResponse result) { @@ -2738,13 +2856,16 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - PlatformProductType productTypeArg = PlatformProductType.values()[(int) args.get(0)]; + PlatformProductType productTypeArg = + PlatformProductType.values()[(int) args.get(0)]; Result resultCallback = new Result() { public void success(PlatformPurchaseHistoryResponse result) { @@ -2767,7 +2888,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2796,7 +2919,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2806,8 +2931,7 @@ public void error(Throwable error) { try { Boolean output = api.isFeatureSupported(featureArg); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -2820,7 +2944,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2847,7 +2973,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -2874,14 +3002,17 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList(); Result resultCallback = new Result() { - public void success(PlatformAlternativeBillingOnlyReportingDetailsResponse result) { + public void success( + PlatformAlternativeBillingOnlyReportingDetailsResponse result) { wrapped.add(0, result); reply.reply(wrapped); } @@ -2902,7 +3033,8 @@ public void error(Throwable error) { } private static class InAppPurchaseCallbackApiCodec extends StandardMessageCodec { - public static final InAppPurchaseCallbackApiCodec INSTANCE = new InAppPurchaseCallbackApiCodec(); + public static final InAppPurchaseCallbackApiCodec INSTANCE = + new InAppPurchaseCallbackApiCodec(); private InAppPurchaseCallbackApiCodec() {} @@ -2960,72 +3092,87 @@ public InAppPurchaseCallbackApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ /** The codec used by InAppPurchaseCallbackApi. */ static @NonNull MessageCodec getCodec() { return InAppPurchaseCallbackApiCodec.INSTANCE; } /** Called for BillingClientStateListener#onBillingServiceDisconnected(). */ - public void onBillingServiceDisconnected(@NonNull Long callbackHandleArg, @NonNull VoidResult result) { - final String channelName = "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected"; + public void onBillingServiceDisconnected( + @NonNull Long callbackHandleArg, @NonNull VoidResult result) { + final String channelName = + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected"; BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( new ArrayList(Collections.singletonList(callbackHandleArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), (String) listReply.get(2))); + result.error( + new FlutterError( + (String) listReply.get(0), + (String) listReply.get(1), + (String) listReply.get(2))); } else { result.success(); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } /** Called for PurchasesUpdatedListener#onPurchasesUpdated(BillingResult, List). */ - public void onPurchasesUpdated(@NonNull PlatformPurchasesResponse updateArg, @NonNull VoidResult result) { - final String channelName = "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated"; + public void onPurchasesUpdated( + @NonNull PlatformPurchasesResponse updateArg, @NonNull VoidResult result) { + final String channelName = + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated"; BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( new ArrayList(Collections.singletonList(updateArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), (String) listReply.get(2))); + result.error( + new FlutterError( + (String) listReply.get(0), + (String) listReply.get(1), + (String) listReply.get(2))); } else { result.success(); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } /** Called for UserChoiceBillingListener#userSelectedAlternativeBilling(UserChoiceDetails). */ - public void userSelectedalternativeBilling(@NonNull PlatformUserChoiceDetails detailsArg, @NonNull VoidResult result) { - final String channelName = "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling"; + public void userSelectedalternativeBilling( + @NonNull PlatformUserChoiceDetails detailsArg, @NonNull VoidResult result) { + final String channelName = + "dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling"; BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( new ArrayList(Collections.singletonList(detailsArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), (String) listReply.get(2))); + result.error( + new FlutterError( + (String) listReply.get(0), + (String) listReply.get(1), + (String) listReply.get(2))); } else { result.success(); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } } diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java index 08a794f5f67..c7305a69938 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java @@ -18,11 +18,9 @@ import android.content.Context; import android.os.Bundle; import android.util.Log; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; - import com.android.billingclient.api.AcknowledgePurchaseParams; import com.android.billingclient.api.BillingClient; import com.android.billingclient.api.BillingClientStateListener; @@ -35,7 +33,6 @@ import com.android.billingclient.api.QueryProductDetailsParams; import com.android.billingclient.api.QueryPurchaseHistoryParams; import com.android.billingclient.api.QueryPurchasesParams; - import io.flutter.plugins.inapppurchase.Messages.FlutterError; import io.flutter.plugins.inapppurchase.Messages.InAppPurchaseApi; import io.flutter.plugins.inapppurchase.Messages.InAppPurchaseCallbackApi; @@ -48,7 +45,6 @@ import io.flutter.plugins.inapppurchase.Messages.PlatformPurchasesResponse; import io.flutter.plugins.inapppurchase.Messages.PlatformQueryProduct; import io.flutter.plugins.inapppurchase.Messages.Result; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java b/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java index 210981c5bb2..58b1c42a0e4 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java @@ -29,7 +29,6 @@ import android.app.Activity; import android.content.Context; - import com.android.billingclient.api.AcknowledgePurchaseParams; import com.android.billingclient.api.AcknowledgePurchaseResponseListener; import com.android.billingclient.api.AlternativeBillingOnlyAvailabilityListener; @@ -55,7 +54,6 @@ import com.android.billingclient.api.QueryProductDetailsParams; import com.android.billingclient.api.QueryPurchaseHistoryParams; import com.android.billingclient.api.QueryPurchasesParams; - import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; import io.flutter.plugins.inapppurchase.Messages.FlutterError; import io.flutter.plugins.inapppurchase.Messages.InAppPurchaseCallbackApi; @@ -69,14 +67,12 @@ import io.flutter.plugins.inapppurchase.Messages.PlatformPurchaseHistoryResponse; import io.flutter.plugins.inapppurchase.Messages.PlatformPurchasesResponse; import io.flutter.plugins.inapppurchase.Messages.PlatformQueryProduct; - import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; - import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart index d66806017e5..e6444b8d9b6 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/messages.g.dart @@ -18,7 +18,8 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -40,8 +41,10 @@ enum PlatformBillingChoiceMode { /// /// Default state. playBillingOnly, + /// Billing through app provided flow. alternativeBillingOnly, + /// Users can choose Play billing or alternative billing. userChoiceBilling, } @@ -220,9 +223,11 @@ class PlatformProductDetails { productType: PlatformProductType.values[result[3]! as int], title: result[4]! as String, oneTimePurchaseOfferDetails: result[5] != null - ? PlatformOneTimePurchaseOfferDetails.decode(result[5]! as List) + ? PlatformOneTimePurchaseOfferDetails.decode( + result[5]! as List) : null, - subscriptionOfferDetails: (result[6] as List?)?.cast(), + subscriptionOfferDetails: (result[6] as List?) + ?.cast(), ); } } @@ -250,7 +255,8 @@ class PlatformProductDetailsResponse { result as List; return PlatformProductDetailsResponse( billingResult: PlatformBillingResult.decode(result[0]! as List), - productDetails: (result[1] as List?)!.cast(), + productDetails: + (result[1] as List?)!.cast(), ); } } @@ -275,7 +281,8 @@ class PlatformAlternativeBillingOnlyReportingDetailsResponse { ]; } - static PlatformAlternativeBillingOnlyReportingDetailsResponse decode(Object result) { + static PlatformAlternativeBillingOnlyReportingDetailsResponse decode( + Object result) { result as List; return PlatformAlternativeBillingOnlyReportingDetailsResponse( billingResult: PlatformBillingResult.decode(result[0]! as List), @@ -579,7 +586,8 @@ class PlatformPurchaseHistoryResponse { result as List; return PlatformPurchaseHistoryResponse( billingResult: PlatformBillingResult.decode(result[0]! as List), - purchases: (result[1] as List?)!.cast(), + purchases: + (result[1] as List?)!.cast(), ); } } @@ -649,7 +657,8 @@ class PlatformSubscriptionOfferDetails { offerId: result[1] as String?, offerToken: result[2]! as String, offerTags: (result[3] as List?)!.cast(), - pricingPhases: (result[4] as List?)!.cast(), + pricingPhases: + (result[4] as List?)!.cast(), ); } } @@ -681,7 +690,8 @@ class PlatformUserChoiceDetails { return PlatformUserChoiceDetails( originalExternalTransactionId: result[0] as String?, externalTransactionToken: result[1]! as String, - products: (result[2] as List?)!.cast(), + products: + (result[2] as List?)!.cast(), ); } } @@ -725,7 +735,8 @@ class _InAppPurchaseApiCodec extends StandardMessageCodec { if (value is PlatformAccountIdentifiers) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is PlatformAlternativeBillingOnlyReportingDetailsResponse) { + } else if (value + is PlatformAlternativeBillingOnlyReportingDetailsResponse) { buffer.putUint8(129); writeValue(buffer, value.encode()); } else if (value is PlatformBillingConfigResponse) { @@ -775,35 +786,36 @@ class _InAppPurchaseApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return PlatformAccountIdentifiers.decode(readValue(buffer)!); - case 129: - return PlatformAlternativeBillingOnlyReportingDetailsResponse.decode(readValue(buffer)!); - case 130: + case 129: + return PlatformAlternativeBillingOnlyReportingDetailsResponse.decode( + readValue(buffer)!); + case 130: return PlatformBillingConfigResponse.decode(readValue(buffer)!); - case 131: + case 131: return PlatformBillingFlowParams.decode(readValue(buffer)!); - case 132: + case 132: return PlatformBillingResult.decode(readValue(buffer)!); - case 133: + case 133: return PlatformOneTimePurchaseOfferDetails.decode(readValue(buffer)!); - case 134: + case 134: return PlatformPricingPhase.decode(readValue(buffer)!); - case 135: + case 135: return PlatformProductDetails.decode(readValue(buffer)!); - case 136: + case 136: return PlatformProductDetailsResponse.decode(readValue(buffer)!); - case 137: + case 137: return PlatformPurchase.decode(readValue(buffer)!); - case 138: + case 138: return PlatformPurchaseHistoryRecord.decode(readValue(buffer)!); - case 139: + case 139: return PlatformPurchaseHistoryResponse.decode(readValue(buffer)!); - case 140: + case 140: return PlatformPurchasesResponse.decode(readValue(buffer)!); - case 141: + case 141: return PlatformQueryProduct.decode(readValue(buffer)!); - case 142: + case 142: return PlatformSubscriptionOfferDetails.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -819,12 +831,15 @@ class InAppPurchaseApi { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = _InAppPurchaseApiCodec(); + static const MessageCodec pigeonChannelCodec = + _InAppPurchaseApiCodec(); /// Wraps BillingClient#isReady. Future isReady() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isReady'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -850,15 +865,18 @@ class InAppPurchaseApi { } /// Wraps BillingClient#startConnection(BillingClientStateListener). - Future startConnection(int callbackHandle, PlatformBillingChoiceMode billingMode) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future startConnection( + int callbackHandle, PlatformBillingChoiceMode billingMode) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.startConnection'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([callbackHandle, billingMode.index]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([callbackHandle, billingMode.index]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -879,8 +897,10 @@ class InAppPurchaseApi { /// Wraps BillingClient#endConnection(BillingClientStateListener). Future endConnection() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.endConnection'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -902,8 +922,10 @@ class InAppPurchaseApi { /// Wraps BillingClient#getBillingConfigAsync(GetBillingConfigParams, BillingConfigResponseListener). Future getBillingConfigAsync() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.getBillingConfigAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -929,9 +951,12 @@ class InAppPurchaseApi { } /// Wraps BillingClient#launchBillingFlow(Activity, BillingFlowParams). - Future launchBillingFlow(PlatformBillingFlowParams params) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future launchBillingFlow( + PlatformBillingFlowParams params) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.launchBillingFlow'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -957,9 +982,12 @@ class InAppPurchaseApi { } /// Wraps BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, AcknowledgePurchaseResponseListener). - Future acknowledgePurchase(String purchaseToken) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future acknowledgePurchase( + String purchaseToken) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.acknowledgePurchase'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -986,8 +1014,10 @@ class InAppPurchaseApi { /// Wraps BillingClient#consumeAsync(ConsumeParams, ConsumeResponseListener). Future consumeAsync(String purchaseToken) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.consumeAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1013,15 +1043,18 @@ class InAppPurchaseApi { } /// Wraps BillingClient#queryPurchasesAsync(QueryPurchaseParams, PurchaseResponseListener). - Future queryPurchasesAsync(PlatformProductType productType) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future queryPurchasesAsync( + PlatformProductType productType) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchasesAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([productType.index]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([productType.index]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1041,15 +1074,18 @@ class InAppPurchaseApi { } /// Wraps BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, PurchaseHistoryResponseListener). - Future queryPurchaseHistoryAsync(PlatformProductType productType) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future queryPurchaseHistoryAsync( + PlatformProductType productType) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryPurchaseHistoryAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([productType.index]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([productType.index]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1069,9 +1105,12 @@ class InAppPurchaseApi { } /// Wraps BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, ProductDetailsResponseListener). - Future queryProductDetailsAsync(List products) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future queryProductDetailsAsync( + List products) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.queryProductDetailsAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1098,8 +1137,10 @@ class InAppPurchaseApi { /// Wraps BillingClient#isFeatureSupported(String). Future isFeatureSupported(String feature) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isFeatureSupported'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1126,8 +1167,10 @@ class InAppPurchaseApi { /// Wraps BillingClient#isAlternativeBillingOnlyAvailableAsync(). Future isAlternativeBillingOnlyAvailableAsync() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.isAlternativeBillingOnlyAvailableAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1153,9 +1196,12 @@ class InAppPurchaseApi { } /// Wraps BillingClient#showAlternativeBillingOnlyInformationDialog(). - Future showAlternativeBillingOnlyInformationDialog() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future + showAlternativeBillingOnlyInformationDialog() async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.showAlternativeBillingOnlyInformationDialog'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1181,9 +1227,12 @@ class InAppPurchaseApi { } /// Wraps BillingClient#createAlternativeBillingOnlyReportingDetailsAsync(AlternativeBillingOnlyReportingDetailsListener). - Future createAlternativeBillingOnlyReportingDetailsAsync() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future + createAlternativeBillingOnlyReportingDetailsAsync() async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseApi.createAlternativeBillingOnlyReportingDetailsAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1204,7 +1253,8 @@ class InAppPurchaseApi { message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as PlatformAlternativeBillingOnlyReportingDetailsResponse?)!; + return (__pigeon_replyList[0] + as PlatformAlternativeBillingOnlyReportingDetailsResponse?)!; } } } @@ -1239,17 +1289,17 @@ class _InAppPurchaseCallbackApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return PlatformAccountIdentifiers.decode(readValue(buffer)!); - case 129: + case 129: return PlatformBillingResult.decode(readValue(buffer)!); - case 130: + case 130: return PlatformPurchase.decode(readValue(buffer)!); - case 131: + case 131: return PlatformPurchasesResponse.decode(readValue(buffer)!); - case 132: + case 132: return PlatformUserChoiceDetails.decode(readValue(buffer)!); - case 133: + case 133: return PlatformUserChoiceProduct.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1258,7 +1308,8 @@ class _InAppPurchaseCallbackApiCodec extends StandardMessageCodec { } abstract class InAppPurchaseCallbackApi { - static const MessageCodec pigeonChannelCodec = _InAppPurchaseCallbackApiCodec(); + static const MessageCodec pigeonChannelCodec = + _InAppPurchaseCallbackApiCodec(); /// Called for BillingClientStateListener#onBillingServiceDisconnected(). void onBillingServiceDisconnected(int callbackHandle); @@ -1269,17 +1320,20 @@ abstract class InAppPurchaseCallbackApi { /// Called for UserChoiceBillingListener#userSelectedAlternativeBilling(UserChoiceDetails). void userSelectedalternativeBilling(PlatformUserChoiceDetails details); - static void setup(InAppPurchaseCallbackApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(InAppPurchaseCallbackApi? api, + {BinaryMessenger? binaryMessenger}) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onBillingServiceDisconnected was null.'); final List args = (message as List?)!; final int? arg_callbackHandle = (args[0] as int?); assert(arg_callbackHandle != null, @@ -1289,24 +1343,28 @@ abstract class InAppPurchaseCallbackApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated was null.'); final List args = (message as List?)!; - final PlatformPurchasesResponse? arg_update = (args[0] as PlatformPurchasesResponse?); + final PlatformPurchasesResponse? arg_update = + (args[0] as PlatformPurchasesResponse?); assert(arg_update != null, 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.onPurchasesUpdated was null, expected non-null PlatformPurchasesResponse.'); try { @@ -1314,24 +1372,28 @@ abstract class InAppPurchaseCallbackApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling was null.'); final List args = (message as List?)!; - final PlatformUserChoiceDetails? arg_details = (args[0] as PlatformUserChoiceDetails?); + final PlatformUserChoiceDetails? arg_details = + (args[0] as PlatformUserChoiceDetails?); assert(arg_details != null, 'Argument for dev.flutter.pigeon.in_app_purchase_android.InAppPurchaseCallbackApi.userSelectedalternativeBilling was null, expected non-null PlatformUserChoiceDetails.'); try { @@ -1339,8 +1401,9 @@ abstract class InAppPurchaseCallbackApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } From 01bf1e279d97d86204f1ba567642c2111a3d9833 Mon Sep 17 00:00:00 2001 From: Adam Vongrej Date: Sun, 12 May 2024 09:17:07 +0200 Subject: [PATCH 4/4] Fix typo in CHANGELOG --- packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md index 98857720780..d366c771acb 100644 --- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md @@ -14,7 +14,6 @@ * Adds `countryCode` API. - ## 0.3.3+1 * Moves alternative billing listener creation to BillingClientFactoryImpl.