prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
interval boundary (with scan resp):
char scan_resp_data[] = "scan resp data";
BLEAdData *ad_scannable = create_ad(NULL, scan_resp_data);
advert_term.min_interval_slots = 159;
advert_term.max_interval_slots = 159;
job = gap_le_advert_schedule(ad_scannable,
&advert_term, sizeof(ad... | cl_assert_equal_i(regular_timer_seconds_count(), 0) | ;
}
void test_gap_le_advert__continue_after_slave_connection(void) {
BLEAdData *ad = create_ad(NULL, NULL);
GAPLEAdvertisingJobTerm advert_term = {
.min_interval_slots = 160,
.max_interval_slots = 320,
.duration_secs = 10,
};
GAPLEAdvertisingJobRef job;
job = gap_le_advert_schedule(ad, &advert_te... |
ght_b = GPoint(origin.x + width - 1, origin.y + radius + height_actual - 1);
// Draw lines between each transformed corner point
graphics_draw_line(ctx, top_l, top_r); // top
graphics_draw_line(ctx, bottom_l, bottom_r); // bottom
graphics_draw_line(ctx, left_t, left_b); // left
graphics_draw_line(c... | (framebuffer, &framebuffer->size) | ,
.parent_framebuffer = framebuffer,
.parent_framebuffer_vertical_offset = 0,
.lock = false
};
// init the font cache
FontCache *font_cache = &context->font_cache;
memset(font_cache->cache_keys, 0, sizeof(font_cache->cache_keys));
memset(font_cache->cache_data, 0, sizeof(font_cache->cache_data));... |
{
if (s_dialog) {
dialog_pop(s_dialog);
s_dialog = NULL;
}
} | ||
= {
{"Star Wars", NULL, NULL, NULL, DEFAULT_ICON_ALIGN},
{"The Lord of the Rings", "The Fellowship of the Ring", NULL, NULL, DEFAULT_ICON_ALIGN},
{"The Lord of the Rings", NULL, NULL, &s_tictoc_icon_bitmap, DEFAULT_ICON_ALIGN},
{"The Matrix", "Revolutions", NULL, &s_tictoc_icon_bitmap, DEFAULT_ICON_ALIGN},
{... | graphics_context_set_tint_color(&s_ctx, foreground_color) | ;
graphics_context_set_stroke_color(&s_ctx, foreground_color);
Layer cell_layer;
layer_init(&cell_layer, &cell_frame);
cell_layer.is_highlighted = is_selected;
s_cell_is_highlighted = is_selected;
const MenuCellLayerConfig config = {
.title_font = column_data->title_font ? fonts_get_system_font(column... |
read the PPG data. The timing constraints are pretty tight (we need to read this
// within 30ms~ of getting the handshake or else we'll lose PPG data). The other registers can
// be read at anytime before the next handshake, so it's ok to do this first.
prv_read_ppg_data(HRM, &data.ppg_data);
if (should_expec... | {
// get the device info
if (!prv_read_register_block(dev, ADDR_INFO_START, info, sizeof(AS7000InfoRecord))) {
return false;
}
if (log_version) {
// print out the version information
PBL_LOG(LOG_LEVEL_INFO, "AS7000 enabled! Protocol v%" PRIu8 ".%" PRIu8
", SW v%" PRIu8 ".%" PRIu8 ".%" PRIu8 "... |
static bool prv_is_app_running(HRMDevice *dev, AS7000AppId app) {
uint8_t running_apps = 0;
if (!prv_read_register(dev, ADDR_APP_IDS, &running_apps)) {
return false;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Apps running: 0x%"PRIx8, running_apps);
if (app == AS7000AppId_Idle) {
// no apps should be running
re... |
}
// -------- Pebble Protocol Handlers ------------------------------------------------------------ //
static bool prv_has_invalid_header_length(size_t length) {
if (length < sizeof(AppMessageHeader)) {
PBL_LOG(LOG_LEVEL_ERROR, "Too short");
return true;
}
return false;
}
//! The new implementation us... | {
AppMessageCtx *app_message_ctx = app_state_get_app_message_ctx();
app_message_ctx->inbox.received_callback = NULL;
app_message_ctx->inbox.dropped_callback = NULL;
app_message_ctx->inbox.user_context = NULL;
app_message_ctx->outbox.sent_callback = NULL;
app_message_ctx->outbox.failed_callback = NULL;
app... |
static bool prv_supports_8k(void) {
if (!sys_app_pp_has_capability(CommSessionAppMessage8kSupport)) {
return false;
}
const Version app_sdk_version = sys_get_current_app_sdk_version();
const Version sdk_version_8k_messages_enabled = (const Version) { 0x05, 0x3f };
return (version_compare(sdk_version_8k_... |
560},
{ 304, 744, 640},
{ 392, 736, 680},
{ 344, 832, 688},
{ 440, 904, 768},
{ 448, 656, 616},
{ 368, 528, 656},
{ 328, 680, 712},
// 205 seconds
{ 296, 704, 712},
{ 328, 760, 736},
{ 272, 776, 608},
{ 224, 744, 600},
{ 176, 848, 656},
{ 152, 728, 528},
{ 96... | { -288, 936, 264},
{ -344, 896, 408},
{ -360, 744, 472},
{ -352, 832, 448},
{ -320, 816, 472},
{ -304, 688, 504},
{ -296, 792, 528},
{ -296, 704, 504},
{ -304, 704, 568},
{ -288, 792, 488},
{ -320, 728, 544},
{ -328, 696, 520},
{ -344, 776, 528},
{ -344, 760, 504}... |
{ 0, 704, 600},
{ 0, 696, 608},
{ 0, 656, 632},
{ -24, 632, 664},
{ -56, 632, 696},
{ -72, 648, 752},
{ -40, 672, 712},
{ -56, 624, 696},
{ -40, 608, 696},
{ 0, 600, 640},
{ 8, 544, 560},
{ -88, 560, 488},
{ -216, 656, 488},
{ -272, 632, 496},
{ -288, 752, 60... |
_p(s_fill_points, NULL);
prv_reset();
// set stroke color to be transparent and restore fill - fill should be drawn, but no outline
// should be drawn
gdraw_command_set_fill_color(command, GColorRed);
color = gdraw_command_get_stroke_color(command);
color.a = 0;
gdraw_command_set_stroke_color(command, co... | (command_list->commands[0].points, points1, sizeof(points1)) | ;
GContext *ctx = (GContext *)123; // just a fake internal guard != NULL
gdraw_command_list_draw(ctx, command_list);
cl_assert_equal_i(s_path_stroke_count, 1);
cl_assert_equal_i(s_path_fill_count, 1);
cl_assert_equal_i(s_circle_stroke_count, 0);
cl_assert_equal_i(s_circle_fill_count, 0);
prv_reset();
... |
cache if we need to
system_task_add_callback(prv_cleanup_app_cache_if_needed, NULL);
}
unlock:
mutex_unlock_recursive(s_app_cache_mutex);
return rv;
}
//! Tests if an entry with the given AppInstallId is in the cache
bool app_cache_entry_exists(AppInstallId app_id) {
bool exists = false;
mutex_lock_recur... | settings_file_open(&file, APP_CACHE_FILE_NAME, APP_CACHE_MAX_SIZE) | ;
if (rv != S_SUCCESS) {
goto unlock;
}
// set max so that any application will have a lower priority.
AppCacheEachData to_evict = {
.id = INSTALL_ID_INVALID,
.priority = MAX_PRIORITY,
};
settings_file_each(&file, prv_each_min_priority, (void *)&to_evict);
settings_file_c... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | APP_LOG(APP_LOG_LEVEL_INFO, "steps 1st half of today: %d", (int)steps) | ;
steps = health_service_sum(HealthMetricStepCount, day_start - (SECONDS_PER_DAY / 2), day_start);
APP_LOG(APP_LOG_LEVEL_INFO, "steps 2nd half of yesterday: %d", (int)steps);
// Test the get_minute_history call
const int minute_data_len = 10;
HealthMinuteData minute_data[minute_data_len];
ui... |
/*
* 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... | ((Layer *)layout) | ;
if (layout && swap_layer->callbacks.layout_removed_handler) {
swap_layer->callbacks.layout_removed_handler(swap_layer, layout, swap_layer->context);
}
}
//! Calls the fetch layout callback and gets the layout that is at an offset of rel_change from the
//! current index (which is stored and kept track of by... |
/*
* 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... | debug_print_str_and_int("Bytes TX/RXed: ", transferred) | ;
}
// Interesting observation: The INT fires on writes once the data has been drained to the FIFO,
// not when it actually gets drained.
static void prv_write_or_read_bytes(void *byte_buffer, int num_bytes, bool do_write) {
s_expected_bytes_received = false;
if (do_write) {
hw_spi_write_buf(HOST_SPI->sp... |
res = E_OUT_OF_MEMORY;
goto cleanup;
}
file->namelen = strlen(name);
file->start_offset = FILEDATA_LEN + file->namelen;
if (is_tmp || ((res == E_DOES_NOT_EXIST) && ((op_flags & OP_FLAG_WRITE) != 0))) {
res = pfs_open_handle_create_request(fd, file_type, start_size);
} else if ((op_flags & OP_FLA... | (buf, to_copy, base_addr + i) | ;
}
}
}
kernel_free(buf);
return (S_SUCCESS);
}
static void recover_region_from_file(int fd) {
GCData gcdata;
pfs_seek(fd, 0, FSeekSet);
pfs_read(fd, &gcdata, sizeof(gcdata));
if (!GCDATA_VALID(gcdata.flags)) {
// we never completed setting up the migration
goto done;
}
// at th... |
if (session->storage.write_offset != 0) {
if (prv_get_session_file(session, 0)) {
*size_p += prv_pfs_get_file_size(session->storage.fd);
prv_release_session_file(session);
}
} |
return true;
}
// ----------------------------------------------------------------------------------------
// Get total amount of space we have allocated from the file system. This is the sum of the
// file sizes of all the DLS files.
static uint32_t prv_get_total_file_system_bytes(void) {
uint32_t size = 0;
d... | |
bt_ctl_set_airplane_mode_async(!bt_ctl_is_airplane_mode_on()) | ;
}
static const ActionToggleImpl s_airplane_mode_action_toggle_impl = {
.window_name = "Airplane Mode Toggle",
.prompt_icon = RESOURCE_ID_AIRPLANE,
.result_icon = RESOURCE_ID_AIRPLANE,
// Toggling airplane mode involves locks which can block animation, don't animate
.result_icon_static = true,
.prompt_ena... | |
------------------------------------------------------------------------------------
//! Pins alarm in the timeline for the next three days
static void prv_timeline_add_alarm(SettingsFile *file, const Alarm *alarm,
const CronJob *cron, const time_t current_time) {
// If an alarm was... | timeline_event_refresh() | ;
}
}
// ----------------------------------------------------------------------------------------------
//! Scans the all the configured alarms and re-adds them all.
//! @return True if at least one alarm was found
static bool prv_reload_alarms(SettingsFile *file) {
bool alarm_found = false;
s_next_alarm_time =... |
///////////////////////
#include "fake_pbl_malloc.h"
#include "fake_spi_flash.h"
// Stubs
////////////////////////////////////////////////////////////////
#include "stubs_analytics.h"
#include "stubs_events.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_hexdump.h"
#include "stubs_passert.h"
#in... | weather_service_locations_list_destroy(head) | ;
}
void test_weather_service__get_default_location_forecast_from_weather_db_update(void) {
WeatherLocationForecast *forecast = weather_service_create_default_forecast();
// no blob db events were fired during unit test, therefore forecast cache never updated
cl_assert(!forecast);
const int default_location_i... |
ond_line.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_across_y);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_y.${BIT_DEPTH_NAME}.pbi"));
test_gra... | graphics_context_set_text_color(&ctx, GColorBlack) | ;
graphics_draw_text(&ctx, "ajj", &s_font_info, RECT_TEXT_2_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_ajj22.${BIT_DEPTH_NAME}.pbi"));
// Test when clipping/drawing and text bounds are all at (2, 0) - no negative offs... |
l,
.arg1 = "South Korea KCC",
.select_cb = prv_push_kcc_window,
});
}
if (flags->has_mexico_nom_nyce) {
prv_append_certification_menu(cd, &(SystemCertificationMenuItem) {
.draw_cell_fn = prv_draw_regulatory_id_cell,
.arg1 = "IFETEL",
.arg2 = prv_get_mexico_ifetel_id()... | GSize(window_bounds.size.w, fonts_get_font_height(title_text_font)) | ;
const GFont info_text_font = fonts_get_system_font(FONT_KEY_GOTHIC_14);
const GSize info_text_size = GSize(window_bounds.size.w, fonts_get_font_height(info_text_font));
const int16_t vertical_spacing = 3;
GRect certification_rect = (GRect) {
.size = GSize(window_bounds.size.w,
bmp_size.h... |
Rect) { .size = text_size };
const GAlign item_label_text_alignment = GAlignCenter;
grect_align(&text_box, content_box, item_label_text_alignment, true /* clip */);
text_box.origin.y -= fonts_get_font_cap_offset(font);
graphics_draw_text(ctx, item->label, font, text_box, overflow_mode, text_alignment, NULL);
}... | // force it to clip around the shadow.
if (draw_top_shading) {
ctx->draw_state.clip_box.origin.y += VERTICAL_PADDING;
ctx->draw_state.clip_box.size.h -= VERTICAL_PADDING;
}
if (draw_bottom_shading) {
ctx->draw_state.clip_box.size.h -= VERTICAL_PADDING + bottom_inset;
}
// Preve... |
static void prv_draw_row(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index,
void *callback_context) {
ActionMenuLayer *aml = callback_context;
if (cell_index->row < aml->num_items) {
const ActionMenuItem *item = prv_get_item_for_index(aml, cell_index->row);
const bool... |
*nf) {
layer_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) {
... | fonts_get_system_font(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... |
u may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the... | {
s_has_cache = true;
s_get_value = CommSessionInfiniteLogDumping;
bool has_cap =
comm_session_current_app_session_cache_has_capability(CommSessionInfiniteLogDumping);
cl_assert_equal_b(true, has_cap);
cl_assert_equal_b(true, s_get_called);
cl_assert_equal_b(true, s_close_called);
} |
void test_app_session_capabilities__cache_file_but_no_key_and_not_connected(void) {
bool has_cap =
comm_session_current_app_session_cache_has_capability(CommSessionInfiniteLogDumping);
cl_assert_equal_b(false, has_cap);
cl_assert_equal_b(true, s_get_called);
cl_assert_equal_b(true, s_close_called);
}
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... | PBL_ASSERTN_LR(0, lr) | ;
}
NORETURN os_assertion_failed_lr(const char *filename, int line, uint32_t lr) {
PBL_ASSERTN_LR(0, lr);
}
void *os_malloc(size_t size) {
return kernel_malloc(size);
}
void *os_malloc_check(size_t size) {
return kernel_malloc_check(size);
}
void os_free(void *ptr) {
kernel_free(ptr);
}
|
cal_line_dotted(&ctx, GPoint(12, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 7), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(24, 7), 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted... | GPoint(41, 11) | |
(&start_tm) | ;
rtc_set_time(utc_sec);
// Add a Sleep session
const time_t time_elapsed = (120 * SECONDS_PER_MINUTE);
ActivitySession sleep_session = {
.start_utc = utc_sec - time_elapsed,
.length_min = time_elapsed,
.type = ActivitySessionType_Sleep,
.ongoing = true,
};
activity_sessions_prv_add_activit... | |
dbgserial_print("Checksum - wanted ");
dbgserial_print_hex(firmware_description->checksum);
dbgserial_print(" got ");
dbgserial_print_hex(calculated_crc);
dbgserial_newline();
return calculated_crc == firmware_description->checksum;
}
typedef enum UpdateFirmwareResult {
UPDATE_FW_SUCCESS = 0,
UPDATE_FW_... | boot_bit_set(BOOT_BIT_RECOVERY_START_IN_PROGRESS) | ;
break;
case UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED:
case UPDATE_FW_ERROR_MICRO_FLASH_MANGLED:
// Keep us booting into recovery firmware.
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
if (!boot_bit_test(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE))... |
test_message_handler, test_dropped_handler);
cl_assert(result != NULL);
cl_assert_equal_b(true, app_inbox_service_has_inbox_for_tag(AppInboxServiceTagUnitTest));
}
void test_app_inbox__app_inbox_create_and_register_kernel_oom(void) {
fake_kernel_malloc_set_largest_free_block(0);
vo... | app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer) | );
cl_assert_equal_b(true, app_inbox_service_is_being_written_for_tag(AppInboxServiceTagUnitTest));
cl_assert_equal_i(1, app_inbox_service_num_failed_for_tag(AppInboxServiceTagUnitTest));
}
void test_app_inbox__app_inbox_service_begin_not_enough_storage_space(void) {
prv_create_test_inbox();
cl_assert_equal_b(... |
},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 56, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 0, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
... | { 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 56, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 0, -1000},
{ 48, 8, -1000},
{... | |
RD), &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_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;
s_data.metric_history[ActivityMetricSleepState][0] = A... |
he end address of the object's section in flash (exclusive)
uint32_t end_address;
//! An optional offset from the beginning of the object's section in flash. This is useful if
//! you need to insert some derived metadata after the object has been written to flash.
uint32_t start_offset;
} MemoryLayout;
static... | if (previous_system_task_watchdog_state) {
task_watchdog_mask_clear(PebbleTask_KernelBackground);
} |
if (append_offset == 0) {
// By erasing the entire region we make it more likely for 'pb_storage_raw_get_status' to
// recover the correct location.
flash_region_erase_optimal_range(layout->start_address, layout->start_address,
layout->end_address, layout->end_address);
} else {
// Some da... |
ints = 3,
};
GPoint points2[] = { { 6, 7 }, {5, 5}, { 0, 0 } };
memcpy(command->points, points2, sizeof(points2));
return command_list;
}
void test_gdraw_command__draw_command_list(void) {
GDrawCommandList *command_list = malloc(sizeof(GDrawCommandList) + sizeof(GDrawCommand) +
(sizeof(GPoint) * 2));
... | (image, size) | );
free(image);
}
void test_gdraw_command__clone_image(void) {
cl_assert_equal_p(gdraw_command_image_clone(NULL), NULL);
size_t size = sizeof(GDrawCommandImage) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6);
GDrawCommandImage *image = malloc(size);
memset(image, 0, size);
GDrawCom... |
ped_handler);
PBL_ASSERTN(s_session_id != AUDIO_ENDPOINT_SESSION_INVALID_ID);
PBL_LOG(LOG_LEVEL_INFO, "Send session setup message. Session type: %d", session_type);
voice_endpoint_setup_session(session_type, s_session_id, &transfer_info,
s_from_app ? &s_app_uuid : NULL);
if (s_timeout == TIMER_INVALID_... | {
size_t *size = data;
*size += word->length + sizeof(char); // add 1 for space or null terminator
return true;
} |
static bool prv_build_string_cb(const TranscriptionWord *word, void *data) {
char *sentence = data;
// if the current word is a punctuation mark strip out backspace (phone app inserts backspace
// before punctuation mark) and do not insert a space before the word
if (word->data[0] == '\x08') {
strncat(se... |
ion_open(transport, &s_transport_imp,
TransportDestinationSystem);
cl_assert_equal_b(comm_session_is_valid(session), true);
fake_session_send_queue_set_length(1234);
cl_assert_equal_i(fake_system_task_count_callbacks(), 0);
comm_session_send_next(session);
cl_assert... | (s_reset_count, 1) | ;
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
}
void test_session__reset_invalid_session(void) {
CommSession *invalid_session = (CommSession *) TransportID1;
cl_assert_equal_b(comm_session_is_valid(invalid_session), false);
cl_assert_equal_i(s_reset_count, 0);
comm_session_r... |
sert_equal_i(l.flow_data.paging.origin_on_screen.y, 2);
cl_assert_equal_i(l.flow_data.paging.page_on_screen.origin_y, 4);
cl_assert_equal_i(l.flow_data.paging.page_on_screen.size_h, 6);
}
void test_text_layout__disable_text_flow(void) {
TextLayoutExtended l = {.flow_data.perimeter.impl = (const GPerimeter *)(123... | if (!process_manager_compiled_with_legacy2_sdk()) {
graphics_text_layout_set_line_spacing_delta((void*)&layout, FONT_LINE_DELTA - 1);
cl_assert_equal_i(graphics_text_layout_get_line_spacing_delta((void*)&layout), (FONT_LINE_DELTA - 1));
cl_assert_equal_i(layout.max_used_size.h, 3 * (FONT_HEIGHT + FONT_LINE_... |
graphics_text_layout_get_max_used_size(&gcontext, "JR Whopper 123", font, box, GTextOverflowModeWordWrap, GTextAlignmentLeft, (void*)&layout);
cl_assert(layout.hash != 0);
cl_assert_equal_i(layout.max_used_size.w, 4 * HORIZ_ADVANCE_PX);
if (!process_manager_compiled_with_legacy2_sdk()) {
// 3 lines - but n... |
/*
* 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... | (true /* watchface_is_dest */) | |
120, 48},
{ 1064, 136, 72},
{ 936, 160, 56},
{ 872, 168, 40},
{ 816, 104, 88},
{ 800, 64, 120},
{ 800, 56, 128},
{ 784, 120, 64},
{ 848, 128, 64},
{ 888, 168, 96},
{ 968, 152, 80},
{ 928, 152, -24},
{ 1280, 160, 80},
{ 1136, 160, 24},
{ 968, 216, -120},
{ 856... | ARRAY_LENGTH(samples) | ;
return samples;
}
|
_horizontal_line_dotted(&ctx, GPoint(45, 75), 5);
// T facing right - odd vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(71, 71), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(66, 76), 5);
// T facing left - even vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(100,... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(10, 96), 5) | ;
// T facing right - even vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(50, 90), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(46, 95), 5);
// T facing right - odd vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(71, 91), 10);
graphics_draw_horizontal_line_dotte... |
alue("event");
cl_assert_equal_b(true, jerry_value_is_null(event_null));
jerry_release_value(event_null);
Layer *l = &app_window_stack_get_top_window()->layer;
l->update_proc(l, NULL);
const jerry_value_t event = prv_js_global_get_value("event");
cl_assert_equal_b(true, jerry_value_is_object(event));
co... | (PP(29.5, 39.5), lc->fill_radial_precise.center) | ;
cl_assert_equal_i(10*8, lc->fill_radial_precise.radius_inner.raw_value);
cl_assert_equal_i(30*8, lc->fill_radial_precise.radius_outer.raw_value);
cl_assert_equal_i(TRIG_MAX_ANGLE * 1 / 4, lc->fill_radial_precise.angle_start);
cl_assert_equal_i(TRIG_MAX_ANGLE * 5 / 4, lc->fill_radial_precise.angle_end);
EXE... |
mode, generate a core dump so we can get debugging information
#ifdef WORKER_CRASH_CAUSES_RESET
kernel_fault(RebootReasonCode_WorkerHardFault, stashed_lr);
#endif
} else {
PBL_LOG_FROM_FAULT_HANDLER("WTF?");
kernel_fault(RebootReasonCode_HardFault, stashed_lr);
}
process_manager_put_kill_process_eve... | kernel_fault(RebootReasonCode_HardFault, stacked_lr) | ;
return;
}
// We got this! Let's redirect this task to a spin function and tell the app manager to kill us.
prv_return_to_landing_zone(stacked_pc, stacked_lr, stacked_args); // We can't get LR or PC, so just set to 0's.
}
// Hardware Fault Handlers
///////////////////////////////////////////////////////... |
_lock.h"
#include "stubs_events.h"
#include "stubs_hexdump.h"
#include "stubs_layout_layer.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_regular_timer.h"
#include "stubs_reminder_db.h"... | pin_db_insert_item(&reminder_app_item) | ;
cl_assert_equal_i(pin_db_is_dirty(&is_dirty), S_SUCCESS);
cl_assert(is_dirty);
dirty_list = pin_db_get_dirty_list();
cl_assert(dirty_list);
cl_assert(list_count((ListNode *)dirty_list) == 1);
// Mark the reminder item as synced
pin_db_mark_synced((uint8_t *)&reminder_app_item.header.id, sizeof(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... | {
// Increment the selected attribute
AppData *data = window_get_user_data(s_window);
switch (data->selection) {
case ATTRIBUTE_HUE:
if (data->hue <= 0) {
data->hue = HUE_COUNT - 1;
} else {
--data->hue;
}
break;
case ATTRIBUTE_PIXEL_BIT:
if (data->pixel_bit <... |
static void down_handler(ClickRecognizerRef recognizer, void *context) {
// Decrement the selected attribute
AppData *data = window_get_user_data(s_window);
GRect bounds = data->canvas_layer->bounds;
switch (data->selection) {
case ATTRIBUTE_HUE:
++data->hue;
if (data->hue >= HUE_COUNT) {
... |
equal_i(window_stack_count(app_stack), 0);
window_destroy(window1);
window_destroy(window2);
}
// Description:
// This test ensures that the flow of adding a window to the window stack is followed
// correctly. That is, we add the window to the window stack, its load handler is
// called, it calls to set the cli... | window_set_window_handlers(window, &(WindowHandlers){
.load = prv_pop_window_load,
.unload = prv_window_unload
}) | |
ipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerTopRight},
.full_quadrants = GCornersRight,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(180),GCornerBottomLeft}
}));
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(180), TO_TRIG(360)), ((EllipsisDrawConfig){
... | (TO_TRIG(360 + 45), TO_TRIG(360 + 270 + 45)) | |
KinoReelProcessor *processor) {
KinoReel *reel = prv_get_current_reel(data);
GDrawCommandList *source_list = kino_reel_get_gdraw_command_list(reel);
GDrawCommandList *list = prv_get_or_create_list_copy(data, source_list);
offset = gpoint_to_local_coordinates(GPointZero, ctx);
if (!list) ... | kino_reel_destroy(data->to_reel) | ;
}
data->to_reel = to_reel;
data->owns_to_reel = take_ownership;
prv_free_list_copy(data);
}
KinoReel *kino_reel_transform_get_to_reel(KinoReel *reel) {
KinoReelTransformData *data = kino_reel_custom_get_data(reel);
if (data) {
return data->to_reel;
}
return NULL;
}
void kino_reel_transform_set_l... |
d in the mean time
return;
}
// Flip the flag before the send_next callback, so it can schedule again if needed.
session->is_send_next_call_pending = false;
// Kick the transport to send out the next bytes from the send buffer
const size_t read_space = comm_session_send_queue_get_length(session);
if (r... | if (state == ResponseTimeMax) {
s_responsiveness_latency_is_reduced = false;
} |
s_last_responsiveness_granted_handler = granted_handler;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Session related functions
ResponsivenessGrantedHandler fake_comm_session_get_last_responsiveness_granted_handler(void) {
return s_last_responsiveness... |
ense for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/bluetooth/ble_ad_parse.h"
#include "system/hexdump.h"
#include "clar.h"
#include <btutil/bt_uuid.h>
// Stubs
///////////////////////////////////////////////////////////
#include "stubs_ble_syscalls.h"
#... | bt_uuid_expand_16bit(0xabcd) | |
bool is_selected = menu_index_compare(cell_index, &selected_index) == 0;
return is_selected ? MENU_CELL_ROUND_FOCUSED_SHORT_CELL_HEIGHT :
MENU_CELL_ROUND_UNFOCUSED_TALL_CELL_HEIGHT;
#else
return menu_cell_basic_cell_height();
#endif
}
static void prv_draw_row(GContext *ctx, const Layer *cel... | window_stack_push(window_stack, window, true) | ;
}
|
success, uint32_t length) {
const FrameHeader *header = mbuf_get_data(s_read_mbuf);
mbuf_free(s_read_mbuf);
s_read_mbuf = NULL;
const uint32_t data_length = length - sizeof(FrameHeader);
if (!success ||
(length < sizeof(FrameHeader)) ||
(data_length > MAX_DATA_LENGTH) ||
(header->type != s_... | (LOG_LEVEL_DEBUG, "Smartstrap detected - attempting to connect.") | ;
s_last_connection_request_time = current_time;
smartstrap_link_control_connect();
}
return true;
} else if (smartstrap_connection_get_time_since_valid_data() > STATUS_CHECK_INTERVAL) {
if (current_time > s_last_status_check_time + MIN_STATUS_REQUEST_INTERVAL) {
// send a status message... |
critical -> good
*/
typedef enum {
PowerStateGood,
PowerStateLowPower,
PowerStateCritical,
PowerStateStandby
} PowerStateID;
extern PowerStateID s_power_state;
void test_battery_monitor__transitions(void) {
int good_mv = battery_curve_lookup_voltage_by_percent(100, false);
int low_mv = battery_curve_lookup... | periodic_timer_trigger(5) | |
/*
* 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... | {
stub_new_timer_fire(connection->gatt_service_changed_indication_timer);
} |
fake_system_task_callbacks_invoke_pending();
}
#define prv_expect_service_changed_indication_api_call_count(expected_count) \
{ \
prv_process_pending_callbacks(s_connection); \
cl_assert_equal_i(fake_gatt_get_service_changed_indication_count(), expected_count); \
}
// Tests
////////////////////////////////////... |
roc(&layer, &draw_text_single_line_ellipsis_clip_across_y);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_y.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_cl... | (&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_outside_y.${BIT_DEPTH_NAME}.pbi") | );
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_outside_nx);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_outside_nx.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb... |
/*
* 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... | (&layer, &GRect(0, 0, 32, 24)) | ;
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"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
la... |
/*
* 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... | gbitmap_get_format(bitmap) | , GBitmapFormat1BitPalette);
}
// Tests 2-bit palettized PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_2_bit(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(2bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(2bitpalette)));
cl_assert... |
-------------------------------------------------------------------------------------------
static time_t prv_build_cron(AlarmConfig *config, CronJob *cron) {
*cron = (CronJob) {
.cb = prv_cron_callback,
.cb_data = (void*)0,
.minute = config->minute,
.hour = config->hour,
.mday = CRON_MDAY_ANY,
... | {
new_timer_stop(s_snooze_timer_id);
} | |
index of the service
Uuid uuid; // UUID
} EventPluginUUIDEntry;
static uint16_t s_next_service_index = 0;
static ListNode s_plugin_list;
// This mutex guards the s_plugin_list linked list
static PebbleMutex *s_plugin_list_mutex = NULL;
// There's an event service for each event so ... | {
const PebbleTaskBitset task_bit = (1 << task);
return (e->task_mask & task_bit);
} |
static bool prv_steal_buffer(void *buf, EventServiceEntry *service, PebbleEvent *e) {
uint16_t intents_pending = 0;
for (int i = 0; i < NumPebbleTask; i++) {
if (!prv_task_is_masked_out(e, i) && service->subscribers[i]) {
const PebbleTaskBitset task_bit = (1 << i);
intents_pending |= task_bit;
... |
_button.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/modals/modal_manager.h"
#include "services/normal/timeline/timeline.h"
#include <stdint.h>
void timeline_pin_window_set_item(TimelinePinWindow *pin_window, TimelineItem *item,
... | WINDOW_NAME("Pin") | );
window_set_user_data(window, pin_window);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_pin_window_load,
.unload = prv_pin_window_unload,
});
TimelineItemLayer *layer = &pin_window->item_detail_layer;
GRect frame = window->layer.bounds;
frame.origin.y += STATUS_BAR_LAYER_HEI... |
"standby.h"
#include "system/bootbits.h"
#include "system/reset.h"
#include "util/delay.h"
#include "stm32f2xx.h"
static const uint8_t SELECT_BUTTON_MASK = 0x4;
bool firmware_is_new_world(void* base) {
uint32_t* fw_base = base;
if (fw_base == NULL) {
fw_base = (uint32_t*)FIRMWARE_NEWWORLD_BASE;
}
if (fw_... | ("Booting firmware @ ") | |
ication(time_t notif_time, ActivitySession *session,
Uuid *pin_uuid) {
const int hours = session->length_min / MINUTES_PER_HOUR;
const int minutes = session->length_min % MINUTES_PER_HOUR;
// Enough to fit the filled out format string below and i18n variants
const ... | (ActivityMetricSleepState, 1, &sleep_state) | |
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 on an... | prv_fixed_s3_from_double(val) | ;
return true;
default:
WTF;
return false;
}
}
static bool prv_assign_bool(const RockyArgBinding *binding, const jerry_value_t argv[],
RockyArgValueCheckError *value_error_out) {
*((bool *)binding->ptr) = jerry_value_to_boolean(argv[0]);
return true;
}
static vo... |
/*
* 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... | {
kernel_free(request);
} |
kernel_free(resp);
return rv;
}
void bt_driver_advert_advertising_disable(void) {
HcProtocolMessage request = {
.message_length = sizeof(request),
.endpoint_id = HcEndpointID_Advert,
.command_id = HcMessageID_Advert_Disable,
};
HcProtocolMessage *resp = hc_protocol_enqueue_and_expect(&request);
... |
mutex_create() | ;
device_information_service_init(&config->dis_info);
pebble_pairing_service_init();
hrm_service_init(config->is_hrm_supported_and_enabled);
ppogatt_service_init();
}
static void prv_gatt_local_services_register(void) {
device_information_service_register(DEVICE_INFORMATION_SERVICE_EXPECTED_ATT_STARTING_HAND... | |
48, 144, -912},
{ 56, 128, -928},
{ 56, 136, -912},
{ 56, 176, -912},
{ 56, 152, -928},
{ 56, 160, -936},
{ 64, 152, -912},
// 169 seconds
{ 56, 152, -920},
{ 48, 160, -928},
{ 48, 136, -912},
{ 48, 136, -920},
{ 56, 152, -920},
{ 48, 128, -912},
{ 40, 152, -912}... | { 40, 144, -912},
{ 48, 168, -912},
{ 48, 144, -912},
{ 40, 160, -928},
{ 40, 144, -912},
{ 40, 152, -912},
{ 48, 152, -920},
{ 48, 152, -912},
{ 48, 160, -920},
{ 48, 168, -920},
{ 48, 160, -912},
{ 48, 152, -920},
// 175 seconds
{ 40, 160, -920},
{ 40, 160, ... |
{ 40, 152, -904},
{ 40, 216, -936},
{ 32, 160, -912},
{ 40, 136, -912},
{ 48, 216, -920},
{ 32, 168, -920},
{ 40, 168, -896},
{ 40, 160, -912},
{ 32, 176, -912},
{ 56, 256, -912},
{ 32, 112, -904},
{ 32, 112, -904},
{ 48, 192, -920},
{ 40, 136, -904},
{ 40, 1... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
SessionSendQueueJob *job = session->send_queue_head;
while (job) {
SessionSendQueueJob *next = (SessionSendQueueJob *) job->node.next;
job->impl->free(job);
job = next;
}
session->send_queue_head = NULL;
} | |
/*
* 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... | (action_bar, i, false) | ;
}
}
}
static void action_bar_legacy2_update_proc(ActionBarLayerLegacy2 *action_bar, GContext* ctx) {
const GColor bg_color = get_native_color(action_bar->background_color);
graphics_context_set_fill_color(ctx, bg_color);
const uint8_t radius = 3;
const uint8_t margin = 1;
graphics_fill_round_rect(ctx... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | mutex_lock(mutex_1) | ;
mutex_lock(mutex_2);
cl_assert_equal_b(fake_mutex_all_unlocked(), false);
mutex_unlock(mutex_2);
cl_assert_equal_b(fake_mutex_all_unlocked(), false);
mutex_unlock(mutex_1);
cl_assert_equal_b(fake_mutex_all_unlocked(), true);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return EXTI15_10_IRQn;
} |
if (exti_line == ExtiLineOther_RTCAlarm) {
return RTC_Alarm_IRQn;
}
if (exti_line == ExtiLineOther_RTCWakeup) {
return RTC_WKUP_IRQn;
}
WTF;
}
static void prv_configure_nvic_channel(IRQn_Type irqn) {
NVIC_SetPriority(irqn, EXTI_PRIORITY);
NVIC_EnableIRQ(irqn);
}
static void prv_check_nvic_chann... |
/*
* 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... | {
flash_erase_subsector_blocking(FLASH_REGION_MFG_INFO_BEGIN);
flash_write_bytes((const uint8_t*) data, FLASH_REGION_MFG_INFO_BEGIN, sizeof(*data));
} | |
n_setup_timeout)
VoiceSessionId voice_start_dictation(VoiceEndpointSessionType session_type) {
mutex_lock(s_lock);
if (s_state != SessionState_Idle) {
mutex_unlock(s_lock);
return VOICE_SESSION_ID_INVALID;
}
s_state = SessionState_StartSession;
// check if we're being started from an app so we know ... | (LOG_LEVEL_WARNING, "Session setup result for invalid session type received") | ;
goto done;
}
if (result != VoiceEndpointResultSuccess) {
prv_cancel_session();
VoiceStatus status = prv_get_status_from_result(result);
PBL_LOG(LOG_LEVEL_WARNING, "Error occurred setting up session: %d", result);
prv_send_event(VoiceEventTypeSessionSetup, status, NULL);
goto done;
}
... |
));
}
static bool prv_check_force_boot_recovery(void) {
if (boot_bit_test(BOOT_BIT_FORCE_PRF)) {
boot_bit_clear(BOOT_BIT_FORCE_PRF);
return true;
}
if (prv_prf_button_combination_is_pressed()) {
dbgserial_putstr("Hold down UP + BACK + SELECT for 5 secs. to force-boot PRF");
for (int i = 0; i < 5... | prv_check_for_recovery_start_failure() | ) {
boot_bit_clear(BOOT_BIT_RECOVERY_START_IN_PROGRESS);
prv_sad_watch(ERROR_CANT_LOAD_FW);
}
bool force_boot_recovery_mode = prv_check_force_boot_recovery();
if (force_boot_recovery_mode) {
dbgserial_putstr("Force-booting recovery mode...");
}
if (force_boot_recovery_mode || prv_check_for_fw_st... |
// Simple write register command with no error handling
static bool prv_write_register(uint8_t register_address, uint8_t value) {
return i2c_write_register(I2C_LIS3DH, register_address, value);
}
static void prv_clear_fifo(void) {
// Use I2C calls instead of accel wrappers to avoid recursion (reset called from l... | PBL_LOG(LOG_LEVEL_ERROR, "Failed to enter low power mode") | ;
}
bool accel_running(void) {
return (s_running);
}
bool accel_start(void) {
if (!s_initialized) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to start accel, not yet initialized");
return false;
}
if (s_running) {
return true; // Already running
}
i2c_use(I2C_LIS3DH);
s_running = true;
return t... |
(action_menu) | ;
}
for (int i = 0; i < num_notifications; i++) {
TimelineItem item;
if (notif_list[i].type == NotificationReminder) {
if (reminder_db_read_item(&item, ¬if_list[i].id) != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_ERROR, "Trying to dismiss all an invalid reminder");
continue;
}
} els... | |
d->layer.bounds;
const GRect info_text_box = {{ offset_x, info_offset_y }, { bounds->size.w, info_height }};
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, text, graph_card->legend_font, info_text_box,
GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
}
static... | (buffer, 0, sizeof(buffer)) | ;
if (graph_card->info_update) {
const int32_t day_point = prv_get_info_data_point(graph_card);
graph_card->info_update(graph_card, day_point, buffer, sizeof(buffer));
}
if (IS_EMPTY_STRING(buffer)) {
return;
}
prv_draw_info_with_text(graph_card, ctx, buffer);
}
static void prv_health_graph_layer... |
("var is_called = false; _rocky.on('a', function(e) { is_called = true; });") | ;
jerry_value_t a_event = rocky_global_create_event("a");
rocky_global_call_event_handlers_async(a_event);
ASSERT_JS_GLOBAL_EQUALS_B("is_called", false);
s_process_manager_callback(s_process_manager_callback_data);
ASSERT_JS_GLOBAL_EQUALS_B("is_called", true);
}
| |
ons
////////////////////////////////////
#include "test_graphics.h"
#include "${BIT_DEPTH_NAME}/test_framebuffer.h"
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
static FrameBuffer *fb = NULL;
// Setup
void test_graphics_draw_rect_${BIT_DEPTH_NAME... | (&ctx, fb) | |
const uint8_t *payload_end,
const uint8_t *buffer,
const uint8_t *buf_end) {
SerializedAddressHeader *serialized_address = (SerializedAddressHeader *)*cursor;
*cursor += sizeof(SerializedA... | ((TimelineItemActionGroup *)group_ptr) | ;
} else {
size += prv_get_serialized_address_list_size((AddressList *)group_ptr);
}
}
return size;
}
// -----------------------------------------------------------------------------
static AttributeList *prv_serialize_action(TimelineItemAction *action,
uint... |
ype_malloc(MenuLayer);
if (layer) {
menu_layer_init(layer, &frame);
}
return layer;
}
void menu_layer_pad_bottom_enable(MenuLayer *menu_layer, bool enable) {
menu_layer->pad_bottom = enable;
}
void menu_layer_deinit(MenuLayer *menu_layer) {
prv_cancel_selection_animation(menu_layer);
layer_deinit(&men... | {
menu_layer_set_callbacks(menu_layer, callback_context, &callbacks);
} |
void menu_layer_set_click_config_onto_window(MenuLayer *menu_layer, struct Window *window) {
// Delegate this directly to the scroll layer:
scroll_layer_set_click_config_onto_window(&menu_layer->scroll_layer, window);
}
//! @returns 0 if A and B are equal, 1 if A has a higher section & row combination than B or ... |
{
return;
}
if (item_layer->animation
&& animation_is_scheduled(property_animation_get_animation(item_layer->animation))) {
// Don't do anything if we're already animating to this position from our current position
int16_t offset;
property_animation_get_to_int16(item_layer->animation, &offset... | (item_layer, min_scroll, true) | ;
#if PBL_RECT // fudge breaks ROUND display paging
} else if (current_scroll - (SCROLL_AMOUNT + SCROLL_FUDGE_AMOUNT) < first_scroll) {
prv_update_scroll_offset(item_layer, first_scroll, false);
#endif
} else {
prv_update_scroll_offset(item_layer, current_scroll - SCROLL_AMOUNT, false);
}
layer_mark_di... |
ineLayer *timeline_layer, GColor color) {
timeline_layer->sidebar_color = color;
}
void timeline_layer_set_sidebar_width(TimelineLayer *timeline_layer, int16_t width) {
timeline_layer->sidebar_width = width;
}
static void prv_sidebar_setter(void *context, int16_t value) {
TimelineLayer *timeline_layer = context... | layer_set_hidden((Layer *)&layer->end_of_timeline, hidden) | ;
}
void timeline_layer_init(TimelineLayer *layer, const GRect *frame_ref,
TimelineScrollDirection scroll_direction) {
*layer = (TimelineLayer) {};
// timeline layer
layer_init(&layer->layer, frame_ref);
layer_set_clips(&layer->layer, false);
layer_set_update_proc(&layer->layer, prv_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
Window *window = &pin_window->window;
// delay window unload until the end of the animation
window_set_window_handlers(window, &(WindowHandlers) {});
window_stack_remove(window, false);
// animate the pop by using the new top most window
Window *other_window = app_window_stack_get_top_window();
layer_... |
void timeline_pin_window_init(TimelinePinWindow *pin_window, TimelineItem *item,
time_t current_day) {
if (pin_window->pop_animation) {
animation_unschedule(pin_window->pop_animation);
}
Window *window = &pin_window->window;
window_init(window, WINDOW_NAME("Pin"));
window_... |
mock));
}
// Validate the arguments based on the shape that is drawn
static bool validate_args(ArgsForMock *actual_args, ArgsForMock *valid_args) {
if (memcmp(actual_args, valid_args, sizeof(ArgsForMock)) == 0) {
return true;
}
return false;
}
// This macro will call the expected code_block and then valida... | graphics_context_set_fill_color(&context, color) | |
{ 1112, 344, -152},
// 44 seconds
{ 1776, 328, 48},
{ 1400, 368, 152},
{ 1112, 232, 112},
{ 1168, 152, 192},
{ 1272, 32, 264},
{ 1000, -8, 280},
{ 832, 40, 144},
{ 824, 48, 128},
{ 816, 8, 64},
{ 832, -72, 64},
{ 984, -112, 104},
{ 1144, -136, 64},
{ 1032, -64... |
{ 1288, 16, 96},
{ 1376, 104, 72},
{ 1224, 264, 216},
{ 1048, 344, 208},
{ 952, 384, 240},
{ 920, 280, 192},
{ 840, 232, 112},
// 47 seconds
{ 880, 328, -48},
{ 968, 336, -88},
{ 1160, 384, -152},
{ 1200, 296, -40},
{ 1816, 312, -24},
{ 1368, 320, 160},
{ 119... | |
fn[20];
snprintf(fn, sizeof(fn), "tos_%06d.png", t);
tests_write_gbitmap_to_pbi(&ctx.dest_bitmap, fn);
free(img);
t += dt;
}
}
int16_t prv_int_scale_and_translate_to(
int16_t value, int16_t size, int16_t from_range, int16_t to_range,
int16_t from_min, int16_t to_min, int32_t normalized, Inter... | weather_app_resource_create_cloud() | ;
GPointIndexLookup *index_lookup = gdraw_command_list_create_index_lookup_by_distance(
gdraw_command_image_get_command_list(img), GPoint(s / 2, s));
free(img);
Fixed_S32_16 f = Fixed_S32_16(FIXED_S32_16_ONE.raw_value / 8);
while (t <= ANIMATION_NORMALIZED_MAX) {
graphics_context_set_fill_color(&ctx,... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (bounds.origin, offset) | ;
// Save compositing mode
GCompOp prev_compositing_mode = ctx->draw_state.compositing_mode;
GCompOp op = (bitmap_reel->bitmap->info.format == GBitmapFormat1Bit)
? GCompOpAssign
: GCompOpSet;
graphics_context_set_compositing_mode(ctx, op);
graphics_draw_bitmap_in_rect_processe... |
e_yield_cb);
fake_event_clear_last();
gatt_client_subscriptions_handle_server_notification(s_connection, s_handle,
value, 1 /* one byte */);
// Data will be dropped, no event :(
prv_assert_no_event();
// Receive another GATT notification. Won't fit until... | cl_assert_equal_i(header.value_length, 0) | ;
cl_assert_equal_i(header.characteristic, BLE_CHARACTERISTIC_INVALID);
cl_assert_equal_b(has_more, false);
BLECharacteristic characteristic_out = ~0;
uint8_t value = 0xff;
value_length = sizeof(value);
gatt_client_subscriptions_consume_notification(&characteristic_out, &value, &value_length,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_context_get_current_context() | ;
const GSize current_framebuffer_size = graphics_context_get_framebuffer_size(ctx);
layer_init(&status_bar_layer->layer, &GRect(0, 0, current_framebuffer_size.w, prv_height()));
status_bar_layer->layer.update_proc = prv_status_bar_layer_render;
status_bar_layer->layer.property_changed_proc = prv_status_bar_pr... |
ll disabled due to low-power or factory-reset");
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Force killing app.");
app_manager_force_quit_to_launcher();
}
static void back_button_force_quit_handler(void *data) {
launcher_task_add_callback(launcher_force_quit_app, NULL);
}
static void launcher_handle_button_event... | if (!app_install_is_worker_running(e->launch_app.id)) {
process_manager_launch_process(&(ProcessLaunchConfig) {
.id = e->launch_app.id,
.common = NULL_SAFE_FIELD_ACCESS(e->launch_app.data, common, (LaunchConfigCommon) {}),
.worker = true,
});
} | |
t_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NULL,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
}
void test_graphics_draw_text_8bit__color(void) {
GContext ctx;
... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_data_row_offsets.8bit.pbi") | );
}
|
+ (i * WAKEUP_EVENT_WINDOW), 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + (i * WAKEUP_EVENT_WINDOW));
}
// Test that the 9th wakeup event fails to schedule (E_DOES_NOT_EXIST)
wakeup_id = sys_wakeup_schedule(sys_get_time() + ((MAX_WAKEUP_EVENTS_PER_APP + 1) * WAKEUP_EVENT_WINDOW... | (sys_wakeup_query(third_wakeup_id), third_event) | ;
// Schedule another in the future
time_t fourth_event = sys_get_time() + WAKEUP_EVENT_WINDOW * 4;
WakeupId fourth_wakeup_id = sys_wakeup_schedule(fourth_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(fourth_wakeup_id), fourth_event);
// Jump to the future right before the 3rd event
rtc_set_time(sy... |
bool icon_is_default;
} LoadedNotificationNode;
typedef struct NotificationNode {
ListNode node;
Uuid id;
} NotificationNode;
typedef struct NotificationsData {
Window window;
MenuLayer menu_layer;
TextLayer text_layer;
NotificationNode *notification_list;
LoadedNotificationNode *loaded_notification_... | list_get_tail(
(ListNode*) *loaded_list) | ;
list_remove((ListNode*) old_node, (ListNode**) loaded_list, NULL);
prv_unload_loaded_notification(old_node);
}
// load the notification
TimelineItem notification;
if (!notification_storage_get(&node->id, ¬ification)) {
return NULL;
}
// track the loaded notification
loaded_node = app_ma... |
o_reel_duration = kino_reel_get_duration(player->reel);
bool is_reel_infinite = (kino_reel_duration == PLAY_DURATION_INFINITE);
bool is_animation_reversed = animation_get_reverse(animation);
bool is_animation_infinite =
(animation_get_duration(animation, false, false) == PLAY_DURATION_INFINITE);
if (!is_an... | (player->reel, from_elapsed_ms) | ;
prv_create_play_animation(player, from_elapsed_ms, to_elapsed_ms);
animation_schedule(player->animation);
}
}
ImmutableAnimation *kino_player_create_play_animation(KinoPlayer *player) {
if (player && player->reel) {
const uint32_t from_value = kino_reel_get_elapsed(player->reel);
const uint32_t t... |
... ......
const uint8_t expected_raw_data[] = {
0x01, 0x00, 0x69, 0x50, 0x68, 0x6f, 0x6e, 0x65,
0x20, 0x4d, 0x61, 0x72, 0x74, 0x79, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf9,
0x92, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x75, 0x36,
0x9c, 0x6e, 0x1a, 0x1b, 0xeb, 0x5f, 0xfb, 0x89,
0xdb... | bt_persistent_storage_get_raw_data(&key, sizeof(key), data, data_size) | |
i18n_owner,
active_window->workout_data);
if (strlen(number_text_node->text) > 5) {
number_text_node->font = prv_get_number_font(false);
}
break;
}
case WorkoutMetricType_Duration:
{
const size_t buffer_size = sizeof("... | {
action_bar_layer_set_icon(action_bar, active_window->pause_button,
active_window->action_bar_start);
if (can_stop) {
action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, active_window->action_bar_stop);
}
} | else {
action_bar_layer_clear_icon(action_bar, BUTTON_ID_SELECT);
action_bar_layer_set_icon(action_bar, active_window->pause_button,
active_window->action_bar_pause);
}
if (active_window->num_scrollable_metrics > 1) {
action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, ... |
ory/smartstrap_attribute.h"
#include "services/normal/accessory/smartstrap_comms.h"
#include "services/normal/accessory/smartstrap_connection.h"
#include "services/normal/accessory/smartstrap_link_control.h"
#include "services/normal/accessory/smartstrap_state.h"
#include "syscall/syscall.h"
#include "syscall/syscall_i... | if (smartstrap_profiles_send_control()) {
did_send = true;
} else if (smartstrap_attribute_send_pending()) {
did_send = true;
} | |
er leaves behind. This includes disabling the PLL.
// GPIOs are not reset here: resetting them would change their output values,
// which could unintentionally turn of e.g. PMIC power rails.
// The backup domain is not reset; that would be foolish.
const uint32_t ahb1_periphs =
RCC_AHB1Periph_CRC | RCC_AHB1... | (BOOT_BIT_RESET_LOOP_DETECT_THREE) | ;
return true;
}
switch (++counter) {
case 1:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 2:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO);
break;
case 3:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 4... |
/*
* 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... | {BIT_DEPTH_NAME}__framebuffer_clear(void) {
// clear the framebuffer
framebuffer_init(&framebuffer, &(GSize) { DISP_COLS, DISP_ROWS });
framebuffer_clear(&framebuffer);
// check the clearing
#if SCREEN_COLOR_DEPTH_BITS == 1
for (int i = 0; i < ARRAY_LENGTH(framebuffer.buffer); i++) {
cl_assert(framebuffe... | |
// See if we got the expected sleep events
cl_assert(s_num_captured_sleep_events > 0);
event = s_captured_sleep_event;
cl_assert_equal_i(event.type, PEBBLE_HEALTH_SERVICE_EVENT);
cl_assert_equal_i(event.health_event.type, HealthEventSleepUpdate);
// -----------------------------------
// Test that we r... | {
prv_feed_cannned_accel_data(165 * SECONDS_PER_MINUTE, 0, ActivitySleepStateLightSleep);
prv_feed_cannned_accel_data(15 * SECONDS_PER_MINUTE, 20, ActivitySleepStateAwake);
} |
activity_get_metric(ActivityMetricSleepEnterAtSeconds, 1, &value);
cl_assert_equal_i(value, 2 * SECONDS_PER_HOUR /* 2am */);
activity_get_metric(ActivityMetricSleepTotalSeconds, 1, &value);
cl_assert_equal_i(value, 330 * SECONDS_PER_MINUTE);
activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value)... |
ing of the firmware off flash to see if it's new world or old world
const unsigned world_length = FW_IDENTIFIER_OFFSET + sizeof(uint32_t); // NeWo read as uint32_t
uint8_t buffer[world_length];
flash_read_bytes(buffer, flash_new_fw_addr, world_length);
return firmware_is_new_world(buffer);
}
static bool prv_... | ("\nInvalid firmware description!") | ;
return UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED;
}
if (!prv_check_valid_firmware_crc(
flash_new_fw_addr + sizeof(FirmwareDescription), &firmware_description)) {
dbgserial_putstr("Invalid firmware CRC in SPI flash!");
return UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED;
}
bool new_world = prv_check... |
_data));
keyed_circular_cache_init(&font_cache->line_cache, font_cache->cache_keys,
font_cache->cache_data, sizeof(LineCacheData), LINE_CACHE_SIZE);
graphics_context_set_default_drawing_state(context, init_mode);
}
void graphics_context_set_default_drawing_state(GContext *ctx,
... | (ctx->parent_framebuffer, rect) | ;
}
}
bool graphics_frame_buffer_is_captured(GContext* ctx) {
PBL_ASSERTN(ctx);
return ctx->lock;
}
GBitmap* graphics_capture_frame_buffer_format(GContext *ctx, GBitmapFormat format) {
PBL_ASSERTN(ctx);
if (ctx->lock) {
APP_LOG(APP_LOG_LEVEL_WARNING,
"Frame buffer has already been captured; ... |
id) {
s_remote_app_uuid = uuid;
}
//! @note Assumes same order of tuples in both dictionaries!
static void prv_assert_dict_equal(DictionaryIterator *a, DictionaryIterator *b) {
Tuple *a_tuple = dict_read_first(a);
Tuple *b_tuple = dict_read_first(b);
while (b_tuple && a_tuple) {
cl_assert_equal_i(a_tuple->... | cl_assert(length == sizeof(AppMessage)) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "message %"PRIu32", id1 %"PRIu32", id2 %"PRIu32, message->transaction_id,
TEST_TRANSACTION_ID_1, TEST_TRANSACTION_ID_2);
if (message->transaction_id == TEST_TRANSACTION_ID_1) {
cl_assert_equal_b(s_ack_received_for_id_1, false);
s_ack_received_for_id_1 = true;
cl_assert_e... |
info_valid,
pairing_info_out.is_remote_identity_info_valid);
cl_assert_equal_b(PAIRING_INFO.is_remote_encryption_info_valid,
pairing_info_out.is_remote_encryption_info_valid);
cl_assert_equal_b(PAIRING_INFO.is_local_encryption_info_valid,
pairing_info_out.... | shared_prf_storage_get_ble_pinned_address(&addr_buf) | ;
cl_assert_equal_b(rv, true);
cl_assert_equal_m(&DEVICE_ADDR, &addr_buf, sizeof(DEVICE_ADDR));
shared_prf_storage_set_ble_pinned_address(&DEVICE_ADDR);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0);
shared_prf_storage_set_ble_pinned_address(NULL);
rv = shared_prf_storage_get_ble_pinned... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.