prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
0, SW_EVEN));
#endif
setup_test(&context, true, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4);
#if PBL_COLOR
ASSERT_CALLED(prv_draw_round_rect_aa_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_EVEN));
#else
ASSERT_CALLED(prv_draw_round_rect_stroked(&c... | (graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10))) | ;
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, false, 2, GColorBlack, GColorBlack, true);
ASSERT_NO_CHANGE(gra... |
1},
.parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0x01},
.timestamp = 3,
.duration = 0,
.type = TimelineItemTypeReminder,
.layout = LayoutIdTest,
},
};
static TimelineItem item3 = {
.header = {
.id = {0x7c, 0x65, 0x2e, 0... | (memcmp(&item1, &temp, sizeof(TimelineItem)) == 0) | ;
cl_assert(S_SUCCESS == reminder_db_delete_item(&temp.header.id, true /* send_event */));
cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(Uuid)) == 0);
// check item 2
memset(&temp, 0, sizeof(TimelineItem));
cl_assert(S_SUCCESS == reminder_db_next_item_header(&temp));
cl_assert(uuid_equa... |
/*
* 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... | (LOG_LEVEL_ERROR, "BT driver failed to start!") | ;
// FIXME: PBL-36163 -- handle this better
}
stop_mode_enable(InhibitorCommMode);
}
static void prv_comm_stop(void) {
if (!s_comm_is_running) {
return;
}
stop_mode_disable(InhibitorCommMode);
#if CAPABILITY_HAS_BUILTIN_HRM
ble_hrm_deinit();
#endif
gap_le_deinit();
// Should be the last thing... |
s);
cd->menu_items[cd->menu_count - 1] = *item;
}
static void prv_append_regulatory_compliance_mark(SystemCertificationData *cd,
GBitmap *mark) {
// Determine whether adding this mark overflows the cell, necessitating
// another cell for this mark.
uint16_t mar... | (&data->status_layer, &data->window, i18n_get("Certification", data)) | ;
SystemCertificationData *cd = &data->certification_data;
*cd = (SystemCertificationData) {};
// Load up the assets
gbitmap_init_with_resource(&cd->fcc_mark, RESOURCE_ID_SYSTEM_FCC_MARK);
gbitmap_init_with_resource(&cd->kcc_mark, RESOURCE_ID_SYSTEM_KCC_MARK);
gbitmap_init_with_resource(&cd->ce_mark, RESO... |
sert_equal_i(s_command_list[0].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[1].addr, 64 * 1024);
cl_assert_equal_i(s_command_list[1].type, SectorEraseCommand);
cl_assert_equal_i(s_command_list[2].addr, 2 * 64 * 1024);
cl_assert_equal_i(s_command_list[2].type, SubsectorEraseCommand);
}
void ... | (s_command_list[2].addr, 0x331000) | |
case TimelineItemActionTypeRemoteRemove:
return prv_invoke_remote_action(action_menu, action, pin, (void *)label);
case TimelineItemActionTypeEmpty:
case TimelineItemActionTypeUnknown:
break;
#if CAPABILITY_HAS_BUILTIN_HRM
case TimelineItemActionTypeBLEHRMStopSharing:
prv_invoke_ble_hrm... | {
action_result->voice_data = voice_data;
} | else {
prv_cleanup_voice_data(voice_data);
}
}
static ActionMenuLevel *prv_create_level(uint16_t num_items, ActionMenuLevel *parent_level) {
ActionMenuLevel *level = action_menu_level_create(num_items);
level->parent_level = parent_level;
return level;
}
static ActionMenuLevel *prv_create_template_level_... |
f
}
// ----------------------------------------------------------------------------------------------
static int prv_get_sleep_seconds(void) {
#if CAPABILITY_HAS_HEALTH_TRACKING
int32_t sleep_seconds;
const bool rv = activity_get_metric(ActivityMetricSleepStateSeconds, 1, &sleep_seconds);
return rv ? sleep_secon... | if (!app_install_get_entry_for_install_id(APP_ID_ALARMS, entry)) {
goto cleanup;
} |
int num_pin_adds = 0;
time_t alarm_time = prv_get_alarm_time(alarm, cron_job_get_execute_time(cron));
time_t last_alarm = 0;
for (int i = 0; alarm_time <= current_time + SECONDS_PER_DAY * 3; i++) {
if (last_alarm != alarm_time) {
last_alarm = alarm_time;
localtime_r(&alarm_time, local_alarm_t... |
GAPLEClientKernel, true /* is_response_required */);
}
void test_ams__send_remote_command_non_kernel_main_task_then_disconnect(void) {
prv_connect_ams();
// Simulate Music app calling music_command_send():
stub_pebble_tasks_set_current(PebbleTask_App);
music_command_send(MusicCom... | music_get_pos(&track_pos_ms, &track_duration_ms) | |
_write_space_available(const CircularBuffer *buffer,
size_t required_length, uint32_t timeout_ms) {
bool did_stall = false;
const RtcTicks timeout_end_ticks = rtc_get_ticks() + milliseconds_to_ticks(timeout_ms);
while (true) {
prv_lock();
// bt_lock() is he... | (buffer, (sizeof(header) + length),
write_timeout) | |
k_should_deinit;
volatile bool task_is_running;
SPITransportMsgStatus *status_local;
SPITransportMsgStatus status_remote;
uint8_t rx_storage[HOST_TRANSPORT_HOST_RX_BUFFER_SIZE];
uint8_t *tx_storage;
SPITransportMsgFooter rx_footer;
SPITransportMsgFooter *tx_footer;
bool watchdog_timer_active;
} SPITrans... | xSemaphoreGiveFromISR(s_spi_transport.semph, &was_higher_task_woken) | ;
*should_context_switch = (was_higher_task_woken != pdFALSE);
}
static void prv_handle_sending_footer_complete_isr(bool *should_context_switch) {
s_spi_transport.state = SPITransportState_Idle;
prv_lock();
circular_buffer_consume(&s_spi_transport.tx, s_spi_transport.bytes_sendable_count);
prv_unlock();
p... |
>CACHE_LNSIZECFG_REG = 0x0;
CACHE->CACHE_ASSOCCFG_REG = 0x2;
CACHE->CACHE_CTRL2_REG = 0x0;
CACHE->CACHE_CTRL3_REG = 0x22;
CACHE->CACHE_MRM_HITS_REG = 0x0;
CACHE->CACHE_MRM_MISSES_REG = 0x0;
CACHE->CACHE_MRM_CTRL_REG = 0x0;
CACHE->CACHE_MRM_TINT_REG = 0x0;
CACHE->CACHE_MRM_THRES_REG = 0x0;
CACHE->SWD_R... | (DCDC, DCDC_TRIM_REG, DCDC_N_COMP_TRIM, 0x0) | ;
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_COMP_CLK, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_CURRENT, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_OUTPUT_MONITOR, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_ANA_TEST, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_IDLE, 0x0);
REG_SETF(DCDC, DCDC_T... |
H_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 + c... | (ctx, i, x_a.x, x_b.x, x_a.delta, x_b.delta, user_data) | ;
}
}
}
// restore original stroke color
ctx->draw_state.stroke_color = tmp;
cleanup:
applib_free(rot_points);
applib_free(intersections_up);
applib_free(intersections_down);
}
#endif // PBL_COLOR
void gpath_draw_filled_with_cb(GContext *ctx, GPath *path, GPathDrawFilledCallback cb,
... |
andler = dropped_handler;
new_node->event_handler_task = pebble_task_get_current();
new_node->buffer.storage = storage;
new_node->buffer.size = storage_size;
s_app_inbox_head = (AppInboxNode *)list_prepend((ListNode *)s_app_inbox_head,
(ListN... | prv_mark_failed_if_no_writer(inbox) | |
E_STATIC, 10);
cl_assert(fd >= 0);
pfs_close(fd);
cl_assert(s_watch_file_callback_called_count == 0);
}
extern status_t test_scan_for_last_written(void);
void test_pfs__last_written_page(void) {
pfs_format(true);
pfs_init(false);
// we just formatted so we shouldn't have a last written page
cl_assert(te... | cl_assert(list_find(&dir_list->list_node, prv_find_name, "b_test_1")) | ;
pfs_delete_file_list(dir_list);
// Do another search using a filter
dir_list = pfs_create_file_list(prv_filename_filter_a_prefix_cb);
// Should have 2 entries in it
cl_assert_equal_i(list_count(&dir_list->list_node), 2);
cl_assert(list_find(&dir_list->list_node, prv_find_name, "a_test_0"));
cl_assert... |
al
if (!entry->handler(entry->value, entry->value_len)) {
// If the handler returns false, that means it reset the global back to the default,
// so we should write the new value to the backing
prefs_private_write_backing(event->key, event->key_len, entry->value, entry->value_len);
}
}
}
//... | (app_id, &uuid) | ;
prv_pref_set(PREF_KEY_DEFAULT_WORKER, &uuid, sizeof(uuid));
}
bool quick_launch_is_enabled(ButtonId button) {
switch (button) {
case BUTTON_ID_UP:
return s_quick_launch_up.enabled;
case BUTTON_ID_DOWN:
return s_quick_launch_down.enabled;
case BUTTON_ID_SELECT:
return s_quick_launch_... |
ssert_equal_b(hrm_is_enabled(HRM), true);
// Send some data while enabled
int num_updates;
for (num_updates = 0; num_updates < 1000 && hrm_is_enabled(HRM); num_updates++) {
prv_fake_send_new_data();
fake_system_task_callbacks_invoke_pending();
}
// Should be disabled relatively quickly since we don'... | (false /* is plugged in */) | ;
cl_assert(prv_can_turn_sensor_on());
fake_system_task_callbacks_invoke_pending();
cl_assert(hrm_is_enabled(HRM));
}
|
ame_height = 0;
GSize icon_frame_size = GSizeZero;
const GFont subtitle_font = prv_get_cell_subtitle_font(config);
const bool render_subtitle = prv_should_render_subtitle_round(config, is_selected);
if (render_subtitle) {
subtitle_text_frame_height = fonts_get_font_height(subtitle_font);
}
const int su... | if (icon_align == GAlignTop) {
// The icon is on its own line at the top, extend accordingly
container_height += icon_frame_size.h;
} else if (render_icon && (icon_align == GAlignLeft)) {
// Let the icon extend the container height if it's taller than the title/subtitle combo
container_height = MAX(ic... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_INFO, "sending data") | ;
comm_session_send_data(session, 2000, (uint8_t *)0x08000000,
comm_session_send_buffer_get_max_payload_length(session),
COMM_SESSION_DEFAULT_TIMEOUT);
s_pending_count--;
}
// =================================================================================
// You... |
/*
* 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_data) | ;
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* battery_critical_get_app_info() {
static const PebbleProcessMdSystem s_app_md = {
.common = {
.main_func = s_main,
.visibility = ProcessVisibilityHidden,
// UUID: 4a71eb65-238d-4fa... |
= shadow_top->bounds.size.h;
const int16_t shadow_top_y_offset = -shadow_top_bitmap_h - CLIP(content_offset.y, -shadow_top_bitmap_h, 0);
if (shadow_top_y_offset >= -shadow_top_bitmap_h) {
graphics_draw_bitmap_in_rect(ctx, shadow_top, &GRect(0, shadow_top_y_offset,
... | {
// showing full page-aligned contents of last page
min_y_offset = ROUND_TO_MOD_CEIL(min_y_offset, page_height);
} |
}
if (scroll_layer_get_clips_content_offset(scroll_layer)) {
bounds.origin.x = CLIP(offset.x, MIN(min_x_offset, 0), 0);
bounds.origin.y = CLIP(offset.y, MIN(min_y_offset, 0), 0);
} else {
bounds.origin = offset;
}
if (gpoint_equal(&old_offset, &bounds.origin)) {
// Not changed.
// still... |
));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, STROKE_BIG);
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_origin_aa_r16_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ... | (&ctx, CENTER_OF_OFFSET_RECT, RADIUS_BIG) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_aa_r16_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, STROKE_BIG);
graphics_draw_circle(&ctx, CENTER_OF_OFFSET_RECT_NXNY, RADIUS_BIG);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "s... |
E_COMPLEX
const int duration_a = 300;
const int delay_a = 100;
const int duration_b = 500;
const int delay_b = 200;
const int delay_spawn = 150;
int duration_total = MAX(duration_a + delay_a, duration_b + delay_b) + delay_spawn;
// Create 2 test animations
Animation *a = prv_create_test_animation();
... | prv_create_test_animation() | ;
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
animation_set_play_count(b, 0);
// Create a sequence
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
animation_set_play_count(seq, play_count_seq)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_s(dstbuf, "There are 4 lights, -4") | ;
// Alternate form
snprintf(dstbuf, 256, "There are %#d lights, %#d", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %02d lights, %02d", 4, -4);
cl_assert_equal_s(dstbuf, "There are 04 lights, -4");
// Space padded ... |
{ 1160, 208, -136},
{ 1168, 528, -240},
{ 1696, 144, -144},
{ 1576, -216, -88},
{ 992, 200, -224},
{ 736, 152, 0},
{ 792, -40, 120},
{ 1104, 248, 312},
{ 1096, 136, 280},
{ 880, 64, 200},
{ 1008, 224, 112},
{ 984, 152, 120},
{ 1048, 192, 144},
// 172 seconds
{ 98... | { 968, 112, -352},
{ 896, 88, -352},
{ 864, 232, -416},
{ 840, 208, -480},
{ 816, 144, -528},
{ 800, 208, -592},
{ 792, 232, -592},
{ 744, 216, -576},
{ 712, 160, -592},
{ 736, 112, -648},
{ 880, -8, -760},
{ 896, -40, -736},
{ 848, -56, -760},
{ 648, -88, -736},
... |
{ -144, 760, -384},
{ -112, 736, -384},
{ -112, 824, -488},
{ -168, 816, -464},
{ -248, 752, -520},
{ -240, 632, -536},
{ -344, 664, -520},
// 180 seconds
// elapsed: 3 minutes
{ -384, 552, -608},
{ -416, 448, -720},
{ -384, 264, -736},
{ -328, 176, -784},
{ -272... |
urn device;
}
static void prv_mock_put_service_discovery_events(void) {
// Simulate discovery of Blood Pressure service:
fake_gatt_put_discovery_indication_blood_pressure_service(TEST_GATT_CONNECTION_ID);
fake_gatt_put_discovery_indication_health_thermometer_service(TEST_GATT_CONNECTION_ID);
fake_gatt_put_disc... | cl_assert_equal_i(num_descriptors, num_found_descriptors) | |
stem/logging.h"
#include "system/passert.h"
#include "util/size.h"
#include "util/time/time.h"
_Static_assert(sizeof(AnalyticsEventBlob) == 36,
"When the blob format or size changes, be sure to bump up ANALYTICS_EVENT_BLOB_VERSION");
// ---------------------------------------------------------------------------... | prv_simple_pin_event(timestamp, parent_id, AnalyticsEvent_PinOpen, "open") | ;
}
// ------------------------------------------------------------------------------------------
// Log a pin created event.
void analytics_event_pin_created(time_t timestamp, const Uuid *parent_id) {
prv_simple_pin_event(timestamp, parent_id, AnalyticsEvent_PinCreated, "created");
}
// -------------------------... |
/////////////////////////
static void settings_bluetooth_reconnect_once(void) {
// After the user toggles BT back on, immediately attempt to reconnect once:
if (bt_ctl_is_airplane_mode_on() == false) {
bt_driver_reconnect_try_now(true /*ignore_paused*/);
}
}
static void settings_bluetooth_toggle_airplane_mo... | {
SettingsBluetoothData *data = (SettingsBluetoothData*) context;
if (!data) {
return;
}
StoredRemote* remote = (StoredRemote*) list_find_next(data->remote_list_head,
dual_remote_filter, true, device);
if (remote) {
// The remote is also a ble 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... | PBL_LOG(LOG_LEVEL_INFO, "Notification modified: %s", uuid_string) | ;
notifications_handle_notification_acted_upon(id);
} else if (!has_status_bits) {
notification_storage_store(¬ification);
PBL_LOG(LOG_LEVEL_INFO, "Notification added: %s", uuid_string);
notifications_handle_notification_added(id);
}
timeline_item_free_allocated_buffer(¬ification);
return... |
if (sequence->play_count == GDRAW_COMMAND_SEQUENCE_PLAY_COUNT_INFINITE_STORED) {
return PLAY_DURATION_INFINITE;
} |
return prv_get_single_play_duration(sequence) * sequence->play_count;
}
uint32_t gdraw_command_sequence_get_num_frames(GDrawCommandSequence *sequence) {
if (!sequence) {
return 0;
}
return sequence->num_frames;
}
| |
thin
// - After completion
// - Bounce back timeline pin layouts
// - Speed lines (if launching into a deep pin)
// animate the peek layer to the right
GRect *start = &data->peek_layer.layer.frame;
GRect stop = { { was_mini_peek ? 0 : start->size.w , 0 }, start->size };
Animation *peek_out... | (&data->focus_event_info) | ;
prv_intro_timer_callback(data);
}
static void prv_peek_did_focus_handler(PebbleEvent *e, void *context) {
TimelineAppData *data = context;
event_service_client_unsubscribe(&data->focus_event_info);
#if ANIMATION_DOT
peek_layer_play(&data->peek_layer);
#elif ANIMATION_SLIDE
prv_play_peek_in(data);
#endif
... |
circle(ctx, command->points[0], command->radius);
}
}
static void prv_draw_precise_path(GContext *ctx, GDrawCommand *command) {
if (command->num_points <= 1) {
return;
}
// draw all values of alpha, except fully transparent
if ((command->fill_color.a != 0)) {
graphics_context_set_fill_color(ctx, com... | {
return false;
} |
return command->hidden;
}
size_t gdraw_command_copy_points(GDrawCommand *command, GPoint *points, const size_t max_bytes) {
const size_t actual_size = gdraw_command_get_num_points(command) * sizeof(GPoint);
const size_t size = MIN(max_bytes, actual_size);
memcpy(points, command->points, size);
return size;
... |
fer would not fill until 400ms, resulting
//! in a 150ms latency. This is how the legacy implementation worked as well
//! but is potentionally something we could improve in the future if it becomes
//! a problem.
static uint32_t prv_get_sample_interval_info(uint32_t *lowest_interval_us,
... | (state->data_cb_handler, state->data_cb_context) | ;
default:
WTF; // Unsupported task for the accel manager
}
}
//! This is called every time new samples arrive from the accel driver & every
//! time data has been drained by the accel service. Its responsibility is
//! populating subscriber storage with new samples (at the requested sample
//! frequency) ... |
/*
* 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... | bool_to_str(shared_prf_storage_get_getting_started_complete()) | |
ight = prv_get_row_height_depending_on_selection_state,
});
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(0, l.selection.y);
cl_assert_equal_i(0, scroll_layer_get_content_offset(&l.scroll_layer).y);
cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]);
... | cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionUp]) | ;
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
menu_layer_set_selected_next(&l, true, MenuRowAlignNone, false);
cl_assert_equal_i(2 * NORMAL, l.selection.y);
cl_assert_equal_i(NORMAL - FOCUSED, scroll_layer_get_content_offset(&l.scroll_layer).y);
cl_assert_equal_i(FOCUSED, l.s... |
s_active_corr[3] = { 0 };
static bool s_service_init = false;
static bool s_saved_corr_present = false;
static int16_t s_saved_corr[3] = { 0 };
static int32_t s_last_heading = -1; // the last heading we found
#ifdef RECOVERY_FW
static MagData s_last_mag_sample = { 0 };
#endif
///////////////////////////////////////... | cos_lookup(pitch) | ) / TRIG_MAX_RATIO;
mx_rot += (((my * sin_lookup(pitch)) / TRIG_MAX_RATIO) * sin_lookup(roll)) /
TRIG_MAX_RATIO;
mx_rot += (((mz * sin_lookup(pitch)) / TRIG_MAX_RATIO) * cos_lookup(roll)) /
TRIG_MAX_RATIO;
my_rot = mz * sin_lookup(roll) - my * cos_lookup(roll);
my_rot /= TRIG_MAX_RATIO;
int32_t ... |
es away the
// overhead of handling this in the subscriber module
this->state->subscriber.idx += (size / sizeof(int16_t));
if (this->state->subscriber.idx == this->state->subscriber.size) {
this->state->subscriber.callback(this->state->subscriber.buffer,
this->st... | {
this->state->overflow_cnt++;
break;
} | |
{
dbgserial_putstr("Failed to start firmware, strike one.");
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
}
return false;
}
static bool prv_prf_button_combination_is_pressed(void) {
return (button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK)
&& button_is_pressed(BUTTON_ID_SEL... | {
display_error_code(j << (i*4));
delay_us(200000);
} |
}
display_error_code(0x01234567);
delay_us(200000);
display_error_code(0x89abcdef);
delay_us(200000);
display_error_code(0xcafebabe);
delay_us(200000);
display_error_code(0xfeedface);
delay_us(200000);
display_error_code(0x8badf00d);
delay_us(200000);
display_error_code(... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(!iter_next(&utf8_iter)) | ;
cl_assert(!iter_next(&utf8_iter));
}
void test_utf8_iterator__decode_valid_string(void) {
// Mutable types
Iterator utf8_iter;
Utf8IterState utf8_iter_state;
// Immutable types
bool success = false;
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, s_valid_test_string);
cl_assert(success);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(0, gbitmap_get_data_row_info(&bmp, 3).min_x) | |
tic bool prv_set_s_backlight_timeout_ms(uint32_t *timeout_ms) {
if (*timeout_ms > 0) {
s_backlight_timeout_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);
sta... | {
if (new_settings->resting_hr > new_settings->elevated_hr ||
new_settings->elevated_hr > new_settings->max_hr) {
return false;
}
if (new_settings->zone1_threshold > new_settings->zone2_threshold ||
new_settings->zone2_threshold > new_settings->zone3_threshold) {
return false;
}
s_activit... |
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_HAS_BUILTIN_HRM
hrm_manager_handle_prefs_changed();
#endif //... |
clude "stubs_cron.h"
#include "stubs_event_loop.h"
#include "stubs_i18n.h"
#include "stubs_layer.h"
#include "stubs_logging.h"
#include "stubs_memory_layout.h"
#include "stubs_menu_cell_layer.h"
#include "stubs_modal_manager.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "... | if (config->subtitle) {
attribute_list_add_cstring(&list, AttributeIdSubtitle, config->subtitle);
} |
attribute_list_add_uint32(&list, AttributeIdIconPin, config->icon);
item = timeline_item_create_with_attributes(timestamp, MINUTES_PER_HOUR,
TimelineItemTypePin, LayoutIdGeneric,
&list, NULL);
attribute_list_des... |
(window1, ModalPriorityGeneric, false);
modal_manager_event_loop_upkeep();
cl_assert_equal_i(modal_manager_get_properties(),
ModalProperty_Exists | ModalProperty_CompositorTransitions |
ModalProperty_RenderRequested);
// Disable all modals
modal_manager_set_min_priority... | (window_stack_count(modal_stack), 0) | ;
cl_assert_equal_i(window2->on_screen, false);
// Switch to app happens via the compositor
compositor_transition(NULL);
// Call the upkeep function so the change in state is handled
modal_manager_event_loop_upkeep();
// The app is unobstructed, it should not be idle
cl_assert_equal_b(s_app_idle, false)... |
eof(file_name), "file%d", i);
cl_assert(pfs_remove(file_name) == S_SUCCESS);
}
cl_assert(pfs_active_in_region(0, pfs_get_size()));
// continuation page on region and make sure pfs is active
pfs_format(true);
int fd = pfs_open("testfile", OP_FLAG_WRITE, FILE_TYPE_STATIC, 68000);
cl_assert(fd >= 0);
cl... | memcmp(rbuf, buf, len) | == 0);
cl_assert(fd >= 0);
cl_assert(pfs_close(fd) == S_SUCCESS);
}
}
static uint32_t s_watch_file_callback_called_count = 0;
static void prv_file_changed_callback(void *data) {
s_watch_file_callback_called_count++;
}
void test_pfs__watch_file_callbacks(void) {
const char* file_name = "newfile";
PFS... |
OFFSET; fd < FD_INDEX_OFFSET+PFS_FD_SET_SIZE; fd++) {
if (PFS_FD(fd).fd_status == FD_STATUS_FREE) {
*fdp = fd;
return (FDAvail);
}
if (PFS_FD(fd).fd_status == FD_STATUS_UNREFERENCED) {
if ((unref == -1) || (PFS_FD(fd).time_closed < curr_time_closed)) {
unref = fd;
curr_time... | {
size_t bytes_to_write = MIN(free_bytes_in_page(file->curr_page) - pg_offset,
size - bytes_written);
prv_flash_write(buf + bytes_written, bytes_to_write,
prv_page_to_flash_offset(file->curr_page) + AVAIL_BYTES_OFFSET + pg_offset);
bytes_written += bytes_to_write;
file->offset += bytes... |
res = bytes_written;
cleanup:
mutex_unlock_recursive(s_pfs_mutex);
return (res);
}
uint32_t pfs_get_size(void) {
// one sector is needed for internal book keeping
return s_pfs_size - GC_REGION_SIZE;
}
void pfs_set_size(uint32_t new_size, bool new_region_erased) {
uint32_t prev_size = s_pfs_size;
s_pfs... |
0},
{ 0, 0x7c, 0, 205, 0},
{ 0, 0x7c, 0, 205, 0},
{ 0, 0x7c, 0, 205, 0},
// 690: Local time: 2015-11-13 06:52:00 AM
{ 0, 0x7c, 0, 205, 0},
{ 0, 0x7c, 0, 204, 0},
{ 0, 0x7c, 0, 205, 0},
{ 0, 0x7c, 0, 204, 0},
{ 0, 0x7c, 6, 193, 0},
{ 0, 0x7c, 0, 204, 0},
{ 0, 0x7c, 0, 204, 0}... | { 0, 0x53, 3646, 233, 0},
// 795: Local time: 2015-11-13 08:37:00 AM
{ 44, 0x41, 3304, 218, 0},
{ 77, 0x41, 4977, 208, 0},
{ 33, 0x43, 3133, 187, 0},
{ 0, 0x43, 2239, 167, 0},
{ 0, 0x43, 3691, 158, 0},
{ 0, 0x43, 1000, 153, 0},
{ 8, 0x43, 1173, 165, 0},
{ 0, 0x63, 6209, 168, 0},
... | |
, -48},
{ 1040, 40, -80},
{ 1152, 88, -80},
{ 1104, 80, -64},
{ 1328, -16, -48},
{ 1480, 40, -144},
{ 1192, 56, -120},
{ 960, 32, -72},
{ 920, 64, -120},
{ 1184, 48, -136},
{ 1368, 16, -56},
{ 1288, -16, -8},
{ 1208, -40, 0},
{ 1176, -8, 8},
{ 1072, -56, -8},
... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 20:03:39 local
AccelRawData *activity_sample_walk_100_pbl_25673_3(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25673_3
//> TEST... |
tive_kcalories > 0);
// If we init again, we should start out with the same metrics because we
// would have retrieved them from settings
prv_activity_init_and_set_enabled(true);
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricStepCount,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){100, 0, 0, 0, 0, 0, 0}));
AS... | activity_prefs_get_age_years() | ;
cl_assert_equal_i(age_years, ACTIVITY_DEFAULT_AGE_YEARS);
// Set the settings, re-init, and make sure they stick
height_mm += 10;
weight_dag += 11;
gender = ActivityGenderOther;
age_years += 10;
activity_prefs_set_height_mm(height_mm);
activity_prefs_set_weight_dag(weight_dag);
activity_prefs_set_g... |
t(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_wrap_x-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test vertical wrapping when dest_rect taller than src_bitmap.
// Setup:
// - Source is 25 x 10
// - 4 rows red, 2 rows blue, 4 rows black.
// - Dest is Green, 50 x 50
// - Dest Rect is 10 x 24 at (... | gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_and-expect.8bit.pbi") | );
memset(dest_data, GColorBlue.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpClear, GColorWhite);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_clear-expect.8bit.pbi"));
memset(dest_data, GColorBlue.argb, sizeof(dest_data));
bitblt_bitma... |
dows[idx] = window_create();
}
window_stack_push(stack, windows[0], true);
cl_assert_equal_i(window_stack_count(stack), 1);
cl_assert_equal_i(windows[0]->on_screen, true);
window_stack_push(stack, windows[1], true);
cl_assert_equal_i(window_stack_count(stack), 2);
cl_assert_equal_i(windows[0]->on_screen... | {
++idx;
window_stack_push(window_stacks[idx], windows[idx], false);
cl_assert_equal_i(window_stack_count(window_stacks[idx]), 1);
cl_assert_equal_i(windows[idx]->on_screen, true);
// All windows below the current priority should now not be on the screen
// as the modal has subverted them.
... | while (idx < NumModalPriorities - 1);
}
void test_window_stack__modal_properties_transparent(void) {
const int num_windows_per_stack = 2;
Window *windows[NumModalPriorities][num_windows_per_stack];
WindowStack *window_stacks[NumModalPriorities];
for (ModalPriority idx = ModalPriorityMin; idx < NumModalPriori... |
BATTERY_CRITICAL_VOLTAGE_DISCHARGING},
{2, 3465},
{5, 3615},
{10, 3685},
{20, 3725},
{30, 3760},
{40, 3795},
{50, 3830},
{60, 3885},
{70, 3955},
{80, 4065},
{90, 4160},
{100, 4250},
};
static const VoltagePoint charge_curve[] = {
{0, BATTERY_CRITICAL_VOLTAGE_CHARGING},
{2, ... | {
VoltagePoint const * const battery_curve = (is_charging) ? charge_curve : discharge_curve;
uint8_t const num_curve_points = (is_charging) ? NUM_CHARGE_POINTS : NUM_DISCHARGE_POINTS;
// Constrain the voltage between the min and max points of the curve
if (battery_mv <= battery_curve[0].voltage) {
return b... |
uint32_t battery_curve_lookup_percent_by_voltage(uint32_t battery_mv, bool is_charging) {
return prv_lookup_percent_by_voltage(battery_mv, is_charging, 1);
}
static uint32_t prv_sample_scaled_charge_percent(
uint32_t battery_mv, bool is_charging, uint32_t scaling_factor) {
int compensate = 0; // We compensa... |
pen = is_open,
.is_system = true
};
music_endpoint_handle_mobile_app_event(&app_event);
}
static void prv_receive_pp_data(const uint8_t *data, uint16_t length) {
fake_event_clear_last();
music_protocol_msg_callback(NULL, data, length);
}
static void prv_receive_and_assert_now_playing(bool expect_is_handle... | {
cl_assert_equal_i(data_length, 1);
cl_assert_equal_i(data[0], 0x08); // MusicEndpointCmdIDGetAllInfo
s_now_playing_requested = true;
} |
static bool s_next_track_command_sent;
static void prv_assert_next_track_command_sent_cb(uint16_t endpoint_id,
const uint8_t* data, unsigned int data_length) {
cl_assert_equal_i(data_length, 1);
cl_assert_equal_i(data[0], 0x04); // MusicEndpointCmdIDNextTrack
s... |
(prv_out_sent_callback), NULL);
cl_assert_equal_p(app_message_register_outbox_failed(prv_out_failed_callback), NULL);
cl_assert_equal_p(app_message_register_inbox_dropped(prv_in_dropped_callback), NULL);
cl_assert_equal_p(app_message_register_inbox_received(prv_in_received_callback), NULL);
s_out_sent_call_cou... | app_message_is_accepting_outbound() | , true);
}
void test_app_message__send_ack_timeout(void) {
// We'll send the ack right after the timeout
prv_set_remote_receive_handler(prv_ack_sent_callback);
prv_send_test_data();
prv_call_outbox_sent(AppOutboxStatusSuccess);
// Fire the timeout and send the data
app_timer_trigger(app_message_ack_timer_... |
prev_state == TimelineAppStatePeek ||
prev_state == TimelineAppStateHidePeek) {
prv_cleanup_timer(&data->intro_timer_id);
} else if (prev_state == TimelineAppStateStationary ||
prev_state == TimelineAppStateUpDown) {
TimelineLayout *first_timeline_layout =
timeline_layer_get_curre... | (state->pin.header.timestamp, &app_uuid) | ;
}
static Animation *prv_animate_to_pin_window(TimelineAppData *data) {
Layer *layer = &data->timeline_layer.layer;
GPoint to_origin = GPoint(-layer->bounds.size.w, 0);
Animation *animation = (Animation *)property_animation_create_bounds_origin(layer, NULL,
... |
b, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1, GCornerTopRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_topright.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_... | prv_clamp_corner_radius(GSize(0, 0), GCornersAll, 8) | , 0);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(0, 5), GCornersAll, 8), 0);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(4, 0), GCornersAll, 8), 0);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(4, 8), GCornerNone, 8), 0);
// Test minimum of width and height is taken as radius
cl_assert_equal_i(pr... |
sions and
* limitations under the License.
*/
#include "fw_copy.h"
#include "drivers/dbgserial.h"
#include "drivers/display.h"
#include "drivers/flash.h"
#include "drivers/system_flash.h"
#include "firmware.h"
#include "flash_region.h"
#include "system/bootbits.h"
#include "system/firmware_storage.h"
#include "syst... | boot_bit_test(BOOT_BIT_NEW_FW_AVAILABLE) | |
O_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1, GCornerBottomRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_aa_bottomright.${BIT_DEPTH_NAME}.pbi"));
#endif
}
extern uint16_t prv_clamp_corner_radius(... | test_graphics_context_init(&ctx, fb) | ;
setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, true, 1);
graphics_context_set_stroke_color(&ctx, GColorBlack);
// Fills rectangles around boundaries of clipping box - AA true
prv_fill_rects(&ctx, 0, 0, 0);
prv_fill_rects(&ctx, CLIP_OFFSET, 1, 0);
prv_fill_rects(&ctx, 2 * CLIP_OFFSET, ... |
ngle_start = TRIG_MAX_ANGLE / 8;
uint32_t angle_end = angle_start + (TRIG_MAX_ANGLE / 4);
GPointPrecise center = GPointPrecise(CENTER_OF_ORIGIN_RECT.x * 8, CENTER_OF_ORIGIN_RECT.y * 8);
Fixed_S16_3 radius = (Fixed_S16_3){.integer = RADIUS_BIG};
for (int precision_mode = 0; precision_mode < 2; precision_mode++)... | TO_TRIG(360) | |
SimpleMenuItem menu_items[] = {
{
.title = "Tracking",
.callback = prv_debug_cmd_tracking,
}, {
.title = "Activity Insights",
.callback = prv_debug_cmd_activity_insights,
}, {
.title = "Sleep Insights",
.callback = prv_debug_cmd_sleep_insights,
}, {
.title = "D... | (data->debug_window) | ;
app_free(data);
}
// -------------------------------------------------------------------------------
static void init(void) {
ActivityDemoAppData *data = app_malloc_check(sizeof(ActivityDemoAppData));
s_data = data;
memset(data, 0, sizeof(ActivityDemoAppData));
app_state_set_user_data(data);
// Debug w... |
(&s_cache, 1) | ;
cl_assert(output);
cl_assert(*output == input);
}
void test_lru_cache__flush(void) {
uint32_t input = 0xdeadbeef;
lru_cache_put(&s_cache, 1, &input);
lru_cache_flush(&s_cache);
uint32_t *output = lru_cache_get(&s_cache, 1);
cl_assert(output == NULL);
}
void test_lru_cache__evict(void) {
for (int i =... | |
lackers*/);
if (!success) {
// Although unlikely, we could get buffer overruns if we failed to open up the data logging
// session after a number of retries. In that case, we will start dropping the oldest
// minute data from data logging.
PBL_LOG(LOG_LEVEL_ERROR, "Circular buffer overrun");
succe... | {
const unsigned start_minute = time_util_get_minute_of_day(session->start_utc);
const time_t end_utc = session->start_utc + (session->length_min * SECONDS_PER_MINUTE);
const unsigned end_minute = time_util_get_minute_of_day(end_utc);
ACTIVITY_LOG_DEBUG("procesing activity %d, start_min: %u, len: %"PRI... |
// for us to re-label it. Note that this logic makes the assumption that restful sessions
// always follow the container session that they belong to. This is assumption is valid given
// the way that the algorithm identifies sleep sessions.
if (session->type == ActivitySessionType_RestfulSleep) {
... |
undefined(JSON));
JS_VAR func = jerry_get_object_field(JSON, function_name);
PBL_ASSERTN(jerry_value_is_function(func));
return jerry_call_function(func, JSON, args, args_count);
}
T_STATIC jerry_value_t prv_json_stringify(jerry_value_t object) {
return prv_call_json_function(GLOBAL_JSON_STRINGIFY, &object, ... | {
return rocky_error_arguments_missing();
} |
const jerry_value_t js_msg = argv[0];
JS_VAR json_string = prv_json_stringify(js_msg);
if (jerry_value_has_error_flag(json_string)) {
return jerry_acquire_value(json_string);
}
if (jerry_value_is_undefined(json_string)) {
// ECMA v5.1, 15.12.3, Note 5: Values that do not have a JSON representation ... |
.layout = LayoutIdTest,
}
};
static TimelineItem item4 = {
.header = {
.id = {0x8c, 0x65, 0x2e, 0xb9, 0x26, 0xd6, 0x44, 0x2c,
0x98, 0x68, 0xa4, 0x36, 0x79, 0x7d, 0xe2, 0x05},
.parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22,... | reminder_db_get_len((uint8_t *)&item2.header.id, sizeof(Uuid)) | == 0);
// check item 3 or 4
memset(&temp, 0, sizeof(TimelineItem));
cl_assert(S_SUCCESS == reminder_db_next_item_header(&temp));
if (uuid_equal(&item3.header.id, &temp.header.id)) {
temp.attr_list.attributes = NULL;
timeline_item_free_allocated_buffer(&temp);
cl_assert(memcmp(&item3, &temp, sizeof... |
/*
* 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... | gpio_af_init(&dev->rx_gpio, otype, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL) | ;
}
// configure the UART peripheral control registers
// - 8-bit word length
// - no parity
// - RX / TX enabled
// - 1 stop bit
// - no flow control
dev->periph->CR1 = cr1_extra_flags;
dev->periph->CR2 = 0;
dev->periph->CR3 = (dev->half_duplex ? USART_CR3_HDSEL : 0);
// QEMU doesn't want you t... |
/*
* 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 defined(MALLOC_INSTRUMENTATION)
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return prv_zalloc(size, saved_lr);
#else
return prv_zalloc(size, 0);
#endif
} |
void applib_free(void *ptr) {
#if defined(MALLOC_INSTRUMENTATION)
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
task_free_with_pc(ptr, saved_lr);
#else
task_free(ptr);
#endif
}
|
ld_vibrate_for_type(AlertPhoneCall));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(alerts_should_enable_backlight_for_type(AlertPhoneCall));
cl_assert(alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_vibrate_fo... | (rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS) | ;
cl_assert(alerts_should_enable_backlight_for_type(AlertPhoneCall));
cl_assert(alerts_should_notify_for_type(AlertMobile));
cl_assert(alerts_should_vibrate_for_type(AlertMobile));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(ale... |
vice_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm_smart__dont_trigger_30_min_early_deep_sleep(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10... | (s_num_timeline_removes, 3) | ;
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm_smart__across_midnight_boundary(void) {
prv_set_time(s_sunday, 22, 0);
AlarmId id;
bool monday_only[7] = {false, true, false, false, false, false, false};
id = alarm_create(&(AlarmInfo) { .hour = 0, .minute ... |
->spi.cs.pin,
HW_GPIO_MODE_INPUT, HOST_SPI->spi.cs.function);
}
}
static void prv_spi_chip_select_interrupt_handler(void) {
// Interrupt handler should always reset interrupt state, otherwise it will be called again.
hw_wkup_reset_interrupt();
prv_disable_spi_cs_wakeup_interrupt_h... | prv_lock() | ;
circular_buffer_consume(&s_tx_buffer, tx_len);
prv_unlock();
// Send the footer
spi_transfer_data tx_footer_transfer = {
.wbuf = &tx_footer,
.length = sizeof(tx_footer),
};
prv_do_blocking_spi_transfer(dev, &tx_footer_transfer);
HOST_TRANSPORT_DEBUG_LOG("Sent %u bytes.", tx_... |
util/sleep.h"
#include "services/common/analytics/analytics.h"
#include "services/normal/filesystem/pfs.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/attributes.h"
#include "util/math.h"
#include "util/string.h"
#include <inttypes.h>
#include <stddef.h>
#include <stdio.h>
typedef enum {
... | PBL_LOG(LOG_LEVEL_ERROR, "Wrote only %d bytes, expected %d", (int)bytes_wrote, (int)size) | ;
return false;
}
return true;
}
// ----------------------------------------------------------------------------------------
// Logs if an error occurs, returns true on success
static bool prv_pfs_seek(int fd, int offset, FSeekType seek_type) {
int result;
result = pfs_seek(fd, offset, seek_type);
if (r... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_passert(EXECUTE_SCRIPT(
"var data = [];\n"
"_rocky.on('memorypressure', function(){\n"
" var handlerData = [];\n"
" for (var i = 0; i < 100000; i++) {handlerData.push(i);}\n"
"});\n"
"for (var i = 0; i < 100000; i++) {data.push(i);}\n"
)) | |
---------------------------------
// Exported function used by blob_db API to set the backing store for a specific key
bool prefs_private_write_backing(const uint8_t *key, size_t key_len, const void *value,
int value_len) {
const PrefsTableEntry *entry = prv_prefs_entry(key, key_len);
... | prv_pref_set(PREF_KEY_CLOCK_TIMEZONE_SOURCE_IS_MANUAL, &manual, sizeof(manual)) | |
tributeIdTitle);
cl_assert_equal_s(response_action->attr_list.attributes[0].cstring, "Reply");
cl_assert_equal_i(response_action->attr_list.attributes[1].id, AttributeIdEmojiSupported);
cl_assert_equal_i(response_action->attr_list.attributes[1].uint8, 1);
ActionMenuItem menu_item = (ActionMenuItem) {
.acti... | (notif_attributes,
app_attrs,
&app_metadata,
NULL,
timestamp,
... | ;
cl_assert(item);
cl_assert_equal_i(item->action_group.num_actions, 1);
cl_assert_equal_i(item->action_group.actions[0].type, TimelineItemActionTypeAncsNegative);
}
void test_ancs_pebble_actions__test_group_sms(void) {
prv_support_sms_replies();
ANCSAttribute *notif_attributes[NUM_FETCHED_NOTIF_ATTRIBUTES... |
/*
* 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_put_debounced_connection_event(conn_id) | ;
regular_timer_remove_callback(&s_debounce_timers[conn_id]);
}
void debounced_connection_service_init(void) {
for (int i = 0; i < NumConnectionsToDebounce; i++) {
s_debounce_timers[i].cb = prv_handle_disconnection_debounced;
s_debounce_timers[i].cb_data = (void *)(uintptr_t)i;
}
// initial state of t... |
ite(write_sb[i], fake_data, payload_length);
comm_session_send_buffer_end_write(write_sb[i]);
}
// Can't write another message:
cl_assert_equal_p(NULL, comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
1 /* length */, TIMEOUT_MS));
... | {
s_valid_session = &s_session;
// Fill the send buffer completely:
const size_t max_length = comm_session_send_buffer_get_max_payload_length(&s_session);
SendBuffer *write_sb = comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
max_lengt... |
void test_session_send_buffer__send_queue_interface(void) {
s_valid_session = &s_session;
// Fill the send buffer completely:
const size_t max_payload_length = comm_session_send_buffer_get_max_payload_length(&s_session);
SendBuffer *write_sb = comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
... |
TTINGS_ICON_AIRPLANE,
.template_string = "Test subtitle",
},
},
{
.expiration_time = 1465579430, // (Fri, 10 Jun 2016 17:23:50 GMT)
.type = AppGlanceSliceType_IconAndSubtitle,
.icon_and_subtitle = {
.icon_resource_id = RESOURCE_ID_SETTINGS_ICON_BLUETOOTH,
... | (&APP_GLANCE_TEST_UUID, &empty_glance) | , S_SUCCESS);
AppGlance read_back_glance = {};
cl_assert_equal_i(app_glance_db_read_glance(&APP_GLANCE_TEST_UUID, &read_back_glance),
S_SUCCESS);
cl_assert_equal_m(&empty_glance, &read_back_glance, sizeof(AppGlance));
}
void test_app_glance_db__insert_no_app_installed(void) {
s_app_install_... |
ge_get_valid_page_number(void);
extern void shared_prf_storage_set_valid_page_number(uint32_t page_num);
// Defines
//////////////////////////////////////////////////////////
#define SPRF_REGION_SIZE (FLASH_REGION_SHARED_PRF_STORAGE_END - \
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_... | SPRF_PAGE_FLASH_OFFSET(j) | , sizeof(inv_magic));
}
// Write the valid page
flash_read_bytes((uint8_t *) &data, SPRF_PAGE_FLASH_OFFSET(page_idx[i]), sizeof(data));
data.magic = SprfMagic_ValidEntry;
flash_write_bytes((uint8_t *) &data, SPRF_PAGE_FLASH_OFFSET(page_idx[i]), sizeof(data));
// Call init and see if it found t... |
er, false);
animation_set_custom_interpolation((Animation *)anim, prv_interpolate_moook_soft);
animation_set_duration((Animation *)anim, interpolate_moook_soft_duration(NUM_MOOOK_FRAMES_MID));
animation_set_handlers((Animation *)anim, (AnimationHandlers) {
.stopped = prv_handle_animation_stop,
}, data);
... | window_set_click_context(BUTTON_ID_BACK, context) | ;
window_single_click_subscribe(BUTTON_ID_BACK, &prv_mic_click_handler);
window_set_click_context(BUTTON_ID_SELECT, context);
window_single_click_subscribe(BUTTON_ID_SELECT, &prv_mic_click_handler);
}
static void prv_back_click_config_provider(void *context) {
window_set_click_context(BUTTON_ID_BACK, context);... |
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(-14, 2, 28, 20), 4);
}
void across_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ct... | layer_set_update_proc(&layer, &inside_layer_update_callback) | ;
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &clear_layer_update_callback);
layer_render_tree(&layer, &ctx);
#if SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "... |
nt_id = {0},
.timestamp = 1421178061, // Tue Jan 13 11:41:01 2015 PST
.duration = 1,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
},
.attr_list = {
.num_attributes = 0,
.attributes = NULL,
},
.action_group = {
.num_acti... | timeline_model_init(first_time, &model) | ;
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[0]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[1]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(timelin... |
/*
* 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... | prompt_send_response("OK") | |
ow) {
prv_call_click_provider(window);
}
void window_set_click_config_provider_with_context(
Window *window, ClickConfigProvider click_config_provider, void *context) {
PBL_ASSERTN(window);
window->click_config_provider = click_config_provider;
window->click_config_context = context;
if (window->on_scre... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Cannot register BUTTON_ID_BACK raw handler");
return;
} |
ClickManager *mgr = prv_get_current_click_manager();
ClickConfig *cfg = &mgr->recognizers[button_id].config;
cfg->raw.up_handler = up_handler;
cfg->raw.down_handler = down_handler;
cfg->raw.context = context;
}
ClickConfigProvider window_get_click_config_provider(const Window *window) {
return window->cl... |
voice_window_transcription_dialog_keep_alive_on_select(data->voice_window, true);
voice_window_push(data->voice_window);
#endif
}
typedef enum ReplyOption {
ReplyOption_Voice,
ReplyOption_Template,
ReplyOption_Emoji,
ReplyOptionCount,
} ReplyOption;
static bool prv_is_reply_option_supported(ReplyOption op... | {
local_tm.tm_hour = 18;
local_tm.tm_min = 0;
local_tm.tm_sec = 0;
} | |
_bitmap->is_heap_allocated = false;
} else {
*sub_bitmap = *base_bitmap;
// it's the responsibility of the parent bitmap to free the underlying data and palette
sub_bitmap->info.is_palette_heap_allocated = false;
sub_bitmap->info.is_bitmap_heap_allocated = false;
}
grect_clip(&sub_rect, &base_bitm... | prv_platform_supports_format(size, format) | |
return (res);
}
static int pfs_open_gc_file(uint32_t space_needed, bool create) {
int fd = GC_FD_HANDLE_ID; // the gc fd follows the avail fd
File *file = &PFS_FD(fd).file;
// settings for cached & new fds
file->op_flags = OP_FLAG_READ;
if (create) {
file->op_flags |= OP_FLAG_WRITE;
}
file->offset ... | (fd, &gcdata, sizeof(gcdata)) | ;
// copy all the data we need to the file
copy_or_recover_gc_data(fd, &gcdata, true);
// mark our data as valid
gcdata.flags &= ~GC_DATA_VALID;
pfs_seek(fd, offsetof(GCData, flags), FSeekSet);
pfs_write(fd, &gcdata.flags, sizeof(gcdata.flags));
return (fd);
}
static NOINLINE status_t garbage_collect_... |
event with 'BLESubscriptionNone' type and error bubbled up:
prv_assert_subscription_event(characteristic, BLESubscriptionNone, BLEGATTErrorInvalidHandle,
true /* kernel */, false /* app */);
// Verify everything is cleaned up:
fake_kernel_malloc_mark_assert_equal();
}
// ---------------------... | {
// Subscribe app:
BLECharacteristic characteristic = prv_get_indicatable_characteristic();
BTErrno e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
GAPLEClientApp);
cl_assert_equal_i(e, BTErrnoOK);
// Subscribe kernel:
e... |
gatt_client_subscriptions_handle_server_notification(s_connection, s_handle,
value, sizeof(value));
cl_assert_equal_i(fake_event_get_count(), 2);
prv_assert_notification_event(characteristic, value, sizeof(value),
true /* kern... |
(prv_is_selection_last_weekday(graph_card)) {
// The graph starts on Monday, so wrap around the selection and current_day for Sunday
const time_t selection_time =
((positive_modulo(graph_card->selection - Monday, DAYS_PER_WEEK) -
positive_modulo(graph_card->current_day - Monday, DAYS_PER_WEEK)... | (FONT_KEY_GOTHIC_24_BOLD,
FONT_KEY_GOTHIC_18_BOLD) | );
graph_card->legend_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
graph_card->current_day = prv_get_weekday(graph_card->data_timestamp);
// The day characters in standard tm weekday order
graph_card->day_chars = i18n_get("SMTWTFS", graph_card);
graph_card->selection = HealthGraphIndex_Ave... |
//! app_fetch_binaries().
static void prv_app_fetch_binaries_system_task_cb(void *data) {
AppFetchInstallRequest *request = (AppFetchInstallRequest *)data;
// check if Bluetooth is active. If so, this will send.
bool successful = comm_session_send_data(comm_session_get_system_session(), APP_FETCH_ENDPOINT_ID,
... | {
PBL_ASSERT_TASK(PebbleTask_KernelBackground);
prv_cancel_fetch_from_system_task((void *)(uintptr_t)app_id);
} |
void app_fetch_cancel(AppInstallId app_id) {
// Everything within app fetch happens on the background task
system_task_add_callback(prv_cancel_fetch_from_system_task, (void *)(uintptr_t)app_id);
}
bool app_fetch_in_progress(void) {
return s_fetch_state.in_progress;
}
////////////////////////////
// Exported C... |
ge we are logging to
uint32_t offset_in_log_page; // the offset we writing to in a given page
uint32_t log_start_addr; // the starting address of the curr log being written
uint8_t bytes_remaining; // the bytes left to write for the current log
uint8_t log_chunk_id; // the id of the current page being logged... | flash_erase_subsector_blocking(addr) | |
ealthServiceStats weekend_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
HealthServiceStats yesterday_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
DayInWeek day_in_week = todays_day_in_week;
for (int i = 0; i < ACTIVITY_HISTORY_DAYS; i++, day_in_week--) {
day_in_week = positive_modu... | {
// Only test scoped results. Non-scoped results for heart rate are computed using
// minute data and verified in the test_health__heart_rate_scope_once()
cl_assert_equal_i(result, exp_value);
} |
}
}
}
// --------------------------------------------------------------------------------------
// Test calls to compute heart rate stats with scope once. This ends up being implemented using
// the minute history
void test_health__heart_rate_scope_once(void) {
const time_t now = rtc_get_time();
const time... |
c SessionState s_state = SessionState_Idle;
static PebbleMutex* s_lock = NULL;
// Handle requests from apps
static bool s_from_app;
static Uuid s_app_uuid;
static AudioEndpointSessionId s_session_id = AUDIO_ENDPOINT_SESSION_INVALID_ID;
static TimerID s_timeout = TIMER_INVALID_ID;
static void prv_send_event(VoiceEve... | {
PBL_LOG(LOG_LEVEL_WARNING, "Received audio transfer message when no session was in progress ("
"%d)", session_id);
return;
} |
mutex_lock(s_lock);
prv_handle_subsystem_started(SessionState_AudioEndpointSetupReceived);
mutex_unlock(s_lock);
}
static void prv_session_result_timeout(void * data) {
mutex_lock(s_lock);
PBL_ASSERTN(s_state == SessionState_WaitForSessionResult);
prv_reset();
PBL_LOG(LOG_LEVEL_WARNING, "Timeout wait... |
aw_round_rect_offset_r4_aa_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// AA = true, SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 5);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_off... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw3_no_clip.${BIT_DEPTH_NAME}.pbi")) | ;
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 3);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw3_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NX... |
printf(data->status_string, STATUS_STRING_LENGTH, "Test Failed to Start");
app_window_stack_push(&data->status_window, true);
if (data->current_test_step != BTLETestStep_BTStart) {
// A BTLE Test start failed, stop BT Test
const bool success = prv_run_test_step(BTLETestStep_BTEnd, data);
PBL_A... | app_state_get_user_data() | |
------------------------------------
static TimelineItem *prv_create_day_1_insight(time_t notif_time) {
if (activity_prefs_get_health_app_opened_version() != 0) {
// The user already knows about the Health app
return NULL;
}
AttributeList notif_attr_list = {0};
const char *body = i18n_get("Wanna know m... | i18n_free_all(¬if_attr_list) | ;
attribute_list_destroy_list(¬if_attr_list);
attribute_list_destroy_list(&dismiss_action_attr_list);
attribute_list_destroy_list(&open_app_action_attr_list);
return item;
}
// ------------------------------------------------------------------------------------------------
static TimelineItem *prv_create_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... | (RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR)) | ;
dbgserial_newline();
}
void boot_version_write(void) {
if (boot_version_read() == s_bootloader_timestamp) {
return;
}
RTC_WriteBackupRegister(BOOTLOADER_VERSION_REGISTER, s_bootloader_timestamp);
}
uint32_t boot_version_read(void) {
return RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER);
}
|
,
.actions = actions,
}
};
Uuid i2;
uuid_generate(&i2);
TimelineItem e2 = {
.header = {
.id = i2,
.type = TimelineItemTypeNotification,
.status = 0,
.ancs_uid = 1,
.layout = LayoutIdGeneric,
.timestamp = 0x53f0dda6,
},
.attr_list = {
.num_attribut... | notification_storage_find_ancs_notification_by_timestamp(&test, &h) | ,
false);
test = e3;
test.header.id = UUID_INVALID;
cl_assert(notification_storage_find_ancs_notification_by_timestamp(&test, &h));
cl_assert_equal_m(&e3.header, &h, sizeof(CommonTimelineItemHeader));
}
void test_notification_storage__should_detect_corruption(void) {
Uuid i1;
uuid_gene... |
printf("\n") | ;
#endif
cl_assert_equal_s(s_output, s_full_tests[i].expect_str);
cl_assert_equal_i(rv, s_full_tests[i].expect_rv);
cl_assert_equal_i(cond.eval_time, s_full_tests[i].expect_time);
if (cond.eval_time != 0) {
cl_assert_equal_b(cond.force_eval_on_time, true);
} else {
cl_assert_equal_b(con... | |
/*
* 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_timer_register(500, prv_timer_callback, NULL) | ;
}
static void prv_record_als_reading(void) {
AmbientLightAppData *data = app_state_get_user_data();
mfg_info_write_als_result(data->latest_als_value);
}
static void prv_handle_init(void) {
AmbientLightAppData *data = task_zalloc_check(sizeof(AmbientLightAppData));
data->window = window_create();
Layer *... |
h"
#include "applib/ui/layer.h"
#include "clar.h"
#include "util.h"
#include <stdio.h>
// Helper Functions
////////////////////////////////////
#include "test_graphics.h"
#include "${BIT_DEPTH_NAME}/test_framebuffer.h"
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs... | (&ctx, CENTER_OF_ORIGIN_RECT_NXNY, RADIUS_MIN_CALCULATED) | |
/*
* 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... | GRect(10, 40, 30, 0) | |
PBL_LOG(LOG_LEVEL_WARNING, "Failed to read status registers");
return;
}
PBL_LOG(LOG_LEVEL_INFO, "%s: StatusA = 0x%"PRIx8"; StatusB = 0x%"PRIx8, preamble, status_a,
status_b);
}
static void prv_debounce_callback(void* data) {
bool is_connected = pmic_is_usb_connected();
PBL_LOG(LOG_LEVEL_DEBUG, ... | gpio_output_set(&BOARD_CONFIG_POWER.rail_4V5_ctrl, enabled) | ;
}
void set_6V6_power_state(bool enabled) {
PBL_ASSERTN(BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio);
gpio_output_set(&BOARD_CONFIG_POWER.rail_6V6_ctrl, enabled);
}
|
gcolor_component_multiply(j, i) | );
}
}
// A few specific combinations
cl_assert_equal_i(gcolor_component_multiply(3, 3), 3);
cl_assert_equal_i(gcolor_component_multiply(3, 2), 2);
cl_assert_equal_i(gcolor_component_multiply(2, 2), 1);
cl_assert_equal_i(gcolor_component_multiply(1, 3), 1);
cl_assert_equal_i(gcolor_component_multiply... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.