CoraLibre / CoraLibre-android-sdk

CoraLibre-android-sdk fork of prestandard DP-3T to make compatible with the Google/Apple protocol
Mozilla Public License 2.0
127 stars 7 forks source link

EN Nearby api implementation on top of PPCP #58

Closed Stypox closed 4 years ago

Stypox commented 4 years ago

This PR makes the Nearby api actually do something, implementing the stub methods. I created a branch here so that you can easily push changes, too, in case you want to. I took inspiration from microg's implementation.

Closes #33

This is what needs to be done:

Stypox commented 4 years ago

I pushed three more commits. I implemented diagnosis keys protobuf parsing using microg's .proto, along with the database methods to store them, and I added findAllMeasuredExposures().

But I am facing some problems matching the CapturedDatas stored in the database with the provided DiagnosisKeys: the microg implementation is obscure for me, and I have some doubts about the byte[] stored in the CapturedData object. @theScrabi does that array represent just the TemporaryExposureKey received from the other phone, or does it represent the received data as a whole?

Also, I have a design question: I noticed that microg caches matches inside provideDiagnosisKeys, so that they don't have to be recalculated later. Is it ok if for now I don't implement that (as it would require adding another table to the database), and then we'll get to it later?

haitrec commented 4 years ago

I implemented a big part of the actual matching procedure / computation of ExposureSummary and ExposureInformation. See the 'matching' package for most of the new stuff. I did not write tests for these parts yet. Also there are some parts of the computation, where I was not 100% sure, I marked thse parts with TODOs in the code. I did some restructuring along the way, in particular I moved all datatypes that are used in different parts of the sdk to an own 'datatypes' package. I moved some of the constants (key lengths, rolling period, ...) to an own EnFrameworkConstants file.

When reviewing, better don't look at every change from every commit, but on the result, since not all commits are super clean ;)

Because of the structural changes, my idea would be to merge this branch as soon as possible, even if the implementation is not complete yet. That would also allow us to make own issues / PRs out of the many TODOs, on that different people then could work.

BjoernPetersen commented 4 years ago

I'll review this tomorrow 👍

BjoernPetersen commented 4 years ago

I made a few rather minor suggestions. When they are fixed/applied, I'd be okay with merging this PR.

BjoernPetersen commented 4 years ago

I'll apply the suggested changes myself and merge this PR.