Browse Source

Fix unexpected crashes during accessibility actions. (#20687)

dev/timill/macos-setup-app
SunnyDesignor 1 month ago
committed by GitHub
parent
commit
f8a1f2e2aa
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 22
      src/Android/Avalonia.Android/AvaloniaAccessHelper.cs

22
src/Android/Avalonia.Android/AvaloniaAccessHelper.cs

@ -135,10 +135,30 @@ namespace Avalonia.Android
protected override bool OnPerformActionForVirtualView(int virtualViewId, int action, Bundle? arguments)
{
return (GetNodeInfoProvidersFromVirtualViewId(virtualViewId) ?? [])
.Select(x => x.PerformNodeAction(action, arguments))
.Select(x => TryPerformNodeAction(x, action, arguments))
.Aggregate(false, (a, b) => a | b);
}
private static bool TryPerformNodeAction(INodeInfoProvider nodeInfoProvider, int action, Bundle? arguments)
{
try
{
return nodeInfoProvider.PerformNodeAction(action, arguments);
}
catch (ElementNotEnabledException)
{
return false;
}
catch (InvalidOperationException)
{
return false;
}
catch (NotSupportedException)
{
return false;
}
}
protected override void OnPopulateNodeForVirtualView(int virtualViewId, AccessibilityNodeInfoCompat? nodeInfo)
{
if (nodeInfo is null || !_peers.TryGetValue(virtualViewId, out AutomationPeer? peer))

Loading…
Cancel
Save