コード例 #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 ListDevicesAndArchitectures()
        {
            var runner = new AdbRunner(_mainLog.Object, _processManager.Object, s_adbPath);
            var result = runner.GetAttachedDevicesWithProperties("architecture");

            _processManager.Verify(pm => pm.Run(s_adbPath, "devices -l", TimeSpan.FromSeconds(30)), Times.Once);

            // Ensure it called, parsed the three random device names and found all three architectures
            foreach (var fakeDeviceInfo in _fakeDeviceList.Keys)
            {
                _processManager.Verify(pm => pm.Run(s_adbPath, $"-s {fakeDeviceInfo.Item1} shell getprop ro.product.cpu.abi", TimeSpan.FromSeconds(30)), Times.Once);
                Assert.Equal(fakeDeviceInfo.Item2, result[fakeDeviceInfo.Item1]);
            }
            Assert.Equal(4, result.Count);
        }