24
24
import com .android .billingclient .api .BillingResult ;
25
25
import com .android .billingclient .api .ConsumeParams ;
26
26
import com .android .billingclient .api .ConsumeResponseListener ;
27
- import com .android .billingclient .api .PriceChangeFlowParams ;
28
27
import com .android .billingclient .api .Purchase ;
29
28
import com .android .billingclient .api .PurchaseHistoryRecord ;
30
29
import com .android .billingclient .api .PurchaseHistoryResponseListener ;
31
30
import com .android .billingclient .api .PurchasesResponseListener ;
32
31
import com .android .billingclient .api .QueryPurchaseHistoryParams ;
33
32
import 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 ;
37
33
import io .flutter .plugin .common .MethodCall ;
38
34
import io .flutter .plugin .common .MethodChannel ;
39
35
import java .util .HashMap ;
@@ -55,7 +51,9 @@ class MethodCallHandlerImpl
55
51
private final Context applicationContext ;
56
52
private final MethodChannel methodChannel ;
57
53
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 <>();
59
57
60
58
/** Constructs the MethodCallHandlerImpl */
61
59
MethodCallHandlerImpl (
@@ -185,21 +183,29 @@ private void isReady(MethodChannel.Result result) {
185
183
result .success (billingClient .isReady ());
186
184
}
187
185
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" )
189
191
private void querySkuDetailsAsync (
190
192
final String skuType , final List <String > skusList , final MethodChannel .Result result ) {
191
193
if (billingClientError (result )) {
192
194
return ;
193
195
}
194
196
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 ();
197
202
billingClient .querySkuDetailsAsync (
198
203
params ,
199
- new SkuDetailsResponseListener () {
204
+ new com . android . billingclient . api . SkuDetailsResponseListener () {
200
205
@ Override
201
206
public void onSkuDetailsResponse (
202
- BillingResult billingResult , List <SkuDetails > skuDetailsList ) {
207
+ BillingResult billingResult ,
208
+ List <com .android .billingclient .api .SkuDetails > skuDetailsList ) {
203
209
updateCachedSkus (skuDetailsList );
204
210
final Map <String , Object > skuDetailsResponse = new HashMap <>();
205
211
skuDetailsResponse .put ("billingResult" , Translator .fromBillingResult (billingResult ));
@@ -220,7 +226,9 @@ private void launchBillingFlow(
220
226
if (billingClientError (result )) {
221
227
return ;
222
228
}
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 );
224
232
if (skuDetails == null ) {
225
233
result .error (
226
234
"NOT_FOUND" ,
@@ -258,6 +266,8 @@ private void launchBillingFlow(
258
266
return ;
259
267
}
260
268
269
+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
270
+ @ SuppressWarnings ("deprecation" )
261
271
BillingFlowParams .Builder paramsBuilder =
262
272
BillingFlowParams .newBuilder ().setSkuDetails (skuDetails );
263
273
if (accountId != null && !accountId .isEmpty ()) {
@@ -401,16 +411,21 @@ public void onAcknowledgePurchaseResponse(BillingResult billingResult) {
401
411
});
402
412
}
403
413
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 ) {
405
418
if (skuDetailsList == null ) {
406
419
return ;
407
420
}
408
421
409
- for (SkuDetails skuDetails : skuDetailsList ) {
422
+ for (com . android . billingclient . api . SkuDetails skuDetails : skuDetailsList ) {
410
423
cachedSkus .put (skuDetails .getSku (), skuDetails );
411
424
}
412
425
}
413
426
427
+ // TODO(stuartmorgan): Migrate this code. See TODO on querySkuDetailsAsync.
428
+ @ SuppressWarnings ("deprecation" )
414
429
private void launchPriceChangeConfirmationFlow (String sku , MethodChannel .Result result ) {
415
430
if (activity == null ) {
416
431
result .error (
@@ -428,7 +443,7 @@ private void launchPriceChangeConfirmationFlow(String sku, MethodChannel.Result
428
443
// is handled by the `billingClientError()` call.
429
444
assert billingClient != null ;
430
445
431
- SkuDetails skuDetails = cachedSkus .get (sku );
446
+ com . android . billingclient . api . SkuDetails skuDetails = cachedSkus .get (sku );
432
447
if (skuDetails == null ) {
433
448
result .error (
434
449
"NOT_FOUND" ,
@@ -439,8 +454,10 @@ private void launchPriceChangeConfirmationFlow(String sku, MethodChannel.Result
439
454
return ;
440
455
}
441
456
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 ();
444
461
billingClient .launchPriceChangeConfirmationFlow (
445
462
activity ,
446
463
params ,
0 commit comments