prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
, GPoint(5, 5), GPoint(45, 10), SW_ODD));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, fa... | 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, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10)... |
, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
// 150: Local time: 11:55:00 PM
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
{ 0, 0x8c, 0, 0x0},
... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME sleep_6
//> TEST_VERSION 2
//> TEST_TOTAL -1
//> TEST_TOTAL_MIN -1
//> TEST_TOTAL_MAX -1
//> TEST_DEEP -1
//> TEST_DEEP_MIN -1
//> TEST_DEEP_MAX -1
//> TEST_START_AT -1
//> TEST_START_AT_MIN -1
//> TEST_START_AT_... |
{ 70, 0x40, 5558, 0x0},
{ 77, 0x40, 6180, 0x0},
// 30: Local time: 07:22:00 PM
{ 27, 0x40, 4019, 0x0},
{ 31, 0x4f, 3790, 0x0},
{ 22, 0x41, 4540, 0x0},
{ 20, 0x42, 6276, 0x0},
{ 0, 0x32, 6765, 0x0},
{ 30, 0x41, 6216, 0x0},
{ 0, 0x76, 1622, 0x0},
{ 0, 0x46, 4395, 0x0},
{ 0... |
PBL-16475
// Brief vibration just before microphone is turned on https://pebbletechnology.atlassian.net/browse/PBL-20406
#define DICTATION_TIMEOUT (15 * 1000) // 15s timeout for each dictation
#define SPEECH_DETECTION_TIMEOUT (3 * 1000)
// Session must last at least 600ms before reporting an error to the user
#d... | sys_send_pebble_event_to_kernel(&event) | |
eck(app_stack);
cl_check(modal_stack);
cl_check(!app_stack->list_head);
cl_check(!modal_stack->list_head);
// Switch to the app state to push a window
stub_pebble_tasks_set_current(PebbleTask_App);
window_stack_push(app_stack, window1, true);
cl_assert_equal_i(window_stack_count(app_stack), 1);
cl_a... | (event.type, PEBBLE_APP_WILL_CHANGE_FOCUS_EVENT) | ;
cl_assert_equal_i(event.app_focus.in_focus, true);
cl_assert_equal_i(window_stack_count(app_stack), 1);
// Pop the modal window off the stack
window_stack_remove(window2, true);
cl_assert_equal_i(window_stack_count(modal_stack), 0);
cl_assert_equal_i(window2->on_screen, false);
// Switch to app happ... |
/*
* 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 (!size) {
return NULL;
}
#if defined(MALLOC_INSTRUMENTATION)
void *result = task_malloc_with_pc(size, client_pc);
#else
void *result = task_malloc(size);
#endif
if (!result && mcu_state_is_thread_privileged()) {
// We want to trip an assert if our malloc failed and we're not running a 3rd party... |
static void* prv_zalloc(size_t size, uintptr_t client_pc) {
void *result = prv_malloc(size, client_pc);
if (result) {
memset(result, 0, size);
}
return result;
}
void* applib_malloc(size_t size) {
#if defined(MALLOC_INSTRUMENTATION)
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
retu... |
process_metadata_get_run_level(app_md) | );
app_install_release_md(app_md);
return false;
}
s_next_app = (NextApp) {
.md = app_md,
.common = config->common,
};
s_next_app.common.transition = prv_get_transition(&config->common, new_app_id);
if ((config->common.reason == APP_LAUNCH_WAKEUP) && (config->common.args != NULL)) {
Wak... | |
ecific language governing permissions and
* limitations under the License.
*/
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "kernel/pebble_tasks.h"
#include "mcu/interrupts.h"
#include "services/normal/accessory/smartstrap_profiles.h"
#include "services/normal/accessory/smartstrap_state.h"
#incl... | for (uint32_t i = 0; i < s_num_connected_services; i++) {
if (s_connected_services[i] == service_id) {
return i;
}
} |
return -1;
}
//! NOTE: the caller must hold s_services_lock
static bool prv_remove_connected_service(uint16_t service_id) {
mutex_assert_held_by_curr_task(s_services_lock, true);
int index = prv_find_connected_service(service_id);
if (index == -1) {
return false;
}
PBL_ASSERTN(s_num_connected_services... |
ken) + 1, "%d", &state->test_entry.in_sleep.max);
} else if (strcmp(token, "TEST_IN_DEEP_SLEEP") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_deep_sleep.value);
} else if (strcmp(token, "TEST_IN_DEEP_SLEEP_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &stat... | sscanf(token + strlen(token) + 1, "%d", &state->test_entry.version) | ;
} else if (strcmp(token, "TEST_ACTIVITY_TYPE") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.activity_type.value);
} else if (strcmp(token, "TEST_ACTIVITY_TYPE_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.activity_type.min);
} else if... |
ader, not including this header. If this value
//! is 0xff that means no log message follows. If this value is 0x0 this means there are no
//! more logs remaining in this chunk.
uint8_t log_length;
} LogHeader;
//! Which chunk we're writing to. [0 - NUM_CHUNKS)
static int s_current_chunk;
//! The id we're using ... | {
break;
} | |
animation_create();
animation_set_curve(animation, AnimationCurveEaseIn);
animation_set_duration(animation, BUMP_TEXT_DURATION_MS);
AnimationHandlers anim_handler = {
.stopped = prv_bump_text_stopped,
};
animation_set_handlers(animation, anim_handler, selection_layer);
selection_layer->bump_text_impl =... | {
Animation *animation = animation_create();
animation_set_curve(animation, AnimationCurveEaseIn);
animation_set_duration(animation, SLIDE_DURATION_MS);
AnimationHandlers anim_handler = {
.stopped = prv_slide_stopped,
};
animation_set_handlers(animation, anim_handler, selection_layer);
selection_laye... | |
OR, container);
active_window->workout_controller->metric_to_string(metric_type,
(char *) number_text_node->text,
buffer_size, i18n_owner,
a... | (i18n_noop("MI"),
i18n_noop("KM")) | ;
GTextNodeText *units_text_node = health_util_create_text_node_with_text(
i18n_get(units_string, i18n_owner), units_font, TEXT_COLOR, container);
units_text_node->node.offset.y = units_offset_y;
#endif
}
break;
}
case WorkoutMetricType_Speed:
{
const size_t buf... |
if the fd has already been located
for (int fd = FD_INDEX_OFFSET; fd < FD_INDEX_OFFSET+MAX_FD_HANDLES; fd++) {
File *f = &PFS_FD(fd).file;
if ((f->is_tmp == is_tmp) && (f->name != NULL)) {
if (strcmp(f->name, name) == 0) {
PBL_ASSERTN(PFS_FD(fd).fd_status != FD_STATUS_FREE);
*fdp = fd;
... | if ((file->offset + size) > file->file_size) {
res = E_RANGE;
goto cleanup;
} |
uint32_t pg_offset;
if (scan_to_offset(file, &pg_offset) != S_SUCCESS) {
res = E_INTERNAL;
goto cleanup;
}
size_t bytes_written = 0;
while (bytes_written < size) {
size_t bytes_to_write = MIN(free_bytes_in_page(file->curr_page) - pg_offset,
size - bytes_written);
prv_flash_write(bu... |
.to_minute = 0,
};
do_not_disturb_set_schedule(WeekdaySchedule, &weekday_schedule_2);
do_not_disturb_set_schedule(WeekendSchedule, &weekend_schedule_2);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
do_not_disturb_set_schedule_enabled(WeekendSchedule, true);
rtc_set_time(s_friday_23_30); /... | do_not_disturb_is_active() | ;
cl_assert(active == false);
// Reset override and enable Smart DND
do_not_disturb_toggle_smart_dnd();
do_not_disturb_toggle_smart_dnd();
s_event_ongoing = true;
active = do_not_disturb_is_active();
cl_assert(active == true);
// Does not necessarily toggle Manual DND, sets Manual DND to opposite of D... |
/*
* 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 ((__get_PRIMASK() & 0x1) == 0) {
__disable_irq();
s_interrupts_disabled_by_heap = true;
} |
}
static void prv_heap_unlock(void *ctx) {
if (s_interrupts_disabled_by_heap) {
__enable_irq();
s_interrupts_disabled_by_heap = false;
}
}
void kernel_heap_init(void) {
const bool fuzz_on_free = true;
extern uint8_t __heap_start;
uint8_t *heap_start = &__heap_start;
uint8_t *heap_end = heap_star... |
ol s_session_is_system;
bool comm_session_is_system(CommSession *session) {
return s_session_is_system;
}
static bool s_session_is_valid;
bool comm_session_is_valid(const CommSession *session) {
return (session == &s_session) && s_session_is_valid;
}
static bool s_data_sent;
bool comm_session_send_data(CommSessio... | (s_capability_flags, s_expected_capabilities) | ;
}
void test_session_remote_version__app_session(void) {
s_session_is_system = false;
prv_receive_v3_response(3, 2, 1, s_expected_capabilities);
// Triggers no event:
cl_assert_equal_i(fake_event_get_count(), 0);
cl_assert_equal_i(s_capability_flags, s_expected_capabilities);
}
|
fset = PBL_IF_RECT_ELSE(49, 67);
icon_y_offset = 38;
text_y_offset = 90;
#endif
}
if (first_use_is_complete) {
#if PBL_BW && !PLATFORM_TINTIN
// Override the icon to use the fullscreen version
icon_res_id = RESOURCE_ID_RECOVERY_LAUNCH_APP;
icon_x_offset = 0;
icon_y_offset = 0;
url_stri... | (app_state_get_graphics_context(),
&data->name_text_layer) | ;
content_size.w += 4;
content_size.h += 4;
}
// Actually set the frame centered on the screen and just below the url_text_layer.
const int16_t window_width = data->launch_app_window.layer.frame.size.w;
const int16_t text_x_offset = (window_width - content_size.w) / 2;
#if PLATFORM_ROBERT || PLATFORM_C... |
BL_RECT
status_bar_layer_set_separator_mode(data->status_layer, StatusBarLayerSeparatorModeDotted);
#endif
layer_add_child(background, status_bar_layer_get_layer(data->status_layer));
// labels
const char * const font_key_label = FONT_KEY_GOTHIC_09;
// back, mid, front numbers
const char * const font_key_s... | layer_add_child(background, text_layer_get_layer(text[TextPar])) | ;
// Back value.
text[TextBack] = text_layer_create(GRect(distance_column_x_offset, back_value_y_offset,
distance_column_width, small_numbers_height));
prv_setup_text_layer(text[TextBack], font_key_small_numbers, NULL, distance_text_alignment);
layer_add_child(backgro... |
////////////////////////////////////////////////////
static void prv_enable_shake_detection(void) {
bma255_write_register(BMA255Register_INT_EN_0, BMA255_INT_EN_0_SLOPE_X_EN |
BMA255_INT_EN_0_SLOPE_Y_EN |
BMA255_INT_EN_... | psleep(50) | ;
uint8_t new_negative;
int16_t negative = prv_read_axis(axis, &new_negative);
negative = prv_raw_to_mgs(negative);
prv_soft_reset();
int delta = positive - negative;
delta = abs(delta);
PBL_LOG(LOG_LEVEL_DEBUG,
"Self test axis %c: %d Pos: %d Neg: %d Delta: %d (required %d)",
AXIS_N... |
/*
* 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_handle_action(StationaryActionEnableStationary);
} | |
r->config.long_click.handler != NULL || recognizer->config.long_click.release_handler != NULL);
}
static void prv_auto_repeat_single_click(ClickRecognizer *recognizer) {
if (!recognizer->is_button_down) {
// If this button isn't being held down anymore, don't re-register the timer.
return;
}
++(recognize... | {
int clicks_over = recognizer->number_of_clicks_counted;
for(int i = 0; i < clicks_over; i++) {
prv_dispatch_event(recognizer, ClickHandlerOffsetSingle, false);
}
} |
prv_click_reset(recognizer);
}
static void prv_multi_click_timeout_callback(void *data) {
ClickRecognizer *recognizer = (ClickRecognizer *) data;
recognizer->multi_click_timer = NULL;
if (recognizer->config.multi_click.last_click_only &&
(recognizer->number_of_clicks_counted >= prv_multi_click_get_min(... |
uint8_t curr_fifo_num_samples_wm = 0;
static bool s_double_tap_detection_enabled = false;
static bool s_shake_detection_enabled = false;
// Accelerometer configuration criteria
// Each operating mode can be enabled and disabled independently from each other and the driver
// will configure the accelerometer in the hi... | {
int16_t readings[3];
for (unsigned int i = 0; i < ARRAY_LENGTH(readings); i++) {
int base = i * 2;
readings[i] = raw_buf[base] | (raw_buf[base + 1] << 8);
}
const AccelConfig *cfg = &BOARD_CONFIG_ACCEL.accel_config;
data->x = (cfg->axes_inverts[AXIS_X] ? -1 : 1) *
prv_raw_to_mgs(readings[cfg... |
static uint64_t prv_get_curr_system_time_ms(void) {
time_t time_s;
uint16_t time_ms;
rtc_get_time_ms(&time_s, &time_ms);
return (((uint64_t)time_s) * 1000 + time_ms);
}
static uint32_t prv_sensortime_to_timestamp(uint8_t sensor_time[3]) {
return (sensor_time[0] | (sensor_time[1] << 8) | (sensor_time[2] << ... |
/*
* 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_raw_drawing_function_counters[GDrawRawFunctionTypeAssignVerticalLine]++;
} |
static void prv_fake_raw_blend_horizontal_line(GContext *ctx, int16_t y, int16_t x1,
int16_t x2, GColor color) {
s_raw_drawing_function_counters[GDrawRawFunctionTypeBlendHorizontalLine]++;
}
static void prv_fake_raw_blend_vertical_line(GContext *ctx, int16_t x, int16_... |
begin(
PULSE_PROTOCOL_FLASH_IMAGING);
*ack = (EraseAndWriteAck) {
.opcode = IMAGING_RESP_ACK_WRITE,
.address = cmd->write.address,
.length = write_length,
.complete = 1
};
pulse_best_effort_send(ack, sizeof(EraseAndWriteAck));
// Since packets arrive so rapidly when writing, flash imaging... | pulse_best_effort_send(resp, response_length) | ;
}
|
menu_layer_update_proc(Layer *scroll_content_layer, GContext* ctx) {
MenuLayer *menu_layer = (MenuLayer*)(((uint8_t*)scroll_content_layer) -
offsetof(MenuLayer, scroll_layer.content_sublayer));
const GSize frame_size = menu_layer->scroll_layer.layer.frame.size;
const int16_t content_top_y = -scroll_layer_ge... | (inverter_layer_get_layer(&menu_layer->inverter), true) | ;
#if PBL_ROUND
prv_set_center_focused(menu_layer, true);
#endif
}
MenuLayer* menu_layer_create(GRect frame) {
MenuLayer *layer = applib_type_malloc(MenuLayer);
if (layer) {
menu_layer_init(layer, &frame);
}
return layer;
}
void menu_layer_pad_bottom_enable(MenuLayer *menu_layer, bool enable) {
menu_... |
system registry first, if found return the ID.
AppInstallId id = app_get_install_id_for_uuid_from_registry(uuid);
if (id != INSTALL_ID_INVALID) {
return id;
}
// registry miss, now lets search in the app_db
id = app_db_get_install_id_for_uuid(uuid);
if (id != INSTALL_ID_INVALID) {
return id;
}
... | (app_install_id_from_app_db(cur_worker_id)))) {
PBL_LOG(LOG_LEVEL_DEBUG, "close and delay callbacks for worker closing");
s_install_callback_data.callback_paused_for_worker = true;
s_pending_worker_deletion = cur_worker_id;
worker_manager_handle_remove_current_worker();
... |
PBL_LOG(LOG_LEVEL_DEBUG, "app_install_invoke_callbacks");
app_install_invoke_callbacks(s_install_callback_data.install_type,
s_install_callback_data.install_id);
bool app_upgrade = false;
switch (s_install_callback_data.install_type) {
case APP_UPGRADED:
app_upgrade ... |
52},
{ 1312, 280, -144},
// 38 seconds
{ 1328, 216, -32},
{ 1576, 272, -72},
{ 1480, 384, -136},
{ 1032, 336, -120},
{ 1080, 240, -64},
{ 1152, 200, -48},
{ 1200, 128, -8},
{ 1056, 200, 48},
{ 936, 232, 80},
{ 888, 208, 104},
{ 856, 192, 104},
{ 848, 184, 112},
... | { 1008, 136, -232},
{ 1104, 80, -136},
{ 1256, 152, -104},
{ 1064, 256, -64},
{ 880, 320, -64},
{ 872, 400, -88},
{ 976, 360, -128},
{ 1024, 264, -128},
// 44 seconds
{ 992, 248, -136},
{ 1040, 240, -128},
{ 1200, 264, -152},
{ 1248, 280, -112},
{ 1600, 192, 32},
... |
{ 960, 232, -176},
{ 992, 216, -200},
{ 1072, 232, -208},
{ 1240, 272, -272},
{ 1320, 224, -256},
{ 1528, 160, -144},
{ 1568, 216, -160},
{ 1320, 320, -128},
{ 1072, 272, -56},
{ 1152, 216, -64},
{ 1232, 192, -32},
{ 1120, 160, 32},
{ 960, 192, 72},
{ 896, 192, 7... |
num_dropped_messages) {}
void test_message_handler(const uint8_t *data, size_t length,
AppInboxConsumerInfo *consumer_info) {}
void test_alt_message_handler(const uint8_t *data, size_t length,
AppInboxConsumerInfo *consumer_info) {}
void test_alt_dropped_handler(u... | app_message_receiver_open(sizeof(AppMessagePush)) | );
Receiver *r = s_rcv_imp->prepare(s_session, &s_app_message_endpoint,
sizeof(AppMessagePush));
cl_assert(r != NULL);
s_rcv_imp->write(r, (const uint8_t *)&s_push, sizeof(s_push));
return r;
}
static void prv_destroy_inbox(void) {
app_message_receiver_close();
}
void tes... |
temActionTypeAncsResponse) {
return false;
}
return ancs_notifications_util_is_group_sms(app_id, subtitle);
}
static void prv_populate_actions(TimelineItem *item,
uint8_t **buffer,
uint8_t *buf_end,
const ANCSAt... | prv_max_ellipsified_cstring_size(display_name) | ;
required_space_for_strings += prv_max_ellipsified_cstring_size(subtitle);
if (has_multimedia) {
required_space_for_strings += MULTIMEDIA_INDICATOR_LENGTH;
}
required_space_for_strings += prv_max_ellipsified_cstring_size(message);
required_space_for_strings += prv_max_ellipsified_cstring_size(positive_ac... |
0 1 2 3
// +-+-+-+-+
// |*| Len | Where * is the encoded symbol [0,1] and 'Len + 1' is the number of symbols
// +-+-+-+-+ in the run [1,8]. For example, 1000 expands to '1' and 0100 expands to '00000'
//
// RLE Units are packed as pairs -- two to a byte.
//
// Decoding is done by expanding t... | (text_render_flash) | ;
size_t num_bytes_loaded = sys_resource_load_range(font_res->app_num, font_res->resource_id,
bitmap_addr, target, glyph_size_bytes);
SYS_PROFILER_NODE_STOP(text_render_flash);
if (glyph_size_bytes && !num_bytes_loaded) {
PBL_LOG(LOG_LEVEL_WARNING,... |
ue;
}
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!prv_is_mutable(state, animation)) {
return false;
}
animation->implementation = implementation;
return true;
}
// ------------------------------------------------------------------------------... | (state, animation_h, false /*quiet*/) | ;
if (!prv_is_mutable(state, animation)
|| animation->type != AnimationTypePrimitive) {
return false;
}
animation->duration_ms = duration_ms;
return true;
}
// -------------------------------------------------------------------------------------------
uint32_t animation_get_duration(Animation *anim... |
rrent_entry = (LauncherAppGlanceCacheEntry *)current_node;
Uuid *uuid_to_find = context;
return (current_entry && uuid_equal(¤t_entry->glance->uuid, uuid_to_find));
}
static LauncherAppGlance *prv_load_glance_for_node(const AppMenuNode *node,
LauncherAppGlan... | (&cache_entry->node, &service->glance_cache, NULL) | ;
service->glance_cache = list_insert_before(service->glance_cache, &cache_entry->node);
glance = cache_entry->glance;
}
// Try to load the glance requested if we didn't find it in the cache
if (!glance) {
glance = prv_load_glance_for_node(node, service);
if (!glance) {
// Just bail out and... |
{ 872, 112, -440},
{ 1000, 8, -336},
{ 952, 88, -288},
{ 816, 104, -296},
// 71 seconds
{ 800, 200, -240},
{ 968, 328, -336},
{ 1248, 432, -360},
{ 1312, 656, -464},
{ 1192, 704, -440},
{ 936, 680, -456},
{ 888, 720, -480},
{ 936, 576, -280},
{ 1056, 576, -264},
{... | { 1168, 80, -192},
{ 1144, 96, -208},
{ 1128, 80, -200},
{ 880, 40, -256},
{ 1008, 128, -216},
{ 552, 0, -400},
{ 928, 176, -472},
{ 976, 112, -376},
{ 800, 80, -352},
{ 744, 176, -280},
{ 904, 272, -304},
{ 1184, 440, -368},
{ 1280, 544, -392},
{ 1072, 664, -368}... |
// 79 seconds
{ 1184, 376, -272},
{ 1120, 280, -240},
{ 944, 176, -224},
{ 936, 96, -216},
{ 1064, 144, -184},
{ 1240, 88, -144},
{ 1256, 112, -144},
{ 1256, 104, -168},
{ 856, -96, -152},
{ 1088, -48, -96},
{ 648, -128, -240},
{ 984, 120, -416},
{ 1216, 40, -264... |
2
15, // Minutes in zone 3
};
// Tests
////////////////////////////////////////////////////////////////
void test_health_db__blob_db_api(void) {
const char *key = "monday_sleepData";
// insert one
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
... | (ActivityMetricHeartRateZone1Minutes, Monday, &val_out) | |
mfg_info_set_model("test_model") | ;
mfg_info_get_model(buffer);
cl_assert_equal_s(buffer, "test_model");
{
char long_string[] = "01234567890123456789";
mfg_info_set_model(long_string);
// We only expect to see the first 15 (MFG_INFO_MODEL_STRING_LENGTH - 1) characters
mfg_info_get_model(buffer);
cl_assert_equal_s(bu... | |
ScaleMode mode = GOvalScaleModeFillCircle;
// Basic container rect with GPointZero origin
const GRect container_rect1 = GRect(0, 0, 10, 10);
const GRect resulting_rect1 = grect_centered_from_polar(container_rect1, mode, 0, GSize(3, 5));
cl_assert_equal_grect(resulting_rect1, GRect(3, -2, 3, 5));
// Containe... | cl_assert_fixedS16_3(radius, 1) | ;
grect_polar_calc_values(NULL, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 1, 2);
cl_assert_fixedS16_3(radius, 1);
}
void test_graphics_circle__grect_polar_calc_values_edge_cases(void) {
GPointPrecise center = {};
Fixed_S16_3 radius = {};
const GOvalScaleMode mode = GOvalScaleModeFillCircle... |
MAX);
// B should be in the middle
int32_t update_b_after = prv_last_update_distance(b);
cl_assert(abs(update_b_after - ANIMATION_NORMALIZED_MAX/2) < 5000);
// C should be at the end
int32_t update_c_after = prv_last_update_distance(c);
cl_assert_equal_i(update_c_after, ANIMATION_NORMALIZED_MAX);
// -... | (&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), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, c),... |
(hrm_is_available) {
WorkoutMetricType scrollable_metrics[] = {WorkoutMetricType_Duration};
return workout_active_create_double_layout(WorkoutMetricType_Hr,
ARRAY_LENGTH(scrollable_metrics),
scrollable... | (active_window) | ;
if (active_window->current_scrollable_metric >= active_window->num_scrollable_metrics) {
active_window->current_scrollable_metric = 0;
}
prv_update_ui(active_window);
}
|
ystem/app_file.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/hexdump.h"
#include "util/build_id.h"
// 64k. Note that both tintin and snowy apps have a maximum size of 64k enforced by the SDK, even
// though there isn't enough memory for load more than 24k in practice on tintin.
static con... | strlen(APP_FILE_NAME_SUFFIX) |
: strlen(WORKER_FILE_NAME_SUFFIX);
app_file_name_make(name, buf_length, app_id, task_str, task_str_len);
}
|
ug/power_tracking.h"
#include "drivers/display/ice40lp/ice40lp_definitions.h"
#include "drivers/periph_config.h"
#include "drivers/gpio.h"
#include "drivers/spi.h"
#include "drivers/exti.h"
#include "drivers/pmic.h"
#include "system/logging.h"
#include "system/passert.h"
#include "kernel/util/delay.h"
#include "util/si... | if (!gpio_input_read(&ICE40LP->cdone)) {
PBL_LOG(LOG_LEVEL_ERROR, "CDONE not high after programming");
return false;
} |
#endif
return true;
}
void display_program(const uint8_t *fpga_bitstream, uint32_t bitstream_size) {
periph_config_acquire_lock();
int attempt = 1;
while (1) {
if (prv_try_program(fpga_bitstream, bitstream_size)) {
break;
}
if (attempt++ >= 3) {
PBL_CROAK("Too many failed FPGA program... |
/*
* 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_run_next_job(connection) | ;
}
}
bt_unlock();
}
// assumes bt lock is held
static BTErrno prv_run_next_job(GAPLEConnection *connection) {
DiscoveryJobQueue *node = connection->discovery_jobs;
if (!node) {
return BTErrnoOK; // no more jobs to run
}
// Note, that the job only gets removed from the list after discovery
// ha... |
d_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);
// Complete sequence
prv_advance_to_ms_with_timers(start_ms + duration_a + duration_b + 5 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert... | cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, c), 1)... |
const GPoint *center, const GFont font,
const GColor color, const char *text) {
GSize text_size = app_graphics_text_layout_get_content_size(
text, font, (GRect) { .size = *max_size }, GTextOverflowModeFill, GTextAlignmentCenter);
GPoint text_center = *... | graphics_fill_oval(ctx, bob_center_rect, GOvalScaleModeFitCircle) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | fake_kernel_malloc_init() | |
message = i18n_get("Incompatible JS", data);
break;
case AppFetchResultGeneralFailure:
case AppFetchResultUUIDInvalid:
case AppFetchResultPutBytesFailure:
case AppFetchResultTimeoutError:
case AppFetchResultPhoneBusy:
default:
icon = TIMELINE_RESOURCE_GENERIC_WARNING;
message =... | window_single_click_subscribe(BUTTON_ID_BACK, (ClickHandler) prv_click_handler) | ;
}
static void handle_init(void) {
AppFetchUIData* data = app_zalloc_check(sizeof(AppFetchUIData));
app_state_set_user_data(data);
// get app args, copy them to app memory, and free the kernel buffer
AppFetchUIArgs *temp_fetch_args =
(AppFetchUIArgs *)process_manager_get_current_process_args();
memcp... |
ALARM_SNOOZE_DELAY_S / SECONDS_PER_MINUTE)
void test_alarm_smart__trigger_30_min_early_awake(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY, .is_smart = true });
prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
cl... | (s_num_timeline_adds, 6) | |
etting to zero is ignored
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_stroke_width(&context, 0);
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
// Check draw state
memset(&draw_state, 0x5A, sizeof(GDrawState));
graphics_context_set_drawing_... | (prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_EVEN)) | |
/*
* 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_get_state_bits() | == 0) {
// All the buttons are released!
break;
}
}
}
}
static void prv_clear_wakeup_flags(void) {
// This function follows the steps listed in Erratum 2.1.4 "Wakeup sequence from Standby mode..."
// to avoid a situation where the watch cannot wake up
// or immediately wakes up after... |
IC power rails.
// The backup domain is not reset; that would be foolish.
const uint32_t ahb1_periphs =
RCC_AHB1Periph_CRC | RCC_AHB1Periph_DMA1 | RCC_AHB1Periph_DMA2
| RCC_AHB1Periph_DMA2D | RCC_AHB1Periph_ETHMAC | RCC_AHB1Periph_OTGHS;
const uint32_t ahb2_periphs =
RCC_AHB2Periph_DCMI | RCC_AHB2Peri... | (BOOT_BIT_RESET_LOOP_DETECT_ONE) | ;
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO);
break;
case 3:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 4:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_TWO);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_THREE);
break;
case 5:... |
break;
}
case WorkoutMetricType_Speed:
case WorkoutMetricType_Pace:
{
strncpy(buffer, data->pace_string, MIN(buffer_size, sizeof(data->pace_string)));
break;
}
case WorkoutMetricType_Distance:
{
strncpy(buffer, data->distance_string, MIN(buffer_size, sizeof(data->dist... | app_state_get_user_data() | ;
health_service_set_heart_rate_sample_period(0 /* interval_s */);
app_sync_deinit(&data->sync);
app_free(data);
activity_algorithm_enable_activity_tracking(true /* enable */);
}
////////////////////
// App boilerplate
static void prv_main(void) {
prv_init();
app_event_loop();
prv_deinit();
}
const Pe... |
now - 2 * SECONDS_PER_HOUR;
const time_t time_end = now;
// ----------------------------------------------------------------
// Put in our minute history
HealthServiceCache *cache = NULL;
unsigned num_minutes_per_call = ARRAY_LENGTH(cache->minute_data);
s_sys_activity_get_minute_history_values = (sys_activ... | (s_metric_alert_count, 1) | |
_names;
}
static char *prv_get_timezone_title(void) {
/// Title of the menu for changing the watch's timezone.
return i18n_noop("Timezone");
}
// Timezone Region Menu
/////////////////////////
static void prv_region_menu_select(OptionMenu *option_menu, int selection, void *context) {
SettingsTimeData *data = (... | menu_cell_basic_draw(ctx, cell_layer, i18n_get(title, data), i18n_get(subtitle, data), NULL) | ;
}
static void prv_selection_will_change_cb(SettingsCallbacks *context, uint16_t *new_row,
uint16_t old_row) {
if (!clock_timezone_source_is_manual() && *new_row == TimeRow_Timezone) {
*new_row = old_row;
}
}
static uint16_t prv_num_rows_cb(SettingsCallbacks *context)... |
t_data(void) {
if (!s_sent_data) {
return;
}
if (!s_is_connected) {
return;
}
if (!s_is_app_message_receiver_open) {
return;
}
cl_assert(s_remote_receive_handler);
s_remote_receive_handler(s_sent_endpoint_id, s_sent_data, s_sent_data_length);
kernel_free(s_sent_data);
s_sent_data = NULL;... | app_message_is_accepting_outbound() | , true);
}
void test_app_message__send_happy_case_ack_then_outbox_sent(void) {
prv_set_remote_receive_handler(prv_ack_sent_callback);
prv_send_test_data();
prv_process_sent_data();
// With certain PP transports (i.e. PPoGATT), the 'consuming' of the outbound data / outbox sent
// callback can fire after the... |
/////////////////////////////////////////////////////////////////////////////////
#include "stubs_analytics.h"
#include "stubs_bt_lock.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
static int s_app_install_timestamp_update_count;
void app_install_mark_prioritized(AppInstallId ... | cl_assert(session) | |
{ 136, -200, -960},
{ 128, -200, -968},
{ 128, -208, -968},
{ 128, -200, -968},
{ 136, -208, -968},
{ 128, -200, -976},
{ 136, -200, -960},
{ 128, -200, -968},
// 94 seconds
{ 128, -208, -968},
{ 128, -200, -968},
{ 136, -216, -968},
{ 128, -208, -960},
{ 128, -200, ... | { 120, -248, -960},
{ 128, -256, -960},
{ 120, -240, -968},
{ 128, -256, -960},
{ 120, -248, -968},
{ 128, -248, -960},
{ 128, -240, -968},
{ 112, -264, -960},
{ 128, -248, -968},
{ 136, -232, -968},
{ 120, -256, -960},
{ 120, -256, -960},
{ 120, -248, -968},
{ 12... | |
y(menu_layer_id, menu_layer_size /* size */);
cl_assert_equal_i(2, menu_layer_id);
// load second app
app_storage_get_file_name(filename_buf, sizeof(filename_buf), 2,
PebbleTask_App);
load_fixture_on_pfs(APP2_APP_FIXTURE_NAME, filename_buf);
resource_storage_get_file_name(filename... | (uuid, UUID_INVALID) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// ctx->draw_state.drawing_box is the correct rect when this function gets
// called through layer_render_tree(),
GRect rect = ctx->draw_state.drawing_box;
// invert bytes in rect
grect_clip(&rect, &ctx->dest_bitmap.bounds); // clip to display bounds
for (int16_t y = rect.origin.y; y < rect.origin.y + re... | |
user selects a menu icon with a menu item select callback
static void menu_select_callback(int index, void *ctx) {
PBL_LOG(LOG_LEVEL_DEBUG, "Selected menu item %d", index);
// Here we just change the subtitle to a literal string
s_app_data->menu_items[index].subtitle = "You've hit select here!";
// Mark ... | // Trigger it. This transfers control to our ISR handler OTG_FS_WKUP_IRQHandler
NVIC_SetPendingIRQ(OTG_FS_WKUP_IRQn);
} else if (index == 10) {
PBL_LOG(LOG_LEVEL_INFO, "Causing bus fault in app");
typedef void (*KaboomCallback)(void);
KaboomCallback kaboom = 0;
kaboom();
} else if (index ... |
}
// =================================================================================
static void prv_window_load(Window *window) {
TestTimersAppData *data = s_app_data;
int i = 0;
data->menu_items[i++] = (SimpleMenuItem) {
.title = "croak",
.callback = menu_select_callback,
};
data->menu_... |
--------->|
* Integrate over this range for the mean
*/
//! The current state of the backlight (example: ON/ON_TIMED/ON_FADING).
static BacklightState s_light_state;
//! The brightness of the display in a range between BACKLIGHT_BRIGHTNESS_OFF and BACKLIGHT_BRIGHTNESS_ON
static int32_t s_cu... | if (!s_backlight_allowed) {
return false;
} | |
leep Time
3333, // Wakeup Time
4444, // Active Time
5555, // Typical sleep duration
6666, // Typical deep sleep duration
7777, // Typical fall asleep time
8888, // Typical wakeup time
};
static uint32_t s_old_sleep_data[] = {
1, // Version
NOW... | cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
(uint8_t *)s_sleep_data, sizeof(s_sleep_data)),
S_SUCCESS) | ;
cl_assert_equal_i(s_metric_updated_count, NUM_CURRENT_SLEEP_METRICS);
// check typicals
int32_t val_out;
cl_assert(health_db_get_typical_value(ActivityMetricSleepTotalSeconds, Monday, &val_out));
cl_assert_equal_i(val_out, s_sleep_data[SD_TypicalSleepDuration]);
cl_assert(health_db_get_typical_value(A... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (window, true) | ;
// App Logging!
APP_LOG(APP_LOG_LEVEL_DEBUG, "Just pushed a window!");
// Subscribe Accelerometer and Register Timer
accel_data_service_subscribe(0, NULL);
s_timer = app_timer_register(TIMEOUT_MS, prv_timer_cb, NULL);
}
void handle_deinit(void) {
// Destroy Timer and Unsubscribe Accelerometer
app_tim... |
is now the late wakeup id.
cl_assert_equal_i(late_wakeup_id, wakeup_get_next_scheduled());
// Set time 10 minutes into the future, late_event should fire
rtc_set_time(late_event);
// Force wakeup to check for current wakeup event.
wakeup_enable(false);
wakeup_enable(true);
// Simulate the firing of the... | (first_timer) | |
OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "apps/system_apps/health/health_sleep_detail_card.h"
#include "apps/system_apps/health/health_detail_card.h"
#include "apps/system_apps/health/hea... | (&card->menu_layer, MenuIndex(0, 1), MenuRowAlignCenter, false) | |
{ -1010, 487, -6},
{ -955, 411, -24},
{ -876, 370, -22},
{ -754, 353, -35},
{ -765, 314, -23},
{ -834, 358, -9},
{ -961, 447, 43},
{ -936, 390, 70},
{ -820, 353, 70},
{ -773, 294, 61},
{ -798, 336, 69},
{ -792, 324, 65},
{ -751, 308, 61},
{ -749, 307, 73},
{ -... | { -825, 370, -47},
{ -920, 418, -41},
{ -923, 462, 30},
{ -1157, 500, 56},
{ -972, 466, 30},
{ -941, 473, 34},
{ -953, 447, 60},
{ -917, 399, 63},
{ -888, 373, 67},
{ -956, 378, 82},
{ -971, 383, 94},
{ -940, 372, 89},
{ -840, 299, 110},
{ -798, 283, 121},
{ -... |
{ -799, 341, -115},
{ -810, 324, -105},
{ -772, 272, -102},
{ -728, 269, -108},
{ -725, 315, -138},
{ -758, 312, -137},
{ -839, 397, -138},
{ -953, 368, -63},
{ -1177, 411, -14},
{ -1275, 561, -41},
{ -1027, 528, -6},
{ -858, 364, -49},
{ -788, 385, -76},
{ -730,... |
{
PebbleEvent event = {
.type = PEBBLE_APP_FETCH_EVENT,
.app_fetch = {
.type = type,
.id = s_fetch_state.app_id,
}
};
event_put(&event);
} |
//! Recomputes and saves the progress percent for the current application fetch session
static uint8_t prv_compute_progress_percent(PutBytesObjectType type, unsigned int type_percent) {
// Add 33(34) percent for each piece that has finished (or is unneeded)
uint8_t percent = 0;
if (s_fetch_state.app) {
per... | |
/*
* 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... | (decoded_codepoint, actual_codepoint) | ;
++i;
} while (iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
cl_assert(i == NUM_VALID_CODEPOINTS);
cl_assert(utf8_iter_state.current == utf8_bounds.end);
cl_assert(*utf8_iter_state.current == '\0');
cl_assert(utf8_iter_state.codepoint == 0);
}
void test_utf8_iterator__decode_valid_strin... |
er, sizeof(uuid_buffer)), E_DOES_NOT_EXIST);
cl_assert_equal_i(persist_write_data(key, &test_uuid_a, sizeof(test_uuid_a)), size);
cl_assert_equal_i(persist_get_size(key), size);
cl_assert_equal_i(persist_read_data(key, &uuid_buffer, sizeof(uuid_buffer)), size);
cl_assert(uuid_equal(&test_uuid_a, &uuid_buffe... | (&test_uuid_a) | ;
persist_service_client_open(&test_uuid_a);
// Reset out buffer so we can check the read's honesty.
memset(buffer, 0, strlen(buffer));
// Read part of the data we wrote
cl_assert_equal_i(persist_read_string(0, buffer, 2), 2);
cl_assert_equal_i(strlen(buffer), 2 - 1); // -1 because null termination
cl_ass... |
ui_data->call_status_text_buf,
CALL_STATUS_BUFFER_LENGTH);
}
}
text_layer_set_text(&s_phone_ui_data->call_status_text_layer,
s_phone_ui_data->call_status_text_buf);
prv_show_call_status();
}
// Handles cleanup when the SMS reply menu closes
static void prv_ac... | (SMS_REPLY_DELAY_MS) | |
s_workout_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__workout_render_walk(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 84,
.distance_m = 1234,
.avg_pace = health_util_... | {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 789,
.distance_m = 234,
.avg_pace = health_util_get_pace(789, 234),
.bpm = 167,
.hr_zone = 2,
};
WorkoutActiveWindow *active_window = workout_active_create_for_activity_type(
ActivitySessionType_Run, &s_workout_data, &s_... |
void test_workout_active__workout_render_hr_zone_3(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 789,
.distance_m = 234,
.avg_pace = health_util_get_pace(789, 234),
.bpm = 197,
.hr_zone = 3,
};
WorkoutActiveWindow *active_window = workout_active_create_for_activit... |
call the current node's render procedure
if (node->update_proc) {
node->update_proc(node, ctx);
}
// if client has forgotten to release frame buffer
if (ctx->lock) {
graphics_release_frame_buffer(ctx, &ctx->dest_bitmap);
APP_LOG(APP_LOG_LEVEL_WARNING,
"Frame ... | {
if (!child || child->parent == NULL) {
return;
}
if (child->parent->window) {
window_schedule_render(child->parent->window);
}
Layer *node = child->parent->first_child;
if (node == child) {
child->parent->first_child = node->next_sibling;
} else {
while (node->next_sibling != child) {
... |
void layer_remove_child_layers(Layer *parent) {
Layer *child = parent->first_child;
while (child) {
// Get the reference to the next now; layer_remove_from_parent will unlink them.
Layer *next_sibling = child->next_sibling;
layer_remove_from_parent(child);
child = next_sibling;
};
}
void layer_... |
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... | (fd, 0, FSeekSet) | |
/*
* 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 (isdigit(c)) return c - '0' + 52; |
if (c == '+') return 62;
if (c == '/') return 63;
if (c == '=') return 127;
return -1;
}
unsigned int base64_decode_inplace(char* buffer, unsigned int length) {
unsigned int read_index = 0;
unsigned int write_index = 0;
while (read_index < length) {
int quad_index = 0;
unsigned int v = 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... | {
case NotificationMobile:
return AlertMobile;
case NotificationPhoneCall:
return AlertPhoneCall;
case NotificationOther:
return AlertOther;
case NotificationReminder:
return AlertReminder;
default:
return AlertInvalid;
} |
}
static void prv_toggle_dnd_from_back_click(ClickRecognizerRef recognizer, void *data) {
do_not_disturb_manual_toggle_with_dialog();
}
static void prv_toggle_dnd_from_action_menu(ActionMenu *action_menu,
const ActionMenuItem *item,
... |
s_s*)context;
WakeupId wakeup_id;
info->get_key(old_file, (uint8_t*)&wakeup_id, sizeof(WakeupId));
WakeupEntry entry;
info->get_val(old_file, (uint8_t*)&entry, info->val_len);
if (struct_migration) {
entry.timestamp = wakeup_id; // WakeupId (key) is a timestamp
entry.utc = false; // If we're migrati... | rtc_get_time() | |
tubs_system_theme.h"
#include "stubs_syscalls.h"
#include "stubs_task_watchdog.h"
#include "stubs_tick.h"
#include "stubs_time.h"
#include "stubs_watchface.h"
#include "stubs_weather_service.h"
#include "stubs_weather_types.h"
#include "stubs_window_manager.h"
#include "stubs_window_stack.h"
#include "stubs_workout_ser... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_launcher_menu_layer__no_icon_app_with_glance(void) {
// Insert a glance with a slice for the app that doesn't have a default icon
const AppGlance glance = (AppGlance) {
.num_slices = 1,
.slices = {
{
.expiration_time = 1464734484, // (Tue, 31 May 2016 22:41:24 GMT)
... |
re_b = prv_last_handler_entry(&s_started_handler_calls, b0)->fire_order;
first_fire_b = MIN(first_fire_b,
prv_last_handler_entry(&s_started_handler_calls, b1)->fire_order);
first_fire_b = MIN(first_fire_b,
prv_last_handler_entry(&s_started_handler_calls, b2)->fire_order);
f... | prv_advance_to_ms_with_timers(start_ms + duration_a + delay_seq + delay_a + delay_b
+ 2 * MIN_FRAME_INTERVAL_MS + 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_started_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, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0)... |
((i * ANIMATION_NORMALIZED_MAX) / num_frames,
-20000, 20000, 0, true) | , expected[i]);
}
}
void test_animation_interpolate__moook_soft(void) {
const int32_t moook_num_soft_frames = 3;
cl_assert_equal_i(-20000, interpolate_moook_soft(0, -20000, 20000, moook_num_soft_frames));
// mid frame is closer to end due to more end frames
cl_assert_equal_i(6676, interpolate_moook_soft(ANI... | |
/*
* 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... | (decoded_codepoint, actual_codepoint) | ;
malformed_test_string_utf8 = utf8_get_next(malformed_test_string_utf8);
}
// When we decode the invalid codepoint, it should return an invalid stream
// error and set the pointer to the stream to be null
cl_assert_equal_i(utf8_peek_codepoint(malformed_test_string_utf8, NULL), 0);
cl_assert_(*malformed_... |
rame to place dot in middle of layer
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_circle(ctx, grect_center_point(&layer->bounds), data->mic_window.mic_dot_radius);
}
static void prv_set_dot_width(void *subject, int16_t radius) {
VoiceUiData *data = subject;
data->mic_window.mic_dot_radius =... | kino_layer_rewind(&data->mic_window.icon_layer) | ;
GRect from = kino_reel_transform_get_from_frame(reel);
GRect to = kino_reel_transform_get_to_frame(reel);
kino_reel_scale_segmented_set_from_stroke_width(reel, FIXED_S16_3_ONE, GStrokeWidthOpMultiply);
kino_reel_scale_segmented_set_to_stroke_width(reel, FIXED_S16_3_ONE, GStrokeWidthOpMultiply);
if (is_reve... |
every minute. If the orientation has
//! changed by a significant amount, we consider the watch as in motion, and restart the
//! stationary counter
static void prv_watch_is_in_motion(void) {
prv_handle_action(StationaryActionWakeUp);
}
static void prv_stationary_check_launcher_task_cb(void *unused_data) {
if (pr... | accel_session_shake_subscribe(s_accel_session, prv_accel_tap_handler) | ;
event_service_client_subscribe(&s_button_event_info);
#if DEBUG_STATIONARY
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(Statio... |
etting the minute history
void test_activity__get_minute_history(void) {
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending... | rtc_set_time(utc_sec) | ;
prv_activity_init_and_set_enabled(true);
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricStepCount,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){300, 200, 100, 0, 0, 0, 0}));
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricSleepTotalSeconds,
((const uint32_t [ACTIVI... |
/*
* 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... | mcu_state_is_isr() | && __get_BASEPRI() == 0
&& xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) {
PBL_LOG(LOG_LEVEL_WARNING, "Reboot reason is already set");
}
return;
}
RTC_WriteBackupRegister(REBOOT_REASON_REGISTER_1, raw[0]);
RTC_WriteBackupRegister(REBOOT_REASON_REGISTER_2, raw[1]);
RTC_WriteBacku... |
g *dialog = workout_dialog_get_dialog(workout_dialog);
dialog_show_status_bar_layer(dialog, true);
dialog_set_fullscreen(dialog, true);
dialog_set_background_color(dialog, PBL_IF_COLOR_ELSE(GColorYellow, GColorWhite));
dialog_set_text_color(dialog, GColorBlack);
dialog_set_icon(dialog, RESOURCE_ID_WORKOUT_AP... | prv_prep_and_open_active_window(existing_workout_type) | ;
}
return;
}
const bool found_automatic_session =
workout_utils_find_ongoing_activity_session(&data->ongoing_session);
if (found_automatic_session) {
prv_show_workout_detected_dialog(data);
} else {
workout_push_summary_window();
}
}
static void prv_deinit(void) {
WorkoutAppData *d... |
UP_EVENT, NULL, NULL);
// Create single reusable timer for wakeup events
s_current_timer_id = new_timer_create();
s_wakeup_state.next_wakeup_id = rtc_get_time();
s_wakeup_state.timestamp = -1;
SettingsFile wakeup_settings;
if (settings_file_open(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) !=... | app_manager_get_current_app_md() | ->uuid, &entry.uuid)) {
if (wakeup_id == s_wakeup_state.current_wakeup_id &&
new_timer_scheduled(s_current_timer_id, NULL)) {
new_timer_stop(s_current_timer_id);
}
prv_wakeup_settings_delete_entry(wakeup_id);
prv_wakeup_timer_next_pending();
}
}
static bool prv_check_count_and_availabil... |
/*
* 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... | {
assert_checksum(0xffffffff);
} |
void test_legacy_checksum__one_byte(void) {
update("A", 1);
assert_checksum(0xf743b0bb);
}
void test_legacy_checksum__standard(void) {
update("123456789", 9);
assert_checksum(0xaff19057);
}
void test_legacy_checksum__one_word(void) {
update("1234", 4);
assert_checksum(0xc2091428);
}
void test_legacy_ch... |
/*
* 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... | framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS}) | |
RUNNING)) {
data->test_case_status = FLASH_TEST_STATUS_STOPPED;
stop_flash_test_case();
update_test_case_status(data);
}
}
static void run_test(void* context) {
struct FlashTestData *data = app_state_get_user_data();
FlashTestErrorType status = FLASH_TEST_SUCCESS;
// Execute test - pass in 0 by de... | WINDOW_NAME("Flash Test") | );
window_set_user_data(&data_ptr->window, data_ptr);
window_set_window_handlers(&data_ptr->window, &(WindowHandlers){
.load = flash_test_window_load,
});
const bool animated = true;
app_window_stack_push(&data_ptr->window, animated);
tick_timer_service_subscribe(SECOND_UNIT, handle_timer);
}
stati... |
r_frame;
layer_get_global_frame((Layer *)&peek_layer->kino_layer, &layer_frame);
if (grect_equal(&icon_from, &GRectZero)) {
icon_from = (GRect) {
.origin.x = layer_frame.origin.x + (layer_frame.size.w - size.w) / 2,
.origin.y = layer_frame.origin.y + (layer_frame.size.h - size.h) / 2,
.size = ... | {
prv_set_text(&peek_layer->title, title);
} |
if (subtitle) {
prv_set_text(&peek_layer->subtitle, subtitle);
}
prv_layout_text(peek_layer);
}
void peek_layer_clear_fields(PeekLayer *peek_layer) {
peek_layer_set_fields(peek_layer, "", "", "");
}
void peek_layer_set_fields_hidden(PeekLayer *peek_layer, bool hidden) {
layer_set_hidden(&peek_layer->nu... |
/*
* 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... | (&out_stream, 0) | ;
}
}
}
return out_stream.index;
}
|
se
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__fill(void) {
// Fill shape, non-antialiased (Stroke width/color N/A)
setup_test(&context, false, 5, GColorBlack, GColorBlack, false);
graphics_fill_rect(&context, &... | GPoint(5, 5) | , GPoint(45, 10)));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(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, true, 2, GColorBlack, GColorBlack, true);
ASS... |
/*
* 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 (existing_notif_prefs) {
for (int i = 0; i < num_existing_attributes; i++) {
new_attr_list.attributes[i] = existing_notif_prefs->attr_list.attributes[i];
}
} |
char msg_buffer[message->length + 1];
memcpy(msg_buffer, message->value, message->length);
msg_buffer[message->length] = '\0';
attribute_list_add_cstring(&new_attr_list, AttributeIdAuthCode, msg_buffer);
// This will trigger a sync sending the auth code to the phone
ios_notif_pref_db_store_prefs(app_id->... |
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 the License is distribu... | cl_assert(NULL == bmp) | ;
bmp = gbitmap_create_blank(s180, GBitmapFormat8BitCircular);
cl_assert(NULL != bmp);
cl_assert(g_gbitmap_spalding_data_row_infos == bmp->data_row_infos);
#endif
}
void test_gbitmap_formats__create_blank_with_palette(void) {
const GSize s10 = GSize(10, 10);
const GSize s180 = GSize(180, 180);
GBitmap *bm... |
2_t QSPIC_DUMMYDATA_REG;
uint32_t QSPIC_ERASECTRL_REG;
uint32_t QSPIC_ERASECMDA_REG;
uint32_t QSPIC_ERASECMDB_REG;
uint32_t QSPIC_BURSTBRK_REG;
uint32_t QSPIC_STATUSCMD_REG;
uint32_t QSPIC_CHCKERASE_REG;
uint32_t QSPIC_GP_REG;
uint32_t QSPIC_UCODE_START;
// GPREG
uint16_t PLL_SYS_CTRL1_RE... | REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_FAST_RAMPING, 0x1) | ;
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_VOLTAGE, 0x18);
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_CUR_LIM_MAX_HV, 0x1F);
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_CUR_LIM_MIN, 0x4);
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_HV, 0x1);
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_LV, 0x0);
REG_SETF(DCDC... |
(dstbuf, "23257157360,23257157360") | ;
}
void test_sprintf__percent_x(void) {
char dstbuf[256];
// Simple %x
snprintf(dstbuf, 256, "There are %x lights, %x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, fffffffc");
// Alternate form (adds 0x prefix)
snprintf(dstbuf, 256, "There are %#x lights, %#x", 16, -4);
cl_assert_equal_s(... | |
tate->samples[state->test_entry.num_samples++] = (AccelRawData) {
.x = x,
.y = y,
.z = z,
};
continue;
}
// End of a sample
if (strcmp(token, "}") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
break;
}
}
// Did we get samples?
if (state->tes... | strlen(token) | + 1, "%d", &state->test_entry.cur_state_elapsed.min);
} else if (strcmp(token, "TEST_CUR_STATE_ELAPSED_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.cur_state_elapsed.max);
} else if (strcmp(token, "TEST_IN_SLEEP") == 0) {
sscanf(token + strlen(token) + 1, "%d",... |
22) },
.caller_id_pos_y = PBL_IF_RECT_ELSE(80, 88),
.caller_id_height = 60,
.status_pos_y = PBL_IF_RECT_ELSE(138, 144),
.status_height = 20,
.large_caller_id = true,
};
static const PhoneStyle *s_phone_styles[NumPreferredContentSizes] = {
[PreferredContentSizeSmall] = &s_phone_style_default,
[PreferredC... | kino_layer_play(&s_phone_ui_data->icon_layer) | ;
s_phone_ui_data->current_icon = image;
s_phone_ui_data->current_icon_id = resource;
#else
kino_layer_set_reel(&s_phone_ui_data->icon_layer, image, true);
s_phone_ui_data->current_icon = image;
s_phone_ui_data->current_icon_id = resource;
#endif
}
#if !PLATFORM_TINTIN
static void prv_update_color_boundary(v... |
/*
* 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... | (0, DATA_LOGGING_BYTE_ARRAY, 4, true) | ;
for (int i = 0; i < 32; ++i) {
uint32_t t = ((uint32_t) time(NULL)) + i;
data_logging_log(session, &t, 1);
}
data_logging_finish(session);
app_timer_register(100, log_data, 0);
}
int main(void) {
Window *window = window_create();
const bool animated = true;
window_stack_push(window, animate... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ERROR, "App relaunch failed: %u", err) | ;
}
}
|
ssert_equal_i(4, string_list_count(list));
cl_assert_equal_s("", string_list_get_at(list, 0));
cl_assert_equal_s("", string_list_get_at(list, 1));
cl_assert_equal_s("", string_list_get_at(list, 2));
cl_assert_equal_s("", string_list_get_at(list, 3));
// non-null-terminated string is treated as one string - t... | string_list_get_at(list, 3) | );
}
|
+ lock_flag))[0] =
S29VSCommand_SectorLock;
}
static uint16_t prv_read_manufacturer_id(void) {
// Issue the DeviceIDEntry command to change to the ID-CFI Address Map. This means that reading from the bank will
// give us ID-CFI information instead of the normal flash contents. See Table 11.2 (ID/CFI Data) ... | {
s_num_flash_uses = 0;
gpio_use(GPIOB);
gpio_use(GPIOD);
gpio_use(GPIOE);
flash_impl_use();
flash_s29vs_hw_init();
flash_impl_release();
gpio_release(GPIOE);
gpio_release(GPIOD);
gpio_release(GPIOB);
} |
void flash_impl_enable_write_protection(void) {
}
// Protects start_sector - end_sector, inclusive, from any kind of program
// operation
status_t flash_impl_write_protect(FlashAddress start_sector,
FlashAddress end_sector) {
prv_flash_reset();
prv_flash_protect_range(start_sect... |
fidence
0x08, 0x00, // Word length
'c', 'o', 'm', 'p', 'u', 't', 'e', 'r',
// Sentence #2
0x03, 0x00, // Word count
// Word #1
13, // Confidence
0x04, 0x00, // Word length
'h', 'e', 'l', 'l',
// Word #1
3, // Confidence
0x02, 0x00, // Word lengt... | cl_assert(!attr3) | ;
}
void test_generic_attribute__add_attribute(void) {
uint8_t data[] = {
0x01, 0x55, 0x77, 0x54, 0x47
};
uint8_t data_out[(2 * sizeof(GenericAttribute)) + sizeof(data) + sizeof(Uuid)];
GenericAttribute *next = (GenericAttribute *)data_out;
next = generic_attribute_add_attribute(next, VEAttributeIdTransc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.