prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
last 20
// samples (about one second).
// - Host reads any data/HRV-result/LED-current, as needed (see registers [14...53])
// - Host reads the HRM-result/SYNC-byte (registers [54...57]).
// If not in HRM-mode, the host can just read the SYNC-byte (register 57).
// Reading the SYNC-byte causes the... | PBL_LOG(LOG_LEVEL_DEBUG, " - None (idle)") | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_has_send_text_reply_action() | ;
}
void send_text_service_init(void) {
// Save the initial state
s_has_send_text_reply_action = prv_has_send_text_reply_action();;
// Register for updates
static EventServiceInfo s_blobdb_event_info = {
.type = PEBBLE_BLOBDB_EVENT,
.handler = prv_blobdb_event_handler,
};
event_service_client_subs... |
;
}
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 v... | dialog_spi_end_cmd() | |
/*
* 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... | (!pstring_equal(ps2, ps3)) | ;
cl_assert(!pstring_equal(ps1, NULL));
cl_assert(!pstring_equal(NULL, NULL));
}
void test_pstring__equal_cstring(void) {
const char *str1 = "Phil";
uint8_t ps1_buf[128];
PascalString16 *ps1 = (PascalString16 *)&ps1_buf;
ps1->str_length = strlen(str1);
memcpy(ps1->str_value, str1, strlen(str1));
cons... |
that. Try again."));
} else {
prv_show_generic_error_dialog(data);
}
} else {
if (!speech_detected) {
VOICE_LOG("No speech detected! Exiting...");
prv_exit_and_send_result_event(data, DictationSessionStatusFailureNoSpeechDetected);
} else {
prv_exit_and_send_result_event(data,... | prv_update_analytics_metrics(data) | ;
app_timer_cancel(data->dictation_timeout);
prv_handle_dictation_result(data, event);
}
break;
case StateTransitionToText:
case StateError:
case StateFinished:
case StateExiting:
// Discard event
VOICE_LOG("Ignoring event");
break;
default:
WTF;... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GPIO_Init(FLASH_CONFIG.spi_gpio, &gpio_cfg) | ;
// Configure the SCLK pin to have a weak pull-down to put it in a known state
// when SCS is toggled
gpio_cfg.GPIO_PuPd = GPIO_PuPd_DOWN;
gpio_cfg.GPIO_Pin = (1 << FLASH_CONFIG.sclk_pin);
GPIO_Init(FLASH_CONFIG.spi_gpio, &gpio_cfg);
// Configure SCS to be controlled in software; pull up to high when ina... |
44, 280, -48},
{ 904, 240, -8},
// 85 seconds
{ 704, 192, -48},
{ 640, 160, -32},
{ 648, 136, 16},
{ 776, 136, -8},
{ 864, 128, 24},
{ 1088, 136, -16},
{ 1136, 128, 0},
{ 1080, 96, 0},
{ 1304, 144, -64},
{ 1128, 120, 24},
{ 1168, 176, -56},
{ 1352, 200, -32},
... | { 1056, 336, -256},
{ 1304, 384, -232},
{ 1200, 384, -240},
{ 992, 336, -168},
{ 1032, 336, -168},
{ 1152, 312, -144},
{ 1112, 264, -80},
{ 904, 200, -56},
{ 728, 168, -64},
{ 640, 168, -72},
{ 664, 160, -32},
{ 752, 152, -8},
// 91 seconds
{ 864, 104, 0},
{ 1... | |
{ -936, 136, -152},
{ -936, 160, -176},
{ -944, 152, -176},
{ -928, 184, -184},
{ -936, 176, -160},
{ -920, 176, -168},
// 492 seconds
{ -920, 160, -176},
{ -936, 168, -160},
{ -936, 152, -144},
{ -952, 232, -144},
{ -960, 184, -128},
{ -944, 184, -208},
{ -928, 1... | { 352, 664, -768},
{ 368, 656, -744},
{ 376, 648, -760},
{ 376, 608, -768},
{ 440, 584, -688},
{ 616, 672, -1000},
{ 288, 1544, 0},
{ 200, 2096, -120},
{ 56, 848, 608},
{ -136, 1200, 432},
{ -120, 760, 368},
{ -192, 632, 360},
{ -272, 704, 352},
{ -312, 672, 296},... | |
_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_WKUP_IRQn;
// Lower values are higher priority - make this same or lower priority than a FreeRTOS ISR
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = (configMAX_SYSCALL_INTERRUPT_PRIORITY >> 4);
NVIC_InitStructure.NVIC_IRQChannelSubPrior... | window_init(data->window, "") | ;
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.
}
// ===========... |
tySession) {.start_utc = now, .length_min = 5},
&(ActivitySession) {.start_utc = now + (2 * SECONDS_PER_MINUTE), .length_min = 5},
HealthIterationDirectionPast));
}
void test_health__get_minute_history_edge_case_args(void) {
const time_t now = rtc_get_time();
HealthMinuteData data[5] = {};
uint32_t writ... | (0, s_sys_activity_get_minute_history_values.in[0].num_records) | ;
////////////
// start time almost on the next minute
s_sys_activity_get_minute_history_values.stage = 0;
const time_t time_almost_next_minute = time_on_boundary + 59;
// respects time_end, 2.5 minutes => 3 records
time_start = time_almost_next_minute;
time_end = time_start + (5 * SECONDS_PER_MINUTE / 2... |
test_column_width,
num_src_colors);
prv_prepare_canvas(ctx, bitmap_size);
// Fill the canvas so each column (of width hline_applying_test_column_width) is set to one of the
// different possible dest_colors
for (int16_t y = 0; y < bitmap_size.h; y++) {
for (int16_t column_... | {
// The initial transparency doesn't really matter since we're about to overwrite it
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparent);
cl_assert(mask);
const GSize mask_size = ctx->dest_bitmap.bounds.size;
for (int16_t y = 0; y < mask_size.h; y++) {
cons... |
typedef void (*VerticalClippingMaskApplyFunc)(GContext *ctx, int16_t x, int16_t y1, int16_t y2,
GColor color);
static void prv_mask_apply_vline_test_pattern(VerticalClippingMaskApplyFunc apply_func) {
GContext *ctx = s_ctx;
prv_prepare_canvas_for_vline_applying_test... |
{ -184, -48, -1008},
{ -176, -24, -976},
{ -136, -40, -968},
{ -152, -56, -1008},
{ -168, -56, -976},
{ -176, -24, -1000},
{ -168, -32, -1008},
{ -160, -72, -992},
{ -160, -72, -1000},
{ -152, -72, -1008},
{ -176, -56, -1000},
{ -160, -40, -992},
{ -176, -24, -1000},
... |
{ -160, -48, -1016},
{ -176, -56, -984},
{ -168, -32, -984},
{ -168, -32, -1000},
{ -176, -48, -1000},
{ -168, -56, -992},
{ -168, -40, -992},
{ -168, -40, -992},
{ -176, -48, -1000},
{ -184, -40, -1000},
{ -176, -32, -1000},
{ -168, -48, -984},
// 126 seconds
{ ... | |
t_layer, caller_id_font);
if (lines == 1) {
s_phone_ui_data->caller_id_text_layer.layer.bounds.origin.y = SINGLE_LINE_BOUND_OFFSET;
} else {
s_phone_ui_data->caller_id_text_layer.layer.bounds.origin.y = DOUBLE_LINE_BOUND_OFFSET;
}
s_phone_ui_data->caller_id_text_layer.layer.bounds.size.h =
lines *... | animation_sequence_create(upward, bounceback, NULL) | ;
s_phone_ui_data->call_status_animation = animation;
animation_schedule(animation);
#else
s_phone_ui_data->call_status_text_layer.layer.bounds.origin = GPointZero;
#endif
}
static void prv_update_call_time(void *unused) {
if (s_phone_ui_data == NULL) {
return;
}
if (layer_get_hidden(&s_phone_ui_data-... |
get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(-1)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[3]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[4]].head... | cl_assert(uuid_equal(&s_items[s_correct_order[4]].header.id,
&timeline_model_get_iter_state(2)->pin.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_get_iter_state(2) == timeline_model_get_iter_state_with_timeline_idx(4));
cl_assert(ti... |
nly modified the data at base_addr and left all other
// power-of-2 addresses with the data pattern in them. The write_initial_pattern() method
// will skip erasing a sector if all of the power of 2 addresses within it still have the
// data pattern, so only the first sector will end up being re-erased.
status ... | PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Invalid range") | ;
return FLASH_TEST_ERR_ADDR_RANGE;
}
// Erase sectors
flash_erase_sector_blocking(stress_addr1);
status = prv_read_verify_halfword(stress_addr1, 0xFFFF, FLASH_TEST_ERR_ERASE, false);
VERIFY_TEST_STATUS(status);
flash_erase_sector_blocking(stress_addr2);
status = prv_read_verify_halfword(stress_addr2... |
ut *layout) {
const AttributeList *attributes = layout->layout_layer.attributes;
const size_t num_vertical_nodes = 3;
GTextNodeVertical *vertical_node = graphics_text_node_create_vertical(num_vertical_nodes);
const bool is_future = (layout->info->scroll_direction == TimelineScrollDirectionDown);
const bool i... | {
LayoutNodeTextDynamicConfig secondary_config = {
.text.extent.node.type = is_peek ? LayoutNodeType_TextDynamic : LayoutNodeType_Text,
.update = prv_peek_time_text_update,
.buffer_size = ATTRIBUTE_SUBTITLE_MAX_LEN,
.text.style = LayoutContentSizeDefault,
.text.style_font = TextStyleFo... |
if (PBL_IF_ROUND_ELSE(is_fat && !has_secondary, false)) {
const int single_offset = 2;
const GFont numbers_font =
system_theme_get_font_for_default_size(TextStyleFont_TimeHeaderNumbers);
vertical_node->container.node.offset.y =
((is_future ? -1 : 1) * fonts_get_font_height(numbers_font))... |
ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, -40, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_outside_y(Layer* me, GContext* ctx) {
graphics_context_set_... | (&ctx, fb) | ;
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_outside_nx);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside_nx.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_te... |
, since stack is only 8192 bytes
static uint8_t buffer[MAX_CHUNK_SIZE];
uint32_t chunk_size;
for (uint32_t i = 0; i < firmware_length; i += chunk_size) {
chunk_size = MIN(MAX_CHUNK_SIZE, firmware_length - i);
flash_read_bytes(buffer, flash_new_fw_start + i, chunk_size);
if (!system_flash_write(FIRMWAR... | boot_bit_set(BOOT_BIT_NEW_FW_INSTALLED) | ;
}
bool switch_to_recovery_fw() {
dbgserial_putstr("Loading recovery firmware");
UpdateFirmwareResult result = update_fw(FLASH_REGION_SAFE_FIRMWARE_BEGIN);
bool recovery_fw_ok = true;
switch (result) {
case UPDATE_FW_SUCCESS:
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_clear(BO... |
ce 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 WARRANTIES OR CONDITIONS OF ANY KIND, either expr... | {
Window *window = s_main_window_data.window;
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(window, animated);
} |
static void deinit(void) {
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
}
}
//! Assumes that s_flash_lock is held.
static void prv_erase_resume(void) {
if (s_erase.suspended) {
status_t status = flash_impl_erase_resume(s_erase.address);
PBL_ASSERT(PASSED(status), "Erase resume failure: %" PRId32, status);
s_erase.suspended = false;
}
}
static void prv_erase_suspend_time... | flash_impl_get_sector_base_address(addr) | ,
.on_complete_cb = on_complete_cb,
.cb_context = context,
.expected_duration = is_subsector?
flash_impl_get_typical_subsector_erase_duration_ms() :
flash_impl_get_typical_sector_erase_duration_ms(),
};
stop_mode_disable(InhibitorFlash); // FIXME: PBL-18028
status_t status = is_subsec... |
/*
* 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... | comm_session_send_queue_consume(session, read_space) | ;
}
static bool s_is_current_task_send_next_task = false;
bool comm_session_is_current_task_send_next_task(CommSession *session) {
return s_is_current_task_send_next_task;
}
// Tests
///////////////////////////////////////////////////////////
static const uint16_t ENDPOINT_ID = 1234;
static const uint32_t TIMEOUT_... |
sad_watch(ERROR_STUCK_BUTTON) | ;
}
if (is_flash_broken()) {
sad_watch(ERROR_BAD_SPI_FLASH);
}
boot_bit_dump();
// If the recovery firmware crashed at start-up, the watch is now a
// $150 brick. That's life!
if (check_for_recovery_start_failure()) {
boot_bit_clear(BOOT_BIT_RECOVERY_START_IN_PROGRESS);
sad_watch(ERROR_CAN... | |
_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_pixel_inside_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_x_off... | (p.x + 5, p.y + 1) | |
const uint8_t *tx_bytes = NULL;
prv_lock();
uint16_t tx_bytes_available = circular_buffer_get_read_space_remaining(&s_tx_buffer);
if (tx_bytes_available) {
circular_buffer_read(&s_tx_buffer, tx_bytes_available, &tx_bytes, &tx_bytes_available);
}
uint8_t *rx_buffer_ptr = NULL;
uint16_t rx_bytes_avail... | HOST_TRANSPORT_DEBUG_LOG("Nothing to receive.") | ;
}
bool has_more_rx_data = (remote_status_in.bytes_sendable_count > rx_bytes_available);
bool should_continue_to_rx_data =
(has_more_rx_data && (local_status_out.bytes_receivable_count != 0));
if (has_more_rx_data && !should_continue_to_rx_data) {
HOST_TRANSPORT_DEBUG_LOG("Host Transport Receive Buf... |
subscription(s_device_b, true);
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_b));
prv_assert_permissions_ui_and_respond(true /* is_granted */);
cl_assert_equal_b(true, ble_hrm_is_sharing_to_connection(&s_conn_b));
prv_assert_event_service_subscribed(true);
cl_assert_equal_i(s_hrm_manager_... | (true /* is_granted */) | ;
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a));
}
void test_ble_hrm__decline_permission_dont_ask_again_even_after_reconnecting(void) {
bt_driver_cb_hrm_service_update_subscription(s_device_a, true);
// Decline:
prv_assert_permissions_ui_and_respond(false /* is_granted */);
// Unsu... |
p_buffer[i] != want) {
char err_buf[80];
prompt_send_response_fmt(err_buf, sizeof(err_buf), "FAIL at ADDR %d Got: %d Wanted %d",
(int)offset, (int)memmap_buffer[i], (int)want);
break;
}
}
}
// clean up
flash_erase_sector_blocking(TEST_ADDR);
if... | prompt_command_finish() | |
============================================
// Application Data
typedef struct {
Window *window;
SimpleMenuLayer *menu_layer;
SimpleMenuSection menu_section;
SimpleMenuItem menu_items[NUM_MENU_ITEMS];
} TestTimersAppData;
static TestTimersAppData *s_app_data = 0;
// =========================================... | {
PBL_LOG(LOG_LEVEL_INFO, "Forcing inf loop during core dump");
core_dump_test_force_inf_loop();
core_dump_reset(false /* don't force overwrite */);
} | else if (index == 8) {
PBL_LOG(LOG_LEVEL_INFO, "Forcing assert loop during core dump");
core_dump_test_force_assert();
core_dump_reset(false /* don't force overwrite */);
} else if (index == 9) {
PBL_LOG(LOG_LEVEL_INFO, "Calling core_dump FreeRTOS ISR");
s_call_core_dump_from_isr = true;
... |
t plugged_in = 0;
if (state->test_entry.version == 1) {
sscanf(token + strlen(token) + 1, "%d, 0x%x, %d", &steps, &orientation, &vmc);
} else if (state->test_entry.version == 2) {
sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d", &steps, &orientation, &vmc, &light);
} else if (stat... | sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.max) | ;
} else if (strcmp(token, "TEST_FORCE_SHUT_DOWN_AT") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.force_shut_down_at);
} else if (strcmp(token, "TEST_WEIGHT") == 0) {
sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight);
} else if (strcmp(token, "T... |
PADDING;
// Status text
const GRect call_status_text_rect = GRect(TEXT_MARGIN_WIDTH, style->status_pos_y,
width, style->status_height);
text_layer_init_with_parameters(&s_phone_ui_data->call_status_text_layer,
&call_status_text_rect, N... | prv_set_answer_window() | ;
}
void phone_ui_handle_call_end(bool call_accepted, bool disconnected) {
if (!s_phone_ui_data) {
PBL_LOG(LOG_LEVEL_ERROR, "Can't handle call end, UI isn't setup");
return;
}
prv_stop_ringing();
prv_stop_call_duration_timer();
// This must be called before prv_set_status_text, otherwise the text ... |
64, -952},
{ 48, 80, -936},
{ 48, 80, -944},
{ 32, 40, -912},
{ -24, 8, -952},
{ 64, 144, -920},
// 300 seconds
// elapsed: 5 minutes
{ 16, 8, -928},
{ 40, 136, -928},
{ 40, 120, -928},
{ 40, 56, -928},
{ 56, 160, -936},
{ 32, 88, -912},
{ 32, 104, -928},
{ 5... | ARRAY_LENGTH(samples) | |
s
// within 30ms~ of getting the handshake or else we'll lose PPG data). The other registers can
// be read at anytime before the next handshake, so it's ok to do this first.
prv_read_ppg_data(HRM, &data.ppg_data);
if (should_expect_samples) {
interval_timer_take_sample(&s_handshake_interval_timer);
}
... | (LOG_LEVEL_INFO, "AS7000 enabled! Protocol v%" PRIu8 ".%" PRIu8
", SW v%" PRIu8 ".%" PRIu8 ".%" PRIu8 ", HW Rev %" PRIu8,
info->protocol_version_major, info->protocol_version_minor,
HRM_SW_VERSION_PART_MAJOR(info->sw_version_major),
HRM_SW_VERSION_PART_MINOR(info->sw_version_ma... | ;
}
prv_log_running_apps(dev);
return true;
}
static bool prv_is_app_running(HRMDevice *dev, AS7000AppId app) {
uint8_t running_apps = 0;
if (!prv_read_register(dev, ADDR_APP_IDS, &running_apps)) {
return false;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Apps running: 0x%"PRIx8, running_apps);
if (app == AS7000Ap... |
er_timeout(timer_id) / 1000);
cl_assert(timeline_remove(&item1.header.id));
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 3);
cl_assert(!prv_get_calendar_ongoing());
cl_assert(!stub_new_timer_is_scheduled(timer_id));
}
void test_calendar__init_with_past_event(void) {
cl_a... | (fake_event_get_count(), 1) | ;
cl_assert(!prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get_next();
cl_assert(!stub_new_timer_is_scheduled(timer_id));
}
|
AlertMaskAllOn);
// Should not allow any notifications through while in low power
s_low_power_active = true;
cl_assert(!alerts_should_notify_for_type(AlertInvalid));
cl_assert(!alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_notify_for_type(AlertReminder));
cl_assert(!alerts_should_n... | (AlertPhoneCall) | );
cl_assert(!alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_vibrate_for_type(AlertMobile));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertMobile));
cl_assert(!... |
/*
* 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... | flash_region_erase_optimal_range(0, 0, 0, 0) | |
((t->tm_wday - t->tm_yday) % 7) + 7) % 7;
// Don't ask me, I didn't decide this.
if (wday == normal_compare || (YEAR_IS_LEAP(year) && wday == leap_compare)) {
return 53;
} else {
return 52;
}
}
static int prv_iso8601_adjust(const struct tm *t, int year) {
const int week = prv_iso8601_base_week(t);
... | if (left <= length) {
goto _out_of_size;
} |
if (i18nstr) {
sys_i18n_get_with_buffer(i18nstr, dest_str, length + 1);
} else {
memcpy(dest_str, cpystr, length);
}
dest_str += length;
left -= length;
break;
case 'A':
FMT_STRCOPY_I18N(time_locale->weekday[t->tm_wday % DAYS_PER_WEEK]);... |
" json_str = JSON.stringify(e.data);\n" // stringify again to make assert simple
" event = e;\n"
"});");
JS_VAR event_null = prv_js_global_get_value("event");
cl_assert_equal_b(true, jerry_value_is_null(event_null));
// Get 3x the same message in a row:
for (int j = 0; j ... | cl_assert_equal_b(fake_app_timer_is_scheduled(t), true) | ;
// Connect:
prv_simulate_transport_connection_event(true /* is_connected */);
prv_postmessageconnected_postmessagedisconnected_negotiate_to_open_session();
// Timer for the 3rd should be cancelled now:
cl_assert(EVENTED_TIMER_INVALID_ID == rocky_api_app_message_get_session_closed_object_queue_timer());
... |
if (!launcher_menu_layer || !launcher_menu_layer->data_source) {
return;
}
const MenuIndex new_selected_menu_index = MenuIndex(0, index);
menu_layer_set_selected_index(&launcher_menu_layer->menu_layer, new_selected_menu_index,
row_align, animated);
prv_play_glance_for_row(l... | (menu_layer) | );
launcher_app_glance_service_init(&launcher_menu_layer->glance_service,
LAUNCHER_MENU_LAYER_GENERIC_APP_ICON);
const LauncherAppGlanceServiceHandlers glance_handlers = (LauncherAppGlanceServiceHandlers) {
.glance_changed = prv_glance_changed,
};
launcher_app_glance_serv... |
{0};
jerry_string_to_utf8_char_buffer(value, (jerry_char_t *)str, sizeof(str));
#define HANDLE_CASE(identifer, value) \
if (strcmp(identifer, str) == 0) { \
*result = value; \
return true; \
}
HANDLE_CASE("left", GTextAlignmentLeft);
HANDLE_CASE("right", GTextAlignmentRight);
HANDLE_CAS... | {
return jerry_create_string_utf8((const jerry_char_t *)s_rocky_text_state.font_name);
} |
JERRY_FUNCTION(prv_measure_text) {
char *str_buffer;
ROCKY_ARGS_ASSIGN_OR_RETURN_ERROR(
ROCKY_ARG(str_buffer),
);
GContext *const ctx = rocky_api_graphics_get_gcontext();
const int16_t box_x = argc >= 2 ? (int16_t)jerry_get_int32_value(argv[1]) : 0;
const int16_t box_y = argc >= 3 ? (int16_t)jerr... |
w_data, id, true /* close am */);
}
}
static void prv_clear_stale_reminders(void *data) {
notifications_presented_list_each(prv_clear_if_stale_reminder, data);
}
static void prv_clear_stale_reminders_timer_cb(void *data) {
// This functionality only exists for popups (modal windows) which currently all
// run... | (item, action, NULL) | |
AppData *data) {
if (s_app_data->timeline_model.direction == TimelineIterDirectionPast) {
return TIMELINE_PAST_COLOR;
} else {
return TIMELINE_FUTURE_COLOR;
}
}
T_STATIC void prv_init_peek_layer(TimelineAppData *data) {
Window *window = &data->timeline_window;
PeekLayer *peek_layer = &data->peek_laye... | (item_layer->timeline_layout, pin_timeline_layout) | ;
}
#endif
// animate the timeline layer from the left
Layer *layer = &data->timeline_layer.layer;
GPoint from_origin = { -layer->bounds.size.w, 0 };
Animation *layer_in = (Animation *)property_animation_create_bounds_origin(layer, &from_origin,
... |
// _ _ _ _ _ _
// .... ____| |_| |_| |______________________| |_| |_| |_________ .....
//
// By using a FIFO of depth 1, the bma255 respects EST mode and will provide
// samples at a predictable interval and rate.
const bool use_fifo = (num_samples > 0);
if (use_f... | prv_conv_raw_to_12bit(raw_buf) | |
k, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle... | (prv_draw_rect_aa_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD)) | ;
#else
ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
#endif
setup_test(&context, true, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
#if PBL_COLOR
ASSERT_CALLED(graphics_circle_draw_stroked_aa(&context, GPoint(50, 50), 10, SW_OD... |
event = (PebbleHRMEvent) {
.event_type = HRMEvent_HRV,
.hrv = {
.ppi_ms = data->hrv_ppi_ms,
.quality = data->hrv_quality,
},
};
break;
case HRMFeature_LEDCurrent:
*event = (PebbleHRMEvent) {
.event_type = HRMEvent_LEDCurrent,
.led = {
... | // Only send BPM and HRV events if the sensor is stable
if (!stable_sensor && (feature == HRMFeature_BPM || feature == HRMFeature_HRV)) {
continue;
}
if (state->callback_handler) {
// For kernel BG subscribers, we only queue one event of each type (which is then
// dispat... |
prv_remove_and_free_subscription(expired_state);
}
}
// Update the HRM enable state. If no subscribers need an update for a while, we can turn off the
// HR sensor and set a timer to turn it on again later. To avoid this overhead on every callback,
// we only check it once every HRM_CHECK_SENSOR_DIS... |
al_len);
if (!read_response) {
*gatt_value_length = 0;
return BLEGATTErrorLocalInsufficientResources;
}
*read_response = (const ReadResponseData) {
.object_ref = data->obj_ref,
.length = val_len,
};
memcpy(read_response->value, resp->value, val_len);
if (s_read_responses[... | {
GAPLEConnection *connection;
const uint16_t att_handle = handle_getter(obj_ref, &connection);
if (!att_handle) {
ret_val = BTErrnoInvalidParameter;
goto unlock;
}
GattClientEventContext *data = prv_create_event_context(client);
if (!data) {
ret_val = BTErrnoNotEnoughResource... |
unlock:
bt_unlock();
return ret_val;
}
static BTErrno prv_write(uintptr_t obj_ref, const uint8_t *value, size_t value_length,
GAPLEClient client, HandleAndConnectionGetter handle_getter,
PebbleBLEGATTClientEventType subtype) {
BTErrno ret_val = BTErrnoOK;
bt_l... |
42 };
const size_t num_data = ARRAY_LENGTH(data);
const StatsBasicOp op =
(StatsBasicOp_Sum | StatsBasicOp_Average | StatsBasicOp_Min | StatsBasicOp_Max |
StatsBasicOp_Count | StatsBasicOp_Consecutive | StatsBasicOp_ConsecutiveFirst |
StatsBasicOp_Median);
struct {
int32_t sum;
i... | (test_cases) | ; i++) {
int32_t w_median = stats_calculate_weighted_median(test_cases[i].values,
test_cases[i].weights,
test_cases[i].num_values);
printf("W_Median test case: %d\n", (int)i);
cl_assert_equal_i(test... |
setting a play count of 0
void test_animation__basic_play_count_0(void) {
#ifdef TEST_INCLUDE_BASIC
const int duration_a = 300;
Animation *a = prv_create_test_animation();
animation_set_play_count(a, 0);
animation_set_duration(a, duration_a);
prv_clear_handler_histories();
animation_schedule(a);
uint64... | (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);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq),... |
nx_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_y_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&... | (&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 2, GCornersAll) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 3, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_orig... |
ry) {};
strcpy(entry->name, file_name);
head = list_insert_before(head, &entry->list_node);
}
mutex_unlock_recursive(s_pfs_mutex);
return (PFSFileListEntry *)head;
}
void pfs_delete_file_list(PFSFileListEntry *head) {
ListNode *node = (ListNode *)head;
ListNode *next;
while (node) {
next = node... | (curr_page, &next_page) | |
id *id = notifications_presented_list_relative(
notifications_presented_list_current(), rel_position);
// if no layers, don't return one
if (uuid_is_invalid(id)) {
return NULL;
}
NotificationType type = notifications_presented_list_get_type(id);
TimelineItem *item = task_zalloc_check(sizeof(Timel... | (10, item->header.duration) | * SECONDS_PER_MINUTE;
}
static void prv_clear_if_stale_reminder(Uuid *id, NotificationType type, void *cb_data) {
NotificationWindowData *window_data = cb_data;
if (type != NotificationReminder) {
return;
}
TimelineItem reminder;
if (S_SUCCESS != reminder_db_read_item(&reminder, id)) {
return;
}... |
en - 1) {
cl_assert(is_complete == true);
cl_assert(should_store == false);
} else {
cl_assert(is_complete == false);
cl_assert(should_store == true);
cl_assert(c == str[i]);
}
}
}
void test_hdlc__special_characters(void) {
// make sure the escape characters haven't changed
... | cl_assert(is_complete == false) | |
"IN 1 H", time_buf);
// June 10th 2015, 13:01:00 (T-00:59:00)
rtc_set_time(event_time - (59 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 59 MIN", time_buf);
// June 10th 2015, 13:01:59 (T-00:58:01)
rtc_set_time(ev... | rtc_set_time(event_time - SECONDS_PER_DAY + 1) | ;
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Fri, 12:00 PM", time_buf);
// June 11th 2015, 23:59:29 (T-12:00:31)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) - 31);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time... |
t++;
status = is_subsector? flash_impl_erase_subsector_begin(addr)
: flash_impl_erase_sector_begin(addr);
if (PASSED(status)) {
flash_impl_set_nvram_erase_status(is_subsector, addr);
mutex_unlock(s_flash_lock);
return (s_erase.expected_duration * 7 / 8);
} else {
stop_mode_... | {
uint32_t total_time_spent_waiting_ms = 0;
uint32_t remaining_ms = prv_flash_erase_start(
sector_addr, prv_blocking_erase_complete, NULL, is_subsector, 0);
while (remaining_ms) {
psleep(remaining_ms);
total_time_spent_waiting_ms += remaining_ms;
remaining_ms = prv_flash_erase_poll();
// ... |
// other locks while waiting for a flash operation to complete, leading to other tasks
// triggering their task watchdogs before this erase completes. Let's kick all watchdogs
// instead. The downside to this is that it may take us longer to detect another thread is
// stuck, but we should stil... |
vities());
// Start on known boundary
struct tm start_tm = {
// Jan 1, 2015, 5am
.tm_hour = 5,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
time_t utc_sec = mktime(&start_tm);
rtc_set_time(utc_sec);
const time_t time_elapsed = (20 * SECONDS_PER_MINUTE);
// Add a run session
Activi... | prv_set_median_hr_for_minutes(70 /* BPM */, 4 /* minutes */) | |
uring LSE failed
bool rtc_init(void) {
if (!prv_clocksource_lse_configure()) {
return false;
}
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForSynchro();
return true;
}
// Before entering standby we set the RTC to it's default time (Jan 1, 2000)
// here we calculate the secon... | if (prv_slow_mode()) {
// If we're already slowed down there is nothing to do
return;
} |
// Calculate the current time and then save it back into the backup register
int32_t last_save_time = RTC_ReadBackupRegister(CURRENT_TIME_REGISTER);
uint32_t last_save_ticks = RTC_ReadBackupRegister(CURRENT_INTERVAL_TICKS_REGISTER);
uint32_t ticks_since_save = prv_elapsed_ticks(last_save_ticks, prv_cur_ticks(... |
/*
* 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... | host_transport_deinit() | ;
hc_protocol_deinit();
}
void bt_driver_power_down_controller_on_boot(void) {
// Don't make any assumptions about the state of the BT chip on initial bootup. (since the code
// runs in RAM) If we want to be in airplane mode, power the chip on then off
BTDriverConfig config = { };
if (bt_driver_start(&config... |
recognizer, void *context) {
app_window_stack_pop(true);
}
static void prv_decline_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, prv_decline_click_handler);
}
static void prv_show_decline_dialog(DialogsData *data) {
ActionableDialog *actionable_dialog = actionable_dialog_crea... | ("Expandable Dialog") | ;
Dialog *dialog = expandable_dialog_get_dialog(expandable_dialog);
dialog_set_text(dialog, data->lorem_ipsum);
dialog_set_background_color(dialog, GColorLightGray);
dialog_set_icon(dialog, data->resource_id_25);
dialog_show_status_bar_layer(dialog, true);
expandable_dialog_set_header(expandable_dialog, "A... |
test_resources.h"
// access it directly just to test things out
#include "shell/system_app_registry_list.auto.h"
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
// Stub Includes
////////////////////////////////////
#include "stubs_activity.h"
#include "stubs_analytics.h"
#include "stubs_app_custom_ic... | {
return false;
} |
if (!app_install_entry_is_watchface(entry)) {
return false; // Only watchfaces
}
return true;
}
static bool everything_filter_callback(struct AppMenuDataSource *source, AppInstallEntry *entry) {
return true;
}
void test_app_menu_data_source__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs_... |
lor = GColorBlack,
.mode = StatusBarLayerModeClock,
};
GRect frame = window->layer.frame;
// window.frame.origin.y is 0 already (for 2.x compatibility reasons)
// see prv_adjust_drawing_state_for_legacy2_apps()
// so all we need to alter is the height of the frame
frame.size.h = STATUS_B... | {
if (overrides_back_button == window->overrides_back_button) {
return;
}
window->overrides_back_button = overrides_back_button;
} | |
/*
* 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... | (data->normalized, ANIMATION_NORMALIZED_MAX, data->duration) | ;
}
static uint32_t prv_get_duration(KinoReelTransformData *data) {
uint32_t duration = data->duration;
if (data->from_reel) {
const uint32_t from_duration = kino_reel_get_duration(data->from_reel);
// If we don't have a 'to_reel' then we are looping back to the 'from_reel' so it's okay for
// the 'fro... |
/*
* 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_(timingr != I2C_TIMINGR_INVALID_VALUE, "timingr == I2C_TIMINGR_INVALID_VALUE") | ;
cl_assert_equal_i((timingr >> 28) + 1, expected_prescaler);
cl_assert_equal_i((timingr & 0xFF) + 1, expected_scl_low);
cl_assert_equal_i(((timingr >> 8) & 0xFF) + 1, expected_scl_high);
cl_assert_equal_i(((timingr >> 20) & 0xF) + 1, expected_scl_delay);
}
void test_i2c_timingr__valid_no_prescaler_no_rise_fal... |
ORES
VibeScore *vibe_score;
#endif
} AlarmPopupData;
AlarmPopupData *s_alarm_popup_data = NULL;
static void prv_stop_animation_kernel_main_cb(void *callback_context) {
if (s_alarm_popup_data) {
dialog_set_icon((Dialog *) s_alarm_popup_data->alarm_popup,
RESOURCE_ID_ALARM_CLOCK_LARGE_STATI... | action_bar_layer_init(action_bar) | ;
action_bar_layer_set_background_color(action_bar, GColorBlack);
s_alarm_popup_data->action_bar_snooze =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_SNOOZE);
s_alarm_popup_data->action_bar_dismiss =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_X);
action_bar_layer_set_icon... |
prv_count_handler_entries(&s_setup_handler_calls, 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_stopped_handler_calls, a), 0);
cl_assert(prv_count_handler_entries(&s_update_handler_calls, a)
>= test_duration/MIN_FRA... | prv_count_handler_entries(&s_started_handler_calls, b) | |
ze_tuplets(callback, context, tuplets, tuplets_count);
}
static const uint8_t NULL_TUPLE_BUFFER[sizeof(Tuple) + sizeof(uint32_t)] = { 0 };
const Tuple * const NULL_TUPLE = (const Tuple * const) NULL_TUPLE_BUFFER;
static uint8_t* dict_copy(DictionaryIterator* iter) {
size_t size = dict_size(iter);
uint8_t* buf = t... | (dest_iter) | ;
if (orig_buffer == NULL) return DICT_MALLOC_FAILED;
DictionaryIterator orig_iter;
DictionaryResult result = dict_init(&orig_iter, orig_buffer, dict_size(dest_iter));
if (result != DICT_OK) goto cleanup;
result = dict_write_begin(dest_iter,
(uint8_t*)dest_iter->dictionary,
... |
0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the Lic... | {
FontHashTableEntry table_entry;
Codepoint hash_entry_offset = s_font_md_size[version] + table_id * sizeof(FontHashTableEntry);
// find which bucket the codepoint was put into TODO: cache hash table?
PBL_LOG_D(LOG_DOMAIN_TEXT, LOG_LEVEL_DEBUG,
"HTE read: table_id:%d, cp:%"PRIx32", offset:... |
PBL_LOG_D(LOG_DOMAIN_TEXT, LOG_LEVEL_DEBUG, "HT read: offset: %zx, bytes: %zu", offset,
num_bytes);
SYS_PROFILER_NODE_START(text_render_flash);
sys_resource_load_range(font_res->app_num, font_res->resource_id, offset,
(uint8_t *)font_cache->offsets_buffer_4_4, num_bytes);
... |
ondition will only trip on the last run).
// But, other parts of the system rely on the cursor being set properly at the end of this iteration.
if (it->cursor.index.row < num_rows_in_section - 1 || it->cursor.index.section < num_sections - 1) {
it->cursor.y += it->cursor.sep;
}
++(it->cu... | {
GDrawState prev_state = graphics_context_get_drawing_state(ctx);
const GRect *bounds = &bg_layer->bounds;
ctx->draw_state.drawing_box.origin.y = bounds->origin.y;
ctx->draw_state.drawing_box.size.h = bounds->size.h;
MenuLayerDrawBackgroundCallback draw_background_cb = menu_layer->callbacks.draw_background... | |
WindowTransitionRoundImplementation *implementation =
(WindowTransitionRoundImplementation *)context->implementation;
Window *window_to = context->window_to;
if (window_to) {
// move framebuffer by amount of pixels the window_to moves
// => gives impression of a moving window_from
const int16_t new_... | (animation, PORT_HOLE_TRANSITION_DURATION_MS) | |
/*
* 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... | (dialog, NULL, false) | ;
uint16_t len = strlen(text);
dialog->is_buffer_owned = true;
dialog->buffer = applib_malloc(len + 1);
strncpy(dialog->buffer, text, len + 1);
text_layer_set_text(&dialog->text_layer, dialog->buffer);
}
void dialog_set_text_buffer(Dialog *dialog, char *buffer, bool take_ownership) {
if (dialog->buffer && ... |
alize the I2C peripheral.
//! Always lock the bus and peripheral config access before enabling it
static void prv_bus_enable(I2CBus *bus) {
// Don't power up rail if the bus is already in use (enable can be called to reset bus)
if (bus->state->user_count == 0) {
prv_bus_rail_power_up(bus);
}
prv_bus_pins_... | {
static const int WAIT_DELAY = 10; // milliseconds
if (i2c_hal_is_busy(bus)) {
delay_ms(WAIT_DELAY);
if (i2c_hal_is_busy(bus)) {
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for bus %s to become non-busy", bus->name);
return false;
}
}
return true;
} |
//! Set up and start a transfer to a bus, wait for it to finish and clean up after the transfer
//! has completed
static bool prv_do_transfer(I2CBus *bus, TransferDirection direction, uint16_t device_address,
uint8_t register_address, uint32_t size, uint8_t *data,
... |
GattClientEventContext *data = prv_create_event_context(client);
if (!data) {
ret_val = BTErrnoNotEnoughResources;
goto unlock;
}
// Zero'd out and added to list in `prv_create_event_context`
data->client = client;
data->subtype = subtype;
data->obj_ref = obj_ref;
ret_val = bt_... | list_foreach(&s_client_event_ctxs[client]->node, prv_deinit_ctx_list, NULL) | ;
s_client_event_ctxs[client] = NULL;
ReadResponseData *read_response = s_read_responses[client];
while (read_response) {
ReadResponseData *next_read_response = (ReadResponseData *) read_response->node.next;
kernel_free(read_response);
read_response = next_read_response;
}
s_read_... |
));
}
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_global_get_value("event");
cl_assert_equal_b(true, jerry_value_is_null(ev... | 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.center);
cl_assert_equal_i(10*8, lc->fill_radial_precise.radius_inner.raw_value);
... |
/*
* 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 (true) {
uint16_t write_space = circular_buffer_get_write_space_remaining(&q->circular_buffer);
if (write_space >= q->item_size) {
// Just write a zero for a semaphore
const uint8_t semph_data = 0;
const uint8_t *data = q->is_semph ? &semph_data : (const uint8_t *) pvItemToQueue;
c... |
}
QueueHandle_t xQueueGenericCreate(unsigned portBASE_TYPE uxQueueLength,
unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType) {
uint16_t item_size;
const bool is_semph = (ucQueueType == queueQUEUE_TYPE_BINARY_SEMAPHORE);
if (is_semph) {
item_size = 1;
} else {
... |
nt_callbacks(SettingsData *data) {
PBL_ASSERTN(data && data->callbacks);
return data->callbacks;
}
// Menu appearance helpers
//////////////////////////
static void prv_set_sub_menu_colors(GContext *ctx, const Layer *cell_layer, bool highlight) {
if (highlight) {
graphics_context_set_fill_color(ctx, SETTING... | status_bar_layer_set_colors(status_layer, GColorWhite, GColorBlack) | ;
status_bar_layer_set_separator_mode(status_layer, OPTION_MENU_STATUS_SEPARATOR_MODE);
layer_add_child(&data->window.layer, status_bar_layer_get_layer(status_layer));
GRect bounds = grect_inset(data->window.layer.bounds, (GEdgeInsets) {
.top = STATUS_BAR_LAYER_HEIGHT,
.bottom = PBL_IF_RECT_ELSE(0, STATU... |
{
prv_log_consume_random(logging_sessions[i], item_size, num_bytes);
} |
}
}
// ----------------------------------------------------------------------------------------
// Filling up the file system. We should be limited to creating DLS_MAX_DATA_BYTES worth
// of storage
void test_data_logging__fill_quota(void) {
const int item_size = 1;
const int num_sessions = 5;
DataLoggingSes... | |
/*
* 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_id, &entry) | ) {
continue;
}
cb(&entry, context);
}
}
typedef struct {
uint8_t count;
AppInstallId *app_ids;
} WakeupUICbData;
static void prv_show_dialog(void *context) {
WakeupUICbData *data = context;
const char* missed_text_raw =
i18n_noop("While your Pebble was off wakeup events occurred for:\... |
ode));
if (!subscription) {
// OOM
return BTErrnoNotEnoughResources;
}
// Initialize it:
*subscription = (const GATTClientSubscriptionNode) {
.characteristic = characteristic_ref,
.att_handle = att_handle,
};
// Prepend to the list of subscriptions of the connection:
... | while (subscription) {
GATTClientSubscriptionNode *next_subscription =
(GATTClientSubscriptionNode *) subscription->node.next;
// If subscribed, unsubscribe:
if (subscription->subscriptions[client] != BLESubscriptionNone) {
prv_subscribe(subscription->chara... |
return false /* should_stop */;
}
void gatt_client_subscriptions_cleanup_by_client(GAPLEClient client) {
bt_lock();
{
// Walk all the connections to find subscriptions to unsubscribe:
gap_le_connection_find(prv_cleanup_subscriptions_for_client, (void *)(uintptr_t) client);
}
bt_unlock();
}
// -----... |
!= NULL) {
jerry_cleanup();
rocky_runtime_context_deinit();
}
fake_pbl_malloc_check_net_allocs();
}
static const RockyGlobalAPI *s_graphics_api[] = {
&GRAPHIC_APIS,
NULL,
};
#define PP(x, y) \
GPointPrecise((int16_t)(((x)) * FIXED_S16_3_FACTOR), \
(int16_t)(((y)) * FIXED_S16_3_FACTO... | (2, s_gpath_draw_filled.call_count) | |
icense at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific la... | (&(*config)->info) | ;
task_free(*config);
*config = NULL;
}
|
cursor,
payload_end,
buffer,
buf_end);
}
// -----------------------------------------------------------------------------
static int prv_get_serialized_action_group_size(TimelineItem... | {
PBL_ASSERTN(buffer != NULL);
uint8_t *buf_start = buffer;
uint8_t *buf_end = buffer + buffer_size;
if (attr_list) {
buffer += attribute_list_serialize(attr_list, buffer, buf_end);
}
if (group_ptr) {
buffer = prv_serialize_group_element(type, group_ptr, buffer, buf_end);
}
return buffer - bu... | |
/*
* 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... | (scroll_layer, GSize(window->layer.bounds.size.w,
max_size.h + vert_scroll_padding)) | ;
scroll_layer_add_child(scroll_layer, &text->layer);
InverterLayer *inverter = &data->inverter;
inverter_layer_init(inverter, &GRect(15, 15, 30, 30));
scroll_layer_add_child(scroll_layer, &inverter->layer);
layer_add_child(&window->layer, &scroll_layer->layer);
}
static void push_window(ScrollAppData *da... |
tif_time,
ActivitySession *session,
int32_t avg_hr,
int32_t *hr_zone_time_s) {
if (session->length_min <= 0) {
return;
}
ActivityInsigh... | if (prv_get_sleep_state() != ActivitySleepStateAwake) {
INSIGHTS_LOG_DEBUG("Not adding session pin - asleep");
return;
} | |
keTransport *transport = (FakeTransport *) kernel_malloc(sizeof(FakeTransport));
*transport = (const FakeTransport) {
.destination = destination,
.sent_cb = sent_cb,
};
if (app_uuid) {
transport->app_uuid = *app_uuid;
}
s_fake_transport_head = (FakeTransport *) list_prepend((ListNode *) s_fake_tra... | ((Transport *) fake_transport) | |
wenty_four_hour_relative(void) {
char time_buf[64];
const int jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 12th 2015, 12:00
// Now + two days
const int event_time = jun10th_noon_2015 + (2 * SECONDS_PER_DAY);
// if the event is in 2... | cl_assert_equal_s("IN 12 H", time_buf) | ;
// June 12th 2015, 00:30:00 (T-11:30:00)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) + (30 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 11 H", time_buf);
// June 12th 2015, 00:30:01 (T-11:29:59)
rtc_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... | (FLASH_BASE, 0, NULL, NULL) | );
cl_assert_equal_i(0, erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte(void) {
cl_assert(system_flash_erase(FLASH_BASE, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sec... |
ac[1] - v_ab[1] * v_ac[0];
// solve for d
plane_eq[3] = -(plane_eq[0] * s_samples[0][0] +
plane_eq[1] * s_samples[0][1] + plane_eq[2] * s_samples[0][2]);
// Distance^2 = (a * xo + b * yo + c * zo + d) / (a^2 + b^2 + c^2)
int64_t distance = ABS((plane_eq[0] * s_samples[idx_pt][0] +
plane_eq[1] * s_... | if (!pt_to_plane_dist_under_thresh(0, 1, 2, 3, thresh)) {
return (MagCalStatusNoSolution);
} |
}
// the sample has passed its distance threshold check so add it
PBL_LOG(LOG_LEVEL_DEBUG, "---> [%d] Adding %d %d %d \n",
s_sample_idx, (int)sample[0], (int)sample[1], (int)sample[2]);
s_sample_idx++;
if (s_sample_idx != 4) {
return (MagCalStatusNoSolution); // we need 4 pts before we can do a 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... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("off_screen_left_aa_clipping"))) | ;
};
void test_framebuffer_clipping__off_screen_right_aa_clipping(void) {
cl_assert_equal_i(GBITMAP_NATIVE_FORMAT, GBitmapFormat8BitCircular);
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, true, 1);
cl_assert_equal_i(ctx.dest_bitmap.in... |
()));
}
void test_pfs__get_size(void) {
cl_assert(pfs_get_size() == (ftl_get_size() - SECTOR_SIZE_BYTES));
}
void test_pfs__migration(void) {
// reset the flash
fake_spi_flash_cleanup();
fake_spi_flash_init(0, 0x1000000);
extern void ftl_force_version(int version_idx);
pfs_init(true);
ftl_force_version... | ("test", OP_FLAG_WRITE, FILE_TYPE_STATIC, size) | ;
cl_assert(fd >= 0);
cl_assert(test_scan_for_last_written() >= 0);
}
extern void test_force_reboot_during_garbage_collection(uint16_t start_page);
extern void pfs_reset_all_state(void);
void test_pfs__reboot_during_gc(void) {
pfs_format(true);
pfs_reset_all_state();
pfs_init(false);
const int pages_to_... |
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 License for the specific ... | blob_db_get_dirty_list(BlobDBIdTest) | ;
cl_assert(dirty_list == NULL);
blob_db_util_free_dirty_list(dirty_list);
char *keys[] = { "key1", "key2", "key3", "key4", "key5" };
int key_len = strlen(keys[0]);
char *values[] = { "val1", "val2", "val3", "val4", "val5" };
int value_len = strlen(values[0]);
// insert all keys
for (int i = 0; i < AR... |
t successfully sent a read request, so should move to ReadInProgress to prepare to
// read the response. We do this here to ensure we don't miss any bytes of the response due to
// KernelBG not getting scheduled quickly enough.
PBL_ASSERTN(!mbuf_get_next(&s_header_mbuf));
mbuf_append(&s_header_m... | (SmartstrapStateReadReady) | ;
return SmartstrapResultBusy;
}
} else {
accessory_use_dma(false);
smartstrap_fsm_state_set(SmartstrapStateReadReady);
if (!mbuf_iterator_is_finished(&s_send_info.mbuf_iter)) {
// The write was not successful, so return an error
return SmartstrapResultBusy;
}
}
return Smart... |
uint32_t max_elapsed_ticks) {
uint16_t pages_to_find = (file_size + PFS_PAGE_SIZE) / PFS_PAGE_SIZE;
uint16_t free_page = 0;
uint32_t start_ticks = rtc_get_ticks();
uint16_t last_written_page = s_last_page_written;
while ((pages_to_find > 0) && (free_page != INVALID_PAGE)) {
mutex_lock_rec... | { // do we need to find a free page
if ((rv = find_free_page(&next_page, use_gc_allocator, true)) != S_SUCCESS) {
unlink_flash_file(start_page); // on failure, unallocate
return (rv);
}
pg_hdr.next_page_crc = crc8_next_page(next_page);
pg_hdr.next_page = next_page;
write_pg... | else {
write_pg_header(&pg_hdr, curr_page);
break; // we are done
}
}
// we have succesfully allocated space for the file, so add file specific info
f->start_page = f->curr_page = start_page;
FileHeader file_hdr;
memset(&file_hdr, 0xff, sizeof(file_hdr));
file_hdr.file_namelen = strlen(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... | if (consumer_out) {
*consumer_out = responsible_consumer;
} | |
apps, 1 default watchface, 1 default worker
#define DO_NOT_EVICT_LIST_SIZE (NUM_BUTTONS + 2)
static PebbleRecursiveMutex *s_app_cache_mutex = NULL;
//! Actual data structure stored in flash about an app cache entry
typedef struct PACKED {
time_t install_date;
time_t last_launch;
uint32_t total_size;
u... | if (prv_is_in_list(id, data->do_not_evict, DO_NOT_EVICT_LIST_SIZE)) {
priority = MAX_PRIORITY;
} | |
/*
* 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... | (Uint32ListSize(max_num_items)) | ,
.max_num_items = max_num_items,
.max_item_string_size = max_item_string_size,
};
return metric;
}
void metric_group_destroy(MetricGroup *metric_group) {
if (!metric_group) {
return;
}
task_free(metric_group->names);
task_free(metric_group->values);
task_free(metric_group->icons);
task_fre... |
ine_res_id) {
TimelineResourceInfo timeline_res = {
.res_id = timeline_res_id,
};
AppResourceInfo icon_res_info;
timeline_resources_get_id(&timeline_res, s_phone_ui_data->style->icon_size, &icon_res_info);
const ResourceId resource = icon_res_info.res_id;
KinoReel *image = kino_reel_create_with_resourc... | if ((name[0] == '-') || (length == 0)) {
return false;
} |
for (size_t i = 0; i < length; ++i) {
unsigned char chr = name[i];
if ((chr != '(') && (chr != ')') && (chr != '+') && (chr != ' ') && (chr != '-') && (chr != '.')
&& !isdigit(chr)) {
return false;
}
}
return true;
}
static bool prv_has_long_name(GFont font) {
// Figure out if it's ... |
AlarmOperationCallback)(AlarmId id, AlarmConfig *config, void *context);
static void prv_alarm_operation(AlarmId id, AlarmOperationCallback callback, void *context) {
SettingsFile file;
if (!prv_file_open_and_lock(&file)) {
return;
}
AlarmConfig config;
bool rv = prv_alarm_get_config(&file, id, &config)... | (scheduled_days, &config.scheduled_days, DAYS_PER_WEEK) | ;
cleanup:
prv_file_close_and_unlock(&file);
return rv;
}
// ----------------------------------------------------------------------------------------------
void alarm_set_enabled(AlarmId id, bool enable) {
SettingsFile file;
if (!prv_file_open_and_lock(&file)) {
return;
}
AlarmConfig config;
bool r... |
,
{ "'%R')", 3607, true,
"1:00",
8,
},
{ "'%R')", -3666, true,
"-1:01",
7,
},
// Advanced %T tests
{ "'%0T')", 3666, true,
"01:01:06",
1,
},
{ "'%uT')", 3666, true,
"1 hour, 1 minute, and 6 seconds",
1,
},
{ "'%aT')", 3666, true,
"1 hr 1 min 6 sec",
1,
},
... | printf("%s\n", s_error_strings[s_error.status]) | ;
}
#endif
cl_assert_equal_i(s_error.status, test->expect_status);
cl_assert_equal_i(err_index, test->expect_index);
}
cl_assert_equal_s(s_output, test->expect_str);
cl_assert_equal_i(s_cond.eval_time, test->expect_eval_time);
#if DEBUG_PRINTING
printf("\n");
#endif
}
}
//////////... |
/*
* 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... | (BT_CONN_MGR_INACTIVITY_TIMEOUT_SECS) | ;
state = conn_mgr_get_latency_for_le_connection(&s_hdl, &secs_to_wait);
cl_assert_equal_i(state, ResponseTimeMiddle);
cl_assert_equal_i(secs_to_wait, 30 - BT_CONN_MGR_INACTIVITY_TIMEOUT_SECS);
cl_assert_equal_i(fake_gap_le_connect_params_get_last_requested(), ResponseTimeMiddle);
// removing all consumers ... |
static const PropertyAnimationImplementation implementation = {
.base = {
.update = (AnimationUpdateImplementation) property_animation_update_gpoint,
},
.accessors = {
.setter = { .gpoint = (const GPointSetter) prv_gpoint_setter, },
.getter = { .gpoint = (const GPointGetter) prv_gpoint_g... | (test_value, GTransformIdentity()) | |
ert_ack_count(1);
assert_nack_count(0);
cl_assert_equal_i(EXPECTED_COOKIE, put_bytes_get_index());
}
void test_put_bytes__init_nack_upon_oom(void) {
fake_malloc_set_largest_free_block(1024); // PutBytes allocates ~2K
prv_receive_init(1024 * 1024, ObjectFirmware);
fake_malloc_set_largest_free_block(~0);
... | (event.put_bytes.type, PebblePutBytesEventTypeProgress) | ;
cl_assert_equal_i(event.put_bytes.object_type, ObjectFirmware);
cl_assert_equal_i(event.put_bytes.bytes_transferred, sizeof(chunk));
cl_assert_equal_i(event.put_bytes.progress_percent, 100 * sizeof(chunk) / VALID_OBJECT_SIZE);
cl_assert_equal_b(event.put_bytes.failed, false);
}
static uint32_t s_next_value_t... |
nothing to flush yet
}
bool success = false;
uint8_t *buffer = kernel_malloc_check(DLS_ENDPOINT_MAX_PAYLOAD);
unsigned int num_bytes = DLS_ENDPOINT_MAX_PAYLOAD;
PBL_ASSERTN(logging_session->item_size <= num_bytes);
num_bytes -= (num_bytes % logging_session->item_size);
uint32_t new_read_offset;
int32... | {
kernel_free(session->data->buffer_storage);
} |
// All the lock/unlock session calls are made from privileged mode, so it is impossible
// for the task to exit with the session locked (open_count > 0)
PBL_ASSERTN(session->data->open_count == 0);
session->status = DataLoggingStatusInactive;
// Free up the data and mutex for this sessi... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_WEEKENDS }) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.