PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
App database

Installed apps (BlobDBIdApps). More...

Data Structures

struct  AppDBEntry
 App database record, as sent by the phone. More...
 

Macros

#define APP_DB_LEGACY_ENTRY_SIZE   offsetof(AppDBEntry, permissions)
 
#define APP_DB_PERMISSION_MICROPHONE   (1u << 0)
 
#define APP_DB_PERMISSION_HEALTH_ENFORCED   (1u << 1)
 Without it health is allowed, as it is for a phone that never sends permissions.
 
#define APP_DB_PERMISSION_HEALTH_GRANTED   (1u << 2)
 

Typedefs

typedef void(* AppDBEnumerateCb) (AppInstallId install_id, AppDBEntry *entry, void *data)
 Callback of app_db_enumerate_entries().
 

Functions

bool app_db_microphone_granted (const Uuid *uuid)
 
bool app_db_health_allowed (const Uuid *uuid)
 
AppInstallId app_db_get_install_id_for_uuid (const Uuid *uuid)
 Find the install id of an app.
 
int app_db_get_app_entry_for_uuid (const Uuid *uuid, AppDBEntry *entry)
 Read the record of an app by UUID.
 
int app_db_get_app_entry_for_install_id (AppInstallId app_id, AppDBEntry *entry)
 Read the record of an app by install id.
 
void app_db_enumerate_entries (AppDBEnumerateCb cb, void *data)
 Call a function for every app in the database.
 
bool app_db_exists_install_id (AppInstallId app_id)
 Check whether an install id is in the database.
 
void app_db_init (void)
 Initialize the app database.
 
int app_db_insert (const uint8_t *key, int key_len, const uint8_t *val, int val_len)
 Insert or replace a record in the app database.
 
int app_db_get_len (const uint8_t *key, int key_len)
 Get the length of a record in the app database.
 
int app_db_read (const uint8_t *key, int key_len, uint8_t *val_out, int val_out_len)
 Read a record from the app database.
 
int app_db_delete (const uint8_t *key, int key_len)
 Delete a record from the app database.
 
int app_db_flush (void)
 Delete all records of the app database.
 
int app_db_compact (void)
 Compact the settings file backing the app database.
 
AppInstallId app_db_check_next_unique_id (void)
 Get the next install id to be assigned, for tests.
 

Detailed Description

Installed apps (BlobDBIdApps).

Records are keyed by app UUID on the wire and stored keyed by AppInstallId.


Data Structure Documentation

◆ AppDBEntry

struct AppDBEntry

App database record, as sent by the phone.

Data Fields
GColor8 app_face_bg_color Background color of the app face.
Version app_version App version.
uint32_t icon_resource_id Resource id of the app icon.
uint32_t info_flags Process info flags (visibility, process type, worker), as in the app binary.
char name[APP_NAME_SIZE_BYTES] App name.
uint32_t permissions Optional phone-authorized permissions; absent on legacy records.

Only app_db_read() fills it; use app_db_microphone_granted() or app_db_health_allowed() to check a grant.

Version sdk_version SDK version the app was built with.
uint8_t template_id Template id, unused by the firmware.
Uuid uuid App UUID.

Macro Definition Documentation

◆ APP_DB_LEGACY_ENTRY_SIZE

#define APP_DB_LEGACY_ENTRY_SIZE   offsetof(AppDBEntry, permissions)

◆ APP_DB_PERMISSION_HEALTH_ENFORCED

#define APP_DB_PERMISSION_HEALTH_ENFORCED   (1u << 1)

Without it health is allowed, as it is for a phone that never sends permissions.

◆ APP_DB_PERMISSION_HEALTH_GRANTED

#define APP_DB_PERMISSION_HEALTH_GRANTED   (1u << 2)

◆ APP_DB_PERMISSION_MICROPHONE

#define APP_DB_PERMISSION_MICROPHONE   (1u << 0)

Typedef Documentation

◆ AppDBEnumerateCb

typedef void(* AppDBEnumerateCb) (AppInstallId install_id, AppDBEntry *entry, void *data)

Callback of app_db_enumerate_entries().

Parameters
install_idInstall id of the app.
entryRecord; only valid during the call.
dataUser data.

Function Documentation

◆ app_db_check_next_unique_id()

AppInstallId app_db_check_next_unique_id ( void  )

Get the next install id to be assigned, for tests.

Returns
Install id.

◆ app_db_compact()

int app_db_compact ( void  )

Compact the settings file backing the app database.

Returns
0 on success, a negative errno otherwise.

◆ app_db_delete()

int app_db_delete ( const uint8_t *  key,
int  key_len 
)

Delete a record from the app database.

The key is the app UUID. Notifies the app install manager.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
0 on success, a negative errno otherwise.

◆ app_db_enumerate_entries()

void app_db_enumerate_entries ( AppDBEnumerateCb  cb,
void *  data 
)

Call a function for every app in the database.

The database is locked during the iteration.

Parameters
cbCallback.
dataUser data passed to cb.

◆ app_db_exists_install_id()

bool app_db_exists_install_id ( AppInstallId  app_id)

Check whether an install id is in the database.

Parameters
app_idInstall id.
Returns
true if it exists.

◆ app_db_flush()

int app_db_flush ( void  )

Delete all records of the app database.

Also cancels any app fetch and clears the app install manager state.

Returns
0 on success, a negative errno otherwise.

◆ app_db_get_app_entry_for_install_id()

int app_db_get_app_entry_for_install_id ( AppInstallId  app_id,
AppDBEntry *  entry 
)

Read the record of an app by install id.

Parameters
app_idInstall id.
[out]entryRecord.
Returns
0 on success, a negative errno otherwise.

◆ app_db_get_app_entry_for_uuid()

int app_db_get_app_entry_for_uuid ( const Uuid *  uuid,
AppDBEntry *  entry 
)

Read the record of an app by UUID.

Parameters
uuidApp UUID.
[out]entryRecord.
Returns
0 on success, a negative errno otherwise.

◆ app_db_get_install_id_for_uuid()

AppInstallId app_db_get_install_id_for_uuid ( const Uuid *  uuid)

Find the install id of an app.

Parameters
uuidApp UUID.
Returns
Install id, INSTALL_ID_INVALID if the app is not in the database, or a negative errno if the database could not be opened.

◆ app_db_get_len()

int app_db_get_len ( const uint8_t *  key,
int  key_len 
)

Get the length of a record in the app database.

The key is the app UUID.

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

◆ app_db_health_allowed()

bool app_db_health_allowed ( const Uuid *  uuid)

◆ app_db_init()

void app_db_init ( void  )

Initialize the app database.

Scans the database to pick the next unused install id.

◆ app_db_insert()

int app_db_insert ( const uint8_t *  key,
int  key_len,
const uint8_t *  val,
int  val_len 
)

Insert or replace a record in the app database.

The key is the app UUID and the value an AppDBEntry. A new app gets the next unused install id; an existing one keeps its id, and an in-progress fetch of it is cancelled. Notifies the app install manager.

Parameters
keyKey data.
key_lenLength of key in bytes.
valValue data.
val_lenLength of val in bytes.
Returns
0 on success, a negative errno otherwise.

◆ app_db_microphone_granted()

bool app_db_microphone_granted ( const Uuid *  uuid)

◆ app_db_read()

int app_db_read ( const uint8_t *  key,
int  key_len,
uint8_t *  val_out,
int  val_out_len 
)

Read a record from the app database.

The key is the app UUID.

Parameters
keyKey data.
key_lenLength of key in bytes.
[out]val_outBuffer for the value.
val_out_lenSize of val_out in bytes.
Returns
0 on success, a negative errno otherwise.