prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* 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... | (bus->hal->er_irq_channel) | ;
prv_i2c_deinit(bus);
}
void i2c_hal_enable(I2CBus *bus) {
const I2CBusHal *hal = bus->hal;
periph_config_enable(hal->i2c, hal->clock_ctrl);
// Soft reset of the state machine and status bits by disabling the peripheral.
// Note: PE must be low for 3 APB cycles after this is done for the reset to be succes... |
, touch_event)) {
return;
}
recognizer->handling_touch_event = true;
recognizer->impl->handle_touch_event(recognizer, touch_event);
recognizer->handling_touch_event = false;
}
void recognizer_reset(Recognizer *recognizer) {
PBL_ASSERTN(recognizer && recognizer->impl);
recognizer_cancel(recognizer);
... | recognizer->impl->on_destroy(recognizer) | ;
}
applib_free(recognizer);
}
bool recognizer_is_owned(Recognizer *recognizer) {
if (!recognizer) {
return false;
}
return recognizer->is_owned;
}
void recognizer_add_to_list(Recognizer *recognizer, RecognizerList *list) {
if (!recognizer || !list || recognizer->is_owned) {
return;
}
recogn... |
10x10 square, white.
// - Destination is either a black or white square.
// Result:
// - When source is transparent or tint color is clear, dest is black.
// - When source is opaque, dest is blended blue
void test_bitblt__8bit_to_8bit_comptint(void) {
GBitmap *src_bitmap = get_gbitmap_from_pbi("test_bitblt__8b... | GRect(0, y_upper, 3, 1) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (rtr->header_buffer + rtr->bytes_received, *data_p, header_bytes_to_copy) | |
);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 0), 4);
graphics_draw_vertical_line_dotted(&ctx, GPoint(15, 0), 20);
graphics_draw_vertical_line_dotted(&ctx, GPoint(17, 0), 21);
graphics_draw_vertical_line_dotted(&ctx, GPoint(19, 0), 22);
graphics_draw_vertical_line_dotted(&ctx, GPoint(21, 0), MAX_NUM_... | graphics_draw_vertical_line_dotted(&ctx, GPoint(19, 0), 22) | ;
graphics_draw_vertical_line_dotted(&ctx, GPoint(21, 0), MAX_NUM_ROWS - 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 0), MAX_NUM_ROWS + 1 );
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_odd_cols_no_clip")));
// Test to make sure drawing on... |
/*
* 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_finished_failure_callback(data);
} |
}
static void prv_animation_stopped_failure(Animation *animation, bool finished, void *context) {
ProgressWindow *data = context;
prv_show_peek_layer(data);
}
static void prv_schedule_progress_success_animation(ProgressWindow *data) {
#if !PLATFORM_TINTIN
GRect beg = data->progress_layer.layer.bounds;
GRect ... |
ASSERT_JS_GLOBAL_EQUALS_S("t", "undefined");
// rocky_global_init() injects global...
static const RockyGlobalAPI *apis[] = {
NULL,
};
rocky_global_init(apis);
EXECUTE_SCRIPT(test_object);
ASSERT_JS_GLOBAL_EQUALS_S("t", "object");
// ...which also has a method .on()
EXECUTE_SCRIPT("var t = typ... | cl_assert_equal_b(true, rocky_global_has_event_handlers("b")) | ;
prv_add_event_listener_to_list("a", jerry_create_external_function(prv_listener_a2));
cl_assert_equal_b(true, rocky_global_has_event_handlers("a"));
cl_assert_equal_b(true, rocky_global_has_event_handlers("b"));
jerry_value_t a_event = rocky_global_create_event("a");
rocky_global_call_event_handlers(a_eve... |
, 288, -48},
{ 104, 272, 16},
{ 96, 328, 16},
{ 72, 456, 88},
{ 32, 760, 136},
{ -216, 1408, 176},
// 49 seconds
{ -224, 1712, 296},
{ -336, 1792, 304},
{ -192, 1536, 96},
{ -48, 1328, -104},
{ -80, 1008, -80},
{ -120, 760, -56},
{ -56, 656, -120},
{ -88, 536, -88... | { 272, 1568, 0},
{ 88, 1816, -56},
{ 104, 1192, -80},
{ 136, 888, -120},
{ 112, 568, -112},
{ 0, 560, -264},
{ -32, 360, -296},
{ -48, 128, -200},
{ -152, 8, -120},
{ -256, -112, -96},
{ -464, -56, -128},
{ -1040, 8, -192},
{ -1704, 96, -8},
{ -2688, -24, 368},
... |
{ -1448, -32, -16},
{ -1488, -88, -56},
{ -1360, -48, -112},
{ -1288, 24, 0},
{ -1520, 152, -16},
{ -1728, 360, -200},
{ -1520, 648, -272},
// 57 seconds
{ -1376, 448, -528},
{ -1336, 264, -336},
{ -1168, 480, -504},
{ -1480, 624, -408},
{ -1320, 312, -168},
{ -1... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | round(-0.5) | , -1.0);
cl_assert_equal_d(round(-1.0), -1.0);
cl_assert_equal_d(round(1.7976931348623157e+308), 1.7976931348623157e+308);
cl_assert_equal_d(round(2.2250738585072014e-308), -0.0);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(key_type < SMRootKeyTypeNum) | ;
bool rv = cl_mock_type(bool);
if (rv) {
memcpy(key_out, &s_retrieved_keys[key_type], sizeof(*key_out));
}
return rv;
}
static SM128BitKey s_stored_keys[SMRootKeyTypeNum];
void bt_persistent_storage_set_root_keys(SM128BitKey *keys_in) {
cl_mock_type(void);
memcpy(s_stored_keys, keys_in, sizeof(SM128Bi... |
list_find(&dir_list->list_node, prv_find_name, "a_test_1"));
cl_assert(list_find(&dir_list->list_node, prv_find_name, "b_test_0"));
cl_assert(list_find(&dir_list->list_node, prv_find_name, "b_test_1"));
pfs_delete_file_list(dir_list);
// Do another search using a filter
dir_list = pfs_create_file_list(prv_f... | (filename, "test%d", i) | ;
int fd = pfs_open(filename, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd > 0);
}
}
|
.crc);
prv_core_dump();
}
#if HOST_TRANSPORT_DEBUG
HOST_TRANSPORT_DEBUG_LOG("Received %u bytes:", rx_len);
PBL_HEXDUMP(LOG_LEVEL_DEBUG, rx_buffer_ptr, rx_len);
#endif
} else {
HOST_TRANSPORT_DEBUG_LOG("Nothing to receive.");
}
bool has_more_rx_data = (remote_status_in.bytes_sendable_count >... | {
init_spi_pins();
} |
static void prv_wakeup_init(void) {
hw_wkup_init(NULL);
hw_wkup_set_counter_threshold(1);
hw_wkup_set_debounce_time(0);
hw_wkup_configure_pin(HOST_SPI->spi.cs.port, HOST_SPI->spi.cs.pin,
true /* enabled */, HW_WKUP_PIN_STATE_LOW);
hw_wkup_reset_interrupt();
hw_wkup_reset_counter();... |
s();
}
const bool is_app_hidden_and_unfocused =
(!(update.properties & ModalProperty_Transparent) && !is_modal_unfocused);
const bool was_app_hidden_and_unfocused =
(!(last_properties & ModalProperty_Transparent) && !was_modal_unfocused);
if (!was_app_hidden_and_unfocused && is_app_hidden_and_unfoc... | if (window->is_click_configured && !is_focused) {
// A different modal window now has focus
window->is_click_configured = false;
} |
// Set the last highest visible modal priority
if (is_visible) {
ctx->highest_idx = iter->current_idx;
}
// Update properties based on state changes
// If this callback was called, there exists a modal
ctx->properties |= ModalProperty_Exists;
if (iter->current_idx > ModalPriorityDiscreet) {
//... |
ge(next_page, &next_page) != S_SUCCESS) {
return (E_RANGE);
}
}
f->curr_page = next_page;
}
*pg_offset = data_offset % free_bytes_in_page(f->curr_page);
return (S_SUCCESS);
}
static int mark_fd_free(int fd) {
if (PFS_FD(fd).file.name != NULL) {
kernel_free(PFS_FD(fd).file.name);
... | {
new_offset += offset;
} |
// allow one to seek to very EOF
if ((new_offset >= 0) &&
(new_offset <= (int)PFS_FD(fd).file.file_size)) {
if (PFS_FD(fd).file.offset != (uint32_t)new_offset) {
PFS_FD(fd).file.offset = (uint32_t)new_offset;
PFS_FD(fd).file.curr_page = INVALID_PAGE;
}
res = new_offset;
} else {
... |
le%d", i);
snprintf(buf, sizeof(buf), "This is small buf %d!", i);
int len = strlen(buf);
int fd = pfs_open(file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, len);
cl_assert(fd >= 0);
cl_assert(pfs_write(fd, (uint8_t *)buf, len) == len);
cl_assert(pfs_close(fd) == S_SUCCESS);
if ((i % 2) == 0) {
... | (rv, sizeof(st_val)) | |
most recent accesses are at the head of the list)
static LauncherAppGlance *prv_fetch_from_cache_or_load_glance_for_node(AppMenuNode *node,
LauncherAppGlanceService *service) {
if (!service || !node) {
return NULL;
}
Uuid *uuid = &node->uuid;
LauncherAppGlance *glance = NULL;
// Try to find the req... | kino_player_rewind(glance_reel_player) | ;
const bool use_glance_cache = prv_should_use_glance_cache_for_app_with_uuid(&node->uuid);
if (!use_glance_cache) {
// Don't play glances that we don't store in the cache since they don't live long enough
// to advance frames
return;
}
LauncherAppGlance *glance = prv_fetch_from_cache_or_load_glan... |
/*
* 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... | {
case CommSessionTypeApp:
return destination == TransportDestinationApp || destination == TransportDestinationHybrid;
case CommSessionTypeSystem:
return destination == TransportDestinationSystem || destination == TransportDestinationHybrid;
default:
return false;
} | |
the phone call
static TimerID s_call_watchdog = TIMER_INVALID_ID;
static void prv_handle_call_end(bool disconnected);
static bool prv_call_is_ancs(void) {
return (s_call_source == PhoneCallSource_ANCS_Legacy) || (s_call_source == PhoneCallSource_ANCS);
}
static void prv_poll_phone_for_status(void *context) {
pp... | phone_ui_handle_missed_call() | ;
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_INCOMING_COUNT, AnalyticsClient_System);
} else {
// PBL_LOG(LOG_LEVEL_DEBUG, "Ignoring missed call. A call is not in progress");
}
}
static void prv_handle_call_start(void) {
if (s_call_in_progress) {
if (prv_call_is_ancs()) {
// We don't show... |
tion->header.ancs_uid == existing_header->ancs_uid);
}
static bool prv_should_ignore_because_apple_mail_dot_app_bug(const ANCSAttribute *app_id,
const ANCSAttribute *message) {
// Apple's Mail.app sometimes sends a notification with "Loading..." or
// "T... | if (prv_should_ignore_because_stale(timestamp)) {
return true;
} |
return false;
}
void ancs_notifications_handle_message(uint32_t uid,
ANCSProperty properties,
ANCSAttribute **notif_attributes,
ANCSAttribute **app_attributes) {
PBL_ASSERTN(notif_attributes && ap... |
,
jerry_size_t buffer_size) {
return jerry_object_to_string_to_utf8_char_buffer(object,
buffer_p,
buffer_size);
}
jerry_value_t jerry_get_object_keys(const jerry_... | {
if (jerry_value_has_error_flag(value)) {
return TYPE_ERROR_FLAG;
}
return (jerry_value_t)EM_ASM_INT({
return __jerryRefs.ref(String(__jerryRefs.get($0)));
}, value);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_context_set_stroke_color(ctx, GColorBlack) | |
/*
* 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... | {
case HealthMetricStepCount:
case HealthMetricActiveSeconds:
case HealthMetricWalkedDistanceMeters:
case HealthMetricSleepSeconds:
case HealthMetricSleepRestfulSeconds:
case HealthMetricRestingKCalories:
case HealthMetricActiveKCalories:
return HealthAggregationSum;
case HealthMet... |
WTF;
return 0;
}
// ----------------------------------------------------------------------------------------------
static HealthServiceState* prv_get_state(bool ensure_cache_initialized) {
PebbleTask task = pebble_task_get_current();
HealthServiceState *result = NULL;
if (task == PebbleTask_App) {
resu... |
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_nx_origin_layer")));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_no_clip"))) | ;
// Even rows of different lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 0), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 2), 148);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 4), 0... |
T2 to avoid "data inconsistencies" which arise when
// we have it fifo / data interrupt on INT1.
static void prv_bma255_IRQ2_handler(bool *should_context_switch) {
BMA255_DBG("Data Int");
if (!s_accel_outstanding_data_work) {
s_accel_outstanding_data_work = true;
accel_offload_work_from_isr(prv_handle... | {
case BMA255SampleInterval_1HZ:
odr = BMA255ODR_1HZ;
break;
case BMA255SampleInterval_10HZ:
odr = BMA255ODR_10HZ;
break;
case BMA255SampleInterval_19HZ:
odr = BMA255ODR_19HZ;
break;
case BMA255SampleInterval_83HZ:
odr = BMA255ODR_83HZ;
break;
case BMA... |
return odr;
}
static BMA255SampleInterval prv_get_supported_sampling_interval(uint32_t interval_us) {
BMA255SampleInterval sample_interval;
if (BMA255SampleInterval_1HZ <= interval_us) {
sample_interval = BMA255SampleInterval_1HZ;
} else if (BMA255SampleInterval_10HZ <= interval_us) {
sample_interval ... |
/*
* 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_ctx, &s_fb, GContextInitializationMode_App) | ;
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
... |
tate.compositing_mode = processor_with_data->saved_compositing_mode;
ctx->draw_state.tint_color = processor_with_data->saved_tint_color;
}
GColor launcher_app_glance_structured_get_highlight_color(
LauncherAppGlanceStructured *structured_glance) {
return PBL_IF_COLOR_ELSE(GColorBlack,
... | fonts_get_font_cap_offset(font) | );
underlying_text_node_text->max_size.h = fonts_get_font_height(font);
return &underlying_text_node_text->node;
}
static void prv_structured_glance_title_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *node, UNUSED const GRect *box,
UNUSED const GTextNodeDrawConfig *config, UNUSED bool r... |
OCKY_WATCHINFO_FW_PATCH "patch"
#define ROCKY_WATCHINFO_FW_SUFFIX "suffix"
static const char *prv_get_platform_name_string(void) {
const PlatformType platform = sys_get_current_app_sdk_platform();
return platform_type_get_name(platform);
}
static jerry_value_t prv_get_platform_name(void) {
return jerry_create_s... | ("pebble_2_hr_white") | ;
break;
case WATCH_INFO_COLOR_PEBBLE_2_HR_AQUA:
model_name = SILK_MODEL("pebble_2_hr_aqua");
break;
case WATCH_INFO_COLOR_PEBBLE_2_SE_BLACK:
model_name = SILK_MODEL("pebble_2_se_black");
break;
case WATCH_INFO_COLOR_PEBBLE_2_SE_WHITE:
model_name = SILK_... |
me_since_activity = time_get_uptime_seconds() - app->last_activity;
if (app->can_expire && (time_since_activity < VISIBILITY_ON_ACTIVITY_TIMEOUT_SECONDS)) {
// The recent app should eventually expire and we are still below the threshold
rv = true;
} else if (!app->can_expire && app->last_act... | (&iter->node) | ;
}
}
static void app_install_invoke_callbacks(InstallEventType event_type, AppInstallId install_id) {
struct AppInstallCallbackNode *callback_node = (struct AppInstallCallbackNode *) s_head_callback_node_list;
while (callback_node) {
if (callback_node->callbacks[event_type]) {
callback_node->callbacks... |
st_single_codepoint_string_single_byte(void) {
// Mutable types
Iterator utf8_iter;
Utf8IterState utf8_iter_state;
// Immutable types
bool success = false;
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, "A");
cl_assert(utf8_bounds.end - utf8_bounds.start == 1);
cl_assert(success);
// Init ... | (s_codes[index], codepoint) | ;
cl_assert_equal_p(context, &s_context);
s_each_count++;
return (index != 2);
}
void test_utf8_iterator__each_codepoint_break(void) {
void *context = &s_context;
const char *str = "abcde";
s_each_count = 0;
cl_assert_equal_b(utf8_each_codepoint(str, prv_each_codepoint_break, context), true);
cl_assert... |
e_pending();
// Feed in 100 steps/min over 1 min, 1 minute of deep and 1 minute of light sleep
prv_feed_cannned_accel_data(60, 100, ActivitySleepStateAwake);
prv_feed_cannned_accel_data(60, 0, ActivitySleepStateLightSleep);
prv_feed_cannned_accel_data(60, 0, ActivitySleepStateRestfulSleep);
// Put in a step... | (actual_resting_kcalories[i] >= min_resting_kcalories
&& actual_resting_kcalories[i] <= exp_resting_kcalories_now) | ;
} else {
cl_assert_equal_i(actual_resting_kcalories[i], exp_resting_kcalories[i]);
}
}
// Make sure all of our activities persisted
ASSERT_NUM_ACTIVITY_SESSIONS(3); // 2 sleep sessions + 1 activity sessions
ASSERT_STEP_ACTIVITY_SESSION_PRESENT(&walk_activity);
// Pretend that 24 hours has ... |
SSERTN(response.data[2] == PACKET_FOOTER);
*(uint8_t *)result = response.data[1];
} else if (type == StatusReadType_12bit) {
// The 3 data bytes are ST PQ R1 (in hex) with ST being the address and RPQ being the value.
PBL_ASSERTN(response.data[0] == address);
PBL_ASSERTN((response.data[2] & 0x0F) == P... | {
const uint8_t msbs = message.touch.finger_data[i][0];
const uint8_t x_lsb = message.touch.finger_data[i][1];
const uint8_t y_lsb = message.touch.finger_data[i][2];
GPoint point = {
.x = ((uint16_t)msbs & 0xF0) << 4 | x_lsb,
.y = ((uint16_t)msbs & 0x0F) << 8 | y_lsb
... |
} else if (message.packet_id == PACKET_ID_PALM_DETECTION) {
touch_handle_driver_event(TouchDriverEvent_PalmDetect);
} else if (message.packet_id == PACKET_ID_HELLO) {
// TODO: PBL-29944 handle this gracefully by re-initializing - should "never" happen
PBL_CROAK("Touch controller reset!");
... |
nd of the second B
// Save the current update elapsed
animation_set_elapsed(complex, duration_total - 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&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_c... | (start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS) | ;
cl_assert_equal_i(prv_count_handler_entries(&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_count_handler_entries(&s_started_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0... |
ristic(void) {
prv_discover_ams(1 /* num_instances */);
// Not connected yet (still need to subscribe):
cl_assert_equal_s(music_get_connected_server_debug_name(), NULL);
// Simulate successful subscription:
BLECharacteristic entity_update = s_characteristics[0][AMSCharacteristicEntityUpdate];
ams_handle_su... | (ams_is_registered_for_all_entity_updates(), false) | ;
}
void test_ams__register_for_entity_updates_retry_if_out_of_resources(void) {
prv_discover_ams(1 /* num_instances */);
// Simulate not having enough resources to process the request:
fake_gatt_client_op_set_write_return_value(BTErrnoNotEnoughResources);
// Simulate successful subscription:
BLECharacteri... |
this->stream->controller->periph->HISR & DMA_HISR_TCIF4;
*has_ht = this->stream->controller->periph->HISR & DMA_HISR_HTIF4;
break;
case (uintptr_t)DMA1_Stream5:
case (uintptr_t)DMA2_Stream5:
*has_tc = this->stream->controller->periph->HISR & DMA_HISR_TCIF5;
*has_ht = this->stream->contr... | PBL_ASSERTN(!this->stream->state->initialized) | ;
// sanity check that the stream and controller are valid
switch ((uintptr_t)this->stream->periph) {
case (uintptr_t)DMA1_Stream0:
case (uintptr_t)DMA1_Stream1:
case (uintptr_t)DMA1_Stream2:
case (uintptr_t)DMA1_Stream3:
case (uintptr_t)DMA1_Stream4:
case (uintptr_t)DMA1_Stream5:
case (... |
s, 11);
cl_assert_equal_i(s_num_timeline_removes, 7);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// First alarm goes off. Second one should be up
s_current_hour = 10;
s_current_minute = 30;
s_current_day = s_friday;
cron_service_wakeup();
cl_assert_equal_i(s_num_al... | (s_num_alarms_fired, 1) | ;
s_current_day = s_saturday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 2);
s_current_day = s_sunday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 3);
s_current_day = s_monday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 4);
s_current_day = s_t... |
4, -576},
{ 408, 672, -576},
{ 408, 672, -576},
{ 416, 664, -576},
{ 416, 680, -568},
{ 416, 680, -568},
{ 416, 672, -568},
{ 416, 672, -560},
{ 416, 688, -552},
{ 416, 696, -552},
{ 416, 688, -544},
// 77 seconds
{ 424, 696, -544},
{ 416, 696, -544},
{ 416, 696, ... | { 416, 520, -768},
{ 376, 384, -808},
{ 352, 328, -800},
{ 392, 368, -816},
{ 384, 400, -816},
{ 392, 384, -808},
{ 400, 360, -808},
{ 392, 352, -816},
{ 392, 368, -816},
{ 392, 384, -800},
{ 392, 392, -808},
{ 392, 368, -816},
{ 384, 384, -808},
{ 392, 360, -808}... |
{ 384, 392, -800},
{ 392, 384, -800},
{ 384, 376, -800},
{ 392, 416, -792},
// 85 seconds
{ 392, 432, -792},
{ 384, 416, -800},
{ 384, 344, -800},
{ 384, 408, -792},
{ 384, 432, -800},
{ 392, 400, -800},
{ 392, 368, -800},
{ 384, 384, -808},
{ 384, 400, -800},
... |
e = (properties & ModalProperty_Transparent) ? CompositorState_AppAndModal :
CompositorState_Modal;
compositor_modal_render_ready();
// Force the app framebuffer to be released. We hold it during transitions to keep the app
// framebuffer from changi... | framebuffer_get_as_bitmap(&s_framebuffer, &s_framebuffer.size) | ;
}
GBitmap compositor_get_app_framebuffer_as_bitmap(void) {
// Get the app framebuffer state based on the size it should be to prevent a malicious app from
// changing it and causing issues.
GSize app_framebuffer_size;
app_manager_get_framebuffer_size(&app_framebuffer_size);
return framebuffer_get_as_bitmap... |
ACK:
uuid = &s_quick_launch_back.uuid;
break;
case NUM_BUTTONS:
break;
}
PBL_ASSERTN(uuid);
return app_install_get_id_for_uuid(uuid);
}
void quick_launch_set_app(ButtonId button, AppInstallId app_id) {
QuickLaunchPreference pref = (QuickLaunchPreference) {
.enabled = true,
};
app_... | (!shell_prefs_get_language_english()) | ;
}
#if CAPABILITY_HAS_HEALTH_TRACKING
static void prv_activity_pref_set(void) {
prv_pref_set(PREF_KEY_ACTIVITY_PREFERENCES, &s_activity_preferences,
sizeof(s_activity_preferences));
}
time_t activity_prefs_get_activation_time(void) {
return s_activity_activation_timestamp;
}
void activity_prefs_s... |
r_cleanup_by_connection(GAPLEConnection *connection) {
}
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
callback(data);
}
// Tests
///////////////////////////////////////////////////////////
void test_bluetooth_persistent_storage__initialize(void) {
bonding_sync_init();
fake_spi_fl... | (fake_shared_prf_storage_get_ble_store_count(), 1) | |
bpm;
time_t last_updated;
GFont bpm_font;
GFont timestamp_font;
GFont units_font;
} HealthHrSummaryCardData;
#define PULSING_HEART_TIMEOUT (30 * MS_PER_SECOND)
#define PROGRESS_BACKGROUND_COLOR (PBL_IF_COLOR_ELSE(GColorRoseVale, GColorBlack))
#define PROGRESS_OUTLINE_COLOR (PBL_IF_COLOR_ELSE(GColorClear, GCol... | (ctx, TEXT_COLOR) | ;
graphics_draw_text(ctx, buffer, data->timestamp_font,
rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
static void prv_render_hrm_disabled(GContext *ctx, Layer *base_layer) {
HealthHrSummaryCardData *data = layer_get_data(base_layer);
const int y = PBL_IF_RECT_ELSE(100, 109... |
prv_count_handler_entries(&s_stopped_handler_calls, a) | , 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);
// Just before A completes
prv_advance_to_ms_with_timers(start_ms + duration_a - 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_... | |
/*
* 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... | new_timer_delete(s_app_timer_id) | ;
s_app_timer_id = TIMER_INVALID_ID;
}
s_app_event_pending = false;
}
}
// ------------------------------------------------------------------------------------------
static void prv_timer_callback(void * context) {
PebbleTask task = (PebbleTask)context;
PebbleEvent e = {
.type = PEBBLE_CALLBA... |
//////////////////
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_rand_ptr.h"
// Fakes
///////////////////////////////////////
#include "fake_app_manager.h"
#include "fake_pebble_tasks.h"
// Structures
///////////////////////////////////////
typedef struct PACKED {... | cl_assert_equal_i(s_launcher_deprecated_messages, 1) | ;
cl_assert_equal_i(s_app_run_state_messages, 1);
// Changing the remote should change the flags and use launcher_app_message
// if app_run_state not supported
prv_set_remote_active();
app_run_state_send_update(&s_app_uuid, NOT_RUNNING);
cl_assert_equal_i(s_launcher_deprecated_messages, 2);
cl_assert_equ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (af_config->gpio) | |
_assert(app_smartstrap_attribute_get_service_id(NULL) == 0);
cl_assert(app_smartstrap_attribute_get_attribute_id(NULL) == 0);
// smartstrap_attribute_begin_write()
uint8_t *buffer;
size_t buffer_len;
assert_result_invalid(app_smartstrap_attribute_begin_write(NULL, NULL, NULL));
assert_result_invalid(app_sm... | (!s_pending_did_read.active) | ;
// destroy the attribute
app_smartstrap_attribute_destroy(attr);
}
void test_app_smartstrap__write(void) {
// create the attribute
SmartstrapAttribute *attr = app_smartstrap_attribute_create(0x1111, 0x2222, 100);
// start a write request
stub_pebble_tasks_set_current(PebbleTask_App);
uint8_t *write_b... |
able law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/cpu_c... | cl_assert_equal_i(s_flush_size, 0x08) | ;
cl_assert_equal_i(s_invalidate_addr, 0x20);
cl_assert_equal_i(s_invalidate_size, 0x08);
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Invalid);
}
void test_cpu_cache__userspace_ignore(void) {
cl_will_return(icache_is_enabled, true);
cl_will_return(dcache_is_enabled, true);
cl_will_return(icache_line... |
-----
static void steps_base_layer_update_proc(Layer *layer, GContext* ctx) {
const GRect bounds = layer_get_bounds(layer);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
// Show the battery level in the outer circle
BatteryChargeState charge_state = batt... | (HealthMetricStepCount) | ;
data->cur_steps = peek_steps + data->steps_offset;
data->lap_steps = persist_read_int(AppPersistKeyLapSteps);
if (data->lap_steps > data->cur_steps) {
// Probably left over since a midnight rollover, reset the persistent storage
data->lap_steps = data->cur_steps;
persist_write_int(AppPersistKeyLapSt... |
ting, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mag3110.h"
#include "board/board.h"
#in... | prv_enter_standby_mode() | ;
uint8_t raw_data[7];
// DR_STATUS_REG is immediately before data registers
mag3110_read(DR_STATUS_REG, sizeof(raw_data), raw_data);
// Now we can actually remove power and disable the interrupt
i2c_release(I2C_MAG3110);
exti_disable(BOARD_CONFIG_MAG.mag_int);
}
mutex_unlock(s_mag_mutex)... |
_DETECT_TWO);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_THREE);
break;
case 5:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 6:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO);
break;
case 7:
boot_bit_set(BOOT_BIT_RESET_LOOP_DE... | ("exit standby") | ;
system_hard_reset();
}
periph_config_disable(PWR, RCC_APB1Periph_PWR);
}
static void prv_print_bootloader_version(void) {
char bootloader_version_str[12];
memset(bootloader_version_str, 0, 12);
itoa_hex(boot_version_read(), bootloader_version_str, 12);
dbgserial_putstr(bootloader_version_str);
dbgs... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | analytics_metric_kind(metric) | != ANALYTICS_METRIC_KIND_UNKNOWN);
return &s_heartbeat_template[metric];
}
AnalyticsMetricElementType analytics_metric_element_type(AnalyticsMetric metric) {
return prv_get_metric_data_type(metric)->element_type;
}
uint32_t analytics_metric_num_elements(AnalyticsMetric metric) {
return prv_get_metric_data_type... |
.client = client,
.is_response_required = is_response_required,
.value = buffer,
.value_length = value_length,
};
if (s_write_head) {
list_append((ListNode *)s_write_head, &write->node);
} else {
s_write_head = write;
}
return BTErrnoOK;
}
BTErrno gatt_client_op_write(BLECharacteristic c... | (old_write) | ;
}
|
////////////////////////////////////////////////////////////////////////
//! Fakes
time_t rtc_get_time(void) {
return s_current_day + prv_hours_and_minutes_to_seconds(s_current_hour, s_current_minute);
}
void rtc_get_time_ms(time_t* out_seconds, uint16_t* out_ms) {
*out_ms = 0;
*out_seconds = rtc_get_time();
}
... | (&(AlarmInfo) { .hour = 6, .minute = 14, .kind = ALARM_KIND_WEEKDAYS }) | ;
prv_assert_alarm_config(id, 6, 14, false, ALARM_KIND_WEEKDAYS, s_weekday_schedule);
}
void test_alarm__alarm_create_just_once(void) {
AlarmId id;
// It's currently Thursday @ 00:00
bool just_once_schedule_thursday[7] = {false, false, false, false, true, false, false};
id = alarm_create(&(AlarmInfo) { .hour... |
nt32_t value_out = 0;
const bool success = prv_float_string_parse(update->value_str, value_length, 100, &value_out);
if (success) {
music_update_player_volume_percent(value_out);
} else {
prv_analytics_log_event_with_info(AMSAnalyticsEventErrorPlayerVolumeUpdate, value_length);
}
}
// -----------------... | (update, value_length) | ;
return;
case AMSPlayerAttributeIDPlaybackInfo:
prv_handle_player_playback_info_update(update, value_length);
return;
case AMSPlayerAttributeIDVolume:
prv_handle_player_volume_update(update, value_length);
return;
default:
break;
... |
c_bitmap, &rect, NULL);
}
typedef struct DivResult {
int32_t quot;
int32_t rem;
} DivResult;
//! a div and mod operation where any remainder will always be the same direction as the numerator
static DivResult polar_div(int32_t numer, int32_t denom) {
DivResult res;
res.quot = numer / denom;
res.rem = numer ... | {
// TODO: Optimize further (PBL-15657)
// If src_ic is within the bounds of the source image, do the following performance
// optimization:
// Create a clipping rectangle based on the max distance away from the pivot point
// that the destination image could be located at:
// max distance from ... |
for (int y = dest_clip.origin.y; y < dest_clip.origin.y + dest_clip.size.h; ++y) {
for (int x = dest_clip.origin.x; x < dest_clip.origin.x + dest_clip.size.w; ++x) {
// only draw if within the dest range
const GBitmapDataRowInfo dest_info = gbitmap_get_data_row_info(dest_bitmap, y);
if (!WITHI... |
/*
* 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 (end < start) {
swap16(&start, &end);
} |
graphics_private_draw_horizontal_line_prepared(ctx, framebuffer, &ctx->draw_state.clip_box, y1,
(Fixed_S16_3) {.integer = start},
(Fixed_S16_3) {.integer = end}, stroke_color);
} else if (dx == 0) {
// Vert... |
/*
* 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... | (mfg_info_get_rtc_freq(), 0xfefefefe) | ;
mfg_info_set_rtc_freq(1337);
cl_assert_equal_i(mfg_info_get_rtc_freq(), 1337);
}
void test_snowy_mfg_info__model(void) {
// Intentionally make the buffer too long so we can check for truncation.
char buffer[MFG_INFO_MODEL_STRING_LENGTH + 1] = { 0 };
mfg_info_get_model(buffer);
cl_assert_equal_s(buffer,... |
/*
* 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 (uuid_equal(uuid, &launcher_menu_app_get_app_info()->uuid)) {
return false;
} |
#endif
return true;
}
// ------------------------------------------------------------------------------------------
// Log an out-of-memory situation for an app.
void analytics_event_app_oom(AnalyticsEvent type,
uint32_t requested_size, uint32_t total_size, uint32_t total_free,
... |
/*
* 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... | update("1111", 4) | ;
assert_checksum(0x13cbc447);
}
void test_legacy_checksum__two_words(void) {
update("abcd", 4);
update("efgh", 4);
assert_checksum(0x18c4859c);
}
void test_legacy_checksum__split_word(void) {
update("123", 3);
update("4", 1);
assert_checksum(0xc2091428);
}
void test_legacy_checksum__finish_with_partia... |
may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the L... | {
prv_state_init();
} |
return SmartstrapResultOk;
#else
return SmartstrapResultNotPresent;
#endif
}
void app_smartstrap_unsubscribe(void) {
#if USE_SMARTSTRAP
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
state->handlers = (SmartstrapHandlers) {0};
if (!prv_should_subscribe()) {
prv_state_deinit();
}
... |
/*
* 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... | (IWDG_WriteAccess_Disable) | ;
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP, ENABLE);
}
void watchdog_start(void) {
IWDG_Enable();
watchdog_feed();
}
// This behaves differently from the bootloader and the firmware.
void watchdog_feed(void) {
IWDG_ReloadCounter();
}
bool watchdog_check_reset_flag(void) {
return RCC_GetFlagStatus(RCC_FLAG... |
case PhoneCallSource_ANCS_Legacy:
return IOS_PHONE_KEY;
break;
}
return NULL;
}
// Checks for the existance of a call reply action in the notif pref db and loads it into
// a timeline item
static bool prv_load_sms_reply_action(const char *number, PhoneCallSource source) {
const char *app_id = p... | kino_layer_deinit(&s_phone_ui_data->icon_layer) | ;
#if !PLATFORM_TINTIN
// The reels will destroy intermediate images, but not the one currently on screen
// clean it up here. Note that we don't have to do this on Tintin/Bianca as we
// do not create an intermediary reel for animating.
kino_reel_destroy(s_phone_ui_data->current_icon);
animation_unschedule... |
ATUS), bmi160_read_reg(BMI160_REG_ACC_CONF));
}
void bmi160_set_gyro_power_mode(BMI160GyroPowerMode mode) {
int retries = 20;
prv_run_command(BMI160_CMD_GYR_SET_PMU_MODE | mode);
while (retries--) {
uint8_t status = 0;
// can take up to 80ms to power up
status = bmi160_read_reg(BMI160_REG_PMU_STATUS)... | prv_configure_operating_mode() | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (BUTTON_ID_SELECT, prv_select_click_handler) | ;
window_set_click_context(BUTTON_ID_UP, context);
window_set_click_context(BUTTON_ID_SELECT, context);
window_set_click_context(BUTTON_ID_DOWN, context);
}
static void prv_window_load(Window *window) {
MorphSquareDemoData *data = window_get_user_data(window);
Layer *window_layer = window_get_root_layer(wind... |
mmand_arg(uint8_t arg) {
display_write_byte(arg);
}
static void prv_end_command(void) {
while (SPI_I2S_GetFlagStatus(DISP_SPI, SPI_I2S_FLAG_BSY)) continue;
GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_SET);
}
static bool prv_wait_busy(void) {
// The display should come out of busy within 35 milliseconds;
// i... | prv_screen_on() | ;
dbgserial_print("Display initialized after ");
dbgserial_print_hex(retries);
dbgserial_putstr(" retries.");
return;
}
prv_reset_fpga();
}
// It's taken too many attempts and the FPGA still isn't behaving. Give up on
// showing the splash screen and keep the screen off so that 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... | if (r == 0 || strncmp(buf, "Tuesday", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"A\": %s", buf);
} |
r = strftime(buf, buf_size, "%b", &good_data);
if (r == 0 || strncmp(buf, "May", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"b\": %s", buf);
}
r = strftime(buf, buf_size, "%B", &good_data);
if (r == 0 || strncmp(buf, "May", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with... |
al_i(s_num_requested_notif_attributes, 1);
// simulate a disconnection/reconnection
ancs_handle_service_removed(s_characteristics, NumANCSCharacteristic);
ancs_handle_service_discovered(s_characteristics);
// we should be back in the Idle state
cl_assert_equal_i(prv_get_state(), ANCSClientStateIdle);
// Mak... | prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_complete_dict), (uint8_t*) s_complete_dict) | ;
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_message_app_info_dict),
(uint8_t *)s_message_app_info_dict);
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(... |
nsed 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 in writing, software
* distributed under t... | if (dev->periph->CR1 & USART_CR1_OVER8) {
scaled_apbclock <<= 1;
} |
// calculate the baud rate value
const uint32_t div = (scaled_apbclock / baud_rate);
const uint32_t brr = (div & 0xFFF0) | ((div & 0xF) >> 1);
// we can only change the baud rate when the UART is disabled
dev->periph->CR1 &= ~USART_CR1_UE;
dev->periph->BRR = brr / DIV_PRECISION;
dev->periph->CR1 |= USA... |
.current_workout->type,
.start_utc = s_workout_data.current_workout->start_utc,
.length_min = len_min,
.ongoing = false,
.manual = true,
.step_data.steps = s_workout_data.current_workout->steps,
.step_data.distance_meters = s_workout_data.current_workout->distance_m,
... | {
*steps_out = s_workout_data.current_workout->steps;
} |
if (duration_s_out) {
*duration_s_out = s_workout_data.current_workout->duration_s;
}
if (distance_m_out) {
*distance_m_out = s_workout_data.current_workout->distance_m;
}
if (current_bpm_out) {
*current_bpm_out = s_workout_data.current_workout->current_bpm;
... |
ECONDS_PER_MINUTE * MS_PER_SECOND;
int long_walk_distance_m = activity_private_compute_distance_mm(steps, time_ms) / MM_PER_METER;
cl_assert_within(long_walk_distance_m, 48000, 52000);
// A typical cadence is roughly 165 steps per minute
const int running_cadence_spm = 165;
// Running for 25 minutes should... | cl_assert_equal_i(long_run_calories, 3172) | ;
}
// ---------------------------------------------------------------------------------------
void test_activity_calculators__inactive_calories(void) {
// People burn roughly 2000 (women) - 2400 (men) a day. This number includes active calories
// so I would expect the values we get to be less than that. I don't ... |
****************************************
Stop our timer and display results.
A frame update consists of the following operations:
op_1) App renders to its own frame buffer
op_2) System copies the app frame buffer to the system frame buffer
op_3) System sends the system frame buffer to the display hardware (u... | {
data->time_started = prv_time_64();
PROFILER_INIT;
PROFILER_START;
} |
data->rendered_frames++;
}
static void prv_window_disapper(Window *window) {
}
void prv_syncing_content_offset_changed(struct ScrollLayer *scroll_layer, void *context) {
AppData *data = app_state_get_user_data();
data->prv_orig_content_offset_changed(scroll_layer, context);
GPoint offset = scroll_layer_get_... |
.type = TimelineItemTypeReminder,
.layout = LayoutIdTest,
},
.attr_list = (AttributeList) {
.num_attributes = 1,
.attributes = (Attribute[1]) {{ .id = AttributeIdTitle, .cstring = "test 2" }}
}
};
static void prv_insert_default_reminders(void) {
// add all four explicitly out of order
cl_ass... | (&item3, &temp, sizeof(TimelineItem)) | == 0);
cl_assert(S_SUCCESS == reminder_db_delete_item(&temp.header.id, true /* send_event */));
cl_assert(reminder_db_get_len((uint8_t *)&item3.header.id, sizeof(Uuid)) == 0);
}
cl_assert(S_NO_MORE_ITEMS == reminder_db_next_item_header(&temp));
}
void test_reminder_db__size_test(void) {
prv_insert_defa... |
/*
* 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... | {
// Nothing to do
return true;
} | |
int32_t angle = DEG_TO_TRIGANGLE(45);
t = GTransformRotation(angle);
int32_t cosine = cos_lookup(angle);
int32_t sine = sin_lookup(angle);
t_c = GTransform(GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO),
GTransformNumberFromNumber(-(float)sine / TRIG_MAX_RATIO),
... | (gtransform_is_equal(&t1, &t2)) | ; // ensure t1 has not changed
gtransform_translate_number(&t_new, &t1, 10, 200);
cl_assert(gtransform_is_equal(&t_new, &t_c));
cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has not changed
// Test pointer re-use
gtransform_translate(&t1, &t1, GTransformNumberFromNumber(10), GTransformNumberFromNum... |
1,
},
{ "'%T')", -3666, true,
"-1:01:06",
1,
},
// Basic %R tests
{ "'%R')", 1, true,
"0",
2,
},
{ "'%R')", 66, true,
"1",
7,
},
{ "'%R')", 3607, true,
"1:00",
8,
},
{ "'%R')", -3666, true,
"-1:01",
7,
},
// Advanced %T tests
{ "'%0T')", 3666, true,... | ("%*s^\n", (int)err_index + 1, "") | ;
if (s_error.status >= TemplateStringErrorStatusCount) {
printf("Invalid status code\n");
} else {
printf("%s\n", s_error_strings[s_error.status]);
}
#endif
cl_assert_equal_i(s_error.status, test->expect_status);
cl_assert_equal_i(err_index, test->expect_index);
}
... |
he License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specifi... | (CURRENT_TIME_REGISTER) | ;
RtcIntervalTicks current_ticks = get_rtc_interval_ticks();
const int32_t ticks_since_last_save = elapsed_ticks(last_save_time_ticks, current_ticks);
s_time_base = last_save_time + (ticks_since_last_save / RTC_TICKS_HZ);
s_time_tick_base = -(((int64_t)current_ticks) % RTC_TICKS_HZ);
#ifdef VERBOSE_LOGGING
... |
rmissions and
* limitations under the License.
*/
#include <bluetooth/gatt.h>
#include "comm/ble/gatt_client_subscriptions.h"
#include "comm/ble/gap_le_connection.h"
#include "comm/ble/gap_le_task.h"
#include "comm/ble/gatt_service_changed.h"
#include "clar.h"
#include <btutil/bt_device.h>
#include <btutil/bt_uui... | cl_assert_equal_i(event.bluetooth.le.gatt_client.subtype,
PebbleBLEGATTClientEventTypeCharacteristicSubscribe) | ;
cl_assert_equal_i(event.bluetooth.le.gatt_client.subscription_type, subscription_type);
cl_assert_equal_i(event.bluetooth.le.gatt_client.object_ref, characteristic);
cl_assert_equal_i(event.bluetooth.le.gatt_client.gatt_error, error);
PebbleTaskBitset task_mask = ~0;
if (kernel) {
task_mask &= ~gap_le_p... |
{
mutex_unlock_recursive(s_alg_state->mutex);
}
// ----------------------------------------------------------------------------------------------
// Open the minute data settings file and malloc space for the file struct
// We use NOINLINE to reduce the stack requirements during the minute handler (see PBL-38130)
s... | if (chunk->hdr.version != ALG_MINUTE_FILE_RECORD_VERSION) {
return false;
} | |
Certification Window
///////////////////////
int16_t prv_certification_get_cell_height_callback(MenuLayer *menu_layer,
MenuIndex *cell_index,
void *context) {
return PBL_IF_RECT_ELSE(menu_cell_basic_cell_height(),
... | fonts_get_font_height(fcc_number_subtitle_font) | ;
const GTextOverflowMode text_overflow_mode = GTextOverflowModeFill;
graphics_context_set_text_color(ctx, cell_is_highlighted ? GColorWhite : GColorBlack);
// Calculate the container of the FCC cell content and center it within the cell
const int16_t title_and_icon_width = 50;
GRect container_rect = (GRect... |
/*
* 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_mobile_app_is_connected_debounced()) | |
/*
* 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 0;
} |
}
static void prv_update_item(GContext *ctx, TimelineItemLayer *item_layer) {
if (item_layer->timeline_layout) {
GRect bounds = item_layer->timeline_layout->layout_layer.layer.bounds;
bounds.origin.y = 0 - item_layer->scroll_offset_pixels;
layer_set_bounds((Layer *)item_layer->timeline_layout, &bounds);... |
ad_complete, sizeof(s_payload_complete)) == 0);
}
void test_timeline_item__string_list(void) {
StringList *list = malloc(20);
memset(list, 0, 20);
// no data
list->serialized_byte_length = 0;
cl_assert_equal_i(0, string_list_count(list));
list->serialized_byte_length = 3;
// 4 empty strings
cl_assert_... | {
// Make sure we're resilient to NULL items
cl_assert_equal_p(timeline_item_find_action_with_id(NULL, 0), NULL);
// Make sure we can handle timeline items with no actions
TimelineItem item = {};
cl_assert_equal_p(timeline_item_find_action_with_id(&item, 0), NULL);
// Make sure we actually find the items ... |
void test_timeline_item__find_action_by_type(void) {
// Make sure we're resilient to NULL items
cl_assert_equal_p(timeline_item_find_action_by_type(NULL, TimelineItemActionTypeGeneric), NULL);
// Make sure we can handle timeline items with no actions
TimelineItem item = {};
cl_assert_equal_p(timeline_item_... |
AppId_PRV = 0x04,
AS7000AppId_GSR = 0x08,
AS7000AppId_NTC = 0x10,
} AS7000AppId;
typedef enum AS7000LoaderStatus {
AS7000LoaderStatus_Ready = 0x00,
AS7000LoaderStatus_Busy1 = 0x3A,
AS7000LoaderStatus_Busy2 = 0xFF,
// all other values indicate an error
} AS7000LoaderStatus;
typedef struct PACKED AS7000FWUp... | (num_ppg_samples, MAX_PPG_SAMPLES) | |
Event *hrm_event, void *context) {
#if CAPABILITY_HAS_BUILTIN_HRM
if (!s_hrm_present) {
return;
}
ACTIVITY_LOG_DEBUG("Got HR event: %d", (int) hrm_event->event_type);
if (hrm_event->event_type == HRMEvent_BPM) {
ACTIVITY_LOG_DEBUG("HR bpm: %"PRIu8", qual: %"PRId8" ", hrm_event->bpm.bpm,
... | kernel_free(file) | |
acts as zero)
snprintf(dstbuf, 256, "%.dzero%.d", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.-3dzero%.-3d", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (non-zero digits outputting zero)
snprintf(ds... | snprintf(dstbuf, 256, "%hhi,%hi,%i,%li", hurf, hurf, hurf, hurf) | ;
cl_assert_equal_s(dstbuf, "-16,-8464,-1698898192,-1698898192");
snprintf(dstbuf, 256, "%lli,%ji", hurf, hurf);
cl_assert_equal_s(dstbuf, "1311768467463790320,1311768467463790320");
snprintf(dstbuf, 256, "%zi,%ti", hurf, hurf);
cl_assert_equal_s(dstbuf, "-1698898192,-1698898192");
}
void test_sprintf__perce... |
.stopped = prv_update_icon,
}, new_bitmap);
Animation *sequence = animation_sequence_create(disappear_animation, bounceback_animation, NULL);
data->cassette_current_icon = new_bitmap;
animation_schedule(sequence);
}
static void prv_skipping_click_config_provider(void *data);
static void prv_volume_click_c... | (is_volume_up) | ;
// Trigger haptic feedback only on repeat
if (click_number_of_clicks_counted(recognizer) >= 2) {
prv_do_haptic_feedback_vibe(context);
}
}
static void prv_ellipsis_click_handler(ClickRecognizerRef recognizer, void *context) {
MusicAppData *data = context;
data->action_bar_revert_timer = app_timer_regi... |
entRight, NULL);
content_box->size.w -= (indicator_size.w + (2 * horizontal_padding));
}
} else {
content_box->size.w -= horizontal_padding;
}
#if SCREEN_COLOR_DEPTH_BITS == 1
// Fill in the background layer. This effectively does nothing on watches where we have the
// ability to draw with colo... | GSize(label_text_container->size.w, indicator_height) | |
ngSession_ID;
// Logged items
static bool s_dls_accel_samples_created;
static int s_num_dls_accel_records;
static ActivityRawSamplesRecord s_dls_accel_records[100];
static bool s_dls_activity_sessions_created;
static int s_num_dls_activity_records;
static ActivitySessionDataLoggingRecord s_dls_activity_records[100];... | {
if (!memcmp(record, &s_dls_activity_records[i], sizeof(*record))) {
return;
}
} |
printf("\nFound records:");
for (int i = 0; i < s_num_dls_activity_records; i++) {
printf("\ntype: %d, start_utc: %"PRIu32", elapsed: %"PRIu32", utc_to_local: %"PRIu32" ",
(int)s_dls_activity_records[i].activity, (uint32_t)s_dls_activity_records[i].start_utc,
s_dls_activity_records[i].ela... |
,
{ 1056, -40, 256},
{ 888, -24, 208},
{ 704, -32, 168},
{ 576, -64, 128},
// 50 seconds
{ 560, -64, 40},
{ 688, 16, -96},
{ 896, 96, -96},
{ 1488, -168, 136},
{ 1848, -168, 376},
{ 1568, 408, 224},
{ 1280, 600, -96},
{ 1336, 400, -16},
{ 1224, 288, 296},
{ 11... | { 1096, 32, 216},
{ 944, 24, 160},
{ 848, 24, 104},
{ 768, -8, 96},
{ 664, -24, 24},
{ 584, -128, 0},
{ 752, -24, -104},
{ 992, 152, -192},
{ 1464, -144, 136},
{ 1600, 8, 304},
{ 1512, 384, 72},
// 56 seconds
{ 1496, 592, -72},
{ 1192, 496, 224},
{ 1048, 232, ... |
{ 1288, 264, 248},
{ 1088, 336, 304},
{ 984, 288, 296},
{ 936, 280, 224},
{ 856, 272, 160},
{ 816, 328, 56},
{ 832, 424, -32},
{ 856, 440, -8},
{ 1064, 408, 40},
{ 1240, 352, 120},
{ 1696, 296, 176},
{ 1632, 320, 152},
{ 1144, 296, 88},
{ 1184, 160, 160},
{ 1... |
E * 2];
memset(&bufcmp[0], i, sizeof(bufcmp));
int fd = pfs_open(file_small, OP_FLAG_READ, FILE_TYPE_STATIC, sizeof(buf));
cl_assert(fd >= 0);
cl_assert_equal_i(pfs_read(fd, &buf[0], sizeof(buf)), sizeof(buf));
cl_assert(memcmp(buf, bufcmp, sizeof(buf)) == 0);
cl_assert_equal_i(pfs_close(fd), ... | (fd, i * sizeof(buf), FSeekSet) | , i * sizeof(buf));
uint8_t read_byte;
for (int j = 0; j < 16; j++) {
cl_assert_equal_i(pfs_read(fd, &read_byte, sizeof(read_byte)), sizeof(read_byte));
cl_assert_equal_i(read_byte, 0xff - i);
}
}
pfs_close(fd);
}
void test_pfs__write(void) {
int rv = pfs_write(-1, NULL, 0);
cl_assert(... |
SettingsFile *file) {
mutex_lock_with_timeout(s_mutex, portMAX_DELAY);
status_t rv = settings_file_open(file, ALARM_FILE_NAME, ALARM_MAX_FILE_SIZE);
bool success = rv == S_SUCCESS;
if (!success) {
mutex_unlock(s_mutex);
}
return success;
}
// ----------------------------------------------------------... | (alarm_time, id, type, config->kind, uuid_out) | ;
}
// ----------------------------------------------------------------------------------------------
//! Pins alarm in the timeline for the next three days
static void prv_timeline_add_alarm(SettingsFile *file, const Alarm *alarm,
const CronJob *cron, const time_t current_time) {
... |
jerry_create_string((const jerry_char_t *)"js") | ,
.expected_output = "js",
},
{
.input = jerry_create_null(),
.expected_output = "null",
},
{
.input = jerry_create_undefined(),
.expected_output = "undefined",
},
{
.input = jerry_create_array(0),
.expected_output = "", // Kinda weird?
},
{
... | |
implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/app_watch_info.h"
#include "drivers/flash.h"
#include "flash_region/flash_region.h"
#include "system/firmware_storage.h"
#include "system/passert.h"
#include "util/attributes.h"
#inclu... | {
size_t build_id_bytes_left = elf_build_id->data_length;
const uint8_t *build_id = &elf_build_id->data[elf_build_id->name_length];
byte_stream_to_hex_string(buffer, buffer_bytes_left, build_id,
build_id_bytes_left, false);
} |
void version_copy_current_build_id_hex_string(char *buffer, size_t buffer_bytes_left) {
version_copy_build_id_hex_string(buffer, buffer_bytes_left, &TINTIN_BUILD_ID);
}
void version_get_major_minor_patch(unsigned int *major, unsigned int *minor,
char const **patch_ptr) {
*major... |
, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
#if PBL_COLOR
ASSERT_CALLED(prv_draw_rect_aa_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
#else
ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
#endif
setup_test(&context, true, SW_ODD, GColorBla... | graphics_draw_circle(&context, GPoint(50, 50), 10) | );
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, true);
ASSERT_NO_CHANGE(graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10)));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT... |
, -680},
// 2 seconds
{ 608, 480, -704},
{ 704, 456, -736},
{ 816, 416, -728},
{ 872, 520, -736},
{ 808, 304, -688},
{ 928, 352, -704},
{ 1112, 584, -680},
{ 888, 696, -584},
{ 752, 520, -480},
{ 696, 608, -456},
{ 496, 576, -304},
{ 536, 728, -320},
{ 672, 848, -... | { 1520, 528, -440},
{ 1168, 696, -704},
{ 1024, 624, -768},
{ 1288, 448, -560},
{ 1224, 272, -296},
{ 872, 320, -240},
{ 616, 352, -136},
{ 472, 336, -16},
{ 544, 440, -168},
{ 520, 448, -224},
{ 592, 472, -384},
{ 712, 528, -432},
// 8 seconds
{ 912, 536, -496},
... | |
ction *action,
void *i18n_owner) {
static const char *short_strings[] = {
"😃", "😉", "😂", "😍", "😘", "\xe2\x9d\xa4",
"😇", "😎", "😛", "😟", "😩", "😭", "😴", "😐",
"😯", "👍", "👎", "👌", "💩", "🎉", "🍺"};
const uint16_t num_items = ARRAY_L... | ("Emoji", root_level) | ,
.is_leaf = 0,
},
};
ActionMenuLevel *(*level_getters[ReplyOptionCount])
(ActionMenuLevel *, TimelineItemAction *, void *) = {
NULL,
prv_create_template_level_from_action,
prv_create_emoji_level_from_action,
};
unsigned int item = 0;
for (ReplyOption reply = 0; reply < ReplyOptio... |
}
prv_unlock();
return is_rx_buffer_full;
}
static void prv_handle_rx_buffer_has_space_available(void) {
// The slave is waiting to send more, just fire the external interrupt again:
if (s_spi_transport.should_transact_after_consuming_rx) {
s_spi_transport.should_transact_after_consuming_rx = false;
di... | {
prv_indicate_has_data_if_idle();
} |
hc_protocol_process_receive_buffer();
prv_handle_rx_buffer_has_space_available();
}
// Clean-up & kill this task
pebble_task_unregister(PebbleTask_BTRX);
// Signal host_transport_deinit() that we're done
s_spi_transport.task_is_running = false;
vTaskDelete(NULL);
}
HostTransportEnqueueStatus 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... | launcher_app_glance_structured_get_data(structured_glance) | ;
return NULL_SAFE_FIELD_ACCESS(watchfaces_glance, title, NULL);
}
static void prv_watchfaces_glance_subtitle_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *node, UNUSED const GRect *box,
UNUSED const GTextNodeDrawConfig *config, UNUSED bool render, char *buffer, size_t buffer_size,
vo... |
updated steps/sleep events.
static void prv_clear_event_queue(void) {
event_queue_cleanup_and_reset(app_manager_get_task_context()->to_process_event_queue);
}
// -------------------------------------------------------------------------------
// Run the minute callback enough times to cause everything that is norma... | (s_walk_30_steps) | |
/www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissio... | memset(bitmap, 0, prv_gbitmap_size()) | |
mple_state(data->state);
VOICE_LOG("Event received: %"PRIu8"; state:%"PRIu8, event->type, simple_state);
switch (simple_state) {
case StateWaitForReady:
if (event->type == VoiceEventTypeSessionSetup) {
prv_handle_ready_event(data, event);
}
break;
case StateWaitForResponse:
... | property_animation_set_from_int16(anim, &from) | ;
property_animation_set_to_int16(anim, &to);
animation_set_duration((Animation *) anim, duration);
animation_set_curve((Animation *) anim, AnimationCurveEaseInOut);
return anim;
}
static const PropertyAnimationImplementation s_animated_dot_impl = {
.base = {
.update = (AnimationUpdateImplementa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.