コード例 #1
0
ファイル: Emulator.cs プロジェクト: imgen/AndroidSdk.Tools
            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);
            }
コード例 #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);
        }
コード例 #3
0
ファイル: Emulator.cs プロジェクト: imgen/AndroidSdk.Tools
            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);
            }