Exemple #1
0
        internal async Task <bool> CheckEmulatorRunning(CancellationToken cancellationToken)
        {
            Program.Debug("Checking for running emulator");
            var output = await ProcessHelper.RunCommandWithOutput(
                Adb, AdbCommandLine ("devices"), cancellationToken).ConfigureAwait(false);

            var re = new Regex("(emulator-\\d+)\\s+(device|offline)");

            foreach (var line in SplitOutputLines(output))
            {
                // Program.Debug ("ADB DEVICES: {0}", line);
                var match = re.Match(line);
                // Program.Debug ("DO WE HAVE IT: {0}", match.Success);
                if (!match.Success)
                {
                    continue;
                }

                // Program.Debug ("TEST: |{0}|{1}|", match.Groups [1].Value, match.Groups [2].Value);

                if (match.Groups [2].Value.Equals("offline"))
                {
                    Program.Debug("Emulator is offline.");
                    continue;
                }
                else if (!match.Groups [2].Value.Equals("device"))
                {
                    continue;
                }

                var id = match.Groups [1].Value;

                var getPropArgs = $"-s {id} shell getprop sys.boot_completed";
                var getProp     = await ProcessHelper.RunCommandWithOutput(Adb, getPropArgs, cancellationToken);

                getProp = getProp.Trim();

                if (getProp.Equals("1"))
                {
                    Program.Debug("Emulator completed booting.");
                    return(true);
                }
                else
                {
                    Program.Debug("Emulator still booting ...");
                }
            }

            return(false);
        }
Exemple #2
0
        internal async Task <string[]> GetAvds(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var output = await ProcessHelper.RunCommandWithOutput(AndroidTool, "list avd -c", cancellationToken);

            var avds = SplitOutputLines(output);

            foreach (var avd in avds)
            {
                Program.Debug("AVD: {0}", avd);
            }

            return(avds);
        }