Kleidos API Search

In development. It changes without notice.

Topic

Settings View Model

How a setting reads on the screen: its value in words, what handles it on a keyboard panel, and the tables of device information.

Everything here describes; applying a value is in Settings Screen & Service.

See also
Settings Model, Settings Screen & Service

Files

file src/ui/settings/info_panel.h
The read-only info panels' facts and their label / value table.
file src/ui/settings/info_panel_logic.h
The read-only info panels' rows, pages and privacy key rows, apart from the drawing. Pure, host-testable.
file src/ui/settings/keyboard_panel_dispatch.h
Keyboard-panel handler classification for each settings option (headless).
file src/ui/settings/privacy_key_reveal.h
When the Privacy key panel shows the device's key, not only its fingerprint. Pure, host-testable.
file src/ui/settings/settings_presenter.h
Headless presenter over the settings option model.

Classes

struct kleidos::ui::settings::InfoRow
One fact an info panel states: a label and its value. More about kleidos::ui::settings::InfoRow
struct kleidos::ui::settings::InfoRows
The facts an info panel states, in order. Wiped when it goes out of scope: a panel may state a key. More about kleidos::ui::settings::InfoRows
struct kleidos::ui::settings::InfoPage
Which rows one page of an info table shows, and where its neighbors start. More about kleidos::ui::settings::InfoPage
class kleidos::ui::settings::PrivacyKeyReveal
The reveal state of one Privacy key panel. More about kleidos::ui::settings::PrivacyKeyReveal
class kleidos::ui::settings::SettingsPresenter
Resolves the flat option model into one board's visible settings tree. More about kleidos::ui::settings::SettingsPresenter

Typedefs

usingkleidos::ui::settings::PrivacyKeyBytes
The device's privacy key, as the Bluetooth facade reads it.

Enumerations

enum class kleidos::ui::settings::InfoKind : uint8_t { kleidos::ui::settings::InfoKind::Battery, kleidos::ui::settings::InfoKind::Device, kleidos::ui::settings::InfoKind::About, kleidos::ui::settings::InfoKind::LockoutPolicy, kleidos::ui::settings::InfoKind::DeviceBinding, kleidos::ui::settings::InfoKind::AuditLog, kleidos::ui::settings::InfoKind::DeviceAdvanced, kleidos::ui::settings::InfoKind::PrivacyKey }
Which read-only info panel is showing. More about kleidos::ui::settings::InfoKind
enum class kleidos::ui::settings::KbHandler : uint8_t { kleidos::ui::settings::KbHandler::Toggle, kleidos::ui::settings::KbHandler::Stepper, kleidos::ui::settings::KbHandler::Picker, kleidos::ui::settings::KbHandler::Info, kleidos::ui::settings::KbHandler::BleHosts, kleidos::ui::settings::KbHandler::TextEntry, kleidos::ui::settings::KbHandler::Confirm, kleidos::ui::settings::KbHandler::Action, kleidos::ui::settings::KbHandler::DeferRequest, kleidos::ui::settings::KbHandler::Delegate, kleidos::ui::settings::KbHandler::StationDeferred, kleidos::ui::settings::KbHandler::Unsupported }
How the keyboard panel services a settings option when selected. More about kleidos::ui::settings::KbHandler

Functions

voidkleidos::ui::settings::collectInfoRows (InfoKind kind, InfoRows &out, bool revealKey=false)
Gather the facts kind states (none for About).
boolkleidos::ui::settings::infoAsTable (const ui::LayoutContext &layout)
Whether a panel of this layout draws the label / value table: the roomy color panels, wide enough for a label and a value side by side.
InfoPagekleidos::ui::settings::drawInfoTable (ui::Canvas &canvas, const ui::LayoutContext &layout, int16_t top, int16_t bottom, const InfoRows &rows, uint8_t first=0)
Draw rows as an inert table between top and bottom, from the page holding row first, and say which rows it showed.
voidkleidos::ui::settings::drawAboutBody (ui::Canvas &canvas, const ui::LayoutContext &layout, const ui::Rect &band)
Draws the brand panel of About from top down, centered.
std::optional< InfoKind >kleidos::ui::settings::infoKindFor (OptionId id)
The info panel an option opens, if it opens one.
i18n::StringIdkleidos::ui::settings::infoTitleId (InfoKind kind)
Title string id for a read-only info screen.
uint8_tkleidos::ui::settings::infoPageStep (const InfoPage &page, bool forward)
The first row of the page after page, or of the one before it.
voidkleidos::ui::settings::addBatteryRows (InfoRows &out, bool known, int percent, int millivolts, bool charging)
Add the Battery panel's rows: level, state and voltage.
voidkleidos::ui::settings::addAuditRows (InfoRows &out, const AuditEntry *entries, uint8_t count)
Add the Audit log panel's rows, newest first, as many as the panel holds.
voidkleidos::ui::settings::formatIrkPrint (const PrivacyKeyBytes &key, kleidos::util::str::InplaceString< kInfoValueCap > &out)
Write the fingerprint of key ("9f3a 21c4") into out.
voidkleidos::ui::settings::addPrivacyKeyRows (InfoRows &out, const PrivacyKeyBytes &key, bool revealKey)
Add the Privacy key panel's rows for key.
constexpr KbHandlerkleidos::ui::settings::kbHandlerFor (kleidos::settings::OptionId id)
The keyboard panel's handler for an option (its dispatch contract).
template<std::size_t Capacity>
voidkleidos::ui::settings::formatMaskedKey (kleidos::util::str::InplaceString< Capacity > &out)
Write the masked key's row: bullets in groups of four, as a secret field shows a hidden password, built from the mask glyph alone.

Variables

constexpr size_tkleidos::ui::settings::kInfoValueCap
Capacity of one info-panel value.
constexpr std::size_tkleidos::ui::settings::kPrivacyKeyLen
Bytes of the device's privacy key (an identity resolving key, IRK).
constexpr uint32_tkleidos::ui::settings::kPrivacyKeyRevealMs
constexpr std::size_tkleidos::ui::settings::kMaskedKeyGroupLen
Bullets in one group of the masked key (as the shown key groups its hex digits).
constexpr std::size_tkleidos::ui::settings::kMaskedKeyGroups
Groups of bullets in the masked key's row.

Back to the top

Enumeration Type Documentation

InfoKind #

enum class kleidos::ui::settings::InfoKind : uint8_t

Which read-only info panel is showing.

Enumerator
Battery 

Live battery level / state / voltage.

Device 

Curated device info (model / firmware / name / storage / boot).

About 

Product identity + credits.

LockoutPolicy 

Brute-force lockout thresholds (read-only guarantee).

DeviceBinding 

Device-binding + secure-boot / flash-encryption status.

AuditLog 

Recent security-event audit entries.

DeviceAdvanced 

Deep diagnostics (chip / memory / uptime / fuses / MACs).

PrivacyKey 

The Bluetooth privacy key (IRK): fingerprint, hex, base64.

KbHandler #

enum class kleidos::ui::settings::KbHandler : uint8_t

How the keyboard panel services a settings option when selected.

Enumerator
Toggle 

In-place flip + persist (shared toggleOption).

Stepper 

Keyboard +/- editor (shared stepper spec + commit).

Picker 

Single-select list (language / HID layout).

Info 

Read-only info panel.

BleHosts 

BLE bonded-hosts list.

TextEntry 

Typed text entry (device name / SSID+PSK / NTP server).

Confirm 

Shared confirm-then-effect (wipe/reset/factory/sleep).

Action 

Self-contained one-shot keyboard action (GPS re-detect).

DeferRequest 

Deferred to the vault view (admin portal / SD flows).

Delegate 

Delegated to the shared button-tree wizard.

StationDeferred 

Station-mode feature configured from the admin portal.

Unsupported 

Not offered on keyboard boards (gated out upstream).

Back to the top

Function Documentation

addAuditRows() #

void kleidos::ui::settings::addAuditRows(InfoRows & out, const AuditEntry * entries, uint8_t count)

Add the Audit log panel's rows, newest first, as many as the panel holds.

Each row is named for its event ("?" for a value no build wrote) and its value says when: the UTC time of day it was stored with (the ring keeps no date), or its place in the ring when no clock was running. Only a failed unlock adds the attempt count. An empty log is one row saying so.

Parameters
NameDirectionMeaning
outin, outThe panel's rows, appended to.
entriesinThe log, oldest first.
countinHow many entries entries holds.

addBatteryRows() #

void kleidos::ui::settings::addBatteryRows(InfoRows & out, bool known, int percent, int millivolts, bool charging)

Add the Battery panel's rows: level, state and voltage.

Before the battery sample's first good reading the battery is unknown, and the three rows say so rather than show the empty sample's zeros.

Parameters
NameDirectionMeaning
outin, outThe panel's rows, appended to.
knowninThe sample holds a good reading.
percentinIts charge estimate, 0..100 %.
millivoltsinIts terminal voltage, mV.
charginginThe charger is active.

addPrivacyKeyRows() #

void kleidos::ui::settings::addPrivacyKeyRows(InfoRows & out, const PrivacyKeyBytes & key, bool revealKey)

Add the Privacy key panel's rows for key.

The first row is the key's fingerprint, the first four bytes of an HMAC-SHA256 of the key under a fixed label ("9f3a 21c4"), which names the key without giving it. While revealKey is false the next row holds the hex row's place with bullets, and the key never reaches a row. Once revealed, the key follows in hex (groups of four digits, half the key per line) and in base64 (half per line), the second line of each with no label of its own. What does not fit out is left out. The caller wipes key.

Parameters
NameDirectionMeaning
outin, outThe panel's rows, appended to.
keyinThe device's privacy key.
revealKeyinThe owner revealed the key (PrivacyKeyReveal).

collectInfoRows() #

void kleidos::ui::settings::collectInfoRows(InfoKind kind, InfoRows & out, bool revealKey)

Gather the facts kind states (none for About).

The facts of every info panel but About, gathered once for whichever layout draws them.

The Privacy key panel states the key's fingerprint and, only while the owner revealed it (PrivacyKeyReveal), the key itself; otherwise its hex row is masked with bullets (finding C28).

Parameters
NameDirectionMeaning
kindinThe panel.
outoutIts rows, in order.
revealKeyinThe Privacy key panel's key is revealed; ignored by every other panel.

drawAboutBody() #

void kleidos::ui::settings::drawAboutBody(ui::Canvas & canvas, const ui::LayoutContext & layout, const ui::Rect & band)

Draws the brand panel of About from top down, centered.

Draw the About panel centered in band: the key mark, the name and version on one line, the copyright and the license.

Every line is laid out from the drawn fonts and wrapped to the band's width; a band too short for the whole stack drops the mark, never the text.

Parameters
NameDirectionMeaning
canvasin, outDrawing surface.
layoutinResponsive context.
bandinThe region between the header and the keys.

drawInfoTable() #

InfoPage kleidos::ui::settings::drawInfoTable(ui::Canvas & canvas, const ui::LayoutContext & layout, int16_t top, int16_t bottom, const InfoRows & rows, uint8_t first = 0)

Draw rows as an inert table between top and bottom, from the page holding row first, and say which rows it showed.

A panel wide enough sets label (secondary, left) and value (primary, right, fitted) on one line, and a value too long to share its label's line takes the line under it, still flush right; a narrow panel stacks the label (small) over the value. Lines keep their pitch whatever the count: what does not fit goes to the next page, never under the line above.

Parameters
NameDirectionMeaning
canvasin, outDrawing surface.
layoutinResponsive context.
topinFirst row's top edge.
bottominThe table's bottom limit.
rowsinThe facts.
firstinIndex of a row on the page to draw.
Returns
The page it drew.

formatIrkPrint() #

void kleidos::ui::settings::formatIrkPrint(const PrivacyKeyBytes & key, kleidos::util::str::InplaceString< kInfoValueCap > & out)

Write the fingerprint of key ("9f3a 21c4") into out.

The first four bytes of an HMAC-SHA256 of the key under the fixed label "kleidos-irk-print", in hex in two groups: a short, one-way name for the key that a host's record can be checked against without the key itself. "?" when the HMAC cannot be computed.

Parameters
NameDirectionMeaning
keyinThe device's privacy key.
outoutThe fingerprint, replaced.

formatMaskedKey() #

template<std::size_t Capacity>
void kleidos::ui::settings::formatMaskedKey(kleidos::util::str::InplaceString< Capacity > & out)

Write the masked key's row: bullets in groups of four, as a secret field shows a hidden password, built from the mask glyph alone.

The panel draws it in the hex row's place while the key is masked, so the key never reaches the frame until the owner reveals it. What fits out is written and nothing past it (a bullet is never cut).

Template Parameters
NameMeaning
CapacityThe row's capacity in bytes.
Parameters
NameDirectionMeaning
outoutThe row, replaced.

infoAsTable() #

bool kleidos::ui::settings::infoAsTable(const ui::LayoutContext & layout)

Whether a panel of this layout draws the label / value table: the roomy color panels, wide enough for a label and a value side by side.

Whether the info panels draw as a sub-screen with a label / value table: on the Roomy color panels, wide enough for a label and a value side by side.

Parameters
NameDirectionMeaning
layoutinResponsive context.
Return values
ValueMeaning
trueDraw the table.
falseDraw one "label: value" line per fact.

infoKindFor() #

std::optional< InfoKind > kleidos::ui::settings::infoKindFor(OptionId id)

The info panel an option opens, if it opens one.

Parameters
NameDirectionMeaning
idinA settings option.
Returns
Its panel, or std::nullopt for an option that is not an info row.

infoPageStep() #

uint8_t kleidos::ui::settings::infoPageStep(const InfoPage & page, bool forward)

The first row of the page after page, or of the one before it.

Parameters
NameDirectionMeaning
pageinThe page shown.
forwardinToward the end of the table.
Returns
The next page's first row, clamped to the table (no wrap).

infoTitleId() #

i18n::StringId kleidos::ui::settings::infoTitleId(InfoKind kind)

Title string id for a read-only info screen.

The id of the title an info panel shows.

Parameters
NameDirectionMeaning
kindinThe panel.
Returns
Its title id.

kbHandlerFor() #

KbHandler kleidos::ui::settings::kbHandlerFor(kleidos::settings::OptionId id)
constexpr

The keyboard panel's handler for an option (its dispatch contract).

Parameters
NameDirectionMeaning
idinThe option to classify.
Returns
The KbHandler the panel routes id through.

Back to the top

Variable Documentation

kPrivacyKeyRevealMs #

uint32_t kleidos::ui::settings::kPrivacyKeyRevealMs
inlineconstexpr

How long the Privacy key panel shows the key before it masks it again (ms). Long enough to copy 32 hex digits or 24 base64 characters off the glass.

Back to the top