Skip to content

Sensor settings should be declared, not created as a side effect of reading them #7225

Description

@TimoPtr

Description

SensorManager.getSetting persists the default value into the DB when the setting is not stored yet. The sensor detail screen discovers which settings exist from the stored rows (getSettingsFlow), so a setting only becomes visible once some code path happens to read it. This write-on-read side effect is the root cause of #6773 and forced the workaround in #7206, where requestSensorUpdate calls a getter and discards the result purely so the write happens.
#7040 already removed this pattern for the sensors themselves: the repository returns the default when nothing is stored, and only an actual change is persisted. Settings should follow the same model.

Proposal

  • Sensor managers declare the settings each sensor offers (name, type, default, entries), similar to how available sensors are declared via getAvailableSensors.
  • The detail screen merges the declaration with the stored values, so settings are visible immediately without a DB row.
  • getSetting returns the stored value or the declared default, without writing. Only user changes persist.

Benefits

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions