PebbleOS
Loading...
Searching...
No Matches
Modules | Data Structures | Enumerations | Functions
Notifications

Notification storage, alerting policy and Do Not Disturb. More...

Modules

 Action chaining window
 Menu window to pick a follow-up action of a chained action result.
 
 Alerts
 Decides whether and how the user is alerted for a call or notification.
 
 Alert preferences
 Persistent user preferences for alerts, Do Not Disturb and the speaker.
 
 Alert preferences (internal)
 Preferences backing the alerts, Do Not Disturb and notification UI services.
 
 Alerts settings
 Alert masks and settings accessors used by the settings UI.
 
 ANCS notifications
 Turns notifications received over the Apple Notification Center Service into items.
 
 Do Not Disturb
 Quiet Time state, combining manual, scheduled and calendar-aware activation.
 
 Do Not Disturb toggle
 Quiet Time toggle dialog.
 
 Notification constants
 Constants shared by the SMS reply and phone call UIs.
 
 Notification images
 Single slot holding the phone-supplied image of the notification on screen.
 
 Notification storage
 Flash storage for received notifications.
 
 Notification storage sizing
 Size of the notification storage file.
 
 Notification types
 Kinds of alerting items shared by notifications and reminders.
 

Data Structures

struct  PebbleSysNotificationActionResult
 Result of an action, delivered in a PEBBLE_SYS_NOTIFICATION_EVENT. More...
 

Enumerations

enum  ActionResultType {
  ActionResultTypeSuccess , ActionResultTypeFailure , ActionResultTypeChaining , ActionResultTypeDoResponse ,
  ActionResultTypeSuccessANCSDismiss
}
 Outcome of an action invoked on a timeline item. More...
 

Functions

void notifications_init (void)
 Initialize the notifications service.
 
void notifications_handle_notification_action_result (PebbleSysNotificationActionResult *action_result)
 Post the result of an invoked action.
 
void notifications_handle_notification_added (Uuid *notification_id)
 Announce that a notification was added to storage.
 
void notifications_handle_notification_acted_upon (Uuid *notification_id)
 Announce that a stored notification was acted upon or updated on the phone.
 
void notifications_handle_notification_removed (Uuid *notification_id)
 Announce that a notification was removed.
 
void notifications_migrate_timezone (const int new_tz_offset)
 Shift the timestamps of all stored notifications after a timezone change.
 
void notifications_add_notification (TimelineItem *notification)
 Store a notification and announce it to the system.
 

Detailed Description

Notification storage, alerting policy and Do Not Disturb.

A notification is a TimelineItem of type TimelineItemTypeNotification (see Timeline items). Notifications arrive from the phone through the Notifs BlobDB, from ANCS on iOS (ANCS notifications) or are created on the watch. They are kept in a flash file (Notification storage) that is wiped at boot, and every change is announced to the UI with a PEBBLE_SYS_NOTIFICATION_EVENT.

Whether and how the user is alerted is decided by the alerts service (Alerts), which combines the user preferences (Alert preferences) with the Do Not Disturb state (Do Not Disturb).

Posting a notification created on the watch:

AttributeList attr_list = {0};
attribute_list_add_cstring(&attr_list, AttributeIdBody, "Body text");
AttributeList dismiss_attrs = {0};
attribute_list_add_cstring(&dismiss_attrs, AttributeIdTitle, "Dismiss");
TimelineItemActionGroup action_group = {
.actions = (TimelineItemAction[]){
{.id = 0, .type = TimelineItemActionTypeDismiss, .attr_list = dismiss_attrs},
},
};
&action_group);
if (item) {
}
time_t rtc_get_time(void)
Get the current time.
void notifications_add_notification(TimelineItem *notification)
Store a notification and announce it to the system.
List of attributes.
Definition attribute.h:234
void attribute_list_add_cstring(AttributeList *list, AttributeId id, const char *cstring)
Add a string attribute, or replace the value of an existing one.
void attribute_list_destroy_list(AttributeList *list)
Free the attributes array of a list.
@ AttributeIdTitle
(string) Title shown in a detailed view, at most 64 bytes.
Definition attribute.h:82
@ AttributeIdBody
(string) Body text of the view, at most 512 bytes.
Definition attribute.h:86
uint8_t num_actions
Number of actions.
Definition item.h:192
Action of a timeline item.
Definition item.h:180
Actions of a timeline item.
Definition item.h:190
A reminder, notification or pin.
Definition item.h:280
void timeline_item_destroy(TimelineItem *item)
Free an item allocated by the functions in this group, and its buffer.
TimelineItem * timeline_item_create_with_attributes(time_t timestamp, uint16_t duration, TimelineItemType type, LayoutId layout, AttributeList *attr_list, TimelineItemActionGroup *action_group)
Create an item from an attribute list and action group.
@ TimelineItemTypeNotification
Notification.
Definition item.h:170
@ TimelineItemActionTypeDismiss
Dismiss; handled locally for items that the phone does not track.
Definition item.h:116
@ LayoutIdNotification
Notification; requires a title.
Definition layout_layer.h:68

Removing it again:

void notification_storage_remove(const Uuid *id)
Remove a notification by marking it deleted.
void notifications_handle_notification_removed(Uuid *notification_id)
Announce that a notification was removed.

Data Structure Documentation

◆ PebbleSysNotificationActionResult

struct PebbleSysNotificationActionResult

Result of an action, delivered in a PEBBLE_SYS_NOTIFICATION_EVENT.

Allocated on the kernel heap as a single block with the attributes and actions following the struct; the event loop frees it after dispatch.

Data Fields
TimelineItemActionGroup action_group Follow-up actions, used with ActionResultTypeChaining.
AttributeList attr_list Result attributes, typically a message (title) and a large icon.
Uuid id Id of the item the action was invoked on.
ActionResultType type Outcome of the action.

Enumeration Type Documentation

◆ ActionResultType

Outcome of an action invoked on a timeline item.

Enumerator
ActionResultTypeSuccess 

The action succeeded.

ActionResultTypeFailure 

The action failed.

ActionResultTypeChaining 

The phone needs the user to pick a follow-up action from the result's action group.

ActionResultTypeDoResponse 

The phone asks the watch to start a reply.

ActionResultTypeSuccessANCSDismiss 

The action succeeded and the ANCS notification should also be dismissed.

Function Documentation

◆ notifications_add_notification()

void notifications_add_notification ( TimelineItem *  notification)

Store a notification and announce it to the system.

The item is serialized into storage, so the caller keeps ownership of notification.

Parameters
notificationNotification to add.

◆ notifications_handle_notification_acted_upon()

void notifications_handle_notification_acted_upon ( Uuid *  notification_id)

Announce that a stored notification was acted upon or updated on the phone.

Parameters
notification_idId allocated on the kernel heap. Ownership passes to the event loop.

◆ notifications_handle_notification_action_result()

void notifications_handle_notification_action_result ( PebbleSysNotificationActionResult *  action_result)

Post the result of an invoked action.

Parameters
action_resultResult allocated on the kernel heap, or NULL when there is no result to show. Ownership passes to the event loop.

◆ notifications_handle_notification_added()

void notifications_handle_notification_added ( Uuid *  notification_id)

Announce that a notification was added to storage.

Parameters
notification_idId allocated on the kernel heap. Ownership passes to the event loop.

◆ notifications_handle_notification_removed()

void notifications_handle_notification_removed ( Uuid *  notification_id)

Announce that a notification was removed.

Only posts the event; remove the notification from storage with notification_storage_remove().

Parameters
notification_idId of the removed notification. It is copied.

◆ notifications_init()

void notifications_init ( void  )

Initialize the notifications service.

Initializes notification storage, which discards all stored notifications.

◆ notifications_migrate_timezone()

void notifications_migrate_timezone ( const int  new_tz_offset)

Shift the timestamps of all stored notifications after a timezone change.

Parameters
new_tz_offsetOffset in seconds subtracted from each stored timestamp.