prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
onding_sync.h>
#include <bluetooth/connectability.h>
#include <bluetooth/features.h>
#include <btutil/bt_device.h>
#include <btutil/sm_util.h>
#ifdef UNITTEST
// Let the unittest define this using a header override:
# include "services/normal/bluetooth/bluetooth_persistent_storage_unittest_impl.h"
#else
# if BT_CONT... | {
BTDeviceAddress addr;
SM128BitKey key;
char classic_name[BT_DEVICE_NAME_BUFFER_SIZE];
uint8_t platform_bits;
if (bt_persistent_storage_get_bt_classic_pairing_by_id(
id, &addr, &key, classic_name, &platform_bits)) {
shared_prf_storage_store_bt_classic_pairing_data(
&addr... | else if (type == BtPersistBondingTypeBLE) {
SMPairingInfo pairing_info;
char ble_name[BT_DEVICE_NAME_BUFFER_SIZE] = { };
bool requires_address_pinning = false;
uint8_t flags = 0;
if (prv_bt_persistent_storage_get_ble_smpairinginfo_by_id(
id, &pairing_info, ble_name, &requires_address_pi... |
r_ui_window_get(PBL_IF_COLOR_ELSE(GColorRed, GColorDarkGray));
app_window_stack_push(spinner_window, false /* animated */);
}
data->spinner_is_visible = true;
data->spinner_should_close = false;
}
static void prv_hide_spinner(RecoveryFUAppData *data) {
data->spinner_should_close = true;
data->spinner_clo... | (&data->kino_layer, icon_reel, /* take_ownership */ true) | ;
// Configure the url text layer
data->url_text_layer.layer.frame.origin.y = text_y_offset;
text_layer_set_text(&data->url_text_layer, url_string);
}
static void prv_update_name_text(RecoveryFUAppData *data) {
const GAPLEConnection *gap_conn = gap_le_connection_any();
// Set the name text
if (data->is_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... | ("SO on %s", pcTaskName) | ;
// TODO: Register which stack had the overflow.
RebootReason reason = {
.code = RebootReasonCode_StackOverflow,
};
reboot_reason_set(&reason);
while (1) {};
}
/**
* @brief Application tick hook
*/
void vApplicationTickHook( void )
{
#if mainCHECK_INTERRUPT_STACK == 1
extern unsigned long _pvHeapS... |
/*
* 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_ad_data->data, data, length) | |
R
ASSERT_CALLED(graphics_internal_circle_quadrant_fill_aa(&context, GPoint(50, 50), 10, GCornersAll));
#else
ASSERT_CALLED(graphics_circle_fill_non_aa(&context, GPoint(50, 50), 10));
#endif
setup_test(&context, true, 5, GColorBlack, GColorBlack, false);
graphics_fill_round_rect(&context, &GRect(20, 80, 40, 10)... | GPoint(50, 50) | |
/worker
static void convert_to_process_offset(bool known, uintptr_t* pc, PebbleTask task) {
if (known) {
*pc = (uintptr_t) process_manager_address_to_offset(task, (void*) *pc);
}
}
static CrashInfo s_current_app_crash_info;
static void setup_log_app_crash_info(CrashInfo crash_info) {
// Write the informatio... | make_crash_info_pc_lr(stacked_pc, stacked_lr) | ;
setup_log_app_crash_info(crash_info);
// Alright, now to neuter the current task. We're going to do some work to make it so when we return from
// this fault handler we'll end up in a perfectly safe place while we wait to die.
SCB->BFAR &= 1 << 7; // Clear Bus Fault Address Register "address is valid" bit
... |
ICK_DEFAULT_MIN = 2;
//! Default timeout after which looking for follow up clicks will be stopped
static const uint32_t MULTI_CLICK_DEFAULT_TIMEOUT_MS = 300;
//! Default delay before long click is fired
static const uint32_t LONG_CLICK_DEFAULT_DELAY_MS = 400;
typedef enum {
ClickHandlerOffsetSingle = offsetof(ClickC... | if (recognizer->config.multi_click.max == 0) {
return prv_multi_click_get_min(recognizer);
} |
return recognizer->config.multi_click.max;
}
static uint32_t prv_multi_click_get_timeout(ClickRecognizer *recognizer) {
if (false == prv_is_multi_click_enabled(recognizer)) {
return 0;
}
if (recognizer->config.multi_click.timeout == 0) {
return MULTI_CLICK_DEFAULT_TIMEOUT_MS;
}
return recognizer->... |
/*
* 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 (text_layer == NULL) {
return;
} |
text_layer->text = text;
layer_mark_dirty(&text_layer->layer);
}
const char* text_layer_legacy2_get_text(TextLayerLegacy2 *text_layer) {
if (text_layer == NULL) {
return NULL;
}
return text_layer->text;
}
void text_layer_legacy2_set_background_color_2bit(TextLayerLegacy2 *text_layer, GColor2 color) {
... |
nPrivate *)node;
ParentChildInfo *info = (ParentChildInfo *)data;
return animation->parent == info->parent && animation->child_idx == info->child_idx;
}
static AnimationPrivate* prv_find_animation_by_parent_child_idx(AnimationState *state,
AnimationPrivate *parent, int child_idx) {
if (!parent) {
... | (state, child, true, true) | ;
if (child_duration == PLAY_DURATION_INFINITE) {
return PLAY_DURATION_INFINITE;
}
max_child_duration = MAX(max_child_duration, child_duration);
}
duration += max_child_duration;
} else {
PBL_ASSERTN(animation->type == AnimationTypePrimitive);
duration += animation->duration... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return true;
} |
static BTBondingID prv_next_id(void) {
return s_next_id++;
}
static bool prv_find_by_id(ListNode *found_node, void *data) {
BTBondingID bonding_id = (BTBondingID) data;
const FakeBonding *bonding = (const FakeBonding *) found_node;
return (bonding->id == bonding_id);
}
bool bt_persistent_storage_get_ble_pai... |
_incoming_calls,
DEFAULT_VIBE_SCORE_INCOMING_CALLS);
s_vibe_score_alarms = prv_return_default_if_invalid(s_vibe_score_alarms,
DEFAULT_VIBE_SCORE_ALARMS);
}
static void prv_set_vibe_scores_based_on_lega... | (s_dnd_schedule_keys[WeekendSchedule].schedule_pref_key,
s_dnd_schedule[WeekendSchedule].schedule) | ;
RESTORE_PREF(s_dnd_schedule_keys[WeekendSchedule].enabled_pref_key,
s_dnd_schedule[WeekendSchedule].enabled);
RESTORE_PREF(PREF_KEY_FIRST_USE_COMPLETE, s_first_use_complete);
RESTORE_PREF(PREF_KEY_NOTIF_WINDOW_TIMEOUT, s_notif_window_timeout_ms);
#undef RESTORE_PREF
prv_migrate_legacy_dnd_sche... |
shed_v1(BinLogMessage_Unhashed_v1 *msg);
#endif
void hc_endpoint_logging_handler(const HcProtocolMessage *msg) {
switch (msg->command_id) {
case HcMessageID_Logging_LogMsg: {
BinLogMessage_Header *header = (BinLogMessage_Header *)msg->payload;
switch (header->version) {
case BINLOGMSG_V... | {
// Force NULL termination on the filename
char filename[17] = { 0 };
memcpy(filename, msg->body.filename, 16);
pbl_log(msg->body.level, filename, msg->body.line_number, (const char *)msg->body.string);
} |
#endif // PBL_LOGS_HASHED
|
fo, ARRAY_LENGTH(sg_info));
}
static void prv_read_modify_write(uint8_t reg, uint8_t value, uint8_t mask) {
uint8_t new_val = bmi160_read_reg(reg);
new_val &= ~mask;
new_val |= value;
prv_write_reg(reg, new_val);
}
static void prv_run_command(uint8_t command) {
prv_write_reg(BMI160_REG_CMD, command);
if (... | (sensor_timestamp_after) | |
RAY_LENGTH(s_message_app_info_dict),
(uint8_t *)s_message_app_info_dict);
}
return BTErrnoOK;
}
// else: notif request
uint32_t uid = ((GetNotificationAttributesMsg *)buffer)->notification_uid;
s_num_requested_notif_attributes++;
if (uid == comple_dict_uid) {... | (s_message_app_info_dict) | ,
(uint8_t *)s_message_app_info_dict);
s_num_ds_notifications_received++;
}
return BTErrnoOK;
}
// Tests
///////////////////////////////////////////////////////////
#define TEST_START FILESYSTEM_FILE_TEST_SPACE_BEGIN
#define TEST_SIZE (FILESYSTEM_FILE_TEST_SPACE_END ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&data->time_text_layer.layer.frame) | ;
const int line_top_margin = 14;
const int line_stroke_width = 2;
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_rect(ctx, &GRect(0, time_max_y + line_top_margin, DISP_COLS, line_stroke_width));
#endif
}
static void prv_update_time(SdkAppData *data) {
#if CAPABILITY_HAS_SDK_SHELL4
clock_co... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (af_config->gpio) | |
st->list_node, prv_find_name, "a_test_1"));
cl_assert(list_find(&dir_list->list_node, prv_find_name, "b_test_0"));
cl_assert(list_find(&dir_list->list_node, prv_find_name, "b_test_1"));
pfs_delete_file_list(dir_list);
// Do another search using a filter
dir_list = pfs_create_file_list(prv_filename_filter_a_... | for (int i = 5; i > 0; --i) {
char filename[20];
sprintf(filename, "test%d", i);
int fd = pfs_open(filename, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd > 0);
} |
}
|
{
Recognizer *triggered = prv_dispatch_touch_event_to_all_recognizers(manager, touch_event);
prv_cleanup_state_change(manager, triggered);
} |
}
void recognizer_manager_init(RecognizerManager *manager) {
PBL_ASSERTN(manager);
*manager = (RecognizerManager) {
.state = RecognizerManagerState_WaitForTouchdown
};
}
void recognizer_manager_set_window(RecognizerManager *manager, Window *window) {
PBL_ASSERTN(manager);
manager->window = window;
}
v... | |
MQuality_Good);
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 20);
cl_assert_equal_i(duration_s, 20);
cl_assert_equal_i(bpm, 80);
cl_assert(workout_service_pause_workout(true... | (ActivitySessionType_Run) | );
// Start with only 10 steps and make sure it updates.
prv_inc_steps_and_put_event(10);
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 10);
// Increment a lot so we can mak... |
(
&step->arc.center, (uint16_t)step->arc.radius.raw_value, step->arc.angle_end) | ;
ASSIGN_P(pt_to);
break;
}
default:
WTF;
}
}
#undef ASSIGN_P
return jerry_create_undefined();
}
static void prv_fill_points(GPoint *points, size_t num) {
if (num < 3) {
return;
}
GPath path = {
.num_points = num,
.points = points,
};
GContext *const... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
RTC_WriteBackupRegister(RTC_BKP_FLASH_ERASE_PROGRESS, 0);
return S_SUCCESS;
} |
status_t flash_impl_get_nvram_erase_status(bool *is_subsector,
FlashAddress *addr) {
uint32_t reg = RTC_ReadBackupRegister(RTC_BKP_FLASH_ERASE_PROGRESS);
if (reg == 0) {
return S_FALSE;
}
*addr = reg & ERASE_ADDRESS_MASK;
*is_subsector = (reg & ERASE_IS_SUBSEC... |
/*
* 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 (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(start, size);
} | |
, 1248, -312},
{ 1184, 1248, -216},
{ 1136, 760, -184},
{ 1328, 816, -152},
{ 1656, 712, -64},
{ 1632, 448, -56},
// 18 seconds
{ 1240, 208, -136},
{ 1136, 304, -80},
{ 1192, 168, -88},
{ 1224, 240, -120},
{ 1296, 152, -72},
{ 1264, 104, -80},
{ 800, -480, 136},
{... | { 1344, 256, -352},
{ 1408, 232, -384},
{ 1408, 264, -176},
{ 1376, 528, -160},
{ 1536, 600, -200},
{ 1504, 920, -232},
{ 1328, 832, -360},
{ 1008, 944, -496},
{ 776, 1232, -584},
{ 1048, 1200, -464},
{ 1136, 928, -296},
{ 1344, 800, -248},
{ 1608, 728, -168},
{ 1... |
{ 1064, 144, -64},
{ 1040, 216, -112},
// 26 seconds
{ 1056, 128, -136},
{ 1072, 112, -208},
{ 792, -72, -192},
{ 688, -40, -152},
{ 608, 72, -392},
{ 1016, 192, -296},
{ 1400, 376, -432},
{ 1296, 256, -296},
{ 1096, 400, -240},
{ 1080, 392, -96},
{ 1312, 544, -1... |
4, 168)
#define OFFSET_DRAW_RECT_NO_CLIP GRect(6, 6, RECT_WIDTH, RECT_HEIGHT)
#define OFFSET_DRAW_RECT_CLIP_XY GRect(6, 6, RECT_WIDTH, RECT_HEIGHT)
#define OFFSET_DRAW_RECT_CLIP_NXNY GRect(-16, -16, RECT_WIDTH, RECT_HEIGHT)
void test_graphics_draw_round_rect_${BIT_DEPTH_NAME}__offset_aa_sw(void) {
GContext ctx;
... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi") | );
#endif
// AA = true, SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 5);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw5_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa... |
re-processor directive, skip it
if (token[0] == '#') {
continue;
}
// If this is a comment skip it
if (strcmp(token, "//") == 0) {
continue;
}
// If this is an AlgDlsMinuteData line, get the name
if (strcmp(token, "AlgDlsMinuteData") == 0) {
PBL_ASSERT(state->test_entry.n... | (token, "TEST_WEIGHT") | == 0) {
sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight);
} else if (strcmp(token, "TEST_NAME") == 0) {
sscanf(token + strlen(token) + 1, "%s", state->test_entry.name);
}
}
// If this is a "static AlgDlsMinuteData samples[] = {" line, skip it
if (strcmp(token,... |
/*
* 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 scroll_layer_is_instance_value == layer;
} |
TextLayer text_layer;
Window window;
void test_text_layer_flow__initialize(void) {
window = (Window){.layer.window = &window};
text_layer_init(&text_layer, &GRect(10, 20, 30, 40));
text_layer.layer.window = &window;
scroll_layer_is_instance_value = NULL;
}
void test_text_layer_flow__cleanup(void) {
}
void ... |
if (player && player->reel) {
const uint32_t from_value = kino_reel_get_elapsed(player->reel);
const uint32_t to_value = kino_reel_get_duration(player->reel);
prv_create_play_animation(player, from_value, to_value);
return (ImmutableAnimation *)player->animation;
} |
return NULL;
}
ImmutableAnimation *kino_player_create_play_section_animation(
KinoPlayer *player, uint32_t from_elapsed_ms, uint32_t to_elapsed_ms) {
if (player && player->reel) {
prv_create_play_animation(player, from_elapsed_ms, to_elapsed_ms);
return (ImmutableAnimation *)player->animation;
}
r... | |
attribute_get_string(attributes, layout->impl->attributes.secondary_id, "");
}
static void prv_peek_time_text_update(const LayoutLayer *layout_ref,
const LayoutNodeTextDynamicConfig *config,
char *buffer, bool render) {
const Timeline... | } else if (has_secondary) {
primary_node->node.margin.h = style->primary_secondary_peek_margin_h;
}
graphics_text_node_container_add_child(&vertical_node->container, &primary_node->node);
} |
if (has_secondary) {
LayoutNodeTextDynamicConfig secondary_config = {
.text.extent.node.type = is_peek ? LayoutNodeType_TextDynamic : LayoutNodeType_Text,
.update = prv_peek_time_text_update,
.buffer_size = ATTRIBUTE_SUBTITLE_MAX_LEN,
.text.style = LayoutContentSizeDefault,
.text.s... |
sion->transport);
}
return bt_driver_comm_is_current_task_send_next_task();
}
void prv_send_next(CommSession *session, bool is_callback) {
bt_lock();
{
if (!comm_session_is_valid(session)) {
// Session closed in the mean time
goto unlock;
}
// Flip the flag before the send_next callback... | app_manager_get_current_app_md() | ->uuid;
if (uuid_is_system(app_uuid) || uuid_is_invalid(app_uuid)) {
return NULL;
}
FindByAppUUIDContext ctx = (FindByAppUUIDContext) {
.app_uuid = app_uuid,
};
// Try most specific first:
CommSession *session = (CommSession *) list_find((ListNode *) s_session_head,
... |
p events
static void prv_session_do_double_tap_handle(PebbleEvent *e, void *context) {
AccelServiceState *state = context;
if (state->double_tap_handler != NULL) {
state->double_tap_handler(e->accel_tap.axis, e->accel_tap.direction);
}
}
// -------------------------------------------------------------------... | prv_is_session_task() | ;
}
applib_free(state->raw_data);
state->manager_state = NULL;
state->raw_data = NULL;
state->data_handler = NULL;
state->raw_data_handler = NULL;
state->raw_data_handler_deprecated = NULL;
}
// -----------------------------------------------------------------------------------------------
int accel_se... |
d, sizeof(enabled));
}
uint32_t backlight_get_timeout_ms(void) {
#if INFINITE_BACKLIGHT
return UINT32_MAX;
#endif
return s_backlight_timeout_ms;
}
void backlight_set_timeout_ms(uint32_t timeout_ms) {
prv_pref_set(PREF_KEY_BACKLIGHT_TIMEOUT_MS, &timeout_ms, sizeof(timeout_ms));
}
uint16_t backlight_get_intensit... | (PREF_KEY_QUICK_LAUNCH_SETUP_OPENED, &s_quick_launch_setup_opened,
sizeof(s_quick_launch_setup_opened)) | ;
}
}
uint8_t quick_launch_get_quick_launch_setup_opened(void) {
return s_quick_launch_setup_opened;
}
void watchface_set_default_install_id(AppInstallId app_id) {
Uuid uuid;
app_install_get_uuid_for_install_id(app_id, &uuid);
prv_pref_set(PREF_KEY_DEFAULT_WATCHFACE, &uuid, sizeof(uuid));
}
void welcome_se... |
ndpoint ID %u", message->endpoint_id);
return;
}
hc_protocol_cb_dispatch_handler(handler, message, should_free);
}
static bool prv_expectation_for_message_list_filter_cb(ListNode *found_node, void *data) {
HcExpectation *expectation = (HcExpectation *)found_node;
const HcProtocolMessage *message = (const ... | {
if (!expectation->request) {
// Semaphore already given or timed out, so skip it.
continue;
}
// Just give, the expectation + semaphore should get cleaned up automatically now.
xSemaphoreGive(expectation->semaphore);
expectation = (HcExpectation *) list_get_next(&expectation->node);
... |
prv_unlock();
}
|
NDS_PER_HOUR) + 1);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 11 H", time_buf);
// June 12th 2015, 01:30:00 (T-10:30:00)
rtc_set_time(event_time - (11 * SECONDS_PER_HOUR) + (30 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(tim... | clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("1 H AGO", time_buf);
// June 9th 2015, 13:29:30 (T+01:29:30)
rtc_set_time(event_time + SECONDS_PER_HOUR + (29 * SECONDS_PER_MINUTE) + 30);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 H AGO", time_buf);
// June 9th 20... |
er(const char *number, const char *name) {
return NULL;
}
void ancs_perform_action(uint32_t notification_uid, uint8_t action_id) {
}
void notifications_handle_notification_action_result(
PebbleSysNotificationActionResult *action_result) {
}
void notification_storage_set_status(const Uuid *id, uint8_t status) {... | timeline_exists(&id) | );
cl_assert_equal_i(pin_db_get(&id, &item_temp), -9);
}
|
/*
* 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) | |
e postMessage_HEADER_SIZE_BYTES (2 * sizeof(Tuple))
////////////////////////////////////////////////////////////////////////////////
// API: "postmessageerror" event
////////////////////////////////////////////////////////////////////////////////
static void prv_free_json_buffer_associated_with_postmessageerror_event... | (json_string) | + 1 /* trailing zero */;
char *const data_buffer = task_zalloc(str_size);
if (!data_buffer) {
return prv_create_oom_error();
}
jerry_string_to_utf8_char_buffer(json_string, (jerry_char_t *)data_buffer, str_size);
OutgoingObject * const obj = task_zalloc(sizeof(*obj));
if (!obj) {
task_free(data_bu... |
_region_from_file(fd);
}
// find a free region
if (!prv_update_gc_reserved_region()) {
PBL_LOG(LOG_LEVEL_ERROR, "No free flash erase units!");
// Note: It should not be possible for this to happen since start of day no
// files will be written on then flash. We could also try to force apps to
// ... | mutex_unlock_recursive(s_pfs_mutex) | ;
}
// pass in either 0 or 1 to as argument
void pfs_command_fs_format(const char *erase_headers) {
int write_erase_headers = atoi(erase_headers);
if (write_erase_headers == 1) {
pfs_format(true /* write erase headers */);
} else {
pfs_format(false /* write erase headers */);
}
}
void pfs_command_dump... |
log_file(0, prv_serial_dump_chunk_callback, prv_serial_dump_completed_callback);
prompt_command_continues_after_returning();
}
void command_log_dump_last(void) {
flash_dump_log_file(1, prv_serial_dump_chunk_callback, prv_serial_dump_completed_callback);
prompt_command_continues_after_returning();
}
void command... | profiler_init() | ;
// don't let context switches skew our results
__disable_irq();
char buf[80];
// test short delays because we should really be using psleep() for longer stalls!
for (uint32_t i = 1; i <= 1000; i += 2) {
profiler_start();
delay_us(i);
profiler_stop();
uint32_t duration_us = profiler_get_tot... |
/*
* 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... | {
*IRK_out = bonding->irk;
} | |
tateConnectedClosedAwaitingResetCompleteSelfInitiatedReset ||
client->state == StateConnectedClosedAwaitingResetCompleteRemoteInitiatedReset) {
if (LIKELY(packet->type == PPoGATTPacketTypeResetComplete)) {
prv_handle_reset_complete(client, packet, value_length - sizeof(PPoGATTPacket));
} else... | {
PBL_ASSERT_TASK(PebbleTask_KernelMain);
PBL_ASSERTN(!s_ppogatt_head);
s_timer_ticks = 0;
} | |
color(dialog, GColorGreen);
dialog_set_icon(dialog, data->resource_id_80);
dialog_show_status_bar_layer(dialog, true);
actionable_dialog_set_action_bar_type(actionable_dialog, DialogActionBarConfirm, NULL);
actionable_dialog_set_click_config_provider(actionable_dialog,
prv_confirm_config_provider);
app... | {
ExpandableDialog *expandable_dialog = expandable_dialog_create("Expandable Dialog");
Dialog *dialog = expandable_dialog_get_dialog(expandable_dialog);
dialog_set_text(dialog, data->lorem_ipsum);
dialog_set_background_color(dialog, GColorLightGray);
dialog_set_icon(dialog, data->resource_id_25);
dialog_sho... |
////////////////////////////////
// Expandable Dialog with multi line header
static void prv_show_expandable_dialog_long_header(DialogsData *data) {
ExpandableDialog *expandable_dialog = expandable_dialog_create("Expandable Dialog");
Dialog *dialog = expandable_dialog_get_dialog(expandable_dialog);
dialog_set_... |
not exposing the GTransform in the public SDK, so the setter and getter
// must be typecast
static const PropertyAnimationImplementation implementation = {
.base = {
.update = (AnimationUpdateImplementation) property_animation_update_fixed_s32_16,
},
.accessors = {
.setter = { .int16 = (cons... | (start_ms + duration/2) | ;
cl_assert(abs((int32_t)value - (int32_t)mid_value) < 10);
// End
prv_advance_to_ms_with_timers(start_ms + duration + MIN_FRAME_INTERVAL_MS*2);
cl_assert_equal_i(value, end_value);
#endif
}
// --------------------------------------------------------------------------------------
// Test a basic gcolor8 pro... |
service_state());
#endif
unobstructed_area_service_deinit(app_state_get_unobstructed_area_state());
}
Heap *app_state_get_heap(void) {
return &s_app_state_ptr->heap;
}
struct tm *app_state_get_gmtime_tm(void) {
return &s_app_state_ptr->gmtime_tm;
}
struct tm *app_state_get_localtime_tm(void) {
return &s_app_s... | PBL_ASSERTN(s_app_state_ptr->legacy2_framebuffer) | ;
return s_app_state_ptr->legacy2_framebuffer;
}
#if CAPABILITY_HAS_TOUCHSCREEN
RecognizerList *app_state_get_recognizer_list(void) {
return &s_app_state_ptr->recognizer_list;
}
#endif
RockyRuntimeContext *app_state_get_rocky_runtime_context(void) {
return s_app_state_ptr->rocky_runtime_context;
}
uint8_t *app... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
va_list args;
va_start(args, fmt);
app_log_vargs(log_level, src_filename, src_line_number, fmt, args);
va_end(args);
} | |
l on) {
if (on == s_power_enabled) {
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Setting accessory power %s", on?"on":"off");
s_power_enabled = on;
gpio_output_set(&BOARD_CONFIG_ACCESSORY.power_en, on);
}
bool accessory_is_present(void) {
accessory_set_power(true);
gpio_input_init_pull_up_down(&BOARD_CONFIG_... | accessory_use_dma(false) | ;
char buffer[50];
if (!success) {
prompt_send_response_fmt(buffer, sizeof(buffer), "FAILED: send timed-out");
} else if (s_num_test_bytes == 0) {
prompt_send_response_fmt(buffer, sizeof(buffer), "PASS!");
} else {
prompt_send_response_fmt(buffer, sizeof(buffer), "FAILED: %"PRId32" bytes left!",
... |
_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn /* sn */,
s_short_data_fragment, sizeof(s_short_data_fragment) - sn);
}
}
void test_ppogatt__retransmit_timed_out_data_packets_race_everything_acked_at_once(void) {
test_ppogatt__open_session_when_found_pebble_app();
T... | ppogatt_send_next(transport) | ;
}
for (int sn = 0; sn < num_packets; sn++) {
for (int i = 0; i < (PPOGATT_TIMEOUT_TICKS - 1); ++i) {
regular_timer_fire_seconds(PPOGATT_TIMEOUT_TICK_INTERVAL_SECS);
}
prv_receive_ack(s_characteristics[0][PPoGATTCharacteristicData], sn /* sn */);
}
fake_comm_session_process_send_next();
... |
pliance 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 CONDITIONS OF ANY KIND, either... | (confirmation_dialog) | ;
const char *fmt = i18n_get("Run %s instead of %s as the background app?", confirmation_dialog);
char *msg_buffer = task_zalloc_check(DIALOG_MAX_MESSAGE_LEN);
sniprintf(msg_buffer, DIALOG_MAX_MESSAGE_LEN, fmt, new_entry.name, old_entry.name);
confirmation_dialog_set_click_config_provider(confirmation_dialog, ... |
void *context) {
NotificationWindowData *data = &s_notification_window_data;
data->action_menu = NULL;
}
static void prv_select_single_click_handler(ClickRecognizerRef recognizer, void *data) {
NotificationWindowData *window_data = data;
TimelineItem *item = prv_get_current_not... | (&data->swap_layer) | |
hedules];
static const DoNotDisturbScheduleConfigKeys s_dnd_schedule_keys[NumDNDSchedules] = {
[WeekdaySchedule] = {
.schedule_pref_key = "dndWeekdaySchedule",
.enabled_pref_key = "dndWeekdayScheduleEnabled",
},
[WeekendSchedule] = {
.schedule_pref_key = "dndWeekendSchedule",
.enabled_pref_key = ... | {
s_vibe_score_notifications = prv_return_default_if_invalid(s_vibe_score_notifications,
DEFAULT_VIBE_SCORE_NOTIFS);
s_vibe_score_incoming_calls = prv_return_default_if_invalid(s_vibe_score_incoming_calls,
... |
static void prv_set_vibe_scores_based_on_legacy_intensity(VibeIntensity intensity) {
if (intensity == VibeIntensityHigh) {
s_vibe_score_notifications = VibeScoreId_StandardShortPulseHigh;
s_vibe_score_incoming_calls = VibeScoreId_StandardLongPulseHigh;
s_vibe_score_alarms = VibeScoreId_StandardLongPulse... |
data.num_samples != 20) {
PBL_LOG_COLOR(LOG_LEVEL_DEBUG, LOG_COLOR_CYAN, "Only got %"PRIu16" samples!",
hrm->debug->ppg_data.num_samples);
}
if (hrm->debug->accel_data.num_samples) {
HRMAccelData *d = &hrm->debug->accel_data;
dict_write_data(app_data->out_iter,... | (&window->layer, &bpm_tl->layer) | ;
bounds.origin.y += 35;
TextLayer *quality_tl = &app_data->quality_text_layer;
text_layer_init(quality_tl, &bounds);
text_layer_set_font(quality_tl, fonts_get_system_font(FONT_KEY_GOTHIC_18));
text_layer_set_text_alignment(quality_tl, GTextAlignmentCenter);
text_layer_set_text(quality_tl, "Loading...");
... |
pling_rate;
} else {
PBL_ASSERTN(highest_rate == ACCEL_SAMPLING_25HZ
&& state->sampling_rate == ACCEL_SAMPLING_10HZ);
new_num = 2;
new_den = 5;
}
if (state->subsample_numerator != new_num || state->subsample_denominator != new_den) {
state->subsample_numerator = new... | prv_set_restore_fifo_mode_timer() | ;
int max_loops = 12;
result = -3;
while (max_loops--) {
accel_data->timestamp = accel_get_latest_timestamp();
if (accel_data->timestamp != old_timestamp_ms) {
accel_get_latest_reading((AccelRawData *)accel_data);
result = 0;
break;
}
vTas... |
/*
* 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... | {
nf->value = new_val;
is_decreased = true;
} |
if (is_decreased) {
if (nf->callbacks.decremented != NULL) {
nf->callbacks.decremented(nf, nf->callback_context);
}
update_output_value(nf);
}
}
static void select_click_handler(ClickRecognizerRef recognizer, NumberWindow *nf) {
if (nf->callbacks.selected != NULL) {
nf->callbacks.selected(... |
t(uint8_t bus_idx) {
bus_disable(bus_idx);
bus_enable(bus_idx);
}
/*---------------INIT/USE/RELEASE/RESET FUNCTIONS----------------------*/
void i2c_init(void) {
for (uint32_t i = 0; i < ARRAY_LENGTH(i2c_buses); i++) {
i2c_buses[i].i2c = BOARD_CONFIG.i2c_bus_configs[i].i2c;
i2c_buses[i].user_count = 0;
... | PBL_ASSERTN(s_initialized) | ;
PBL_ASSERTN(device_id < BOARD_CONFIG.i2c_device_count);
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
// Take control of bus; only one task may use bus at a time
bus_lock(bus);
if (bus->user_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted access to d... |
This part of the API can be used for fairly straightforward SPI interactions
//! The assertion and deassertion of the SCS line is automatic
//
static bool prv_is_bidrectional(const SPISlavePort *slave) {
bool is_bidirectional = (slave->spi_direction == SpiDirection_2LinesFullDuplex) ||
(slave->spi_directi... | (slave->slave_state->initialized) | ;
PBL_ASSERTN(slave->slave_state->acquired);
spi_slave_wait_until_idle_blocking(slave);
prv_spi_clear_flags(slave->spi_bus);
spi_ll_slave_spi_disable(slave);
slave->slave_state->acquired = false;
prv_spi_disable_peripheral_clock(slave->spi_bus);
}
void spi_ll_slave_spi_enable(const SPISlavePort *slave) {
... |
//! coming back to the MCU (e.g. HcProtocol). When we disconnect, we call gatt_client_op_cleanup
//! which cleans up all of the memory for the nodes in the lists in `s_client_event_ctxs`.
//! Here, we check if the context related to the response coming in has already been cleaned up,
//! and if it has, we... | prv_read(characteristic, client,
gatt_client_characteristic_get_handle_and_connection,
PebbleBLEGATTClientEventTypeCharacteristicRead) | ;
}
void gatt_client_consume_read_response(uintptr_t object_ref,
uint8_t value_out[],
uint16_t value_length,
GAPLEClient client) {
bt_lock();
{
// For responses with 0 length, no ReadResponseDat... |
// This is a recursive function, so watch out!
// The recursion happens on the %R and %T cases only, and will only recurse once.
// So when adding stack variables, realize the stack usage may be doubled!
T_STATIC const char *prv_template_format_specifier(TemplateStringState *state, const char *input,
... | (*state->position) | ) {
return match;
}
PredicateCondition predicate_cond;
intmax_t predicate_value = 0;
// If this is a predicate, we need to evaluate it for a match.
match = prv_template_predicate_match(state, &predicate_cond, &predicate_value);
if (state->error->status != TemplateStringErrorStatus_Success) {
return... |
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat2BitPalette);
}
// Tests 4-bit palettized PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_4_bit(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(4bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, ... | (gbitmap_get_format(bitmap), GBitmapFormat2BitPalette) | ;
}
// Tests 4-bit transparent greyscale PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__greyscale_4_bit_transparent(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(4bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(4bitpalette)));
cl_assert... |
phics_context_set_stroke_color(ctx, GColorWhite);
graphics_draw_pixel(ctx, GPoint(5, 5));
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorClear);
graphics_draw_pixel(ctx, GPoint(5, 5));
}
void outside_x_layer_update_callback(Layer* me, GContext* ctx) {... | test_graphics_context_reset(&ctx, fb) | ;
layer_set_update_proc(&layer, &outside_x_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_x_y_offset_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_nx_y_layer_update_callback);
l... |
, .size = 132316 }, // priority rank 41
{ .id = 13, .priority = 45, .size = 214356 }, // priority rank 35
{ .id = 14, .priority = 47, .size = 258908 }, // priority rank 36
{ .id = 15, .priority = 19, .size = 117885 }, // priority rank 11
{ .id = 16, .priority = 42, .size = 167427 }, // priority rank 31
{ .id ... | cl_assert_equal_i(after_size, (before_size - to_free)) | ;
// test lowest priority's size
prv_cleanup();
to_free = 1; // should remove 207357
before_size = app_cache_get_size();
cl_assert(before_size >= to_free);
cl_assert_equal_i(S_SUCCESS, app_cache_free_up_space(to_free));
fake_system_task_callbacks_invoke_pending();
after_size = app_cache_get_size();
c... |
ack:
if (job->unscheduled_callback) {
job->unscheduled_callback(job, false /* completed */,
job->unscheduled_callback_data);
}
// In case the payload pointer of a future jobs ends up being the same, ensure the adv data
// will get updated in that case:
... | if (!s_gap_le_advert_is_initialized) {
goto unlock;
} |
// Call prv_perform_next_job() to trigger refreshing the configuration of
// the controller: it can advertise connectable packets again.
prv_perform_next_job(true /* force refresh, connectability mode changed */);
}
unlock:
bt_unlock();
}
GAPLEAdvertisingJobRef gap_le_advert_get_current_job(void) {
... |
info->key_len == sizeof(BTBondingID)) {
// Skip pairing entries
return;
}
// Re-write non-pairing entries
void *key = kernel_zalloc_check(info->key_len);
info->get_key(old_file, key, info->key_len);
void *data = kernel_malloc_check(info->val_len);
info->get_val(old_file, data, info->val_len);
... | info->get_key(file, &key[0], info->key_len) | ;
// prompt_send_response("Raw dump Key");
// PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG, (uint8_t *)&key, info->key_len);
uint8_t val[info->val_len];
memset(val, 0x0, info->val_len);
info->get_val(file, &val[0], info->val_len);
// prompt_send_response("Raw dump Value:");
// PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBU... |
/*
* 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, point) | |
= INT32_MIN,
};
HealthServiceStats weekend_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
HealthServiceStats yesterday_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
DayInWeek day_in_week = todays_day_in_week;
for (int i = 0; i < ACTIVITY_HISTORY_DAYS; i++, day_in_week--) {
day_in... | if (scope != HealthServiceTimeScopeOnce) {
// Only test scoped results. Non-scoped results for heart rate are computed using
// minute data and verified in the test_health__heart_rate_scope_once()
cl_assert_equal_i(result, exp_value);
} |
}
}
}
// --------------------------------------------------------------------------------------
// Test calls to compute heart rate stats with scope once. This ends up being implemented using
// the minute history
void test_health__heart_rate_scope_once(void) {
const time_t now = rtc_get_time();
const time... |
cel_Mode_Normal);
psleep(10);
// Set to 8g range, as required for the self test mode
prv_set_accel_scale(BMI160_SCALE_8G);
// Set ODR to 1600Hz
accel_set_sampling_interval(BMI160SampleRate_1600_HZ);
prv_accel_enable_undersampling(false);
PBL_LOG(LOG_LEVEL_DEBUG, "Self Test: Negative offset");
// Ena... | BMI160_DBG("PMU_STATUS: 0x%x ACC_CONF: 0x%x",
bmi160_read_reg(BMI160_REG_PMU_STATUS), bmi160_read_reg(BMI160_REG_ACC_CONF)) | ;
}
void bmi160_set_gyro_power_mode(BMI160GyroPowerMode mode) {
int retries = 20;
prv_run_command(BMI160_CMD_GYR_SET_PMU_MODE | mode);
while (retries--) {
uint8_t status = 0;
// can take up to 80ms to power up
status = bmi160_read_reg(BMI160_REG_PMU_STATUS) >> 2;
if (status == mode) {
break... |
_and_render(&health_data);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_sleep_summary_card__render_sleep_late_start_early_end2(void) {
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
HealthData health_data = {
// Used for text
.sleep_data[0] = (8 * ... | time_util_get_midnight_of(s_now_utc) | ;
HealthData health_data = {
// Used for text
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
.typical_sleep = (10 * SECONDS_PER_HOUR),
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
// Used for typical
.sleep_start = -4 * SECONDS_PER_HOUR,
.sleep_end = 4 * SECON... |
sert_equal_p(NULL, callback); // we're using the event service
cl_assert_equal_i(features, HRMFeature_BPM);
++s_hrm_manager_subscribe_with_callback_call_count;
s_last_session_ref = ++s_next_session_ref;
return s_last_session_ref;
}
static GAPLEConnection *s_connections[2];
GAPLEConnection *gap_le_connection_b... | {
// let cleanup & initialize do the work :)
} | |
ee_segments++;
/* Accumulate the total number of free Bytes. */
*free += heap_info_ptr->Size * ALIGNMENT_SIZE;
/* Check to see if the current fragment is larger that any */
/* we have seen and update the Max Value if it is larger. */
if(heap_info_ptr->Size > *max_free) {... | UTIL_ASSERT(heap_contains_address(heap, ptr)) | ; // <ptr> not in range (heap->begin, heap->end)
heap_lock(heap);
{
/* Get a pointer to the Heap Info. */
HeapInfo_t *heap_info_ptr = HEAP_INFO_FOR_PTR(ptr);
/* Verify that this segment is allocated. */
if (!heap_info_ptr->is_allocated) {
// I... |
----------------------------------------
// Test getting the sleep sessions
void test_activity__get_sleep_sessions(void) {
int32_t value;
// 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_trackin... | for (int j = 0; j < num_records; j++) {
printf("\nRecord:%d, steps: %d", j, (int)received_records[j].steps);
} |
// Verify the contents of the records
for (int j = 0; j < num_records; j++) {
cl_assert_equal_i(received_records[j].steps,
(start_time + (j * SECONDS_PER_MINUTE)) % 255);
}
// Advance another minute.
rtc_set_time(utc_sec + (i * SECONDS_PER_MINUTE));
}
}
// ------... |
layer->selection.index;
if (!provide_correct_selection_index) {
menu_layer->selection.index.section = MENU_INDEX_NOT_FOUND;
}
const int16_t result = menu_layer->callbacks.get_cell_height(menu_layer, cell_index,
menu_layer->callback_conte... | grect_equal(&cell_layer->frame, &menu_layer->inverter.layer.frame) | ;
const bool partial = grect_overlaps_grect(&cell_layer->frame, &menu_layer->inverter.layer.frame);
if (fully_covered || !partial) {
prv_prepare_and_draw_row(ctx, menu_layer, cell_layer, cursor, fully_covered);
} else {
// Render the full cell without highlight
prv_prepare_and_draw_row(ctx, menu_laye... |
}
break;
case WordStateJoining:
if (codepoint == NEWLINE_CODEPOINT) {
new_state = WordStateEnd;
} else if (codepoint_is_ideograph(codepoint)) {
new_state = WordStateIdeograph;
} else if (codepoint == WORD_JOINER_CODEPOINT) {
new_state = WordStateJoining;
} ... | if (!iter_next(char_iter)) {
return false;
} |
}
while (codepoint_is_zero_width(utf8_iter_state->codepoint)) {
if (utf8_iter_state->codepoint == 0) {
PBL_ASSERTN(utf8_iter_state->current == utf8_iter_state->bounds->end);
return false;
}
if (!iter_next(char_iter)) {
break;
}
}
return true;
}
static bool prv_line_iter_is... |
/*
* 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... | (test0, 0, 0, 1, 1) | == 1);
cl_assert(raw_image_get_value_for_bitdepth(test0, 1, 0, 1, 1) == 1);
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 1) == 1);
cl_assert(raw_image_get_value_for_bitdepth(test1, 0, 3, 1, 4) == 12);
cl_assert(raw_image_get_... |
const time_t jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 16:00:00
// Now - one day
const time_t event_time = jun10th_noon_2015 - SECONDS_PER_DAY + (4 * SECONDS_PER_HOUR);
time_t format_time;
clock_set_24h_style(true);
//... | clock_get_relative_daypart_string(timestamp, 32 /* hours_in_the_future */) | ;
cl_assert_equal_s(tomorrow_afternoon, daypart_string);
// (6pm tomorrow) time tomorrow between 6pm and 9pm is tomorrow evening
daypart_string = clock_get_relative_daypart_string(timestamp, 38 /* hours_in_the_future */);
cl_assert_equal_s(tomorrow_evening, daypart_string);
// (9pm tomorrow) time tomorrow b... |
/*
* 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... | utf8_get_bounds(&success, "A") | ;
cl_assert(utf8_bounds.end - utf8_bounds.start == 1);
cl_assert(success);
// Init mutable types
utf8_iter_init(&utf8_iter, &utf8_iter_state, &utf8_bounds, utf8_bounds.start);
// Tests
cl_assert(!iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
}
//! Decod... |
l, GPoint target) {
return false;
}
// Helper Functions
/////////////////////
#include "../graphics/test_graphics.h"
#include "../graphics/util.h"
// Setup and Teardown
////////////////////////////////////
static FrameBuffer *fb = NULL;
static GBitmap *s_dest_bitmap;
// To easily render multiple windows in a si... | (buffer, sizeof(buffer), "%d%% Battery", percent) | ;
dialog_set_text(dialog, buffer);
dialog_set_icon(dialog, RESOURCE_ID_BATTERY_ICON_LOW_LARGE);
prv_push_and_render_simple_dialog(dialog);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_simple_dialog__ping(void) {
SimpleDialog *simple_dialog = simple_dialog_create("Ping");
Dialog *dia... |
h) {
PulseTransferFD *pulse_fd = prv_get_fd(cmd, length);
if (!pulse_fd) {
// prv_get_fd has already sent an error response
return;
}
uint32_t bytes_read = 0;
const unsigned int chunk_size = 128;
uint8_t buffer[chunk_size];
uint32_t crc = crc32(0, NULL, 0);
while (bytes_read < cmd->crc.length)... | {
BulkIOPacketCallbackData *data = kernel_malloc_check(length + sizeof(length));
data->length = length;
memcpy(&data->packet, packet, length);
system_task_add_callback(prv_handle_packet, data);
} |
void pulse2_bulkio_link_open_handler(void) {
}
void pulse2_bulkio_link_closed_handler(void) {
for (int i = 0; i < MAX_PULSE_FDS; i++) {
if (s_transfer_fds[i].impl) {
PulseTransferFD *pulse_fd = &s_transfer_fds[i];
pulse_fd->impl->close_proc(pulse_fd->domain_state);
prv_free_fd(i);
}
}
}... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (value_length_out) {
syscall_assert_userspace_buffer(value_length_out, sizeof(*value_length_out));
} |
}
GATTBufferedNotificationHeader header;
const bool has_notification = gatt_client_subscriptions_get_notification_header(GAPLEClientApp,
&header);
if (has_notification) {
if (characteristic_out) {
*characteristic_out = ... |
_LEVEL_ERROR, "Error parsing attributes: %u, %u", did_get_attrs, error);
prv_reset_and_next();
return;
}
const ANCSAttribute *app_id = s_ancs_client->attributes[FetchedNotifAttributeIndexAppID];
ANCSAttribute *app_name = ancs_app_name_storage_get(app_id);
if (app_name) {
prv_put_ancs_message(&app_n... | {
const BTErrno e = gatt_client_subscriptions_subscribe(characteristics[c],
BLESubscriptionNotifications,
GAPLEClientKernel);
PBL_ASSERTN(e == BTErrnoOK);
} | |
R_HOUR);
clock_get_month_named_date(time_buf, sizeof(time_buf), format_time);
cl_assert_equal_s("June 7", time_buf);
// June 16th 2015, 13:00:00 (-07:00:00)
format_time = event_time + (7 * SECONDS_PER_DAY) + (1 * SECONDS_PER_HOUR);
clock_get_month_named_date(time_buf, sizeof(time_buf), format_time);
cl_ass... | (timestamp, 28 /* hours_in_the_future */) | |
/*
* 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... | gbitmap_pbi_eq(bitmap, TEST_PBI_FILE) | );
}
// Tests 2-bit palettized PBI loading into gbitmap
// Result:
// - gbitmap matches platform loaded PBI
void test_pbi__color_2_bit(void) {
GBitmap *bitmap = setup_pbi_test(TEST_PBI_FILE);
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE));
}
// Tests 4-bit palettized PBI loading into gbitmap
// Result:
// -... |
c FrameBuffer *fb = NULL;
GContext *graphics_context_get_current_context(void) {
return &s_ctx;
}
void test_timeline_layouts__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
const GContextInitializationMode context_init_mode = GContextInitialization... | TEST_PBI_FILE_X(details1) | ));
// Round only needs to scroll down once to see everything
#if !PBL_ROUND
prv_construct_and_render_layout(&config, 2);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE_X(details2)));
#endif
}
void test_timeline_layouts__weather(void) {
const TimelineLayoutTestConfig config = (TimelineLayoutTestCon... |
&intent->device.opaque);
}
}
static void prv_intent_remove_and_free(GAPLEConnectionIntent *intent) {
list_remove(&intent->node, (ListNode **) &s_intents, NULL);
kernel_free(intent);
}
static bool prv_intent_filter_by_device(ListNode *node, void *data) {
const BTDeviceInternal *target_device = (const BTDevice... | {
// If there are already connection intents, cancel connecting briefly,
// otherwise it's illegal to modify the white-list.
prv_stop_connecting();
// Mutate white-list:
prv_mutate_whitelist(device, is_adding);
// Start/continue connecting:
prv_start_connecting_if_needed();
} |
// -------------------------------------------------------------------------------------------------
// Helper data structure for prv_register_intent
struct RegisterIntentRequest {
bool is_bonding_based;
union {
const BTDeviceInternal *device;
GAPLEConnectionIntentBonding bonding;
};
};
// -----------... |
/*
* 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 CAPABILITY_HAS_JAVASCRIPT
const size_t header_length = sizeof(ROCKY_EXPECTED_SNAPSHOT_HEADER);
if (buffer_size < header_length ||
memcmp(ROCKY_EXPECTED_SNAPSHOT_HEADER.signature,
buffer,
sizeof(ROCKY_EXPECTED_SNAPSHOT_HEADER.signature)) != 0) {
return false;
}
const ui... |
static bool prv_rocky_eval_buffer(const uint8_t *buffer, size_t buffer_size) {
jerry_value_t rv;
if (rocky_is_snapshot(buffer, buffer_size)) {
buffer += sizeof(ROCKY_EXPECTED_SNAPSHOT_HEADER);
buffer_size -= sizeof(ROCKY_EXPECTED_SNAPSHOT_HEADER);
PBL_ASSERTN((uintptr_t)buffer % 8 == 0);
rv = jerr... |
#include "stubs_logging.h"
#include "stubs_pbl_malloc.h"
#include "stubs_mutex.h"
// Globals
QemuSerialGlobals s_state;
// Setup
////////////////////////////////////
void test_qemu_serial__initialize(void) {
qemu_serial_private_init_state(&s_state);
}
void test_qemu_serial__cleanup(void) {
}
// ---------------... | (msg_data, sizeof(msg_data)) | ;
rcv_msg = qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol);
cl_assert(rcv_msg);
cl_assert_equal_i(rcv_bytes, 2*sizeof(msg_data));
cl_assert_equal_m(msg_data, rcv_msg, sizeof(msg_data));
cl_assert_equal_m(msg_data, rcv_msg+sizeof(msg_data), sizeof(msg_data));
prv_send_footer();
... |
(uuid, uuid_buffer) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "No app found with uuid %s", uuid_buffer);
return;
}
switch (cmd) {
case APP_RUN_STATE_RUN_COMMAND:
// Launch the application provided it isn't running, otherwise this is a noop
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = install_id,
... | |
/*
* 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... | strrchr(testbuf, 'B') | , testbuf+6);
}
void test_strchr__r_unfound(void) {
char testbuf[10] = "Hello!B\0Z";
cl_assert_equal_p(strrchr(testbuf, 'Z'), NULL);
}
void test_strchr__r_big_value(void) {
char testbuf[8] = "Hello!B";
cl_assert_equal_p(strrchr(testbuf, 0xF00 + 'B'), testbuf+6);
}
void test_strchr__r_end_of_string(void) {
... |
alarm_time = kernel_malloc_check(sizeof(struct tm));
uint8_t *settings_file_buffer = kernel_malloc_check(ALARM_ENTRY_SIZE);
AppInstallEntry *entry = kernel_malloc_check(sizeof(AppInstallEntry));
if (!app_install_get_entry_for_install_id(APP_ID_ALARMS, entry)) {
goto cleanup;
}
int num_pin_adds = 0;
tim... | {
Alarm alarm = { .id = i, .config = config };
prv_check_and_schedule_alarm(file, &alarm, false /* refresh */);
alarm_found = true;
} |
}
timeline_event_refresh();
return alarm_found;
}
// ----------------------------------------------------------------------------------------------
static void prv_put_alarm_event(void) {
if (!s_alarms_enabled) {
return;
}
AlarmConfig *config = s_most_recent_alarm_id != ALARM_INVALID_ID ? &s_most_re... |
ck->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_assert_equal_i(window1->on_screen, true);
cl_assert_equal_p(... | (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 happens via the compositor
compositor_transition(NULL);... |
w, 18));
switch (data->test_case) {
case FLASH_TEST_CASE_RUN_DATA_TEST:
text_layer_set_text(msg_text_layer, "Data Bus Test");
break;
case FLASH_TEST_CASE_RUN_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Addr Bus Test");
break;
case FLASH_TEST_CASE_RUN_STRESS_ADDR_TEST:
tex... | run_flash_test_case(data->test_case, 0) | |
.region_num = MemoryRegion_TaskStackGuard,
.enabled = true,
.base_address = (uint32_t) __WORKER_RAM__,
.size = (uint32_t) __stack_guard_size__,
.cache_policy = MpuCachePolicy_NotCacheable,
.priv_read = false,
.priv_write = false,
.user_read = false,
.user_write = false
};
static const MpuRegion s_app_... | MIN((const char*) region_end, str + max_length) | |
ss_bar, PROGRESS_TYPICAL_COLOR, typical_end);
#endif
}
}
static void prv_render_progress_bar(GContext *ctx, Layer *base_layer) {
HealthSleepSummaryCardData *data = layer_get_data(base_layer);
// Renders the background
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
... | prv_render_icon(ctx, base_layer) | |
{ -984, -40, 8},
{ -816, 120, -64},
{ -1032, 48, 40},
{ -992, 96, -16},
// 55 seconds
{ -1024, 64, 8},
{ -1120, 0, 48},
{ -1200, 0, -16},
{ -1248, 128, -24},
{ -1152, 320, -512},
{ -1152, 240, -376},
{ -1192, -32, -40},
{ -1192, -272, -48},
{ -1032, 120, -128},
... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_28394_6
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ -272, -384, -992},
{ ... |
{ 72, 896, 192},
{ 112, 1016, 184},
{ 80, 928, 128},
{ 64, 840, 144},
{ 32, 776, 184},
{ 128, 568, 224},
{ 128, 968, 208},
{ 144, 712, 488},
{ 248, 936, 296},
{ 232, 928, 440},
{ 248, 896, 344},
{ 272, 640, 344},
{ 208, 984, 208},
{ 192, 760, 8},
{ 264, 920, ... |
S_SETTINGS_SLEEP_REWARD,
.default_val = ACTIVITY_INSIGHTS_SETTINGS_SLEEP_REWARD_DEFAULT
},
{
.key = ACTIVITY_INSIGHTS_SETTINGS_SLEEP_SUMMARY,
.default_val = ACTIVITY_INSIGHTS_SETTINGS_SLEEP_SUMMARY_DEFAULT
},
{
.key = ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD,
.default_val = ACTIVITY_INSIGH... | prv_open_settings_and_lock(&file) | ) {
if (settings_file_set(&file,
insight_name, strlen(insight_name),
settings, sizeof(*settings)) != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_WARNING, "Unable to save insight setting with key %s", insight_name);
} else {
rv = true;
}
prv_close_settin... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERTN(scroll_layer) | ;
if (process_manager_compiled_with_legacy2_sdk() || !scroll_layer->shadow_sublayer.hidden) {
return false;
}
return !scroll_layer->paging.paging_disabled;
}
T_STATIC uint16_t prv_scroll_layer_get_paging_height(ScrollLayer *scroll_layer) {
if (!prv_scroll_layer_is_paging_enabled(scroll_layer)) {
return... |
/*
* 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... | strlen(str) | ;
for (int i = 0; i < len; i++) {
str[i] = toupper((unsigned char)str[i]);
}
}
void byte_stream_to_hex_string(char *out_buf, size_t out_buf_len,
const uint8_t *byte_stream, size_t byte_stream_len, bool print_backward) {
size_t bytes_left = byte_stream_len;
if (print_backward) {
byte_stream += (byte... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR) | ;
current_value |= bit;
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, current_value);
}
void boot_bit_clear(BootBitValue bit) {
uint32_t current_value = RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR);
current_value &= ~bit;
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, current_value);
}
bool boot_bit_test(BootBitVa... |
ct_call(const jerry_length_t argc, const jerry_value_t argv[],
void (*func)(GContext *, const GRect *)) {
GRectPrecise prect;
ROCKY_ARGS_ASSIGN_OR_RETURN_ERROR(
ROCKY_ARG(prect),
);
GContext *const ctx = rocky_api_graphics_get_gcontext();
const GRect rect = prv_grect_fr... | (radius1.raw_value, radius2.raw_value) | |
tmap *bitmap = test_data->bitmap_create_func(test_image_filename);
cl_assert(bitmap);
cl_assert(gbitmap_get_format(bitmap) == test_data->expected_test_image_bitmap_format);
// Draw the two variations of the test image at GPointZero
prv_composite_test_draw_bitmap(&s_ctx, bitmap, GPointZero, compositing_... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_graphics_draw_bitmap__offset_bitmap_layer_inside(void) {
prv_offset_bitmap_layer_test(GPointZero);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_bitmap_layer_across_x(void) {
prv_offset_bitmap_layer_test(GPoint(25, 0));
cl_check(gbitmap_pbi... |
Possible);
// Window recognizer becomes triggered
e.type = TouchEvent_PositionUpdate;
s_next_state = RecognizerState_Started;
s_idx_to_change = 0;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0 }, 2, &s_recognizers_handled);
prv_compare_recognizers_pr... | cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible) | ;
// A touchdown occurs and the active layer goes from non-null to null. All layer recognizers get
// reset. All recognizers remain in the possible state.
s_active_layer = &layer_a;
e.type = TouchEvent_Touchdown;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[])... |
nd_timer_id()), 27000 * MS_PER_SECOND);
rtc_set_time(s_saturday_10_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Sunday. (14.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 52200 * MS_PER_S... | (get_dnd_timer_id()) | |
/*
* 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... | memset(s1 + strn, '\0', n - strn) | ;
}
return rc;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.