Beispiel #1
0
        /// <summary>
        /// Get a system property of a device.
        /// Throws an exception when the request fails.
        /// </summary>
        public static string GetProperty(IDevice device, string propertyName, int timeout, bool errorIfFailed = true)
        {
            var receiver = new StringShellOutputReceiver();

            using (var socket = new AdbRequest(EndPoint))
            {
                try
                {
                    socket.ExecuteShellCommand(receiver, device, timeout, "getprop", propertyName);
                }
                catch (Exception ex)
                {
                    if (errorIfFailed)
                    {
                        throw new AdbException(string.Format("Failed to get property because: {0}", ex.Message));
                    }
                    return(null);
                }
            }
            var result = receiver.ToString().Trim(' ', '\t', '\n', '\r');

            return(string.IsNullOrEmpty(result) ? null : result);
        }
Beispiel #2
0
 /// <summary>
 /// Get a system property of a device.
 /// Throws an exception when the request fails.
 /// </summary>
 public static string GetProperty(IDevice device, string propertyName, int timeout, bool errorIfFailed = true)
 {
     var receiver = new StringShellOutputReceiver();
     using (var socket = new AdbRequest(EndPoint))
     {
         try
         {
             socket.ExecuteShellCommand(receiver, device, timeout, "getprop", propertyName);
         }
         catch (Exception ex)
         {
             if (errorIfFailed)
             {
                 throw new AdbException(string.Format("Failed to get property because: {0}", ex.Message));
             }
             return null;
         }
     }
     var result = receiver.ToString().Trim(' ', '\t', '\n', '\r');
     return string.IsNullOrEmpty(result) ? null : result;
 }