示例#1
0
        protected override Task <ExitCode> InvokeInternal(ILogger logger)
        {
            logger.LogInformation("Getting state of ADB and attached Android device(s)");
            try
            {
                var    runner = new AdbRunner(logger);
                string state  = runner.GetAdbState();
                if (string.IsNullOrEmpty(state))
                {
                    state = "No device attached";
                }
                logger.LogInformation($"ADB Version info:{Environment.NewLine}{runner.GetAdbVersion()}");
                logger.LogInformation($"ADB State ('device' if physically attached):{Environment.NewLine}{state}");

                logger.LogInformation($"List of devices:");
                var deviceAndArchList = runner.GetAttachedDevicesWithProperties("architecture");
                foreach (string device in deviceAndArchList.Keys)
                {
                    logger.LogInformation($"Device: '{device}' - Architecture: {deviceAndArchList[device]}");
                }

                return(Task.FromResult(ExitCode.SUCCESS));
            }
            catch (Exception toLog)
            {
                logger.LogCritical(toLog, $"Error: {toLog.Message}");
                return(Task.FromResult(ExitCode.GENERAL_FAILURE));
            }
        }
示例#2
0
        public void GetAdbState()
        {
            var    runner = new AdbRunner(_mainLog.Object, _processManager.Object, s_adbPath);
            string result = runner.GetAdbState();

            _processManager.Verify(pm => pm.Run(s_adbPath, "get-state", TimeSpan.FromMinutes(5)), Times.Once);
            Assert.Equal("device", result);
        }
示例#3
0
    public void GetAdbState()
    {
        var    runner = new AdbRunner(_mainLog.Object, _processManager.Object, s_adbPath);
        string result = runner.GetAdbState();

        VerifyAdbCall("get-state");
        Assert.Equal("device", result);
    }
示例#4
0
 protected override Task <ExitCode> InvokeInternal()
 {
     _log.LogInformation("Getting state of ADB and attached Android device(s)");
     try
     {
         var    runner = new AdbRunner(_log);
         string state  = runner.GetAdbState();
         if (string.IsNullOrEmpty(state))
         {
             state = "No device attached";
         }
         _log.LogInformation($"ADB Version info:{Environment.NewLine}{runner.GetAdbVersion()}");
         _log.LogInformation($"ADB State ('device' if physically attached):{Environment.NewLine}{state}");
         return(Task.FromResult(ExitCode.SUCCESS));
     }
     catch (Exception toLog)
     {
         _log.LogCritical(toLog, $"Error: {toLog.Message}");
         return(Task.FromResult(ExitCode.GENERAL_FAILURE));
     }
 }