prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (islower(c)) return (c - 'a') + 10; |
return -1;
}
static uint8_t ascii_hex_to_uint(const uint8_t msb, const uint8_t lsb) {
return 16 * ascii_hex_to_int(msb) + ascii_hex_to_int(lsb);
}
uintptr_t str_to_address(const char *address_str) {
unsigned int address_str_length = strlen(address_str);
if (address_str_length < 3) return -1; // Invalid add... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (STUCK_BUTTON_REGISTER) | ;
uint8_t* button_counter = (uint8_t*) (&button_counter_register);
bool result = false;
for (int button_id = 0; button_id < NUM_BUTTONS; button_id++) {
if (!button_is_pressed(button_id)) {
button_counter[button_id] = 0;
continue;
}
if (button_counter[button_id] >= STUCK_BUTTON_THRESHOLD)... |
ggered;
recognizer_manager_deregister_recognizer(&manager, r1);
cl_assert_equal_p(manager.triggered, r2);
cl_assert_equal_p(manager.active_layer, &layer_a);
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersTriggered);
cl_assert_equal_i(r2->state, RecognizerState_Started);
cl_assert(!recogn... | (manager.state, RecognizerManagerState_WaitForTouchdown) | ;
cl_assert_equal_p(manager.triggered, NULL);
cl_assert_equal_p(manager.active_layer, NULL);
prv_compare_recognizers_processed((int []) { 0, 1 }, 2, &s_recognizers_reset);
recognizer_set_simultaneous_with(r[0], prv_simultaneous_with_cb);
r[0]->state = RecognizerState_Started;
r[1]->state = RecognizerState_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | delay_us(5) | ;
} else {
psleep(2); // must sleep >= 450us
}
}
static void prv_burst_read(uint8_t reg, void *buf, size_t len) {
reg |= BMI160_READ_FLAG;
SPIScatterGather sg_info[2] = {
{.sg_len = 1, .sg_out = ®, .sg_in = NULL}, // address
{.sg_len = len, .sg_out = NULL, .sg_in = buf} // read data
};
spi_... |
0,
&GPoint(10, 10), 20, 5, true);
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(13, 13), 4... | prv_test_touch_event(&ctx.touch_events[1], 0, TouchEvent_PositionUpdate, &GPoint(13, 13), 3686420,
6, &GPoint(2, 2), 20, 0, true) | ;
touch_dispatch_touch_events(1, prv_touch_event_dispatch_cb, &ctx);
cl_assert_equal_i(ctx.idx, 4);
prv_test_touch_event(&ctx.touch_events[2], 1, TouchEvent_Touchdown, &GPoint(55, 55), 3686480, 2,
NULL, 0, 0, false);
prv_test_touch_event(&ctx.touch_events[3], 1, TouchEvent_PositionUpdate... |
ed.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "timeline_layout_animations.h"
#include "applib/graphics/graphics.h"
#include "applib/ui/animation_interpolate.h"
#include "applib/ui/animation_timing.h"
#include "applib/ui/kino/kino_reel/scale_s... | prv_pin_to_card_second_half(timeline_layout, timeline_layout->transition_layout) | ;
}
timeline_layout->transition_layout = NULL;
}
void timeline_layout_transition_pin_to_card(TimelineLayout *pin_timeline_layout,
TimelineLayout *card_timeline_layout) {
KinoReel *from_reel = kino_reel_create_with_resource_system(
pin_timeline_layout->icon_res_i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ((uint8_t *)&read_buffer, read_addr, sizeof(read_buffer)) | ;
if (disp_logs) {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Reading Addr 0x%"PRIx32" value is 0x%"PRIx16,
read_addr, read_buffer);
}
if (read_buffer != expected_val) {
switch (err_code) {
case FLASH_TEST_ERR_ERASE:
PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Did not successfully erase the sector");
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_context_move_draw_box(ctx, offset) | ;
gdraw_command_list_draw_processed(ctx, &image->command_list, processor);
// Offset graphics context drawing box back to previous origin
graphics_context_move_draw_box(ctx, GPoint(-offset.x, -offset.y));
}
size_t gdraw_command_image_get_data_size(GDrawCommandImage *image) {
if (!image) {
return 0;
}
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, GCompOpAssign) | ;
graphics_draw_rotated_bitmap(ctx, (GBitmap*)&s_gfx_rotated_bitmap_64_bitmap,
GPointZero, 0, GPointZero);
}
static void prv_test_0_set_64px(Layer *layer, GContext* ctx) {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
graphics_draw_rotated_bitmap(ctx, (GBitmap*)&s_gfx_rot... |
stem_font(config->music_time_font_key));
layer_add_child(&data->window.layer, &data->length_text_layer.layer);
prv_configure_music_text_layer(&data->title_text_layer, data->title_buffer, &title_rect,
TITLE_BOUNDS_OFFSET, ARTIST_TITLE_TEXT_ALIGNMENT,
... | prv_update_layout(data) | |
LL) ?:
attribute_get_string(attributes, layout->impl->attributes.primary_id, "");
primary_node->line_spacing_delta = style->primary_line_spacing_delta;
int num_primary_lines = is_fat ? 2 : 1;
if (is_peek) {
if (!has_secondary) {
num_primary_lines = 2;
const int primary_only_off... | (&vertical_icon_node->container, &icon_node->node) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cron_service_init() | ;
}
void test_cron__cleanup(void) {
cron_service_deinit();
}
static TimezoneInfo g_timezone;
static void prv_set_rtc(time_t t, const TimezoneInfo *tz_info) {
fake_rtc_init(0, t);
g_timezone = *tz_info;
time_util_update_timezone(&g_timezone);
}
static void prv_cron_callback(CronJob *job, void* data) {
job->... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
OptionMenu * const option_menu = settings_option_menu_create(
i18n_title_key, content_type, choice, callbacks_ref, num_rows, icons_enabled, rows, context);
if (option_menu) {
const bool animated = true;
app_window_stack_push(&option_menu->window, animated);
}
return option_menu;
} |
void *settings_option_menu_get_context(SettingsOptionMenuData *data) {
return data->context;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_copy_pstring_and_add_ellipsis(&ancs_attr->pstr, (char *)buffer,
(ancs_attr->length == max_length)) | ;
}
static uint8_t *prv_add_action_msg_to_attribute(
uint8_t *buffer, const ANCSAttribute *sender, int sender_max_length,
const ANCSAttribute *caption, int caption_max_length, const char *action_msg,
Attribute *attribute, AttributeId attribute_id) {
// Sets an attribute to <sender> ' ' <action_msg> ( '\n... |
stale 10 minutes after their start time, or when the event is over
return item->header.timestamp + MAX(10, item->header.duration) * SECONDS_PER_MINUTE;
}
static void prv_clear_if_stale_reminder(Uuid *id, NotificationType type, void *cb_data) {
NotificationWindowData *window_data = cb_data;
if (type != Notifica... | (simple_dialog) | ;
const char *msg = i18n_get("Snoozed", dialog);
dialog_set_text(dialog, msg);
dialog_set_icon(dialog, RESOURCE_ID_REMINDER_SNOOZE);
i18n_free(msg, dialog);
dialog_set_text_color(dialog, GColorWhite);
dialog_set_fullscreen(dialog, true);
dialog_set_background_color(dialog, GColorBlueMoon);
dialog_set_ti... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | dbgserial_putchar_lazy(c) | ;
dbgserial_flush();
}
void dbgserial_putchar_lazy(uint8_t c) {
uart_write_byte(DBG_UART, c);
}
void dbgserial_flush(void) {
uart_wait_for_tx_complete(DBG_UART);
}
void dbgserial_putstr_fmt(char* buffer, unsigned int buffer_size, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsniprintf(buffer, b... |
out doing
// anything further.
break;
}
}
}
static void prv_reset(Transport *transport) {
PBL_LOG(LOG_LEVEL_INFO, "Unimplemented");
}
static void prv_granted_kernel_main_cb(void *ctx) {
ResponsivenessGrantedHandler granted_handler = ctx;
granted_handler();
}
static void prv_set_connection_res... | kernel_free(data) | ;
}
static void prv_pulse_pp_send(uint8_t opcode, uint8_t *data, size_t data_length) {
size_t packet_length = sizeof(PulsePPCallbackPacket) + data_length;
PulsePPCallbackPacket *cb_data = kernel_malloc_check(packet_length);
cb_data->packet_length = sizeof(PulsePPPacket) + data_length;
cb_data->packet.opcode = ... |
itmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r0_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r1_sw11... | (&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi") | |
168, 128, 216},
{ 1232, 24, 280},
// 100 seconds
{ 984, 56, 232},
{ 840, 72, 160},
{ 824, 72, 64},
{ 792, -32, 128},
{ 824, 16, 72},
{ 888, 0, 32},
{ 888, -72, -8},
{ 960, -72, -72},
{ 1288, -208, 24},
{ 1352, -112, 152},
{ 1224, 216, 0},
{ 1432, 272, -24},
{ ... | { 1304, 240, -128},
{ 1248, 176, -112},
{ 1040, 184, 152},
{ 880, 216, 136},
{ 928, 280, 128},
{ 912, 312, 160},
{ 856, 352, 88},
// 106 seconds
{ 816, 344, -16},
{ 928, 400, -120},
{ 1040, 376, -128},
{ 1216, 384, -136},
{ 1696, 296, 56},
{ 1784, 328, 96},
{ ... |
{ -144, 448, -752},
{ -72, 192, -768},
{ 8, -8, -864},
{ 96, 8, -928},
{ 184, 24, -1032},
{ 136, -96, -1048},
{ 40, -16, -1024},
{ 176, 0, -1048},
{ 128, -72, -1048},
{ 96, -80, -1040},
{ 56, -104, -1032},
{ 104, -72, -1008},
{ 32, -152, -1016},
};
*len = ARRAY_L... |
reason = evt->reason,
.handle = evt->conn_idx,
};
hc_endpoint_gap_le_connect_send_disconnection_complete(&event);
connection_destroy(connection_by_idx(evt->conn_idx));
}
static void prv_handle_evt_gap_sec_level_changed(const ble_evt_gap_sec_level_changed_t *evt) {
PBL_LOG(LOG_LEVEL_INFO, "Security level ... | PBL_LOG(LOG_LEVEL_DEBUG, "Skipping syncing new pairing info...") | ;
} else {
const bool success = (evt->status == BLE_STATUS_OK);
if (success && evt->bond) {
// Sync the new bonding:
bonding_sync_handle_pairing_completed(conn, conn_idx);
}
BTDeviceInternal device = {};
connection_get_address(conn, &device);
hc_endpoint_pairing_send_pairing_comple... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | pfs_seek(fd, address, FSeekSet) | |
se, app_install_id_from_system(1000000));
}
void test_app_install_manager__is_from_app_db(void) {
cl_assert_equal_b(false, app_install_id_from_app_db(-1000000));
cl_assert_equal_b(false, app_install_id_from_app_db(-1));
cl_assert_equal_b(false, app_install_id_from_app_db(0));
cl_assert_equal_b(true, app_instal... | cl_assert(true == app_install_entry_is_hidden(&entry)) | ;
}
void test_app_install_manager__recently_communicated(void) {
static const uint32_t INIT_TIME = 1388563200;
fake_rtc_init(0, INIT_TIME);
cl_assert_equal_b(false, app_install_is_prioritized(music_id));
// Update most recent time.
app_install_mark_prioritized(music_id, true /* can_expire */);
cl_assert_... |
Task];
EventServiceAddSubscriberCallback add_subscriber_callback;
EventServiceRemoveSubscriberCallback remove_subscriber_callback;
} EventServiceEntry;
typedef struct {
ListNode list_node;
void *ptr;
// There is an intent bit for each task + a special "claimed" bit
uint16_t intents_pending;
} EventServiceB... | kernel_free(s_event_services[type]) | ;
}
s_event_services[type] = kernel_malloc(sizeof(EventServiceEntry));
memset(s_event_services[type], 0, sizeof(*s_event_services[type]));
s_event_services[type]->add_subscriber_callback = add_subscriber_callback;
s_event_services[type]->remove_subscriber_callback = remove_subscriber_callback;
}
bool event_... |
he certification content and center it in the window
GBitmap *bmp = &data->kcc_mark;
const GSize bmp_size = bmp->bounds.size;
const GFont title_text_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
const GSize title_text_size = GSize(window_bounds.size.w, fonts_get_font_height(title_text_font));
const G... | (a_dialog, prv_shutdown_click_provider) | |
onst void *arg2) {
const GRect *cell_layer_bounds = &cell_layer->bounds;
uint32_t start_idx = (uintptr_t)arg1;
uint32_t num_marks = (uintptr_t)arg2;
// Calculate rect containing generic marks
GSize overall_size = GSize(MARK_PADDING * (num_marks + 1), 0);
for (uint32_t i = 0; i < num_marks; i++) {
const ... | menu_cell_basic_draw(ctx, cell_layer, title, subtitle, NULL) | ;
i18n_free(subtitle, title);
}
static void prv_certification_draw_row_callback(GContext* ctx, const Layer *cell_layer,
MenuIndex *cell_index, void *context) {
SettingsSystemData *data = (SettingsSystemData *) context;
PBL_ASSERTN(cell_index->section == 0);
System... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | list_insert_before(&b, &a) | |
#include "os/mutex.h"
#include "system/logging.h"
#include "system/passert.h"
#include <bluetooth/bluetooth_types.h>
#include <btutil/bt_device.h>
#include <util/list.h>
#include <stdint.h>
#include <string.h>
extern void ppogatt_destroy_state(PPoGATTWorkAroundState *state);
typedef struct ForEachCbData {
Connect... | cb_data->cb((Connection *)found_node, cb_data->data) | ;
return false; // Force not found -- iterate the entire list
}
void connection_for_each(ConnectionForEachCallback cb, void *data) {
prv_lock();
ForEachCbData cb_data = { .cb = cb, .data = data };
{
list_find((ListNode *)s_connections, prv_connection_for_each_cb, &cb_data);
}
prv_unlock();
}
//
// Get... |
ic void prv_read_samples(void *data) {
uint8_t src_reg;
lis3dh_read(LIS3DH_FIFO_SRC_REG, 1, &src_reg);
uint8_t num_samples = src_reg & FSS_MASK;
AccelRawData accel_raw_data[num_samples];
if (src_reg & FIFO_OVRN) {
PBL_LOG(LOG_LEVEL_ERROR, "Fifo overrun");
analytics_inc(ANALYTICS_DEVICE_METRIC_ACCEL_F... | lis3dh_get_fifo_mode() | |
///
/// Helper routines for pfs_open()
///
//! Returns true iff the file is found in the cache and the fd is ready to use
//! fd_used >= 0 if we were able to allocate a fd for the file (regardless of
//! whether or not its in the cache), else it reflects the error code
static NOINLINE bool file_found_in_cache(const ... | {
res = pfs_open_handle_create_request(fd, file_type, start_size);
} | else if ((op_flags & OP_FLAG_READ) != 0) {
res = pfs_open_handle_read_request(fd, page);
} else { // unexpected situation
res = E_INTERNAL;
}
cleanup:
if (res < S_SUCCESS) {
mark_fd_free(fd);
} else {
PFS_FD(fd).fd_status = FD_STATUS_IN_USE;
}
return (res);
}
int pfs_open(const char *name... |
00},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
... | { 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1008},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 40, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 40, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{... |
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 40, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 40, 0, -1000},
{ 48, 8, -1000},
... |
include "system/passert.h"
#include "system/status_codes.h"
#include "util/math.h"
//! Return true to continue iteration and false to stop it.
typedef bool (*SliceForEachCb)(AppGlanceSliceInternal *slice, void *context);
static void prv_slice_for_each(AppGlance *glance, SliceForEachCb cb, void *context) {
if (!glan... | {
static EventServiceInfo s_blob_db_event_info = {
.type = PEBBLE_BLOBDB_EVENT,
.handler = prv_blob_db_event_handler,
};
event_service_client_subscribe(&s_blob_db_event_info);
static EventServiceInfo s_app_cache_event_info = {
.type = PEBBLE_APP_CACHE_EVENT,
.handler = prv_handle_app_cache_eve... |
bool app_glance_service_get_current_slice(const Uuid *app_uuid, AppGlanceSliceInternal *slice_out) {
if (!slice_out) {
return false;
}
bool success;
// Try to read the app's glance, first checking the cache
AppGlance *app_glance = kernel_zalloc_check(sizeof(*app_glance));
const status_t rv = app_glan... |
{
return;
} |
launcher_task_add_callback(prv_push_calibration_dialog, NULL);
}
T_STATIC bool prv_is_known_misaligned_serial_number(const char *serial) {
// Filter watches known to be misaligned based on the serial number. This is possible because
// Serial numbers are represented as strings as described in:
// https://peb... | |
lti Click! (%u)\nMin: 2, Max: 10", count);
PBL_LOG(LOG_LEVEL_DEBUG, "Multi Click! (%u)", click_number_of_clicks_counted(recognizer));
text_layer_set_text(&data->text, data->text_buffer);
toggle_color(window);
}
static void select_single_click_handler(ClickRecognizerRef recognizer, Window *window) {
ClickAppDat... | handle_init() | ;
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* click_app_get_info() {
static const PebbleProcessMdSystem s_click_app_info = {
.common.main_func = s_main,
.name = "Clicks"
};
return (const PebbleProcessMd*) &s_click_app_info;
}
#undef TEXT_BUFFER_SIZE
|
expandable_dialog_get_dialog(expandable_dialog) | , crash_reason);
expandable_dialog_show_action_bar(expandable_dialog, false);
expandable_dialog_push(expandable_dialog, prv_get_window_stack());
light_enable_interaction();
}
//! Restrict only to the two defines above
//! Show the "Your pebble has just reset"
void crashed_ui_show_pebble_reset(void) {
launcher... | |
_t conn_idx, const HcProtocolMessage *msg) {
PBL_ASSERTN(msg->command_id == HcMessageID_Gatt_WriteNoResponse);
// Remap a data write to a data notification
HcGattWriteData *data = (HcGattWriteData *)&msg->payload[0];
ble_error_t e = ble_gatts_send_event(
conn_idx, s_ppogatt_ctx.att_hdl.data, GATT_EVENT_N... | (&uuid, GATT_PROP_WRITE_NO_RESP | GATT_PROP_NOTIFY,
ATT_PERM_WRITE,
data_wr_size,
enable_read_cb_flag, NULL,
&ctx->att_hdl.data) | == BLE_STATUS_OK);
ble_uuid_create16(UUID_GATT_CLIENT_CHAR_CONFIGURATION, &uuid);
PBL_ASSERTN(ble_gatts_add_descriptor(&uuid, ATT_PERM_RW, sizeof(uint16_t), enable_read_cb_flag,
&ctx->att_hdl.cccd) == BLE_STATUS_OK);
prv_convert_uuid_to_little_endian((const uint8_t[]){PEB... |
{ -1048, 592, -32},
{ -1184, 464, 0},
{ -1456, 400, 96},
{ -1448, 384, 0},
{ -1400, 304, -728},
{ -1344, 480, 128},
{ -1192, 336, 224},
{ -1232, 184, 296},
{ -1080, 168, 280},
{ -1232, 64, 360},
{ -1200, -256, 280},
{ -1176, -152, 120},
{ -1168, 64, -24},
{ -1104... | { -1112, 472, 104},
{ -1320, 488, -40},
{ -1408, 456, -56},
{ -1384, 392, -24},
{ -1232, 208, 120},
{ -1176, 136, 424},
{ -1200, 136, 120},
// 61 seconds
{ -1144, 152, 112},
{ -1040, 136, 120},
{ -1024, 120, 128},
{ -1088, 64, 168},
{ -912, -72, 152},
{ -1016, -24... |
{ -40, 936, 208},
{ -48, 888, 272},
{ -48, 856, 304},
{ -48, 888, 304},
{ -8, 808, 304},
{ -16, 864, 248},
{ 0, 824, 328},
{ -40, 992, 376},
{ -16, 1048, 248},
{ -8, 784, 448},
{ 48, 784, 160},
{ 8, 896, 216},
{ 16, 848, 240},
{ 0, 840, 312},
{ 0, 880, 184},
... |
0x0},
{ 8, 0x62, 5481, 0x0},
{ 0, 0x47, 301, 0x0},
// 585: Local time: 07:16:00 AM
{ 0, 0x47, 0, 0x0},
{ 0, 0x47, 276, 0x0},
{ 0, 0x47, 0, 0x0},
{ 0, 0x47, 0, 0x0},
{ 0, 0x47, 10, 0x0},
{ 0, 0x47, 0, 0x0},
{ 0, 0x47, 29, 0x0},
{ 0, 0x47, 0, 0x0},
{ 0, 0x47, 0, 0x0},
{... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME watch_on_table_2
//> TEST_VERSION 2
//> TEST_TOTAL 0
//> TEST_TOTAL_MIN 0
//> TEST_TOTAL_MAX 0
//> TEST_DEEP 0
//> TEST_DEEP_MIN 0
//> TEST_DEEP_MAX 0
//> TEST_START_AT -1
//> TEST_START_AT_MIN -1
//> TEST_START_... |
{ 0, 0x8c, 0, 201},
{ 0, 0x8c, 0, 201},
{ 0, 0x8c, 0, 200},
{ 0, 0x8c, 0, 200},
{ 0, 0x8c, 0, 200},
{ 0, 0x8c, 0, 201},
{ 0, 0x8c, 0, 201},
{ 0, 0x8c, 0, 201},
{ 0, 0x8c, 0, 202},
{ 0, 0x8c, 0, 200},
{ 0, 0x8c, 91, 209},
{ 0, 0x8c, 0, 203},
{ 0, 0x8c, 0, 205},
{ ... |
--------------------------------------------------
// Exported function used by blob_db API to read our backing store
bool prefs_private_read_backing(const uint8_t *key, size_t key_len, void *value, int value_len) {
const PrefsTableEntry *entry = prv_prefs_entry(key, key_len);
if (!entry) {
return false;
}
... | {
prv_pref_set(PREF_KEY_BACKLIGHT_ENABLED, &enabled, sizeof(enabled));
} | |
111, // Deep Sleep Duration
2222, // Fall Asleep Time
3333, // Wakeup Time
4444, // Active Time
5555, // Typical sleep duration
6666, // Typical deep sleep duration
7777, // Typical fall asleep time
8888, // Typical wakeup time
};
static ui... | cl_assert_equal_i(val_out, s_sleep_data[SD_TypicalWakeupTime]) | ;
}
void test_health_db__hr_zone_data(void) {
const char *key = "monday_heartRateZoneData";
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
(uint8_t *)s_hr_zone_data, sizeof(s_hr_zone_data)),
S_SUCCESS);
cl_assert_equal_i(s_metric_updated_... |
system_theme_get_font_key_for_size(ToPreferredContentSize(content_size), style_font);
}
GTextNodeVertical *layout_create_headings_paragraphs_node(
const LayoutLayer *layout, const LayoutNodeHeadingsParagraphsConfig *config) {
const AttributeList *attributes = layout->attributes;
StringList *headings = att... | PBL_IF_ROUND_ELSE(icon_config_node, NULL) | |
E.raw_value) {
// Color hack
GColor tmp_color = ctx->draw_state.stroke_color;
ctx->draw_state.stroke_color = ctx->draw_state.fill_color;
// prv_circle_arc_draw_1px(ctx, center, radius_outer, angle_start, angle_end);
// Restore color
ctx->draw_state.stroke_color = tmp_color;
// We're done ... | GPointFromGPointPrecise(result) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | sign_extend(1, 3) | , 1);
cl_assert_equal_i(sign_extend(-1, 32), -1);
cl_assert_equal_i(sign_extend(-1, 3), -1);
cl_assert_equal_i(sign_extend(7, 32), 7);
cl_assert_equal_i(sign_extend(7, 3), -1);
}
void test_math__serial_distance32(void) {
{
int32_t dist = serial_distance32(0x0, 0x1);
cl_assert_equal_i(dist, 1);
}... |
->length - offsetof(PebblePairingServiceConnParamsWrite,
remote_desired_state));
switch (conn_params->cmd) {
case PebblePairingServiceConnParamsWriteCmd_SetRemoteParamMgmtSettings:
rv = prv_validate_set_remote_param_mgmt_settings_cmd(&conn_params->remote_param... | ble_gatts_add_service(&uuid, GATT_SERVICE_PRIMARY, num_attr, start_hdl) | == 0);
// RivieraWaves caches values internally and only calls back once if we don't set this:
const uint8_t enable_read_cb_flag = GATTS_FLAG_CHAR_READ_REQ;
// Connectivity Status characteristic + CCCD:
prv_convert_uuid_to_little_endian(
(const uint8_t[]){PEBBLE_BT_PAIRING_SERVICE_CONNECTION_STATUS_UUI... |
_stack =
modal_manager_get_window_stack(ModalPriorityGeneric);
cl_check(window_stack);
cl_check(!window_stack->list_head);
window_stack_push(window_stack, window, true);
cl_assert_equal_i(window_stack_count(window_stack), 1);
window_stack_pop(window_stack, true);
cl_assert_equal_i(window_stack_co... | (window1->on_screen, true) | ;
cl_assert_equal_i(window2->on_screen, false);
app_window_stack_pop(true);
cl_assert_equal_i(app_window_stack_count(), 1);
cl_assert_equal_i(window1->on_screen, false);
cl_assert_equal_i(window2->on_screen, true);
app_window_stack_pop(true);
cl_assert_equal_i(app_window_stack_count(), 0);
cl_assert... |
eState state,
uint16_t max_period_secs,
ResponsivenessGrantedHandler granted_handler);
CommSession *s_session;
Transport *s_transport = (Transport *) ~0;
const TransportImplementation s_transport_implementation = {
.send_ne... | RECEIVE(0x00) | ;
cl_assert_equal_i(s_prepare_count, 0);
// Length low byte (big endian!)
RECEIVE(0x01);
cl_assert_equal_i(s_prepare_count, 0);
// Endpoint low byte (big endian!)
RECEIVE(PRIVATE_TEST_ENDPOINT_ID >> 8);
cl_assert_equal_i(s_prepare_count, 0);
// Endpoint low byte (big endian!)
RECEIVE(PRIVATE_TEST_E... |
NAME}__origin_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// SW = 1
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin... | (&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 5) | ;
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// SW = 11
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx... |
= Unknown (process stack pointer)
// LR = 0xFFFFFFFF
// PC = VECTOR_TABLE[1]
// PRIMASK = 0x0
// FAULTMASK = 0x0
// BASEPRI = 0x0
// CONTROL = 0x0
//
// Attempt to put the processor into as close to the reset state as possible
// before passing control to the firmware.
/... | if (boot_bit_test(BOOT_BIT_FORCE_PRF)) {
boot_bit_clear(BOOT_BIT_FORCE_PRF);
return true;
} |
if (prv_prf_button_combination_is_pressed()) {
dbgserial_putstr("Hold down UP + BACK + SELECT for 5 secs. to force-boot PRF");
for (int i = 0; i < 5000; ++i) {
if (!prv_prf_button_combination_is_pressed()) {
// stop waiting if not held down any longer
return false;
}
delay_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */) | ;
resource_init();
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
content_indicator_init_buffer(buffer);
}
void test_weather_app_layout__cleanup(void) {
free(fb);
}
// Helpers
//////////////////////
static void prv_create_layout_for_forecast(const WeatherLocationForecast *forecas... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gpio_af_init(&bus->sda_gpio, GPIO_OType_OD, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL) | ;
}
static void prv_bus_pins_cfg_input(I2CBus *bus) {
InputConfig in_scl = {
.gpio = bus->scl_gpio.gpio,
.gpio_pin = bus->scl_gpio.gpio_pin,
};
gpio_input_init(&in_scl);
InputConfig in_sda = {
.gpio = bus->sda_gpio.gpio,
.gpio_pin = bus->sda_gpio.gpio_pin,
};
gpio_input_init(&in_sda);
}
/... |
ullyCharged
}},
[BatteryWarning] = { .enter = prv_display_warning, .exit = prv_dismiss_warning, .next_state = {
BatteryGood, BatteryWarning, BatteryLowPower, BatteryCharging
}},
[BatteryLowPower] = { .enter = prv_enter_low_power, .exit = prv_exit_low_power, .next_state = {
BatteryWarning, BatteryCritica... | (StatusLedState_Off) | ;
}
// TODO PBL-39883: Replace w/ QUIRK_RESET_ON_SHUTDOWN_WHILE_CHARGING once arbitrary prefixes land
#if PLATFORM_TINTIN || PLATFORM_SILK
static void prv_shutdown(void *ignored) {
battery_ui_handle_shut_down();
}
#else
static void prv_enter_shutdown_charging(void *ignored) {
app_manager_put_launch_app_event(&(App... |
lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_malloc(task_heap_get_for_current_task(), bytes, saved_lr);
}
void *task_malloc_check(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap = task_heap_get_for_current_task();
void *mem = heap_malloc(heap, bytes, saved_l... | (app_state_get_heap(), s, saved_lr) | ;
}
// kernel_* functions that allocate on the kernel heap
///////////////////////////////////////////////////////////
void *kernel_malloc(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_malloc(kernel_heap_get(), bytes, saved_lr);
}
void *kernel_malloc_check(size_t bytes... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, &fb, GContextInitializationMode_System) | ;
const uint16_t row_size_bytes = bounds.w;
ctx->dest_bitmap = (GBitmap){
.addr = malloc(row_size_bytes * bounds.h),
.bounds = (GRect){.size = bounds},
.row_size_bytes = row_size_bytes,
.info.version = 1,
.info.format = GBitmapFormat8Bit,
};
ctx->draw_state.clip_box = ctx->dest_bitmap.boun... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (MAG_Z_CORRECTION_VAL, 0x0) | ;
s_saved_corr_present = false;
}
static void prv_save_calibration_values(int16_t *corr) {
// first zero out the valid marker
prv_reset_saved_sample();
uint32_t valxy = (((uint32_t)corr[1]) << BITS_PER_CORRECTION_VAL) |
(corr[0] & CORRECTION_VAL_MASK);
uint32_t valz = (((uint32_t)VALID_CORR_MARKER) <<... |
but if there
// is an integer remainder, the prescaler will ensure that the clock frequency is within spec.
prescaler -= 1;
}
// Make sure all the values fit in their corresponding fields
PBL_ASSERTN((duty_cycle_low <= TIMINGR_MASK_SCLL) &&
(duty_cycle_high <= TIMINGR_MASK_SCLH) &&
... | (bus, event) | |
e top window above an opaque top window does not result in Unfocusable
modal_manager_event_loop_upkeep();
cl_assert_equal_i(modal_manager_get_properties(),
ModalProperty_Exists | ModalProperty_CompositorTransitions |
ModalProperty_RenderRequested);
cl_assert_equal_i(windows... | cl_assert_equal_p(s_last_click_configured_window, window1) | ;
// Switch to the kernel to push a modal window
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
window_stack_push(modal_stack, window2, true);
cl_assert_equal_i(window_stack_count(modal_stack), 1);
cl_assert_equal_i(window2->on_screen, true);
cl_assert_equal_p(s_last_click_configured_window, windo... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (heartbeat, metric) | ;
analytics_storage_give_lock();
printf("Battery change period: %"PRId64"\n", value);
// 1024 ticks === 1000 ms
cl_assert(value == 1000);
}
static bool dls_log_called = false;
static int64_t expected_value = 254307546;
void test_analytics__minimal_logging_test(void) {
analytics_set(ANALYTICS_DEVICE_METRIC_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (initial_size == 0) {
pos--; // the space we previously added should be omitted from our string.
break;
} |
pos += initial_size;
destination[pos++] = '.';
} while ((space = strchr(space, ' ')));
destination[pos] = '\0';
}
// based on https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers
void phone_format_phone_number(const char *phone_number, char *formatted_phone_number,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ANALYTICS_DEVICE_METRIC_STACK_FREE_BLUETOPIA_SMALL,
prv_task_get_stack_free(PebbleTask_BTTimer), AnalyticsClient_System) | ;
analytics_set(ANALYTICS_DEVICE_METRIC_STACK_FREE_NEWTIMERS,
prv_task_get_stack_free(PebbleTask_NewTimers), AnalyticsClient_System);
}
QueueHandle_t pebble_task_get_to_queue(PebbleTask task) {
QueueHandle_t queue;
switch (task) {
case PebbleTask_KernelMain:
queue = event_get_to_kernel_queue(pebbl... |
i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Cancelled);
cl_assert_equal_i(recognizers[2]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_... | ((int[]) {4, 0}, 2, &s_recognizers_handled) | ;
prv_compare_recognizers_processed(NULL, 0, &s_recognizers_reset);
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersActive);
cl_assert_equal_p(manager.triggered, NULL);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerSta... |
_t gothic_18_handle = RESOURCE_ID_GOTHIC_18;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
uint8_t glyph_size_bytes;
const GlyphData *glyph;
glyph = text_resources_get_glyph(&s_font_cache, 'a', &s_font_info);
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(a_... | cl_assert(text_resources_init_font(0, gothic_18_bold_handle, gothic_18_bold_extended_handle, &s_font_info)) | ;
cl_assert(s_font_info.loaded);
cl_assert(s_font_info.extended);
uint8_t glyph_size_bytes;
const GlyphData *glyph;
glyph = text_resources_get_glyph(&s_font_cache, 'a', &s_font_info);
cl_assert(glyph != NULL);
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(a_glyph_data_bytes, glyph-... |
256, -80},
{ 936, 248, -104},
{ 1240, 312, -120},
// 41 seconds
{ 1416, 376, -112},
{ 1792, 416, -208},
{ 1720, 456, -168},
{ 1248, 400, -144},
{ 1192, 328, -40},
{ 1208, 248, 32},
{ 1168, 272, -24},
{ 1000, 216, 48},
{ 920, 160, 112},
{ 912, 184, 120},
{ 912, 160... | { 888, 256, 24},
{ 752, 304, -40},
{ 696, 336, -40},
{ 760, 336, 24},
{ 888, 384, 16},
{ 968, 392, 8},
{ 1104, 424, -48},
{ 1256, 408, -32},
{ 1504, 288, 176},
// 47 seconds
{ 1728, 472, 32},
{ 1184, 512, 32},
{ 1192, 312, 72},
{ 1328, 304, 64},
{ 1352, 280, 1... |
{ 1072, 416, -24},
{ 1168, 336, -40},
{ 1224, 264, 0},
{ 1248, 192, 16},
{ 1096, 200, 88},
{ 976, 200, 96},
{ 936, 208, 104},
{ 888, 184, 112},
{ 832, 152, 120},
{ 808, 120, 120},
{ 840, 72, 120},
{ 1008, 64, 144},
{ 1112, 88, 96},
{ 1464, 40, 232},
// 50 sec... |
st *put_msg = (PutRequest *)buffer;
*put_msg = (PutRequest) {
.cmd = CmdPut,
.cookie = htonl(s_last_response_cookie),
.payload_size = htonl(payload_size) + 1 /* one off! */,
};
memcpy(&put_msg->payload[0], chunk, payload_size);
prv_receive_data(s_session, buffer, sizeof(buffer));
assert_ack_count... | {
uint8_t max_batched_ops = prv_put_bytes_get_max_batched_pb_ops();
int num_ops = 500;
if (max_batched_ops < 2) { // This race condition is not possible if we aren't pre-Acking
return;
}
prv_receive_init(VALID_OBJECT_SIZE * num_ops, ObjectFirmware);
fake_comm_session_process_send_next();
fake_system... |
////////////////////////////////////////////////////////////////////////////////////////////////////
// Commit Message
void test_put_bytes__commit_message_too_short(void) {
prv_receive_init_and_put_fw_object();
const uint8_t incomplete_put_msg = CmdCommit;
prv_receive_data(s_session, (const uint8_t *) &incomp... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (sign_extend(0, 3), 0) | ;
cl_assert_equal_i(sign_extend(1, 32), 1);
cl_assert_equal_i(sign_extend(1, 3), 1);
cl_assert_equal_i(sign_extend(-1, 32), -1);
cl_assert_equal_i(sign_extend(-1, 3), -1);
cl_assert_equal_i(sign_extend(7, 32), 7);
cl_assert_equal_i(sign_extend(7, 3), -1);
}
void test_math__serial_distance32(void) {
{
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERTN(s_list_mutex == NULL) | |
nd_utc;
if (activity_sessions_prv_is_sleep_activity(sessions[i].type)) {
end_utc = sleep_earliest_end_utc;
} else {
end_utc = step_earliest_end_utc;
}
// See if we should keep this activity
time_t end_time = sessions[i].start_utc + (sessions[i].length_min * SECONDS_PER_MINUTE);
if (... | mutex_lock_recursive(state->mutex) | ;
{
if (!session->ongoing) {
state->need_activities_saved = true;
}
// Modifying a sleep session?
if (activity_sessions_prv_is_sleep_activity(session->type)) {
state->sleep_sessions_modified = true;
}
// If this is an existing activity, update it
ActivitySession *stored_sessi... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(s_settings_file.open) | ;
s_settings_file.open = false;
}
bool settings_file_exists(SettingsFile *file, const void *key, size_t key_len) {
const uint8_t key_crc8 = crc8_calculate_bytes(key, key_len, false);
return (s_settings_file.values[key_crc8] != NULL &&
memcmp(s_settings_file.keys[key_crc8], key, key_len) == 0);
}
statu... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, hand->color) | ;
graphics_line_draw_precise_stroked_aa(ctx, center, watch_hand_end, hand->thickness);
}
static void prv_draw_watch_hand_pointed(GContext *ctx, ClockHand *hand, GPoint center,
GPath *path) {
graphics_context_set_fill_color(ctx, hand->color);
gpath_rotate_to(path, hand->ang... |
n;
} result;
// Note: we ignore history[0] since it's the current day
stats_calculate_basic(op, &history[1], ACTIVITY_HISTORY_DAYS - 1, prv_stats_filter, NULL,
&result.mean);
*stats = (ActivityInsightMetricHistoryStats) {
.metric = metric,
.mean = result.mean,
.total_days =... | timeline_item_create_with_attributes(notif_time, 0,
TimelineItemTypeNotification,
LayoutIdNotification, ¬if_attr_list,
&action_group) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
MfgData data = prv_fetch_struct();
data.color = color;
prv_update_struct(&data);
} | |
ites
static const char *const TEST_FILE_C_NAME = "c";
static const size_t TEST_FILE_C_SIZE = 9001; // it's over 9000!
static char s_test_file_c[TEST_FILE_C_SIZE];
static uint32_t num_pages(void) {
return pfs_get_size() / PFS_SECTOR_SIZE;
}
void test_pfs__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs... | ("dne", OP_FLAG_READ, 0, 0) | |
ystem, NULL,
prv_transport_sent_data_cb);
s_session = fake_transport_set_connected(transport, true /* connected */);
}
// ----------------------------------------------------------------------------------------
void test_data_logging__cleanup(void) {
regular_timer_dei... | prv_log_random_data(logging_sessions[i], item_size, bytes_per_session) | |
s_is_session_type_ongoing(ActivitySessionType_Sleep));
cl_assert_equal_i(0, health_service_peek_current_activities());
}
// ---------------------------------------------------------------------------------------
// Test that we report the that multiple sessions are ongoing.
void test_activity__activity_sessions_ongo... | (ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes) | ;
cl_assert_equal_i(zone1_minutes, 0);
activity_get_metric(ActivityMetricHeartRateZone2Minutes, 1, &zone2_minutes);
cl_assert_equal_i(zone2_minutes, 0);
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes);
cl_assert_equal_i(zone3_minutes, 0);
// Add some "very elevated" heart rates.... |
432, -848},
{ -120, 592, -928},
{ -168, 464, -816},
{ -144, 448, -936},
{ -192, 488, -928},
{ -120, 592, -840},
{ -128, 416, -952},
{ -104, 512, -864},
{ -112, 424, -936},
{ -96, 504, -840},
{ -80, 448, -928},
{ -112, 440, -840},
{ -120, 448, -1048},
{ -160, 496, -82... | { -128, 448, -888},
{ -128, 504, -960},
{ -128, 608, -1008},
{ -176, 496, -928},
{ -176, 488, -944},
{ -184, 624, -912},
{ -152, 528, -896},
{ -144, 544, -976},
{ -112, 408, -904},
{ -136, 552, -952},
// 127 seconds
{ -128, 504, -896},
{ -128, 504, -848},
{ -112, ... | |
actory_reset_start_delay,
start_factory_reset, NULL);
}
//! Wipe registry + Enter Standby (for factory)
static void confirm_long_click_handler(ClickRecognizerRef recognizer, Window *window) {
// Need to lock-out inputs after starting the factory reset.
prv_lockout_back_button(window);
facto... | app_free(data) | ;
}
void settings_factory_reset_window_push(void) {
ConfirmUIData *data = (ConfirmUIData*)app_malloc_check(sizeof(ConfirmUIData));
*data = (ConfirmUIData){};
Window *window = &data->window;
window_init(window, "Settings Factory Reset");
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_... |
yer l;
menu_layer_init(&l, &GRect(10, 10, DISP_COLS, DISP_ROWS));
menu_layer_set_center_focused(&l, true);
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks) {
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
.selection_will_change = prv_skip_odd_rows,
});
menu_layer_reload_data(&... | layer->update_proc(layer, &ctx) | |
/ Minimum digits output (non-zero digits outputting zero)
snprintf(dstbuf, 256, "%.1ozero%.1o", 0, 1);
cl_assert_equal_s(dstbuf, "0zero1");
// Variable length character output
snprintf(dstbuf, 256, "There are %*o lights", 3, 8);
cl_assert_equal_s(dstbuf, "There are 10 lights");
// Variable length digits ... | (dstbuf, "There are 10 lights, FFFFFFFC") | ;
// Alternate form (adds 0X prefix)
snprintf(dstbuf, 256, "There are %#X lights, %#X", 16, -4);
cl_assert_equal_s(dstbuf, "There are 0X10 lights, 0XFFFFFFFC");
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %03X lights, %03X", 16, -4);
cl_assert_equal_s(dstbuf, "There are 010 li... |
const int max_relative_hours = 24; // show up to "in 24 hours"
clock_get_until_time_without_fulltime(buffer, config->buffer_size, layout->info->timestamp,
max_relative_hours);
}
T_STATIC void prv_get_subtitle_from_attributes(AttributeList *attributes, char *buffer,
... | {
return (existing_attributes[AttributeIdTitle] && existing_attributes[AttributeIdSubtitle]);
} |
LayoutLayer *alarm_layout_create(const LayoutLayerConfig *config) {
AlarmLayout *layout = task_zalloc_check(sizeof(AlarmLayout));
static const TimelineLayoutImpl s_timeline_layout_impl = {
.attributes = { AttributeIdTitle, AttributeIdSubtitle },
.default_colors = { { .argb = GColorBlackARGB8 },
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return NULL;
} |
// Old versions of the Android app (<3.5) will allow voice replies (which also use this code-path)
// but don't set the capability flag, so we don't want to block all requests here, just those from
// apps. This will result in apps not being able to use the voice APIs unless the phone has the
// capability fl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// System resources are missing!
#if defined(IS_BIGBOARD)
pbl_log(LOG_LEVEL_ERROR, __FILE_NAME__, __LINE__,
"System resources are missing or corrupt, time to sad watch");
launcher_panic(ERROR_BAD_RESOURCES);
#else
PBL_LOG(LOG_LEVEL_ERROR, "System resources are missing or corrupt! Going to PRF"... |
}
bool system_resource_is_valid(void) {
return resource_init_app(SYSTEM_APP, &SYSTEM_RESOURCE_VERSION);
}
#define NUM_SYSTEM_FONTS ARRAY_LENGTH(s_font_resource_keys)
// Total number of fonts = NUM_SYSTEM_FONTS + 1 for the fallback font
FontInfo s_system_fonts_info_table[NUM_SYSTEM_FONTS + 1] KERNEL_READONLY_DATA;... |
392, 480, -760},
{ 368, 568, -800},
{ 328, 432, -744},
{ 352, 544, -784},
{ 392, 488, -752},
{ 424, 520, -760},
{ 376, 288, -872},
{ 304, 248, -848},
// 283 seconds
{ 344, 216, -824},
{ 416, 208, -896},
{ 368, 224, -880},
{ 304, 144, -808},
{ 384, -24, -792},
{ 37... | { 256, 680, -840},
{ 288, 696, -656},
{ 392, 584, -592},
{ 432, 672, -576},
{ 456, 704, -480},
{ 400, 752, -552},
{ 368, 632, -616},
{ 408, 656, -576},
{ 408, 688, -560},
{ 424, 648, -592},
{ 408, 704, -616},
{ 368, 672, -568},
{ 408, 680, -536},
{ 416, 688, -528}... | |
prv_lock();
s_has_sent_byte = true;
s_did_send_byte = true;
PBL_ASSERTN(!s_input_enabled);
while (!(uart_is_tx_ready(ACCESSORY_UART))) continue;
// this section needs to be atomic since the UART IRQ also modifies these variables
portENTER_CRITICAL();
if (s_send_history.has_data) {
// The send buffer... | {
prv_lock();
s_use_dma = use_dma;
if (s_use_dma) {
prv_enable_dma();
} else {
prv_disable_dma();
}
prv_unlock();
} |
bool accessory_bus_contention_detected(void) {
return s_bus_contention_detected;
}
static uint32_t prv_get_baudrate(AccessoryBaud baud_select) {
const uint32_t BAUDS[] = { 9600, 14400, 19200, 28800, 38400, 57600, 62500, 115200, 125000, 230400,
250000, 460800, 921600 };
_Static_asse... |
ER_SIZE - 2;
const size_t name_size = strnlen(remote->name, BT_DEVICE_NAME_BUFFER_SIZE);
char *remote_name = task_zalloc_check(max_name_size + sizeof(ellipsis));
strncpy(remote_name, remote->name, name_size);
if (name_size > max_name_size) {
const size_t ellipsis_start_offset = utf8_get_size_truncate(remote... | (ctx, i18n_get("Disable Airplane Mode to connect.", data), font,
box, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL) | ;
} else {
graphics_draw_text(ctx, i18n_get("Open the Pebble app on your phone to connect.", data),
font, box, GTextOverflowModeTrailingEllipsis,
GTextAlignmentCenter, NULL);
}
ctx->draw_state = draw_state;
}
#endif
} e... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&s_ctx, &s_fb, GContextInitializationMode_App) | |
ata) {
}
static void prv_add_prf_layers(GRect pair_text_area, BTPairingUIData *data) {
}
static void prv_initialize_info_text(BTPairingUIData *data) {
strncpy(data->info_text_layer_buffer, (char *)i18n_get("Pair?", data), MAX_PAIR_STR_LEN);
}
static void prv_deinitialize_info_text(BTPairingUIData *data) {
i18n_fr... | window_get_user_data(window) | ;
PBL_ASSERTN(data->ui_state == BTPairingUIStateAwaitingUserConfirmation);
prv_send_response(false /* is_confirmed */);
// Not updating ui_state, the handler is capable of dealing with transitioning from
// BTPairingUIStateAwaitingUserConfirmation directly to BTPairingUIStateFailed
prv_handle_pairing_complete... |
------------------------------------------------------------------------------------------------
static bool prv_client_filter_callback(ListNode *found_node, void *data) {
return ((const PPoGATTClient *) found_node == (const PPoGATTClient *) data);
}
static bool prv_is_client_valid(const PPoGATTClient *client) {
... | prv_reset_ack_timeout(client) | |
steps_select_click_handler(ClickRecognizerRef recognizer, void *context) {
HealthAPITestAppData *data = (HealthAPITestAppData *)context;
data->lap_steps = data->cur_steps;
persist_write_int(AppPersistKeyLapSteps, data->lap_steps);
text_layer_set_text(data->steps_card.delta_step_layer, "0");
}
// -------------... | APP_LOG(APP_LOG_LEVEL_DEBUG, "Got sleep update event") | ;
} else if (event == HealthEventHeartRateUpdate) {
prv_hr_update_text(data);
} else if (event == HealthEventMetricAlert) {
HealthValue now_bpm = health_service_peek_current_value(HealthMetricHeartRateBPM);
APP_LOG(APP_LOG_LEVEL_INFO, "Crossed HR threshold of %d. HR: %"PRIi32" ",
(int)HEAR... |
ogle LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* ... | {
return rv;
} |
}
rv = ble_gap_adv_start(GAP_CONN_MODE_UNDIRECTED);
if (rv != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_adv_start: status = 0x%x", rv);
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Adverts (re)started");
}
return rv;
}
static ble_error_t prv_advert_disable(void) {
ble_error_t rv = ble_gap_adv_st... |
nk_state == LinkState_Stopping) {
prv_transition_to(this, LinkState_Stopped);
} else if (this->state->link_state == LinkState_AckReceived) {
prv_transition_to(this, LinkState_RequestSent);
} else if (this->state->link_state == LinkState_Opened) {
PBL_LOG(LOG_LEVEL_WARNING, "Terminate-Ack received on an ... | ntoh16(packet->length) | < sizeof(*packet) ||
length < ntoh16(packet->length)) {
// Invalid packet; silently discard
goto done;
}
switch (packet->code) {
case ControlCode_ConfigureRequest:
prv_on_configure_request(this, packet);
break;
case ControlCode_ConfigureAck:
prv_on_configure_ack(this, packe... |
nse at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific langu... | (glyph_target.size.w,
MAX(0, glyph_target.size.w - clipped_glyph_target.size.w - left_clip)) | |
dot_ring_outer_radius_from,
dot_ring_outer_radius_to);
const int16_t dot_ring_inner_radius = interpolated_dot_ring_outer_radius - dot_radius;
// Draw the dot ring
graphics_context_set_fill_color(ctx, TI... | (prv_modal_transition_get_rect,
prv_modal_transition_get_round) | |
initial transparency doesn't really matter since we're about to overwrite it
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparent);
cl_assert(mask);
const GSize mask_size = ctx->dest_bitmap.bounds.size;
for (int16_t x = 0; x < mask_size.w; x++) {
const uint8_t ... | graphics_context_mask_use(ctx, mask) | );
for (int16_t x = 0; x < num_src_colors; x++) {
GColor src_color = (GColor) { .argb = (uint8_t)x };
for (int dest_color_index = 0; dest_color_index < num_dest_colors; dest_color_index++) {
for (int mask_value_index = 0; mask_value_index < num_mask_values; mask_value_index++) {
int16_t y1 = (i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return plugin_service_subscribe(NULL, (PluginServiceHandler)handler);
} |
// ---------------------------------------------------------------------------------------------------------------
// Unsubscribe from a specific plug-in service by uuid.
bool app_worker_message_unsubscribe(void) {
return plugin_service_unsubscribe(NULL);
}
// ----------------------------------------------------... |
test_timeline_peek__cleanup(void) {
}
// Helpers
//////////////////////
static void prv_render_layer(Layer *layer, const GRect *box, bool use_screen) {
gbitmap_destroy(s_dest_bitmap);
const GRect *drawing_box = use_screen ? &DISP_FRAME : box;
const GSize bitmap_size = drawing_box->size;
s_dest_bitmap = gbitm... | (s_dest_bitmap, TEST_PBI_FILE) | );
}
void test_timeline_peek__peek_concurrent_2(void) {
prv_render_timeline_peek(&(TimelinePeekItemConfig) {
.title = "Stock for party 🍺",
.subtitle = "Pebble Pad on Park",
.icon = TIMELINE_RESOURCE_NOTIFICATION_REMINDER,
.num_concurrent = 2,
});
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_F... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_health_hr_detail_card__render_zones2(void) {
HealthData health_data = {
.hr_zone1_minutes = 30,
.hr_zone2_minutes = 35,
.hr_zone3_minutes = 40,
};
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
#if PBL_ROUND
menu_layer_set_selected_index(&card... |
rly recent unread core image already present, don't replace it. Once it is read through
// the get_bytes_protocol_msg_callback(), the unread flag gets cleared out.
uint32_t flash_base;
flash_base = prv_flash_start_address(false /*new*/);
if (!s_core_dump_is_forced && flash_base != CORE_DUMP_FLASH_INVALID_ADDR) ... | (s_saved_registers.core_reg[portCANONICAL_REG_INDEX_LR]) | ) {
// Another exception invoked the core dump handler
xPORT_TASK_INFO task_info;
task_info.pcName = "ISR";
task_info.taskHandle = (void *)1;
for (int i = 0; i < portCANONICAL_REG_COUNT; i++) {
// registers [r0-r12, sp, lr, pc, sr]
task_info.registers[i] = s_saved_registers.core_reg[i];
... |
tributeTypeResourceId:
case AttributeTypeUint32:
size += sizeof(attr_list->attributes[i].uint32);
break;
case AttributeTypeUint8:
size += sizeof(attr_list->attributes[i].uint8);
break;
case AttributeTypeStringList:
size += attr_list->attributes[i... | {
case AttributeTypeString: {
dest->cstring = (char *)*buffer;
strncpy(dest->cstring, src->cstring, attribute_length);
break;
}
case AttributeTypeStringList: {
dest->string_list = (StringList *)*buffer;
dest->string_list->serialized_byte_length = src->string_list->serialized_by... |
*buffer += attribute_length;
return true;
}
bool attribute_copy(Attribute *dest, const Attribute *src, uint8_t **buffer,
uint8_t *const buffer_end) {
// shallow copy the attribute
memcpy(dest, src, sizeof(Attribute));
// deep copy strings into the buffer
return prv_deep_copy_attribut... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | send_text_service_init() | ;
protobuf_log_init();
#if CAPABILITY_HAS_WEATHER
weather_service_init();
#endif
#if CAPABILITY_HAS_MICROPHONE
voice_init();
#endif
#if CAPABILITY_HAS_APP_GLANCES
app_glance_service_init();
#endif
}
static struct ServiceRunLevelSetting s_runlevel_settings[] = {
{
.set_enable_fn = wakeup_enable,
.e... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | while (*result_string != '\0') {
if (*result_string != ' ' &&
*result_string != '\n') {
break;
}
result_string++;
} |
return result_string;
}
void string_strip_trailing_whitespace(const char *string, char *string_out) {
int string_len = strlen(string);
bool trim = true;
for (int i = string_len; i >= 0; i--) {
if (trim &&
(string[i] == ' ' || string[i] == '\n' || string[i] == '\0')) {
string_out[i] = '\0';
... |
.id, &s_extra_case_items[0].header.id));
// check next
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[1].header.id));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[2].header.id));
cl_assert(!iter_next(&iter... | fake_pbl_malloc_num_net_allocs() | ,
init_net_allocs + ARRAY_LENGTH(s_items) + 2);
// deinit should free all the memory
timeline_iter_deinit(&iterator1, &state1, &head);
timeline_iter_deinit(&iterator2, &state2, &head);
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), init_net_allocs);
}
void test_timeline__delete_on_ite... |
c uint16_t get_num_sections_callback(struct MenuLayer *menu_layer, AppData *data) {
(void)data;
(void)menu_layer;
return 4;
}
static uint16_t get_num_rows_callback(struct MenuLayer *menu_layer, uint16_t section_index, AppData *data) {
(void)data;
(void)menu_layer;
switch (section_index) {
default:
... | menu_layer_set_click_config_onto_window(menu_layer, window) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.