Repository navigation
fix(android): JNI-based setChecked to span AndroidX.Core 1.16/1.17 - #23262
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Android accessibility runtime compatibility issues by avoiding the managed AccessibilityNodeInfoCompat.Checked setter (which can throw MissingMethodException when the app restores a different AndroidX.Core binding version) and instead invoking setChecked via JNI while probing both (Z)V and (I)V signatures.
Changes:
- Replaced the managed
node.Checked = ...assignment with a JNI-based helper call inUnoExploreByTouchHelper. - Added
AccessibilityNodeInfoCompatJnito probe and cache the availablesetCheckedmethod signature at runtime and dispatch accordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Uno.UI.Runtime.Skia.Android/Accessibility/UnoExploreByTouchHelper.cs | Switches checked-state assignment to the new JNI helper to avoid binding mismatches at runtime. |
| src/Uno.UI.Runtime.Skia.Android/Accessibility/AccessibilityNodeInfoCompatJni.cs | Introduces a JNI helper that probes setChecked signatures and calls the available one. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3220e93 to
ced9c85
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23262/wasm-skia-net9/index.html |
ced9c85 to
e933487
Compare
AndroidX.Core 1.17.0 changed the AccessibilityNodeInfoCompat.setChecked binding from setChecked(boolean) to setChecked(int) with state constants. When Uno.UI is compiled against one binding version and the consuming app pulls in the other (e.g. transitively via Sentry), the managed setter throws MissingMethodException at runtime (fixes #22999). This calls setChecked through JNI directly, probing both Java signatures once and dispatching to whichever the loaded binding exposes. The C# Checked property is no longer touched, so the fix stays neutral to the AndroidX.Core version the final app ships - no AndroidX or SupportedOSPlatformVersion bumps required. Alternative path to #23097, which solved the same crash by bumping AppCompat to 1.7.1.3 and cascading the AndroidX stack to minSdk 23. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23262/wasm-skia-net9/index.html |
|
@Mergifyio backport release/stable/6.5 |
✅ Backports have been createdDetails
|
|
@Mergifyio backport release/stable/6.6 |
✅ Backports have been createdDetails
|
…6.6/pr-23262 fix(android): JNI-based setChecked to span AndroidX.Core 1.16/1.17 (backport #23262)
…6.5/pr-23262 fix(android): JNI-based setChecked to span AndroidX.Core 1.16/1.17 (backport #23262)
Summary
Fixes #22999 by calling
AccessibilityNodeInfoCompat.setCheckedthrough JNI rather than the managed C# property.Xamarin.AndroidX.Core 1.17.0changed thesetCheckedbinding fromsetChecked(boolean)tosetChecked(int)(state constants). When Uno.UI is compiled against one binding version and the consuming app pulls in the other transitively (the reported case wasSentry.Bindings.Android≥ 6.2.0 dragging in Core 1.17.0), the managed setter throwsMissingMethodExceptionat runtime.Both binding versions wrap the same underlying Java method whose JNI signature simply changed from
(Z)Vto(I)V. The newAccessibilityNodeInfoCompatJnihelper probes both signatures once on first use and dispatches to whichever the loaded binding exposes — no managed reflection, AOT/trim safe.Alternative to #23097
This is a deliberately narrower path than the already-merged #23097, which solved the same crash by bumping
Xamarin.AndroidX.AppCompat 1.7.0.7 → 1.7.1.3and cascading newer Activity / Fragment / Lifecycle / SavedState / Collection bindings, plus raisingSupportedOSPlatformVersionto 23. That cascade in turn forced uno.templates to either bump matching bindings on its side or ride the new minSdk 23 floor, and brokeMicrosoft.Maui.Controls 10.0.60's transitively-pinned older.Ktxpackages (NU1605/NU1608).The JNI helper here resolves #22999 without touching AppCompat, the surrounding AndroidX stack, the minimum Android API level, or Maui's binding pins. Branch is based on the commit immediately before #23097 merged, so the PR diff shows exactly the cost of the fix.
Test plan
Uno.UI.Runtime.Skia.Androidagainst anAndroidX.Core 1.16.xbaseline (default in the branch's base commit) and confirmnode.Checkedcallers compile and run.Xamarin.AndroidX.Core 1.17.0+(e.g.Sentry.Bindings.Android 6.3.0).ToggleButton/CheckBoxsoUnoExploreByTouchHelper.OnPopulateNodeForVirtualViewruns.MissingMethodExceptionis logged and TalkBack reports the checked state correctly under both Core 1.16.x and 1.17.x.🤖 Generated with Claude Code