prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
cl_assert_equal_p(write_sb, NULL);
// ..send_buffer_destroy() is already called in the yield cb
}
void test_session_send_buffer__write_beyond_available_space(void) {
s_valid_session = &s_session;
// Fill the send buffer completely:
const size_t max_length = comm_session_send_buffer_get_max_payload_length(&s... | memcmp(pp_data_out + sizeof(PebbleProtocolHeader) - offset,
fake_data_payload, max_payload_length - offset) | , 0);
// ..._get_read_pointer():
uint16_t bytes_read = 0;
uint16_t read_space;
const uint8_t *data_out;
while ((read_space = s_default_kernel_send_job_impl.get_read_pointer(job, &data_out))) {
PebbleProtocolHeader *header = (PebbleProtocolHeader *) data_out;
if (bytes_read == 0) {
cl_assert(re... |
rt_equal_i(fake_event_get_count(), 1);
cl_assert(prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get_next();
cl_assert(timer_id != TIMER_INVALID_ID);
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(5*60, stub_new_timer_timeout(timer_id) / 1000);
}
void test_calendar_handle_... | (stub_new_timer_is_scheduled(timer_id)) | ;
cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(110 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_count(), 6);
cl_assert(!prv_get_calendar_ongoing());
cl_assert(!stub_new_timer_is_scheduled(timer_id));
}
void test_calendar__handle_non_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... | (bg_color) | ) {
GDrawState prev_state = graphics_context_get_drawing_state(ctx);
graphics_context_set_fill_color(ctx, bg_color);
graphics_fill_rect(ctx, &layer->bounds);
graphics_context_set_drawing_state(ctx, prev_state);
}
}
//! helper struct to move displacement logic out of window_render()
typedef struct {
... |
void) {
prv_enable_display_access();
prv_display_write_byte(DISP_MODE_CLEAR);
prv_display_write_byte(0x00);
prv_disable_display_access();
}
//! Static mode is entered by sending 0x00 to the panel
//! This stops any further updates being registered by
//! the display, preventing corruption on shutdown / boot
... | memset(buffer, 0x00, sizeof(buffer)) | |
?
// A: No, a drop will be a NACK to the other side, so the other side should retry.
PBL_LOG(LOG_LEVEL_WARNING, "inbox dropped msg in state %u because %u", s_state.state, reason);
}
////////////////////////////////////////////////////////////////////////////////
// Object (de)serialization and (de)chunking
//////... | {
// Still not open and still things in the object queue, restart the timer:
prv_start_session_closed_object_queue_timer();
} | |
for (int i = 0; i < ARRAY_LENGTH(s_extra_case_items); i++) {
cl_assert_equal_i(pin_db_insert_item(&s_extra_case_items[i]), 0);
}
}
// 5am, no events passed
void test_timeline__extra_case_forwards(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNod... | (&iterator1, &state1, &head, TimelineIterDirectionFuture,
1421178000) | , 0);
// should have one alloc for each node in list, + 1 for the current timelineitem
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(),
init_net_allocs + ARRAY_LENGTH(s_items) + 1);
// second iterator should not alloc any more memory
cl_assert_equal_i(timeline_iter_init(&iterator2, &stat... |
/*
* 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... | {
char testbuf1[8] = "Hello!\0\0";
char testbuf2[8] = "Hello\0\0\0";
testbuf2[5] = '!';
cl_assert_equal_b(!strcmp(testbuf1, testbuf2), true);
} |
void test_strcmp__different_content(void) {
char testbuf1[8] = "Hello!\0\0";
char testbuf2[8] = "Hello\0\0\0";
cl_assert_equal_b(!strcmp(testbuf1, testbuf2), false);
}
void test_strcmp__n_same_buffer(void) {
char testbuf[8] = "Hello!\0\0";
cl_assert_equal_b(!strncmp(testbuf, testbuf, 8), true);
}
void tes... |
rv = pfs_seek(fd, -1, FSeekSet);
cl_assert(rv == E_RANGE);
}
void test_pfs__read(void) {
const int rd_len = 10;
int rv = pfs_read(-1, NULL, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_read(0, NULL, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = pfs_open("newfile", OP_FLAG_WRITE, F... | free(bigbuf) | ;
// now read back the large files
curr = 0;
for (int i = 0; i < 2; i++) {
snprintf(file_large, sizeof(file_large), "large%d", i);
int fd = pfs_open(file_large, OP_FLAG_READ, 0, 0);
cl_assert(fd >= 0);
size_t sz = pfs_get_file_size(fd);
cl_assert(sz == large_file_size);
uint8_t *b = call... |
unds(const Layer *layer, GRect *bounds_out) {
*bounds_out = layer->bounds;
}
void layer_mark_dirty(Layer *layer) {}
static Window s_app_window_stack_get_top_window;
Window *app_window_stack_get_top_window() {
return &s_app_window_stack_get_top_window;
}
// no text rendering in this test
void rocky_api_graphics_t... | cl_check(eq_result) | ;
}
void test_rocky_api_graphics_rendering__rect(void) {
prv_init_gcontext(GSize(500, 150));
prv_global_init_and_set_ctx();
// taken from http://fiddle.jshell.net/a5gjzb7c/6/
EXECUTE_SCRIPT(
"function render(x, y, f) {\n"
" f(x + 10, y + 10, 10, 10);\n"
" f(x + 30.2, y + 10, 10, 10.2);\n"
... |
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// SW = 3
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 3);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check... | setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 1) | |
Animation *current_down = prv_create_anim_frame_scroll((Layer *)swap_layer->current, SWAP_MS, dy,
NULL);
Animation *next_down = prv_create_anim_frame_scroll((Layer *)swap_layer->next, SWAP_MS, dy,
NULL);
... | ((Layer *)swap_layer->next, SCROLL_MS, dy, NULL) | ;
#if PBL_RECT
animation_set_curve(next, curve);
#endif
animation = animation_spawn_create(current, next, NULL);
} else {
animation = current;
}
swap_layer->animation = animation;
animation_schedule(animation);
}
// scroll to top of current notification
static void prv_scroll_to_top(SwapLayer *swap... |
har *[]){
"Unhandled exception",
" "ERROR_STRING,
NULL
};
const char *script = "var "FUNC_NAME" = function() { throw '"ERROR_STRING"'; };";
prv_do_call_user_function(script);
cl_assert(*s_log_internal__expected == NULL);
}
void test_rocky_api_util__call_throw_number(void) {
s_log_internal__expe... | {
// printf("passed for %04d-%02d-%02d: %d\n", y, (m + 1), d, (int)result);
} | |
prv_create_timer_if_needed();
bool success = new_timer_start(s_pb_state.timer_id, timeout_ms, prv_expect_init_timeout_cb, NULL,
0 /*flags*/);
PBL_ASSERTN(success);
xSemaphoreGive(s_pb_semaphore);
}
void put_bytes_handle_comm_session_event(const PebbleCommSessionEvent *
... | {
// Could happen if put_bytes_cancel() was called after "prepare"
PBL_LOG(LOG_LEVEL_WARNING, "No message pending, PutBytes cancelled? Will NACK.");
s_pb_state.receiver.should_nack = true;
goto finally;
} | |
rcular_buffer_write(&session->send_buffer, (const uint8_t *) &pp_header, sizeof(pp_header));
circular_buffer_write(&session->send_buffer, session->temp_write_buffer, session->bytes_written);
kernel_free(session->temp_write_buffer);
session->temp_write_buffer = NULL;
session->endpoint_id = ~0;
session->bytes_... | (&fake_transport->sent_data->node,
&data_node->node) | ;
}
circular_buffer_consume(&session->send_buffer, sizeof(pp_header) + pp_header.length);
}
kernel_free(buffer);
}
static void prv_fake_transport_reset(Transport *transport) {
cl_assert_(false, "Not implemented: prv_fake_transport_reset");
}
static const TransportImplementation s_fake_transport_implemen... |
// the data we got was the ACK of the write, so change the event type and don't block writes
event.smartstrap.type = SmartstrapDataSentEvent;
} else {
// prevent writing to the attribute until the app handles the event, at which point applib
// code will call sys_smartstrap_attribute_event_pr... | prv_queue_deferred_delete(attr, false /* !do_free */) | ;
}
mutex_unlock(s_attr_list_lock);
}
DEFINE_SYSCALL(void, sys_smartstrap_attribute_get_info, SmartstrapAttribute *app_attr,
uint16_t *service_id, uint16_t *attribute_id, size_t *length) {
mutex_lock(s_attr_list_lock);
SmartstrapAttributeInternal *attr = prv_find_by_buffer((uint8_t *)app_attr);
... |
cl_assert_equal_i(result, S_SUCCESS);
int val_i = atoi((char*)val + 1);
cl_assert_equal_i(key_i, val_i);
return true;
}
void test_settings_file__each(void) {
printf("\nTesting if we can use each...\n");
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_each", 4096));
uint8_t key[5... | (&file, "test_file_reallocate_larger", k_larger_size) | |
/*
* 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... | (system_flash_erase(FLASH_BASE, 1, NULL, NULL)) | ;
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sector(void) {
cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_s... |
ng on our own (someone found the sys_exit syscall and called in when
// we weren't expecting it?) we should let the app manager know.
process_manager_put_kill_process_event(task, true);
// Better to die in our sleep ...
vTaskSuspend(NULL /* self */);
// We don't expect someone to resume us.
PBL_CROAK("");... | milliseconds_to_ticks(1000) | )) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to send event %u to app! Closing it!", e->type);
// We could be called from a timer task callback, so post a kill event rather than call
// process_manager_close_process directly.
process_manager_put_kill_process_event(task, false);
return false;
}
return ... |
// Achieves the design spec'd 6 px horizontal spacing b/w the percent text and battery icon
battery_percent_text_node->margin.w = 4;
GTextNode *vertically_centered_battery_percent_text_node =
prv_wrap_text_node_in_vertically_centered_container(battery_percent_text_node);
graphics_text_node_conta... | if (!settings_glance->glance_state.is_pebble_app_connected) {
return RESOURCE_ID_CONNECTIVITY_BLUETOOTH_DISCONNECTED;
} else if (settings_glance->glance_state.is_quiet_time_enabled) {
return RESOURCE_ID_CONNECTIVITY_BLUETOOTH_DND;
} else if (prv_mute_notifications_allow_calls_only()) {
return RESOURCE_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... | (RCC_APB1PeriphClockCmd, DISPLAY_SPI_CLOCK) | ;
}
static void prv_enable_chip_select(void) {
gpio_use(DISP_GPIO);
GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_SET);
// required setup time > 3us
delay_us(7);
gpio_release(DISP_GPIO);
}
static void prv_disable_chip_select(void) {
gpio_use(DISP_GPIO);
// delay while last byte is emitted by the SPI periph... |
/*
* 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... | mutex_lock(s_buffer_mutex) | |
version = (Version) {
.major = PROCESS_INFO_CURRENT_SDK_VERSION_MAJOR,
.minor = PROCESS_INFO_CURRENT_SDK_VERSION_MINOR - 10
}
},
.should_pass = true
}, {
.entry = (AppInstallEntry) {
.install_id = 5,
.sdk_version = (Version) {
.major = PROCESS_INFO_CURRENT_SDK_VER... | cl_assert_equal_p(s_app_install_get_md__result,
s_app_manager_launch_new_app__config.md) | |
808, 192, -56},
{ 752, 184, -24},
{ 784, 216, -8},
{ 840, 168, -16},
{ 832, 112, 8},
{ 968, 128, 0},
{ 1024, 120, -32},
// 42 seconds
{ 1032, 128, -40},
{ 1152, 200, -96},
{ 1152, 192, -48},
{ 1024, 224, -72},
{ 1232, 216, -168},
{ 1320, 288, -176},
{ 1096, 296, ... | { 816, 296, -184},
{ 1048, 288, -224},
{ 1008, 344, -296},
{ 1072, 344, -272},
{ 1280, 424, -232},
{ 1152, 424, -216},
{ 1088, 376, -144},
{ 1120, 344, -144},
{ 1128, 312, -104},
{ 1056, 280, -48},
{ 896, 216, -16},
{ 792, 192, -64},
{ 768, 168, -16},
{ 768, 168, ... |
{ 1112, 352, -144},
// 50 seconds
{ 1152, 296, -120},
{ 1024, 272, -88},
{ 848, 224, -80},
{ 736, 184, -64},
{ 712, 184, -72},
{ 760, 192, -56},
{ 800, 176, -8},
{ 864, 160, -24},
{ 976, 168, -16},
{ 992, 160, 8},
{ 944, 184, -24},
{ 1184, 256, -152},
{ 1136,... |
ense at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific lang... | {
switch (state->recv_state) {
case QemuRecvState_WaitingHdrSignatureMSB: {
state->msg_buffer_bytes = 0;
shared_circular_buffer_read_consume(&state->isr_buffer, &state->isr_buffer_client, 1, &byte,
&bytes_read);
bytes_avail -= bytes_read;
if (byte == QEMU_HEADER_... |
state->hdr.protocol = ntohs(state->hdr.protocol);
state->hdr.len = ntohs(state->hdr.len);
// Validity checking
if (state->hdr.len > QEMU_MAX_DATA_LEN) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid header data size %d", state->hdr.len);
state->recv_state = QemuRecvState_Waitin... |
ssion_send_next(session);
session = next;
}
fake_system_task_callbacks_invoke_pending();
}
uint32_t fake_comm_session_get_responsiveness_max_period(void) {
return s_responsiveness_max_period_s;
}
uint32_t fake_comm_session_is_latency_reduced(void) {
return s_responsiveness_latency_is_reduced;
}
/////////... | (transport, &s_fake_transport_implementation,
fake_transport->destination) | ;
return fake_transport->session;
} else {
cl_assert(fake_transport->session);
comm_session_close(fake_transport->session, 0);
fake_transport->session = NULL;
return NULL;
}
}
void fake_transport_set_sent_cb(Transport *transport, FakeTransportSentCallback sent_cb) {
cl_assert(transport);
Fa... |
;
assert_cleanup_event(ObjectWatchApp, VALID_OBJECT_SIZE);
if (prv_put_bytes_get_max_batched_pb_ops() > 1) {
// With pre-acking, the put will have already been ack'ed and then a Nack will follow
assert_ack_count(1);
} else {
assert_ack_count(0);
}
assert_nack_count(1);
}
void test_put_bytes__ch... | prv_receive_init_and_put_fw_object() | |
} else {
// middle day of non-all day multiday event
prv_get_relative_all_day_string(word_buffer, word_buffer_size, current_day);
strncpy(number_buffer, "", number_buffer_size);
}
}
DEFINE_SYSCALL(bool, clock_is_24h_style, void) {
return shell_prefs_get_clock_24h_style();
}
void clock_set_24h_style(... | prv_format_time(buffer, buf_size, i18n_noop("%A"), timestamp) | ;
} else {
// Otherwise use "Month Day", aka "June 21"
prv_format_time(buffer, buf_size, i18n_noop("%B %d"), timestamp);
}
}
enum {
RoundTypeHalfUp,
RoundTypeHalfDown,
RoundTypeAlwaysUp,
RoundTypeAlwaysDown,
};
static time_t prv_round(time_t round_me, time_t multiple, int round_type) {
switch (r... |
t set here in case the app fetch fails.
menu_layer_reload_data(menu_layer);
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = app_node->install_id,
.common.reason = APP_LAUNCH_USER,
.common.button = BUTTON_ID_SELECT,
});
}
static int16_t get_cell_height_callback(struct MenuLayer *menu_... | (GColorJazzberryJam, GColorBlack) | |
, 608, -200},
{ -1568, 560, -496},
{ -1344, 296, -400},
{ -1192, 184, -176},
{ -840, 240, -104},
{ -736, 296, -16},
{ -688, 288, -16},
{ -760, 208, 56},
{ -736, 176, 48},
{ -688, 168, 80},
{ -960, 376, -8},
{ -1152, 360, 0},
{ -1984, 672, -144},
{ -1088, 536, -360},
... | { -1544, -144, -160},
{ -1712, 72, -152},
{ -1544, 440, -40},
{ -1272, 624, -192},
{ -1048, 488, -216},
// 13 seconds
{ -1248, 424, -168},
{ -1072, 248, -152},
{ -1192, 488, -184},
{ -1096, 744, -232},
{ -1560, 552, -104},
{ -1160, 376, -176},
{ -1112, 360, -312},
... |
{ -1336, 616, -176},
{ -1624, 384, 24},
{ -1672, 272, 40},
{ -1272, 192, 48},
{ -1080, 128, 32},
{ -1088, 152, 88},
{ -1104, 104, 80},
{ -1032, 72, 96},
{ -1056, 48, 104},
{ -1120, -72, 96},
{ -816, -200, -40},
{ -1072, -64, -104},
{ -1328, 264, -384},
{ -1168, 1... |
/*
* 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 (!response) {
return false;
} |
if (response->message_length < sizeof(HcProtocolMessage) + sizeof(uint8_t)) {
PBL_LOG(LOG_LEVEL_ERROR, "Received error response.");
return false;
}
*level = response->payload[0];
kernel_free(response);
return true;
}
static void prv_log_string_v1(BinLogMessage_String_v1 *msg) {
PBL_LOG(LOG_LEVEL_A... |
, active_cal: %"PRIu32", dist: %"PRIu32" ",
(int)sessions[i].activity, (int)sessions[i].start_utc, sessions[i].len_minutes,
sessions[i].steps, sessions[i].resting_calories, sessions[i].active_calories,
sessions[i].distance_mm);
}
printf("\nLooking for: type: %d, start_utc: %d, len: ... | (file, "test, epoch_type, epoch_idx") | ;
for (int i = 0; i < s_stats_num_columns; i++) {
fprintf(file, ", %s", s_stats_column_names[i]);
}
fprintf(file, "\n");
} else {
file = fopen(filename, "a");
cl_assert(file);
}
// Write out the column values for each row
StatsRow *row = s_stat_rows;
int row_idx = 0;
for (; row !=... |
// Attribute ID - AttributeIdTimestamp
0x04, 0x00, // Attribute Length
// Slice expiration time:
0x94, 0x64, 0x4F, 0x57, // 1464820884 (Wed, 1 June 2016 22:41:24 GMT)
0x30, // Attribute ID - AttributeIdIcon
0x04, 0x00, // Attribute Length
// Slice icon resou... | (app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, invalid_key_length,
(uint8_t *)&s_app_glance_basic,
sizeof(s_app_glance_basic)),
E_INVALID_ARGUMENT) | ;
// Invalid val length should fail
const size_t invalid_val_size = sizeof(SerializedAppGlanceHeader) - 1;
cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&s_app_glance_basic, invalid_val_size),
E_INVALID_... |
/*
* 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... | ulTaskDebugGetStackedLR(task_handle) | |
ase WATCH_INFO_COLOR_STAINLESS_STEEL:
model_name = TINTIN_MODEL("pebble_steel_silver");
break;
case WATCH_INFO_COLOR_MATTE_BLACK:
model_name = TINTIN_MODEL("pebble_steel_black");
break;
case WATCH_INFO_COLOR_BLUE:
model_name = TINTIN_MODEL("pebble_blue");
brea... | (fw_version.patch) | ;
// Parse the suffix out of the version tag
FirmwareMetadata md;
version_copy_running_fw_metadata(&md);
char *suffix_str = strstr(md.version_tag, "-");
if (suffix_str) {
// Skip the '-' character
suffix_str++;
} else {
suffix_str = "";
}
JS_VAR version_suffix = jerry_create_string((const j... |
[i].intime;
cond.eval_time = EVAL_FALL_THROUGH;
memset(s_output, 'Z', sizeof(s_output));
template_string_evaluate(s_truncation_tests[i].instr, s_output, s_truncation_tests[i].size,
&cond, &vars, &err);
cl_assert_equal_s(s_output, s_truncation_tests[i].output);
}
}
/////... | prv_state_init() | ;
s_vars.current_time = s_time_since_tests[i].current_time;
prv_template_evaluate_filter(&s_state, "time_since", s_time_since_tests[i].params);
cl_assert_equal_b(s_state.filters_complete, false);
cl_assert_equal_i(s_state.filter_state, s_time_since_tests[i].done_state);
prv_state_init();
s_vars... |
8_t rssi;
int8_t tx_power_level;
char local_name[32];
bool has_services;
bool has_heart_rate_service;
Uuid first_service_uuid;
} ScanResult;
static bool s_is_scanning;
//------------------------------------------------------------------------------
// ScanResult List management
static ScanResult *s_head;
... | (APP_LOG_LEVEL_INFO, "Local Name: %s", result->local_name) | ;
} else {
// Clear out the local name field:
result->local_name[0] = 0;
}
// Try to copy the first Service UUID, we'll display this in the list:
const uint8_t num_services = ble_ad_copy_service_uuids(ad_data,
&result->first_service_uuid, 1);
if (num_se... |
CURRENT_TEXT_COLOR, container);
graphics_text_node_draw(&container->node, ctx, &rect, NULL, NULL);
graphics_text_node_destroy(&container->node);
} else {
char buffer[16];
const GFont font = data->em_dash_font;
snprintf(buffer, sizeof(buffer), EM_DASH);
graphics_co... | layer_get_data(base_layer) | ;
i18n_free_all(base_layer);
kino_reel_destroy(data->icon);
layer_destroy(base_layer);
}
GColor health_sleep_summary_card_get_bg_color(Layer *layer) {
return CARD_BACKGROUND_COLOR;
}
bool health_sleep_summary_show_select_indicator(Layer *layer) {
HealthSleepSummaryCardData *health_sleep_summary_card_data = ... |
/*
* 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... | (recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
sizeof(s_test_impl_data), dummy,
NULL)) | ;
s_test_impl.handle_touch_event = dummy;
s_test_impl.reset = NULL;
cl_assert_passert(recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
sizeof(s_test_impl_data), dummy,
NULL));
s_test_impl.reset = dummy;
... |
/*
* 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 *window = window_stack_get_top_window(&context->window_stack);
return (window && !window->is_transparent);
} | |
raw.up_handler),
ClickHandlerOffsetRawDown = offsetof(ClickConfig, raw.down_handler),
} ClickHandlerOffset;
static ClickHandler prv_get_handler(ClickRecognizer *recognizer, ClickHandlerOffset offset) {
return *((ClickHandler*)(((uint8_t*)&recognizer->config) + offset));
}
static void prv_cancel_timer(AppTimer **t... | {
return LONG_CLICK_DEFAULT_DELAY_MS;
} |
return recognizer->config.long_click.delay_ms;
}
inline static bool prv_can_more_clicks_follow(ClickRecognizer *recognizer) {
if (recognizer->number_of_clicks_counted >= prv_multi_click_get_max(recognizer)) {
return false;
}
return true;
}
uint8_t click_number_of_clicks_counted(ClickRecognizerRef recogni... |
, 120},
{ 800, 64, 8},
{ 792, 112, 64},
{ 792, 0, 64},
{ 784, -112, 88},
{ 904, -104, -8},
{ 936, -64, -8},
{ 1432, -168, 88},
{ 1368, -8, 152},
{ 1320, 160, -56},
// 104 seconds
{ 1432, 248, -96},
{ 1096, 344, 0},
{ 840, 64, 176},
{ 976, 248, 64},
{ 952, 280,... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_25297_11
//> TEST_EXPECTED 200
//> TEST_EXPECTED_MIN 165
//> TEST_EXPECTED_MAX 230
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ 88, -104, -1024},
{... |
{ 744, 96, 272},
{ 736, 136, 128},
{ 744, 224, 32},
{ 760, 208, 64},
{ 776, 264, 16},
{ 832, 424, -168},
{ 744, 360, 32},
{ 1208, 440, -80},
{ 1264, 136, 128},
{ 1736, 320, 160},
{ 1448, 416, -24},
{ 568, 520, 24},
{ 600, 176, -32},
{ 944, 136, 136},
{ 936, 1... |
ge_calls;
GRect last_will_change_final_area;
AnimationProgress last_change_progress;
} UnobstructedAreaTestData;
UnobstructedAreaTestData s_data;
static void prv_will_change(GRect final_area, void *context) {
s_data.last_will_change_final_area = final_area;
cl_assert_equal_p(context, s_data.context);
s_data... | app_state_get_unobstructed_area_state() | ->handlers.will_change, prv_will_change);
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
fake_event_service_handle_last();
unobstructed_area_service_will_change(from_area.size.h,... |
/*
* 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->stroke_width.curve(normalized) | :
animation_timing_curve(normalized, AnimationCurveEaseInOut);
gdraw_command_list_scale_stroke_width(
list, data->stroke_width.from, data->stroke_width.to,
data->stroke_width.from_op, data->stroke_width.to_op, stroke_width_progress);
if (delay_ctx.owns_lookup) {
applib_free(index_lookup);
... |
ification_ignore_seconds);
}
// -----------------------------------------------------------------------------
// Data source (DS) notification reassembly logic
static void prv_reset_reassembly_context(void) {
memset(s_ancs_client->attributes, 0, sizeof(s_ancs_client->attributes));
buffer_clear(&s_ancs_client->rea... | prv_reassembly_is_complete(response_data, response_length,
&parse_error) | ;
if (parse_error) {
PBL_HEXDUMP(LOG_LEVEL_INFO, response_data, response_length);
prv_reset_due_to_parse_error();
return;
}
if (!is_complete) {
// Keep waiting
BLE_LOG_DEBUG("Incomplete response. Waiting for another DS notification.");
return;
}
// Got all the data, pass up to parse... |
.types = types,
}
};
ProtobufLogRef session_ref = protobuf_log_create(&log_config, prv_protobuf_log_transport, 110);
cl_assert(session_ref != NULL);
// ------------------
// Keep adding samples, relying on auto-flush
bool success;
TestPLParsedMsg *msg;
uint32_t num_samples_encoded = 0;
for ... | rtc_get_time() | ,
vals[0], // BPM
vals[1]); // Quality
cl_assert(success);
}
// Convert the values from HRMQuality to pebble_pipeline values
for (unsigned i = 1; i < input.msrmt.num_values; i += 2) {
values[i] = prv_hr_quality_int(values[i... |
ntry, and delete the app cache
app_cache_free_up_space(1);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_b(false, app_cache_entry_exists(app1.id));
cl_assert_equal_b(false, app_cache_entry_exists(app2.id));
cl_assert_equal_b(false, app_cache_entry_exists(app3.id));
}
static const uint32_t SIZ... | (S_SUCCESS, app_cache_add_entry(t_data[i].id, t_data[i].size)) | ;
cl_assert_equal_i(S_SUCCESS, app_cache_app_launched(t_data[i].id));
// increment time so everything won't happen in the same second
}
for (int i = 0; i < 50; i++) {
cl_assert_equal_b(true, app_cache_entry_exists(t_data[i].id));
}
cl_assert_equal_i(SIZE_SUM, app_cache_get_size());
}
void prv_cle... |
GAPLEClient client, HandleAndConnectionGetter handle_getter,
PebbleBLEGATTClientEventType subtype) {
BTErrno ret_val = BTErrnoOK;
bt_lock();
{
GAPLEConnection *connection;
const uint16_t att_handle = handle_getter(obj_ref, &connection);
if (!att_handle) {
... | prv_write(cccd, (const uint8_t *) value, sizeof(*value), GAPLEClientKernel,
gatt_client_descriptor_get_handle_and_connection,
PebbleBLEGATTClientEventTypeCharacteristicSubscribe) | ;
}
static bool prv_deinit_ctx_list(ListNode *node, void *unused) {
kernel_free(node);
return true;
}
void gatt_client_op_cleanup(GAPLEClient client) {
bt_lock();
{
// Free all memory associated with outstanding operations
list_foreach(&s_client_event_ctxs[client]->node, prv_deinit_ctx_list, NULL);
... |
ed_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, spawn), 1);
// Run to the completion of C, start of D
prv_advance_to_ms_with_timers(start_ms + 1080 + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1);
cl_a... | (a, handlers, context) | ;
animation_set_auto_destroy(a, auto_destroy);
animation_schedule(a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_a);
animation_set_delay(b, delay_a);
animation_set_handlers(b, handlers, context);
animation_set_auto_destroy(b, auto_destroy);
animation_schedule(b);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (unsigned int i = 0; i < data_length; ++i) {
last_word = (last_word << 8) | data[i];
} |
crc_value = CRC_CalcCRC(last_word);
} else {
crc_value = CRC_GetCRC();
}
return crc_value;
}
static void prv_calculate_incremental_stop(void) {
prv_disable_crc_clock();
}
uint32_t crc_calculate_bytes(const uint8_t* data, unsigned int data_length) {
prv_calculate_incremental_start();
// First ca... |
cl_assert(ancs_filtering_is_muted(&mute_always)) | ;
cl_assert(!ancs_filtering_is_muted(&mute_weekends));
cl_assert(ancs_filtering_is_muted(&mute_weekdays));
}
void test_ancs_filtering__record_app_no_display_name(void) {
iOSNotifPrefs *existing_prefs = NULL;
// No display name so we expect the app name to be the title
AttributeList expected_attributes = {
... | |
{
// Increment source but don't draw
continue;
}
}
dest[dest_x] = src[src_x];
}
}
break;
}
case GCompOpTint:
case GCompOpTintLuminance:
case GCompOpSet:
default: {
// Initialize the tint luminance lookup table if ... | (dest_bitmap, dest_y) | ;
uint8_t *dest = dest_row_info.data;
const int16_t dest_delta_begin_x = MAX(dest_row_info.min_x - dest_rect.origin.x, 0);
const int16_t dest_begin_x = dest_delta_begin_x ? dest_row_info.min_x : dest_rect.origin.x;
const int16_t dest_end_x = MIN(grect_get_max_x(&dest_rect), dest_row_info.max_x + 1);
... |
_recursive(s_resource_mutex);
return rv;
}
void resource_init(void) {
// see if there's a system bank waiting to be loaded
resource_storage_init();
s_resource_mutex = mutex_create_recursive();
}
uint32_t resource_get_and_cache(ResAppNum app_num, uint32_t resource_id) {
PBL_ASSERTN(app_num == SYSTEM_APP);
... | (s_resource_mutex) | ;
bool rv = resource_storage_check(app_num, resource_id, NULL /* No expected version */);
if (rv) {
ResourceStoreEntry entry;
prv_get_resource(app_num, resource_id, &entry);
rv = (entry.id != 0);
}
mutex_unlock_recursive(s_resource_mutex);
return rv;
}
bool resource_version_matches(const Resource... |
/*
* 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... | (a23 - atan2_lookup((int16_t)((y2 - y1) / fixedpoint_base),
(int16_t)((x2 - x1) / fixedpoint_base))) | |
);
chunk_size = 0;
}
if (samples_in_minute >= KALG_SAMPLE_HZ * SECONDS_PER_MINUTE) {
ref_minute_stats(&orientation, &vmc);
samples_in_minute = 0;
}
}
// leftover data, if any
if (chunk_size > 0) {
steps = ref_accel_data_handler(accel_buf, chunk_size);
}
steps = ref_finish_ep... | if (strcmp(token, "TEST_WEIGHT") == 0) {
sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight);
} else if (strcmp(token, "TEST_NAME") == 0) {
sscanf(token + strlen(token) + 1, "%s", state->test_entry.name);
} |
}
// If this is a "static AccelRawData samples[] = {" line, skip it
if (strcmp(token, "static") == 0) {
continue;
}
// Grab a sample
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
int x, y, z;
sscanf(token + strlen(token) + 1, "%d, %d, %d",... |
v_open(file, name, flags, max_used_space);
}
status_t status = bootup_check(file);
if (status < 0) {
PBL_LOG(LOG_LEVEL_ERROR,
"Bootup check failed (%"PRId32"), not good. "
"Attempting to recover by deleting %s...", status, name);
pfs_close_and_remove(fd);
return prv_open(file,... | settings_raw_iter_end(&file->iter) | ;
settings_raw_iter_next(&file->iter)) {
if (overwritten(&file->iter.hdr) || deleted_and_expired(&file->iter.hdr)) {
file->dead_space += record_size(&file->iter.hdr);
} else {
file->used_space += record_size(&file->iter.hdr);
}
if (file->iter.hdr.last_modified > file->last_modified) {... |
out_service_get_current_workout_hr_zone_time(hr_zone_time_s));
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 0);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone1], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone2], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 0);
prv_inc_time(10);
prv_put_bpm_even... | (workout_service_pause_workout(false)) | |
DDING (4)
#define MIC_DOT_MAX_RADIUS (9)
#define MIC_DOT_LAYER_RADIUS (MIC_DOT_MAX_RADIUS + 1)
#define MIC_DOT_LAYER_SIZE ((GSize){ .w = MIC_DOT_LAYER_RADIUS * 2, .h = MIC_DOT_LAYER_RADIUS * 2})
#define MAX_MESSAGE_LEN (500)
#define MAX_ERROR_COUNT (4)
#define ERROR_DIALOG_TIMEOUT (5000)
static const uint32_t UNFO... | prv_start_dictation(data) | |
info->get_val(file, (uint8_t *)&value, sizeof(uint32_t));
cl_assert(value == desired_value);
return true;
}
static void prv_test_settings_file_compaction(const bool manual) {
// If manual is enabled, then the test will force a compaction every so often
// If manual is disabled, then the test will only compa... | (settings_file_set(&file, key, key_len, val, val_len), E_OUT_OF_STORAGE) | |
st_semaphore, portMAX_DELAY);
return data->last_test_step_result;
}
return true;
}
static void prv_stop_mic_and_cleanup(AppData *data) {
mic_stop(MIC);
app_free(data->mic_buffer);
data->mic_buffer = NULL;
}
static void prv_run_test(AppData *data) {
PBL_ASSERTN(data->current_test_step == BTLETestStep_N... | number_window_init(number_window, label,
(NumberWindowCallbacks){ .selected = prv_number_window_selected_cb, }, value) | ;
number_window_set_min(number_window, 0);
number_window_set_max(number_window, max);
number_window_set_value(number_window, *value);
app_window_stack_push(number_window_get_window(number_window), true);
}
//--------------------------------------------------------------------------------
// Payload Selection... |
int num_sleep_sessions = 4;
const int num_restfulsleep_sessions = 2;
const int num_run_sessions = 1;
const int num_walk_sessions = 1;
const int num_open_sessions = 1;
const int num_sessions = num_sleep_sessions + num_restfulsleep_sessions +
num_run_sessions + num_walk_sessions + nu... | cl_assert_equal_i(s_sys_activity_get_metric_values.in.metric, ActivityMetricSleepState) | ;
s_sys_activity_get_metric_values.out.history[0] = ActivitySleepStateLightSleep;
activities = health_service_peek_current_activities();
cl_assert_equal_i(activities, HealthActivitySleep);
s_sys_activity_get_metric_values.out.history[0] = ActivitySleepStateRestfulSleep;
activities = health_service_peek_curr... |
ter, 1, 2);
cl_assert_fixedS16_3(radius, 1);
}
void test_graphics_circle__grect_polar_calc_values_edge_cases(void) {
GPointPrecise center = {};
Fixed_S16_3 radius = {};
const GOvalScaleMode mode = GOvalScaleModeFillCircle;
GRect r = GRect(0, 5, 0, 0);
grect_polar_calc_values(&r, mode, ¢er, &radius);
... | graphics_fill_oval(NULL, GRect(10, 12, -10, -12), GOvalScaleModeFitCircle) | ;
cl_assert_gpoint_precise(s_center, 4.5, 5.5);
cl_assert_fixedS16_3(s_radius_outer, 4.5);
cl_assert(s_radius_inner.integer <= 0);
cl_assert_equal_i(s_angle_start, 0);
cl_assert_equal_i(s_angle_end, TRIG_MAX_ANGLE);
graphics_fill_oval(NULL, GRect(0, 0, 0, 0), GOvalScaleModeFillCircle);
cl_assert_gpoint_... |
rs/task_watchdog.h"
#include "flash_region/filesystem_regions.h"
#include "flash_region/flash_region.h"
#include "services/normal/filesystem/pfs.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include "util/size.h"
//! Flash translation operation
typedef enum {
FTLRead,
FTLWrite,... | (s_region_list[i].start, s_region_list[i].end, true) | ;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Filesystem: New size - %"PRId32" Kb", (s_ftl_size / 1024));
}
uint32_t ftl_get_size(void) {
return s_ftl_size;
}
static void prv_ftl_operation(uint8_t *buffer, uint32_t size, uint32_t offset,
FTLOperation operation) {
uint32_t curr_virt_offset_begin = 0;
uint32_t curr_vir... |
/*
* 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... | {
units_changed |= DAY_UNIT;
} |
if (s_state.last_time.tm_mon != currtime.tm_mon) {
units_changed |= MONTH_UNIT;
}
if (s_state.last_time.tm_year != currtime.tm_year) {
units_changed |= YEAR_UNIT;
}
}
}
s_state.last_time = currtime;
s_state.first_tick = false;
if ((s_state.tick_units & units_change... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_get_root_layer(window) | ;
layer_init(&pin_window->layer, &window_layer->bounds);
layer_add_child(window_layer, &pin_window->layer);
TimelineItemLayer *item_layer = &pin_window->item_detail_layer;
timeline_item_layer_set_click_config_onto_window(item_layer, window);
layer_add_child(&pin_window->layer, &item_layer->layer);
layer_i... |
mutex_create() | ;
}
void voltage_monitor_device_init(VoltageMonitorDevice *device) {
gpio_analog_init(&device->input);
}
// It takes ~12µs to get our ADC readings. From time to time, we're busy
// processing elsewhere for upwards of 25µs and end up getting overrun issues.
// In the case that overrun occurs, clean the flag and retu... | |
int16_t y, Fixed_S16_3 *left_margin, Fixed_S16_3 *right_margin) {
// This function will calculate edges of the cap for stroked line using horizontal lines
Fixed_S16_3 progress = (Fixed_S16_3){.integer = y};
prv_calc_cap_prepared(line_end_point->y, line_end_point->x,
cap_radius, progress, ... | if (dy_fixed > 0) {
// Line heading up left
(*far_top) = points[3];
(*far_bottom) = points[0];
(*far_left) = points[2];
(*far_right) = points[1];
} else {
// Line heading up right
(*far_top) = points[2];
(*far_bottom) = points[1];
(*far_left) = points[0];
... |
}
// Since we already rotated the vector by 90 degrees, delta x is actually delta y
// therefore if x is bigger than y we have have vertical dominance
if (ABS(dx_fixed) > ABS(dy_fixed)) {
return true;
}
return false;
}
void prv_draw_stroked_line_precise(GContext* ctx, GPointPrecise p0, GPointPrecise... |
/*
* 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... | BcdToByte((time_register & (RTC_TR_HT | RTC_TR_HU)) >> 16) | ;
const uint8_t minutes = BcdToByte((time_register & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);
const uint8_t seconds = BcdToByte(time_register & (RTC_TR_ST | RTC_TR_SU));
return (((hours * 60) + minutes) * 60) + seconds;
}
static RtcIntervalTicks elapsed_ticks(RtcIntervalTicks before, RtcIntervalTicks after) {
int32_... |
/*
* 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... | (range_end, top, bottom) | ;
// height of triangle from center to range start
height = ABS(center.y - range_start);
const int32_t start_width = prv_triangle_side(radius, height);
// height of triangle from center to range end
height = ABS(center.y - range_end);
const int32_t end_width = prv_triangle_side(radius, height);
width =... |
{ 1944, 72, 856},
{ 1696, -16, 576},
{ 1624, 40, 536},
{ 1664, 72, 552},
{ 1584, -16, 440},
{ 1408, -96, 368},
{ 1312, -40, 224},
{ 920, -248, -584},
{ 824, 224, -656},
{ 800, -200, -272},
{ 1272, 288, 104},
{ 1432, 224, 304},
{ 1584, -8, 440},
{ 1728, 48, 552},
... |
{ 464, 856, 1312},
// 267 seconds
{ 664, 472, 1464},
{ 1072, 256, 1096},
{ 1712, 328, 1224},
{ 2440, 80, 1232},
{ 2312, 72, 944},
{ 2080, -24, 1032},
{ 2112, 24, 752},
{ 1848, -16, 648},
{ 1728, 272, 752},
{ 1224, 384, 736},
{ 720, 696, 648},
{ 320, 664, 568},
... | |
_interval_s, expire_s,
features);
fake_system_task_callbacks_invoke_pending();
HRMSubscriberState *subscriber = prv_get_subscriber_state_from_ref(session_ref);
cl_assert(subscriber);
cl_assert(subscriber->session_ref == session_ref);
cl_assert(subsc... | sys_hrm_manager_get_app_subscription(app_id) | == HRM_INVALID_SESSION_REF);
}
// Test that system subscriptions expire correctly
void test_hrm_manager__kernel_expiration(void) {
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
const uint16_t expire_s = SECONDS_PER_MINUTE;
HRMSessionRef session_ref = hrm_manager_subscribe_with_callback(INSTALL_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... | malloc(sizeof(GContext)) | |
/*
* 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_get("TIME IN ZONES", card_data) | ,
.primary_value = app_zalloc_check(buffer_size),
.fill_color = GColorWhite,
.outline_color = PBL_IF_COLOR_ELSE(GColorClear, GColorBlack),
};
prv_set_heading_value(heading->primary_value, buffer_size,
(zone_time_minutes * SECONDS_PER_MINUTE), card_data);
const HealthDetailCar... |
a->window;
window_init(window, WINDOW_NAME("Bluetooth SSP"));
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
});
window_set_user_data(window, data);
window_set_overrides_back_button(window, true);
modal_window_push(window, ModalPriorityC... | {
PBL_LOG(LOG_LEVEL_ERROR, "Got complete event for unknown process %p vs %p",
event->ctx, s_data_ptr ? s_data_ptr->ctx : NULL);
} |
break;
default:
WTF;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// BT Driver callback implementations:
static void prv_put_pairing_event(const PebbleBluetoothPairEvent *pair_event) {
PebbleEvent event = {
.type = PEBBLE_BT_PAIRING... |
GAPLEClientKernel);
cl_assert_equal_i(e, BTErrnoOK);
cl_assert_equal_i(s_last_cccd_value, BLESubscriptionIndications);
prv_confirm_cccd_write(BLEGATTErrorSuccess);
prv_assert_subscription_event(characteristic, BLESubscriptionIndications, BLEGATTErrorSuccess,
true /* kernel */, false /* app ... | gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
GAPLEClientApp) | ;
s_last_cccd_value = ~0;
// Unsubscribe kernel:
e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionNone, GAPLEClientKernel);
// Kernel should get event immediately:
prv_assert_subscription_event(characteristic, BLESubscriptionNone, BLEGATTErrorSuccess,
true /* kernel ... |
E_NAME_MAX_LENGTH sizeof("ps000001")
static status_t prv_get_file_name(char *name, size_t buf_len, const Uuid *uuid) {
// Firmware 2.x persist files are named "p%06d", the added "s" in the file
// name prefix indicates that it is in SettingsFile format.
int pid = persist_map_auto_id(uuid);
if (FAILED(pid)) {
... | (store &&
list_contains(s_client_stores, &store->list_node) &&
store->usage_count >= 1) | ;
if (--store->usage_count == 0) {
if (store->file_open) {
settings_file_close(&store->file);
}
list_remove(&store->list_node,
&s_client_stores /* &head */, NULL /* &tail */);
kernel_free(store);
}
}
prv_unlock();
}
|
erases++) {
for (int i = 0; i < num_pages(); i++) {
snprintf(file_small, sizeof(file_small), "file%d", i);
snprintf(buf, sizeof(buf), "This is small buf %d!", i);
int len = strlen(buf);
int fd = pfs_open(file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, len);
cl_assert(fd >= 0);
cl_as... | (file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, sizeof(buf)) | |
%[reset_handler]\n"
: : [initial_sp] "r" (initial_stack_pointer),
[reset_handler] "r" (reset_handler)
);
__builtin_unreachable();
}
static bool prv_check_and_increment_reset_loop_detection_bits(void) {
uint8_t counter =
(boot_bit_test(BOOT_BIT_RESET_LOOP_DETECT_THREE) << 2) |
(boot_bit_te... | if ((uintptr_t)reset_vector == 0xffffffff ||
(uintptr_t)initial_sp == 0xffffffff) {
dbgserial_putstr("Firmware is erased");
return 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... | if (s_comm_override == BtCtlModeOverrideNone && !s_comm_airplane_mode_on) {
return true;
} |
}
return false;
}
bool bt_ctl_is_bluetooth_running(void) {
return s_comm_is_running;
}
static void prv_put_disconnection_event(void) {
PebbleEvent event = (PebbleEvent) {
.type = PEBBLE_BT_CONNECTION_EVENT,
.bluetooth.connection = {
.is_ble = true,
.state = PebbleBluetoothConnectionEventS... |
0x05, 0x00, 0x52, 0x65, 0x70, 0x6c,
0x79, 0x08, 0x71, 0x00, 0x4f, 0x6b, 0x00, 0x59, 0x65, 0x73, 0x00, 0x4e, 0x6f, 0x00, 0x43, 0x61,
0x6c, 0x6c, 0x20, 0x6d, 0x65, 0x00, 0x43, 0x61, 0x6c, 0x6c, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6c,
0x61, 0x74, 0x65, 0x72, 0x00, 0x54, 0x68, 0x61, 0x6e, 0x6b, 0x20, 0x79, 0x6f, 0x75, 0... | (name->cstring, "GMail") | ;
Attribute *updated = attribute_find(¬if_prefs->attr_list, AttributeIdLastUpdated);
cl_assert(updated);
cl_assert_equal_i(updated->uint32, 123456);
attribute_list_destroy_list(&attr_list);
ios_notif_pref_db_free_prefs(notif_prefs);
}
void test_ios_notif_pref_db__store_empty_prefs(void) {
// Store empt... |
/*
* 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(!alerts_should_notify_for_type(AlertInvalid)) | ;
cl_assert(!alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_notify_for_type(AlertReminder));
}
void test_alerts__migration(void) {
cl_assert(alerts_get_mask() == AlertMaskAllOn);
alerts_set_mask(AlertMaskAllOnLegacy);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
}
void test_alert... |
8753a444d6f12269c600050e4c00067
uint8_t data[GAP_LE_AD_REPORT_DATA_MAX_LENGTH] =
"\x02\x01\x1a\x11\x06\x67\x00\xc0\xe4\x50\x00\x60\x9c\x26\x12\x6f\x4d\x44" \
"\x3a\x75\x68";
set_ad_data(data, sizeof(data));
// Test ble_ad_includes_service:
uint8_t uuid_bytes[] = "\x68\x75\x3a\x44\x4d\x6f\x12\x26\x9c\x... | bt_uuid_expand_16bit(0x1800 + i) | ;
}
// Hand-construct expected raw advertisement data:
uint8_t expected_ad_data[] = {
(2 * sizeof(uint16_t)) + 1 /* +1 for Type byte */,
0x03, // Service UUIDs, 16-bit, Complete
0x00, 0x18, // Little endian
0x01, 0x18,
};
// 2x 16-bit UUIDs should fit fine, expect true:
ad = ble_ad_create(... |
e License for the specific language governing permissions and
* limitations under the License.
*/
#include "peek.h"
#include "drivers/rtc.h"
#include "kernel/event_loop.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "kernel/pebble_tasks.h"
#include "services/common/system_task.h"
#include "se... | if ((now > start) && (time_util_get_midnight_of(now) == time_util_get_midnight_of(start))) {
update->today_timed_event_passed = true;
} |
if (now >= end) {
return false;
}
if (header->common.dismissed) {
// Ignore dismissed events
return false;
}
const bool peeking = prv_is_in_peeking_time_window(header, now);
if (peeking) {
update->num_peeking++;
}
// Peeking or future event
return (peeking || (now <= start));
}
stati... |
a_end);
return;
}
#endif
graphics_fill_rect(
ctx, &(GRect) { { x_range_begin.integer + 1, y },
{ x_range_end.integer - x_range_begin.integer - 1, 1 } });
}
void gpath_draw_filled(GContext* ctx, GPath* path) {
#if PBL_COLOR
// This algorithm makes sense only in 8bit mode...
if (c... | GPointPreciseFromGPoint(
rotate_offset_point(&path->points[0], path->rotation, &path->offset)) | ;
min_x = max_x = rot_points[0].x.integer;
min_y = max_y = rot_points[0].y.integer;
// begin finding the last path segment's direction going backwards through the path
// we must go backwards because we find intersections going forwards
for (int i = path->num_points - 1; i > 0; --i) {
rot_points[i] = rot... |
3PeriphResetCmd(ahb3_periphs, ENABLE);
RCC_AHB3PeriphResetCmd(ahb3_periphs, DISABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, ENABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, DISABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, ENABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, DISABLE);
}
static void __attribute__((noreturn... | ("Failed to start firmware, strike three.") | ;
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
return true;
} else if (boot_bit_test(BOOT_BIT_FW_START_FAIL_STRIKE_ONE)) {
dbgserial_putstr("Failed to start firmware, strike two.");
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
} else {... |
c16();
hw_cpm_dcdc_off();
hw_cpm_ldo_io_ret_off();
hw_watchdog_freeze();
while (true) {
__WFI();
}
__builtin_unreachable();
}
// Timer0 is very limited -- there is no way to reset the count until it's triggered, so it's
// not useful as a generic one-shot. We'll let it run free and calculate deltas.... | {
s_spi_dma_complete = false;
hw_spi_read_buf(s_spi->bus_id, buffer, len, prv_spi_dma_tx_cb, NULL);
// Now signal the host that we're ready to RX.
host_transport_set_mcu_int(true);
prv_wait_for_dma(false);
host_transport_set_mcu_int(false);
} |
static void prv_send_response(const uint8_t *buffer, uint16_t len) {
uint32_t crc = crc32(CRC32_INIT, buffer, len);
s_spi_dma_complete = false;
hw_spi_write_buf(s_spi->bus_id, buffer, len, prv_spi_dma_tx_cb, NULL);
// Now signal the host that we're ready to TX.
host_transport_set_mcu_int(true);
prv_wait... |
48, 504, -32},
{ 1392, 512, -96},
{ 1112, 368, -56},
{ 1376, 352, -24},
{ 1416, 312, 56},
{ 1128, 256, 88},
{ 872, 256, 32},
{ 800, 256, 24},
{ 816, 200, 88},
{ 816, 120, 120},
{ 800, 128, 80},
{ 792, 104, 40},
{ 880, 72, 64},
{ 960, 72, 48},
{ 1440, 48, 120},
... | { 1152, 456, -40},
{ 1264, 312, 56},
// 63 seconds
{ 1392, 296, 64},
{ 1256, 248, 96},
{ 992, 208, 104},
{ 840, 224, 88},
{ 816, 208, 88},
{ 808, 160, 112},
{ 784, 120, 136},
{ 744, 144, 48},
{ 776, 80, 8},
{ 896, 72, 40},
{ 1104, 24, 32},
{ 1560, 224, 8},
... |
{ 1160, -24, 56},
{ 1408, 48, -16},
{ 1264, 232, -352},
{ 1408, 312, -280},
{ 1608, 744, -424},
{ 1272, 600, -80},
{ 960, 304, 0},
// 66 seconds
{ 816, 232, -8},
{ 728, 280, 24},
{ 664, 328, 32},
{ 728, 368, 8},
{ 800, 400, -8},
{ 992, 432, -8},
{ 1264, 496, ... |
timeline_model_get_iter_state(0) | ->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(1));
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_w... | |
/*
* 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... | (buffer, 30) | ;
pb_encode(&s, SimpleMessage_fields, &msg);
PBL_LOG(LOG_LEVEL_DEBUG, "Encoded message, size: %u bytes", s.bytes_written);
PBL_HEXDUMP(LOG_LEVEL_DEBUG, buffer, s.bytes_written);
app_state_set_user_data(buffer);
}
static void prv_deinit(void) {
SimpleMessage msg = {0};
uint8_t *buffer = app_state_get_user_d... |
/*
* 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 (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(tz_p, sizeof(*tz_p));
} |
time_t utc_now;
time_ms(&utc_now, NULL);
int32_t dstoffset = time_get_isdst(utc_now) ? time_get_dstoffset() : 0;
tz_p->daylight_saving_time = dstoffset / 3600;
tz_p->offset = -1 * time_get_gmtoffset() / 60;
return 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... | (s_text_layer, GTextAlignmentCenter) | ;
layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
}
static void prv_window_unload(Window *window) {
text_layer_destroy(s_text_layer);
}
static void prv_init(void) {
s_window = window_create();
window_set_click_config_provider(s_window, prv_click_config_provider);
window_set_window_handler... |
detail_card__render_no_data(void) {
prv_create_card_and_render(&(HealthDetailCardConfig) {});
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_detail_card__render_one_heading(void) {
HealthDetailCardConfig config = {
.num_headings = 1,
.headings = &(HealthDetailHeading) {
... | prv_create_card_and_render(&config) | ;
#if PBL_ROUND
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);
#endif
window_render(&card->window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_detail_card__render_crown(void) {
HealthDetailZone zones[] = DEFAULT_ZONE... |
/*
* 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(fb);
} |
// Tests
////////////////////////////////////
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 30, 40)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 30, 40)
#define START_ON_ORIGIN_RECT GPointPrecise(5, 5)
#define END_ON_ORIGIN_RECT GPointPrecise(... |
draw_horizontal_line_dotted(&ctx, GPoint(0, 11), 3);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 13), 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 15), 20);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 17), 21);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 19), 22);
graphi... | (&ctx, GPoint(0, 7), 1) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 11), 3);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 13), 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 15), 20);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 17), 21... |
wakeup_id), first_event);
TimerID first_timer = wakeup_get_current();
// Schedule another a minute away
time_t second_event = sys_get_time() + WAKEUP_EVENT_WINDOW * 2;
WakeupId second_wakeup_id = sys_wakeup_schedule(second_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(second_wakeup_id), second_event)... | cl_assert_equal_i(sys_wakeup_query(first_timer), E_DOES_NOT_EXIST) | ;
}
|
tats(true);
stub_pebble_tasks_set_current(TEST_TARGET_TASK);
s_num_messages_to_consume_from_handler = 0;
s_can_send_event = true;
s_dropped_idx = 0;
memset(s_dropped_messages, 0, sizeof(s_dropped_messages));
s_message_idx = 0;
memset(s_messages, 0, sizeof(s_messages));
}
void test_app_inbox__cleanup(void... | cl_assert_equal_b(false, app_inbox_service_has_inbox_for_tag(AppInboxServiceTagUnitTestAlt)) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return false;
} |
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForSynchro();
return true;
}
// Before entering standby we set the RTC to it's default time (Jan 1, 2000)
// here we calculate the seconds elapsed since then
static int32_t prv_seconds_since_standby(void) {
// This function assumes the ... |
IG(0),GCornerTopRight}
}));
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(270), TO_TRIG(360 + 90)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerTopLeft},
.full_quadrants = GCornersTop,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBott... | (prv_calc_draw_config_ellipsis(TO_TRIG(360 + 90 + 45), TO_TRIG(360 + 360 + 45)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90 + 45),GCornerBottomRight},
.full_quadrants = GCornersLeft,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(45),GCornerTopRight}
})) | ;
// ## Section with negative angles
// Within same quadrant
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(30 - 360), TO_TRIG(60 - 360)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(30)+1,GCornerTopRight},
.full_quadrants = GCornerNone,
.end_quadrant = (Ellip... |
cteristic, value, value_length, GAPLEClientApp);
}
DEFINE_SYSCALL(BTErrno, sys_ble_client_write_without_response,
BLECharacteristic characteristic,
const uint8_t *value,
size_t value_length) {
return gatt_client_op_write_without_response(charact... | syscall_assert_userspace_buffer(device, sizeof(*device)) | ;
}
*device = gatt_client_characteristic_get_device(characteristic).opaque;
}
DEFINE_SYSCALL(uint8_t, sys_ble_characteristic_get_descriptors,
BLECharacteristic characteristic,
BLEDescriptor descriptors_out[],
uint8_t num_descriptors) {
if (... |
ew samples");
token = strtok(NULL, "(");
// Copy starting from token + 1 to skip the '*' at the front
strncpy(state->test_entry.name, token + 1, sizeof(state->test_entry.name));
printf("\nParsing function samples: %s", state->test_entry.name);
continue;
}
// Look for and parse th... | {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.total.max);
} | |
oth_ctl.h"
#include "services/common/comm_session/session.h"
#include "system/logging.h"
#include "util/bitset.h"
#include "util/math.h"
#include <bluetooth/analytics.h>
#include <bluetooth/gap_le_connect.h>
typedef struct {
uint32_t slave_latency_events;
uint32_t supervision_to_ms;
int num_samps;
} LeConnectio... | bluetooth_analytics_handle_connection_params_update(conn_params) | ;
uint8_t link_quality = 0;
int8_t rssi = 0;
bool success = bt_driver_analytics_get_connection_quality(peer_addr, &link_quality, &rssi);
if (success) {
PBL_LOG(LOG_LEVEL_DEBUG, "Link quality: %x, RSSI: %d", link_quality, rssi);
analytics_add(ANALYTICS_DEVICE_METRIC_BLE_LINK_QUALITY_SUM,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.