예제 #1
0
        private async Task <IList <TemporaryExposureKey> > GetReleasedTemporaryExposureKeys(
            ExposureNotificationClient enClient,
            Context appContext
            )
        {
            TaskCompletionSource <Intent> taskCompletionSource = new TaskCompletionSource <Intent>(TaskCreationOptions.RunContinuationsAsynchronously);
            BroadcastReceiver             receiver             = new PreAuthorizeReleasePhoneUnlockedBroadcastReceiver(taskCompletionSource);

            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(API_TIMEOUT_MILLIS);

            using (cancellationTokenSource.Token.Register(() =>
            {
                Logger.D("cancellationTokenSource canceled.");
                taskCompletionSource.TrySetCanceled();
                appContext.UnregisterReceiver(receiver);
            }))
            {
                appContext.RegisterReceiver(
                    receiver,
                    INTENT_FILTER_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED
                    );

                await enClient.RequestPreAuthorizedTemporaryExposureKeyReleaseAsync();

                Intent intent = await taskCompletionSource.Task;

                IList <TemporaryExposureKey> temporaryExposureKeys = intent.GetParcelableArrayListExtra(EXTRA_TEMPORARY_EXPOSURE_KEY_LIST)
                                                                     .Cast <AndroidTemporaryExposureKey>()
                                                                     .Select(tek => (TemporaryExposureKey) new PlatformTemporaryExposureKey(tek))
                                                                     .ToList();

                return(temporaryExposureKeys);
            }
        }
예제 #2
0
            private async Task <(ExposureSummary, IList <ExposureInformation> exposureInformations)> GetExposureV1Async(
                ExposureNotificationClient enClient,
                string token
                )
            {
                Logger.D($"GetExposureV1Async");

                AndroidExposureSummary exposureSummary = await enClient.EnClient.GetExposureSummaryAsync(token);

                IList <AndroidExposureInformation> eis = await enClient.EnClient.GetExposureInformationAsync(token);

                IList <ExposureInformation> exposureInformations = eis.Select(ei => (ExposureInformation) new PlatformExposureInformation(ei)).ToList();

                return(new PlatformExposureSummary(exposureSummary), exposureInformations);
            }
예제 #3
0
            private async Task <(List <DailySummary> dailySummaries, List <ExposureWindow> exposureWindows)> GetExposureV2Async(
                ExposureNotificationClient enClient,
                ExposureConfiguration exposureConfiguration
                )
            {
                Logger.D($"GetExposureV2Async");


                IList <AndroidDailySummary> dss = await enClient.EnClient.GetDailySummariesAsync(
                    exposureConfiguration.GoogleDailySummariesConfig.ToAndroidDailySummariesConfig()
                    );

                List <DailySummary> dailySummaries = dss.Select(ds => (DailySummary) new PlatformDailySummary(ds)).ToList();

                IList <AndroidExposureWindow> ews = await enClient.EnClient.GetExposureWindowsAsync();

                List <ExposureWindow> exposureWindows = ews.Select(ew => (ExposureWindow) new PlatformExposureWindow(ew)).ToList();

                return(dailySummaries, exposureWindows);
            }