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... | (RegPwmOut1, brightness) | ;
write_register(RegPwmOut2, brightness);
write_register(RegPwmOut3, brightness);
write_register(RegDataUpdate, 0xaa);
i2c_release(I2C_LED);
s_backlight_off = (brightness == 0);
if (s_backlight_off && s_rgb_current_color == LED_BLACK) {
prv_shutdown(true);
}
}
void led_controller_rgb_set_color(u... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return key_len != 0 && // invalid length
strchr((const char *)key, '_') != NULL; // invalid key
} |
static bool prv_value_is_valid(const uint8_t *key,
int key_len,
const uint8_t *val,
int val_len) {
return val_len && val_len % sizeof(uint32_t) == 0;
}
static bool prv_is_last_processed_timestamp_valid(time_t timestamp) {
... |
d_sender_version: major: %"PRIu32", minor: %"PRIu32", patch: %s",
s_parsed_msg.payload_sender_v_major, s_parsed_msg.payload_sender_v_minor, s_parsed_msg.payload_sender_version_patch);
LOG("payload_send_time: %"PRIu32"", s_parsed_msg.payload_send_time);
LOG("MeasurementSet:");
char uuid_str[UUID_STRI... | (" Activity Type: %d, Start Reason: %d", session->type.type.internal_type,
session->start_reason) | |
112},
{ 792, 224, 160},
{ 832, 288, 32},
// 67 seconds
{ 824, 192, 64},
{ 952, 296, -32},
{ 1120, 280, -24},
{ 1272, 336, 72},
{ 1664, 336, 168},
{ 1328, 616, 144},
{ 872, 480, 168},
{ 1184, 200, 0},
{ 1200, -224, 472},
{ 1080, 248, 160},
{ 920, 168, 96},
{ 75... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-03 08:52:18 local
AccelRawData *activity_sample_walk_100_pbl_25531_3(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25531_3
//> TEST... |
= watch_app_prefs_db_init,
.insert = watch_app_prefs_db_insert,
.get_len = watch_app_prefs_db_get_len,
.read = watch_app_prefs_db_read,
.del = watch_app_prefs_db_delete,
.flush = watch_app_prefs_db_flush,
#else
// Disabled on tintin for code savings
.disabled = true,
#endif
},
[BlobDBIdH... | if (!prv_db_valid(db_id)) {
return E_RANGE;
} | |
) || (!next)) {
// No relationship bar shown
return RelationshipBarTypeNone;
}
const time_t current_end = current->end_time;
if ((next->timestamp > current_end) && (current->current_day == next->current_day)) {
// Next pin starts after the end of the current pin
return RelationshipBarTypeFreeTime... | {
// Delay to avoid overlapping moving icon with bars
animation_set_delay(prev_rel_bar_anim, 0);
animation_set_duration(prev_rel_bar_anim, duration / 3);
} | |
e_dotted(&ctx, GPoint(17, 0), 21);
graphics_draw_vertical_line_dotted(&ctx, GPoint(19, 0), 22);
graphics_draw_vertical_line_dotted(&ctx, GPoint(21, 0), MAX_NUM_ROWS - 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 0), MAX_NUM_ROWS + 1 );
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_... | GPoint(23, 0) | |
ctivitySleep
// when calling health_service_activities_iterate()
if (sleep_state == ActivitySleepStateRestfulSleep) {
result |= (HealthActivitySleep | HealthActivityRestfulSleep);
}
if (sys_activity_sessions_is_session_type_ongoing(ActivitySessionType_Walk)) {
result |= HealthActivityWalk;
}
if (s... | if (activity_mask == HealthActivityNone) {
return HealthServiceAccessibilityMaskNotAvailable;
} |
// TODO: PBL-31630 provide more accurate value for available time frame
// for now, we say that there's only 1 day worth of data for sleep sessions
HealthServiceTimeRange range;
if (!prv_calculate_time_range(start_time, end_time, &range)) {
return HealthServiceAccessibilityMaskNotAvailable;
}
if (ran... |
/*
* 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... | ("Unknown runlevel") | ;
return;
} else if (runlevel == 0 && arg[0] != '0') {
prompt_send_response("Invalid runlevel number. Choices:");
prv_list_runlevels();
return;
}
char response[80];
strcpy(response, "Switching to runlevel ");
strcat(response, s_runlevel_debug_names[runlevel]);
prompt_send_response(response)... |
eceive_byte(vt[i]);
}
dialog_spi_end_cmd();
uint32_t received_crc = 0;
dialog_spi_receive_data((uint8_t *)&received_crc, sizeof(received_crc));
PBL_LOG(LOG_LEVEL_DEBUG, "VT Crc. Expected: 0x%x Received CRC: 0x%x",
(int)expected_crc, (int)received_crc);
return (received_crc == expected_crc);
}
s... | PBL_LOG(LOG_LEVEL_INFO, "BLE FW loaded!") | ;
return true;
}
//
// Exported routines
//
bool dialog_spi_bootloader_load_image(void) {
dialog_spi_init(NULL);
const bool result = prv_load_bt_image_over_spi();
dialog_spi_deinit();
return result;
}
void dialog_test_cmds(void) {
dialog_spi_bootloader_load_image();
}
|
--------------------------------------------------
void test_kraepelin_algorithm__cleanup(void) {
}
// ---------------------------------------------------------------------------------------
void test_kraepelin_algorithm__step_tests(void) {
bool success = prv_sample_discovery_init(&s_accel_sample_discovery_state.co... | ("\n%-40s %-10d %-10d %-10d %-10d %-10d %-10d %-10.2f %-10s",
entry->name,
entry->exp_steps,
results->steps,
error,
entry->exp_steps_min,
entry->exp_steps_max,
results->ref_steps,
weighted_error,
status) | ;
}
if (fail_count) {
printf("\n\ntest FAILED: %d failures, Avg weighted error: %.2f", fail_count,
weighted_sum / num_tests);
} else {
printf("\n\ntest PASSED! Avg weighted error: %.2f", weighted_sum / num_tests);
}
cl_assert_equal_i(fail_count, 0);
}
// --------------------------------... |
_list.num_attributes, &attr_list_out);
const uint8_t *buffer = (uint8_t *)deserialized_buffer;
const uint8_t *cursor = serialized_buffer;
attribute_deserialize_list((char **)&buffer, (char *)&deserialized_buffer[buffer_size],
&cursor, &serialized_buffer[serialized_size],
... | (&list, AttributeIdTitle, "") | , "Title1");
cl_assert_equal_i(list.num_attributes, 1);
attribute_list_add_cstring(&list, AttributeIdSubtitle, "Subtitle");
cl_assert_equal_s(attribute_get_string(&list, AttributeIdSubtitle, ""), "Subtitle");
cl_assert_equal_s(attribute_get_string(&list, AttributeIdTitle, ""), "Title1");
cl_assert_equal_i(li... |
handle = TIMER_INVALID_ID;
static bool s_debounced_is_usb_connected = false;
static bool battery_is_usb_connected_raw(void);
static void battery_vusb_interrupt_handler(bool *should_context_switch);
static void battery_conn_debounce_callback(void* data) {
s_debounced_is_usb_connected = battery_is_usb_connected_raw(... | gpio_release(BOARD_CONFIG_POWER.chg_stat.gpio) | ;
periph_config_release_lock();
if (BOARD_CONFIG_POWER.has_vusb_interrupt) {
// Prime the debounced state.
s_debounced_is_usb_connected = battery_is_usb_connected_raw();
}
}
bool battery_charge_controller_thinks_we_are_charging_impl(void) {
periph_config_acquire_lock();
gpio_use(BOARD_CONFIG_POWER.... |
frame);
const bool is_future = (layer->scroll_direction == TimelineScrollDirectionDown);
const TimelineLayerStyle *style = prv_get_style();
gpoint_add_eq(&frame->origin,
GPoint(style->fin_offset_x,
is_future ? style->future_fin_offset_y : style->past_fin_offset_y));
frame... | (layer, s_visible_items[i]) | ;
}
TimelineIterState *state = timeline_model_get_iter_state(i);
if (!state) {
continue;
}
TimelineNode *node = state->node;
if (i < num_items && node) {
prv_create_layout(layer, state, s_visible_items[i]);
}
}
}
static void prv_update_pins_mode(TimelineLayer *layer) {
for (... |
/*
* 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... | {
action_toggle_push(&(ActionToggleConfig) {
.impl = &s_dnd_action_toggle_impl,
.prompt = prompt,
.set_exit_reason = set_exit_reason,
});
} | |
44, 8},
{ 1048, 40, -56},
{ 1160, 136, -192},
{ 1424, 80, -136},
{ 1416, -8, -240},
{ 1048, 32, -56},
{ 936, 96, -120},
{ 1080, 256, -24},
{ 1192, 280, 88},
{ 1192, 272, 64},
{ 1016, 272, 96},
{ 1216, 304, 200},
{ 1072, 376, 352},
{ 1088, 504, 248},
{ 1080, 496, 6... | { 1048, 128, -120},
{ 1200, 120, -16},
{ 1352, 216, -8},
{ 1120, 320, -104},
{ 1040, 296, -80},
{ 1256, 400, -72},
{ 912, 544, 72},
{ 1048, 376, -64},
{ 1408, 352, -96},
{ 1056, 296, -32},
{ 1200, 264, 32},
{ 1456, 256, 24},
{ 1336, 208, 24},
{ 1192, 40, 104},
... |
// 60 seconds
// elapsed: 1 minutes
{ 1328, -64, 56},
{ 1104, -24, 56},
{ 880, -24, 64},
{ 1016, -24, 112},
{ 696, -112, 0},
{ 584, -8, -16},
{ 952, -64, -160},
{ 1272, -64, -224},
{ 1392, -144, -200},
{ 1368, -160, -144},
{ 1056, -104, -200},
{ 792, -128, 0},
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
data->line_spacing_delta -= 1;
} | else {
data->line_spacing_delta -= 5;
}
text_layer_set_line_spacing_delta(&data->text_layer, data->line_spacing_delta);
}
GSize size_used = text_layer_get_content_size(app_get_current_graphics_context(),
&data->text_layer);
PBL_LOG(LOG_LEVEL_DEBUG, "... |
abs(last_pos->x - cur_pos->x) | + abs(last_pos->y - cur_pos->y) +
abs(last_pos->z - cur_pos->z));
}
static void prv_timer_cb(void *data) {
s_timer = app_timer_register(TIMEOUT_MS, prv_timer_cb, NULL);
AccelData accel_data;
int error;
if ((error = accel_service_peek(&accel_data)) != 0) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Accelerometer... | |
/*
* 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_perform_lookup_using_color_luminance_and_multiply_alpha(fill_color,
luminance_tint_lookup_table) | |
lipper->size.h;
rect_to_clip->size.h = 0;
}
overflow = rect_to_clip->origin.y + rect_to_clip->size.h - (rect_clipper->origin.y + rect_clipper->size.h);
if (overflow > 0) {
rect_to_clip->size.h -= overflow;
}
}
GRect grect_union(const GRect *r1, const GRect *r2) {
GRect s_r1 = *r1;
GRect s_r2 = *r2;... | (rect,
(GEdgeInsets) {.top = dy, .right = dx, .bottom = dy, .left = dx}) | ;
}
GRect grect_inset(GRect r, GEdgeInsets insets) {
grect_standardize(&r);
const int16_t new_width = r.size.w - insets.left - insets.right;
const int16_t new_height = r.size.h - insets.top - insets.bottom;
if (new_width < 0 || new_height < 0) {
return GRectZero;
}
return GRect(r.origin.x + insets.left... |
/*
* 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... | (buf, 3, "%02u", data->minute) | ;
return buf;
case TimeInputIndexAMPM: // We should only get this in 12h style
if (data->hour < 12) {
i18n_get_with_buffer("AM", buf, 3);
} else {
i18n_get_with_buffer("PM", buf, 3);
}
return buf;
default:
return "";
}
}
void date_time_handle_time_change(Ti... |
cl_assert(fd >= 0);
cl_assert(pfs_close(fd) == S_SUCCESS);
}
}
static uint32_t s_watch_file_callback_called_count = 0;
static void prv_file_changed_callback(void *data) {
s_watch_file_callback_called_count++;
}
void test_pfs__watch_file_callbacks(void) {
const char* file_name = "newfile";
PFSCallbackHan... | (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);
}
}
static bool prv_filename_filter_a_prefix_cb(const char *name) {
return (strncmp(name, "a_", 2) == 0);
}
static bool prv_find_name(ListNode *node, void *data) {
PFSFileListEntry *entry = (PFSFileListEntry... |
// swap frames so that we shrink to a dot during reverse
kino_reel_transform_set_from_frame(reel, to);
kino_reel_transform_set_to_frame(reel, from);
}
kino_reel_scale_segmented_set_end_as_dot(reel, data->mic_window.mic_dot_radius);
kino_layer_play_section(&data->mic_window.icon_layer, 0, UNFO... | if (animation_is_scheduled((Animation *)data->mic_window.fly_anim)) {
GRect to;
property_animation_get_to_grect(data->mic_window.fly_anim, &to);
animation_unschedule((Animation *)data->mic_window.fly_anim);
layer_set_frame(&data->mic_window.mic_dot_layer, &to);
} |
}
static void prv_set_percent(void *subject, int16_t percent) {
VoiceUiData *data = subject;
progress_layer_set_progress((ProgressLayer *)&data->mic_window.progress_bar, percent);
}
static const PropertyAnimationImplementation s_progress_bar_impl = {
.base = {
.update = (AnimationUpdateImplementation) prop... |
(read_buf) | ;
return status;
}
bool pin_db_exists_with_parent(const TimelineItemId *parent_id) {
return timeline_item_storage_exists_with_parent(&s_pin_db_storage, parent_id);
}
status_t pin_db_read_item_header(TimelineItem *item_out, TimelineItemId *id) {
SerializedTimelineItemHeader hdr = {{{0}}};
status_t rv = pin_db_... | |
T_MASTER(SPI1, CORE_DUMP_SPI, CONFIG_SPI_WORD_MODE,
CONFIG_SPI_POL_MODE, CONFIG_SPI_PHASE_MODE,
CONFIG_SPI_DMA_CHANNEL);
void DMA_Handler(void); // This is the Dialog SPI/DMA Interrupt handler
static volatile bool s_spi_dma_complete;
static const ... | (wd_start_ticks, TIMER0_1_S) | ) {
}
}
REG_SET_BIT(CRG_TOP, CLK_RADIO_REG, BLE_LP_RESET); /* reset BLE LP timer */
hw_timer0_disable();
hw_timer1_disable();
// The following block of code was lifted from sys_power_mgr.c:apply_wfi().
//
// TODO: It's not entirely clear what's going on, but it does reduce current draw to ~0 uA. At... |
erState_Possible);
// A touchdown occurs where no layers are touched
s_active_layer = NULL;
e.type = TouchEvent_Touchdown;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0}, 2, &s_recognizers_handled);
prv_compare_recognizers_processed(NULL, 0, &s_recogni... | recognizer_set_manager(r1, &manager) | |
ink control responses before we try to reconnect
#define MAX_STRIKES 3
//! How often we'll go without some valid data from the smartstrap before sending a status message
//! and disconnecting if the smartstrap doesn't reply. This is in seconds.
#define STATUS_CHECK_INTERVAL 5
//! The m... | if (status == LinkControlStatusBaudRate) {
PBL_LOG(LOG_LEVEL_DEBUG, "Got link control status: Baud rate");
prv_do_send(LinkControlTypeBaud);
} else if (status == LinkControlStatusDisconnect) {
PBL_LOG(LOG_LEVEL_DEBUG, "Got link control status: Disconnect");
smartstrap_link_control_disconnect... |
} else if (header->type == LinkControlTypeProfiles) {
// profiles message
if ((data_length % sizeof(uint16_t)) == 0) {
s_profiles = 0;
uint16_t *profiles = (uint16_t *)header->data;
const uint32_t num_profiles = data_length / sizeof(uint16_t);
for (uint32_t i = 0; i < num_profiles; 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... | (addr_hex_str_out, BT_DEVICE_ADDRESS_FMT_BUFFER_SIZE,
BD_ADDR_FMT, BT_DEVICE_ADDRESS_XPLODE(s_local_address)) | ;
} else {
sniprintf(addr_hex_str_out, BT_DEVICE_ADDRESS_FMT_BUFFER_SIZE, "Unknown");
}
}
void bt_local_id_copy_address_mac_string(char addr_mac_str_out[BT_DEVICE_ADDRESS_FMT_BUFFER_SIZE]) {
sniprintf(addr_mac_str_out, BT_DEVICE_ADDRESS_FMT_BUFFER_SIZE,
BT_DEVICE_ADDRESS_FMT, BT_DEVICE_ADDRESS_XP... |
events those threads from blocking each other
uint32_t bytes_to_free = ((s_pfs_page_count * PFS_PAGE_SIZE) * 4) / 100;
PBL_LOG(LOG_LEVEL_DEBUG, "Preparing %"PRIu32" bytes of flash for filesystem use",
bytes_to_free);
pfs_prepare_for_file_creation(bytes_to_free, 15 * RTC_TICKS_HZ);
return (S_SUCCESS)... | (LOG_LEVEL_DEBUG, hdr, sizeof(hdr)) | ;
}
void pfs_command_fs_ls(void) {
char display_buf[80];
int pages_in_use = 0;
prompt_send_response("Page:\tFilename\tFile Size\tFile Info\tErase Count\n");
for (uint16_t pg = 0; pg < s_pfs_page_count; pg++) {
PageHeader pg_hdr;
FileHeader file_hdr;
pg_hdr.page_flags = prv_get_page_flags(pg);
... |
ype.internal_type,
b_event->activity_session.type.type.internal_type);
cl_assert_equal_i(a_event->activity_session.start_reason,
b_event->activity_session.start_reason);
// TODO: Add more detailed comparisons
}
}
}
}
static void prv_fill_v... | protobuf_log_init() | ;
}
// ---------------------------------------------------------------------------------------------
void test_protobuf_log__cleanup(void) {
}
// ---------------------------------------------------------------------------------------------
// Test some simple message variants
void test_protobuf_log__measurements_si... |
{
return data;
} |
}
return NULL;
}
static const TimelineResourceTestAppData *prv_get_data_for_app_with_uuid(const Uuid *uuid) {
for (int i = 0; i < TimelineResourceTestAppIdCount; i++) {
const TimelineResourceTestAppData *data = &s_test_apps[i];
if (uuid_equal(uuid, &data->install_entry.uuid)) {
return data;
}
... | |
Rect container_rect3 = GRect(2, 2, 5, 5);
const GRect resulting_rect3 = grect_centered_from_polar(container_rect3, mode,
DEG_TO_TRIGANGLE(180), GSize(2, 4));
cl_assert_equal_grect(resulting_rect3, GRect(3, 4, 2, 4));
}
void test_graphics_circle__grect_cente... | cl_assert_gpoint_precise(center, -1, -5) | ;
cl_assert_fixedS16_3(radius, 0);
// 2 pixel width means: center is 1px from side, 0.5 pixels to center of outer pixels
r = GRect(-1, -5, 2, 2);
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, -0.5, -4.5);
cl_assert_fixedS16_3(radius, 0.5);
}
void test_graphics_circl... |
t
const uint32_t test_duration = 10000;
const uint32_t duration_a = ANIMATION_DURATION_INFINITE;
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
prv_clear_handler_histories();
animation_schedule(a);
uint64_t start_ms = prv_now_ms();
prv_advance_to_ms_with_timers(sta... | cl_assert(prv_last_handler_entry(&s_stopped_handler_calls, a)->fire_order
< prv_last_handler_entry(&s_started_handler_calls, b)->fire_order) | ;
// Just before B completes the 2nd play
prv_advance_to_ms_with_timers(start_ms + duration_total - 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), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_... |
if (left_margin.raw_value <= right_margin.raw_value) {
graphics_private_plot_horizontal_line(ctx, y, left_margin, right_margin,
(fraction_for_top >> 1));
}
}
for (int16_t y = (fraction_for_top ? y_min + 1 : y_min); y <= y_max; y++) {
if (y > l... | // Top and bottom most point helpers for main loop
GPointPrecise tm_p0 = far_left;
GPointPrecise tm_p1 = far_top;
GPointPrecise bm_p0 = far_left;
GPointPrecise bm_p1 = far_bottom;
const int8_t fraction_for_left = (MIN(p0.x.raw_value, p1.x.raw_value) - radius.raw_value)
... |
// We're crossing far_bottom point, time to swap...
bm_p0 = far_bottom;
bm_p1 = far_right;
}
// Starting and ending point of the line, initialized with extremes
Fixed_S16_3 top_margin = {.raw_value = INT16_MAX};
Fixed_S16_3 bottom_margin = {.raw_value = INT16_MIN};
... |
GRect(0, 0, 150, 600) | );
layer_set_frame(&l, &GRect(10, 20, 100, 700));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 150, 700));
}
| |
/*
* 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... | string_list_count(list) | );
cl_assert_equal_s("ab", string_list_get_at(list, 0));
cl_assert_equal_s("", string_list_get_at(list, 1));
// 2 strings (non-null terminated) - this is the standard case
list->serialized_byte_length = 4;
list->data[0] = 'a';
list->data[1] = 'b';
list->data[2] = '\0';
list->data[3] = 'c'; // end of da... |
ion();
animation_set_duration(b, duration_b);
animation_set_play_count(b, play_count_b);
// Create a sequence
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
// Setup started/stopped handlers for the sequence
const AnimationHandlers handlers = {
.started = prv_started... | prv_count_handler_entries(&s_teardown_handler_calls, b) | |
"comm/ble/gap_le_connection.h"
#include "comm/bt_lock.h"
#include "comm/ble/gap_le_connection.h"
#include "kernel/pbl_malloc.h"
#include "services/common/comm_session/session_internal.h"
#include "services/normal/alarms/alarm.h"
#include "services/normal/timeline/timeline.h"
#include "syscall/syscall.h"
#include "sysca... | ("pin %s event: timestamp: %"PRIu32", uuid:%s", verb,
event_blob.pin_open_create_update.time_utc, uuid_string) | ;
#endif
analytics_logging_log_event(&event_blob);
}
// ------------------------------------------------------------------------------------------
// Log a pin open event.
void analytics_event_pin_open(time_t timestamp, const Uuid *parent_id) {
prv_simple_pin_event(timestamp, parent_id, AnalyticsEvent_PinOpen, "... |
ibuteIdIconTiny, config->icon);
attribute_list_add_resource_id(&pin_attr_list, AttributeIdIconSmall,
s_tier_config[tier].card_icon);
attribute_list_add_uint8(&pin_attr_list, AttributeIdDisplayTime, WeatherTimeType_None);
attribute_list_add_uint32(&pin_attr_list, AttributeIdLastUp... | stats_calculate_basic(op, &history[1], ACTIVITY_HISTORY_DAYS - 1, prv_stats_filter, NULL,
&result.mean) | ;
*stats = (ActivityInsightMetricHistoryStats) {
.metric = metric,
.mean = result.mean,
.total_days = result.count,
.consecutive_days = result.first_streak,
.median = result.median,
};
kernel_free(history);
INSIGHTS_LOG_DEBUG("Metric history stats - med: %"PRIu16" mean: %"PRIu16" tot: %"P... |
d(seq, &position);
cl_assert_equal_i(position, duration_a + delay_a - leftover_a);
// Now, advance sequence to almost the end of seq. Positions don't include the delay, so
// pass false for 'include_delay'
animation_set_elapsed(seq, animation_get_duration(seq, false /*delay*/, true /*play_count*/)
... | animation_set_elapsed(seq, animation_get_duration(seq, false /*delay*/, true /*play_count*/)
- leftover_seq) | ;
// Verify that a finished and that a's stop handler got called before B's start handler
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX);
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... |
/*
* 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 (this->state->link_state == LinkState_Opened &&
nextstate != LinkState_Opened) {
this->on_this_layer_down(this);
} | |
veCustomInterpolationFunction,
interpolate_function);
}
// -------------------------------------------------------------------------------------------
static void *prv_animation_get_custom_function(Animation *animation_h, AnimationCurve curve) {
if (animation_private_using_... | (state, animation_h, false /*quiet*/) | ;
if (!prv_is_mutable(state, animation)) {
return false;
}
if (play_count == ANIMATION_PLAY_COUNT_INFINITE) {
animation->play_count = ANIMATION_PLAY_COUNT_INFINITE_STORED;
} else if (play_count > ANIMATION_PLAY_COUNT_INFINITE_STORED) {
// We can't support play counts greater than ANIMATION_PLAY_COU... |
recognizers_processed(NULL, 0, &s_recognizers_handled);
prv_compare_recognizers_processed(NULL, 0, &s_recognizers_reset);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
// Layer A's recognizer's gesture completes immediately. All recognizers receive the touch event
// because Layer ... | cl_assert_equal_i(recognizers[0]->state, RecognizerState_Started) | ;
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Cancelled); // was already cancelled
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Failed);
// A child layer of the active layer becomes active when a window recognizer is triggered
e.type = TouchEvent_Touchdown;
s_active_layer = &layer_c;... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG_SYNC(LOG_LEVEL_INFO, "Factory resetting...") | ;
// This function can block the system task for a long time.
// Prevent callbacks being added to the system task so it doesn't overflow.
system_task_block_callbacks(true /* block callbacks */);
launcher_block_popups(true);
worker_manager_disable();
event_service_clear_process_subscriptions(PebbleTask_App... |
/*
* 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... | PASSED(prv_open(&settings_file)) | ) {
settings_file_rewrite(&settings_file, prv_rewrite_cb, NULL);
settings_file_close(&settings_file);
}
}
|
// Slice 2 (invalid total_size)
0xFF, 0x00, // Total size
0x00, // AppGlanceSliceType - AppGlanceSliceType_IconAndSubtitle
0x01, // Number of attributes
// Slice Attributes
0x25, // Attribute ID - AttributeIdTimestamp
0x0... | app_glance_db_read((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE, glance_out,
glance_size) | |
(true /* start_connected */);
RCV_RESET_REQUEST();
EXPECT_OUTBOX_RESET_COMPLETE_PENDING();
prv_rcv_app_message_ack(APP_MSG_OK);
cl_assert_equal_i(rocky_api_app_message_get_state(),
PostMessageStateAwaitingResetCompleteRemoteInitiated);
}
static void prv_init_and_goto_awaiting_reset_compl... | {
prv_init_and_goto_awaiting_reset_complete_local_initiated();
} |
void test_rocky_api_app_message__awaiting_reset_complete_loc_init__rcv_reset_request(void) {
prv_init_and_goto_awaiting_reset_complete_local_initiated();
RCV_RESET_REQUEST();
EXPECT_OUTBOX_RESET_COMPLETE_PENDING();
prv_rcv_app_message_ack(APP_MSG_OK);
cl_assert_equal_i(rocky_api_app_message_get_state(),
... |
_png_test(TEST_PNG_FILE_FMT(4bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(4bitpalette)));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat4BitPalette);
}
// Tests 8-bit palettized 64-color PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__c... | setup_png_test(TEST_PNG_FILE_FMT(4bitpalette)) | ;
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(4bitpalette)));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat4BitPalette);
}
// Tests 8-bit transparent color PNG with 4-bit number of colors (<= 16 colors)
// loading into gbitmap
// Checks for bug fixed for PBL-15809, where GBitmap depth was base... |
} else {
ptr_bitmap = &data->deselected_icon;
}
graphics_context_set_compositing_mode(ctx, GCompOpTint);
menu_cell_basic_draw_icon_right(ctx, cell_layer, cell_text, NULL, ptr_bitmap);
}
}
static bool prv_is_custom_day_scheduled(AlarmEditorData *data) {
for (unsigned int i = 0; i < sizeof(data... | gbitmap_init_with_resource(&data->checkmark_icon, RESOURCE_ID_CHECKMARK_ICON_BLACK);
data->current_checkmark_icon_resource_id = RESOURCE_ID_CHECKMARK_ICON_BLACK;
app_window_stack_push(&data->custom_day_picker_window, true);
} |
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Time Picker
static void prv_time_picker_window_unload(Window *window) {
AlarmEditorData *data = (AlarmEditorData *)window_get_user_data(window);
if (data->creating_alarm) {
#if !CAPABILITY_HAS_HEALTH_TRACKING
... |
BIT_DEPTH_NAME}__draw_antialiased(void) {
// Stroke width = 1, antialiased
setup_test(&context, true, 1, GColorBlack, GColorBlack, false);
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10));
#if PBL_COLOR
ASSERT_CALLED(graphics_line_draw_1px_aa(&context, GPoint(5, 5), GPoint(45, 10)));
#else
ASSERT_CA... | (&context, &GRect(20, 80, 40, 10), 4, SW_EVEN) | );
}
void test_graphics_context_${BIT_DEPTH_NAME}__draw_stroke_width_odd(void) {
// Stroke width odd > 1, non-antialiased
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10));
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, G... |
/*
* 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 (node->next != NULL) {
node = node->next;
} |
return node;
}
ListNode* list_get_head(ListNode* node) {
if (node == NULL) {
return NULL;
}
while (node->prev != NULL) {
node = node->prev;
}
return node;
}
bool list_is_head(const ListNode *node) {
if (!node) {
return false;
}
return !node->prev;
}
bool list_is_tail(const ListNode *no... |
E_BUSY;
} else if (flag_status_reg & dev->state->part->flag_status_bit_masks.erase_suspend) {
return E_AGAIN;
} else {
return S_SUCCESS;
}
}
status_t qspi_flash_erase_begin(QSPIFlash *dev, uint32_t addr, bool is_subsector) {
uint8_t instruction;
if (is_subsector) {
instruction = dev->state->part... | (dev->qspi, instruction, addr, dummy_cycles, buffer, length, is_ddr) | |
---------------------
static void prv_send_bytes(void *p, uint32_t size) {
uint8_t *src = (uint8_t *)p;
for (uint32_t i=0; i<size; i++) {
qemu_test_add_byte_from_isr(&s_state, *src++);
}
}
// ------------------------------------------------------------------------------------
static void prv_send_hdr(uint16... | prv_send_footer();
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
} | |
/*
* 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... | (fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
const GContextInitializationMode context_init_mode = GContextInitializationMode_System;
graphics_context_init(&s_ctx, fb, context_init_mode);
framebuffer_clear(fb);
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixtu... |
s_count == 0 && !s_data_subscribers) {
PBL_LOG(LOG_LEVEL_DEBUG, "Stopping accel service");
if (accel_running()) {
accel_stop();
}
}
}
mutex_unlock_recursive(s_mutex);
}
// -------------------------------------------------------------------------------------------
DEFINE_SYSCALL(void,... | {
accel_start();
} |
AccelData data;
int result = sys_accel_manager_peek(&data);
PBL_LOG(LOG_LEVEL_DEBUG, "result: %d", result);
char buffer[20];
prompt_send_response_fmt(buffer, sizeof(buffer), "X: %"PRId16, data.x);
prompt_send_response_fmt(buffer, sizeof(buffer), "Y: %"PRId16, data.y);
prompt_send_response_fmt(buffer, s... |
GPointZero, GCompOpAssign, GColorWhite);
const int16_t y_lower = y_upper + LEGEND_HEIGHT + NUM_COLORS + OFFSET;
const GRect lower_rect = GRect(x, y_lower, WIDTH, 1);
const GRect lower_left_legend_rect = GRect(0, y_lower, 3, 1);
const GRect lower_right_legend_rect = GRect(offset_x, y_... | (&dest_bitmap, src_bitmap, dest_offset, GCompOpAssign, GColorWhite) | ;
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_clipping-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test horizontal wrapping when dest_rect wider than src_bitmap.
// Setup:
// - Source 15 x 10, each row has the folling pattern:
// - 2px Red
// - 13px Black
// - Dest Green ... |
, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 12 H", time_buf);
// June 12th 2015, 00:29:29 (T-11:30:31)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) + (29 * SECONDS_PER_MINUTE) + 29);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 12 H", t... | clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("10 MIN AGO", time_buf);
// June 9th 2015, 12:10:30 (T+00:10:30)
rtc_set_time(event_time + (10 * SECONDS_PER_MINUTE) + 30);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("10 MIN AGO", time_buf);
// June 9th 2015, 12:10:59 ... |
/*
* 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... | text_layer_get_layer(localtime_layer) | |
" MMP: %"PRIu32,
size, dma_time, pol_time, mmap_time);
kernel_free(buffer_dma_ptr);
kernel_free(buffer_pol);
kernel_free(buffer_mmap);
return success;
}
struct FlashReadTestValues {
int size;
int offset;
};
const struct FlashReadTestValues FLASH_READ_TEST_TABLE[] = {
{ .si... | ("FAILURE: sector not blank!?!") | ;
} else {
++passes;
}
profiler_start();
is_blank = flash_impl_blank_check_subsector(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN);
profiler_stop();
blank = profiler_get_total_duration(true);
prompt_send_response_fmt(buf, buf_size, "Subsector blank check via read took: %"PRIu32,
bl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | list_find((ListNode *)head, prv_filter, uuid) | ;
return node;
}
static bool prv_is_in_window(time_t node_timestamp, uint16_t node_duration, time_t timestamp) {
time_t future_window = time_util_get_midnight_of(timestamp + TIMELINE_FUTURE_WINDOW);
time_t past_window = time_util_get_midnight_of(timestamp - TIMELINE_PAST_WINDOW);
time_t end_time = node_timesta... |
day_high = 68,
.today_low = 52,
.current_weather_type = WeatherType_Sun,
.current_weather_phrase = TEST_WEATHER_DB_SHORT_PHRASE_SUNNY,
.tomorrow_high = 70,
.tomorrow_low = 60,
.tomorrow_weather_type = WeatherType_CloudyDay
},
{
.location_name = TEST_WEATHER_DB_LOCATION_KITCHENER,
.is... | (&flush_event, s_event_info->context) | |
n calculation is correct
int32_t angle = DEG_TO_TRIGANGLE(45);
int32_t cosine = cos_lookup(angle);
GTransformNumber num = GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO);
GTransformNumber num2 =
(GTransformNumber) { .raw_value = (int32_t)(((int64_t)cosine *
... | (1, 2, 3, 4, 5, 6) | ;
gtransform_concat(&t_new, &t1, &t2);
cl_assert(gtransform_is_equal(&t_new, &t_c));
// Test pointer re-use
gtransform_concat(&t2, &t1, &t2);
cl_assert(gtransform_is_equal(&t2, &t_c));
// Test non-identity concatenation with identity
t1 = GTransformIdentity();
t2 = GTransformFromNumbers(1, 2, 3, 4, 5,... |
alid(ResAppNum app_num, uint32_t resource_id,
uint32_t expected_signature, uint32_t *data_size) {
// Load file signature, and check that it matches the expected_signature
uint32_t data_signature;
if (!(sys_resource_load_range(app_num, resource_id, 0, (uint8_t*)&data_si... | if (!score) {
return 0;
} |
GenericAttribute *notes_attribute = generic_attribute_find_attribute(&score->attr_list,
VibeAttributeId_Notes,
score->attr_list_size);
GenericAttribute *pattern_attribute = ... |
d:
#if PBL_RECT
/// Speed Label
return i18n_noop("SPEED");
#else
/// Speed Label with units
return active_window->workout_controller->get_distance_string(i18n_noop("SPEED (MPH)"),
i18n_noop("SPEED (KM/H)"));
#endif
case Work... | (container, &heart_node->node) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (abs(a.ty.integer - b.ty.integer) < 10) | ;
}
// --------------------------------------------------------------------------------------
static void cl_assert_equal_fixed_s32_16(const Fixed_S32_16 a, const Fixed_S32_16 b) {
cl_assert_equal_i(a.raw_value, b.raw_value);
}
static void cl_assert_close_fixed_s32_16(const Fixed_S32_16 a, const Fixed_S32_16 b) {
... |
ms_util.h"
#include "clar.h"
// Stubs
///////////////////////////////////////////////////////////
#include "stubs_logging.h"
// Helpers
///////////////////////////////////////////////////////////
static char s_results[10][32];
static uint32_t s_results_lengths[10];
static uint8_t s_results_count;
static uint32_t s... | ("2147483648", 1, false, 0) | ;
// succeeds:
// "2147483647" * 1
assert_float_parse("2147483647", 1, true, 2147483647);
}
void test_ams_util__float_string_parse_overflow_negative(void) {
// fails:
// "-2147483649" * 1
assert_float_parse("-2147483649", 1, false, 0);
// succeeds:
// "-2147483648" * 1
assert_float_parse("-21474836... |
erRef recognizer, void *context) {
TimelineAppData *data = context;
prv_exit(data);
}
static void prv_up_down_stopped(Animation *animation, bool finished, void *context) {
TimelineAppData *data = context;
if (finished) {
prv_set_state(data, TimelineAppStateStationary);
}
}
static void prv_hide_day_sep_s... | (&data->timeline_layer, new_idx) | ;
}
timeline_layer_move_data(&data->timeline_layer, 1);
} else {
if (!timeline_model_iter_prev(&new_idx, &has_new)) {
prv_exit(data);
goto done;
}
if (has_new) {
timeline_layer_set_prev_item(&data->timeline_layer, new_idx);
}
timeline_layer_move_data(&data->timeline_layer... |
{ -856, 120, 248},
{ -880, 16, 248},
{ -888, -8, 224},
{ -864, 32, 216},
{ -968, 96, 176},
{ -1032, -40, 24},
{ -1120, -128, 56},
{ -1472, 240, 264},
{ -1256, 392, -40},
{ -1160, 392, -64},
{ -1200, -40, 96},
{ -1320, 48, 272},
{ -1192, 352, 200},
{ -952, 496, 96},... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-02 15:39:33 local
AccelRawData *activity_sample_walk_100_pbl_25478_6(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25478_6
//> TEST... |
is_clip_box_overflow_top_stop_condition_cb(ctx, line, text_box_params) | );
}
#define TEXT_LINE_BASE_LINE(line) ((line)->height_px)
#define TEXT_LINE_CAP_LINE(line) ((line)->height_px * 1 / 2)
// Based on Gothic fonts, DESCENDER is approx 1/5 of height (ascender + descender)
// Gothic 24 Bold ascent = 840, descent 168
// Gothic 18 Bold ascent = 840, descent 168
// Gothic 14 ascent = 864, d... | |
PBL_ASSERTN(framebuffer->bounds.origin.x == 0 && framebuffer->bounds.origin.y == 0);
// Clip the line to the bitmap data row's range, taking into account fractions
const GBitmapDataRowInfo destination_data_row_info = gbitmap_get_data_row_info(framebuffer, y);
x1.raw_value = MAX(x1.raw_value, destination_data_ro... | gbitmap_get_data_row_info(&app_framebuffer, y1.integer) | ;
input = (GColor8 *)(source_data_row_info.data + x);
destination_data_row_info = gbitmap_get_data_row_info(framebuffer, y1.integer);
output = (GColor8 *)(destination_data_row_info.data + x);
}
// middle pixels
while (y1.integer <= y2.integer) {
// Only draw the pixel if its within the bitmap dat... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(mfg_info_get_rtc_freq(), 0xfefefefe) | ;
mfg_info_set_rtc_freq(1337);
cl_assert_equal_i(mfg_info_get_rtc_freq(), 1337);
}
void test_snowy_mfg_info__model(void) {
// Intentionally make the buffer too long so we can check for truncation.
char buffer[MFG_INFO_MODEL_STRING_LENGTH + 1] = { 0 };
mfg_info_get_model(buffer);
cl_assert_equal_s(buffer,... |
alue len;
ActualValue start_at;
float weighted_err;
bool all_passed;
} ActivityTestResults;
typedef struct {
KAlgActivityType activity;
time_t start_utc;
uint16_t len_minutes;
bool ongoing;
uint16_t steps;
uint32_t resting_calories;
uint32_t active_calories;
uint32_t distance_mm;
} KAlgTestActi... | (num_stats, s_stats_num_columns) | ;
// Create a new row of stats
StatsRow *stats = malloc(sizeof(StatsRow));
memset(stats, 0, sizeof(*stats));
// Collect the stats and also print them out
for (int i = 0; i < num_stats; i++) {
printf("%s: %d, ", names[i], values[i]);
stats->values[i] = values[i];
}
printf("\n");
// Append to t... |
under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "services/common/shared_prf_storage/shared_prf_storage.h"
#include "ser... | (device_name, name_out) | , 0);
cl_assert_equal_b(pairing_info->is_remote_signing_info_valid,
pairing_info_out.is_remote_signing_info_valid);
cl_assert_equal_b(pairing_info->is_remote_identity_info_valid,
pairing_info_out.is_remote_identity_info_valid);
cl_assert_equal_b(pairing_info->is_remote_encr... |
m in the event the app inbox write fails in the end.
//! We only want to write up to MAX_HEADER_SIZE, to keep the kernel heap impact to a minimum.
size_t header_bytes_remaining;
//! Pointer to the default system receiver context, to which we want to forward the header data.
Receiver *kernel_receiver;
} AppMess... | (ANALYTICS_APP_METRIC_MSG_BYTE_IN_COUNT, length, AnalyticsClient_App) | ;
if (rcv->header_bytes_remaining > 0) {
const size_t header_bytes_to_write = MIN(rcv->header_bytes_remaining, length);
g_default_kernel_receiver_implementation.write(rcv->kernel_receiver,
data, header_bytes_to_write);
rcv->header_bytes_remaining -= head... |
28},
{ -736, 200, 472},
{ -752, 88, 816},
{ -888, -80, 1080},
{ -960, 208, 1152},
{ -776, 440, 1008},
{ 2712, 4000, -4000},
{ -2848, -240, 1248},
{ -368, 1864, -496},
{ -1176, 128, 248},
// 303 seconds
{ -712, 632, -16},
{ -832, 296, 440},
{ -1000, -240, 1184},
{ ... | { -344, 384, -1544},
{ 176, 160, -1232},
// 308 seconds
{ -456, -264, -224},
{ 24, 616, -1368},
{ 144, 424, -688},
{ -24, 864, -880},
{ 24, 856, -776},
{ 72, 600, -864},
{ 56, 560, -840},
{ 56, 592, -864},
{ 56, 552, -872},
{ 80, 544, -880},
{ 72, 584, -872},
... |
{ 56, 592, -864},
{ 56, 592, -872},
{ 56, 592, -872},
{ 56, 576, -872},
{ 48, 568, -872},
{ 48, 568, -880},
{ 48, 568, -880},
{ 48, 568, -888},
// 311 seconds
{ 64, 568, -880},
{ 64, 560, -888},
{ 56, 568, -880},
{ 64, 560, -880},
{ 56, 576, -880},
{ 72, 576,... |
s 0 if not in table. Otherwise, returns the rank in `s_override_table`. Rank is
// where the lowest index returns the highest rank
static int prv_override_index(AppInstallId app_id) {
const uint32_t num_overrides = ARRAY_LENGTH(s_override_table);
for (uint32_t i = 0; i < num_overrides; i++) {
AppInstallId cur_i... | {
menu_node->storage_order = AppMenuStorageOrder_SettingsDefaultOrder;
} |
source->list = (AppMenuNode *)list_sorted_add(&source->list->node, &menu_node->node,
prv_app_node_comparator, true /* ascending */);
}
////////////////////////////////
// AppInstallManager Callbacks
////////////////////////////////
typedef struct InstallData {
App... |
LED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__fill(void) {
// Fill shape, non-antialiased (Stroke width/color N/A)
setup_test(&context, false, 5, GColorBlack, GColorBlack, false);
graphics_fill_rect(&context, &GRect(10, 20, 4... | GPoint(45, 10) | ));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, true, 2, GColorBlack, GColorBlack, true);
ASSERT_NO_CHANGE(gr... |
6, 272, -64},
{ 792, 264, -56},
{ 720, 208, -40},
{ 744, 184, -32},
{ 816, 176, -24},
{ 888, 152, 8},
{ 1040, 184, -16},
{ 1064, 168, 0},
{ 1088, 128, -32},
{ 1232, 168, -72},
{ 1112, 176, -104},
{ 920, 152, -160},
{ 1048, 168, -176},
{ 1168, 208, -144},
{ 1064, 2... | { 992, 368, -264},
{ 1232, 392, -176},
// 56 seconds
{ 1208, 432, -200},
{ 1064, 416, -136},
{ 984, 352, -120},
{ 1088, 352, -104},
{ 1096, 304, -48},
{ 984, 256, 0},
{ 880, 200, 0},
{ 776, 192, 8},
{ 736, 144, 16},
{ 768, 224, -24},
{ 792, 160, -16},
{ 904, 1... |
{ 984, 216, 16},
{ 800, 176, -16},
{ 704, 192, -40},
{ 688, 200, -16},
{ 768, 208, 24},
{ 832, 160, 56},
{ 984, 184, -8},
{ 1056, 200, -48},
{ 1072, 168, -72},
{ 1176, 192, -160},
// 59 seconds
{ 1048, 160, -120},
{ 976, 168, -120},
{ 1080, 264, -112},
{ 1216... |
/*
* 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 (values[i] > values[j]) {
swap16(&values[i], &values[j]);
}
} |
}
}
static void swapIntersections(Intersection *a, Intersection *b) {
Intersection t = *a;
*a = *b;
*b = t;
}
static void sortIntersections(Intersection *values, size_t length) {
for (unsigned int i = 0; i < length; i++) {
for (unsigned int j = i+1; j < length; j++) {
if (values[i].x.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... | (&state->did_focus_info) | ;
}
if (handlers.will_focus) {
state->will_focus_info.type = PEBBLE_APP_WILL_CHANGE_FOCUS_EVENT;
state->will_focus_info.handler = prv_focus_event_handler;
event_service_client_subscribe(&state->will_focus_info);
}
state->handlers = handlers;
}
void app_focus_service_subscribe(AppFocusHandler handle... |
ead(BLECharacteristic characteristic,
GAPLEClient client) {
if (s_read_return_value != BTErrnoOK) {
return s_read_return_value;
}
Read *read = malloc(sizeof(Read));
*read = (const Read) {
.characteristic = characteristic,
.client = client,
};
if (s_read_head) {
li... | (client, s_read_head->client) | ;
} else {
cl_assert_(false, "No gatt_client_op_read() has happened at all");
}
Read *old_head = s_read_head;
s_read_head = (Read *) list_pop_head(&s_read_head->node);
free(old_head);
}
void fake_gatt_client_op_set_write_return_value(BTErrno e) {
s_write_return_value = e;
}
void fake_gatt_client_op_cl... |
0;
}
void app_manager_put_launch_app_event(const AppLaunchEventConfig *config) {
app_run_state_send_update(&app_manager_get_current_app_md()->uuid, RUNNING);
}
void process_manager_put_kill_process_event(PebbleTask task, bool gracefully) {
app_run_state_send_update(&app_manager_get_current_app_md()->uuid, NOT_RU... | (s_launcher_deprecated_messages, 0) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | notification_storage_remove(¬ification->header.id) | ;
notification_storage_store(notification);
// we won't use this anywhere, free up the memory
timeline_item_destroy(notification);
}
static time_t prv_get_timestamp_from_ancs_date(const ANCSAttribute *date,
const ANCSAttribute *app_id) {
time_t timestamp = ancs_n... |
assert_equal_i(last_touch_event.type, TouchEvent_Liftoff);
cl_assert_equal_b(updated, true);
cl_assert_equal_i(rec_event, RecognizerEvent_Completed);
r->state = RecognizerState_Possible;
updated = false;
new_state = RecognizerState_Started;
recognizer_handle_touch_event(r, &(TouchEvent) { .type = TouchEven... | (r1, NULL) | );
cl_assert(!recognizer_should_evaluate_simultaneously(NULL, r2));
cl_assert(!recognizer_should_evaluate_simultaneously(r1, r2));
recognizer_set_simultaneous_with(r1, prv_simultaneous_with_cb);
cl_assert(!recognizer_should_evaluate_simultaneously(NULL, NULL));
cl_assert(!recognizer_should_evaluate_simultane... |
};
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
animation_set_delay(a, delay_a);
animation_set_auto_destroy(a, auto_destroy);
animation_schedule(a);
Animation *b = prv_create_test_animation();
animation_set_implementation(b, &implementation);
animation_set_durat... | animation_get_custom_interpolation(a) | , NULL);
cl_assert_equal_i(animation_get_curve(a), AnimationCurveDefault);
animation_set_custom_curve(a, curve);
cl_assert_equal_p(animation_get_custom_curve(a), curve);
cl_assert_equal_p(animation_get_custom_interpolation(a), NULL);
cl_assert_equal_i(animation_get_curve(a), AnimationCurveCustomFunction);
... |
ware_update_is_in_progress = false;
prv_receive_commit(s_last_response_cookie, EXPECTED_CRC);
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__commit_message_crc_mismatch(void) {
prv_receive_init_and_put_fw_object();
prv_receive_commit(s_last_response_cookie, ~EXPECTED_CRC);
assert_ack_co... | ((s_boot_bits_orred & BOOT_BIT_NEW_SYSTEM_RESOURCES_AVAILABLE),
BOOT_BIT_NEW_SYSTEM_RESOURCES_AVAILABLE) | ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Timeouts
void test_put_bytes__init_starts_timeout_timer(void) {
prv_receive_init_fw_object();
TimerID timer_id = put_bytes_get_timer_id();
cl_assert_equal_b(true, stub_new_timer_is_scheduled(timer_id));
... |
/*
* 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... | circular_cache_get(&s_test_cache, &s_test_item[0]) | );
cl_assert(!circular_cache_get(&s_test_cache, &s_test_item[1]));
cl_assert(!circular_cache_get(&s_test_cache, &s_test_item[2]));
circular_cache_push(&s_test_cache, &s_test_item[0]);
circular_cache_push(&s_test_cache, &s_test_item[1]);
cl_assert(!circular_cache_get(&s_test_cache, &s_test_item[2]));
cl_as... |
/*
* 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_stack_push(window, animated) | ;
}
static void deinit(void) {
window_destroy(window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
0},
{ -56, 928, 440},
{ -56, 928, 432},
{ -56, 928, 440},
{ -56, 936, 432},
{ -56, 928, 432},
{ -56, 936, 432},
{ -56, 936, 432},
{ -56, 928, 432},
{ -56, 928, 432},
{ -48, 936, 432},
{ -48, 936, 424},
{ -56, 936, 424},
{ -56, 928, 424},
{ -56, 936, 424},
{ -5... | { -8, 1032, 112},
{ -8, 1048, 104},
{ -8, 1040, 88},
{ -8, 1040, 72},
{ -8, 1024, 56},
{ 8, 1016, 40},
{ 8, 1064, 32},
{ 8, 1008, 8},
{ 0, 1096, 0},
{ -8, 1008, 0},
{ 0, 1016, -8},
{ -8, 1032, 0},
{ 0, 1048, 24},
// 36 seconds
{ 0, 1048, 40},
{ 0, 1064, 56... |
{ -24, 1032, 40},
{ -24, 1040, 48},
{ -16, 1064, 48},
{ -24, 1024, 48},
{ -16, 1064, 48},
{ -24, 1016, 32},
{ -16, 1040, 24},
{ -16, 1056, 40},
{ -16, 1024, 32},
{ -24, 1032, 32},
{ -24, 1056, 40},
{ -16, 1048, 16},
{ -16, 1032, 8},
// 39 seconds
{ -16, 1040,... |
/*
* 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... | {
PebbleEvent event = {
.type = PEBBLE_BT_CONNECTION_DEBOUNCED_EVENT,
.bluetooth.comm_session_event.is_open = s_debounced_state_is_connected[conn_id],
.bluetooth.comm_session_event.is_system = (conn_id == MobileAppDebounce),
};
event_put(&event);
} | |
/*
* 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 (text_layer == NULL) {
return;
}
layer_deinit(&text_layer->layer);
graphics_text_layout_cache_deinit(&text_layer->layout_cache);
text_layer->layout_cache = NULL;
} |
Layer* text_layer_legacy2_get_layer(TextLayerLegacy2 *text_layer) {
if (text_layer == NULL) {
return NULL;
}
return &text_layer->layer;
}
void text_layer_legacy2_set_size(TextLayerLegacy2 *text_layer, const GSize max_size) {
if (text_layer == NULL) {
return;
}
layer_set_frame(&text_layer->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... | free(result) | ;
return;
}
prev = result;
result = result->next;
}
}
//! Finds ScanResult based on BTDevice. If found, unlink and return ScanResult.
static ScanResult *list_unlink(const BTDevice *device) {
ScanResult *prev = NULL;
ScanResult *result = s_head;
while (result) {
if (bt_device_equal(&result... |
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
1... | cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | |
TimelineItemTypePin, LayoutIdGeneric,
&list, NULL);
pin_db_insert_item_without_event(item);
timeline_item_destroy(item);
attribute_list_destroy_list(&list);
}
static void prv_add_activity_session_pin(int32_t ... | prv_add_sports_pin(3 * 60 * 60, GColorWhite, is_ingame, has_broadcaster) | ;
prv_add_calendar_pin(4 * 60 * 60, 60, !is_all_day, recurring, 0, 0);
prv_add_calendar_pin(6 * 60 * 60, 60, !is_all_day, recurring, 0, 0);
prv_add_generic_pin(7 * 60 * 60, has_subtitle);
prv_add_generic_pin(8 * 60 * 60, !has_subtitle);
prv_add_weather_pin(1 * 24 * 60 * 60);
prv_add_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
TestImplData *data = recognizer_get_impl_data(recognizer, &s_test_impl);
cl_assert_equal_i(data->test, TEST_PATTERN);
if (data->last_touch_event) {
*data->last_touch_event = *touch_event;
}
if (data->handled) {
*data->handled = true;
}
if(data->new_state && (*data->new_state != RecognizerState_P... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | periph_config_release_lock() | ;
gpio_use(BOARD_CONFIG.mic_config.i2s_ck.gpio);
gpio_use(BOARD_CONFIG.mic_config.i2s_sd.gpio);
// Configure pins as SPI/I2S pins
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOP... |
er_not_active(void) {
prv_set_step_history_avg();
activity_insights_init(rtc_get_time());
// Make sure that being above average but not active doesn't trigger
s_data.steps_per_minute = 0;
s_data.metric_history[ActivityMetricStepCount][0] = HIGH_STEPS;
prv_minute_update(ACTIVE_MINUTES);
cl_assert_equal_i(... | activity_insights_process_sleep_data(rtc_get_time()) | ;
cl_assert_equal_i(s_data.pins_added, 1);
Uuid orig_id = s_last_timeline_id;
// Advance to midnight and perform the midnight rollover logic
rtc_set_time(rtc_get_time() + 15 * SECONDS_PER_MINUTE); // Puts us at midnight
activity_insights_recalculate_stats(); // Process the midnight rollove... |
(&ctx, GPoint(22, 0), MAX_NUM_ROWS + 1 ) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_even_cols_no_clip")));
// Odd cols of different lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(1, 0), MAX_NUM_ROWS);
... | |
/*
* 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... | {
WTF;
} | |
th) {
PBL_ASSERT_TASK(PebbleTask_KernelBackground);
PebbleEvent event = {
.type = PEBBLE_SMARTSTRAP_EVENT,
.smartstrap = {
.type = type,
.profile = profile,
.result = result,
.read_length = read_length,
},
};
mutex_lock(s_attr_list_lock);
SmartstrapAttributeInternal *attr =... | {
system_task_add_callback(prv_do_deferred_delete_cb, NULL);
s_deferred_delete_queued = true;
} |
}
DEFINE_SYSCALL(void, sys_smartstrap_attribute_unregister, SmartstrapAttribute *app_attr) {
mutex_lock(s_attr_list_lock);
SmartstrapAttributeInternal *attr = prv_find_by_buffer((uint8_t *)app_attr);
if (!attr) {
mutex_unlock(s_attr_list_lock);
return;
}
prv_queue_deferred_delete(attr, true /* do_fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.