Repository navigation
Commit 016b17b
authored
[android] Isolate API-34 high contrast listener in AccessibilityBridge behind Api34Impl (flutter#192502)
Isolates API-34 `UiModeManager.ContrastChangeListener` and related
contrast calls in `AccessibilityBridge` inside an
`@RequiresApi(API_LEVELS.API_34)` static holder class (`Api34Impl`) with
`@DoNotInline`.
### Background / Root Cause
On Android 12 and 13 (API < 34), `AccessibilityBridge` previously
evaluated a ternary merge point in `<init>` between a lambda cast to
`(ContrastChangedListener & UiModeManager.ContrastChangeListener)` and a
no-op fallback. D8 desugars this intersection cast into a synthetic
class implementing `UiModeManager.ContrastChangeListener`. Because this
ternary join occurs in `<init>`, the ART verifier attempts to resolve
the synthetic class and its unimplemented interface when loading
`AccessibilityBridge`, failing with `NoClassDefFoundError: Failed
resolution of: Lt2;` (`ClassNotFoundException:
android.app.UiModeManager$ContrastChangeListener`).
By moving all references to `UiModeManager.ContrastChangeListener` into
`Api34Impl` and holding the observer as an `Object` reference on
`AccessibilityBridge`, ART never attempts to load or verify the API-34
types on devices with API < 34.
Fixes flutter#192231
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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.
- [ ] I updated/added relevant in-code documentation (doc comments with
`///`).
- [ ] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[flutter/website]: https://github.com/flutter/website
[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
---
*This pull request was generated with Gemini / AI assistance.*1 parent a0b6113 commit 016b17b
2 files changed
Lines changed: 83 additions & 38 deletions
File tree
- engine/src/flutter/shell/platform/android
- io/flutter/view
- test/io/flutter/view
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
433 | 424 | | |
434 | 425 | | |
435 | 426 | | |
| |||
612 | 603 | | |
613 | 604 | | |
614 | 605 | | |
| 606 | + | |
| 607 | + | |
615 | 608 | | |
616 | | - | |
| 609 | + | |
| 610 | + | |
617 | 611 | | |
618 | 612 | | |
619 | 613 | | |
| |||
651 | 645 | | |
652 | 646 | | |
653 | 647 | | |
654 | | - | |
655 | | - | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
656 | 651 | | |
657 | 652 | | |
658 | 653 | | |
| |||
720 | 715 | | |
721 | 716 | | |
722 | 717 | | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | 718 | | |
742 | 719 | | |
743 | 720 | | |
| |||
748 | 725 | | |
749 | 726 | | |
750 | 727 | | |
751 | | - | |
752 | 728 | | |
753 | 729 | | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
| 730 | + | |
758 | 731 | | |
759 | 732 | | |
760 | 733 | | |
| |||
2999 | 2972 | | |
3000 | 2973 | | |
3001 | 2974 | | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
3002 | 3013 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1579 | 1579 | | |
1580 | 1580 | | |
1581 | 1581 | | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
1582 | 1616 | | |
1583 | 1617 | | |
1584 | 1618 | | |
| |||
0 commit comments