public static String pathToNode(AccessibilityNodeInfo nodeInfo){
  AccessibilityNodeInfo origin=nodeInfo;
  List<AccessibilityNodeInfoSpec> list=new ArrayList<AccessibilityNodeInfoSpec>();
  list.add(0,new AccessibilityNodeInfoSpec(0,nodeInfo.getClassName()));
  AccessibilityNodeInfo parent=nodeInfo.getParent();
  while (parent != null) {
    int index=0;
    for (int i=0; i < parent.getChildCount(); i++) {
      AccessibilityNodeInfo child=parent.getChild(i);
      if (child != null && child.equals(nodeInfo)) {
        index=i;
        break;
      }
    }
    list.add(0,new AccessibilityNodeInfoSpec(index,parent.getClassName()));
    nodeInfo=parent;
    parent=nodeInfo.getParent();
  }
  list.add(0,new AccessibilityNodeInfoSpec(0,nodeInfo.getClassName()));
  String string=TextUtils.join(Element.CHAR_SP_NEXT,list) + withNodeInfo(origin);
  return string;
}

public static String pathToNode ( AccessibilityNodeInfo nodeInfo ) { AccessibilityNodeInfo origin = nodeInfo ; List < AccessibilityNodeInfoSpec > list = new ArrayList < AccessibilityNodeInfoSpec > ( ) ; list . add ( 0 , new AccessibilityNodeInfoSpec ( 0 , nodeInfo . getClassName ( ) ) ) ; AccessibilityNodeInfo parent = nodeInfo . getParent ( ) ; while ( parent != null ) { int index = 0 ; for ( int i = 0 ; i < parent . getChildCount ( ) ; i ++ ) { AccessibilityNodeInfo child = parent . getChild ( i ) ; if ( child != null && child . equals ( nodeInfo ) ) { index = i ; break ; } } list . add ( 0 , new AccessibilityNodeInfoSpec ( index , parent . getClassName ( ) ) ) ; nodeInfo = parent ; parent = nodeInfo . getParent ( ) ; } list . add ( 0 , new AccessibilityNodeInfoSpec ( 0 , nodeInfo . getClassName ( ) ) ) ; String string = TextUtils . join ( Element . CHAR_SP_NEXT , list ) + withNodeInfo ( origin ) ; return string ; }
print the path from root to this node
