prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
lue_t)(EM_ASM_INT({ \
return __jerryRefs.ref(new (type)(Module.Pointer_stringify($0, $1))) \
}, (msg), (sz)))
jerry_value_t jerry_create_error_sz(jerry_error_t error_type,
const jerry_char_t *message_p,
jerry_size_t message_size) {
jer... | (prop_name_val) | ) {
return false;
}
return (bool)EM_ASM_INT({
var obj = __jerryRefs.get($0);
var name = __jerryRefs.get($1);
try {
return delete obj[name];
} catch (e) {
// In strict mode, delete throws SyntaxError if the property is an
// own non-configurable property.
r... |
/*
* 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... | {
// Get the information about the app whose worker crashed
AppInstallEntry entry;
const bool app_found = app_install_get_entry_for_install_id(app_install_id, &entry);
// Construct the crash reason string (copied by the dialog, so we don't have to free it ourselves)
// "Worker " is 7, optional space is 1, up... | |
than 2 hours)
// PBL-9066: Increased to 20 minutes due to Mail.app only fetching emails every 15 minutes
// PBL-9251: Increased to 2 hours. People have Fetch set to hourly.
// PBL-12726: Added a check to see if the timstamp is coming from a location based reminder
// This work-around is causing more trouble th... | (app_id, message) | |
, index, &callbacks, ARRAY_LENGTH(s_intensity_labels),
true /* icons_enabled */, s_intensity_labels, data);
}
// Timeout Settings
/////////////////////////////
static const uint32_t s_timeout_values[] = { 3000, 5000, 8000 };
static const char *s_timeout_labels[] = {
i18n_noop("3 Seconds"),
i18n_noop("5 Sec... | {
subtitle = i18n_noop("Off");
} |
break;
case SettingsDisplayAmbientSensor:
title = i18n_noop("Ambient Sensor");
if (backlight_is_ambient_sensor_enabled()) {
subtitle = i18n_noop("On");
} else {
subtitle = i18n_noop("Off");
}
break;
case SettingsDisplayBacklightIntensity:
title = i18n_n... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
.draw_arc.center = center,
.draw_arc.radius = radius,
.draw_arc.angle_start = angle_start,
.draw_arc.angle_end = angle_end,
} | |
{ 280, 736, 112},
// 5 seconds
{ 344, 1912, 312},
{ -96, 1464, 600},
{ -192, 1632, 456},
{ -48, 752, 328},
{ 80, 624, 128},
{ 184, 504, 120},
{ 208, 504, 144},
{ 200, 632, 216},
{ 184, 944, 136},
{ 168, 1080, 272},
{ -8, 1152, 200},
{ 0, 1200, 32},
{ -112, 904... |
{ 88, 736, -16},
{ 192, 664, -48},
{ 288, 560, 32},
{ 304, 712, 8},
{ 280, 784, 32},
{ 240, 832, 48},
// 8 seconds
{ 224, 1048, 88},
{ 272, 1136, 56},
{ 264, 1296, 248},
{ 288, 1400, 432},
{ -120, 1592, 480},
{ 80, 1296, 448},
{ 48, 856, 328},
{ 136, 568, 224... | |
e schedule_2 = {
.from_hour = 5,
.from_minute = 0,
.to_hour = 13,
.to_minute = 0,
};
do_not_disturb_set_schedule(WeekdaySchedule, &schedule_2);
rtc_set_time(s_thursday_12_00);
do_not_disturb_handle_clock_change(); // Should still be in scheduled period
cl_assert(do_not_disturb_is_manually_ena... | (WeekendSchedule, false) | ;
rtc_set_time(s_saturday_01_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 00:00 on Monday. (46.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 167400 * MS_PER_SECOND);
rtc_set_time(s_thursday_00_... |
L_DEBUG, "Subtracting %"PRIu8" steps that occurred during sleep",
dls_record->samples[sample_idx].base.steps);
s_alg_state->steps -= dls_record->samples[sample_idx].base.steps;
s_alg_state->steps = MAX(0, s_alg_state->steps);
dls_record->samples[sample_idx].base.steps = 0;
dls_record->sample... | {
file_record = &s_alg_state->file_record;
} | |
y 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 Lic... | {
return;
} |
image->compositing_mode = mode;
layer_mark_dirty(&image->layer);
}
|
_slots = 0;
s_max_advertising_interval_slots = 0;
}
int GAP_LE_Advertising_Disable(unsigned int BluetoothStackID) {
s_is_le_advertising_enabled = false;
s_le_adv_connection_event_callback = NULL;
s_le_adv_connection_callback_param = 0;
s_min_advertising_interval_slots = 0;
s_max_advertising_interval_slots ... | s_le_adv_connection_event_callback(1, event, s_le_adv_connection_callback_param) | ;
}
void fake_gap_put_connection_event(uint8_t status,
bool is_master,
const BTDeviceInternal *device) {
GAP_LE_Connection_Complete_Event_Data_t event_data =
(GAP_LE_Connection_Complete_Event_Data_t) {
.Sta... |
/*
* 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... | smartstrap_link_control_is_profile_supported(SmartstrapProfileRawData) | ) {
smartstrap_connection_state_set_by_service(SMARTSTRAP_RAW_DATA_SERVICE_ID, true);
}
}
static SmartstrapResult prv_send(const SmartstrapRequest *request) {
return smartstrap_send(SmartstrapProfileRawData, request->write_mbuf, request->read_mbuf,
request->timeout_ms);
}
const Smart... |
/*
* 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... | {
syscall_assert_userspace_buffer(t, sizeof(*t));
syscall_assert_userspace_buffer(out_ms, sizeof(*out_ms));
} |
rtc_get_time_ms(t, out_ms);
}
DEFINE_SYSCALL(RtcTicks, sys_get_ticks, void) {
return rtc_get_ticks();
}
DEFINE_SYSCALL(void, sys_pbl_log, LogBinaryMessage* log_message, bool async) {
kernel_pbl_log(log_message, async);
}
DEFINE_SYSCALL(void, sys_copy_timezone_abbr, char* timezone_abbr, time_t time) {
if (P... |
{
return false;
} |
return command->path_open;
}
void gdraw_command_set_hidden(GDrawCommand *command, bool hidden) {
if (!command) {
return;
}
command->hidden = hidden;
}
bool gdraw_command_get_hidden(GDrawCommand *command) {
if (!command) {
return false;
}
return command->hidden;
}
size_t gdraw_command_copy_poin... | |
--;
}
}
bool launcher_popups_are_blocked(void) {
return s_block_popup_count > 0;
}
void launcher_cancel_force_quit(void) {
new_timer_stop(s_back_hold_timer);
}
static void launcher_force_quit_app(void *data) {
if (low_power_is_active() || factory_reset_ongoing()) {
PBL_LOG(LOG_LEVEL_DEBUG, "Forcekill dis... | process_manager_launch_process(&(ProcessLaunchConfig) {
.id = e->launch_app.id,
.common = NULL_SAFE_FIELD_ACCESS(e->launch_app.data, common, (LaunchConfigCommon) {}),
}) | ;
}
return;
case PEBBLE_WORKER_LAUNCH_EVENT:
if (!app_install_is_worker_running(e->launch_app.id)) {
process_manager_launch_process(&(ProcessLaunchConfig) {
.id = e->launch_app.id,
.common = NULL_SAFE_FIELD_ACCESS(e->launch_app.data, common, (LaunchConfigCommon) {}),
... |
check_atan2(0, 0);
check_atan2(0, 10);
check_atan2(10, 0);
check_atan2(-32768, 1); // <- causes overflow for int16
check_atan2(1, -32768); // <- causes overflow for int16
check_atan2(20001, 20000); // <- causes overflow if numbers are added in an int16
check_atan2(32767, 1);
check_atan2(1, 32767);
ch... | (-9, min, max) | , false);
// Positive out of bounds
cl_assert_equal_i(WITHIN(0, min, max), false);
cl_assert_equal_i(WITHIN(5, min, max), false);
}
void test_math__distance_to_boundary(void) {
cl_assert_equal_i(10, distance_to_mod_boundary(10, 100));
cl_assert_equal_i(50, distance_to_mod_boundary(50, 100));
cl_assert_equ... |
0x00, 0x00, 0x00, 0x00, 0x00 },
.timestamp = 100 * SECONDS_PER_MINUTE,
.duration = 5,
.type = TimelineItemTypePin,
.all_day = false,
.layout = LayoutIdCalendar,
},
.attr_list = {
.num_attributes = 1,
.attributes = &title_attr,
},
};
// not a calendar pin
static TimelineItem s_weather... | (prv_event_handler) | |
.connection_interval_min_1_25ms = 135,
.connection_interval_max_1_25ms = 161,
.supervision_timeout_10ms = 600,
},
[ResponseTimeMin] = {
.slave_latency_events = 0, // Not using Slave Latency
.connection_interval_min_1_25ms = 9, // Min. allowed by iOS
.connection_interval_max_1_25ms = 17,
.su... | // update requests are sent only after the previous request is completed, you can ignore the
// 30 second Tgap timeout."
const GAPLEConnectRequestParams *desired_params = prv_params_for_state(connection, state);
BleConnectionParamsUpdateReq req = {
.interval_min_1_25ms = desired_params->connection_interval... |
static void prv_watchdog_timer_callback(void *ctx) {
// This should all take very little time, so just execute on NewTimer task:
bt_lock();
GAPLEConnection *connection = (GAPLEConnection *)ctx;
if (gap_le_connection_is_valid(connection)) {
// Override the flag:
connection->param_update_info.is_request... |
gap_le_assert_advertising_interval(advert_terms[term].min_interval_slots,
advert_terms[term].max_interval_slots);
regular_timer_fire_seconds(1);
}
}
cl_assert(!gap_le_is_advertising_enabled());
cl_assert_equal_i(s_unscheduled_cb_count, 1);
cl_assert_equal_... | assert_ad_data("C") | ;
regular_timer_fire_seconds(1);
assert_ad_data("D");
// One job ("C") should been have been unscheduled:
cl_assert_equal_i(s_unscheduled_cb_count, 1);
// Round-robin 5 times:
for (int i = 0; i < 5; ++i) {
regular_timer_fire_seconds(1);
assert_ad_data("E");
regular_timer_fire_seconds(1);
... |
time_util_get_midnight_of(now) - SECONDS_PER_DAY,
time_util_get_midnight_of(now));
cl_assert_equal_i(result, 2000);
// yesterday and today
result = health_service_sum(HealthMetricStepCount,
time_util_get_midnight_of(now) - SECOND... | health_service_events_subscribe(NULL, NULL) | ;
HealthServiceCache *const cache = s_health_service.cache;
cl_assert(cache != NULL);
// cache is preserved
health_service_events_subscribe(NULL, NULL);
cl_assert_equal_p(s_health_service.cache, cache);
health_service_events_unsubscribe();
cl_assert_equal_p(s_health_service.cache, NULL);
// multiple ... |
ree(fb);
}
// Helpers
//////////////////////
void prv_handle_down_click(ClickRecognizerRef recognizer, void *context);
static void prv_render_layout(LayoutId layout_id, const AttributeList *attr_list,
size_t num_down_clicks) {
PBL_ASSERTN(attr_list);
TimelineItem item = (TimelineIt... | (details1) | |
/*
* 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... | {
kernel_pbl_log(log_message, async);
} | |
proc(&layer, &across_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_y_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&lay... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_r8_quad_top_right.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_circle_quadrant_draw_1px_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, GCornerBottomLeft);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_r8_quad_bottom_left.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(gcolor_equal__deprecated(GColorRed, GColorRed)) | ;
cl_assert(!gcolor_equal__deprecated(GColorRed, GColorBlue));
// Check the behavior of the deprecated function (which is incorrect) that two colors with
// zero alpha values but different RGB values are not considered equal
GColor8 color1 = GColorBlue;
color1.a = 0;
GColor8 color2 = GColorRed;
color2.a ... |
}
typedef void (*HorizontalClippingMaskRecordFunc)(GContext *ctx, int16_t y, int16_t x1, int16_t x2,
GColor color);
static void prv_mask_record_hline_test_pattern(HorizontalClippingMaskRecordFunc record_func) {
GContext *ctx = s_ctx;
prv_prepare_canvas_for_hline_... | for (int16_t x = starting_x; x < starting_x + hline_applying_test_column_width; x++) {
ctx->draw_state.stroke_color = (GColor) { .argb = (uint8_t)(column_index | 0b11000000) };
graphics_draw_pixel(ctx, GPoint(x, y));
} |
}
}
}
static GDrawMask *prv_create_mask_for_hline_applying_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(mask);
const GSize mask_size... |
e_t utc_time, TimezoneInfo *tz_info) {
#ifdef RECOVERY_FW
*tz_info = (TimezoneInfo) { .dst_id = 0 };
#else
timezone_database_load_region_info(region_id, tz_info);
prv_update_dstrule_timestamps_by_dstzone_id(tz_info, utc_time);
#endif
}
static TimezoneInfo prv_get_timezone_info_from_data(TimezoneCBData *tz_data)... | (LOG_LEVEL_WARNING, "Mobile app calling deprecated API, time = %d",
(int)new_time) | ;
if (clock_is_timezone_set()) {
new_time = prv_migrate_local_time_to_UTC(new_time);
}
prv_update_time_info_and_generate_event(&new_time, NULL);
}
void clock_protocol_msg_callback(CommSession *session, const uint8_t* data, unsigned int length) {
char sub_command = *data++;
switch (sub_command) {
//... |
/*
* 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... | (&buffer, 2, &out_buffer, &out_length) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (task >= NumPebbleTask) {
if (task == PebbleTask_Unknown) {
return "Unknown";
}
WTF;
}
TaskHandle_t task_handle = g_task_handles[task];
if (!task_handle) {
return "Unknown";
}
return (const char*) pcTaskGetTaskName(task_handle);
} |
// NOTE: The logging support calls toupper() this character if the task is currently running privileged, so
// these identifiers should be all lower case and case-insensitive.
char pebble_task_get_char(PebbleTask task) {
switch (task) {
case PebbleTask_KernelMain:
return 'm';
case PebbleTask_KernelBackgro... |
/*
* 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... | (&success, "A") | |
nvalid data length read");
}
flash_impl_release();
return S_SUCCESS;
}
int flash_impl_write_page_begin(const void *vp_buffer,
const FlashAddress start_addr, size_t len) {
if (!len) {
return E_INVALID_ARGUMENT;
}
const uint8_t *buffer = vp_buffer;
// Flash write trans... | // second byte as bits are only allowed to be written from 1 -> 0. 1s will
// stay 1s, and 0s will stay 0s.
const uint16_t trailing_short_value = *buffer | 0xFF00;
*flash_write_dest = trailing_short_value;
}
// Buffer writing is complete, issue the buffer to flash command to actually
// commit th... |
// if they are concerned about reliability.
result = S_SUCCESS;
}
}
prv_allow_write_if_sector_is_not_protected(true, sector_addr);
flash_impl_release();
return FAILED(result) ? result : (int)bytes_in_page;
}
status_t flash_impl_get_write_status(void) {
flash_impl_use();
const uint8_t stat... |
/*
* 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... | (gdraw_command_get_fill_color(processed_command), p->app_fb_key_color) | ) {
gdraw_command_set_hidden(processed_command, true);
const uint16_t num_points = gdraw_command_get_num_points(processed_command);
GPoint points[num_points];
if (sizeof(points) == gdraw_command_copy_points(processed_command, points, sizeof(points))) {
GPath path = {
.num_points = num_poin... |
struct clar_suite *suite = &_clar_suites[0];
const struct clar_func *test_funcs = suite->tests;
const struct clar_func *test = NULL;
for (int i = 0; i < suite->test_count; i++) {
if (!strcmp(test_funcs[i].name, test_name)) {
test = &test_funcs[i];
break;
}
}
... | snprint_eq(buf, 128, "%d != %d", i1, i2) | ;
clar__assert(0, file, line, err, buf, should_abort);
}
}
void clar__assert_equal_d(
double d1,
double d2,
const char *file,
int line,
const char *err,
int should_abort)
{
if (d1 != d2) {
char buf[128];
snprint_eq(buf, 128, "%f != %f", d1, d2);
clar__assert(0, file, line, err, buf, sh... |
st uint8_t *expected_attr_list_serialized,
size_t expected_attr_list_serialized_size) {
uint8_t buffer[expected_attr_list_serialized_size];
const size_t size = attribute_list_serialize(attr_list_to_serialize, buffer,
buffer + exp... | (&list, AttributeIdLastUpdated, value_uint32) | ;
attribute_list_add_uint8(&list, AttributeIdBgColor, value_uint8);
cl_assert_equal_i(value_uint32, attribute_get_uint32(&list, AttributeIdLastUpdated, 0));
cl_assert_equal_i(value_uint8, attribute_get_uint8(&list, AttributeIdBgColor, 0));
cl_assert_equal_i(list.num_attributes, 4);
attribute_list_destroy_lis... |
PBL_LOG(LOG_LEVEL_ERROR, "Got callback, but zero messages!?") | ;
// fall-through
}
// These conditions are redundant, just for safety:
while ((num_message_consumed < info.num_success) && (info.it < info.end)) {
AppInboxMessageHeader *msg = (AppInboxMessageHeader *)info.it;
// Increment now so that if the message_handler calls into sys_app_inbox_service_consume(... | |
yer, GContext *ctx) {
DisplayCalibrationData *data = window_get_user_data(layer_get_window(layer));
if ((data->state == DisplayCalibrationState_X_Adjust) ||
(data->state == DisplayCalibrationState_Confirm)) {
prv_draw_border_stripe(layer, ctx, GAlignLeft);
prv_draw_border_stripe(layer, ctx, GAlignRig... | (BUTTON_ID_BACK, prv_back_click_handler) | |
48},
{ -1136, 392, -200},
{ -1400, 360, -200},
{ -888, 432, -360},
{ -1048, 392, -320},
{ -1168, 352, -376},
{ -1520, 248, -344},
{ -1264, 120, -312},
{ -1152, 120, -216},
{ -1024, 104, -160},
{ -960, 136, -120},
{ -872, 152, -40},
{ -856, 184, -40},
{ -1024, 368, -56... | { -1216, 520, -136},
{ -1128, 400, -136},
{ -1184, 304, -112},
{ -1096, 280, -216},
{ -888, 264, -256},
{ -1096, 384, -160},
{ -1072, 584, -184},
{ -1288, 384, -280},
{ -1240, 400, -256},
{ -960, 456, -312},
// 23 seconds
{ -1136, 464, -296},
{ -1536, 384, -152},
... | |
/*
* 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_set_line_spacing_delta(&data->text_layer, data->line_spacing_delta) | ;
} else if (button == BUTTON_ID_SELECT) {
data->overflow_mode = (data->overflow_mode + 1) % 3;
text_layer_set_overflow_mode(&data->text_layer, data->overflow_mode);
} else if (button == BUTTON_ID_DOWN) {
if (data->line_spacing_delta < 5) {
data->line_spacing_delta -= 1;
} else {
data->l... |
ZE_BYTES];
for (uint32_t i = 0; i < WRITE_PAGE_SIZE_BYTES; i++) {
page[i] = (uint8_t)(value++ & 0xFF);
}
uint32_t bytes_remaining = length;
while (bytes_remaining > 0)
{
uint32_t bytes_to_write = WRITE_PAGE_SIZE_BYTES;
if (bytes_remaining < WRITE_PAGE_SIZE_BYTES) {
bytes_to_write = bytes_re... | (TEST_ADDR) | ) {
prompt_send_response("FAIL: sector not erased");
return;
}
prompt_send_response("OK");
}
//! Some flash chips have an accelerated method of checking for erased sectors. This is a sanity
//! check against that method. It reads the bytes in raw form and makes sure it is really erased.
static bool prv_i... |
ot to be set yet:
cl_assert_equal_i((s_boot_bits_orred & BOOT_BIT_NEW_FW_AVAILABLE), 0);
// System Resources object:
prv_receive_init_put_commit_and_install(ObjectSysResources);
assert_ack_count(1);
assert_nack_count(0);
// Finally, expect both boot bits to be set at once:
cl_assert_equal_i((s_boot_bits... | assert_cleanup_event(ObjectFirmware, VALID_OBJECT_SIZE) | ;
}
void test_put_bytes__session_closed_after_expect_init(void) {
put_bytes_expect_init(EXPECT_INIT_TIMEOUT_MS);
PebbleCommSessionEvent app_event = {
.is_open = false,
.is_system = true
};
// Close the BT session, have put_bytes react
put_bytes_handle_comm_session_event(&app_event);
fake_system_... |
/*
* 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... | i18n_free_all(¬if_attr_list) | ;
attribute_list_destroy_list(¬if_attr_list);
attribute_list_destroy_list(&dismiss_action_attr_list);
if (!item) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to welcome the user.");
return;
}
item->header.from_watch = true;
notifications_add_notification(item);
timeline_item_destroy(item);
welcome_... |
/*
* 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... | ((addr & (SUBSECTOR_SIZE_BYTES - 1)) == 0,
"Sections must be subsector aligned! addr is 0x%" PRIx32, addr) | ;
PBL_ASSERT((CHUNK_SIZE_BYTES & (SUBSECTOR_SIZE_BYTES - 1)) == 0,
"Sections divide into subsectors evenly, size is 0x%" PRIx16, CHUNK_SIZE_BYTES);
for (unsigned int i = 0; i < (CHUNK_SIZE_BYTES / SUBSECTOR_SIZE_BYTES); ++i) {
flash_erase_subsector_blocking(addr + (i * SUBSECTOR_SIZE_BYTES));
}
LogC... |
*)&APP_GLANCE_TEST_UUID, UUID_SIZE,
invalid_glance_out, glance_size),
E_INVALID_ARGUMENT);
}
void test_app_glance_db__basic_glance_blob_delete(void) {
// Call the basic glance blob insert test to insert the basic glance blob
test_app_glance_db__basic_glanc... | (glance_out, (uint8_t *)s_app_glance_with_too_many_slices, trimmed_glance_size) | ;
}
static void prv_check_invalid_version_code_blob_not_inserted(uint8_t version) {
const SerializedAppGlanceHeader app_glance = (SerializedAppGlanceHeader) {
.version = version,
};
cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(... |
to a 1440 minute day. The BMR for
// the above user is 1388 kcalories per day, so we expect to get:
// 1388 * 1020/1440 = 1023 kcalories
activity_get_metric(ActivityMetricRestingKCalories, 1, &value);
const int k_bmr_cal = 1388 * ACTIVITY_CALORIES_PER_KCAL;
cl_assert_equal_i(value, ROUND(k_bmr_cal * k_minu... | activity_get_metric(ActivityMetricStepCount, 1, &value) | ;
cl_assert_equal_i(value, k_exp_steps_2);
activity_get_metric(ActivityMetricActiveKCalories, 1, &value);
// The following determined from a known good commit
int32_t exp_active_kcalories_2 = 486;
cl_assert_equal_i(value, exp_active_kcalories_2);
// We now expect to get the following resting calories
co... |
e_mode(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent:
BTErrno e = gap_le_connect_connect(&device,
true /* auto_reconnect */,
false /* is_pairing_required */,
GAPLECli... | gap_le_connect_connection_intents_count() | , 0);
cl_assert_equal_b(gap_le_connect_has_pending_create_connection(), false);
}
void __disabled_test_gap_le_connect__disconnection_event_upon_cancel_connect(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent for app:
gap_le_connect_connect(&device,
f... |
ts = (GEdgeInsets) {
.top = STATUS_BAR_LAYER_HEIGHT,
.bottom = PBL_IF_RECT_ELSE(0, STATUS_BAR_LAYER_HEIGHT)
};
bounds = grect_inset(bounds, menu_layer_insets);
menu_layer_init(menu_layer, &bounds);
menu_layer_set_callbacks(menu_layer, data, &(MenuLayerCallbacks) {
.get_num_rows = prv_information_get... | (ctx, mark, &box, highlight) | ;
return origin.x + box.size.w;
}
#define MARK_PADDING 10
static void prv_draw_rt_cell_rect(GContext *ctx, const Layer *cell_layer, GBitmap *mark,
const char *text, UNUSED bool is_selected) {
int16_t x = (MARK_PADDING / 2);
GRect box = cell_layer->bounds;
const bool highlight... |
c TickType_t s_last_freertos_tick_count = 0;
static RtcTicks s_coarse_ticks = 0;
bool ints_enabled = mcu_state_are_interrupts_enabled();
if (ints_enabled) {
__disable_irq();
}
TickType_t freertos_tick_count = xTaskGetTickCount();
if (freertos_tick_count < s_last_freertos_tick_count) {
// We rolled... | rtc_sanitize_struct_tm(¤t_time) | ;
// Calculate our results
*out_seconds = mktime(¤t_time);
*out_ms = (uint16_t)(
((RTC_CLOCK_SYNC_PRESCALER - sub_seconds) * 1000) / (RTC_CLOCK_SYNC_PRESCALER + 1));
if (sanitization_done) {
// Fix up the underlying registers so we don't have to do this again.
rtc_set_time(*out_seconds);
... |
cl_assert_equal_s("Jun 9, 4:00 PM", time_buf);
}
void test_clock__time_24h_style(void) {
char time_buf[64];
const int 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 int event_time = jun10th_n... | ("An hour ago", time_buf) | ;
// June 9th 2015, 17:30:00 (T+01:30:00)
rtc_set_time(event_time + SECONDS_PER_HOUR + (30 * SECONDS_PER_MINUTE));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("2 hours ago", time_buf);
// June 9th 2015, 16:01:00 (T+00:01:00)
rtc_set_time(event_time + (... |
cess_management/app_manager.h"
#include "resource/resource_ids.auto.h"
#include "services/common/battery/battery_curve.h"
#include "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "system/logging.h"
#include "util/time/time.h"
typedef void (*DialogUpdateFn)(D... | {
dialog_pop(old_dialog);
} |
}
// Public API
////////////////////
void battery_ui_display_plugged(void) {
// If we're plugged in for charging, we want to alert the user of this,
// but we don't want to overlay ourselves over anything they may have
// on the screen at the moment.
WindowStack *stack = modal_manager_get_window_stack(ModalP... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_window_stack_get_top_window() | ;
layer_add_child(&other_window->layer, &pin_window->layer);
// animate the card layout to the right
GPoint to_origin = { pin_window->layer.bounds.size.w, 0 };
Animation *animation = prv_create_bounds_origin_animation(pin_window, NULL, &to_origin);
animation_set_custom_interpolation(animation, interpolate_mo... |
ck,
prv_serial_dump_completed_callback);
prompt_command_continues_after_returning();
}
static void spam_callback(void *data) {
uint32_t iteration = (uintptr_t) data;
uint8_t buffer[128];
time_t base = sys_get_time();
for (int i = 0; i < 16; ++i) {
LogBinaryMessage* msg = (LogBinaryM... | {
profiler_start();
delay_us(i);
profiler_stop();
uint32_t duration_us = profiler_get_total_duration(true);
// make sure we have idled for at least the time specified and have not exceeded
// the requested time by more than 5%
bool passed = ((duration_us >= i) && (duration_us <= ((i * 105) ... |
prompt_send_response("delay_us audit complete");
__enable_irq();
}
// Simply parks the chip permanently in stop mode in whatever state it's currently in. This can be
// pretty handy when trying to profile power of the chip under certains states
// NOTE: If you did not configure with `--nowatchdog`, the HW watchdo... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_window_stack_pop(false /* animated */) | |
s of sleep", &pin_attr_list); /// "10H 30M of sleep"
snprintf(short_subtitle, max_attr_length, short_subtitle_fmt, elapsed);
attribute_list_add_cstring(&pin_attr_list, AttributeIdShortSubtitle, short_subtitle);
attribute_list_add_cstring(&pin_attr_list, AttributeIdSubtitle, elapsed);
const char *title_i18n = P... | (now_utc, session) | |
w;
const int16_t text_x_offset = (window_width - content_size.w) / 2;
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
const int16_t text_y_offset = 33;
#else
const int16_t text_y_offset = 22;
#endif
const GRect frame = { { text_x_offset, text_y_offset }, content_size };
layer_set_frame(&data->name_text_layer.layer, ... | prv_show_spinner(s_fu_app_data) | |
? 1 : 0;
num_item_specific_actions += (has_ancs_mute_action) ? 1 : 0;
// Create root level
uint8_t num_actions = num_timeline_actions + num_local_actions;
uint8_t separator_index = num_actions > num_item_specific_actions ? num_item_specific_actions : 0;
ActionMenuLevel *root_level = timeline_actions_create_a... | action_menu_level_add_action(root_level,
do_not_disturb_is_active() ?
i18n_get("End Quiet Time", root_level) :
i18n_get("Start Quiet Time", root_level),
prv_toggle_dnd_from_action_... | ;
}
return root_level;
}
static void prv_action_menu_did_close(ActionMenu *action_menu, const ActionMenuItem *item,
void *context) {
NotificationWindowData *data = &s_notification_window_data;
data->action_menu = NULL;
}
static void prv_select_single_click_handler(ClickR... |
lude "stubs_memory_layout.h"
#include "stubs_pbl_malloc.h"
#include "stubs_resources.h"
#include "stubs_syscalls.h"
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libgen.h>
#include "util_pbi.h"
static char *s_pbi2png_path;
// Stubs
void passert_failed... | (filename, output) | ;
strcat(output, ".png");
write_gbitmap_to_pbi(&ctx.dest_bitmap, output, s_pbi2png_path);
prv_teardown_context(&ctx);
}
static void prv_convert_pdc(const char *filename) {
FILE *f = fopen(filename, "rb");
if (f == NULL) {
printf("File not found: %s\n", filename);
return;
}
// Check that file ... |
er_handle_state_change(&manager, r[1]);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_p(manager.active_layer, NULL);
prv_compare_recognizers_processed((int []) { 0, 1 }, 2, &s_recognizers_reset);
manager.active_layer = &layer_a;
manager.state = RecognizerManagerSt... | cl_assert_equal_i(r[0]->state, RecognizerState_Started) | ;
cl_assert_equal_i(r[1]->state, RecognizerState_Completed);
}
|
_cap_horiz(&p0, radius, y, &left_margin, &right_margin);
prv_calc_cap_horiz(&p1, radius, y, &left_margin, &right_margin);
// Finally draw line
if (left_margin.raw_value <= right_margin.raw_value) {
graphics_private_draw_horizontal_line(ctx, y, left_margin, right_margin);
}
}
//... | if (x > tm_p1.x.integer) {
// We're crossing far_top point, time to swap...
tm_p0 = far_top;
tm_p1 = far_right;
} |
if (x > bm_p1.x.integer) {
// We're crossing far_bottom point, time to swap...
bm_p0 = far_bottom;
bm_p1 = far_right;
}
// Starting and ending point of the line, initialized with extremes
Fixed_S16_3 top_margin = {.raw_value = INT16_MAX};
Fixed_S16_3 bottom_margi... |
_NewTimers);
cl_assert(stub_new_timer_fire(get_reminder_timer_id()));
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
fake_system_task_callbacks_invoke(1);
cl_assert_equal_i(num_events_put, 3);
cl_assert_equal_m(&item3.header.id, stub_new_timer_callback_data(get_reminder_timer_id()), sizeof(Timel... | time_util_update_timezone(&s_tz) | ;
// set time to 21:00 PST March 5, when s_all_day_reminder should be rejected for being stale
now = 1425618000;
cl_assert_equal_i(reminders_insert(&s_all_day_reminder), E_INVALID_OPERATION);
// set time to 21:00 PST March 4
now = 1425531600;
// if the timestamp of s_all_day_reminder isn't adjusted, it wou... |
l_assert(line.height_px == 10);
cl_assert(line.width_px == 1 * HORIZ_ADVANCE_PX);
cl_assert(iter_next(&word_iter));
cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 1 * HORIZ_ADVANCE_PX);
// reset line
line... | (line.height_px == 10) | ;
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 0);
cl_assert(line.origin.x == 0);
cl_assert(line.suffix_codepoint == 0);
cl_assert(*line.start == '\n');
// ar
cl_assert(*word_iter_state.current.start == 'a');
cl_assert(*word_iter_state.current.end == ' ');
cl_assert(word_iter_state.current.width_px ==... |
ctx.lineTo(4095.375, -4095.5);");
EXECUTE_SCRIPT_EXPECT_ERROR("ctx.lineTo(4096.5, 0);", "TypeError: Value out of bounds");
EXECUTE_SCRIPT_EXPECT_ERROR("ctx.lineTo(0, -4095.625);", "TypeError: Value out of bounds");
}
void test_rocky_api_graphics_path2d__minimal_path(void) {
rocky_global_init(s_graphics_api);
... | {
rocky_global_init(s_graphics_api);
prv_create_global_ctx();
EXECUTE_SCRIPT(
"ctx.moveTo(1, 2);\n"
"ctx.lineTo(3, 4);\n"
"ctx.lineTo(5, 6);\n"
);
// OOM!
fake_malloc_set_largest_free_block(0);
// Call implementation directly instead of executing a script, to avoid mallocs by the VM itself... | |
ervice_uuids, destination array too small:
found = ble_ad_copy_service_uuids(s_ad_data, copied_uuids, 0);
cl_assert_equal_i(found, 1);
// Test ble_ad_get_tx_power_level returns false, when no TX Power Level:
int8_t tx_power_level_out;
cl_assert(!ble_ad_get_tx_power_level(s_ad_data, &tx_power_level_out));
}
... | ble_ad_destroy(ad) | ;
// 7x 32-bit UUIDs should fit, expect true:
ad = ble_ad_create();
cl_assert_equal_b(ble_ad_set_service_uuids(ad, uuid, 7), true);
ble_ad_destroy(ad);
// 8x 32-bit UUIDs does not fit, expect false:
ad = ble_ad_create();
cl_assert_equal_b(ble_ad_set_service_uuids(ad, uuid, 8), false);
ble_ad_destroy(a... |
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 distributed on a... | attribute_get_string(&reminder->attr_list, AttributeIdTitle, "") | ;
if (strcmp(title, reminder_info->title) != 0) {
timeline_item_free_allocated_buffer(reminder);
return true; // continue iteration
}
if (reminder_info->filter_cb && !reminder_info->filter_cb(&header, context)) {
timeline_item_free_allocated_buffer(reminder);
return true; // continue iteration
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | mfg_info_set_model("test_model") | ;
mfg_info_get_model(buffer);
cl_assert_equal_s(buffer, "test_model");
{
char long_string[] = "01234567890123456789";
mfg_info_set_model(long_string);
// We only expect to see the first 15 (MFG_INFO_MODEL_STRING_LENGTH - 1) characters
mfg_info_get_model(buffer);
cl_assert_equal_s(buffer, "0... |
test_unobstructed_area_service__change_after_subscribe(void) {
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_chan... | (s_data.num_did_change_calls, 1) | |
event_service.h"
#include "process_management/app_install_manager.h"
#include "clar.h"
// Fakes
//////////////////////////////////////////////////////////
#include "fake_app_manager.h"
#include "fake_rtc.h"
#include "fake_new_timer.h"
#include "fake_pbl_malloc.h"
#include "fake_spi_flash.h"
#include "fake_system_task... | sys_wakeup_schedule(sys_get_time() + WAKEUP_EVENT_WINDOW + 59, 0, false) | ;
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST);
// Test that another event < 1 minute away fails to schedule (E_DOES_NOT_EXIST)
wakeup_id = sys_wakeup_schedule(sys_get_time() + 1, 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST);
}
// work around system_task_add_... |
/*
* 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... | gdraw_command_set_stroke_color(processed_command, tinted_stroke_color) | |
/ TX enabled
// - 1 stop bit
// - no flow control
dev->periph->CR1 &= ~USART_CR1_UE;
dev->periph->CR2 = (dev->do_swap_rx_tx ? USART_CR2_SWAP : 0);
dev->periph->CR3 = (dev->half_duplex ? USART_CR3_HDSEL : 0);
dev->periph->CR1 = cr1_extra_flags | USART_CR1_UE;
dev->state->initialized = true;
// initial... | if (enabled) {
PBL_ASSERTN(dev->state->tx_irq_handler || dev->state->rx_irq_handler);
// enable the interrupt
NVIC_SetPriority(dev->irq_channel, dev->irq_priority);
NVIC_EnableIRQ(dev->irq_channel);
} else {
// disable the interrupt
NVIC_DisableIRQ(dev->irq_channel);
} |
}
void uart_set_rx_interrupt_handler(UARTDevice *dev, UARTRXInterruptHandler irq_handler) {
PBL_ASSERTN(dev->state->initialized);
dev->state->rx_irq_handler = irq_handler;
}
void uart_set_tx_interrupt_handler(UARTDevice *dev, UARTTXInterruptHandler irq_handler) {
PBL_ASSERTN(dev->state->initialized);
dev->st... |
{ 0, 0x6a, 0, 140, 0},
{ 0, 0x6a, 0, 140, 0},
{ 0, 0x6b, 1308, 140, 0},
{ 0, 0x6b, 0, 140, 0},
// 360: Local time: 2016-05-20 03:06:00 AM
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{... |
// 405: Local time: 2016-05-20 03:51:00 AM
{ 0, 0x79, 0, 140, 0},
{ 0, 0x79, 5, 140, 0},
{ 0, 0x69, 2149, 141, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
{ 0, 0x6b, 0, 140, 0},
... | |
tted(&ctx, GPoint(70, 15), 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(65, 15), 10);
// T facing down
graphics_draw_vertical_line_dotted(&ctx, GPoint(101, 11), 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(96, 16), 10);
// cross - even vert, even horiz
graphics_draw_vertical_line_dotted(... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(66, 36), 10) | ;
// T facing down - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(101, 33), 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(97, 37), 10);
// T facing left - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 70), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(5, 76), 5... |
digits)
snprintf(dstbuf, 256, "%.0izero%.0i", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.izero%.i", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 25... | cl_assert_equal_s(dstbuf, "240,57072,2596069104,2596069104") | ;
snprintf(dstbuf, 256, "%llu,%ju", hurf, hurf);
cl_assert_equal_s(dstbuf, "1311768467463790320,1311768467463790320");
snprintf(dstbuf, 256, "%zu,%tu", hurf, hurf);
cl_assert_equal_s(dstbuf, "2596069104,2596069104");
}
void test_sprintf__percent_o(void) {
char dstbuf[256];
// Simple %o
snprintf(dstbuf, ... |
InterpolateInt64Function animation_private_current_interpolate_override(void) {
return NULL;
}
static FrameBuffer *fb = NULL;
// Setup
void test_gdraw_command_transforms__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
}
// Teardown
void test_gdraw_co... | test_graphics_context_init(&ctx, fb) | |
/*
* 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... | {
strncpy(dest, "QEMU", dest_size);
} | |
eponse *)event;
PBL_ASSERTN(data->subtype == PebbleBLEGATTClientEventTypeCharacteristicRead ||
data->subtype == PebbleBLEGATTClientEventTypeDescriptorRead);
gatt_err_code = prv_handle_response(resp, data, &gatt_value_length);
break;
}
case GattClient... | (value_out, read_response->value, read_response->length) | ;
}
list_remove(&read_response->node, (ListNode **) &s_read_responses[client], NULL);
kernel_free(read_response);
}
bt_unlock();
}
BTErrno gatt_client_op_write(BLECharacteristic characteristic,
const uint8_t *value,
size_t value_length,
... |
>rectr.size.h > data->window.layer.bounds.size.h) {
data->rectr_velocity_y = data->rectr_velocity_y * -1;
}
} else if (shape == CIRCLE) {
// Move the line X per Y
data->circle_origin.x += (data->circle_velocity_x * PIXEL_SPEED_PER_FRAME);
if (data->circle_origin.x - data->circle_radi... | if (shape == CIRCLE) {
graphics_context_set_fill_color(ctx, data->circle_color);
graphics_context_set_stroke_color(ctx, data->circle_color);
graphics_draw_circle(ctx, data->circle_origin, data->circle_radius);
} else if (shape == GPATH_TRIANGLE) {
gpath_draw_outline(ctx, data->triangle);
... |
}
}
static int64_t prv_time_64(void) {
time_t s;
uint16_t ms;
rtc_get_time_ms(&s, &ms);
return (int64_t)s * 1000 + ms;
}
static void layer_update_proc(Layer *layer, GContext* ctx) {
AppData *data = app_state_get_user_data();
graphics_context_set_fill_color(ctx, GColorBlack);
if (stroke_width_enabled... |
node) {
GATTServiceNode *next = (GATTServiceNode *) node->node.next;
kernel_free(node->service);
node->service = NULL;
kernel_free(node);
node = next;
}
connection->gatt_remote_services = NULL;
}
static void prv_remove_current_discovery_job(GAPLEConnection *connection) {
DiscoveryJobQueue *no... | {
prv_finalize_discovery(connection, errno);
} |
}
unlock:
bt_unlock();
return finalize_discovery;
}
BTErrno gatt_client_discovery_discover_all(const BTDeviceInternal *device) {
BTErrno ret_val = BTErrnoOK;
bt_lock();
{
GAPLEConnection *connection = gap_le_connection_by_device(device);
if (!connection) {
ret_val = BTErrnoInvalidParameter;
... |
++y) {
for (int x = 0; x < WIDTH; ++x) {
snprintf(print_buf, sizeof(print_buf), "Failed index = %d, %d", x, y);
cl_check_(gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]), print_buf);
cl_check_(gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]), print_buf);
}
}
#endif
bi... | {
memset(s_palette, color.argb, sizeof(s_palette));
} |
break;
}
case GCompOpAssign:
break;
case GCompOpTint: {
for (uint8_t idx = 0; idx < WIDTH; idx++) {
if (s_palette[idx].a == 3 || transparent) {
s_palette[idx] = color;
}
}
break;
}
default:
break;
}
cl_assert(prv_check_source_stripe... |
size_t value_length,
uint16_t value_offset,
BLEGATTError error) {
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
Uuid descriptor_uuid = ble_descriptor_get_uuid(descriptor);
uuid_to_string(&descriptor_uuid, uu... | uuid_equal(&hrm_uuid, &characteristic_uuid) | |
WeatherAppLayout *layout, Window *window) {
window_init(window, WINDOW_NAME("Weather"));
weather_app_layout_init(layout, &s_ctx.dest_bitmap.bounds);
weather_app_layout_set_data(layout, forecast);
window_set_user_data(window, layout);
Layer *window_root_layer = window_get_root_layer(window);
layer_add... | prv_create_layout_for_forecast_and_render(&forecast) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_weather_app_layout__render_generic_generic(void) {
const WeatherLocationForecast forecast = {
.location_name = "HOUSTON",
.current_temp = 110,
.today_high = 120,
.today_low = 85,
.current_weather_type = Weather... |
n illuminate for us what is going on here
// but in the meantime let's use this workaround.
prv_set_accel_power_mode(BMA255PowerMode_Normal);
prv_set_accel_power_mode(BMA255PowerMode_Standby);
}
PBL_LOG(LOG_LEVEL_WARNING, "Failed to program fifo reg, 0x%"PRIx8" = 0x%"PRIx8, address, data);
}
static vo... | (AccelOperatingMode_ShakeDetection, BMA255SampleInterval_83HZ) | ;
}
static void prv_disable_shake_detection(void) {
// Don't worry about the configuration registers but disable interrupts from the accel
bma255_write_register(BMA255Register_INT_EN_0, 0);
prv_disable_operating_mode(AccelOperatingMode_ShakeDetection);
}
void accel_enable_shake_detection(bool enable) {
if (s... |
rce_id,
uint32_t *num_bytes_out) { return NULL; }
// Helper Functions
////////////////////////////////////
#include "../graphics/test_graphics.h"
#include "../graphics/8bit/test_framebuffer.h"
static FrameBuffer *fb = NULL;
// Setup
void test_kino_reel__initialize(void) {
... | {
// Test loading PDCI Kino Reel
uint32_t resource_id = sys_resource_load_file_as_resource(
TEST_IMAGES_PATH, "test_kino_reel__resource_pdcs.pdc");
cl_assert(resource_id != UINT32_MAX);
KinoReel *kino_reel = kino_reel_create_with_resource(resource_id);
cl_assert(kino_reel);
cl_assert(kino_reel_get_ty... |
static KinoReelProcessor s_dummy_processor;
static void prv_dummy_impl_draw_processed(KinoReel *reel, GContext *ctx, GPoint offset,
KinoReelProcessor *processor) {
cl_assert_equal_p(processor, &s_dummy_processor);
}
void test_kino_reel__draw_processed(void) {
// Calling... |
/*
* 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_IF_RECT_ELSE(0, (rl_margin / 2)) | |
_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 4, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r4_aa_no_clip.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix left corners PBL-15915
setup_test_aa_sw(&ctx, fb, ORIGIN_... | graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1, GCornersAll) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_aa_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2), GCornersAll);
cl_check(gbitmap_p... |
/*
* 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... | calloc(1, size) | |
ne_minutes(HealthData *health_data) {
activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &health_data->hr_zone1_minutes);
activity_get_metric(ActivityMetricHeartRateZone2Minutes, 1, &health_data->hr_zone2_minutes);
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &health_data->hr_zone3_minutes... | {
return health_data->hr_zone2_minutes;
} |
int32_t health_data_hr_get_zone3_minutes(HealthData *health_data) {
return health_data->hr_zone3_minutes;
}
|
(a, false, false) | ;
cl_assert_equal_i(duration, duration_a);
// -------------------------------------------------------------------------------------
// Advance to the end
animation_set_elapsed(complex, duration_total);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_cou... | |
stdio.h>
#include <string.h>
#include "drivers/crc.h"
#include "drivers/flash.h"
#include "flash_region.h"
#include "git_version.auto.h"
#include "system/firmware_storage.h"
#include "system/passert.h"
#include "version.h"
//! The linker inserts the build id as an "elf external note" structure:
struct ElfExternalNote... | snprintf(buffer, buffer_bytes_left, "%02x", *build_id) | ;
buffer += 2;
buffer_bytes_left -= 2;
build_id += 1;
build_id_bytes_left -= 1;
}
}
static void version_fw_version_to_major_minor(unsigned int *major, unsigned int *minor,
char *version_str) {
// read in the two X's (vX.X)
sscanf(version_str, "v%u.%u", major, minor);
}
//! Compares its two a... |
28, 920},
{ -184, 1224, 1016},
{ -168, 1360, 1104},
{ -232, 1224, 992},
{ -200, 744, 768},
{ -128, 688, 552},
{ -96, 624, 608},
{ -104, 624, 584},
{ -152, 584, 520},
{ -136, 416, 416},
{ -136, 344, 344},
// 117 seconds
{ -152, 464, 344},
{ -144, 352, 448},
{ 8, 28... | { -160, 464, -912},
{ -40, 528, -1016},
{ -120, 600, -960},
{ -80, 264, -1192},
{ -248, -232, -504},
{ -216, -248, -1016},
{ -128, -296, -1024},
{ -328, -264, -952},
{ -88, -408, -920},
{ -264, -472, -928},
{ -216, -504, -824},
{ 8, -568, -896},
{ -224, -392, -928},
... |
// ----------------------------------------------------------------
// Sample captured: 2015-10-02 15:49:34 local
AccelRawData *activity_sample_walk_200_pbl_25479_9(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_25479_9
//> TEST_EXPECTED 200
//> T... |
<inttypes.h>
#include <stdint.h>
#include <stdio.h>
//! Evaluates to 1 iff execution will use the process stack when returning from
//! the exception.
#define RETURNS_TO_PSP(exc_return) ((exc_return & 0x4) == 0x4)
//! This symbol and its contents are provided by the linker script, see the
//! .note.gnu.build-id sec... | {
if (s_use_cd_flash_driver) {
cd_flash_read_bytes(buffer_ptr, start_addr, buffer_size);
} else {
flash_read_bytes(buffer_ptr, start_addr, buffer_size);
}
} |
// -------------------------------------------------------------------------------------------------
// NOTE: We are explicitly avoiding use of vsniprintf and cohorts to reduce our stack
// requirements
static void prv_debug_str(const char* msg) {
kernel_pbl_log_from_fault_handler(__FILE_NAME__, 0, msg);
}
// ---... |
ghted(ActionBarLayer *action_bar, uint8_t index) {
PBL_ASSERTN(index < NUM_ACTION_BAR_ITEMS);
return (bool) (action_bar->is_highlighted & (1 << index));
}
static void prv_register_redraw_timer(ActionBarLayer *layer);
static void prv_timed_redraw(void *context) {
ActionBarLayer *action_bar = context;
layer_mar... | {
graphics_context_set_fill_color(ctx, bg_color);
PBL_IF_RECT_ELSE(prv_draw_background_rect,
prv_draw_background_round)(action_bar, ctx, bg_color);
} | |
/*
* 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(s_flash_state.mutex != 0);
} |
static void enable_flash_dma_clock(void) {
// TINTINHACK: Rather than update this file to use the new DMA driver, just rely on the fact that
// this is the only consumer of DMA2.
periph_config_enable(DMA2, RCC_AHB1Periph_DMA2);
}
static void disable_flash_dma_clock(void) {
// TINTINHACK: Rather than update t... |
} else {
file->used_space += record_size(&file->iter.hdr);
}
if (file->iter.hdr.last_modified > file->last_modified) {
file->last_modified = file->iter.hdr.last_modified;
}
}
}
status_t settings_file_rewrite_filtered(
SettingsFile *file, SettingsFileRewriteFilterCallback filter_cb, void... | prv_is_desired_hdr(iter, key, key_len) | ) {
return true;
}
}
// If we got here, we didn't find it between `resumed_pos` and the last record in the file.
// Wrap around to the beginning and search until we get to the `resumed_pos`
settings_raw_iter_begin(iter);
for (; settings_raw_iter_get_current_record_pos(iter) < resumed_pos;
... |
ive(void) {
char time_buf[64];
const int jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 12:00:00
// Now - one day
const int event_time = jun10th_noon_2015 - SECONDS_PER_DAY;
// if the event is within 24 hours, then show the... | rtc_set_time(event_time - (2 * SECONDS_PER_MINUTE)) | ;
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 2 MIN", time_buf);
// June 10th 2015, 04:00:00 (T+12:00:00)
rtc_set_time(event_time + (12 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELA... |
et_size(&worker_ram) - stack_guard_size);
MemorySegment worker_segment;
PBL_ASSERTN(memory_segment_split(&worker_ram, &worker_segment,
worker_segment_size));
PBL_ASSERTN(memory_segment_split(&worker_segment, NULL, stack_guard_size));
// No (accessible) memory segments can be ... | if (s_next_worker.md != NULL) {
worker_manager_launch_new_worker_with_args(s_next_worker.md, s_next_worker.args);
} else {
// Do we have a default worker we should switch to that is different from the previous worker?
AppInstallId default_id = worker_manager_get_default_install_id();
if (default_id !=... | |
atic CompositorTransitionDirection prv_flip_transition_direction(
CompositorTransitionDirection direction) {
switch (direction) {
case CompositorTransitionDirectionUp:
return CompositorTransitionDirectionDown;
case CompositorTransitionDirectionDown:
return CompositorTransitionDirectionUp;
ca... | (ctx, scaled_br, scaled_bl) | ;
graphics_draw_line(ctx, scaled_bl, scaled_tl);
}
//! Callback to be used with prv_collapse_animation to fill with the current fill_color
static void prv_gpath_draw_filled_cb(GContext *ctx, int16_t y,
Fixed_S16_3 x_range_begin, Fixed_S16_3 x_range_end,
... |
prv_certification_window_push(data) | ;
break;
case SystemMenuItemStationaryToggle:
stationary_set_enabled(!stationary_get_enabled());
break;
case SystemMenuItemShutDown:
if (prv_shutdown_enabled()) {
launcher_task_add_callback(prv_shutdown_cb, 0);
}
break;
case SystemMenuItemFactoryReset:
setti... | |
ubs_events.h"
#include "stubs_hexdump.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
void app_install_clear_ap... | cl_assert_equal_b(true, uuid_equal(&app3.uuid, &temp.uuid)) | ;
cl_assert_equal_i(0, strncmp((char *)&app3.name, (char *)&temp.name, APP_NAME_SIZE_BYTES));
}
void test_app_db__retrieve_app_db_entries_by_install_id(void) {
AppDBEntry temp;
// check app_db_get_install_id_for_uuid for app 1
memset(&temp, 0, sizeof(AppDBEntry));
AppInstallId app_one_id = app_db_get_instal... |
de "stubs_logging.h"
#include "stubs_modal_manager.h"
#include "stubs_mutex.h"
#include "stubs_notification_storage.h"
#include "stubs_notifications.h"
#include "stubs_passert.h"
#include "stubs_phone_call_util.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_regular_timer.h"
#include "stubs_rem... | fake_event_init() | ;
pin_db_init();
}
void test_calendar__cleanup(void) {
timeline_event_deinit();
stub_new_timer_cleanup();
fake_settings_file_reset();
}
// Tests
////////////////////////////////////////////////////////////////
void test_calendar__no_events(void) {
timeline_event_init();
cl_assert_equal_i(fake_event_get_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... | (EWD1000->i2c, len, data) | |
AIN_EVENTS , sizeof(PebbleEvent));
PBL_ASSERTN(s_from_kernel_event_queue != NULL);
xQueueAddToSet(s_kernel_event_queue, s_system_event_queue_set);
xQueueAddToSet(s_from_app_event_queue, s_system_event_queue_set);
xQueueAddToSet(s_from_worker_event_queue, s_system_event_queue_set);
}
//! Get the from_process q... | {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
QueueHandle_t queue = event_get_to_kernel_queue(task);
prv_event_put(queue, "from app", saved_lr, event);
} | |
(BUTTON_ID_UP) | ;
// Now we're just holding down, which is a different combo
StubTimer *timer = prv_find_combo_timer();
cl_assert(timer);
cl_assert_equal_i(stub_new_timer_timeout(timer->id), 5000);
stub_new_timer_fire(timer->id);
cl_assert(!s_mfg_mode_entered);
cl_assert(s_select_cb_called);
}
void test_getting_star... | |
/*
* 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(((min_start & (~SUBSECTOR_ADDR_MASK)) == 0) &&
((max_end & (~SUBSECTOR_ADDR_MASK)) == 0) &&
(min_start <= max_start) &&
(max_start <= min_end) &&
(min_end <= max_end)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.