SettingsProvider

Provider interface for Android Auto settings management.

This interface defines the contract for reading and updating navigation/routing settings from the Android Auto settings screen. It follows the same provider pattern used by SearchProvider, QuickAccessProvider, and GuidanceProvider.

Architecture

androidauto  (interface)           app (implementation)
┌───────────────────────┐ ┌───────────────────────────┐
│ SettingsProvider │◄────────│ SettingsProviderImpl │
│ - settingsState │ │ - GuidancePreferences │
│ - updateSetting() │ │ - RoutingPreferences │
│ - refresh() │ │ - TrafficPreferences │
│ - dispose() │ └───────────────────────────┘
│ - reinitialize() │ ▲
└───────────────────────┘ │
▲ AndroidAutoModule (DI)
│
android_auto (consumer)
┌──────────────────────────────┐
│ AndroidAutoSettingsScreen │
│ - observes settingsState │
│ - calls updateSetting() │
└──────────────────────────────┘

Lifecycle

The provider is created as a singleton via Hilt DI and follows the standard AA provider lifecycle:

  • dispose(): Called when AA disconnects — cancels coroutines, resets state

  • reinitialize(): Called when AA reconnects — recreates scope, reloads preferences

Thread Safety

All settings reads/writes go through SharedPreferences which are thread-safe. State updates are performed atomically via StateFlow.

See also

Properties

Link copied to clipboard
abstract val settingsState: StateFlow<AASettingsState>

StateFlow of the current settings state for reactive observation.

Functions

Link copied to clipboard
abstract fun dispose()

Disposes of the provider and releases all resources.

Link copied to clipboard

Returns the list of custom setting keys with their display labels and current values.

Link copied to clipboard
abstract fun refresh()

Refreshes all settings from shared preferences.

Link copied to clipboard
abstract fun reinitialize()

Reinitializes the provider after disposal.

Link copied to clipboard
open fun updateCustomSetting(key: String, enabled: Boolean)

Updates a custom setting value defined by the client application.

Link copied to clipboard

Updates the Android Auto map's day/night mode, when the user changes it on the Android Auto settings screen.

Link copied to clipboard
abstract fun updateSetting(key: AASettingKey, enabled: Boolean)

Updates a single setting value and persists it to shared preferences.