예제 #1
0
 public ICommandProcedure OpenCommand(string commandName, params string[] args)
 {
     lock (openCommandLock)
     {
         var commandProcedure = new CommandProcedure(commandName, args);
         commandProcedure.Disposed += CommandProcedure_Disposed;
         notDisposeds?.Add(commandProcedure);
         return(commandProcedure);
     }
 }
예제 #2
0
 public ICommandProcedure OpenCommand(string commandName, params string[] args)
 {
     lock (openCommandLock)
     {
         var commandProcedure = new CommandProcedure()
         {
             FileName  = commandName,
             Arguments = string.Join(" ", args)
         };
         commandProcedure.InitializeAdbEnvironment(this.adbClientDir, this.adbPort);
         commandProcedure.Disposed += CommandProcedure_Disposed;
         notDisposeds?.Add(commandProcedure);
         return(commandProcedure);
     }
 }
예제 #3
0
        protected virtual void KillServer()
        {
            lock (concurrentLock)
            {
                using var cmd = new CommandProcedure()
                      {
                          FileName      = AdbExecutableFile.ToString(),
                          Arguments     = $"-P{ServerEndPoint.Port} kill-server",
                          DirectExecute = true,
                      };
                cmd.InitializeAdbEnvironment(AdbClientDirectory, (ushort)ServerEndPoint.Port);

                new LocalAdbServerKiller(cmd).Kill().Wait();

                SLogger.Info(this, "Adb Server has been stopped.");
            }
        }
예제 #4
0
        protected virtual IPEndPoint StartServer(ushort port = 6605)
        {
            using var cmd = new CommandProcedure()
                  {
                      FileName      = AdbExecutableFile.ToString(),
                      Arguments     = $"-P{port} start-server",
                      DirectExecute = true,
                  };
            cmd.InitializeAdbEnvironment(AdbClientDirectory, port);

            int line = 0;

            cmd.OutputReceived += (s, e) =>
            {
                line++;
                SLogger.Info(this, $"statring adb server {line}:{e.Text}");
            };
            cmd.Execute();
            return(new IPEndPoint(IPAddress.Parse("127.0.0.1"), port));
        }
예제 #5
0
        protected virtual void KillServer()
        {
            lock (concurrentLock)
            {
                using var cmd = new CommandProcedure()
                      {
                          FileName      = AdbExecutableFile.ToString(),
                          Arguments     = $"-P{ServerEndPoint.Port} kill-server",
                          DirectExecute = true,
                      };
                cmd.InitializeAdbEnvironment(AdbClientDirectory, (ushort)ServerEndPoint.Port);

                int line = 0;
                cmd.OutputReceived += (s, e) =>
                {
                    line++;
                    SLogger.Info(this, $"killing adb server {line}:{e.Text}");
                };
                cmd.Execute();
                SLogger.Info(this, "server killed");
            }
        }
예제 #6
0
 /// <summary>
 /// 初始化ADB环境
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="dir"></param>
 /// <param name="port"></param>
 public static void InitializeAdbEnvironment(this CommandProcedure cmd, DirectoryInfo dir, ushort port)
 {
     cmd.ExtraPathVariables.Add(dir.FullName);
     cmd.ExtraEnvironmentVariables[ENV_KEY_ANDROID_ADB_SERVER_PORT] = port.ToString();
 }