Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.0'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.11.0'
implementation 'io.reactivex:rxjava:1.3.8'
implementation 'io.apisense:rhino-android:1.1.1'
implementation 'io.apisense:rhino-android:1.3.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'io.dropwizard.metrics:metrics-core:4.1.17'
implementation 'com.dynatrace.dynahist:dynahist:1.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ class PreferencesFragment : PreferenceFragmentCompat() {
p3?.isVisible = true
}

"mock" -> {
p1?.isVisible = false
p2?.isVisible = false
p3?.isVisible = false
}

else -> {
}
}
Expand All @@ -254,6 +260,12 @@ class PreferencesFragment : PreferenceFragmentCompat() {
p3?.isVisible = true
}

"mock" -> {
p1?.isVisible = false
p2?.isVisible = false
p3?.isVisible = false
}

else -> {
p1?.isVisible = false
p2?.isVisible = true
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
<string name="pref.connection.category">OBD2 Adapter Connection</string>
<string name="pref.connection.category.summary">This section contains settings related to your adapter type. Here, you can configure the Wi-Fi or Bluetooth parameters of your adapter.</string>

<string name="pref.connection.connection_type">Type of connection</string>
<string name="pref.connection.connection_type_dialog">Select OBD adapter connection type</string>
<string name="pref.connection.connection_type"><b><font color='#01804F'>OBD adapter connection type</font></b></string>
<string name="pref.connection.connection_timeout">Connection timeout</string>

<string name="pref.adapter_id">Available bluetooth devices</string>
Expand Down Expand Up @@ -431,9 +432,10 @@
<string name="pref.theme">Theme</string>

<string-array name="pref.connection_type_array">
<item name="connection.wifi">wifi</item>
<item name="connection.bluetooth">bluetooth</item>
<item name="connection.wifi">wifi</item>
<item name="connection.usb">usb</item>
<item name="connection.mock">mock</item>
</string-array>

<string name="pref.settings">Settings</string>
Expand Down
8 changes: 1 addition & 7 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@

<ListPreference
android:defaultValue="bluetooth"
android:dialogTitle="@string/pref.connection.connection_type"
android:dialogTitle="@string/pref.connection.connection_type_dialog"
android:entries="@array/pref.connection_type_array"
android:entryValues="@array/pref.connection_type_array"
android:key="pref.adapter.connection.type"
Expand Down Expand Up @@ -2108,12 +2108,6 @@
android:key="pref.debug.logging.enabled"
android:title="@string/pref.debug_logging_enabled" />

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref.debug.generator.enabled"
android:title="@string/pref.debug_generator_enabled"
app:singleLineTitle="false" />

<Preference
android:key="pref.adapter.gps"
android:title="Open GPS screen"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugins {

project.ext {
compileSdkVersion = 35
minSdkVersion = 24
minSdkVersion = 26
}

allprojects {
Expand Down
4 changes: 4 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ dependencies {
implementation("io.github.tzebrowski:obd-metrics:$obdMetricVersion") { changing = true }
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
implementation 'pub.devrel:easypermissions:3.0.0'


implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0'
}
31 changes: 16 additions & 15 deletions common/src/main/java/org/obd/graphs/Async.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@

package org.obd.graphs

import android.os.AsyncTask
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

private val backgroundScope = kotlinx.coroutines.CoroutineScope(Dispatchers.Default + kotlinx.coroutines.SupervisorJob())

fun <T> runAsync(wait: Boolean = true, handler: () -> T) : T {
val asyncJob: AsyncTask<Void, Void, T> = object : AsyncTask<Void, Void, T>() {
@Deprecated("Deprecated in Java", ReplaceWith("handler()"))
override fun doInBackground(vararg params: Void?): T {
return handler()
}
}
return if (wait) {
asyncJob.execute().get()
} else {
asyncJob.execute()
null as T
}
}
fun <T> runAsync(wait: Boolean = false, handler: () -> T): T? {
return if (wait) {
runBlocking(Dispatchers.Default) {
handler()
}
} else {
backgroundScope.launch {
handler()
}
null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.obd.metrics.api.model.PidDefinitionCustomization
import org.obd.metrics.api.model.ProducerPolicy
import org.obd.metrics.api.model.STNxxExtensions
import org.obd.metrics.api.model.SniffingPolicy
import org.obd.metrics.codec.GeneratorPolicy
import java.io.File

internal class AdjustmentsStrategy {
Expand Down Expand Up @@ -86,12 +85,6 @@ internal class AdjustmentsStrategy {
.pidPriority(4, 4) // atm pressure, ambient temp
.conditionalSleepEnabled(false)
.build(),
).generatorPolicy(
GeneratorPolicy
.builder()
.enabled(preferences.generatorEnabled)
.increment(0.5)
.build(),
).adaptiveTimeoutPolicy(
AdaptiveTimeoutPolicy
.builder()
Expand All @@ -103,13 +96,17 @@ internal class AdjustmentsStrategy {
)

if (dataLoggerSettings.instance().adapter.stnExtensionsEnabled) {
val highPriorityOverridePolicy = PidDefinitionCustomization.builder().priority(0).build()
val highPriorityOverridePolicy =
PidDefinitionCustomization.builder().priority(0).build()
builder =
builder
.override(Pid.ATM_PRESSURE_PID_ID.id, highPriorityOverridePolicy)
.override(Pid.AMBIENT_TEMP_PID_ID.id, highPriorityOverridePolicy)
.override(Pid.DYNAMIC_SELECTOR_PID_ID.id, highPriorityOverridePolicy)
.override(Pid.ENGINE_TORQUE_PID_ID.id, PidDefinitionCustomization.builder().priority(4).build())
.override(
Pid.ENGINE_TORQUE_PID_ID.id,
PidDefinitionCustomization.builder().priority(4).build(),
)
}

return builder.build()
Expand All @@ -120,9 +117,15 @@ internal class AdjustmentsStrategy {
.builder()
.sniffing(SniffingPolicy.builder().enabled(false).build())
.debugEnabled(preferences.debugLogging)
.override(Pid.DISTANCE_PID_ID.id, PidDefinitionCustomization.builder().lastInTheQuery(true).build())
.formulaExternalParams(FormulaExternalParams.builder().param("unit_tank_size", preferences.fuelTankSize).build())
.errorsPolicy(
.override(
Pid.DISTANCE_PID_ID.id,
PidDefinitionCustomization.builder().lastInTheQuery(true).build(),
).formulaExternalParams(
FormulaExternalParams
.builder()
.param("unit_tank_size", preferences.fuelTankSize)
.build(),
).errorsPolicy(
ErrorsPolicy
.builder()
.numberOfRetries(preferences.adapter.maxReconnectNum)
Expand All @@ -142,7 +145,7 @@ internal class AdjustmentsStrategy {
STNxxExtensions
.builder()
.promoteSlowGroupsEnabled(false)
.stripWhitespaces(true)
.stripWhitespaces(dataLoggerSettings.instance().adapter.connectionType != "mock")
.promoteAllGroupsEnabled(preferences.adapter.stnIgnorePIDsPriorities)
.enabled(preferences.adapter.stnExtensionsEnabled)
.build(),
Expand All @@ -153,7 +156,12 @@ internal class AdjustmentsStrategy {
.cachePolicy(
CachePolicy
.builder()
.resultCacheFilePath(File(getContext()?.cacheDir, "formula_cache.json").absolutePath)
.resultCacheFilePath(
File(
getContext()?.cacheDir,
"formula_cache.json",
).absolutePath,
).storeResultCacheOnDisk(false)
.resultCacheEnabled(preferences.adapter.resultsCacheEnabled)
.build(),
).producerPolicy(
Expand All @@ -162,12 +170,6 @@ internal class AdjustmentsStrategy {
.conditionalSleepEnabled(preferences.adapter.adaptiveConnectionEnabled)
.conditionalSleepSliceSize(10)
.build(),
).generatorPolicy(
GeneratorPolicy
.builder()
.enabled(preferences.generatorEnabled)
.increment(0.5)
.build(),
).adaptiveTimeoutPolicy(
AdaptiveTimeoutPolicy
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ data class DataLoggerSettings(
var dragRacingCommandFrequency: Long = 10,
@XmlPreference("pref.mode", "Generic mode", String::class)
var mode: String = "Generic mode",
@XmlPreference("pref.debug.generator.enabled", "false", Boolean::class)
var generatorEnabled: Boolean = false,
@XmlPreference("pref.pids.registry.list", "", Set::class)
var resources: Set<String> = modules.getDefaultModules().keys,
@XmlPreference("pref.debug.trip.save.connector_response", "false", Boolean::class)
Expand Down
Loading
Loading