Skip to content

陽性者数の確認のシーケンス図

Tomoaki Masuda edited this page Sep 16, 2020 · 3 revisions

陽性者との接触を確認 の補足のためにシーケンス図を書き起こしました。

「陽性者数を確認する」をクリックしたとき

UserDataMode::ExposureInformation への追加(iOS版)

UserDataMode::ExposureInformation への追加(Android版)

以下は、StackEdit 用のコードです。 Chome で GitHub + Mermaid 拡張を入れると、直接ブラウザから見えるようになります。

接触数コード解析

「陽性者との接触を確認する」をクリックした時

ホーム画面から「陽性者との接触を確認する」をクリックしたときは、

  1. UserDataModel::ExposureInformation コレクションの数を調べる
  2. count > 0 の場合は、ContactedNotifyPage ページに飛ぶ
  3. count = 0 の場合は、 NotContactPage ページに飛ぶ
sequenceDiagram
HomePageView ->> HomePageViewModel: OnClickExposures
HomePageViewModel ->> ExposureNotificationService: GetExposureCount()
ExposureNotificationService ->> UserDataModel: ExposureInformation.Count()

Note right of UserDataModel: UserDataModel::ExposureInformationに保持される 

UserDataModel -->> ExposureNotificationService: count
ExposureNotificationService -->> HomePageViewModel: count
HomePageViewModel ->> NavigationService: NavigateAsync(ContactedNotifyPage) if count > 0
HomePageViewModel ->> NavigationService: NavigateAsync(NotContactPage) if count = 0
Loading

UserDataModel::ExposureInformation コレクション(iOS版)

ExposureInformation コレクションへの追加は、定期的なスケジュール呼び出しで実現される

sequenceDiagram

PlatformScheduleFetch ->> ExposureNotification(share): UpdateKeysFromServer
ExposureNotification(share) ->> ExposureNotificationHandler: FetchExposureKeyBatchFilesFromServerAsync(submitBatches)
ExposureNotificationHandler ->> ExposureNotificationHandler: DownloadBatchAsync
ExposureNotificationHandler -->> ExposureNotificationHandler: downloadedFiles
ExposureNotificationHandler ->> ExposureNotificationHandler: downloadedFiles.Count > 0

ExposureNotificationHandler ->> ExposureNotification(share): submitBatches: callback

ExposureNotification(share) ->> ExposureNotification(ios): PlatformDetectExposuresAsync(downloadedFiles) 
ExposureNotification(ios) ->> ENManager: DetectExposuresAsync
ENManager -->> ExposureNotification(ios): summary
ExposureNotification(ios) -->> ExposureNotification(share): return summary, info

ExposureNotification(share) ->> ExposureNotification(share): summary?.MatchedKeyCount > 0
ExposureNotification(share) ->> ExposureNotificationHandler: ExposureDetectedAsync(summay, info)
ExposureNotificationHandler ->> UserDataModel: ExposureSummary = summary 
UserDataModel -->> ExposureNotificationHandler: 


ExposureNotificationHandler ->> ExposureNotification(ios): info(): callback
ExposureNotification(ios) ->> ExposureNotification(ios): if summary?.MatchedKeyCount > 0 then
ExposureNotification(ios) ->> ENManager: GetExposureInfoAsync(detectionSummary...)
ENManager -->> ExposureNotification(ios): exposures
loop exposures
	ExposureNotification(ios) ->> ExposureNotification(ios): info.add(new ExposureInfo())
end 
ExposureNotification(ios) -->> ExposureNotificationHandler: return info

ExposureNotificationHandler ->> ExposureNotificationHandler: exposureInfo <- info()
loop add
	ExposureNotificationHandler ->> UserDataModel: ExposureInformation.add( exposure )
end
UserDataModel ->> UserDataModel: Save
ExposureNotificationHandler -->> ExposureNotification(share): return ExposureDetectedAsync
ExposureNotification(share) -->> ExposureNotificationHandler: return submitBatches
ExposureNotificationHandler ->> ExposureNotificationHandler: delete files
ExposureNotificationHandler -->> ExposureNotification(share): return FetchExposureKeyBatchFilesFromServerAsync
ExposureNotification(share) -->> PlatformScheduleFetch: processedAnyFiles

Loading

UserDataModel::ExposureInformation コレクション(Android版)

ExposureInformation コレクションへの追加は、Android から com.google.android.gms.nearby.exposurenotification

  • ACTION_EXPOSURE_STATE_UPDATED 通知が来てから行われる。
sequenceDiagram

BackgroundFetchWorker ->> ExposureNotification(share): UpdateKeysFromServer
ExposureNotification(share) ->> ExposureNotificationHandler: FetchExposureKeyBatchFilesFromServerAsync(submitBatches)
ExposureNotificationHandler ->> ExposureNotificationHandler: DownloadBatchAsync
ExposureNotificationHandler -->> ExposureNotificationHandler: downloadedFiles
ExposureNotificationHandler ->> ExposureNotificationHandler: downloadedFiles.Count > 0

ExposureNotificationHandler ->> ExposureNotification(share): submitBatches: callback

ExposureNotification(share) ->> ExposureNotification(android): PlatformDetectExposuresAsync(downloadedFiles) 
ExposureNotification(android) ->> Android.Gms.Nearby: ProvideDiagnosisKeysAsync
Android.Gms.Nearby -->> ExposureNotification(android): return 
ExposureNotification(android) -->> ExposureNotification(share): return

ExposureNotification(share) -->> ExposureNotificationHandler: return submitBatches
ExposureNotificationHandler ->> ExposureNotificationHandler: delete files
ExposureNotificationHandler -->> ExposureNotification(share): return FetchExposureKeyBatchFilesFromServerAsync
ExposureNotification(share) -->> BackgroundFetchWorker : return processedAnyFiles
Loading

クラス名が長いので以下で省略

  • EXPOSURE_CALLBACK : com.google.android.gms.nearby.exposurenotification
  • ACTION_EXPOSURE_STATE_UPDATED : com.google.android.gms.exposurenotification.ACTION_EXPOSURE_STATE_UPDATED
  • BIND_JOB_SERVICE: android.permission.BIND_JOB_SERVICE
  • ENCBroadcastReceiver : ExposureNotificationCallbackBroadcastReceiver
  • ENCService : ExposureNotificationCallbackService
sequenceDiagram

Android ->> ENCBroadcastReceiver : EXPOSURE_CALLBACK : OnReceive
ENCBroadcastReceiver ->> ENCBroadcastReceiver : if intent.Action = ACTION_EXPOSURE_STATE_UPDATED then
ENCBroadcastReceiver ->> ENCService : EnqueueWork( context, intent )
ENCService -->> ENCBroadcastReceiver : 
ENCBroadcastReceiver -->> Android: 

Android ->> ENCService : OnHandleWork
ENCService ->> ENCService : get token
ENCService ->> ExposureNotification(android): PlatformGetExposureSummaryAsync(token)
ExposureNotification(android) ->> Android.Gms.Nearby: GetExposureSummaryAsync
Android.Gms.Nearby -->> ExposureNotification(android): return summary
ExposureNotification(android) -->> ENCService : return summary
ENCService ->> ENCService: if summary?.MatchedKeyCount > 0 then
ENCService ->> ExposureNotificationHandler: ExposureDetectedAsync( summary, info )

ExposureNotificationHandler ->> UserDataModel: ExposureSummary = summary 
UserDataModel -->> ExposureNotificationHandler: 

ExposureNotificationHandler ->> ENCService : info(): callback
ENCService ->> ExposureNotification(android): PlatformGetExposureInformationAsync(token)
ExposureNotification(android) ->> Android.Gms.Nearby: GetExposureInformationAsync(token)
Android.Gms.Nearby -->> ExposureNotification(android): return exposures;
ExposureNotification(android) ->> ExposureNotification(android): info <- exposures.select
ExposureNotification(android) -->> ENCService: return info
ENCService -->> ExposureNotificationHandler: return of info():callback
ExposureNotificationHandler ->> ExposureNotificationHandler: exposureInfo <- info()
loop add
	ExposureNotificationHandler ->> UserDataModel: ExposureInformation.add( exposure )
end
UserDataModel ->> UserDataModel: Save
ExposureNotificationHandler -->> ENCService: return of ExposureDetectedAsync
ENCService -->> Android: 
Loading
Clone this wiki locally