From 2c58dcc8f8279c092c009cd31ff1a55dd8db7444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Sch=C3=BCtz?= Date: Thu, 30 Jul 2020 10:44:54 +0200 Subject: [PATCH] Add report id to android alerts (#141) * Add report id to Android alert * Add jarRepositories.xml to gitignore --- android/core/.gitignore | 1 + .../androidTest/java/org/coepi/core/JNIInterfaceTests.kt | 6 +++--- .../core/src/main/java/org/coepi/core/domain/model/Alert.kt | 1 + .../core/core/src/main/java/org/coepi/core/jni/JniApi.kt | 1 + .../core/src/main/java/org/coepi/core/services/AlertsApi.kt | 1 + src/android/android_interface.rs | 5 ++++- src/android/jni_domain_tests.rs | 2 +- 7 files changed, 12 insertions(+), 5 deletions(-) diff --git a/android/core/.gitignore b/android/core/.gitignore index 42a2b7a..82d870c 100644 --- a/android/core/.gitignore +++ b/android/core/.gitignore @@ -47,6 +47,7 @@ captures/ .idea/assetWizardSettings.xml .idea/dictionaries .idea/libraries +.idea/jarRepositories.xml # Android Studio 3 in .gitignore file. .idea/caches .idea/modules.xml diff --git a/android/core/core/src/androidTest/java/org/coepi/core/JNIInterfaceTests.kt b/android/core/core/src/androidTest/java/org/coepi/core/JNIInterfaceTests.kt index ae99013..71c15a3 100644 --- a/android/core/core/src/androidTest/java/org/coepi/core/JNIInterfaceTests.kt +++ b/android/core/core/src/androidTest/java/org/coepi/core/JNIInterfaceTests.kt @@ -36,7 +36,7 @@ class JNIInterfaceTests { assertEquals( JniOneAlertResult( 1, "", JniAlert( - "123", JniPublicSymptoms( + "123", "224", JniPublicSymptoms( reportTime = 234324, earliestSymptomTime = 1590356601, feverSeverity = 1, @@ -63,7 +63,7 @@ class JNIInterfaceTests { JniAlertsArrayResult( 1, "", arrayOf( JniAlert( - "123", JniPublicSymptoms( + "123", "224", JniPublicSymptoms( reportTime = 131321, earliestSymptomTime = 1590356601, feverSeverity = 1, @@ -78,7 +78,7 @@ class JNIInterfaceTests { ), 1592567315, 1592567335, 1.2f, 2.1f, false ), JniAlert( - "343356", JniPublicSymptoms( + "343356", "224", JniPublicSymptoms( reportTime = 32516899200, earliestSymptomTime = 1590356601, feverSeverity = 1, diff --git a/android/core/core/src/main/java/org/coepi/core/domain/model/Alert.kt b/android/core/core/src/main/java/org/coepi/core/domain/model/Alert.kt index 0868a79..16361e5 100644 --- a/android/core/core/src/main/java/org/coepi/core/domain/model/Alert.kt +++ b/android/core/core/src/main/java/org/coepi/core/domain/model/Alert.kt @@ -6,6 +6,7 @@ import kotlinx.android.parcel.Parcelize @Parcelize data class Alert( var id: String, + var reportId: String, val reportTime: UnixTime, val earliestSymptomTime: UserInput, val feverSeverity: FeverSeverity, diff --git a/android/core/core/src/main/java/org/coepi/core/jni/JniApi.kt b/android/core/core/src/main/java/org/coepi/core/jni/JniApi.kt index b4c375e..aecbb8d 100644 --- a/android/core/core/src/main/java/org/coepi/core/jni/JniApi.kt +++ b/android/core/core/src/main/java/org/coepi/core/jni/JniApi.kt @@ -136,6 +136,7 @@ data class JniAlertsArrayResult( data class JniAlert( var id: String, + var reportId: String, var symptoms: JniPublicSymptoms, var contactStart: Long, var contactEnd: Long, diff --git a/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt b/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt index 79bdde0..4901d24 100644 --- a/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt +++ b/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt @@ -42,6 +42,7 @@ class AlertsFetcherImpl(private val api: JniApi) : private fun JniAlert.toAlert() = Alert( id = id, + reportId = reportId, contactStart = when { contactStart < 0 -> error("Invalid contact start: $contactStart") else -> UnixTime.fromValue(contactStart) diff --git a/src/android/android_interface.rs b/src/android/android_interface.rs index 4d373e0..4a35c1d 100644 --- a/src/android/android_interface.rs +++ b/src/android/android_interface.rs @@ -666,6 +666,8 @@ pub fn alert_to_jobject(alert: Alert, env: &JNIEnv) -> Result Result = env .new_object( jni_alert_class, - "(Ljava/lang/String;Lorg/coepi/core/jni/JniPublicSymptoms;JJFFZ)V", + "(Ljava/lang/String;Ljava/lang/String;Lorg/coepi/core/jni/JniPublicSymptoms;JJFFZ)V", &[ id_j_value, + report_id_j_value, JValue::from(jni_public_symptoms_obj), contact_start_j_value, contact_end_j_value, diff --git a/src/android/jni_domain_tests.rs b/src/android/jni_domain_tests.rs index 8d5a250..e9a8a2d 100644 --- a/src/android/jni_domain_tests.rs +++ b/src/android/jni_domain_tests.rs @@ -80,7 +80,7 @@ fn create_test_alert(id: &str, report_time: u64) -> Alert { Alert { id: id.to_owned(), - report_id: id.to_owned(), // re-use alert id, not particular reason other than we don't need separate id for now + report_id: "224".to_owned(), symptoms, contact_start: 1592567315, contact_end: 1592567335,