prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ing for unit tests
uint8_t flash_value = 0;
prv_flash_read(&flash_value, sizeof(flash_value),
prv_page_to_flash_offset(pg) + offsetof(PageHeader, page_flags));
return flash_value;
#else
PBL_ASSERTN(s_pfs_page_flags_cache && (pg < s_pfs_page_count));
return s_pfs_page_flags_cache[pg];
#endif
}... | prv_page_to_flash_offset(pg) | +
FILEHEADER_OFFSET);
return (S_SUCCESS);
}
static status_t write_pg_header(PageHeader *hdr, uint16_t pg) {
// recover current erase count which is updated in erase routine
prv_flash_read((uint8_t *)&hdr->erase_count, sizeof(hdr->erase_count),
prv_page_to_flash_offset(pg) + offsetof(PageHeader, eras... |
bi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_core_assign_horizontal_line_delta_raw")));
};
// VERTICAL LINE TESTS
// These tests use a pattern of two skinny 66% opacity rectangles drawn at the right of the
// screen (green on top and yellow on bottom) and one tall 66% opacity blue rectan... | setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, false, 1) | ;
const GRect *bitmap_bounds = &ctx.dest_bitmap.bounds;
// Fill the screen with red
graphics_context_set_fill_color(&ctx, GColorRed);
graphics_fill_rect(&ctx, bitmap_bounds);
// Draw 66% opacity blue pixels using graphics_private_plot_pixel() over the entire screen
// The expected result is that the enti... |
/*
* 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... | va_end(argp) | ;
}
|
-320},
{ 1264, -112, -192},
{ 1144, 40, -496},
{ 928, -232, -272},
{ 1088, 176, -712},
{ 888, -152, -512},
{ 808, -136, -584},
{ 624, -272, -640},
{ 464, -320, -536},
{ 344, -448, -480},
{ 264, -472, -568},
// 113 seconds
{ 248, -544, -488},
{ 200, -568, -592},
{... | // 118 seconds
{ 296, -168, -1048},
{ 232, -120, -1048},
{ 168, -112, -984},
{ 128, -72, -896},
{ 144, -56, -720},
{ 184, 32, -752},
{ 440, 16, -632},
{ 552, -40, -304},
{ 1200, -48, -240},
{ 1648, -152, -296},
{ 1664, -216, -296},
{ 1672, -256, -264},
{ 1608, -19... |
{ 1048, -56, -232},
{ 1144, 0, -240},
{ 1024, 0, -176},
{ 1040, -16, -152},
{ 1152, -8, -104},
{ 1176, 16, -48},
{ 1176, 16, -32},
{ 1200, 0, 0},
{ 1240, 24, 64},
{ 1240, 112, 72},
{ 1248, 200, 64},
// 121 seconds
{ 1184, 160, 88},
{ 1080, 136, 112},
{ 1024, ... |
/*
* 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(mutex) | |
/*
* 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(KinoReelImpl)) | |
/*
* 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... | (vector, sizeof(vector), sizeof(expected)) | ;
assert_out_equal(expected, sizeof(expected));
}
|
uteList attr_list) {
for (int i = 0; i < attr_list.num_attributes; i++) {
if (!prv_deserialize_attribute(buffer, buf_end, cursor, payload_end,
&attr_list.attributes[i])) {
PBL_LOG(LOG_LEVEL_WARNING, "Encountered unknown attribute");
break;
}
}
return true;
}... | (list, id) | ->uint32 = uint32;
}
void attribute_list_add_resource_id(AttributeList *list, AttributeId id,
uint32_t resource_id) {
if (prv_attribute_type(id) != AttributeTypeResourceId) {
PBL_LOG(LOG_LEVEL_WARNING, "Adding attribute with type ResourceId for non-ResourceId " \
"... |
/*
* 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 (int32_t i = subsector_start; i < sector_start; i += SUBSECTOR_SIZE_BYTES) {
flash_erase_subsector_blocking(i);
} |
// Erase the full sectors...
for (int32_t i = sector_start; i < sector_end; i += SECTOR_SIZE_BYTES) {
flash_erase_sector_blocking(i);
}
// Erase the trailing subsectors
for (int32_t i = sector_end; i < subsector_end; i += SUBSECTOR_SIZE_BYTES) {
flash_erase_subsector_blocking(i);
... |
al(&s_items[s_correct_order[5]].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(4));
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(5));
cl_assert(time... | cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(2)) | ;
cl_assert(timeline_model_get_iter_state(2) == timeline_model_get_iter_state_with_timeline_idx(3));
cl_assert(timeline_model_iter_prev(&new_idx, NULL));
cl_assert_equal_i(new_idx, 0);
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[0]].header.id,
&ti... |
undefined value.
return rocky_error_unexpected_type(0, "JSON.stringify()-able object");
}
const uint32_t str_size = jerry_get_utf8_string_size(json_string) + 1 /* trailing zero */;
char *const data_buffer = task_zalloc(str_size);
if (!data_buffer) {
return prv_create_oom_error();
}
jerry_string_to... | {
return false;
} |
if (call_handler) {
prv_call_handler_when_registering(event_name, handler);
}
return true;
}
static bool prv_add_handler(const char *event_name, jerry_value_t handler) {
if (strcmp(ROCKY_EVENT_MESSAGE, event_name) == 0 || strcmp(ROCKY_EVENT_ERROR, event_name) == 0) {
return true;
}
return prv_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... | crc_calculate_flash(flash_address, desc->firmware_length) | ;
return crc == desc->checksum;
}
// Fills in the first 50% of the progress bar
static void prv_display_erase_progress(
uint32_t progress, uint32_t total, void *ctx) {
display_firmware_update_progress(progress, total * 2);
}
//! Returns true if we're going to install a new world firmware
static bool prv_check... |
y += (data->line_velocity_y * PIXEL_SPEED_PER_FRAME);
if (data->line_p0.y < 0 || data->line_p0.y > data->window.layer.bounds.size.h ||
data->line_p1.y < 0 || data->line_p1.y > data->window.layer.bounds.size.h ) {
data->line_velocity_y = data->line_velocity_y * -1;
}
} else if (shape ==... | {
// Move the line 2*X per 3*Y
data->bucket_offset.x += (data->bucket_velocity_x * PIXEL_SPEED_PER_FRAME * 2);
if (data->bucket_offset.x < 0 ||
data->bucket_offset.x > data->window.layer.bounds.size.w) {
data->bucket_velocity_x = data->bucket_velocity_x * -1;
}
data->buc... |
}
}
static void draw_shape(GContext* ctx, AppData *data, DrawShape shape, GColor color) {
graphics_context_set_fill_color(ctx, color);
graphics_context_set_stroke_color(ctx, color);
if (data->fill) {
if (shape == POINT) {
graphics_draw_pixel(ctx, data->point_p0);
} else if (shape == LINE) {
... |
UseDialog {
ExpandableDialog dialog;
AlarmsAppData *data;
} FirstUseDialog;
static void prv_alarms_app_opened_click_handler(ClickRecognizerRef recognizer, void *context) {
ExpandableDialog *expandable_dialog = context;
expandable_dialog_pop(expandable_dialog);
}
static void prv_push_alarms_app_opened_dialog(A... | alarm_editor_create_new_alarm(prv_handle_alarm_editor_complete, data) | |
{
gpath_draw_outline_open(ctx, data->bucket);
}
}
}
static int64_t prv_time_64(void) {
time_t s;
uint16_t ms;
rtc_get_time_ms(&s, &ms);
return (int64_t)s * 1000 + ms;
}
static void layer_update_proc(Layer *layer, GContext* ctx) {
AppData *data = app_state_get_user_data();
graphics_context_set... | {
init();
app_event_loop();
deinit();
} |
const PebbleProcessMd* pebble_shapes_get_app_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = s_main,
.name = "Pebble Shapes"
};
return (const PebbleProcessMd*) &s_app_info;
}
|
.id, &s_items[3].header.id));
// check second
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[2].header.id));
// check fourth
cl_assert(iter_next(&iter... | cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
14700), 0) | ;
#if CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[2].header.id));
cl_assert(iter_next(&iterator));
#endif
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[3].header.id));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_... |
S, config->no_music_text_field.size_h);
text_layer_init_with_parameters(&window->text_layer,
&NO_MUSIC_TEXT_RECT,
i18n_get("START PLAYBACK\nON YOUR PHONE", window),
fonts_get_system_font(config->no_music_font_key),
... | {
case MusicPlayStatePlaying:
// We need to update the progress bar every second.
tick_timer_service_subscribe(SECOND_UNIT, prv_handle_tick_time);
break;
default:
// We're no longer updating the progress bar; unsubscribe.
tick_timer_service_unsubscribe();
} |
}
static void prv_configure_music_text_layer(
TextLayer *text_layer, char* text_buffer, const GRect *rect, int16_t y_offset,
GTextAlignment align, GFont font) {
text_layer_init_with_parameters(text_layer, rect, text_buffer, font,
GColorBlack, GColorClear, align, GTextOverfl... |
nd = ALARM_KIND_EVERYDAY });
alarm_set_custom(id2, schedule_2);
prv_assert_alarm_config(id2, 4, 14, false, ALARM_KIND_CUSTOM, schedule_2);
alarm_get_custom_days(id2, verify_schedule_2);
prv_assert_alarm_config(id2, 4, 14, false, ALARM_KIND_CUSTOM, verify_schedule_2);
}
void test_alarm__alarm_get_string_for_cus... | (&(AlarmInfo) { .hour = 13, .minute = 13, .kind = ALARM_KIND_WEEKDAYS }) | ;
id4 = alarm_create(&(AlarmInfo) { .hour = 14, .minute = 14, .kind = ALARM_KIND_WEEKDAYS });
id5 = alarm_create(&(AlarmInfo) { .hour = 15, .minute = 15, .kind = ALARM_KIND_WEEKDAYS });
id6 = alarm_create(&(AlarmInfo) { .hour = 16, .minute = 16, .kind = ALARM_KIND_WEEKDAYS });
alarm_delete(id4);
prv_assert_al... |
8_t *)result = response.data[1];
} else if (type == StatusReadType_12bit) {
// The 3 data bytes are ST PQ R1 (in hex) with ST being the address and RPQ being the value.
PBL_ASSERTN(response.data[0] == address);
PBL_ASSERTN((response.data[2] & 0x0F) == PACKET_FOOTER);
*(uint16_t *)result = response.dat... | {
EventMessage message = { };
prv_read_data((uint8_t *)&message, sizeof(message));
// Packet format: https://pebbletechnology.atlassian.net/wiki/display/PRODUCT/Elan+Protocol
if (message.packet_id == PACKET_ID_TOUCH_STATUS) {
for (uint32_t i = 0; i < ARRAY_LENGTH(message.touch.finger_data); i++) ... |
}
static void prv_exti_cb(bool *should_context_switch) {
if (s_callback_scheduled) {
return;
}
PebbleEvent e = {
.type = PEBBLE_CALLBACK_EVENT,
.callback.callback = prv_process_pending_messages
};
*should_context_switch = event_put_isr(&e);
s_callback_scheduled = true;
}
// Initialization
//... |
esent otherwise do what rect does
if (show_action_bar) {
x = grect_get_max_x(bounds) - action_bar_width - content_and_action_bar_horizontal_spacing -
icon_size.w;
} else {
x = (grect_get_max_x(bounds) - action_bar_width - icon_size.w) / 2;
}
#endif
y = icon_top_margin_px;
if (dialog_init... | strlen(text) | ;
workout_dialog->subtext_buffer = applib_malloc(len + 1);
strncpy(workout_dialog->subtext_buffer, text, len + 1);
}
void workout_dialog_set_action_bar_hidden(WorkoutDialog *workout_dialog, bool should_hide) {
workout_dialog->hide_action_bar = should_hide;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
static const GAPLEAdvertisingJobTerm s_advert_terms[] = {
// When starting to advertise for reconnection, burst for 25 seconds:
[0] = {
.duration_secs = 25,
.min_interval_slots = 244, // 152.5 ms -- Apple-recommended advertising interval
.max_interval_slots = 256, // 160.0 ms
},
/... | |
ve == false);
s_event_ongoing = true;
active = do_not_disturb_is_active();
cl_assert(active == true);
// Testing the override capability
do_not_disturb_set_manually_enabled(false);
active = do_not_disturb_is_active();
cl_assert(active == false);
}
void test_do_not_disturb__weekday_weekend_schedule(voi... | (WeekdaySchedule, false) | ;
rtc_set_time(s_thursday_01_00);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 00:00 on Saturday. (47.0 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 169200 * MS_PER_SECOND);
do_not_disturb_set_schedu... |
v_cancel_fake_progress_timer(ProgressWindow *data) {
if (data->fake_progress_timer != EVENTED_TIMER_INVALID_ID) {
evented_timer_cancel(data->fake_progress_timer);
data->fake_progress_timer = EVENTED_TIMER_INVALID_ID;
}
}
static void prv_set_progress(ProgressWindow *data, int16_t progress) {
data->progres... | progress_layer_set_background_color(progress_layer, GColorBlack) | ;
#endif
progress_layer_set_corner_radius(progress_layer, PROGRESS_SUGGESTED_CORNER_RADIUS);
layer_add_child(&window->layer, (Layer *)progress_layer);
data->max_fake_progress_percent = PROGRESS_WINDOW_DEFAULT_FAKE_PERCENT;
data->state = ProgressWindowState_FakeProgress;
data->is_peek_layer_used = false;
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 (accessory_manager_set_state(AccessoryInputStateSmartstrap)) {
// enable the accessory port
accessory_set_baudrate(AccessoryBaud9600);
accessory_set_power(true);
smartstrap_comms_set_enabled(true);
return true;
} else {
PBL_LOG(LOG_LEVEL_ERROR, "The accessory is already in use");
re... |
static void prv_release_accessory(void) {
PBL_ASSERTN(!s_subscriber_count);
smartstrap_fsm_state_set(SmartstrapStateUnsubscribed);
PBL_LOG(LOG_LEVEL_DEBUG, "Disconnecting from smartstrap");
smartstrap_link_control_disconnect();
smartstrap_comms_set_enabled(false);
new_timer_stop(s_monitor_timer);
// st... |
VICE_ADDRESS_XPLODE(s_local_addr_desired_policy.pinned_address));
// Note: the pinned address is actually resolvable, but we need to lie to the SDK here to avoid
// automatically cycling, see irb_ble_handler_gap_address_set_cmd():
desired_address_out->addr_type = PRIVATE_STATIC_ADDRESS;
memcpy(&desired_address... | prv_assert_is_executing_on_ble_task() | ;
if (s_local_addr_state == LocalAddressState_AwaitingDisconnection) {
PBL_LOG(LOG_LEVEL_DEBUG, "Got disconnection, trying to update own address");
prv_try_updating_own_address();
}
}
void local_addr_init(void) {
s_local_addr_state = LocalAddressState_Uninitialized;
// Put all zeroes into ble_dev_par... |
called when the bus is locked
static void abort_transfer(I2cBus *bus) {
// Disable all interrupts on the bus
bus->i2c->CR2 &= ~(I2C_CR2_ITEVTEN | I2C_CR2_ITERREN | I2C_CR2_ITBUFEN);
// Generate a stop condition
bus->i2c->CR1 |= I2C_CR1_STOP;
bus->transfer.state = TRANSFER_STATE_INVALID;
}
//! Set up and star... | (device_id, i2c_device_address, register_address, 1, result) | ;
}
bool i2c_read_register_block(I2cDevice device_id, uint8_t i2c_device_address, uint8_t
register_address_start, uint8_t read_size, uint8_t* result_buffer) {
#if defined(TARGET_QEMU)
PBL_LOG(LOG_LEVEL_DEBUG, "i2c reads on QEMU not supported");
return false;
#endif
// Do transfer lo... |
cache_callback(MenuIterator *iterator) {
MenuPrimeCacheIterator *it = (MenuPrimeCacheIterator*)iterator;
if (false == it->cache_set) {
// Prime the cursor cache:
it->it.menu_layer->cache.cursor = it->it.cursor;
// Set initial selection too:
it->it.menu_layer->selection = it->it.cursor;
it->cache... | (menu_layer->animation.animation) | |
/*
* 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... | interpolate_moook_duration() | );
}
static void prv_transition_from_launcher_animation_init(Animation *animation) {
prv_configure_transition_animation(animation, CompositorTransitionDirectionRight);
}
static void prv_transition_to_launcher_animation_init(Animation *animation) {
prv_configure_transition_animation(animation, CompositorTransition... |
break;
// Not implemented
}
menu_layer_reload_data(&s_data->menu_layer);
prv_update_text_layer_visibility(s_data);
}
// we don't handle reminders within the notifications app
}
///////////////////
// Window callbacks
static void prv_window_appear(Window *window) {
NotificationsData *data = ... | (&data->notification_event_info) | ;
prv_loaded_notification_list_deinit(data->loaded_notification_list);
prv_notification_list_deinit(data->notification_list);
i18n_free_all(data);
app_free(data);
s_data = NULL;
}
static void prv_s_main(void) {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
}
#else
static void prv_s_main(... |
strlen(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD), &disabled_activity,
sizeof(disabled_activity));
pfs_watch_cb(NULL); // Update the settings cache
prv_minute_update(ACTIVE_MINUTES);
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
}
// -------------... | time_util_update_timezone(&tz) | ;
rtc_set_time(time_util_get_midnight_of(rtc_get_time()) + tz.tm_gmtoff);
prv_set_sleep_history_avg();
activity_insights_init(rtc_get_time());
// At midnight, enter/exit get set to midnight UTC (for PST, this is 4PM), total sleep is 0
uint32_t midnight_local = ((24 + tz.tm_gmtoff) % 24) * SECONDS_PER_HOUR;... |
;
// Iterate through all entires and find the one with the highest AppInstallId. The next unique
// is then one greater than the largest found.
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
WTF;
}
struct AppDBInitData data = { 0 };
settings_file_each(&s_app_db.settings_file, ... | app_fetch_in_progress() | ) {
// cancels any app fetch
status_t rv = prv_cancel_app_fetch(INSTALL_ID_INVALID);
if (rv != S_SUCCESS) {
return rv;
}
}
app_install_do_callbacks(APP_DB_CLEARED, INSTALL_ID_INVALID, NULL, NULL, NULL);
// let app install manager deal with deleting the cache and removing related timeline p... |
ion) {
if (s_welcome_version != version) {
s_welcome_version = version;
prv_pref_set(PREF_KEY_WELCOME_VERSION, &version, sizeof(version));
}
}
uint8_t welcome_get_welcome_version(void) {
return s_welcome_version;
}
static bool prv_set_default_any_watchface_enumerate_callback(AppInstallEntry *entry, void... | {
s_activity_preferences.activity_insights_enabled = enable;
prv_activity_pref_set();
} |
bool activity_prefs_sleep_insights_are_enabled(void) {
return s_activity_preferences.sleep_insights_enabled;
}
void activity_prefs_sleep_insights_set_enabled(bool enable) {
s_activity_preferences.sleep_insights_enabled = enable;
prv_activity_pref_set();
}
bool activity_prefs_tracking_is_enabled(void) {
retu... |
And finally our current width is the starting width plus any change
int current_cell_width = cur_cell_width + current_cell_width_change;
const GRect rect =
GRect(current_x_offset, 0, current_cell_width, selection_layer->layer.frame.size.h);
graphics_context_set_fill_color(ctx, selection_layer->active_backg... | if (selection_layer->selected_cell_idx == i) {
int delta = (selection_layer->bump_text_anim_progress *
prv_get_font_top_padding(selection_layer->font)) / 100;
if (selection_layer->bump_is_upwards) {
delta *= -1;
}
y_offset += delta;
}
... |
}
static void prv_draw_selection_layer(SelectionLayer *selection_layer, GContext *ctx) {
// The first thing that is drawn is the background for each cell
prv_draw_cell_backgrounds(selection_layer, ctx);
// If the slider is in motion draw it. This is above the backgrounds, but below the text
if (selection_lay... |
START_SYNC:
PBL_LOG(LOG_LEVEL_DEBUG, "Got SYNC");
prv_handle_start_sync(session, data, data_length);
break;
case BLOB_DB_COMMAND_WRITE_RESPONSE:
PBL_LOG(LOG_LEVEL_DEBUG, "WRITE Response");
prv_handle_write_response(session, data, data_length);
break;
case BLOB_DB_COMMAND_WRIT... | comm_session_send_data(comm_session_get_system_session(),
BLOB_DB2_ENDPOINT_ID,
(uint8_t *)&msg,
sizeof(msg),
COMM_SESSION_DEFAULT_TIMEOUT) | ;
}
void blob_db2_protocol_msg_callback(CommSession *session, const uint8_t* data, size_t length) {
PBL_ASSERT_TASK(PebbleTask_KernelBackground);
analytics_inc(ANALYTICS_DEVICE_METRIC_BLOB_DB_EVENT_COUNT, AnalyticsClient_System);
// Each BlobDB message is required to have at least a Command and a Token
stati... |
(steps_event_handler) | ;
// Subscribe to second ticks
tick_timer_service_subscribe(SECOND_UNIT, handle_second_tick);
// Launch the worker
AppWorkerResult result = app_worker_launch();
APP_LOG(APP_LOG_LEVEL_INFO, "launch result: %d", result);
// Subscribe to health service
health_service_events_subscribe(health_event_handler,... | |
on:
// 1.) Before FreeRTOS has been initialized - only 1 "task", no mutexes available
// 2.) After FreeRTOS, but before our mutex has been created (via kernel_applib_init())
// 3.) After our mutex has been created.
// In phase 1, we don't bother taking the mutex but still log
// In phase 2, we just retu... | (kernel_applib_get_connection_service_state()) | ;
battery_state_service_state_init(kernel_applib_get_battery_state_service_state());
}
|
alse);
cl_assert_equal_i(s_path_fill_count, 1);
cl_assert_equal_i(s_path_stroke_count, 1);
cl_assert(prv_compare_points(points, s_stroke_points, s_path_num_points));
cl_assert(prv_compare_points(points, s_fill_points, s_path_num_points));
prv_reset();
// set stroke width to zero - fill should be drawn, but... | (s_path_num_points, 2) | |
_t bitmap_offset_8bit = ((uint32_t)block_addr * 8) - (padding * y_offset);
// Calculate just the offset from the start of the target row in the 8-bit bitmap (i.e. "x")
return bitmap_offset_8bit - (dest_bitmap->bounds.size.w * y_offset);
}
// PRO TIP: if you have to modify this function, expect to waste the rest of... | (src, dest_shift) | |
gure_operating_mode();
}
uint32_t accel_set_sampling_interval(uint32_t interval_us) {
BMI160SampleRate sample_rate = prv_get_supported_sample_rate(interval_us);
prv_enable_operating_mode(AccelOperatingModeData, sample_rate);
return prv_get_min_sampling_interval_us();
}
uint32_t accel_get_sampling_interval(void)... | (BMI160_REG_INT_MAP_0, en_val, en_val) | ;
// Actually enable the anymotion interrupt
uint8_t int_en = (BMI160_INT_EN_0_ANYMOTION_Z_EN |
BMI160_INT_EN_0_ANYMOTION_Y_EN | BMI160_INT_EN_0_ANYMOTION_X_EN);
prv_read_modify_write(BMI160_REG_INT_EN_0, int_en, int_en);
// configure the anymotion interrupt to fire after 4 successcive
// samples are ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, text_layer->text, text_layer->font, text_layer->layer.bounds,
text_layer->overflow_mode, text_layer->text_alignment,
prv_text_layer_legacy2_get_cache_handle(text_layer)) | ;
}
}
void text_layer_legacy2_init(TextLayerLegacy2 *text_layer, const GRect *frame) {
PBL_ASSERTN(text_layer);
*text_layer = (TextLayerLegacy2){};
text_layer->layer.frame = *frame;
text_layer->layer.bounds = (GRect){{0, 0}, frame->size};
text_layer->layer.update_proc = (LayerUpdateProc)text_layer_legacy2_... |
passert.h"
#include "util/size.h"
#include "util/trig.h"
#include "vendor/jerryscript/jerry-libm/include/math.h" // easiest way to get M_PI
#include <stdlib.h>
#include <string.h>
#define ROCKY_SINGLETON "_rocky"
// [MT] including <math.h> causes the jerry-libm header to get included again :(
extern double round(dou... | jerry_set_object_field(parent, name, result) | ;
if (was_created) {
*was_created = true;
}
return jerry_acquire_value(result);
}
static jerry_value_t prv_create_function(void *c_function_ptr) {
return jerry_create_external_function(c_function_ptr);
}
bool rocky_add_function(jerry_value_t parent, char *name, jerry_external_handler_t handler) {
bool ... |
e new_state) {
PBL_ASSERTN(prv_is_valid_fsm_transition(attr, new_state));
attr->state = new_state;
}
//! Note; This should only be called from the consumer task
static bool prv_start_transaction(SmartstrapAttributeInternal *attr, AttributeTransaction txn) {
PBL_ASSERT_TASK(CONSUMER_TASK);
if ((txn == Attribute... | (attr, SmartstrapAttributeStateRequestInProgress) | |
gress_layer_set_progress(&data->track_pos_bar, 0);
} else {
unsigned int percent = MIN((data->track_pos * 100) / data->track_length, 100);
progress_layer_set_progress(&data->track_pos_bar, percent);
prv_copy_time_period(data->position_buffer, sizeof(data->position_buffer),
data->t... | GRect(0, WINDOW_SIZE.h - horizontal_margin - 24,
WINDOW_SIZE.w - ACTION_BAR_WIDTH, 24) | );
layer_add_child(&data->window.layer, &data->cassette_container);
layer_set_clips(&data->cassette_container, false);
bitmap_layer_init(&data->cassette_layer, &cassette_rect);
bitmap_layer_set_bitmap(&data->cassette_layer, &data->image_cassette);
data->cassette_current_icon = &data->image_cassette;
const ... |
bar, i, false);
}
}
}
static GPoint prv_offset_since_time(int64_t time_ms, int64_t duration_ms,
GPoint max_offset) {
if (time_ms == 0) {
return GPointZero;
}
const int64_t delta_ms = prv_get_precise_time() - time_ms;
if (delta_ms >= duration_ms) {
return GPoin... | grect_align(&icon_rect, &rect, GAlignCenter, clip) | ;
#if PBL_ROUND
// Offset needed because the new curvature of the action bar makes the icons look off-center
const int32_t icon_horizontal_offset = -2;
icon_rect.origin.x += icon_horizontal_offset;
#endif
icon_rect.origin.x += offset.x;
icon_rect.origin.y += offset.y;
// We use GComp... |
fill_color = GColorJaegerGreen;
EXECUTE_SCRIPT(
"ctx.clearRect(1, 2, 3, 4);\n"
);
cl_assert_equal_i(1, s_graphics_fill_rect.call_count);
cl_assert_equal_rect(GRect(1, 2, 3, 4), s_graphics_fill_rect.last_call.rect);
cl_assert_equal_i(GColorBlackARGB8, s_graphics_fill_rect__color.argb);
cl_assert_equal_... | cl_assert_equal_i(20 * 8, lc->fill_radial_precise.radius_outer.raw_value) | ;
// inner radius capped to >= 0
EXECUTE_SCRIPT(
"ctx.rockyFillRadial(30, 40, -10, 20, 0, Math.PI);\n"
);
cl_assert_equal_i(2, s_graphics_fill_radial_precise_internal.call_count);
cl_assert_equal_point_precise((PP(29.5, 39.5)), lc->fill_radial_precise.center);
cl_assert_equal_i(0, lc->fill_radial_preci... |
rams_get_actual_state(hdl) >= state);
if (consumer_request == NULL) {
if (state == ResponseTimeMax) {
// No changes: there was no previous node and the new state is the default "low power" one.
goto handle_current_state;
}
// create node
consumer_request = kernel_malloc_check(sizeof(Conn... | (enabled_str) | ;
bool is_enabled = (s_chaos_monkey_timer != TIMER_INVALID_ID);
if (new_enabled == is_enabled) {
return;
}
bt_lock();
if (new_enabled) {
GAPLEConnection *conn_hdl = gap_le_connection_any();
if (conn_hdl) {
s_chaos_monkey_timer = new_timer_create();
prv_mode_chaos_monkey_callback(conn... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (resource_id != UINT32_MAX) | ;
KinoReel *kino_reel = kino_reel_create_with_resource(resource_id);
cl_assert(kino_reel);
cl_assert(kino_reel_get_type(kino_reel) == KinoReelTypePDCI);
cl_assert_equal_i(kino_reel_get_data_size(kino_reel), 192);
}
void test_kino_reel__resource_pdcs(void) {
// Test loading PDCS Kino Reel
uint32_t 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... | {
const BatteryWarningDisplayData *data = context;
const uint32_t percent = data->percent;
dialog_set_background_color(dialog, data->background_color);
const size_t warning_length = 64;
char buffer[warning_length];
const uint32_t battery_hours_left = battery_curve_get_hours_remaining(percent);
const char ... |
static void prv_dialog_on_unload(void *context) {
Dialog *dialog = context;
i18n_free_all(dialog);
if (dialog == s_dialog) {
s_dialog = NULL;
}
}
static void prv_display_modal(WindowStack *stack, DialogUpdateFn update_fn, void *data) {
if (s_dialog) {
update_fn(s_dialog, data);
return;
}
S... |
_timer_minutes_count(), 0);
regular_timer_deinit();
}
// Janky black box smoke-test to exercise the ANCS message re-assembly state
// machine
void test_ancs__should_handle_small_and_large_messages(void) {
// Get 4 complete notifications
prv_send_notification((uint8_t *)&s_complete_dict);
prv_send_notification(... | (fake_notification_storage_get_remove_count(), 0) | ;
// If there's a notification that matches with a different uid, we update the notification by
// removing and then storing again (we don't send a NotificationAdded event)
fake_notification_storage_set_existing_ancs_notification(&(Uuid)UUID_SYSTEM, UINT32_MAX);
prv_send_notification((uint8_t *)&s_complete_dic... |
e, false);
}
}
static void prv_app_button_down_handler(PebbleEvent *e, void *context) {
WindowStack *app_window_stack = app_state_get_window_stack();
if (window_stack_is_animating(app_window_stack)) {
return;
}
sys_analytics_inc(ANALYTICS_APP_METRIC_BUTTONS_PRESSED_COUNT, AnalyticsClient_App);
if (e-... | pebble_task_get_current() | ;
if ((task != PebbleTask_App) && (task != PebbleTask_Worker)) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Only supported from app or worker tasks");
return INSTALL_ID_INVALID;
}
// Get the app id
if (task == PebbleTask_App) {
return sys_app_manager_get_current_app_id();
} else {
return sys_worker_manage... |
led and some have
// already completed.
//
// Here's a graph of what we are doing
//
// 0 10 310 320 330 500 680 730 850 950 1080 1300
// | | | | | | | | | | | |
// --------------------------------------------------------... | prv_count_handler_entries(&s_stopped_handler_calls, spawn) | , 1);
#endif
}
void prv_update_unschedule_all_handler(Animation *animation, const AnimationProgress distance) {
prv_add_handler_entry(&s_update_handler_calls, animation, false,
(void *)(uintptr_t)distance /*context*/);
DPRINTF("%"PRIu64" ms: Executing update handler for %d, distance: %d\n"... |
ed = (const char *[]){
"Exception while e3", "ReferenceError", NULL,
};
rocky_log_exception("e3", e3);
cl_assert(*s_log_internal__expected == NULL);
}
/*
* FIXME: JS Tests should be built in a 32-bit env
void test_js__size(void) {
cl_assert_equal_i(4, sizeof(size_t));
}
*/
void test_js__snapshot(void) {
... | jerry_release_value(date_builtin) | ;
}
void test_js__get_global_builtin_changed(void) {
jerry_value_t date_builtin = jerry_get_global_builtin((const jerry_char_t *)"Date");
jerry_value_t global_object = jerry_get_global_object();
const char *source = "Date = 'some string';";
jerry_eval((const jerry_char_t *)source, strlen(source), 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... | {
if (!glance || !glance->should_consider_slices) {
return;
}
const Uuid *uuid = &glance->uuid;
AppGlanceSliceInternal current_slice = {};
// If there's no current slice, this function won't modify the zeroed-out current_slice, so we
// can safely set the glance's current slice to current_slice either... |
void launcher_app_glance_draw(GContext *ctx, const GRect *frame, LauncherAppGlance *glance,
bool is_highlighted) {
if (!glance || !frame || !ctx) {
return;
}
glance->size = frame->size;
glance->is_highlighted = is_highlighted;
kino_reel_draw(glance->reel, ctx, frame->origi... |
t_ms = *timeout_ms;
return true;
}
s_backlight_timeout_ms = DEFAULT_BACKLIGHT_TIMEOUT_MS;
return false;
}
static uint16_t prv_convert_backlight_percent_to_intensity(uint32_t percent_intensity);
static bool prv_set_s_backlight_intensity(uint16_t *intensity) {
if (*intensity > BACKLIGHT_BRIGHTNESS_OFF) {
... | {
return false;
} |
s_activity_hr_preferences = *new_settings;
return true;
}
static bool prv_set_s_activity_hrm_preferences(ActivityHRMSettings *new_settings) {
// Set the preference before calling `hrm_manager_enable` because it actually queries
// for the setting
s_activity_hrm_preferences = *new_settings;
#if CAPABILITY_... |
epare, write, finish happy
//! path. Ensure that the endpoint handler CB is run from kernel BG and that
//! we don't leak memory
void test_default_kernel_receiver__prepare_write_finish_single(void) {
char *data = "helloworld";
Receiver *receiver = g_default_kernel_receiver_implementation.prepare(
FAKE_COMM_... | fake_pbl_malloc_num_net_allocs() | , 0);
}
//! Test the case where a callback has been pended to kernelBG and we get a cleanup
void test_default_kernel_receiver__race_condition(void) {
char *data = "cleanup but finish ran first!";
Receiver *receiver = g_default_kernel_receiver_implementation.prepare(
FAKE_COMM_SESSION, &s_endpoints[0], strle... |
er_get_button_id(recognizer);
GRect frame = data->text_layer.layer.frame;
if (button == BUTTON_ID_UP) {
if (data->select_index == SelectIndexPixels) {
// Do inverse
if (data->up_down_direction) {
frame.origin.y--;
} else {
frame.origin.x--;
}
} else if (data->select_... | (&data->direction_layer, GTextAlignmentCenter) | ;
text_layer_set_overflow_mode(&data->direction_layer, GTextOverflowModeTrailingEllipsis);
// Init word wrap layer
text_layer_init(&data->word_wrap_layer, &GRect(5, 130, 135, 20));
text_layer_set_background_color(&data->word_wrap_layer, GColorWhite);
text_layer_set_text_color(&data->word_wrap_layer, GColorBl... |
s_receive_variable = (s_receive_variable + 1) % MODULUS;
if (ntoh16(packet->i.length) <= length) {
size_t info_length = ntoh16(packet->i.length) - sizeof(ReliablePacket);
// This variable is read in the macro-expansion below, but linters
// have a hard time figuring that out.
(v... | PBL_ASSERT_NOT_TASK(PebbleTask_PULSE) | |
/*
* 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 (on) {
stop_mode_disable(InhibitorVibes);
} else {
stop_mode_enable(InhibitorVibes);
}
stop_mode_disabled = on;
} |
}
static uint16_t prv_get_vsys_mv(void) {
if (battery_get_charge_state().is_plugged) {
// Plugged in, use Vsys rather than Vbat
return pmic_get_vsys();
}
// Not plugged in, use latest battery reading
return battery_state_get_voltage();
}
static uint32_t prv_vibe_get_pwm_duty_cycle(int8_t strength) {
... |
rt_equal_i(s_handler_call_count[HandlerA], 1);
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
}
//! Multiple sessions should be able to be transmitting messages concurrently
void test_default_kernel_receiver__prepare_write_finish_multiple_sessions(void) {
Receiver *receiver[NumHandlers];
CommSession *se... | (data, strlen(data)) | ;
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(s_handler_call_count[HandlerA], 1);
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
}
|
-------------------------
T_STATIC AnimationPrivate *prv_animation_get_current(void) {
AnimationState *state = prv_animation_state_get(PebbleTask_Unknown);
return state->aux->current_animation;
}
InterpolateInt64Function animation_private_current_interpolate_override(void) {
AnimationPrivate *animation = prv_ani... | (animation) | ;
}
// -------------------------------------------------------------------------------------------
static int prv_scheduler_comparator(void *a, void *b) {
AnimationPrivate *animation_a = (AnimationPrivate *)a;
AnimationPrivate *animation_b = (AnimationPrivate *)b;
return serial_distance32(animation_a->abs_start... |
ERTN(slave->slave_state->scs_selected);
uint8_t *cptr = in;
while (len--) {
*(cptr++) = spi_ll_slave_read_write(slave, 0); // useless write-data
}
}
void spi_ll_slave_burst_write(const SPISlavePort *slave, const void *out, size_t len) {
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->sla... | prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_ReqTx, true) | ;
dma_request_start_direct(slave->tx_dma, (void *)&slave->spi_bus->spi->DR, out, len,
prv_dma_irq_handler, (void *)slave);
}
void spi_ll_slave_write_dma_stop(const SPISlavePort *slave) {
if (slave->slave_state->dma_state != SPISlavePortDMAState_Write) {
return;
}
dma_request_stop... |
bounds.start == 2);
cl_assert(success);
// Init mutable types
utf8_iter_init(&utf8_iter, &utf8_iter_state, &utf8_bounds, utf8_bounds.start);
// Tests
cl_assert(!iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
}
void test_utf8_iterator__decode_valid_string(v... | cl_assert_equal_i(s_each_count, 0) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (false /* run filesystem check */) | ;
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
// Setup content indicator
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
co... |
watchface_filter_callback);
}
}
void test_app_menu_data_source__last_app_not_in_order_file(void) {
// settings has to be at the beginning. The app_menu_data_source module enforces it
AppInstallId app_order[] = {APP_ID_SETTINGS, APP_ID_MUSIC, APP_ID_NOTIFICATIONS, APP_ID_ALARM... | app_menu_data_source_deinit(&data_source) | ;
}
void test_app_menu_data_source__complete_sorted_order(void) {
// Apps are sorted in the order of Quick Launch only, Override apps, Storage (smallest first),
// Record (smallest first), and finally Install ID (smallest first). Verify that this is true.
// This also tests that the Settings app (a special case)... |
/*
* 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... | comm_session_send_queue_copy(session, 0 /* start_offset */,
bytes_to_copy, &resp->data[0]) | ;
pulse_reliable_send(resp, bytes_to_copy + sizeof(PulsePPPacket));
comm_session_send_queue_consume(session, bytes_to_copy);
bytes_remaining -= bytes_to_copy;
} else {
// Reliable transport went down while waiting to send.
// The CommSession has already been closed so simply return wi... |
tch_list = NULL;
static PebbleRecursiveMutex *s_analytics_lock = NULL;
// Locking Functions
static void prv_lock(void) {
mutex_lock_recursive(s_analytics_lock);
}
static void prv_unlock(void) {
mutex_unlock_recursive(s_analytics_lock);
}
// Analytic Node Functions
static bool prv_compare_analytic(ListNode *fou... | analytics_add(metric, prv_stopwatch_elapsed_ms(stopwatch, rtc_get())) | |
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 11);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq... | graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY) | |
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 2);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ... | (&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw11_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_draw_round_rect_${BIT_DEPTH_NAME}__origin_radius_aa_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// AA = true, SW = 1
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_... |
prv_manual_scroll(&expandable_dialog->scroll_layer, 1);
}
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
ExpandableDialog *expandable_dialog = context;
prv_manual_scroll(&expandable_dialog->scroll_layer, -1);
}
static void prv_config_provider(void *context) {
ExpandableDial... | (header_layer, 8) | |
(rx_index == sizeof(core_dump_connect_ping)) {
if (memcmp(buffer, core_dump_connect_ping, sizeof(core_dump_connect_ping)) == 0) {
// Handshake received. Switch to tx mode.
hw_spi_change_fifo_mode(s_spi->bus_id, HW_SPI_FIFO_TX_ONLY);
rx_mode = false;
tx_index = 0... | ((uint8_t *)&DIALOG_BUILD_ID, BUILD_ID_TOTAL_EXPECTED_LEN) | |
nse, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed ... | PBL_ASSERT_RUNNING_FROM_EXPECTED_TASK(PebbleTask_KernelBackground) | |
2, 2), 20, 0, true);
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
cl_assert_equal_p(touch_event, NULL);
}
void test_touch__dispatch_touch_events_two_fingers(void) {
TouchEventContext ctx = {
.idx = 0
};
touch_dispatch_touch_events(0, prv_touch_event_dispatch_cb, &ctx);
cl_assert_equal_i... | (0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420) | ;
touch_handle_update(1, TouchState_FingerDown, &GPoint(55, 55), 2, 3686480);
fake_event_set_callback(prv_handle_palm_events);
touch_handle_driver_event(TouchDriverEvent_PalmDetect);
// Cancelled event, followed by a palm detection event
cl_assert_equal_i(s_expected_palm_events[0].type, PEBBLE_TOUCH_EVENT);... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&prefs1->attr_list, &prefs1->action_group, buf1, buf_size) | ;
attributes_actions_serialize_payload(&prefs2->attr_list, &prefs2->action_group, buf2, buf_size);
cl_assert_equal_m(buf1, buf2, attributes_actions_get_serialized_payload_size(&prefs2->attr_list, &prefs2->action_group));
}
void test_ancs_filtering__initialize(void) {
s_now = 1;
s_performed_store = false;
s_e... |
EL_ERROR, "Error opening file %d", fd);
} else {
pfs_close(fd);
}
s_write_offset = 0;
s_notif_storage_mutex = mutex_create_recursive();
}
void notification_storage_lock(void) {
mutex_lock_recursive(s_notif_storage_mutex);
}
void notification_storage_unlock(void) {
mutex_unlock_recursive(s_notif_storag... | (fd, iter_state.header.payload_length, FSeekCur) | < 0) {
break;
}
}
return true;
}
//! Compress storage by reading all valid notifications out of old file and storing to new file
//! via overwrite
static bool prv_compress(size_t size_needed, int *fd) {
pfs_seek(*fd, 0, FSeekSet);
//Open file for overwrite
int new_fd = pfs_open(FILENAME, OP_FLAG_... |
radius_outer_fixed,
radius_inner_fixed, radius_inner_fixed, angle_start, angle_end);
}
void graphics_fill_radial(GContext *ctx, GRect rect, GOvalScaleMode scale_mode,
uint16_t inset_thickness,
int32_t angle_start, int32_t angle_end) {
GPoin... | {
const GPointPrecise center = prv_gpointprecise_from_polar(&rect, scale_mode, angle);
return grect_centered_internal(¢er, size);
} |
void grect_polar_calc_values(const GRect *r, GOvalScaleMode scale_mode, GPointPrecise *center,
Fixed_S16_3 *radius) {
if (!r) {
return;
}
GRect rect = *r;
grect_standardize(&rect);
const int16_t FIXED_ONE = FIXED_S16_3_ONE.raw_value;
const int16_t FIXED_HALF = FIXED_S16_... |
nclude "stubs_pebble_tasks.h"
#include "stubs_persist.h"
#include "stubs_queue.h"
#include "stubs_resources.h"
#include "stubs_syscalls.h"
#include "stubs_task.h"
#include "stubs_tick.h"
#include "stubs_watchface.h"
#include "stubs_worker_manager.h"
#include "stubs_worker_state.h"
char __APP_RAM__[1024*128];
char *__A... | {
s_event_put__event = event;
cl_assert(event != NULL);
} |
void event_put_from_app(PebbleEvent* event) { cl_fail("unexpected"); }
void event_put_from_process(PebbleTask task, PebbleEvent* event) { cl_fail("unexpected"); }
void event_reset_from_process_queue(PebbleTask task) { cl_fail("unexpected"); }
void test_process_manager__initialize(void) {
s_app_install_get_md__res... |
ey);
return ltk;
}
static key_ltk_t *prv_create_local_ltk_from_info(const SMLocalEncryptionInfo *enc_info) {
key_ltk_t *ltk = kernel_zalloc_check(sizeof(key_ltk_t));
ltk->rand = enc_info->rand;
ltk->ediv = enc_info->ediv;
memcpy(ltk->key, enc_info->ltk.data, sizeof(ltk->key));
ltk->key_size = sizeof(ltk->k... | {
// If the device did not exchange an IRK, we have been given the devices identity address and
// this is how we will associate our connection with the device in the future. Therefore, mark
// is_remote_identity_info_valid as true but leave the irk 0'ed out to indicate it is unused
PBL_LOG(LOG_... | |
{
size_t size = sizeof(GDrawCommandImage) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6);
GDrawCommandImage *image = malloc(size);
GDrawCommandList *command_list = prv_create_command_list_3();
memcpy(&image->command_list, command_list, sizeof(GDrawCommandList) + (3 * sizeof(GDrawCommand)) +
(... | (s_path_num_points, 2) | ;
points[0] = GPoint(0, 2);
points[1] = GPoint(1, -1);
cl_assert(prv_compare_points(points, s_stroke_points, s_path_num_points));
cl_assert(prv_compare_points(points, s_fill_points, s_path_num_points));
free(frame);
}
static int s_iterations = 0;
static bool prv_iterate(GDrawCommand *command, uint32_t index... |
nfig_onto_window(menu_layer, &data->window);
layer_add_child(&data->window.layer, menu_layer_get_layer(menu_layer));
}
static void prv_information_window_unload(Window *window) {
SettingsSystemData *data = (SettingsSystemData*) window_get_user_data(window);
menu_layer_deinit(&data->menu_layer);
prv_deinit_sta... | (FONT_KEY_GOTHIC_18) | ;
graphics_draw_text(ctx, text, font, box, GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}
static void prv_draw_rt_cell_round(GContext *ctx, const Layer *cell_layer, GBitmap *mark,
const char *text, bool is_selected) {
GRect rt_rect = cell_layer->bounds;
const int16_t horiz... |
t_kind(id, ALARM_KIND_WEEKENDS);
prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_WEEKENDS, s_weekend_schedule);
}
void test_alarm__alarm_set_recurring_weekdays(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 3, 14, f... | alarm_get_string_for_custom(schedule_6, alarm_day_text_6) | ;
cl_assert_equal_s(alarm_day_text_6, "Thursdays");
bool schedule_7[7] = {false, false, false, false, false, true, false};
char alarm_day_text_7[32] = {0};
alarm_get_string_for_custom(schedule_7, alarm_day_text_7);
cl_assert_equal_s(alarm_day_text_7, "Fridays");
bool schedule_8[7] = {false, false, false, ... |
on_b);
cl_assert_equal_i(animation_get_duration(b, true, true), total_duration_b);
cl_assert_equal_i(animation_get_duration(spawn, false, false),
MAX(total_duration_a, total_duration_b));
cl_assert_equal_i(animation_get_duration(spawn, false, true),
play_count_spawn * (MAX... | cl_assert(memcmp(&c_handlers, &handlers, sizeof(AnimationHandlers)) == 0) | ;
// Context
cl_assert(animation_get_context(h) == context);
// Duration
cl_assert(animation_get_duration(h, true, true) == 250); // default value
animation_set_duration(h, duration);
cl_assert(animation_get_duration(h, true, true) == duration);
// Delay
cl_assert(animation_get_delay(h) == 0);
anim... |
&layout->view_size);
#if PBL_ROUND
if (render) {
// restore original clip box
ctx->draw_state.clip_box.size.h = orig_clip_height;
}
#endif
layout->view_size.h += LAYOUT_TOP_BANNER_HEIGHT;
#if PBL_ROUND
// Notification text is paged by LAYOUT_HEIGHT, so m... | {
NotificationLayoutInfo *layout_info = config->context;
static const LayoutLayerImpl s_layout_layer_impl = {
.size_getter = prv_layout_get_content_size,
.destructor = prv_layout_destroy,
#if PBL_COLOR
.color_getter = prv_layout_get_colors,
#endif
.context_getter = prv_layout_get_context,
};
// ... |
#else
LayoutLayer *notification_layout_create(const LayoutLayerConfig *config) { return NULL; }
bool notification_layout_verify(bool existing_attributes[]) { return false; }
#endif
TimelineResourceId notification_layout_get_fallback_icon_id(TimelineItemType item_type) {
return (item_type == TimelineItemTypeNotific... |
) {
data->hrm_quality = HRMQuality_Poor;
} else if (hrm_data_regs.sqi <= AS7000SQIThreshold_Worst) {
data->hrm_quality = HRMQuality_Worst;
} else if (hrm_data_regs.sqi == AS7000SQIThreshold_OffWrist) {
data->hrm_quality = HRMQuality_OffWrist;
} else {
data->hrm_quality = HRMQuality_NoSignal;
}
}... | mutex_assert_held_by_curr_task(dev->state->lock, true) | ;
exti_configure_pin(dev->handshake_int, ExtiTrigger_Falling, prv_as7000_interrupt_handler);
exti_enable(dev->handshake_int);
}
static void prv_log_running_apps(HRMDevice *dev) {
uint8_t app_ids = 0;
if (!prv_read_register(dev, ADDR_APP_IDS, &app_ids)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to get running apps... |
TimelineResourceSizeTiny, icon_to, align_in_frame);
#if ANIMATION_SLIDE
if (was_mini_peek) {
prv_play_peek_in(data);
return;
}
#endif
peek_layer_set_duration(peek_layer, duration);
peek_layer_play(peek_layer);
}
static void prv_intro_timer_callback(void *context) {
TimelineAppDat... | if (!first_pin) {
return;
} |
TimelineLayout *first_timeline_layout = timeline_layer_get_current_layout(&data->timeline_layer);
if (!first_timeline_layout) {
return;
}
PeekLayer *peek_layer = &s_app_data->peek_layer;
#if PLATFORM_TINTIN
const bool is_mini_peek = false;
#else
// if we are hiding the peek, we are in a mini peek
... |
_t *)&data,
SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_page_number()),
sizeof(data));
cl_assert_equal_i(data.getting_started.crc, new_crc);
// Should be corrupt, so it should return false
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), false);
... | cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0) | ;
shared_prf_storage_erase_ble_pairing_data();
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 2);
char device_name_out[BT_DEVICE_NAME_BUFFER_SIZE];
SMPairingInfo pairing_info_out;
const bool rv = shared_prf_storage_get_ble_pairing_data(&pairing_info_out, device_name_out, NULL,
... |
64, -1008},
{ 24, -184, -984},
{ -56, -184, -976},
{ -56, -192, -992},
{ 96, -120, -1040},
{ 120, -96, -1048},
{ -24, -48, -1016},
{ -8, -72, -1024},
{ 208, -296, -784},
{ -48, -40, -1008},
{ 64, -120, -1152},
{ 136, -96, -1112},
{ 208, -96, -992},
// 62 seconds
{... | { 8, -120, -1032},
{ 8, -120, -1024},
{ 0, -128, -1032},
{ 8, -128, -1016},
{ 8, -120, -1032},
{ 8, -120, -1032},
{ 0, -128, -1024},
{ -8, -120, -1032},
{ 16, -120, -1032},
{ 0, -128, -1032},
{ 8, -120, -1024},
{ 0, -128, -1024},
{ 0, -128, -1016},
{ -8, -120, -10... |
{ 328, -8, -464},
{ 552, 32, -184},
{ 1016, 136, -32},
{ 2096, 464, 48},
{ 2416, 784, 464},
{ 2272, 792, 592},
// 5 seconds
{ 1736, 576, -88},
{ 1392, 288, 160},
{ 1256, 416, 384},
{ 1112, 568, 400},
{ 1008, 736, 440},
{ 712, 176, 112},
{ 624, -344, -112},
{ ... |
yer_mark_dirty(&nf->window.layer);
}
// implemented from: http://stackoverflow.com/questions/707370/clean-efficient-algorithm-for-wrapping-integers-in-c
// answered by: Eddie Parker, <http://stackoverflow.com/users/56349/eddie-parker>
static int wrap(int num, int const lower_bound, int const upper_bound) {
int range... | (NUMBER_FONT_KEY) | , frame,
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
void number_window_set_label(NumberWindow *nw, const char *label) {
nw->label = label;
layer_mark_dirty(&nw->window.layer);
}
void number_window_set_max(NumberWindow *nf, int32_t max) {
nf->max_val = max;
if (nf->v... |
/*
* 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 (!session) {
return false;
}
return (s_valid_session == session);
} |
static int s_send_next_count = 0;
void comm_session_send_next(CommSession *session) {
++s_send_next_count;
}
void comm_session_send_next_immediately(CommSession *session) {
// Pretend to send out all the data:
size_t read_space = comm_session_send_queue_get_length(session);
comm_session_send_queue_consume(se... |
NULL));
cl_assert_passert(recognizer_create_with_data(&s_test_impl, NULL,
sizeof(s_test_impl_data), dummy,
NULL));
cl_assert_passert(recognizer_create_with_data(&s_test_impl,... | (!s_manager_state_change) | ;
recognizer_transition_state(r, RecognizerState_Completed);
cl_assert_equal_i(event_type, RecognizerEvent_Completed);
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Failed));
cl_assert_passert(recognizer_transition_state(r, Recognizer... |
stributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//! Overview:
//! - Summary of text layout and rendering:
//! - A line iterator is created to ... | if (codepoint_is_ideograph(codepoint)) {
new_state = WordStateIdeograph;
} else if (codepoint == WORD_JOINER_CODEPOINT) {
new_state = WordStateJoining;
} else {
new_state = WordStateGrowing;
} |
break;
case WordStateEnd:
new_state = WordStateEnd;
break;
}
return new_state;
}
//! @return true if init to new word, false otherwise (ie end of text)
//! @note assumes 'start' is not NULL, but does not assume 'start' is valid start of word
bool word_init(GContext* ctx, Word* word, const T... |
rdData *data = layer_get_data(base_layer);
// Renders the background
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
0, HEALTH_PROGRESS_BAR_MAX_VALUE);
prv_render_sleep_sessions(ctx, data);
prv_render_typical_markers(ctx, data);
// This is required ... | (ctx, base_layer) | |
w.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 language governing permissions ... | perimeter_for_display_round(&p, &ctx_size, r, 500) | |
}
static void prv_day_picker_draw_row(GContext *ctx, const Layer *cell_layer,
MenuIndex *cell_index, void *callback_context) {
AlarmEditorData *data = (AlarmEditorData *)callback_context;
AlarmKind kind = prv_index_to_alarm_kind(cell_index->row);
const bool all_caps = false;
... | if (data->show_check_something_first_text) { // clicking "complete" when no days selected
box.size = GSize(cell_layer->bounds.size.w, ALARM_DAY_LIST_CELL_HEIGHT);
box.origin = GPoint(0, 4);
graphics_draw_text(ctx, i18n_get("Check something first.",
... | |
{
.from_hour = 0,
.from_minute = 0,
.to_hour = 12,
.to_minute = 30,
};
do_not_disturb_set_schedule(WeekdaySchedule, &schedule_1);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
active = do_not_disturb_is_active();
cl_assert(active == true); // Scheduled ON
DoNotDisturbSchedul... | rtc_set_time(s_saturday_10_30) | |
/*
* 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... | (&pin_attr_list, type, kind) | ;
TimelineItem *item = timeline_item_create_with_attributes(alarm_time, 0, TimelineItemTypePin,
LayoutIdAlarm, &pin_attr_list, &action_group);
item->header.from_watch = true;
item->header.parent_id = (Uuid)UUID_ALARMS_DATA_SOURCE;
pin_db_insert_item_without_event(item);
i18n_free_all(&pin_attr_list);
... |
/*
* 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... | (SPRF_REGION_SIZE) | ;
fake_spi_flash_erase();
memset(buf, 0x17, SPRF_REGION_SIZE);
flash_write_bytes(buf, FLASH_REGION_SHARED_PRF_STORAGE_BEGIN, SPRF_REGION_SIZE);
kernel_free(buf);
}
static void prv_assert_mutexes_unlocked(void) {
cl_assert_equal_b(s_mutex_locked, false);
}
// Tests
///////////////////////////////////////////... |
(60 minutes)
#define ANCS_IS_ALIVE_RESPONSE_WAIT_TIME_SECONDS 5 // 5 seconds
static void prv_is_ancs_alive_cb(void *data);
static void prv_is_ancs_alive_response_timeout(void *data);
static void prv_ancs_is_alive_schedule_next_check(void) {
s_ancs_client->is_alive_timer = (const RegularTimerInfo) {
.cb = prv_... | {
if (regular_timer_is_scheduled(&s_notification_connection_delay_timer)) {
regular_timer_remove_callback(&s_notification_connection_delay_timer);
}
s_just_connected = true;
const int post_connection_notification_ignore_seconds = 10;
s_notification_connection_delay_timer = (const RegularTimerInfo) {
... |
// -----------------------------------------------------------------------------
// 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->reassembly_ctx.buffer);
}
stat... |
;
load_fixture_on_pfs(APP1_WORKER_FIXTURE_NAME, filename_buf);
resource_storage_get_file_name(filename_buf, sizeof(filename_buf), 1);
load_fixture_on_pfs(APP1_RESOURCES_FIXTURE_NAME, filename_buf);
// simulate installing app2 on flash
app_db_insert((uint8_t *)&menu_layer.uuid, sizeof(Uuid), (uint8_t *)&menu_... | app_install_get_uuid_for_install_id(tictoc_id, &uuid) | |
(uint32_t addr, bool is_subsector) {
bool erased = (is_subsector) ? flash_subsector_is_erased(addr) : flash_sector_is_erased(addr);
if (erased) {
char buffer[64];
uint32_t end_addr = addr + (is_subsector ? SUBSECTOR_SIZE_BYTES : SECTOR_SIZE_BYTES);
for (uint32_t i_addr = addr; i_addr < end_addr; i_addr ... | SPLIT_64_BIT_ARG(ticks) | );
}
void command_croak(void) {
prompt_command_finish();
PBL_CROAK("You asked for this!");
}
typedef void (*KaboomCallback)(void);
void command_hardfault(void) {
prompt_command_finish();
KaboomCallback kaboom = 0;
kaboom();
}
void command_boot_bit_set(const char* bit, const char* value) {
int len = st... |
tic char s_test_file_b[TEST_FILE_B_APPEND_SIZE];
// c - space to perform non-append writes
static const char *const TEST_FILE_C_NAME = "c";
static const size_t TEST_FILE_C_SIZE = 9001; // it's over 9000!
static char s_test_file_c[TEST_FILE_C_SIZE];
static uint32_t num_pages(void) {
return pfs_get_size() / PFS_SECTO... | cl_assert_equal_i(pfs_close(fd), S_SUCCESS) | ;
}
void test_pfs__open(void) {
int fd = pfs_open("dne", OP_FLAG_READ, 0, 0);
cl_assert(fd == E_DOES_NOT_EXIST);
fd = pfs_open("dne", OP_FLAG_OVERWRITE, FILE_TYPE_STATIC, 0);
cl_assert(fd == E_DOES_NOT_EXIST);
char name[] = {'a'};
int fds[100]; // arbitrarily large # of FDs
int i;
for (i = 0; i < (si... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.