Browse Source
Fix unexpected crashes during accessibility actions. (#20687)
dev/timill/macos-setup-app
SunnyDesignor
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
21 additions and
1 deletions
-
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)) |
|
|
|
|