Skip to content

deprecate Android announcement events and add deprecation warning.#165195

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
ash2moon:master2
Mar 20, 2025
Merged

deprecate Android announcement events and add deprecation warning.#165195
auto-submit[bot] merged 6 commits into
flutter:masterfrom
ash2moon:master2

Conversation

@ash2moon

@ash2moon ash2moon commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

Due to this Android deprecation Flutter needs to show deprecation warnings to developers when using announce on Android.

Unfortunately testing this log statement is impossible since robolectric currently does not support API >=36.
#165220 will add the test code in once robolectric supports 36.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@ash2moon ash2moon requested a review from a team March 14, 2025 14:41
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added platform-android Android applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) labels Mar 14, 2025
Comment on lines +306 to +312
if (Build.VERSION.SDK_INT >= API_LEVELS.API_36) {
Log.w(
TAG,
"Using AnnounceSemanticsEvent for accessibility is deprecated on Android. "
+ "Migrate to using semantic properties for a more robust and accessible "
+ "user experience");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried adding a test for this log, but the problem is that robolectric does not support API 36 yet so there's no way of testing this if statement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

File an issue and link that issue here. It is fine that we cant test something with roboletric that isn't supported.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just created it: robolectric/robolectric#10103
Adding it to my PR description now too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please close that. We dont need to bother the robolectric team they know they need to add support for api 36. I meant file a bug against us to add the test once there is a version we can support.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah gotcha, sorry that makes much more sense! Just added that issue:
#165220

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also if there is android owned public documentation can you link to that?
Maybe https://developer.android.com/reference/android/view/View#announceForAccessibility(java.lang.CharSequence)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, added this.

Comment thread engine/src/flutter/shell/platform/android/io/flutter/Build.java
@matanlurey

Copy link
Copy Markdown
Contributor

test-exempt: Not supported by platform infrastructure.

@reidbaker reidbaker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

approve % removal of flutter_min or re-add of @VisibleForTesting annotation.

Comment thread engine/src/flutter/shell/platform/android/io/flutter/Build.java
Comment thread engine/src/flutter/shell/platform/android/io/flutter/Build.java
Comment on lines +306 to +312
if (Build.VERSION.SDK_INT >= API_LEVELS.API_36) {
Log.w(
TAG,
"Using AnnounceSemanticsEvent for accessibility is deprecated on Android. "
+ "Migrate to using semantic properties for a more robust and accessible "
+ "user experience");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also if there is android owned public documentation can you link to that?
Maybe https://developer.android.com/reference/android/view/View#announceForAccessibility(java.lang.CharSequence)

@ash2moon ash2moon added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
Comment thread engine/src/flutter/shell/platform/android/io/flutter/Build.java
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
@auto-submit

auto-submit Bot commented Mar 18, 2025

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/165195, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@ash2moon ash2moon added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
@auto-submit

auto-submit Bot commented Mar 19, 2025

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/165195, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
@ash2moon ash2moon added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
@auto-submit auto-submit Bot added this pull request to the merge queue Mar 19, 2025
Merged via the queue into flutter:master with commit ecbb115 Mar 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
auto-submit Bot pushed a commit that referenced this pull request Apr 21, 2025
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:
What is the link to the issue this cherry-pick is addressing?

This was a follow-up to #165195 and part of issue #165510

### Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples

Developer warning message in `SemanticService.announce` is not clear when using internal flutter widgets.

### Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

Developers see non-actionable warning messages when Accessibility Services are on and developers are using widgets like TimePicker, DatePicker, ExpansionTile, and Form.

### Workaround:
Is there a workaround for this issue?

No workaround.

### Risk:
What is the risk level of this cherry-pick?

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

### Validation Steps:
What are the steps to validate that this fix works?

Run the example below: https://github.com/flutter/flutter/blob/5491c8c146441d3126aff91beaa3fb5df6d710d0/examples/api/lib/material/time_picker/show_time_picker.0.dart#L10

When opening the time picker, the corrected warning message should show.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
zhangyuang pushed a commit to zhangyuang/flutter-fork that referenced this pull request Jun 9, 2025
…lutter#165195)

Due to this [Android
deprecation](https://developer.android.com/reference/android/view/View#announceForAccessibility(java.lang.CharSequence))
Flutter needs to show deprecation warnings to developers when using
announce on Android.

Unfortunately testing this log statement is impossible since robolectric
currently does not support API >=36.
flutter#165220 will add the test code
in once robolectric supports 36.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
…lutter#165195)

Due to this [Android
deprecation](https://developer.android.com/reference/android/view/View#announceForAccessibility(java.lang.CharSequence))
Flutter needs to show deprecation warnings to developers when using
announce on Android.

Unfortunately testing this log statement is impossible since robolectric
currently does not support API >=36.
flutter#165220 will add the test code
in once robolectric supports 36.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) engine flutter/engine related. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants