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... | prv_read_ptr_and_length_from_buffer(read_iter, msg + length,
&album_ptr, &album_length) | ;
if (!read_iter) {
return;
}
const char* title_ptr;
size_t title_length;
read_iter = prv_read_ptr_and_length_from_buffer(read_iter, msg + length,
&title_ptr, &title_length);
if (!read_iter) {
return;
}
music_update_now_playing(title_ptr, title_len... |
/*
* 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... | {
(void)ctx;
static Window s_window;
window_init(&s_window, "Window Name");
window_stack_push(&s_window);
static Layer s_watch_layer;
layer_init(&s_watch_layer, s_window.layer.frame);
layer_add_child(&s_window.layer, &s_watch_layer);
PBL_GEN_INIT(&s_watch_layer);
} |
static void handle_render(AppContextRef ctx, PebbleRenderEvent *e) {
(void)ctx;
window_render(e->window, e->ctx);
layer_mark_dirty(&e->window->layer);
}
static void handle_deinit(AppContextRef ctx) {
(void)ctx;
// TODO: let go of resources
}
void pbl_main(void* params) {
PebbleAppHandlers s_handlers = ... |
/*
* 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... | (head == &a) | ;
cl_assert(list_get_prev(&a) == NULL);
cl_assert(list_get_next(&a) == &b);
cl_assert(list_get_prev(&b) == &a);
cl_assert(list_get_next(&b) == &c);
cl_assert(list_get_prev(&c) == &b);
cl_assert(list_get_next(&c) == NULL);
}
void test_list__count(void) {
ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL, c ... |
/*
* 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... | {
uint32_t length = 0;
const uint8_t *msg= prv_build_push_message(key, value, &length);
launcher_app_message_protocol_msg_callback_deprecated(s_session, msg, length);
} |
// Tests
////////////////////////////////////
void test_launcher_app_message__initialize(void) {
launcher_app_message_reset();
s_last_cmd = APP_RUN_STATE_INVALID_COMMAND;
fake_comm_session_init();
s_transport = fake_transport_create(TransportDestinationSystem, NULL, NULL);
s_session = fake_transport_set_c... |
ARRAY_LENGTH(written_order) | ;
prv_write_order_to_file(written_order, num_entries);
app_install_mark_prioritized(APP_ID_MUSIC, true /* can expire */);
app_menu_data_source_init(&data_source, &(AppMenuDataSourceCallbacks) {
.changed = prv_menu_layer_reload_data,
.filter = app_filter_callback,
}, &menu_layer);
uint16_t num_apps =... | |
>debug_card.dialog_text, "HR stats");
// Get various stats
time_t end_time = time(NULL);
// List of time ranges
typedef struct {
uint32_t seconds;
char *desc;
} TimeRange;
TimeRange ranges[] = {
{1 * SECONDS_PER_HOUR, "1 hour"},
{30 * SECONDS_PER_MINUTE, "30 min"},
};
unsigned num_ra... | (data->steps_window, data) | |
,
{ 608, 960, 392},
{ 376, 912, 80},
{ 432, 736, -536},
{ 752, 128, 144},
{ 1320, 16, -184},
{ 1240, -80, 88},
{ 992, -240, 1008},
{ 992, 864, -528},
{ 1112, 176, 192},
{ 600, 472, 472},
// 5 seconds
{ 160, 752, 272},
{ -72, 40, -304},
{ -328, 120, 240},
{ -16... | { 552, 600, -104},
{ 872, 728, -280},
{ 896, 568, -152},
{ 1160, 464, -208},
{ 1584, 640, -168},
{ 1928, 648, -136},
{ 1968, 336, -40},
{ 1776, 104, 0},
{ 1488, 104, -112},
{ 1240, 128, -144},
{ 1000, 120, -72},
{ 904, 64, -112},
{ 1040, 80, -136},
{ 944, 128, -17... |
{ 1216, 120, -192},
{ 1104, 80, -232},
{ 1008, -16, -200},
{ 968, 24, -296},
{ 856, -32, -376},
// 13 seconds
{ 736, -56, -416},
{ 856, -72, -296},
{ 1144, 32, -392},
{ 1192, 8, -504},
{ 1248, -24, -416},
{ 1320, 72, -392},
{ 1240, 168, -448},
{ 1056, 272, -328},... |
eIterDirectionPast,
1421178000), 2);
}
void test_timeline__middle_forwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
// check first
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1421... | (1421178000) | ;
fake_pbl_malloc_clear_tracking();
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1421178000), 0);
cl_assert_equal_i(prv_num_items(iterator), 6);
// Thursday Jan 16 00:00:00 PST 2... |
sed_msg.payload_sender_version_patch,
&s_parsed_msg.payload_send_time,
&s_parsed_msg.payload_sender_v_major,
&s_parsed_msg.payload_sender_v_minor,
&s_parsed_msg.msrmt.uuid,
&s_parsed_msg.msrmt.time_utc,
&s_parsed_msg.msrmt.time_end_utc,
&s_parsed_msg.msrmt.utc_to_local,
&... | LOG("Events: Number: %d", num_events) | ;
for (int i = 0; i < num_events; i++) {
pebble_pipeline_Event *event = &s_parsed_msg.events.events[i];
LOG(" Event -- Type: %d", event->type);
char uuid_str[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(&s_parsed_msg.events.uuids[i], uuid_str);
LOG(" Uuid: %s", uuid_str);
LOG(" ... |
data->action_menu_layer, NULL, 0, 0);
action_menu_layer_set_items(&data->action_menu_layer, cur_level->items, cur_level->num_items,
cur_level->default_selected_item, cur_level->separator_index);
}
crumbs_layer_set_level(&data->crumbs_layer, vm->num_dots);
}
static void prv_next_level_anim_stopped(Anima... | item->perform_action(action_menu, item, data->config.context) | ;
data->performed_item = item;
if (!data->frozen) {
prv_action_window_pop(true /*animated*/, action_menu);
}
} else if (item->next_level) {
prv_set_level(data, item->next_level);
}
}
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
ActionMenuData *data = co... |
----------------------------------------
static void do_callbacks(ListNode* list) {
mutex_lock(s_callback_list_semaphore);
for (ListNode* iter = list_get_next(list); iter != 0; ) {
RegularTimerInfo* reg_timer = (RegularTimerInfo*) iter;
if (--reg_timer->private_count == 0) {
reg_timer->private_count... | {
// special case for triggering each second
regular_timer_add_multisecond_callback(cb, 1);
} |
// --------------------------------------------------------------------------------------------
void regular_timer_add_multiminute_callback(RegularTimerInfo* cb, uint16_t minutes) {
PBL_ASSERTN(s_callback_list_semaphore);
mutex_lock(s_callback_list_semaphore);
cb->private_reset_count = minutes;
cb->private_... |
Config UP / DOWN button behavior:
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, scroll_layer_scroll_up_click_handler);
window_single_repeating_click_subscribe(BUTTON_ID_DOWN, 100, scroll_layer_scroll_down_click_handler);
// Set the context for the SELECT button:
window_set_click_context(BUTTON_ID_... | {
return scroll_layer->content_sublayer.clips;
} | |
alth_service(uint32_t *session_entries,
ActivitySession *sessions,
HealthIterationDirection direction) {
time_t now = rtc_get_time();
s_health_sessions_count = 0;
s_health_sessions_max = *session_entries;
s_h... | (ActivityMetricActiveKCalories,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){0, 0, 0, 0, 0, 0, 0})) | ;
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricRestingKCalories, exp_resting_kcalories);
// 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_callback... |
/*
* 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... | GSize(num_mask_values * num_pixels_per_mask_value, num_src_colors) | ;
prv_prepare_canvas(ctx, bitmap_size);
}
static GDrawMask *prv_create_mask_for_hline_recording_test(GContext *ctx) {
// The initial transparency doesn't really matter since we're about to overwrite it
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparent);
cl_assert... |
layer, cd, is_selected, item->arg1, item->arg2);
}
static uint16_t prv_certification_get_num_rows_callback(MenuLayer *menu_layer,
uint16_t section_index,
void *context) {
SettingsSystemData *data = (Settin... | prv_append_certification_menu(cd, &(SystemCertificationMenuItem) {
.draw_cell_fn = prv_draw_rt_cell,
.arg1 = &cd->t_mark,
.arg2 = prv_get_japan_telec_t_id()
}) | |
uture */);
cl_assert_equal_s(morning, daypart_string);
// (9am today) time before 12pm is this morning
daypart_string = clock_get_relative_daypart_string(timestamp, 5 /* hours_in_the_future */);
cl_assert_equal_s(morning, daypart_string);
// (4pm today) time between 12pm and 6pm is this afternoon
daypart_... | cl_assert_equal_i(minute, 45) | ;
hour = 23;
minute = 15;
clock_hour_and_minute_add(&hour, &minute, 65);
cl_assert_equal_i(hour, 0);
cl_assert_equal_i(minute, 20);
hour = 0;
minute = 15;
clock_hour_and_minute_add(&hour, &minute, -30);
cl_assert_equal_i(hour, 23);
cl_assert_equal_i(minute, 45);
}
|
y_header(ReceiveRouter *rtr, size_t *data_size_p, const uint8_t **data_p) {
// New message or still gathering the header of the message
const uint16_t header_bytes_missing = sizeof(PebbleProtocolHeader) - rtr->bytes_received;
const uint16_t header_bytes_to_copy = MIN(header_bytes_missing, *data_size_p);
memcpy(... | (LOG_DOMAIN_COMM, LOG_LEVEL_DEBUG_VERBOSE, data, data_size) | ;
ReceiveRouter *rtr = &session->recv_router;
while (data_size) {
if (prv_ignore_skipped_message_if_needed(&data, &data_size, rtr)) {
return; // we're done
}
// Deal with the header:
if (rtr->bytes_received < sizeof(PebbleProtocolHeader)) {
if (prv_copy_header(rtr, &data_size, &data)... |
eString;
case AttributeIdAncsAction:
case AttributeIdSportsGameState:
case AttributeIdPrimaryColor:
case AttributeIdSecondaryColor:
case AttributeIdBgColor:
case AttributeIdDisplayRecurring:
case AttributeIdEmojiSupported:
case AttributeIdHealthInsightType:
case AttributeIdDisplayTim... | if ((*cursor + attribute->length) > end) {
return -1;
} |
int32_t string_alloc_size = 0;
switch (prv_attribute_type(attribute->id)) {
case AttributeTypeString:
if (attribute->id <= AttributeIdBody) {
string_alloc_size +=
MIN(MAX_ATTRIBUTE_LENGTHS[attribute->id - 1], attribute->length) + 1;
} else if (attribute->id == AttributeIdSubtitleTem... |
t_get_blood_pressure_service();
uint8_t num_found_services = gatt_client_copy_service_refs_matching_uuid(&device, service_refs,
num_services,
&bp_service->uuid);
cl_a... | (service_refs_out[0]) | ;
const Uuid uuid2 = gatt_client_service_get_uuid(service_refs_out[0]);
cl_assert(uuid_equal(&uuid1, &thermo_service->uuid) ||
uuid_equal(&uuid1, &random_128bit_service->uuid));
cl_assert(uuid_equal(&uuid2, &thermo_service->uuid) ||
uuid_equal(&uuid2, &random_128bit_service->uuid));
}
|
NDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "protobuf_log.h"
#include "protobuf_log_private.h"
#include "protobuf_log_util.h"
#include "applib/data_logging.h"
#include "drivers/rtc.h"
#include "k... | (&v_major, &v_minor, &version_patch_ptr) | ;
// Sender Id
const char *watch_serial = mfg_get_serial_number();
pebble_pipeline_Payload payload = {
.sender = {
.type = {
.funcs.encode = protobuf_log_util_encode_string,
.arg = (void *)PLOG_PAYLOAD_SENDER_TYPE,
},
.id = {
.funcs.encode = protobuf_log_util_encode... |
, 536, -256},
{ 2000, 344, -104},
// 42 seconds
{ 1688, 216, -120},
{ 1296, 232, -184},
{ 1048, 224, -144},
{ 864, 160, -72},
{ 784, 120, -64},
{ 720, 112, -72},
{ 760, 184, -88},
{ 784, 128, -72},
{ 848, 8, -56},
{ 776, -80, -80},
{ 968, -56, -56},
{ 1248, 176, -... | { 880, 584, -320},
{ 808, 584, -416},
{ 752, 568, -432},
{ 840, 608, -416},
{ 912, 600, -296},
{ 1352, 680, -240},
{ 1384, 768, -336},
{ 1256, 648, -160},
{ 1624, 608, -144},
{ 1832, 504, -48},
{ 1544, 336, 40},
{ 1240, 208, 56},
{ 1032, 216, -8},
{ 936, 216, 0},
... |
{ 1928, 416, -88},
{ 1600, 232, -48},
{ 1296, 232, -72},
{ 1072, 264, -96},
{ 904, 224, -80},
{ 752, 152, -64},
{ 656, 104, -16},
{ 432, -168, -24},
{ 520, -160, -64},
{ 760, 0, -152},
{ 960, 112, -200},
{ 1312, 96, -128},
{ 1416, 248, -168},
{ 1472, 272, -336},
... |
OGGING_BYTE_ARRAY, sizeof(ActivityRawSamplesRecord),
true /*buffered*/, false /*resume*/, &system_uuid);
if (data->dls_session == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "Unable to create DLS session");
return;
}
}
if (finish) {
PBL_ASSERTN(num_samples == 0 && accel_data == NULL);
}
... | (LOG_LEVEL_INFO, __FILE_NAME__, __LINE__, "RAW: %s", data->base64_buf) | ;
// Reset the stored record. 0 in num_samples causes it to be re-initialized
// at the top of this loop.
data->record.num_samples = 0;
}
if (finish) {
break;
}
}
}
// ------------------------------------------------------------------------------------------------
// Accel call... |
/*
* 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, "Failed to load action for dismissal from %s", uuid_buffer) | |
n, true, true), duration_total);
animation_destroy(spawn);
#endif
}
// --------------------------------------------------------------------------------------
// Test unschedule all when we have multiple animations, some complex
void test_animation__unschedule_all(void) {
#ifdef TEST_INCLUDE_COMPLEX
// Create a... | cl_assert_equal_i(animation_get_play_count(h), 1) | ;
animation_set_play_count(h, 2);
cl_assert_equal_i(animation_get_play_count(h), 2);
cl_assert(animation_get_duration(h, true, true) == 2*(duration + delay));
// Curve
cl_assert(animation_get_curve(h) == AnimationCurveDefault);
animation_set_curve(h, AnimationCurveEaseOut);
cl_assert(animation_get_curve(... |
// 217 seconds
{ -16, -56, -960},
{ -16, -56, -952},
{ -16, -40, -960},
{ -16, -64, -960},
{ -16, -32, -952},
{ -16, -48, -960},
{ -16, -64, -952},
{ -24, -48, -960},
{ -24, -64, -952},
{ -8, -56, -952},
{ -16, -48, -952},
{ -16, -56, -960},
{ -16, -80, -952},
... | { -16, -48, -952},
{ -16, -48, -952},
{ -16, -48, -960},
{ -16, -56, -960},
{ -16, -40, -952},
{ -16, -48, -960},
{ -16, -48, -952},
{ -16, -40, -952},
{ -16, -48, -952},
{ -16, -48, -960},
{ -16, -48, -960},
{ -16, -48, -952},
{ -16, -40, -960},
{ -16, -48, -952}... | |
use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CON... | {
// copy length from iter to out_len, then save a local copy of the length
*out_int = *(uint16_t*)iter;
iter += sizeof(uint16_t);
return iter;
} |
static BlobDBToken prv_try_read_token(const uint8_t *data, uint32_t length) {
if (length < sizeof(BlobDBToken)) {
return 0;
}
return *(BlobDBToken*)data;
}
static void prv_handle_database_insert(CommSession *session, const uint8_t *data, uint32_t length) {
if (length < MIN_INSERT_LENGTH) {
prv_send_... |
return false;
}
return (intent->bonding->id == bonding_id);
}
static GAPLEConnectionIntent * prv_get_intent_by_bonding_id(BTBondingID bonding_id) {
return (GAPLEConnectionIntent *) list_find(&s_intents->node,
prv_intent_filter_by_bonding_id,
... | {
return BTErrnoNotEnoughResources;
} |
bool is_already_connected = false;
bool is_already_encrypted = false;
bool local_is_master = false;
const BTDeviceInternal *connected_device = NULL;
GAPLEConnectionIntent *intent;
if (request->is_bonding_based) {
const GAPLEConnection *connection = gap_le_connection_find_by_irk(&request->bonding.irk... |
r(), 0);
}
// Sets the getting started field, then corrupts the ble_pairing_data crc
// This tests that when setting a value, all fields in the struct must be valid.
void test_shared_prf_storage_v3__handle_currupt_field_during_setting(void) {
bool GETTING_STARTED_COMPLETE = true;
shared_prf_storage_set_getting_sta... | shared_prf_storage_set_getting_started_complete(true) | ;
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 1);
shared_prf_storage_set_getting_started_complete(true);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 1);
shared_prf_storage_set_getting_started_complete(false);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 2);... |
he stored activities
status_t result = settings_file_get(file, &key, sizeof(key), state->activity_sessions,
sizeof(state->activity_sessions));
if (result != S_SUCCESS) {
return;
}
// Scan to see how many valid activities we have.
ActivitySession *session = state->act... | activity_sessions_is_session_type_ongoing(type) | ;
}
|
/*
* 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... | text_layer_destroy(data->title_text_layer) | |
{ 1232, 160, -128},
{ 1088, 24, -24},
{ 600, 456, -8},
{ 960, 440, -72},
// 340 seconds
{ 944, 184, -8},
{ 664, 200, -16},
{ 584, 320, -24},
{ 648, 288, 64},
{ 1016, 296, 128},
{ 1312, 424, 176},
{ 1376, 544, 320},
{ 1288, 840, 496},
{ 1224, 848, 608},
{ 1104, 58... | { 1712, 648, 472},
{ 1648, 512, 432},
{ 1664, 480, 360},
{ 1712, 512, 312},
{ 1608, 336, 336},
{ 1296, 200, 232},
{ 1032, -512, -424},
{ 984, -672, -216},
{ 1208, 656, -368},
{ 1184, 336, -112},
{ 1320, 248, 152},
{ 1392, 272, 304},
{ 1408, 464, 376},
{ 1488, 608,... | |
include "applib/ui/dialogs/dialog.h"
#include "applib/ui/dialogs/simple_dialog.h"
#include "applib/ui/vibes.h"
#include "applib/ui/window_manager.h"
#include "kernel/ui/modals/modal_manager.h"
#include "process_state/app_state/app_state.h"
#include "resource/resource_ids.auto.h"
#include "services/common/i18n/i18n.h"
#... | (actionable_dialog) | ;
prv_call_set_state_callback(ctx);
}
static void prv_action_toggle_dialog_unload(void *context) {
ActionToggleContext *ctx = context;
if (!ctx) {
return;
}
if (ctx->defer_destroy) {
ctx->defer_destroy = false;
return;
}
applib_free(ctx);
}
static void prv_prompt_click_config_provider(void *... |
/*
* 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... | (dest, "Katharine B.") | ;
}
void test_phone_formatting__name_trailing_space(void) {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharine Berry ", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine B.");
memset(dest, 0, NAME_LENGTH);
phone_format_caller_name("Katharine Berry ", dest, NAME_LENGTH);
cl_assert_equal_s(... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GPoint(48, 96) | );
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "test_gdraw_command_transforms__to_square.8bit.pbi"));
}
// re-enable this "test" to debug per-frame transitions
void _test_gdraw_command_transforms__to_square_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&c... |
dialogs/simple_dialog.h"
#include "applib/ui/progress_window.h"
#include "applib/ui/window.h"
#include "applib/ui/window_manager.h"
#include "applib/voice/voice_window.h"
#include "applib/voice/voice_window_private.h"
#include "comm/ble/kernel_le_client/ancs/ancs.h"
#include "kernel/events.h"
#include "kernel/pbl_mallo... | {
return;
} |
// report to analytics the result of the action
if (data->response.attribute.id == AttributeIdTitle &&
data->response.attribute.cstring) {
analytics_event_canned_response(data->response.attribute.cstring, succeeded);
}
if (data->action_complete.callback) {
data->action_complete.callback(succeed... |
;
manager.state = RecognizerManagerState_RecognizersTriggered;
recognizer_manager_deregister_recognizer(&manager, r1);
cl_assert_equal_p(manager.triggered, r2);
cl_assert_equal_p(manager.active_layer, &layer_a);
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersTriggered);
cl_assert_equal_i... | (&manager, r[0]) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_p(manager.triggered, NULL);
cl_assert_equal_p(manager.active_layer, NULL);
prv_compare_recognizers_processed((int []) { 0, 1 }, 2, &s_recognizers_reset);
recognizer_set_simultaneous_with(r[0], prv_simultaneous_with_c... |
oid)animation;
}
AnimationProgress animation_bounce(AnimationProgress linear_distance) {
// An awful linear "bounce-like" animation
if (linear_distance < ANIMATION_NORMALIZED_MAX/2) {
return linear_distance * 2;
} else if (linear_distance < ANIMATION_NORMALIZED_MAX * 3/4) {
return ANIMATION_NORMALIZED_MA... | {
static const PebbleProcessMdSystem animated_demo_app_info = {
.common.main_func = s_main,
.name = "Animation Demo"
};
return (const PebbleProcessMd*) &animated_demo_app_info;
} | |
sion);
activity_metrics_prv_reset_hr_stats();
#endif // CAPABILITY_HAS_BUILTIN_HRM
}
// ----------------------------------------------------------------------------------------------
// Open the settings file and malloc space for the file struct
SettingsFile *activity_private_settings_open(void) {
SettingsFile *... | {
return;
} |
// The following sections of code can access the settings file and/or update globals,
// so we need to surround it with mutex ownership
mutex_lock_recursive(s_activity_state.mutex);
{
SettingsFile *file = activity_private_settings_open();
if (file && (s_activity_state.update_settings_counter <= 0)) {... |
a it had received.
// Don't roll back directly to avoid creating an Sorcerer's Apprentice bug
// https://en.wikipedia.org/wiki/Sorcerer%27s_Apprentice_Syndrome
// We'll rely on the ACK timeout for the next data packet to fire and roll back.
PBL_LOG(LOG_LEVEL_WARNING, "Received retransmitted Ack for sn:%... | PBL_LOG(LOG_LEVEL_ERROR, "Invalid UUID") | |
1) {
// Non-Antialiased and Stroke Width > 1
graphics_circle_quadrant_draw_stroked_non_aa(ctx, p, radius, stroke_width, quadrant);
} else {
// Non-Antialiased and Stroke Width == 1
graphics_circle_quadrant_draw_1px_non_aa(ctx, p, radius, quadrant);
}
}
T_STATIC void graphics_circle_draw_1px_non_aa... | GPoint(x0 - radius, y0) | |
) {
LauncherAppGlanceService *service = context;
PBL_ASSERTN(service);
// Update the current slice of the glance that was changed if the glance is in the cache
LauncherAppGlance *glance_in_cache = prv_find_glance_in_cache(service,
event->app_glanc... | (&service->glance_reel_player, glance_reel_player_callbacks, service) | ;
}
void launcher_app_glance_service_set_handlers(LauncherAppGlanceService *service,
const LauncherAppGlanceServiceHandlers *handlers,
void *context) {
if (!service) {
return;
} else if (!handlers) {
service->handle... |
56 ms.
// Something is wrong if it takes more than twice that time.
int timeout = 100 * 10; // * 100 microseconds
while (!gpio_input_read(&ICE40LP->cdone)) {
if (timeout-- == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "FPGA CDONE timeout expired!");
return false;
}
delay_us(100);
}
return true;
}
... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling 6v6 (Display VDDC)");
set_6V6_power_state(false);
psleep(2);
} | |
NIMATION_NORMALIZED_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_NORMA... | cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 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), 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... | PBL_CROAK("Error: Heap corrupt around <%p>", ptr) | |
fer_offset);
}
} else {
// Original SVGs use Red for the stroke, replace it here
const GColor8 key_stroke_color = GColorRed;
gdraw_command_replace_color(processed_command, key_stroke_color, p->stroke_color);
// replace surrounding color
gdraw_command_replace_color(processed_command, p->key_col... | (output, mask, data_row_offset, x1.integer, 1, *input) | |
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 permissions and
* limitations under the License.
*/
#include "app... | if (!command || command->hidden) {
return;
} |
switch (command->type) {
case GDrawCommandTypePath:
prv_draw_path(ctx, command);
break;
case GDrawCommandTypePrecisePath:
prv_draw_precise_path(ctx, command);
break;
case GDrawCommandTypeCircle:
prv_draw_circle(ctx, command);
break;
default:
WTF;
}
}
size... |
GDrawCommand *c2 = gdraw_command_list_get_command(list, 2);
*c2 = (GDrawCommand){
.type = GDrawCommandTypePath,
.hidden = false,
.stroke_color = GColorBlack,
.stroke_width = 3,
.path_open = true,
.num_points = ARRAY_LENGTH(c2_points),
};
memcpy(c2->points, c2_points, sizeof(c... | gdraw_command_list_get_command(&result->command_list, 0) | ->points, c0_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 1)->points, c1_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 2)->points, c2_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 3)->points, c3_points)
COPY_POINTS(gdraw_comman... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | TEST_PBI_FILE_FMT(4bitpalette) | |
/*
* 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 s_dnd_active;
} | |
{
action_menu_layer_set_short_items(&data->action_menu_layer, NULL, 0, 0);
action_menu_layer_set_items(&data->action_menu_layer, cur_level->items, cur_level->num_items,
cur_level->default_selected_item, cur_level->separator_index);
} |
crumbs_layer_set_level(&data->crumbs_layer, vm->num_dots);
}
static void prv_next_level_anim_stopped(Animation *anim, bool finished, void *context) {
// update the view model
AnimationContext *anim_ctx = (AnimationContext*) context;
ActionMenuData *data = window_get_user_data((Window*) anim_ctx->window);
if... | |
, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi")) | ;
// SW = 11
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIG... |
_1.identity, sizeof(device_out));
// Re-pair device 1 again:
// In case the device is the same as the existing pairing, make sure the operation is "change"
// and not "delete" to avoid disconnecting just because the existing pairing is deleted.
// For bug details see https://pebbletechnology.atlassian.net/bro... | (bonding_sync_contains_pairing_info(&pairing_3, false), false) | ;
}
void test_bluetooth_persistent_storage_prf__get_ble_by_address(void) {
bool ret;
// Output variables
SMIdentityResolvingKey irk_out;
// Store a pairing
SMPairingInfo pairing = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,... |
limitations under the License.
*/
#include "launcher_app_glance_music.h"
#include "launcher_app_glance_structured.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "process_management/app_install_manager.h"
#include "resource/resource_ids.auto.h"
#include "services/normal/music.h"
#include "syst... | launcher_app_glance_structured_get_data(structured_glance) | ;
PBL_ASSERTN(music_glance);
// Zero out the glance's subtitle buffer
const size_t music_glance_subtitle_size = sizeof(music_glance->subtitle);
memset(music_glance->subtitle, 0, music_glance_subtitle_size);
// Default to showing the default icon
uint32_t new_icon_resource_id = music_glance->default_icon_r... |
------------------------------------------------------------------------------------
//! 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) {
// If an alarm was... | {
timeline_event_refresh();
} | |
new_timer_start(s_app_data->timer[0], 100, stuck_timer_callback, cb_data, zero_flags);
PBL_ASSERTN(success);
}
// =================================================================================
void invaid_timer_id_menu_cb(int index, void *ctx) {
void *cb_data = 0;
uint32_t zero_flags = 0;
menu_callback_pre... | layer_add_child(window_layer, simple_menu_layer_get_layer(data->menu_layer)) | ;
}
// =================================================================================
// Deinitialize resources on window unload that were initialized on window load
static void prv_window_unload(Window *window) {
simple_menu_layer_destroy(s_app_data->menu_layer);
}
// =========================================... |
elled);
cl_assert_equal_i(r->state, RecognizerState_Cancelled);
cl_assert(!s_manager_state_change);
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Failed));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Possible));
cl_assert_passert(recognizer_transition_state(r, Recognize... | (cancelled, true) | ;
}
void test_recognizer__cancel(void) {
bool cancelled = false;
s_test_impl_data.cancelled = &cancelled;
RecognizerEvent rec_event = -1;
NEW_RECOGNIZER(r) = test_recognizer_create(&s_test_impl_data, &rec_event);
recognizer_cancel(r);
cl_assert_equal_i(r->state, RecognizerState_Possible);
cl_assert_equa... |
ad[i]->window);
applib_free(items_to_unload[i]);
}
}
static void prv_transition_to(Window *window_from, Window *window_to,
const WindowTransitionImplementation *transition) {
PBL_ASSERTN(window_to && transition);
WindowStack *window_stack = window_to->parent_window_stack;
Wind... | if (is_app_window && sys_app_is_watchface()) {
window_set_fullscreen(window, true);
} |
// If on the list of removed items for a window stack, remove from the removed items list
// as we want to add it back to the window stack.
if (window_stack_from) {
ListNode *node = list_find(window_stack_from->removed_list_head,
prv_filter_window_item_for_window, window);
if (node != NULL) {
... |
(data, length);
}
static void prv_endpoint_handler_b(
CommSession *session, const uint8_t *data, size_t length) {
s_handler_call_count[HandlerB]++;
prv_assert_data_matches_expected(data, length);
}
static void prv_endpoint_handler_c(
CommSession *session, const uint8_t *data, size_t length) {
s_handler_... | g_default_kernel_receiver_implementation.finish(receiver) | ;
data += 1;
}
prv_assert_no_handler_calls();
char expected_data = 'a';
for (int i = 0; i < batch_num; i++) {
prv_set_expected_data(&expected_data, 1);
fake_system_task_callbacks_invoke(1);
cl_assert_equal_i(s_handler_call_count[HandlerA], i + 1);
expected_data += 1;
}
cl_assert_equa... |
{ 1488, 392, -112},
{ 888, 352, -104},
{ 1040, 184, 0},
{ 1120, 16, 176},
{ 952, 96, 176},
{ 864, 128, 120},
{ 808, 96, 144},
{ 744, 40, 104},
{ 760, 48, 120},
{ 768, 40, 72},
{ 864, -8, 56},
{ 1048, -32, -48},
{ 1176, -144, 56},
{ 1608, -152, 192},
{ 1176, 12... | { 888, -8, 56},
{ 1008, -72, 24},
{ 1088, -160, 144},
// 33 seconds
{ 1880, -208, 360},
{ 1384, 288, 16},
{ 1232, 496, -272},
{ 1064, 312, 32},
{ 856, 160, 128},
{ 808, 144, 64},
{ 816, 168, 152},
{ 864, 344, -8},
{ 776, 288, 48},
{ 944, 368, -136},
{ 1136, 37... |
{ 1456, 264, 16},
{ 1792, 328, 24},
{ 1048, 416, -80},
{ 1056, 520, 56},
{ 1184, 176, 224},
{ 984, 128, 296},
{ 848, 144, 248},
{ 792, 112, 192},
{ 728, 8, 184},
// 36 seconds
{ 688, 56, 72},
{ 728, 160, 120},
{ 792, 104, 48},
{ 920, 56, 72},
{ 1080, 72, -16}... |
/*
* 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... | {
// Don't let the timer interrupt us while we're mucking with it.
__disable_irq();
if (!prv_check_timer_enabled()) {
periph_config_enable(TIM4, RCC_APB1Periph_TIM4);
TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM4, ENABLE);
// Prevent us from entering stop mode (and disabling the clock t... |
static void prv_button_interrupt_handler(bool *should_context_switch) {
prv_enable_button_timer();
}
static void clear_stuck_button(ButtonId button_id) {
__disable_irq();
const uint32_t button_counter_register = RTC_ReadBackupRegister(STUCK_BUTTON_REGISTER);
if (button_counter_register != 0) {
// Create... |
NUTES_PER_FILE_RECORD * SECONDS_PER_MINUTE);
for (int i = 0; i < ALG_MINUTES_PER_FILE_RECORD; i++) {
// Ask for the last ALG_MINUTES_PER_RECORD minutes of data
num_records = ALG_MINUTES_PER_FILE_RECORD;
time_t start_time = oldest_to_fetch + (i * SECONDS_PER_MINUTE);
time_t end_time = utc_sec;
Hea... | (60, 0, ActivitySleepStateLightSleep) | ;
// Wait long enough for our recompute sleep logic to run.
prv_feed_cannned_accel_data(SECONDS_PER_MINUTE * ACTIVITY_SESSION_UPDATE_MIN, 0,
ActivitySleepStateAwake);
// Advance to next day
prv_feed_cannned_accel_data(SECONDS_PER_HOUR * 24, 0, ActivitySleepStateAwake);
// Feed... |
/*
* 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 (is_valid_tmp_path("/tmp")) {
strncpy(buffer, "/tmp", length);
return 0;
} | |
atic void prv_exit_stationary(void) {
accel_enable_high_sensitivity(false);
services_set_runlevel(RunLevel_Normal);
}
static void prv_enter_peek_state(void) {
analytics_event_stationary_state_change(rtc_get_time(), StationaryAnalyticsExitToPeek);
//! When exiting out of stationary, we aren't certain that this ... | (s_current_state < ARRAY_LENGTH(prv_action_jump_table)) | ;
prv_action_jump_table[s_current_state](action);
}
static void prv_setup_callback_info(void) {
//! Timer callback to check whether the watch is stationary every minute
s_accel_stationary_timer_info = (RegularTimerInfo) {
.cb = prv_stationary_check_timer_cb
};
//! Button press events
s_button_event_in... |
//////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_rect(ctx, &GRect(4, 2, 16, 8));
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_ant... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi")) | ;
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, "fill_rect_across_nx_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&lay... |
M_MAX_LV, 0x6);
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_IDLE_HYST, 0x4);
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_IDLE_MIN, 0x10);
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_TEST_1_REG, DCDC_TEST_REG, 0x0);
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_BROWN_OUT_IRQ_CLEAR, 0x0);
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_V18P_TIMEOUT_IRQ_CLEAR, 0x0);
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_VDD_TIMEOUT_IRQ_CLEAR, 0x0);
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_V18_TIMEOU... |
REG_SETF(CRG_TOP, AON_SPARE_REG, OSC16_SH_DISABLE, 0x0); // GUESS
REG_SETF(CRG_TOP, AON_SPARE_REG, EN_BATSYS_RET, 0x0); // GUESS
REG_SETF(CRG_TOP, AON_SPARE_REG, EN_BUSSYS_RET, 0x0); // GUESS
// QSPIC
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_DIS_CS, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_EN_CS, 0... |
10);
// Cancel wakeup event
sys_wakeup_delete(wakeup_id);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST);
// Schedule again
wakeup_id = sys_wakeup_schedule(sys_get_time() + 10, 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + 10);
// Cancel all wakeup events
... | (first_wakeup_id) | , first_event);
TimerID first_timer = wakeup_get_current();
// Schedule another a minute away
time_t second_event = sys_get_time() + WAKEUP_EVENT_WINDOW * 2;
WakeupId second_wakeup_id = sys_wakeup_schedule(second_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(second_wakeup_id), second_event);
Timer... |
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... | i2c_use(I2C_LED) | ;
write_register(RegPwmOut4, red);
write_register(RegPwmOut6, blue);
write_register(RegPwmOut5, green);
write_register(RegDataUpdate, 0xaa);
i2c_release(I2C_LED);
if (s_backlight_off && s_rgb_current_color == LED_BLACK) {
prv_shutdown(true);
}
}
uint32_t led_controller_rgb_get_color(void) {
ret... |
/*
* 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... | (
structured_glance, prv_music_glance_subtitle_dynamic_text_node_update) | ;
}
static void prv_destructor(LauncherAppGlanceStructured *structured_glance) {
LauncherAppGlanceMusic *music_glance =
launcher_app_glance_structured_get_data(structured_glance);
if (music_glance) {
event_service_client_unsubscribe(&music_glance->music_event_info);
kino_reel_destroy(music_glance->ic... |
if (s_hci_cmd_info.write_offset == (HCI_CMD_HEADER_LEN + s_hci_cmd_info.param_len)) {
// We have found an HCI command, forward to the dialog chip
uint8_t payload_len = s_hci_cmd_info.write_offset;
uint8_t buf_len = payload_len + 1;
uint8_t *buf = kernel_zalloc_check(buf_len);
buf[0] = payload_len;... | prv_in_test_mode() | ) {
return;
}
uint8_t test_end_cmd[] = {
HCI_CMD_START,
HCI_LE_TEST_STOP_OCF,
OPCODE_TEST_CMDS_MSB,
0x0 // param length
};
hc_endpoint_enqueue_hci_cmd(test_end_cmd, sizeof(test_end_cmd));
}
void bt_driver_register_response_callback(BTDriverResponseCallback callback) {
s_response_callback... |
/
void test_timeline_resources__get_id_system(void) {
AppResourceInfo res_info;
// Calling the function with an invalid TimelineResourceId should return false
cl_assert(!timeline_resources_get_id_system(TIMELINE_RESOURCE_INVALID, TimelineResourceSizeTiny,
TimelineResourceTestAppId_ValidApp, &res_inf... | cl_assert_passert(timeline_resources_get_id(&timeline_res_info, TimelineResourceSizeCount,
&res_info)) | ;
cl_assert_passert(timeline_resources_get_id(NULL, TimelineResourceSizeTiny, &res_info));
cl_assert_passert(timeline_resources_get_id(&timeline_res_info, TimelineResourceSizeTiny, NULL));
// Set the TimelineResourceInfo to have the UUID of an app with an invalid LUT
const TimelineResourceTestAppData *app_with... |
/*
* 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... | {
pwr_access_backup_domain(true);
if (!boot_bit_test(BOOT_BIT_INITIALIZED)) {
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, BOOT_BIT_INITIALIZED);
}
} | |
ache 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 dis... | (ANALYTICS_DEVICE_METRIC_BT_OFF_TIME, AnalyticsClient_System) | |
s_done_service_discovery = true;
} else {
return false;
}
} else if (attr == ManagementServiceAttributeNotificationInfo) {
if (length != sizeof(NotificationInfoData)) {
PBL_LOG(LOG_LEVEL_WARNING, "Notification info response is invalid length: %"PRIu32, length);
return false;
}
co... | if (success && (header->error != GenericServiceResultOk)) {
// The response was completely valid, but there was a non-Ok error returned
success = false;
// translate the error code to the appropraite SmartstrapResult
if (header->error == GenericServiceResultNotSupported) {
result = SmartstrapResul... |
const uint16_t service_id = s_read_info.service_id;
const uint16_t attribute_id = s_read_info.attribute_id;
if (success) {
length = header->length;
} else {
length = 0;
}
if (service_id <= ReservedServiceMax) {
// This is a reserved service read which we should handle internally
void *dat... |
tate != prev_button_state) {
system_reset();
}
delay_ms(10);
}
}
static void prv_print_reset_reason(void) {
dbgserial_print("Reset Register ");
dbgserial_print_hex(RCC->CSR);
dbgserial_newline();
if (RCC_GetFlagStatus(RCC_FLAG_BORRST) == SET) {
dbgserial_putstr("Brown out reset");
}
}
/... | is_flash_broken() | ) {
prv_sad_watch(ERROR_BAD_SPI_FLASH);
}
boot_bit_dump();
// If the recovery firmware crashed at start-up, the watch is now a
// $150 brick. That's life!
if (prv_check_for_recovery_start_failure()) {
boot_bit_clear(BOOT_BIT_RECOVERY_START_IN_PROGRESS);
prv_sad_watch(ERROR_CANT_LOAD_FW);
}
... |
al.h"
#include "stubs_shell_prefs.h"
#include "stubs_sleep.h"
#include "stubs_syscalls.h"
#include "stubs_task_watchdog.h"
#include "stubs_unobstructed_area.h"
#include "stubs_window_manager.h"
#include "stubs_window_stack.h"
// Setup and Teardown
////////////////////////////////////
typedef struct OptionMenuTestData... | (false /* icons_enabled */, "Special Height",
true /* special_height */) | ;
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE();
}
void test_option_menu_window__long_title_special_height_icons(void) {
prv_create_menu_and_render_long_title(true /* icons_enabled */, "Special Height",
true /* special_height */);
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_F... |
rv_setup_peek_animation(TimelineAppData *data, TimelineResourceInfo *timeline_res,
bool use_pin) {
PeekLayer *peek_layer = &data->peek_layer;
#if ANIMATION_DOT
peek_layer_set_icon(peek_layer, timeline_res);
#elif ANIMATION_SLIDE
GRect icon_from;
GRect icon_to;
const bool s... | (data, TimelineAppStateFarDayHidePeek) | ) {
// entering into a day that isn't today, setup the day separator
layer_set_hidden((Layer *)&data->peek_layer, true);
#if ANIMATION_DOT
timeline_layer_set_day_sep_frame(&data->timeline_layer, &data->timeline_layer.layer.frame);
#elif ANIMATION_SLIDE
GRect frame;
layer_get_frame(&data->timeline_la... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (worker_id == INSTALL_ID_INVALID) {
return 0;
}
const uint16_t current_worker_app_index =
app_menu_data_source_get_index_of_app_with_install_id(data->data_source, worker_id);
if (current_worker_app_index == MENU_INDEX_NOT_FOUND) {
return 0;
} else {
return current_worker_app_index + 1... |
// Gets the current chosen row index; i.e., the row which was most recently chosen by the user.
static int16_t prv_get_chosen_row_index(SettingsActivityTrackerData *data) {
const AppInstallId worker_id = worker_manager_get_current_worker_id();
return prv_get_chosen_row_index_for_id(data, worker_id);
}
static int... |
/*
* 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 ((const PebbleProcessMdResource*) md)->name;
} |
return ((const PebbleProcessMdSystem*) md)->name;
}
uint32_t process_metadata_get_size_bytes(const PebbleProcessMd *md) {
if (md->process_storage == ProcessStorageFlash) {
return ((const PebbleProcessMdFlash*) md)->size_bytes;
} else if (md->process_storage == ProcessStorageResource) {
return ((const Pe... |
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0x550055)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0000)).argb);
// contradiction with previous case - oh dear...
// cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xff5500)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GC... | for (GColor8Component i = 0; i < GCOLOR8_COMPONENT_NUM_VALUES; i++) {
cl_assert_equal_i(lookup_table_out[i].a, tint_color.a);
} |
}
static void prv_test_tint_using_luminance_and_perform_lookup_using_color_luminance(
GColor8 src_color, GColor8 tint_color, GColor8 expected_result_color) {
GColor8 lookup_table[GCOLOR8_COMPONENT_NUM_VALUES];
gcolor_tint_luminance_lookup_table_init(tint_color, lookup_table);
cl_assert(gcolor_equal(
g... |
/*
* 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... | kino_reel_custom_get_data(reel) | )->duration_ms;
}
static struct TestReelData *test_reel_data;
static KinoReelImpl *test_reel_impl = NULL;
static KinoReel *test_reel = NULL;
static KinoPlayer *test_player = NULL;
// Setup
void test_kino_player__initialize(void) {
test_reel_data = malloc(sizeof(TestReelData));
memset(test_reel_data, 0, sizeof(Tes... |
--------------------------------
// Bluetopia's Security Manager API
int GAP_LE_Authentication_Response(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR,
GAP_LE_Authentication_Response_Information_t *GAP_LE_Authentication_Information) {
return 0;
}
int GAP_LE_Diversify_Function(unsigned int Blueto... | (*IRK, s_fake_irk) | ;
}
void fake_GAPAPI_init(void) {
memset(&s_encrypted_device, 0, sizeof(s_encrypted_device));
s_is_le_advertising_enabled = false;
s_le_adv_connection_event_callback = NULL;
s_le_adv_connection_callback_param = 0;
memset(&s_ad_data, 0, sizeof(s_ad_data));
s_ad_data_length = 0;
s_le_create_connection_even... |
, RecognizerState_Failed);
// A second touchdown event occurs while recognizers are active. A different layer is touched, so
// the active recognizers on non-touched layers in the tree are cancelled
s_active_layer = &layer_b;
e.type = TouchEvent_Touchdown;
recognizer_manager_handle_touch_event(&e, &manager);... | ((int[]) { 4, 0, 1 }, 3, &s_recognizers_reset) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_p(manager.triggered, NULL);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerSt... |
/*
* 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_text_color(ctx, GColorBlack) | ;
}
graphics_fill_rect(ctx, &cell_layer->bounds);
}
// Menu Layer Handling
//////////////////////
static void prv_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *context) {
SettingsData *data = context;
const uint16_t row = cell_index->row;
SettingsCallbacks *callbacks = prv_get_current... |
(sizeof(SerializedSendTextContact) * NUM_SEND_TEXT_CONTACTS))
static uint8_t s_send_text_prefs[SEND_TEXT_DATA_LEN];
#define WEATHER_KEY ((uint8_t *)PREF_KEY_WEATHER_APP)
#define WEATHER_KEY_LEN (strlen(PREF_KEY_WEATHER_APP))
#define NUM_WEATHER_LOCATIONS (4)
#define WEATHER_DATA_SIZE (sizeof(SerializedWea... | cl_assert_equal_i(watch_app_prefs_db_delete(SEND_TEXT_KEY, SEND_TEXT_KEY_LEN), S_SUCCESS) | ;
cl_assert_equal_i(watch_app_prefs_db_get_len(SEND_TEXT_KEY, SEND_TEXT_KEY_LEN), 0);
cl_assert_equal_i(watch_app_prefs_db_insert(WEATHER_KEY, WEATHER_KEY_LEN, s_weather_prefs,
sizeof(s_weather_prefs)), S_SUCCESS);
cl_assert_equal_i(watch_app_prefs_db_delete(WEATHER_... |
/*
* 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... | worker_manager_get_task_context() | ->install_id == INSTALL_ID_INVALID) {
// No worker currently running, launch this one and make it the default
worker_manager_put_launch_worker_event(app_node->install_id);
worker_manager_set_default_install_id(app_node->install_id);
} else if (worker_manager_get_task_context()->install_id != app_n... |
// DMA Requests
static DMARequestState s_dbg_uart_dma_request_state;
static DMARequest DBG_UART_RX_DMA_REQUEST = {
.state = &s_dbg_uart_dma_request_state,
.stream = &DMA1_STREAM1_DEVICE,
.channel = 4,
.irq_priority = IRQ_PRIORITY_INVALID, // no interrupts
.priority = DMARequestPriority_High,
.type = DMAR... | IRQ_MAP(I2C1_EV, i2c_hal_event_irq_handler, &I2C_MAIN_BUS) | ;
IRQ_MAP(I2C1_ER, i2c_hal_error_irq_handler, &I2C_MAIN_BUS);
IRQ_MAP(I2C2_EV, i2c_hal_event_irq_handler, &I2C_2V5_BUS);
IRQ_MAP(I2C2_ER, i2c_hal_error_irq_handler, &I2C_2V5_BUS);
// VOLTAGE MONITOR DEVICES
static const VoltageMonitorDevice VOLTAGE_MONITOR_ALS_DEVICE = {
.adc = ADC2,
.adc_channel = ADC_Channel_12... |
/*
* 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... | GEdgeInsets(-overdraw) | |
/*
* 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_hrs.svc) | ;
}
static void prv_handle_subscribe(uint16_t conn_idx, bool enabled) {
Connection *connection = connection_by_idx(conn_idx);
if (!connection) {
return;
}
HcHrmSubscription subscription;
subscription.is_subscribed = enabled;
connection_get_address(connection, &subscription.device);
hc_endpoint_hrm_u... |
/*
* 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... | task_malloc_check(sizeof(uint16_t) + sizeof(char) * length) | ;
pstring->str_length = length;
strncpy(pstring->str_value, string, length);
}
return pstring;
}
void pstring_destroy_pstring16(PascalString16 *pstring) {
task_free(pstring);
}
void pstring_pstring16_to_string(const PascalString16 *pstring, char *string_out) {
strncpy(string_out, pstring->str_value, p... |
al_i(2, s_graphics_draw_text.call_count);
cl_assert_equal_rect((GRect(-4900, 100, large_int, large_int)),
s_graphics_draw_text.last_call.draw_text.box);
EXECUTE_SCRIPT(
"ctx.textAlign = 'right';\n"
"ctx.fillText('some text', 100, 100);\n"
);
cl_assert_equal_i(3, s_graphics_draw_... | jerry_create_string((jerry_char_t *)def->js_name) | ;
RockyAPISystemFontDefinition *cmp_def = NULL;
bool actual = prv_font_definition_from_value(name_js, &cmp_def);
cl_assert_equal_b(true, actual);
cl_assert_equal_s(cmp_def->res_key, def->res_key);
jerry_release_value(name_js);
def++;
}
}
void test_rocky_api_graphics__measure_text(void) {
pr... |
_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_left_clipped_aa.${BIT_DEPTH_NAME}.pbi"));
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_house_path;
ctx.draw_state.clip_box = GRect(SCREEN_WIDTH / 2, 0, SCREEN_WIDTH / 2, SCREEN_HEIGHT);
... | prv_filled_update_proc(NULL, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_house_105_aa.8bit.pbi"));
// Safety
s_path_angle = 0;
}
void test_graphics_gpath_8bit__clipping_aa(void) {
// NOTE: This test verifies correct clipping of anti-aliased edges on gpaths, therefore
// it works only on 8bit
GContext ctx;
La... |
__vector_table_length,
},
{ .tag = MemoryRegionTag_Heap,
.start = &__heap_start,
.length = (uint32_t)__heap_length,
},
{ .tag = MemoryRegionTag_RwData,
.start = &__data_start__,
.length = (uint32_t)__rwdata_length,
},
{ .tag = MemoryRegionTag_StackAndBss,
.start = &__zero_initialized_sta... | prv_timer_check_delta(wd_start_ticks, TIMER0_1_S) | ) {
if (rx_mode) {
// Has a byte arrived?
if (!hw_spi_get_interrupt_status(s_spi->bus_id)) {
continue;
}
hw_spi_clear_interrupt(s_spi->bus_id);
buffer[rx_index++] = hw_spi_fifo_read8(s_spi->bus_id);
if (rx_index == sizeof(core_dump_connect_ping)) {
... |
/*
* 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 (task == PebbleTask_App) {
return app_state_get_tick_timer_service_state();
} else if (task == PebbleTask_Worker) {
return worker_state_get_tick_timer_service_state();
} else if (task == PebbleTask_KernelMain) {
return kernel_applib_get_tick_timer_service_state();
} else {
WTF;
} | |
_properties(const BTDriverConfig *config) {
ble_error_t e;
e = ble_gap_appearance_set(BLE_GAP_APPEARANCE_GENERIC_WATCH, ATT_PERM_READ);
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_appearance_set: %u", e);
}
#if 0 // FIXME: PBL-36556 -- How to configure the identity address?
const BTDevi... | hc_protocol_process_receive_buffer() | ;
extern bool should_log_about_mic_error(uint32_t *max_subsequent_failures);
uint32_t num_subsequent_failures = 0;
if (should_log_about_mic_error(&num_subsequent_failures)) {
hc_endpoint_analytics_log_mic_error_detected(num_subsequent_failures);
}
/* notified from BLE manager, can get event ... |
/*
* 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... | {
__enable_irq();
} |
return ret_value;
}
void rtc_set_time(time_t time) {
struct tm t;
gmtime_r(&time, &t);
// Just die if sanitization is necessary.
PBL_ASSERTN(!rtc_sanitize_struct_tm(&t));
RTC_TimeTypeDef rtc_time_struct = {
.RTC_Hours = t.tm_hour,
.RTC_Minutes = t.tm_min,
.RTC_Seconds = t.tm_sec
};
RTC_... |
oid prv_init_exti(ExtiHandlerCallback int_exti_cb) {
gpio_input_init(DIALOG_INT_CONFIG_PTR);
if (gpio_input_read(DIALOG_INT_CONFIG_PTR)) {
int_exti_cb(NULL);
}
exti_configure_pin(DIALOG_EXTI, ExtiTrigger_Rising, int_exti_cb);
exti_enable(DIALOG_EXTI);
}
void dialog_spi_set_pending_int(void) {
exti_set... | prv_enable_spi_clock() | ;
dialog_spi_assert_chip_select(true);
}
void dialog_spi_end_cmd(void) {
dialog_spi_assert_chip_select(false);
prv_disable_spi_clock();
}
uint8_t dialog_spi_send_and_receive_byte(uint8_t byte) {
return spi_ll_slave_read_write(DIALOG_SPI, byte);
}
void dialog_spi_transmit_data_no_wait(uint8_t *send, size_t bu... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("---Shared PRF Contents---\n------------------------\n") | ;
char buf[DISPLAY_BUF_LEN];
SMPairingInfo pairing_info;
char name[BT_DEVICE_NAME_BUFFER_SIZE];
bool requires_address_pinning;
uint8_t flags;
if (shared_prf_storage_get_ble_pairing_data(&pairing_info, name, &requires_address_pinning,
&flags)) {
bluetooth_pe... |
d wake it up
// from sleep mode.
gpio_af_configure_fixed_output(&this->ck_gpio, false);
// Configure the data pin as an analog input, which is the lowest
// power state it can be in. The mic's data pin goes into Hi-Z mode
// when the mic is asleep, so the signal could float around and waste
// power if the... | MIN(MAX_VOLUME, volume) | ;
}
bool mic_start(MicDevice *this, MicDataHandlerCB data_handler, void *context,
int16_t *audio_buffer, size_t audio_buffer_len) {
PBL_ASSERTN(this->state->initialized);
mutex_lock_recursive(this->state->mic_mutex);
bool success = false;
if (this->state->running) {
goto unlock;
}
cir... |
(BUTTON_ID_DOWN, prv_raw_down_handler, prv_raw_up_handler, NULL) | ;
}
////////////////////////////////////////////////////////////
// Windows
static void prv_update_background_image_and_url_text(RecoveryFUAppData *data) {
uint32_t icon_res_id;
const char *url_string;
GColor background;
GRect kino_area;
int16_t icon_x_offset;
int16_t icon_y_offset;
int16_t text_y_offse... | |
(dest, (utf8_t *)"\xf0", 5) | ;
cl_assert_equal_i(copied, 0);
cl_assert_equal_s((char *)dest, "");
}
void test_utf8__invalid_character(void) {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)"\xf0hi", 5);
cl_assert_equal_i(copied, 0);
cl_assert_equal_s((char *)dest, "");
}
void test_utf8__g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.