public static bool IsSameNode(AccessibilityNodeInfo node1, AccessibilityNodeInfo node2)
 {
     if (node1 != null && node2 != null)
     {
         return(node1.Equals(node2) || node1.GetHashCode() == node2.GetHashCode());
     }
     return(false);
 }
Esempio n. 2
0
 public static bool IsSameNode(AccessibilityNodeInfo info1, AccessibilityNodeInfo info2)
 {
     if (info1 != null && info2 != null)
     {
         return(info1.Equals(info2) || info1.GetHashCode() == info2.GetHashCode());
     }
     return(false);
 }
        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);
        }