prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
---------------------
// Sample captured: 2015-10-05 16:17:23 local
AccelRawData *activity_sample_walk_200_pbl_25670_13(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_25670_13
//> TEST_EXPECTED 200
//> TEST_EXPECTED_MIN 165
//> TEST_EXPECTED_MAX 230
... | { 1176, 312, -104},
{ 904, 248, -16},
{ 672, 192, -16},
{ 616, 168, -48},
// 5 seconds
{ 616, 152, -24},
{ 744, 160, -16},
{ 904, 112, -8},
{ 1200, 168, 0},
{ 1200, 128, -16},
{ 1072, 120, -32},
{ 1216, 160, -80},
{ 1096, 104, -72},
{ 968, 112, -96},
{ 1144, 1... |
{ 1208, 96, -104},
{ 1088, 24, -104},
{ 1240, 136, -144},
{ 1144, 96, -64},
{ 1080, 88, -64},
{ 1256, 184, -160},
{ 1184, 216, -168},
{ 944, 208, -120},
{ 664, 216, -168},
{ 496, 176, -152},
{ 464, 152, -128},
{ 560, 192, -152},
// 8 seconds
{ 696, 240, -112},
... |
/*
* 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... | {
ActivitySession activity_sessions[MAX_ACTIVITY_SESSIONS];
uint32_t num_sessions = MAX_ACTIVITY_SESSIONS;
activity_get_sessions(&num_sessions, activity_sessions);
uint32_t total_seconds = 0;
time_t sleep_enter_utc = -1;
time_t sleep_exit_utc = -1;
for (uint32_t i = 0; i < num_sessions; i++) {
time_t... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (root_layer, &bounds) | ;
window_set_on_screen(appeared_window, true /* new window */, true /* call handlers */);
click_manager_clear(window_manager_get_window_click_manager(appeared_window));
}
static void prv_unload_removed_windows(WindowStack *window_stack) {
// Copy the removed windows list into a local array and then call the un... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_load_system_font(font_key) | ;
return result;
}
DEFINE_SYSCALL(GFont, sys_font_get_system_font, const char *font_key) {
if (font_key && PRIVILEGE_WAS_ELEVATED) {
if (!memory_layout_is_cstring_in_region(memory_layout_get_app_region(), font_key, 100) &&
!memory_layout_is_cstring_in_region(memory_layout_get_microflash_region(), font_... |
ame_out);
}
// Test that setting a local_name to NULL will rewrite the field with 0xFF and allow it to
// be rewritten without causing a new page to be written
void test_shared_prf_storage_v3__local_device_name_NULL_new_erased_field(void) {
shared_prf_storage_set_local_device_name(DEVICE_NAME);
char device_name_o... | (&PAIRING_INFO, DEVICE_NAME,
true /* requires_address_pinning */, 0xff /* flags */) | ;
shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE);
shared_prf_storage_set_local_device_name(DEVICE_NAME);
for (uint32_t i = 0; i < 50; i++) {
GETTING_STARTED_COMPLETE = !GETTING_STARTED_COMPLETE;
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), i % SPRF_NUM_PAGES);... |
ERY_INTERVAL 1
typedef struct {
uint16_t service_id;
uint16_t attribute_id;
} ReadInfo;
typedef struct PACKED {
uint8_t version;
uint16_t service_id;
uint16_t attribute_id;
uint8_t type;
uint8_t error;
uint16_t length;
} FrameInfo;
typedef struct PACKED {
uint16_t service_id;
uint16_t attribute_... | (LOG_LEVEL_WARNING, "Service discovery response is invalid length: %"PRIu32, length) | ;
return false;
}
// validate and mark the services as connected
uint32_t i;
uint16_t *services = data;
bool has_valid_service = false;
for (i = 0; i < length / sizeof(uint16_t); i++) {
if ((services[i] > ReservedServiceMax) || (services[i] == ReservedServiceControl)) {
has_v... |
ata = {
.perimeter.impl = &(GPerimeter){.callback=perimeter_for_display_round},
.perimeter.inset = 8,
},
};
render_steps(&layout, RenderMoveDrawBox, DELTA, DISP_ROWS, NULL);
// should result in the very same output as if you did a placement via text box
cl_check(gbitmap_pbi_eq(s_dest_bitmap, "te... | (144, 300) | ;
prv_prepare_fb_steps_xy(size, num_steps, 1);
ctx.draw_state.avoid_text_orphans = true;
render_steps(&layout, RenderMoveDrawBox, 0, size.h, texts);
// draw markers to visualize page breaks
ctx.draw_state.clip_box = s_dest_bitmap->bounds;
ctx.draw_state.drawing_box = s_dest_bitmap->bounds;
ctx.dest_bit... |
int16_t overshoot, uint32_t delay_duration,
uint32_t pulse_duration) {
uint32_t stage_duration = (pulse_duration / 3);
// Declare these here so that if we goto cleanup, then the variables are initialized
PropertyAnimation *expand = NULL;... | animation_unschedule(data->mic_window.mic_dot_anim) | ;
}
const GRect *root_frame = &window_get_root_layer(&data->mic_window.window)->frame;
GRect dot_frame = data->mic_window.mic_dot_layer.frame;
grect_align(&dot_frame, root_frame, GAlignCenter, false);
layer_set_frame(&data->mic_window.mic_dot_layer, &dot_frame);
layer_set_hidden(&data->mic_window.mic_dot_l... |
DB_END;
fake_flash_assert_region_untouched(FLASH_REGION_DEBUG_DB_END, size);
fake_spi_flash_cleanup();
}
typedef struct {
char **msg_arr;
int curr_msg_idx;
int num_items;
int num_processed;
} ExpectedMessage;
static ExpectedMessage s_msg;
void test_flash_logging_get_info(uint32_t *tot_size, uint32_t *era... | {
memcpy(&msg[j], buf, MIN(strlen(buf), log_len - j));
} |
msg[log_len] = '\0';
msg_arr[i] = task_strdup(msg);
}
return (msg_arr);
}
static void free_logs(char **msg_arr, int num_logs) {
for (int i = 0; i < num_logs; i++) {
free(msg_arr[i]);
}
free(msg_arr);
}
//
// Actual Tests
//
//! Simple test to confirm that we can log and read back several me... |
/*
* 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... | {
const GPoint p = GPoint(x, y);
// Calculate the new mask pixel value
const GColor8Component src_color_luminance = gcolor_get_luminance(color);
const uint8_t current_mask_value = graphics_private_raw_mask_get_value(ctx, mask, p);
const uint8_t new_pixel_value =
g_bitblt_private_blending_mask... | |
-872},
{ -56, 528, -864},
{ -56, 520, -848},
{ -64, 512, -856},
{ -64, 536, -856},
// 294 seconds
{ -64, 544, -864},
{ -56, 512, -856},
{ -56, 528, -848},
{ -64, 528, -848},
{ -64, 520, -856},
{ -56, 536, -856},
{ -56, 528, -856},
{ -64, 528, -864},
{ -72, 528, -... | { -120, 544, -856},
{ -104, 584, -840},
{ -112, 584, -784},
{ -128, 576, -800},
{ -120, 560, -824},
{ -120, 536, -856},
{ -112, 536, -864},
{ -96, 544, -832},
{ -104, 552, -816},
{ -120, 552, -824},
{ -112, 536, -848},
{ -104, 552, -848},
{ -120, 568, -824},
{ -11... |
{ -120, 568, -832},
{ -120, 544, -816},
{ -120, 536, -816},
{ -120, 552, -816},
// 302 seconds
{ -128, 568, -824},
{ -120, 576, -832},
{ -120, 568, -840},
{ -136, 568, -816},
{ -128, 560, -824},
{ -112, 552, -824},
{ -112, 552, -816},
{ -120, 560, -824},
{ -112, ... |
/*
* 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... | (GROUP_TYPE,
attr_list,
action_group) | ;
}
size_t attributes_actions_serialize_payload(AttributeList *attr_list,
TimelineItemActionGroup *action_group,
uint8_t *buffer,
size_t buffer_size) {
return attribute_group_serialize_... |
(ppogatt_client_count(), 1) | ;
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true);
Transport *client2 = ppogatt_client_for_uuid(&s_meta_v0_system.app_uuid);
}
void test_ppogatt__invalidate_characteristic_refs_immediately_after_update(void) {
prv_notify_services_discovered(1);
ppogatt_handle_service_removed(&s... | |
RRY_INIT_EMPTY);
s_app_window_stack_get_top_window = (Window){};
s_app_event_loop_callback = NULL;
s_log_internal__expected = NULL;
s_prv_api_init__callcount = 0;
s_prv_api_add__callcount = 0;
s_prv_api_add__result = false;
s_prv_api_remove__callcount = 0;
s_prv_listener_a1__callcount = 0;
s_prv_li... | jerry_release_value(o) | ;
cl_assert_equal_i(2, jerry_obj_refcount(o));
jerry_release_value(o);
cl_assert_equal_i(1, jerry_obj_refcount(o));
jerry_release_value(o);
cl_assert_equal_i(0, jerry_obj_refcount(o));
}
void test_rocky_api_global__calls_listeners(void) {
static const RockyGlobalAPI *apis[] = {NULL};
rocky_global_init(ap... |
/*
* 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 (characteristic_out) {
syscall_assert_userspace_buffer(characteristic_out, sizeof(*characteristic_out));
} |
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,
... |
t;
}
ModalProperty modal_manager_get_properties(void) {
return s_modal_window_present ? ModalProperty_Exists : ModalPropertyDefault;
}
GContext* kernel_ui_get_graphics_context(void) {
static GContext s_context;
return &s_context;
}
void framebuffer_clear(FrameBuffer* f) {
}
void framebuffer_dirty_all(FrameBuf... | (s_count_animation_schedule, 1) | ;
cl_assert_equal_i(s_count_compositor_init_func_a, 1);
cl_assert_equal_i(s_count_compositor_init_func_b, 1);
// Make the app render, now the animation should be scheduled
compositor_app_render_ready();
cl_assert_equal_i(s_count_animation_schedule, 2);
// Push a modal window mid transition, the resulting ... |
equal_i(s_hrm_manager_subscribe_with_callback_call_count, 0);
ble_hrm_init(); // reinit, __cleanup() will deinit again
}
static void prv_put_and_assert_hrm_event(HRMEventType subtype, uint8_t bpm, HRMQuality quality,
bool expect_bt_driver_cb, bool expected_is_on_wrist) {
i... | (true, regular_timer_is_scheduled(timer)) | ;
cl_assert_equal_i(0, s_ble_hrm_push_reminder_popup_call_count);
fake_regular_timer_trigger(timer);
cl_assert_equal_i(1, s_ble_hrm_push_reminder_popup_call_count);
// Except timer to be rescheduled again:
cl_assert_equal_b(true, regular_timer_is_scheduled(timer));
bt_driver_cb_hrm_service_update_subscri... |
s7000_watchdog_timer;
// Incremented by s_as7000_watchdog_timer. Reset to 0 by our interrupt handler.
static uint8_t s_missing_interrupt_count;
//! Interval timer to track how frequently the as7000 is handshaking with us
static IntervalTimer s_handshake_interval_timer;
static void prv_enable_timer_cb(void *context);... | prv_write_register_block(dev, ADDR_ACCEL_SAMPLE_IDX, &sample_data, sizeof(sample_data)) | ;
}
static void prv_read_hrm_data(HRMDevice *dev, HRMData *data) {
struct PACKED {
uint16_t led_current;
uint8_t hrm_status;
uint8_t bpm;
uint8_t sqi;
} hrm_data_regs;
prv_read_register_block(dev, ADDR_LED_CURRENT_MSB, &hrm_data_regs, sizeof(hrm_data_regs));
data->led_current_ua = ntohs(hrm_d... |
cl_assert_equal_i(zone2_minutes, 0) | ;
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes);
cl_assert_equal_i(zone3_minutes, 0);
}
// ---------------------------------------------------------------------------------------
// Test that we can add / delete an activity session
void test_activity__activity_sessions_add_delete_sess... | |
;
bool is_success;
uint32_t total_size;
uint32_t append_offset;
uint32_t remaining_bytes;
PutBytesStorage storage;
//! the time in ticks at which the put bytes init request completed
RtcTicks start_ticks;
SlaveConnEventStats conn_event_stats;
//! Holds PB commands. Will enqueue multiple PutRequests... | if (put_jobs->enable_preack) {
// Don't Pre-Ack if the payload that is arriving will fill our job queue
pre_ack = ((put_jobs->num_ops_pending + 1) < put_jobs->num_allocated_pb_jobs);
} |
put_jobs->need_to_ack_later = !pre_ack;
}
prv_unlock_pb_job_state();
if (pre_ack) {
prv_send_response(ResponseAck, s_pb_state.token);
} else if (put_jobs->enable_preack) {
PBL_LOG(LOG_LEVEL_DEBUG, "Not enough buffer room to pre-ack PB packet");
}
}
static void prv_deinit_put_job_queue(void) {
... |
t_utc = start_of_today + (13 * SECONDS_PER_HOUR), // 1pm
.length_min = 2 * MINUTES_PER_HOUR,
.type = ActivitySessionType_Sleep,
},
{
.start_utc = start_of_today + (17 * SECONDS_PER_HOUR), // 5pm
.length_min = 2 * MINUTES_PER_HOUR,
.type = ActivitySessionType_Sleep,
... | (&steps_awake_60m) | |
_data->read_cursor, true, NULL);
if (metadata_bytes <= 0) {
goto cleanup;
}
buffer = applib_zalloc(metadata_bytes);
if (buffer == NULL) {
goto cleanup;
}
ResAppNum app_num = sys_get_current_resource_num();
const size_t bytes_read = sys_resource_load_range(
app_num, bitmap_sequence->resour... | {
const uint32_t corrected_dst_x = x + delta_x;
const uint8_t palette_index = raw_image_get_value_for_bitdepth(upng_buffer, x, y,
row_stride_bytes, bpp);
const GColor8 src = palette[palette_index];
GColor8 *const dst = (GColor8 *)(row_info.data + corrected_dst_x);
if... |
}
} else if (png_format >= UPNG_LUMINANCE1 && png_format <= UPNG_LUMINANCE8) {
const int32_t transparent_gray = gbitmap_png_get_transparent_gray_value(upng);
for (uint32_t y = 0; y < fctl.height; y++) {
const uint16_t corrected_y = fctl.y_offset + y + bitmap->bounds.origin.y;
const GBitmapDa... |
em, current_day);
timeline_item_layer_set_item(&pin_window->item_detail_layer, item, &pin_window->info);
}
static Animation *prv_create_bounds_origin_animation(
TimelinePinWindow *pin_window, GPoint *from_origin, GPoint *to_origin) {
Animation *animation = property_animation_get_animation(
property_anima... | (layer, &frame) | |
,
{ 920, 8, -192},
{ 880, 88, -312},
{ 840, -8, -416},
{ 832, -72, -472},
{ 832, -24, -496},
{ 840, -200, -440},
{ 864, 16, -424},
{ 848, -64, -408},
{ 848, -64, -400},
{ 872, -176, -344},
{ 904, -56, -376},
{ 864, 32, -320},
{ 904, 8, -344},
{ 888, -40, -264},
... | { 448, 528, -456},
{ 432, 592, -392},
{ 456, 720, -432},
{ 552, 584, -504},
{ 504, 480, -440},
{ 552, 608, -576},
{ 528, 472, -480},
// 13 seconds
{ 472, 472, -624},
{ 464, 384, -632},
{ 456, 88, -784},
{ 504, 288, -864},
{ 520, 16, -728},
{ 600, 248, -664},
{... |
{ 368, 672, -776},
{ 352, 704, -736},
{ 360, 432, -576},
{ 464, 528, -768},
{ 400, 352, -576},
{ 456, 560, -648},
{ 440, 472, -616},
{ 432, 472, -680},
{ 400, 480, -760},
{ 424, 352, -784},
{ 464, 440, -848},
{ 520, 712, -688},
{ 392, 440, -736},
{ 504, 80, -640}... |
/*
* 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... | (&bitmap_layer, GCompOpAssign) | ;
layer_render_tree(bitmap_layer_get_layer(&bitmap_layer), &s_ctx);
}
static void prv_origin_bitmap_layer_test(GPoint bounds_origin) {
prv_bitmap_layer_test(GPointZero, bounds_origin);
}
static void prv_offset_bitmap_layer_test(GPoint bounds_origin) {
prv_bitmap_layer_test(TEST_LAYER_OFFSET_ORIGIN, bounds_origi... |
e_private.h"
#include "applib/platform.h"
#include "applib/rockyjs/rocky_res.h"
#include "applib/ui/dialogs/dialog.h"
#include "applib/ui/dialogs/expandable_dialog.h"
#include "process_state/app_state/app_state.h"
#include "process_state/worker_state/worker_state.h"
#include "pebble_process_md.h"
#include "kernel/peb... | new_timer_create() | |
{
acc_odr = BMI160AccODR_100_HZ;
} else if (BMI160SampleRate_200_HZ == sample_rate) {
acc_odr = BMI160AccODR_200_HZ;
} else if (BMI160SampleRate_400_HZ == sample_rate) {
acc_odr = BMI160AccODR_400_HZ;
} else if (BMI160SampleRate_800_HZ == sample_rate) {
acc_odr = BMI160AccODR_800_HZ;
} else { //... | BMI160_DBG("INT_MAP[1] = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_INT_MAP_1)) | ;
BMI160_DBG("INT_EN[1] = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_INT_EN_1));
int_enabled = enable_int;
s_fifo_in_use = use_fifo;
}
void accel_set_num_samples(uint32_t num_samples) {
uint8_t fifo_frame_size = prv_get_fifo_frame_size(); // x,y,z accel data
uint16_t max_num_samples = (BMI160_FIFO_LEN_BYTES / fif... |
uint8_t max_put_ops = prv_put_bytes_get_max_batched_pb_ops();
prv_receive_init(VALID_OBJECT_SIZE * max_put_ops, ObjectFirmware);
prv_process_and_reset_test_counters();
const uint8_t chunk[] = { 0xaa, 0xbb, 0xcc, 0xdd };
for (int i = 0; i < max_put_ops; i++) {
prv_receive_put(s_last_response_cookie, chun... | assert_ack_count(1) | ;
assert_nack_count(0);
cl_assert_equal_i((s_boot_bits_orred & BOOT_BIT_NEW_PRF_AVAILABLE), BOOT_BIT_NEW_PRF_AVAILABLE);
}
void test_put_bytes__install_message_fw_and_sys_resources_boot_bits_set(void) {
// Firmware object:
prv_receive_init_put_commit_and_install(ObjectFirmware);
assert_ack_count(1);
assert... |
turn custom_node;
}
static void prv_destroy_text_node_base(GTextNode *node) {
if (node && node->free_on_destroy) {
task_free(node);
}
}
static bool prv_destroy_container_iter(GTextNode *node, void *context) {
graphics_text_node_destroy(node);
return true;
}
static void prv_destroy_text_node_container(GTe... | prv_container(ctx->node)->get_axis_align(ctx->node) | ;
graphics_text_node_get_size(ctx->node, ctx->gcontext, ctx->draw_box, ctx->config, &max_used_size);
const int16_t excess_length = ToGValue(&ctx->box.size)[axis] - ToGValue(&max_used_size)[axis];
if (align == GAxisAlign_Center) {
ToGValue(&ctx->box.origin)[axis] += excess_length / 2;
} else if (align == GAx... |
r), 8);
contiguous_num_bytes_left = circular_buffer_write_prepare(&buffer, &data_out);
cl_assert_equal_i(contiguous_num_bytes_left, 0);
cl_assert_equal_p(data_out, NULL);
const uint16_t copy_out_size = 8;
uint8_t copy_out[copy_out_size];
cl_assert_equal_i(circular_buffer_copy(&buffer, copy_out, copy_out_s... | circular_buffer_read(
&buffer, sizeof(letterB), (const uint8_t **)&data_buf, &num_bytes) | );
cl_assert_equal_i(num_bytes, sizeof(letterB));
cl_assert_equal_m(data_buf, &letterB, sizeof(letterB));
}
|
E_MASK));
}
static bool page_is_erased(uint8_t page_flags) {
return (page_type_bits_set(page_flags, PAGE_FLAG_ERASED_PAGE));
}
static bool page_is_unallocated(uint8_t page_flags) {
return (page_is_deleted(page_flags) || page_is_erased(page_flags) ||
(page_flags == 0xff));
}
static uint8_t prv_get_page_... | prv_flash_read((uint8_t *)file_hdr, sizeof(*file_hdr), FILEHEADER_OFFSET +
prv_page_to_flash_offset(page)) | ;
if (compute_file_header_crc(file_hdr) != file_hdr->hdr_crc) {
return (HdrCrcCorrupt);
}
return (PageAndFileHdrValid);
}
static status_t write_file_header(FileHeader *hdr, uint16_t pg) {
hdr->hdr_crc = compute_file_header_crc(hdr);
prv_flash_write((uint8_t *)hdr, sizeof(*hdr), prv_page_to_flash_offset... |
hrm_manager_unsubscribe(session_ref);
}
// Advance time the given number of milliseconds
static void prv_advance_time_ms(uint32_t ms) {
RtcTicks delta_ticks = milliseconds_to_ticks(ms);
fake_rtc_set_ticks(rtc_get_ticks() + delta_ticks);
rtc_set_time(rtc_get_time() + ms / MS_PER_SECOND);
}
// Test that we handl... | hrm_manager_enable(true) | ;
cl_assert(prv_can_turn_sensor_on());
fake_system_task_callbacks_invoke_pending();
cl_assert(hrm_is_enabled(HRM));
// Test the pref changes
s_activity_prefs_heart_rate_is_enabled = false;
hrm_manager_handle_prefs_changed();
cl_assert(!prv_can_turn_sensor_on());
fake_system_task_callbacks_invoke_pendin... |
v_fixed_s32_16_getter(Fixed_S32_16 *p) {
return *p;
}
// --------------------------------------------------------------------------------------
static void prv_uint32_setter(int32_t *p, uint32_t value) {
*p = value;
}
static uint32_t prv_uint32_getter(uint32_t *p) {
return *p;
}
// --------------------------... | cl_assert_equal_i(s_stopped_handler_calls.num_calls, 1) | ;;
cl_assert(s_stopped_handler_calls.entries[0].fired_time_ms - start_ms >= duration);
cl_assert(s_stopped_handler_calls.entries[0].context == context);
cl_assert(s_stopped_handler_calls.entries[0].finished);
// -------------------------------------------------------------------------------------------
// T... |
dialog_set_icon(dialog, RESOURCE_ID_WORKOUT_APP_DETECTED);
dialog_set_icon_animate_direction(dialog, DialogIconAnimateNone);
dialog_set_destroy_on_pop(dialog, false);
const char *dialog_text =
workout_utils_get_detection_text_for_activity(data->ongoing_session.type);
workout_dialog_set_text(workout_dial... | workout_push_summary_window() | ;
}
}
static void prv_deinit(void) {
WorkoutAppData *data = app_state_get_user_data();
workout_service_frontend_closed();
app_free(data);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// App Main
static void prv_main(void) {
prv_init();
app_event_l... |
erviceStats 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_week = positive_modulo(day_in_week, DAYS_PER_WEEK);
HealthValue value = 1000 + (i * 50);
s_sys_activity_ge... | (result, exp_value) | |
KinoReel *new_reel = kino_reel_scale_segmented_create(from_reel, take_ownership, icon_from);
kino_reel_transform_set_to_frame(new_reel, icon_to);
kino_reel_transform_set_transform_duration(new_reel, duration / 2);
kino_reel_scale_segmented_set_delay_by_distance(
new_reel, GPoint(icon_from.size.w, icon_from.... | animation_set_handlers(animation, (AnimationHandlers) {
.stopped = prv_up_down_stopped,
}, layout) | |
ytics.h"
#include "stubs_hexdump.h"
#include "stubs_layout_layer.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
#define CONTACT_1_UUID 0x0a, 0... | contacts_db_insert((uint8_t *)&contact, UUID_SIZE,
(uint8_t *)&contact, sizeof(contact)) | |
mark.
line->suffix_codepoint = HYPHEN_CODEPOINT;
utf8_t* last_visited = walk_line(ctx, line, text_box_params,
(CharVisitorCallback) update_dimensions_char_visitor_cb);
last_visited = (last_visited == NULL) ? (word->start) : last_visited;
// Trim the word
int suffix_width_px = prv_codepoint... | if (is_ellipsis_on_overflow) {
callbacks->last_line_cb = set_ellipsis_on_overflow_last_line_cb;
} else {
callbacks->last_line_cb = NULL;
} | |
board/board.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "drivers/rtc.h"
#include "FreeRTOS.h"
#include "kernel/pbl_malloc.h"
#include "os/tick.h"
#include "kernel/util/sleep.h"
#include "kernel/util/stop.h"
#include "os/mutex.h"
#include "semphr.h"
#include "services/common/analytics/analyt... | gpio_af_init(&bus->scl_gpio, GPIO_OType_OD, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL) | ;
gpio_af_init(&bus->sda_gpio, GPIO_OType_OD, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL);
}
static void prv_bus_pins_cfg_input(I2CBus *bus) {
InputConfig in_scl = {
.gpio = bus->scl_gpio.gpio,
.gpio_pin = bus->scl_gpio.gpio_pin,
};
gpio_input_init(&in_scl);
InputConfig in_sda = {
.gpio = bus->sda_gpio.... |
serial_string[MFG_SERIAL_NUMBER_SIZE + 1];
char hw_version_string[MFG_HW_VERSION_SIZE + 1];
char uptime_string[16]; // "xxd xxh xxm xxs"
char const * subtitle_text[SystemInformationItem_Count];
char language_string[16];
} SystemInformationData;
typedef struct SettingsSystemData {
SettingsCallbacks callbacks... | {
PBL_ASSERTN(cell_index->section == 0);
PBL_ASSERTN(cell_index->row < SystemInformationItem_Count);
SettingsSystemData *data = (SettingsSystemData *) context;
SystemInformationData *info = &data->information_data;
const char *title = i18n_get(s_information_titles[cell_index->row], data);
menu_cell_basic_... |
int16_t prv_information_get_cell_height_callback(MenuLayer *menu_layer,
MenuIndex *cell_index, void *context) {
return PBL_IF_RECT_ELSE(menu_cell_basic_cell_height(),
(menu_layer_is_index_selected(menu_layer, cell_index) ?
... |
tain 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 License... | if (bt_device_internal_equal(device, &s_connections[i]->device)) {
return s_connections[i];
} |
}
return NULL;
}
BTDeviceInternal *device_from_le_connection(GAPLEConnection *conn) {
return &conn->device;
}
bool gap_le_connection_is_valid(const GAPLEConnection *conn) {
for (int i = 0; i < ARRAY_LENGTH(s_connections); ++i) {
if (s_connections[i] == conn) {
return true;
}
}
return false;
... |
bool failed = false;
if (!prv_run_test_step(BTLETestStep_BTLEStop, data)) {
failed = true;
goto cleanup;
} else if (data->current_test == BTLETestType_RX) {
snprintf(data->status_string, STATUS_STRING_LENGTH,
"Packets Received: %"PRIu16, data->rx_test_received_packets);
app_window_stack... | (&data->payload_window, true) | |
->pg_cache = kernel_malloc(sizeof(FilePageCache) * cur_idx);
if (f->pg_cache != NULL) { // if we are not OOM
memcpy(f->pg_cache, fpc, sizeof(FilePageCache) * cur_idx);
f->pg_cache_len = cur_idx;
}
kernel_free(fpc);
}
///
/// Helper routines for pfs_open()
///
//! Returns true iff the file is found in t... | {
res = E_OUT_OF_MEMORY;
goto cleanup;
} |
file->namelen = strlen(name);
file->start_offset = FILEDATA_LEN + file->namelen;
if (is_tmp || ((res == E_DOES_NOT_EXIST) && ((op_flags & OP_FLAG_WRITE) != 0))) {
res = pfs_open_handle_create_request(fd, file_type, start_size);
} else if ((op_flags & OP_FLAG_READ) != 0) {
res = pfs_open_handle_read_re... |
pBondingFileSetFail);
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to store pinned address");
} else if (rv == GapBondingFileSetUpdated) {
shared_prf_storage_set_ble_pinned_address(addr);
}
return success;
}
BTBondingID bt_persistent_storage_store_ble_pairing(const SMPairingInfo *new_pairing_info,
... | prv_init_and_assign_ble_bonding(&bonding, deleted_data) | ;
bt_driver_handle_host_removed_bonding(&bonding);
}
void bt_persistent_storage_delete_ble_pairing_by_id(BTBondingID bonding) {
BtPersistBondingData deleted_data;
if (!prv_delete_pairing_with_type_by_id(bonding, BtPersistBondingTypeBLE, &deleted_data)) {
return;
}
prv_remove_ble_bonding_from_bt_driver(&... |
m_dnd_events_put, 1);
do_not_disturb_set_manually_enabled(false);
enabled = do_not_disturb_is_manually_enabled();
cl_assert(do_not_disturb_is_active() == false);
cl_assert(enabled == false);
prv_assert_manually_dnd_setting_val(false);
cl_assert_equal_i(s_num_dnd_events_put, 2);
do_not_disturb_set_manual... | (WeekdaySchedule, true) | ;
active = do_not_disturb_is_active();
cl_assert(active == true);
}
void test_do_not_disturb__disabling_manual_dnd_should_override_scheduled(void) {
bool active;
// Time 00:00, Manual and Scheduled DND both OFF
DoNotDisturbSchedule schedule = {
.from_hour = 0,
.from_minute = 30,
.to_hour = 12,
... |
nclude "kernel/pbl_malloc.h"
#include "popups/phone_ui.h"
#include "services/common/analytics/analytics.h"
#include "services/common/comm_session/session.h"
#include "services/common/phone_pp.h"
#include "services/common/system_task.h"
#include "services/normal/notifications/alerts.h"
#include "services/normal/notifica... | analytics_stopwatch_stop(ANALYTICS_DEVICE_METRIC_PHONE_CALL_TIME) | |
/*
* 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->list, data->target) | |
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 3);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 3);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 1);
... | cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 2) | |
ew_window = window_create();
window_set_window_handlers(new_window, &(WindowHandlers){
.load = prv_window_load,
.unload = prv_window_unload
});
cl_check(window->parent_window_stack);
cl_assert_equal_i(window->on_screen, true);
cl_assert_equal_i(window->is_loaded, false);
window_stack_push(window->... | (window1, true) | ;
cl_assert_equal_i(app_window_stack_count(), 1);
cl_assert_equal_i(window1->on_screen, true);
app_window_stack_push(window2, true);
cl_assert_equal_i(app_window_stack_count(), 2);
cl_assert_equal_i(window1->on_screen, false);
cl_assert_equal_i(window2->on_screen, true);
app_window_stack_remove(window... |
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Adverts (re)started");
}
return rv;
}
static ble_error_t prv_advert_disable(void) {
ble_error_t rv = ble_gap_adv_stop();
if (rv != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_adv_stop: status = 0x%x", rv);
}
return rv;
}
static ble_error_t prv_try_to_en... | {
prv_advert_disable();
} |
s_adv_state = AdvertState_Pausing;
} else if (s_adv_state == AdvertState_Paused) {
// It's safe to call the cb
cb(ctx);
cb_executed = true;
prv_resume_if_needed();
}
}
prv_unlock();
return cb_executed;
}
void advert_init(void) {
s_adv_state = AdvertState_Off;
s_desired... |
/*
* 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(after_stats.allocated_bytes - before_stats.allocated_bytes >=
ROCKY_API_MEMORY_HEADROOM_DESIRED_SIZE_BYTES) | ;
cl_assert_equal_b(true, rocky_global_has_event_handlers("memorypressure"));
}
void test_rocky_api_memory__oom_app_fault_if_handler_allocates_more_than_headroom(void) {
s_skip_pbl_malloc_check = true;
cl_assert_passert(EXECUTE_SCRIPT(
"var data = [];\n"
"_rocky.on('memorypressure', function(){\n"
"... |
_x, clip_max_x)) {
goto cleanup;
}
// x-intersections of path segments whose direction is up
intersections_up = applib_zalloc(path->num_points * sizeof(int16_t));
// x-intersections of path segments whose direction is down
intersections_down = applib_zalloc(path->num_points * sizeof(int16_t));
// If e... | {
if (!points) {
return;
}
// draw precise path (no real support currently for paths with GPointPrecise)
for (uint16_t i = 0; i < (open ? (num_points - 1) : num_points); ++i) {
size_t i2 = (i + 1) % num_points;
graphics_line_draw_precise_stroked(ctx, points[i], points[i2]);
}
} | |
const PlatformType sdk_platform =
process_metadata_get_app_sdk_platform(s_app_task_context.app_md);
if (sdk_platform == PBL_PLATFORM_TYPE_CURRENT) {
*size = GSize(DISP_COLS, DISP_ROWS);
return;
}
// We cannot use the SDK type for this compatibility check but there's
// also no easy way to get the ... | (uuid, sizeof(*uuid)) | ;
}
*uuid = app_manager_get_current_app_md()->uuid;
}
DEFINE_SYSCALL(Version, sys_get_current_app_sdk_version, void) {
return process_metadata_get_sdk_version(app_manager_get_current_app_md());
}
DEFINE_SYSCALL(bool, sys_get_current_app_is_js_allowed, void) {
return (app_manager_get_current_app_md()->allow_j... |
c void prv_handle_characteristic_write(const PebbleBLEGATTClientEvent *e) {
BLEAppState *ble_app_state = app_state_get_ble_app_state();
const BLEClientWriteHandler handler = ble_app_state->gatt_characteristic_write_handler;
if (handler) {
handler(e->object_ref, e->gatt_error);
}
}
static void prv_handle_ch... | {
const off_t offset = offsetof(BLEAppState, gatt_characteristic_write_handler);
return prv_set_handler(handler, offset);
} | |
l_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + WAKEUP_EVENT_WINDOW);
// Test that another event < 1 minute away fails to schedule (E_DOES_NOT_EXIST)
wakeup_id = sys_wakeup_schedule(sys_get_time() + WAKEUP_EVENT_WINDOW + 59, 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIS... | ((void *)(uintptr_t)first_wakeup_id) | ;
// The current timer should be the second event, even though it is in the past, and should
// have a WAKEUP_CATCHUP_WINDOW second gap scheduled
TimerID gap_timer = wakeup_get_current();
cl_assert_equal_i(stub_new_timer_timeout(gap_timer) / 1000, WAKEUP_CATCHUP_WINDOW);
stub_new_timer_fire(wakeup_get_curre... |
/*
* 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... | _Static_assert(offsetof(MovementData, version) == 0, "Version not at the start of MovementData") | |
e, chunk, sizeof(chunk));
}
assert_ack_count(max_pb_ops);
assert_nack_count(1);
}
void test_put_bytes__chunk_too_large(void) {
prv_receive_init_fw_object();
prv_process_and_reset_test_counters();
size_t chunk_size = 1024 * 1024;
uint8_t *chunk = kernel_malloc(chunk_size);
prv_receive_put(s_last_respo... | prv_receive_put(s_last_response_cookie, chunk, sizeof(chunk)) | ;
}
prv_receive_commit(s_last_response_cookie, EXPECTED_CRC);
assert_ack_count(max_put_ops); // For the Put(s)
assert_nack_count(1); // For the Commit
}
void test_put_bytes__commit_message_cookie_mismatch(void) {
prv_receive_init_and_put_fw_object();
prv_receive_commit(~s_last_response_cookie, EXPECTED_... |
{ 0, 0x6e, 1422, 0x0},
{ 0, 0x7f, 947, 0x0},
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f, 11, 0x0},
// 255: Local time: 01:46:00 AM
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f, 17, 0x0},
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f, 0, 0x0},
{ 0, 0x7f,... | // 375: Local time: 03:46:01 AM
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x0},
{ 0, 0x4b, 0, 0x... | |
sportState_Idle;
prv_lock();
circular_buffer_consume(&s_spi_transport.tx, s_spi_transport.bytes_sendable_count);
prv_unlock();
prv_give_semamphore_from_isr(should_context_switch);
}
static void prv_handle_sending_complete_isr(bool *should_context_switch) {
// Wait for the controller to signal that it's read... | if (s_spi_transport.status_remote.msg_id != SPITransportMsgID_Status) {
// Unexpected msg ID...
prv_trigger_core_dump_from_isr();
return;
} |
// We now know how many bytes to receive / send:
s_spi_transport.bytes_receivable_count = MIN(s_spi_transport.status_local->bytes_receivable_count,
s_spi_transport.status_remote.bytes_sendable_count);
s_spi_transport.bytes_sendable_count = MIN(s_spi_transport.statu... |
2 * SECONDS_PER_MINUTE);
cl_assert(workout_service_stop_workout());
// Wait 20 minutes. By this time, as soon as we leave the app, we should turn off the HR device.
prv_inc_time(20 * SECONDS_PER_MINUTE);
workout_service_frontend_closed();
cl_assert_equal_b(s_hrm_subscribed, false);
cl_assert_equal_i(s_hrm... | (hr_zone_time_s[HRZone_Zone2], 10) | ;
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 20);
prv_inc_time(10);
prv_put_bpm_event(ZONE_2_HR, HRMQuality_Good);
cl_assert(workout_service_get_current_workout_hr_zone_time(hr_zone_time_s));
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone1], 20);
cl... |
_browse_svc_t *evt) {
// Check whether the service is the "GATT Profile Service":
att_uuid_t gatt_service_uuid;
ble_uuid_create16(GATT_SERVICE_UUID, &gatt_service_uuid);
att_uuid_t service_changed_characteristic_uuid;
ble_uuid_create16(GATT_SERVICE_CHANGED_CHARACTERISTIC_UUID, &service_changed_characteristi... | {
ppogatt_inject_emulated_ppogatt_service_if_needed(complete_event->conn_idx);
PBL_LOG(LOG_LEVEL_DEBUG, "Gatt Service Discovery Complete: %d", complete_event->status);
BTDeviceInternal addr;
Connection *connection = connection_by_idx_check(complete_event->conn_idx);
connection_get_address(connection, &addr)... | |
i++) {
cl_assert(s_num_dls_records < ARRAY_LENGTH(s_dls_records));
s_dls_records[s_num_dls_records++] = records[i];
}
return DATA_LOGGING_SUCCESS;
}
DataLoggingSession *dls_create(uint32_t tag, DataLoggingItemType item_type, uint16_t item_size,
bool buffered, bool resume, c... | if (s_kalg_sleep_start_utc == 0 || now < s_kalg_sleep_start_utc + SECONDS_PER_HOUR) {
// We are before the requested sleep time
*stats = (KAlgOngoingSleepStats) { };
} else {
// We are somewhere after the start of sleep
time_t sleep_end = s_kalg_sleep_start_utc + s_kalg_sleep_m * SECONDS_PER_MINUTE;
... |
}
// --------------------------------------------------------------------------------------------
// Create sample data for testing sleep and data logging
static void prv_create_test_data(uint32_t num_minutes, AlgMinuteDLSSample *minute_data) {
uint16_t next_vmc = 0;
uint8_t next_orient = 1;
uint8_t next_light... |
_draw_horizontal_line_dotted(&ctx, GPoint(0, 4), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 6), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 8), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 10), 3);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 12), 4);
graphics_dr... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 2), MAX_NUM_COLS + 4) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 4), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 6), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 8), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 10), 3);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 12), 4);
... |
/*
* 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_will_return(bt_persistent_storage_set_ble_pinned_address, true) | ;
cl_will_return(bt_driver_set_local_address, 0);
s_last_bt_persist_pinned_addr_is_null = true;
bt_local_addr_init();
}
static void prv_assert_driver_addr_is_null(void) {
cl_assert_equal_b(s_last_driver_addr_is_null, true);
cl_assert_equal_m(&s_last_driver_addr, &(BTDeviceAddress){}, sizeof(s_last_driver_add... |
the int_status for drdy is not latched so we check the status register
// instead to confirm new data accel data is available
uint8_t status = bmi160_read_reg(BMI160_REG_STATUS);
if ((status & BMI160_STATUS_DRDY_ACC_MASK) != 0) {
AccelDriverSample data;
prv_read_curr_accel_data(&data);
accel_cb_new_... | {
prv_update_accel_interrupts(false);
prv_run_command(BMI160_CMD_SOFTRESET);
psleep(50);
bmi160_enable_spi_mode();
bmi160_set_accel_power_mode(BMI160_Accel_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
... | |
menu);
}
} else if (item->next_level) {
prv_set_level(data, item->next_level);
}
}
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
ActionMenuData *data = context;
if (animation_is_scheduled(data->level_change_anim)) {
animation_set_elapsed(data->level_change_anim... | window_get_user_data(&action_menu->window) | ;
if (data->result_window) {
prv_remove_window(data->result_window);
}
// insert new result window
if (result_window) {
prv_action_window_insert_below(action_menu, result_window);
}
data->result_window = result_window;
}
void action_menu_set_align(ActionMenuConfig *config, ActionMenuAlign align)... |
alScaleModeFitCircle; // irrelevant as we deal with squares
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 2, 2);
cl_assert_fixedS16_3(radius, 2);
r = GRect(0, 0, 6, 6);
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 2.5, 2.5);
... | cl_assert_equal_i(DEG_TO_TRIGANGLE(-720), -TRIG_MAX_ANGLE * 2) | ;
cl_assert_equal_i(DEG_TO_TRIGANGLE(360), TRIG_MAX_ANGLE);
cl_assert_equal_i(DEG_TO_TRIGANGLE(-360), -TRIG_MAX_ANGLE);
cl_assert_equal_i(DEG_TO_TRIGANGLE(180), TRIG_PI);
cl_assert_equal_i(DEG_TO_TRIGANGLE(-180), -TRIG_PI);
cl_assert_equal_i(DEG_TO_TRIGANGLE(90), TRIG_PI / 2);
cl_assert_equal_i(DEG_TO_TR... |
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 an "AS IS"... | prv_exti_line_to_bit(exti_line) | |
og *) transcription_dialog)->scroll_layer;
TextLayer *text_layer = &dialog->text_layer;
const GSize size = text_layer_get_content_size(graphics_context_get_current_context(),
text_layer);
const uint16_t font_height = fonts_get_font_height(text_layer->font);
text_layer_set_size(text_layer, (GSize) { text... | if (transcription_dialog->keep_alive_on_select) {
action_bar_layer_clear_icon(&transcription_dialog->e_dialog.action_bar, BUTTON_ID_SELECT);
} else {
transcription_dialog_pop(transcription_dialog);
} |
}
static void prv_transcription_dialog_select_handler(ClickRecognizerRef recognizer, void *context) {
TranscriptionDialog *transcription_dialog = context;
if (transcription_dialog->select_pressed) {
// We are waiting to pop the window, don't run the callback again
return;
}
transcription_dialog->selec... |
/*
* 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... | (font_key, s_font_helpers[i].key) | ) {
return &s_font_helpers[i];
}
}
return NULL;
}
static GFont prv_get_font(const char *font_key) {
FontHelper *font_helper = prv_font_helper_from_font_key(font_key);
cl_assert_(font_helper, font_key);
FontInfo *result = &font_helper->font_info;
if (!result->loaded) {
bool init_result = text_... |
{ 960, 152, 16},
{ 912, 168, 32},
{ 872, 128, 48},
{ 816, 136, 72},
{ 800, 112, 80},
{ 800, 88, 88},
{ 800, 120, 72},
{ 848, 144, 80},
{ 888, 152, 96},
{ 944, 168, 96},
{ 944, 168, -8},
{ 1064, 168, -8},
{ 1232, 144, 112},
{ 1064, 232, -24},
{ 976, 208, -128},... |
{ 864, 152, 56},
{ 848, 176, 72},
{ 904, 192, 64},
{ 896, 208, -32},
{ 976, 168, -56},
{ 1248, 168, 80},
{ 1096, 184, -40},
{ 968, 192, -200},
{ 824, 152, -152},
{ 824, 72, -32},
{ 896, 40, 72},
{ 896, 72, 112},
{ 864, 136, 88},
{ 840, 176, 16},
{ 840, 184, -... | |
sferState_RepeatStart:
// Generate a repeat start
i2c->CR1 |= I2C_CR1_START;
transfer->state = I2CTransferState_WriteAddressRx;
break;
case I2CTransferState_WriteAddressRx:
// Write the I2C bus address again, but this time in read mode.
i2c->DR = transfer->device_address | I2C_R... | {
portEND_SWITCHING_ISR(prv_event_irq_handler(bus));
} |
void i2c_hal_error_irq_handler(I2CBus *bus) {
portEND_SWITCHING_ISR(prv_error_irq_handler(bus));
}
|
RITE | OP_FLAG_READ,
FILE_TYPE_STATIC, sizeof(buf));
for (int i = 0; i < sizeof(buf); i++) {
buf[i] = i;
}
rv = pfs_write(fd, NULL, sizeof(buf));
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(fd, buf, sizeof(buf) / 2);
int off = sizeof(buf) / 2;
rv = pfs_write(fd, &buf[off], sizeof(buf) - ... | (rv == S_SUCCESS) | ;
rv = pfs_close(fd); // should not be able to double close an fd
cl_assert(rv == E_INVALID_ARGUMENT);
}
void test_pfs__remove(void) {
cl_assert(pfs_remove(NULL) == E_INVALID_ARGUMENT);
char *fname = "abc";
int fd = pfs_open(fname, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10 * 1024);
cl_assert(fd >= 0);
cl_asse... |
nclude "process_management/app_manager.h"
void command_enter_standby(void) {
enter_standby(RebootReasonCode_MfgShutdown);
}
void command_color_read(void) {
char buffer[10];
prompt_send_response_fmt(buffer, sizeof(buffer), "%d", mfg_info_get_watch_color());
}
void command_color_write(const char* color_num) {
... | if (strcmp(dest_type, "prf") == 0) {
as_fw = false;
} | |
pp_data->reg_timers[0].cb = reg_timer_1_callback;
regular_timer_add_minutes_callback(&s_app_data->reg_timers[0]);
// This should assert when the callback runs because it tries to reschedule as a seconds callback
}
// =================================================================================
void reg_timer_... | {
// Don't bother freeing anything, the OS should be re-initing the heap.
} |
// =================================================================================
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
// =================================================================================
const PebbleProcessMd* test_sys_timer_app_get_info() {
stat... |
ll_end_common(void) {
s_call_in_progress = false;
prv_cancel_call_watchdog();
analytics_stopwatch_stop(ANALYTICS_DEVICE_METRIC_PHONE_CALL_TIME);
}
static void prv_handle_incoming_call(const PebblePhoneEvent *event) {
// Only 1 call at a time is supported
if (s_call_in_progress) {
PBL_LOG(LOG_LEVEL_INFO, ... | prv_handle_call_end(true /* disconnected */) | |
list_get_tail((ListNode *)head) | ;
while (current) {
if (prv_show_event(current, timestamp, today_midnight, TimelineIterDirectionPast,
show_all_day_events)) {
break;
}
current = (TimelineNode *)current->node.prev;
}
return current;
}
static TimelineNode *prv_find_first_future(TimelineNode *head, time_t timestamp,
time_t... | |
mitations under the License.
*/
#include "action_chaining_window.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
typedef struct {
Window window;
MenuLayer menu_layer;
StatusBarLayer status_layer;
const char *title;
TimelineItemActionGroup *action_group;
ActionChainingMenuSelectCb select_cb;... | (&data->menu_layer, &data->window) | |
cutive_days = result.first_streak,
.median = result.median,
};
kernel_free(history);
INSIGHTS_LOG_DEBUG("Metric history stats - med: %"PRIu16" mean: %"PRIu16" tot: %"PRIu8
" cons: %"PRIu8, stats->median, stats->mean, stats->total_days,
stats->consecutive_days);
}
/... | (&open_app_action_attr_list) | ;
return item;
}
// ------------------------------------------------------------------------------------------------
static TimelineItem *prv_create_day_4_insight(time_t notif_time) {
if (activity_prefs_get_health_app_opened_version() == 0) {
// The user has not enabled pebble health
return NULL;
}
A... |
6, 480, -728},
{ 456, 472, -720},
{ 456, 464, -720},
{ 456, 480, -728},
{ 456, 456, -728},
{ 456, 480, -728},
{ 456, 472, -720},
{ 448, 472, -720},
{ 464, 464, -736},
{ 464, 480, -720},
{ 464, 488, -712},
{ 448, 456, -720},
// 128 seconds
{ 448, 472, -712},
{ 464,... | { 480, 368, -592},
{ 384, 560, -1000},
{ 400, 72, -1048},
{ 416, 264, -1000},
{ 264, 224, -968},
{ 400, 144, -952},
{ 448, 344, -904},
{ 496, 256, -744},
{ 512, 408, -768},
{ 504, 448, -768},
{ 488, 352, -720},
{ 440, 280, -720},
{ 416, 312, -792},
{ 416, 408, -85... |
{ 360, 312, -792},
{ 384, 480, -776},
{ 376, 512, -768},
{ 368, 416, -776},
{ 368, 440, -784},
{ 368, 472, -768},
// 136 seconds
{ 360, 432, -768},
{ 368, 456, -768},
{ 368, 448, -776},
{ 376, 456, -768},
{ 376, 488, -768},
{ 384, 440, -768},
{ 376, 424, -776},
... |
(factor.x * offset_value, factor.y * offset_value) | ;
const AnimationProgress half_time = ANIMATION_NORMALIZED_MAX / 2;
const bool first_half = progress < half_time;
GPoint from;
GPoint to;
// does a movement of the first pixels, a cut, and then a movement of the last pixels
if (first_half) {
from = GPoint(factor.x * DISP_COLS, factor.y *... | |
ber can be increased provided that there is enough heap
//! space. Each depth uses sizeof(GTextNodeDrawContext) heap memory in bytes.
#define MAX_DRAW_DEPTH 8
#define ToGValue(value) ((GValue *)value)
typedef int16_t GValue;
_Static_assert(sizeof(GPoint) == sizeof(GValue[2]),
"TextNode requires a GPoi... | {
GTextNode *node = container_node->nodes[i];
if (callback(node, context) == false) {
return false;
}
} |
return true;
}
static GAxis prv_get_opposite_axis(GAxis axis) {
switch (axis) {
case GAxis_X:
return GAxis_Y;
case GAxis_Y:
return GAxis_X;
}
return GAxis_X;
}
GTextNodeText *graphics_text_node_create_text(size_t buffer_size) {
GTextNodeText *text_node = task_zalloc(sizeof(GTextNodeText... |
utes.h>
#include <util/math.h>
#include <util/size.h>
#include <util/uuid.h>
// Dialog SDK
#include "ble_gap.h"
#include "ble_gatt.h"
#include "ble_gattc.h"
#include "ble_gatts.h"
#include "ble_service.h"
#include "ble_uuid.h"
#include "storage.h"
#include <inttypes.h>
#include <string.h>
// Hack Alert
//
// There ... | if (!state) {
state = (PPoGATTWorkAroundState *)kernel_zalloc_check(sizeof(PPoGATTWorkAroundState));
connection_set_ppogatt_wa_state(conn, state);
} | |
uint32_t crc = ntohl(request->crc);
uint32_t calculated_crc = pb_storage_calculate_crc(&s_pb_state.storage, PutBytesCrcType_Legacy);
bool commit_succeeded = (calculated_crc == crc);
if (elapsed_time_ms > 0) {
int bytes_per_sec = (int)((s_pb_state.total_size * 1000) / elapsed_time_ms);
PBL_LOG(LOG_LEVEL_... | (PutBytesPut, (SharedHeader *)job->buffer) | |
liance 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 ... | BT_DEVICE_ADDRESS_XPLODE(s_pinned_addr) | );
if (bt_persistent_storage_has_pinned_ble_pairings()) {
PBL_LOG(LOG_LEVEL_INFO, "Bonding that requires address pinning exists, applying pinned addr!");
bt_local_addr_pause_cycling();
s_cycling_paused_due_to_dependent_bondings = true;
} else {
#if RECOVERY_FW
PBL_LOG(LOG_LEVEL_INFO, "Pausing addre... |
n);
// these values are unchanged until the animation updates them
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(0 * basic_cell_height, l.selection.y);
cl_assert_equal_i(initial_scroll_offset, l.scroll_layer.content_sublayer.bounds.origin.y);
// in this test setup, we can dir... | cl_assert_equal_i(2, s_num_rows) | ;
menu_layer_reload_data(&l);
cl_assert_equal_i(s_num_rows - 1, l.selection.index.row);
cl_assert_equal_i(focused_height, l.selection.h);
s_num_rows--;
cl_assert_equal_i(1, s_num_rows);
menu_layer_reload_data(&l);
cl_assert_equal_i(s_num_rows - 1, l.selection.index.row);
cl_assert_equal_i(focused_heigh... |
/*
* 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_equal_i(PEBBLE_CALLBACK_EVENT, e->type);
cl_assert_equal_i(task, TEST_TARGET_TASK);
if (s_can_send_event) {
EventNode *node = (EventNode *)malloc(sizeof(EventNode));
*node = (const EventNode) {
.event = *e,
};
s_event_head = (EventNode *)list_prepend((ListNode *)s_event_head, (Li... |
static void prv_process_callback_events_alt(bool should_execute_callback) {
EventNode *node = s_event_head;
while (node) {
EventNode *next = (EventNode *) node->node.next;
if (should_execute_callback) {
node->event.callback.callback(node->event.callback.data);
}
free(node);
node = next;
... |
ealth_data) {
Window window;
window_init(&window, WINDOW_NAME("Health"));
Layer *window_layer = window_get_root_layer(&window);
Layer *card_layer = health_sleep_summary_card_create(health_data);
layer_set_frame(card_layer, &window_layer->bounds);
layer_add_child(window_layer, card_layer);
window_set_backg... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_health_sleep_summary_card__render_sleep_early_start_early_end1(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 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
.typical_sleep = (10 * SECONDS_PER_... |
_GATTAPI.h"
#include "fake_GATTAPI_test_vectors.h"
#include "fake_new_timer.h"
#include "fake_queue.h"
#include "fake_system_task.h"
#include "stubs_regular_timer.h"
static BTErrno s_write_descriptor_cccd_result;
static BLEDescriptor s_last_cccd_ref;
static uint16_t s_last_cccd_value;
BTErrno gatt_client_op_write_de... | (GAPLEClientApp) | ;
}
cl_assert_equal_i(event.task_mask, task_mask);
}
static void prv_assert_notification_event_ext(BLECharacteristic characteristic,
const uint8_t *value, uint16_t assert_value_length,
bool kernel, bool app, bool should_con... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_verify_checksum(info, destination->start) | ) {
PBL_LOG(LOG_LEVEL_DEBUG, "Calculated CRC does not match, aborting...");
return false;
}
// Poke in the address of the OS's API jump table to an address known by the shims
uint32_t *pbl_jump_table_addr = prv_offset_to_address(destination, info->sym_table_addr);
*pbl_jump_table_addr = (uint32_t)&g_pb... |
e from Bluetopia:
fake_gap_put_connection_event(HCI_ERROR_CODE_SUCCESS,
is_master, device);
cl_assert_equal_b(gap_le_connection_is_connected(device), true);
}
static void prv_fake_disconnect(const BTDeviceInternal *device, bool is_master) {
fake_gap_put_disconnection_event(HCI_ERR... | gap_le_connect_cancel(NULL, GAPLEClientApp) | ;
cl_assert_equal_i(e, BTErrnoInvalidParameter);
}
void test_gap_le_connect__register_invalid_bonding(void) {
BTErrno e = gap_le_connect_connect_by_bonding(BT_BONDING_ID_INVALID,
true /* auto_reconnect */,
false /* is_p... |
DeInit(DISP_SPI);
SPI_Init(DISP_SPI, &s_disp_spi_init);
SPI_Cmd(DISP_SPI, ENABLE);
// Hold LCD on
GPIO_WriteBit(DISP_LCD_GPIO, DISP_PIN_LCD, Bit_SET);
}
// Clear-all mode is entered by sending 0x04 to the panel
void display_clear(void) {
prv_enable_display_access();
prv_display_write_byte(DISP_MODE_CLE... | for (int i = 7; i >= 0; i--) {
// Mask off 4 bits at a time
uint32_t mask = (0xf << (i * 4));
unsigned digit = ((code & mask) >> (i * 4));
prv_render_char(digit, x_offset, y_offset, buffer);
// Each character is 9px wide plus 2px of padding
x_offset += 11;
} |
}
void display_error_code(uint32_t code) {
uint8_t buffer[DISP_ROWS][DISP_LINE_BYTES];
memset(buffer, 0x00, sizeof(buffer));
prv_draw_bitmap(dead_face_bits, 24, 32, dead_face_width, dead_face_height, buffer);
prv_draw_code(code, buffer);
prv_draw_bitmap(error_url_bits, 16, 144, error_url_width, error_url... |
alog *transcription_dialog = transcription_dialog_create();
static char transcription[500] = {0};
uint16_t len = strlen(data->long_message);
strncpy(transcription, data->long_message, len);
transcription_dialog_update_text(transcription_dialog, transcription, len);
app_transcription_dialog_push(transcription_... | (sizeof(DialogsData)) | ;
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Dialogs"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);... |
#include "mfg/mfg_info.h"
#include "mfg/mfg_serials.h"
#include "resource/resource_ids.auto.h"
#include "services/common/i18n/i18n.h"
#include "services/common/new_timer/new_timer.h"
#include "shell/prefs.h"
#include "util/size.h"
// The calibration screen will be changing the screen offsets, so it's best that it rema... | if (shell_prefs_should_prompt_display_calibration()) {
s_timer = new_timer_create();
const uint32_t prompt_delay_time_ms = MS_PER_SECOND * SECONDS_PER_MINUTE;
new_timer_start(s_timer, prompt_delay_time_ms, prv_timer_callback, NULL, 0 /* flags */);
} |
}
#endif
|
leanup_and_send_response(ResponseAck);
}
static void prv_do_abort(void) {
PBL_LOG(LOG_LEVEL_INFO, "PutBytes abort CB. Tok: %"PRIu32".", s_pb_state.token);
prv_mark_pb_jobs_complete(1);
prv_cleanup_and_send_response(ResponseAck);
}
static bool prv_has_invalid_token(const PutBytesCommand command, uint32_t request... | strcpy(storage_info->filename, filename) | ;
break;
}
case ObjectAppResources: {
char filename[APP_RESOURCE_FILENAME_MAX_LENGTH + 1];
// The +1 is to make up for the fact that app banks start at 0, res banks start at 1. Fixing
// in D641
resource_storage_get_file_name(filename, sizeof(filename), index);
storage_info =... |
ader = {
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4},
.parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0x01},
.timestamp = 1,
.duration = 0,
.type = TimelineIte... | cl_assert(S_SUCCESS == reminder_db_insert_item(&item1)) | ;
TimelineItem temp = {{{0}}};
cl_assert(S_SUCCESS == reminder_db_read((uint8_t*)&item1.header.id, sizeof(Uuid), (uint8_t*)&temp,
sizeof(CommonTimelineItemHeader)));
// Note: we set things to null because it makes it easier to compare two
// TimelineItems with memcmp
// check item 1
memset(&temp, 0, ... |
ent, so 100x multiplier:
[AMSPlaybackInfoIdxRate] = 100,
// Third value is the elapsed time in seconds. We store as ms, so 1000x multiplier:
[AMSPlaybackInfoIdxElapsedTime] = 1000,
};
if (value_length && !ams_util_float_string_parse(value, value_length,
... | (update->value_str, value_length) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "Queue shuffle mode update: %d", shuffle_mode);
// TODO: Do something with this info
}
static void prv_handle_queue_repeat_mode_update(const AMSEntityUpdateNotification *update,
const uint16_t value_length) {
const AMSRepeatMode repeat_mo... |
lude "applib/graphics/gtypes.h"
#include "kernel/events.h"
#include "services/common/touch/touch.h"
#include "services/common/touch/touch_event.h"
#include "services/common/touch/touch_client.h"
#include "util/size.h"
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "fake_events.h"
// Stubs
#inc... | (touch_event, 1, TouchEvent_Liftoff, &GPointZero, 0, 0, &GPoint(1, 13),
3686401, 0, true) | ;
}
void test_touch__handle_update_liftoff_null_pos(void) {
touch_handle_update(0, TouchState_FingerDown, &GPoint(1, 13), 5, 3686400);
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
prv_test_touch_event(touch_event, 0, TouchEvent_Touchdown, &GPoint(1, 13), 3686400, 5,
&GPoint... |
/*
* 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_data->text, &text_frame) | ;
GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_28);
text_layer_set_font(&app_data->text, font);
text_layer_set_text_alignment(&app_data->text, GTextAlignmentCenter);
layer_add_child(window_get_root_layer(&app_data->window), (Layer*)&app_data->text);
}
static void prv_verify_modify_on_app_task(void *data)... |
/*
* 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 (!command_list ||
(size < sizeof(GDrawCommandList)) ||
(command_list->num_commands == 0)) {
return false;
}
uint8_t *end = (uint8_t *)command_list + size;
GDrawCommand *command = command_list->commands;
for (uint32_t i = 0; i < command_list->num_commands; i++) {
if ((end <= (uint8_t ... |
void *gdraw_command_list_iterate_private(GDrawCommandList *command_list,
GDrawCommandListIteratorCb handle_command,
void *callback_context) {
if (!command_list) {
return NULL;
}
GDrawCommand *command = command_list->commands;
for (uint32_t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.