-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Wires up Android API to set section locale #173364
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
base: master
Are you sure you want to change the base?
Conversation
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.
Code Review
This pull request wires up the Android accessibility API to support setting a locale on a semantics node. The changes span from the UI layer in C++ down to the Android platform-specific Java code. My review includes a few suggestions: fixing a bug in a new unit test, using the correct log level for a debug message, and removing an unused parameter from a function signature. Overall, the changes look good and the new test coverage is appreciated.
.../platform/android/platform_view_android_delegate/platform_view_android_delegate_unittests.cc
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
CI had a failure that stopped further tests from running. We need to investigate to determine the root cause. SHA at time of execution: 494a34b. Possible causes:
A blank commit, or merging to head, will be required to resume running CI for this PR. Error Details:
Stack trace:
|
1519545
to
a946cbb
Compare
/gemini review |
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.
Code Review
This pull request wires up the Android accessibility API to support setting a locale on a semantics node. The changes span across Dart, C++, and Java to pass the locale information from the framework to the Android accessibility services. The implementation is mostly correct, but I've found a critical issue in the Java code where an incorrect locale format will cause a runtime crash. I've also pointed out an unused parameter in the C++ code that should be addressed.
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
@@ -69,7 +69,9 @@ void SemanticsUpdateBuilder::updateNode( | |||
std::string linkUrl, | |||
int role, | |||
const std::vector<std::string>& controlsNodes, | |||
int validationResult) { | |||
int validationResult, | |||
int inputType, |
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.
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 this bot comment correct?
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.
it is not used because there is no usage outside of web (this file is the glue code for non-web engine), but i have to keep it here because this is a positional parameter so that I can use the locale parameter
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
if (node.locale.empty()) { | ||
buffer_int32[position++] = -1; | ||
} else { | ||
buffer_int32[position++] = strings.size(); | ||
strings.push_back(node.locale); | ||
} | ||
|
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.
No change you need to make but this makes me sad to review. This type of message passing is so easy to mess up in a way that is hard for authors or reviewers to realize. There are formats for passing data via strings and the conversion code is all generated.
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.
There are formats for passing data via strings and the conversion code is all generated.
Do you have example? I only know json, but think that may not be efficient
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.
protobuffs, msgpack, even pigeon which we maintain lets authors author a platform independent object that is typesafe after serialization across the wire.
@@ -266,6 +266,13 @@ void PlatformViewAndroidDelegate::UpdateSemantics( | |||
strings.push_back(node.linkUrl); | |||
} | |||
|
|||
if (node.locale.empty()) { |
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.
Somewhere in this code please articulate the meaning of the magical number -1 when used in the local location and the expected format of the local string. Especially if the assumption is for it to match some standard.
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 refactored out the code so less duplicate, but I am not sure how can i addressed the magical number -1 here since defining a constant won't be useful outside this class (it can't be use from java side when decoding the buffer)
@@ -69,7 +69,9 @@ void SemanticsUpdateBuilder::updateNode( | |||
std::string linkUrl, | |||
int role, | |||
const std::vector<std::string>& controlsNodes, | |||
int validationResult) { | |||
int validationResult, | |||
int inputType, |
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 this bot comment correct?
6ebed01
to
c3fa588
Compare
5fc4116
to
1d44e84
Compare
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.
Couple of comments, In addition to my review please get a review from someone who is more comfortable in c++
engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
private static String getStringFromBuffer(@NonNull ByteBuffer buffer, @NonNull String[] strings) { | ||
int stringIndex = buffer.getInt(); | ||
|
||
return stringIndex == -1 ? null : strings[stringIndex]; |
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.
Please make -1 a private constant. Maybe name it NOT_FOUND?
* <p>Use {@code addLocale} to set the locale and/or {@code addUrl} to set the url for the entire | ||
* string. Uses {@code addAttributes} to add any additional {@code StringAttribute} to the string | ||
*/ | ||
private static class AccessibilityStringBuilder { |
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.
Consider putting this into its own file. This file is already pretty large.
expected_strings.push_back(node0.identifier); | ||
buffer_int32[position++] = expected_strings.size(); // node0.label | ||
expected_strings.push_back(node0.label); | ||
buffer_int32[position++] = -1; // node0.labelAttributes |
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.
Thank you for labeling these values it helps with readability.
related #99600
what still missing:
internal only doc: go/flutter-semantics-language
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assist
bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.