2424import com .android .billingclient .api .BillingResult ;
2525import com .android .billingclient .api .ConsumeParams ;
2626import com .android .billingclient .api .ConsumeResponseListener ;
27- import com .android .billingclient .api .PriceChangeFlowParams ;
2827import com .android .billingclient .api .Purchase ;
2928import com .android .billingclient .api .PurchaseHistoryRecord ;
3029import com .android .billingclient .api .PurchaseHistoryResponseListener ;
3130import com .android .billingclient .api .PurchasesResponseListener ;
3231import com .android .billingclient .api .QueryPurchaseHistoryParams ;
3332import com .android .billingclient .api .QueryPurchasesParams ;
34- import com .android .billingclient .api .SkuDetails ;
35- import com .android .billingclient .api .SkuDetailsParams ;
36- import com .android .billingclient .api .SkuDetailsResponseListener ;
3733import io .flutter .plugin .common .MethodCall ;
3834import io .flutter .plugin .common .MethodChannel ;
3935import java .util .HashMap ;
@@ -55,7 +51,9 @@ class MethodCallHandlerImpl
5551 private final Context applicationContext ;
5652 private final MethodChannel methodChannel ;
5753
58- private HashMap <String , SkuDetails > cachedSkus = new HashMap <>();
54+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
55+ @ SuppressWarnings ("deprecation" )
56+ private HashMap <String , com .android .billingclient .api .SkuDetails > cachedSkus = new HashMap <>();
5957
6058 /** Constructs the MethodCallHandlerImpl */
6159 MethodCallHandlerImpl (
@@ -185,21 +183,29 @@ private void isReady(MethodChannel.Result result) {
185183 result .success (billingClient .isReady ());
186184 }
187185
188- // TODO(garyq): Migrate to new subscriptions API: https://developer.android.com/google/play/billing/migrate-gpblv5
186+ // TODO(stuartmorgan): Migrate to new subscriptions API. See:
187+ // - https://developer.android.com/google/play/billing/migrate-gpblv5
188+ // - https://github.com/flutter/flutter/issues/114265
189+ // - https://github.com/flutter/flutter/issues/107370
190+ @ SuppressWarnings ("deprecation" )
189191 private void querySkuDetailsAsync (
190192 final String skuType , final List <String > skusList , final MethodChannel .Result result ) {
191193 if (billingClientError (result )) {
192194 return ;
193195 }
194196
195- SkuDetailsParams params =
196- SkuDetailsParams .newBuilder ().setType (skuType ).setSkusList (skusList ).build ();
197+ com .android .billingclient .api .SkuDetailsParams params =
198+ com .android .billingclient .api .SkuDetailsParams .newBuilder ()
199+ .setType (skuType )
200+ .setSkusList (skusList )
201+ .build ();
197202 billingClient .querySkuDetailsAsync (
198203 params ,
199- new SkuDetailsResponseListener () {
204+ new com . android . billingclient . api . SkuDetailsResponseListener () {
200205 @ Override
201206 public void onSkuDetailsResponse (
202- BillingResult billingResult , List <SkuDetails > skuDetailsList ) {
207+ BillingResult billingResult ,
208+ List <com .android .billingclient .api .SkuDetails > skuDetailsList ) {
203209 updateCachedSkus (skuDetailsList );
204210 final Map <String , Object > skuDetailsResponse = new HashMap <>();
205211 skuDetailsResponse .put ("billingResult" , Translator .fromBillingResult (billingResult ));
@@ -220,7 +226,9 @@ private void launchBillingFlow(
220226 if (billingClientError (result )) {
221227 return ;
222228 }
223- SkuDetails skuDetails = cachedSkus .get (sku );
229+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
230+ @ SuppressWarnings ("deprecation" )
231+ com .android .billingclient .api .SkuDetails skuDetails = cachedSkus .get (sku );
224232 if (skuDetails == null ) {
225233 result .error (
226234 "NOT_FOUND" ,
@@ -258,6 +266,8 @@ private void launchBillingFlow(
258266 return ;
259267 }
260268
269+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
270+ @ SuppressWarnings ("deprecation" )
261271 BillingFlowParams .Builder paramsBuilder =
262272 BillingFlowParams .newBuilder ().setSkuDetails (skuDetails );
263273 if (accountId != null && !accountId .isEmpty ()) {
@@ -401,16 +411,21 @@ public void onAcknowledgePurchaseResponse(BillingResult billingResult) {
401411 });
402412 }
403413
404- private void updateCachedSkus (@ Nullable List <SkuDetails > skuDetailsList ) {
414+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
415+ @ SuppressWarnings ("deprecation" )
416+ private void updateCachedSkus (
417+ @ Nullable List <com .android .billingclient .api .SkuDetails > skuDetailsList ) {
405418 if (skuDetailsList == null ) {
406419 return ;
407420 }
408421
409- for (SkuDetails skuDetails : skuDetailsList ) {
422+ for (com . android . billingclient . api . SkuDetails skuDetails : skuDetailsList ) {
410423 cachedSkus .put (skuDetails .getSku (), skuDetails );
411424 }
412425 }
413426
427+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
428+ @ SuppressWarnings ("deprecation" )
414429 private void launchPriceChangeConfirmationFlow (String sku , MethodChannel .Result result ) {
415430 if (activity == null ) {
416431 result .error (
@@ -428,7 +443,7 @@ private void launchPriceChangeConfirmationFlow(String sku, MethodChannel.Result
428443 // is handled by the `billingClientError()` call.
429444 assert billingClient != null ;
430445
431- SkuDetails skuDetails = cachedSkus .get (sku );
446+ com . android . billingclient . api . SkuDetails skuDetails = cachedSkus .get (sku );
432447 if (skuDetails == null ) {
433448 result .error (
434449 "NOT_FOUND" ,
@@ -439,8 +454,10 @@ private void launchPriceChangeConfirmationFlow(String sku, MethodChannel.Result
439454 return ;
440455 }
441456
442- PriceChangeFlowParams params =
443- new PriceChangeFlowParams .Builder ().setSkuDetails (skuDetails ).build ();
457+ com .android .billingclient .api .PriceChangeFlowParams params =
458+ new com .android .billingclient .api .PriceChangeFlowParams .Builder ()
459+ .setSkuDetails (skuDetails )
460+ .build ();
444461 billingClient .launchPriceChangeConfirmationFlow (
445462 activity ,
446463 params ,
0 commit comments