Exemplo n.º 1
0
        public void CloseApp()
        {
            int count = 0;

            _mobile.SetTimeout(1);
            while (!_mobile.DoesScreenContains(new UiSelector().ResourceId("com.printeron.droid.phone:id/main_entry_function_panel")))
            {
                _mobile.PressKey(4);
                count++;
                if (count > 5)
                {
                    _mobile.ExecuteADBCommand($"shell am force-stop {PACKAGE_NAME}");
                    _mobile.SetTimeout(DEFAULT_TIMEOUT);
                    return;
                }
            }
            _mobile.SetTimeout(DEFAULT_TIMEOUT);
            _mobile.PressKey(4);
        }
Exemplo n.º 2
0
        /// <summary>Waits for availability of the given resource identifier for up to the given time.</summary>
        /// <param name="resourceId">The resource identifier.</param>
        /// <param name="tsWait">The ts wait.</param>
        /// <returns>true if found</returns>
        public bool WaitForAvailableResourceId(string resourceId, TimeSpan tsWait)
        {
            int      timeOut = _controller.GetTimeout();
            DateTime dtWait  = DateTime.Now.AddSeconds(tsWait.TotalSeconds);

            UiSelector uiSelector = new UiSelector().ResourceId(resourceId);
            bool       available  = _controller.DoesScreenContains(uiSelector);

            while (!available && dtWait > DateTime.Now)
            {
                Thread.Sleep(250);
                available = _controller.DoesScreenContains(uiSelector);

                double myTime = dtWait.Subtract(DateTime.Now).TotalSeconds;
                if (myTime % 5 == 0)
                {
                    _controller.PressKey(KeyCode.KEYCODE_WAKEUP);
                }
            }

            _controller.SetTimeout(timeOut);
            return(available);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AndroidAppManagerBase"/> class.
        /// </summary>
        /// <param name="pluginExecutionData"></param>
        /// <param name="activityData"></param>
        public AndroidAppManagerBase(PluginExecutionData pluginExecutionData, HpRoamActivityData activityData)
        {
            try
            {
                _executionData = pluginExecutionData;
                _activityData  = activityData;
                _controller    = SESLib.Create(_activityData.MobileEquipmentId);
                _controller.Connect(false, true);

                _androidHelper = new AndroidHelper(_controller);

                _controller.PressKey(KeyCode.KEYCODE_WAKEUP); //Power Button
                _controller.PressKey(KeyCode.KEYCODE_HOME);

                if (_androidHelper.ExistResourceId("com.android.systemui:id/keyguard_indication_area"))
                {
                    _controller.Swipe(SESLib.To.Up);
                }
            }
            catch (NullReferenceException ex)
            {
                throw new DeviceWorkflowException($"Unable to connect to the android phone using the connection ID {_activityData.MobileEquipmentId}.", ex);
            }
        }
Exemplo n.º 4
0
        private void EnterPassword()
        {
            UiSelector passwordSelector = new UiSelector().ResourceId("password");
            string     passwordtext     = _controller.GetText(passwordSelector);

            if (string.IsNullOrEmpty(passwordtext))
            {
                OnStatusUpdate("Enter password.");
                if (!_controller.SetText(passwordSelector, Credential.Password))
                {
                    throw new DeviceWorkflowException("Failed to enter password.");
                }
            }

            //Get rid of the keyboard if present
            if (_controller.IsVirtualKeyboardShown().Value)
            {
                _controller.PressKey(KeyCode.KEYCODE_ESCAPE);
            }
        }
 /// <summary>
 /// Returns the device to the home screen.
 /// </summary>
 public void SendToHomeScreen()
 {
     _controller.PressKey(KeyCode.KEYCODE_HOME);
 }