diff --git a/app/src/main/java/org/openobservatory/ooniprobe/common/OONIDescriptor.kt b/app/src/main/java/org/openobservatory/ooniprobe/common/OONIDescriptor.kt index 79b01dbd8..bbf6ad6e2 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/common/OONIDescriptor.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/common/OONIDescriptor.kt @@ -367,7 +367,7 @@ enum class OONITests( } } -fun autoRunTests(context: Context, preferenceManager: PreferenceManager): List { +fun autoRunTests(context: Context, preferenceManager: PreferenceManager, testDescriptorManager: TestDescriptorManager): List { return ooniDescriptors(context).filter { ooniDescriptor -> when (ooniDescriptor.name) { @@ -439,6 +439,15 @@ fun autoRunTests(context: Context, preferenceManager: PreferenceManager): List + val runV2AtoRunTests: List = + testDescriptorManager.getRunV2Descriptors(expired = false, autoRun = true) + .map { testDescriptor -> + testDescriptor.toDynamicTestSuite(context).apply { + autoRun = true + } + } + descriptors.addAll(runV2AtoRunTests) } } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/common/TestDescriptorManager.kt b/app/src/main/java/org/openobservatory/ooniprobe/common/TestDescriptorManager.kt index 4da72eb78..8dd3a6667 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/common/TestDescriptorManager.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/common/TestDescriptorManager.kt @@ -137,10 +137,11 @@ class TestDescriptorManager @Inject constructor( } } - fun getRunV2Descriptors(autoUpdate: Boolean? = null, expired: Boolean? = null): List { + fun getRunV2Descriptors(autoUpdate: Boolean? = null, autoRun: Boolean? = null, expired: Boolean? = null): List { return SQLite.select().from(TestDescriptor::class.java) .where( autoUpdate?.let { TestDescriptor_Table.auto_update.eq(it) }, + autoRun?.let { TestDescriptor_Table.auto_run.eq(it) }, expired?.let { TestDescriptor_Table.is_expired.eq(it) } ) .orderBy(TestDescriptor_Table.is_expired.asc()) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/common/service/ServiceUtil.java b/app/src/main/java/org/openobservatory/ooniprobe/common/service/ServiceUtil.java index caa2157d7..801730618 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/common/service/ServiceUtil.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/common/service/ServiceUtil.java @@ -18,6 +18,7 @@ import org.openobservatory.ooniprobe.common.OONITests; import org.openobservatory.ooniprobe.common.PreferenceManager; import org.openobservatory.ooniprobe.common.ReachabilityManager; +import org.openobservatory.ooniprobe.common.TestDescriptorManager; import org.openobservatory.ooniprobe.domain.GenerateAutoRunServiceSuite; import org.openobservatory.ooniprobe.test.suite.AbstractSuite; import org.openobservatory.ooniprobe.test.suite.DynamicTestSuite; @@ -77,7 +78,7 @@ public static void startRunTestServiceUnattended(Application app) { if (!d.generateAutoRunServiceSuite.shouldStart(config.isOnWiFi(), config.isCharging(), isVPNInUse)) { return; } - ServiceUtil.startRunTestServiceCommon(app, new ArrayList<>(autoRunTests(app, d.preferenceManager)), false, true); + ServiceUtil.startRunTestServiceCommon(app, new ArrayList<>(autoRunTests(app, d.preferenceManager, d.testDescriptorManager)), false, true); d.generateAutoRunServiceSuite.markAsRan(); } @@ -105,5 +106,8 @@ public static class Dependencies { @Inject PreferenceManager preferenceManager; + + @Inject + TestDescriptorManager testDescriptorManager; } } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.kt b/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.kt index afb9f274f..8a1b9aaf2 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/model/database/TestDescriptor.kt @@ -20,6 +20,7 @@ import org.openobservatory.ooniprobe.common.AppDatabase import org.openobservatory.ooniprobe.common.LocaleUtils import org.openobservatory.ooniprobe.common.PreferenceManager import org.openobservatory.ooniprobe.common.resolveStatus +import org.openobservatory.ooniprobe.test.suite.DynamicTestSuite import java.io.Serializable import java.util.Date import com.raizlabs.android.dbflow.annotation.TypeConverter as TypeConverterAnnotation @@ -104,6 +105,10 @@ class TestDescriptor( fun localizedDescription() :String { return descriptionIntl.getValueForKey(LocaleUtils.getLocale().language) ?: description } + + fun toDynamicTestSuite(context: Context) : DynamicTestSuite { + return InstalledDescriptor(this).getTest(context) + } } /**