public static string GetUri(AccessibilityNodeInfo root) { var uri = string.Concat(Constants.AndroidAppProtocol, root.PackageName); if (SupportedBrowsers.ContainsKey(root.PackageName)) { var browser = SupportedBrowsers[root.PackageName]; AccessibilityNodeInfo addressNode = null; foreach (var uriViewId in browser.UriViewId.Split(",")) { addressNode = root.FindAccessibilityNodeInfosByViewId( $"{root.PackageName}:id/{uriViewId}").FirstOrDefault(); if (addressNode != null) { break; } } if (addressNode != null) { uri = ExtractUri(uri, addressNode, browser); addressNode.Recycle(); } else { // Return null to prevent overwriting notification pendingIntent uri with browser packageName // (we login to pages, not browsers) return(null); } } return(uri); }
private void CancelOverlayPrompt() { _overlayAnchorObserverRunning = false; if (_windowManager != null && _overlayView != null) { try { _windowManager.RemoveViewImmediate(_overlayView); System.Diagnostics.Debug.WriteLine(">>> Accessibility Overlay View Removed"); } catch { } } _overlayView = null; _lastAnchorX = 0; _lastAnchorY = 0; _isOverlayAboveAnchor = false; if (_anchorNode != null) { _anchorNode.Recycle(); _anchorNode = null; } }
public static NodeList GetWindowNodes(AccessibilityNodeInfo n, AccessibilityEvent e, Func <AccessibilityNodeInfo, bool> condition, bool disposeIfUnused, NodeList nodes = null, int recursionDepth = 0) { if (nodes == null) { nodes = new NodeList(); } var dispose = disposeIfUnused; if (n != null && recursionDepth < 100) { var add = n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && condition(n); if (add) { dispose = false; nodes.Add(n); } for (var i = 0; i < n.ChildCount; i++) { var childNode = n.GetChild(i); if (childNode == null) { continue; } else if (i > 100) { Android.Util.Log.Info(BitwardenTag, "Too many child iterations."); break; } else if (childNode.GetHashCode() == n.GetHashCode()) { Android.Util.Log.Info(BitwardenTag, "Child node is the same as parent for some reason."); } else { GetWindowNodes(childNode, e, condition, true, nodes, recursionDepth++); } } } if (dispose) { n?.Recycle(); n?.Dispose(); } return(nodes); }