Each new downloaded Diagnosis Key file (please see Downloading Diagnosis Keys section) is provided for exposure checking. The check is performed by Exposure Notification API with Exposure Configuration options that tune the matching algorithm. In order to provide elastic architecture, the exposure configuration is obtained from Firebase RemoteConfig service. Providing of Diagnosis Key files is done in a background Worker as this is done periodically and doesn't require the user to have application in the foreground.
Steps:
- New Diagnosis Key files that have never been analyzed are downloaded as described in Downloading Diagnosis Keys section. Diagnosis Key files must be signed appropriately - the matching algorithm only runs on data that has been verified with the public key distributed by the device configuration mechanism. See more here.
- Exposure configuration options are obtained from Firebase RemoteConfig. The configuration allows to provide Health Authority recommendations regarding different aspects of exposure (like duration, attenuation or days since exposure). More about ExposureConfiguration can be found here.
- Repository function: RemoteConfigurationRepository.getExposureConfigurationItem()
- Repository implementation: RemoteConfigurationRepositoryImpl.getExposureConfigurationItem()
- The new downloaded Diagnosis Key files and the Exposure Configuration are provided for Exposure Notification API
- Worker: ProvideDiagnosisKeyWorker
- UseCase: ProvideDiagnosisKeysUseCase
- Repository function: ExposureNotificationRepository.provideDiagnosisKeys(files: List, token: String, exposureConfigurationItem: ExposureConfigurationItem)
- Repository implementation: ExposureNotificationRepositoryImpl.provideDiagnosisKeys(files: List, token: String, exposureConfigurationItem: ExposureConfigurationItem)
- When the data has been successfully provided for Exposure Notification API then:
- Information about the latest analyzed Diagnosis Key file timestamp is stored locally on a device (encrypted Shared Preferences). This information is used to select the future Diagnosis Key files that have not been analyzed yet – only files with higher Diagnosis Key timestamp are selected
- Repository function: DiagnosisKeyRepository.setLatestProcessedDiagnosisKeyTimestamp(timestamp: Long)
- Repository implementation: DiagnosisKeyRepositoryImpl.setLatestProcessedDiagnosisKeyTimestamp(timestamp: Long)
- All sent to analysis Diagnosis Key files are deleted from device internal storage
- Diagnosis keys analysis will be performed by Exposure Notification API, after which application will receive a broadcast message in case any exposure is detected
- Information about the latest analyzed Diagnosis Key file timestamp is stored locally on a device (encrypted Shared Preferences). This information is used to select the future Diagnosis Key files that have not been analyzed yet – only files with higher Diagnosis Key timestamp are selected