Ejemplo n.º 1
0
        public async void UnlockSingleDeviceAsync()
        {
            // Arrange
            var unlockedDevice = _device1;

            unlockedDevice.Available      = true;
            unlockedDevice.AppiumEndpoint = "";

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When(HttpMethod.Put, $"{_httpLocalhost}/api/v1/device/{_device1.Id}")
            .Respond("application/json", JsonConvert.SerializeObject(unlockedDevice));
            mockHttp.When(HttpMethod.Get, $"{_httpLocalhost}/api/v1/device/{_device1.Id}")
            .Respond("application/json", JsonConvert.SerializeObject(_device1));

            var mockAppiumService = new Mock <IAppiumService>();

            mockAppiumService.Setup(appiumService => appiumService.StopAppiumForDeviceIdAsync(_device1.Id))
            .Returns(Task.FromResult(true));

            // Act
            var deviceUtils = new DeviceUtils(Logger, _externalProcesses);
            var restClient  = new RestClient(_config.Object, new HttpClient(mockHttp), Logger);
            var result      = await deviceUtils.UnlockDevice(_device1.Id, restClient, mockAppiumService.Object);

            // Assert
            Assert.IsType <Device>(result);
            Assert.Equal(unlockedDevice.Id, result.Id);
            Assert.Equal(unlockedDevice.Available, result.Available);
            Assert.Equal(unlockedDevice.AppiumEndpoint, result.AppiumEndpoint);
        }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        Debug.LogFormat("IDFV: {0}", DeviceUtils.GetIdentifierForVendor());
        Debug.LogFormat("IDFA: {0}", DeviceUtils.GetAdvertisingIdentifier());
        Debug.LogFormat("Android ID: {0}", DeviceUtils.GetAndroidId());
        Debug.LogFormat("Play AD ID: {0}", DeviceUtils.GetPlayAdId());
        Debug.LogFormat("Model name: {0}", DeviceUtils.GetModelName());
        Debug.LogFormat("Manufacturer: {0}", DeviceUtils.GetManufacturer());
        Debug.LogFormat("System name: {0}", DeviceUtils.GetSystemName());
        Debug.LogFormat("System version: {0}", DeviceUtils.GetSystemVersion());
        Debug.LogFormat("Android API level: {0}", DeviceUtils.GetAndroidApiLevel());
        Debug.LogFormat("App name: {0}", DeviceUtils.GetAppName());
        Debug.LogFormat("App version: {0}", DeviceUtils.GetAppVersion());
        Debug.LogFormat("App language: {0}", DeviceUtils.GetAppLanguage());
        Debug.LogFormat("Network carrier: {0}", DeviceUtils.GetNetworkCarrierName());

        Debug.LogFormat("Screen brightness before modifying: {0}", DeviceUtils.GetScreenBrightness());

        int  brightness = Random.Range(1, 256);
        bool isSuccess  = DeviceUtils.SetScreenBrightness(brightness);

        Debug.LogFormat("Set screen brightness: {0}", isSuccess ? "true" : "false");

        Debug.LogFormat("Screen brightness after modifying: {0}", DeviceUtils.GetScreenBrightness());
    }
Ejemplo n.º 3
0
        public async void FindMatchingDevice_byDeviceType_AndroidAsync()
        {
            // Arrange
            var requestedDevice = new RequestedDevices
            {
                DeviceType = DeviceType.Android
            };

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When(HttpMethod.Get, $"{_httpLocalhost}/api/v1/device").Respond("application/json",
                                                                                     JsonConvert.SerializeObject(new List <Device> {
                _device1, _device2
            }));

            // Act
            var deviceUtils = new DeviceUtils(Logger, _externalProcesses);
            var restClient  = new RestClient(_config.Object, new HttpClient(mockHttp), Logger);
            var result      = await deviceUtils.FindMatchingDevice(requestedDevice, restClient);

            // Assert
            var viewResult = Assert.IsType <Device>(result);

            Assert.Equal(DeviceType.Android, viewResult.Type);
            Assert.True(viewResult.Available);
        }
Ejemplo n.º 4
0
        // runs only when not restored from state
        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            // set hamburger menu to full screen mode on Mobile devices.
            if (DeviceUtils.Current().IsPhone())
            {
                Views.Shell.HamburgerMenu.IsFullScreen = true;
            }

            if (!AuthHelper.IsCachedCredentialsAvailable())
            {
                Debug.WriteLine("App.OnStartAsync() : no cached credentials available, loading login page...");
                NavigationService.Navigate(typeof(Views.LoginPage));
            }
            else
            {
                Debug.WriteLine("App.OnStartAsync() : cached credentials found, bypassing login page...");
                await AuthHelper.AuthenticateAsync();

                if (Settings.IsAlreadyConfigured)
                {
                    Debug.WriteLine("App.OnStartAsync() : already set up, skipping to MainPage...");
                    NavigationService.Navigate(typeof(Views.MainPage));
                }
                else
                {
                    Debug.WriteLine("App.OnStartAsync() : not configured, starting setup wizard...");
                    NavigationService.Navigate(typeof(Views.SetupWizardHomePage));
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Request Multi Permissions Once
 /// </summary>
 private void RequestMultiPermissions(string[] permissions)
 {
     DeviceUtils.RequestPermissions(permissions).ThenAction((result) =>
     {
         if (result.IsAllGranted)
         {
             Debug.Log("All Permission is Granted");
         }
         else
         {
             for (int i = 0; i < result.PermissionNames.Length; i++)
             {
                 if (result.GrantResults[i])
                 {
                     Debug.Log(result.PermissionNames[i] + " is Granted");
                 }
                 else
                 {
                     if (DeviceUtils.IsRefuseShowRequestDialog(result.PermissionNames[i]))
                     {
                         text.text += result.PermissionNames[i] + " Denied and Refuse Show Request Dialog";
                         Debug.Log(result.PermissionNames[i] + " Denied and Refuse Show Request Dialog");
                     }
                     else
                     {
                         Debug.Log(result.PermissionNames[i] + " is Denied");
                     }
                 }
             }
         }
     });
 }
Ejemplo n.º 6
0
 public DeviceModel(int?deviceId)
 {
     if (deviceId.HasValue)
     {
         DeviceEntity device = new DeviceEntity(deviceId.Value);
         if (!device.IsNew)
         {
             DeviceId         = deviceId.Value;
             OrganizationId   = device.Location.OrganizationId;
             OrganizationName = device.Location.Organization.Name;
             LocationId       = device.LocationId;
             LocationName     = device.Location.Name;
             DeviceState      = device.DeviceState;
             SerialNumber     = device.SerialNumber;
             RevisionLevel    = device.RevisionLevel;
             ScansAvailable   = device.ScansAvailable;
             ScansCompleted   = device.ScansUsed;
             IssuedTime       = device.DateIssued;
             UniqueIdentifier = device.UniqueIdentifier;
             LastReportTime   = device.LastReportTime;
             UidQualifier     = DeviceUtils.GetUidQualifier(device, false);
         }
         else
         {
             DeviceState    = DeviceState.New;
             OrganizationId = -1;
         }
     }
     else
     {
         DeviceState    = DeviceState.New;
         OrganizationId = -1;
     }
 }
        public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;
            _throttleHelper.ThrottledEvent += ThrottleHelperOnThrottledEvent;

            // process start
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                element.Visibility = Visibility.Visible;
            }
            else
            {
                // handle click
                element.Click += new Common.WeakReference <NavButtonBehavior, object, RoutedEventArgs>(this)
                {
                    EventAction  = (i, s, e) => i.Element_Click(s, e),
                    DetachAction = (i, w) => element.Click -= w.Handler,
                }.Handler;
                CalculateThrottled();
                if (BootStrapper.Current != null)
                {
                    BootStrapper.Current.ShellBackButtonUpdated += Current_ShellBackButtonUpdated;
                }
                _deviceUtils = DeviceUtils.Current();
                if (_deviceUtils != null)
                {
                    _deviceUtils.Changed += DispositionChanged;
                }
            }
        }
Ejemplo n.º 8
0
 private void PerformWithdrawAsync()
 {
     DeviceUtils.StopScanServices();
     DeviceUtils.CleanDataFromDevice();
     NavigationHelper.RestartApp(this);
     ShowSpinner(false);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new <see cref="IVRDevice"/> and returns it.
        /// </summary>
        /// <returns>The <see cref="IVRDevice"/> that was created.</returns>
        public IVRDevice CreateDevice()
        {
#if UNITY_EDITOR
            return(DeviceUtils.CreateDevice(EditorType));
#else
            return(DeviceUtils.CreateDevice(BuildType));
#endif
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MobileManager.Services.AndroidDeviceService"/> class.
 /// </summary>
 public AndroidDeviceService(IManagerConfiguration configuration, IManagerLogger logger, IExternalProcesses externalProcesses)
 {
     _logger            = logger;
     _externalProcesses = externalProcesses;
     _logger.Debug("Running AndroidDeviceService service.");
     _deviceUtils = new DeviceUtils(_logger, _externalProcesses);
     _restClient  = new RestClient(configuration, _logger);
 }
        public void AudioMinus()
        {
            float audioValue = DeviceUtils.GetVolume();

            audioValue = Mathf.Clamp(audioValue - audioStep, 0, 15);
            DeviceUtils.SetVolume(audioValue);

            CheckAudioButtonEnable();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MobileManager.Services.ReservationService"/> class.
        /// </summary>
        public ReservationService(IManagerConfiguration configuration, IManagerLogger logger, IExternalProcesses externalProcesses)
        {
            _logger = logger;
            var externalProcesses1 = externalProcesses;

            _deviceUtils   = new DeviceUtils(_logger, externalProcesses1);
            RestClient     = new RestClient(configuration, _logger);
            _appiumService = new AppiumService(configuration, logger, externalProcesses1);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DeviceConnectors.iOS.IOSDeviceConnector"/> class.
 /// </summary>
 public IosDeviceService(IManagerConfiguration configuration, IManagerLogger logger,
                         IExternalProcesses externalProcesses)
 {
     _logger            = logger;
     _externalProcesses = externalProcesses;
     _deviceUtils       = new DeviceUtils(_logger, _externalProcesses);
     _logger.Info("Running IOSDeviceConnector service.");
     _restClient = new RestClient(configuration, _logger);
 }
Ejemplo n.º 14
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MobileManager.Controllers.ReservationsQueueController" /> class.
 /// </summary>
 /// <param name="reservationsQueueRepository">Reservations queue repository.</param>
 /// <param name="restClient">Rest client.</param>
 /// <param name="logger">Logger.</param>
 /// <param name="externalProcesses"></param>
 public ReservationsQueueController(IRepository <Reservation> reservationsQueueRepository,
                                    IRestClient restClient, IManagerLogger logger, IExternalProcesses externalProcesses) : base(logger)
 {
     _reservationsQueueRepository = reservationsQueueRepository;
     _restClient        = restClient;
     _logger            = logger;
     _externalProcesses = externalProcesses;
     _deviceUtils       = new DeviceUtils(_logger, _externalProcesses);
 }
        public float GetCurrentNow()
        {
            if (!TryReadAttr("current_now", out var value))
            {
                return(0);
            }

            return(DeviceUtils.MicroToBaseUnit(int.Parse(value)));
        }
        public float GetChargeFullDesign()
        {
            if (!TryReadAttr("charge_full_design", out var value))
            {
                return(0);
            }

            return(DeviceUtils.MicroToBaseUnit(int.Parse(value)));
        }
        public float GetVoltageNow()
        {
            if (!TryReadAttr("voltage_now", out var value))
            {
                return(0);
            }

            return(DeviceUtils.MicroToBaseUnit(int.Parse(value)));
        }
Ejemplo n.º 18
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MobileManager.Controllers.ReservationsAppliedController" /> class.
 /// </summary>
 /// <param name="reservationsAppliedRepository">Reservations applied repository.</param>
 /// <param name="restClient">Rest client.</param>
 /// <param name="appiumService">Appium service.</param>
 /// <param name="logger">Logger.</param>
 /// <param name="externalProcesses"></param>
 public ReservationsAppliedController(IRepository <ReservationApplied> reservationsAppliedRepository,
                                      IRestClient restClient, IAppiumService appiumService, IManagerLogger logger, IExternalProcesses externalProcesses) : base(logger)
 {
     _reservationsAppliedRepository = reservationsAppliedRepository;
     _restClient        = restClient;
     _appiumService     = appiumService;
     _logger            = logger;
     _externalProcesses = externalProcesses;
     _deviceUtils       = new DeviceUtils(_logger, _externalProcesses);
 }
Ejemplo n.º 19
0
        void DoBackEvent()
        {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
            DeviceUtils.ShowDialog(Title, null, YesBtn, () => { Application.Quit(); }, NoBtn, () => { });
#else
            // Exit Playing
            UnityEditor.EditorApplication.isPlaying = false;
#endif
            //parent.SetState(MainControl.Transtion.Back);
        }
Ejemplo n.º 20
0
 public void Attach(DependencyObject associatedObject)
 {
     AssociatedObject = associatedObject;
     _deviceUtils     = Utils.DeviceUtils.Current();
     if (_deviceUtils != null)
     {
         _deviceUtils.Changed += DeviceDispositionBehavior_Changed;
     }
     Update();
     _ready = true;
 }
        private void HandleRegistration(Context context, Intent intent)
        {
            var token = intent.GetStringExtra("registration_id");

            _logger.Info(this.Class.SimpleName, "Received Token : " + token);
            if (_pushNotificationRegister.ShouldSendToken(token))
            {
                var uid = Android.Provider.Settings.Secure.GetString(MainActivity.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                _notificationService.AddPushToken(token, DeviceUtils.GetDeviceType(), uid);
            }
        }
Ejemplo n.º 22
0
 public void Attach(DependencyObject associatedObject)
 {
     AssociatedObject = associatedObject;
     _deviceUtils     = DeviceUtils.Current(Services.WindowWrapper.WindowWrapperManager.Current());
     if (_deviceUtils != null)
     {
         _deviceUtils.Changed += DeviceDispositionBehavior_Changed;
     }
     Update();
     _ready = true;
 }
        private void Awake()
        {
            GetBrightnessAction = delegate(float screenBrightness)
            {
                Debug.Log("GetActivityBrightness " + screenBrightness);
                BrightnessValue = screenBrightness;
            };

            CheckAudioButtonEnable();
            BrightnessValue = DeviceUtils.GetBrightness();
        }
Ejemplo n.º 24
0
        public V0100.Objects.Calibration Add(V0100.Objects.Calibration calibration)
        {
            // Get the device that authenticated.
            DeviceEntity device = GetDevice();

            // Device must be active.
            if (device.DeviceState != DeviceState.Active)
            {
                throw new WebFaultException <string>(V0100.Constants.StatusSubcode.DEVICE_STATE_INVALID, HttpStatusCode.NotAcceptable);
            }

            // If the calibration specifies a different device, switch to that one.
            // This allows uploading a calibration for a previously-attached scanner.
            if (!string.IsNullOrEmpty(calibration.DeviceGuid) && calibration.DeviceGuid != device.UniqueIdentifier)
            {
                // Get device. It must exist.
                device = DeviceUtils.GetByUid(calibration.DeviceGuid);
                if (device == null)
                {
                    throw new WebFaultException <string>(V0100.Constants.StatusSubcode.DEVICE_NOT_FOUND, HttpStatusCode.PreconditionFailed);
                }
            }

            // Get the calibration if it exists.
            CalibrationEntity calibrationEntity = CalibrationUtils.GetByUid(calibration.Guid);

            if (calibrationEntity == null)
            {
                // Not found. Creating a new one. Be sure the image set exists.
                ImageSetEntity imageSet = ImageSetUtils.GetByUid(calibration.ImageSetGuid);
                if (imageSet == null)
                {
                    throw new WebFaultException <string>(V0100.Constants.StatusSubcode.IMAGE_SET_NOT_FOUND, HttpStatusCode.PreconditionFailed);
                }

                // Create new calibration.
                calibration.CalibrationId = CalibrationUtils.Create(device.DeviceId, calibration.Guid, calibration.Timestamp, calibration.PerformedBy, imageSet.ImageSetId);
            }
            else
            {
                // Calibration already exists. Device IDs must match.
                if (calibrationEntity.DeviceId != device.DeviceId)
                {
                    throw new WebFaultException <string>(V0100.Constants.StatusSubcode.CALIBRATION_INVALID, HttpStatusCode.Conflict);
                }

                // Get existing ID.
                calibration.CalibrationId = calibrationEntity.CalibrationId;
            }

            // Return it with the ID provided.
            return(calibration);
        }
        private void BtnQuit_Onclick(BaseEventData obj)
        {
            // Quit App
            Application.runInBackground = false;
            Application.Quit();

#if UNITY_ANDROID && !UNITY_EDITOR
            DeviceUtils.OpenApplication(MirageAR_SDK.mLauncherPackageName);
#elif UNITY_IOS && !UNITY_EDITOR
            DeviceUtils.OpenApplication(MirageAR_SDK.mLauncherPackageName.Split('.')[2] + "://");
#endif
        }
        /// <summary>
        /// Check Mirage Needed Permission
        /// </summary>
        private bool CheckMiragePermission()
        {
            bool value = true;

            foreach (var item in MirageAR_AndroidPermissionManager.MirageARPermissions)
            {
                if (!DeviceUtils.CheckPermission(item))
                {
                    value = false;
                }
            }
            return(value);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Request Single Permission Once
        /// </summary>
        public void CallRequestPermission()
        {
            text.text = "";

            if (DeviceUtils.CheckPermission(targetPermissionName))
            {
                text.text = targetPermissionName + " Is Granted";
            }
            else
            {
                RequestPermission(targetPermissionName);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Request Multi Permissions Once
        /// </summary>
        public void CallRequestMultiPermissions()
        {
            text.text = "";

            foreach (var item in targetPermissionNames)
            {
                if (DeviceUtils.CheckPermission(item))
                {
                    text.text += item + " Is Granted; ";
                }
            }

            RequestMultiPermissions(targetPermissionNames);
        }
Ejemplo n.º 29
0
        public void Service_Administrator_Can_Set_State()
        {
            // find a device to modify
            Create_Edit_Device(TestData.ServiceAdminUsername, true);
            var device = new LinqMetaData().Device.FirstOrDefault(x => x.SerialNumber == "DeviceTest1");

            Assert.IsNotNull(device);

            // change the state
            var controller = Mock();

            controller.Invoke(x => x.Edit(device.DeviceId, new DeviceModel(device.DeviceId)
            {
                DeviceState = DeviceState.Locked
            }));

            // TODO: get validation information from wcf service
            var authToken = DeviceUtils.GetAuthenticationToken(device);

            HttpContext.Current.User = new RolePrincipal(new GenericIdentity(device.UniqueIdentifier));
            Thread.CurrentPrincipal  = HttpContext.Current.User;
            if (Membership.ValidateUser(device.UniqueIdentifier, authToken))
            {
                try
                {
                    new ScanService().Validate(new ValidationKeys
                    {
                        LocationGuid     = device.Location.UniqueIdentifier,
                        OrganizationGuid = device.Location.Organization.UniqueIdentifier
                    });
                    Assert.Fail("Validate should fail because device is not active.");
                }
                catch (WebFaultException <string> ex)
                {
                    Assert.AreEqual(Constants.StatusSubcode.DEVICE_STATE_INVALID, ex.Detail);
                    Assert.AreEqual(HttpStatusCode.NotAcceptable, ex.StatusCode);
                }
            }
            else
            {
                Assert.Fail("Device should be authenticated.");
            }

            // change the state
            controller = Mock();
            controller.Invoke(x => x.Edit(device.DeviceId, new DeviceModel(device.DeviceId)
            {
                DeviceState = DeviceState.Active
            }));
        }
Ejemplo n.º 30
0
 public void Authenticate()
 {
     while (true)
     {
         //卡认证
         int intReadRet = DeviceUtils.Authenticate();
         //label1.Text = "intReadRet:" + intReadRet;
         if (intReadRet != 1)
         {
             // MessageBox.Show("身份证信息:未认证 ");
             continue;
         }
         readCard();
     }
 }