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

Tracks the applications whose binaries are stored on the watch. More...

Functions

void app_cache_init (void)
 Initialize the app cache.
 
int app_cache_add_entry (AppInstallId app_id, uint32_t total_size)
 Add an entry for a newly installed app.
 
int app_cache_remove_entry (AppInstallId app_id)
 Remove an app's entry and delete its binaries.
 
bool app_cache_entry_exists (AppInstallId app_id)
 Check whether an app has an entry in the cache.
 
int app_cache_app_launched (AppInstallId app_id)
 Record a launch of an app.
 
int app_cache_free_up_space (uint32_t bytes_needed)
 Evict apps until at least bytes_needed bytes of binaries are freed.
 
void app_cache_flush (void)
 Clear the whole cache and delete all cached app binaries.
 

Detailed Description

Tracks the applications whose binaries are stored on the watch.

Each entry records an app's size, install date, last launch and launch count, persisted in a settings file. When storage runs low, the entries with the lowest priority (least recently installed or launched) are evicted and their binaries deleted; the default watchface and worker and the quick launch apps are only evicted as a last resort. Removing an entry deletes the app's binaries and emits a PEBBLE_APP_CACHE_EVENT.

Function Documentation

◆ app_cache_add_entry()

int app_cache_add_entry ( AppInstallId  app_id,
uint32_t  total_size 
)

Add an entry for a newly installed app.

Schedules an eviction on SysWorkq if free space is now too low.

Parameters
app_idApp to add.
total_sizeSize of the app's binaries, in bytes.
Return values
0Success.
Returns
Negative errno from the settings file on failure.

◆ app_cache_app_launched()

int app_cache_app_launched ( AppInstallId  app_id)

Record a launch of an app.

Updates the last launch time and launch count. If the app has no entry, its binaries are deleted.

Parameters
app_idLaunched app.
Return values
0Success.
Returns
Negative errno from the settings file on failure.

◆ app_cache_entry_exists()

bool app_cache_entry_exists ( AppInstallId  app_id)

Check whether an app has an entry in the cache.

An entry whose binaries are missing from storage is removed.

Parameters
app_idApp to look up.
Returns
true if the entry exists and the app's binaries are stored.

◆ app_cache_flush()

void app_cache_flush ( void  )

Clear the whole cache and delete all cached app binaries.

Must be called from SysWorkq.

◆ app_cache_free_up_space()

int app_cache_free_up_space ( uint32_t  bytes_needed)

Evict apps until at least bytes_needed bytes of binaries are freed.

Parameters
bytes_neededNumber of bytes to free.
Return values
0Success.
-EINVALbytes_needed is 0.
Returns
Other negative errno values come from the settings file.

◆ app_cache_init()

void app_cache_init ( void  )

Initialize the app cache.

Deletes leftover app binaries when no cache file exists and purges orphaned resource files.

◆ app_cache_remove_entry()

int app_cache_remove_entry ( AppInstallId  app_id)

Remove an app's entry and delete its binaries.

Parameters
app_idApp to remove.
Return values
0Success.
Returns
Negative errno from the settings file on failure.