prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
_get_app_segment_size(app_md);
// The stack guard is counted as part of the app segment size...
const size_t stack_guard_size = prv_get_stack_guard_size();
// ...and is carved out of the stack.
const size_t stack_size = prv_get_app_stack_size(app_md) - stack_guard_size;
MemorySegment app_ram = prv_get_app_ra... | PBL_LOG(LOG_LEVEL_DEBUG, "App heap init %p %p",
app_segment.start, app_segment.end) | ;
heap_init(app_heap, app_segment.start, app_segment.end, enable_heap_fuzzing);
heap_set_lock_impl(app_heap, (HeapLockImpl) {
.lock_function = prv_heap_lock,
});
process_heap_set_exception_handlers(app_heap, app_md);
// We're now going to start the app. We can't abort the app now without calling prv_ap... |
/*
* 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... | (&sys_bitmap, &app_bitmap, point, GCompOpAssign, GColorWhite) | ;
} else {
// First half of the transition
const int16_t diff = s_data.animation_offset_px - current_offset_px;
if (direction_vertical) {
graphics_private_move_pixels_vertically(&ctx->dest_bitmap, diff);
} else {
graphics_private_move_pixels_horizontally(&ctx->dest_bitmap, diff,
... |
ance_to_ms_with_timers(start_ms + total_duration + 5 * MIN_FRAME_INTERVAL_MS);
// Make sure neither inner_seq, a, nor b played
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 0);
cl_assert_equal_i(prv_count_han... | cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MIN);
... |
/*
* 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 false;
} |
bool rtc_sanitize_time_t(time_t *t) {
return rtc_sanitize_struct_tm(NULL);
}
uint16_t rtc_get_timezone_id(void) {
if (rtc_is_timezone_set()) {
return s_tzinfo.timezone_id;
}
return -1;
}
//! @return millisecond port of the current second.
void rtc_get_time_ms(time_t* out_seconds, uint16_t* out_ms) {
*... |
+
sizeof(PebbleProtocolHeader) - app_message_send_job->consumed_length);
}
static bool prv_is_header_consumed_for_offset(uint32_t offset) {
return (offset >= sizeof(PebbleProtocolHeader));
}
static size_t prv_get_read_pointer(AppMessageSendJob *app_message_send_job,
uin... | app_install_mark_prioritized(app_id, true /* can_expire */) | ;
analytics_inc(ANALYTICS_APP_METRIC_MSG_OUT_COUNT, AnalyticsClient_App);
}
// The outbox_message is owned by app_outbox_service, calling consume will free it as well:
const AppOutboxStatus status =
(const AppOutboxStatus) (is_completed ? AppMessageSenderErrorSuccess :
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
gpio_af_init(
&BOARD_CONFIG_MCO1.af_cfg, GPIO_OType_PP, GPIO_Speed_2MHz, GPIO_PuPd_NOPULL);
// LSE is 32kHz, we want 32kHz for our external clock and is used by:
// - The cc2564 bluetooth module
// - Snowy / Spalding display VCOM
RCC_MCO1Config(RCC_MCO1Source_LSE, RCC_MCO1Div_1);
++s... | else {
PBL_ASSERTN(s_refcount > 0);
--s_refcount;
if (s_refcount == 0) {
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling MCO1");
gpio_analog_init(&BOARD_CONFIG_MCO1.an_cfg);
}
}
portEXIT_CRITICAL();
}
|
if (!render) {
grect_align(&frame, box, kino_layer_get_alignment(kino_layer), false);
frame.origin.y = box->origin.y;
layer_set_frame(&kino_layer->layer, &frame);
} |
if (size_out) {
*size_out = frame.size;
}
}
GTextNodeCustom *layout_node_create_kino_layer_wrapper(KinoLayer *kino_layer) {
return graphics_text_node_create_custom(prv_kino_layer_wrapper_callback, (void *)kino_layer);
}
| |
= prv_app_smartstrap_event
};
event_service_client_subscribe(&state->event_info);
state->timeout_ms = SMARTSTRAP_TIMEOUT_DEFAULT;
sys_smartstrap_subscribe();
state->is_initialized = true;
}
static void prv_state_deinit(void) {
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
if (!sta... | (attr, type, 0, 0) | ;
if (result == SmartstrapResultOk) {
*buffer = (uint8_t *)attr;
sys_smartstrap_attribute_get_info(attr, NULL, NULL, buffer_length);
}
return result;
#else
return SmartstrapResultNotPresent;
#endif
}
SmartstrapResult app_smartstrap_attribute_end_write(SmartstrapAttribute *attr, size_t write_length,
... |
the License for the specific language governing permissions and
* limitations under the License.
*/
#include "simple_menu_layer.h"
#include "applib/legacy2/ui/menu_layer_legacy2.h"
#include "applib/applib_malloc.auto.h"
#include "process_management/process_manager.h"
static int16_t get_header_height(struct MenuLay... | (simple_menu->menu.selection.index.section, index) | ;
menu_layer_set_selected_index(&simple_menu->menu, menu_index, MenuRowAlignCenter, animated);
}
MenuLayer *simple_menu_layer_get_menu_layer(SimpleMenuLayer *simple_menu) {
return &simple_menu->menu;
}
|
progress_success_animation(ProgressWindow *data) {
#if !PLATFORM_TINTIN
GRect beg = data->progress_layer.layer.bounds;
GRect mid = beg;
GRect end = beg;
// Morph from progress_layer to a large transition dot to the compositor dot
// by changing the bounds of the progress_layer using 2 animations
layer_set_... | evented_timer_cancel(data->fake_progress_timer) | ;
data->fake_progress_timer = EVENTED_TIMER_INVALID_ID;
}
}
static void prv_set_progress(ProgressWindow *data, int16_t progress) {
data->progress_percent = CLIP(progress, data->progress_percent, MAX_PROGRESS_PERCENT);
progress_layer_set_progress(&data->progress_layer, data->progress_percent);
}
static void ... |
rage_private.h"
#include "flash_region/flash_region.h"
#include "services/normal/filesystem/pfs.h"
#include "util/size.h"
#include "clar.h"
#include "stdbool.h"
// Stubs
////////////////////////////////////
#include "fake_spi_flash.h"
#include "fake_rtc.h"
#include "stubs_analytics.h"
#include "stubs_hexdump.h"
#in... | (a->header.status, b->header.status) | ;
cl_assert_equal_i(a->header.timestamp, b->header.timestamp);
cl_assert_equal_i(a->header.layout, b->header.layout);
compare_attr_list(a->attr_list, b->attr_list);
cl_assert_equal_i(a->action_group.num_actions, b->action_group.num_actions);
for (int i = 0; i < a->action_group.num_actions; i++) {
cl_asser... |
iteration
}
// Read the full reminder to compare text
TimelineItem *reminder = reminder_info->reminder_out;
if (timeline_item_storage_get_from_settings_record(file, info, reminder) != S_SUCCESS) {
return true; // continue iteration
}
const char *title = attribute_get_string(&reminder->attr_list, Attri... | reminders_init() | |
cl_assert_equal_i(s_num_ds_notifications_received, 2);
}
void test_ancs__ancs_invalid_param(void) {
NSNotification ns_notification = {
.event_id = EventIDNotificationAdded,
.event_flags = 0,
.category_id = CategoryIDSocial,
.category_count = 1,
.uid = 0,
};
const uint32_t comple_dict_ui... | prv_cmp_last_received_notification(&s_unknown_app_parsed_item) | ;
// Make sure both apps attributes were requested (Messages and FakeApp)
cl_assert_equal_i(s_num_requested_app_attributes, 2);
// Test a recognized app with a unique title
prv_send_notification((uint8_t *)&s_message_dict);
prv_cmp_last_received_notification(&s_message_parsed_item);
// Test an unrecogniz... |
prv_set_time(s_current_day, 10, 0);
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm_smart__dont_trigger_30_min_early_deep_sleep(void) {
AlarmId id... | (s_num_timeline_adds, 6) | |
/*
* 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... | low_power_is_active() | ? backlight_low_power_intensity : backlight_get_intensity();
}
static void prv_change_brightness(int32_t new_brightness) {
const uint16_t HALF_BRIGHTNESS = (prv_backlight_get_intensity() - BACKLIGHT_BRIGHTNESS_OFF) / 2;
// update the debug stats
if (new_brightness > HALF_BRIGHTNESS && s_current_brightness <= H... |
;
slave->slave_state->dma_complete_handler = handler;
slave->slave_state->dma_complete_context = context;
prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_ReqTx, true);
dma_request_start_direct(slave->tx_dma, (void *)&slave->spi_bus->spi->DR, out, len,
prv_dma_irq_handler, (void *)slave);
}
... | {
prv_configure_spi_sclk(spi_sclk, slave->spi_bus->spi_sclk_speed);
} |
}
void spi_ll_slave_clear_errors(const SPISlavePort *slave) {
// First, empty the RX FIFO by reading the data. If in TX-only mode, it's possible that
// received data (0x00s) will be left in the RX FIFO.
// NOTE: Obviously, do not call this function with transfer in progress.
while (slave->spi_bus->spi->SR &... |
,
{ 1192, 120, -376},
{ 1224, 144, -392},
{ 1160, 152, -392},
{ 1072, 208, -256},
{ 1088, 232, -264},
{ 1168, 352, -304},
{ 1152, 384, -328},
{ 1104, 424, -312},
{ 912, 472, -288},
{ 616, 560, -88},
{ 720, 704, -232},
{ 936, 632, -144},
// 21 seconds
{ 832, 496, -... | { 1056, 120, -200},
{ 912, 24, -224},
{ 824, -40, -232},
{ 792, -176, -200},
{ 792, -104, -312},
{ 688, -160, -376},
{ 744, -152, -384},
{ 1096, -56, -296},
{ 1568, 48, -312},
{ 1792, 192, -336},
{ 2040, 200, -304},
{ 1856, 360, -288},
{ 1488, 408, -344},
{ 1216, ... |
{ 1288, 48, -448},
{ 1560, 104, -360},
{ 1640, 192, -336},
{ 1416, 328, -344},
{ 1248, 384, -232},
{ 1128, 400, -264},
{ 1160, 376, -312},
{ 1232, 472, -312},
{ 1248, 536, -272},
// 29 seconds
{ 992, 712, -168},
{ 576, 768, -312},
{ 600, 608, -160},
{ 832, 792, -... |
/*
* 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_data.window, true, true) | |
propriately
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 12), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 23), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 13), 10);
graphics_draw_horizontal_line... | (&ctx, fb) | ;
// Test odd and even rows draw appropriately
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 12), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 23), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 13), 10);... |
License.
*/
#include "rocky_api_datetime.h"
#include "rocky_api_errors.h"
#include "rocky_api_util.h"
#include "services/common/clock.h"
#include "system/passert.h"
#include "util/size.h"
#include <string.h>
#define ROCKY_DATE_TOLOCALETIMESTRING "toLocaleTimeString"
#define ROCKY_DATE_TOLOCALEDATESTRING "toLocaleD... | (options, "hour") | ;
JS_VAR day = jerry_get_object_field(options, "day");
JS_VAR month = jerry_get_object_field(options, "month");
JS_VAR year = jerry_get_object_field(options, "year");
JS_VAR hour12 = jerry_get_object_field(options, "hour12");
if (!jerry_value_is_undefined(hour12)) {
*is_24h_style = !jerry_get_boolean_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... | prv_fetch_struct() | |
e) {
goto exit;
}
session->data->write_request_pending = false;
int bytes_remaining = shared_circular_buffer_get_read_space_remaining(
&session->data->buffer, &session->data->buffer_client);
if (bytes_remaining == 0) {
goto exit;
}
got_session_file = prv_get_session_file(session, bytes_remain... | {
PBL_LOG(LOG_LEVEL_ERROR, "Nuking storage for session %d", logging_session->comm.session_id);
dls_storage_delete_logging_storage(logging_session);
} |
return last_whole_items_read_bytes;
}
// -----------------------------------------------------------------------------------------
// Consume num_bytes of data. As a special case, if num_bytes is 0, this simply advances the
// internal storage.read_offset to match the # of bytes already consumed without consuming... |
s ready to use
//! fd_used >= 0 if we were able to allocate a fd for the file (regardless of
//! whether or not its in the cache), else it reflects the error code
static NOINLINE bool file_found_in_cache(const char *name, uint8_t op_flags, int *fd_used) {
int fd, res;
bool is_tmp = ((op_flags & OP_FLAG_OVERWRITE) !... | pfs_open_handle_read_request(fd, page) | ;
} else { // unexpected situation
res = E_INTERNAL;
}
cleanup:
if (res < S_SUCCESS) {
mark_fd_free(fd);
} else {
PFS_FD(fd).fd_status = FD_STATUS_IN_USE;
}
return (res);
}
int pfs_open(const char *name, uint8_t op_flags, uint8_t file_type,
size_t start_size) {
size_t namelen = (name ==... |
R, "Not getting BT Classic id %d. Type mismatch", bonding);
return false;
}
if (address_out) {
*address_out = data.bt_classic_data.addr;
}
if (link_key_out) {
*link_key_out = data.bt_classic_data.link_key;
}
if (name_out) {
strncpy(name_out, data.bt_classic_data.name, BT_DEVICE_NAME_BUFFER_... | {
*bonding_out = active_gateway;
} |
if (type_out) {
*type_out = prv_get_type_for_id(active_gateway);
}
return true;
}
bool bt_persistent_storage_is_unfaithful(void) {
return prv_file_get_bool(&IS_UNFAITHFUL_KEY, sizeof(IS_UNFAITHFUL_KEY), true /* default */);
}
void bt_persistent_storage_set_unfaithful(bool is_unfaithful) {
PBL_LOG(LOG_... |
ncreased as it's not used anymore in this function
}
// last pixel with blending (don't render first *and* last pixel if line length is 1)
if (x2.fraction != 0) {
prv_blend_color_and_update_mask(ctx, y, last_pixel_x, last_pixel_x, color,
(uint8_t)x2.fraction);
}
}
T_STA... | {
x1.integer++;
continue;
} |
if (x1.integer > clip_box_max_x) {
break;
}
prv_blend_color_and_update_mask(ctx, y, x1.integer, x1.integer, color,
(uint8_t)(FIXED_S16_3_ONE.raw_value * i / left_aa_offset));
x1.integer++;
}
}
// middle pixels
if (x1.integer < x2.integer ... |
return &s_app_message_ctx;
}
bool app_message_receiver_open(size_t buffer_size) {
if (s_app_receiver_oom) {
return false;
}
s_is_app_message_receiver_open = true;
return true;
}
void app_message_receiver_close(void) {
s_is_app_message_receiver_open = false;
}
size_t sys_app_pp_app_message_inbox_size_ma... | (prv_in_received_callback) | |
acy2_sdk()) {
return GBITMAP_VERSION_0;
}
return bitmap->info.version;
}
// indirection to allow conditional mocking in unit-tests
T_STATIC
#if !UNITTEST
// apparently, GCC doesn't inline this otherwise
// scary, I wonder how many more places like these aren't inlined
ALWAYS_INLINE
#endif
GBitmapDataRowInfo pr... | if (bitmap) {
gbitmap_init_as_sub_bitmap(bitmap, base_bitmap, sub_rect);
} |
return bitmap;
}
static GColor* prv_allocate_palette(GBitmapFormat format) {
PBL_ASSERTN(!process_manager_compiled_with_legacy2_sdk());
GColor *palette = NULL;
uint8_t palette_size = gbitmap_get_palette_size(format);
if (palette_size > 0) {
palette = applib_zalloc(palette_size * sizeof(GColor));
}
r... |
80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f, /* bytes 2880 - 2896 */
0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x07, 0x80, 0x07, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* bytes 2896 - 2912 */
0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x0f, 0xc0, 0x0f, 0xc0, 0xff, 0xff, /* bytes 291... | load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */) | ;
pfs_format(false /* write erase headers */);
}
void test_resource__cleanup(void) {
}
void test_resource__system_resource_init(void) {
}
void test_resource__resource_update(void) {
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, true /* is_next */);
fake_boot_bit_set(BO... |
be invalid, iter_next takes care of the others
Codepoint codepoint = utf8_iter_state->codepoint;
if (codepoint_should_skip(codepoint) || codepoint_is_formatting_indicator(codepoint)) {
if (!iter_next(char_iter)) {
return false;
}
}
while (codepoint_is_zero_width(utf8_iter_state->codepoint)) {
... | {
CharIterState* char_iter_state = (CharIterState*) state;
Codepoint codepoint;
Iterator* utf8_iter = &char_iter_state->utf8_iter;
Utf8IterState* utf8_iter_state = &char_iter_state->utf8_iter_state;
while (true) {
if (utf8_iter_state->current >= utf8_iter_state->bounds->end) {
// EOS while searchi... |
bool char_iter_prev(IteratorState state) {
CharIterState* char_iter_state = (CharIterState*) state;
Codepoint codepoint;
Iterator* utf8_iter = &char_iter_state->utf8_iter;
Utf8IterState* utf8_iter_state = &char_iter_state->utf8_iter_state;
while (true) {
if (utf8_iter_state->current <= utf8_iter_state... |
&s_time_selection_config_large,
[PreferredContentSizeExtraLarge] = &s_time_selection_config_large,
};
static const TimeSelectionSizeConfig *prv_selection_config(void) {
const PreferredContentSize runtime_platform_default_size =
system_theme_get_default_content_size_for_runtime_platform();
return s_time_sel... | selection_layer_set_cell_padding(from_selection_layer, padding) | ;
selection_layer_set_active_bg_color(from_selection_layer, color);
selection_layer_set_inactive_bg_color(from_selection_layer, GColorDarkGray);
selection_layer_set_callbacks(from_selection_layer, time_range_selection_window,
(SelectionLayerCallbacks) {
.get_cell_text = prv_handle_from_get_text,
.co... |
= {
RESOURCE_ID_BATTERY_ICON_LOW_LARGE,
RESOURCE_ID_BATTERY_ICON_VERY_LOW_LARGE
};
static void prv_update_ui_fully_charged(Dialog *dialog, void *ignored) {
dialog_set_text(dialog, i18n_get("Fully Charged", dialog));
dialog_set_background_color(dialog, GColorKellyGreen);
dialog_set_icon(dialog, RESOURCE_ID_B... | modal_manager_get_window_stack(ModalPriorityGeneric) | ;
prv_display_modal(stack, prv_update_ui_fully_charged, NULL);
}
void battery_ui_display_warning(uint32_t percent, BatteryUIWarningLevel warning_level) {
// If we're not plugged in, that means we hit a critical power notification,
// so we want to alert the user, subverting any non-critical windows they
// hav... |
alogActionBarCustom) {
actionable_dialog->action_bar = action_bar_layer_create();
action_bar_layer_set_click_config_provider(actionable_dialog->action_bar,
actionable_dialog->config_provider);
}
ActionBarLayer *action_bar = actionable_dialog->action_bar;
if (... | dialog_init(&actionable_dialog->dialog, dialog_name) | ;
Window *window = &actionable_dialog->dialog.window;
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_actionable_dialog_load,
.unload = prv_actionable_dialog_unload,
.appear = prv_actionable_dialog_appear,
});
window_set_user_data(window, actionable_dialog);
}
ActionableDialog *a... |
lance_db__reading_nonexistent_glance_returns_does_not_exist(void) {
AppGlance glance = {};
cl_assert_equal_i(app_glance_db_read_glance(&UUID_INVALID, &glance), E_DOES_NOT_EXIST);
}
void test_app_glance_db__reading_glance_with_invalid_arguments_fails(void) {
// NULL UUID fails
AppGlance glance_out = {};
cl_as... | ((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
s_app_glance_basic, sizeof(s_app_glance_basic)) | |
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{... |
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
... | |
SECONDS_PER_DAY + (4 * SECONDS_PER_HOUR);
// if the event is within 24 hours, then show the actual time instead of "X hours ago"
const int MAX_RELATIVE_HRS = 13;
clock_set_24h_style(true);
// June 9th 2015, 17:00:00 (T+01:00:00)
rtc_set_time(event_time + SECONDS_PER_HOUR);
clock_get_until_time_capitalized... | rtc_set_time(event_time + (1 * SECONDS_PER_MINUTE)) | ;
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 minute ago", time_buf);
// June 9th 2015, 16:02:00 (T+00:02:00)
rtc_set_time(event_time + (2 * SECONDS_PER_MINUTE));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_asse... |
metric, middle_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics,
&s_sports_data, &s_sports_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_speed(void) {
s_sports_data = (SportsData) {
... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_workout_active__sports_hr_z3(void) {
s_sports_data = (SportsData) {
.current_bpm = 180,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMetricType middle_metric = WorkoutMetricType_D... |
igin.y += (data->rect_velocity_y * PIXEL_SPEED_PER_FRAME * 2);
if (data->rect.origin.y < 0 ||
data->rect.origin.y + data->rect.size.h > data->window.layer.bounds.size.h) {
data->rect_velocity_y = data->rect_velocity_y * -1;
}
} else if (shape == RECTANGLE_ROUND) {
// Move rounded... | if (data->fill) {
if (shape == POINT) {
graphics_draw_pixel(ctx, data->point_p0);
} else if (shape == LINE) {
graphics_draw_line(ctx, data->line_p0, data->line_p1);
} else if (shape == SQUARE) {
graphics_fill_rect(ctx, &data->square);
} else if (shape == RECTANGLE) {
graphics_fil... |
} else if (shape == GPATH_TRIANGLE) {
gpath_draw_outline(ctx, data->triangle);
} else if (shape == GPATH_OPEN_BUCKET) {
gpath_draw_outline_open(ctx, data->bucket);
}
}
}
static int64_t prv_time_64(void) {
time_t s;
uint16_t ms;
rtc_get_time_ms(&s, &ms);
return (int64_t)s * 1000 + ms;... |
ger);
Layer layer_a;
layer_init(&layer_a, &GRectZero);
layer_add_child(root, &layer_a);
manager.window = &window;
manager.active_layer = &layer_a;
recognizer_add_to_list(r1, &layer_a.recognizer_list);
recognizer_add_to_list(r2, &layer_a.recognizer_list);
RecognizerManager manager2;
recognizer_set_... | (&manager, r[0]) | |
TRY_ALLOCATE_STEPS_OR_RETURN_ERROR(1);
const bool anti_clockwise = (argc >= 6) ? jerry_get_boolean_value(argv[5]) : false;
// adjust for coordinate system
center.x.raw_value -= FIXED_S16_3_HALF.raw_value;
center.y.raw_value -= FIXED_S16_3_HALF.raw_value;
s_rocky_path_steps[s_rocky_path_steps_num++] = (Rock... | (obj, PATH2D_RECT, prv_rect) | ;
rocky_add_function(obj, PATH2D_CLOSEPATH, prv_close_path);
rocky_add_function(obj, ROCKY_CONTEXT2D_STROKE, prv_stroke);
rocky_add_function(obj, ROCKY_CONTEXT2D_FILL, prv_fill);
}
//! For unit testing
jerry_value_t rocky_api_graphics_path2d_try_allocate_steps(size_t inc_steps) {
TRY_ALLOCATE_STEPS_OR_RETURN_E... |
sert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x00aaff)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0055)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x55aa55)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5555)).argb);
cl_assert_equal_i(GColorWhite... | (gcolor_equal(lookup_table_out[3], GColorWhite)) | ;
// Setting the tint color to blue should result in a gradient from blue to yellow
tint_color = GColorBlue;
gcolor_tint_luminance_lookup_table_init(tint_color, lookup_table_out);
cl_assert(gcolor_equal(lookup_table_out[0], GColorBlue));
cl_assert(gcolor_equal(lookup_table_out[1], GColorLiberty));
cl_asser... |
;
}
Layer *old_next_sibling = above_layer->next_sibling;
above_layer->next_sibling = layer_to_insert;
layer_to_insert->next_sibling = old_next_sibling;
}
void layer_set_hidden(Layer *layer, bool hidden) {
if (hidden == layer->hidden) {
return;
}
layer->hidden = hidden;
if (layer->parent) {
laye... | if (!layer || !recognizer) {
return;
} |
recognizer_manager_register_recognizer(window_get_recognizer_manager(layer_get_window(layer)),
recognizer);
recognizer_add_to_list(recognizer, &layer->recognizer_list);
#endif
}
void layer_detach_recognizer(Layer *layer, Recognizer *recognizer) {
#if CAPABILITY_HAS_TOUCHSC... |
* (1 << FIXED_S16_3_PRECISION)) };
sum = Fixed_S16_3_add(num1, num2);
sum_c = (Fixed_S16_3){ .raw_value = (int16_t)((float)3 * (1 << FIXED_S16_3_PRECISION)) };
cl_assert(sum.raw_value == sum_c.raw_value);
// sum = -2.1 + 5.4 ~= 3.375 (nearest 1/8 fraction to the expected result)
// math is as follows:
// -... | (num1, num2) | |
&loaded_node->notification;
const char *title = attribute_get_string(¬ification->attr_list, AttributeIdTitle, "");
const char *subtitle = attribute_get_string(¬ification->attr_list, AttributeIdSubtitle, "");
const char *app_name = attribute_get_string(¬ification->attr_list, AttributeIdAppName, "");
con... | (window->layer.bounds, 0, STATUS_BAR_LAYER_HEIGHT) | );
menu_layer_init(menu_layer, &menu_layer_frame);
menu_layer_set_callbacks(menu_layer, data, &(MenuLayerCallbacks) {
.get_num_rows = prv_get_num_rows_callback,
.draw_row = prv_draw_row_callback,
.get_cell_height = prv_get_cell_height,
.select_click = prv_select_callback,
});
menu_layer... |
ons under the License.
*/
#include "clar.h"
#include "test_jerry_port_common.h"
#include "test_rocky_common.h"
#include "applib/graphics/gtypes.h"
#include "applib/rockyjs/api/rocky_api_global.h"
#include "applib/rockyjs/api/rocky_api_graphics.h"
#include "applib/rockyjs/api/rocky_api_graphics_color.h"
#include "app... | cl_assert_parsed_color("clear", &GColorClear) | ;
cl_assert_parsed_color("black", &GColorBlack);
cl_assert_parsed_color("red", &GColorRed);
cl_assert_parsed_color("white", &GColorWhite);
cl_assert_parsed_color("gray", &GColorLightGray);
}
extern const RockyAPIGraphicsColorDefinition s_color_definitions[];
void test_rocky_api_graphics_color__color_names_co... |
) {
int16_t x1_rounded = (x1.raw_value + (FIXED_S16_3_ONE.raw_value / 2)) / FIXED_S16_3_ONE.raw_value;
int16_t x2_rounded = (x2.raw_value + (FIXED_S16_3_ONE.raw_value / 2)) / FIXED_S16_3_ONE.raw_value;
if (x1_rounded > x2_rounded) {
// AA algorithm will draw lines in one way only, so non-AA should reject tho... | if (patch_garbage) {
memset(garbage_start, fill_byte, delta_bytes);
} |
}
if (delta_neg) {
if (delta_bits) {
const int rshift = delta_bits;
const int lshift = 8 - rshift;
for (int i = 0; i < bytes - 1; i++) {
buf[i] = (buf[i] >> rshift) | (buf[i+1] << lshift);
}
if (patch_garbage) {
... |
ssert_equal_i(values[1], 1000);
cl_assert_equal_i(values[2], 1000 / 10);
// ensure we look at seconds_total_last_day
values[0] = 1000;
values[2] = 1000;
range.seconds_total_last_day = SECONDS_PER_DAY / 4;
prv_adjust_value_boundaries(values, ARRAY_LENGTH(values), &range);
cl_assert_equal_i(values[0], 4 * ... | health_service_metric_accessible(HealthMetricStepCount, now - 10, now) | ;
cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskAvailable);
// values that partly are in unsupported range are available
accessible = health_service_metric_accessible(HealthMetricStepCount, now - 10, now + 20);
cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskAvailable);
// if all v... |
:%02uAM";
} else {
format = add_space ? "%u:%02u PM" : "%u:%02uPM";
}
}
return sniprintf(buffer, size, format, time_util_get_num_hours(hours, is24h), minutes);
}
size_t clock_copy_time_string_timestamp(char *buffer, uint8_t size, time_t timestamp) {
struct tm time;
sys_localtime_r(×tamp, &ti... | strncpy(number_buffer, "", number_buffer_size) | ;
} else if (time_util_get_midnight_of(timestamp) == current_day) {
// first day of multiday event or only day
prv_copy_relative_time_string(number_buffer, number_buffer_size, word_buffer,
word_buffer_size, timestamp, end_time);
} else if (time_util_get_midnight_of(end_time) == current_day) {
//... |
(PebbleEvent *e, void *context);
typedef struct {
bool active;
SmartstrapAttribute *attribute;
size_t length;
} PendingInfo;
static EventServiceEventHandler s_event_handler;
static PendingInfo s_pending_did_read;
static PendingInfo s_pending_did_write;
static PendingInfo s_pending_notified;
// Stubs / fakes
v... | app_smartstrap_attribute_end_write(NULL, 0, false) | );
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 0, true));
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 100, false));
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 100, true));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, false));
asser... |
/*
* 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 true;
} |
return false;
}
bool gtransform_is_only_translation(const GTransform * const t) {
if (!t) {
return false;
}
if ((t->a.raw_value == GTransformNumberOne.raw_value) &&
(t->b.raw_value == GTransformNumberZero.raw_value) &&
(t->c.raw_value == GTransformNumberZero.raw_value) &&
(t->d.raw_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... | (filename, line_number, lr, "ASSERTN", NULL) | ;
}
NORETURN passert_failed_no_message(const char* filename, int line_number) {
handle_passert_failed(filename, line_number,
(uintptr_t)__builtin_return_address(0), "ASSERTN", NULL);
}
NORETURN wtf(void) {
uintptr_t saved_lr = (uintptr_t) __builtin_return_address(0);
PBL_LOG(LOG_LEVEL_ALWAYS, "*** WTF %p", ... |
if (custom_reel->impl->destructor) {
custom_reel->impl->destructor(reel);
} |
applib_free(custom_reel);
}
static uint32_t prv_elapsed_getter(KinoReel *reel) {
KinoReelImplCustom *custom_reel = (KinoReelImplCustom *)reel;
if (custom_reel->impl->get_elapsed) {
return custom_reel->impl->get_elapsed(reel);
}
return 0;
}
static bool prv_elapsed_setter(KinoReel *reel, uint32_t elaps... | |
aphics_color.h"
#define ROCKY_EVENT_DRAW "draw"
#define ROCKY_EVENT_DRAW_CONTEXT "context"
#define ROCKY_REQUESTDRAW "requestDraw"
#define ROCKY_CONTEXT2D_CONSTRUCTOR "CanvasRenderingContext2D"
#define ROCKY_CONTEXT2D_CANVAS "canvas"
#define ROCKY_CONTEXT2D_CLEARRECT "clearRect"
#define ROCKY_CONTEXT2D_FILLRECT "fillR... | {
const int16_t x = Fixed_S16_3_rounded_int(rect->origin.x);
const int16_t y = Fixed_S16_3_rounded_int(rect->origin.y);
const int16_t w = Fixed_S16_3_rounded_int(grect_precise_get_max_x(rect)) - x;
const int16_t h = Fixed_S16_3_rounded_int(grect_precise_get_max_y(rect)) - y;
return GRect(x, y, w, 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... | {
return (source->callbacks.filter && (source->callbacks.filter(source, entry) == false));
} |
/////////////////////////
// Order List helpers
/////////////////////////
//! Place these in the order that is desired in the Launcher.
//! Set `move_on_activity` to true if you only want the item to jump to the top during communication
//! The movement will not happen while looking at the launcher, it will only ref... |
n_uid;
const uint32_t split_timestamp_uid = ((GetNotificationAttributesMsg*)s_split_timestamp_dict_part_one)->notification_uid;
const uint32_t message_dict_uid = ((GetNotificationAttributesMsg*)s_message_dict)->notification_uid;
const uint32_t app_name_title_dict_uid = ((GetNotificationAttributesMsg*)s_app_name_t... | (s_message_dict) | , (uint8_t*) s_message_dict);
s_num_ds_notifications_received++;
} else if (uid == app_name_title_dict_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_app_name_title_dict), (uint8_t *)s_app_name_title_dict);
s_num_ds_notifications_received++;
} else if (uid == unknown_app_message_dict_uid) {
... |
ULL);
assert_nack_count(1);
}
static void prv_cancel_before_write_second_message(void) {
put_bytes_cancel();
}
void test_put_bytes__cancel_between_prepare_and_finish(void) {
// When the put_bytes_cancel() is called while the PutBytes message is written (between "prepare"
// and "finish"), expect to receive a... | strlen(fn) | + 1);
assert_ack_count(1);
assert_nack_count(0);
}
void test_put_bytes__init_worker_okay_while_not_in_fw_update_mode(void) {
s_firmware_update_is_in_progress = false;
prv_receive_init_cookie(VALID_OBJECT_SIZE, ObjectWatchWorker, EXPECTED_COOKIE);
assert_ack_count(1);
assert_nack_count(0);
cl_assert_equ... |
include "services/common/event_service.h"
#include "services/common/new_timer/new_timer.h"
#include "services/common/regular_timer.h"
#include "services/common/system_task.h"
#include "syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"... | new_timer_stop(s_timer_id) | ;
AccelSubscriberState *state = (AccelSubscriberState *)s_data_subscribers;
while (state) {
if (state->sampling_rate > highest_rate) {
highest_rate = state->sampling_rate;
}
if (state->samples_per_update > 0) {
num_fifo_subscribers++;
ms_per_update = state->samples_per_update * 1000 /... |
nt(void) {
return true;
}
static int s_sys_hrm_manager_unsubscribe_call_count;
bool sys_hrm_manager_unsubscribe(HRMSessionRef session) {
++s_sys_hrm_manager_unsubscribe_call_count;
cl_assert_equal_i(session, s_last_session_ref);
return true;
}
//////////////////////////////////////////////////////////////////... | (true, ble_hrm_is_sharing_to_connection(&s_conn_a)) | ;
// Device A subscribes again, should be a no-op, no new permissions prompt:
bt_driver_cb_hrm_service_update_subscription(s_device_a, true);
cl_assert_equal_i(s_hrm_manager_subscribe_with_callback_call_count, 1);
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count, 0);
// Device B subscribes, should... |
{
// as all these values need to be configured in the test, we assert per default
.out[0].asserts = true,
};
s_activity_prefs_heart_rate_enabled = true;
}
void test_health__sum_today_returns_0_on_failure(void) {
s_sys_activity_get_metric_values.out.result = false;
s_sys_activity_get_metric_values.out... | cl_assert_equal_range(range, ((HealthServiceTimeRange){
.last_day_idx = 0,
.num_days = 2,
.seconds_first_day = 53258 - utc_to_local_delta,
.seconds_last_day = 33142 + utc_to_local_delta,
.seconds_total_last_day = 33142 + utc_to_local_delta,
})) | ;
}
void test_health__range_to_day_id_rejects_invalid_values(void) {
const time_t now = rtc_get_time();
bool result;
// check that we *can* return success
result = prv_calculate_time_range(now - 10, now, NULL);
cl_assert_equal_b(result, true);
// in the future
result = prv_calculate_time_range(now + 10... |
/*
* 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... | RCC_GetClocksFreq(&rcc_clocks) | ;
return rcc_clocks.PCLK1_Frequency;
}
static const int DUTY_CYCLE_DIVIDERS[] = {
[I2CDutyCycle_16_9] = 25,
[I2CDutyCycle_2] = 3
};
static uint32_t prv_prescalar_to_frequency(I2CDutyCycle duty_cycle, uint32_t prescalar) {
const uint32_t pclk1 = prv_get_apb1_frequency();
return pclk1 / (prescalar * DUTY_CYCL... |
);
static void prv_reset_slice_expiration_timer(LauncherAppGlanceService *service) {
if (!service) {
return;
}
if (service->slice_expiration_timer) {
app_timer_cancel(service->slice_expiration_timer);
service->slice_expiration_timer = NULL;
}
// Set the next slice expiration time to "never"
s... | {
LauncherAppGlanceService *service = context;
LauncherAppGlanceCacheEntry *entry = (LauncherAppGlanceCacheEntry *)node;
prv_glance_cache_destroy_entry(service, entry);
// Continue iterating to destroy all of the entries
return true;
} |
static void prv_glance_cache_deinit(LauncherAppGlanceService *service) {
if (service) {
list_foreach(service->glance_cache, prv_glance_cache_deinit_foreach_cb, service);
service->glance_cache = NULL;
}
}
//! Don't call this directly; it's used by prv_get_glance_for_node() below
static void prv_glance_cac... |
ame_decode_ctx, s_current_rx_frame,
RX_MAX_FRAME_SIZE);
// Break out after processing one complete frame so that we handle
// the timer and kick the watchdog within a reasonable amount of
// time, even if the queue is filling as fast as we can drain it.
... | PBL_ASSERT(payload_length <= FRAME_MAX_SEND_SIZE, "PULSE frame payload too long") | ;
// Rewind the pointer to the beginning of the buffer
char *frame = ((char *) buf) - COBS_OVERHEAD(FRAME_MAX_SEND_SIZE) - LINK_HEADER_LEN;
size_t length = LINK_HEADER_LEN + payload_length;
uint32_t fcs = crc32(CRC32_INIT, frame + COBS_OVERHEAD(FRAME_MAX_SEND_SIZE),
length);
memcpy(&f... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_draw_line(ctx,
GPoint(segment_width * i, 0),
GPoint(segment_width * i, SCREEN_HEIGHT)) | |
alue, 100 * SECONDS_PER_MINUTE);
cl_assert_equal_i(health_service_sum_today(HealthMetricSleepRestfulSeconds),
100 * SECONDS_PER_MINUTE);
activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value);
cl_assert_equal_i(value, 2 * SECONDS_PER_HOUR + 20 * SECONDS_PER_MINUTE
... | cl_assert(!enabled) | ;
cl_assert_equal_i(num_samples, k_raw_samples);
cl_assert_equal_i(seconds,
(k_raw_samples + ALGORITHM_SAMPLING_RATE - 1) / ALGORITHM_SAMPLING_RATE);
// Verify the collected data
AccelRawData captured_data[k_raw_samples];
prv_uncompress_captured_data(captured_data, k_raw_sampl... |
/*
* 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 (cmd == RCC_APB1PeriphClockCmd) {
return "APB1";
} else if (cmd == RCC_APB2PeriphClockCmd) {
return "APB2";
} else if (cmd == RCC_AHB1PeriphClockCmd) {
return "AHB1";
} else if (cmd == RCC_AHB2PeriphClockCmd) {
return "AHB2";
} else {
return NULL;
} |
}
#endif
// F(S)MC is the only AHB3 peripheral
#ifdef FMC_R_BASE
#define AHB3_BASE FMC_R_BASE
#else
#define AHB3_BASE FSMC_R_BASE
#endif
_Static_assert(APB1PERIPH_BASE < APB2PERIPH_BASE, "Clock mapping assumptions don't hold");
_Static_assert(APB2PERIPH_BASE < AHB1PERIPH_BASE, "Clock mapping assumptions don't hold")... |
ttributes_enable_screen_text_flow((GTextLayoutCacheRef) &l, 123);
cl_assert_equal_p(l.flow_data.perimeter.impl, g_perimeter_for_display);
cl_assert_equal_i(l.flow_data.perimeter.inset, 123);
}
void test_text_layout__create_destroy(void) {
GTextAttributes *attributes = graphics_text_attributes_create();
cl_asse... | {
cl_assert_equal_i(layout.max_used_size.h, 3 * FONT_HEIGHT);
} | |
/*
* 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 (has_hrm) {
data->hrm_event_info = (EventServiceInfo){
.type = PEBBLE_HRM_EVENT,
.handler = prv_handle_hrm_data,
};
event_service_client_subscribe(&data->hrm_event_info);
// Use app data as session ref
AppInstallId app_id = 1;
data->hrm_session = sys_hrm_manager_app_subscribe(ap... |
app_window_stack_push(window, true);
}
static void prv_handle_deinit(void) {
AppData *data = app_state_get_user_data();
event_service_client_unsubscribe(&data->hrm_event_info);
if (mfg_info_is_hrm_present()) {
sys_hrm_manager_unsubscribe(data->hrm_session);
}
text_layer_deinit(&data->title_text_laye... |
} payload[];
} AppMessage;
extern AppTimer *app_message_ack_timer_id(void);
extern bool app_message_is_accepting_inbound(void);
extern bool app_message_is_accepting_outbound(void);
extern bool app_message_is_closed_inbound(void);
extern bool app_message_is_closed_outbound(void);
extern void app_message_monitor_reset(... | (context, &s_context) | ;
prv_assert_dict_equal(received, &s_expected_iter);
s_in_received_is_called = true;
}
static void prv_in_dropped_callback(AppMessageResult reason, void *context) {
cl_assert_equal_p(context, &s_context);
cl_assert_equal_b(s_in_dropped_is_called, false);
s_in_dropped_is_called = true;
s_dropped_reason = re... |
lse);
}
static bool prv_task_is_masked_out(PebbleEvent *e, PebbleTask task) {
const PebbleTaskBitset task_bit = (1 << task);
return (e->task_mask & task_bit);
}
static bool prv_steal_buffer(void *buf, EventServiceEntry *service, PebbleEvent *e) {
uint16_t intents_pending = 0;
for (int i = 0; i < NumPebbleTa... | if (esb->intents_pending & CLAIMED_BIT) {
// If other events still need the buffer removing the claim marker will make things
// get cleaned up as usual.
uint16_t intents_pending = __sync_and_and_fetch(&esb->intents_pending, ~CLAIMED_BIT);
if (!intents_pending) {
list_remove((ListNode *)esb, (Li... |
}
// ---------------------------------------------------------------------------------------------------------------
static bool prv_service_filter(ListNode *node, void *tp) {
EventPluginUUIDEntry *info = (EventPluginUUIDEntry *)node;
return uuid_equal(&info->uuid, (Uuid *)tp);
}
// -----------------------------... |
uccess &= commit_succeeded;
prv_mark_pb_jobs_complete(1);
prv_cleanup_and_send_response((commit_succeeded) ? ResponseAck : ResponseNack);
}
static bool prv_is_valid_command_for_current_state(PutBytesCommand command) {
switch (s_pb_state.current_command) {
case PutBytesIdle:
return (command == PutBytesInit ... | PBL_ASSERTN(new_timer_start(s_pb_state.timer_id, PUT_TIMEOUT_MS, prv_timer_callback,
&s_pb_state, 0 /*flags*/)) | ;
prv_mark_pb_jobs_complete(num_put_jobs);
// At this point we have updated the outstanding jobs. Check to see if a job started to arrive in
// the meantime which needs to be ack'ed now that space is free
bool do_ack;
prv_lock_pb_job_state();
{
do_ack = put_jobs->need_to_ack_later;
put_jobs->need_... |
in_progress_semaphore);
stop_mode_enable(InhibitorDisplay);
analytics_stopwatch_stop(ANALYTICS_APP_METRIC_DISPLAY_WRITE_TIME);
}
// Static mode is entered by sending 0x00 to the panel
static void prv_display_enter_static(void) {
prv_enable_chip_select();
prv_display_write_byte(DISP_MODE_STATIC);
prv_display... | dma_request_start_direct(SHARP_SPI_TX_DMA, dst, framebuffer_addr, framebuffer_size,
prv_dma_handler, NULL) | ;
}
void display_show_splash_screen(void) {
// The bootloader has already drawn the splash screen for us; nothing to do!
}
// Stubs for display offset
void display_set_offset(GPoint offset) {}
GPoint display_get_offset(void) { return GPointZero; }
|
path;
ctx.draw_state.clip_box = GRect(0, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT / 2);
graphics_context_set_antialiased(&ctx, true);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_top_clipped_aa.${BIT_DEPTH_NAME}.pbi"));
prv_reset();
test_graphics... | prv_filled_update_proc(NULL, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_infinite_70_aa.8bit.pbi"));
// House path - two edge cases for tipping points of the path
prv_reset();
s_current_path = s_house_path;
gpath_move_to(s_house_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
s_path_angle = 20;
test_graphics_contex... |
bool schedule_1[7] = {true, false, false, false, false, false, true};
char alarm_day_text_1[32] = {0};
alarm_get_string_for_custom(schedule_1, alarm_day_text_1);
cl_assert_equal_s(alarm_day_text_1, "Sat,Sun");
bool schedule_2[7] = {true, true, true, true, true, true, true};
char alarm_day_text_2[32] = {0}... | alarm_delete(id4) | ;
prv_assert_alarm_config_absent(id4);
assert_alarm_pins_absent(id4);
id7 = alarm_create(&(AlarmInfo) { .hour = 17, .minute = 17, .kind = ALARM_KIND_WEEKENDS });
for (int i = 0; i < MAX_CONFIGURED_ALARMS; ++i) {
alarm_delete(i);
prv_assert_alarm_config_absent(i);
assert_alarm_pins_absent(i);
}
... |
/*
* 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... | (cell_index->row) | |
rants = GCornerTopRight,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight}
}));
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(90), TO_TRIG(180)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight},
.full_quadrants = GCorn... | (TO_TRIG(45), TO_TRIG(270 + 45)) | , ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(45),GCornerTopRight},
.full_quadrants = GCornersBottom,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270 + 45),GCornerTopLeft}
}));
// Ending quadrant filling up and starting quadrant finishing
cl_assert_equal_edc(prv_cal... |
default:
break;
// Not implemented
}
menu_layer_reload_data(&s_data->menu_layer);
prv_update_text_layer_visibility(s_data);
}
// we don't handle reminders within the notifications app
}
///////////////////
// Window callbacks
static void prv_window_appear(Window *window) {
Notificati... | event_service_client_unsubscribe(&data->notification_event_info) | ;
prv_loaded_notification_list_deinit(data->loaded_notification_list);
prv_notification_list_deinit(data->notification_list);
i18n_free_all(data);
app_free(data);
s_data = NULL;
}
static void prv_s_main(void) {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
}
#else
static void prv_s_main(... |
/*
* 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 (!layer) {
return;
}
layer_remove_from_parent(layer);
#if CAPABILITY_HAS_TOUCHSCREEN
// Destroy all attached recognizers
recognizer_list_iterate(&layer->recognizer_list, prv_destroy_recognizer, layer);
#endif
} |
void layer_destroy(Layer* layer) {
if (layer == NULL) {
return;
}
layer_deinit(layer);
applib_free(layer);
}
void layer_mark_dirty(Layer *layer) {
if (layer->property_changed_proc) {
layer->property_changed_proc(layer);
}
if (layer->window) {
window_schedule_render(layer->window);
}
}
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... | (&result->command_list, 4) | ->points, c4_points)
return result;
}
GDrawCommandImage *weather_app_resource_create_sun(void) {
GPoint c0_points[] = {{47, 23}, {5, 23}};
GPoint c1_points[] = {{13, 10}, {39, 36}};
GPoint c2_points[] = {{26, 2}, {26, 44}};
GPoint c3_points[] = {{39, 10}, {13, 36}};
GPoint c4_points[] = {{21, 11}, {31, 11... |
er, &out_length));
cl_assert(!circular_buffer_consume(&buffer, 1));
}
void test_circular_buffer__copy(void) {
CircularBuffer buffer;
uint8_t storage[8];
circular_buffer_init(&buffer, storage, sizeof(storage));
const uint16_t data_out_size = 8;
uint8_t data_out[data_out_size];
// Test copy when there is... | cl_assert_equal_i(circular_buffer_copy(&buffer, copy_out, copy_out_size), 6) | |
start();
s_spi_transport.state = SPITransportState_WaitingForReceiving_Footer;
}
static void prv_handle_int_waiting_for_receiving(void) {
s_spi_transport.state = SPITransportState_Receiving;
dialog_spi_send_and_receive_dma(NULL, s_spi_transport.rx_write_ptr,
s_spi_transport.byte... | (&s_spi_transport.rx) | |
/*
* 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... | {
test_accel_manager_reset();
} | |
ksum;
}
typedef enum UpdateFirmwareResult {
UPDATE_FW_SUCCESS = 0,
UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED = 1,
UPDATE_FW_ERROR_MICRO_FLASH_MANGLED = 2
} UpdateFirmwareResult;
static UpdateFirmwareResult update_fw(uint32_t flash_address) {
display_firmware_update_progress(0, 1);
boot_bit_set(BOOT_BIT_NEW_FW_U... | dbgserial_putstr("Failed to load recovery firmware, strike two. Try again.") | ;
boot_bit_set(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO);
boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
system_reset();
} else {
dbgserial_putstr("Failed to load recovery firmware, strike three. SAD WATCH");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT... |
sion 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "A... | prv_assert_erase_commands(expected_commands) | ;
prv_assert_callback_called(
s_command_list_index? S_SUCCESS : S_NO_ACTION_REQUIRED);
}
// Tests
///////////////////////////////////////////////////////////
void test_flash_erase__initialize(void) {
s_command_list_index = 0;
s_callback_called_count = 0;
s_callback_status = 42;
s_simulate_work_queue_f... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_DEBUG, "Multi Click! (%u)", click_number_of_clicks_counted(recognizer)) | ;
text_layer_set_text(&data->text, data->text_buffer);
toggle_color(window);
}
static void select_single_click_handler(ClickRecognizerRef recognizer, Window *window) {
ClickAppData *data = window_get_user_data(window);
const uint16_t count = click_number_of_clicks_counted(recognizer);
sniprintf(data->text_bu... |
20, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_across_y_second_line(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, -10, 72, 50),
... | (&layer, &draw_text_single_line_ellipsis_clip_across_nx) | ;
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_nx.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_x);
layer_render_tree(&canvas, &ctx);
cl_ch... |
RF storage:");
PBL_HEXDUMP(LOG_LEVEL_INFO, (const uint8_t *) keys, sizeof(keys));
#endif
bt_persistent_storage_set_root_keys(keys);
return;
}
// if we get here there are no root keys in prf storage, let's load the root
// keys normal fw has been using. This shouldn't ever really happen unless we
//... | {
PBL_LOG(LOG_LEVEL_ERROR, "Type mismatch: not deleting pairing. Is the bonding db corrupted?");
return false;
} |
if (prv_file_set(&bonding, sizeof(bonding), NULL, 0) == GapBondingFileSetFail) {
return false;
}
return true;
}
bool prv_has_active_gateway_by_type(BtPersistBondingType desired_type) {
BTBondingID bonding;
BtPersistBondingType type;
if (!bt_persistent_storage_get_active_gateway(&bonding, &type)) {
... |
causes this
//! operation can take seconds to complete on certain flash parts
//!
//! @param file_size - The amount of file space to erase
//! @param max_elapsed_ticks - The max amount of time to spend attempting to
//! find / create the free space. If 0, then there is no timeout
static void pfs_prepare_for_file_cr... | (curr_page) | + offsetof(PageHeader, page_flags));
if (pgs_needed > 0) { // do we need to find a free page
if ((rv = find_free_page(&next_page, use_gc_allocator, true)) != S_SUCCESS) {
unlink_flash_file(start_page); // on failure, unallocate
return (rv);
}
pg_hdr.next_page_crc = crc8_next_page... |
/*
* 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_file_get_app_id("@00000001/abc"), 1) | ;
}
void test_app_file__get_app_id_invalid_1(void) {
cl_assert_equal_i(app_file_get_app_id("pindb"), INSTALL_ID_INVALID);
}
void test_app_file__get_app_id_invalid_2(void) {
cl_assert_equal_i(app_file_get_app_id("@abcdefg0/foo"), INSTALL_ID_INVALID);
}
void test_app_file__get_app_id_hex(void) {
cl_assert_equal_... |
/*
* 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... | (I2C4_EV, i2c_hal_event_irq_handler, &I2C_PMIC_MAG_BUS) | ;
IRQ_MAP(I2C4_ER, i2c_hal_error_irq_handler, &I2C_PMIC_MAG_BUS);
void board_init(void) {
i2c_init(&I2C_PMIC_MAG_BUS);
}
|
oid)data;
(void)menu_layer;
switch (section_index) {
default:
case 0: return 2;
case 1: return 3;
case 2: return 4;
case 3: return 5;
}
}
static int16_t get_cell_height_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index, AppData *data) {
(void)data;
(void)menu_layer;
(void)cel... | window_set_user_data(window, data) | ;
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void handle_init(void) {
AppData *data = app_malloc_check(sizeof(AppData));
app_state_set_user_da... |
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.
*/
#include "weather_app.h"
#include "weather_app_layout.h"
#include "weather_app_splash... | app_state_get_user_data() | ;
data->weather_event_info = (EventServiceInfo) {
.type = PEBBLE_WEATHER_EVENT,
.handler = prv_handle_weather,
};
event_service_client_subscribe(&data->weather_event_info);
}
static void prv_main_window_load(Window *window) {
WeatherAppData *data = app_state_get_user_data();
layer_add_child(&window->... |
rvice_enabled) {
PBL_ASSERTN(s_vibe_strength == VIBE_STRENGTH_OFF);
return;
}
if (new_strength != VIBE_STRENGTH_OFF) {
vibe_set_strength(new_strength);
vibe_ctl(true /* on */);
if (s_vibe_strength == VIBE_STRENGTH_OFF) {
prv_vibe_history_start_event();
}
} else {
vibe_ctl(false /... | (void, sys_vibe_pattern_clear, void) | {
mutex_lock(s_vibe_pattern_mutex);
while (s_vibe_queue_head) {
VibePatternStep *removed_node = s_vibe_queue_head;
s_vibe_queue_head = (VibePatternStep*)list_pop_head((ListNode*)s_vibe_queue_head);
kernel_free(removed_node);
}
prv_vibes_set_vibe_strength(VIBE_STRENGTH_OFF);
s_pattern_in_progress ... |
h:
case FullStyleCapital12h:
if (with_fulltime) {
time_fmt = i18n_noop("Yesterday, %l:%M %p");
} else {
time_fmt = i18n_noop("Yesterday");
}
break;
case FullStyleLower24h:
case FullStyleCapital24h:
if (with_fulltime) {
time_fmt = i1... | {
str_fmt = i18n_noop("IN %lu H");
} | else if (num_hrs == 1) {
str_fmt = i18n_noop("In %lu hour");
} else {
str_fmt = i18n_noop("In %lu hours");
}
snprintf(buffer, buf_size, i18n_get(str_fmt, buffer), num_hrs);
} else {
prv_clock_get_full_relative_time(buffer, buf_size, timestamp, capitalized, with_fulltime);
}
i18n_free... |
src_bpp);
// Default color to be the raw color index - update only if palletized
GColor src_color = (GColor){.argb = cindex};
bool palletized = ((format == GBitmapFormat1BitPalette) ||
(format == GBitmapFormat2BitPalette) ||
... | cos_lookup(-rotation) | |
/*
* 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... | (!uuid_equal(&system, &invalid)) | ;
const Uuid test_uuid_1 = (Uuid) {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5
};
// Different at the start
Uuid test_uuid_2 = test_uuid_1;
++test_uuid_2.byte0;
// Different at the end
Uuid test_uuid_3 = test_uuid_1;
++test_uuid_3.byte15;
cl_assert(uuid_equal(&test_uuid_1, &test_uuid_1));... |
data) : NULL,
.duration_m = SMART_ALARM_RANGE_S / SECONDS_PER_MINUTE,
.enabled = is_smart,
},
};
time_selection_window_configure(&data->time_picker_window, &config);
// Reset the selection layer to the first cell
data->time_picker_window.selection_layer.selected_cell_idx = 0;
}
static void prv... | prv_setup_time_picker_window(data) | ;
prv_setup_day_picker_window(data);
#if CAPABILITY_HAS_HEALTH_TRACKING
prv_setup_type_menu_window(data);
return &data->alarm_type_menu->window;
#else
return &data->time_picker_window.window;
#endif
}
void alarm_editor_update_alarm_time(AlarmId alarm_id, AlarmType alarm_type,
... |
eset(CommSession *session) {
bt_lock();
{
if (!comm_session_is_valid(session)) {
PBL_LOG(LOG_LEVEL_WARNING, "Already closed!");
goto unlock;
}
session->transport_imp->reset(session->transport);
}
unlock:
bt_unlock();
}
// -----------------------------------------------------------------... | (session, true /* is_open */) | ;
// Request capabilities for both the Pebble app and 3rd party companion apps:
session_remote_version_start_requests(session);
comm_session_analytics_open_session(session);
prv_put_comm_session_event(true, is_system);
if (is_system && (session->destination == TransportDestinationHybrid)) {
// For And... |
value += minute_data[i].heart_rate_bpm;
break;
case HealthAggregationMax:
value = MAX(value, minute_data[i].heart_rate_bpm);
break;
case HealthAggregationMin:
value = MIN(value, minute_data[i].heart_rate_bpm);
break;
case HealthAggregationSum... | {
return false;
} |
unsigned int length_sec = session->length_min * SECONDS_PER_MINUTE;
const bool time_matches = session->start_utc < time_end &&
(time_t)(session->start_utc + length_sec) > time_start;
return time_matches;
}
// ----------------------------------------------------------------------------------------------
T_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... | (*data->failed, 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... | {
return emx_resources_read(app_num, id, start_bytes, buffer, num_bytes);
} |
size_t sys_resource_size(ResAppNum app_num, uint32_t handle) {
return emx_resources_get_size(app_num, handle);
}
GFont sys_font_get_system_font(const char *font_key) {
static FontInfo s_system_fonts_info_table[NUM_SYSTEM_FONTS + 1] = {};
for (int i = 0; i < (int) NUM_SYSTEM_FONTS; ++i) {
if (0 == strcmp(f... |
the minute
.tm_min = 30, // 30 minutes after the hour
.tm_hour = 17, // 17 hours since midnight
.tm_mday = 6, // 6st day of the month
.tm_mon = 0, // January
.tm_year = 2014 - 1900,
.tm_isdst = 0,
};
// DST info for US/Canada 2014
TimezoneInfo tz_info = {
.dst_start = 1394330400, // S... | ("Wed, 2:00 PM", time_buf) | ;
// June 8th 2015, 23:59:58 (T-38:00:02)
rtc_set_time(event_time - SECONDS_PER_DAY - (14 * SECONDS_PER_HOUR) - 2);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Wed, 2:00 PM", time_buf);
// June 8th 2015, 23:59:59 (T-38:00:01)
rtc_set_time... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.