prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
_val, map_mask);
prv_read_modify_write(BMI160_REG_INT_EN_1, int_en_val, int_en_mask);
BMI160_DBG("INT_MAP[1] = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_INT_MAP_1));
BMI160_DBG("INT_EN[1] = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_INT_EN_1));
int_enabled = enable_int;
s_fifo_in_use = use_fifo;
}
void accel_set_num... | (BMI160_REG_INT_EN_0, 0x0, dis_mask) | ;
prv_disable_operating_mode(AccelOperatingModeShakeDetection);
}
static void prv_enable_double_tap_detection(void) {
uint8_t tap_0_cfg =
(0x1 << BMI160_INT_TAP_QUIET_SHIFT) | // 0 = 20 ms, 1 = 30ms
(0x1 << BMI160_INT_TAP_SHOCK_SHIFT) | // 0 = 50 ms, 1 = 75ms
(0x4 << BMI160_INT_TAP_DUR_SHIFT); ... |
atic void clar_category_print_enabled(const char *prefix);
/* Event callback overrides */
${clar_event_overrides}
/* Autogenerated test data by clar */
${clar_callbacks}
${clar_categories}
static const struct clar_suite _clar_suites[] = {
${clar_suites}
};
static size_t _clar_suite_count = ${clar_suite_count};
s... | clar_run_suite(&_clar_suites[num]) | ;
}
else if (!has_colon || argument[-1] == ':') {
for (j = 0; j < (int)_clar_suite_count; ++j)
if (strncmp(argument, _clar_suites[j].name, len) == 0)
clar_run_suite(&_clar_suites[j]);
}
else {
for (j = 0; j < (int)_clar_suite_count; ++j)
if (strcmp... |
GBitmap *bitmap = gbitmap_create_blank(GSize(180, 180), GBitmapFormat8BitCircular);
cl_assert(bitmap);
// Since frame 1 has 0 delay, it renders then immediately we render frame 2
gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 0);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)));
// Fr... | (bitmap_sequence, bitmap, NULL) | ;
cl_assert_equal_b(status, true);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3)));
#endif
}
void test_gbitmap_sequence__1bit_to_1bit_notification(void) {
uint32_t resource_id = sys_resource_load_file_as_resource(TEST_IMAGES_PATH, GET_APNG_NAME);
cl_assert(resource_id != UINT32_MAX);
GBitmapSequence *bitma... |
int16_t y, int16_t min_x, int16_t max_x,
GColor color) {
PBL_ASSERTN(ctx);
if (gcolor_is_invisible(color)) {
return;
}
GDrawMask *mask = ctx->draw_state.draw_mask;
PBL_ASSERTN(mask);
const GBitmap *framebuffer = &ctx->dest_bitmap;
const GBitmapDataRowInfo current_data_ro... | {
// Skip over pixels outside the bitmap data row's range
const GBitmapDataRowInfo data_row_info = gbitmap_get_data_row_info(framebuffer, (uint16_t)i);
if (!WITHIN(x, data_row_info.min_x, data_row_info.max_x)) {
continue;
}
prv_update_mask(ctx, i, x, x, color);
} | |
/*
* 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... | (GRect(0, 0, 10, 20)) | |
GPoint(p.x + 5, p.y + 2) | );
graphics_draw_pixel(ctx, GPoint(p.x + 6, p.y + 2));
graphics_draw_pixel(ctx, GPoint(p.x + 7, p.y + 2));
graphics_draw_pixel(ctx, GPoint(p.x + 0, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 1, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 2, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 3, p.y... | |
gger a disconnect to try and put us back into a sane state
PBL_LOG(LOG_LEVEL_ERROR,
"Not adding connection for device. It is already connected .. disconnecting");
bt_driver_gap_le_disconnect(&event->peer_address);
break;
}
const SMIdentityResolvingKey *remote_irk = e... | (local_is_master) | ;
bluetooth_analytics_handle_connection_disconnection_event(
AnalyticsEvent_BtLeDisconnect, event->reason, &connection->remote_version_info);
if (!local_is_master) {
s_is_connected_as_slave = false;
gap_le_advert_handle_disconnect_as_slave();
prv_put_legacy_connection_ev... |
/*
* 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... | {
char buffer[100] = {0};
snprintf(buffer, sizeof(buffer), "Argument at index %"PRIu32" is not a %s",
arg_idx, expected_type_name);
return rocky_error_argument_invalid(buffer);
} |
static jerry_value_t prv_error_two_parts(jerry_error_t error_type,
const char *left, const char *right) {
char buffer[100] = {0};
snprintf(buffer, sizeof(buffer), "%s%s", left, right);
return jerry_create_error(error_type, (jerry_char_t *)buffer);
}
jerry_value_t rocky_... |
nt year = current_tm.tm_year + (i - DST_YEARS_OFFSET);
dst_start_stamps[i] =
prv_clock_dstrule_to_timestamp(false, tz_info, &dst_rule_begin, year);
dst_end_stamps[i] =
prv_clock_dstrule_to_timestamp(true, tz_info, &dst_rule_end, year);
}
// Figure out which timestamps are relevant to us
... | ntohl(tz_data->utc_time) | ;
tz_data->utc_offset_min = ntohs(tz_data->utc_offset_min);
const char *region_name = tz_data->region_name;
if (tz_data->region_name_len == 0) {
region_name = "[N/A]";
}
PBL_LOG(LOG_LEVEL_DEBUG, "set_timezone utc_time: %u offset: %d region_name: %s",
(int) tz_data->utc_time, (int) tz_data->utc_... |
ee,
0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
},
[SMRootKeyTypeIdentity] = {
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
},
};
bool bt_persistent_storage_get_root_key(SMRootKeyType key_type, SM128BitKey *key_out) {
cl_assert(key_type < SMRoo... | (&s_stored_keys[SMRootKeyTypeIdentity], &rand_id, sizeof(SM128BitKey)) | |
ck_recursive(s_recent_apps.mutex);
{
RecentApp *app = circular_cache_get(&s_recent_apps.cache, &install_id);
if (app) {
const int32_t time_since_activity = time_get_uptime_seconds() - app->last_activity;
if (app->can_expire && (time_since_activity < VISIBILITY_ON_ACTIVITY_TIMEOUT_SECONDS)) {
... | {
struct AppInstallCallbackNode *iter = (struct AppInstallCallbackNode *) s_head_callback_node_list;
while (iter) {
if (iter->registered_by == PebbleTask_App) {
list_remove((ListNode *)&iter->node, &s_head_callback_node_list, NULL);
}
iter = (struct AppInstallCallbackNode *) list_get_next(&iter->n... |
static void app_install_invoke_callbacks(InstallEventType event_type, AppInstallId install_id) {
struct AppInstallCallbackNode *callback_node = (struct AppInstallCallbackNode *) s_head_callback_node_list;
while (callback_node) {
if (callback_node->callbacks[event_type]) {
callback_node->callbacks[event_... |
_form_fit;
} MenuLayerSystemCellTestRowData;
#define DEFAULT_ICON_ALIGN PBL_IF_RECT_ELSE(MenuCellLayerIconAlign_Left, MenuCellLayerIconAlign_Top)
static const MenuLayerSystemCellTestRowData s_menu_system_cell_test_row_data[] = {
{"Star Wars", NULL, NULL, NULL, DEFAULT_ICON_ALIGN},
{"The Lord of the Rings", "The F... | (&s_ctx, background_color) | |
/*
* 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 i;
} |
}
return 0;
}
static void prv_timeout_menu_select(OptionMenu *option_menu, int selection, void *context) {
backlight_set_timeout_ms(s_timeout_values[selection]);
app_window_stack_remove(&option_menu->window, true /* animated */);
}
static void prv_timeout_menu_push(SettingsDisplayData *data) {
int index = ... |
/*
* 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... | (LOG_LEVEL_DEBUG, "New BT Conn change event, We are now disconnected") | |
t(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
... | ARRAY_LENGTH(s_zones) | ,
.zones = s_zones,
};
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&config);
#if PBL_ROUND
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 3), MenuRowAlignCenter, false);
#endif
window_render(&card->window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, ... |
t_storage_get_bt_classic_pairing_by_id(BTBondingID bonding,
BTDeviceAddress *address_out,
SM128BitKey *link_key_out,
char *name_out,
... | bt_driver_classic_update_connectability() | ;
}
bt_persistent_storage_set_cached_system_capabilities(NULL);
}
}
bool bt_persistent_storage_get_active_gateway(BTBondingID *bonding_out,
BtPersistBondingType *type_out) {
BTBondingID active_gateway;
int read_size = prv_file_get(&ACTIVE_GATEWAY_KEY, sizeof(... |
nect */,
false /* is_pairing_required */,
GAPLEClientApp);
cl_assert_equal_i(e, BTErrnoOK);
// Device isn't connected. Verify no event was caused as a result of the
// registration.
prv_assert_no_event();
// Connect & verify the client ... | (&device, true /* connected */, (1 << PebbleTask_KernelMain),
HCI_ERROR_CODE_SUCCESS) | ;
// Register connection intent for app:
e = gap_le_connect_connect_by_bonding(bonding_id,
true /* auto_reconnect */,
false /* is_pairing_required */,
GAPLEClientApp);
cl_assert_equal_i(e, BTEr... |
/////////////////////
// Data structures
typedef struct {
Window window;
TextLayer percent_done_text_layer;
char percent_done_text_buffer[5]; //<! Text for progress percentage label, format %02d%%
SimpleDialog finished_dialog;
ProgressLayer progress_layer;
AppTimer *timer;
unsigned int percent_complete;
... | {
ProgressUIData *data = window_get_user_data(window);
if (data) {
i18n_free_all(data);
app_timer_cancel(data->timer);
app_free(data);
}
} | |
*payload_size_out = 0;
return &client->out.ack_packet_to_send;
}
if (!new_timer_scheduled(client->rx_ack_timer, NULL)) {
new_timer_start(client->rx_ack_timer, PPOGATT_MAX_DATA_ACK_LATENCY_MS,
rx_ack_timer_cb, client, 0);
}
// We will defer sending the Ack for no... | if (e == BTErrnoNotEnoughResources) {
// Need to wait for "Buffer Empty" event (see ppogatt_handle_buffer_empty)
break;
} else if (e != BTErrnoOK) {
// Most likely the LE connection got busted, don't think retrying will help.
PBL_LOG(LOG_LEVEL_ERROR, "Write failed %i", e);
break;
}... |
const uint8_t max_loop_count = 10;
if (loop_count > max_loop_count) {
// If more bytes left to send (but loop_count became >= 10),
// schedule a callback to process them later to avoid blocking the task for too long:
prv_send_next_packets_async(client);
break;
}
}
kernel_free(... |
/*
* 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_private_raw_mask_set_value(ctx, mask, p, new_pixel_value) | ;
}
}
static void prv_blend_color_and_update_mask(GContext *ctx, int16_t y, int16_t min_x, int16_t max_x,
GColor color, uint8_t factor) {
color.a = (GColor8Component)(factor * 3 / (FIXED_S16_3_ONE.raw_value - 1));
prv_update_mask(ctx, y, min_x, max_x, color);
}
T_STAT... |
(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &custom_schedule1 }) | ;
prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_CUSTOM, custom_schedule1);
alarm_set_kind(id, ALARM_KIND_EVERYDAY);
prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
}
void test_alarm__alarm_set_recurring_weekends(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) {... | |
PATH_STRING_LENGTH);
if (index) {
snprintf(filename, PATH_STRING_LENGTH, "%s_%u.%s", func_name, index, extension);
} else {
snprintf(filename, PATH_STRING_LENGTH, "%s.%s", func_name, extension);
}
return filename;
}
// Tests
////////////////////////////////////
// Reference PNGs reside in "tests/test_... | (bitmap, GET_PBI_NAME(88)) | );
#endif
}
// Tests APNG file with 8-bit color, 5 frames and loop = 1
// Tests gbitmap_sequence_update_bitmap_by_elapsed with 0 delay frames for 1, 4 and 5
// and 2 & 3 have delay 1000ms
// Result:
// - gbitmaps matches platform decoded APNG
void test_gbitmap_sequence__color_8bit_coin(void) {
#if PLATFORM_SPALDING... |
fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_outside_ny);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &dra... | prv_setup_resources() | ;
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18_BOLD;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
test_graphics_context_init(&ctx, fb);
// Test when clipping/drawing and text bounds are all at (0, 0)
setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1);
gr... |
length that "
"settings_file supports.");
static SettingsFile * prv_lock_and_get_store(void) {
return persist_service_lock_and_get_store(
&sys_process_manager_get_current_process_md()->uuid);
}
static void prv_unlock(SettingsFile **store) {
persist_service_unlock_store(*store);
}
#define LO... | {
return persist_write_data(key, buffer, buffer_size);
} |
DEFINE_SYSCALL(int, persist_write_string, const uint32_t key, const char *cstring) {
if (PRIVILEGE_WAS_ELEVATED) {
if (!memory_layout_is_cstring_in_region(
memory_layout_get_app_region(), cstring, -1)) {
syscall_failed();
}
}
const size_t cstring_length = strlen(cstring) + 1;
return pe... |
cs_draw_horizontal_line_dotted(&ctx, GPoint(0, 23), 145);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_odd_rows_no_clip")));
// Test to make sure drawing on all rows creates checkerboard pattern
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO... | GPoint(0, 19) | , 22);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 21), MAX_NUM_COLS - 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 23), MAX_NUM_COLS + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_even_offset_odd_rows_no_clip")));
// Test to make sure d... |
/*
* 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... | {
switch(cell_index->row) {
case 0: return menu_cell_small_cell_height();
case 1: return menu_cell_basic_cell_height();
case 2: return menu_cell_small_cell_height();
case 3: return menu_cell_basic_cell_height();
default:
return menu_cell_basic_cell_height();
}
} |
static void prv_window_load(Window *window) {
PBL_LOG(LOG_LEVEL_INFO, "WINDOW LOADING");
AppData *data = window_get_user_data(window);
gbitmap_init_with_resource(&data->checked_icon, RESOURCE_ID_CHECKBOX_ICON_CHECKED);
MenuLayer *menu_layer = &data->menu_layer;
menu_layer_init(menu_layer, &window->layer.bo... |
/*
* 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... | (test2, 6, 2, 1, 1) | == 0);
cl_assert(raw_image_get_value_for_bitdepth(test2, 5, 0, 2, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 5, 0, 2, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 1, 1, 2, 8) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 0, 1, 3, 8) == 3);
cl_assert(raw_image_get_va... |
/*
* 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_add(metric, increment, client);
} |
DEFINE_SYSCALL(void, sys_analytics_inc, AnalyticsMetric metric, AnalyticsClient client) {
analytics_inc(metric, client);
}
DEFINE_SYSCALL(void, sys_analytics_stopwatch_start, AnalyticsMetric metric,
AnalyticsClient client) {
analytics_stopwatch_start(metric, cl... |
new_state == ANCSClientStateIdle);
case ANCSClientStatePerformingAction:
return (new_state == ANCSClientStateIdle);
case ANCSClientStateRequestedApp:
return (new_state == ANCSClientStateIdle);
case ANCSClientStateAliveCheck:
return (new_state == ANCSClientStateIdle);
cas... | if (s_ancs_client == NULL) {
return;
} | |
data rows above (and not also the source data rows) because we
// assume that both source and destination are framebuffers using the native bitmap format
PBL_ASSERTN(app_framebuffer.info.format == framebuffer->info.format);
PBL_ASSERTN(app_framebuffer.data_row_infos == framebuffer->data_row_infos);
const GBitm... | while (y1.integer <= y2.integer) {
// Only draw the pixel if its within the bitmap data row range
if (WITHIN(x, destination_data_row_info.min_x, destination_data_row_info.max_x)) {
#if CAPABILITY_HAS_MASKING
const GDrawMask *mask = ctx->draw_state.draw_mask;
graphics_private_raw_mask_apply(output, m... |
// last pixel with blending (don't render first *and* last pixel if line length is 1)
if (y2.fraction != 0) {
// Only draw the pixel if its within the bitmap data row range
if (WITHIN(x, destination_data_row_info.min_x, destination_data_row_info.max_x)) {
graphics_private_raw_blend_color_factor(ctx,... |
848},
{ 312, 312, -896},
{ 328, 336, -856},
{ 240, 368, -896},
{ 344, 528, -1088},
{ 376, 216, -896},
{ 496, 328, -728},
{ 496, 32, -608},
{ 480, 328, -696},
{ 168, 424, -704},
{ -80, 400, -1088},
// 29 seconds
{ 376, 600, -752},
{ 336, 144, -912},
{ 360, 400, -85... | { 1040, -224, -304},
{ 1048, -328, -272},
{ 1016, -224, -104},
{ 1008, -384, -136},
{ 1000, -96, -136},
{ 1000, -328, -152},
{ 1016, -104, -168},
{ 1016, -208, -128},
{ 1024, -232, -232},
{ 1032, -240, -192},
{ 1376, -184, -264},
{ 792, -48, -104},
{ 1064, -360, -80},... | |
ate_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_stroke_width(ctx, 10);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, -30), GPoint(45, 30));
}
void across_screen_layer_update_callback(Layer* me, GContext* ctx) {... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_same_point_offset_layer.${BIT_DEPTH_NAME}.pbi")) | ;
}
#define COLOR_START_POINT GPoint(5, 35)
#define COLOR_END_POINT GPoint(45, 40)
void test_graphics_draw_stroke_${BIT_DEPTH_NAME}__color(void) {
// TODO: Fix blending and reenable this - PBL-16509
/*
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_... |
es = 2, \
.trigger_steps_per_minute = 50 \
} \
} \
}
#define ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_SUMMARY_DEFAULT { \
.version = ACTIVITY_INSIGHTS_SETTINGS_CURRENT_STRUCT_VERSION, \
.enabled = true, \
.summary = { \
.above_avg_threshold = 10, \
.below_avg_threshold = -10, \
.fail_threshold... | (insight_name) | ,
settings_out, sizeof(*settings_out)) != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_DEBUG, "Didn't find insight with key %s", insight_name);
goto close;
}
if (settings_out->version != ACTIVITY_INSIGHTS_SETTINGS_CURRENT_STRUCT_VERSION) {
// versions don't match, bail out!
... |
/*
* 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... | (dstbuf, 256, "There are %2d lights, %2d", 4, -4) | ;
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// Left-align, Space padded minimum character output
snprintf(dstbuf, 256, "There are %-2d lights, %-2d", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// Space for positive signed
snprintf(dstbuf, 256, "There are % d lights, the abso... |
mfg_info_get_watch_color() | ) {
// stepped white bezel
case WATCH_INFO_COLOR_TIME_ROUND_ROSE_GOLD_14:
case WATCH_INFO_COLOR_TIME_ROUND_SILVER_14:
return 3200;
case WATCH_INFO_COLOR_TIME_ROUND_BLACK_14:
case WATCH_INFO_COLOR_TIME_ROUND_SILVER_20:
return 3330;
case WATCH_INFO_COLOR_TIME_ROUND_BLACK_20:
retu... | |
/*
* 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... | (slice.layout.subtitle_template_string,
template_string_too_long_size) | == template_string_too_long_size) {
result |= APP_GLANCE_RESULT_TEMPLATE_STRING_TOO_LONG;
}
// Check if the provided subtitle string is a valid template string, if it's present.
const time_t current_time = sys_get_time();
if (slice.layout.subtitle_template_string) {
const TemplateStringVars template_s... |
/*
* 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... | {
ANCSAppData app_data = {
.bundle_id = "com.getpebble.PebbleApp",
.display_name = "Pebble",
.flags = ANCSAppIsBlocked,
};
app_data.is_meta_changed = true;
ancs_app_storage_save(&app_data);
ANCSAppData app_data_out = { 0 };
ancs_app_storage_load(app_data.bundle_id, &app_data_out);
cl_assert_... |
void test_ancs_app_storage__overwrite(void) {
ANCSAppData app_data = {
.bundle_id = "com.getpebble.PebbleApp",
.display_name = "Pebble",
.flags = ANCSAppIsBlocked,
};
app_data.is_meta_changed = true;
ancs_app_storage_save(&app_data);
app_data.display_name = "Pebble 2";
app_data.is_meta_change... |
xpire_s,
features);
fake_system_task_callbacks_invoke_pending();
HRMSubscriberState *subscriber = prv_get_subscriber_state_from_ref(session_ref);
cl_assert(subscriber);
cl_assert(subscriber->session_ref == session_ref);
cl_assert(subscriber->expire_... | (sys_hrm_manager_get_app_subscription(app_id) == HRM_INVALID_SESSION_REF) | ;
}
// Test that system subscriptions expire correctly
void test_hrm_manager__kernel_expiration(void) {
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
const uint16_t expire_s = SECONDS_PER_MINUTE;
HRMSessionRef session_ref = hrm_manager_subscribe_with_callback(INSTALL_ID_INVALID, 1,
... |
/*
* 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... | (JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH, 0, true) | ;
jmem_pools_collect_empty();
}
static void prv_memorypressure_app_log(const char *level, const jmem_heap_stats_t *stats) {
APP_LOG(LOG_LEVEL_WARNING, "Memory pressure level: %s", level);
APP_LOG(LOG_LEVEL_WARNING,
"heap size: %zu, alloc'd: %zu, waste: %zu, largest free block: %zu,",
stats->s... |
= 0x86,
PmicRegisters_CHARGE_STATUS_2 = 0x87,
PmicRegisters_LOCK_REG = 0x8e,
PmicRegisters_CHIP_ID = 0x90,
PmicRegisters_CHIP_REV = 0x91,
PmicRegisters_FUSE_5 = 0xa5,
PmicRegisters_FUSE_6 = 0xa6,
PmicRegisters_FUSE_7 = 0xa7,
PmicRegisters_FUSE_8 = 0xa8,
PmicRegisters_FUSE_9 = 0xa9,
PmicRegisters... | (PmicRegisters_PWM_CNTL_L, pwm_high_low_time_us) | ;
bool success = false;
uint8_t ref_cntl;
if (prv_read_register(PmicRegisters_REFERENCE_CNTL, &ref_cntl)) {
ref_cntl |= 0x3; // Divisor of 16
prv_write_register(PmicRegisters_REFERENCE_CNTL, ref_cntl);
// Enable PWM Output on GPIO2 (Fig. 64)
// Bits 6-4: Mode, 0x1 = Output
// Bits 0-3: iosf,... |
/*
* 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(cell_index->row < ARRAY_LENGTH(s_tests)) | ;
menu_cell_title_draw(ctx, cell_layer, s_tests[cell_index->row]->name);
}
static void prv_click_handler(struct MenuLayer *menu_layer, MenuIndex *cell_index,
void *callback_context) {
PBL_ASSERTN(cell_index->row < ARRAY_LENGTH(s_tests));
prv_start_test(s_tests[cell_index->row], (App... |
{
prv_discover_ams(1 /* num_instances */);
// Simulate not having enough resources to process the request:
fake_gatt_client_op_set_write_return_value(BTErrnoNotEnoughResources);
// Simulate successful subscription:
BLECharacteristic entity_update = s_characteristics[0][AMSCharacteristicEntityUpdate];
ams_... |
static const MusicServerImplementation s_dummy_server_implementation = {};
static void prv_set_dummy_server_connected(bool connected) {
music_set_connected_server(&s_dummy_server_implementation,
connected /* connected */);
}
void test_ams__dont_register_if_another_music_server_is_alrea... | |
service_remove_info->num_characteristics);
}
}
#if !RELEASE
char uuid_string[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(&service_remove_info->uuid, uuid_string);
PBL_LOG(LOG_LEVEL_INFO, "%s removed: %d", uuid_string, (int)removed);
#endif
int num_hdls = service_remove_info->num_descript... | (&event_info->services_added_data, &event_info->device) | ;
break;
default:
WTF;
}
}
static const KernelLEClient * prv_client_for_characteristic(BLECharacteristic characteristic) {
for (int c = 0; c < KernelLEClientNum; ++c) {
const KernelLEClient * const client = &s_clients[c];
if (client->can_handle_characteristic && client->can_handle_character... |
d = INSTALL_ID_INVALID;
#if !RECOVERY_FW
destination_app_id = prv_get_app_exit_reason_destination_install_id_override();
#endif
if (destination_app_id == INSTALL_ID_INVALID) {
// If we get here, the app exit reason didn't override the destination app ID
if (!s_next_app.md) {
destination_app_id = sys... | prompt_send_response_fmt(buffer, sizeof(buffer), "app name: %s",
process_metadata_get_name(app_metadata)) | ;
prompt_send_response_fmt(buffer, sizeof(buffer), "is watchface: %d",
(app_metadata->process_type == ProcessTypeWatchface));
prompt_send_response_fmt(buffer, sizeof(buffer), "visibility: %u", app_metadata->visibility);
prompt_send_response_fmt(buffer, sizeof(buffer), "bank: %d"... |
/*
* 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... | hw_aes_hash_init(&aes_setup) | ;
hw_aes_hash_start();
hw_aes_hash_disable(true /* wait_until_inactive */);
return true;
}
|
le this "test" to debug per-frame transitions
void _test_gdraw_command_transforms__to_square_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
int32_t dt = ANIMATION_NORMALIZED_MAX / 16;
int32_t t = 0;
while (t <= ANIMATION_NORMALIZED_MAX) ... | free(index_lookup) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "test_gdraw_command_transforms__segmented_scale.8bit.pbi"));
}
// re-enable this "test" to debug per-frame transitions
void _test_gdraw_command_transforms__scale_segmented_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_ant... |
if (DialogTaskList[DialogTask_Ble] == 0) {
// We don't bring up the ble task until we have received an init cmd
hc_protocol_process_receive_buffer();
} else {
OS_TASK_NOTIFY(DialogTaskList[DialogTask_Ble], 0x0, eSetBits);
} |
ad_spi_device_release(dev);
ad_spi_close(dev);
host_transport_configure_spi_scs_pin(SCSPinFunction_Wakeup_GPIO);
}
}
HostTransportEnqueueStatus host_transport_tx_enqueue(const uint8_t *buffer, size_t length) {
PBL_ASSERTN(length < HOST_TRANSPORT_CTLR_TX_BUFFER_SIZE &&
length < HOST_TRA... | |
ike the following.
//!
//! Header
//! + Metrics
//! v v Logs
//! +--+--------+-------------------------------------+
//! | | | |
//! | | | |
//! +--+--------+-------------------------------------+
//!
... | ((uint8_t*) &file_header, get_file_address(i), sizeof(file_header)) | |
*service = (GATTService) {
.size_bytes = blob_size,
.att_handle = base_handle,
.num_characteristics = type_counts[GATTC_ITEM_TYPE_CHARACTERISTIC],
.num_descriptors = type_counts[GATTC_ITEM_TYPE_DESCRIPTOR],
.num_att_handles_included_services = type_counts[GATTC_ITEM_TYPE_INCLUDE],
};
prv_at... | if (characteristic_info->type != GATTC_ITEM_TYPE_CHARACTERISTIC) {
continue;
} | |
/*
* 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... | stub_new_timer_get_next() | );
bool callback_fired = s_launcher_callback_added;
s_launcher_callback_added = false;
return callback_fired;
}
// defined in display_calibration_prompt.c
bool prv_is_known_misaligned_serial_number(const char *serial);
// Tests
//////////////////////
void test_display_calibration_prompt__initialize(void) {
s... |
_is_in_click_config_provider(window, "subscribe");
ClickManager *mgr = prv_get_current_click_manager();
ClickConfig *cfg = &mgr->recognizers[button_id].config;
cfg->click.repeat_interval_ms = 0;
cfg->click.handler = handler;
if (button_id == BUTTON_ID_BACK) {
window_set_overrides_back_button(window, tru... | {
if (window->is_loaded) {
return;
}
window_call_handler(window, WindowHandlerOffsetLoad);
window->is_loaded = true;
} |
void window_unload(Window *window) {
if (!window->is_loaded) {
return;
}
window->is_loaded = false;
window_call_handler(window, WindowHandlerOffsetUnload);
// Don't touch window after calling it's unload handler. We allow windows to free themselves on unload.
}
// TODO PBL-1769: deal with window unloa... |
, to.origin.y, normalized, interpolate));
}
typedef struct {
GRect from;
GRect to;
GSize size;
GPoint offset;
} ScaleToGValues;
typedef struct {
const struct {
ScaleToGValues integer;
ScaleToGValues precise;
Fixed_S32_16 duration_fraction;
GPointIndexLookup *lookup;
AnimationProgress no... | (native, op_value) | ;
case GStrokeWidthOpAdd:
return Fixed_S16_3_add(native, op_value);
default:
WTF;
}
}
static bool prv_gdraw_command_scale_stroke_width(GDrawCommand *command, uint32_t index,
void *context) {
ScaleStrokeWidthCBContext *scale = context;
const Fix... |
/*
* 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 (msg->command_id != HcMessageID_Hci_Cmd) {
PBL_LOG(LOG_LEVEL_ERROR, "Unhandled HCI command id: 0x%x", (int)msg->command_id);
}
PBL_LOG(LOG_LEVEL_DEBUG, "HCI CMD Received:");
PBL_HEXDUMP(LOG_LEVEL_DEBUG, (uint8_t *)msg, msg->message_length);
hci_cmd_msg_t *hci_cmd = (hci_cmd_msg_t *)&msg->payload[0]... | |
ame);
}
}
prv_unlock();
}
//!
//! BLE Root Key APIs
//!
bool shared_prf_storage_get_root_key(SMRootKeyType key_type, SM128BitKey *key_out) {
bool rv;
prv_lock();
{
SprfRootKeys data;
rv = SPRF_FETCH_FIELD(data, root_keys);
if (!rv) {
goto unlock;
}
SM128BitKey nil_key = {};
... | (pairing_info->is_local_encryption_info_valid,
SprfValidFields_LocalEncryptionInfoValid) | |
has_pinned_ble_pairings(void) {
return cl_mock_type(bool);
}
#define TEST_PINNED_ADDR_1 ((BTDeviceAddress){ .octets = { 0x11, 0x22, 0x33, 0x33, 0x44, 0x55 } })
#define TEST_PINNED_ADDR_2 ((BTDeviceAddress){ .octets = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff } })
bool bt_driver_id_generate_private_resolvable_address(BTD... | bt_local_addr_handle_bonding_change(TEST_BONDING_ID, BtPersistBondingOpDidAdd) | ;
cl_assert_equal_b(false, s_last_driver_allow_cycling);
prv_assert_driver_addr_is_addr1();
// Unpin (done implicitly when bonding is removed):
cl_will_return(bt_persistent_storage_has_pinned_ble_pairings, false);
cl_will_return(bt_driver_set_local_address, 0);
bt_local_addr_handle_bonding_change(TEST_BOND... |
/*
* 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... | rtc_get_time_ms(&s, &ms) | ;
mutex_lock(s_vibe_history_mutex);
VibeHistory *vibe = (VibeHistory*)list_get_tail((ListNode*)s_vibe_history);
if (vibe->time_end == END_NOT_SET) {
vibe->time_end = ((uint64_t)s) * 1000 + ms;
}
mutex_unlock(s_vibe_history_mutex);
}
typedef struct {
ListNode list_node;
uint32_t duration_ms;
int32_... |
void pebble_task_unregister(PebbleTask task) {
}
const char* pebble_task_get_name(PebbleTask task) {
return "?";
}
void pebble_task_create(PebbleTask pebble_task, TaskParameters_t *task_params,
TaskHandle_t *handle) {
}
void * process_loader_load(const PebbleProcessMd *app_md, PebbleTask ... | cl_assert(app_manager_get_current_app_md() == (PebbleProcessMd*) &s_launch_app) | ;
s_last_to_app_event = (PebbleEvent) {0};
// Now the app sets the safe_to_kill flag to true and sends a kill event back to
// the launcher to get the app killed again. This calls close_current_app, which ends
// up launching s_third_party_app because it's in the next app slot.
app_manager_get_task_context()... |
nd_uid = ((GetNotificationAttributesMsg*)memory_with_attribute_id_at_end.attribute_data)->notification_uid;
const uint32_t loading_uid = ((GetNotificationAttributesMsg*)s_loading_response)->notification_uid;
const uint32_t no_content_uid = ((GetNotificationAttributesMsg*)s_this_message_has_no_content_response)->not... | if (uid == loading_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_loading_response),
(uint8_t*) s_loading_response);
s_num_ds_notifications_received++;
} else if (uid == no_content_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_this_message_has_no_content_re... |
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_unknown_app_dict), (uint8_t *)s_unknown_app_dict);
s_num_ds_notifications_received++;
} else if (uid == unknown_app_unique_title_dict_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_unknown_app_unique_title_dict), (uint8_t *)s_unknown_app_unique_... |
SMIdentityResolvingKey *irk_out) {
bool success = true;
storage_acquire();
{
device_t *dev = find_device_by_conn_idx(conn_idx);
if (!dev) {
success = false;
goto release;
}
bool is_resolved = false;
if (dev && dev->irk) {
is_resolve... | ble_gap_conn_param_update_reply(evt->conn_idx, true) | ;
}
static void prv_handle_conn_param_update(const ble_evt_gap_conn_param_updated_t *event) {
// This callback getting invoked means that conn param request was successful
// Note: If this cb is not invoked within 30s after issuing an update request
// we will be auto-disconnected (according to the ble_gap_conn_... |
e);
const uint8_t mute_option = ancs_filtering_get_mute_type(notif_prefs);
const bool is_mute_weekdays = mute_option == MuteBitfield_Weekdays;
const bool is_mute_weekends = mute_option == MuteBitfield_Weekends;
if (is_mute_weekdays || is_mute_weekends) {
action_menu_level_add_action(root_level,
... | window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_single_click_handler) | ;
window_long_click_subscribe(BUTTON_ID_SELECT, 1000, prv_select_long_click_handler, NULL);
window_set_click_context(BUTTON_ID_SELECT, data);
window_single_click_subscribe(BUTTON_ID_BACK, prv_back_button_single_click_handler);
window_set_click_context(BUTTON_ID_BACK, data);
if (s_notification_window_data.is... |
ayer2);
cl_assert(content_indicator3 != content_indicator);
}
void test_content_indicator__should_only_be_created_for_scroll_layer_upon_client_access(void) {
ContentIndicatorsBuffer *content_indicators_buffer = content_indicator_get_current_buffer();
Buffer *buffer = &content_indicators_buffer->buffer;
// At t... | (&content_indicator, down, &dummy_config) | );
}
|
/*
* 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_num_packets_sent, 2) | ;
cl_assert_equal_i(s_num_bytes_sent, LOG_METADATA_LENGTH + 20);
cl_assert_equal_s(s_log_message_buffer, "TestTestTestTestTest");
}
void test_pulse_logging__simple_trucate(void) {
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTestTestTestTestTestTest"
"Tes... |
---------------------------------------------------------------
T_STATIC void prv_timer_kernel_bg_callback(void *data) {
AlarmId id = (intptr_t) data;
if (id == ALARM_INVALID_ID) {
return;
}
// We allocate some larger variables on the heap to reduce stack usage
AlarmConfig *config = &s_most_recent_alarm_... | for (int i = 0; i < MAX_CONFIGURED_ALARMS; ++i) {
AlarmStorageKey key = { .id = i, .type = ALARM_DATA_CONFIG };
if (settings_file_get_len(file, &key, sizeof(key)) == 0) {
id_out = i;
break;
}
} |
return id_out;
}
// ----------------------------------------------------------------------------------------------
static int prv_get_day_for_just_once_alarm(int hour, int minute) {
// Figure out what day the alarm should happen
struct tm local_time;
const time_t current_time = rtc_get_time();
localtime_r(... |
w(uint32_t flash_new_fw_addr) {
display_firmware_update_progress(0, 1);
boot_bit_set(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
FirmwareDescription firmware_description =
firmware_storage_read_firmware_description(flash_new_fw_addr);
if (!firmware_storage_check_valid_firmware_description(&firmware_description... | {
dbgserial_putstr("Failed to load recovery firmware, strike one. Try again.");
boot_bit_set(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
system_reset();
} | else if (!boot_bit_test(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO)) {
dbgserial_putstr("Failed to load recovery firmware, strike two. Try again.");
boot_bit_set(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO);
boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
system_reset();
} else {
dbgserial_p... |
/*
* 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... | portENTER_CRITICAL() | ;
{
const uint64_t current_time = prv_get_curr_system_time_ms();
// Handle the first sample specially. We don't have an interval until we have
// 2 samples.
if (timer->num_samples == 0) {
timer->num_samples++;
} else {
const int64_t last_interval = current_time - timer->last_sample_ti... |
, 0);
s_sleep_state = ActivitySleepStateRestfulSleep;
s_sleep_state_seconds = 0;
s_last_vmc = 0;
prv_set_time(s_current_day, 10, 0);
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 0);
}
void test_alarm_smart__trigger_15_min_early_light_sleep(vo... | (s_num_timeline_adds, 1) | ;
cl_assert_equal_i(s_num_timeline_removes, 0);
// Set sleep status
s_sleep_state = ActivitySleepStateAwake;
s_sleep_state_seconds = 0;
// Don't trigger too early
prv_set_time(s_sunday, 23, 44);
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 0);
cl_assert_equal_i(s_num_alarm_events_put... |
tes) + (sx * step_w);
}
typedef enum {
RenderMoveTextBox,
RenderMoveDrawBox,
} RenderMoveMode;
void render_steps(TextLayoutExtended *layout, RenderMoveMode mode, int delta, int16_t height,
char **texts) {
const GTextLayoutCacheRef layout_cache = (GTextLayoutCacheRef const)layout;
int steps_... | (s_dest_bitmap, TEST_PBI_FILE) | );
}
void test_graphics_draw_text_flow__avoid_repeat_text_to_avoid_orphans(void) {
TextLayoutExtended layout = {
.flow_data = {
.perimeter.impl = &(GPerimeter){.callback=perimeter_for_display_round},
.perimeter.inset = 8,
.paging.page_on_screen = {
.origin_y = 25,
.size_h = 100
... |
#include "kernel/pbl_malloc.h"
#include "kernel/util/sleep.h"
#include "process_management/pebble_process_md.h"
#include "process_management/pebble_process_md.h"
#include "process_state/app_state/app_state.h"
#include "services/common/comm_session/session.h"
#include "services/common/comm_session/session_send_buffer.h... | window_set_window_handlers(data->window, &(WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
}) | ;
app_window_stack_push(data->window, true /*animated*/);
}
static void handle_deinit(void) {
// Don't bother freeing anything, the OS should be re-initing the heap.
}
// =================================================================================
static void s_main(void) {
handle_init();
app_event_loop... |
animation_set_custom_interpolation((Animation *)anim, prv_interpolate_moook_soft);
animation_set_duration((Animation *)anim, interpolate_moook_soft_duration(NUM_MOOOK_FRAMES_MID));
animation_set_handlers((Animation *)anim, (AnimationHandlers) {
.stopped = prv_handle_animation_stop,
}, data);
data->mic_w... | (BUTTON_ID_BACK, context) | |
6 frames and loop = infinite
// Tests start, stop, reset and loop
// Result:
// - gbitmaps matches platform decoded APNG
void test_gbitmap_sequence__color_2bit_bouncing_ball(void) {
#if PLATFROM_SPALDING
uint32_t resource_id = sys_resource_load_file_as_resource(TEST_IMAGES_PATH, GET_APNG_NAME);
cl_assert(resour... | gbitmap_sequence_create_with_resource(resource_id) | ;
cl_assert(bitmap_sequence);
GBitmap *bitmap = gbitmap_create_blank(gbitmap_sequence_get_bitmap_size(bitmap_sequence),
GBitmapFormat8Bit);
cl_assert(bitmap);
// Since frame 1 has 0 delay, it renders then immediately we render frame 2
gbitmap_sequence_update_bitmap_b... |
_assert(circular_buffer_consume(&buffer, 4));
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 6);
// Now there's just 56 in the buffer. Fill it to the brim
cl_assert(circular_buffer_write(&buffer, (uint8_t*) "789", 3));
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer),... | (circular_buffer_copy_offset(&buffer, 2 /* start_offset */,
data_out, data_out_size), 6) | ;
cl_assert(memcmp("456789", data_out, 6) == 0);
}
void test_circular_buffer__direct_write(void) {
CircularBuffer buffer;
uint8_t storage[8];
circular_buffer_init(&buffer, storage, sizeof(storage));
circular_buffer_write(&buffer, (uint8_t *)"0123", 4);
uint8_t *data_out;
uint16_t contiguous_num_bytes_l... |
s = utf8_get_bounds(&success, (char[]) { 0x10, 0x0 });
cl_assert(success);
const TextBoxParams text_box_params = (TextBoxParams) {
.utf8_bounds = &utf8_bounds,
};
// Init mutable types
word_iter_init(&word_iter, &word_iter_state, &s_ctx, &text_box_params, utf8_bounds.start);
// Tests
cl_assert(word... | (*word_iter_state.current.end == '\n') | ;
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == '\0');
cl_assert(!iter_next(&word_iter));
}
|
/*
* 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... | ((unsigned int) buffer_len > sizeof(LogBinaryMessage)) | ;
LogBinaryMessage* msg = (LogBinaryMessage*) buffer;
time_t time_seconds = sys_get_time();
msg->timestamp = htonl(time_seconds);
msg->log_level = log_level;
msg->line_number = htons(src_line_number & 0xffff);
msg->message_length = 0;
// Ensure we only send the last 15 characters of a filename
const... |
time_util_get_midnight_of(now));
cl_assert_equal_i(result, 2000);
// yesterday and today
result = health_service_sum(HealthMetricStepCount,
time_util_get_midnight_of(now) - SECONDS_PER_DAY,
now);
cl_assert_equal_i(result, 1000 + 2000);
}
void test_... | (cache != NULL) | |
the TextLayer. Note that the matching
// graphics_text_attributes_destroy() will not need to be called here, as the ownership
// of text_attributes will be transferred to the TextLayer we assign it to.
text_attributes = graphics_text_attributes_create();
graphics_text_attributes_enable_screen_text_flow(text_at... | (dialog, icon, GPoint(x, y), false) | ) {
layer_add_child(window_root_layer, &dialog->icon_layer.layer);
}
dialog_load(dialog);
}
static void prv_workout_dialog_appear(Window *window) {
WorkoutDialog *workout_dialog = window_get_user_data(window);
dialog_appear(&workout_dialog->dialog);
}
static void prv_workout_dialog_unload(Window *window)... |
/*
* 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... | (button_id) | ) {
button_counter[button_id] = 0;
continue;
}
if (button_counter[button_id] >= STUCK_BUTTON_THRESHOLD) {
dbgserial_putstr("Stuck button register is invalid, clearing.");
dbgserial_print_hex(button_counter_register);
RTC_WriteBackupRegister(STUCK_BUTTON_REGISTER, 0);
return... |
CDC_V18_ENABLE_LV, 0x0);
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_CUR_LIM_MAX_LV, 0xF);
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_IDLE_HYST, 0x4);
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_IDLE_MIN, 0x10);
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_FAST_RAMPING, 0x1);
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_VOLTAGE,... | (CRG_TOP, BOD_STATUS_REG, BOD_VDD_LOW, 0x0) | ;
REG_SETF(CRG_TOP, FORCE_SLEEP_REG, FORCE_BLE_SLEEP, 0x0); // GUESS
REG_SETF(CRG_TOP, FORCE_SLEEP_REG, FORCE_FTDF_SLEEP, 0x0); // GUESS
REG_SETF(CRG_TOP, LDOS_DISABLE_REG, LDOS_DISABLE, 0x0); // GUESS
REG_SETF(CRG_TOP, AON_SPARE_REG, OSC16_HOLD_AMP_REG, 0x0); // GUESS
REG_SETF(CRG_TOP, AON_SPARE_REG, OSC1... |
/*
* 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... | {
spi_ll_slave_acquire(DIALOG_SPI);
spi_ll_slave_drive_clock(DIALOG_SPI, false);
} |
static void prv_disable_spi_clock(void) {
// When the SPI peripheral is disabled, the CLK line floats. Let's
// reconfigure the CLK GPIO to be active low so the Dialog BT controller
// doesn't see a false clock edge
spi_ll_slave_drive_clock(DIALOG_SPI, true);
spi_ll_slave_release(DIALOG_SPI);
}
static void... |
node's callback) as well
// as the size requested by the provided LayoutNodeTextDynamicConfig
GTextNodeTextDynamic *text_node = graphics_text_node_create_text_dynamic(
sizeof(TextDynamicContext) + config->buffer_size, prv_text_dynamic_node_callback, NULL);
if (text_node) {
TextDynamicContext *context =... | (content_size) | |
3Minutes, Monday, &val_out));
}
void test_health_db__step_averages(void) {
const struct {
const char *key;
const char *val;
} entries[] = {
{
.key = "sunday_steps",
.val = "l4tHpFsFGE6UINneFPMnf2lgINlYuXlDS6xh6vizK9jbDen5mHQgWF6E8jOzBVnEdV0j2DNOzONfJbsWoSWH0QoQpPmm1NSW" \
"l4tH... | strlen(key) | ,
(uint8_t *)s_movement_data, sizeof(s_movement_data)),
S_SUCCESS);
cl_assert_equal_i(s_metric_updated_count, NUM_CURRENT_MOVEMENT_METRICS);
s_metric_updated_count = 0;
key = "thursday_sleepData";
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen... |
/*
* 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... | (NULL, test_size) | ;
cl_assert_equal_p(result, false);
result = transcription_validate(validate_test, test_size - 1);
cl_assert_equal_p(result, false);
result = transcription_validate(validate_test, test_size + 1);
cl_assert_equal_p(result, false);
result = transcription_validate(validate_test, 0);
cl_assert_equal_p(resu... |
;
graphics_context_set_text_color(&context, color);
cl_assert_equal_i(context.draw_state.text_color.argb, GColorClear.argb);
color.a = 0;
graphics_context_set_text_color(&context, color);
cl_assert_equal_i(context.draw_state.text_color.argb, GColorClear.argb);
// Text Color - 2-bit
graphics_context_set_... | (&context, false, 2, GColorBlack, GColorBlack, false) | ;
graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4);
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, 2));
}
void test_graphics_context_${BIT_DEPTH_NAME}__draw_stroke_width_even(void) {
// Stroke width even > 2, non-antialiased
setup_test(&context, false, SW_EVEN, GCol... |
112, -144},
{ 928, 56, -216},
{ 936, -24, -232},
{ 1032, -56, -184},
{ 968, -56, -232},
{ 1024, 8, -248},
{ 1176, 104, -304},
{ 1112, 152, -152},
{ 976, 184, -128},
{ 952, 248, -168},
{ 976, 304, -160},
// 56 seconds
{ 1048, 288, -64},
{ 1120, 312, -24},
{ 1032, ... | { 56, -128, -1000},
{ 40, -96, -968},
{ -8, -184, -992},
{ -24, -152, -1024},
{ -8, -176, -1016},
{ 0, -208, -984},
{ -24, -264, -984},
{ 88, -168, -1008},
{ 136, -64, -1040},
{ 880, 160, -1176},
{ 64, -240, -1056},
{ 32, -128, -1024},
{ 8, -64, -1008},
{ 24, -184... |
{ 88, 8, -1040},
{ 80, -64, -1024},
{ 88, -72, -1024},
{ 48, -96, -1000},
{ 104, -128, -984},
{ 120, -88, -1032},
{ 64, -24, -1008},
{ 72, -40, -1008},
};
*len = ARRAY_LENGTH(samples);
return samples;
}
// ----------------------------------------------------------------
// Sam... |
a(layout, &forecasts_list_head->forecast);
const bool multiple_forecasts_exist = (forecasts_count_out > 1);
weather_app_layout_set_down_arrow_visible(layout, multiple_forecasts_exist);
data->forecasts_list_head = forecasts_list_head;
// Only show the first forecast if the number of forecasts has differ... | weather_service_create_default_forecast() | ;
const bool is_default_forecast_data_recent = prv_is_weather_forecast_recent(default_forecast);
weather_service_destroy_default_forecast(default_forecast);
// TODO PBL-38484: Consider using a different dialog for when data is stale but phone is connected
if (is_default_forecast_data_recent || connection_servi... |
}
for (int dest_y = clipped_glyph_target.origin.y; dest_y != clipped_glyph_target.origin.y + clipped_glyph_target.size.h; ++dest_y) {
dest_shift = dest_shift_at_line_begin;
// Number of bits to render on this line.
uint8_t glyph_line_bits_left = clipped_glyph_target.size.w;
uint32_t *dest_block =... | rotl32(src, dest_shift) | ;
src_rotated = dest_shift;
// Continue with this dest_block if there is still space left:
if (dest_shift) {
continue;
}
}
++dest_block;
}
dest_shift += right_clip % 32;
// emulate having drawn the right clip
if (glyph_block_bits_left <= right_cli... |
ength_min = 15, // end = -65
};
s_sys_activity_get_sessions_values.out.sessions[4] = (ActivitySession){
.type = ActivitySessionType_Walk,
.start_utc = now - (65 * SECONDS_PER_MINUTE),
.length_min = 15, // end = -50
};
s_sys_activity_get_sessions_values.out.sessions[3] = (ActivitySession){
.type ... | (7, s_prv_activity_cb__call_count) | |
(s_inhibitor_profile[inhibitor].active_count != 0) | ;
--s_num_items_disallowing_stop_mode;
--s_inhibitor_profile[inhibitor].active_count;
if (s_inhibitor_profile[inhibitor].active_count == 0) {
s_inhibitor_profile[inhibitor].total_ticks_while_disabled += rtc_get_ticks() -
s_inhibitor_profile[inhibitor].ticks_when_stop_mode_disabled;
}
portEXIT_CRI... | |
/*
* 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... | status_bar_layer_render(ctx, &status_bar_layer->layer.bounds, &status_bar_layer->config) | ;
ctx->draw_state.drawing_box.origin.x = stored_drawing_box_x;
}
void status_bar_layer_init(StatusBarLayer *status_bar_layer) {
PBL_ASSERTN(status_bar_layer);
*status_bar_layer = (StatusBarLayer){
.previous_min_of_day = -1,
};
// The status bar needs to be as wide as the framebuffer we will render it i... |
,
{ 1288, 592, -248},
{ 1208, 544, -144},
{ 1408, 568, -64},
{ 1544, 552, -64},
{ 1360, 296, -48},
{ 1240, 312, -64},
{ 1264, 328, -16},
{ 1264, 288, -8},
{ 1248, 200, 24},
{ 1280, 184, -32},
{ 1216, 232, -96},
{ 1056, -136, -232},
{ 680, -424, 0},
{ 448, -192, -4... | { -152, -400, -584},
{ -64, -408, -552},
{ 64, -376, -568},
{ 152, -400, -600},
{ 384, -304, -448},
{ 728, -48, -416},
{ 1040, 136, -344},
{ 1736, 200, -248},
{ 2248, 552, -328},
{ 2032, 456, -240},
{ 1800, 488, -424},
{ 1664, 680, -224},
// 74 seconds
{ 1760, 680... | |
/*
* 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... | {
// Interrupt Clear-Enable Register
NVIC->ICER[i] = 0xFFFFFFFF;
// Interrupt Clear-Pending Register
NVIC->ICPR[i] = 0xFFFFFFFF;
} |
// Set the peripheral clock enable registers to their reset values as
// specified in the datasheet.
RCC->AHB1ENR = 0x00100000; // Core-coupled memory is enabled at reset
RCC->AHB2ENR = 0;
RCC->AHB3ENR = 0;
RCC->APB1ENR = 0;
RCC->APB2ENR = 0;
// Reset most peripherals used by the bootloader. We want... |
1000);
cl_assert_equal_i(s_num_alarm_events_put, 0);
s_current_minute = 10;
cl_assert_equal_i(s_num_alarm_events_put, 1);
}
void test_alarm__get_string_for_kind(void) {
bool all_caps = false;
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_EVERYDAY, all_caps), "Every Day");
cl_assert_equal_s(alarm_g... | cron_service_wakeup() | ;
cl_assert_equal_i(s_num_alarms_fired, 1);
}
void test_alarm__recurring_daily_alarm_timeout_behind(void) {
AlarmId id;
s_current_hour = 11;
s_current_minute = 30;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 10, 30, false, ALARM_KIN... |
header.id));
cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(2));
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(3));
cl_assert(timeline_model_iter_next(&new_idx, &has_next));
cl_assert(has_next);
cl_assert_equal_i(n... | (new_idx, 2) | ;
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[3]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(uuid_equ... |
LOG(LOG_LEVEL_INFO, "Snoozing for %d minutes", snooze_delay_s / SECONDS_PER_MINUTE);
bool success = new_timer_start(s_snooze_timer_id, snooze_delay_s * MS_PER_SECOND,
prv_snooze_timer_callback, NULL, 0 /* flags*/);
PBL_ASSERTN(success);
}
// ----------------------------------------... | prv_set_day_for_just_once_alarm(&config, config.hour, config.minute) | ;
Alarm alarm = {
.id = i,
.config = config,
};
prv_persist_alarm(&file, &alarm);
}
}
}
prv_reload_alarms(&file);
prv_file_close_and_unlock(&file);
}
// ----------------------------------------------------------------------------------------------
void alar... |
r_mode(BMA255PowerMode_Normal);
prv_set_accel_power_mode(BMA255PowerMode_LowPower1);
const bool enable_int = (num_samples != 0);
prv_configure_fifo_interrupts(enable_int, use_fifo);
s_fifo_is_enabled = use_fifo;
}
////////////////////////////////////////////////////////////////////////////////
// Shake Detec... | bma255_write_register(BMA255Register_PMU_SELFTEST, axis_bits | SELFTEST_SIGN_POSITIVE) | ;
psleep(50);
uint8_t new_positive;
int16_t positive = prv_read_axis(axis, &new_positive);
positive = prv_raw_to_mgs(positive);
prv_soft_reset();
bma255_set_scale(BMA255Scale_4G);
// Negative axis
bma255_write_register(BMA255Register_PMU_SELFTEST, axis_bits | SELFTEST_SIGN_NEGATIVE);
psleep(50);
u... |
ALID_SESSION);
// Check that adding a slice with APP_GLANCE_SLICE_DEFAULT_ICON as the icon succeeds
slice = (AppGlanceSlice) {
.expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION,
.layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
.layout.subtitle_template_string = "Test subtitle {time_until(500)|format('%uS'... | (s_test_state.reload_callback_was_called, true) | ;
}
static void prv_glance_clear_test(AppGlanceReloadCallback reload_cb) {
// Insert some slices for the glance
const AppGlance glance = (AppGlance) {
.num_slices = 2,
.slices = {
{
.expiration_time = 1464734504, // (Tue, 31 May 2016 22:41:44 GMT)
.type = AppGlanceSliceType_IconAndSub... |
map(&s_dest_bitmap, src_bitmap, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi_eq(&s_dest_bitmap,
"test_bitblt_palette_1bit__2bit_palette_to_1bit-expect.pbi"));
gbitmap_destroy(src_bitmap);
}
// Tests assign, from same size to same size.
// Setup:
// - Source is 50x50, alternat... | cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorBlack, 1), 0x00000000) | |
)) {
rocky_log_exception("removing event listener", remove_result);
}
for (size_t i = 0; i < ARRAY_LENGTH(args); i++) {
jerry_release_value(args[i]);
}
// mark item as removed and stop iterating
query_data->found = true;
return false;
}
return true;
}
T_STATIC bool prv_remove_e... | (rocky, name_to, on) | ;
}
void rocky_global_init(const RockyGlobalAPI *const *global_apis) {
PBL_ASSERTN(global_apis);
s_global_apis = global_apis;
JS_VAR rocky = jerry_create_object();
// this keeps a permanent reference to the singleton
rocky_set_rocky_singleton(rocky);
rocky_add_function(rocky, ROCKY_ON, prv_add_event_list... |
seq + delay_a + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_han... | cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
// Start B
prv_advance_to_ms_with_timers(start_ms + delay_spawn + MAX(delay_a, delay_b)
+ 2 * MIN_FRAME_INTERVAL_MS);
c... |
ata);
}
DEFINE_SYSCALL(int, sys_accel_manager_peek, AccelData *accel_data) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(accel_data, sizeof(*accel_data));
}
// bump peek analytics
analytics_inc(ANALYTICS_DEVICE_METRIC_ACCEL_PEEK_COUNT, AnalyticsClient_System);
PebbleTask task = pebble_... | (min_rate_mHz <= ONLY_SUPPORTED_JITTERFREE_RATE_MILLIHZ) | ;
mutex_lock_recursive(s_accel_manager_mutex);
state->sampling_interval_us = (US_PER_SECOND * 1000) / ONLY_SUPPORTED_JITTERFREE_RATE_MILLIHZ;
prv_update_driver_config();
mutex_unlock_recursive(s_accel_manager_mutex);
return ONLY_SUPPORTED_JITTERFREE_RATE_MILLIHZ;
}
DEFINE_SYSCALL(int, sys_accel_manager_s... |
{ 560, 400, -40},
{ 720, 408, 72},
{ 968, 512, 256},
{ 1120, 712, 480},
{ 1104, 696, 416},
{ 1168, 576, 432},
{ 824, 608, 528},
{ 824, 816, 464},
{ 896, 488, 312},
{ 1128, 456, 96},
{ 1200, 464, 56},
{ 1064, 592, 72},
{ 808, 320, 32},
{ 656, 320, -96},
{ 784, 480... | { 1528, 1184, 376},
{ 1704, 1008, 552},
{ 2112, 1000, 240},
{ 2656, 1320, 408},
{ 2056, 1208, 784},
// 343 seconds
{ 1304, 784, 480},
{ 1272, 392, 248},
{ 1408, 608, 344},
{ 1200, 896, 656},
{ 832, 704, 624},
{ 496, 1072, 624},
{ 536, 936, 768},
{ 824, 976, 576},
... |
{ 1712, 648, 472},
{ 1648, 512, 432},
{ 1664, 480, 360},
{ 1712, 512, 312},
{ 1608, 336, 336},
{ 1296, 200, 232},
{ 1032, -512, -424},
{ 984, -672, -216},
{ 1208, 656, -368},
{ 1184, 336, -112},
{ 1320, 248, 152},
{ 1392, 272, 304},
{ 1408, 464, 376},
{ 1488, 608... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.