/// <summary>
        /// Initializes the device for interaction by ensuring connectivity, waking the device,
        /// clearing all settings and navigating to the home screen.
        /// </summary>
        /// <param name="performSignOut">Whether or not to sign out any current users during initialization.</param>
        public virtual void InitializeDevice(bool performSignOut)
        {
            // Enable SystemTest mode if necessary.  Normally DAT takes care of this for us,
            // but in this case we are using a lower-layer call that circumvents the control panel
            // objects that will check for that case.
            bool success = _device.SystemTest.Enable();

            if (!success && _device.SystemTest.IsSupported())
            {
                LogWarn("Unable to enable SystemTest mode.");
            }

            // If all inspectable pages are in use, force disconnect one.
            using (WebInspector inspector = new WebInspector(_device.Address, 9222, TimeSpan.FromSeconds(30)))
            {
                var inspectablePages = inspector.DiscoverInspectablePages();
                if (inspectablePages.Any() && inspectablePages.All(n => n.ClientConnected))
                {
                    LogWarn($"Disconnecting inspectable page connection from {_device.Address}.");
                    inspector.ForceDisconnect(inspectablePages.First());
                }
            }

            WakeDevice();
            NavigateHome();

            if (performSignOut && SignOutRequired())
            {
                SignOut();
                PressExitButton();
            }
        }
Exemplo n.º 2
0
        public override void AwakeFromNib()
        {
            XcbWebView = new XcbWebView(this);

            UIDelegate     = new XIWebUIDelegate();
            PolicyDelegate = new XIWebPolicyDelegate();

            RegisterViewClass <XIMapViewWebDocumentView, XIMapViewWebDocumentRepresentation> (
                "application/x-inspector-map-view");

            if (WebKitPrefs.DeveloperExtrasEnabled)
            {
                using (NativeExceptionHandler.Trap()) {
                    try {
                        WebInspector = this.GetInspector();
                    } catch (Exception e) {
                        Log.Error(TAG, "private WebKit API may have been removed", e);
                    }
                }

                switch (Prefs.Developer.StartupWebInspectorPane.GetValue())
                {
                case Prefs.Developer.WebInspectorPane.Console:
                    WebInspector?.ShowConsole(this);
                    break;

                case Prefs.Developer.WebInspectorPane.ElementTree:
                    WebInspector?.Show(this);
                    break;
                }
            }
        }