prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
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, InterpolateInt64Function interpolate);
int64_t prv_default_... | |
/*
* 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... | (conn_idx) | |
ION_SHARED_PRF_STORAGE_END - \
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_NUM_PAGES (SPRF_REGION_SIZE / sizeof(SharedPRFData))
#define SPRF_PAGE_FLASH_ADDR(idx) (FLASH_REGION_SHARED_PRF_STORAGE_BEGIN + \
(idx * sizeof(SharedPRFData)))
// CRC Unwri... | ((uint8_t *)data, prv_current_page_flash_addr(), sizeof(*data)) | ;
}
}
static void prv_erase_region_and_save(SharedPRFData *data) {
flash_region_erase_optimal_range_no_watchdog(FLASH_REGION_SHARED_PRF_STORAGE_BEGIN,
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN,
FLASH_REGION_SHARED_PRF_STORAGE... |
/*
* 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_byte(datum);
} |
}
static void prv_prompt_output_cb(int16_t *samples, size_t sample_count, void *context) {
const int OUTPUT_SAMPLE_RATE = (s_is_8khz) ? 8000 : 16000;
int to_process = MIN((int)sample_count, s_timeout);
s_timeout -= to_process;
if (to_process > 0) {
// Groups of samples are encapsulated in HDLC-like fram... |
r __asm("lr");
uintptr_t saved_lr = lr;
return prv_strdup(task_heap_get_for_current_task(), s, saved_lr);
}
// app_* functions that allocate on the app heap
///////////////////////////////////////////////////////////
void *app_malloc(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
... | prv_strdup(kernel_heap_get(), s, saved_lr) | ;
}
char *kernel_strdup_check(const char *s) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap = kernel_heap_get();
void *mem = prv_strdup(heap, s, saved_lr);
if (!mem) {
PBL_CROAK_OOM(strlen(s) + 1, saved_lr, heap);
}
return mem;
}
// Wrappers (Jay-Z, Tupac, etc)
// We want... |
ognizerRef recognizer, Window *window) {
// If the animation is still running, fast-foward to 300ms from the end
if (animation_is_scheduled(s_animation)) {
uint32_t duration = animation_get_duration(s_animation, true, true);
animation_set_elapsed(s_animation, duration - 300);
APP_LOG(APP_LOG_LEVEL_INFO,... | text_layer_set_text(s_text_layer_b, "Spawned") | |
que top window removes Transparent and Unfocused
modal_manager_event_loop_upkeep();
cl_assert_equal_i(modal_manager_get_properties(),
ModalProperty_Exists | ModalProperty_CompositorTransitions |
ModalProperty_RenderRequested);
cl_assert_equal_i(windows[2][0]->on_screen, tru... | (windows[3][1]->is_click_configured, true) | ;
cl_assert_equal_i(windows[2][1]->on_screen, true);
cl_assert_equal_i(windows[2][1]->is_click_configured, false);
cl_assert_equal_i(windows[1][0]->on_screen, true);
cl_assert_equal_i(windows[1][0]->is_click_configured, false);
cl_assert_equal_p(s_last_click_configured_window, windows[3][1]);
for (ModalPri... |
mp(buf, "May", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"h\": %s", buf);
}
r = strftime(buf, buf_size, "%H", &good_data);
if (r == 0 || strncmp(buf, "11", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"H\": %s", buf);
}
r = strftime(buf, buf_size, "%I", &good_data);
... | (buf, buf_size, "%B", &bad_data) | ;
strftime(buf, buf_size, "%c", &bad_data);
strftime(buf, buf_size, "%d", &bad_data);
strftime(buf, buf_size, "%D", &bad_data);
strftime(buf, buf_size, "%e", &bad_data);
strftime(buf, buf_size, "%F", &bad_data);
strftime(buf, buf_size, "%g", &bad_data);
strftime(buf, buf_size, "%G", &bad_data);
... |
less required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
... | (apb1_periphs, ENABLE) | ;
RCC_APB1PeriphResetCmd(apb1_periphs, DISABLE);
const uint32_t apb2_periphs = 0
| RCC_APB2Periph_TIM1
| RCC_APB2Periph_TIM8
| RCC_APB2Periph_USART1
| RCC_APB2Periph_USART6
| RCC_APB2Periph_ADC
| RCC_APB2Periph_SDIO
| RCC_APB2Periph_SPI1
| RCC_APB2Periph_SYSCFG
| RCC_APB2Periph_... |
allback = prv_system_task_starved_callback,
.data = NULL,
},
};
event_put_isr(&event);
}
prv_log_failed_message(&reason);
// Re-write the reason including the stuck task info collected by prv_log_failed_message()
reboot_reason_clear();
reboot_reason_set(&reason);
... | {
task_watchdog_disable_interrupt();
s_watchdog_bits |= (1 << task);
task_watchdog_enable_interrupt();
} |
bool task_watchdog_mask_get(PebbleTask task) {
task_watchdog_disable_interrupt();
bool result = (s_watchdog_mask & (1 << task));
task_watchdog_enable_interrupt();
return result;
}
void task_watchdog_mask_set(PebbleTask task) {
task_watchdog_disable_interrupt();
s_watchdog_mask |= (1 << task);
task_watc... |
h) {
.num_points = ARRAY_LENGTH(s_battery_silhouette_path_points),
.points = (GPoint *)s_battery_silhouette_path_points,
.offset = rect->origin,
};
const GColor battery_silhouette_color =
launcher_app_glance_structured_get_highlight_color(structured_glance);
const GColor battery_f... | (&horizontal_container_node->container,
vertically_centered_battery_percent_text_node) | ;
}
#if PLATFORM_ROBERT
const int16_t subtitle_icon_offset_y = 5;
#else
const int16_t subtitle_icon_offset_y = 2;
#endif
GTextNodeCustom *battery_icon_node =
graphics_text_node_create_custom(prv_battery_icon_node_draw_cb, structured_glance);
// Push the battery icon down to center it properly
batter... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | i18n_get("Your screen may need calibration. Calibrate it now?",
confirmation_dialog) | );
dialog_set_background_color(dialog, GColorMediumAquamarine);
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_PIN_TINY);
confirmation_dialog_set_click_config_provider(confirmation_dialog,
prv_calibrate_click_config);
confirmation_dialog_push(confirmation_dialog,
... |
PLOT_BRIGHTNESS;
int16_t weighting = 0;
// Locking framebuffer...
GBitmap *framebuffer = graphics_capture_frame_buffer(ctx);
GColor stroke_color = ctx->draw_state.stroke_color;
// Step 1
for (progress = 0; progress < stop_progress; progress++) {
Fixed_S16_3 edge = (Fixed_S16_3){.raw_value = radius_fix... | (ctx, y, start, end) | ;
}
}
static void prv_stroke_circle_quadrant_full(GContext* ctx, GPoint p, uint16_t radius,
uint8_t stroke_width, GCornerMask quadrant) {
// This algorithm will draw stroked circle with vairable width (only odd numbers for now)
const uint8_t half_stroke_width = stroke_... |
acking is enabled
PutBytesPendingJobs pb_pending_jobs;
//! Storage for the Pebble Protocol ReceiverImplementation:
struct {
//! Backing storage for the received Put Bytes message. This buffer points to one of the buffers
//! allocated within `pb_pending_jobs`
uint8_t *buffer;
//! The length in b... | PBL_LOG(LOG_LEVEL_DEBUG, "Not enough buffer room to pre-ack PB packet") | ;
}
}
static void prv_deinit_put_job_queue(void) {
PutBytesPendingJobs *put_jobs = &s_pb_state.pb_pending_jobs;
for (int i = 0; i < MAX_BATCHED_PB_PUT_OPS; i++) {
kernel_free(put_jobs->job[i].buffer);
put_jobs->job[i].buffer = NULL;
}
}
static bool prv_init_put_job_queue_if_necessary(void) {
PutByte... |
{ 976, 184, 64},
{ 992, 168, 56},
{ 1000, 216, 8},
{ 912, 208, -8},
{ 848, 192, 24},
{ 768, 168, 24},
{ 768, 120, 64},
{ 808, 72, 128},
{ 832, 88, 144},
{ 856, 88, 136},
{ 936, 112, 144},
{ 1064, 136, 104},
{ 1000, 160, -40},
{ 1304, 104, 32},
{ 1216, 128, -16},
... | { 848, 152, -8},
{ 872, 184, -40},
{ 880, 176, -56},
{ 888, 192, -64},
{ 864, 160, -72},
{ 896, 144, -48},
{ 968, 168, -16},
{ 1008, 200, 8},
{ 1104, 152, 112},
{ 1216, 120, 136},
{ 1224, 192, 96},
{ 912, 168, 56},
{ 1048, 88, 48},
{ 1072, 112, 24},
{ 920, 184... | |
_spi_flash_erase();
shared_prf_storage_init();
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0);
// Test that it sees all pages are invalid, rewrites everything, and picks the first empty page
prv_fill_flash_random_data();
shared_prf_storage_init();
cl_assert_equal_i(shared_prf_storage_get_... | (&PAIRING_INFO.csrk, &pairing_info_out.csrk,
sizeof(SM128BitKey)) | , 0);
shared_prf_storage_erase_ble_pairing_data();
cl_assert_equal_b(shared_prf_storage_get_ble_pairing_data(NULL, NULL, NULL, NULL), false);
}
void test_shared_prf_storage_v3__root_keys(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_root_key(SMRootKeyTypeIdentity, NULL), fal... |
;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
// check second again
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check fourth
cl_assert(iter_next(&iterator));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.p... | cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id)) | |
License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*... | (&data->text_layer, GTextAlignmentCenter) | ;
layer_add_child(&window->layer, &data->text_layer.layer);
}
static void config_provider(Window *window) {
window_single_click_subscribe(BUTTON_ID_UP, (ClickHandler)click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler)click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, (Clic... |
s under the License.
*/
#include "clar.h"
#include "applib/graphics/gdraw_command.h"
#include "applib/graphics/gdraw_command_list.h"
#include "applib/graphics/gdraw_command_image.h"
#include "applib/graphics/gdraw_command_private.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/graphics.h"
#include ... | free(s_fill_points) | ;
s_fill_points = NULL;
}
s_path_open = false;
s_radius = 0;
s_path_stroke_count = 0;
s_path_stroke_precise_count = 0;
s_path_fill_count = 0;
s_path_fill_precise_count = 0;
s_circle_stroke_count = 0;
s_circle_fill_count = 0;
s_offset = (GPoint){ 0 };
if (s_precise_lines) {
free(s_precise... |
bute_list_add_cstring(&list, AttributeIdTitle, "3.3 Mile run");
attribute_list_add_cstring(&list, AttributeIdSubtitle, "30M of activity");
attribute_list_add_uint32(&list, AttributeIdLastUpdated, now);
uint8_t buffer[Uint32ListSize(ActivitySessionMetricCount)];
Uint32List *icons = (Uint32List *)buffer;
icons... | prv_add_calendar_pin(-(3 * SECONDS_PER_DAY) / 2, 3 * MINUTES_PER_DAY, is_all_day,
!recurring, 0, 0) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_LOG(LOG_LEVEL_ERROR, "No connection found for pairing request");
return;
} |
// PBL-38595: Make the connection fast during the pairing:
const uint16_t max_period_secs = 40;
conn_mgr_set_ble_conn_response_time(connection, BtConsumerLePairing,
ResponseTimeMin, max_period_secs);
PairingUserConfirmationCtx *ctx = (PairingUserConfirmationCtx *)connect... |
nclude "rocky_api_graphics_color.h"
#include "rocky_api_util.h"
#include "string.h"
#include "util/size.h"
#define GColorARGB8FromRGBA(red, green, blue, alpha) \
(uint8_t)( \
((((alpha) >> 6) & 0b11) << 6) | \
((((red) >> 6) & 0b11) << 4) | \
((((green) >> 6) & 0b11) << 2) | \
((((blue) >> 6) & 0b1... | GColorARGB8FromHEX(0xcd5c5c) | },
// {"indigo", GColorARGBFromHEX(0x4b0082)}, inconsistent with Pebble color
{"ivory", GColorARGB8FromHEX(0xfffff0)},
{"khaki", GColorARGB8FromHEX(0xf0e68c)},
{"lavender", GColorARGB8FromHEX(0xe6e6fa)},
{"lavenderblush", GColorARGB8FromHEX(0xfff0f5)},
{"lawngreen", GColorARGB8FromHEX(0x7cfc00)},
{"lemonch... |
(false, file, line, "Missing activity record", "", true);
}
#define ASSERT_ACTIVITY_SESSION_PRESENT(sessions, num_sessions, session) \
prv_assert_activity_present((sessions), (num_sessions), (session), __FILE__, __LINE__)
// ==================================================================================
... | {
// We consider the first and last epoch of each sample as a "partial stepping" epoch.
epoch_type = StatsEpochTypePartialStepping;
} | else {
epoch_type = StatsEpochTypeStepping;
}
fprintf(file, " ,%d, %d", (int)epoch_type, row_idx);
for (int i = 0; i < s_stats_num_columns; i++) {
fprintf(file, " ,%d", row->values[i]);
}
fprintf(file, "\n");
}
cl_assert_equal_i(0, fclose(file));
printf("Stats written to file: %s... |
/*
* 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... | {
CrashInfo* crash_info = (CrashInfo*) data;
char lr_str[16];
if (crash_info->lr_known) {
sniprintf(lr_str, sizeof(lr_str), "%p", (void*) crash_info->lr);
} else {
strncpy(lr_str, "???", sizeof(lr_str));
}
char pc_str[16];
if (crash_info->pc_known) {
sniprintf(pc_str, sizeof(pc_str), "%p", (... |
//! Converts an address from an absolute address in our memory space to one that's relative to the start
//! of the loaded app/worker
static void convert_to_process_offset(bool known, uintptr_t* pc, PebbleTask task) {
if (known) {
*pc = (uintptr_t) process_manager_address_to_offset(task, (void*) *pc);
}
}
st... |
/*
* 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;
} |
path_layer->fill_color = color;
layer_mark_dirty(&(path_layer->layer));
}
Layer* path_layer_get_layer(const PathLayer *path_layer) {
return &((PathLayer *)path_layer)->layer;
}
|
t an expriration time
// placed on it
void test_hrm_manager__app_cleanup(void) {
stub_pebble_tasks_set_current(PebbleTask_App);
AppInstallId app_id = 1;
const uint32_t update_interval_s = 1;
uint16_t expire_s = 0;
HRMFeature features = HRMFeature_BPM;
// If we subscribe with no expiration, we should get 0... | rtc_get_time() | + expire_s + 1);
// Send more data, the subscription should go away now
prv_fake_send_new_data();
fake_system_task_callbacks_invoke_pending();
cl_assert(prv_get_subscriber_state_from_ref(session_ref) == NULL);
}
void test_hrm_manager__subscribe_multiple(void) {
const int num_refs = 3;
HRMSessionRef sess... |
3897 }, // priority rank 27
{ .id = 39, .priority = 24, .size = 233217 }, // priority rank 16
{ .id = 40, .priority = 8, .size = 23717 }, // priority rank 6
{ .id = 41, .priority = 61, .size = 266668 }, // priority rank 49
{ .id = 42, .priority = 58, .size = 61228 }, // priority rank 46
{ .id = 43, .priori... | (after_size, 0) | ;
}
static bool prv_file_for_id_exists(AppInstallId id) {
char buffer[30];
itoa_int(id, buffer, 10);
int fd = pfs_open(buffer, OP_FLAG_READ, FILE_TYPE_STATIC, 0);
if (fd < 0) {
return false;
}
pfs_close(fd);
return true;
}
static void prv_create_file_for_id(AppInstallId id) {
char buffer[30];
i... |
{ 1168, -88, -88},
{ 1096, -96, -72},
{ 1056, -120, -72},
{ 1008, -104, -40},
{ 904, -104, -56},
{ 952, -96, -104},
{ 944, -80, -112},
// 16 seconds
{ 1064, -80, -96},
{ 1144, -40, -72},
{ 1280, -32, 16},
{ 1512, 72, 56},
{ 1368, 112, 88},
{ 1320, 128, 72},
{ ... | { 1008, -32, -8},
{ 976, -32, 0},
{ 936, -32, -8},
{ 920, -24, -32},
{ 864, -48, -64},
{ 856, -56, -64},
{ 904, -80, -88},
{ 1032, -104, -64},
{ 1496, -80, -64},
{ 1576, -64, -112},
{ 1328, 16, -232},
{ 968, 48, -360},
{ 968, 64, -368},
{ 1136, 24, -264},
{ 12... |
{ 936, -136, 96},
{ 864, -104, 56},
{ 784, -72, -8},
{ 808, 0, -88},
{ 880, -8, -104},
{ 896, -96, -168},
{ 1288, -240, -56},
{ 1424, -120, -168},
{ 1112, -80, -224},
{ 936, -48, -320},
{ 1152, -136, -472},
{ 1256, -168, -304},
{ 1176, -200, -160},
{ 1064, -136, ... |
st_ams__receive_non_numeric_player_playback_info_update(void) {
prv_connect_ams();
// Receive: 'A', 'B.0' playback rate, elapsed time 184.755s
// 0000 00 01 00 41 2c 42 2e 30 2c 31 38 34 2e 37 35 35 ...A,B.0 ,184.755
uint8_t nan_playback_info_update[] = {
0x00, 0x01, 0x00, 0x41, 0x2c, 0x42, 0x2e, 0x30,... | (NumMusicCommand) | , false);
}
// Tests: Create & Destroy
///////////////////////////////////////////////////////////
void test_ams__create_again_trips_assert(void) {
cl_assert_passert(ams_create());
}
void test_ams__create_works_again_after_destroy(void) {
ams_destroy();
ams_create();
// No assert hit.
}
void test_ams__destr... |
/*
* 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... | {
averages->average[j] = 0;
} | |
ER_UNFOLD_DURATION);
const int16_t expand = 8;
kino_reel_scale_segmented_set_deflate_effect(kino_reel, expand);
layer_set_hidden((Layer *)&peek_layer->kino_layer, true);
peek_layer->show_dot = prv_is_dot_size(icon_from.size);
if (peek_layer->show_dot) {
kino_reel_unfold_set_start_as_dot(kino_reel, peek_l... | {
kino_reel_scale_segmented_set_end_as_dot(kino_reel, peek_layer->dot_diameter / 2);
} |
kino_layer_set_reel(&peek_layer->kino_layer, kino_reel, true);
kino_layer_set_callbacks(&peek_layer->kino_layer, (KinoLayerCallbacks) {
.did_stop = prv_scale_to_did_stop,
}, peek_layer);
peek_layer->hidden_fields_timer = evented_timer_register(PEEK_LAYER_SCALE_DURATION,
... |
istered_filter, &cb->list_node));
cb->is_executing = false;
cb->pending_delete = false;
list_append(&s_seconds_callbacks, &cb->list_node);
} else {
// If it is marked for deletion, remove the deletion flag
cb->pending_delete = false;
}
mutex_unlock(s_callback_list_semaphore);
}
// ----------... | {
prv_fire_callbacks(&s_seconds_callbacks, secs);
} |
void regular_timer_fire_minutes(uint8_t mins) {
prv_fire_callbacks(&s_minutes_callbacks, mins);
}
static uint32_t prv_count(ListNode *list) {
uint32_t count = 0;
mutex_lock(s_callback_list_semaphore);
// -1, because s_..._callbacks is a ListNode too
count = list_count(list) - 1;
mutex_unlock(s_callback_l... |
,
};
static TimelineItemAction actions[] = {
{.id = 0, .type = TimelineItemActionTypeGeneric, .attr_list = {.num_attributes = ARRAY_LENGTH(action1_attributes), .attributes = action1_attributes}},
{.id = 1, .type = TimelineItemActionTypeGeneric, .attr_list = {.num_attributes = ARRAY_LENGTH(action2_attributes), ... | string_list_get_at(list, 0) | );
cl_assert_equal_s("bc", string_list_get_at(list, 1));
}
static TimelineItemAction s_basic_action_list[] = {
{ .id = 0, .type = TimelineItemActionTypeGeneric },
{ .id = 1, .type = TimelineItemActionTypeHttp },
{ .id = 2, .type = TimelineItemActionTypeOpenPin },
};
void test_timeline_item__find_action_wit... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&ctx, START_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT, 10) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_origin_layer_aa.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 10);
graphics_line_draw_precise_stroked_aa(&ctx, START_ON_ORIGIN_RECT_XY, END_ON_ORIGIN_RECT_XY, 10);
cl_check(gbitmap_pbi... |
buffer, format,
gbitmap_format_get_row_size_bytes(width, format), true);
gbitmap_set_bounds(bitmap, (GRect){.origin = {0, 0}, .size = {width, height}});
bitmap->info.version = GBITMAP_VERSION_CURRENT;
if (palette) {
gbitmap_set_palette(bitmap, palette, true);
}
retval = true;
cleanup:
if (!retv... | {
return true;
} |
}
return false;
}
int32_t gbitmap_png_get_transparent_gray_value(upng_t *upng) {
int32_t transparent_gray = -1; // default to invalid value
// Handle grayscale transparency value (1 single transparent gray)
uint8_t *alpha_palette = NULL;
uint16_t alpha_palette_entries = upng_get_alpha_palette(upng, &alp... |
/*
* 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_DEBUG, "Current conn params: intvl min: %d max: %d latency: %d STO: %d",
(int)conn_params->interval_min, (int)conn_params->interval_max,
(int)conn_params->slave_latency, (int)conn_params->sup_timeout) | ;
}
static bool prv_get_device_and_irk_by_conn_idx(uint16_t conn_idx,
bool *is_resolved_out,
SMIdentityResolvingKey *irk_out) {
bool success = true;
storage_acquire();
{
device_t *dev = find_device_by_conn_idx(conn_... |
prv_serialize_group_element(type, group_ptr, buffer, buf_end) | ;
}
return buffer - buf_start;
}
| |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
uart_wait_for_tx_complete(DBG_UART);
} |
void dbgserial_putstr_fmt(char* buffer, unsigned int buffer_size, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsniprintf(buffer, buffer_size, fmt, ap);
va_end(ap);
dbgserial_putstr(buffer);
}
|
&client), 0);
}
void test_shared_circular_buffer__subsampling_2of5(void) {
SharedCircularBuffer buffer;
uint16_t item_size = 2;
uint8_t storage[12*item_size];
uint8_t out_buffer[12*item_size];
uint16_t items_read;
shared_circular_buffer_init(&buffer, storage, sizeof(storage));
SubsampledSharedCircular... | (shared_circular_buffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 3), 3) | ;
// Normally the next read would skip 5f, but changing the ratio resets the
// subsampling state and the first sample after resetting the state is never
// skipped.
cl_assert_equal_m(out_buffer, "5f7h8i", 6);
}
void test_shared_circular_buffer__subsampling_set_ratio_is_idempotent(void) {
SharedCircularBuff... |
TION_STORAGE_FILE_SIZE);
if (fd < 0) {
// If a write operation or a read operation fails with anything other than "does not exist",
// log error
bool read_only =
((op_flags & (OP_FLAG_WRITE | OP_FLAG_OVERWRITE | OP_FLAG_READ)) == OP_FLAG_READ);
if ((!read_only) || (fd != E_DOES_NOT_EXIST)) {
... | PBL_LOG(LOG_LEVEL_ERROR, "Error opening new file for compression %d", new_fd) | ;
return false;
}
// Delete old notifications if there is no space left in storage
size_t size_available;
if (prv_is_storage_full(size_needed, &size_available, *fd)) {
pfs_seek(*fd, 0, FSeekSet);
prv_reclaim_space(size_needed - size_available, *fd);
}
pfs_seek(*fd, 0, FSeekSet);
int write_of... |
/*
* 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... | (alarm_time, 0, TimelineItemTypePin,
LayoutIdAlarm, &pin_attr_list, &action_group) | ;
item->header.from_watch = true;
item->header.parent_id = (Uuid)UUID_ALARMS_DATA_SOURCE;
pin_db_insert_item_without_event(item);
i18n_free_all(&pin_attr_list);
i18n_free_all(&edit_attr_list);
attribute_list_destroy_list(&pin_attr_list);
attribute_list_destroy_list(&edit_attr_list);
task_free(action_g... |
--length;
}
}
static void background_update_proc(Layer *layer, GContext *ctx) {
GRect bounds = layer_get_bounds(layer);
// Draw lines to contain 'hole' and 'par' sections.
// Magic numbers measured from design spec
const int16_t vertical_divider_height = PBL_IF_ROUND_ELSE(107, 50);
const int16_t horizonta... | status_bar_layer_set_colors(data->status_layer, GColorClear, GColorBlack) | ;
#if PBL_RECT
status_bar_layer_set_separator_mode(data->status_layer, StatusBarLayerSeparatorModeDotted);
#endif
layer_add_child(background, status_bar_layer_get_layer(data->status_layer));
// labels
const char * const font_key_label = FONT_KEY_GOTHIC_09;
// back, mid, front numbers
const char * const fon... |
s and
* limitations under the License.
*/
#include "rocky_api_graphics_color.h"
#include "rocky_api_util.h"
#include "string.h"
#include "util/size.h"
#define GColorARGB8FromRGBA(red, green, blue, alpha) \
(uint8_t)( \
((((alpha) >> 6) & 0b11) << 6) | \
((((red) >> 6) & 0b11) << 4) | \
((((green) >>... | GColorARGB8FromHEX(0xff69b4) | },
{"indianred", GColorARGB8FromHEX(0xcd5c5c)},
// {"indigo", GColorARGBFromHEX(0x4b0082)}, inconsistent with Pebble color
{"ivory", GColorARGB8FromHEX(0xfffff0)},
{"khaki", GColorARGB8FromHEX(0xf0e68c)},
{"lavender", GColorARGB8FromHEX(0xe6e6fa)},
{"lavenderblush", GColorARGB8FromHEX(0xfff0f5)},
{"lawngre... |
lor bg_color;
GColor fg_color;
uint8_t alpha;
TextLayer *alpha_text;
char alpha_text_buffer[30];
TextLayer *fg_text;
char fg_text_buffer[5];
TextLayer *fg_color_text;
char fg_color_text_buffer[20];
uint8_t fg_color_index;
TextLayer *bg_text;
char bg_text_buffer[5];
TextLayer *bg_color_text;
... | GPoint(point.x, point.y + 1) | |
timezone_clear();
clock_init();
static const time_t jan1st_noon_2015 = 1420113600;
for (int dstid = 0; dstid < DST_ID_COUNT; dstid++) {
TimezoneInfo tz_info = {
.dst_id = dstid,
.tm_gmtoff = s_dst_correct_values[dstid][2]
};
prv_update_dstrule_timestamps_by_dstzone_id(&tz_info, jan1st_n... | {
struct tm may_30 = {
.tm_sec = 0,
.tm_min = 59,
.tm_hour = 7,
.tm_mday = 30,
.tm_mon = 4, // May
.tm_year = 2016 - 1900,
.tm_isdst = 1,
.tm_gmtoff = -5 * SECONDS_PER_HOUR,
};
struct tm may_31 = {
.tm_sec = 0,
.tm_min = 0,
.tm_hour = 5,
.tm_mday = 31,
.tm_mon ... |
void test_clock__time_until_one_hour_relative(void) {
char time_buf[64];
const int jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 10th 2015, 14:00:00
// Now + two hours
const int event_time = jun10th_noon_2015 + (2 * SECONDS_PER_HOUR)... |
CreateFunc bitmap_create_func;
bool need_to_destroy_bitmap;
} CompositeTest;
static const CompositeTest s_composite_tests[] = {
{
.test_name = "1bitBW",
.expected_test_image_bitmap_format = GBitmapFormat1Bit,
.bitmap_create_func = prv_create_bitmap_from_pbi_file,
.need_to_destroy_bitmap = false,
... | snprintf(unit_test_result_image_file_base_name, PATH_STRING_LENGTH,
"%s_%s", unit_test_name, test_data->test_name) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap,
namecat(unit_test_result_image_file_base_name, ".pbi")));
if (test_data->need_to_destroy_bitmap) {
gbitmap_destroy(bitmap);
}
}
}
// Tests
////////////////////////////////////
void test_graphics_draw_bitmap__origin_layer_inside(void) {
... |
bytes[] = {0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x83, 0xc1, 0x60, 0x30, 0x18, 0x0c, 0xfe, 0x01};
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
int8_t horiz_advance = text_resources_get_glyph_horiz_advance(&s_font_cache,
... | glyph_get_size_bytes(glyph) | ;
cl_assert_equal_m(phone_bytes, glyph->data, glyph_size_bytes);
}
void test_text_resources__test_glyph_decompression(void) {
// There is no way to get the list of glyphs present in a font with the existing API. This list
// of ranges lists the 371 glyphs currently in fontname.ttf
typedef struct Codepoint_Ran... |
/*
* 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... | circular_buffer_consume(&buffer, 2) | ;
// Write data that will be wrapped:
circular_buffer_write(&buffer, (uint8_t *)"456789", 6);
// Test copying the whole thing (providing buffer of 8 bytes):
memset(data_out, 0, data_out_size);
cl_assert_equal_i(circular_buffer_copy(&buffer, data_out, data_out_size), 8);
cl_assert(memcmp("23456789", data_o... |
layStatePaused;
}
static Animation *prv_create_cassette_animation(MusicAppData *data) {
const MusicAppSizeConfig *config = prv_config();
const GRect cassette_rect = prv_cassette_rect();
GPoint left_target = GPoint(-cassette_rect.size.w - cassette_rect.origin.x, 0);
Animation *cassette_left = property_animation... | animation_set_duration(bounceback_animation, 4 * ANIMATION_FRAME_MS) | |
ter(void) {
prv_create_test_inbox();
cl_assert_equal_b(false, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, NULL));
cl_assert_equal_b(false, app_inbox_service_is_being_written_for_tag(AppInboxServiceTagUnitTest));
}
void test_app_inbox__app_in... | assert_num_message_callbacks(0) | ;
}
void test_app_inbox__app_inbox_service_write_happy_case(void) {
prv_create_test_inbox_and_begin_write();
cl_assert_equal_b(true, app_inbox_service_write(AppInboxServiceTagUnitTest,
s_test_data, BUFFER_SIZE));
// After ending the write, expect num_success to b... |
ansport went down while waiting to send.
// The CommSession has already been closed so simply return without doing
// anything further.
break;
}
}
}
static void prv_reset(Transport *transport) {
PBL_LOG(LOG_LEVEL_INFO, "Unimplemented");
}
static void prv_granted_kernel_main_cb(void *ctx) {
... | {
PulsePPCallbackPacket *cb_data = data;
uint8_t *resp = pulse_reliable_send_begin(PULSE2_PEBBLE_PROTOCOL);
memcpy(resp, &cb_data->packet, cb_data->packet_length);
pulse_reliable_send(resp, cb_data->packet_length);
kernel_free(data);
} |
static void prv_pulse_pp_send(uint8_t opcode, uint8_t *data, size_t data_length) {
size_t packet_length = sizeof(PulsePPCallbackPacket) + data_length;
PulsePPCallbackPacket *cb_data = kernel_malloc_check(packet_length);
cb_data->packet_length = sizeof(PulsePPPacket) + data_length;
cb_data->packet.opcode = opc... |
64},
{ -720, 480, 472},
{ -712, 480, 472},
{ -712, 480, 464},
{ -712, 472, 472},
{ -712, 472, 472},
{ -712, 464, 472},
{ -712, 464, 480},
{ -720, 472, 464},
{ -720, 480, 472},
{ -720, 480, 464},
{ -720, 488, 464},
{ -712, 480, 464},
{ -712, 472, 472},
{ -720, 472,... | { -720, 480, 464},
{ -712, 480, 472},
{ -720, 480, 464},
{ -704, 488, 472},
{ -720, 472, 464},
{ -720, 472, 464},
{ -720, 464, 472},
{ -720, 480, 472},
{ -712, 488, 464},
{ -720, 480, 464},
// 145 seconds
{ -720, 480, 472},
{ -720, 480, 464},
{ -720, 480, 472},
... |
{ -712, 480, 472},
{ -712, 472, 464},
{ -712, 472, 464},
{ -720, 480, 464},
{ -712, 480, 472},
{ -720, 480, 472},
{ -712, 480, 456},
{ -712, 488, 464},
{ -720, 480, 464},
{ -712, 480, 456},
{ -712, 480, 456},
{ -712, 488, 472},
{ -712, 496, 472},
{ -704, 488, 488... |
_pgs, pages_to_seek);
pages_to_seek -= contig_pgs;
next_page += contig_pgs;
}
}
for (uint16_t i = 0; i < pages_to_seek; i++) {
if (get_next_page(next_page, &next_page) != S_SUCCESS) {
return (E_RANGE);
}
}
f->curr_page = next_page;
}
*pg_offset = data_offs... | {
res = E_INVALID_ARGUMENT;
goto cleanup;
} | |
/*
* 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_WARNING, "Attempted to unsubscribe from %d, not subscribed",
subscription->event_type) | ;
return;
}
PBL_ASSERTN(service->num_subscribers > 0);
--service->num_subscribers;
service->subscribers[subscription->task] = NULL;
if (service->remove_subscriber_callback != NULL) {
service->remove_subscriber_callback(subscription->task);
}
}
static void prv_event_service_subscribe(PebbleSubscri... |
v_get_num_rows,
.selection_will_change = prv_skip_odd_rows,
});
menu_layer_reload_data(&l);
const int16_t basic_cell_height = menu_cell_basic_cell_height();
const int initial_scroll_offset = (DISP_ROWS - basic_cell_height) / 2;
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).section);
cl_assert_e... | (&l, &GRect(10, 10, height, DISP_COLS)) | ;
menu_layer_set_center_focused(&l, true);
s_num_rows = 3;
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks) {
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
.get_cell_height = prv_get_row_height_depending_on_selection_state,
});
menu_layer_set_center_focused(&l, true);
menu_... |
{ -160, -144, -992},
{ -160, -144, -984},
{ -160, -144, -992},
{ -160, -144, -992},
{ -152, -144, -992},
{ -160, -152, -992},
{ -152, -152, -984},
{ -160, -144, -1000},
{ -160, -152, -992},
// 297 seconds
{ -160, -144, -984},
{ -160, -152, -1000},
{ -160, -144, -992},... |
{ -128, -48, -1016},
{ -96, -104, -1040},
{ -80, -120, -1032},
{ -144, -88, -992},
{ -160, -80, -952},
{ -200, -96, -968},
{ -152, -96, -1008},
{ -120, -120, -1016},
{ -120, -176, -936},
{ -144, -168, -984},
{ -144, -200, -984},
{ -160, -192, -1016},
{ -144, -128, -9... | |
take priority
ADD_EVENT( .item = &s_item1 );
CHECK_EVENT( .count = 2, .item_id = s_item1.header.id, .num_concurrent = 0,
.timeout_ms = SECONDS_PER_MINUTE * MS_PER_SECOND,
.time_type = TimelinePeekTimeType_ShowWillStart, .is_first_event = true );
ADD_EVENT( .item = &s_item2 );
CHECK... | {
rtc_set_time(30 * SECONDS_PER_MINUTE);
ADD_EVENT( .item = &s_item2 );
CHECK_NO_EVENTS( .count = 2, .is_future_empty = true );
} |
void test_timeline_peek_event__dismiss_event(void) {
// Check that dismissing the last event causes no events to peek
TimelineItem *item = &s_future_item;
rtc_set_time(item->header.timestamp - TIMELINE_PEEK_DEFAULT_SHOW_BEFORE_TIME_S / 2);
ADD_EVENT( .item = item );
CHECK_EVENT( .count = 2, .item_id = item-... |
C, GMT-8 */
[31]={ 1425808800, 1446368400,-8 * SECONDS_PER_HOUR },
/* Uruguay (Uruguay) [America/Montevideo]
* Uruguay has abandoned DST */
[32]={ 0, 0,-3 * SECONDS_PER_HOUR },
/* W-Eur (Western Europe) [Nowhere uses this anymore] [Europ... | (&t, &now) | ;
time_t timestamp = clock_to_timestamp(TODAY, now.tm_hour, now.tm_min + 1);
cl_assert_equal_i(timestamp, t + 60);
}
}
void test_clock__cross_dst(void) {
struct tm oct_31 = {
.tm_sec = 0,
.tm_min = 59,
.tm_hour = 23,
.tm_mday = 31,
.tm_mon = 9, // Oct
.tm_year = 2015 - 1900,
.t... |
, // Attribute 2 Length
// Attribute text: "Test"
0x01
};
static uint8_t attr_list3_serialized[] = {
// Attribute 1
0x01, // Attribute ID - Title
0x11, 0x00, // Attribute Length
// Attribute text: "Test Notification"
0x54, 0x65, 0x73, 0x74... | (attribute_get_string(&list2, AttributeIdTitle, "") !=
attribute_get_string(&list, AttributeIdTitle, "")) | ;
cl_assert(attribute_get_string(&list2, AttributeIdSubtitle, "") !=
attribute_get_string(&list, AttributeIdSubtitle, ""));
cl_assert(attribute_get_string(&list2, AttributeIdBody, "") !=
attribute_get_string(&list, AttributeIdBody, ""));
attribute_list_destroy_list(&list);
kernel_free(buffer);
}
static... |
pe, timeline_peek_get_obstruction_origin_y())) {
PBL_LOG(LOG_LEVEL_ERROR, "App state configuration failed");
return false;
}
// The remaining space in app_segment is assigned to the app's heap.
// app_state needs to be configured before initializing the app heap
// as the AppState struct holds the app h... | app_inbox_service_unregister_all() | ;
app_outbox_service_cleanup_all_pending_messages();
#endif
light_reset_user_controlled();
sys_vibe_history_stop_collecting();
#if !defined(PLATFORM_TINTIN)
ble_app_cleanup();
#endif
#if CAPABILITY_HAS_MAPPABLE_FLASH
resource_mapped_release_all(PebbleTask_App);
#endif
app_comm_set_sniff_interval(SNIFF_INTE... |
/*
* 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... | GColorFromHEX(0x005500) | ).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0x550055)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0000)).argb);
// contradiction with previous case - oh dear...
// cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xff5500)).argb);
cl_assert_equal_i(GColorWhiteARG... |
meone pushed a button!
break;
}
}
if (button_state == 0) {
// We made it through with all the buttons released. We're good.
return;
}
// Alright, so either the button is held down or we hit a bounce. Wait
// for all the buttons to release again.
// 100000 is about a s... | for (int i = 0; i < 100000; ++i) {
if (button_get_state_bits() == 0) {
// stop waiting if not held down any longer and go back to sleep
return false;
}
} |
return true;
}
void leave_standby_mode(void) {
// Speed up the RTC so the firmware doesn't need to deal with it
rtc_speed_up();
}
|
/*
* 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_single_click_subscribe(BUTTON_ID_UP, prv_calibrate_confirm_cb);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_calibrate_confirm_pop);
window_single_click_subscribe(BUTTON_ID_BACK, prv_calibrate_confirm_pop);
} |
static TimerID s_timer = TIMER_INVALID_ID;
static void prv_push_calibration_dialog(void *data) {
shell_prefs_set_should_prompt_display_calibration(false);
ConfirmationDialog *confirmation_dialog = confirmation_dialog_create("Calibrate Prompt");
Dialog *dialog = confirmation_dialog_get_dialog(confirmation_dial... |
id_out = entry.uuid;
return true;
} else {
*uuid_out = UUID_INVALID;
return false;
}
}
bool app_install_is_watchface(AppInstallId app_id) {
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(app_id, &entry)) {
return false;
}
return app_install_entry_is_watchface(&entry);
}
s... | app_db_enumerate_entries(prv_enumerate_app_db_delete, 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... | {
fake_settings_file_reset();
return S_SUCCESS;
} |
// Setup
////////////////////////////////////////////////////////////////
void test_app_glance__initialize(void) {
fake_rtc_init(0, 1337);
fake_settings_file_reset();
app_glance_db_init();
app_glance_service_init();
s_test_state = (AppGlanceTestState) {};
}
void app_glance_db_deinit(void);
void test_app... |
.get($0);
var to_set = __jerryRefs.get($2);
obj[$1] = to_set;
return __jerryRefs.ref(true);
}, obj_val, index, value_to_set);
}
void jerry_init_property_descriptor_fields(jerry_property_descriptor_t *prop_desc_p) {
*prop_desc_p = (jerry_property_descriptor_t) {
.value = jerry_create_undefin... | jerry_value_is_constructor(func_obj_val) | |
/*
* 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(BITS_BETWEEN(0, 0), erased_sector) | ;
cl_assert(flash_locked);
}
void test_system_flash__erase_16KB_sectors(void) {
cl_assert(system_flash_erase(FLASH_BASE, 48 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 2), erased_sector);
cl_assert(flash_locked);
}
void callback_is_called_cb(uint32_t num, uint32_t den, void *context) {
callback_cal... |
vent_local_bt_disconnect(uint16_t conn_handle, uint32_t lr) {
AnalyticsEventBlob event_blob = {
.event = AnalyticsEvent_LocalBtDisconnect,
};
event_blob.local_bt_disconnect.lr = lr;
event_blob.local_bt_disconnect.conn_handle = conn_handle;
ANALYTICS_LOG_DEBUG("Event %d - BT Disconnect: Handle:%"PRIu16" ... | (uuid, uuid_string) | ;
ANALYTICS_LOG_DEBUG("App Crash event: uuid:%s, pc: %p, lr: %p",
uuid_string, (void *)pc, (void *)lr);
#endif
analytics_logging_log_event(&event_blob);
}
extern bool comm_session_is_valid(const CommSession *session);
// ----------------------------------------------------------------------... |
when we hit the storage limits...\n");
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_max_storage", 4096));
uint8_t key[5];
int key_len = 4;
uint8_t val[5];
int val_len = 4;
// 255 * (8 + 4 + 4) = 4080 + 8 + 8 = 4096
for (int i = 0; i < 255; i++) {
snprintf((char *)key, sizeof... | (0, 1388563200) | |
/*
* 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... | interval_timer_get(&timer, &average_ms) | ;
cl_assert_equal_i(num_intervals, 0);
cl_assert_equal_i(average_ms, 0);
fake_rtc_increment_time_ms(1000);
interval_timer_take_sample(&timer);
num_intervals = interval_timer_get(&timer, &average_ms);
cl_assert_equal_i(num_intervals, 1);
cl_assert_equal_i(average_ms, 1000);
fake_rtc_increment_time_ms(... |
values_buf_size, session);
prv_add_active_calories_metric_info(headings, headings_buf_size,
values, values_buf_size, session);
prv_add_hr_metric_info(headings, headings_buf_size, values, values_buf_size,
avg_hr, hr_zone_time_s);
} else if (ses... | task_zalloc_check(num_sessions * sizeof(ActivitySession)) | |
-248},
{ -1440, 520, -96},
{ -1648, 352, 64},
{ -1536, 360, 48},
{ -1264, 232, 88},
{ -1176, 152, 104},
{ -1152, 112, 136},
{ -1040, 24, 96},
{ -960, 464, -40},
// 54 seconds
{ -1128, 208, -88},
{ -912, -32, -32},
{ -800, -56, -136},
{ -1120, 128, -72},
{ -1216, ... | { -1200, 72, -48},
{ -1104, 176, -32},
{ -1216, 144, 120},
{ -1224, 56, 88},
{ -1080, 24, 64},
{ -1072, -48, 136},
{ -1128, -232, 184},
{ -1112, -256, 224},
{ -1328, 128, 104},
{ -1104, 200, -240},
{ -1312, 248, -208},
{ -1336, 112, -8},
{ -1152, -152, 96},
{ -100... |
{ -1232, -128, -112},
{ -1104, 88, -152},
{ -888, 224, -104},
{ -864, 328, -112},
{ -976, 344, -136},
{ -952, 288, -120},
{ -1208, 400, -200},
{ -1296, 712, -152},
{ -1328, 192, -168},
{ -1688, 280, -192},
// 62 seconds
{ -1272, 384, -296},
{ -1096, 384, -256},
{... |
ess_manager_send_event_to_process(task, &event);
}
// ----------------------------------------------------------------------------------------------
void *process_manager_address_to_offset(PebbleTask task, void *system_address) {
ProcessContext *context = prv_get_context_for_task(task);
if (system_address >= conte... | {
return prv_get_context()->install_id;
} | |
n_select_callback,
});
menu_layer_set_highlight_colors(menu_layer, SETTINGS_MENU_HIGHLIGHT_COLOR, GColorWhite);
menu_layer_set_click_config_onto_window(menu_layer, &data->window);
layer_add_child(&data->window.layer, menu_layer_get_layer(menu_layer));
}
static void prv_certification_window_unload(Window *wind... | text_layer_get_layer(&data->info_text) | );
}
static void prv_kcc_window_unload(Window *window) {
SystemCertificationData *data = (SystemCertificationData *) window_get_user_data(window);
prv_deinit_status_bar(&data->status_layer);
bitmap_layer_deinit(&data->bmp_layer);
text_layer_deinit(&data->title_text);
text_layer_deinit(&data->info_text);
i1... |
/*
* 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... | {
Fixed_S16_3 num;
int16_t test_num;
cl_assert(FIXED_S16_3_PRECISION == 3);
int Fixed_S16_3_size = sizeof(Fixed_S16_3);
cl_assert(Fixed_S16_3_size == sizeof(int16_t));
test_num = 1 << FIXED_S16_3_PRECISION;
num = (Fixed_S16_3){ .integer = 1, .fraction = 0 };
// Test number creation
test_num = (int... |
void test_math_fixed__S16_3_fraction(void) {
Fixed_S16_3 num;
int16_t test_num;
// This test shows how the values change across various fraction values
test_num = (int16_t)((float)-1.125 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -2);
cl_ass... |
{ 264, 912, 336},
{ 264, 736, 400},
{ 240, 768, 328},
{ 232, 784, 496},
{ 216, 848, 392},
{ 280, 856, 504},
{ 272, 736, 480},
{ 264, 816, 496},
{ 256, 816, 464},
{ 248, 800, 488},
{ 248, 792, 464},
{ 232, 760, 432},
{ 240, 760, 344},
{ 272, 752, 296},
{ 280, 8... |
{ 296, 864, 184},
{ 296, 840, 192},
{ 296, 824, 216},
{ 312, 800, 200},
{ 288, 800, 216},
{ 288, 824, 224},
{ 280, 800, 208},
{ 272, 824, 176},
{ 272, 832, 176},
{ 288, 872, 144},
{ 280, 928, 112},
{ 320, 872, 96},
{ 336, 936, 112},
{ 392, 920, 16},
{ 360, 92... | |
s_is_message_cancelled = true;
}
void comm_session_analytics_inc_bytes_sent(CommSession *session, uint16_t length) {
}
static CommSession s_system_session;
static CommSession *s_system_session_ptr;
CommSession *comm_session_get_system_session(void) {
return s_system_session_ptr;
}
static CommSession s_app_sessi... | app_message_sender_init() | ;
cl_assert(s_outbox_message_handler);
}
void test_app_message_sender__cleanup(void) {
// Flush out to avoid other tests failing:
if (s_system_session_ptr) {
prv_process_send_queue(s_system_session_ptr);
}
if (s_app_session_ptr) {
prv_process_send_queue(s_app_session_ptr);
}
}
// Tests that exerci... |
_color.right = DEFAULT_COLOR;
s_phone_ui_data->bg_color.boundary = 0;
#endif
const int16_t width = window->layer.bounds.size.w - (TEXT_MARGIN_WIDTH * 2);
// Container layer
layer_init(&s_phone_ui_data->core_ui_container, &window->layer.bounds);
layer_add_child(&window->layer, &s_phone_ui_data->core_ui_conta... | prv_phone_ui_init() | ;
s_phone_ui_data->show_ongoing_call_ui = show_ongoing_call_ui;
prv_unfold_icon_resource(TIMELINE_RESOURCE_INCOMING_PHONE_CALL);
bool can_reply = false;
if (caller) {
prv_display_caller_info(caller);
// Check if we support sms reply
can_reply = prv_load_sms_reply_action(caller->number, source);
... |
/*
* 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... | (builder, GPoint(x1234 / fixedpoint_base,
y1234 / fixedpoint_base)) | |
er off
accessory_set_baudrate(DEFAULT_BAUD);
periph_config_release_lock();
prv_initialize_exti();
}
static void prv_set_baudrate(uint32_t baudrate, bool force_update) {
if ((baudrate != s_baudrate) || force_update) {
PBL_LOG(LOG_LEVEL_DEBUG, "Changing accessory connector baud rate to %"PRIu32, baudrate)... | (s_send_semaphore, portMAX_DELAY) | |
prv_read_verify_byte(test_addr, data_pattern, FLASH_TEST_ERR_SKIP, 0, display_logs) | ;
if (status != FLASH_TEST_SUCCESS) {
// Write default data pattern to address
status = prv_write_read_verify_byte(test_addr, data_pattern, data_pattern, display_logs);
VERIFY_TEST_STATUS(status);
}
}
if (!skip_base_addr) {
test_addr = base_addr;
// Read initial value
read_bu... | |
nse");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WIT... | MAX(inset_amount - 1, MIN(outer_point.y, frame->size.h - inset_amount)) |
};
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
// UI Drawing
static void prv_draw_outer_ring(GContext *ctx, int32_t current, int32_t total,
int32_t fill_thickness, GRect frame, GColor color) {
graphics_context_set_f... |
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util/circular_cache.h"
#include "util/size.h"
#include "clar.h"
#include <string.h>
#define NUM_TEST_ITEMS (3)
typedef struct {
int id;
bool *freed;
} TestCacheItem;
// Stubs
static bool s_... | (&s_test_cache, &s_test_item[0]) | ;
circular_cache_push(&s_test_cache, &s_test_item[1]);
cl_assert(!circular_cache_contains(&s_test_cache, &s_test_item[2]));
cl_assert(circular_cache_contains(&s_test_cache, &s_test_item[0]));
cl_assert(circular_cache_contains(&s_test_cache, &s_test_item[1]));
}
void test_circular_cache__fill(void) {
circula... |
ar displays we just center it horizontally b/w the left edge of the display and
// the left edge of the action bar
#if PBL_RECT
x = (grect_get_max_x(bounds) - action_bar_width - icon_size.w) / 2;
#else
// On round displays we right align it with respect to the same imaginary vertical line that the
// text is ri... | dialog_pop(&workout_dialog->dialog) | ;
}
void workout_dialog_set_text(WorkoutDialog *workout_dialog, const char *text) {
dialog_set_text(&workout_dialog->dialog, text);
}
void workout_dialog_set_subtext(WorkoutDialog *workout_dialog, const char *text) {
if (workout_dialog->subtext_buffer) {
applib_free(workout_dialog->subtext_buffer);
}
uint... |
/*
* 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_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-4faa-b2a0-112aa910d7b4
.uuid = {0x4a, 0x71, 0xeb, 0x65, 0x23, 0x8... |
}
return s_text_styles[content_size].fonts[font];
fail:
PRIVILEGE_WAS_ELEVATED ? syscall_failed() : WTF;
}
////////////////////
// Public API
// *** WARNING WARNING WARNING ***
// Be very careful when modifying this syscall. It currently returns a pointer
// to constant data in flash, which unprivileged apps are... | analytics_set(ANALYTICS_DEVICE_METRIC_SYSTEM_THEME_TEXT_STYLE, content_size,
AnalyticsClient_System) | ;
}
|
codepoint);
valid_test_string_utf8 = utf8_get_next(valid_test_string_utf8);
}
}
void test_utf8__decode_malformed_test_string(void) {
bool success = false;
utf8_get_bounds(&success, s_malformed_test_string);
cl_assert(!success);
utf8_t* malformed_test_string_utf8 = (utf8_t*)s_malformed_test_string;
fo... | cl_assert_equal_i(16, utf8_get_size_truncate("Hello World! \xF0\x9F\x98", 17)) | ;
cl_assert_equal_i(13, utf8_get_size_truncate("Hello World! \xF0\x9F\x98\x84", 16));
cl_assert_passert(utf8_get_size_truncate("Hi", 0));
}
void test_utf8__truncate_with_ellipsis(void) {
// basic smoke test
char *output_buffer = malloc(6);
size_t trunc_size = utf8_truncate_with_ellipsis("WWWWWWWWWWWWWWW", o... |
/*
* 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... | ("size", "small") | ;
}
void test_rocky_api_preferences__medium(void) {
s_preferred_content_size = PreferredContentSizeMedium;
rocky_global_init(s_preferences_api);
EXECUTE_SCRIPT("var size = _rocky.userPreferences.contentSize");
ASSERT_JS_GLOBAL_EQUALS_S("size", "medium");
}
void test_rocky_api_preferences__large(void) {
s_p... |
o the compositor dot
// by changing the bounds of the progress_layer using 2 animations
layer_set_clips((Layer *)&data->progress_layer, false); // Extending bounds to grow the dot
progress_layer_set_corner_radius(&data->progress_layer, DOT_TRANSITION_RADIUS);
mid.size.w = DOT_TRANSITION_RADIUS * 2;
mid.size.... | CLIP(progress, data->progress_percent, MAX_PROGRESS_PERCENT) | ;
progress_layer_set_progress(&data->progress_layer, data->progress_percent);
}
static void prv_fake_update_progress(void *context) {
ProgressWindow *data = context;
prv_set_progress(data, data->progress_percent + FAKE_PROGRESS_UPDATE_AMOUNT);
if (data->progress_percent >= data->max_fake_progress_percent) {
... |
it's garbage data anyway).
break;
}
if (overwritten(hdr) || deleted_and_expired(hdr)) {
continue;
}
if (partially_overwritten(hdr)) {
// The only case where we should hit this is if we are compacting a file
// which has a record which was in the middle of being overwritten, but
... | settings_raw_iter_next(&file->iter) | ; // Skip the current record
bool found_another = search_forward(&file->iter, key, file->iter.hdr.key_len);
if (!found_another) {
// No other file->iter.hdr found, we must have rebooted in the middle of
// writing the new record. Compacting the file will copy over the
// previous record while... |
liance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either ... | {
uintptr_t myLR = (uintptr_t) __builtin_return_address(0);
OS_ASSERT(!mcu_state_is_isr());
xLightMutexLockRecursive(handle->common.freertos_mutex, portMAX_DELAY);
LOG_LOCKED(handle->common.lr, myLR);
} |
bool mutex_lock_recursive_with_timeout_and_lr(PebbleRecursiveMutex * handle,
uint32_t timeout_ms, uint32_t myLR) {
OS_ASSERT(!mcu_state_is_isr());
TickType_t timeout_ticks = milliseconds_to_ticks(timeout_ms);
LightMutexHandle_t mutex = handle->common.freertos_mutex;
if (xLightMutexLockRecursive(mutex, t... |
OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "i2c_hal.h"
#include "i2c_definitions.h"
#include "i2c_hal_definitions.h"
#include "drivers/periph_config.h"
#include "system/logging.h"
#include "system/passe... | (bus->hal->i2c, bus->hal->clock_ctrl) | ;
// We currently don't need to worry about the other TIMINGR fields (they come out to 0), but might
// need to revisit this if we ever need FM+ speeds.
TIMINGR timingr = {
.PRESC = prescaler,
.SCLH = duty_cycle_high - 1, // Duty cycle high is SCLH + 1
.SCLL = duty_cycle_low - 1, // Duty cycle low i... |
,
{ 136, 936, -512},
{ 136, 912, -544},
{ 72, 904, -560},
{ 0, 864, -576},
{ 56, 696, -688},
// 74 seconds
{ 56, 624, -760},
{ 48, 688, -664},
{ 48, 792, -600},
{ 104, 968, -680},
{ 112, 960, -704},
{ 128, 768, -656},
{ 176, 672, -752},
{ 184, 616, -856},
{ 20... | { 368, 352, -912},
{ 384, 376, -904},
{ 384, 400, -920},
{ 384, 392, -896},
{ 368, 376, -896},
{ 368, 392, -904},
{ 384, 376, -920},
{ 376, 360, -896},
{ 376, 416, -864},
{ 384, 376, -840},
{ 408, 456, -920},
{ 344, 528, -904},
{ 384, 456, -944},
{ 344, 448, -872}... |
{ -672, 272, 352},
{ 400, 488, -616},
{ -272, 448, -800},
{ -608, -224, -280},
{ -688, -112, -224},
{ -840, -344, -336},
{ -888, -432, -584},
{ -960, -400, -616},
{ -800, -240, -528},
{ -696, -128, -400},
{ -600, -88, -512},
{ -624, -144, -440},
{ -696, -216, -424},
... |
MPLETE = true;
shared_prf_storage_store_ble_pairing_data(&PAIRING_INFO, DEVICE_NAME,
true /* requires_address_pinning */, 0xff /* flags */);
shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE);
shared_prf_storage_set_local_device_name(DEVICE_NAME)... | ((uint8_t *)&data,
SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_page_number()),
sizeof(data)) | ;
cl_assert_equal_i(data.getting_started.crc, new_crc);
// Should be corrupt, so it should return false
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), false);
// Should have moved to the next page
cl_assert_equal_b(shared_prf_storage_get_valid_page_number(), 1);
// Let's do it again,... |
cted. Therefore, if
// it's a frame error, let's carry on and see if the data we read matches what we expect
// anyway
if (!errors.framing_error) {
PBL_LOG(LOG_LEVEL_WARNING, "UART ERROR: 0x%x 0x%d", (int)errors.error_mask, (int)dr);
return false;
} else {
PBL_LOG(LOG_LEV... | prv_bootrom_wait_for_char_with_timeout(&c, wait_time_ticks) | ) {
PBL_LOG(LOG_LEVEL_ERROR, "Error waiting for chip ID / start message (i=%"PRIu32")", i);
success = false;
goto cleanup;
}
if (c == 0x02) {
// Got start message!
break;
} else if (c == 'D') { // First valid character we expect to receive for AE silicon
wait_time_ms = DI... |
ual_i(s_data.pins_added, 1);
// Make sure we still merge properly after a power cycle
activity_insights_init(rtc_get_time());
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR);
prv_add_sleep_session(0.5, 1.5);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 2);
... | cl_assert_equal_i(s_data.pins_added, 1) | ;
// Re-init (simulates power cycle) and make sure we don't add a pin again
activity_insights_init(rtc_get_time());
activity_insights_process_minute_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 1);
// Make sure we still trigger properly after a power cycle
activity_insights_init(rtc_get_time... |
nt key_len, const uint8_t *val,
int val_len);
void test_app_glance_db__read_stale_glance_blob(void) {
// Force the insertion of a stale glance blob (outdated version)
const SerializedAppGlanceHeader app_glance = (SerializedAppGlanceHeader) {
.version = APP_GLANCE_DB_CURRENT_... | (NULL, &glance_out) | , E_INVALID_ARGUMENT);
// NULL glance_out fails
cl_assert_equal_i(app_glance_db_read_glance(&APP_GLANCE_TEST_UUID, NULL), E_INVALID_ARGUMENT);
}
void test_app_glance_db__inserting_glance_with_invalid_arguments_fails(void) {
// NULL UUID fails
const AppGlance glance = {};
cl_assert_equal_i(app_glance_db_inse... |
/*
* 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(8675309, (uintptr_t)context) | ;
}
void test_system_flash__callback_is_called(void) {
cl_assert(system_flash_erase(FLASH_BASE, 16 KiB, callback_is_called_cb,
(void *)8675309));
cl_assert(callback_called);
cl_assert(flash_locked);
}
void test_system_flash__handle_erase_error(void) {
return_status = FLASH_ERROR_OPERATION;
cl_as... |
, 152, 256},
{ 904, 200, 232},
{ 752, 280, 56},
{ 736, 312, 16},
{ 824, 400, -16},
{ 944, 360, 8},
{ 1088, 648, -120},
{ 1280, 568, 56},
{ 1800, 552, 240},
{ 1664, 424, 224},
{ 1096, 336, 88},
{ 1312, 352, 88},
{ 1584, 264, 224},
{ 1408, 88, 400},
{ 1160, 40, 344}... | { 824, 424, 88},
{ 864, 536, 8},
{ 896, 504, 32},
{ 1136, 480, 72},
{ 1224, 472, 152},
// 53 seconds
{ 1640, 560, 176},
{ 1552, 536, 224},
{ 1088, 336, 168},
{ 1288, 280, 224},
{ 1736, 248, 104},
{ 1240, 144, 368},
{ 1216, 96, 152},
{ 1056, 0, 296},
{ 912, -16... |
{ 1096, 32, 216},
{ 944, 24, 160},
{ 848, 24, 104},
{ 768, -8, 96},
{ 664, -24, 24},
{ 584, -128, 0},
{ 752, -24, -104},
{ 992, 152, -192},
{ 1464, -144, 136},
{ 1600, 8, 304},
{ 1512, 384, 72},
// 56 seconds
{ 1496, 592, -72},
{ 1192, 496, 224},
{ 1048, 232,... |
p_state.h"
#include "resource/resource_ids.auto.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
enum ActionBarState {
ActionBarStateSkip,
ActionBarStateVolume,
ActionBarStateLongPress,
};
typedef struct MusicAppSizeC... | (0, prv_content_width() - config->cassette_rect.size.w) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.