[ExposureNotification] Implement the shared API for v2 #955
[ExposureNotification] Implement the shared API for v2 #955mattleibow wants to merge 18 commits intomainfrom
Conversation
|
Could there be a way to define if we want to use Android v1.5 or v1.6, since it seems like v1.6 will require Android 11, which we might not get ready for. I suppose iOS 14 will be a requirement. |
|
@JanettHolst290490 sorry for the long delay, we are hoping to get this done very soon. Based on my work so far, I think we are very close, I will just need to see how we can test because I don't have all the required access to the API because neither I nor MS are "Authorized Health Providers". However, this is not too much of a big deal as we think we have most of the things ready and then your feedback will help us fix up any issues. So, to address your questions:
This is automatically handled. The APIs are actually bound to Google Play Services, not the version of Android. This means that this code should work on any version that has the various versions of the services. In addition to that, we actually check each of the available APIS, so it basically tries v1.6, and if that is not there, then it tries v1.5 and finally it falls back to the v1.0.
Similar to Android, it will fallback gracefully since we detect the version of the OS before trying to use new APIs. Both of these questions are why we decided to go with the new handler as a derived handler. This basically means that it can fall back if necessary. public interface IExposureNotificationDailySummaryHandler : IExposureNotificationHandler
{
Task<DailySummaryConfiguration> GetDailySummaryConfigurationAsync();
Task ExposureStateUpdatedAsync(IEnumerable<ExposureWindow> windows, IEnumerable<DailySummary>? summaries);
} |
Seems the tooling doesn't like the new ValueTuples
|
I have also started updating the sample app based on these new APIs. It is not yet complete, but it should have a starting point: xamarin/ExposureNotification.Sample#86 |
|
Hello @mattleibow , According to this, there is an important improvement in 1.5 SDK for Android, namely:
As I see in the log for this PR, this cross-platform lib is planned to be build on Android 1.7.1 SDK, does it mean that we will also get this "force-stop improvements" when updating to the new nuget-package for shared EN API? Or some extra actions will be required? |
|
@pavshr according to the release notes, it looks like that feature was implemented in 1.5, and this PR builds with 1.6. This should mean that these improvements should come automatically. |
|
Hello @mattleibow Do you plan to add also support for iOS 12.5 as in https://developer.apple.com/documentation/exposurenotification/supporting_exposure_notifications_in_ios_12_5 ? |
| w.ScanInstances.Select(s => s.FromNative()))); | ||
| } | ||
|
|
||
| internal static async Task PlatformUpdateDiagnosisKeysDataMappingAsync() |
There was a problem hiding this comment.
I couldn't find the code calling this method in this PR...
There was a problem hiding this comment.
Could you search PlatformGetExposureWindowsAsync ?
internal static async Task<IEnumerable> PlatformGetExposureWindowsAsync()
There was a problem hiding this comment.
I'm sorry. I might have confused you.
Where is PlatformUpdateDiagnosisKeysDataMappingAsync called?
There was a problem hiding this comment.
You are correct, @tmurakami, this is not called in the nuget code. We ended up into calling SetDiagnosisKeysDataMappingAsync manually before calling UpdateKeysFromServer. Ideally, this should be called on Android after getting keys and configuration, so it won't send one more request to the server to fetch configuration one more time. There is, apparently, a limit on number of time how often this API can be called, so I would recommend either catching the exception when this limit is reached, or ensure that the method is not called more often than once a week (src)
There was a problem hiding this comment.
@pavshr Thank you for sharing the information ❤️
|
As i have noted in #1097 EN v2 features should be marked as introduced in iOS 12.5 |
| if (IsDailySummaries) | ||
| { | ||
| // Check that the summary has actual data before notifying the callback | ||
| if (detectionSummary.DaySummaries.Length > 0) | ||
| { | ||
| var (windows, dailySummary) = await PlatformProcessSummaryV2Async(m, detectionSummary, cancellationToken); |
There was a problem hiding this comment.
Hello, I am actively working on testing the Nuget package with these changes. Based on what I see on iOS, await DailySummaryHandler!.ExposureStateUpdatedAsync(windows, dailySummary) is never called, indicating that something here might be out of control. ExposureDetectedAsync is not called either. I managed to apply the new configuration object, and in the phone settings I see that the analysis of the submitted keys with the new configuration went well and multiple matches are found, however, ExposureStateUpdatedAsync() on the handler is never called.
No exceptions are thrown.
@tmurakami Did you test it out as well? Do you have the same issue?
Thanks in advance!
There was a problem hiding this comment.
@pavshr I'm not sure because I can't test it, but I guess you need to assign Infectiousness to all the keys (-14 to 14).
https://github.com/folkehelseinstituttet/Fhi.Smittestopp.App/blob/044831fe92695866643d5c14517aaaf2a00002c3/NDB.Covid19/NDB.Covid19/ExposureNotifications/ExposureNotificationHandler.cs#L168-L173
dsc.DaysSinceOnsetInfectiousness = new Dictionary<int, Infectiousness>()
{
[-14] = Infectiousness.Standard, // Standard, High, or None
[-13] = Infectiousness.Standard,
[-12] = Infectiousness.Standard,
*snip*
[-1] = Infectiousness.Standard,
[0] = Infectiousness.Standard,
[1] = Infectiousness.Standard,
*snip*
[12] = Infectiousness.Standard,
[13] = Infectiousness.Standard,
[14] = Infectiousness.Standard,
};See Configure Criteria to Estimate Risk for more details.
https://developer.apple.com/documentation/exposurenotification/building_an_app_to_notify_users_of_covid-19_exposure
There was a problem hiding this comment.
@mattleibow The same results from my debugging. It seems detectionSummary.DaySummaries.Length is always 0 or even null.
There was a problem hiding this comment.
When using the V2 TEK format in the zip file (with DSOS and ReportType), iOS' ExposureStateUpdatedAsync is called. So there is no issue here, just managed to verify it yesterday.
FYI @tmurakami
There was a problem hiding this comment.
@ns-kano @pavshr
I had the same problem. I found out we can set the parameter infectiousnessWhenDaysSinceOnsetMissing to infectiousnessForDaysSinceOnsetOfSymptoms.
keiji/chino@f6032cc#diff-1d4d67341f260be73d3e12f741daf36c4e17020b81c566ca3a56cfc10fb0ca59R383-R391
You can see the code in Server.swift, a reference app provided by Apple.
I didn't try to V2 TEK format. I am using TEK Export Tool from exposure-notifications-server.
|
|
||
| Task<IEnumerable<ExposureInfo>> GetInfo() | ||
| // we used windows mode and implemented the windows mode handler | ||
| if (token == ExposureNotificationClient.TokenA && ExposureNotification.DailySummaryHandler != null) |
|
@mattleibow During investigation of the scores on the iOS we have found that weights for iOS are set incorrectly. |
|
@mattleibow can we have a updated version of Xamarin.GooglePlayServices.Nearby.ExposureNotification? |




Generally, the two platforms are similar, but there are some differences.
The biggest difference I think is that iOS "extended" their
ENExposureConfigurationin an interesting way. They just moved all the previous member to the bottom and then added all the new ones at the top. And then added a flag to say which one.Android was a bit better and created a "separate" API with new configuration types. This is better in the fact that there is no overlap. And, they also split operations up again, so there are two new configurations. So, now iOS still has one big thing and Android has 3: 1 obsolete, 2 smaller.
I have created a "v2" handler that returns a new configuration object. So, instead of implementing
IExposureNotificationHandler, you can implement theIExposureNotificationDailySummaryHandlerto support the "Exposure Window" mode. This is an additive feature to support older devices:The app will just have to add this additional interface to the existing handler implementation. This is an additive handler because it could exist that a device might be running an older version of Google Play Services that does not yet support the v1.5 and v1.6 APIs. Or if the iOS device is not yet updated.
In order for the library to use the new APIs, there are 2 requirements:
IExposureNotificationDailySummaryHandler