prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
GTextNode *timeline_layout_create_card_view_from_config(const TimelineLayout *layout,
const LayoutNodeConfig *config) {
if (config->type != LayoutNodeType_Vertical) {
return timeline_layout_create_card_view_from_config(layout, config);
}
LayoutNodeVertic... | graphics_text_node_create_custom(prv_page_break_node_callback, (void *)layout) | ;
return page_break_node;
}
void timeline_layout_time_text_update(const LayoutLayer *layout_ref,
const LayoutNodeTextDynamicConfig *config,
char *buffer, bool render) {
const TimelineLayout *layout = (TimelineLayout *)layout_ref;
clock_c... |
/*
* 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_factory_registry) | ;
}
int factory_registry_add(const char* key, const uint8_t key_length, const uint8_t* uuid,
const uint8_t description, const uint8_t* value, uint8_t value_length) {
return registry_private_add(key, key_length, uuid, description, value, value_length,
&s_factory_... |
h OFF
do_not_disturb_set_manually_enabled(true);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
active = do_not_disturb_is_active();
cl_assert(active == true); // Both ON
rtc_set_time(s_thursday_12_00);
do_not_disturb_handle_clock_change(); // In scheduled period
active = do_not_disturb_is_... | rtc_set_time(s_friday_23_30) | ; // In schedule
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == true);
// Timer will go off at 00:00 on Saturday. (0.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 1800 * MS_PER_SECOND);
rtc_set_time(s_saturday_00_30);
do_not_disturb... |
E}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, STROKE_SMALL);
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_SMALL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_origin_aa_r1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_C... | graphics_draw_circle(&ctx, CENTER_OF_OFFSET_RECT, RADIUS_SMALL) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_aa_r1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, STROKE_SMALL);
graphics_draw_circle(&ctx, CENTER_OF_OFFSET_RECT_NXNY, RADIUS_SMALL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,... |
/*
* 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_frame_layer_implementation, layer, from_frame, to_frame) | |
/*
* 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... | regular_timer_remove_callback(&s_missed_call_timer_id) | ;
}
}
void ancs_phone_call_temporarily_block_missed_calls(void) {
const int BLOCK_MISS_CALL_TIME_S = 7;
if (regular_timer_is_scheduled(&s_missed_call_timer_id)) {
regular_timer_remove_callback(&s_missed_call_timer_id);
}
s_missed_call_timer_id = (const RegularTimerInfo) {
.cb = prv_handle_missed_cal... |
ontentSizeSmall] = PBL_IF_RECT_ELSE(46, MENU_CELL_ROUND_UNFOCUSED_SHORT_CELL_HEIGHT),
[PreferredContentSizeMedium] = PBL_IF_RECT_ELSE(46,
MENU_CELL_ROUND_UNFOCUSED_SHORT_CELL_HEIGHT),
[PreferredContentSizeLarge] = menu_cell_basic_cell_height(),
//! @note t... | (s_data, id) | ;
app_notification_window_remove_notification_by_id(id);
}
static void prv_handle_notification_acted_upon(Uuid *id) {
app_notification_window_handle_notification_acted_upon_by_id(id);
}
static void prv_handle_notification_added(Uuid *id) {
TimelineItem notification;
if (!notification_storage_get(id, ¬ifica... |
AnimationEachCallback)(AnimationPrivate *animation, uintptr_t context);
static void prv_each(AnimationPrivate *animation, AnimationEachCallback callback,
uintptr_t context) {
if (animation->first_child) {
prv_each(animation->first_child, callback, context);
}
if (animation->sibling) {
... | {
return false;
} |
if (animation->scheduled) {
prv_each(animation, prv_call_scheduled, false);
prv_each(animation, prv_call_update, ANIMATION_NORMALIZED_MAX);
prv_each(animation, prv_call_stopped, animation->is_completed);
}
return true;
}
// Interface for unit tests to query the fake animation state
/////////////////... |
/*
* 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... | (MHZ_TO_HZ(20), I2CBusMode_Standard,
KHZ_TO_HZ(100), 500, 500) | |
/*
* 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... | {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = s_main,
.name = "Bouncing Box"
};
return (const PebbleProcessMd*) &s_app_info;
} | |
/*
* 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... | malloc(sizeof(FrameBuffer)) | ;
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
}
// Teardown
void test_graphics_draw_stroke_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
... |
r->bounds;
const GTextOverflowMode overflow = GTextOverflowModeTrailingEllipsis;
const GTextAlignment alignment = GTextAlignmentCenter;
const GSize text_size = graphics_text_layout_get_max_used_size(ctx, no_activities_string, font,
box, overflow, ... | option_menu_init(&data->option_menu) | ;
// Not using option_menu_configure because prv_reload_menu_data already sets
// icons_enabled and chosen row index
option_menu_set_status_colors(&data->option_menu, GColorWhite, GColorBlack);
option_menu_set_highlight_colors(&data->option_menu, SETTINGS_MENU_HIGHLIGHT_COLOR, GColorWhite);
option_menu_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... | (ctx, &hr_box) | ;
}
if (size_out) {
*size_out = hr_box.size;
}
}
static GTextNode *prv_horizontal_rule_constructor(const LayoutLayer *layout_ref,
const LayoutNodeConstructorConfig *config) {
GTextNodeCustom *custom_node = graphics_text_node_create_custom(prv_horizontal_ru... |
/*
* 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 (num_whole_word_bytes--) {
crc = crc ^ *((uint32_t*)data);
for(int bit = 0; bit < 32; ++bit) {
if ((crc & 0x80000000) != 0) {
crc = (crc << 1) ^ CRC_POLY;
} else {
crc = (crc << 1);
}
}
data += 4;
} | |
inning */,
false /* auto_accept_re_pairing */);
cl_assert(id_2 != BT_BONDING_ID_INVALID);
cl_assert_equal_i(s_ble_bonding_change_add_count, 2);
cl_assert_equal_i(fake_shared_prf_storage_get_ble_store_count(), 1); // This wasn't a gateway
// Read both... | (&pairing_2, false) | |
for (int i = 0; i < s_num_dls_accel_records; i++) {
ActivityRawSamplesRecord *record = &s_dls_accel_records[i];
// Verify the header info
cl_assert_equal_i(record->version, ACTIVITY_RAW_SAMPLES_VERSION);
cl_assert_equal_i(record->len, sizeof(ActivityRawSamplesRecord));
if (i == 0) {
cl_assert... |
cl_assert_equal_i(num_samples, 0);
}
// ---------------------------------------------------------------------------------------
// Init and enable the activity service
static void prv_activity_init_and_set_enabled(bool enable) {
activity_init();
activity_set_enabled(enable);
fake_system_task_callbacks_invoke... | |
get_calendar_ongoing());
cl_assert(!stub_new_timer_is_scheduled(timer_id));
}
void test_calendar__init_with_ongoing_event(void) {
cl_assert(timeline_add(&item1));
timeline_event_handle_blobdb_event();
rtc_set_time(15 * 60);
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1);
cl_assert(p... | (timer_id) | );
cl_assert_equal_i(65*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(100 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_count(), 5);
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_new_... |
/*
* 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... | _Static_assert(AHB1PERIPH_BASE < AHB2PERIPH_BASE, "Clock mapping assumptions don't hold") | ;
_Static_assert(AHB2PERIPH_BASE < AHB3_BASE, "Clock mapping assumptions don't hold");
// Note: this works only with peripheral (<...>Typedef_t *) defines, not with RCC defines
static ClockCmd prv_get_clock_cmd(uintptr_t periph_addr) {
PBL_ASSERTN(periph_addr >= APB1PERIPH_BASE);
if (periph_addr < APB2PERIPH_BASE)... |
nJob* job = (CronJob*)s_scheduled_jobs;
s_scheduled_jobs = list_pop_head(s_scheduled_jobs);
// Re-calculate the execute time.
// See the notes in the API header on how this works.
if (must_recalc || change_diff >= job->clock_change_tolerance) {
job->cached_execute_time = cron_job_get_execute_time(... | prv_timer_callback(NULL) | ;
}
// ---------------------------------------------------------------------------------------
// The brains.
typedef enum {
CronAssignMode_LocalEpoch, // 'any' uses local epoch's value
CronAssignMode_Zero, // 'any' uses 0
} CronAssignMode;
// Indices for the access arrays
#define CRON_INDEX_YEAR 0
#define CRON_I... |
ay 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Li... | bt_unlock() | ;
if (comm_session_is_system(session)) {
const PebbleProtocolCapabilities capabilities = { .flags = capability_flags };
bt_persistent_storage_set_cached_system_capabilities(&capabilities);
}
}
//! Resets the session (close and attempt re-opening the session)
//! @note If the underlying transport is iAP, ... |
/*
* 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 false;
} |
void passert_failed(const char* filename, int line_number, const char* message, ...) {
}
void passert_failed_no_message(const char* filename, int line_number) {
}
void pbl_log(uint8_t log_level, const char* src_filename,
int src_line_number, const char* fmt, ...) {
va_list args;
va_start(args, fmt)... |
;
}
static void prv_assert_driver_addr_is_addr1(void) {
cl_assert_equal_b(s_last_driver_addr_is_null, false);
cl_assert_equal_m(&s_last_driver_addr, &TEST_PINNED_ADDR_1, sizeof(s_last_driver_addr));
}
static void prv_assert_driver_addr_is_addr2(void) {
cl_assert_equal_b(s_last_driver_addr_is_null, false);
cl_... | cl_assert_equal_b(false, s_last_driver_allow_cycling) | |
41 seconds
{ -1096, 88, 104},
{ -1024, 88, 104},
{ -1096, 8, 24},
{ -968, -168, 16},
{ -920, -144, -184},
{ -1240, -40, -288},
{ -1200, -32, -344},
{ -1360, -48, -344},
{ -1496, -48, -208},
{ -1440, -32, -56},
{ -1208, 96, -8},
{ -976, 232, 80},
{ -936, 280, 112},
... | { -264, 264, -16},
{ -416, -32, -48},
{ -552, -48, -16},
{ -744, 64, -24},
{ -1592, 32, 576},
{ -2696, 432, 456},
{ -2560, 1032, -152},
{ -2064, 744, 176},
{ -1352, 376, -56},
{ -1064, 48, 72},
{ -1032, 360, 56},
{ -1008, 368, -72},
{ -992, 248, -112},
{ -888, 496... |
{ -1576, 208, -72},
{ -1480, 512, -136},
{ -1200, 512, -216},
{ -1368, 352, -120},
{ -1552, 232, 0},
{ -1344, 112, 24},
{ -1080, 136, 48},
{ -1032, 112, 88},
{ -1048, 104, 128},
{ -1072, 64, 160},
{ -1200, 72, 200},
{ -1336, 32, 272},
{ -1056, 0, -80},
{ -1240, 0... |
(ctx, PBL_IF_COLOR_ELSE(GColorDarkGray, GColorWhite)) | ;
}
graphics_draw_text(ctx, items[i].label, font, r, GTextOverflowModeTrailingEllipsis,
GTextAlignmentCenter, NULL);
r.origin.x += r.size.w;
}
}
static const ActionMenuItem *prv_get_item_for_index(ActionMenuLayer *aml, int idx) {
if (!aml->num_items && !aml->num_short_items) {
return NULL... | |
IN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 4, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r4_aa_no_clip.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix left corners PBL-15915
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIG... | MIN(RECT_WIDTH, RECT_HEIGHT) | ) / 2) - 1, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_aa_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2), GCornersAl... |
;
prv_process_and_reset_test_counters();
prv_receive_install(s_last_response_cookie);
}
// Tests
///////////////////////////////////////////////////////////
static void prv_system_msg_sent_callback(uint16_t endpoint_id,
const uint8_t* data, unsigned int data_length) {
i... | assert_nack_count(1) | ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Init Message
void test_put_bytes__init_firmware(void) {
prv_receive_init(VALID_OBJECT_SIZE, ObjectFirmware);
// All good!
assert_ack_count(1);
assert_nack_count(0);
// Expect "Start" event:
Pebble... |
/*
* 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_LOG(LOG_LEVEL_INFO, "Updating PRF!");
flash_prf_set_protection(false);
bool saved_sleep_when_idle = flash_get_sleep_when_idle();
flash_sleep_when_idle(false);
FirmwareDescription description =
firmware_storage_read_firmware_description(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN);
if (!firmware_stora... | |
TimelineLayout *layout = (TimelineLayout *)layout_ref;
clock_get_time_number(buffer, config->buffer_size, layout->info->pin_time);
}
static void prv_time_word_update(const LayoutLayer *layout_ref,
const LayoutNodeTextDynamicConfig *config, char *buffer,
... | if (time_text_node) {
graphics_text_node_container_add_child(&vertical_node->container, time_text_node);
} |
const char *secondary_text = prv_get_secondary_text(layout);
const bool is_fat = (layout->layout_layer.mode == LayoutLayerModePinnedFat);
UNUSED const bool is_thin = (layout->layout_layer.mode == LayoutLayerModePinnedThin);
const TimelineLayoutStyle *style = prv_get_style();
const bool thin_can_have_seconda... |
i].busy = false;
i2c_buses[i].transfer.idx = 0;
i2c_buses[i].transfer.size = 0;
i2c_buses[i].transfer.data = NULL;
i2c_buses[i].transfer.state = TRANSFER_STATE_INVALID;
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = BOARD_CONFIG.i2c_bus_configs[i].ev_irq_channel;
... | PBL_LOG(LOG_LEVEL_ERROR, "Attempted access to disabled bus %d by device %d", bus_idx, device_id) | |
OLD_NUMBERS);
// "disconnected" text
const char * const font_key_disconnected = FONT_KEY_GOTHIC_24_BOLD;
static const GTextAlignment distance_text_alignment = PBL_IF_ROUND_ELSE(GTextAlignmentRight,
GTextAlignmentCenter);
// text heights... | text_layer_create(GRect(distance_column_x_offset, front_value_y_offset,
distance_column_width, small_numbers_height)) | ;
prv_setup_text_layer(text[TextFront], font_key_small_numbers, NULL, distance_text_alignment);
layer_add_child(background, text_layer_get_layer(text[TextFront]));
// Disconnected text.
data->disconnected_text = text_layer_create(GRect(0, disconnected_text_y_offset,
... |
d);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST);
// Schedule again
wakeup_id = sys_wakeup_schedule(sys_get_time() + 10, 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + 10);
// Cancel all wakeup events
sys_wakeup_cancel_all_for_app();
cl_assert_equal_i(sys_... | wakeup_get_current() | ;
// Schedule another a minute away
time_t second_event = sys_get_time() + WAKEUP_EVENT_WINDOW * 2;
WakeupId second_wakeup_id = sys_wakeup_schedule(second_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(second_wakeup_id), second_event);
TimerID test_timer = wakeup_get_current();
// Wakeup should sti... |
/*
* 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... | app_window_stack_push(data->window, true) | ;
app_timer_register(10, timer_callback, NULL);
}
static void handle_deinit(void) {
AmbientLightAppData *data = app_state_get_user_data();
text_layer_destroy(data->text_layer);
window_destroy(data->window);
task_free(data);
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit()... |
/*
* 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... | kernel_zalloc_check(sizeof(BTDeviceAddress)) | ;
memcpy(addr, &resp->addr, sizeof(BTDeviceAddress));
system_task_add_callback(bt_driver_store_device_name_kernelbg_cb, addr);
}
void hc_endpoint_gap_service_resp_handler(const HcProtocolMessage *msg) {
switch (msg->command_id) {
case HcMessageId_GapService_MtuChanged:
prv_mtu_changed((const HcProtocol... |
hr_elevated(), true);
prv_set_median_hr_for_minutes(70 /* BPM */, 1 /* minutes */);
cl_assert_equal_b(prv_is_hr_elevated(), false);
activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes);
cl_assert_equal_i(zone1_minutes, 2);
activity_get_metric(ActivityMetricHeartRateZone2Minutes, 1, &zon... | {
ActivitySession activity = walk_activity;
activity.start_utc = i;
activity_sessions_prv_add_activity_session(&activity);
cl_assert_equal_i(activity_private_state()->activity_sessions_count, i + 1);
cl_assert_equal_m(&activity_private_state()->activity_sessions[i], &activity,
s... |
for (int i = ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT - 1; i >= 0; i--) {
ActivitySession activity = walk_activity;
activity.start_utc = i;
ActivitySession next_activity = activity;
next_activity.start_utc = i - 1;
activity_sessions_prv_delete_activity_session(&activity);
cl_assert_equal_i(act... |
/*
* 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... | (a.b.integer - b.b.integer) | < 10);
cl_assert(abs(a.c.integer - b.c.integer) < 10);
cl_assert(abs(a.d.integer - b.d.integer) < 10);
cl_assert(abs(a.tx.integer - b.tx.integer) < 10);
cl_assert(abs(a.ty.integer - b.ty.integer) < 10);
}
// --------------------------------------------------------------------------------------
static void cl... |
// Clipping on even boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_EVEN, OFFSET_RECT_EVEN, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED... | GPoint(col, 0) | , MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_even_clip")));
// Clipping on odd boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_ODD, OFFSET_RECT_ODD, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
... |
if ((min_size % bytes_per_sector) > 0) {
num_pages++;
}
int optimal_size = num_pages * bytes_per_sector;
optimal_size -= sizeof(FileHeader);
optimal_size -= sizeof(FileMetaData);
optimal_size -= namelen;
return optimal_size;
}
uint32_t get_available_pfs_space(void) {
uint32_t allocated_space = 0;
... | (display_buf, sizeof(display_buf), "%3d:\t%8s%s\t%5d\t\t0x%x\t%15d",
pg, file_name, is_tmp_file(pg) ? "(tmp)" : "", (int)file_hdr.file_size,
file_hdr.file_type, (int)pg_hdr.erase_count) | ;
prompt_send_response(display_buf);
}
snprintf(display_buf, sizeof(display_buf), "\n---\n%d / %d pages in use "
"(%"PRIu32" kB available)", pages_in_use, s_pfs_page_count,
get_available_pfs_space() / 1024);
prompt_send_response(display_buf);
}
// Dump the first n bytes of a file (from current ... |
/*
* 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... | (
tag, DATA_LOGGING_BYTE_ARRAY, item_length, buffered, resume, &system_uuid) | |
evice_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
bus_lock(bus);
if (bus->user_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted release of disabled bus %d by device %d", bus_idx, device_id);
bus_unlock(bus);
return;
}
bus->user_count--;
if (bus->user_count == 0) {
bus_disable(bus_... | {
PBL_LOG(LOG_LEVEL_ERROR, "I2C Error on bus %" PRId8, bus_idx);
} |
} else if (bus->transfer.nack_count < I2C_NACK_COUNT_MAX) {
// NACK received after start condition sent: the MFI chip NACKs start conditions whilst it is busy
// Retry start condition after a short delay.
// A NACK count is incremented for each NACK received, so that legitimate NACK
... |
sys_activity_get_metric(prv_get_activity_metric(metric), 1, &value) | ;
if (!success) {
return;
}
bool went_above = ((value > info->threshold) && (info->prior_reading < info->threshold));
bool went_below = ((value < info->threshold) && (info->prior_reading > info->threshold));
if (went_above || went_below) {
state->event_handler(HealthEventMetricAlert, state->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... | {
applib_free(bytes);
} |
}
#if CAPABILITY_HAS_MAPPABLE_FLASH
bool applib_resource_track_mmapped(const void *bytes) {
if (resource_storage_builtin_bytes_are_readonly(bytes)) {
return true;
}
if (resource_storage_flash_bytes_are_readonly(bytes)) {
sys_resource_mapped_use();
return true;
}
return false;
}
bool applib_r... |
/*
* 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... | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) | ;
IWDG_SetPrescaler(IWDG_Prescaler_64); // ~8 seconds
IWDG_SetReload(0xfff);
IWDG_WriteAccessCmd(IWDG_WriteAccess_Disable);
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP, ENABLE);
}
void watchdog_start(void) {
IWDG_Enable();
watchdog_feed();
}
// This behaves differently from the bootloader and the firmware... |
/*
* 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 (node->next) {
node->next->prev = node->prev;
} |
if (node->prev) {
node->prev->next = node->next;
}
node->prev = NULL;
node->next = NULL;
}
ListNode* list_append(ListNode* node, ListNode* new_node) {
return list_insert_after(list_get_tail(node), new_node);
}
ListNode* list_prepend(ListNode* node, ListNode* new_node) {
return list_insert_before(list... |
/*
* 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 (compositing_mode == GCompOpTintLuminance) {
gcolor_tint_luminance_lookup_table_init(tint_color, tint_luminance_lookup_table);
} | |
urrent item in the list
//! }
#define FOREACH_VALID_ATTR(item) \
for (item = s_attr_head; item; item = NEXT_ATTR(item)) \
if (!item->deferred_delete)
// This file relies on the ServiceId/AttributeId being uint16_t as the protocol defines it as such.
_Static_assert(sizeof(SmartstrapServiceId) == sizeof(uint16_t... | (attr, SmartstrapAttributeStateRequestPending) | ;
return true;
} else if ((txn == AttributeTransactionBeginWrite) &&
(attr->state == SmartstrapAttributeStateIdle)) {
prv_set_attribute_state(attr, SmartstrapAttributeStateWritePending);
return true;
} else if ((txn == AttributeTransactionEndWrite) &&
(attr->state == Smartstrap... |
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 2) == 3) | ;
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 1) == 1);
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 4) == 12);
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 8) == 192);
cl_assert(raw_image_get_value_for_bitdepth(test1, 4, 1, 2, 2) == 3);
cl_assert(raw_image_get_valu... | |
>
#define CORE_NUMBER 0
static NORETURN handle_passert_failed_vargs(const char* filename, int line_number,
uintptr_t lr, const char* expr, const char* fmt, va_list fmt_args) {
char buffer[160];
pbl_log_sync(LOG_LEVEL_ALWAYS, filename, line_number, "*** ASSERTION FAILED: %s", expr);
if (fmt) {
vsniprin... | {
PBL_LOG(LOG_LEVEL_ALWAYS, "CROAK OOM: Failed to alloc %d bytes at LR: 0x%x",
bytes, saved_lr);
#ifdef MALLOC_INSTRUMENTATION
command_dump_malloc_kernel();
#endif
trigger_oom_fault(bytes, saved_lr, heap_ptr);
} | |
/*
* 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... | ("Up/Down to adjust\nSelect to proceed") | |
it to die.
SCB->BFAR &= 1 << 7; // Clear Bus Fault Address Register "address is valid" bit
SCB->MMFAR &= 1 << 7; // Clear Memory Manage Address Register "address is valid" bit
SCB->CFSR &= ~0; // Clear the complete status register
// Redirect this task to nowhere by changing the stacked PC register.
// We c... | mpu_get_region(MemoryRegion_TaskStackGuard) | |
quence animation
void test_animation__simple_sequence(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_b = 2;
int duration_total = duration_a + play_count_b * duration_b;
// Create 2 animations
Animation *a = prv_create_test_animation();
ani... | prv_count_handler_entries(&s_teardown_handler_calls, a) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 2);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 1);... |
-1248, 152, 176},
{ -1072, 792, -80},
{ -1144, 640, -120},
{ -1392, 472, -160},
{ -1408, 528, 72},
{ -1072, 360, 288},
{ -1072, -240, 336},
{ -1040, 240, 192},
{ -992, 72, 176},
// 102 seconds
{ -864, 80, 208},
{ -792, 72, 192},
{ -880, 72, 208},
{ -1024, -96, 192},
... | { -1360, 464, -40},
{ -1424, 424, 16},
{ -1496, 416, 72},
{ -1480, 208, 272},
{ -1256, 408, 200},
{ -1168, 280, 104},
{ -1152, 232, 192},
{ -1040, 176, 256},
{ -952, 152, 264},
{ -872, 136, 272},
{ -760, 152, 304},
{ -744, 224, 344},
{ -952, 328, 512},
{ -960, 272... |
{ -1328, 336, 192},
{ -1248, 352, 200},
{ -920, 264, 176},
{ -752, 160, 256},
{ -768, 208, 272},
{ -744, 208, 296},
// 110 seconds
{ -728, 208, 344},
{ -880, 312, 472},
{ -776, 224, 664},
{ -1344, 488, 400},
{ -1344, 104, 608},
{ -1128, 304, 424},
{ -1176, 392, 3... |
[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)"hello", 5);
cl_assert_equal_i(copied, 1);
cl_assert_equal_s((char *)dest, "h");
}
void test_utf8__copy_multibyte_char(void) {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)NIHAO, 5);
... | realloc(output_buffer, 5) | ;
cl_assert_passert(utf8_truncate_with_ellipsis("Hello", output_buffer, 6));
free(output_buffer);
}
|
= 0xFF) {
erased = false;
prompt_send_response_fmt(buffer, sizeof(buffer),
"(Sub)Sector at addr: 0x%"PRIX32" not really erased. is_subsector: %d",
addr, is_subsector);
goto done;
}
}
}
}
done:
return erased;
}
// ARG:
// 0 - Only show sec... | for (int i = 0; i < len; ++i) {
bit_number *= 10;
int next_digit = bit[i] - '0';
if (next_digit < 0 || next_digit > 9) {
prompt_send_response("invalid bit number");
return;
}
bit_number += next_digit;
} |
int bit_mask = 1 << bit_number;
if (value[0] == '0') {
boot_bit_clear(bit_mask);
} else if (value[0] == '1') {
boot_bit_set(bit_mask);
} else {
prompt_send_response("invalid bit value, pick 1 or 0");
return;
}
prompt_send_response("OK bit assigned");
}
typedef struct {
ButtonId button_... |
skParameters_t task_params = {
.pvTaskCode = main_task,
.pcName = "KernelMain",
.usStackDepth = kernel_main_stack_words,
.uxPriority = (tskIDLE_PRIORITY + 3) | portPRIVILEGE_BIT,
.puxStackBuffer = (void*)(uintptr_t)((uint32_t)__kernel_main_stack_start__
+ (u... | PBL_ASSERT(s_sjlj_num == 3, "SJLJ TRACK INCORRECT @ END") | |
f, "There are 04 lights, -04");
// Minimum digits output (zero digits)
snprintf(dstbuf, 256, "%.0izero%.0i", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.izero%.i", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum d... | snprintf(dstbuf, 256, "%hhu,%hu,%u,%lu", hurf, hurf, hurf, hurf) | ;
cl_assert_equal_s(dstbuf, "240,57072,2596069104,2596069104");
snprintf(dstbuf, 256, "%llu,%ju", hurf, hurf);
cl_assert_equal_s(dstbuf, "1311768467463790320,1311768467463790320");
snprintf(dstbuf, 256, "%zu,%tu", hurf, hurf);
cl_assert_equal_s(dstbuf, "2596069104,2596069104");
}
void test_sprintf__percent_o... |
phics_context_set_fill_color;
void graphics_context_set_fill_color(GContext* ctx, GColor color) {
record_mock_call(s_graphics_context_set_fill_color) {
.ctx = ctx, .color = color,
};
}
static MockCallRecordings s_graphics_context_set_stroke_color;
void graphics_context_set_stroke_color(GContext* ctx, GColor co... | {
// invalid cases
cl_assert_parsed_color("#", NULL);
cl_assert_parsed_color("##q3", NULL);
cl_assert_parsed_color("", NULL);
cl_assert_parsed_color("#00zz10", NULL);
cl_assert_parsed_color("#123456789", NULL);
// different lengths
cl_assert_parsed_color("#f00", &GColorRed);
cl_assert_parsed_color("#... | |
_dnd_should_override_scheduled(void) {
bool active;
// Time 00:00, Manual and Scheduled DND both OFF
DoNotDisturbSchedule schedule = {
.from_hour = 0,
.from_minute = 30,
.to_hour = 12,
.to_minute = 30,
};
active = do_not_disturb_is_active();
cl_assert(active == false); // both OFF
do_not_... | cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == true) | ;
cl_assert(do_not_disturb_is_manually_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == false); // Scheduled ON
}
void test_do_not_disturb__smart_dnd(void) {
bool active;
calendar_init();
cl_assert(do_not_disturb_is_smart_dnd_enabled() == false);
do_not_disturb_toggle_smart_... |
/*
* 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... | APP_LOG(APP_LOG_LEVEL_ERROR, "Exception while %s", message) | ;
jerry_char_t buffer[100] = {};
const ssize_t written = jerry_object_to_string_to_utf8_char_buffer(exception, buffer,
sizeof(buffer) - 1);
if (written > 0) {
APP_LOG(APP_LOG_LEVEL_ERROR, "%s", buffer);
} else {
APP_LOG(APP_LOG_LEVEL_... |
compositor_unfreeze();
s_screenshot_in_progress = false;
}
static void prv_request_fast_connection(CommSession *session) {
comm_session_set_responsiveness(session, BtConsumerPpScreenshot, ResponseTimeMin,
MIN_LATENCY_MODE_TIMEOUT_SCREENSHOT_SECS);
}
static uint32_t prv_framebu... | {
const ScreenshotHeader header = (const ScreenshotHeader) {
.response_code = SCREENSHOT_OK,
#if SCREEN_COLOR_DEPTH_BITS == 1
.version = htonl(1),
#elif SCREEN_COLOR_DEPTH_BITS == 8
.version = htonl(2),
#else
#warning "Need SCREEN_COLOR_DEPTH_BITS for screenshot version."
#endif
... |
comm_session_send_buffer_end_write(sb);
kernel_free(buffer);
prv_request_fast_connection(session);
system_task_add_callback(screenshot_send_next_chunk, state);
}
void screenshot_protocol_msg_callback(CommSession *session, const uint8_t* msg_data, unsigned int msg_len) {
uint8_t sub_command = msg_data[0];... |
estamp = 100 * SECONDS_PER_MINUTE,
.duration = 5,
.type = TimelineItemTypePin,
.all_day = false,
.layout = LayoutIdCalendar,
},
.attr_list = {
.num_attributes = 1,
.attributes = &title_attr,
},
};
// not a calendar pin
static TimelineItem s_weather_item = {
.header = {
.id = { 0x06,... | timeline_event_init() | ;
}
void test_timeline_peek_event__cleanup(void) {
timeline_peek_set_show_before_time(TIMELINE_PEEK_DEFAULT_SHOW_BEFORE_TIME_S);
timeline_event_deinit();
stub_new_timer_cleanup();
fake_settings_file_reset();
}
// Tests
////////////////////////////////////////////////////////////////
typedef struct AddEventPa... |
m();
// Don't need the GPIO peripheral clocks to be enabled anymore
gpio_release(PWR_CTL_GPIO);
gpio_release(DISP_GPIO);
}
// Clear-all mode is entered by sending 0x04 to the panel
void display_clear(void) {
prv_enable_display_access();
prv_display_write_byte(DISP_MODE_CLEAR);
prv_display_write_byte(0x00... | (digit, x_offset, y_offset, buffer) | ;
// Each character is 9px wide plus 2px of padding
x_offset += 11;
}
}
void display_error_code(uint32_t code) {
uint8_t buffer[DISP_ROWS][DISP_LINE_BYTES];
memset(buffer, 0x00, sizeof(buffer));
prv_draw_bitmap(dead_face_bits, 24, 32, dead_face_width, dead_face_height, buffer);
prv_draw_code(code,... |
TimelineResourceSizeTiny, SYSTEM_APP, &res_info);
return lookup_success ? res_info.res_id : (uint32_t)RESOURCE_ID_INVALID;
}
static void prv_weather_event_handler(UNUSED PebbleEvent *event, void *context) {
LauncherAppGlanceStructured *structured_glance = context;
LauncherAppGlanc... | (weather_glance->fallback_title, node->name, fallback_title_size) | ;
weather_glance->fallback_title[fallback_title_size - 1] = '\0';
const bool should_consider_slices = false;
LauncherAppGlanceStructured *structured_glance =
launcher_app_glance_structured_create(&node->uuid, &s_weather_structured_glance_impl,
should_consider_sli... |
/*
* 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... | regular_timer_remove_callback(&s_tick_timer_info) | ;
}
}
|
ff);
RCC->APB2ENR &= ~(0x01177933);
// Reset most peripherals used by the bootloader. We want to minimize the
// chances that the firmware unintentionally relies on some state that the
// bootloader leaves behind. This includes disabling the PLL.
// GPIOs are not reset here: resetting them would change their... | boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE) | ;
break;
case 4:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_TWO);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_THREE);
break;
case 5:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 6:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE... |
ng, 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 language governing permissions and
* limitations under the License.
*/
#include "apps/watch/kickstart/kickstart.h"
#include... | (&s_data.window, &s_ctx) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_kickstart__render_steps_below_typical(void) {
prv_set_data(&s_data, 5543, 6500, 8000, 0);
window_set_on_screen(&s_data.window, true, true);
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.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... | (s_stopwatch_list, (ListNode *)stopwatch) | ;
}
static uint32_t prv_rtc_ticks_to_ms(uint32_t rtc_ticks) {
return (uint32_t)(((uint32_t)rtc_ticks) * MS_PER_SECOND / configSYSTICK_CLOCK_HZ);
}
static uint32_t prv_stopwatch_elapsed_ms(AnalyticsStopwatchNode *stopwatch,
uint32_t current_ticks) {
// Even if current_ticks... |
CK_OFFSET;
}
layer_mark_dirty((Layer*) layer);
}
#define TIMELINE_NUM_REL_BARS (TIMELINE_NUM_VISIBLE_ITEMS + 1)
static void prv_update_rel_bars(TimelineLayer *layer) {
// Store prev, current, and next item relationship bar types
RelationshipBarType rel_bar_types[TIMELINE_NUM_REL_BARS];
layer->relbar_layer... | prv_get_overlap_line_length(layer, NULL, NULL) | |
/*
* 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... | i2c_release(EWD1000->i2c) | ;
}
static void prv_wait_for_interrupt(void) {
const RtcTicks timeout = rtc_get_ticks() + RTC_TICKS_HZ * INIT_TIMEOUT_S;
while (gpio_input_read(&EWD1000->int_gpio)) {
if (rtc_get_ticks() > timeout) {
PBL_CROAK("Touch controller didn't respond!");
}
}
}
// Status Register Operations
//////////////... |
((TestReelData*)kino_reel_custom_get_data(reel))->elapsed_ms = elapsed_ms;
return true;
}
static uint32_t prv_duration_getter(KinoReel *reel) {
return ((TestReelData*)kino_reel_custom_get_data(reel))->duration_ms;
}
static struct TestReelData *test_reel_data;
static KinoReelImpl *test_reel_impl = NULL;
static K... | animation_set_elapsed(test_player->animation, 20) | ;
animation_set_duration(test_player->animation, 300);
prv_play_animation_update(test_player->animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 20);
}
void test_kino_player__create_finite_animation_infinite_reel_forward(void) {
// Choose duration and elapsed to hav... |
n("newfile", OP_FLAG_WRITE, FILE_TYPE_STATIC, rd_len);
cl_assert(fd >= 0);
uint8_t buf[rd_len];
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
pfs_close(fd);
fd = pfs_open("newfile", OP_FLAG_READ, 0, 0);
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == rd_len);
rv = pfs_read(fd, ... | (sz == large_file_size) | ;
uint8_t *b = calloc(sz, 1);
cl_assert(pfs_read(fd, b, sz) == sz);
for (int j = 0; j < large_file_size / 4; j++) {
uint32_t *val = ((uint32_t *)((uint8_t *)b)) + j;
cl_assert(*val == (curr | (curr << 16)));
curr++;
}
cl_assert(pfs_close(fd) == S_SUCCESS);
free(b);
}
}
vo... |
400, 224, -232},
{ -1288, 352, -248},
{ -1160, 368, -128},
{ -1152, 424, -184},
{ -1088, 376, -96},
{ -976, 384, -144},
{ -1056, 488, -192},
{ -1056, 768, -80},
{ -1224, 736, -288},
{ -1296, 344, -160},
{ -920, 472, -328},
{ -1152, 480, -296},
{ -1536, 512, -200},
{ -... | { -1168, 136, -352},
{ -1080, 256, -512},
{ -920, 176, -480},
{ -1064, -40, -344},
{ -1216, -64, -224},
{ -1168, 96, -176},
{ -1016, 272, -96},
{ -888, 384, -136},
{ -896, 416, -136},
{ -928, 464, -184},
{ -904, 576, -320},
{ -992, 1056, -424},
{ -952, 816, -264},
... | |
if (data->action_menu == NULL) {
// If the user has an action menu open, then we don't want to refresh the pop timeout,
// as they are still interacting with the Notification stack
data->pop_timer_is_final = final;
data->pop_timer_id = evented_timer_register_or_reschedule(data->pop_timer_id, timeout,... | { // Android
// Show all actions unless the item has already been acted upon, in which case show none
return (!item->header.actioned &&
!item->header.dismissed &&
(data->is_modal ||
comm_session_has_capability(comm_session_get_system_session(),
... |
}
static bool prv_should_provide_action_menu_for_item(NotificationWindowData *data,
const TimelineItem *item) {
for (int i = 0; i < item->action_group.num_actions; i++) {
TimelineItemAction *action = &item->action_group.actions[i];
if (prv_should_show_acti... |
/*
* 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... | MIN(x2, x_max) | ;
if (!WITHIN(y, y_min, y_max) || x1 > x2) {
// Outside of drawing bounds..
return;
}
// Capture framebuffer & pass it to drawing implementation
GBitmap *framebuffer = graphics_capture_frame_buffer(ctx);
if (!framebuffer) {
// Couldn't capture framebuffer
return;
}
ctx->draw_state.draw_... |
/*
* 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(data != NULL && should_store != NULL && hdlc_error != NULL);
bool is_complete = false;
*hdlc_error = false;
*should_store = false;
if (*data == HDLC_FLAG) {
if (ctx->escape) {
// extra escape character before flag
ctx->escape = false;
*hdlc_error = true;
}
// we've ... | |
/*
* 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_equal_p(memchr(testbuf, 0xF78, 8), testbuf+3) | ;
}
|
if there is no item or it is an earlier item in the future direction
return ((uuid_is_invalid(&update->first_header.common.id)) ||
(timeline_item_time_comparator(&header->common, &update->first_header.common,
TimelineIterDirectionFuture) < 0));
}
static bool prv_p... | {
*time_type_out = TimelinePeekTimeType_None;
} |
return 0;
}
static int prv_peek_compare_and_save_next_timeout(
SerializedTimelineItemHeader *new_header, SerializedTimelineItemHeader *old_header,
void **context) {
const int rv = prv_peek_comparator(new_header, old_header, context);
CommonTimelineItemHeader *next_header = &((rv > 0) ? new_header : old_... |
ssion %u with tag %"PRIu32", type %u, size %hu",
msg->session_id, msg->logging_session_tag, msg->data_item_type, msg->data_item_size);
break;
}
case DataLoggingEndpointCmdData:
{
DataLoggingSendDataMessage *msg = (DataLoggingSendDataMessage *)message;
PBL_LOG_D(LOG_DOMAIN_DATA_LO... | uuid_is_system(&logging_session->app_uuid) | ) {
analytics_inc_for_uuid(ANALYTICS_APP_METRIC_LOG_OUT_COUNT, &logging_session->app_uuid);
analytics_add_for_uuid(ANALYTICS_APP_METRIC_LOG_BYTE_OUT_COUNT, data_buffer_length, &logging_session->app_uuid);
}
return true;
}
static void prv_dls_endpoint_handle_ack(uint8_t session_id) {
DataLoggingSession *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... | {
ActionMenuData *data = window_get_user_data(&action_menu->window);
if (data->config.will_close) {
data->config.will_close(action_menu,
data->performed_item,
data->config.context);
}
} |
static void prv_invoke_did_close(ActionMenu *action_menu) {
ActionMenuData *data = window_get_user_data(&action_menu->window);
if (data->config.did_close) {
data->config.did_close(action_menu,
data->performed_item,
data->config.context);
}
}
static void... |
{});");
cl_assert_equal_b(true, rocky_global_has_event_handlers("draw"));
}
void test_rocky_api_graphics__draw_event_has_ctx(void) {
rocky_global_init(s_graphics_api);
EXECUTE_SCRIPT(
"var event = null;\n"
"_rocky.on('draw', function(e) {event = e;});"
);
const jerry_value_t event_null = prv_js_glo... | (TRIG_MAX_ANGLE * 1 / 4, lc->fill_radial_precise.angle_start) | ;
cl_assert_equal_i(TRIG_MAX_ANGLE * 3 / 4, lc->fill_radial_precise.angle_end);
EXECUTE_SCRIPT(
"ctx.rockyFillRadial(30, 40, 10, 30, 0, 2 * Math.PI);\n"
);
cl_assert_equal_i(2, s_graphics_fill_radial_precise_internal.call_count);
cl_assert_equal_point_precise(PP(29.5, 39.5), lc->fill_radial_precise.cent... |
/*
* 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... | mfg_info_set_watch_color(WATCH_INFO_COLOR_RED) | ;
cl_assert_equal_i(mfg_info_get_watch_color(), WATCH_INFO_COLOR_RED);
mfg_info_set_watch_color(WATCH_INFO_COLOR_GREEN);
cl_assert_equal_i(mfg_info_get_watch_color(), WATCH_INFO_COLOR_GREEN);
}
void test_spalding_mfg_info__rtc_freq(void) {
cl_assert_equal_i(mfg_info_get_rtc_freq(), 0);
mfg_info_set_rtc... |
endif
}
static void prv_int_exti_cb(bool *should_context_switch) {
// The controller responded -- stop the watchdog.
prv_watchdog_stop();
switch (s_spi_transport.state) {
case SPITransportState_Idle:
// If the RX buffer is full, defer ack'ing the Dialog INT until we have
// some room to actually... | (LOG_LEVEL_INFO, "Skipping host transport enqueue .. waiting for reset") | |
ognizer/recognizer_impl.h"
#include "applib/ui/recognizer/recognizer_manager.h"
#include "applib/ui/recognizer/recognizer_private.h"
#include "util/size.h"
// Stubs
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_logging.h"
#include "test_recognizer_impl.h"
static bool s_manager_state_change ... | (r->state, RecognizerState_Failed) | ;
cl_assert_equal_i(event_type, -1);
// Test that invalid state transitions get caught by asserts
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Completed));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Started));
r->state = RecognizerState_Possible;
cl_assert_passert... |
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT W... | if (!ctx->config.impl->callbacks.set_state) {
return;
} |
const bool next_state = !ctx->enabled;
ctx->config.impl->callbacks.set_state(next_state, ctx->config.context);
ctx->enabled = next_state;
if (ctx->config.set_exit_reason) {
app_exit_reason_set(APP_EXIT_ACTION_PERFORMED_SUCCESSFULLY);
}
prv_vibe(next_state);
}
static void prv_handle_prompt_confirm(Clic... |
XPAND);
kino_reel_scale_segmented_set_delay_by_distance(new_reel, GPoint(0, icon_to.size.h / 2));
prv_change_reel(card_timeline_layout, new_reel);
kino_layer_play_section(&card_timeline_layout->icon_layer, duration / 2, duration);
kino_layer_set_callbacks(&card_timeline_layout->icon_layer, (KinoLayerCallbacks... | (icon_from.size.w, icon_from.size.h / 2) | );
prv_change_reel(card_timeline_layout, new_reel);
kino_layer_set_callbacks(&card_timeline_layout->icon_layer, (KinoLayerCallbacks) {
.did_stop = prv_card_to_pin_stopped,
}, pin_timeline_layout);
kino_layer_play(&card_timeline_layout->icon_layer);
// for now, use the card icon for the entire animation,... |
/*
* 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... | {
va_list argp;
va_start(argp, msg);
fprintf(stdout, "Bail out! ");
vfprintf(stdout, msg, argp);
va_end(argp);
} | |
l. This is temporary until we have better support to
// send the DLS data to a server and retrieve it from there. The record itself
// is about 112 bytes. Base64 encoded it becomes 112 * 4/3 = 150 bytes. That is too much
// to fit in a single log line, so we split it into 2.
uint32_t chunk_size ... | (&time_s, &time_ms) | ;
uint64_t timestamp = ((uint64_t)time_s) * MS_PER_SECOND + time_ms;
// Feed samples into the algorithm
prv_accel_cb(context->data, context->num_samples, timestamp);
kernel_free(context);
s_activity_state.pending_test_cb = false;
}
// ------------------------------------------------------------------------... |
ice_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 6);
cl_assert_equal_i(s_num_timeline_removes, 2);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm goes off. First one... | cron_service_wakeup() | ;
cl_assert_equal_i(s_num_alarms_fired, 1);
}
void test_alarm__delete_upcoming_alarm(void) {
AlarmId id1, id2;
id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
id2 = alarm_creat... |
;
s_process_manager_callback = async_cb;
s_process_manager_callback_data = ctx;
}
static int s_app_inbox_consume_call_count;
void app_inbox_consume(AppInboxConsumerInfo *consumer_info) {
++s_app_inbox_consume_call_count;
}
// Setup
////////////////////////////////////
void test_app_message__initialize(void) {
... | (s_out_sent_call_count, 1) | ;
// Check that the state is reset properly after everything
cl_assert_equal_b(app_message_is_accepting_outbound(), true);
}
void test_app_message__cancel_timer(void) {
prv_set_remote_receive_handler(prv_ack_sent_callback);
prv_send_test_data();
prv_call_outbox_sent(AppOutboxStatusSuccess);
prv_process_se... |
/*
* 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... | {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
} |
static void push_window(void) {
Window *window = window_create();
window_set_fullscreen(window, s_next_window_fullscreen);
window_set_window_handlers(window, (WindowHandlers) {
.unload = unload_handler,
});
window_set_click_config_provider(window, click_config_provider);
s_next_window_fullscreen = !s... |
rt_extra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
s_feb_5_midnight + 8 * SECONDS_PER_HOUR + 16 * SECONDS_PER_MINUTE), 0);
#if CAPABILI... | cl_assert(iter_next(&iterator)) | |
mp = midnight_march_3_utc,
.duration = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.layout = LayoutIdTest,
.all_day = 0, // this is a non-all-day event spanning 24h
},
};
cl_assert(timeline_add(&all_day_item));
Iterator iterator = {};
TimelineIterState state = {};
TimelineNode ... | cl_assert_equal_i(timeline_init(&head), S_SUCCESS) | ;
// 1425272400 is 21:00 March 1 2015 PST
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1425272400),
S_SUCCESS);
time_t midnight_march_2_pst = 1425283200;
// day 1
cl_assert(uuid_equal(&state.pin.header.id, &multiday_item.header.id));
cl_assert(uuid_equal(&... |
OG(LOG_LEVEL_DEBUG, "Overwriting SPRF field at offset %d, size %d",
(int)offset, (int)field_size);
// write the crc first so it's easier to detect a non empty field (we can just read if the CRC is
// not 0xFFFFFFFF instead of comparing all bytes.
*(uint32_t *)field = new_crc;
flash_write_bytes(field... | prv_unlock() | |
void __disabled_test_gap_le_connect__single_client_no_autoreconnect(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent for app:
gap_le_connect_connect(&device,
false /* no auto_reconnect */,
false /* is_pairing_required */,
... | fake_gap_le_put_cancel_create_event(&device, true /* is_master */) | ;
// Verify the app task got a (virtual) disconnection event:
prv_assert_client_event(&device, false /* connected */, (1 << PebbleTask_App),
GAPLEConnectHCIReasonExtensionCancelConnect);
// Verify there are no more intents:
cl_assert_equal_i(gap_le_connect_connection_intents_count(), ... |
0x05,
0x0a,
0x0f,
0x0b,
0x1b,
0x06,
0x07,
0x2b,
0x16,
0x17,
0x01,
0x02,
0x03,
0x13,
0x27,
0x12,
0x23,
0x3b,
0x26,
0x37,
0x11,
0x22,
0x33,
0x32,
0x36,
0x21,
0x31,
};
typedef enum {
PROPERTY_FG_COLOR,
PROPERTY_BG_COLOR,
PROPERTY_ALPHA,
// Add more above here
... | GPoint(point.x + 1, point.y) | );
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1));
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
} else if (alpha == ALPHA_66) {
graphics_context_set_stroke_color(ctx, fg_color);
graphics_draw_pixel(ctx, point);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
... |
d_connection(
BLECharacteristic characteristic_ref,
GAPLEConnection **connection);
extern SemaphoreHandle_t gatt_client_subscription_get_semaphore(void);
extern void gatt_client_subscription_cl... | gatt_client_subscriptions_get_notification_header(GAPLEClientApp, &header) | ;
cl_assert_equal_i(header.value_length, assert_value_length);
cl_assert_equal_i(header.characteristic, characteristic);
if (should_consume) {
uint16_t value_length = assert_value_length;
gatt_client_subscriptions_consume_notification(&characteristic_out, buffer, &value_length,
... |
atic const int RTC_SYNC_PRESCALER = 3;
static const unsigned int RTC_TICKS_HZ = 1024;
static const unsigned int TICKS_IN_INTERVAL = 60 * 60 * 24;
static uint32_t prv_get_asynchronous_prescaler(void) {
return (RTC->PRER >> 16) & 0x7f;
}
static uint32_t prv_get_synchronous_prescaler(void) {
return RTC->PRER & 0x1f... | prv_seconds_since_standby() | ;
int32_t saved_time = RTC_ReadBackupRegister(CURRENT_TIME_REGISTER);
// Correct the saved time with the number of seconds we've been in standby mode
saved_time += elapsed_since_standby;
// Save time in the backup register so the firmware can read it once it boots
RTC_WriteBackupRegister(CURRENT_TIME_REGIST... |
.type = PEBBLE_HEALTH_SERVICE_EVENT,
.health_event = {
.type = HealthEventSignificantUpdate,
.data.significant_update = {
.day_id = 0,
},
},
};
sys_send_pebble_event_to_kernel(&event);
return true;
#endif
}
// ------------------------------------------------------------------... | {
return 0;
} | else {
return HRM_MANAGER_APP_EXIT_EXPIRATION_SEC;
}
#endif
}
// ----------------------------------------------------------------------------------------------
uint32_t health_service_get_minute_history(HealthMinuteData *minute_data, uint32_t max_records,
time_t *time_... |
{
attribute_list_add_cstring(&attr_list, AttributeIdBody, config->body);
} |
if (config->icon_timeline_res_id != TIMELINE_RESOURCE_INVALID) {
attribute_list_add_resource_id(&attr_list, AttributeIdIconPin, config->icon_timeline_res_id);
}
attribute_list_add_uint8(&attr_list, AttributeIdDisplayTime, config->weather_time_type);
// Just need to put something here so our mocked clock_ge... | |
lineResourceSize res_size, GRect icon_from) {
kino_layer_set_reel(&peek_layer->kino_layer, NULL, false);
AppResourceInfo icon_res_info;
timeline_resources_get_id(timeline_res, res_size, &icon_res_info);
KinoReel *from_reel = kino_reel_create_with_resource_system(icon_res_info.res_app_num,
... | ((Layer *)&peek_layer->kino_layer, &layer_frame) | ;
if (grect_equal(&icon_from, &GRectZero)) {
icon_from = (GRect) {
.origin.x = layer_frame.origin.x + (layer_frame.size.w - size.w) / 2,
.origin.y = layer_frame.origin.y + (layer_frame.size.h - size.h) / 2,
.size = size,
};
}
if (to_reel && align_in_frame) {
GRect rect_to_align = { ... |
sh_start(void) {
gpio_use(FLASH_CONFIG.spi_gpio);
// Enable the GPIOA clock
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
uint8_t altfunc = GPIO_AF_SPI1;
// Connect pins to their SPI functionality
GPIO_PinAFConfig(FLASH_CONFIG.spi_gpio, FLASH_CONFIG.sclk_pin, altfunc);
GPIO_PinAFConfig(FLASH_CO... | (FLASH_CMD_WAKE) | ;
prv_flash_end_cmd();
// wait a sufficient amount of time to enter standby mode
// It appears violating these timing conditions can lead to
// random bit corruptions on flash writes!
delay_us(100);
}
static uint32_t prv_flash_whoami(void) {
prv_enable_flash_spi_clock();
prv_flash_wait_for_write_bounde... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.