Skip to content

Commit

Permalink
feat:
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Sep 7, 2023
1 parent c6d794b commit d330d89
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions automotive/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
<category android:name="androidx.car.app.category.NAVIGATION"/>
<category android:name="androidx.car.app.category.FEATURE_CLUSTER"/>
</intent-filter>

<intent-filter>
<action android:name="androidx.car.app.action.NAVIGATE" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="geo" />
</intent-filter>

</service>
</application>
</manifest>
27 changes: 27 additions & 0 deletions automotive/src/main/java/org/obd/graphs/aa/CarScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import android.util.Log
import androidx.car.app.CarContext
import androidx.car.app.Screen
import androidx.car.app.model.*
import androidx.car.app.navigation.NavigationManager
import androidx.car.app.navigation.NavigationManagerCallback
import androidx.car.app.navigation.model.NavigationTemplate
import androidx.core.graphics.drawable.IconCompat
import androidx.lifecycle.DefaultLifecycleObserver
Expand All @@ -20,6 +22,7 @@ import org.obd.graphs.renderer.DynamicSelectorMode
import org.obd.graphs.renderer.Fps
import org.obd.graphs.renderer.ScreenSettings


private const val LOG_KEY = "CarScreen"
private const val VIRTUAL_SCREEN_1_SETTINGS_CHANGED = "pref.aa.pids.profile_1.event.changed"
private const val VIRTUAL_SCREEN_2_SETTINGS_CHANGED = "pref.aa.pids.profile_2.event.changed"
Expand Down Expand Up @@ -138,13 +141,15 @@ internal class CarScreen(
surfaceController.renderFrame()
fps.stop()
invalidate()
navigationManager().navigationEnded()
}

DATA_LOGGER_CONNECTED_EVENT -> {
toast.show(carContext, R.string.main_activity_toast_connection_established)
renderingThread.start()
fps.start()
invalidate()
navigationManager().navigationStarted()
}

DATA_LOGGER_STOPPING_EVENT -> {
Expand Down Expand Up @@ -303,6 +308,7 @@ internal class CarScreen(
}

init {

lifecycle.addObserver(this)
dataLogger.observe(this) {
metricsCollector.append(it)
Expand All @@ -314,5 +320,26 @@ internal class CarScreen(
} else {
Log.i(LOG_KEY, "Data logger is not running.")
}

navigationManager().setNavigationManagerCallback(
object : NavigationManagerCallback {
override fun onStopNavigation() {

try {
renderingThread.stop()
surfaceController.renderFrame()
fps.stop()
invalidate()
}catch (e: Throwable){
Log.e(LOG_KEY,"Failed to stop DL threads",e)
}
}

override fun onAutoDriveEnabled() {

}
})
}

private fun navigationManager() = carContext.getCarService(NavigationManager::class.java)
}
1 change: 1 addition & 0 deletions automotive/src/main/java/org/obd/graphs/aa/CarService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.car.app.validation.HostValidator
internal class CarService : CarAppService() {
override fun onCreateSession(): Session = CarSession()
override fun createHostValidator(): HostValidator {

return if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
HostValidator.ALLOW_ALL_HOSTS_VALIDATOR
} else {
Expand Down

0 comments on commit d330d89

Please sign in to comment.