Beispiel #1
0
            public bool WaitForBootComplete(CancellationToken token)
            {
                var adb = new Adb(androidSdkHome);

                var booted = false;

                Serial = null;

                // Keep trying to see if the boot complete prop is set
                while (string.IsNullOrEmpty(Serial) && !token.IsCancellationRequested)
                {
                    if (process.HasExited)
                    {
                        return(false);
                    }

                    Thread.Sleep(1000);

                    // Get a list of devices, we need to find the device we started
                    var devices = adb.GetDevices();

                    // Find the device we just started and get it's adb serial
                    foreach (var d in devices)
                    {
                        try
                        {
                            var name = adb.GetEmulatorName(d.Serial);
                            if (name.Equals(AvdName, StringComparison.OrdinalIgnoreCase))
                            {
                                Serial = d.Serial;
                                break;
                            }
                        }
                        catch { }
                    }
                }

                while (!token.IsCancellationRequested)
                {
                    if (process.HasExited)
                    {
                        return(false);
                    }

                    if (adb.Shell("getprop dev.bootcomplete", Serial).Any(l => l.Contains("1")))
                    {
                        booted = true;
                        break;
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }

                return(booted);
            }
Beispiel #2
0
        public AndroidSdkManager(DirectoryInfo home = null)
        {
            Home = home ?? FindHome()?.FirstOrDefault();

            SdkManager     = new SdkManager(Home);
            AvdManager     = new AvdManager(Home);
            PackageManager = new PackageManager(Home);
            Adb            = new Adb(Home);
            Emulator       = new Emulator(Home);
        }
Beispiel #3
0
            public bool Shutdown()
            {
                var success = false;

                if (!string.IsNullOrWhiteSpace(Serial))
                {
                    var adb = new Adb(androidSdkHome);

                    try { success = adb.EmuKill(Serial); }
                    catch { }
                }

                if (process != null && !process.HasExited)
                {
                    try { process.Kill(); success = true; }
                    catch { }
                }

                return(success);
            }