Skip to content

[in_app_purchase] Mostly convert to Android Pigeon #6262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 3, 2024

Conversation

stuartmorgan-g
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g commented Mar 4, 2024

Replaces manual method channels with Pigeon.

This replaces all of the method calls in both direction with Pigeon calls, and converts all the top-level objects used for params and returns to Pigeon objects. However, because of the significant object graph, in order to somewhat limit the scope of this PR I made a cut at that layer in the object graph, with nested objects still using the existing JSON serialization. In a follow-up PR, those will be converted to typed Pigeon objects as well, completing the transition.

Unfortunately a significant amount of JSON code can't be removed yet even though it's now unused by the plugin, because it's part of the API of the public wrappers, so clients may be using it. Once all the JSON code is unused, we could @Deprecated all of it, and then could do a follow-up breaking change later to remove it.

Most of flutter/flutter#117910

Pre-launch Checklist

@stuartmorgan-g stuartmorgan-g changed the title [in_app_purchase] Convert to Pigeon [in_app_purchase] Mostly convert to Android Pigeon Mar 12, 2024
@stuartmorgan-g stuartmorgan-g marked this pull request as ready for review March 12, 2024 17:57
@stuartmorgan-g
Copy link
Contributor Author

This should be ready to review. There's a lot of code, but I went ahead and did all the methods in one PR since having a hybrid of manual method channel code and Pigeon code was kind of weird, particularly in tests. Each method is its own commit though, so it's possible to review incrementally, and I could cut it up if preferred. (It might be useful to look at one incremental commit to see the pattern, and then review in bulk after that?)

@reidbaker If you could give this a manual sanity test, that would be great, since I don't have a setup to be able to do actual end-to-end tests.

},
)) ??
<String, dynamic>{});
// TODO(stuartmorgan): Investigate whether forceOkResponseCode is actually
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reidbaker @gmackall FYI, someone who can dig into the expected behavior should probably take a look at this ASAP. This is a Dart conversion of this code, but for the reasons explained in this comment, I'm pretty skeptical that the Java code was correct. I deliberately didn't change it here since this PR is supposed to be a functional no-op, but I did want to flag it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the code you have as is for this pr.

billingResult -> {
result.success(fromBillingResult(billingResult));
});
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add all of these try/catch wrappers to all the *Async methods because it turns out the plugin is relying on them as part of its API 🙁. We have an integration test that checks that when we pass an empty product query, for instance, that we get back a platform exception (with a specific string, even though we don't control that string, so that could be fun someday).

Ideally we should be preventing invalid cases explicitly instead, but that would change behavior. These FlutterErrors match the generic error made by the method channel code in the engine, so it's doing the same thing, it's just more explicit now (which means more boilerplate than pre-Pigeon, but also that we can see the anti-pattern—and the need to fix it—more clearly).

Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (billingClientError(result)) {
public void showAlternativeBillingOnlyInformationDialog(
@NonNull Result<PlatformBillingResult> result) {
if (billingClient == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a behavior change for "endConnection" It used to be safe to call multiple times aka on a null billing client and with this check is is no longer ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm there is no longer a shared onMethodCall.


assertEquals(billingResultMap.get("responseCode"), newBillingResult.getResponseCode());
assertEquals(billingResultMap.get("debugMessage"), newBillingResult.getDebugMessage());
assertEquals(platformResult.getResponseCode().longValue(), newBillingResult.getResponseCode());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd that we would need to get a long value here are you sure it is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where I have these in tests it's because the Java compiler was angry at me for trying to pass a Long and a long (or sometimes int) to assertEquals, which wants the same kind of object.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 3, 2024
@auto-submit auto-submit bot merged commit 0e848fa into flutter:main Apr 3, 2024
@stuartmorgan-g stuartmorgan-g deleted the iap-android-pigeon branch April 3, 2024 14:56
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 3, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 3, 2024
flutter/packages@83f3842...0e848fa

2024-04-03 [email protected] [in_app_purchase] Mostly convert to Android Pigeon (flutter/packages#6262)
2024-04-02 [email protected] [various] Remove all traces of the `_ambiguate` workaround (flutter/packages#6449)
2024-04-02 [email protected] Roll Flutter from 7fa932b to a418568 (5 revisions) (flutter/packages#6450)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request Apr 8, 2024
Follow-up to #6262, converting the nested data objects from the legacy JSON conversion to typed Pigeon objects.

Deprecates all the JSON code in the wrapper objects, but does not remove it because, unfortunately, the wrapper objects were both platform data transfer objects *and* the public API surface, so the JSON serialization/deserialization code that was part of those objects for platform channel usage is part of the public API as well. At some point we can do a breaking change to clean up that code (flutter/flutter#146202).

Fixes flutter/flutter#117910
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
Replaces manual method channels with Pigeon.

This replaces all of the method calls in both direction with Pigeon calls, and converts all the top-level objects used for params and returns to Pigeon objects. However, because of the significant object graph, in order to somewhat limit the scope of this PR I made a cut at that layer in the object graph, with nested objects still using the existing JSON serialization. In a follow-up PR, those will be converted to typed Pigeon objects as well, completing the transition.

Unfortunately a significant amount of JSON code can't be removed yet even though it's now unused by the plugin, because it's part of the API of the public wrappers, so clients may be using it. Once all the JSON code is unused, we could `@Deprecated` all of it, and then could do a follow-up breaking change later to remove it.

Most of flutter/flutter#117910
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
Follow-up to flutter#6262, converting the nested data objects from the legacy JSON conversion to typed Pigeon objects.

Deprecates all the JSON code in the wrapper objects, but does not remove it because, unfortunately, the wrapper objects were both platform data transfer objects *and* the public API surface, so the JSON serialization/deserialization code that was part of those objects for platform channel usage is part of the public API as well. At some point we can do a breaking change to clean up that code (flutter/flutter#146202).

Fixes flutter/flutter#117910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: in_app_purchase platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants