From c0d34c2d1f4498f3cfd5f6f7cc2915139a45dcd7 Mon Sep 17 00:00:00 2001 From: Norbel Ambanumben Date: Mon, 9 Oct 2023 08:31:32 +0100 Subject: [PATCH] Adds ooni run id to anotations --- .../ooniprobe/model/database/TestDescriptor.java | 1 + .../ooniprobe/model/settings/Settings.java | 7 +++++++ .../ooniprobe/test/test/AbstractTest.java | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.java b/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.java index a2cf09867..3df969e06 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.java @@ -263,6 +263,7 @@ public OONIRunSuite getTestSuite(Context context) { for (String url : nettest.getInputs()) Url.checkExistingUrl(url); } + test.setOoniRunLinkId(runId); test.setInputs(nettest.getInputs()); return test; } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/model/settings/Settings.java b/app/src/main/java/org/openobservatory/ooniprobe/model/settings/Settings.java index 8f57bcb4e..db628d312 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/model/settings/Settings.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/model/settings/Settings.java @@ -77,6 +77,10 @@ public void setOrigin(String origin) { annotations.origin = origin; } + public void setOoniRunLinkId(Long ooniRunLinkId) { + annotations.ooniRunLinkId = String.valueOf(ooniRunLinkId); + } + private class OONIMKTaskConfigAdapter implements OONIMKTaskConfig { private String serialized; private Settings settings; @@ -103,6 +107,9 @@ public static class Annotations { @SerializedName("origin") public String origin; + @SerializedName("ooni_run_link_id") + public String ooniRunLinkId; + public Annotations(Context c) { this.network_type = ReachabilityManager.getNetworkType(c); this.flavor = BuildConfig.FLAVOR; diff --git a/app/src/main/java/org/openobservatory/ooniprobe/test/test/AbstractTest.java b/app/src/main/java/org/openobservatory/ooniprobe/test/test/AbstractTest.java index fdc1ba5ee..fc08d4cc7 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/test/test/AbstractTest.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/test/test/AbstractTest.java @@ -52,6 +52,7 @@ public abstract class AbstractTest implements Serializable { private final int urlResId; private final int runtime; private List inputs; + private Long ooniRunLinkId; private Integer max_runtime; private Network network; @@ -81,6 +82,9 @@ void run(Context c, PreferenceManager pm, AppLogger logger, Gson gson, Settings settings.inputs = inputs; settings.setMaxRuntime(max_runtime); settings.setOrigin(origin); + if (ooniRunLinkId != null && ooniRunLinkId > 0) { + settings.setOoniRunLinkId(ooniRunLinkId); + } measurements = new SparseArray<>(); ThirdPartyServices.addLogExtra("settings", ((Application) c.getApplicationContext()).getGson().toJson(settings)); @@ -349,7 +353,11 @@ public void setInputs(List inputs) { this.inputs = inputs; } - public Integer getMax_runtime() { + public void setOoniRunLinkId(Long ooniRunLinkId) { + this.ooniRunLinkId = ooniRunLinkId; + } + + public Integer getMax_runtime() { return max_runtime; }