PebbleOS
Loading...
Searching...
No Matches
Functions
Settings database

System and notification settings synced both ways (BlobDBIdSettings). More...

Functions

void settings_blob_db_init (void)
 Initialize the settings database.
 
status_t settings_blob_db_insert (const uint8_t *key, int key_len, const uint8_t *val, int val_len)
 Insert or replace a record in the settings database.
 
int settings_blob_db_get_len (const uint8_t *key, int key_len)
 Get the length of a record in the settings database.
 
status_t settings_blob_db_read (const uint8_t *key, int key_len, uint8_t *val_out, int val_len)
 Read a record from the settings database.
 
status_t settings_blob_db_delete (const uint8_t *key, int key_len)
 Delete a record from the settings database.
 
BlobDBDirtyItem * settings_blob_db_get_dirty_list (void)
 Build the list of records of the settings database not yet synced to the phone.
 
status_t settings_blob_db_mark_synced (const uint8_t *key, int key_len)
 Mark a record of the settings database as synced.
 
status_t settings_blob_db_is_dirty (bool *is_dirty_out)
 Check whether the settings database holds records not yet synced to the phone.
 
status_t settings_blob_db_flush (void)
 Delete all records of the settings database.
 
status_t settings_blob_db_mark_all_dirty (void)
 Mark all whitelisted settings as dirty.
 
status_t settings_blob_db_insert_with_timestamp (const uint8_t *key, int key_len, const uint8_t *val, int val_len, time_t timestamp)
 Insert or update a setting unless the watch copy is newer.
 
bool settings_blob_db_phone_supports_sync (void)
 Check whether the connected phone supports settings sync.
 

Detailed Description

System and notification settings synced both ways (BlobDBIdSettings).

Exposes the shell preferences and notification preferences settings files through BlobDB so the phone can reuse its BlobDB sync. Only a whitelist of settings, kept in settings_blob_db.c, is accessible and synced.

Function Documentation

◆ settings_blob_db_delete()

status_t settings_blob_db_delete ( const uint8_t *  key,
int  key_len 
)

Delete a record from the settings database.

The key is the setting name, with or without a trailing NUL. Only whitelisted settings can be deleted.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ settings_blob_db_flush()

status_t settings_blob_db_flush ( void  )

Delete all records of the settings database.

No-op: settings file writes are already persistent, so records are kept.

Returns
S_SUCCESS on success, an error code otherwise.

◆ settings_blob_db_get_dirty_list()

BlobDBDirtyItem * settings_blob_db_get_dirty_list ( void  )

Build the list of records of the settings database not yet synced to the phone.

Only whitelisted settings are listed.

Returns
Heap-allocated list (free with blob_db_util_free_dirty_list()), NULL if none.

◆ settings_blob_db_get_len()

int settings_blob_db_get_len ( const uint8_t *  key,
int  key_len 
)

Get the length of a record in the settings database.

The key is the setting name, with or without a trailing NUL.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
Length of the value in bytes, 0 if not found, or a negative error code.

◆ settings_blob_db_init()

void settings_blob_db_init ( void  )

Initialize the settings database.

Registers a settings file change callback that syncs whitelisted settings to the phone.

◆ settings_blob_db_insert()

status_t settings_blob_db_insert ( const uint8_t *  key,
int  key_len,
const uint8_t *  val,
int  val_len 
)

Insert or replace a record in the settings database.

The key is the setting name, with or without a trailing NUL. Non-whitelisted settings are rejected with E_INVALID_OPERATION. The record is stored as synced and the in-memory preferences are updated.

Parameters
keyKey data.
key_lenLength of key in bytes.
valValue data.
val_lenLength of val in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ settings_blob_db_insert_with_timestamp()

status_t settings_blob_db_insert_with_timestamp ( const uint8_t *  key,
int  key_len,
const uint8_t *  val,
int  val_len,
time_t  timestamp 
)

Insert or update a setting unless the watch copy is newer.

Parameters
keySetting name.
key_lenLength of key in bytes.
valValue data.
val_lenLength of val in bytes.
timestampModification time of the incoming value.
Return values
S_SUCCESSInserted.
E_INVALID_OPERATIONWatch copy is newer, or the setting is not whitelisted.
Returns
Other error codes on failure.

◆ settings_blob_db_is_dirty()

status_t settings_blob_db_is_dirty ( bool *  is_dirty_out)

Check whether the settings database holds records not yet synced to the phone.

Only whitelisted settings are considered.

Parameters
[out]is_dirty_outSet to true if at least one record is dirty.
Returns
S_SUCCESS on success, an error code otherwise.

◆ settings_blob_db_mark_all_dirty()

status_t settings_blob_db_mark_all_dirty ( void  )

Mark all whitelisted settings as dirty.

Triggers a full sync of the settings to the phone.

Returns
S_SUCCESS on success, an error code otherwise.

◆ settings_blob_db_mark_synced()

status_t settings_blob_db_mark_synced ( const uint8_t *  key,
int  key_len 
)

Mark a record of the settings database as synced.

The key is the setting name, with or without a trailing NUL.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ settings_blob_db_phone_supports_sync()

bool settings_blob_db_phone_supports_sync ( void  )

Check whether the connected phone supports settings sync.

Returns
true if the phone advertises the settings_sync_support capability.

◆ settings_blob_db_read()

status_t settings_blob_db_read ( const uint8_t *  key,
int  key_len,
uint8_t *  val_out,
int  val_len 
)

Read a record from the settings database.

The key is the setting name, with or without a trailing NUL.

Parameters
keyKey data.
key_lenLength of key in bytes.
[out]val_outBuffer for the value.
val_lenSize of val_out in bytes.
Returns
S_SUCCESS on success, an error code otherwise.