prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (chunk_size) | ;
if (!*buffer) {
PBL_LOG(LOG_LEVEL_WARNING, "Insufficient memory for a large CRC buffer, going slow");
chunk_size = 128;
*buffer = kernel_malloc_check(chunk_size);
}
return chunk_size;
}
uint32_t flash_crc32(uint32_t flash_addr, uint32_t num_bytes) {
void *buffer;
unsigned int chunk_size = prv_... |
/*
* 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... | fake_rtc_init(0 /* initial_ticks */, utc_sec) | ;
// Setup graphics context
framebuffer_init(&s_fb, &DISP_FRAME.size);
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(fal... |
!= NULL) {
analytics_set(ANALYTICS_APP_METRIC_FLASH_READ_COUNT, analytics_read_count, AnalyticsClient_Worker);
analytics_set(ANALYTICS_APP_METRIC_FLASH_READ_BYTES_COUNT, analytics_read_bytes_count, AnalyticsClient_Worker);
analytics_set(ANALYTICS_APP_METRIC_FLASH_WRITE_BYTES_COUNT, analytics_write_bytes_co... | flash_send_and_receive_byte(FLASH_CMD_DEEP_SLEEP) | ;
flash_end_cmd();
// guarantee we have actually transitioned to deep sleep
delay_us(5);
s_flash_state.deep_sleep = true;
}
}
static void flash_deep_sleep_exit(void) {
assert_usable_state();
if (s_flash_state.deep_sleep) {
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD_WAKE);
... |
_bitmap->bounds) - 1)) {
// keep correct bounds alignment for circular when tiling
src_x = src_bitmap->bounds.origin.x +
((src_x - src_bitmap->bounds.origin.x) % src_bitmap->bounds.size.w);
} else {
// Increment source but don't draw
continue;
}
... | (&src_bitmap->bounds) | |
{
QEMU_LOG_DEBUG("Sending data:");
QEMU_HEXDUMP(data, len);
while (len--) {
uart_write_byte(QEMU_UART, *data++);
}
uart_wait_for_tx_complete(QEMU_UART);
} |
// -----------------------------------------------------------------------------------------
void qemu_serial_send(QemuProtocol protocol, const uint8_t *data, uint32_t len) {
if (!s_qemu_state.initialized) {
return;
}
mutex_lock(s_qemu_state.qemu_comm_lock);
// Send the header
QemuCommChannelHdr hdr ... | |
("Unsupported options") | ;
}
return 0;
}
struct tm tm;
prv_tm_from_js_date(this_val, &tm);
const char *strftime_format = prv_strftime_format(format, is_24h_style);
const size_t str_len = strftime(buffer, buffer_len, strftime_format, &tm);
const bool strip_leading_char = buffer[0] == '0' && prv_strip_leading_zero(format, ... | |
/*
* 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... | {
// No userspace buffer assertion for ctx needed, because it won't be accessed by the kernel.
PebbleEvent event = {
.type = PEBBLE_CALLBACK_EVENT,
.callback = {
.callback = async_cb,
.data = ctx,
},
};
const PebbleTask task = pebble_task_get_current();
PBL_ASSERTN(task == PebbleTask_... |
DEFINE_SYSCALL(uint32_t, sys_process_events_waiting, PebbleTask task) {
return process_manager_process_events_waiting(task);
}
DEFINE_SYSCALL(void, sys_event_service_client_subscribe, EventServiceInfo *handler) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(handler, sizeof(*handler));
}
... |
bounds->end);
if (is_string_empty) {
return;
}
const GTextOverflowMode overflow_mode = text_box->overflow_mode;
bool is_ellipsis_on_overflow = (overflow_mode == GTextOverflowModeTrailingEllipsis ||
overflow_mode == GTextOverflowModeFill);
if (is_ellipsis_on_overflow) {
... | (ctx, text, font,
box, overflow_mode, alignment, NULL) | ;
return size.h;
}
GSize graphics_text_layout_get_max_used_size(GContext *ctx, const char *text, GFont const font,
const GRect box, const GTextOverflowMode overflow_mode,
const GTextAlignment alignment,
... |
l_i(s_stopped_handler_calls.num_calls, 1);;
cl_assert(s_stopped_handler_calls.entries[0].fired_time_ms - start_ms >= duration);
cl_assert(s_stopped_handler_calls.entries[0].context == context);
cl_assert(s_stopped_handler_calls.entries[0].finished);
// ---------------------------------------------------------... | (num_loops, s_custom_curve_call_count) | ;
// -------------------------------------------------------------------------------------------
// Test the int16 accessor functions
int16_t test_value;
property_animation_get_from_int16(prop_h, &test_value);
cl_assert_equal_i(test_value, start_value);
property_animation_get_to_int16(prop_h, &test_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... | time_get_gmtoffset() | / 60;
return true;
}
|
_transition_state(r, RecognizerState_Updated);
cl_assert_equal_i(r->state, RecognizerState_Updated);
cl_assert_equal_i(event_type, RecognizerEvent_Updated);
cl_assert(!s_manager_state_change);
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Failed));
cl_assert_passert(recognizer_transition_st... | cl_assert_equal_b(sub_destroyed, true) | |
_count(window_stack), 1);
window_stack_pop(window_stack, true);
cl_assert_equal_i(window_stack_count(window_stack), 0);
window_destroy(window);
}
void test_window_stack__basic_window_pop(void) {
Window *window1 = window_create();
Window *window2 = window_create();
// Switch to app state to push windows... | cl_assert_equal_i(window2->on_screen, true) | ;
app_window_stack_pop(true);
cl_assert_equal_i(app_window_stack_count(), 0);
cl_assert_equal_i(window2->on_screen, false);
window_destroy(window1);
window_destroy(window2);
}
// Description:
// During the push of a window, we push another window in the load handler of
// the window being pushed. This ca... |
/*
* 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... | {
// NOTE: THIS IS RUN WITHIN AN ISR
switch (s_input_state) {
case AccessoryInputStateSmartstrap:
return smartstrap_handle_data_from_isr((uint8_t)c);
case AccessoryInputStateIdle:
case AccessoryInputStateMic:
// fallthrough
default:
break;
}
return false;
} | |
/*
* 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... | {
uint32_t read = 0;
flash_read_bytes((uint8_t *)&read, i, sizeof(read));
if (read != 0xffffffff) {
PBL_LOG_SYNC(LOG_LEVEL_INFO, ">>>> Address 0x%lx failed to erase: 0x%lx", i, read);
success = false;
}
} |
return success;
}
// region: region to check (and possibly write)
// use_rand: write random values
// perform_writes: perform writes if true, else see if the region reads as 0
static bool check_region_write(struct Region region, bool use_rand,
bool perform_writes) {
bool success = true;
uint32_t write_rand... |
head_and_emit_error_event_and_own_json_buffer(void) {
DBG("postmessageerror event");
OutgoingObject *old_head = s_state.out.object_queue;
char *const json_data_buffer = old_head->data_buffer;
// Don't free the JSON data buffer, ownership is about to be passed to the error event.
prv_object_queue_pop_head(fal... | {
prv_start_session_closed_object_queue_timer();
} |
}
return jerry_create_undefined();
}
////////////////////////////////////////////////////////////////////////////////
// Rocky boilerplate
////////////////////////////////////////////////////////////////////////////////
static void prv_init_apis(void) {
memset(&s_state, 0, sizeof(s_state));
// Pebble comm ... |
DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &clear_layer_update_callback);
layer_render_tree(&layer, &ctx);
#if SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_pixel_clear.8bit.pbi"));
#else
cl_check(framebuffer_is_empty("clear_over_black", ctx.parent_framebuffer, GColorWhite)... | (ctx, GPoint(1, 15)) | ;
// Right boundary
graphics_draw_pixel(ctx, GPoint(19, 5));
graphics_draw_pixel(ctx, GPoint(20, 10));
graphics_draw_pixel(ctx, GPoint(21, 15));
// Top boundary
graphics_draw_pixel(ctx, GPoint(5, -1));
graphics_draw_pixel(ctx, GPoint(10, 0));
graphics_draw_pixel(ctx, GPoint(15, 1));
// Bottom bound... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | NULL_SAFE_FIELD_ACCESS(settings_glance, icon, NULL) | ;
}
static const char *prv_get_title(LauncherAppGlanceStructured *structured_glance) {
LauncherAppGlanceSettings *settings_glance =
launcher_app_glance_structured_get_data(structured_glance);
return NULL_SAFE_FIELD_ACCESS(settings_glance, title, NULL);
}
static void prv_charging_icon_node_draw_cb(GContext *... |
}
static void prv_display_end_write(void) {
prv_display_write_byte(0x00);
prv_disable_display_access();
}
// Round a bit offset to a byte offset
static unsigned prv_round_to_byte(unsigned x) {
return (x + 7) >> 3;
}
// Draw bitmap onto buffer.
static void prv_draw_bitmap(const uint8_t *bitmap, unsigned x_of... | prv_draw_bitmap(pebble_logo_bits, 16, 64, pebble_logo_width, pebble_logo_height, buffer) | ;
prv_draw_bitmap(empty_bar_bits, x_offset, y_offset, empty_bar_width, empty_bar_height, buffer);
for (unsigned y = 0; y < inner_bar_height; y++) {
for (unsigned x = 0; x < num_pixels; x++) {
// Add 1 to offsets so we don't write into outer box
prv_set_bit(x + x_offset + 1, y_offset + y + 1, buff... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_ERROR, "Failed to malloc buffer for 'mic start' command") | ;
return;
}
uint32_t width = s_is_8_bit ? 8 : 16;
uint32_t rate = s_is_8khz ? 8 : 16;
PBL_LOG(LOG_LEVEL_ALWAYS, "Starting mic recording: %"PRIu32"-bit @ %"PRIu32"kHz for %"PRIu32
" samples", width, rate, (s_timeout / (MIC_SAMPLE_RATE / (rate * 1000))));
PROFILER_INIT;
PROFILER_START;
if (!... |
econds
{ 784, -120, -464},
{ 832, -96, -424},
{ 800, -112, -432},
{ 928, -168, -456},
{ 1328, -184, -520},
{ 1384, -208, -512},
{ 1000, -248, -408},
{ 824, -112, -512},
{ 976, 48, -568},
{ 1144, -80, -408},
{ 1112, -168, -328},
{ 1016, -120, -304},
{ 984, -128, -264},... | { 152, -360, -960},
{ 256, -296, -920},
{ 128, -192, -840},
{ 112, -120, -848},
{ 176, -136, -912},
{ 168, -160, -880},
{ 184, -128, -896},
{ 96, -184, -856},
{ 64, -128, -896},
{ 48, -48, -944},
{ 8, -64, -952},
{ 0, -56, -944},
{ -8, -16, -968},
{ -64, 16, -992}... |
{ 256, 304, -856},
{ 248, 280, -840},
{ 224, 288, -840},
{ 224, 296, -856},
{ 216, 280, -864},
{ 280, 352, -1024},
{ 416, 392, -1048},
{ 384, 272, -944},
{ 312, 168, -776},
{ 232, 192, -712},
{ 304, 248, -808},
{ 432, 312, -912},
{ 584, 256, -856},
{ 424, 136, -7... |
bool start_is_down = false;
int16_t *intersections_up = NULL;
int16_t *intersections_down = NULL;
rot_points[0] = rot_end = rotate_offset_point(&path->points[0], path->rotation, &path->offset);
min_x = max_x = rot_points[0].x;
min_y = max_y = rot_points[0].y;
// begin finding the last path segment's dir... |
// draw the line segments
for (int j = 0; j < MIN(intersection_up_count, intersection_down_count); j++) {
int16_t x_a = intersections_up[j];
int16_t x_b = intersections_down[j];
if (x_a != x_b) {
if (x_a > x_b) {
swap16(&x_a, &x_b);
}
cb(ctx, i, (Fixed_S16_3)... | }
cleanup:
applib_free(rot_points);
applib_free(intersections_up);
applib_free(intersections_down);
}
void gpath_fill_precise_internal(GContext *ctx, GPointPrecise *points, size_t num_points) {
if (!points) {
return;
}
// Convert precise points to normal points and draw filled path with converted poin... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&ctx, fb) | ;
// Big circles
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, STROKE_BIG);
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_origin_aa_r16_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_R... |
,
{ 1241, 399, 103},
{ 1100, 360, 140},
{ 947, 310, 163},
{ 874, 242, 172},
{ 855, 198, 201},
{ 886, 183, 212},
{ 814, 175, 175},
{ 788, 174, 183},
{ 915, 149, 238},
{ 1039, 154, 232},
{ 1115, 232, 126},
{ 1322, 256, 143},
{ 1123, 323, 18},
{ 1127, 478, -186},
... | { 845, 186, 167},
{ 847, 161, 178},
{ 734, 141, 145},
{ 808, 150, 160},
{ 1027, 134, 227},
{ 1055, 173, 183},
{ 1223, 258, 92},
{ 1421, 287, 146},
{ 1111, 390, -62},
{ 995, 421, -137},
{ 983, 313, 37},
{ 954, 259, 82},
{ 876, 227, 62},
{ 823, 267, 71},
{ 809, ... |
{ 871, 411, -1},
{ 837, 365, -32},
{ 786, 287, -49},
{ 973, 255, -24},
{ 1297, 304, 38},
{ 1236, 387, 20},
{ 1254, 510, -49},
{ 1399, 688, -48},
{ 1147, 463, 101},
{ 1164, 421, 79},
{ 1175, 369, 124},
{ 1028, 324, 168},
{ 910, 229, 183},
{ 853, 198, 178},
{ 8... |
i, BOARD_CONFIG_DISPLAY.spi_clk);
power_tracking_start(PowerSystemMcuSpi2);
}
static void prv_disable_display_spi_clock() {
periph_config_disable(BOARD_CONFIG_DISPLAY.spi, BOARD_CONFIG_DISPLAY.spi_clk);
power_tracking_stop(PowerSystemMcuSpi2);
}
static void prv_enable_chip_select(void) {
gpio_output_set(&BOAR... | {
if (xSemaphoreTake(s_dma_update_in_progress_semaphore, 0) == pdPASS) {
xSemaphoreGive(s_dma_update_in_progress_semaphore);
return false;
}
return true;
} |
void display_update(NextRowCallback nrcb, UpdateCompleteCallback uccb) {
PBL_ASSERTN(nrcb != NULL);
PBL_ASSERTN(uccb != NULL);
stop_mode_disable(InhibitorDisplay);
xSemaphoreTake(s_dma_update_in_progress_semaphore, portMAX_DELAY);
analytics_stopwatch_start(ANALYTICS_APP_METRIC_DISPLAY_WRITE_TIME, AnalyticsC... |
shared_circular_buffer__one_client(void) {
SharedCircularBuffer buffer;
uint8_t storage[9];
shared_circular_buffer_init(&buffer, storage, sizeof(storage));
const uint8_t* out_buffer;
uint16_t out_length;
// Add a client
SharedCircularBufferClient client = (SharedCircularBufferClient) {};
shared_circul... | (&buffer, &client1, 4) | );
cl_assert(memcmp(out_buffer, "1234", 4) == 0);
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(shared_circular_buffer_read(&buffer, &client2, 4, &out_buffer, &out_length));
cl_assert(shared_circular_buffer_consume(&buffer, &client2, 4));
cl_assert(memcmp(out_buf... |
/*
* 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... | {
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
s_preferred_content_size = PreferredContentSizeMedium;
} |
void test_rocky_api_preferences__cleanup(void) {
if (app_state_get_rocky_runtime_context() != NULL) {
jerry_cleanup();
rocky_runtime_context_deinit();
}
}
void test_rocky_api_preferences__unknown(void) {
s_preferred_content_size = (PreferredContentSize) -1;
rocky_global_init(s_preferences_api);
EX... |
witch (message[0]) {
case DataLoggingEndpointCmdClose:
{
DataLoggingCloseSessionMessage *msg = (DataLoggingCloseSessionMessage *)message;
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Closing session %d", msg->session_id);
break;
}
case DataLoggingEndpointCmdOpen:
{
Da... | (sb, data, num_bytes) | ;
comm_session_send_buffer_end_write(sb);
dls_endpoint_print_message((uint8_t *) &header, num_bytes);
DLS_HEXDUMP(data, MIN(num_bytes, 64));
logging_session->comm.num_bytes_pending = num_bytes;
update_session_state(logging_session, DataLoggingSessionCommStateSending, true /*reschedule*/);
mutex_unlock(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... | cl_assert(!ble_ad_includes_service(s_ad_data, &missing_uuid)) | ;
// Test ble_ad_copy_service_uuids, destination array sized larged enough:
const uint8_t count = 4;
Uuid copied_uuids[count];
uint8_t found = ble_ad_copy_service_uuids(s_ad_data, copied_uuids, count);
cl_assert_equal_i(found, 1);
// Test ble_ad_copy_service_uuids, destination array too small:
found = b... |
/*
* 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_update_text() | |
_SESSION_MAX_BUFFERED_ITEM_SIZE);
chunk_size -= (chunk_size % item_size);
}
PBL_ASSERTN(chunk_size <= num_bytes);
data_logging_log(logging_session, buf, chunk_size / item_size);
fake_system_task_callbacks_invoke_pending();
buf += chunk_size;
num_bytes -= chunk_size;
}
}
// -------------... | (logging_sessions[i]) | ;
}
// Log Consume
for (int i = 0; i < 10; i++) {
prv_log_consume_random(logging_sessions[i], item_size, rand() % 16);
}
}
// ----------------------------------------------------------------------------------------
void test_data_logging__log_consume_large_items(void) {
DataLoggingSessionRef logging_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... | gcolor_equal(color1, color2) | |
it_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);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO);
break;
case 7:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
... | system_hard_reset() | ;
}
periph_config_disable(PWR, RCC_APB1Periph_PWR);
}
static void prv_print_bootloader_version(void) {
char bootloader_version_str[12];
memset(bootloader_version_str, 0, 12);
itoa_hex(boot_version_read(), bootloader_version_str, 12);
dbgserial_putstr(bootloader_version_str);
dbgserial_putstr("");
dbgse... |
tate->subsample_numerator);
ask_for = ask_for / state->subsample_numerator * state->subsample_numerator;
PBL_ASSERTN(state->num_samples + ask_for <= state->raw_buffer_size);
num_samples = accel_consume_data(state->raw_buffer + state->num_samples, // buffer
... | {
return samples_per_update + 1;
} |
// -------------------------------------------------------------------------------------------
DEFINE_SYSCALL(int, sys_accel_manager_set_sample_buffer, AccelSessionRef session,
AccelRawData *buffer, uint32_t buffer_size, uint32_t samples_per_update) {
int result = 0;
if (samples_per_update > ACCEL... |
ensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under ... | (process_name, sizeof(process_name), id, PebbleTask_App) | ;
pfs_remove(process_name);
// remove resources
resource_storage_clear(id);
}
bool app_storage_app_exists(AppInstallId id) {
PBL_ASSERTN(id > 0);
char process_name[APP_FILENAME_MAX_LENGTH];
// check app binary first
app_storage_get_file_name(process_name, sizeof(process_name), id, PebbleTask_App);
int... |
/*
* 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 CAPABILITY_COMPOSITOR_USES_DMA && !TARGET_QEMU && !UNITTEST
compositor_dma_init();
#endif
const GSize fb_size = GSize(DISP_COLS, DISP_ROWS);
framebuffer_init(&s_framebuffer, &fb_size);
framebuffer_clear(&s_framebuffer);
s_state = CompositorState_App;
s_deferred_render = (DeferredRender) {
.anim... |
// Helper functions to make implementing transitions easier
///////////////////////////////////////////////////////////
void compositor_app_framebuffer_fill_callback(GContext *ctx, int16_t y,
Fixed_S16_3 x_range_begin, Fixed_S16_3 x_range_end,
... |
/*
* 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... | (second, 5) | ;
}
}
|
/*
* 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... | ("2147483647") | , 2147483647); // last valid value
cl_assert_equal_i(atoi("4294967287"), (int)4294967287); // signed integer overflow
// ((2147483648 * 10) + 1) & 0xFFFFFFFF
cl_assert_equal_i(atoi("21474836481"), 1);
// ((2147483647 * 10) + 1) & 0xFFFFFFFF
cl_assert_equal_i(atoi("21474836471"), (int)4294967287);
// -1 * ((... |
tatic bool prv_call_data_callback(AccelSubscriberState *state) {
switch (state->task) {
case PebbleTask_App:
case PebbleTask_Worker:
case PebbleTask_KernelMain: {
PebbleEvent event = {
.type = PEBBLE_CALLBACK_EVENT,
.callback = {
.callback = state->data_cb_handler,
... | PBL_LOG(LOG_LEVEL_WARNING, "not subscribed") | |
em/version.h"
#include <bluetooth/reconnect.h>
#include "FreeRTOS.h"
#include "task.h"
static const uint32_t FORCE_QUIT_HOLD_MS = 1500;
static int s_back_hold_timer = TIMER_INVALID_ID;
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
PebbleEvent event = {
.type = PEBBLE_CALLBACK_EVE... | {
// Chances are the Pebble of our dear customer has been charging away
// from the phone and is disconnected because of that. Try reconnecting
// immediately upon disconnecting the charger:
bt_driver_reconnect_reset_interval();
bt_driver_reconnect_try_now(false /*ignore_paused*/... |
#if STATIONARY_MODE
stationary_handle_battery_connection_change_event();
#endif
return;
}
case PEBBLE_BATTERY_STATE_CHANGE_EVENT:
battery_monitor_handle_state_change_event(e->battery_state.new_state);
#if CAPABILITY_HAS_MAGNETOMETER
ecompass_handle_battery_state_change_event(e->battery... |
e op_3, we use a profiler timer node called "framebuffer_send". This profiler timer
measures the amount of time we spend waiting for a display DMA to complete.
op_1 can be computed from the app's update period - op_2_time
*/
static void prv_pop_all_windows_cb(void *cb_data) {
AppData *data = (AppData *)cb_data;
... | layer_get_bounds(root_layer) | ;
const GRect full_rect = bounds;
data->background_layer = bitmap_layer_create(full_rect);
bitmap_layer_set_background_color(data->background_layer, GColorBlack);
bitmap_layer_set_bitmap(data->background_layer, &s_fps_background_bitmap);
layer_add_child(root_layer, (Layer *)data->background_layer);
data->... |
_c));
t_c = GTransformTranslationFromNumber(2, 5);
cl_assert(gtransform_is_equal(&t, &t_c));
// Test Rotation Matrix
int32_t angle = DEG_TO_TRIGANGLE(45);
t = GTransformRotation(angle);
int32_t cosine = cos_lookup(angle);
int32_t sine = sin_lookup(angle);
t_c = GTransform(GTransformNumberFromNumber(... | GTransformNumberFromNumber(10) | , GTransformNumberFromNumber(200));
cl_assert(gtransform_is_equal(&t_new, &t_c));
cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has not changed
gtransform_translate_number(&t_new, &t1, 10, 200);
cl_assert(gtransform_is_equal(&t_new, &t_c));
cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has ... |
/*
* 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... | {
dls_list_for_each_session(command_dls_list_cb, 0);
} |
// Unused, comment out to avoid pulling in the string literals
#if 0
void command_dls_show(const char *id) {
uint8_t session_id = strtol(id, NULL, 0);
DataLoggingSession *logging_session = dls_list_find_by_session_id(session_id);
if (logging_session == NULL) {
prompt_send_response("LoggingSession not found... |
now_utc, sleep_exit_utc, sleep_total_seconds);
INSIGHTS_LOG_DEBUG("Not adding sleep pin - already checked session %ld", sleep_exit_utc);
return;
}
// Insert or update the pin
INSIGHTS_LOG_DEBUG("Adding sleep pin");
prv_push_sleep_summary_pin(now_utc, sleep_exit_utc, sleep_enter_seconds, sleep_exit_seco... | (&dismiss_action_attr_list, AttributeIdTitle,
i18n_get("Dismiss", ¬if_attr_list)) | ;
AttributeList open_app_action_attr_list = {};
AttributeList open_pin_action_attr_list = {};
// Unfortunately, open app and pin both need the parent uuid, so they are mutually exclusive
// Give open pin more precedence since the pin also links to the app
if (config->open_pin.enabled) {
attribute_list_ad... |
alid
// data/transitions are not triggered. I'd like to preserve them for internal use to quickly catch
// errors (https://pebbletechnology.atlassian.net/browse/PBL-31359)
Recognizer *recognizer_create_with_data(const RecognizerImpl *impl, const void *data,
size_t data_size, Rec... | if (!recognizer || !fail_after) {
return;
} |
if (fail_after->fail_after == recognizer) {
// Avoid circular dependency
return;
}
recognizer->fail_after = fail_after;
}
Recognizer *recognizer_get_fail_after(const Recognizer *recognizer) {
if (!recognizer) {
return NULL;
}
return recognizer->fail_after;
}
void recognizer_set_simultaneous_... |
/*
* 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(!prv_find_combo_timer()) | ;
cl_assert(!s_mfg_mode_entered);
prv_release_button(BUTTON_ID_DOWN);
// Make sure we've waited the appropriate amount of time
StubTimer *timer = prv_find_combo_timer();
cl_assert(timer);
cl_assert_equal_i(stub_new_timer_timeout(timer->id), 5000);
// Pretend 5000ms have elapsed
stub_new_timer_fire(ti... |
;
const int16_t offset_top = (layout->state == GameStatePreGame) ? 11 : 9;
const int16_t offset_bottom = PBL_IF_RECT_ELSE(-2, 0);
const int16_t min_y = box->origin.y + offset_top;
const int16_t max_y = box->origin.y + box->size.h + offset_bottom;
const int16_t offset_x = box->origin.x + box->size.w / 2;
gra... | ARRAY_LENGTH(s_vertical_config_nodes) | ,
.container.nodes = (LayoutNodeConfig **)&s_vertical_config_nodes,
.container.extent.offset.y = CARD_MARGIN_TOP,
.container.extent.margin.h = CARD_MARGIN_TOP + CARD_MARGIN_BOTTOM,
};
return timeline_layout_create_card_view_from_config(timeline_layout,
... |
/*
* 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... | resource_init() | ;
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
content_indicator_init_buffer(buffer);
}
void test_weather_app_layout__cleanup(void) {
free(fb);
}
// Helpers
//////////////////////
static void prv_create_layout_for_forecast(const WeatherLocationForecast *forecast,
... |
4, 240, -896},
// 104 seconds
{ 32, 248, -888},
{ 32, 232, -912},
{ 32, 240, -896},
{ 40, 272, -896},
{ 40, 256, -896},
{ 16, 216, -896},
{ 16, 224, -888},
{ 16, 224, -888},
{ 16, 224, -896},
{ 24, 232, -904},
{ 24, 232, -904},
{ 24, 232, -896},
{ 16, 232, -896},
... | { 88, 104, -928},
{ 80, 136, -952},
{ 72, 144, -952},
{ 48, 120, -896},
{ 56, 328, -928},
{ 40, 160, -912},
// 110 seconds
{ 48, 120, -904},
{ 32, 256, -912},
{ 24, 208, -920},
{ 32, 176, -904},
{ 40, 216, -912},
{ 32, 144, -912},
{ 24, 144, -904},
{ 40, 160, ... |
{ 24, 112, -912},
{ 40, 208, -904},
{ 40, 112, -920},
{ 40, 176, -928},
{ 32, 128, -912},
{ 40, 184, -920},
{ 32, 144, -920},
{ 40, 176, -920},
{ 48, 200, -920},
{ 24, 232, -944},
{ 24, 72, -896},
// 113 seconds
{ 32, 136, -920},
{ 64, 200, -928},
{ 48, 168, ... |
set the current notification and reload data.
notifications_presented_list_set_current(id);
prv_reload_swap_layer(data);
}
void notification_window_service_init(void) {
s_notification_window_mutex = mutex_create();
s_notification_window_data.pop_timer_id = EVENTED_TIMER_INVALID_ID;
}
//////////////////
// E... | notifications_presented_list_next() | ));
}
static void prv_handle_reminder_updated(Uuid *id) {
NotificationWindowData *data = &s_notification_window_data;
// We only need to reload from flash if the item is already in memory
// (ie. the current item or the next/peek item)
if (data->is_modal && prv_is_item_loaded(id)) {
prv_reload_swap_layer(... |
///////////////////////////
#include "fake_events.h"
#include "fake_gatt_client_operations.h"
#include "fake_gatt_client_subscriptions.h"
#include "fake_pebble_tasks.h"
#include "fake_rtc.h"
#include "stubs_app_install_manager.h"
#include "stubs_app_manager.h"
#include "stubs_bt_lock.h"
#include "stubs_hexdump.h"
#in... | (1 /* num_instances */) | ;
// Not connected yet (still need to subscribe):
cl_assert_equal_s(music_get_connected_server_debug_name(), NULL);
// Simulate successful subscription:
BLECharacteristic entity_update = s_characteristics[0][AMSCharacteristicEntityUpdate];
ams_handle_subscribe(entity_update, BLESubscriptionNotifications, BLE... |
ped_handler_calls, c), 1);
// -------------------------------------------------------------------------------------
// animation a has completed, but it shouldn't be deleted yet until the top-level
// animation is done.
uint32_t duration = animation_get_duration(a, false, false);
cl_assert_equal_i(duration,... | prv_advance_to_ms_with_timers(start_ms + duration_total + 1 * MIN_FRAME_INTERVAL_MS) | ;
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), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1... |
r = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
// Note: 1421178000 = Tue Jan 13 11:40:00 PST 2015
// check first
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1421178000), 0);
cl_assert(uuid_equal(&state.pin.header.... | (s_long_items) | ; i++) {
cl_assert_equal_i(pin_db_insert_item(&s_long_items[i]), 0);
}
}
void test_timeline__long_middle_past(void) {
prv_insert_long_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
// initialize it to be 11 min after item cc has started
timeline_init(&hea... |
r);
uint8_t key[file->iter.hdr.key_len];
settings_raw_iter_read_key(&file->iter, key);
settings_raw_iter_next(&file->iter); // Skip the current record
bool found_another = search_forward(&file->iter, key, file->iter.hdr.key_len);
if (!found_another) {
// No other file->iter.hdr found, we must... | settings_raw_iter_resume(&file->iter) | ;
if (search_forward(&file->iter, key, key_len)) {
set_flag(&file->iter.hdr, SETTINGS_FLAG_OVERWRITE_STARTED);
settings_raw_iter_write_header(&file->iter, &file->iter.hdr);
overwritten_record = settings_raw_iter_get_current_record_pos(&file->iter);
}
while (!settings_raw_iter_end(&file->iter)) {
... |
Impl is_dirty;
BlobDBGetDirtyListImpl get_dirty_list;
BlobDBMarkSyncedImpl mark_synced;
bool disabled;
} BlobDB;
static const BlobDB s_blob_dbs[NumBlobDBs] = {
[BlobDBIdPins] = {
.init = pin_db_init,
.insert = pin_db_insert,
.get_len = pin_db_get_len,
.read = pin_db_read,
.del = pin_db_dele... | db->init() | |
periph_config_release_lock();
prv_initialize_exti();
}
static void prv_set_baudrate(uint32_t baudrate, bool force_update) {
if ((baudrate != s_baudrate) || force_update) {
PBL_LOG(LOG_LEVEL_DEBUG, "Changing accessory connector baud rate to %"PRIu32, baudrate);
prv_initialize_uart(baudrate);
if (s_dm... | xSemaphoreGive(s_send_semaphore) | ;
}
uart_set_tx_interrupt_enabled(ACCESSORY_UART, false);
s_stream_cb = NULL;
s_stream_context = NULL;
prv_unlock();
}
void accessory_disable_input(void) {
// NOTE: This function may be called from an ISR
prv_lock();
PBL_ASSERTN(s_input_enabled);
s_input_enabled = false;
s_send_history.has_data = ... |
G(LOG_LEVEL_ALWAYS, "*** Main BLE FW booting... (pre-host logging) ***");
} else {
PBL_LOG(LOG_LEVEL_ALWAYS, "*** Main BLE Controller booted in %d ms... ***",
(int)ticks_to_milliseconds(xTaskGetTickCount()));
}
DialogChipID chip_id = {};
dialog_chip_id_copy(&chip_id);
PBL_LOG(LOG_LEVEL_DEBUG,... | pm_system_init(prv_periph_setup) | ;
#if mainCHECK_INTERRUPT_STACK == 1
/* The size of the stack used by main and interrupts is not defined in
the linker, but just uses whatever RAM is left. Calculate the amount of
RAM available for the main/interrupt/system stack, and check it against
a reasonable number. If this assert is hit then ... |
prv_init_and_goto_awaiting_reset_complete_remote_initiated() | ;
const PostMessageResetCompletePayload unsupported = {
.min_supported_version = POSTMESSAGE_PROTOCOL_MAX_VERSION + 1,
.max_supported_version = POSTMESSAGE_PROTOCOL_MAX_VERSION + 1,
.max_tx_chunk_size = POSTMESSAGE_PROTOCOL_MAX_TX_CHUNK_SIZE,
.max_rx_chunk_size = POSTMESSAGE_PROTOCOL_MAX_RX_CHUNK_SIZ... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_DEBUG,
(uint8_t *)&info->irk,
sizeof(info->irk)) | ;
prompt_send_response(" BTDeviceInternal: ");
PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG,
(uint8_t *)&info->identity,
sizeof(BTDeviceInternal));
prompt_send_response(" SMConnectionSignatureResolvingKey: ");
PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG,
(... |
prompt_send_response("BT SIG RF Test Mode Enabled") | ;
} else {
prompt_send_response("Failed to enter BT SIG RF Test Mode");
}
}
void command_bt_prefs_wipe(void) {
bt_driver_classic_disconnect(NULL);
bt_persistent_storage_delete_all_pairings();
}
void command_bt_sprf_nuke(void) {
shared_prf_storage_wipe_all();
#if RECOVERY_FW
// Reset system to get cach... | |
"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 "applib/graphics/graphics.h"
#include "applib/graphics/graphics_private.h"
#include "applib/graphics/graphics_... | (ctx, rect->origin.x + x, rect->origin.y, grect_get_max_y(rect) - 1, color) | ;
}
}
static void prv_draw_vline_test_pattern(GContext *ctx, HLinePatternDrawFunction draw_func) {
const GRect *bitmap_bounds = &ctx->dest_bitmap.bounds;
// Fill the screen with red
graphics_context_set_fill_color(ctx, GColorRed);
graphics_fill_rect(ctx, bitmap_bounds);
const GSize *bitmap_bounds_size = &... |
ertyAnimation *prop_anim =
property_animation_create_layer_frame((Layer *)&data->action_menu_layer, start, &stop);
Animation *content_out = property_animation_get_animation(prop_anim);
animation_set_duration(content_out, IN_OUT_ANIMATION_DURATION);
AnimationHandlers anim_handlers = {
.started = NULL,
... | (&data->action_menu_layer) | ;
crumbs_layer_deinit(&data->crumbs_layer);
applib_free(data);
}
static void prv_dummy_click_config(void *data) {
}
ActionMenuLevel *action_menu_get_root_level(ActionMenu *action_menu) {
if (!action_menu) return NULL;
ActionMenuData *data = window_get_user_data(&action_menu->window);
return (ActionMenuLevel... |
colors->bg_color);
// bounce back from the right
GPoint from_origin = { -TIMELINE_CARD_MARGIN, 0 };
Animation *animation = prv_create_bounds_origin_animation(pin_window, &from_origin, NULL);
animation_schedule(animation);
}
static void prv_pin_window_unload(Window *window) {
TimelinePinWindow *pin_window =... | event_service_client_subscribe(&pin_window->blobdb_event_info) | |
ns[1];
SimpleMenuItem menu_items[FLASH_TEST_CASE_NUM_MENU_ITEMS];
Window test_window;
TextLayer msg_text_layer[3];
TextLayer status_text_layer;
char status_text[STATUS_TEXT_SIZE];
FlashTestCaseType test_case;
uint8_t test_case_status;
};
/***********************************************************/
/****... | (msg_text_layer, "Press Up to Exit, Down to Stop Test") | ;
}
text_layer_set_text_alignment(msg_text_layer, GTextAlignmentCenter);
text_layer_set_background_color(msg_text_layer, GColorBlack);
text_layer_set_text_color(msg_text_layer, GColorWhite);
text_layer_set_font(msg_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
layer_add_child(&window->layer, ... |
/*
* 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... | for (int i = 0; i < NUM_BUTTONS; ++i) {
window_long_click_subscribe(i, 0, prv_reboot_on_click, NULL);
} | |
"system/passert.h"
#include "system/profiler.h"
#include "util/list.h"
#include "util/size.h"
#include "FreeRTOS.h"
#include "semphr.h"
typedef struct ModalContext {
WindowStack window_stack;
} ModalContext;
typedef struct UpdateContext {
ModalPriority highest_idx;
ModalProperty properties;
} UpdateContext;
s... | window_stack_get_top_window(stack) | ;
}
static void prv_pop_stacks_in_range(ModalPriority low, ModalPriority high) {
// Discreet modals are transparent and unfocusable, they are not meant to be popped when
// requesting opaque focusable modals to pop.
for (ModalPriority priority = MAX(low, ModalPriorityDiscreet + 1); priority <= high;
prior... |
/*
* 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_get_recognizer_list(manager->window), iter_cb, context) | ) {
return false;
}
Layer *root = window_get_root_layer(manager->window);
Layer *layer = manager->active_layer;
// layers attached to window are attached to it's root layer, so don't process recognizers on the
// root layer
while (layer && (layer != root)) {
if (!recognizer_list_iterate(layer_get_r... |
_NOT_EXIST)) { // unexpected error
goto cleanup;
}
// check to see if we are trying to read the file and it doesn't exist
bool is_read_only = (op_flags & (OP_FLAG_READ | OP_FLAG_WRITE |
OP_FLAG_OVERWRITE)) == OP_FLAG_READ;
bool is_tmp = ((op_flags & OP_FLAG_OVERWRITE) != 0);
if ((is_read_only || is... | for (uint16_t pg = 0; pg < PFS_PAGES_PER_ERASE_SECTOR; pg++) {
uint32_t base_addr = prv_page_to_flash_offset(sector_start_page + pg);
uint32_t data_len;
PageHeader hdr;
if (do_copy) {
// if the sector is not active we only need to copy the page header info
data_len = (((sectors_active >> pg... |
kernel_free(buf);
return (S_SUCCESS);
}
static void recover_region_from_file(int fd) {
GCData gcdata;
pfs_seek(fd, 0, FSeekSet);
pfs_read(fd, &gcdata, sizeof(gcdata));
if (!GCDATA_VALID(gcdata.flags)) {
// we never completed setting up the migration
goto done;
}
// at this point we can era... |
/*
* 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 + 25 KiB, 871 KiB - 1, NULL, NULL) | );
cl_assert_equal_i(BITS_BETWEEN(1, 10), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_sectors_1_thru_11(void) {
cl_assert(system_flash_erase(FLASH_BASE + 25 KiB, 871 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(1, 10), erased_sector);
cl_assert(flash_locked);
}
void callbac... |
ut = LayoutIdTest,
}
}
};
// all day item
static TimelineItem s_all_day_items[] = {
{
.header = {
.id = {0x01},
.parent_id = {0},
.timestamp = 1421020800, // midnight jan 12, 2015 UTC
.duration = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.all_day = 1,
... | iter_next(&iterator) | );
cl_assert(uuid_equal(&state.pin.header.id, &s_items[2].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
... |
.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 Li... | (framebuffer, y) | |
}
void test_shared_prf_storage_v3__save_all_data_confirm_all_data_correct(void) {
const bool GETTING_STARTED_COMPLETE = true;
shared_prf_storage_store_ble_pairing_data(&PAIRING_INFO, DEVICE_NAME,
true /* requires_address_pinning */, 0xff /* flags */);
shared_prf_stora... | {
bool GETTING_STARTED_COMPLETE = true;
shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0);
SharedPRFData data;
flash_read_bytes((uint8_t *)&data,
SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_pa... |
SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_page_number())
+ offsetof(SharedPRFData, getting_started)
+ offsetof(SprfGettingStarted, crc),
sizeof(new_crc));
// Should be corrupt, so i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (result, 0, required_size) | ;
result->max_points = max_points;
return result;
}
void gpath_builder_destroy(GPathBuilder *builder) {
applib_free(builder);
}
GPath *gpath_builder_create_path(GPathBuilder *builder) {
if (builder->num_points <= 1) {
return NULL;
}
uint32_t num_points = builder->num_points;
// handle case where l... |
xtern void prv_charger_event_cb(PebbleEvent *e);
// -----------------------------------------------------------------------------
// HRM Driver fakes
// -----------------------------------------------------------------------------
static struct {
bool enabled;
} s_hrm_state;
void hrm_enable(HRMDevice *dev) { s_hr... | (app_id, update_interval_s, expire_s,
features) | |
ude "insights_settings.h"
#include "os/mutex.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/settings/settings_file.h"
#include "system/logging.h"
#include "util/size.h"
#define ACTIVITY_INSIGHTS_SETTINGS_FILENAME "insights"
#define ACTIVITY_INSIGHTS_SETTINGS_DEFAULT_FILE_SIZE 4096
#define A... | settings_file_close(file) | ;
mutex_unlock(s_insight_settings_mutex);
}
void activity_insights_settings_init(void) {
// Create our mutex
s_insight_settings_mutex = mutex_create();
SettingsFile file;
if (settings_file_open(&file,
ACTIVITY_INSIGHTS_SETTINGS_FILENAME,
ACTIVITY_INSIGHTS_SE... |
l_data(num_attributes, num_actions, data, size,
&string_alloc_size, attributes_per_action);
if (!r) {
return NULL;
}
const size_t alloc_size = attributes_actions_get_required_buffer_size(num_attributes, num_actions,
... | (LOG_LEVEL_DEBUG, data, length) | ;
if (header->command == CommandPhoneResponse) {
PhoneResponseMsg *msg = (PhoneResponseMsg *)data;
action_result = prv_action_result_create_from_serial_data(
header, msg->num_attributes, 0, msg->data, length - sizeof(PhoneResponseMsg));
} else {
PhoneActionResponseMsg *msg = (PhoneActionRespons... |
ile_small, OP_FLAG_READ, FILE_TYPE_STATIC, sizeof(buf));
cl_assert(fd >= 0);
cl_assert_equal_i(pfs_read(fd, &buf[0], sizeof(buf)), sizeof(buf));
cl_assert(memcmp(buf, bufcmp, sizeof(buf)) == 0);
cl_assert_equal_i(pfs_close(fd), S_SUCCESS);
}
}
void test_pfs__garbage_collection_when_full(void) {
cha... | for (int i = 0; i < num_regions; i++) {
cl_assert_equal_i(pfs_seek(fd, i * sizeof(buf), FSeekSet), i * sizeof(buf));
uint8_t read_byte;
for (int j = 0; j < 16; j++) {
cl_assert_equal_i(pfs_read(fd, &read_byte, sizeof(read_byte)), sizeof(read_byte));
cl_assert_equal_i(read_byte, 0xff - i);
}
... | |
MM_SESSION_DEFAULT_TIMEOUT);
}
static BlobDBResponse prv_interpret_db_ret_val(status_t ret_val) {
switch (ret_val) {
case S_SUCCESS:
return BLOB_DB_SUCCESS;
case E_DOES_NOT_EXIST:
return BLOB_DB_KEY_DOES_NOT_EXIST;
case E_RANGE:
return BLOB_DB_INVALID_DATABASE_ID;
case E_INVALID_ARG... | if (!iter || (iter != (data + length))) {
prv_send_response(session, token, BLOB_DB_INVALID_DATA);
return;
} |
// perform action on database and return result
status_t ret = blob_db_delete(db_id, key_bytes, key_size);
prv_send_response(session, token, prv_interpret_db_ret_val(ret));
}
static void prv_handle_database_clear(CommSession *session, const uint8_t *data, uint32_t length) {
if (length < MIN_CLEAR_LENGTH) {
... |
should wait outside of stop mode when we first see any noise on the
//! serial port.
#define ACCESSORY_INITIAL_STOP_INTERVALS (500 / ACCESSORY_STOP_INTERVAL_PERIOD_MS)
//! How many intervals we should wait outside of stop mode when we first see valid data on the
//! serial port.
#define ACCESSORY_VALID_DATA_STOP_INTER... | uart_stop_rx_dma(ACCESSORY_UART) | |
lidate the arguments based on the shape that is drawn
static bool validate_args(ArgsForMock *actual_args, ArgsForMock *valid_args) {
if (memcmp(actual_args, valid_args, sizeof(ArgsForMock)) == 0) {
return true;
}
return false;
}
// This macro will call the expected code_block and then validate the arguments... | (&context, color) | ;
#if PBL_COLOR
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorOrange.argb);
#else
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorDarkGray.argb);
#endif
color.a = 2;
graphics_context_set_fill_color(&context, color);
#if PBL_COLOR
cl_assert_equal_i(context.draw_state.fill_color.argb,... |
prv_destroy_layout(layer, i) | ;
}
}
peek_layer_deinit(&layer->day_separator);
kino_layer_deinit(&layer->end_of_timeline);
// TODO: PBL-21982: Only support rectangular screen for now
#if PBL_RECT
timeline_relbar_layer_deinit(layer);
#endif
}
| |
128},
{ 1104, 64, 72},
{ 1104, 16, 16},
{ 1184, 64, -32},
{ 1144, 104, -32},
{ 968, 64, -80},
{ 728, 24, -104},
{ 832, 0, -48},
{ 1032, 32, -168},
{ 920, 80, -312},
{ 1240, -16, -48},
{ 1280, -8, -152},
{ 1312, 56, -192},
{ 1312, 72, -136},
{ 1160, 152, -176},
... | { 1040, 144, 56},
{ 1072, 64, 80},
{ 1184, 16, -16},
{ 1232, 24, -96},
{ 1056, 24, -104},
{ 960, -16, -72},
{ 1120, 8, -152},
{ 832, 32, -272},
{ 896, -8, -152},
{ 1024, -32, -48},
{ 1112, 112, -112},
{ 1360, 288, -392},
{ 1240, 224, -296},
{ 856, 56, 16},
{ 6... |
{ 1480, 320, 672},
{ 2896, 1200, 1440},
{ 2272, 1928, 1888},
{ 1112, 1264, -16},
{ 1376, 328, 152},
{ 1344, 856, 72},
{ 1272, 360, 520},
{ 1296, 112, 448},
{ 1376, 56, 216},
// 49 seconds
{ 1064, 312, 72},
{ 1304, 424, 144},
{ 1240, 616, 408},
{ 824, 720, 376},
... |
GLOBAL_EQUALS_S("a", "left");
EXECUTE_SCRIPT("ctx.textAlign = 'right';\nvar a = ctx.textAlign;\n");
cl_assert_equal_i(GTextAlignmentRight, s_rocky_text_state.alignment);
ASSERT_JS_GLOBAL_EQUALS_S("a", "right");
EXECUTE_SCRIPT("ctx.textAlign = 'center';\nvar a = ctx.textAlign;\n");
cl_assert_equal_i(GTextAli... | ("foo", lc->max_used_size.text) | ;
cl_assert_equal_p(s_rocky_text_state.font, lc->max_used_size.font);
cl_assert_equal_rect((GRect(0, 0, INT16_MAX, INT16_MAX)), lc->max_used_size.box);
cl_assert_equal_i(s_rocky_text_state.overflow_mode, lc->max_used_size.overflow_mode);
cl_assert_equal_i(s_rocky_text_state.alignment, lc->max_used_size.alignmen... |
72, -360},
{ -896, 56, -344},
{ -904, 56, -320},
{ -912, 80, -320},
{ -904, 72, -320},
{ -904, 72, -336},
{ -912, 64, -336},
{ -896, 56, -336},
{ -904, 48, -328},
{ -904, 96, -352},
{ -912, 80, -344},
{ -904, 88, -344},
{ -896, 80, -352},
{ -904, 64, -344},
{ -904... | { -880, 544, -432},
{ -848, 424, -32},
{ -1024, 168, 680},
{ -1064, 104, 1496},
{ -768, 80, 1200},
// 98 seconds
{ 1088, 4000, 208},
{ -808, -1560, 296},
{ -224, 752, -816},
{ -1120, 952, 72},
{ -912, 104, -56},
{ -1000, 480, 96},
{ -944, 376, 368},
{ -1056, -8, 1... | |
uration_s, &distance_m,
&bpm, &hr_zone));
// HR Reading has expired. Should return 0
cl_assert_equal_i(bpm, 0);
cl_assert(workout_service_stop_workout());
}
// ---------------------------------------------------------------------------------------
void test_w... | (s_hrm_subscribed, true) | ;
cl_assert_equal_i(s_hrm_expiration, SECONDS_PER_HOUR);
}
// ---------------------------------------------------------------------------------------
// Open the app, start a workout, 30s, stop the workout. Make sure the HR turns off instantly
// since workout wasn't valid (too short)
void test_workout_service__app_... |
ClickRecognizerRef recognizer, void *context) {
AppWorkerMessage m;
app_worker_send_message('x', &m);
APP_LOG(APP_LOG_LEVEL_INFO, "crashing worker");
}
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
AppWorkerResult result = app_worker_kill();
APP_LOG(APP_LOG_LEVEL_INFO, "kill ... | window_stack_push(window, true /* Animated */) | ;
window_set_background_color(window, GColorBlack);
Layer *window_layer = window_get_root_layer(window);
text_layer = text_layer_create(GRect(7, 40, 144-7, 168-40));
text_layer_set_text_color(text_layer, GColorWhite);
text_layer_set_background_color(text_layer, GColorClear);
text_layer_set_font(text_layer... |
/*
* 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_data->text, "FAILED") | |
emType item_type,
uint16_t item_size, void* buffer, bool resume) {
const PebbleProcessMd *md = sys_process_manager_get_current_process_md();
return prv_dls_create(tag, item_type, item_size, true, buffer, resume, &md->uuid);
}
// --------------------------------------... | shared_circular_buffer_write(&session->data->buffer, data, num_bytes,
false /*advance_slackers*/) | ;
// Only enqueue work on the system_task if we're not already waiting on the system task to handle
// previously enqueued work for this session.
if (!session->data->write_request_pending) {
session->data->write_request_pending = true;
system_task_add_callback(prv_write_all_sessions_to_flash, NULL);
}
... |
{
PBL_ASSERTN(ctx);
ctx->draw_state.drawing_box.origin = gpoint_add(ctx->draw_state.drawing_box.origin, offset);
} |
void graphics_context_set_stroke_color(GContext* ctx, GColor color) {
PBL_ASSERTN(ctx);
if (ctx->lock) {
return;
}
#if PBL_BW
color = gcolor_get_bw(color);
#else
color = gcolor_closest_opaque(color);
#endif
ctx->draw_state.stroke_color = color;
}
void graphics_context_set_stroke_color_2bit... | |
_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry));
cl_assert_equal_b(true, app_install_get_entry_for_install_id(music_id, &id_entry));
cl_assert_equal_b(true, app_install_get_entry_for_uuid(&music_uuid, &uuid_entry));
cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry));
... | (false, app_install_id_from_app_db(-1000000)) | |
/*
* 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... | (box, GEdgeInsets(border_width, 0)) | ;
const GColor label_background_color = GColorWhite;
graphics_context_set_fill_color(ctx, label_background_color);
graphics_fill_rect(ctx, &box);
}
//! Get the corresponding data point for a weekday.
//! Sunday is 0, and the day data begins with today and continues into the past.
static int32_t prv_get_day_point... |
ex_unlock_recursive(s_app_cache_mutex);
return rv;
}
//////////////////////
// AppCache Helpers
//////////////////////
// Remove the filename entry in the PFSFileList (via context) that corresponds to the
// app install id passed in via info
static bool prv_remove_matching_resource_file_callback(SettingsFile *file,... | mutex_unlock_recursive(s_app_cache_mutex) | ;
prv_purge_orphaned_resource_files();
}
//! Adds an entry with the given AppInstallId to the cache
status_t app_cache_add_entry(AppInstallId app_id, uint32_t total_size) {
status_t rv;
mutex_lock_recursive(s_app_cache_mutex);
{
SettingsFile file;
rv = settings_file_open(&file, APP_CACHE_FILE_NAME, AP... |
, 2), grect_centered_internal(&p3, GSize(-1, -2)));
// handles fixed point
cl_assert_equal_grect(GRect(5, 5, 2, 2), grect_centered_internal(&p3, GSize(2, 2)));
p3.x.raw_value += FIXED_S16_3_HALF.raw_value;
cl_assert_equal_grect(GRect(5, 5, 2, 2), grect_centered_internal(&p3, GSize(2, 2)));
// Repeat for a n... | (&r, mode, ¢er, &radius) | ;
cl_assert_gpoint_precise(center, 5.5, 5.5);
cl_assert_fixedS16_3(radius, 3.5);
}
void test_graphics_circle__grect_polar_calc_values_mode(void) {
GPointPrecise center = {};
Fixed_S16_3 radius = {};
GRect r = GRect(0, 0, 144, 168);
grect_polar_calc_values(&r, GOvalScaleModeFitCircle, ¢er, &radius);
... |
erty == PROPERTY_BG_COLOR) {
data->bg_color_index = (data->bg_color_index + 1) & 0x3F;
data->bg_color.argb = (s_color_table[data->bg_color_index] | ALPHA_100);
} else if (data->property == PROPERTY_ALPHA) {
data->alpha = (data->alpha + 0x40) & ALPHA_100;
set_text_layers(data);
} else if (data->prope... | window_get_root_layer(window) | , text_layer_get_layer(data->fg_text));
data->fg_color_text = text_layer_create(GRect(2, 24, 64, 20));
layer_add_child(window_get_root_layer(window), text_layer_get_layer(data->fg_color_text));
data->fg_color_index = 8;
data->bg_text = text_layer_create(GRect(2, 48, 28, 20));
layer_add_child(window_get_roo... |
nse 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 "services/normal/notifications/notification_storage.h"
#include "services/normal/noti... | (list_b, idx) | |
/*
* 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... | kino_layer_deinit(&data->kino_layer) | ;
app_free(data);
}
///////////////////////////
// app boilerplate
///////////////////////////
static void s_main(void) {
prv_init();
app_event_loop();
prv_deinit();
}
const PebbleProcessMd *kino_layer_demo_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common = {
.main_func ... |
alized);
PBL_ASSERTN(slave->slave_state->acquired);
const uint8_t *cptr = out;
while (len--) {
prv_spi_send_data(slave->spi_bus, *(cptr++));
prv_spi_transmit_flush_blocking(slave->spi_bus);
}
}
void spi_ll_slave_burst_read_write(const SPISlavePort *slave,
const void *... | if (slave->slave_state->dma_state != SPISlavePortDMAState_Write) {
return;
} |
dma_request_stop(slave->tx_dma);
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_ReqTx, false);
slave->slave_state->dma_complete_handler = NULL;
slave->slave_state->dma_complete_context = NULL;
}
void spi_ll_slave_read_writ... |
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling MCO1") | ;
gpio_analog_init(&BOARD_CONFIG_MCO1.an_cfg);
}
}
portEXIT_CRITICAL();
}
| |
Y KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "process_management/app_install_types.h"
#include "process_management/pebble_process_info.h"
#include "process_management/pebble_process_md.h"
#inc... | memset(&temp, 0, sizeof(AppDBEntry)) | ;
cl_assert_equal_i(S_SUCCESS, app_db_get_app_entry_for_uuid(&app1.uuid, &temp));
cl_assert_equal_b(true, uuid_equal(&app1.uuid, &temp.uuid));
cl_assert_equal_i(0 , strncmp((char *)&app1.name, (char *)&temp.name, APP_NAME_SIZE_BYTES));
// check app 2
memset(&temp, 0, sizeof(AppDBEntry));
cl_assert_equal_i(... |
nclude "util/time/time.h"
#include <btutil/bt_device.h>
#include <string.h>
// -------------------------------------------------------------------------------------------------
// Function prototypes
static void prv_perform_on_kernel_main_task(void (*callback)(void *), void *data);
// -----------------------------... | (prv_request_reduced_latency_cb,
(void *)(uintptr_t)reduced_latency) | ;
}
static void prv_music_request_low_latency_for_period(uint32_t period_ms) {
prv_perform_on_kernel_main_task(prv_request_low_latency_for_period_cb,
(void *)(uintptr_t)period_ms);
}
static const MusicServerImplementation s_ams_music_implementation = {
.debug_name = "AMS",
.is_... |
he item's parent id points to another
// timeline item. If the attribute isn't found, we assume the ancs id is stored in the header
uint32_t ancs_uid = attribute_get_uint32(&action->attr_list, AttributeIdAncsId,
item->header.ancs_uid);
PBL_LOG(LOG_LEVEL_INFO, "Perform a... | (&item->header.parent_id) | ;
if (install_id == INSTALL_ID_INVALID) {
// This should never happen... but we're not quite there yet
PBL_LOG(LOG_LEVEL_ERROR, "Could not find parent app %s for pin", uuid_buffer);
return;
}
// fetch the relevant attribute
const uint32_t launch_code =
attribute... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.