prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
abled(), true);
assert_ad_data("A");
gap_le_assert_advertising_interval(advert_terms_a[1].min_interval_slots,
advert_terms_a[1].max_interval_slots);
// Expect silence. B's third (silent) is 2 secs, so one more to go and A's third term is silent.
regular_timer_fire_seconds(1... | (!gap_le_is_advertising_enabled()) | ;
cl_assert_equal_i(regular_timer_seconds_count(), 0);
// The job should been have been unscheduled:
cl_assert_equal_i(s_unscheduled_cb_count, 1);
cl_assert_equal_p(s_unscheduled_job, job);
cl_assert_equal_b(s_unscheduled_completed, true);
free(ad);
}
void test_gap_le_advert__invalid_params(void) {
GAP... |
TimelineResourceId card_res) {
attribute_list_add_uint32(list, AttributeIdIconTiny, timeline_res);
attribute_list_add_uint32(list, AttributeIdIconSmall, card_res ?: timeline_res);
attribute_list_add_uint32(list, AttributeIdIconLarge, card_res ?: timeline_res);
}
#define ARRAY_RAND(arr) arr[rand() % AR... | attribute_list_add_uint32(&list, AttributeIdSportsGameState, is_ingame ? 1 : 0) | ;
attribute_list_add_cstring(&list, AttributeIdNameAway, "GSW");
attribute_list_add_cstring(&list, AttributeIdRecordAway, "114-152");
attribute_list_add_cstring(&list, AttributeIdScoreAway, "86");
attribute_list_add_cstring(&list, AttributeIdNameHome, "CHI");
attribute_list_add_cstring(&list, AttributeIdRecor... |
SSERTN(dst < src);
*dst++ = (buf & 0xFF);
buf >>= 8;
buf_num_bits -= 8;
}
// Now process the second nibble
rle_unit_pair >>= 4;
num_rle_units--;
}
}
// Flush out any remaining pixels
while (buf_num_bits > 0) {
PBL_ASSERTN(dst < &((uint8_t *)g->data)[CACHE_... | {
cached = (LineCacheData *)(font_cache->glyph_buffer);
} |
#endif
PBL_LOG_D(LOG_DOMAIN_TEXT, LOG_LEVEL_DEBUG, "looking up cp: %"PRIx32", key:%"PRIx32,
codepoint, cache_key);
// If the glyph_buffer doesn't match this glyph, or we have bitmap caching, check the
// keyed_circular_cache for this glyph.
if (!cached) {
cached = keyed_circular_cache_get(&fon... |
_icons_enabled(&data->option_menu, use_icons /* icons_enabled */);
option_menu_set_choice(&data->option_menu, prv_get_chosen_row_index(data));
option_menu_reload_data(&data->option_menu);
}
// Settings Menu callbacks
///////////////////////////
static void prv_select_cb(OptionMenu *option_menu, int row, void *co... | {
AppMenuNode *node = app_menu_data_source_get_node_at_index(data->data_source, row - 1);
title = node->name;
} |
option_menu_system_draw_row(option_menu, ctx, cell_layer, text_frame, title, false, NULL);
}
static uint16_t prv_row_height_cb(OptionMenu *option_menu, uint16_t row, bool is_selected,
void *context) {
const int16_t cell_height =
option_menu_default_cell_height(option_menu-... |
cteristics);
}
void test_ancs__cleanup(void) {
ancs_destroy();
cl_assert_equal_i(regular_timer_seconds_count(), 0);
cl_assert_equal_i(regular_timer_minutes_count(), 0);
regular_timer_deinit();
}
// Janky black box smoke-test to exercise the ANCS message re-assembly state
// machine
void test_ancs__should_hand... | (fake_kernel_services_notifications_ancs_notifications_count(), 1) | |
on_menu, GColor background, GColor foreground) {
option_menu->normal_colors.background = background;
option_menu->normal_colors.foreground = foreground;
menu_layer_set_normal_colors(&option_menu->menu_layer,
option_menu->normal_colors.background,
optio... | gbitmap_deinit(&option_menu->not_chosen_image) | ;
}
OptionMenu *option_menu_create(void) {
OptionMenu *option_menu = applib_type_malloc(OptionMenu);
if (!option_menu) {
return NULL;
}
option_menu_init(option_menu);
return option_menu;
}
void option_menu_destroy(OptionMenu *option_menu) {
option_menu_deinit(option_menu);
applib_free(option_menu);
... |
G_FILE_FMT(1bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(1bitpalette)));
cl_assert_equal_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) {
GBitm... | (bitmap, TEST_PBI_FILE_FMT(1bitpalette)) | );
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat1BitPalette);
}
// Tests 2-bit transparent greyscale PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__greyscale_2_bit_transparent(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(2bitpalette));
cl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | list_get_next(node) | |
ad_set_service_uuids() will be "smart" and include only the 16-bit UUID, but only if the
// BT SIG Base UUID is used.
Uuid service_uuids[2];
size_t num_uuids = 0;
#if CAPABILITY_HAS_BUILTIN_HRM
// NOTE: The HRM service has to be first in the list because otherwise the Pebble won't
// show up as an HRM device... | gap_le_advert_unschedule(s_discovery_advert_job) | ;
if (discoverable) {
prv_schedule_ad_job();
}
}
bt_unlock();
}
// -----------------------------------------------------------------------------
void gap_le_slave_discovery_init(void) {
bt_lock();
{
PBL_ASSERTN(!s_discovery_advert_job);
}
bt_unlock();
}
// -------------------------------... |
/*
* 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_crumb_config() | ->layer_width;
}
static int prv_crumb_x_position(void) {
return prv_crumb_config()->layer_width / 2;
}
static int prv_crumb_radius(void) {
return prv_crumb_config()->crumb_radius;
}
static int prv_crumb_spacing(void) {
return prv_crumb_config()->crumb_spacing;
}
static int prv_crumb_space_from_top(void) {
r... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (data->cur_temp_layer, data->cur_temp_text) | |
/*
* 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... | {
__atomic_or_fetch(&PWR->CSR2, PWR_CSR2_EWUP1, __ATOMIC_RELAXED);
} | else {
__atomic_and_fetch(&PWR->CSR2, ~PWR_CSR2_EWUP1, __ATOMIC_RELAXED);
}
}
void pwr_flash_power_down_stop_mode(bool power_down) {
if (power_down) {
__atomic_or_fetch(&PWR->CR1, PWR_CR1_FPDS, __ATOMIC_RELAXED);
} else {
__atomic_and_fetch(&PWR->CR1, ~PWR_CR1_FPDS, __ATOMIC_RELAXED);
}
}
void pw... |
, 0x0b);
(*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e);
}
}
// The SubBytes Function Substitutes the values in the
// state matrix with values in an S-box.
static void InvSubBytes(void)
{
uint8_t i,j;
for(i=0;i<4;++i)
{
for(j=0;j<4;++j)
{
(*st... | memset(output + remainders, 0, KEYLEN - remainders) | ; /* add 0-padding */
state = (state_t*)output;
Cipher();
}
}
void AES128_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv)
{
uintptr_t i;
uint8_t remainders = length % KEYLEN; /* Remaining bytes in the last non-full block */
BlockCopy(output, ... |
/*
* 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... | (reel, from, GStrokeWidthOpSet) | |
/*
* 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_unlock(mutex) | ;
cl_assert_equal_b(fake_mutex_all_unlocked(), true);
}
void test_fake_mutex__leave_unlocked(void) {
PebbleMutex *mutex = mutex_create();
mutex_lock(mutex);
cl_assert_equal_b(fake_mutex_all_unlocked(), false);
}
void test_fake_mutex__double_lock(void) {
fake_mutex_set_should_assert(false);
PebbleMutex *m... |
nt_storage_store_bt_classic_pairing(&addr_in, &link_key_in,
name_in, &platform_bits_in);
cl_assert(id != BT_BONDING_ID_INVALID);
// Read it back
BTBondingID id_out = bt_persistent_storage_get_bt_classic_pairing_by_addr(&addr_in, &link_key_out,
... | cl_assert(id != BT_BONDING_ID_INVALID) | ;
// Delete the Pairing
bt_persistent_storage_delete_bt_classic_pairing_by_addr(&addr_in);
// Try to read it back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
name_out, &platform_bits_out);
cl_assert(!ret);
// A... |
t, GFont const font, const GRect box,
const GTextOverflowMode overflow_mode, const GTextAlignment alignment,
const GTextLayoutCacheRef layout_ref) {
GTextNodeText *text_node = (GTextNodeText *)s_data.text_node;
cl_assert(text_node);
cl_assert_equal_s(text_node->text... | (size.h > 0) | ;
cl_assert_equal_i(size.w, TEST_TEXT_SIZE.w);
cl_assert_equal_i(size.h, TEST_TEXT_SIZE.h);
cl_assert_equal_i(size.w, custom_node.node.cached_size.w);
cl_assert_equal_i(size.h, custom_node.node.cached_size.h);
cl_assert_equal_i(s_num_draw_custom_calls, 1);
}
void test_graphics_text_node__create_container_nod... |
ue;
active = do_not_disturb_is_active();
cl_assert(active == true);
// Testing the override capability
do_not_disturb_set_manually_enabled(false);
active = do_not_disturb_is_active();
cl_assert(active == false);
}
void test_do_not_disturb__weekday_weekend_schedule(void) {
bool active;
cl_assert(do_n... | (s_thursday_01_00) | ;
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 00:00 on Saturday. (47.0 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 169200 * MS_PER_SECOND);
do_not_disturb_set_schedule_enabled(WeekendSchedule, false)... |
ack_remove(&active_window->window, false);
}
static void prv_end_workout_down_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutActiveWindow *active_window = context;
workout_dialog_pop(&active_window->end_workout_dialog);
}
static void prv_end_workout_click_config_provider(void *context) {
... | window_get_user_data(window) | ;
if (active_window) {
app_timer_cancel(active_window->update_timer);
app_timer_cancel(active_window->hr_measuring_timer);
gbitmap_destroy(active_window->action_bar_start);
gbitmap_destroy(active_window->action_bar_pause);
gbitmap_destroy(active_window->action_bar_stop);
gbitmap_destroy(active... |
/*
* 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... | attribute_list_add_uint32(list, AttributeIdIconSmall, card_res ?: timeline_res) | |
serialized_prefs->data,
serialized_prefs_data_len,
&string_alloc_size,
attributes_per_action);
if (!r) {
char buffer[key_len + 1];
strncpy(buffer, (const char... | {
char buffer[key_len + 1];
strncpy(buffer, (const char *)key, key_len);
buffer[key_len] = '\0';
PBL_LOG(LOG_LEVEL_INFO, "iOS notif pref insert <%s>", buffer);
// All records inserted from the phone are not dirty (the phone is the source of truth)
rv = settings_file_mark_synced(&file, key, key_... |
prv_file_close_and_unlock(&file);
return rv;
}
int ios_notif_pref_db_get_len(const uint8_t *key, int key_len) {
if (key_len == 0) {
return 0;
}
SettingsFile file;
status_t rv = prv_file_open_and_lock(&file);
if (rv != S_SUCCESS) {
return 0;
}
int length = settings_file_get_len(&file, key... |
L_LOG(LOG_LEVEL_ERROR, "Err %d while writing", (int)bytes_wrote);
return false;
} else if (bytes_wrote < (int)size) {
PBL_LOG(LOG_LEVEL_ERROR, "Wrote only %d bytes, expected %d", (int)bytes_wrote, (int)size);
return false;
}
return true;
}
// ---------------------------------------------------------... | {
prv_release_session_file(session);
} |
return true;
}
// -----------------------------------------------------------------------------------------
// Make sure there is at least 'needed' bytes available in our file system space
// allowed for data logging
static bool prv_make_file_system_space(uint32_t needed) {
// Make sure we have at least 'needed'... |
f (!layer_process_tree_level(node->first_child, ctx, iterator_func)) {
return false;
};
node = node->next_sibling;
}
return true;
}
void layer_process_tree(Layer *node, void *ctx, LayerIteratorFunc iterator_func) {
layer_process_tree_level(node, ctx, iterator_func);
}
inline static Layer __attrib... | graphics_release_frame_buffer(ctx, &ctx->dest_bitmap);
APP_LOG(APP_LOG_LEVEL_WARNING,
"Frame buffer was not released. "
"Make sure to call graphics_release_frame_buffer before leaving update_proc.");
}
descend = true;
}
node_hidden_do_not_descend:
node = prv_... |
}
void layer_property_changed_tree(Layer *node) {
layer_process_tree(node, NULL, layer_property_changed_tree_node);
}
void layer_set_update_proc(Layer *layer, LayerUpdateProc update_proc) {
PBL_ASSERTN(layer != NULL);
layer->update_proc = update_proc;
}
void layer_set_frame(Layer *layer, const GRect *frame) {... |
aw_value, p1.y.raw_value) + radius.raw_value;
const int8_t fraction_for_top = top_point & fraction_mask;
const int8_t fraction_for_bottom = bottom_point & fraction_mask;
// Drawing loop: Iterates over horizontal lines
// As part of optimisation, this algorithm is moving between drawing boundaries,
... | (ctx, y, left_margin, right_margin) | ;
}
}
// Blending of last line
if (fraction_for_bottom != 0) {
int16_t y = y_max + 1;
// Starting and ending point of the line, initialized with extremes
Fixed_S16_3 left_margin = {.raw_value = INT16_MAX};
Fixed_S16_3 right_margin = {.raw_value = INT16_MIN};
// Find ed... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (GetTempPath((DWORD)length, buffer))
return 0; |
#endif
/* This system doesn't like us, try to use the current directory */
if (is_valid_tmp_path(".")) {
strncpy(buffer, ".", length);
return 0;
}
return -1;
}
static void clar_unsandbox(void)
{
if (_clar_path[0] == '\0')
return;
#ifdef _WIN32
chdir("..");
#endif
fs_rm(_clar_path);
}
char *mkdtemp(c... |
_serial.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
#define TEST_START FLASH_REGION_FILE_TEST_SPACE_BEGIN
#define TEST_SIZE (FLASH_REGION_FILE_TEST_SPACE_END - \
FLASH_REGION_FILE_TEST_SPACE_BEGIN)
extern void notification_storage_reset(void);
typedef void (*SystemTaskEventCallback)(void *data);... | (a->action_group.actions[i].attr_list, b->action_group.actions[i].attr_list) | ;
}
}
// Tests
////////////////////////////////////
void test_notification_storage__basic(void) {
Uuid id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4};
TimelineItem e = {
.header = {
.id = id,
.status = 0,
.layout = LayoutId... |
8_t *)event, sizeof(PebbleHRMEvent));
}
static void prv_populate_hrm_event(PebbleHRMEvent *event, HRMFeature feature, const HRMData *data) {
switch (feature) {
case HRMFeature_BPM:
*event = (PebbleHRMEvent) {
.event_type = HRMEvent_BPM,
.bpm = {
.bpm = data->hrm_bpm,
.qu... | if (state->callback_handler) {
// For kernel BG subscribers, we only queue one event of each type (which is then
// dispatched to all KernelBG subscribers from the KernelBG callback) so that we don't
// overfill our limited size circular buffer.
if (kernel_bg_features_sent & feature) {
... |
prv_populate_hrm_event(&hrm_event, feature, data);
PBL_ASSERTN(prv_event_put(state, &hrm_event));
}
// If this is an app subscription, see if we need to send an "expiring" event. We check
// KernelBG subscribers from the system callback function (prv_system_task_hrm_handler).
if (!state->c... |
.origin_y = 48,
.size_h = 85
},
.paging.origin_on_screen.y = 412,
},
};
char text[] = "Dib: You're just jealous...\nZim: This has nothing to do with jelly!\n"
"Zim: You dare agree with me? Prepare to meet your horrible doom!";
prv_prepare_fb_steps_xy(GSize(180, 300), 1, 1);
ctx.dr... | (size_with_orphan_avoidance.h, 279) | ;
cl_assert_equal_i(size_without_orphan_avoidance.h, 255);
}
void test_graphics_draw_text_flow__no_infinite_loop(void) {
TextLayoutExtended layout = {
.flow_data = {
.perimeter.impl = &(GPerimeter){.callback = perimeter_for_display_rect},
},
};
char text[] = "Prevent orhpans for tall-enough pages... |
er = (TimelineLayer *)context;
if (timeline_layer_should_animate_day_separator(layer)) {
prv_rel_bar_reset_offsets(&layer->relbar_layer, RelationshipBarOffsetTypeCurr);
layer_set_hidden(&layer->relbar_layer.layer, true);
return;
}
layer_set_hidden(&layer->relbar_layer.layer, false);
if (layer->relb... | prv_create_curr_rel_bar_animation(layer, duration, interpolate) | |
}
void status_bar_layer_set_separator_mode(StatusBarLayer *status_bar_layer,
StatusBarLayerSeparatorMode mode) {
PBL_ASSERTN(status_bar_layer);
status_bar_layer->config.separator.mode = mode;
layer_mark_dirty(&(status_bar_layer->layer));
}
void status_bar_layer_set_separ... | (config->background_color) | ) {
graphics_context_set_fill_color(ctx, config->background_color);
graphics_fill_rect(ctx, bounds);
}
// Set context text color and compositing mode
graphics_context_set_text_color(ctx, config->foreground_color);
graphics_context_set_compositing_mode(ctx, GCompOpSet);
// update title buffer with ti... |
v_region_size(i);
}
PBL_LOG(LOG_LEVEL_DEBUG, "Filesystem: Temporary size - %"PRId32" Kb", (s_ftl_size / 1024));
pfs_set_size(s_ftl_size, false /* don't erase regions */);
}
//! return a layout version that associates with the labels from above
static uint8_t prv_ftl_get_layout_version(void) {
// add all regio... | if (operation == FTLEraseSector) {
PBL_ASSERTN(size == SECTOR_SIZE_BYTES);
flash_erase_sector_blocking(
s_region_list[idx].start + offset - curr_virt_offset_begin);
} | |
/*
* 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... | {
AttributeList pin_attr_list = {0};
attribute_list_add_uint32(&pin_attr_list, AttributeIdIconTiny,
TIMELINE_RESOURCE_NOTIFICATION_REMINDER);
attribute_list_add_cstring(&pin_attr_list, AttributeIdTitle, data->reminder_str);
attribute_list_add_uint8(&pin_attr_list, AttributeIdBgColor,... |
TimelineItemTypePin,
LayoutIdGeneric,
&pin_attr_list,
&action_group);
item->h... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | resource_init() | ;
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
test_graphics_context_init(&s_ctx, fb);
framebuffer_clear(fb);
}
void test_emoji_fonts__cleanup(void) {
free(fb);
fb = NULL;
gbitmap_destroy(s_dest_bitmap);
s_dest_bitmap = NULL;
}
// Helpers
////////////////... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (key_len != UUID_SIZE ||
val_len < (int)sizeof(SerializedTimelineItemHeader)) {
return E_INVALID_ARGUMENT;
}
// [FBO] this is a little bit silly: we deserialize the item to then re-serialize it in
// notification_storage_store. It has the advantage that it validates the payload
// and works wi... |
int notif_db_get_len(const uint8_t *key, int key_len) {
if (key_len < UUID_SIZE) {
return 0;
}
return notification_storage_get_len((Uuid *)key);
}
status_t notif_db_read(const uint8_t *key, int key_len, uint8_t *val_out, int val_out_len) {
// NYI
return S_SUCCESS;
}
status_t notif_db_delete(const uin... |
.res_id = prv_get_emoji_icon(layout),
},
.align = GAlignCenter,
.icon_layer = &layout->detail_icon_layer,
.extent.offset.y = style->body_icon_offset,
.extent.margin.h = style->body_icon_margin,
};
#endif
const LayoutNodeTextAttributeConfig location_config = {
.attr_id = AttributeIdLocationNa... | (&layout->icon_layer, &GRect(origin_x, origin_y, icon_size.w, icon_size.h)) | ;
kino_layer_set_reel_with_resource_system(&layout->icon_layer, layout->icon_res_info.res_app_num,
layout->icon_res_info.res_id);
layer_add_child(&layout->layout.layer, kino_layer_get_layer(&layout->icon_layer));
}
static void NOINLINE prv_init_view(NotificationLayout *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... | (FONT_KEY_GOTHIC_24_BOLD) | |
/*
* 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... | {
// Match the impedance of the traces (~50 ohms) by configuring the drive strength of the data
// output pins on the MT25Q to the 45 ohm setting This avoids signal integreity issues. This is
// done by setting bits 2:0 in the "Enhanced Volatile Configuration Register" to 101b.
const uint8_t read_instruction = ... |
status_t flash_impl_init(bool coredump_mode) {
qspi_flash_init(QSPI_FLASH, &QSPI_FLASH_PART, coredump_mode);
#if BOARD_CUTTS_BB || BOARD_ROBERT_BB || BOARD_ROBERT_EVT
prv_set_high_drive_strength();
#endif
return S_SUCCESS;
}
status_t flash_impl_get_erase_status(void) {
return qspi_flash_is_erase_complete(QSP... |
ssion->data-mutex
// - if you already own session->data-mutex, it is OK to grab s_list_mutex
bool dls_lock_session(DataLoggingSession *session) {
mutex_lock_recursive(s_list_mutex);
if (session->status != DataLoggingStatusActive) {
mutex_unlock_recursive(s_list_mutex);
return false;
}
PBL_ASSERTN(... | {
if (iter->tag == tag && uuid_equal(&(iter->app_uuid), app_uuid)
&& iter->status == DataLoggingStatusActive) {
mutex_unlock_recursive(s_list_mutex);
return (iter);
}
iter = iter->next;
} |
mutex_unlock_recursive(s_list_mutex);
return (NULL);
}
void dls_list_remove_session(DataLoggingSession *logging_session) {
if (uuid_is_system(&logging_session->app_uuid)) {
PBL_LOG(LOG_LEVEL_WARNING, "Deleting the system data logging session with tag %"PRIu32,
logging_session->tag);
}
mute... |
m1 = {
.header = {
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4},
.timestamp = 0,
.duration = 0,
.type = TimelineItemTypeReminder,
} // don't care about the rest
};
static TimelineItem item2 = {
.header = {
.id = {0x55, 0x... | cl_assert(stub_new_timer_fire(get_reminder_timer_id())) | ;
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
fake_system_task_callbacks_invoke(1);
cl_assert_equal_i(num_events_put, 5);
cl_assert(!new_timer_scheduled(get_reminder_timer_id(), NULL));
}
void test_reminders__first_init_test(void) {
cl_assert_equal_i(reminders_init(), 0);
test_reminders__t... |
eekdays(ActionMenu *action_menu,
const ActionMenuItem *action_menu_item,
void *context) {
prv_mute_notification(action_menu_item, MuteBitfield_Weekdays);
}
static void prv_mute_notification_weekends(ActionMenu *action_menu,
... | (&item->attr_list, AttributeIdiOSAppIdentifier, "") | ;
iOSNotifPrefs *notif_prefs = ios_notif_pref_db_get_prefs((uint8_t *)app_id, strlen(app_id));
char *display_name = "";
if (notif_prefs) {
display_name = (char *)attribute_get_string(¬if_prefs->attr_list, AttributeIdAppName, "");
}
const char *mute_label = i18n_noop("Mute %s");
static ... |
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign) | ;
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPoint(30, 1), DEG_TO_TRIGANGLE(2), GPoint(72, 84));
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_offset_topedge_2.Xbit.pbi"));
// left edge center rotation point, Angle 2
setup_test_rotate_bitmap(&ctx, fb, ... | |
ediv,
pairing_info_out.local_encryption_info.ediv);
cl_assert_equal_i(pairing_info->local_encryption_info.div,
pairing_info_out.local_encryption_info.div);
cl_assert_equal_i(pairing_info->identity.opaque.opaque_64,
pairing_info_out.identity.opaque.opaque_6... | (&out_addr, &addr, sizeof(addr)) | , 0);
cl_assert_equal_i(memcmp(&link_key_out, &link_key_out, sizeof(link_key)), 0);
cl_assert_equal_i(platform_bits_out, 0xaa);
shared_prf_storage_erase_bt_classic_pairing_data();
cl_assert_equal_b(shared_prf_storage_get_bt_classic_pairing_data(NULL, NULL, NULL, NULL), false);
}
void test_shared_prf_storage_v... |
event(true, false);
}
return session;
}
// -------------------------------------------------------------------------------------------------
//! bt_lock() is expected to be taken by the caller!
void comm_session_close(CommSession *session, CommSessionCloseReason reason) {
PBL_ASSERTN(comm_session_is_valid(sess... | {
return session->is_send_next_call_pending;
} | |
nvalid length");
return;
}
int value = atoi(value_str);
if ((value < 0) || (value > 0xFF)) {
prompt_send_response("Invalid value");
return;
}
// Fill flash with a character value
uint8_t page[WRITE_PAGE_SIZE_BYTES];
for (uint32_t i = 0; i < WRITE_PAGE_SIZE_BYTES; i++) {
page[i] = (uint8_... | if (memmap_buffer[i] != want) {
char err_buf[80];
prompt_send_response_fmt(err_buf, sizeof(err_buf), "FAIL at ADDR %d Got: %d Wanted %d",
(int)offset, (int)memmap_buffer[i], (int)want);
break;
} | |
Handle 0x%x", item->i.start_h);
}
}
return payload;
failure:
kernel_free(payload);
return NULL;
}
static void prv_write_cccd_cb(const ble_evt_gattc_write_completed_t *evt) {
if (evt->status != ATT_ERROR_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to write CCCD for idx %d Handle 0x%04X",
evt-... | if (uuid_equal(&payload->service.uuid, &ppogatt_uuid)) {
PBL_LOG(LOG_LEVEL_DEBUG, "PPoGATT found");
ppogatt_emulated_notify_phone_ppogatt_server_found(connection);
} | |
/*
* 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... | {
// Unused in snowy as PMIC turns off everything
} |
// We don't actually support the mag at all on snowy_evt, as we tried a more complicated
// arrangement where the mag was a slave of the bmi160 chip. We never fully implemented it, and
// as we abandoned that approach there's no point in ever implementing it. Below are a bunch of
// stubs that do nothing on this boar... |
96, 512, -600},
{ -88, 616, -648},
{ -88, 640, -680},
{ -80, 704, -744},
{ 24, 760, -800},
{ 96, 680, -784},
{ 216, 744, -896},
{ 400, 824, -960},
{ 592, 680, -848},
// 56 seconds
{ 496, 552, -728},
{ 352, 528, -680},
{ 176, 488, -576},
{ 56, 464, -536},
{ -8, 464... | { -16, 616, -784},
{ -56, 616, -744},
{ -120, 856, -920},
{ 72, 1248, -1096},
{ 104, 856, -768},
{ -8, 952, -800},
{ 32, 880, -776},
{ 64, 752, -632},
{ 48, 552, -560},
{ 8, 520, -536},
{ -16, 472, -520},
{ -8, 432, -568},
{ -8, 424, -648},
{ -24, 400, -648},
... |
{ 248, 984, -600},
{ 320, 984, -696},
// 64 seconds
{ 408, 760, -536},
{ 360, 680, -488},
{ 288, 632, -512},
{ 240, 680, -504},
{ 136, 720, -536},
{ 104, 736, -576},
{ 32, 680, -576},
{ -64, 696, -616},
{ -80, 680, -632},
{ -80, 728, -672},
{ -32, 712, -688},
... |
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_ellipsis_clip_across_ny_descender(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(0, -25, 100, 32),
GTextOverf... | (ctx, GColorBlack) | ;
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-44, 4, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_across_x(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_t... |
row = 0; row < MAX_NUM_ROWS; row++) {
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, row), MAX_NUM_COLS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_odd_offset_checkerboard_no_clip")));
// Clipping on even boundaries - no offset
setup_test_aa_sw(&... | TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_checkerboard_no_clip") | ));
// Clipping on even boundaries - no offset
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_EVEN, ORIGIN_RECT_NO_CLIP, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
T... |
uint32_t to_free;
uint32_t before_size;
uint32_t after_size;
// lets save ids 17, 25, 42, and 47 because they are my favorite numbers
uint32_t after_free = t_data[16].size + t_data[24].size + t_data[41].size + t_data[46].size;
s_test_id_ql_up = 17;
s_test_id_ql_down = 25;
s_test_id_watchface = 42;
s... | prv_app_filename(filename, sizeof(filename), id) | ;
prv_check_file_exists(filename);
prv_res_filename(filename, sizeof(filename), id);
prv_check_file_exists(filename);
}
// finally, make sure the 'standard' files are all there
for (uint32_t i = 0; i < ARRAY_LENGTH(descriptions); ++i) {
prv_check_file_exists(descriptions[i].name);
}
}
void test... |
flash_erase_sector_blocking(TEST_ADDR);
if (!flash_sector_is_erased(TEST_ADDR)) {
prompt_send_response("FAIL: sector not erased");
return;
}
// write data into the sector
const uint32_t BUFFER_SIZE = 256;
uint8_t buffer[BUFFER_SIZE];
for (uint32_t i = 0; i < BUFFER_SIZE; i++) {
buffer[i] = i;... | for (uint32_t i = 0; i < (SECTOR_SIZE_BYTES / SUBSECTOR_SIZE_BYTES); i++) {
const uint32_t sub_addr = (addr + (i * SUBSECTOR_SIZE_BYTES));
bool sub_erased = prv_is_really_erased(sub_addr, true);
prompt_send_response_fmt(buffer, sizeof(buffer), " SUBSECTOR - 0X%-6"PRIx32" :: %s",
... |
}
addr += SECTOR_SIZE_BYTES;
task_watchdog_bit_set(pebble_task_get_current());
}
}
/*
* Commented out by default because this command can harm your flash chip!!
static void prv_flash_stress_callback(void *data) {
uint32_t flash_addr = FLASH_REGION_DEBUG_DB_BEGIN;
uint32_t sector_address = flash_get... |
(builder, p2) | ;
gpath_builder_line_to_point(builder, p3);
gpath_builder_line_to_point(builder, p4);
GPath *path = gpath_builder_create_path(builder);
gpath_builder_destroy(builder);
graphics_context_set_fill_color(ctx, color);
gpath_draw_filled(ctx, path);
gpath_destroy(path);
}
void health_progress_bar_fill(GContext... | |
T_DEPTH_NAME}__origin_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// SW = 1
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rec... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 5) | ;
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// SW = 11
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx... |
*has_ht = this->stream->controller->periph->LISR & DMA_LISR_HTIF1;
break;
case (uintptr_t)DMA1_Stream2:
case (uintptr_t)DMA2_Stream2:
*has_tc = this->stream->controller->periph->LISR & DMA_LISR_TCIF2;
*has_ht = this->stream->controller->periph->LISR & DMA_LISR_HTIF2;
break;
ca... | ((this->stream->periph->CR & DMA_SxCR_EN) == 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... | (&in_stream) | ;
if (byte != escape) {
// simply write the byte into the output stream
prv_byte_stream_write(&out_stream, byte);
continue;
}
// read the escape code
const uint8_t code = prv_byte_stream_read(&in_stream);
if (code == 0) {
// end of stream
break;
} else if (code == ... |
nput = jerry_create_number(1.0),
.expected_output = true,
},
{
.input = jerry_create_string((const jerry_char_t *)" "),
.expected_output = true,
},
{
.input = jerry_create_array(0),
.expected_output = true,
},
{
.input = jerry_create_object(),
.expected_... | jerry_create_number(-4096.0) | ,
[1] = jerry_create_number(-4096.0),
[2] = jerry_create_number(4095.875),
[3] = jerry_create_number(4095.875),
},
.argc = 4,
.expected_output = PP(-32768, -32768, 32767, 32767),
},
{
.argv = {
[0] = jerry_create_number(0),
[1] = jerry_create_numbe... |
n s_mode_change_impl = {
.update = prv_mode_change_update,
};
Animation *mode_change = animation_create();
animation_set_implementation(mode_change, &s_mode_change_impl);
animation_set_handlers(mode_change, (AnimationHandlers){ 0 }, layer);
return animation_spawn_create(animation, mode_change, NULL);
}
... | if (timeline_layer->scroll_direction == TimelineScrollDirectionUp) {
// arrow is in a different position for past & future, but only on rectangular displays
gpath_move_to(&arrow_path,
PBL_IF_RECT_ELSE(GPoint(0, (style->thin_pin_height +
style->past... |
graphics_context_set_antialiased(ctx, true);
const GColor arrow_fill_color = PBL_IF_RECT_ELSE(timeline_layer->sidebar_color, GColorWhite);
graphics_context_set_fill_color(ctx, arrow_fill_color);
gpath_draw_filled(ctx, &arrow_path);
graphics_context_set_antialiased(ctx, false);
}
///////////////////////////... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// Fallback, time XOR'd with an approximation of the current stack pointer:
seed = rtc_get_time() ^ (uintptr_t) &seed;
} | |
/*
* 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... | (touch_idx < MAX_NUM_TOUCHES) | |
/*
* 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... | (in_dropped_handler) | ;
app_message_register_outbox_failed(out_failed_handler);
// Init buffers
app_message_open(64, 64);
}
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
s_text_layer = text_layer_create((GRect) { .origin = { 0, 72 }... |
we can bail immediately.
s_activity_state.update_settings_counter -= 1;
if (s_activity_state.update_settings_counter > 0) {
return;
}
// The following sections of code can access the settings file and/or update globals,
// so we need to surround it with mutex ownership
mutex_lock_recursive(s_activity_... | (time_get_uptime_seconds()) | ;
}
mutex_unlock_recursive(s_activity_state.mutex);
// Send the history update event now if history has changed
if (need_history_update_event) {
PBL_LOG(LOG_LEVEL_DEBUG, "Sending history update event");
PebbleEvent e = {
.type = PEBBLE_HEALTH_SERVICE_EVENT,
.health_event = {
.type =... |
d at build time, with the PNG file copied to TEST_IMAGES_PATH
// and a separate PBI generated by bitmapgen.py from the PNG copied to TEST_IMAGES_PATH
// covers 1,2,4,8 bit palettized
// covers 1,2,4,8 bit palettized with transparency
// covers 1, 2 bit greyscale
// covers 1, 2 bit greyscale with transparency
// covers... | {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(1bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(1bitpalette)));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat1BitPalette);
} |
// Tests 1-bit b&w greyscale PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__greyscale_1_bit(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(1bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(1bitpalette)));
cl_assert_equal_i(gbitmap_get_fo... |
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.
*/
#include "services/common/put_bytes/put_bytes.h"
#include "services/common/comm_session/session_rece... | {
Receiver *r = g_put_bytes_receiver_impl.prepare(session, &s_put_bytes_endpoint, length);
if (r) {
if (s_do_before_write) {
s_do_before_write();
}
g_put_bytes_receiver_impl.write(r, data, length);
g_put_bytes_receiver_impl.finish(r);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "No receiver return... | |
char filename_buf[32];
app_storage_get_file_name(filename_buf, sizeof(filename_buf), 1,
PebbleTask_App);
load_fixture_on_pfs(APP1_APP_FIXTURE_NAME, filename_buf);
app_storage_get_file_name(filename_buf, sizeof(filename_buf), 1,
PebbleTask_Worker);
load_fix... | cl_assert_equal_b(false, prv_app_install_is_watchface(CRAZY_ID)) | ;
}
void test_app_install_manager__get_uuid_for_install_id(void) {
Uuid uuid = {};
cl_assert_equal_b(false, app_install_get_uuid_for_install_id(INSTALL_ID_INVALID, &uuid));
cl_assert_equal_uuid(uuid, UUID_INVALID);
cl_assert_equal_b(true, app_install_get_uuid_for_install_id(tictoc_id, &uuid));
cl_assert_equ... |
/*
* 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... | analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_ALERTS_DND_ACTIVE_TIME,
AnalyticsClient_System) | |
},
};
event_put(&event);
}
}
// ------------------------------------------------------------------------------------------------
// Stop activity tracking system callback
static void prv_stop_tracking_cb(void *context) {
s_activity_state.should_be_started = false;
if (!s_activity_state.started) {
... | xSemaphoreTake(s_activity_state.bg_wait_semaphore, k_timeout) | ;
}
return *cb_success;
}
// ------------------------------------------------------------------------------------------------
bool activity_init(void) {
ACTIVITY_LOG_DEBUG("init");
s_activity_state = (ActivityState) {};
s_activity_state.mutex = mutex_create_recursive();
// This semaphore used to wake up... |
;
break;
}
default:
WTF;
}
}
static bool prv_event_put(HRMSubscriberState *state, PebbleHRMEvent *event) {
bool success;
if (state->queue) {
PebbleEvent e = {
.type = PEBBLE_HRM_EVENT,
.hrm = *event,
};
success = xQueueSendToBack(state->queue, &e, 0);
... | PBL_LOG(LOG_LEVEL_DEBUG, "Subscription %"PRIu32" expired", expired_state->session_ref) | ;
prv_remove_and_free_subscription(expired_state);
}
}
// Update the HRM enable state. If no subscribers need an update for a while, we can turn off the
// HR sensor and set a timer to turn it on again later. To avoid this overhead on every callback,
// we only check it once every HRM_CHECK_SENSOR_DI... |
p_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 2);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_... | (&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw11_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
}
|
/*
* 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... | (data_signature) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
const bool check_crc = false;
return prv_version_copy_flash_fw_metadata(out_metadata, FLASH_REGION_FIRMWARE_SCRATCH_BEGIN,
check_crc);
} |
bool version_copy_recovery_fw_version(char* dest, const int dest_len_bytes) {
FirmwareMetadata out_metadata;
const bool check_crc = false;
bool success = prv_version_copy_flash_fw_metadata(&out_metadata,
FLASH_REGION_SAFE_FIRMWARE_BEGIN,
... |
_precise, &num_points);
if (!points) {
return NULL;
}
gpoint_sort(points, num_points, comparator, context, reverse);
GPointIndexLookup *lookup = applib_malloc(sizeof(GPointIndexLookup)
+ num_points * sizeof(uint16_t));
if (!lookup) {
applib_free(points);
return lookup;
}
lookup->num_p... | {
const int32_t scale = prv_int_scale_to(value, size, from_range, to_range, normalized,
interpolate);
const int32_t translate = interpolate(normalized, from_min, to_min);
return scale + translate;
} |
GPoint gpoint_scale_to(GPoint point, GSize size, GRect from, GRect to, int32_t normalized,
InterpolateInt64Function interpolate) {
return GPoint(
prv_int_scale_and_translate_to(point.x, size.w, from.size.w, to.size.w,
from.origin.x, to.origin.x, normalized, interp... |
a buffer
return substream.bytes_written + MLOG_MAX_VARINT_ENCODED_SIZE;
}
ProtobufLogRef protobuf_log_create(ProtobufLogConfig *config,
ProtobufLogTransportCB transport,
size_t max_msg_size) {
// Error check the passed in max encoded message si... | (LOG_LEVEL_ERROR, "Error adding sample, resetting session") | ;
return prv_session_encode_start(session);
}
return true;
}
bool protobuf_log_session_add_measurements(ProtobufLogRef session_ref, time_t sample_utc,
uint32_t num_values, uint32_t *values) {
PBL_ASSERTN(session_ref != NULL);
PLogSession *session = (PLogSession *... |
/*
* 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(raw_image_get_value_for_bitdepth(test2, 5, 2, 1, 1) == 1) | ;
cl_assert(raw_image_get_value_for_bitdepth(test2, 6, 2, 1, 1) == 0);
cl_assert(raw_image_get_value_for_bitdepth(test2, 5, 0, 2, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 5, 0, 2, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 1, 1, 2, 8) == 3);
cl_assert(raw_image_get_value_fo... |
_is_pressed(BUTTON_ID_SELECT) && !button_is_pressed(BUTTON_ID_DOWN));
}
static bool 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 + SEL... | display_error_code(0x8badf00d) | ;
delay_us(200000);
display_error_code(0xbad1ce40);
delay_us(200000);
display_error_code(0xbeefcace);
delay_us(200000);
display_error_code(0x0defaced);
delay_us(200000);
display_error_code(0xd15ea5e5);
delay_us(200000);
display_error_code(0xdeadbeef);
delay_us(200000);
di... |
2},
{ -176, 512, -920},
{ -160, 472, -928},
{ -168, 504, -968},
{ -192, 504, -928},
{ -184, 456, -872},
{ -136, 528, -912},
{ -176, 400, -896},
{ -152, 536, -904},
// 96 seconds
{ -152, 392, -896},
{ -160, 504, -904},
{ -152, 456, -976},
{ -192, 480, -888},
{ -120... | // 101 seconds
{ -192, 408, -840},
{ -200, 520, -904},
{ -192, 424, -880},
{ -176, 552, -984},
{ -184, 392, -936},
{ -160, 472, -952},
{ -160, 464, -928},
{ -152, 496, -760},
{ -152, 400, -920},
{ -136, 448, -896},
{ -136, 464, -984},
{ -160, 416, -776},
{ -136, 5... |
{ -136, 480, -744},
{ -112, 464, -928},
{ -184, 320, -632},
{ -176, 576, -968},
{ -240, 336, -824},
{ -168, 744, -1080},
{ -288, 392, -888},
{ -120, 688, -1016},
{ -248, 472, -920},
{ -152, 392, -1008},
{ -128, 392, -1072},
// 104 seconds
{ -224, 344, -936},
{ -8... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&s_gcontext, GContextInitializationMode_App) | ;
return true;
}
GContext *sdl_graphics_get_gcontext(void) {
return &s_gcontext;
}
void sdl_graphics_render(void) {
SDL_Flip(screen);
}
|
/*
* 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... | (offset >= s_state.offset) | ;
cl_assert((offset - s_state.offset) <= s_state.length);
// find the offset in the storage array
uint32_t fake_offset = offset - s_state.offset;
// check that file exists and fits in buffer
struct stat st;
cl_assert(stat(path, &st) == 0);
cl_assert(st.st_size < (s_state.length - fake_offset));
FILE ... |
ting_ack_up_to(client, next_sn);
comm_session_send_queue_consume(client->session, num_bytes_acked);
// If next_data_sn is before the Ack'd sn, the packet pending retransmission has just been
// Ack'd. We can determine whether or not a packet is pending retransmission by checking if the
// payload size ... | LIKELY(packet->type == PPoGATTPacketTypeResetComplete) | ) {
prv_handle_reset_complete(client, packet, value_length - sizeof(PPoGATTPacket));
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Resetting, ignoring data/ack packets (%u)", packet->type);
}
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Ignoring all packets in state %u", client->state);
}
}
// -----------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
RegularTimerInfo* reg_timer = (RegularTimerInfo*) iter;
if (--reg_timer->private_count == 0) {
reg_timer->private_count = reg_timer->private_reset_count;
// Release the mutex while we execute the callback
reg_timer->is_executing = true;
mutex_unlock(s_callback_list_semaphore);
... |
mutex_unlock(s_callback_list_semaphore);
}
// -------------------------------------------------------------------------------------------
static void timer_callback(void* data) {
(void) data;
do_callbacks(&s_seconds_callbacks);
time_t t = rtc_get_time();
struct tm time;
localtime_r(&t, &time);
if (ti... |
/*
* 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... | ((ListNode *)data->alarm_list_head,
(ListNode *)new_node,
prv_alarm_comparator,
false) | |
ckerMenuItemsJustOnce;
case ALARM_KIND_CUSTOM:
return DayPickerMenuItemsCustom;
}
return DayPickerMenuItemsJustOnce;
}
static AlarmKind prv_index_to_alarm_kind(DayPickerMenuItems index) {
switch (index) {
case DayPickerMenuItemsWeekdays:
return ALARM_KIND_WEEKDAYS;
case DayPickerMenuItems... | prv_index_to_alarm_kind(cell_index->row) | ;
const bool all_caps = false;
const char *cell_text = alarm_get_string_for_kind(kind, all_caps);
menu_cell_basic_draw(ctx, cell_layer, i18n_get(cell_text, &data->day_picker_window), NULL, NULL);
}
static void prv_day_picker_handle_selection(MenuLayer *menu_layer, MenuIndex *cell_index,
... |
k.h"
#include "util/circular_buffer.h"
#include "system/hexdump.h"
#include "clar_asserts.h"
#include "util/list.h"
#include <string.h>
extern void fake_system_task_callbacks_invoke_pending(void);
typedef struct CommSession {
ListNode node;
Transport *transport;
const TransportImplementation *transport_imp;
... | (sizeof(session->storage) >= max_pp_msg_size) | ;
circular_buffer_init(&session->send_buffer, session->storage, max_pp_msg_size);
s_session_head = (CommSession *) list_prepend((ListNode *) s_session_head, &session->node);
return session;
}
size_t comm_session_send_queue_get_length(const CommSession *session) {
cl_assert(list_contains((const ListNode *) s_s... |
troke_width, GCornerMask quadrant) {
// This algorithm will draw stroked circle with vairable width (only odd numbers for now)
const uint8_t half_stroke_width = stroke_width / 2;
const int16_t inner_radius = radius - half_stroke_width;
const uint8_t outer_radius = radius + half_stroke_width;
if (inner_radius... | (p.x, p.y - radius) | );
graphics_private_set_pixel(ctx, GPoint(p.x + radius, p.y));
graphics_private_set_pixel(ctx, GPoint(p.x - radius, p.y));
}
#if PBL_COLOR
T_STATIC void graphics_circle_draw_1px_aa(GContext* ctx, GPoint p, uint16_t radius) {
graphics_circle_quadrant_draw_1px_aa(ctx, p, radius, GCornersAll);
}
//! Draws an antia... |
/*
* 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... | (button_config->gpio, button_config->gpio_pin) | ;
gpio_release(button_config->gpio);
return (BOARD_CONFIG_BUTTON.active_high) ? bit : !bit;
}
uint8_t button_get_state_bits(void) {
uint8_t button_state = 0x00;
for (int i = 0; i < NUM_BUTTONS; ++i) {
button_state |= (button_is_pressed(i) ? 0x01 : 0x00) << i;
}
return button_state;
}
void button_init(... |
g_heart_rate_string) {
# if CAPABILITY_HAS_BUILTIN_HRM
_Static_assert(false, "FIXME: Implement round drawing code to show heart rate sharing status!");
# endif // CAPABILITY_HAS_BUILTIN_HRM
menu_cell_basic_draw(ctx, cell_layer, remote_name, connected_string, NULL);
}
#endif // PBL_ROUND
static void draw_stored... | (device_name_buffer, false) | ;
subtitle = device_name_buffer;
} else {
subtitle = i18n_get("Now Discoverable", data);
}
icon = &data->icon_heap_bitmap[BluetoothIconIdx];
}
} else {
subtitle = (data->toggle_state == ToggleStateDisablingBluetooth)
? i18n_get("Dis... |
40, 200, -304},
{ 824, 232, -376},
{ 832, 208, -440},
{ 832, 176, -472},
{ 832, 160, -536},
{ 832, 152, -544},
{ 1088, 216, -584},
{ 1112, 272, -648},
{ 872, 168, -528},
{ 704, 168, -416},
{ 808, 208, -464},
{ 968, 264, -456},
{ 944, 248, -416},
{ 880, 216, -440},
... | { 928, -56, -344},
{ 864, -80, -384},
{ 832, -64, -448},
// 64 seconds
{ 840, -88, -488},
{ 856, -136, -488},
{ 864, -160, -464},
{ 848, -160, -440},
{ 840, -112, -416},
{ 856, -64, -368},
{ 832, -16, -264},
{ 1304, 48, -288},
{ 1272, 80, -296},
{ 1136, 56, -200},... |
{ 1096, -56, -96},
{ 1128, -80, -112},
{ 1464, -56, -160},
{ 1312, -64, -144},
{ 1112, -32, -224},
{ 784, -16, -264},
{ 752, 0, -240},
{ 1064, 8, -184},
{ 1184, -24, -144},
{ 1088, -24, -112},
{ 952, 16, -144},
// 67 seconds
{ 872, 24, -184},
{ 888, 8, -184},
... |
/*
* 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... | animation_get_context(animation) | |
app_glance_with_too_many_slices[] = {
// Version
APP_GLANCE_DB_CURRENT_VERSION,
// Creation time
0x14, 0x13, 0x4E, 0x57, // 1464734484 (Tue, 31 May 2016 22:41:24 GMT)
// Slice 1
0x0B, 0x00, // Total size
0x00, // AppGlanceSliceType - AppGlanceSliceType_IconAndSubtitle
... | app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&s_app_glance_basic, glance_size) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gdraw_command_list_get_command(&result->command_list, 2) | ->points, c2_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 3)->points, c3_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 4)->points, c4_points)
return result;
}
GDrawCommandImage *weather_app_resource_create_sun(void) {
GPoint c0_points[] = {{47, 23}, {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... | (BMA255_SPI, BMA255_PERIPH_CLOCK) | ;
}
void bma255_disable_spi_clock(void) {
periph_config_disable(BMA255_SPI, BMA255_PERIPH_CLOCK);
}
uint8_t bma255_send_and_receive_byte(uint8_t byte) {
// Ensure that there are no other write operations in progress
while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET) {}
// Send the byte on the SPI ... |
/*
* 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... | pmic_set_charger_state(charging_enabled) | ;
}
// TODO
// This is my understanding from Figure 9 of the datasheet:
// Charger off -> Pre charge -> Fast Charge (constant current) ->
// Fast Charge (constant voltage) -> Maintain Charge -> Maintain Charge Done
//
// The Pre Charge and Charge Termination currents are programmed via I2C
// The Fast Charge current i... |
_size = DISP_COLS * 0.14; // 20 on snowy
const int32_t s_upwards_movement_size = DISP_ROWS * 0.18; // 30 on snowy
static void prv_transition_animation_update(GContext *ctx, Animation *animation,
uint32_t progress) {
const bool direction_negative = ((s_data.direction == Com... | animation_set_curve(animation, AnimationCurveLinear) | ;
s_data.animation_offset_px = 0;
}
static void prv_transition_animation_update_stub(GContext *ctx,
Animation *animation,
uint32_t progress) {
}
const CompositorTransition *compositor_shutter_transition_get(
Compo... |
y_text_7);
cl_assert_equal_s(alarm_day_text_7, "Fridays");
bool schedule_8[7] = {false, false, false, false, false, false, true};
char alarm_day_text_8[32] = {0};
alarm_get_string_for_custom(schedule_8, alarm_day_text_8);
cl_assert_equal_s(alarm_day_text_8, "Saturdays");
bool schedule_9[7] = {true, false,... | alarm_get_string_for_kind(ALARM_KIND_WEEKDAYS, all_caps) | , "WEEKDAYS");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_WEEKENDS, all_caps), "WEEKENDS");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_JUST_ONCE, all_caps), "ONCE");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_CUSTOM, all_caps), "CUSTOM");
}
void test_alarm__handle_clock_change... |
---------------------------------------------------------------------------------------
static bool prv_intialize_sdk_process(PebbleTask task, const PebbleProcessInfo *info,
MemorySegment *destination) {
if (!prv_verify_checksum(info, destination->start)) {
PBL_LOG(LOG_LEVEL_... | memory_segment_get_size(destination) | |
(s_phone_ui_data->up_action) {
window_single_click_subscribe(BUTTON_ID_UP, s_phone_ui_data->up_action);
}
if (s_phone_ui_data->select_action) {
window_single_click_subscribe(BUTTON_ID_SELECT, s_phone_ui_data->select_action);
}
if (s_phone_ui_data->down_action) {
window_single_click_subscribe(BUTTO... | if (s_phone_ui_data->open_reply_menu_on_pop) {
prv_open_reply_action_menu(NULL);
} |
window_stack_remove(&s_phone_ui_data->window, true /* animated */);
// The window_stack_remove() call should run the unload handler (which deinits the ui),
// but in the rare case that the window never loaded (i.e. a higher priority modal was up)
// then we could leak the phone_ui data and assert on the next... |
top_window;
}
PreferredContentSize preferred_content_size(void) {
return PreferredContentSizeMedium;
}
static MockCallRecordings s_layer_mark_dirty;
void layer_mark_dirty(Layer *layer) {
s_layer_mark_dirty.call_count++;
s_layer_mark_dirty.last_call = (MockCallRecording){.layer = layer};
}
static MockCallRecord... | {
return 0;
} |
static bool s_skip_mem_leak_check;
static void prv_init(void) {
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
}
static void prv_deinit(void) {
jerry_cleanup();
rocky_runtime_context_deinit();
}
void test_js__initialize(void) {
fake_pbl_malloc_clear_tracking();
s_skip_mem_leak_check = fals... |
nd_timer_id()), 27000 * MS_PER_SECOND);
rtc_set_time(s_saturday_10_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Sunday. (14.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 52200 * MS_PER_S... | (stub_new_timer_timeout(get_dnd_timer_id()), 1800 * MS_PER_SECOND) | ;
rtc_set_time(s_sunday_10_00);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Sunday. (14 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 50400 * MS_PER_SECOND);
rtc_set_time(s_sunday_23_30);
... |
, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_ny_offset_layer")));
}
void test_graphics_draw_line__clear(void) {
GContext ctx;
Layer layer;
test_graphics_context_init(&ctx, fb);
layer_init(&layer... | GPoint(0, 23) | , 145);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_odd_rows_no_clip")));
// Test to make sure drawing on all rows creates checkerboard pattern
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
for (int16_t row = 0; row < MA... |
One slot is 625us:
const uint32_t min_interval_ms = ((next->terms[next->cur_term].min_interval_slots * 5) / 8);
const uint32_t max_interval_ms = ((next->terms[next->cur_term].max_interval_slots * 5) / 8);
BLE_LOG_DEBUG("Enable Ad job %s", prv_string_for_debug_tag(next->tag));
bool result = bt... | (job->terms, terms, sizeof(GAPLEAdvertisingJobTerm) * num_terms) | |
h"
#include "util/graphics.h"
#if CAPABILITY_HAS_MASKING
// Clip the provided fixed x values to the framebuffer's data row info values for the row described
// by y. Return true if clipped values are valid for the row, false otherwise.
static bool prv_clip_fixed_x_values_to_data_row_info(GContext *ctx, int16_t y, Fix... | (ctx, y, last_pixel_x, last_pixel_x, color,
(uint8_t)x2.fraction) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.