Beispiel #1
0
        public async Task <string> UpdateStatusMessageAsync()
        {
            loggerService.StartMethod();
            ExposureNotificationStatus = await ExposureNotification.GetStatusAsync();

            loggerService.EndMethod();
            return(await GetStatusMessageAsync());
        }
Beispiel #2
0
 public async Task <bool> IsRunning()
 {
     if (IsAppRestricted)
     {
         return(false);
     }
     try
     {
         return(await ExposureNotification.GetStatusAsync() == Status.Active);
     }
     catch (Exception e)
     {
         if (!e.HandleExposureNotificationException(nameof(InfectionStatusViewModel), nameof(IsRunning)))
         {
             throw e;
         }
         return(false);
     }
 }
        private async void OnUserDataChanged(object sender, UserDataModel userData)
        {
            Console.WriteLine("User Data has Changed!!!");
            this.userData = userDataService.Get();
            Console.WriteLine(Utils.SerializeToJson(userData));

            if (userData.IsExposureNotificationEnabled)
            {
                await StartExposureNotification();
            }
            else
            {
                await StopExposureNotification();
            }

            Status status = await ExposureNotification.GetStatusAsync();

            GetStatusMessage(status);
        }
        /*
         * public async Task TestDownloadBatch()
         * {
         *  long sinceEpochSeconds = new DateTimeOffset(DateTime.UtcNow.AddDays(-14)).ToUnixTimeSeconds();
         *  TemporaryExposureKeysResult tekResult = await httpDataService.GetTemporaryExposureKeys(sinceEpochSeconds);
         *  Console.WriteLine("Fetch Exposure Key");
         *
         *  foreach (var keys in tekResult.Keys)
         *  {
         *      Console.WriteLine(keys.Url);
         *  }
         *
         * }
         *
         * public bool GetOptInStatus()
         * {
         *  return userData.IsOptined;
         * }
         */


        /*
         * public async Task SetOptinStatusAsync(bool flg)
         * {
         *  userData.IsOptined = flg;
         *  await userDataService.SetAsync(userData);
         * }
         * public bool GetOptInStatus()
         * {
         *  return userData.IsOptined;
         * }
         *
         *
         * public async Task SetExposureNotificationStatusAsync(bool flg)
         * {
         *  userData.IsExposureNotificationEnabled = flg;
         *  await userDataService.SetAsync(userData);
         * }
         * public bool GetExposureNotificationStatus()
         * {
         *  return userData.IsExposureNotificationEnabled;
         * }
         *
         * public async Task SetNotificationStatusAsync(bool flg)
         * {
         *  userData.IsNotificationEnabled = flg;
         *  await userDataService.SetAsync(userData);
         * }
         * public bool GetNotificationStatus()
         * {
         *  return userData.IsNotificationEnabled;
         * }
         */
        public async Task <bool> StartExposureNotification()
        {
            if (!userData.IsOptined)
            {
                await UserDialogs.Instance.AlertAsync("利用規約に同意する必要があります。同意ページへ遷移します。");

                await navigationService.NavigateAsync(nameof(PrivacyPolicyPage));
            }

            Status status = await ExposureNotification.GetStatusAsync();

            if (status == Status.BluetoothOff
                //            || status == Status.Restricted
                || status == Status.NotAuthorized)
            {
                await UserDialogs.Instance.AlertAsync(GetStatusMessage(status));

                userData.IsExposureNotificationEnabled = false;
                await userDataService.SetAsync(userData);

                return(false);
            }

            //            bool IsEnabled = await ExposureNotification.IsEnabledAsync();

            if (userData.IsOptined && userData.IsExposureNotificationEnabled && (status == Status.Unknown || status == Status.Active || status == Status.Disabled))
            {
                try
                {
                    await ExposureNotification.StartAsync();
                }
                catch (Exception)
                {
                    userData.IsExposureNotificationEnabled = false;
                    await userDataService.SetAsync(userData);

                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
 public async Task <bool> PermissionUnknown()
 {
     return(await ExposureNotification.GetStatusAsync() == Status.Unknown);
 }
Beispiel #6
0
        /// <summary>
        /// Returns true if Status.Active || status == Status.Disabled || status == Status.Restricted.
        /// Meaning that everything is ready for either starting or stopping the scanner.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> PoweredOn()
        {
            Status status = await ExposureNotification.GetStatusAsync();

            return(status == Status.Active || status == Status.Disabled);
        }
Beispiel #7
0
 public async Task <bool> PoweredOff()
 {
     return(await ExposureNotification.GetStatusAsync() == Status.BluetoothOff);
 }
        public async Task <string> UpdateStatusMessageAsync()
        {
            this.ExposureNotificationStatus = await ExposureNotification.GetStatusAsync();

            return(await GetStatusMessageAsync());
        }
Beispiel #9
0
        public async Task <bool> StartExposureNotification()
        {
            /*
             * if (!userData.IsOptined)
             * {
             *  await UserDialogs.Instance.AlertAsync("利用規約に同意する必要があります。同意ページへ遷移します。");
             *  await navigationService.NavigateAsync(nameof(PrivacyPolicyPage));
             * }
             */

            try
            {
                await ExposureNotification.StartAsync();

                var count = 0;
                while (true)
                {
                    Thread.Sleep(1000);
                    await ExposureNotification.StartAsync();

                    Status status = await ExposureNotification.GetStatusAsync();

                    if (status == Status.Active)
                    {
                        return(true);
                    }
                    else if (status == Status.BluetoothOff)
                    {
                        await UserDialogs.Instance.AlertAsync(GetStatusMessage());

                        return(true);
                    }
                    else
                    {
                        if (count > 2)
                        {
                            throw new Exception();
                        }
                        count++;
                    }
                }
            }
            catch (Exception)
            {
                userData.IsExposureNotificationEnabled = false;
                await userDataService.SetAsync(userData);

                return(false);
            }

            /*
             * ExposureNotificationStatus = await ExposureNotification.GetStatusAsync();
             * if (ExposureNotificationStatus == Status.BluetoothOff
             * //            || ExposureNotificationStatus == Status.Restricted
             || ExposureNotificationStatus == Status.NotAuthorized)
             ||{
             || await UserDialogs.Instance.AlertAsync(GetStatusMessage());
             || userData.IsExposureNotificationEnabled = false;
             || await userDataService.SetAsync(userData);
             || return false;
             ||}
             ||
             ||if (userData.IsOptined && userData.IsExposureNotificationEnabled && (ExposureNotificationStatus == Status.Unknown || ExposureNotificationStatus == Status.Active || ExposureNotificationStatus == Status.Disabled))
             ||{
             || try
             || {
             ||     await ExposureNotification.StartAsync();
             ||
             || }
             || catch (Exception)
             || {
             ||     userData.IsExposureNotificationEnabled = false;
             ||     await userDataService.SetAsync(userData);
             ||     return false;
             || }
             ||}
             ||return true;
             */
        }