prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
_datetime__locale_time_string_options(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT("var d = new Date();");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {second: 'numeric'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "5");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {second: '2-digit'});");
ASSE... | EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {year: 'numeric'});") | ;
ASSERT_JS_GLOBAL_EQUALS_S("s", "2005");
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {year: '2-digit'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "05");
}
void test_rocky_api_datetime__locale_date_string_time_options(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT("var d = new Date();");
EXECUTE_SCRIP... |
/*
* 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... | ARRAY_LENGTH(s_mbuf_pool_space) | |
the video
#define SLIDE_DURATION_MS 107
// 5 frames in the video
#define SLIDE_SETTLE_DURATION_MS 179
typedef struct SelectionSizeConfig {
const char *font_key;
int default_cell_height;
} SelectionSizeConfig;
static const SelectionSizeConfig s_selection_config_medium = {
.font_key = FONT_KEY_GOTHIC_28_BOLD,
... | (selection_layer->bump_settle_anim_progress) | ;
}
// The height of each cell default to the height of the frame.
int original_height = selection_layer->layer.frame.size.h;
int adjusted_height = original_height;
if (selection_layer->selected_cell_idx == i) {
// If we are currently doing the increment animation then the height must be incr... |
[3];
(*state)[1][3]=(*state)[2][3];
(*state)[2][3]=(*state)[3][3];
(*state)[3][3]=temp;
}
// Cipher is the main function that encrypts the PlainText.
static void Cipher(void)
{
uint8_t round = 0;
// Add the First round key to the state before starting the rounds.
AddRoundKey(0);
// There will be Nr ro... | if(remainders)
{
BlockCopy(output, input);
memset(output+remainders, 0, KEYLEN - remainders); /* add 0-padding */
state = (state_t*)output;
InvCipher();
} |
}
#endif // #if defined(CBC) && CBC
bool aes_128_encrypt_block(const uint8_t key[AES_128_KEY_SIZE],
const uint8_t plain_text_block[AES_128_BLOCK_SIZE],
uint8_t cipher_text_block_out[AES_128_BLOCK_SIZE]) {
AES128_ECB_encrypt(plain_text_block, key, cipher_text_b... |
oid) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int delay_a = 100;
const int play_count_a = 1;
const int total_duration_a = play_count_a * (delay_a + duration_a);
const int duration_b = 500;
const int delay_b = 200;
const int play_count_b = 3;
const int total_duration_b = play_coun... | prv_create_test_animation() | ;
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
// Try to create a spawn out of b and c
Animation *c = prv_create_test_animation();
Animation *spawn = animation_spawn_create(c, b, NULL);
cl_assert(spawn == NULL);
// We should be able to create one out of c and d
Anima... |
e_touch_event,
.cancel = prv_cancel,
.reset = prv_reset,
};
}
void test_recognizer_manager__cleanup(void) {
prv_clear_recognizers_processed(&s_recognizers_handled);
prv_clear_recognizers_processed(&s_recognizers_reset);
}
static void prv_store_recognizer_idx(Recognizer *recognizer, ListNode **list) {
... | prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL) | );
prv_compare_recognizers_processed((int[]) {4, 2, 3}, 3, &s_recognizers_handled);
// Recognizers attached to window processed before layer recognizers
recognizer_add_to_list(recognizers[5], window_get_recognizer_list(&window));
cl_assert(prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NUL... |
m.bytes_written + calc_size;
// If it fits, add it. If it doesn't, flush first.
if (size_if_added > session->max_data_size) {
// We would be over capacity if we added this message. Let's flush first.
PROTOBUF_LOG_DEBUG("Session: 0x%x - Would have been over limit at size %"PRIu32", flushing",
... | if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Failure when sending encoded message, resetting session");
} | |
_DeInit(FLASH_TX_DMA_STREAM);
/* RX DMA config */
DMA_StructInit(&dma_config);
dma_config.DMA_Channel = FLASH_DMA_CHANNEL;
dma_config.DMA_DIR = DMA_DIR_PeripheralToMemory;
dma_config.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
dma_config.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
dma_config.... | flash_read_next_byte() | |
/*
* 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... | (GColorBlackARGB8, fun(GColorFromHEX(0x00aaff)).argb) | ;
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0055)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x55aa55)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5555)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0x0055aa)).argb);
cl_assert_equal_i(GC... |
/*
* 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... | load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false) | ;
resource_init();
}
extern void prv_update_time_info_and_generate_event(time_t *t, TimezoneInfo *tz_info);
void clock_set_time(time_t t) {
prv_update_time_info_and_generate_event(&t, NULL);
}
static void prv_clock_reset(int32_t gmtoff) {
TimezoneInfo tzinfo = {{0}};
tzinfo.dst_id = 0;
tzinfo.dst_start = tz... |
);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT... | (!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)) | ;
prv_send_hdr(QemuProtocol_SPP, sizeof(msg_data));
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
prv_send_bytes(msg_data, sizeof(msg_data));
cl_assert(qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
prv_send_footer();
cl_assert(!qemu_seri... |
/*
* 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(app_data.flags, app_data_out.flags) | ;
cl_assert_equal_s(app_data.display_name, app_data_out.display_name);
ancs_app_destroy_buffer(&app_data_out);
}
void test_ancs_app_storage__overwrite(void) {
ANCSAppData app_data = {
.bundle_id = "com.getpebble.PebbleApp",
.display_name = "Pebble",
.flags = ANCSAppIsBlocked,
};
app_data.is_meta... |
ed memory is enabled at reset
RCC->AHB2ENR = 0;
RCC->AHB3ENR = 0;
RCC->APB1ENR = 0;
RCC->APB2ENR = 0;
// Reset most peripherals used by the bootloader. We want to minimize the
// chances that the firmware unintentionally relies on some state that the
// bootloader leaves behind. This includes disabling t... | boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO) | ;
break;
case 3:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 4:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_TWO);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_THREE);
break;
case 5:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);... |
_is_active() == true);
cl_assert(enabled == true);
prv_assert_manually_dnd_setting_val(true);
cl_assert_equal_i(s_num_dnd_events_put, 3);
}
void test_do_not_disturb__manually_enable_active(void) {
bool active;
active = do_not_disturb_is_active();
cl_assert(active == false);
do_not_disturb_set_manually_e... | (active == false) | |
text(data);
} else if (event == HealthEventMetricAlert) {
HealthValue now_bpm = health_service_peek_current_value(HealthMetricHeartRateBPM);
APP_LOG(APP_LOG_LEVEL_INFO, "Crossed HR threshold of %d. HR: %"PRIi32" ",
(int)HEART_RATE_THRESHOLD, now_bpm);
data->num_hr_alerts++;
prv_hr_update_... | (data->steps_card.msg_layer, GColorWhite) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERTN((unsigned int) buffer_len > sizeof(LogBinaryMessage)) | |
return NULL;
}
void smartstrap_profiles_init(void) {
// call the init handler for all the profiles
const SmartstrapProfileInfo *info;
FOREACH_PROFILE_INFO(info) {
if (info->init) {
info->init();
}
}
}
void smartstrap_profiles_handle_connection_event(bool connected) {
// send the event to the ... | if (info->control && info->control()) {
did_send = true;
break;
} |
}
smartstrap_state_unlock();
return did_send;
}
unsigned int smartstrap_profiles_get_max_services(void) {
unsigned int max = 0;
const SmartstrapProfileInfo *info;
FOREACH_PROFILE_INFO(info) {
max += info->max_services;
}
return max;
}
|
RESOURCE_ID_GOTHIC_18;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
int8_t horiz_advance = text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info);
cl_assert(horiz_advance != 0);
cl_assert_equal_i(horiz_advance,
text_resources_get_glyph_horiz_advance(&s_font... | (&s_font_cache,
WILDCARD_CODEPOINT,
&s_font_info) | ;
cl_assert_equal_i(glyph->header.width_px, 7);
cl_assert_equal_i(glyph->header.height_px, 15);
uint8_t glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(wildcard_bytes, glyph->data, glyph_size_bytes);
}
void test_text_resources__extended_font(void) {
const uint8_t chinese_wildcard_bytes[] = ... |
e_out);
static bool prv_container_each(GTextNodeContainer *container_node, ContainerIterCallback callback,
void *context) {
const size_t num_nodes = container_node->num_nodes;
for (size_t i = 0; i < num_nodes; i++) {
GTextNode *node = container_node->nodes[i];
if (callback(no... | {
if (exact_size->w) {
size->w = exact_size->w;
}
if (exact_size->h) {
size->h = exact_size->h;
}
} |
static void prv_clip_width(GSize *size, const GSize *max_size) {
if (max_size->w && size->w > max_size->w) {
size->w = max_size->w;
}
}
static void prv_clip_height(GSize *size, const GSize *max_size) {
if (max_size->h && size->h > max_size->h) {
size->h = max_size->h;
}
}
static void prv_clip_size(G... |
// These are the pages that this test will place a valid header. It will write invalid pages
// before the valid one.
uint8_t page_idx[] = {0, 1, SPRF_NUM_PAGES / 2, SPRF_NUM_PAGES - 1};
for (uint32_t i = 0; i < ARRAY_LENGTH(page_idx); i++) {
fake_spi_flash_erase();
// Invalidate all entries before ... | (PAIRING_INFO.is_remote_encryption_info_valid,
pairing_info_out.is_remote_encryption_info_valid) | ;
cl_assert_equal_b(PAIRING_INFO.is_local_encryption_info_valid,
pairing_info_out.is_local_encryption_info_valid);
cl_assert_equal_i(PAIRING_INFO.local_encryption_info.ediv,
pairing_info_out.local_encryption_info.ediv);
cl_assert_equal_i(PAIRING_INFO.local_encryption_info.d... |
{
// Handshake received. Switch to tx mode.
hw_spi_change_fifo_mode(s_spi->bus_id, HW_SPI_FIFO_TX_ONLY);
rx_mode = false;
tx_index = 0;
tx_start_ticks = prv_timer_get_ticks();
continue;
} | else {
// Buffer is full. Shift everything down one byte.
rx_index--;
memmove(&buffer[0], &buffer[1], rx_index);
}
}
} else { // Tx Mode
if (hw_spi_is_tx_fifo_full(s_spi->bus_id)) {
// Don't spin for too long, just in case the host doesn't c... | |
->actionable_dialog = NULL;
}
static void prv_confirmed_handler(ClickRecognizerRef recognizer, void *context) {
NotificationsData *data = context;
notification_storage_reset_and_init();
prv_loaded_notification_list_deinit(data->loaded_notification_list);
data->loaded_notification_list = NULL;
prv_notificatio... | menu_cell_basic_horizontal_inset() | ;
if (icon) {
void (*draw_func)(GContext *, GDrawCommandImage *, GPoint) = gdraw_command_image_draw;
#if PBL_BW
if (menu_cell_layer_is_highlighted(cell_layer)) {
draw_func = prv_draw_pdc_bw_inverted;
}
#endif
// Inset the draw box from the left to leave some margin on the icon's left side
G... |
(f->is_tmp) {
// TODO: For safety, could disallow this op if user has orig file hdl open
pfs_remove(f->name);
// Note: if we reboot before updating the tmp state flag to done, the tmp &
// original file will be deleted. This is an extremely small window, but
// could be resolved by checking on rebo... | kernel_malloc_check(sizeof(PFSFileListEntry)
+ file_hdr.file_namelen + 1) | ;
*entry = (PFSFileListEntry) {};
strcpy(entry->name, file_name);
head = list_insert_before(head, &entry->list_node);
}
mutex_unlock_recursive(s_pfs_mutex);
return (PFSFileListEntry *)head;
}
void pfs_delete_file_list(PFSFileListEntry *head) {
ListNode *node = (ListNode *)head;
ListNode *next;
... |
get("No location information available. To see weather, add "\
"locations in your Pebble mobile app.", data);
const bool exit_on_pop = true;
prv_show_warning_dialog(data, exit_on_pop, warning_text);
weather_app_layout_set_down_arrow_visible(layout, false);
weather... | i18n_get("Unable to connect. Your weather data may be out of date; "\
"try checking the connection on your phone.", data) | |
{ -1128, 96, 80},
{ -1328, 216, 128},
// 73 seconds
{ -1336, 272, 128},
{ -1288, 360, -8},
{ -1096, 320, -8},
{ -784, 464, -16},
{ -432, 296, 32},
{ -344, 376, -32},
{ -368, 344, 80},
{ -536, 424, 128},
{ -664, 488, 128},
{ -832, 600, 152},
{ -1008, 808, 32},
{ ... | { -1104, 352, 8},
{ -736, 320, 0},
{ -408, 368, 0},
{ -296, 336, 8},
{ -224, 344, 40},
{ -368, 520, 16},
{ -576, 488, 24},
{ -944, 464, 72},
{ -1160, 456, 200},
{ -1264, 512, 240},
{ -1344, 744, -48},
{ -1184, 720, 24},
{ -1184, 560, 40},
// 79 seconds
{ -1080... |
{ -992, 648, 8},
{ -1040, 512, 88},
{ -888, 344, 264},
{ -592, 336, 136},
{ -408, 280, 136},
{ -448, 240, 152},
{ -512, 216, 184},
{ -664, 248, 152},
{ -800, 248, 168},
{ -1128, 416, 112},
{ -1352, 24, 24},
{ -1392, 112, 0},
{ -1328, 128, -24},
{ -1144, 136, -56}... |
dlers.change);
cl_assert(!app_state_get_unobstructed_area_state()->handlers.did_change);
// Subscribing should use the event service
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_change,
.change = prv_change,
.did_change = prv_did_change,
};
app_unobstructed_area_service_subscribe... | unobstructed_area_service_will_change(from_area.size.h, to_area.size.h) | ;
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_change,
.change = prv_change,
};
app_unobstructed_area_service_subscribe(handlers, s_data.context);
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state(... |
false;
}
void low_power_enter(void) {
s_in_low_power = true;
}
bool low_power_is_active(void) {
return s_in_low_power;
}
bool firmware_update_is_in_progress(void) {
return false;
}
void battery_force_charge_enable(bool is_charging) { }
bool stop_mode_is_allowed(void) {
return s_stop_mode_allowed;
}
static... | cl_assert_equal_i(battery_get_charge_state().charge_percent, high_percent) | ;
// ...and should stay that way
periodic_timer_trigger(10);
cl_assert_equal_i(battery_get_charge_state().charge_percent, high_percent);
// Then, when the voltage drops, the percentage should begin to decline - but should not reach the low value yet
fake_battery_set_millivolts(low_mv);
periodic_timer_trig... |
-----------------------------------------
// Make sure we don't push a pin when we have no history to compare against
void test_activity_insights__sleep_summary_no_history(void) {
// Tests init with zero history
activity_insights_init(rtc_get_time());
// Make sure we don't trigger as soon as we're awake
s_dat... | rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR) | ;
prv_add_nap_session(0.5, 1.5);
activity_insights_process_minute_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 2);
#endif
}
// Make sure that when the watch resets, we retain state properly
void test_activity_insights__walk_session_power_cycle(void) {
activity_insights_init(rtc_get_time());
// ... |
ts_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(); ... | (rtc_get_time() + 3 * SECONDS_PER_HOUR) | ;
prv_add_nap_session(2, 1);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 2);
}
// ---------------------------------------------------------------------------------------
// Make sure that when the watch resets, we retain state properly
void test_activity_insights__s... |
t_cron = {
.cb = prv_cron_callback,
.cb_data = (void*)0,
.minute = 45,
.hour = CRON_HOUR_ANY,
.mday = CRON_MDAY_ANY,
.month = CRON_MONTH_ANY,
.may_be_instant = true,
.clock_change_tolerance = 0,
};
CronJob *job = &test_cron;
time_t base = s_2015_nov12_123456_gmt;
prv_set_rtc(b... | cron_service_get_job_count() | |
/*
* 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 NULL;
} |
// fake accel.h impl
static int s_sampling_interval_us = 1000000 / ACCEL_SAMPLING_25HZ;
static int s_num_samples = 0;
//! If true, ignore attempts to change the sampling interval
static bool s_force_sampling_interval;
uint32_t accel_set_sampling_interval(uint32_t interval_us) {
if (!s_force_sampling_interval) {
... |
,
{ 904, 304, -80},
{ 992, 256, -32},
{ 1120, 216, 16},
{ 1040, 144, 104},
{ 920, 160, 80},
{ 848, 168, 80},
{ 848, 176, 88},
{ 872, 160, 80},
{ 832, 104, 72},
{ 872, 88, 80},
{ 944, 80, 80},
{ 992, 120, 56},
{ 1184, 136, 104},
{ 1176, 152, 176},
{ 1200, 272, ... | { 1104, 80, 168},
{ 968, 80, 152},
{ 920, 208, -32},
{ 896, 256, -112},
{ 960, 264, -72},
{ 976, 200, 16},
{ 952, 176, 32},
{ 856, 232, -8},
{ 832, 280, -8},
{ 824, 304, -40},
{ 848, 296, -32},
{ 944, 280, -24},
{ 1120, 328, 0},
{ 1104, 352, 32},
{ 1304, 424, ... |
{ 992, 288, 56},
{ 1048, 280, 112},
{ 984, 248, 120},
{ 872, 184, 160},
{ 864, 184, 96},
{ 936, 128, 176},
{ 896, 80, 200},
{ 976, 88, 184},
{ 1008, 80, 192},
{ 968, 104, 144},
{ 1120, 80, 200},
{ 920, 88, 80},
{ 808, 208, -112},
{ 808, 224, -144},
{ 928, 160... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | _Static_assert(RTC_TICKS_HZ < (1000000 / 450), "Tick period < 450µs") | ;
void bma255_gpio_init(void) {
periph_config_acquire_lock();
gpio_af_init(&BMA255_SCLK_CONFIG, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL);
gpio_af_init(&BMA255_MISO_CONFIG, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL);
gpio_af_init(&BMA255_MOSI_CONFIG, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd... |
>= max_pp_msg_size);
circular_buffer_init(&session->send_buffer, session->storage, max_pp_msg_size);
s_session_head = (CommSession *) list_prepend((ListNode *) s_session_head, &session->node);
return session;
}
size_t comm_session_send_queue_get_length(const CommSession *session) {
cl_assert(list_contains((co... | (&session->send_buffer, (const uint8_t *) &pp_header, sizeof(pp_header)) | |
a) {
struct PACKED {
uint8_t sample_idx;
net16 accel_x;
net16 accel_y;
net16 accel_z;
} sample_data = {
.sample_idx = sample_idx,
.accel_x = hton16(data->x * 2), // Accel service supplies mGs, AS7000 expects lsb = 0.5 mG
.accel_y = hton16(data->y * 2),
.accel_z = hton16(data->z * 2)
... | prv_set_host_one_second_time_register(HRM, average_handshake_interval_ms) | |
num_services,
&bp_service->uuid);
cl_assert_equal_i(num_found_services, num_services);
// Test that the UUID matches the Blood Pressure UUID:
const Uuid uuid = gatt_client_service_get_uuid(service_refs[0]);
c... | uuid_equal(&uuid1, &random_128bit_service->uuid) | );
cl_assert(uuid_equal(&uuid2, &thermo_service->uuid) ||
uuid_equal(&uuid2, &random_128bit_service->uuid));
}
|
noOK && !is_cleaning_up) {
if (subscription_type == BLESubscriptionNone || !has_pending_write) {
// When unsubscribing or when Pebble was already subscribed,
// immediately send unsubscription confirmation event to client:
prv_send_subscription_event(characteristic_ref, ~gap_le_pebble_task_bit_for... | {
GATTClientSubscriptionNode *next = (GATTClientSubscriptionNode *) node->node.next;
if (node->att_handle >= range->start && node->att_handle <= range->end) {
for (GAPLEClient c = 0; c < GAPLEClientNum; ++c) {
prv_subscribe(node->characteristic, BLESubscriptionNone, 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... | (circular_buffer_consume(&buffer, 1)) | ;
// Read the last little bit
cl_assert(circular_buffer_read(&buffer, 1, &out_buffer, &out_length));
cl_assert_equal_i(out_length, 1);
cl_assert(memcmp(out_buffer, (uint8_t*) "c", 1) == 0);
cl_assert(circular_buffer_consume(&buffer, 1));
// And we should be empty
cl_assert(!circular_buffer_read(&buffer,... |
////////////////
#if UNITTEST
static uint32_t s_num_record_changes;
#endif
static uint8_t *read_file_into_ram(SettingsRawIter *iter) {
int pos = pfs_seek(iter->fd, 0, FSeekCur);
int file_size = pfs_get_file_size(iter->fd);
if (file_size < 0) {
return NULL;
}
int read_size = file_size;
uint8_t *content... | (iter, sizeof(iter->file_hdr), FSeekSet) | ;
// Read header for first record.
iter->hdr_pos = sfs_pos(iter);
iter->resumed_pos = iter->hdr_pos;
sfs_read(iter, (uint8_t*)&iter->hdr, sizeof(iter->hdr));
}
void settings_raw_iter_resume(SettingsRawIter *iter) {
iter->resumed_pos = iter->hdr_pos;
}
void settings_raw_iter_next(SettingsRawIter *iter) {
... |
et(void) {
gpio_output_set(&BOARD_CONFIG_BT_COMMON.reset, false);
}
static void prv_send_char(uint8_t c) {
uart_write_byte(BT_TX_BOOTROM_UART, c);
uart_wait_for_tx_complete(BT_TX_BOOTROM_UART);
}
static bool prv_bootrom_wait_for_char_with_timeout(char *char_received, uint32_t wait_time_ticks) {
const uint32_t... | accessory_block() | ;
#endif
// Configure GPIOs & peripherals
prv_init_dialog_bootrom_interface();
// UART is configured and listening for the start message, so exit reset
prv_exit_reset();
// Read until 0x02 start message is found:
// Rev "AD" and before do not send out their chip ID before the 0x02 start message.
// Rev... |
/*
* 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 (mcu_state_are_interrupts_enabled()) {
s_pri_mask = __get_BASEPRI();
__set_BASEPRI((TASK_WATCHDOG_PRIORITY + 1) << (8 - __NVIC_PRIO_BITS));
s_interrupts_disabled_by_heap = true;
}
} | |
/*
* 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... | (PULSE_TRANSPORT_PUSH) | ;
PushPacket *transport = (PushPacket *)frame->information;
transport->protocol = hton16(PULSE_PROTOCOL_LOGGING);
transport->length = hton16(sizeof(PushPacket) + sizeof(s_message_header) +
s_message_length);
unsigned char *app = transport->information;
memcpy(app, s_message_head... |
rcentTier prv_calc_percent_tier(const SummaryPinConfig *config, ActivityScalarStore cur_val,
ActivityScalarStore average, int *percentage) {
// Determine percentage of target
*percentage = (average > 0) ? (((cur_val * 100) / (average)) - 100) : 0;
if (*percentage < config->insig... | (SUBTITLE_BUFFER_LENGTH) | ;
if (percentage == 0) {
strcpy(percentage_buf, "0%");
} else {
sniprintf(percentage_buf, SUBTITLE_BUFFER_LENGTH, "%+d%%", percentage);
}
attribute_list_add_cstring(&pin_attr_list, AttributeIdSubtitle, percentage_buf);
TimelineItem *item = prv_create_pin(pin_time_utc, now_utc, 0, LayoutIdWeather, &pi... |
DDR(i), sizeof(data));
if (prv_valid_struct(&data)) {
s_valid_page_idx = i;
break;
}
}
}
// Keep a write offset, this won't work when we try to roll over to the other 25% of the sectors
if (s_valid_page_idx == SPRF_PAGE_IDX_INVALID) {
prv_erase_region_and_sav... | SPRF_FETCH_FIELD(name_data, ble_pairing_name) | ;
// Should we return a failure on a failed name get?
if (name_rv) {
strncpy(name_out, name_data.name, BT_DEVICE_NAME_BUFFER_SIZE);
} else {
name_out[0] = '\0';
}
}
rv = true;
}
unlock:
prv_unlock();
return rv;
}
void shared_prf_storage_store_ble_pairing_data(
... |
IZER(r) = test_recognizer_create(&s_test_impl_data, &rec_event);
recognizer_cancel(r);
cl_assert_equal_i(r->state, RecognizerState_Possible);
cl_assert_equal_b(cancelled, false);
cl_assert_equal_i(rec_event, -1);
r->state = RecognizerState_Failed;
recognizer_cancel(r);
cl_assert_equal_i(r->state, Recogni... | (r, &(TouchEvent) { .type = TouchEvent_Touchdown }) | |
et_current_app_id() == app_id)) {
// Lookup app, and if installed, launch
if (app_id != INSTALL_ID_INVALID) {
PebbleLaunchAppEventExtended* data =
kernel_malloc_check(sizeof(PebbleLaunchAppEventExtended));
*data = (PebbleLaunchAppEventExtended) {
.common.reason = APP_LAUNCH_WAKEUP,... | MAX(time_difference, WAKEUP_CATCHUP_WINDOW) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (node) {
if (node->property_changed_proc) {
node->property_changed_proc(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... | i18n_noop("5 Min Before") | |
rs [54...57]).
// If not in HRM-mode, the host can just read the SYNC-byte (register 57).
// Reading the SYNC-byte causes the AS7000 to release the handshake-signal
// and allows deep-sleep mode (if the AS7000 is configured for this).
// This step must be the last read for this handshake-pulse.
stat... | {
PBL_LOG(LOG_LEVEL_DEBUG, " - HRM");
} |
if (app_ids & AS7000AppId_PRV) {
PBL_LOG(LOG_LEVEL_DEBUG, " - PRV");
}
if (app_ids & AS7000AppId_GSR) {
PBL_LOG(LOG_LEVEL_DEBUG, " - GSR");
}
if (app_ids & AS7000AppId_NTC) {
PBL_LOG(LOG_LEVEL_DEBUG, " - NTC");
}
}
}
static bool prv_get_and_log_device_info(HRMDevice *dev, A... |
continue;
}
if (rocky_str_equal(option_values[i].field, option_values[i].value)) {
result = option_values[i].format;
found_options++;
}
if (found_options > 1) {
// today, we don't support combinations of several options, it's either none or one
return ToStringFormatUnsuppor... | (buffer, buffer + 1, str_len) | ;
}
return str_len;
}
static jerry_value_t prv_to_locale_time_or_date_string(jerry_value_t this_val,
jerry_length_t argc,
const jerry_value_t argv[],
... |
/*
* 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... | rot_bitmap_layer_init(&pair->black_layer, black) | ;
set_compositing(pair);
layer_init(&pair->layer, &pair->white_layer.layer.frame);
layer_add_child(&pair->layer, &pair->white_layer.layer);
layer_add_child(&pair->layer, &pair->black_layer.layer);
}
void rotbmp_pair_layer_deinit(RotBmpPairLayer *pair) {
layer_deinit(&pair->white_layer.layer);
layer_dein... |
&& defined(APP_ID_SEND_TEXT)
s_capabilities_event_info = (EventServiceInfo) {
.type = PEBBLE_CAPABILITIES_CHANGED_EVENT,
.handler = prv_capabilities_changed_event_handler,
};
event_service_client_subscribe(&s_capabilities_event_info);
#endif
}
bool app_install_id_from_system(AppInstallId id) {
return ... | (reg_entry->color, (Uuid *) ®_entry->uuid) | |
,
* 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 "ad_ble.h"
#include "ble_common.h"
#include "ble_mgr.h"
#include "ble_mgr_irb_common.h"
#include "co_bt.h"
#include "hc_pro... | (0x8, 0x1d, ¶ms[0], sizeof(params)) | ;
break;
}
case 4:
PBL_LOG(LOG_LEVEL_DEBUG, "===LE Stop Rx Test===");
hci_rom_passthrough_send_cmd(0x8, 0x1f, NULL, 0);
break;
default:
return;
}
i++;
}
|
2147483647", },
{ 2147483646LL, 11, "A02220280", },
{ 2147483646LL, 11, "a02220280", },
{ -2147483647LL, 11, "-A02220281", },
{ -2147483647LL, 11, "-a02220281", },
{ 2147483646LL, 12, "4BB2308A6", },
{ 2147483646LL, 12, "4bb2308a6", },
{ -2147483647LL, 12, "-4BB2308A7", },
{ -2147483647LL, 12, "-4bb2308... | {
cl_assert_equal_i(strtol(s_base_test_data[i].str, NULL, s_base_test_data[i].base),
s_base_test_data[i].value);
} |
}
void test_strtol__zerobase(void) {
cl_assert_equal_i(strtol("573bb", NULL, 0), 573);
cl_assert_equal_i(strtol("0x573", NULL, 0), 0x573);
cl_assert_equal_i(strtol("0573", NULL, 0), 0573);
cl_assert_equal_i(strtol(" +573bb", NULL, 0), 573);
cl_assert_equal_i(strtol(" +0x573ghghghgh", NULL, 0), 0x573);
c... |
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 License.
*/
#inc... | {
int num_beers = persist_read_int(COUNT_PKEY);
persist_write_int(COUNT_PKEY, num_beers + (500 + rand() % 500));
menu_layer_reload_data(menu_layer);
break;
} |
case 2: {
int num_beers = persist_read_int(COUNT_PKEY);
persist_write_int(COUNT_PKEY, num_beers - (500 + rand() % 500));
menu_layer_reload_data(menu_layer);
}
}
}
static void prv_window_load(Window *window) {
AppData *data = window_get_user_data(window);
MenuLayer *menu_layer = &data-... |
->timeline_layer.layer;
GPoint from_origin = { -layer->bounds.size.w, 0 };
Animation *layer_in = (Animation *)property_animation_create_bounds_origin(layer, &from_origin,
&GPointZero);
animation_set_duration(layer_in, TIMELINE_CARD_TRANS... | (&s_app_data->inactive_timer_id) | ;
event_service_client_unsubscribe(&s_app_data->focus_event_info);
event_service_client_unsubscribe(&s_app_data->blobdb_event_info);
timeline_layer_deinit(&s_app_data->timeline_layer);
timeline_model_deinit();
app_free(s_app_data);
}
static void prv_main(void) {
prv_init();
app_event_loop();
prv_de... |
/*
* 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_get_array_index_of_type(weather_type) | ];
};
GColor weather_type_get_bg_color(WeatherType weather_type) {
const size_t index = prv_get_array_index_of_type(weather_type);
return PBL_IF_COLOR_ELSE((GColor) {.argb = s_weather_type_bg_colors[index]}, GColorClear);
};
GColor weather_type_get_text_color(WeatherType weather_type) {
return (GColor) {.argb =... |
{
VOICE_LOG("Empty sentence received");
return false;
} |
VOICE_LOG("New sentence: %s", data->message);
return true;
}
static void prv_handle_dictation_error(VoiceUiData *data, VoiceStatus error_status) {
uint64_t elapsed = prv_get_time_ms() - data->start_ms;
const bool speech_detected = (data->speech_detected) || (elapsed < MIN_ELAPSED_DURATION);
data->error_co... | |
/*
* 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... | event_service_client_unsubscribe(&music_glance->music_event_info) | ;
kino_reel_destroy(music_glance->icon);
}
app_free(music_glance);
}
static void prv_set_glance_icon(LauncherAppGlanceMusic *music_glance,
uint32_t new_icon_resource_id) {
if (music_glance->icon_resource_id == new_icon_resource_id) {
// Nothing to do, bail out
return;
... |
/*
* 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... | {
break;
} | else if (g_file_resource_stores[i].last_resource_id >= resource_id) {
const FileResourceData *file = &g_file_resource_stores[i];
entry->store_data = file;
entry->id -= file->resource_id_offset;
return true;
}
}
return false;
}
static ResourceCallbackHandle resource_storage_file_watch(... |
end(void) {
s_sys_activity_get_minute_history_values.stage = 0;
s_sys_activity_get_minute_history_values.out[0].asserts = false;
HealthMinuteData data[5] = {};
// pass time that's not exactly on a boundary
time_t time_start;
time_t time_end;
////////////
// start time on boundary
const time_t time_... | for (int i = 0; i < ACTIVITY_HISTORY_DAYS; i++, day_in_week--) {
day_in_week = positive_modulo(day_in_week, DAYS_PER_WEEK);
s_sys_activity_get_metric_values.out.history[i] = 1000 + (i * 50);
// Day 0 is not included in the stats
if (i == 0) {
continue;
}
// Increment totals for each day ... |
// ----------------------------------------
// Compute expected values
int exp_weekly = day_totals[local_tm.tm_wday] / day_counts[local_tm.tm_wday];
int exp_daily = 0;
int count = 0;
for (int i = 0; i < DAYS_PER_WEEK; i++) {
exp_daily += day_totals[i];
count += day_counts[i];
}
exp_daily /= 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... | {
pfs_remove_files(NULL);
system_task_add_callback(prv_pfs_stress_callback, NULL);
} |
// Issue regular pfs accesses from KernelBG
void pfs_command_stress(void) {
prompt_send_response("PFS stress from kernel BG");
system_task_add_callback(prv_pfs_stress_callback, NULL);
}
extern void command_read_word(const char* address_str) {
int32_t address = str_to_address(address_str);
if (address == -1) ... |
tted(&ctx, GPoint(45, 75), 5);
// T facing right - odd vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(71, 71), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(66, 76), 5);
// T facing left - even vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(100, 70), 10);
graphi... | GPoint(10, 96) | , 5);
// T facing right - even vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(50, 90), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(46, 95), 5);
// T facing right - odd vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(71, 91), 10);
graphics_draw_horizontal_line_d... |
animation_schedule(color_animation);
#else
layer_mark_dirty(&s_phone_ui_data->window.layer);
#endif
}
// Names can sometimes actually be phone numbers. We're assuming that phone numbers will always
// match /^[() +0-9-]+$/
static bool prv_is_string_a_phone_number(const char *name) {
size_t length = strlen(name)... | {
// There is a mutex-related issue that can appear where the timer callback will execute after
// phone_ui cancels the timer and frees the vibe_score / s_phone_ui_data. Thus, bail early
// if we detect this bad state.
// See PBL-35548
return;
} |
vibe_score_do_vibe(s_phone_ui_data->vibe_score);
#else
vibes_long_pulse();
#endif
}
if (alerts_should_enable_backlight_for_type(AlertPhoneCall)) {
light_enable_interaction();
}
}
static void prv_start_ringing(void) {
alerts_incoming_alert_analytics();
s_phone_ui_data->ring_timer = (const Regular... |
/*
* 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... | poll_remote_send_request(POLL_REMOTE_SERVICE_MAIL) | ;
}
static const SimpleMenuItem s_menu_items[] = {
{ "Poll Mail", "", NULL, poll_callback },
{ "Title A", "Callback A", NULL, callback_a },
{ "Another Title", NULL, NULL, other_callback },
{ "Last Title", "Last subtitle", NULL, other_callback }
};
static const SimpleMenuSection s_menu_sections[] = {{ .title =... |
, base_priority, false);
cl_assert_equal_i(window1->on_screen, true);
modal_window_push(window2, base_priority - 1, false);
cl_assert_equal_i(window1->on_screen, true);
cl_assert_equal_i(window2->on_screen, false);
modal_window_push(window1, base_priority - 2, false);
modal_manager_event_loop_upkeep();... | cl_check(modal_stack) | ;
cl_check(!app_stack->list_head);
cl_check(!modal_stack->list_head);
// Switch to the app state to push a window
stub_pebble_tasks_set_current(PebbleTask_App);
window_stack_push(app_stack, window1, true);
cl_assert_equal_i(window_stack_count(app_stack), 1);
cl_assert_equal_i(window1->on_screen, true)... |
goto done;
}
if (addr_out) {
*addr_out = data.bt_classic_data.address;
}
if (link_key_out) {
*link_key_out = data.bt_classic_data.link_key;
}
if (platform_bits) {
*platform_bits = data.bt_classic_data.platform_bits;
}
if (device_name_out) {
strcpy(device_name_out, data.bt_classic_d... | (LOG_LEVEL_DEBUG, "Syncing pairing information to SPRF") | ;
prv_lock_pending_bonding();
{
bool le_bonding_update = s_pending_bondings.has_ble_pairing_pending;
bool classic_bonding_update = s_pending_bondings.has_bt_classic_pairing_pending;
SharedPRFData *data = &s_pending_bondings.pending_data;
if (le_bonding_update && classic_bonding_update) {
prv... |
e_y(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, 40, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_outside_nx(Layer* me, GContext* ctx) ... | test_graphics_context_reset(&ctx, fb) | |
I2C_CR1_TCIE | // Enable transfer complete interrupt
I2C_CR1_TXIE; // Enable transmit interrupt
if (bus->state->transfer.direction == I2CTransferDirection_Read) {
bus->hal->i2c->CR1 |= I2C_CR1_RXIE; // Enable receive interrupt
}
}
static void prv_resume_transfer(I2... | if ((i2c->ISR & I2C_ISR_TC) != 0) {
return prv_end_transfer_irq(bus, I2CTransferEvent_TransferComplete);
} |
break;
case I2CTransferState_Complete:
if (i2c->ISR & I2C_ISR_TXE) {
// We seem to get a spurious interrupt after the last byte is sent
// There is no bit to specifically disable this interrupt and the interrupt may have already
// been pended when we would disable it, so just ... |
params_get_actual_state(hdl) >= state);
if (consumer_request == NULL) {
if (state == ResponseTimeMax) {
// No changes: there was no previous node and the new state is the default "low power" one.
goto handle_current_state;
}
// create node
consumer_request = kernel_malloc_check(sizeof(Co... | atoi(enabled_str) | ;
bool is_enabled = (s_chaos_monkey_timer != TIMER_INVALID_ID);
if (new_enabled == is_enabled) {
return;
}
bt_lock();
if (new_enabled) {
GAPLEConnection *conn_hdl = gap_le_connection_any();
if (conn_hdl) {
s_chaos_monkey_timer = new_timer_create();
prv_mode_chaos_monkey_callback(conn... |
opyright 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 in writi... | assert_float_parse("0.74995", 2, true, 1) | ;
}
void test_ams_util__float_string_parse_multiple_separators(void) {
// "1.2.2" * 3
assert_float_parse("1.2.2", 2, false, 0);
}
void test_ams_util__float_string_positive_multiplier(void) {
// "1.654321" * 33 is approx 54.592593, round up to 55
assert_float_parse("1.654321", 33, true, 55);
}
void test_ams_u... |
===========");
printf("\nRunning activity sample set: \"%s\"\n", entry->name);
memset(s_kalg_state, 0, kalg_state_size());
kalg_init(s_kalg_state, prv_stats_cb);
s_num_captured_activity_sessions = 0;
// Run samples through the activity detector
time_t now = rtc_get_time();
time_t test_star... | if (actual->passed) {
indicator = " ";
} else {
indicator = "**";
} | |
/*
* 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... | (sizeof(int)) | ;
*storage = 1337;
free((void*) storage);
free((void*) storage);
}
static void trigger_stack_overflow(int index, void *context) {
volatile int counter = (int) context;
if (counter > 300) {
return;
}
++counter;
trigger_stack_overflow(index, (void*) counter);
}
static void window_load(Window *window... |
if (s_saved_encoded_msg == NULL) {
LOG("No message available yet...");
} else {
msg = prv_parse_encoded_mset_payload(s_saved_encoded_msg);
cl_assert_equal_m(msg->msrmt.values, &values[num_samples_encoded * num_values_per_sample],
msg->msrmt.num_values * sizeof(uint32_t));
... |
}
// Delete the session now
protobuf_log_session_delete(session_ref);
}
// ---------------------------------------------------------------------------------------------
// Test using the data logging transport
void test_protobuf_log__measurements_with_data_logging(void) {
ProtobufLogMeasurementType types[] =... | |
quest *request_hdr,
uint32_t tot_request_size);
static bool prv_do_put(const PutRequest *request, uint32_t request_size, uint32_t token) {
uint32_t data_length = ntohl(request->length);
xSemaphoreTake(s_pb_semaphore, portMAX_DELAY);
uint32_t remaining_bytes = s_pb_sta... | prv_check_for_state_error(PutBytesPut, request_token, tot_request_size) | ) {
return true;
}
return false;
}
static void prv_process_put_requests_system_task_cb(void *unused) {
PutBytesPendingJobs *put_jobs = &s_pb_state.pb_pending_jobs;
prv_lock_pb_job_state();
uint8_t num_put_jobs = put_jobs->num_ops_pending;
uint8_t read_idx = put_jobs->read_idx;
uint32_t initial_remai... |
e License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or imp... | for (unsigned int i = 0; i < ARRAY_LENGTH(collide_pairs); ++i) {
for (unsigned int j = 0; j < 2; ++j) {
char* name = collide_pairs[i][j];
app_data.bundle_id = name;
app_data.display_name = name;
ancs_app_storage_load(name, &app_data_out);
cl_assert_equal_s(app_data.bundle_id, app_data... |
}
void test_ancs_app_storage__iter(void) {
ANCSAppData apps[] = {
{ .bundle_id = "com.apple.MobileSMS", .display_name = "Messages" },
{ .bundle_id = "com.apple.facetime", .display_name = "FaceTime" },
{ .bundle_id = "com.facebook.Messenger", .display_name = "Facebook" },
{ .bundle_id = "com.atebits.... |
CE_METRIC_BT_OFF_TIME);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "BT driver failed to start!");
// FIXME: PBL-36163 -- handle this better
}
stop_mode_enable(InhibitorCommMode);
}
static void prv_comm_stop(void) {
if (!s_comm_is_running) {
return;
}
stop_mode_disable(InhibitorCommMode);
#if CAPABILITY... | analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BT_OFF_TIME, AnalyticsClient_System) | |
n 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 "host_transport.h"
#include "host_transport_protocol.h"
#include "dialog_spi.h"
#include "hc_protocol/hc... | (&BOARD_BT_WATCHDOG_TIMER.timer,
TIMER_FREQUENCY_HZ) | ;
tim_config.TIM_Period = TIMER_PERIOD_TICKS;
tim_config.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, &tim_config);
TIM_Cmd(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, DISABLE);
TIM_ClearITPendingBit(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update);
... |
_out, sizeof(link_key_out));
cl_assert_equal_s(name_1, name_out);
cl_assert_equal_i(platform_bits_1, platform_bits_out);
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id_2, &addr_out, &link_key_out,
name_out, &platform_bits_out);
cl_assert(ret);
... | fake_shared_prf_storage_get_bt_classic_store_count() | , 1);
// Delete the Pairing
bt_persistent_storage_delete_bt_classic_pairing_by_id(id);
cl_assert_equal_i(fake_shared_prf_storage_get_bt_classic_delete_count(), 2);
// Try to read it back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | string_strip_leading_whitespace(with_whitespace) | |
butes = ARRAY_LENGTH(action1_attributes),
.attributes = action1_attributes
};
AttributeList attr_list2 = {
.num_attributes = ARRAY_LENGTH(action2_attributes),
.attributes = action2_attributes
};
AttributeList attr_list3 = {
.num_attributes = ARRAY_LENGTH(attributes),
.attributes = at... | (&list, AttributeIdBody, "Body") | ;
// title + subtitle + body + 3 * (attributeid + pointer)
size_t size_list = attribute_list_get_buffer_size(&list);
cl_assert_equal_i(size_list, (5 + 1) + (8 + 1) + (4 + 1) + 3 * sizeof(Attribute));
uint8_t *buffer = kernel_malloc_check(size_list);
uint8_t *buffer_orig = buffer;
AttributeList list2 = {0};... |
uint32_t CallbackParameter) {
}
bool static s_is_connected_as_slave = false;
bool gap_le_connect_is_connected_as_slave(void) {
return s_is_connected_as_slave;
}
void ble_legacy_discovery_enable(uint32_t timeout_secs) {
}
void gap_le_slave_reconnect_stop(void) {
}... | assert_ad_data(ad_data) | ;
// Check that the scan resp data that is passed to the controller is the same
// that was given when calling the API:
Scan_Response_Data_t scan_resp_data_out;
cl_assert_equal_i(gap_le_get_scan_response_data(&scan_resp_data_out),
sizeof(scan_resp_data));
cl_assert(memcmp(&scan_resp_data_... |
14, false, ALARM_KIND_WEEKENDS, s_weekend_schedule);
}
void test_alarm__alarm_set_recurring_weekdays(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
alarm_set_kin... | (alarm_day_text_6, "Thursdays") | ;
bool schedule_7[7] = {false, false, false, false, false, true, false};
char alarm_day_text_7[32] = {0};
alarm_get_string_for_custom(schedule_7, alarm_day_text_7);
cl_assert_equal_s(alarm_day_text_7, "Fridays");
bool schedule_8[7] = {false, false, false, false, false, false, true};
char alarm_day_text_8[... |
/*
* 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... | (malformed_test_string_utf8, NULL) | ;
uint32_t actual_codepoint = s_valid_test_codepoints[i];
cl_assert_equal_i(decoded_codepoint, actual_codepoint);
malformed_test_string_utf8 = utf8_get_next(malformed_test_string_utf8);
}
// When we decode the invalid codepoint, it should return an invalid stream
// error and set the pointer to the s... |
}
even = !even;
p0.x += delta.x;
p0.y += delta.y;
--length;
}
}
static void background_update_proc(Layer *layer, GContext *ctx) {
GRect bounds = layer_get_bounds(layer);
// Draw lines to contain 'hole' and 'par' sections.
// Magic numbers measured from design spec
const int16_t vertical_divi... | (data->status_layer) | |
gnizerRef 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 result: %... | (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... |
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 License.
*/
#inc... | dls_clear() | ;
prv_schedule_retry();
return NULL;
}
return dls_session;
}
static void prv_dls_log(AnalyticsHeartbeat *device_hb, AnalyticsHeartbeatList *app_hbs) {
dls_log(s_device_heartbeat_session, device_hb->data, 1);
#ifdef ANALYTICS_DEBUG
analytics_heartbeat_print(device_hb);
#endif
kernel_free(device_hb);
... |
_byte(test_addr, test_pattern, 0x00, false);
VERIFY_TEST_STATUS(status);
// read base address to insure that it wasn't modified due to a stuck at zero in an address
// bit
status = prv_read_verify_byte(base_addr, data_pattern, FLASH_TEST_ERR_STUCK_AT_LOW, bitpos,
false... | PBL_LOG(LOG_LEVEL_DEBUG, ">START - STRESS TEST 1") | ;
uint16_t halfwordcount = 0;
unsigned int iteration_count = 0;
// Read/Write from address 1
uint32_t stress_addr1 = FLASH_TEST_STRESS_ADDR1;
uint16_t stress_data1 = FLASH_TEST_STRESS_DATA1;
// Read/Write from adress 2
uint32_t stress_addr2 = FLASH_TEST_STRESS_ADDR2;
uint16_t stress_data2 = FLASH_TES... |
boot_bit_clear(BOOT_BIT_FORCE_PRF);
return true;
}
if (prv_prf_button_combination_is_pressed()) {
dbgserial_putstr("Hold down UP + BACK + SELECT for 5 secs. to force-boot PRF");
for (int i = 0; i < 5000; ++i) {
if (!prv_prf_button_combination_is_pressed()) {
// stop waiting if not held... | prv_sad_watch(ERROR_CANT_LOAD_FW) | ;
}
bool force_boot_recovery_mode = prv_check_force_boot_recovery();
if (force_boot_recovery_mode) {
dbgserial_putstr("Force-booting recovery mode...");
}
if (force_boot_recovery_mode || prv_check_for_fw_start_failure()) {
if (!fw_copy_switch_to_recovery_fw()) {
// We've failed to load recover... |
terator));
Uuid first_all_day_event = state.pin.header.id;
cl_assert(uuid_equal(&state.pin.header.id, &s_all_day_items[1].header.id) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
cl_assert(state.node->all_day);
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header... | (!iter_next(&iterator)) | ;
}
// 11 am
void test_timeline__extra_case_none_forwards(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
s_feb_5... |
:
for (int c = ANCSCharacteristicData; c >= ANCSCharacteristicNotification; --c) {
const BTErrno e = gatt_client_subscriptions_subscribe(characteristics[c],
BLESubscriptionNotifications,
GAPLEClient... | analytics_add(ANALYTICS_DEVICE_METRIC_NOTIFICATION_BYTE_IN_COUNT, length, AnalyticsClient_System) | ;
if (s_ancs_client->state == ANCSClientStateRequestedApp) {
prv_handle_app_attributes_response(data, length);
} else if (s_ancs_client->state == ANCSClientStateRequestedNotification ||
s_ancs_client->state == ANCSClientStateReassemblingNotification) {
prv_reassemble_ds_notification(length, da... |
ired_timers service loop will take care of this for us.
if (timer->executing) {
timer->defer_delete = true;
mutex_unlock(manager->mutex);
} else {
PBL_ASSERTN(list_contains(manager->idle_timers, &timer->list_node));
list_remove(&timer->list_node, &manager->idle_timers /* &head */, NULL /* &tail */);... | kernel_free(next_timer) | ;
} else {
mutex_unlock(manager->mutex);
}
}
}
void* task_timer_manager_get_current_cb(const TaskTimerManager *manager) {
return manager->current_cb;
}
|
point_logging_handler(const HcProtocolMessage *msg) {
switch (msg->command_id) {
case HcMessageID_Logging_LogMsg: {
BinLogMessage_Header *header = (BinLogMessage_Header *)msg->payload;
switch (header->version) {
case BINLOGMSG_VERSION_STRING_V1:
prv_log_string_v1((BinLogMessa... | pbl_log(msg->body.level, filename, msg->body.line_number, (const char *)msg->body.string) | ;
}
#endif // PBL_LOGS_HASHED
|
irst(int r) {
PBL_ASSERT(s_sjlj_num == 0, "SJLJ TRACK INCORRECT @ FIRST");
s_sjlj_num++;
prv_sjlj_second(r);
PBL_ASSERT(1, "SJLJ IS BROKEN (longjmp didn't occur)");
}
static void prv_sjlj_main(int r) {
PBL_ASSERT(s_sjlj_num == 2, "SJLJ TRACK INCORRECT @ MAIN");
s_sjlj_num++;
PBL_ASSERT(r == 1, "SETJMP IS ... | launcher_main_loop() | ;
}
|
/*
* 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... | {
const char *first = i18n_get("Music", (void *)0x12345);
cl_assert(strcmp(first, "Musique") == 0);
cl_assert(prv_list_find_string("Music", (void *)0x12345) != NULL);
const char *second = i18n_get("Music", (void *)0x12345);
cl_assert(first == second);
const char *third = i18n_get("Music", (void *)0xdeadbeef... |
void test_i18n__locale(void) {
cl_assert(strcmp(i18n_get_locale(), "fr_FR") == 0);
cl_assert_equal_i(i18n_get_version(), 24);
}
void test_i18n__get_with_buffer(void) {
const uint32_t LEN = 20;
char buffer[LEN];
i18n_get_with_buffer("Music", buffer, sizeof(buffer));
cl_assert_equal_s(buffer, "Musique");
... |
ctive == true);
// !Manual && Scheduled && !Smart
do_not_disturb_set_manually_enabled(false);
cl_assert(do_not_disturb_is_active() == false);
do_not_disturb_toggle_scheduled(WeekdaySchedule); // see PBL-22011
cl_assert(do_not_disturb_is_active() == false);
do_not_disturb_toggle_scheduled(WeekdaySchedule);... | do_not_disturb_set_manually_enabled(false) | ;
cl_assert(do_not_disturb_is_manually_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == false); // Both OFF
do_not_disturb_set_manually_enabled(true);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
active = do_not_disturb_is_active();
cl_assert(active == true); /... |
assert_equal_i(persist_get_size(key), size);
cl_assert_equal_i(persist_read_data(key, &uuid_buffer, sizeof(uuid_buffer)), size);
cl_assert(uuid_equal(&test_uuid_a, &uuid_buffer));
}
void test_persist__data_too_big(void) {
char buf[PERSIST_DATA_MAX_LENGTH+2];
memset(buf, '~', sizeof(buf));
cl_assert_equal_... | strlen(buffer) | );
// Read part of the data we wrote
cl_assert_equal_i(persist_read_string(0, buffer, 2), 2);
cl_assert_equal_i(strlen(buffer), 2 - 1); // -1 because null termination
cl_assert_equal_i(buffer[0], 'H');
// Then attempt to read back the entire thing
cl_assert_equal_i(persist_read_string(0, buffer, sizeof(buff... |
192, -48},
{ 1072, 224, -16},
{ 1144, 248, -16},
{ 1144, 304, -120},
{ 1176, 320, -32},
{ 1296, 504, 96},
// 111 seconds
{ 912, 696, 40},
{ 1168, 368, -24},
{ 1048, 496, -128},
{ 1072, 408, -8},
{ 1240, 408, 104},
{ 1568, 336, 120},
{ 1416, 192, 88},
{ 1360, 64, ... | { 1216, 480, 176},
{ 968, 664, 112},
{ 1312, 528, 48},
{ 1056, 360, -64},
{ 1152, 296, 40},
{ 1296, 376, 128},
{ 1536, 304, 112},
{ 1320, 192, 80},
{ 1256, 96, 152},
{ 1224, 8, 80},
{ 1128, 0, 24},
{ 1016, 16, 0},
{ 848, 0, 0},
{ 1072, 0, 64},
// 117 seconds
... |
{ -560, 80, -744},
{ -232, -232, -1136},
{ 56, -176, -1240},
{ 184, -64, -1392},
{ 160, -16, -1424},
{ 224, 8, -1448},
{ 296, -56, -1392},
{ 272, -152, -1208},
{ 200, -104, -1008},
{ 88, -80, -872},
{ -32, -136, -792},
{ -72, -128, -776},
{ -72, -168, -808},
{ -4... |
cal_tm;
localtime_r(&utc_sec, &local_tm);
if (local_tm.tm_hour < 10) {
local_tm.tm_hour = 12;
local_tm.tm_min = 0;
local_tm.tm_sec = 0;
} else if (local_tm.tm_hour < 16) {
local_tm.tm_hour = 18;
local_tm.tm_min = 0;
local_tm.tm_sec = 0;
} else {
local_tm.tm_hour += 2;
local_tm.t... | {
ActionMenuLevel *root_level = action_menu_get_root_level(action_menu);
action_menu_hierarchy_destroy(root_level, NULL, NULL);
i18n_free_all(root_level);
prv_reset_session_responsiveness();
} | |
ppOutboxStatus status, void *cb_ctx) {
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Helpers
static int s_num_message_handler_calls;
static AppOutboxMessage *s_last_message;
static void prv_message_handler(AppOutboxMessage *message) {
s_last_message = mess... | assert_sent_cb_last_status(AppOutboxStatusOutOfResources) | ;
}
void test_app_outbox__send_but_oom(void) {
prv_register();
fake_kernel_malloc_set_largest_free_block(0);
app_outbox_send(s_test_data, s_test_data_length,
test_app_outbox_sent_handler, s_expected_cb_ctx);
assert_sent_cb_last_status(AppOutboxStatusOutOfMemory);
}
void test_app_outbox__send... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.