prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
it's
// not useful as a generic one-shot. We'll let it run free and calculate deltas.
static void prv_timer_enable(void) {
timer0_config cfg = {
.clk_src = HW_TIMER0_CLK_SRC_SLOW,
.on_clock_div = false,
.on_reload = TIMER0_RELOAD_VALUE,
};
hw_timer0_init(&cfg);
hw_timer0_enable();
}
// The initial... | (CRC32_INIT, buffer, len) | |
erMenuLayerTestApp_Travel,
LauncherMenuLayerTestApp_NoIcon,
LauncherMenuLayerTestAppCount
} LauncherMenuLayerTestApp;
typedef struct LauncherMenuLayerTestAppNode {
AppMenuNode node;
uint32_t bitmap_icon_resource_id;
uint32_t pdc_icon_resource_id;
uint32_t bitmap_slice_icon_resource_id;
uint32_t pdc_slic... | cl_assert(source) | ;
cl_assert(node);
if (!node->icon_resource_id) {
return &s_default_app_icon_bitmap;
}
gbitmap_deinit(&s_app_icon_bitmap);
gbitmap_init_with_resource(&s_app_icon_bitmap, node->icon_resource_id);
return &s_app_icon_bitmap;
}
//! We use this function in the app glance service to create a key (the insta... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (true, rocky_global_has_event_handlers("daychange")) | ;
cl_assert_equal_i(3, s_tick_timer_service_subscribe.call_count);
cl_assert_equal_i(MINUTE_UNIT | HOUR_UNIT | DAY_UNIT | MONTH_UNIT | YEAR_UNIT,
s_tick_timer_service_subscribe.last_call.tick_units);
// register for minute again
EXECUTE_SCRIPT("_rocky.on('minutechange', function() {});");
... |
cific language governing permissions and
* limitations under the License.
*/
#include "protobuf_log.h"
#include "protobuf_log_private.h"
#include "protobuf_log_util.h"
#include "applib/data_logging.h"
#include "drivers/rtc.h"
#include "kernel/pbl_malloc.h"
#include "mfg/mfg_serials.h"
#include "os/mutex.h"
#include... | mfg_get_serial_number() | ;
pebble_pipeline_Payload payload = {
.sender = {
.type = {
.funcs.encode = protobuf_log_util_encode_string,
.arg = (void *)PLOG_PAYLOAD_SENDER_TYPE,
},
.id = {
.funcs.encode = protobuf_log_util_encode_string,
.arg = (void *)watch_serial,
},
.has_vers... |
45);
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 < MAX_N... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 21), MAX_NUM_COLS - 1) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 23), MAX_NUM_COLS + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_even_offset_odd_rows_no_clip")));
// Test to make sure drawing on all rows creates checkerboard pattern
setup_test_aa_sw(&ctx, fb, OFFSET_... |
T_SLEEP_MINUTE_OF_DAY * SECONDS_PER_MINUTE;
time_t sleep_earliest_end_utc = start_of_today_utc
- (SECONDS_PER_DAY - last_sleep_second_of_day);
uint32_t num_sessions_returned = 0;
for (uint32_t i = 0; i < s_data.num_sessions; i++) {
if (num_sessions_returned >= *session_entries... | {
prv_set_time(&s_init_time_tm);
fake_kernel_services_notifications_reset();
s_activation_time = 0;
s_health_app_opened_version = 0;
s_data = (StaticData) {};
} |
// ---------------------------------------------------------------------------------------
void test_activity_insights__cleanup(void) {
fake_settings_file_reset();
}
// ---------------------------------------------------------------------------------------
// Test that we correctly calculate the statistics (# days... |
cess, "Failure to store new value for %s in settings file", key);
// Update the backing store
if (success) {
prv_set_pref_backing(entry, value, val_len);
}
}
// ------------------------------------------------------------------------------------
// Exported function used by blob_db API to set the backing s... | (PREF_KEY_CLOCK_24H, &is24h, sizeof(is24h)) | ;
}
bool shell_prefs_is_timezone_source_manual(void) {
return s_clock_timezone_source_is_manual;
}
void shell_prefs_set_timezone_source_manual(bool manual) {
prv_pref_set(PREF_KEY_CLOCK_TIMEZONE_SOURCE_IS_MANUAL, &manual, sizeof(manual));
}
void shell_prefs_set_automatic_timezone_id(int16_t timezone_id) {
prv_... |
on-uint8_t attribute");
}
prv_add_attribute(list, id)->uint8 = uint8;
}
void attribute_list_add_string_list(AttributeList *list, AttributeId id, StringList *string_list) {
PBL_ASSERTN(prv_attribute_type(id) == AttributeTypeStringList);
prv_add_attribute(list, id)->string_list = string_list;
}
void attribute_l... | attribute_find(attr_list, id) | ;
return attribute ? attribute->uint32_list : NULL;
}
|
Create this hierarchy:
//
// +-parent
// |
// '->child_a->child_b
//
layer_add_child(&parent, &child_a);
layer_add_child(&parent, &child_b);
layer_remove_child_layers(&parent);
cl_assert(child_a.parent == NULL);
cl_assert(child_a.next_sibling == NULL);
cl_assert(child_b.parent == NULL);
... | (ab, actual) | ;
cl_assert_equal_i(1, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(ab, stack[1]);
// go back one level and then to sibling
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(b, actual);
cl_assert_equal_i(0, current... |
s(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&... | prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS + 1) | ;
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, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq... |
llback(MenuLayer *menu_layer, uint16_t section_index,
LauncherMenuData *data) {
return app_menu_data_source_get_count(&data->data_source);
}
static void draw_row_callback(GContext *ctx, Layer *cell_layer, MenuIndex *cell_index,
LauncherMenuData *dat... | menu_layer_deinit(&data->menu_layer) | ;
app_menu_data_source_deinit(&data->data_source);
}
static void launcher_menu_push_window(void) {
LauncherMenuData *data = app_zalloc(sizeof(LauncherMenuData));
app_state_set_user_data(data);
// Push launcher menu window:
Window *window = &data->window;
window_init(window, WINDOW_NAME("Launcher Menu"));... |
/*
* 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... | (BT_RX_BOOTROM_UART, DIALOG_BOOTROM_UART_BAUDRATE) | ;
uart_set_baud_rate(BT_TX_BOOTROM_UART, DIALOG_BOOTROM_UART_BAUDRATE);
} else {
uart_init(BT_RX_BOOTROM_UART);
uart_set_baud_rate(BT_RX_BOOTROM_UART, DIALOG_BOOTROM_UART_BAUDRATE);
}
periph_config_release_lock();
}
static void prv_deinit_dialog_bootrom_interface(void) {
periph_config_acquire_lock... |
>len_minutes;
result.start_at.value = start_idx;
found_activity = true;
}
}
result.weighted_err = 0.0;
result.all_passed = true;
ActualValue *actual = &result.activity_type;
ExpectedValue *expected = &entry->activity_type;
for (int j = 0; j < ARRAY_LENGTH(metrics); j++, a... | (exp_minutes) | );
}
// Run the not moving sample
// The expected results were obtained empirically on a known good commit
{
int num_samples;
AccelRawData *samples = activity_sample_not_moving(&num_samples);
TestMinuteData exp_minutes[2] = {
{
.steps = 0,
.orientation = 0x81,
.vmc = 1... |
unlock();
if (LIKELY(write_space >= required_length)) {
if (UNLIKELY(did_stall)) {
PBL_LOG(LOG_LEVEL_DEBUG, "GATT notification stalled for %d ms...",
(int)(timeout_ms - ticks_to_milliseconds(timeout_end_ticks - rtc_get_ticks())));
analytics_inc(ANALYTICS_DEVICE_METRIC_BLE_GATT_... | gap_le_pebble_task_bit_for_client(c) | ;
s_is_notification_event_pending[c] = true;
}
}
prv_unlock();
}
if (UNLIKELY(task_mask != task_mask_none)) {
prv_send_notification_event(task_mask);
}
unlock:
bt_unlock();
}
// -------------------------------------------------------------------------------------------------
static ... |
.attributes = attributes,
},
.action_group = {
.num_actions = 1,
.actions = &actions[2],
}
};
Uuid i3;
uuid_generate(&i3);
TimelineItem e3 = {
.header = {
.id = i3,
.type = TimelineItemTypeNotification,
.status = 0,
.ancs_uid = 0,
.layout = LayoutIdGe... | notification_storage_store(&e2) | ;
notification_storage_remove(&i1);
TimelineItem r;
cl_assert_equal_b(notification_storage_get(&i1, &r), false);
cl_assert(notification_storage_get(&i2, &r));
compare_notifications(&e2, &r);
free(r.allocated_buffer);
}
void test_notification_storage__remove_add(void) {
Uuid i1;
uuid_generate(&i1);
... |
ation and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = ANIMATION_DURATION_INFINITE;
Animation *animation = (Animation *)kino_player_create_play_animation(test_player);
cl_assert_equal_i(animation_is_scheduled(animation), false);... | cl_assert_equal_p(test_player->reel, NULL) | ;
cl_assert_equal_i(s_num_destructor_calls, 1);
test_reel = NULL;
}
void test_kino_player__set_reel_does_not_call_destructor(void) {
test_player->owns_reel = false;
kino_player_set_reel(test_player, test_reel, false);
cl_assert_equal_p(test_player->reel, test_reel);
cl_assert_equal_i(s_num_destructor_cal... |
kHandle resource_storage_file_watch(ResourceStoreEntry *entry,
ResourceChangedCallback callback,
void* data) {
const FileResourceData *file = entry->store_data;
if (!file) {
return NULL;
}
PFS... | resource_storage_get_file_name(filename, sizeof(filename), app_num) | |
sk) {
switch (task) {
case PebbleTask_App:
return FAKE_APP_QUEUE;
case PebbleTask_KernelBackground:
return NULL;
default:
WTF;
}
}
// -----------------------------------------------------------------------------
// Fakes
// -------------------------------------------------------------... | cl_assert_equal_b(hrm_is_enabled(HRM), false) | ;
}
// When we cleanup after an app process, its subscription, if any, should get an expriration time
// placed on it
void test_hrm_manager__app_cleanup(void) {
stub_pebble_tasks_set_current(PebbleTask_App);
AppInstallId app_id = 1;
const uint32_t update_interval_s = 1;
uint16_t expire_s = 0;
HRMFeature fea... |
the specific language governing permissions and
* limitations under the License.
*/
#include "ancs_notifications.h"
#include "ancs_filtering.h"
#include "ancs_item.h"
#include "ancs_phone_call.h"
#include "ancs_notifications_util.h"
#include "nexmo.h"
#include "comm/ble/kernel_le_client/ancs/ancs_types.h"
#includ... | (&app_id->pstr, IOS_REMINDERS_APP_ID) | |
or up
const int16_t area_above_selection_rect_height = selection_rect->origin.y;
if (area_above_selection_rect_height > 0) {
const GRect area_above_selection_rect = GRect(-selection_rect->origin.x, 0, DISP_COLS,
area_above_selection_rect_height);
prv_move_re... | {
const int16_t dest_origin_x = (is_right ? -delta_x_after_cut : start);
// Copy the entire app framebuffer (containing the launcher) to the compositor framebuffer
prv_copy_app_fb_patching_garbage(dest_origin_x);
if (!is_right) {
// Manipulate the launcher's pixels in the system framebuffer so the... |
// Technically the whole framebuffer may not be dirty after each frame (and thus not need to be
// marked as such so we don't flush every scan line to the display), but let's make it easy and
// just dirty the whole framebuffer on each frame anyway since most pixels do change
framebuffer_dirty_all(compositor_... |
+ buffer_size);
if (text_node) {
*text_node = (GTextNodeTextDynamic) {
.text.node.type = GTextNodeType_TextDynamic,
.text.node.free_on_destroy = true,
.text.text = buffer_size ? (char *)text_node->buffer : NULL,
.update = update,
.user_data = user_data,
.buffer_size = buffer_si... | if (config->paging) {
graphics_text_attributes_enable_paging((TextLayout *)&layout,
gpoint_add(*config->origin_on_screen, ctx->box.origin),
*config->page_frame);
} |
}
if (ctx->render) {
const GColor prev_text_color = ctx->gcontext->draw_state.text_color;
if (!gcolor_is_invisible(text_node->color)) {
ctx->gcontext->draw_state.text_color = text_node->color;
}
graphics_draw_text(ctx->gcontext, text_node->text, text_node->font, ctx->box,
... |
}
void test_app_inbox__app_inbox_create_and_register_drop_handler_not_permitted(void) {
// The syscall_failed() fake will trigger passert:
cl_assert_passert(app_inbox_create_and_register(BUFFER_SIZE, 1,
test_message_handler,
... | (false, app_inbox_service_is_being_written_for_tag(AppInboxServiceTagUnitTest)) | |
/*
* 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_get_uint32_list(&attr_list, AttributeIdMetricIcons) | ;
for (int i = 0; i < metric_values->num_values; i++) {
cl_assert_equal_i(metric_values->values[i], other->values[i]);
}
const size_t serialized_size = attribute_list_get_serialized_size(&attr_list);
cl_assert_equal_i(serialized_size, 19);
uint8_t serialized_buffer[serialized_size];
attribute_list_seri... |
dge;
spi_cfg.SPI_NSS = SPI_NSS_Soft;
// APB2 is at 16MHz, max is 54MHz, so we want the smallest prescaler
spi_cfg.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
spi_cfg.SPI_FirstBit = SPI_FirstBit_MSB;
spi_cfg.SPI_CRCPolynomial = 7;
SPI_Init(FLASH_CONFIG.spi, &spi_cfg);
SPI_Cmd(FLASH_CONFIG.spi, ENABLE... | prv_flash_send_24b_address(start_addr) | ;
while (buffer_size--) {
*buffer = prv_flash_read_next_byte();
buffer++;
}
prv_flash_end_cmd();
prv_disable_flash_spi_clock();
}
|
ert(child_a.next_sibling == &child_c);
cl_assert(grand_child_a.parent == &child_a);
cl_assert(child_c.parent == &parent);
// Remove first-child (child_a):
//
// +-parent
// |
// '->child_c
//
// +-child_a
// |
// '->grand_child_a
//
layer_remove_from_parent(&child_a);
cl... | (aa, stack[1]) | ;
// go to child if possible
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaa, actual);
cl_assert_equal_i(2, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1]);
cl_assert_equal_p(aaa, stack[2]);
// ... |
"Got a writeback response with an invalid length: %"PRIu32"", length);
return;
}
prv_handle_wb_write_response(data, length);
}
static void prv_handle_sync_done_response(CommSession *session,
const uint8_t *data,
uint32_t lengt... | comm_session_send_buffer_write(sb, val, val_len) | ;
comm_session_send_buffer_end_write(sb);
}
return writeback_metadata.token;
}
BlobDBToken blob_db_endpoint_send_write(BlobDBId db_id,
time_t last_updated,
const void *key,
int key_len,
... |
o update
status_bar_layer->config.mode = StatusBarLayerModeClock;
prv_status_bar_layer_update_clock(status_bar_layer);
}
void status_bar_layer_set_info_text(StatusBarLayer *status_bar_layer, const char *text) {
PBL_ASSERTN(status_bar_layer);
strncpy(status_bar_layer->config.info_text_buffer, text, INFO_TEXT_BU... | prv_get_text_format() | ;
const GFont font = text_format.font;
const uint8_t font_height = fonts_get_font_height(font);
const int16_t center = (max_x + min_x) / 2;
const int16_t left_width = center - min_x;
const int16_t right_width = max_x - center;
// Use larger distance from the center to min_x or max_x as half of the width (od... |
SS);
}
}
static uint32_t s_watch_file_callback_called_count = 0;
static void prv_file_changed_callback(void *data) {
s_watch_file_callback_called_count++;
}
void test_pfs__watch_file_callbacks(void) {
const char* file_name = "newfile";
PFSCallbackHandle cb_handle = pfs_watch_file(file_name, prv_file_changed_... | (memcmp(buf, bufcmp, sizeof(buf)) == 0) | ;
cl_assert_equal_i(pfs_close(fd), S_SUCCESS);
}
}
static bool prv_filename_filter_a_prefix_cb(const char *name) {
return (strncmp(name, "a_", 2) == 0);
}
static bool prv_find_name(ListNode *node, void *data) {
PFSFileListEntry *entry = (PFSFileListEntry *)node;
return (strcmp(entry->name, (char *)data) =... |
GTransformNumberFromNumber(2),
GTransformNumberFromNumber(3), GTransformNumberFromNumber(4),
GTransformNumberFromNumber(5), GTransformNumberFromNumber(6));
int32_t test_array[6] = {1 * (1 << FIXED_S32_16_PRECISION),
2 * (1 << FIXED_S32_16_PRECISION)... | ((float)sine / TRIG_MAX_RATIO) | ,
GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO),
GTransformNumberZero,
GTransformNumberZero);
cl_assert(!gtransform_is_equal(&t, &t_c));
t = GTransformRotation(0); // Should return identity if angle == 0
cl_assert(gtransform_is_identity(&t));
... |
static void prv_watch_is_in_motion(void) {
prv_handle_action(StationaryActionWakeUp);
}
static void prv_stationary_check_launcher_task_cb(void *unused_data) {
if (prv_update_and_check_accel_is_stationary()) {
prv_watch_is_motionless();
} else {
prv_watch_is_in_motion();
}
}
//! Called every minute to... | regular_timer_add_seconds_callback(&s_accel_stationary_timer_info) | ;
#else
regular_timer_add_minutes_callback(&s_accel_stationary_timer_info);
#endif
s_current_state = StationaryStateAwake;
}
static void prv_handle_awake_action(StationaryAction action) {
switch (action) {
case StationaryActionGoToSleep:
prv_enter_stationary_state();
break;
case StationaryAct... |
equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
menu_layer_set_selected_next(&l, true, MenuRowAlignNone, false);
cl_assert_equal_i(2 * NORMAL, l.selection.y);
cl_assert_equal_i(NORMAL - FOCUSED, scroll_layer_get_content_offset(&l.scroll_layer).y);
cl_assert_equal_i(FOCUSED, l.selection.h);
... | (initial_scroll_offset, l.scroll_layer.content_sublayer.bounds.origin.y) | ;
// in this test setup, we can directly cast an animation to AnimationPrivate
AnimationPrivate *ap = (AnimationPrivate *) l.animation.animation;
const AnimationImplementation *const impl = ap->implementation;
impl->update(l.animation.animation, ANIMATION_NORMALIZED_MAX / 10);
// still unchanged
cl_assert_... |
/*
* 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... | (-10, 2, 18, 4) | );
}
static void across_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_rect(ctx, &GRect(4, 5, 18, 10));
}
static void across_ny_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphic... |
t)GPIOI;
gpio_addr += 0x400) {
gpio_pin = (GPIO_TypeDef *)gpio_addr;
gpio_use(gpio_pin);
uint32_t mode = gpio_pin->MODER;
gpio_release(gpio_pin);
uint16_t pin_cfg_mask = 0;
char buf[80];
for (int pin = 0; pin < 16; pin++) {
if ((mode & GPIO_MODER_MODER0) != GPIO_Mode_AN) {
... | regular_timer_add_seconds_callback(&vcom_timer) | ;
}
}
static void init_drivers(void) {
board_init();
// The dbgserial input support requires timer support, so it is initialized here, much later
// than the core dbgserial_init().
dbgserial_input_init();
serial_console_init();
voltage_monitor_init();
battery_init();
vibe_init();
#if CAPABILITY_... |
{ 840, 296, 104},
{ 888, 424, 40},
{ 896, 392, 0},
{ 1120, 464, -56},
{ 1272, 432, 48},
{ 1800, 480, 120},
{ 1536, 448, 120},
{ 1064, 264, 96},
{ 1360, 160, 144},
// 69 seconds
{ 1632, 56, 280},
{ 1472, 80, 280},
{ 1240, -24, 296},
{ 1072, -24, 232},
{ 968, 0, 1... | { 1152, 408, 104},
{ 1568, 696, 96},
{ 1752, 704, 72},
{ 1352, 496, 24},
{ 1272, 344, 88},
{ 1544, 152, 192},
{ 1472, 0, 232},
{ 1312, 16, 224},
{ 1072, -40, 240},
{ 848, -48, 192},
{ 728, -40, 120},
{ 640, -32, 96},
{ 624, -32, 56},
{ 648, -48, -32},
{ 880, 2... | |
data->error_exit_status = DictationSessionStatusFailureSystemAborted;
prv_push_final_error_dialog(data);
}
else {
const GColor dialog_bg_color = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite);
prv_push_error_dialog(data, msg, RESOURCE_ID_GENERIC_WARNING_LARGE, dialog_bg_color);
}
} els... | ("Turn on usage logs to use voice.\n\n"
"On your phone, go to Settings in the Pebble Time app.") | ,
RESOURCE_ID_GENERIC_WARNING_TINY);
data->error_exit_status = DictationSessionStatusFailureDisabled;
} else {
prv_exit_and_send_result_event(data, DictationSessionStatusFailureDisabled);
}
break;
case VoiceStatusErrorGeneric:
case VoiceStatu... |
// must be typecast
Fixed_S32_16Setter setter = (Fixed_S32_16Setter)((PropertyAnimationImplementation*)
property_animation->animation.implementation)
->accessors.setter.int16;
setter(property_animation->subject, result);
}
// -------------------------... | implementation->accessors.getter.gcolor8(subject) | ;
property_animation->values.from.gcolor8 = from_value ? *((GColor8*)from_value)
: implementation->accessors.getter.gcolor8(subject);
} else if (property_animation->animation.implementation->update
== (AnimationUpdateImplementation)property_animation... |
/*
* 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... | (atol(" 573888"), 573888) | ;
cl_assert_equal_i(atol(" 713713"), 713713);
}
void test_atol__suffix(void) {
cl_assert_equal_i(atol("500hurf"), 500);
cl_assert_equal_i(atol("765berserker"), 765);
cl_assert_equal_i(atol("573888 redmage"), 573888);
cl_assert_equal_i(atol("713713 4 job fiesta111"), 713713);
}
void test_atol__sign(vo... |
(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 3);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw3_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 3);
graphics_dra... | {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// AA = true, SW = 1
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 1);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));... |
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 3);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw3_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 3)... |
key, sizeof(key), buffer, size) == S_SUCCESS) {
for (int i = 0; i < size / UUID_SIZE; i++) {
Uuid *pinid = (Uuid *) &buffer[UUID_SIZE * i];
if (uuid_is_invalid(pinid)) {
continue;
}
alarm_pin_remove(pinid);
settings_file_delete(fd, &key, sizeof(key));
succ... | cron_job_unschedule(&s_next_alarm_cron) | ;
s_next_alarm_cron = *cron;
s_next_alarm_cron.cb_data = (void*)(intptr_t)alarm->id;
s_next_alarm = *alarm;
s_next_alarm_time = cron_job_schedule(&s_next_alarm_cron);
PBL_LOG(LOG_LEVEL_INFO, "Scheduling alarm %u to go off at %d:%d (%ld) (smart:%d)",
alarm->id, alarm->config.hour, alarm->config.minut... |
inute 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_assert_equal_s("2 minutes ago", time_buf);
// June 9th 2015, 15:00:00 (T-01:00:00)
rtc_set_time(event_time ... | clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | |
--------------------------------------------------------------------
// Set to not sleeping
s_kalg_sleep_start_utc = 0;
s_kalg_sleep_m = 0;
activity_algorithm_metrics_changed_notification();
uint16_t steps_awake_60m;
uint16_t steps_awake_100m;
uint16_t steps_awake_120m;
// Call the minute handler, whi... | cl_assert_equal_i(retrieve[i].steps, 0) | ;
} else {
cl_assert_equal_i(retrieve[i].steps, minute_data[i].base.steps);
}
cl_assert_equal_i(retrieve[i].orientation, minute_data[i].base.orientation);
cl_assert_equal_i(retrieve[i].vmc, minute_data[i].base.vmc);
cl_assert_equal_i(retrieve[i].light, ambient_light_level_to_enum(
minute... |
else {
item_layer->animation = property_animation_create(&implementation,
item_layer, NULL, &new_offset);
PBL_ASSERTN(item_layer->animation);
animation_set_auto_destroy(property_animation_get_animation(item_layer->animation), false);
}
Animation *animation = property_animation_get_animation(item... | window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, prv_handle_up_click) | ;
window_single_repeating_click_subscribe(BUTTON_ID_DOWN, 100, prv_handle_down_click);
window_single_click_subscribe(BUTTON_ID_SELECT, prv_handle_select_click);
window_set_click_context(BUTTON_ID_UP, context);
window_set_click_context(BUTTON_ID_DOWN, context);
window_set_click_context(BUTTON_ID_SELECT, contex... |
e "applib/graphics/text_layout_private.h"
#include "applib/graphics/graphics.h"
#include "applib/graphics/framebuffer.h"
#include "clar.h"
///////////////////////////////////////////////////////////
// Stubs
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_hexdump.h"
#include "stubs_heap.h"
#in... | (layout.max_used_size.w, 4 * HORIZ_ADVANCE_PX) | ;
cl_assert_equal_i(layout.max_used_size.h, 3 * FONT_HEIGHT); // 3 lines - but not 4, since the fourth has no chance of appearing ("Jr\nWho-\npper")
}
void test_text_layout__cache_vert_overflow_first_line(void) {
GContext gcontext = (GContext) { };
GFont font = (GFont) { 0 };
GRect box = (GRect) { (GPoint) { ... |
s->all_passed);
if (results->all_passed) {
pass_count++;
} else {
fail_count++;
}
// Print name of test
printf("\n%-24s", entry->name);
// Print each metric for this test
ActualValue *actual = &results->activity_type;
ExpectedValue *expected = &entry->activity_type;
for... | rtc_get_time() | ;
for (int i = 0; i < samples_len; i++) {
// NOTE: We feed in a significant VMC to simulate activity so that the sleep algorithm
// doesn't think we're sleeping
kalg_activities_update(s_kalg_state, now, samples[i].steps, 7000 /*vmc*/, 0 /*orientation*/,
true /*plugged_in*/, samp... |
- ALG_SLEEP_HISTORY_HOURS_FOR_TODAY * SECONDS_PER_HOUR;
const time_t k_newest_valid_utc = now;
AlgLogMinuteFileContext context = (AlgLogMinuteFileContext) {
.oldest_key = prv_minute_file_get_settings_key(k_oldest_valid_utc) - 1,
.newest_key = prv_minute_file_get_settings_key(k_newest_valid_utc) + 1,
.o... | PBL_LOG(LOG_LEVEL_DEBUG, "Compaction done, ended up with %"PRIu16" records",
s_alg_state->num_minute_records) | ;
exit:
if (file && (need_close || nuke_file)) {
prv_minute_data_file_close(file);
file = NULL;
}
if (nuke_file) {
PBL_LOG(LOG_LEVEL_WARNING, "Detected invalid minute data file, deleting it");
pfs_remove(ALG_MINUTE_DATA_FILE_NAME);
}
return file;
}
// --------------------------------------... |
sizeof(core_dump_connect_ping));
psleep(10);
dialog_spi_receive_data_no_wait(buffer, sizeof(buffer));
if (memcmp(buffer, core_dump_connect_response, sizeof(core_dump_connect_response)) == 0) {
PBL_LOG(LOG_LEVEL_INFO, "Core Dump connect response received");
return true;
}
}
PBL... | (&flash_addr, &max_size, (ElfExternalNote *)build_id) | ) {
PBL_LOG(LOG_LEVEL_ERROR, "Can't reserve slot for BLE core dump");
goto powerdown;
}
uint32_t flash_addr_max = flash_addr + max_size;
PBL_LOG(LOG_LEVEL_DEBUG, "Using flash slot %lx %lx", flash_addr, flash_addr_max);
// Read every region from the region table in blocks of 16k.
cmd.cmd = CoreDumpCmd... |
--------------------------------------------------------------------
// Handling inbound GATT Notifications
static void prv_handle_ns_notification(uint32_t length, const uint8_t *notification) {
PBL_ASSERTN(notification != NULL);
analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_NS_COUNT, AnalyticsClient_Sy... | prv_reset_due_to_bt_error() | |
le_info;
#if CAPABILITY_HAS_ACCESSORY_CONNECTOR
SmartstrapConnectionState smartstrap_state;
#endif
ContentIndicatorsBuffer content_indicators_buffer;
bool app_framebuffer_render_pending;
AppFocusState app_focus_state;
UnobstructedAreaState unobstructed_area_service_state;
Layer* layer_tree_stack[LAYER... | tick_timer_service_state_init(app_state_get_tick_timer_service_state()) | ;
#if CAPABILITY_HAS_HEALTH_TRACKING
health_service_state_init(app_state_get_health_service_state());
#endif
locale_init_app_locale(app_state_get_locale_info());
content_indicator_init_buffer(app_state_get_content_indicators_buffer());
unobstructed_area_service_init(app_state_get_unobstructed_area_state(),
... |
sitive_action = i18n_noop("I feel fabulous!"),
.text_neutral_action = i18n_noop("About average"),
.text_negative_action = i18n_noop("I'm still tired"),
.text_positive_response = i18n_noop("Awesome!"),
.text_neutral_response = i18n_noop("Keep it up!"),
.text_negative_response = i18n_noop("We'll get there!"),
... | i18n_noop("A good night's sleep goes a long way! Try to get more hours tonight.") | ,
},
}
};
static void prv_create_and_push_notification(const NotificationConfig *config);
static void prv_push_sleep_summary_notification(time_t notif_time, int32_t sleep_total_seconds,
int32_t sleep_average_seconds, int variant);
static int32_t prv_get_step_count(... |
start_utc, &local_tm);
const int session_start_24h = (local_tm.tm_sec +
local_tm.tm_min * SECONDS_PER_MINUTE +
local_tm.tm_hour * SECONDS_PER_HOUR);
const int session_end_24h = session_start_24h + (session->length_min * SECONDS_PER_MINUTE);
... | PBL_IF_BW_ELSE(37, 32) | , 39);
const int x_center_offset = 17;
kino_reel_draw(data->icon, ctx, GPoint(base_layer->bounds.size.w / 2 - x_center_offset, y));
}
static void prv_render_current_sleep_text(GContext *ctx, Layer *base_layer) {
HealthSleepSummaryCardData *data = layer_get_data(base_layer);
const int y = PBL_IF_RECT_ELSE(PBL_... |
]), print_buf);
cl_check_(gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]), print_buf);
}
}
#endif
bitblt_bitmap_into_bitmap(&dest_bitmap, &s_bmp, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(prv_check_source_stripe_blit(dest_bitmap_data, &s_bmp, GColorWhite));
}
static void prv_opaqu... | for (uint8_t idx = 0; idx < WIDTH; idx++) {
if (s_palette[idx].a == 3 || transparent) {
s_palette[idx] = color;
}
} |
break;
}
default:
break;
}
cl_assert(prv_check_source_stripe_blit(dest_bitmap_data, &s_bmp, GColorWhite));
}
void test_bitblt_palette__2Bit_assign_opaque(void) {
prv_opaque_2bit_simple(GCompOpAssign);
}
void test_bitblt_palette__2Bit_set_opaque(void) {
prv_opaque_2bit_simple(GCompOpSet);... |
che_get_next_eviction());
}
/*************************************
* Add 3, remove 2, evict one *
*************************************/
void test_app_cache__add_remove_evict(void) {
// add all three
cl_assert_equal_i(S_SUCCESS, app_cache_add_entry(app1.id, app1.size));
cl_assert_equal_i(S_SUCCESS, app_cache_... | (false, app_cache_entry_exists(app1.id)) | |
4 - header_overhead;
for (int log_len = 2; log_len < 128; log_len += 3) {
test_flash_logging__cleanup();
test_flash_logging__initialize();
flash_logging_init();
int num_logs;
char **logs = generate_unique_logs(space_avail, log_len, &num_logs);
setup_and_test_expected_msg(logs, 0, 0, num_logs)... | flash_logging_log_start(strlen(log)) | |
/*
* 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... | {
end_utc = sleep_earliest_end_utc;
} | else {
end_utc = step_earliest_end_utc;
}
// See if we should keep this activity
time_t end_time = sessions[i].start_utc + (sessions[i].length_min * SECONDS_PER_MINUTE);
if ((end_time >= end_utc) && (end_time <= utc_sec)
&& (!remove_ongoing || !sessions[i].ongoing)) {
// Keep it
... |
-------------------------------------------------------------------------------
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
}
// -------------------------------------------------------------------------------
static void down_click_handler(ClickRecognizerRef recognizer, void *context) ... | layer_set_update_proc(window_layer, layer_update_proc) | ;
// Current temp
data->cur_temp_layer = text_layer_create(CUR_TEMP_RECT);
text_layer_set_text_alignment(data->cur_temp_layer, GTextAlignmentCenter);
text_layer_set_font(data->cur_temp_layer,
fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS));
text_layer_set_background_color(data->cu... |
test_ancs_filtering__initialize(void) {
s_now = 1;
s_performed_store = false;
s_expected_attributes = NULL;
s_expected_actions = NULL;
}
void test_ancs_filtering__cleanup(void) {
}
void test_ancs_filtering__record_app_no_action_needed(void) {
// We have some existing prefs which includes all the defaults
... | (existing_prefs, &expected_prefs) | ;
}
void test_ancs_filtering__record_app_update_timestamp(void) {
// We already have all the default attributes, but it has been a while since we got our last
// notification from this source
iOSNotifPrefs prefs = {
.attr_list = {
.num_attributes = 3,
.attributes = (Attribute[]) {
{ .id =... |
num_scrollable_metrics,
scrollable_metrics);
}
static void prv_sync_tuple_changed_callback(uint32_t key, const Tuple *new_tuple,
const Tuple *old_tuple, void *context) {
SportsAppData *data = context;
switch (k... | strncpy(buffer, data->duration_string, MIN(buffer_size, sizeof(data->duration_string))) | ;
break;
}
case WorkoutMetricType_Custom:
{
strncpy(buffer,
data->custom_value_string,
MIN(buffer_size, sizeof(data->custom_value_string)));
break;
}
// Not supported by the sports API
case WorkoutMetricType_Steps:
case WorkoutMetricType_AvgPace:... |
/*
* 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... | atoi("573888") | , 573888);
cl_assert_equal_i(atoi("713713"), 713713);
}
void test_atoi__whitespace_pfx(void) {
cl_assert_equal_i(atoi(" 500"), 500);
cl_assert_equal_i(atoi(" 765"), 765);
cl_assert_equal_i(atoi(" 573888"), 573888);
cl_assert_equal_i(atoi(" 713713"), 713713);
}
void test_atoi__suff... |
_t *)dest_bitmap->addr) + dest_begin_x;
const int dest_row_length_words = (dest_bitmap->row_size_bytes / 4);
// The number of bits between the beginning of dest_block and
// the beginning of the nearest 32-bit block:
const uint8_t dest_shift_at_line_begin = (dest_rect.origin.x % 32);
const int16_t src_begin_... | {
case GBitmapFormat1Bit:
bitblt_bitmap_into_bitmap_tiled_1bit_to_1bit(dest_bitmap, src_bitmap, dest_rect,
src_origin_offset, compositing_mode, tint_color);
break;
case GBitmapFormat1BitPalette:
case GBitmapFormat2BitPalette:
bitblt_bitmap... |
}
|
12},
// 88 seconds
{ 1064, 312, -344},
{ 1160, 208, -272},
{ 1432, 208, -304},
{ 1192, 248, -256},
{ 1368, 104, -256},
{ 1400, 24, -104},
{ 1032, 16, -192},
{ 616, 24, -192},
{ 448, 16, -216},
{ 464, -8, -128},
{ 624, 48, -128},
{ 824, 104, -168},
{ 1112, 56, -280... | { 616, 96, -192},
{ 464, 88, -136},
{ 424, 160, -80},
{ 592, 232, -152},
{ 736, 296, -200},
{ 1016, 360, -280},
{ 1208, 328, -352},
{ 1608, 232, -280},
{ 1064, 376, -304},
{ 1264, 144, -272},
{ 1368, 96, -96},
// 94 seconds
{ 1088, 64, -136},
{ 664, 72, -168},
... |
{ 984, 136, -272},
{ 1272, -80, -312},
{ 1248, 40, -288},
{ 960, 0, -304},
{ 568, -24, -304},
{ 384, -48, -216},
{ 368, -48, -104},
{ 536, 64, -152},
{ 752, 192, -232},
{ 976, 248, -328},
{ 1184, 272, -408},
{ 1520, 104, -344},
{ 1160, 216, -360},
{ 1440, 48, -24... |
/*
* 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_bool_to_string(is_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... | {
PBL_ASSERTN(category < SettingsMenuItem_Count);
return s_submodule_registry[category]();
} |
const char *settings_menu_get_status_name(SettingsMenuItem category) {
const SettingsModuleMetadata *info = settings_menu_get_submodule_info(category);
return info->name;
}
void settings_menu_push(SettingsMenuItem category) {
Window *window = settings_menu_get_submodule_info(category)->init();
app_window_sta... |
RootKeyType key_type = 0; key_type < SMRootKeyTypeNum; ++key_type) {
cl_assert_equal_b(shared_prf_storage_get_root_key(key_type, &keys_out[key_type]), true);
// It's a byte array inside, so memcmp should be OK to use:
cl_assert_equal_i(memcmp(&keys[key_type], &keys_out[key_type], sizeof(keys[0])), 0);
}
}... | cl_assert_equal_i(flags, 0xff) | ;
cl_assert_equal_b(sm_is_pairing_info_equal_identity(&PAIRING_INFO, &pairing_info_out), true);
cl_assert_equal_s(device_name_out, DEVICE_NAME);
// Check getting started
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), GETTING_STARTED_COMPLETE);
// Check local_name
cl_assert_equal_b(sh... |
in.y, to.origin.y, normalized, interpolate));
}
typedef struct {
GRect from;
GRect to;
GSize size;
GPoint offset;
} ScaleToGValues;
typedef struct {
const struct {
ScaleToGValues integer;
ScaleToGValues precise;
Fixed_S32_16 duration_fraction;
GPointIndexLookup *lookup;
AnimationProgres... | {
case GStrokeWidthOpSet:
return op_value;
case GStrokeWidthOpMultiply:
return Fixed_S16_3_mul(native, op_value);
case GStrokeWidthOpAdd:
return Fixed_S16_3_add(native, op_value);
default:
WTF;
} |
}
static bool prv_gdraw_command_scale_stroke_width(GDrawCommand *command, uint32_t index,
void *context) {
ScaleStrokeWidthCBContext *scale = context;
const Fixed_S16_3 stroke_width =
Fixed_S16_3(gdraw_command_get_stroke_width(command) << FIXED_S16_3_PRECISIO... |
= play_count_spawn * (MAX(total_duration_a, total_duration_b) + delay_spawn);
// Create 2 test animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
animation_set_delay(a, delay_a);
animation_set_play_count(a, play_count_a);
Animation *b = prv_create_test_animatio... | (spawn != NULL) | |
et_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000);
cl_assert(timeline_remove(&item1.header.id));
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 3);
cl_assert(!prv_get_calendar_ongoing(... | cl_assert(stub_new_timer_is_scheduled(timer_id)) | ;
cl_assert_equal_i(15*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(35 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_count(), 4);
cl_assert(!prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(65*60, stub_new_t... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (pin_config->gpio, &init) | ;
gpio_release(pin_config->gpio);
}
void gpio_output_set(const OutputConfig *pin_config, bool asserted) {
if (!pin_config->active_high) {
asserted = !asserted;
}
gpio_use(pin_config->gpio);
GPIO_WriteBit(pin_config->gpio, pin_config->gpio_pin,
asserted? Bit_SET : Bit_RESET);
gpio_releas... |
possible shape
static void copy_last_args_for_mock(ArgsForMock *actual_args, ArgsForMock *last_args) {
memcpy(actual_args, last_args, sizeof(ArgsForMock));
}
// Zero out the arguments from the last run
static void reset_last_args_for_mock() {
memset(&s_last_args_for_mock, 0x00, sizeof(s_last_args_for_mock));
}
//... | graphics_context_set_stroke_color_2bit(&context, GColor2Black) | ;
cl_assert(gcolor_equal(context.draw_state.stroke_color, GColorBlack));
// Fill Color
graphics_context_set_fill_color(&context, GColorClear);
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb);
color = GColorOrange;
graphics_context_set_fill_color(&context, color);
#if PBL_COLOR
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... | if (!comm_session_is_valid(session)) {
job->impl->free(job);
*job_ptr_ptr = NULL;
goto unlock;
} |
ListNode *head = (ListNode *)session->send_queue_head;
PBL_ASSERTN(!list_contains(head, (const ListNode *)job));
if (head) {
list_append(head, (ListNode *)job);
} else {
session->send_queue_head = job;
}
// Schedule to let the transport to send the enqueued data:
comm_session_se... |
qual_i(BITS_BETWEEN(1, 10), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_sectors_1_thru_11(void) {
cl_assert(system_flash_erase(FLASH_BASE + 25 KiB, 871 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(1, 10), erased_sector);
cl_assert(flash_locked);
}
void callback_is_called_cb(u... | (stderr, "0x%.08x", num) | ;
}
extern void dbgserial_putstr(char *str) {
fprintf(stderr, "%s\n", str);
}
|
/*
* 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_inbox_service_write(AppInboxServiceTagAppMessageReceiver, data, length);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (a, b, 32) | |
/*
* 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_ftl_size += prv_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 regions so PFS can know ab... |
teps_buffer, sizeof(data->steps_buffer), i18n_get("%d,%03d", data),
thousands, hundreds);
} else {
/// Step count less than 1000
snprintf(data->steps_buffer, sizeof(data->steps_buffer), i18n_get("%d", data),
hundreds);
}
layer_mark_dirty(&data->base_layer);
}
static void prv_upd... | gbitmap_init_with_resource(&data->shoe_blue_small, RESOURCE_ID_STRIDE_SHOE_BLUE_SMALL) | ;
gbitmap_init_with_resource(&data->shoe_green_small, RESOURCE_ID_STRIDE_SHOE_GREEN_SMALL);
#endif // PBL_RECT
data->steps_font = fonts_get_system_font(FONT_KEY_AGENCY_FB_36_NUMBERS_AM_PM);
data->time_font = fonts_get_system_font(FONT_KEY_AGENCY_FB_60_NUMBERS_AM_PM);
data->am_pm_font = fonts_get_system_font(FON... |
LE)) {
// we are rediscovering all services so flush everything
prv_free_service_nodes(connection);
prv_send_services_invalidate_all_event(
connection, BTErrnoServiceDiscoveryDatabaseChanged);
} else { // we are rediscovering one service
gatt_client_discovery_handle_service_range_change(connec... | prv_run_next_job(connection) | ;
}
unlock:
bt_unlock();
return ret_val;
}
//! extern for gap_le_connnection.c
//! Cleans up any state and frees the associated memory of all the things this module might have
//! created for a given connection.
//! bt_lock() is assumed to be taken by the caller
void gatt_client_discovery_cleanup_by_connection(G... |
turn NULL;
}
bool memory_layout_is_buffer_in_region(const MpuRegion *region, const void *buf, size_t length) {
return true;
}
// We can't include all of stubs_process_manager because it conflicts with fake_app_manager.h
bool process_manager_send_event_to_process(PebbleTask task, PebbleEvent* e) {
return true;
}
/... | (random_buf) | ;
return (random_crc);
}
// ----------------------------------------------------------------------------------------
static void prv_log_consume_random(DataLoggingSessionRef logging_session, int item_size,
int num_items) {
uint32_t random_crc = prv_log_random_data(logging_session... |
, 20)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 144, 168)
#define ORIGIN_DRAW_RECT_NO_CLIP GRect(6, 6, 30, 40)
#define ORIGIN_DRAW_RECT_CLIP_XY GRect(6, 6, 30, 40)
#define ORIGIN_DRAW_RECT_CLIP_NXNY GRect(-16, -16, 30, 40)
void test_graphics_draw_rect_${BIT_DEPTH_NAME}__origin_aa_sw(void) {
GContext ctx;
... | (&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// AA = true, SW = 11
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 11);
graph... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_s(dest, "Katharine") | ;
}
void test_phone_formatting__name_multiple(void) {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharine Claire Berry", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine C. B.");
}
void test_phone_formatting__name_double_space(void) {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharin... |
/*
* 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... | (shared_circular_buffer_get_write_space_remaining(&buffer), 6) | ;
// Now there's just 56 in the buffer. Fill it to the brim
cl_assert(shared_circular_buffer_write(&buffer, (uint8_t*) "789", 3, false));
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 3);
cl_assert(shared_circular_buffer_write(&buffer, (uint8_t*) "abc", 3, false));
cl_assert_eq... |
flag and just send a single byte.
buffer[0] = is_all_same ? FLASH_READ_FLAG_ALL_SAME : 0; // flags
const uint32_t frame_length = is_all_same ? 2 : request->length + 1;
prv_send_frame(OPCODE_FLASH_READ, buffer, frame_length);
}
static void prv_handle_flash_crc_request(const void *payload, uint32_t length) {
//... | (&s_curr_buf->hdlc_ctx, &data, &should_store, &hdlc_err) | ;
if (hdlc_err) {
s_curr_buf->is_valid = false;
} else if (is_complete) {
if (s_curr_buf->is_valid && s_curr_buf->checksum == CRC32_RESIDUE && s_curr_buf->index) {
// queue up processing of this frame and clear s_curr_buf so we'll switch to a new one
system_task_add_callback_from_isr(prv_process... |
et_x,
is_future ? style->future_fin_offset_y : style->past_fin_offset_y));
frame->size.w -= PBL_IF_RECT_ELSE(style->sidebar_width, 0);
}
static void prv_get_day_sep_frame(TimelineLayer *layer, int index, GRect *frame) {
prv_get_frame(layer, index, frame);
const bool is_future = (layer->scr... | if (i < num_items && node) {
prv_create_layout(layer, state, s_visible_items[i]);
} |
}
}
static void prv_update_pins_mode(TimelineLayer *layer) {
for (int i = 0; i < (int)ARRAY_LENGTH(s_visible_items); i++) {
TimelineLayout *timeline_layout = layer->layouts[s_visible_items[i]];
if (timeline_layout) {
LayoutLayerMode mode = prv_get_mode(i + 1);
layout_set_mode((LayoutLayer *)ti... |
essage_handler(AppOutboxConsumer *consumer,
AppOutboxMessage *message) {
void (*callback)(void *) = (__typeof__(callback))consumer->message_handler;
PebbleEvent event = {
.type = PEBBLE_APP_OUTBOX_MSG_EVENT,
.app_outbox_msg = {
.callback = callback,
... | prv_unlock() | ;
}
bool app_outbox_service_is_message_cancelled(AppOutboxMessage *message) {
prv_lock();
bool cancelled = !prv_find_consumer_with_message(message);
prv_unlock();
return cancelled;
}
void app_outbox_service_consume_message(AppOutboxMessage *message, AppOutboxStatus status) {
prv_lock();
{
if (app_outb... |
prv_trigger_activation_delay_insight(now_utc, &ACTIVATION_DELAY_INSIGHTS[i]) | ;
}
}
static void prv_test_push_walk_run_session(void *unused) {
const time_t now_utc = rtc_get_time();
ActivitySession walk_session = {
.type = ActivitySessionType_Walk,
.start_utc = now_utc - 30 * SECONDS_PER_MINUTE - 15 * SECONDS_PER_MINUTE,
.length_min = 30,
.step_data = {
.steps = 2400... | |
{ -80, -248, -992},
{ -72, -240, -976},
{ -80, -240, -984},
{ -72, -256, -992},
{ -80, -240, -976},
{ -80, -240, -984},
// 246 seconds
{ -80, -240, -976},
{ -72, -232, -984},
{ -80, -240, -992},
{ -80, -256, -984},
{ -80, -248, -984},
{ -80, -240, -992},
{ -80, -2... |
{ -72, -248, -976},
{ -88, -256, -976},
{ -80, -256, -976},
{ -80, -256, -976},
{ -72, -256, -976},
{ -88, -256, -984},
{ -80, -248, -984},
{ -80, -248, -984},
{ -72, -256, -976},
{ -80, -248, -984},
{ -72, -248, -984},
{ -88, -256, -984},
{ -80, -248, -976},
{ -... | |
/*
* 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... | applib_free(anim_ctx) | ;
}
static GEdgeInsets prv_action_menu_insets(Window *window) {
const int crumbs_width = crumbs_layer_width();
return (GEdgeInsets) {
.top = PBL_IF_RECT_ELSE(0, STATUS_BAR_LAYER_HEIGHT),
.right = PBL_IF_RECT_ELSE(0, crumbs_width),
.bottom = PBL_IF_RECT_ELSE(0, STATUS_BAR_LAYER_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... | (id, &entry) | ;
if (success) {
app_manager_put_launch_app_event(&(AppLaunchEventConfig) { .id = id });
prompt_send_response("OK");
} else {
prompt_send_response("No app with id");
}
}
void command_worker_launch(const char *id_str) {
int32_t id = atoi(id_str);
if (id == 0) {
prompt_send_response("invalid a... |
#include <stdio.h>
// Helper Functions
////////////////////////////////////
#include "test_graphics.h"
#include "8bit/test_framebuffer.h"
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
// State
////////////////////////////////////
typedef enum {... | cl_assert_equal_i(0, s_raw_drawing_function_counters[GDrawRawFunctionTypeBlendHorizontalLine]) | ;
cl_assert_equal_i(0, s_raw_drawing_function_counters[GDrawRawFunctionTypeBlendVerticalLine]);
cl_assert_equal_i(0,
s_raw_drawing_function_counters[GDrawRawFunctionTypeAssignHorizontalLineDelta]);
};
|
_head /* &head */, NULL /* &tail */);
const bool ascending = true;
state->scheduled_head = list_sorted_add(state->scheduled_head, &animation->list_node,
prv_scheduler_comparator, ascending);
const bool has_new_head = (&animation->list_node == state->scheduled_head);
... | } else if (animation->type == AnimationTypeSpawn) {
// For a spawn animation, schedule each of the components in parallel
// If any of the children have already been scheduled, then we need to back up our start time
// of the spawn accordingly and adjust the delay_ms field of every child such that
//... |
// Schedule the children that have not been scheduled yet. If any have already been scheduled,
// adjust the delays of all children to make it look the same as if the spawn had been
// scheduled in the past with no children scheduled yet.
int32_t delay = animation->delay_ms + add_delay_ms;
for (chi... |
portState_Idle;
prv_lock();
circular_buffer_consume(&s_spi_transport.tx, s_spi_transport.bytes_sendable_count);
prv_unlock();
prv_give_semamphore_from_isr(should_context_switch);
}
static void prv_handle_sending_complete_isr(bool *should_context_switch) {
// Wait for the controller to signal that it's ready... | {
uint32_t crc = crc32(CRC32_INIT, &s_spi_transport.status_remote,
sizeof(s_spi_transport.status_remote));
if (crc != CRC32_RESIDUE) {
PBL_LOG(LOG_LEVEL_ERROR, "CRC failed on remote SPITransportMsgStatus 0x%"PRIx32 " vs 0x%"PRIx32,
crc, (uint32_t)CRC32_RESIDUE);
PBL_LOG(LO... |
if (s_spi_transport.bytes_receivable_count) {
prv_watchdog_start();
s_spi_transport.state = SPITransportState_WaitingForReceiving;
} else if (s_spi_transport.bytes_sendable_count) {
prv_watchdog_start();
s_spi_transport.state = SPITransportState_WaitingForSending;
} else {
// Nothing to send ... |
const char *text,
uint32_t resource_id) {
prv_set_mic_window_state(data, StateError);
ExpandableDialog *long_error_dialog = &data->long_error_dialog;
expandable_dialog_init(long_error_dialog, "Error");
Dialog *dialog = expandable_dialog_get_dialog(long_error_dialog);
const GColor dialog_bg_color = PBL_IF... | prv_get_time_ms() | ;
data->speech_detected = false;
data->dictation_timeout = app_timer_register(DICTATION_TIMEOUT, prv_dictation_timeout_cb,
data);
// Update UI
prv_set_mic_window_state(data, StateRecording);
break;
case VoiceStatusErrorConnectivity:
// Subsequent attempts are probably... |
e
prv_reset();
s_current_path = s_house_path;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_aa.${BIT_DEPTH_NAME}.pbi"));
// Special case for two points that are duplicates...
... | graphics_context_set_antialiased(&ctx, true) | ;
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_infinite_aa.8bit.pbi"));
// An angle of infinite path - here we see the spacing between the parts
prv_reset();
s_current_path = s_infinite_path;
gpath_move_to(s_infinite_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGH... |
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_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1);
cl_assert_equal_i(prv_count_h... | prv_count_handler_entries(&s_stopped_handler_calls, c) | , 1);
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_last_update_distance(c), ANIMATION_NORMALIZED_MAX);
// Make sure each animation got to the end
AnimTestHandlerEntry *entry;
entry ... |
llId new_app_id = app_install_get_id_for_uuid(&default_process->uuid);
s_next_app = (NextApp) {
.md = default_process,
};
s_next_app.common.transition = shell_get_close_compositor_animation(current_app_id, new_app_id);
prv_app_switch(true /*gracefully*/);
}
const PebbleProcessMd* app_manager_get_current_a... | (ANALYTICS_APP_METRIC_APP_MAJOR_VERSION, app_version.major, AnalyticsClient_App) | ;
analytics_set(ANALYTICS_APP_METRIC_APP_MINOR_VERSION, app_version.minor, AnalyticsClient_App);
ResourceVersion resource_version = process_metadata_get_res_version(app_md);
analytics_set(ANALYTICS_APP_METRIC_RESOURCE_TIMESTAMP, resource_version.timestamp, AnalyticsClient_App);
if (app_md->is_rocky_app) {
... |
/*
* 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... | (render_app) | |
ek day, int32_t value) {
printf("s_metric_updated_count: %d\n", s_metric_updated_count);
s_metric_updated_count++;
}
// Setup
////////////////////////////////////////////////////////////////
void test_health_db__initialize(void) {
fake_settings_file_reset();
health_db_init();
s_metric_updated_count = 0;
}
... | (ActivityMetricSleepTotalSeconds, Monday, &val_out) | |
y.raw_value;
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, data->stroke_width);
if (data->stroke_width >= 2) {
graphics_line_draw_precise_stroked_aa(ctx, p0, p1, data->stroke_width);
} else {
graphics_draw_line(ctx, GPoint(p0.x.integer, p0.y.integer),
... | (s_window, animated) | |
t(job);
cl_assert_equal_i((i + 1) * sizeof(TEST_DATA),
comm_session_send_queue_get_length(s_valid_session));
}
}
static void prv_add_jobs(int num_jobs) {
for (int i = 0; i < num_jobs; ++i) {
SessionSendQueueJob *job = prv_create_test_job(TEST_DATA, sizeof(TEST_DATA));
comm_session... | ((num_jobs * sizeof(TEST_DATA)) - consumed,
comm_session_send_queue_get_length(s_valid_session)) | ;
}
void test_session_send_queue__consume_all(void) {
int num_jobs = 3;
prv_add_jobs(num_jobs);
comm_session_send_queue_consume(s_valid_session, UINT32_MAX);
cl_assert_equal_i(s_free_count, num_jobs);
}
void test_session_send_queue__cleanup_calls_free_on_all_jobs(void) {
cl_assert_equal_i(s_free_count, 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... | (RTC_BKP_BOOTBIT_DR, BOOT_BIT_INITIALIZED) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_ASSERTN(device->adc == ADC1);
mutex_lock(s_adc_mutex);
periph_config_enable(ADC1, RCC_APB2Periph_ADC1);
ADC_TempSensorVrefintCmd(ENABLE);
ADC_CommonInitTypeDef ADC_CommonInitStruct;
// Single ADC mode
ADC_CommonStructInit(&ADC_CommonInitStruct);
ADC_CommonInitStruct.ADC_Mode = ADC_Mode_Independe... |
ADC_SoftwareStartConv(ADC1); // Restart the conversion group
if (!prv_wait_for_conversion()) {
continue;
}
const uint16_t vref = ADC_GetConversionValue(ADC1);
if (!prv_wait_for_conversion()) {
continue;
}
const uint16_t vmon = ADC_GetConversionValue(ADC1);
// Only save val... |
//////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
static FrameBuffer *fb = NULL;
// Setup
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
}
// Teardown
void test_graphics_fil... | GRect(10, 15, 20, 10) | );
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_inside_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
layer_r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.