Skip to content

Commit 2c40c34

Browse files
committed
Merge remote-tracking branch 'upstream/master' into webview_load_file_appfacing
2 parents 9f2edd0 + 3990aaf commit 2c40c34

File tree

13 files changed

+33
-73
lines changed

13 files changed

+33
-73
lines changed

packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 0.2.1
22

3-
* Updates compileSdkVersion to 31.
3+
* Deprecated the `InAppPurchaseAndroidPlatformAddition.enablePendingPurchases()` method and `InAppPurchaseAndroidPlatformAddition.enablePendingPurchase` property. Since Google Play no longer accepts App submissions that don't support pending purchases it is no longer necessary to acknowledge this through code.
4+
* Updates example app Android compileSdkVersion to 31.
45

56
## 0.2.0
67

packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/BillingClientFactory.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ interface BillingClientFactory {
1717
*
1818
* @param context The context used to create the {@link BillingClient}.
1919
* @param channel The method channel used to create the {@link BillingClient}.
20-
* @param enablePendingPurchases Whether to enable pending purchases. Throws an exception if it is
21-
* false.
2220
* @return The {@link BillingClient} object that is created.
2321
*/
24-
BillingClient createBillingClient(
25-
@NonNull Context context, @NonNull MethodChannel channel, boolean enablePendingPurchases);
22+
BillingClient createBillingClient(@NonNull Context context, @NonNull MethodChannel channel);
2623
}

packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/BillingClientFactoryImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@
1212
final class BillingClientFactoryImpl implements BillingClientFactory {
1313

1414
@Override
15-
public BillingClient createBillingClient(
16-
Context context, MethodChannel channel, boolean enablePendingPurchases) {
17-
BillingClient.Builder builder = BillingClient.newBuilder(context);
18-
if (enablePendingPurchases) {
19-
builder.enablePendingPurchases();
20-
}
15+
public BillingClient createBillingClient(Context context, MethodChannel channel) {
16+
BillingClient.Builder builder = BillingClient.newBuilder(context).enablePendingPurchases();
17+
2118
return builder.setListener(new PluginPurchaseListener(channel)).build();
2219
}
2320
}

packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
110110
isReady(result);
111111
break;
112112
case InAppPurchasePlugin.MethodNames.START_CONNECTION:
113-
startConnection(
114-
(int) call.argument("handle"),
115-
(boolean) call.argument("enablePendingPurchases"),
116-
result);
113+
startConnection((int) call.argument("handle"), result);
117114
break;
118115
case InAppPurchasePlugin.MethodNames.END_CONNECTION:
119116
endConnection(result);
@@ -319,12 +316,9 @@ public void onPurchaseHistoryResponse(
319316
});
320317
}
321318

322-
private void startConnection(
323-
final int handle, final boolean enablePendingPurchases, final MethodChannel.Result result) {
319+
private void startConnection(final int handle, final MethodChannel.Result result) {
324320
if (billingClient == null) {
325-
billingClient =
326-
billingClientFactory.createBillingClient(
327-
applicationContext, methodChannel, enablePendingPurchases);
321+
billingClient = billingClientFactory.createBillingClient(applicationContext, methodChannel);
328322
}
329323

330324
billingClient.startConnection(

packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/MethodCallHandlerTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ public class MethodCallHandlerTest {
9090
@Before
9191
public void setUp() {
9292
MockitoAnnotations.openMocks(this);
93-
factory =
94-
(@NonNull Context context,
95-
@NonNull MethodChannel channel,
96-
boolean enablePendingPurchases) -> mockBillingClient;
93+
factory = (@NonNull Context context, @NonNull MethodChannel channel) -> mockBillingClient;
9794
methodChannelHandler = new MethodCallHandlerImpl(activity, context, mockMethodChannel, factory);
9895
when(mockActivityPluginBinding.getActivity()).thenReturn(activity);
9996
}
@@ -153,7 +150,6 @@ public void startConnection() {
153150
public void startConnection_multipleCalls() {
154151
Map<String, Object> arguments = new HashMap<>();
155152
arguments.put("handle", 1);
156-
arguments.put("enablePendingPurchases", true);
157153
MethodCall call = new MethodCall(START_CONNECTION, arguments);
158154
ArgumentCaptor<BillingClientStateListener> captor =
159155
ArgumentCaptor.forClass(BillingClientStateListener.class);
@@ -191,7 +187,6 @@ public void endConnection() {
191187
final int disconnectCallbackHandle = 22;
192188
Map<String, Object> arguments = new HashMap<>();
193189
arguments.put("handle", disconnectCallbackHandle);
194-
arguments.put("enablePendingPurchases", true);
195190
MethodCall connectCall = new MethodCall(START_CONNECTION, arguments);
196191
ArgumentCaptor<BillingClientStateListener> captor =
197192
ArgumentCaptor.forClass(BillingClientStateListener.class);
@@ -865,7 +860,6 @@ public void launchPriceChangeConfirmationFlow_withoutBillingClient_returnsUnavai
865860
private ArgumentCaptor<BillingClientStateListener> mockStartConnection() {
866861
Map<String, Object> arguments = new HashMap<>();
867862
arguments.put("handle", 1);
868-
arguments.put("enablePendingPurchases", true);
869863
MethodCall call = new MethodCall(START_CONNECTION, arguments);
870864
ArgumentCaptor<BillingClientStateListener> captor =
871865
ArgumentCaptor.forClass(BillingClientStateListener.class);
@@ -880,7 +874,6 @@ private void establishConnectedBillingClient(
880874
if (arguments == null) {
881875
arguments = new HashMap<>();
882876
arguments.put("handle", 1);
883-
arguments.put("enablePendingPurchases", true);
884877
}
885878
if (result == null) {
886879
result = mock(Result.class);

packages/in_app_purchase/in_app_purchase_android/example/integration_test/in_app_purchase_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ void main() {
1212

1313
testWidgets('Can create InAppPurchaseAndroid instance',
1414
(WidgetTester tester) async {
15-
InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
1615
InAppPurchaseAndroidPlatform.registerPlatform();
1716
final InAppPurchasePlatform androidPlatform =
1817
InAppPurchasePlatform.instance;

packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ import 'consumable_store.dart';
1515
void main() {
1616
WidgetsFlutterBinding.ensureInitialized();
1717

18-
// For play billing library 2.0 on Android, it is mandatory to call
19-
// [enablePendingPurchases](https://developer.android.com/reference/com/android/billingclient/api/BillingClient.Builder.html#enablependingpurchases)
20-
// as part of initializing the app.
21-
InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
22-
2318
// When using the Android plugin directly it is mandatory to register
2419
// the plugin as default instance as part of initializing the app.
2520
InAppPurchaseAndroidPlatform.registerPlatform();

packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ typedef void PurchasesUpdatedListener(PurchasesResultWrapper purchasesResult);
5353
/// some minor changes to account for language differences. Callbacks have been
5454
/// converted to futures where appropriate.
5555
class BillingClient {
56-
bool _enablePendingPurchases = false;
57-
5856
/// Creates a billing client.
5957
BillingClient(PurchasesUpdatedListener onPurchasesUpdated) {
6058
channel.setMethodCallHandler(callHandler);
@@ -82,14 +80,12 @@ class BillingClient {
8280

8381
/// Enable the [BillingClientWrapper] to handle pending purchases.
8482
///
85-
/// Play requires that you call this method when initializing your application.
86-
/// It is to acknowledge your application has been updated to support pending purchases.
87-
/// See [Support pending transactions](https://developer.android.com/google/play/billing/billing_library_overview#pending)
88-
/// for more details.
89-
///
90-
/// Failure to call this method before any other method in the [startConnection] will throw an exception.
83+
/// **Deprecation warning:** it is no longer required to call
84+
/// [enablePendingPurchases] when initializing your application.
85+
@Deprecated(
86+
'The requirement to call `enablePendingPurchases()` has become obsolete since Google Play no longer accepts app submissions that don\'t support pending purchases.')
9187
void enablePendingPurchases() {
92-
_enablePendingPurchases = true;
88+
// No-op, until it is time to completely remove this method from the API.
9389
}
9490

9591
/// Calls
@@ -105,8 +101,6 @@ class BillingClient {
105101
Future<BillingResultWrapper> startConnection(
106102
{required OnBillingServiceDisconnected
107103
onBillingServiceDisconnected}) async {
108-
assert(_enablePendingPurchases,
109-
'enablePendingPurchases() must be called before calling startConnection');
110104
List<Function> disconnectCallbacks =
111105
_callbacks[_kOnBillingServiceDisconnected] ??= [];
112106
disconnectCallbacks.add(onBillingServiceDisconnected);
@@ -115,7 +109,6 @@ class BillingClient {
115109
"BillingClient#startConnection(BillingClientStateListener)",
116110
<String, dynamic>{
117111
'handle': disconnectCallbacks.length - 1,
118-
'enablePendingPurchases': _enablePendingPurchases
119112
})) ??
120113
<String, dynamic>{});
121114
}

packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform_addition.dart

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,29 @@ class InAppPurchaseAndroidPlatformAddition
1414
extends InAppPurchasePlatformAddition {
1515
/// Creates a [InAppPurchaseAndroidPlatformAddition] which uses the supplied
1616
/// `BillingClient` to provide Android specific features.
17-
InAppPurchaseAndroidPlatformAddition(this._billingClient) {
18-
assert(
19-
_enablePendingPurchase,
20-
'enablePendingPurchases() must be called when initializing the application and before you access the [InAppPurchase.instance].',
21-
);
22-
23-
_billingClient.enablePendingPurchases();
24-
}
17+
InAppPurchaseAndroidPlatformAddition(this._billingClient);
2518

2619
/// Whether pending purchase is enabled.
2720
///
21+
/// **Deprecation warning:** it is no longer required to call
22+
/// [enablePendingPurchases] when initializing your application. From now on
23+
/// this is handled internally and the [enablePendingPurchase] property will
24+
/// always return `true`.
25+
///
26+
// ignore: deprecated_member_use_from_same_package
2827
/// See also [enablePendingPurchases] for more on pending purchases.
29-
static bool get enablePendingPurchase => _enablePendingPurchase;
30-
static bool _enablePendingPurchase = false;
28+
@Deprecated(
29+
'The requirement to call `enablePendingPurchases()` has become obsolete since Google Play no longer accepts app submissions that don\'t support pending purchases.')
30+
static bool get enablePendingPurchase => true;
3131

3232
/// Enable the [InAppPurchaseConnection] to handle pending purchases.
3333
///
34-
/// This method is required to be called when initialize the application.
35-
/// It is to acknowledge your application has been updated to support pending purchases.
36-
/// See [Support pending transactions](https://developer.android.com/google/play/billing/billing_library_overview#pending)
37-
/// for more details.
38-
/// Failure to call this method before access [instance] will throw an exception.
34+
/// **Deprecation warning:** it is no longer required to call
35+
/// [enablePendingPurchases] when initializing your application.
36+
@Deprecated(
37+
'The requirement to call `enablePendingPurchases()` has become obsolete since Google Play no longer accepts app submissions that don\'t support pending purchases.')
3938
static void enablePendingPurchases() {
40-
_enablePendingPurchase = true;
39+
// No-op, until it is time to completely remove this method from the API.
4140
}
4241

4342
final BillingClient _billingClient;

packages/in_app_purchase/in_app_purchase_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: in_app_purchase_android
22
description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
33
repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
5-
version: 0.2.0
5+
version: 0.2.1
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"

packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/billing_client_wrapper_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ void main() {
2222

2323
setUp(() {
2424
billingClient = BillingClient((PurchasesResultWrapper _) {});
25-
billingClient.enablePendingPurchases();
2625
stubPlatform.reset();
2726
});
2827

@@ -90,10 +89,7 @@ void main() {
9089
);
9190
await billingClient.startConnection(onBillingServiceDisconnected: () {});
9291
final MethodCall call = stubPlatform.previousCallMatching(methodName);
93-
expect(
94-
call.arguments,
95-
equals(
96-
<dynamic, dynamic>{'handle': 0, 'enablePendingPurchases': true}));
92+
expect(call.arguments, equals(<dynamic, dynamic>{'handle': 0}));
9793
});
9894

9995
test('handles method channel returning null', () async {

packages/in_app_purchase/in_app_purchase_android/test/in_app_purchase_android_platform_addition_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ void main() {
2929
setUp(() {
3030
widgets.WidgetsFlutterBinding.ensureInitialized();
3131

32-
InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
33-
3432
const String debugMessage = 'dummy message';
3533
final BillingResponse responseCode = BillingResponse.ok;
3634
final BillingResultWrapper expectedBillingResult = BillingResultWrapper(

packages/in_app_purchase/in_app_purchase_android/test/in_app_purchase_android_platform_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:flutter_test/flutter_test.dart';
1010
import 'package:in_app_purchase_android/billing_client_wrappers.dart';
1111
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
1212
import 'package:in_app_purchase_android/src/channel.dart';
13-
import 'package:in_app_purchase_android/src/in_app_purchase_android_platform_addition.dart';
1413
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
1514

1615
import 'billing_client_wrappers/purchase_wrapper_test.dart';
@@ -42,7 +41,6 @@ void main() {
4241
value: buildBillingResultMap(expectedBillingResult));
4342
stubPlatform.addResponse(name: endConnectionCall, value: null);
4443

45-
InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
4644
InAppPurchaseAndroidPlatform.registerPlatform();
4745
iapAndroidPlatform =
4846
InAppPurchasePlatform.instance as InAppPurchaseAndroidPlatform;

0 commit comments

Comments
 (0)