Skip to content
Snippets Groups Projects
Commit 49996ef8 authored by Matthias Urhahn's avatar Matthias Urhahn
Browse files

Fix unexpected token confusing our exposure detection tracking logic.

parent bad8ab7e
No related branches found
No related tags found
No related merge requests found
...@@ -29,11 +29,8 @@ import javax.inject.Inject ...@@ -29,11 +29,8 @@ import javax.inject.Inject
* new keys are processed. Then the [ExposureStateUpdateReceiver] will receive the corresponding action in its * new keys are processed. Then the [ExposureStateUpdateReceiver] will receive the corresponding action in its
* [onReceive] function. * [onReceive] function.
* *
* Inside this receiver no further action or calculation will be done but it is rather used to inform the * Inside this receiver no further action or calculation will be done but it is rather used to start
* [de.rki.coronawarnapp.transaction.RetrieveDiagnosisKeysTransaction] that the processing of the diagnosis keys is * a worker that launches the RiskLevelTask which then makes use of the new data this notifies us of.
* finished and the Exposure Summary can be retrieved in order to calculate a risk level to show to the user.
*
* @see de.rki.coronawarnapp.transaction.RetrieveDiagnosisKeysTransaction
* *
*/ */
class ExposureStateUpdateReceiver : BroadcastReceiver() { class ExposureStateUpdateReceiver : BroadcastReceiver() {
...@@ -54,15 +51,13 @@ class ExposureStateUpdateReceiver : BroadcastReceiver() { ...@@ -54,15 +51,13 @@ class ExposureStateUpdateReceiver : BroadcastReceiver() {
scope.launch(context = scope.coroutineContext) { scope.launch(context = scope.coroutineContext) {
try { try {
val token = intent.requireToken() intent.getStringExtra(EXTRA_TOKEN)?.let {
Timber.tag(TAG).w("Received unknown token from ENF: %s", it)
trackDetection(token, action) }
val data = Data trackDetection(action)
.Builder()
.putString(EXTRA_TOKEN, token)
.build()
val data = Data.Builder().build()
OneTimeWorkRequest OneTimeWorkRequest
.Builder(ExposureStateUpdateWorker::class.java) .Builder(ExposureStateUpdateWorker::class.java)
.setInputData(data) .setInputData(data)
...@@ -78,13 +73,13 @@ class ExposureStateUpdateReceiver : BroadcastReceiver() { ...@@ -78,13 +73,13 @@ class ExposureStateUpdateReceiver : BroadcastReceiver() {
} }
} }
private fun trackDetection(token: String, action: String?) { private fun trackDetection(action: String?) {
when (action) { when (action) {
ACTION_EXPOSURE_STATE_UPDATED -> { ACTION_EXPOSURE_STATE_UPDATED -> {
exposureDetectionTracker.finishExposureDetection(token, Result.UPDATED_STATE) exposureDetectionTracker.finishExposureDetection(identifier = null, result = Result.UPDATED_STATE)
} }
ACTION_EXPOSURE_NOT_FOUND -> { ACTION_EXPOSURE_NOT_FOUND -> {
exposureDetectionTracker.finishExposureDetection(token, Result.NO_MATCHES) exposureDetectionTracker.finishExposureDetection(identifier = null, result = Result.NO_MATCHES)
} }
else -> throw UnknownBroadcastException(action) else -> throw UnknownBroadcastException(action)
} }
......
...@@ -84,7 +84,7 @@ class ExposureStateUpdateReceiverTest : BaseTest() { ...@@ -84,7 +84,7 @@ class ExposureStateUpdateReceiverTest : BaseTest() {
scope.advanceUntilIdle() scope.advanceUntilIdle()
verifySequence { verifySequence {
exposureDetectionTracker.finishExposureDetection("token", TrackedExposureDetection.Result.UPDATED_STATE) exposureDetectionTracker.finishExposureDetection(null, TrackedExposureDetection.Result.UPDATED_STATE)
workManager.enqueue(any<WorkRequest>()) workManager.enqueue(any<WorkRequest>())
} }
} }
...@@ -97,7 +97,7 @@ class ExposureStateUpdateReceiverTest : BaseTest() { ...@@ -97,7 +97,7 @@ class ExposureStateUpdateReceiverTest : BaseTest() {
scope.advanceUntilIdle() scope.advanceUntilIdle()
verifySequence { verifySequence {
exposureDetectionTracker.finishExposureDetection("token", TrackedExposureDetection.Result.NO_MATCHES) exposureDetectionTracker.finishExposureDetection(null, TrackedExposureDetection.Result.NO_MATCHES)
workManager.enqueue(any<WorkRequest>()) workManager.enqueue(any<WorkRequest>())
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment