示例#1
0
 /// <summary>
 /// Keep reading log messages until cancelled by the listener or closed.
 /// </summary>
 public void RunLogService(ILogListener listener, IDevice device, string logName)
 {
     using (var socket = new AdbRequest(EndPoint))
     {
         socket.RunLogService(listener, device, logName);
     }
 }
示例#2
0
        /// <summary>
        /// Start an given activity in the given package.
        /// Throws an exception when starting fails.
        /// </summary>
        public void StartActivity(IDevice device, string packageName, string activityName, bool debuggable, int timeout, IStartActivityListener listener)
        {
            var component = packageName + "/" + activityName;
            var receiver  = new StartActivityReceiver(listener);

            using (var socket = new AdbRequest(EndPoint))
            {
                try
                {
                    var args = new List <string>();
                    args.Add("start");
                    if (debuggable)
                    {
                        args.Add("-D");
                    }
                    args.Add("-n");
                    args.Add(component);
                    socket.ExecuteShellCommand(receiver, device, timeout, "am", args.ToArray());
                }
                catch (Exception ex)
                {
                    throw new AdbException(string.Format("Failed to start activity because: {0}", ex.Message));
                }
            }
        }
示例#3
0
 /// <summary>
 /// Connect local port to JDWP thread on VM process pid.
 /// </summary>
 public void ForwardJdwp(IDevice device, int localPort, int pid)
 {
     using (var socket = new AdbRequest(EndPoint))
     {
         try
         {
             socket.ForwardJdwp(device, localPort, pid);
         }
         catch (Exception ex)
         {
             throw new AdbException(string.Format("Failed to start activity because: {0}", ex.Message));
         }
     }
 }
示例#4
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);
        }
示例#5
0
文件: Adb.cs 项目: Xtremrules/dot42
 /// <summary>
 /// Keep reading log messages until cancelled by the listener or closed.
 /// </summary>
 public void RunLogService(ILogListener listener, IDevice device, string logName)
 {
     using (var socket = new AdbRequest(EndPoint))
     {
         socket.RunLogService(listener, device, logName);
     }            
 }
示例#6
0
文件: Adb.cs 项目: Xtremrules/dot42
 /// <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;
 }
示例#7
0
文件: Adb.cs 项目: Xtremrules/dot42
 /// <summary>
 /// Connect local port to JDWP thread on VM process pid.
 /// </summary>
 public void ForwardJdwp(IDevice device, int localPort, int pid)
 {
     using (var socket = new AdbRequest(EndPoint))
     {
         try
         {
             socket.ForwardJdwp(device, localPort, pid);
         }
         catch (Exception ex)
         {
             throw new AdbException(string.Format("Failed to start activity because: {0}", ex.Message));
         }
     }
 }
示例#8
0
文件: Adb.cs 项目: Xtremrules/dot42
 /// <summary>
 /// Start an given activity in the given package.
 /// Throws an exception when starting fails.
 /// </summary>
 public void StartActivity(IDevice device, string packageName, string activityName, bool debuggable, int timeout, IStartActivityListener listener)
 {
     var component = packageName + "/" + activityName;
     var receiver = new StartActivityReceiver(listener);
     using (var socket = new AdbRequest(EndPoint))
     {
         try
         {
             var args = new List<string>();
             args.Add("start");
             if (debuggable) args.Add("-D");
             args.Add("-n");
             args.Add(component);
             socket.ExecuteShellCommand(receiver, device, timeout, "am", args.ToArray());
         }
         catch (Exception ex)
         {
             throw new AdbException(string.Format("Failed to start activity because: {0}", ex.Message));
         }
     }
 }