prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_add_discovery_job(connection, hdl_range) | ;
if (!connection->gatt_is_service_discovery_in_progress) {
prv_run_next_job(connection);
}
}
bt_unlock();
}
// assumes bt lock is held
static BTErrno prv_run_next_job(GAPLEConnection *connection) {
DiscoveryJobQueue *node = connection->discovery_jobs;
if (!node) {
return BTErrnoOK; // no mor... |
s_last_timeline_item_added->header.id));
AttributeList *pin_attr_list = &s_last_timeline_item_added->attr_list;
const uint32_t pin_icon_tiny = attribute_get_uint32(pin_attr_list, AttributeIdIconTiny, 0);
cl_assert_equal_i((int)pin_icon_tiny, TIMELINE_RESOURCE_ALARM_CLOCK);
const char *pin_title = attribute_g... | cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time()) | ;
// Second alarm goes off. First one should be up again
s_current_hour = 11;
s_current_minute = 30;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 2);
cl_assert_equal_i(s_num_alarm_events_put, 2);
cl_assert_equal_i(s_num_timeline_adds, 20);
cl_assert_equal_i(s_num_timeline_removes, 12);
... |
rkout_service_stop_workout,
.update_data = workout_data_update,
.metric_to_string = workout_data_fill_metric_value,
.get_metric_value = workout_data_get_metric_value,
.get_distance_string = health_util_get_distance_string,
};
typedef struct SportsData {
int32_t current_bpm;
char *duration_string;
char *d... | (
ActivitySessionType_Run, &s_workout_data, &s_workout_controller) | ;
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__workout_render_walk(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 84,
.distance_m = 1234,
.avg_pace = health_util_get_pace(84, 1234),
... |
{
blob_db_insert(BlobDBIdTest, (uint8_t *)extra_keys[i], key_len,
(uint8_t *)extra_values[i], value_len);
}
prv_generate_responses_from_phone();
cl_assert_equal_i(s_num_writebacks, 7);
}
void test_blob_db_sync__sync_some(void) {
char *keys[] = { "key1", "key2", "key3", "key4", "key5" }... | cl_assert(reminders_session == blob_db_sync_get_session_for_token(3)) | |
);
graphics_circle_quadrant_draw_1px_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, GCornerBottomLeft);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_r8_quad_bottom_left.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_circle... | (&layer, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &white_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("white_over_black", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_r... |
(ctx, &GRect(4, 2, 16, 8)) | ;
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(10, 2, 18, 4), 4, GCornersAll);
}
void across_nx_layer_update_callback(Layer* me, GContext* ctx) {
graphics_... | |
>draw_state.clip_box) - 1;
const int x_min = ctx->draw_state.clip_box.origin.x;
const int x_max = grect_get_max_x(&ctx->draw_state.clip_box) - 1;
x1 = MAX(x1, x_min);
x2 = MIN(x2, x_max);
if (!WITHIN(y, y_min, y_max) || x1 > x2) {
// Outside of drawing bounds..
return;
}
// Capture framebuffer &... | if (y1.integer < min_valid_y) {
y1 = (Fixed_S16_3){.integer = min_valid_y, .fraction = 0};
} | |
{ 864, 344, 136},
{ 856, 400, 64},
{ 912, 400, 128},
{ 1224, 480, 72},
{ 1280, 480, 112},
{ 1760, 544, 144},
{ 1472, 584, 200},
{ 1048, 216, 176},
{ 1376, 272, 152},
{ 1224, -144, 528},
{ 1152, -24, 368},
{ 1160, 128, 184},
{ 1040, -136, 280},
{ 896, -72, 216},
{ ... | // 105 seconds
{ 1704, 368, 96},
{ 1816, 456, 96},
{ 1072, 312, 136},
{ 1080, 184, 104},
{ 1336, 144, 176},
{ 1368, 88, 280},
{ 1184, 88, 264},
{ 1056, 8, 248},
{ 952, -16, 232},
{ 848, -24, 216},
{ 760, 8, 128},
{ 728, -40, 104},
{ 816, -48, 32},
{ 960, 64, -... |
{ 904, 8, -48},
{ 1256, -56, -16},
{ 1760, -160, 352},
{ 1504, 224, 232},
{ 1232, 560, -224},
{ 1168, 280, -48},
// 108 seconds
{ 1152, 240, 248},
{ 992, 192, 232},
{ 984, 144, 288},
{ 920, 328, 128},
{ 880, 320, 72},
{ 840, 304, 88},
{ 936, 408, 72},
{ 1056,... |
intf("Making sure we handle running out of storage gracefully...\n");
memcpy(key, "k255", 5);
memcpy(val, "v255", 5);
cl_assert_equal_i(settings_file_set(&file, key, key_len, val, val_len), E_OUT_OF_STORAGE);
int val_len_out = settings_file_get_len(&file, key, key_len);
cl_must_pass(val_len_out);
uint8_t *v... | if (val_len_out == new_value_length) {
printf("new! %d\n", new_value_length);
cl_assert_equal_m(new_value, val_out, val_len_out);
free(val_out);
return RecordResultNew;
} |
// Should not get here! This means that neither the old nor the new value
// could be retreived, and thus the atomicity is broken! Aaaaaaaaaaaaaah!!
cl_assert(false);
}
fake_spi_flash_force_future_failure(after_n_bytes, &jmp);
// Setting this key will cause us to jump up to the above if statement if... |
ull_quadrants = GCornersRight,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(180),GCornerBottomLeft}
}));
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(180), TO_TRIG(360)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(180),GCornerBottomLeft},
.full_quadrants ... | TO_TRIG(45) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | rocky_global_init(s_preferences_api) | ;
EXECUTE_SCRIPT("var size = _rocky.userPreferences.contentSize");
ASSERT_JS_GLOBAL_EQUALS_S("size", "small");
}
void test_rocky_api_preferences__medium(void) {
s_preferred_content_size = PreferredContentSizeMedium;
rocky_global_init(s_preferences_api);
EXECUTE_SCRIPT("var size = _rocky.userPreferences.con... |
mezone_id);
if (clock_timezone_source_is_manual()) {
prv_update_time_info_and_generate_event(&tz_data->utc_time, NULL);
} else {
prv_update_time_info_and_generate_event(&tz_data->utc_time, &tz_info);
}
}
static void prv_handle_set_time_msg(time_t new_time) {
PBL_LOG(LOG_LEVEL_WARNING, "Mobile app calli... | clock_copy_time_string_timestamp(buffer, size, t) | |
(fd) == S_SUCCESS);
}
}
static uint32_t s_watch_file_callback_called_count = 0;
static void prv_file_changed_callback(void *data) {
s_watch_file_callback_called_count++;
}
void test_pfs__watch_file_callbacks(void) {
const char* file_name = "newfile";
PFSCallbackHandle cb_handle = pfs_watch_file(file_name, pr... | cl_assert_equal_i(pfs_read(fd, &buf[0], sizeof(buf)), sizeof(buf));
cl_assert(memcmp(buf, bufcmp, sizeof(buf)) == 0);
cl_assert_equal_i(pfs_close(fd), S_SUCCESS);
}
} |
static bool prv_filename_filter_a_prefix_cb(const char *name) {
return (strncmp(name, "a_", 2) == 0);
}
static bool prv_find_name(ListNode *node, void *data) {
PFSFileListEntry *entry = (PFSFileListEntry *)node;
return (strcmp(entry->name, (char *)data) == 0);
}
void test_pfs__file_list(void) {
pfs_format(t... |
;
prv_receive_entity_update(incomplete_playback_info_update,
sizeof(incomplete_playback_info_update));
prv_assert_initial_playback_state();
}
void test_ams__receive_malformed_player_volume_update(void) {
prv_connect_ams();
cl_assert_equal_i(music_get_volume_percent(), 0);
// Re... | (music_get_connected_server_debug_name(), NULL) | ;
}
// Test setup
///////////////////////////////////////////////////////////
void test_ams__initialize(void) {
s_launcher_task_callback = NULL;
memset(s_conn_mgr_states, 0, sizeof(s_conn_mgr_states));
fake_rtc_init(1234, 5678);
fake_event_init();
fake_gatt_client_subscriptions_init();
fake_gatt_client_op... |
click_handler(ClickRecognizerRef recognizer, void *context) {
AppWorkerResult result = app_worker_launch();
APP_LOG(APP_LOG_LEVEL_INFO, "launch result: %d", result);
}
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
AppWorkerMessage m;
app_worker_send_message('x', &m);
APP_LO... | tick_timer_service_unsubscribe() | ;
health_service_events_unsubscribe();
}
void handle_init(void) {
window = window_create();
window_set_click_config_provider(window, click_config_provider);
window_stack_push(window, true /* Animated */);
window_set_background_color(window, GColorBlack);
Layer *window_layer = window_get_root_layer(window... |
ics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, -46, 72, 50),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_across_y(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffe... | test_graphics_context_reset(&ctx, fb) | ;
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_y);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_y.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_s... |
ing.
// This is a first step towards a general purpose system for static status bars.
const int16_t stored_drawing_box_x = ctx->draw_state.drawing_box.origin.x;
if (window_stack_is_animating_with_fixed_status_bar(app_state_get_window_stack())) {
ctx->draw_state.drawing_box.origin.x -= status_bar_layer->layer... | {
app_timer_cancel(status_bar_layer->title_timer_id);
} |
status_bar_layer->title_timer_id = app_timer_register(STATUS_BAR_LAYER_TITLE_TIMEOUT,
status_bar_layer_reset_title,
status_bar_layer);
}
status_bar_layer->config.mode = StatusBarLayerModeLoading;
layer... |
';
strftime(tmbuf, sizeof(tmbuf), "%U", &dec_30_2014__13_00_00);
cl_assert_equal_s(tmbuf, "52");
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%U", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "00");
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%U", &jan_1_2016__13_00_00);
cl_assert_equal_s... | localized_strftime(tmbuf, sizeof(tmbuf), "%a %A %b %B", &jan_2_2015__13_00_00, NULL) | ;
cl_assert_equal_s(tmbuf, "Fri Friday Jan January");
tmbuf[0] = '\0';
localized_strftime(tmbuf, sizeof(tmbuf), "%c", &jan_2_2015__13_00_00, NULL);
cl_assert_equal_s(tmbuf, "Fri Jan 2 13:00:00 2015");
tmbuf[0] = '\0';
localized_strftime(tmbuf, sizeof(tmbuf), "%a %A %b %B", &jan_2_2015__13_00_00, i18n_get_l... |
{ 72, 1048, 1128},
{ 160, 704, 944},
{ -24, 712, 888},
{ -144, 616, 760},
{ -160, 488, 488},
{ -120, 408, 312},
{ -160, 424, 352},
{ -192, 424, 392},
{ -232, 488, 552},
{ -336, 744, 672},
{ -304, 952, 800},
{ -248, 1008, 824},
{ -208, 1000, 832},
{ -216, 1112, 10... | { -208, 640, 1144},
{ 112, 552, 912},
{ 88, 520, 984},
{ 8, 400, 728},
// 51 seconds
{ -64, 296, 560},
{ -144, 256, 528},
{ -240, 240, 656},
{ -328, 248, 784},
{ -360, 264, 824},
{ -520, 264, 984},
{ -520, 304, 1168},
{ -544, 248, 968},
{ -664, 304, 1864},
{ -... |
{ -200, 824, -88},
{ -248, 1056, -120},
{ -264, 976, -112},
{ -264, 1056, -144},
{ -312, 1056, -208},
{ -264, 928, -312},
{ -16, 728, -752},
{ -120, 568, -264},
{ -624, 1112, -560},
{ -328, 696, -400},
{ -352, 960, -560},
{ -240, 1000, -728},
// 54 seconds
{ -192... |
SE-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 language governing permissions and
* limitations under th... | cl_assert(callback_called) | ;
cl_assert(flash_locked);
}
void test_system_flash__handle_erase_error(void) {
return_status = FLASH_ERROR_OPERATION;
cl_assert(!system_flash_erase(FLASH_BASE, 16 KiB, NULL, NULL));
cl_assert(flash_locked);
}
void error_in_middle_cb(uint32_t num, uint32_t den, void *context) {
int *countdown = context;
i... |
oid *context) {
TimeRangeSelectionWindowData *data = context;
return date_time_selection_get_text(&data->to, index, data->buf);
}
static void prv_handle_to_complete(void *context) {
TimeRangeSelectionWindowData *data = context;
i18n_free_all(&data->window);
data->complete_callback(data, data->callback_contex... | (from_selection_layer, window) | ;
selection_layer_set_active(to_selection_layer, false);
layer_add_child(&window->layer, &from_selection_layer->layer);
layer_add_child(&window->layer, &to_selection_layer->layer);
// Label setup
TextLayer *from_text_layer = &time_range_selection_window->from_text_layer;
GRect text_rect = GRect(0, config-... |
!= new_den) {
state->subsample_numerator = new_num;
state->subsample_denominator = new_den;
}
PBL_LOG(LOG_LEVEL_DEBUG, "set subsampling for session %d to %d/%d", (int)state->session_ref,
state->subsample_numerator, state->subsample_denominator);
state = (AccelSubscriberState *)sta... | accel_data->timestamp = accel_get_latest_timestamp();
if (accel_data->timestamp != old_timestamp_ms) {
accel_get_latest_reading((AccelRawData *)accel_data);
result = 0;
break;
}
vTaskDelay(milliseconds_to_ticks(10));
}
}
}
mutex_unlock_recursiv... |
static bool prv_call_data_callback(AccelSubscriberState *state) {
switch (state->task) {
case PebbleTask_App:
case PebbleTask_Worker:
case PebbleTask_KernelMain: {
PebbleEvent event = {
.type = PEBBLE_CALLBACK_EVENT,
.callback = {
.callback = state->data_cb_handler,
... |
/*
* 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... | process_manager_put_kill_process_event(task, false /*gracefully*/) | |
l_close_timer_callback(void* data) {
PBL_LOG(LOG_LEVEL_DEBUG, "deinit timeout expired, killing app forcefully");
PebbleTask task = (PebbleTask)data;
process_manager_put_kill_process_event(task, false /*gracefully*/);
}
// -----------------------------------------------------------------------------------------... | (id, &entry) | |
///////////////////////////////////////////////////////
// Tests
void test_word_iterator__initialize(void) {
framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
}
void test_word_iterator__test_string_empty(void) {
// Allocate mutable ty... | cl_assert(!iter_next(&word_iter));
} | |
/*
* 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... | FONT_VERSION(font_res->md.version) | ;
if (version == FONT_VERSION_1) {
offset = s_font_md_size[FONT_VERSION_1];
num_bytes = font_res->md.number_of_glyphs * prv_offset_table_entry_size(&font_res->md);
num_entries = font_res->md.number_of_glyphs;
PBL_ASSERTN(num_bytes <= sizeof(font_cache->offsets_buffer_2_2));
} else {
FontHashTab... |
fake_comm_session_process_send_next();
fake_system_task_callbacks_invoke_pending();
uint8_t buffer[num_ops * VALID_OBJECT_SIZE];
for (size_t i = 0; i < sizeof(buffer); i += VALID_OBJECT_SIZE) {
uint32_t towrite = i;
memcpy(&buffer[i], &towrite, sizeof(towrite));
}
// Make sure we can receive new d... | assert_nack_count(0) | ;
assert_cleanup_event(ObjectFirmware, VALID_OBJECT_SIZE);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Install Message
void test_put_bytes__install_message_while_not_idle(void) {
prv_receive_init(VALID_OBJECT_SIZE, ObjectFirmware);
prv_process_and_re... |
/*
* 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_test_db.ram_storage, key, key_len) | |
eBLEGATTClientServiceEvent *)e, &info);
switch (info.type) {
case PebbleServicesAdded:
prv_handle_services_added(handler, info.device, info.status);
break;
case PebbleServicesRemoved:
// TODO (PBL-22087): This is suboptimal. Before we release the BLE API, we should
// either communica... | app_state_get_ble_app_state() | ;
const BLEClientWriteHandler handler = ble_app_state->gatt_characteristic_write_handler;
if (handler) {
handler(e->object_ref, e->gatt_error);
}
}
static void prv_handle_characteristic_subscribe(const PebbleBLEGATTClientEvent *e) {
PBL_LOG(LOG_LEVEL_DEBUG, "TODO: GATT Client Event, subtype=%u", e->subtype... |
IData *data) {
GAlign alignment;
const int16_t width_of_sidebar = data->action_bar_layer.layer.frame.size.w;
const int16_t window_width = data->window.layer.bounds.size.w;
const int16_t config_width = window_width - width_of_sidebar + 10;
int16_t x_offset, y_offset, width;
switch (data->ui_state) {
cas... | PBL_IF_RECT_ELSE(2, -4) | ;
const int32_t width = window->layer.bounds.size.w - width_of_action_bar_with_padding;
const int32_t x_offset = PBL_IF_RECT_ELSE(0, 22);
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
const int32_t info_text_y_offset = 36;
#else
const int32_t info_text_y_offset = PBL_IF_RECT_ELSE(10, 12);
#endif
KinoLayer *kino_l... |
et_frame(timeline_layer, to_index, &to);
timeline_layer_get_icon_frame(timeline_layer, from_index, &icon_from);
timeline_layer_get_icon_frame(timeline_layer, to_index, &icon_to);
layer_set_frame((Layer *)timeline_layout, &from);
return timeline_layout_create_up_down_animation(timeline_layout, &from, &to, &icon_... | peek_layer_set_scale_to_image(&timeline_layer->day_separator, &timeline_res,
TimelineResourceSizeLarge, frame, align_in_frame) | ;
peek_layer_set_fields_hidden(&timeline_layer->day_separator, true);
}
peek_layer_set_fields(&timeline_layer->day_separator, "", friendly_date, month_and_day);
peek_layer_play(&timeline_layer->day_separator);
}
void timeline_layer_unfold_day_sep(TimelineLayer *timeline_layer) {
const bool slide = false;
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (bus->hal->er_irq_channel, I2C_IRQ_PRIORITY) | |
#include "stubs_mutex.h"
#include "stubs_notification_storage.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_process_info.h"
#include "stubs_pebble_tasks.h"
#include "stubs_peek_layer.h"
#include "stubs_pin_db.h"
#include "stubs_print.h"
#include "stubs_process_manager.h"
#include "s... | {
attribute_list_add_cstring(attr_list, AttributeIdBody, s_test_data.body);
} |
if (!gcolor_is_invisible(s_test_data.primary_color)) {
attribute_list_add_uint8(attr_list, AttributeIdPrimaryColor, s_test_data.primary_color.argb);
}
if (!gcolor_is_invisible(s_test_data.background_color)) {
attribute_list_add_uint8(attr_list, AttributeIdBgColor, s_test_data.background_color.argb);
}
... |
sert_equal_b(s_ack_sent_is_called, true);
// Since that callback schedules another callback, we have to invoke
// system tasks again to get th actual callback to trigger.
cl_assert_equal_i(s_out_sent_call_count, 1);
// Check that the state is reset properly after everything
cl_assert_equal_b(app_message_is_... | (app_message_outbox_send(), APP_MSG_BUSY) | |
stbuf, 256, "%.0Xzero%.0X", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.Xzero%.X", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.-3Xzero%.-3X",... | (dstbuf, "What's a cool number? 0x2468ace") | ;
snprintf(dstbuf, 256, "What's a cool number? %p", (void*)(uintptr_t)0);
cl_assert_equal_s(dstbuf, "What's a cool number? 0");
}
void test_sprintf__percent_n(void) {
char dstbuf[512];
int val, val2;
int8_t hhntest[4];
int16_t hntest[2];
int32_t lntest[2];
int64_t llntest[2];
int64_t jntest[2];
in... |
ContentIndicatorDirectionUp,
false);
content_indicator_set_content_available(&health_card_view->down_indicator,
ContentIndicatorDirectionDown,
false);
}
static void prv_s... | animation_schedule(health_card_view->slide_animation) | |
ession,
desired_interval_sec , 0 /*expire_sec*/);
PBL_ASSERTN(success);
// Update history
s_activity_state.hr.currently_sampling = should_be_sampling;
s_activity_state.hr.toggled_sampling_at_ts = now_ts;
PBL_LOG(LOG_LEVEL_DEBUG, "Changed HR samp... | {
return;
} |
sys_hrm_manager_unsubscribe(s_activity_state.hr.hrm_session);
protobuf_log_session_delete(s_activity_state.hr.log_session);
activity_metrics_prv_reset_hr_stats();
#endif // CAPABILITY_HAS_BUILTIN_HRM
}
// ----------------------------------------------------------------------------------------------
// Open t... |
) malloc(too_big);
memset(value, 0x55, too_big);
gatt_client_subscriptions_handle_server_notification(s_connection, s_handle,
value, too_big);
prv_assert_no_event();
// Receive a GATT notification that is supposed to fill up the buffer entirely:
const si... | cl_assert_equal_b(has_more, false) | |
ancs_perform_action(uint32_t notification_uid, uint8_t action_id) {
}
void notifications_handle_notification_action_result(
PebbleSysNotificationActionResult *action_result) {
}
void notification_storage_set_status(const Uuid *id, uint8_t status) {
}
void notifications_handle_notification_acted_upon(Uuid *notifi... | {
fake_spi_flash_init(0, 0x1000000);
fake_rtc_init(0, 0);
pfs_init(false);
// Note: creating a settings file is going to result in one malloc for the FD name
pin_db_init();
time_util_update_timezone(&tz);
fake_pbl_malloc_clear_tracking();
for (unsigned int i = 0; i < ARRAY_LENGTH(s_items); ++i) {
cl... | |
/*
* 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... | graphics_text_node_create_text(buffer_size) | ;
if (container) {
graphics_text_node_container_add_child(container, &text_node->node);
}
text_node->font = font;
text_node->color = color;
return text_node;
}
GTextNodeText *health_util_create_text_node_with_text(const char *text, GFont font, GColor color,
... |
/*
* 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 gap_le_advert_get_tx_power();
} |
// -----------------------------------------------------------------------------
// ble_central.h
DEFINE_SYSCALL(BTErrno, sys_ble_central_connect, BTDeviceInternal device,
bool auto_reconnect, bool is_pairing_required) {
return gap_le_connect_connect(&device, auto_reconnect, is_pairing_required,
... |
case TXMenuIdx_PayloadLength:
prv_txrx_number_window(255, &data->payload_length, "Payload Length", data);
break;
case TXMenuIdx_PayloadType:
prv_payload_type_window(data);
break;
#if CAPABILITY_HAS_BUILTIN_HRM
case TXMenuIdx_HRM:
data->is_hrm_enabled = !data->is_hrm_... | (context, BTLETestType_RX) | ;
}
static void prv_init_main_menu(AppData *data) {
const SimpleMenuItem menu_items[] = {
{ .title = "BTLE TX", .callback = prv_enter_tx_menu },
{ .title = "BTLE RX", .callback = prv_enter_rx_menu },
};
const size_t size = sizeof(menu_items);
data->main_menu_items = app_malloc_check(size);
memcpy(da... |
d_size.w, 2 * HORIZ_ADVANCE_PX); // only the JR, since Whop is not being layed out
cl_assert_equal_i(layout.max_used_size.h, 2 * FONT_HEIGHT); // Nothing - save for the first line - will be rendered below the box
graphics_text_layout_get_max_used_size(&gcontext, "JR\n\nWhop", font, box, GTextOverflowModeWordWrap,... | graphics_text_layout_get_max_used_size(&gcontext, empty_string, font, box,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, (void*)&layout) | |
41}, {41, 23}};
const uint16_t num_commands = 5;
GDrawCommandImage *image = task_malloc(
sizeof(GDrawCommandImage) +
sizeof(GDrawCommand) * num_commands +
sizeof(c0_points) + sizeof(c1_points) + sizeof(c2_points)+ sizeof(c3_points) +
sizeof(c4_points));
*image = (GDrawComma... | memcpy(c1->points, c1_points, sizeof(c1_points)) | ;
GDrawCommand *c2 = gdraw_command_list_get_command(list, 2);
*c2 = *c0;
memcpy(c2->points, c2_points, sizeof(c2_points));
GDrawCommand *c3 = gdraw_command_list_get_command(list, 3);
*c3 = *c0;
memcpy(c3->points, c3_points, sizeof(c3_points));
GDrawCommand *c4 = gdraw_command_list_get_command(list, 4);... |
-72, -768, -632},
{ -24, -800, -616},
{ -8, -712, -648},
{ -16, -752, -560},
{ 64, -680, -504},
{ 152, -640, -488},
{ 200, -480, -432},
{ 208, -264, -416},
{ 136, -64, -552},
{ 208, 456, -856},
{ 80, 1184, -624},
{ -64, 1240, -376},
{ -248, 2152, 16},
{ -240, 1432, 1... | { 88, -400, -936},
// 172 seconds
{ 144, -368, -880},
{ 168, -328, -888},
{ 88, -352, -944},
{ 72, -304, -936},
{ 64, -328, -960},
{ 88, -312, -952},
{ 72, -336, -920},
{ 72, -320, -936},
{ 56, -344, -896},
{ 48, -320, -928},
{ 48, -328, -936},
{ 56, -328, -928},
... |
{ 8, 912, 312},
{ 8, 912, 336},
{ 32, 864, 368},
{ 40, 896, 312},
{ 24, 848, 352},
{ 40, 896, 312},
// 175 seconds
{ 0, 888, 392},
{ 16, 696, 312},
{ 32, 936, 400},
{ 16, 872, 400},
{ 48, 832, 408},
{ 72, 984, 352},
{ -16, 704, 352},
{ 64, 904, 368},
{ 32... |
PBL_ASSERTN(result == APP_MSG_OK);
if (bpm) {
dict_write_uint8(app_data->out_iter, AppMessageKey_HeartRate, bpm);
dict_write_uint8(app_data->out_iter, AppMessageKey_Confidence, bpm_quality);
}
if (led_current) {
dict_write_uint16(app_data->out_iter, AppMessageKey_Current, l... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Out message send failed - reason %i %s",
reason, prv_translate_error(reason));
AppData *app_data = app_state_get_user_data();
app_data->ready_to_send = true;
} |
static void prv_remote_notify_timer_cb(void *data) {
prv_send_status_and_version();
}
static void prv_init(void) {
AppData *app_data = app_malloc_check(sizeof(*app_data));
*app_data = (AppData) {
.session = (HRMSessionRef)app_data, // Use app data as session ref
.ready_to_send = false,
};
app_state... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_menu_data_source_get_count(data_source) | : (uint16_t)0;
}
static void prv_menu_layer_draw_row(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index,
void *context) {
LauncherMenuLayer *launcher_menu_layer = context;
AppMenuDataSource *data_source = launcher_menu_layer->data_source;
if (!data_source) {
re... |
crc.length) {
uint32_t read_len = MIN(cmd->crc.length - bytes_read, chunk_size);
int ret = pulse_fd->impl->read_proc(buffer, cmd->crc.address+bytes_read, read_len,
pulse_fd->domain_state);
if (FAILED(ret)) {
prv_respond_internal_error(cmd, length, E_INTERNAL);
... | {
for (int i = 0; i < MAX_PULSE_FDS; i++) {
if (s_transfer_fds[i].impl) {
PulseTransferFD *pulse_fd = &s_transfer_fds[i];
pulse_fd->impl->close_proc(pulse_fd->domain_state);
prv_free_fd(i);
}
}
} | |
2[s_num_cb_events_2++] = *event;
}
static void prv_put_battery_state_change_event(bool is_plugged_in) {
PebbleEvent e = {
.type = PEBBLE_BATTERY_STATE_CHANGE_EVENT,
.battery_state.new_state.is_plugged = is_plugged_in,
};
event_put(&e);
}
// ---------------------------------------------------------------... | (sys_hrm_manager_get_app_subscription(app_id) == session_ref) | ;
prv_fake_send_new_data();
// We should get the BPM event
cl_assert_equal_i(s_event_count, 1);
cl_assert_equal_i(s_events_received[0].type, PEBBLE_HRM_EVENT);
cl_assert_equal_i(s_events_received[0].hrm.event_type, HRMEvent_BPM);
// Subscribe again before we expire, should get the same session ref back
... |
ibling->next_sibling;
}
prev_sibling->next_sibling = layer_to_insert;
}
layer_to_insert->next_sibling = below_layer;
}
// Above means lower down in the hierarchy so it gets drawn later,
// and as a result the drawn on top of what's below it.
void layer_insert_above_sibling(Layer *layer_to_insert, Layer *ab... | while (node) {
if (layer_contains_point(node, &iter_ctx->pos)) {
iter_ctx->layer = node;
if (!node->first_child && !node->next_sibling) {
return false;
}
iter_ctx->pos = gpoint_sub(iter_ctx->pos, node->bounds.origin);
if (!prv_find_layer_containing_point(node->first_child, ite... |
return true;
}
MOCKABLE Layer *layer_find_layer_containing_point(const Layer *node, const GPoint *point) {
if (!node || !point) {
return NULL;
}
LayerTouchIteratorCtx iter_ctx = {
.pos = *point,
};
gpoint_sub(iter_ctx.pos, node->frame.origin);
prv_find_layer_containing_point(node, &iter_ctx);
... |
fo.div,
pairing_info_out.local_encryption_info.div);
cl_assert_equal_i(pairing_info->identity.opaque.opaque_64,
pairing_info_out.identity.opaque.opaque_64);
cl_assert_equal_i(pairing_info->remote_encryption_info.rand,
pairing_info_out.remote_encryption_inf... | cl_assert_equal_i(platform_bits_out, 0xaa) | ;
shared_prf_storage_erase_bt_classic_pairing_data();
cl_assert_equal_b(shared_prf_storage_get_bt_classic_pairing_data(NULL, NULL, NULL, NULL), false);
}
void test_shared_prf_storage_v2__ble_pairing(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_ble_pairing_data(NULL, NULL, NU... |
nt_luminance_lookup_table_init(tint_color, lookup_table_out);
cl_assert(gcolor_equal(lookup_table_out[0], GColorBlue));
cl_assert(gcolor_equal(lookup_table_out[1], GColorLiberty));
cl_assert(gcolor_equal(lookup_table_out[2], GColorBrass));
cl_assert(gcolor_equal(lookup_table_out[3], GColorYellow));
// lookup... | (gcolor_component_multiply(2, 1), 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... | (&q->circular_buffer, data, q->item_size) | ;
return pdTRUE;
} else {
if (!xTicksToWait || !q->yield_cb) {
return pdFALSE;
} else {
ticks_waited += q->yield_cb(xQueue);
if (ticks_waited >= xTicksToWait) {
return pdFALSE;
}
}
}
}
}
QueueHandle_t xQueueGenericCreate(unsigned portBASE_TYPE... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (int i = 1; i < num_segments; ++i) {
graphics_draw_line(ctx,
GPoint(segment_width * i, 0),
GPoint(segment_width * i, SCREEN_HEIGHT));
graphics_draw_line(ctx,
GPoint(0, segment_height * i),
GPoint(SCREEN_WIDTH, segment_height * i));
} | |
DOW_POP_TIME_S (3)
typedef struct {
Window window;
PathLayer arrows[NUM_BUTTONS];
//! bitset of buttons pressed so far
uint32_t buttons_pressed;
TextLayer title;
TextLayer status;
char status_string[35];
uint32_t seconds_remaining;
bool test_complete;
} AppData;
static void prv_handle_second_tic... | text_layer_set_font(status, fonts_get_system_font(FONT_KEY_GOTHIC_24)) | ;
text_layer_set_text_alignment(status, GTextAlignmentCenter);
layer_add_child(&window->layer, &status->layer);
for (ButtonId id = 0; id < NUM_BUTTONS; ++id) {
init_arrow_layer_for_button(data, id);
}
app_window_stack_push(window, true /* Animated */);
tick_timer_service_subscribe(SECOND_UNIT, prv_ha... |
the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or i... | perimeter_for_display_round(&p, &ctx_size, r, 5) | );
cl_assert_equal_i(0, perimeter_for_display_round(&p, &ctx_size, r, 500).size_w);
}
void test_perimeter__g_perimeter_for_display(void) {
GPerimeterCallback expected = PBL_IF_RECT_ELSE(perimeter_for_display_rect,
perimeter_for_display_round);
cl_assert_equal_p(ex... |
e /* start_connected */);
RCV_RESET_REQUEST();
// Expect responding with a ResetComplete:
EXPECT_OUTBOX_RESET_COMPLETE_PENDING();
cl_assert_equal_i(rocky_api_app_message_get_state(),
PostMessageStateAwaitingResetCompleteRemoteInitiated);
}
void test_rocky_api_app_message__awaiting_reset_... | cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateAwaitingResetRequest) | ;
prv_rcv_app_message_ack(APP_MSG_OK);
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
}
void test_rocky_api_app_message__awaiting_reset_complete_rem_init__receive_request(void) {
prv_init_and_goto_awaiting_reset_complete_remote_initiated();
RCV_RESET_REQUEST();
cl_assert_equal_i(rocky_api_app_message_get_state(),
... |
on_get_animation(prop_anim);
animation_set_duration(content_in, IN_OUT_ANIMATION_DURATION);
#if !defined(PLATFORM_TINTIN)
// animate the dots
Animation *crumbs_anim = crumbs_layer_get_animation(&data->crumbs_layer);
animation_set_duration(crumbs_anim, IN_OUT_ANIMATION_DURATION);
// combine the two
Animatio... | (window_get_root_layer(window), (Layer *)action_menu_layer) | ;
layer_add_child(window_get_root_layer(window), (Layer *)crumbs_layer);
// Click config
window_set_click_config_provider_with_context(window, prv_click_config_provider, data);
// Init the view model
data->view_model = (ActionMenuViewModel) {
.cur_level = data->config.root_level,
.menu_insets = prv_ac... |
/*
* 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... | (
PULSE2_BEST_EFFORT_TRANSPORT_PROTOCOL) | ;
packet->protocol = hton16(app_protocol);
return &packet->information;
}
void pulse_best_effort_send(void *buf, const size_t length) {
PBL_ASSERTN(s_layer_up);
PBL_ASSERT(length <= pulse_link_max_send_size() - sizeof(BestEffortPacket),
"Packet too big to send");
// We're blindly assuming that b... |
d);
if (result < 0) {
// Error occurred
kernel_free(notification.allocated_buffer);
goto cleanup;
}
write_offset += result;
kernel_free(notification.allocated_buffer);
}
s_write_offset = write_offset;
pfs_close(*fd);
pfs_close(new_fd);
*fd = pfs_open(FILENAME, OP_FLAG_READ... | {
notification->allocated_buffer = NULL; // Must be initialized in case this goes to cleanup
// Read notification to temporary buffer
uint8_t *read_buffer = task_zalloc_check(header->payload_length);
int result = pfs_read(fd, read_buffer, header->payload_length);
if (result < 0) {
goto cleanup;
}
i... |
size_t notification_storage_get_len(const Uuid *uuid) {
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return 0;
}
size_t size = 0;
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
if (prv_find_next_notification(&header, prv_uuid_equal_func, (void *) uuid, fd)) {
size = h... |
430 }, // priority rank 3
{ .id = 27, .priority = 5, .size = 248430 }, // priority rank 4
{ .id = 28, .priority = 44, .size = 168622 }, // priority rank 34
{ .id = 29, .priority = 6, .size = 192857 }, // priority rank 5
{ .id = 30, .priority = 19, .size = 183331 }, // priority rank 10
{ .id = 31, .priority ... | app_cache_free_up_space(to_free) | );
fake_system_task_callbacks_invoke_pending();
after_size = app_cache_get_size();
cl_assert_equal_i(after_size, 0);
// test removing 0 bytes
prv_cleanup();
to_free = 0;
before_size = app_cache_get_size();
cl_assert(before_size >= to_free);
cl_assert_equal_i(E_INVALID_ARGUMENT, app_cache_free_up_spac... |
/*
* 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... | assert_float_parse(buffer, 3, true, 3) | ;
}
void test_ams_util__float_string_parse_empty_string(void) {
// "" * 3
assert_float_parse("", 3, false, 0);
}
void test_ams_util__float_string_parse_not_a_number(void) {
// "hello" * 3
assert_float_parse("hello", 3, false, 0);
// " " * 3
assert_float_parse(" ", 3, false, 0);
}
void test_ams_util__floa... |
OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/graphics/graphics.h"
#include "applib/graphics/framebuffer.h"
#include "applib/ui/bitmap_layer.h"
#include "applib/ui/w... | if (end_of_file == -1) {
goto cleanup;
} | |
*manifest, ResourceStoreEntry *entry,
ResAppNum app_num) {
uint32_t num_bytes;
if ((num_bytes = prv_get_store_length(entry, manifest)) == 0) {
PBL_LOG(LOG_LEVEL_WARNING, "Resource table check failed. Table or manifest may be corrupted");
return false;
}
uint32_t calculat... | (app_num, resource_id, &entry) | |
(), true);
// After GATT re-discovery, the registration needs to happen again
ams_invalidate_all_references();
prv_discover_ams(1 /* num_instances */);
cl_assert_equal_b(ams_is_registered_for_all_entity_updates(), false);
}
void test_ams__register_for_entity_updates_retry_if_out_of_resources(void) {
prv_dis... | cl_assert(false) | ;
return 0xFF;
}
}
void test_ams__send_remote_command(void) {
prv_connect_ams();
// Exercise all MusicCommand types (currently they are all supported):
for (MusicCommand music_cmd = 0; music_cmd < NumMusicCommand; ++music_cmd) {
music_command_send(music_cmd);
BLECharacteristic remote_command = ... |
rage_init();
}
void test_shared_prf_storage_v3__cleanup(void) {
fake_spi_flash_cleanup();
prv_assert_mutexes_unlocked();
}
void test_shared_prf_storage_v3__init_all_zeros(void) {
uint8_t *flash_buf = kernel_zalloc(SPRF_REGION_SIZE);
flash_write_bytes(flash_buf, FLASH_REGION_SHARED_PRF_STORAGE_BEGIN, SPRF_REGI... | cl_assert_equal_b(requires_address_pinning_out, false) | ;
cl_assert_equal_i(flags, 0);
cl_assert_equal_i(strcmp(DEVICE_NAME, name_out), 0);
cl_assert_equal_b(PAIRING_INFO.is_mitm_protection_enabled,
pairing_info_out.is_mitm_protection_enabled);
cl_assert_equal_b(PAIRING_INFO.is_remote_signing_info_valid,
pairing_info_out.is_re... |
v) {
dev->periph->CR1 &= ~USART_CR1_UE;
periph_config_disable(dev->periph, dev->rcc_apb_periph);
// Change the pins to be digital inputs rather than AF pins. We can't change to analog inputs
// because those aren't 5V tolerant which these pins may need to be.
if (dev->tx_gpio.gpio) {
const InputConfig inp... | {
// disable interrupt if TX is also disabled
prv_set_interrupt_enabled(dev, dev->state->tx_int_enabled);
dev->periph->CR1 &= ~USART_CR1_RXNEIE;
dev->state->rx_int_enabled = false;
} |
}
void uart_set_tx_interrupt_enabled(UARTDevice *dev, bool enabled) {
PBL_ASSERTN(dev->state->initialized);
if (enabled) {
dev->state->tx_int_enabled = true;
dev->periph->CR1 |= USART_CR1_TXEIE;
prv_set_interrupt_enabled(dev, true);
} else {
// disable interrupt if RX is also disabled
prv_se... |
uch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(13, 13), 40, 6, true);
}
void test_touch__handle_update_position_stationary(void) {
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 3686380, 0);
touch_handle_update(0, TouchState_FingerDown, &G... | cl_assert_passert(touch_handle_update(0, TouchState_FingerDown, NULL, 5, 3686400)) | ;
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 0, 0);
// NULL position not valid for position update event
cl_assert_passert(touch_handle_update(0, TouchState_FingerDown, NULL, 5, 3686400));
}
void test_touch__handle_update_reset_queue_touchdown(void) {
touch_set_touch_state(0, TouchState_Finge... |
");
Dialog *dialog = expandable_dialog_get_dialog(long_error_dialog);
const GColor dialog_bg_color = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite);
prv_init_dialog(data, dialog, text, resource_id, false, dialog_bg_color);
expandable_dialog_set_header(long_error_dialog, header);
expandable_dialog_push(long_e... | prv_set_mic_window_state(data, StateRecording) | ;
break;
case VoiceStatusErrorConnectivity:
// Subsequent attempts are probably going to result in the same error. Let the user sort
// out the error and re-enter the dialog.
prv_show_connectivity_error_and_exit(data);
break;
case VoiceStatusErrorDisabled:
// This should ha... |
;
} else if (icon_frame_size.h > cell_layer_bounds_size.h) {
// The icon is rendered beside but does not fit, cut it out
icon_frame_size = GSizeZero;
}
if (container_height > cell_layer_bounds_size.h) {
// If we couldn't fit one line of title, subtitle, and icon, try cutting out the icon
if (icon_... | {
// Set the title text's frame origin at the bottom of the icon's frame
title_text_frame_origin_y = grect_get_max_y(&rect);
} | |
/*
* 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... | (head, NULL, NULL) | ;
return new_head;
}
ListNode* list_pop_tail(ListNode *node) {
if (node == NULL) {
return NULL;
}
ListNode* tail = list_get_tail(node);
ListNode* new_tail = tail->prev;
list_remove(tail, NULL, NULL);
return new_tail;
}
void list_remove(ListNode* node, ListNode **head, ListNode **tail) {
if (node =... |
: max_clicks;
cfg->multi_click.timeout = (timeout == 0) ? 300 : timeout;
cfg->multi_click.last_click_only = last_click_only;
cfg->multi_click.handler = handler;
if (button_id == BUTTON_ID_BACK) {
window_set_overrides_back_button(window, true);
}
}
void window_long_click_subscribe(ButtonId button_id, ui... | prv_window_load(window) | ;
// In our load handler, we may unload ourselves; this is perfectly fine! However,
// if we do that, we never appear on the screen! In that case, window->on_screen
// may have changed between the time we checked and after we called prv_window_load,
// so we need to check it again!
if (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... | if (!callback) {
return NULL;
} |
// Old versions of the Android app (<3.5) will allow voice replies (which also use this code-path)
// but don't set the capability flag, so we don't want to block all requests here, just those from
// apps. This will result in apps not being able to use the voice APIs unless the phone has the
// capability fl... |
/*
* 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... | {
BTBondingID bonding_id = (BTBondingID) data;
const FakeBonding *bonding = (const FakeBonding *) found_node;
return (bonding->id == bonding_id);
} |
bool bt_persistent_storage_get_ble_pairing_by_id(BTBondingID id,
SMIdentityResolvingKey *IRK_out,
BTDeviceInternal *device_out,
char name[BT_DEVICE_NAME_BUFFER_SIZE]) {
FakeBonding *bonding ... |
vices/common/comm_session/session.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/analytics/analytics.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/status_codes.h"
#include "system/hexdump.h"
#include "util/attributes.h"
#include "util/net.h"
#in... | PBL_LOG(LOG_LEVEL_WARNING, "received blob db wb response with an invalid token: %d", token) | ;
}
}
static void prv_handle_write_response(CommSession *session,
const uint8_t *data,
uint32_t length) {
if (length < WRITE_RESPONSE_LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a write response with an invalid length: %"PRIu32"", length);... |
1 /* minutes */);
cl_assert_equal_b(prv_is_hr_elevated(), true);
prv_set_median_hr_for_minutes(70 /* BPM */, 1 /* minutes */);
cl_assert_equal_b(prv_is_hr_elevated(), false);
activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes);
cl_assert_equal_i(zone1_minutes, 2);
activity_get_metri... | (&activity) | |
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 4);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw4_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 4);
... | prv_draw_rects(&ctx, 3, 2 * CLIP_OFFSET, 0) | ;
prv_draw_rects(&ctx, 4, 3 * CLIP_OFFSET, 0);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_clip_rect.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, false, 1);
prv_draw_rects(&ctx, 1, 0, 1);
prv_draw_rects(&ctx, 2, CLIP_OFFSET, 1);
prv_draw_rects(&ctx, ... |
/*
* 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... | {
continue;
} |
// copy a row from above and paste it into the destination.
uint32_t *src_line = framebuffer_get_line(sys_frame_buffer, fetch_row);
uint32_t *dest_line = framebuffer_get_line(sys_frame_buffer, dest_row);
memcpy(dest_line, src_line, FRAMEBUFFER_BYTES_PER_ROW);
}
// update the current offset of the... |
s_input_enabled = false;
s_send_history.has_data = false;
s_bus_contention_detected = false;
prv_unlock();
}
void accessory_enable_input(void) {
// NOTE: This function may be called from an ISR
if (s_input_enabled) {
return;
}
prv_lock();
if (s_sent_data) {
// wait for the TC flag to be set
... | {
// the callback MUST send a byte in order for this interrupt to trigger again
PBL_ASSERTN(s_did_send_byte);
} | else {
// we're done sending
portBASE_TYPE was_higher_task_woken = pdFALSE;
xSemaphoreGiveFromISR(s_send_semaphore, &was_higher_task_woken);
should_context_switch = (was_higher_task_woken != pdFALSE);
uart_set_tx_interrupt_enabled(dev, false);
s_stream_cb = NULL;
s_stream_cont... |
PAGE_MASK) &&
!is_delete_complete(curr_pg)) {
PBL_LOG(LOG_LEVEL_WARNING, "Delete of %d did not complete", curr_pg);
unlink_flash_file(curr_pg);
}
}
update_last_written_page();
}
static void prv_handle_sector_erase(uint16_t start_page, bool update_erase_count) {
if (!update_erase_count) {... | {
if (!strcmp(callback_node->name, file_name) && (callback_node->event_flags & event)) {
callback_node->callback(callback_node->data);
}
callback_node = (PFSFileChangedCallbackNode *)list_get_next(&callback_node->list_node);
} |
}
status_t pfs_close(int fd) {
mutex_lock_recursive(s_pfs_mutex);
int res = E_UNKNOWN;
if (!FD_VALID(fd)) {
res = E_INVALID_ARGUMENT;
goto cleanup;
}
File *f = &PFS_FD(fd).file;
if (f->is_tmp) {
// TODO: For safety, could disallow this op if user has orig file hdl open
pfs_remove(f->name... |
= STRING_LENGTH_MAX,
#elif PLATFORM_SNOWY
[TestStringFont_Gothic18] = 109,
[TestStringFont_Gothic24B] = 78,
[TestStringFont_Other] = STRING_LENGTH_MAX,
#endif
},
},
[TestString_Worst] = {
.string = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%%^&*()_+QWERTYUIOP{}|A"
... | (s_perftest_text_arguments.string_type, "worst") | == 0) {
text_index = TestString_Worst;
} else if (strcmp(s_perftest_text_arguments.string_type, "typical") == 0) {
text_index = TestString_Typical;
} else {
prompt_send_response("Incorrect type argument, must be 'best', 'typical', or 'worst'.");
return;
}
if (strcmp(s_perftest_text_arguments.fo... |
AX;
int16_t max_y = INT16_MIN;
int16_t min_y = INT16_MAX;
for (uint32_t i = 0; i < path->num_points; ++i) {
if (path->points[i].x > max_x) {
max_x = path->points[i].x;
}
if (path->points[i].x < min_x) {
min_x = path->points[i].x;
}
if (path->points[i].y > max_y) {
max_y = pat... | {
APP_LOG(APP_LOG_LEVEL_ERROR, GPATH_ERROR);
goto cleanup;
} |
int intersection_up_count;
int intersection_down_count;
// convert clip coordinates to drawing coordinates
const int16_t clip_min_y = ctx->draw_state.clip_box.origin.y
- ctx->draw_state.drawing_box.origin.y;
const int16_t clip_max_y = ctx->draw_state.clip_box.size.h + clip_min_y;
min_y = MAX(min_y,... |
cular when tiling
src_x = src_bitmap->bounds.origin.x +
((src_x - src_bitmap->bounds.origin.x) % src_bitmap->bounds.size.w);
} else {
// Increment source but don't draw
continue;
}
}
// src points to the info for the row, so y and stride are 0 for r... | {
if (!WITHIN(src_x, src_begin_x, src_end_x - 1)) {
// Check if content should wrap (under and over) for tiling
if (!WITHIN(src_x, src_bitmap->bounds.origin.x,
grect_get_max_x(&src_bitmap->bounds) - 1)) {
// keep correct bounds alignment for circul... |
}
break;
}
case GCompOpTint:
case GCompOpTintLuminance:
case GCompOpSet:
default: {
// Initialize the tint luminance lookup table if necessary
GColor8 tint_luminance_lookup_table[GCOLOR8_COMPONENT_NUM_VALUES] = {};
if (compositing_mode == GCompOpTintLuminance) {
... |
rintf(buffer, buffer_size, "%"PRId32, current_calories);
}
static void prv_set_distance(char *buffer, size_t buffer_size, int32_t current_distance_meters) {
if (current_distance_meters == 0) {
strncpy(buffer, EN_DASH, buffer_size);
return;
}
const int conversion_factor = health_util_get_distance_factor(... | for (int i = 0; i < card_data->num_subtitles; i++) {
app_free(card_data->subtitles[i].label);
} |
for (int i = 0; i < card_data->num_zones; i++) {
app_free(card_data->zones[i].label);
}
i18n_free_all(card_data);
app_free(card_data);
health_detail_card_destroy(card);
}
|
or today
prv_feed_cannned_accel_data(150 * SECONDS_PER_MINUTE, 0, ActivitySleepStateLightSleep);
// Awake for 30 minutes which puts us at 9pm.
prv_feed_cannned_accel_data(30 * SECONDS_PER_MINUTE, 20, ActivitySleepStateAwake);
// Another 2 hour sleep session starting at 9pm. This will leave us at 11pm. Since t... | (raw_data, k_raw_samples) | ;
// Stop collection
activity_raw_sample_collection(false, true, &enabled, &session_id, &num_samples, &seconds);
cl_assert(!enabled);
cl_assert_equal_i(num_samples, k_raw_samples);
cl_assert_equal_i(seconds,
(k_raw_samples + ALGORITHM_SAMPLING_RATE - 1) / ALGORITHM_SAMPLING_RA... |
oken, &response_code);
BlobDBSyncSession *sync_session = blob_db_sync_get_session_for_token(token);
if (sync_session) {
if (response_code == BLOB_DB_SUCCESS) {
blob_db_sync_next(sync_session);
} else {
blob_db_sync_cancel(sync_session);
}
} else {
// No session
PBL_LOG(LOG_LEVEL_W... | prv_new_token() | ,
.db_id = db_id,
.last_updated = last_updated,
};
size_t writeback_length = sizeof(writeback_metadata) +
sizeof(uint8_t) /* key length size*/ +
key_len +
sizeof(uint16_t) /* val length 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... | if ((event.type == SmartstrapDataSentEvent) && state->handlers.did_write) {
state->handlers.did_write(attr, event.result);
} else if ((event.type == SmartstrapDataReceivedEvent) && state->handlers.did_read) {
// 'attr' already points to the read buffer, so just need to cast it
state->handlers.did_... |
sys_smartstrap_attribute_event_processed(attr);
}
}
// Subscription functions
////////////////////////////////////////////////////////////////////////////////
static bool prv_should_subscribe(void) {
// We don't need to subscribe until either the app creates an attribute or subscribes an
// availability_d... |
3);
cl_assert_equal_i(s_num_timeline_removes, 0);
alarm_set_enabled(id1, false);
prv_assert_alarm_config(id1, 3, 14, true, ALARM_KIND_EVERYDAY, s_every_day_schedule);
cl_assert_equal_i(s_num_timeline_adds, 3);
cl_assert_equal_i(s_num_timeline_removes, 3);
alarm_set_enabled(id1, true);
prv_assert_alarm_... | cron_service_wakeup() | ;
cl_assert_equal_i(s_num_alarms_fired, 1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Alarm Timeline Pin Tests
void test_alarm__pin_add(void) {
const AlarmId dummy_alarm_id = 0;
const AlarmKind alarm_kind = ALARM_KIND_WEEKENDS;
Uuid added_pin_uu... |
/*
* 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_set_click_config_provider(window, config_provider) | ;
window_stack_push(window, true /* Animated */);
Layer *window_layer = window_get_root_layer(window);
text_heap_info = text_layer_create(layer_get_frame(window_layer));
text_layer_set_text_color(text_heap_info, GColorWhite);
text_layer_set_background_color(text_heap_info, GColorBlack);
text_layer_set_font... |
ite);
break;
case TestPattern_Crosshair:
prv_draw_crosshair_screen(layer, ctx, 0);
break;
#if PBL_COLOR
case TestPattern_Red:
prv_draw_solid(layer, ctx, GColorRed);
break;
case TestPattern_Green:
prv_draw_solid(layer, ctx, GColorGreen);
break;
case TestPattern_Blue:
prv_draw_soli... | for (unsigned int i = 0; i < ARRAY_LENGTH(ARGS); ++i) {
if (!strcmp(color, ARGS[i])) {
// Do this first because it launches the mfg menu using a callback, as if we did this in the
// callback we send below to launch the display app it would end up launching the menu on
// top of the display app.
... |
prompt_send_response("Invalid command");
}
|
LID_OBJECT_SIZE, fn, strlen(fn) + 1);
assert_ack_count(1);
assert_nack_count(0);
}
void test_put_bytes__init_worker_okay_while_not_in_fw_update_mode(void) {
s_firmware_update_is_in_progress = false;
prv_receive_init_cookie(VALID_OBJECT_SIZE, ObjectWatchWorker, EXPECTED_COOKIE);
assert_ack_count(1);
assert_... | (s_last_response_cookie, chunk, sizeof(chunk)) | ;
assert_ack_count(1);
assert_nack_count(0);
fake_pb_storage_mem_assert_contents_written(chunk, sizeof(chunk));
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_PUT_BYTES_EVENT);
cl_assert_equal_i(event.put_bytes.type, PebblePutBytesEventTypeProgress);
cl_assert_equal_i(e... |
/*
* 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... | ASSERT_JS_GLOBAL_EQUALS_S("s2", "23:04:05.000") | ;
ASSERT_JS_GLOBAL_EQUALS_S("s3", "2005-07-25");
ASSERT_JS_GLOBAL_EQUALS_S("s4", "Mon Jul 25 2005 20:04:05 GMT-03:00");
}
void test_rocky_api_datetime__locale_time_string_12h(void) {
s_clock_is_24h_style = false;
rocky_global_init(s_api);
EXECUTE_SCRIPT(
"var d = new Date();\n"
"var s = d.toLocaleTim... |
n
graphics_draw_vertical_line_dotted(&ctx, GPoint(101, 11), 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(96, 16), 10);
// cross - even vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 32), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(4, 36), 10);
// cross - odd vert,... | GPoint(101, 33) | , 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(97, 37), 10);
// T facing left - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 70), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(5, 76), 5);
// T facing right - even vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, G... |
out.h"
static bool s_prefs_24h_style;
#define TIMEZONE_FIXTURE_PATH "timezones"
// Setup
/////////////////////////
void test_clock__initialize(void) {
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, f... | (rtc_get_time()) | , jan1st_noon_2005 + time_get_dstoffset());
} else {
cl_assert_equal_i(time_utc_to_local(rtc_get_time()), jan1st_noon_2005);
}
}
}
#define DST_ID_COUNT 36
static const time_t s_dst_correct_values[DST_ID_COUNT][3] = {
/* No DST: 0 ~ 0, GMT+0 */
[ 0]={ 0, 0, 0 },
/* AN (New South Wales) [... |
t event immediately:
prv_assert_subscription_event(characteristic, BLESubscriptionNone, BLEGATTErrorSuccess,
true /* kernel */, false /* app */);
// CCCD value should not be written, because app is still subscribed:
cl_assert_equal_i(s_last_cccd_value, (uint16_t) ~0);
}
void test_gatt_client... | (has_notification, false) | ;
}
void test_gatt_client_subscriptions__notification_app_and_kernel_subscribers(void) {
// Subscribe app:
BLECharacteristic characteristic = prv_get_indicatable_characteristic();
BTErrno e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
... |
buffer,
buf_end);
}
// -----------------------------------------------------------------------------
static int prv_get_serialized_action_group_size(TimelineItemActionGroup *action_group) {
int size = action_group->num_actions * sizeof(SerializedActionHeade... | prv_serialize_group_element(type, group_ptr, buffer, buf_end) | ;
}
return buffer - buf_start;
}
|
/*
* 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... | ("AlarmSnoozeSet") | ;
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
const char *snooze_text = i18n_noop("Snooze delay set to %d minutes");
char snooze_buf[64];
snprintf(snooze_buf, sizeof(snooze_buf), i18n_get(snooze_text, dialog), alarm_get_snooze_delay());
i18n_free(snooze_text, dialog);
dialog_set_text(dialog, s... |
value);
i2c_release(I2C_AS3701B);
return rv;
}
static bool prv_set_register_bit(uint8_t register_address, uint8_t bit, bool enable) {
uint8_t val;
if (!prv_read_register(register_address, &val)) {
return false;
}
if (enable) {
val |= (1 << bit);
} else {
val &= ~(1 << bit);
}
return prv_w... | if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not set pmic charge current.");
} | |
(the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BAS... | text_layer_set_text(&s_data.log_layer, "Logging...") | ;
}
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
if (s_data.info[0].logging_session) {
close_sessions();
} else {
start_logging();
}
}
static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
}
stati... |
LOG(" 0x%"PRIx32"",
s_parsed_msg.msrmt.values[i * s_parsed_msg.msrmt.num_types + j]);
}
}
}
return &s_parsed_msg;
}
// ---------------------------------------------------------------------------------------------
// Parse and encoded message and return a TestPLParsedMsg str... | cl_assert_equal_i(a->msrmt.num_types, b->msrmt.num_types) | ;
cl_assert_equal_m(a->msrmt.types, b->msrmt.types,
b->msrmt.num_types * sizeof(ProtobufLogMeasurementType));
cl_assert_equal_i(a->msrmt.num_samples, b->msrmt.num_samples);
cl_assert_equal_m(a->msrmt.offset_sec, b->msrmt.offset_sec,
b->msrmt.num_samples * sizeof(u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.