Пример #1
0
 /// <summary>
 /// Resolves the link to the true path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 /// <workitem id="19712">Uses "ls -l" to resolve links</workitem>
 public string ResolveLink(string path)
 {
     if (this.Device.BusyBox.Available)
     {
         var cresult = new CommandResultReceiver( );
         this.Device.BusyBox.ExecuteShellCommand("readlink -f {0}", cresult, path);
         // if cresult is empty, return the path
         return((cresult == null || string.IsNullOrEmpty(cresult.Result)) ? path : cresult.Result);
     }
     else
     {
         try {
             // this uses the ls command to get the link path
             var receiver = new LinkResoverReceiver( );
             Device.ExecuteShellCommand("ls {0} -l".With(path.ToArgumentSafe( )), receiver);
             if (!string.IsNullOrEmpty(receiver.ResolvedPath))
             {
                 return(receiver.ResolvedPath);
             }
         } catch (Exception e) {
             Log.d("FileSytem", e.Message);
         }
         return(path);
     }
 }
Пример #2
0
 /// <summary>
 /// Resolves the link to the true path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 /// <workitem id="19712">Uses "ls -l" to resolve links</workitem>
 public string ResolveLink(string path )
 {
     if ( this.Device.BusyBox.Available ) {
         var cresult = new CommandResultReceiver ( );
         this.Device.BusyBox.ExecuteShellCommand ( "readlink -f {0}", cresult, path );
         // if cresult is empty, return the path
         return ( cresult == null || string.IsNullOrEmpty ( cresult.Result ) ) ? path : cresult.Result;
     } else {
         try {
             // this uses the ls command to get the link path
             var receiver = new LinkResoverReceiver ( );
             Device.ExecuteShellCommand ( "ls {0} -l".With ( path.ToArgumentSafe ( ) ), receiver );
             if ( !string.IsNullOrEmpty ( receiver.ResolvedPath ) ) {
                 return receiver.ResolvedPath;
             }
         } catch ( Exception e ) {
             Log.d ( "FileSytem", e.Message );
         }
         return path;
     }
 }
Пример #3
0
 bool? IsWifiDirectGroupOwner(AndroidDevice device)
 // Is this guy the group owner of a Wifi Direct Group?
     {
     try {
         // Example response:
         //  p2p0: ip 192.168.49.1 mask 255.255.255.0 flags [up broadcast running multicast]
         CommandResultReceiver rcvr = new CommandResultReceiver();
         AdbHelper.Instance.ExecuteRemoteCommand(AndroidDebugBridge.AdbServerSocketAddress, "ifconfig p2p0", device.SerialNumbers[0], rcvr);
         string regex=$"p2p0: ip ({Device.RegExIpAddr}) mask {Device.RegExIpAddr} flags \\[([a-zA-Z ]*)\\]";
         Match match = Regex.Match(rcvr.Result, regex, RegexOptions.Compiled|RegexOptions.IgnoreCase|RegexOptions.Singleline);
         if (match.Success && match.Groups[1].Value==AndroidDevice.WifiDirectIPAddress.ToString())
             {
             string[] splits = match.Groups[2].Value.ToLowerInvariant().Split(' ');
             if (splits.Contains("up"))
                 {
                 return true;
                 }
             }
         }
     catch (Exception)
         {
         return null;
         }
     return false;
     }