-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[google_maps_flutter] Semi-convert remaining Android host API calls to Pigeon #6980
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
[google_maps_flutter] Semi-convert remaining Android host API calls to Pigeon #6980
Conversation
Eliminates the remaining google_maps_flutter cases of the once-common-in-this-repo type abuse of getting a value from a method channel arguments dictionary that may either be type `T` or `NSNull`, but assigning directly to a variable of type `T`, and then later comparing that variable to `NSNull` with a cast to silence the (correct) warning from the compiler. Longer term this will be eliminated entirely when the Pigeon conversion is complete, but currently I expect that in the short term we will only do a "shallow" Pigeon conversion (see flutter#6980 for an Android example), meaning this code will likely stay around for a while.
Eliminates the remaining google_maps_flutter cases of the once-common-in-this-repo type abuse of getting a value from a method channel arguments dictionary that may either be type `T` or `NSNull`, but assigning directly to a variable of type `T`, and then later comparing that variable to `NSNull` with a cast to silence the (correct) warning from the compiler. Longer term this will be eliminated entirely when the Pigeon conversion is complete, but currently I expect that in the short term we will only do a "shallow" Pigeon conversion (see #6980 for an Android example), meaning this code will likely stay around for a while.
case "default": | ||
initializeWithRendererRequest(null); | ||
break; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the default condition no longer possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The special "default" value no longer exists, because requesting the default is now expressed as null
in the Pigeon API, just as it already was at both the Dart API and Maps SDK API levels.
"Renderer initialization called with invalid renderer type", | ||
null); | ||
initializationResult = null; | ||
MapsInitializer.Renderer rendererType = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: move this to a Convert.toMapRendererType
I will understand if you tell me this is overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
break; | ||
default: | ||
initializationResult.error( | ||
"Unknown renderer type", "Initialized with unknown renderer type", null); | ||
new Messages.FlutterError( | ||
"Unknown renderer type", "Initialized with unknown renderer type", null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the argument for keeping this error the same but consider passing the type instead of null so that if we ever hit this condition we might be able to trace why the type was wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added renderer.name()
as the details; we don't like to change errors since it could break people, but adding data that just wasn't there is safe for any but the most contrived case.
@@ -647,42 +1120,88 @@ private PigeonCodec() {} | |||
protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { | |||
switch (type) { | |||
case (byte) 129: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly for future work but consider either extracting these to named constants in this class or putting the byte as a static value on each of the class items then having a list of supported object types that all have a byte identifier and a read/write Value method.
Second pass note: Unless this is generated (which I don't think it is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire file is generated (see comment at the very top). In all other languages we make that clear with a .g.
in the file name, but annoyingly Java doesn't allow that since the file name and the class name have to exactly match.
flutter/packages@412ec46...d2705fb 2024-07-01 [email protected] Roll Flutter from 651a17d to 99bb2ff (10 revisions) (flutter/packages#7038) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.test.espresso:espresso-core from 3.5.1 to 3.6.1 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#7032) 2024-07-01 [email protected] [google_maps_flutter] Semi-convert remaining Android host API calls to Pigeon (flutter/packages#6980) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [local_auth]: Bump androidx.test.espresso:espresso-core from 3.5.1 to 3.6.1 in /packages/local_auth/local_auth_android/android (flutter/packages#7022) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [video_player]: Bump com.android.tools.build:gradle from 7.2.1 to 8.5.0 in /packages/video_player/video_player_android/android (flutter/packages#6931) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.android.tools.build:gradle from 7.3.0 to 8.5.0 in /packages/camera/camera_android/android (flutter/packages#6928) 2024-07-01 [email protected] [ci] Adds @matanlurey to some Android CODEOWNERS until Impeller is enabled. (flutter/packages#7014) 2024-06-29 [email protected] [video_player] Bumps web implementation dependency. (flutter/packages#7015) 2024-06-29 [email protected] Manual roll Flutter from 15f95ce to 651a17d (7 revisions) (flutter/packages#7013) 2024-06-28 [email protected] [flutter_markdown] Add horizontal scroll for markdown table (flutter/packages#6983) 2024-06-28 49699333+dependabot[bot]@users.noreply.github.com Bump ossf/scorecard-action from 2.3.1 to 2.3.3 (flutter/packages#6709) 2024-06-28 [email protected] [google_maps_flutter] Fix Obj-C type handling (flutter/packages#7010) 2024-06-28 [email protected] Manual roll Flutter from e726eb4 to 15f95ce (48 revisions) (flutter/packages#7002) 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
flutter/packages@412ec46...d2705fb 2024-07-01 [email protected] Roll Flutter from 651a17d to 99bb2ff (10 revisions) (flutter/packages#7038) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.test.espresso:espresso-core from 3.5.1 to 3.6.1 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#7032) 2024-07-01 [email protected] [google_maps_flutter] Semi-convert remaining Android host API calls to Pigeon (flutter/packages#6980) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [local_auth]: Bump androidx.test.espresso:espresso-core from 3.5.1 to 3.6.1 in /packages/local_auth/local_auth_android/android (flutter/packages#7022) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [video_player]: Bump com.android.tools.build:gradle from 7.2.1 to 8.5.0 in /packages/video_player/video_player_android/android (flutter/packages#6931) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.android.tools.build:gradle from 7.3.0 to 8.5.0 in /packages/camera/camera_android/android (flutter/packages#6928) 2024-07-01 [email protected] [ci] Adds @matanlurey to some Android CODEOWNERS until Impeller is enabled. (flutter/packages#7014) 2024-06-29 [email protected] [video_player] Bumps web implementation dependency. (flutter/packages#7015) 2024-06-29 [email protected] Manual roll Flutter from 15f95ce to 651a17d (7 revisions) (flutter/packages#7013) 2024-06-28 [email protected] [flutter_markdown] Add horizontal scroll for markdown table (flutter/packages#6983) 2024-06-28 49699333+dependabot[bot]@users.noreply.github.com Bump ossf/scorecard-action from 2.3.1 to 2.3.3 (flutter/packages#6709) 2024-06-28 [email protected] [google_maps_flutter] Fix Obj-C type handling (flutter/packages#7010) 2024-06-28 [email protected] Manual roll Flutter from e726eb4 to 15f95ce (48 revisions) (flutter/packages#7002) 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
flutter/packages@412ec46...d2705fb 2024-07-01 [email protected] Roll Flutter from 651a17d to 99bb2ff (10 revisions) (flutter/packages#7038) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.test.espresso:espresso-core from 3.5.1 to 3.6.1 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#7032) 2024-07-01 [email protected] [google_maps_flutter] Semi-convert remaining Android host API calls to Pigeon (flutter/packages#6980) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [local_auth]: Bump androidx.test.espresso:espresso-core from 3.5.1 to 3.6.1 in /packages/local_auth/local_auth_android/android (flutter/packages#7022) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [video_player]: Bump com.android.tools.build:gradle from 7.2.1 to 8.5.0 in /packages/video_player/video_player_android/android (flutter/packages#6931) 2024-07-01 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.android.tools.build:gradle from 7.3.0 to 8.5.0 in /packages/camera/camera_android/android (flutter/packages#6928) 2024-07-01 [email protected] [ci] Adds @matanlurey to some Android CODEOWNERS until Impeller is enabled. (flutter/packages#7014) 2024-06-29 [email protected] [video_player] Bumps web implementation dependency. (flutter/packages#7015) 2024-06-29 [email protected] Manual roll Flutter from 15f95ce to 651a17d (7 revisions) (flutter/packages#7013) 2024-06-28 [email protected] [flutter_markdown] Add horizontal scroll for markdown table (flutter/packages#6983) 2024-06-28 49699333+dependabot[bot]@users.noreply.github.com Bump ossf/scorecard-action from 2.3.1 to 2.3.3 (flutter/packages#6709) 2024-06-28 [email protected] [google_maps_flutter] Fix Obj-C type handling (flutter/packages#7010) 2024-06-28 [email protected] Manual roll Flutter from e726eb4 to 15f95ce (48 revisions) (flutter/packages#7002) 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
…geon (#7079) Does a "shallow" Pigeon conversion of the remaining host API calls in the iOS implementation. All of the actual method calls are now Pigeon, but for the most part the data structures are not yet converted, and the Pigeon representations of the map objects are instead placeholders that currently just wrap the existing JSON serialization. This is done for a few reasons: - Keeps the incremental PR relatively small and easy to understand. - Quickly gets us to a state where any new APIs added will automatically use Pigeon, reducing further accumulation of technical debt. - Avoids duplication of handling code until flutter/flutter#150631 is resolved. As noted in a TODO added in this PR, almost all of the data structures that are passed in these methods are also passed through the PlatformView factory constructor, and Pigeon doesn't yet support using the Pigeon codec in non-Pigeon-generated code, so we would need to have both the structured *and* JSON handler for all of these objects if we converted them now. Future PRs will be able to incrementally convert each map object to a structured form. Converting the Flutter APIs (Java->Dart) will also be done in a follow-up, to limit the scope of this PR. This is the iOS equivalent of #6980, and the Dart code is largely the same. Part of flutter/flutter#117907
Eliminates the remaining google_maps_flutter cases of the once-common-in-this-repo type abuse of getting a value from a method channel arguments dictionary that may either be type `T` or `NSNull`, but assigning directly to a variable of type `T`, and then later comparing that variable to `NSNull` with a cast to silence the (correct) warning from the compiler. Longer term this will be eliminated entirely when the Pigeon conversion is complete, but currently I expect that in the short term we will only do a "shallow" Pigeon conversion (see flutter/packages#6980 for an Android example), meaning this code will likely stay around for a while.
…geon (#7079) Does a "shallow" Pigeon conversion of the remaining host API calls in the iOS implementation. All of the actual method calls are now Pigeon, but for the most part the data structures are not yet converted, and the Pigeon representations of the map objects are instead placeholders that currently just wrap the existing JSON serialization. This is done for a few reasons: - Keeps the incremental PR relatively small and easy to understand. - Quickly gets us to a state where any new APIs added will automatically use Pigeon, reducing further accumulation of technical debt. - Avoids duplication of handling code until flutter/flutter#150631 is resolved. As noted in a TODO added in this PR, almost all of the data structures that are passed in these methods are also passed through the PlatformView factory constructor, and Pigeon doesn't yet support using the Pigeon codec in non-Pigeon-generated code, so we would need to have both the structured *and* JSON handler for all of these objects if we converted them now. Future PRs will be able to incrementally convert each map object to a structured form. Converting the Flutter APIs (Java->Dart) will also be done in a follow-up, to limit the scope of this PR. This is the iOS equivalent of flutter/packages#6980, and the Dart code is largely the same. Part of flutter/flutter#117907
Does a "shallow" Pigeon conversion of the remaining host API calls in the Android implementation. All of the actual method calls are now Pigeon, but for the most part the data structures are not yet converted, and the Pigeon representations of the map objects are instead placeholders that currently just wrap the existing JSON serialization. This is done for a few reasons:
Future PRs will be able to incrementally convert each map object to a structured form. Converting the Flutter APIs (Java->Dart) will also be done in a follow-up, to limit the scope of this PR.
Adds Dart unit tests for each method call, as they were previously not unit tested.
Part of flutter/flutter#117907
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).