prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
f_end = buffer + alloc_size;
attributes_actions_init(¬if_prefs->attr_list, ¬if_prefs->action_group,
&buffer, serialized_prefs->num_attributes, serialized_prefs->num_actions,
attributes_per_action);
if (!attributes_actions_deserialize(¬if_prefs->attr_lis... | if (key_len == 0) {
return E_INVALID_ARGUMENT;
} |
SettingsFile file;
status_t rv = prv_file_open_and_lock(&file);
if (rv != S_SUCCESS) {
return rv;
}
rv = settings_file_delete(&file, key, key_len);
prv_file_close_and_unlock(&file);
return rv;
}
status_t ios_notif_pref_db_flush(void) {
mutex_lock(s_mutex);
status_t rv = pfs_remove(iOS_NOTIF_... |
*connection = connection_by_idx_check(conn_idx);
bool notifications_enabled = false;
if (handle == s_pps_ctx.att_hdl.conn_status_cccd) {
notifications_enabled = connection_is_subscribed_to_connection_status_notifications(connection);
} else if (handle == s_pps_ctx.att_hdl.gatt_mtu_cccd) {
notifications_en... | if (!is_subscribed) {
// The CoreBluetooth central that the iOS app uses to subscribe to the Connection Status
// characteristic does not use state restoration. Therefore, when the app crashes / is
// jetsam'd, iOS will unsubscribe from the characteristic. Use this as a trigger to re-launch
// t... |
} else if (evt->handle == s_pps_ctx.att_hdl.gatt_mtu_cccd) {
connection_set_subscribed_to_gatt_mtu_notifications(connection, is_subscribed);
value_handle = s_pps_ctx.att_hdl.gatt_mtu;
} else if (evt->handle == s_pps_ctx.att_hdl.conn_params_cccd) {
connection_set_subscribed_to_conn_param_notifications(c... |
um_stub_height = 5;
if (bar_height > 0 && bar_height < minimum_stub_height) {
// Show the minimum stub bar if progress just began
bar_height = minimum_stub_height;
}
return bar_height;
}
static void prv_setup_day_bar_box(int weekday, GRect *box, int16_t bar_height) {
const int w = 23; // normal bar wid... | (graph_card, graph_card->day_data[DAYS_PER_WEEK]) | ;
prv_setup_day_bar_box(i, &box, last_bar_height);
const GColor bar_color = prv_get_bar_color(graph_card, is_active, false /* wide bar */);
prv_draw_day_bar(ctx, i, &box, bar_color, false /* wide bar */);
}
// Draw the day bar
prv_setup_day_bar_box(i, &box, bar_height);
const bool is_... |
"FreeRTOS.h"
#include "task.h"
#include "queue.h"
static TimerID s_deinit_timer_id = TIMER_INVALID_ID;
// -------------------------------------------------------------------------------------------
static ProcessContext *prv_get_context_for_task(PebbleTask task) {
if (task == PebbleTask_App) {
return app_mana... | (PebbleTask_KernelMain) | |
D;
app_timer_cancel(data->dictation_timeout);
prv_set_mic_window_state(data, StateFinished);
}
}
// Microphone Window
///////////////////////////////////////////////////////////////////////////
#if (0) // https://pebbletechnology.atlassian.net/browse/PBL-20406
static void prv_short_vibe(void) {
static con... | text_layer_set_text(&data->mic_window.text_layer, data->mic_window.text_buffer) | ;
}
static void prv_kino_reel_stopped_handler(KinoLayer *layer, bool finished, void *context) {
if (!finished) {
return;
}
// This stopped handler is used to defer the transition from recording to the wait for response
// screen until the folding animation is complete.
prv_handle_stop_transition(context... |
/*
* 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... | COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 0)->points, c0_points) |
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 1)->points, c1_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 2)->points, c2_points)
COPY_POINTS(gdraw_command_list_get_command(&result->command_list, 3)->points, c3_points)
COPY_POINTS(gdraw_command_list_get_command(&... |
layer_mark_dirty(&data->percent_done_text_layer.layer);
}
static void prv_update_progress(ProgressUIData *data) {
switch (data->progress_source) {
case PROGRESS_UI_SOURCE_COREDUMP: {
break;
}
case PROGRESS_UI_SOURCE_LOGS: {
break;
}
case PROGRESS_UI_SOURCE_FW_UPDATE: {
if (firmw... | window_set_user_data(window, data) | ;
window_set_overrides_back_button(window, true);
window_set_background_color(window, PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite));
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_window_load_handler,
.unload = prv_window_unload_handler,
});
app_window_stack_push(window, false);
... |
tr);
comm_session_send_queue_consume(s_app_session_ptr, length - 1);
comm_session_send_queue_cleanup(s_app_session_ptr);
assert_consumed(AppMessageSenderErrorDisconnected, 1);
cl_assert_equal_i(s_app_install_timestamp_update_count, 0);
app_free(outbox_data);
}
void test_app_message_sender__byte_by_byte_consu... | cl_assert_equal_i(first_length, comm_session_send_queue_copy(s_app_session_ptr, 0,
first_length, bytes_out)) | ;
comm_session_send_queue_consume(s_app_session_ptr, first_length);
// App quits with only one header byte consumed:
app_outbox_service_cleanup_all_pending_messages();
// Copy & consume the rest:
size_t second_length = (length - first_length);
cl_assert_equal_i(second_length, comm_session_send_queue_copy(... |
pTint, GColorLightGray);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_comptint_white_cross_lightgray_corners-expect.8bit.pbi"));
// Destination Black
memset(dest_data, GColorBlack.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, (GPoint){0}, GCompOpTint, GColorW... | bitblt_bitmap_into_bitmap_tiled_1bit_to_8bit(
&dest_bitmap, src_bitmap, dest_rect, src_origin_offset, GCompOpAssign, GColorWhite) | ;
cl_assert(gbitmap_pbi_eq(&dest_bitmap,
"test_bitblt__1bit_to_8bit_src_origin_offset-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Setup:
// - Source is a 10x32 white square.
// - Dest is all black.
// - Dest origin offset set to 15, 18.
// - Dest clipped to 10x10
// 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... | {
return S_SUCCESS;
} |
status_t flash_impl_exit_low_power_mode(void) {
return S_SUCCESS;
}
status_t flash_impl_erase_suspend(FlashAddress addr) {
return S_SUCCESS;
}
status_t flash_impl_erase_resume(FlashAddress addr) {
return S_SUCCESS;
}
uint32_t flash_impl_get_typical_subsector_erase_duration_ms(void) {
return 100;
}
uint32_... |
if (addr1 == NULL || addr2 == NULL) {
return false;
} |
return memcmp(addr1, addr2, sizeof(BTDeviceAddress)) == 0;
}
bool bt_device_address_is_invalid(const BTDeviceAddress *addr) {
if (!addr) {
return true;
}
BTDeviceAddress invalid = {};
return bt_device_address_equal(addr, &invalid);
}
bool bt_device_internal_equal(const BTDeviceInternal *device1_int,
... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | dialog_set_text(dialog, "Confirmation") | ;
dialog_set_background_color(dialog, GColorGreen);
dialog_set_icon(dialog, data->resource_id_80);
dialog_show_status_bar_layer(dialog, true);
actionable_dialog_set_action_bar_type(actionable_dialog, DialogActionBarConfirm, NULL);
actionable_dialog_set_click_config_provider(actionable_dialog,
prv_confi... |
/*
* 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 (test_image_color->addr) {
free(test_image_color->addr);
}
free(test_image_color);
} |
}
static void setup_test_rotate_bitmap(GContext *ctx, FrameBuffer *fb,
GRect clip_box, GRect drawing_box,
GCompOp compositing_mode) {
test_graphics_context_reset(ctx, fb);
GDrawState draw_state = {
.clip_box = clip_box,
.drawing_bo... |
ommon/clock.h"
#include "services/common/i18n/i18n.h"
#include "system/logging.h"
#include "util/size.h"
#include "util/string.h"
typedef struct HealthHrSummaryCardData {
HealthData *health_data;
HealthProgressBar progress_bar;
GDrawCommandSequence *pulsing_heart;
uint32_t pulsing_heart_frame_index;
AppTimer... | if (data->last_updated <= 0 || data->now_bpm == 0) {
return;
} |
const size_t buffer_size = 32;
char buffer[buffer_size];
clock_get_until_time_without_fulltime(buffer, buffer_size, data->last_updated, HOURS_PER_DAY);
const int y = PBL_IF_RECT_ELSE(130, 136);
GRect rect = GRect(0, y, base_layer->bounds.size.w, 35);
#if PBL_RECT
rect = grect_inset(rect, GEdgeInsets(0, ... |
nd_to_valid) ||
(predicate_cond == cond_to_valid + 1))) {
// This predicate could become valid over time.
// If the conditional is not equal, add 1 to the wait time, because only the equals case
// becomes valid on the specified value.
if (predicate_cond == cond_to_valid) {
... | if (*endptr != ')') {
state->error->status = TemplateStringErrorStatus_MissingClosingParen;
return;
} |
state->position = endptr;
state->filter_state = target_time - state->vars->current_time;
state->time_was_until = true;
}
static void prv_filter_time_since(TemplateStringState *state) {
prv_filter_time_until(state);
if (state->error->status != TemplateStringErrorStatus_Success) {
return;
}
state->fil... |
========================================
void two_timers_menu_cb(int index, void *ctx) {
uint32_t zero_flags = 0;
uint32_t expire_ms;
menu_callback_prefix(index, ctx);
// Multiple timers
int timer_idx_0 = 0;
s_app_data->timer[timer_idx_0] = new_timer_create();
bool success = new_timer_start(s_app_data... | menu_callback_prefix(index, ctx) | ;
// invalid timer id
new_timer_start(0x12345678, 100, timer_callback, cb_data, zero_flags);
}
// =================================================================================
void reg_timer_schedule_1sec_from_cb_menu_cb(int index, void *ctx) {
menu_callback_prefix(index, ctx);
s_app_data->reg_timers[0]... |
n) >> 6) & 0b11) << 2) | \
((((blue) >> 6) & 0b11) << 0) \
)
#define GColorARGB8FromRGB(red, green, blue) GColorARGB8FromRGBA(red, green, blue, 255)
#define GColorARGB8FromHEX(v) \
GColorARGB8FromRGB(((v) >> 16) & 0xff, ((v) >> 8) & 0xff, ((v) & 0xff))
// if performance ever becomes an issue with this, we can... | (0xfff0f5) | },
{"lawngreen", GColorARGB8FromHEX(0x7cfc00)},
{"lemonchiffon", GColorARGB8FromHEX(0xfffacd)},
{"lightblue", GColorARGB8FromHEX(0xadd8e6)},
{"lightcoral", GColorARGB8FromHEX(0xf08080)},
{"lightcyan", GColorARGB8FromHEX(0xe0ffff)},
{"lightgoldenrodyellow", GColorARGB8FromHEX(0xfafad2)},
// {"lightgray", GC... |
d(void) {
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1);
cl_assert(!prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get_next();
cl_assert_equal_i(timer_id, TIMER_INVALID_ID);
cl_assert(!stub_new_timer_is_scheduled(timer_id));
cl_assert(timeline_add(&item1));
timelin... | cl_assert(stub_new_timer_fire(timer_id)) | ;
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(20 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_cou... |
TEST_NAMED_PBI_FILE("draw_line_across_x_offset_layer")));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_nx_offset_layer")));
... | GPoint(0, 3) | , 148);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 7), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 11), 3);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 13),... |
de "FreeRTOS.h"
#include "portmacro.h"
// timezone abbreviation
static char s_timezone_abbr[TZ_LEN] = { 0 }; // longest timezone abbreviation is 5 char + null
static int32_t s_timezone_gmtoffset = 0;
static int32_t s_dst_adjust = SECONDS_PER_HOUR;
static time_t s_dst_start = 0;
static time_t s_dst_end = 0;
static con... | if (days < s_year_lengths[yleap]) {
break;
} |
y++;
days -= s_year_lengths[yleap];
}
} else {
do {
--y;
yleap = YEAR_IS_LEAP(y);
days += s_year_lengths[yleap];
} while (days < 0);
}
res->tm_year = y - TM_YEAR_ORIGIN;
res->tm_yday = days;
const uint8_t *ip = s_mon_lengths[yleap];
for (res->tm_mon = 0; days >= i... |
TEXT_ALIGNMENT,
(GTextLayoutCacheRef) &layout).h;
}
static int prv_get_icon_top_margin(bool has_status_bar, int icon_height, int window_height) {
const uint16_t status_layer_offset = has_status_bar ? 6 : 0;
#if PLATFORM_ROBERT || PLATFORM_CALC... | (simple_dialog) | ;
}
}
static void prv_click_handler(ClickRecognizerRef recognizer, void *context) {
SimpleDialog *simple_dialog = context;
if (!simple_dialog->buttons_disabled) {
dialog_pop(&simple_dialog->dialog);
}
}
static void prv_config_provider(void *context) {
// Simple dialogs are dimissed when any button is pu... |
(s_initialized) {
return;
}
periph_config_acquire_lock();
if (BOARD_CONFIG_VIBE.options & ActuatorOptions_Ctl) {
gpio_output_init(&BOARD_CONFIG_VIBE.ctl, GPIO_OType_PP, GPIO_Speed_2MHz);
gpio_output_set(&BOARD_CONFIG_VIBE.ctl, false);
s_initialized = true;
}
if (BOARD_CONFIG_VIBE.options &... | (strength) | ;
const bool turn_on = strength != 0;
vibe_ctl(turn_on);
prompt_send_response("OK");
}
|
/*
* 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... | ble_ad_destroy(new_ibeacon_ad_data) | ;
}
static BLEAdData *create_too_short_ad_data(void) {
static const uint8_t too_short_ad_element[] =
{ 0x1a, // 26 bytes
0xff, // Manufacturer Specific AD Type
0x4c, 0x00, // Apple
0x02, // iBeacon
0x14, // Number of bytes to follow -- Internally inconsistent!
0x97, 0x6e, 0xbb, 0x18, 0xd3, 0xe9... |
/*
* 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... | {
// extra escape character before flag
ctx->escape = false;
*hdlc_error = true;
} |
// we've reached the end of the frame
is_complete = true;
} else if (*data == HDLC_ESCAPE) {
if (ctx->escape) {
// invalid sequence
ctx->escape = false;
*hdlc_error = true;
} else {
// ignore this character and escape the next one
ctx->escape = true;
}
} else {
... |
break;
default:
PBL_ASSERT(0, "unknown coposting mode %d", compositing_mode);
return;
}
#endif
// Backup context color
const GColor ctx_color = ctx->draw_state.stroke_color;
if (grect_contains_point(&src->bounds, &src_ic)) {
// TODO: Optimize further (PBL-15657)
// If src_ic is ... | for (int i = -1; i <= 1; ++i) {
for (int j = -1; j <= 1; ++j) {
if (src_x + i >= 0 && src_x + i < src->bounds.size.w
&& src_y + j >= 0 && src_y + j < src->bounds.size.h) {
// I'm within bounds
if (get_bitmap_bit(src, src_x + i , src_y + j)) {
// more... | |
nst GTextOverflowMode overflow =
(has_secondary && !is_peek) ? GTextOverflowModeTrailingEllipsis : GTextOverflowModeFill;
if (PBL_IF_ROUND_ELSE(!is_thin, true)) {
// Move the hour and title closer together
const int hour_title_margin = is_fat ? style->fat_time_margin_h : style->thin_time_margin_h;
i... | graphics_text_node_create_horizontal(num_horizontal_icon_nodes) | ;
GTextNodeVertical *vertical_icon_node =
graphics_text_node_create_vertical(num_vertical_icon_nodes);
graphics_text_node_container_add_child(&horizontal_icon_node->container,
&vertical_icon_node->container.node);
horizontal_icon_node->horizontal_alignment ... |
t is larger than the requested size */
/* can be broken into 2 framents leaving a fragment that is of the */
/* requested size and one that is at least as larger as the */
/* MINIMUM_MEMORY_SIZE. */
#define MINIMUM_MEMORY_SIZE 1
/* The following defines the s... | {
HeapInfo_t *heap_info_ptr;
uint16_t free_segments;
uint16_t alloc_segments;
/* Initialize the return values. */
*used = 0;
*free = 0;
*max_free = 0;
free_segments = 0;
alloc_segments = 0;
heap_info_ptr = heap->begin;
do {
... |
void heap_calc_totals(Heap* const heap, unsigned int *used, unsigned int *free, unsigned int *max_free) {
UTIL_ASSERT(heap);
/* Verify that the parameters that were passed in appear valid. */
if((used) && (free) && (max_free) && (heap->begin)) {
heap_lock(heap);
prv_calc_totals(heap, used, free, m... |
gListLiteral("Description\0Attendees\0Organizer");
static StringList paragraphs = StringListLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt "
"ut labore et dolore magna aliqua.\0"
"Ryan Case\nBrad Murray\0Sarah Otten");
attribute_list_add_string_... | (now + delta_time_s, duration_m,
TimelineItemTypePin, LayoutIdHealth,
&list, NULL) | ;
pin_db_insert_item_without_event(item);
timeline_item_destroy(item);
attribute_list_destroy_list(&list);
}
static void prv_launch_timeline(void) {
app_manager_put_launch_app_event(&(AppLaunchEventConfig) { .id = APP_ID_TIMELINE });
}
static void prv_launch_notifications(void) {
app_manager_put_launch_app... |
;
analytics_stopwatch_stop(ANALYTICS_DEVICE_METRIC_BLE_CONNECT_ENCRYPTED_TIME);
prv_update_conn_event_timer(0, true);
}
}
void bluetooth_analytics_handle_encryption_change(void) {
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BLE_CONNECT_ENCRYPTED_TIME,
AnalyticsClient_Syst... | analytics_event_get_bytes_stats(
comm_session_get_system_session(), type,
total_size, elapsed_time_ms, new_stats.num_conn_events,
new_stats.num_sync_errors, new_stats.num_conn_events_skipped,
prv_calc_other_errors(&new_stats)) | ;
}
void analytics_external_collect_ble_parameters(void) {
bt_lock();
{
GAPLEConnection *connection = gap_le_connection_get_gateway();
if (!connection) {
goto unlock;
}
LEChannelMap le_channel_map;
const bool success =
bt_driver_analytics_collect_ble_parameters(&connection->devic... |
/*
* 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... | {
size_t src_size = gdraw_command_image_get_data_size(src);
if (buffer_length < src_size) {
return false;
}
memcpy(buffer, src, src_size);
return true;
} |
GDrawCommandImage *gdraw_command_image_clone(GDrawCommandImage *image) {
if (!image) {
return NULL;
}
// potentially extracting into a generic task_ptrdup(void *, size_t)
size_t size = gdraw_command_image_get_data_size(image);
GDrawCommandImage *result = applib_malloc(size);
if (result) {
memcpy(... |
rmation.
tz_info->dst_start = 0;
tz_info->dst_end = 0;
return;
}
struct tm current_tm;
gmtime_r(&utc_time, ¤t_tm);
// Calculate the timestamps of the start and ends of DST for the previous year, the current
// year, and the next year.
#define DST_YEARS_RANGE 3
#define DST_YEARS_OFFSET 1
... | if (t) {
rtc_set_time(*t);
} |
int new_gmt_offset = time_get_gmtoffset();
int new_utc_time = rtc_get_time();
PebbleEvent e = {
.type = PEBBLE_SET_TIME_EVENT,
.set_time_info = {
.utc_time_delta = new_utc_time - orig_utc_time,
.gmt_offset_delta = new_gmt_offset - orig_gmt_offset,
.dst_changed = false,
}
};
ev... |
services_set_runlevel(RunLevel_BareMinimum) | ;
worker_manager_disable();
}
static void s_main(void) {
prv_handle_init();
app_event_loop();
}
const PebbleProcessMd* shutdown_charging_get_app_info(void) {
static const PebbleProcessMdSystem s_app_md = {
.common = {
.main_func = s_main,
.visibility = ProcessVisibilityHidden,
// UUID: ... | |
dd_child(&window->layer, &kino_layer->layer);
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
GRect pair_text_area = GRect(0, -2, width, 44);
#else
GRect pair_text_area = GRect(0, -2, width, 30);
#endif
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
layer_set_frame(&data->info_text_mask_layer, &GRect(x_offset, info_text_y_o... | (data->info_text_in_animation) | ;
property_animation_destroy(data->info_text_out_animation);
kernel_free(data);
}
s_data_ptr = NULL;
}
static void prv_show_failure_kernel_main_cb(void *unused) {
prv_handle_pairing_complete(false /* success */);
}
static void prv_pairing_timeout_timer_callback(void *unused) {
PBL_LOG(LOG_LEVEL_WARNI... |
(&src->attr_list, &src->action_group, item_out)) {
timeline_item_destroy(item_out);
return NULL;
}
return item_out;
}
size_t timeline_item_get_serialized_payload_size(TimelineItem *item) {
PBL_ASSERTN(item);
return attributes_actions_get_serialized_payload_size(&item->attr_list, &item->action_group);
... | task_free(item->allocated_buffer) | ;
item->allocated_buffer = NULL;
}
}
bool timeline_item_verify_layout_serialized(const uint8_t *val, int val_len) {
SerializedTimelineItemHeader *hdr = (SerializedTimelineItemHeader *)val;
bool has_attribute[NumAttributeIds] = {0};
// verify that the serialized attributes are well-formed
const uint8_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... | system_hard_reset() | ;
#endif
}
void HardFault_Handler(void) {
// Grab the stack pointer, shove it into a register and call
// the c function above.
__asm("tst lr, #4\n"
"ite eq\n"
"mrseq r0, msp\n"
"mrsne r0, psp\n"
"b %0\n" :: "i" (prv_hard_fault_handler_c));
}
|
(void) {
GPointPrecise center = {};
Fixed_S16_3 radius = {};
const GOvalScaleMode mode = GOvalScaleModeFillCircle;
GRect r = GRect(0, 5, 0, 0);
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 0, 5);
cl_assert_fixedS16_3(radius, 0);
// 1 pixel width means radius of... | cl_assert_fixedS16_3(s_radius_outer, 4.5) | ;
cl_assert(s_radius_inner.integer <= 0);
cl_assert_equal_i(s_angle_start, 0);
cl_assert_equal_i(s_angle_end, TRIG_MAX_ANGLE);
graphics_fill_oval(NULL, GRect(0, 0, 0, 0), GOvalScaleModeFillCircle);
cl_assert_gpoint_precise(s_center, 0.0, 0.0);
cl_assert_fixedS16_3(s_radius_outer, 0.0);
cl_assert(s_radius... |
{ -696, 736, 144},
{ -696, 696, 136},
{ -664, 704, 96},
{ -656, 696, 120},
{ -688, 688, 128},
{ -704, 680, 128},
{ -672, 656, 128},
{ -648, 704, 96},
{ -664, 712, 96},
{ -712, 728, 88},
{ -680, 704, 136},
{ -672, 704, 136},
{ -680, 664, 160},
{ -664, 664, 112},
... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 16:04:19 local
AccelRawData *activity_sample_walk_100_pbl_25663_8(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25663_8
//> TEST... |
n. Currently used by Jumboji
//! @return the GTextNode view node of the notification
static NOINLINE GTextNode *prv_create_view(NotificationLayout *layout, bool use_body_icon) {
const NotificationStyle *style = &s_notification_styles[system_theme_get_content_size()];
const bool is_reminder = prv_is_reminder(layout... | if (is_reminder) {
reminder_timestamp_node_config = &reminder_timestamp_config.text.extent.node;
} else {
notification_timestamp_node_config = ¬ification_timestamp_config.text.extent.node;
header_node_config = &header_config.text.extent.node;
} |
#if !PLATFORM_TINTIN
if (!layout->info.show_notification_timestamp && PBL_IF_RECT_ELSE(use_body_icon, true)) {
notification_timestamp_node_config = NULL;
}
#endif
const LayoutNodeConfig * const vertical_config_nodes[] = {
reminder_timestamp_node_config,
#if PBL_ROUND
notification_timestamp_node_confi... |
r(data);
GRect icon_from;
layer_get_global_frame((Layer *)&first_timeline_layout->icon_layer, &icon_from);
peek_layer_set_icon_with_size(peek_layer, &first_timeline_layout->icon_info,
TimelineResourceSizeTiny, icon_from);
} else {
return NULL;
}
GRect icon_to;
... | animation_set_handlers(animation, (AnimationHandlers) {
.stopped = prv_move_timeline_layer_stopped,
}, data) | ;
animation_set_duration(animation, TIMELINE_CARD_TRANSITION_MS / 2);
animation_set_custom_interpolation(animation, interpolate_moook);
animation_schedule(animation);
return animation;
}
static void prv_push_pin_window(TimelineAppData *data, TimelineIterState *state, bool animated) {
TimelineLayout *timeline... |
/*
* 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_crumb_config() | ->layer_width / 2;
}
static int prv_crumb_radius(void) {
return prv_crumb_config()->crumb_radius;
}
static int prv_crumb_spacing(void) {
return prv_crumb_config()->crumb_spacing;
}
static int prv_crumb_space_from_top(void) {
return prv_crumb_config()->crumb_space_from_top;
}
static int prv_crumb_maximum_count... |
/*
* 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... | (VoiceEndpointResultFailInvalidRecognizerResponse,
msg->session_id, NULL, app_initiated, app_uuid) | ;
}
voice_handle_dictation_result(msg->result, msg->session_id, transcription,
app_initiated, app_uuid);
}
static void prv_handle_nlp_result(VoiceSessionResultMsg *msg, size_t size) {
const size_t attr_list_size = size - sizeof(VoiceSessionResultMsg) + sizeof(GenericAttributeList)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_context_set_fill_color(ctx, bg_color) | ;
graphics_fill_rect(ctx, &text_layer->layer.bounds);
}
if (text_layer->text && strlen(text_layer->text) > 0) {
graphics_context_set_text_color(ctx, text_layer->text_color);
graphics_draw_text(ctx, text_layer->text, text_layer->font,
text_layer->layer.bounds, text_layer->overflow_mode,
t... |
gap_le_connect_has_connection_intent_for_bonding(bonding_id, GAPLEClientApp);
cl_assert_equal_b(registered, true);
}
void test_gap_le_connect__register_two_clients_same_device(void) {
BTErrno e;
bool registered;
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent:
e = gap_le_conn... | prv_fake_connect(&device, false /* is_master*/) | ;
prv_assert_client_event(&device, true /* connected */, (1 << PebbleTask_App),
HCI_ERROR_CODE_SUCCESS);
// Disconnect & verify the client task gets the event:
prv_fake_disconnect(&device, false /* is_master */);
prv_assert_client_event(&device, false /* connected */, (1 << PebbleTask... |
GRect *first_icon_frame_out,
GRect *second_icon_frame_out) {
GRect first_icon_frame;
GRect second_icon_frame;
timeline_layer_get_icon_frame(timeline_layer, TIMELINE_LAYER_FIRST_VISIBLE_LAYOUT,
&first_icon_frame);
timeline_layer_get_icon_frame(timeli... | (layer, NULL, NULL) | |
/*
* 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_num, resource_id) | |
mutex_create() | ;
for (int i=0; i < 10000; i++) {
mutex_lock(s_mutex);
mutex_unlock(s_mutex);
}
mutex_destroy(s_mutex);
s_mutex = NULL;
s_rmutex = mutex_create_recursive();
for (int i=0; i < 10000; i++) {
mutex_lock_recursive(s_rmutex);
}
for (int i=0; i < 10000; i++) {
mutex_unlock_recursive(s_rmutex)... | |
/*
* 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... | GPIO_ResetBits(FLASH_GPIO, FLASH_PIN_SCS) | ;
}
static void prv_flash_end_cmd(void) {
GPIO_SetBits(FLASH_GPIO, FLASH_PIN_SCS);
// 50ns required between SCS going high and low again, so just delay here to be safe
delay_us(1);
}
static uint8_t prv_flash_send_and_receive_byte(uint8_t byte) {
// Ensure that there are no other write operations in progress
... |
oint = (const GPointGetter) prv_gpoint_getter },
},
};
start_value = GPoint(0, 0);
end_value = GPoint(100, 200);
prop_h = property_animation_create(&implementation, &value, &start_value, &end_value);
Animation *h = property_animation_get_animation(prop_h);
void *context = &value;
animation_set_handle... | prv_advance_to_ms_with_timers(start_ms + duration/2) | ;
cl_assert_close_gtransform(value, mid_value);
// End
prv_advance_to_ms_with_timers(start_ms + duration + MIN_FRAME_INTERVAL_MS*2);
cl_assert_equal_gtransform(value, end_value);
#endif
}
// --------------------------------------------------------------------------------------
// Test a basic Fixed_S32_16 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... | layer_get_frame(window_get_root_layer(&app_data->window), &frame) | ;
GRect text_frame = {
.size.h = 48,
.size.w = 100,
};
grect_align(&text_frame, &frame, GAlignCenter, false);
text_layer_init(&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->... |
-120},
{ -552, 472, -80},
{ -720, 560, -144},
{ -984, 616, -112},
{ -976, 568, -8},
{ -1296, 696, -136},
{ -1040, 680, -56},
{ -1072, 656, -88},
{ -1168, 672, -104},
{ -808, 456, 32},
{ -440, 472, -96},
{ -336, 456, -192},
{ -320, 384, -80},
{ -440, 328, 0},
{ -52... | { -336, 312, -184},
{ -480, 352, -144},
{ -616, 416, -80},
{ -600, 496, -56},
{ -704, 600, -144},
{ -832, 688, -184},
{ -1192, 720, -160},
{ -1504, 728, -128},
{ -1056, 672, -8},
{ -1056, 736, -168},
{ -968, 656, -152},
{ -632, 424, -24},
{ -432, 472, -128},
// 29... | |
K_NOT_REGISTERED: return "APP_MSG_CALLBACK_NOT_REGISTERED";
case APP_MSG_OUT_OF_MEMORY: return "APP_MSG_OUT_OF_MEMORY";
case APP_MSG_CLOSED: return "APP_MSG_CLOSED";
case APP_MSG_INTERNAL_ERROR: return "APP_MSG_INTERNAL_ERROR";
default: return "UNKNOWN ERROR";
}
}
static void prv_send_msg(void) {
A... | (app_data->out_iter, AppMessageKey_TIA,
(uint8_t *)d->tia, d->num_samples * sizeof(d->tia[0])) | ;
dict_write_data(app_data->out_iter, AppMessageKey_PPG,
(uint8_t *)d->ppg, d->num_samples * sizeof(d->ppg[0]));
}
if (hrm->debug->ppg_data.tia[hrm->debug->ppg_data.num_samples - 1] == 0) {
PBL_LOG_COLOR(LOG_LEVEL_DEBUG, LOG_COLOR_CYAN, "last PPG TIA sample is 0!");
... |
num_records += num_minutes;
utc_start = utc_end;
if (num_minutes == 0) {
break;
}
}
// Print summary
APP_LOG(APP_LOG_LEVEL_DEBUG, "Retrieved %d minute data records", (int)num_records);
// Print detail on the last few minutes
const int k_print_batch_size = 30;
APP_LOG(APP_LOG_LEVEL_... | ("NOT ACCESSIBLE") | ;
return;
}
// Weekday/weekend avg up to now
char temp[64];
HealthValue avg;
avg = health_service_sum_averaged(metric, day_start, now,
HealthServiceTimeScopeDailyWeekdayOrWeekend);
snprintf(temp, sizeof(temp), "\ntypical: %d", (int)avg);
prv_safe_strcat(data->debug... |
3);
}
void test_ams_util__float_string_parse_null_in_the_middle(void) {
uint8_t buffer[] = {'1', 0, '2'};
assert_float_parse(buffer, 3, true, 3);
}
void test_ams_util__float_string_parse_empty_string(void) {
// "" * 3
assert_float_parse("", 3, false, 0);
}
void test_ams_util__float_string_parse_not_a_number(... | assert_result(0, "A", 1) | ;
assert_result(1, "B", 1);
assert_result(2, "C", 1);
}
void test_ams_util__csv_stop_after_one_value(void) {
const char multi_values[] = "A,B,C";
s_max_results_count = 1;
const uint8_t count = ams_util_csv_parse(multi_values, sizeof(multi_values), NULL,
prv_result_c... |
llback)(void *data), void *data) {
callback(data);
}
void process_manager_send_callback_event_to_process(PebbleTask task, void (*callback)(void *data),
void *data) {
callback(data);
}
void accessory_imaging_enable(bool enable) {
}
// Tests
/////////////////////... | (BUTTON_ID_UP) | ;
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_factory_reset_called);
}
|
ond_callback(RegularTimerInfo* cb, uint16_t seconds) {
PBL_ASSERTN(s_callback_list_semaphore);
mutex_lock(s_callback_list_semaphore);
cb->private_reset_count = seconds;
cb->private_count = seconds;
// Only add to the list if not already registered
if (!list_find(&s_seconds_callbacks, prv_callback_registe... | (s_callback_list_semaphore) | |
e_get_length(session);
comm_session_send_queue_consume(session, read_space);
}
static bool s_is_current_task_send_next_task = false;
bool comm_session_is_current_task_send_next_task(CommSession *session) {
return s_is_current_task_send_next_task;
}
// Tests
////////////////////////////////////////////////////////... | {
size_t payload_length = 1;
bytes_free -= sizeof(PebbleProtocolHeader) + payload_length;
// If we cannot fit another message after this one, increment the length to use up the space:
if (bytes_free <= (sizeof(PebbleProtocolHeader) + payload_length)) {
payload_length += bytes_free;
bytes_f... | |
168, 88},
{ 832, 160, 88},
{ 784, 160, 32},
{ 744, 40, 112},
{ 688, 8, 136},
// 22 seconds
{ 656, 32, 128},
{ 824, -24, 80},
{ 1048, 144, 24},
{ 1216, 168, 104},
{ 1824, 24, 360},
{ 1608, 400, 120},
{ 832, 672, -232},
{ 888, 424, -232},
{ 728, 192, 80},
{ 848,... | { 648, 112, 72},
{ 616, 112, -32},
{ 696, 128, 32},
{ 856, 184, 32},
{ 952, 304, 0},
{ 1240, 312, 80},
{ 1768, 208, 248},
{ 1376, 704, 48},
// 28 seconds
{ 1200, 704, -96},
{ 824, 560, 32},
{ 688, 336, 136},
{ 728, 392, 104},
{ 704, 336, 192},
{ 688, 320, 312}... |
{ 720, 304, 96},
{ 656, 320, 40},
{ 736, 336, 16},
{ 832, 368, -32},
{ 920, 336, 40},
{ 1168, 376, 24},
{ 1256, 288, 200},
{ 1728, 448, 232},
{ 1416, 632, 144},
{ 1080, 408, -184},
{ 920, 200, 112},
{ 1200, 168, 56},
{ 1024, 208, 112},
// 31 seconds
{ 808, 96... |
, -64},
{ -1624, 576, -56},
{ -1200, 352, -8},
{ -1184, 304, 104},
{ -1272, 328, 232},
{ -1432, 488, 216},
{ -1304, 384, 240},
{ -1200, 320, 240},
{ -1184, 184, 256},
{ -1112, 40, 232},
{ -1016, -48, 224},
{ -872, -64, 208},
{ -928, -56, 264},
{ -848, -32, 200},
{... | { -2088, 560, 224},
{ -1056, 576, -416},
{ -1096, 616, -424},
{ -1376, 648, 120},
{ -1424, 384, 248},
{ -1160, 176, 152},
{ -912, 40, 128},
{ -808, 24, 136},
{ -824, 40, 128},
{ -856, 64, 136},
{ -1088, -128, 264},
// 60 seconds
// elapsed: 1 minutes
{ -1232, -432... |
{ -1000, -224, 88},
{ -1280, -40, 64},
{ -1136, 248, -120},
{ -1032, 224, -144},
{ -1200, 176, -80},
{ -1352, -64, 160},
{ -1408, -16, 280},
{ -1440, 224, 264},
{ -1368, 432, 208},
{ -1280, 560, 64},
{ -1248, 584, -56},
{ -1112, 256, -64},
{ -1168, 408, -104},
{ ... |
///////////////////////////
#include "fake_new_timer.h"
#include "fake_pbl_malloc.h"
#include "fake_pebble_tasks.h"
#include "fake_rtc.h"
#include "fake_spi_flash.h"
#include "fake_settings_file.h"
#include "fake_events.h"
bool calendar_layout_verify(bool existing_attributes[]) {
return true;
}
bool weather_layout_... | (timeline_add(&item1)) | ;
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(!prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get_next();
cl_assert(timer_id != TIMER_INVALID_ID);
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_new_timer_tim... |
/= is_single_short_row ? num_items : SHORT_COL_COUNT;
#else
r.size.w /= SHORT_COL_COUNT;
#endif
r.origin.y += (r.size.h - font_height) / 2 - 4;
for (int i = 0; i < num_items; i++) {
if (!items[i].label) {
break;
}
if (sel_idx == i) {
graphics_context_set_text_color(ctx, PBL_IF_COLOR_ELS... | (&aml->layer) | ;
}
static void prv_cell_animation_stopped_handler(Animation *animation, bool finished, void *context) {
ActionMenuLayer *aml = context;
if (finished) {
prv_set_cell_offset(aml, aml->item_animation.bottom_offset_y);
}
}
static const PropertyAnimationImplementation s_item_animation_implementation = {
.base... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
pbl_log(LOG_LEVEL_INFO, filename, line, string);
} |
NORETURN os_assertion_failed(const char *filename, int line) {
passert_failed_no_message(filename, line);
}
NORETURN os_assertion_failed_lr(const char *filename, int line, uint32_t lr) {
passert_failed_no_message_with_lr(filename, line, lr);
}
void *os_malloc(size_t size) {
return kernel_malloc(size);
}
void... |
tring.h>
static DataLoggingSession *s_logging_sessions;
static PebbleRecursiveMutex * s_list_mutex;
// ---------------------------------------------------------------------------------------
// Assert that the current task owns the list mutex
void dls_assert_own_list_mutex(void) {
PBL_ASSERTN(mutex_is_owned_recurs... | mutex_unlock(session->data->mutex) | |
link_send_begin(this->protocol_number);
*packet = (struct LCPPacket) {
.code = ControlCode_TerminateAck,
.identifier = identifier,
.length = hton16(LCP_HEADER_LEN),
};
pulse_link_send(packet, LCP_HEADER_LEN);
}
static void prv_send_code_reject(PPPControlProtocol *this,
... | (this, -1) | |
prv_set_file_minute_record_entry(file_record, &cbuf_record->data, i, cbuf_record->utc_sec,
was_sleeping);
// Handle writing the record out to data logging
} else {
prv_set_dls_minute_record_entry(dls_record, &cbuf_record->data, i, cbuf_record->utc_sec,
... | PBL_LOG(LOG_LEVEL_ERROR, "Unexpectedly large number of uncertain minutes") | ;
uncertain_m = KALG_MAX_UNCERTAIN_SLEEP_M;
}
// Send whatever complete DLS records we have
prv_send_minute_data(uncertain_m, sleep_stats.sleep_start_utc, sleep_stats.sleep_len_m,
false /*to_file*/, false /*force_send*/);
// Send whatever complete minute file records we have
prv_s... |
_get_config(&file, id, &config);
if (!rv) {
goto cleanup;
}
if (!callback(id, &config, context)) {
goto cleanup;
}
prv_enable_alarm_config(&config, true /* enabled */);
prv_alarm_set_config(&file, id, &config);
cleanup:
prv_file_close_and_unlock(&file);
}
// -----------------------------------... | if (!prv_file_open_and_lock(&file)) {
return;
} |
AlarmConfig config;
bool rv = prv_alarm_get_config(&file, id, &config);
if (!rv) {
goto cleanup;
}
if (id == s_most_recent_alarm_id && !enable) {
PBL_LOG(LOG_LEVEL_DEBUG, "Canceling snooze timer because alarm was disabled");
// Harmless if the alarm is not currently snoozing - the snooze timer ... |
/*
* 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... | {
GRect bounds = layer_get_bounds(layer);
graphics_context_set_fill_color(ctx, GColorRed);
uint16_t radius = min(bounds.size.w / 2, bounds.size.h / 2);
uint16_t inset_thickness = 1;
// 360 degrees, filled in
__profiler_start();
for (int i = 0; i < ITERATIONS; ++i) {
graphics_fill_radial(ctx, bounds,... |
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
layer_set_update_proc(window_layer, prv_update_proc);
}
static void init(void) {
__profiler_init();
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
});
... |
ine_removes, 3);
alarm_set_enabled(id2, false);
prv_assert_alarm_config(id2, 4, 14, true, ALARM_KIND_EVERYDAY, s_every_day_schedule);
cl_assert_equal_i(s_num_timeline_adds, 12);
cl_assert_equal_i(s_num_timeline_removes, 9);
AlarmId invalid_id = 7;
alarm_set_enabled(invalid_id, false);
cl_assert_equal_i(... | (pin_attr_list, AttributeIdIconTiny, 0) | ;
cl_assert_equal_i((int)pin_icon_tiny, TIMELINE_RESOURCE_ALARM_CLOCK);
const char *pin_title = attribute_get_string(pin_attr_list, AttributeIdTitle, NULL);
cl_assert_equal_s(pin_title, "Alarm");
const char *pin_subtitle = attribute_get_string(pin_attr_list, AttributeIdSubtitle, NULL);
cl_assert_equal_s(pin... |
requency to run the peripheral at
#define TIMER_CLOCK_HZ 32000
// The number of timer ticks that should elapse before the timer interrupt fires
#define TIME_PERIOD (TIMER_CLOCK_HZ / TIMER_INTERRUPT_HZ)
// How many ticks have elapsed since we fed the HW watchdog
static uint8_t s_ticks_since_successful_feed = 0;
// We... | PBL_LOG(LOG_LEVEL_DEBUG, "Ending App Throttling") | ;
}
static void prv_app_task_throttle_start(void) {
static char last_throttled_task[configMAX_TASK_NAME_LEN];
const char *curr_task = pebble_task_get_name(PebbleTask_App);
// if an app results in system throttling, log it at the INFO level at least
// once to aid in debug
if (strcmp(last_throttled_task, cur... |
return strlen(buffer);
} else {
struct tm local_tm = (struct tm) {
.tm_wday = positive_modulo(graph_card->selection, DAYS_PER_WEEK),
};
return strftime(buffer, buffer_size, i18n_get("%a: ", graph_card), &local_tm);
}
}
static void prv_draw_info_with_text(HealthGraphCard *graph_card, GContext *ct... | i18n_free_all(graph_card) | |
/*
* 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... | (BOARD_CONFIG_DISPLAY.spi, BOARD_CONFIG_DISPLAY.spi_clk) | ;
power_tracking_stop(PowerSystemMcuSpi2);
}
static void prv_enable_chip_select(void) {
gpio_output_set(&BOARD_CONFIG_DISPLAY.cs, true);
// setup time > 3us
// this produces a setup time of ~7us
for (volatile int i = 0; i < 32; i++);
}
static void prv_disable_chip_select(void) {
// delay while last byte i... |
42547423257157360");
snprintf(dstbuf, 256, "%zo,%to", hurf, hurf);
cl_assert_equal_s(dstbuf, "23257157360,23257157360");
}
void test_sprintf__percent_x(void) {
char dstbuf[256];
// Simple %x
snprintf(dstbuf, 256, "There are %x lights, %x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, fffffffc"... | (dstbuf, "There are 10 lights, the absolute value of FFFFFFFC") | ;
// Minimum digits output
snprintf(dstbuf, 256, "There are %.3X lights, %.3X", 16, -4);
cl_assert_equal_s(dstbuf, "There are 010 lights, FFFFFFFC");
// Minimum digits output (zero digits)
snprintf(dstbuf, 256, "%.0Xzero%.0X", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspeci... |
the watch was vibrating
return;
}
time_t s;
uint16_t ms;
rtc_get_time_ms(&s, &ms);
mutex_lock(s_vibe_history_mutex);
VibeHistory *vibe = (VibeHistory*)list_get_tail((ListNode*)s_vibe_history);
if (vibe->time_end == END_NOT_SET) {
vibe->time_end = ((uint64_t)s) * 1000 + ms;
}
mutex_unlock(s_... | (LOG_LEVEL_ERROR, "Couldn't malloc for a vibe step") | |
/*
* 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... | {
TestImplData *data = recognizer_get_impl_data(recognizer, &s_test_impl);
cl_assert_equal_i(data->test, TEST_PATTERN);
if (data->failed) {
cl_assert_equal_b(*data->failed, false);
*data->failed = true;
}
} |
static void prv_sub_event_handler(const Recognizer *recognizer, RecognizerEvent event) {
RecognizerEvent *event_type = recognizer_get_user_data(recognizer);
if (event_type) {
*event_type = event;
}
}
Recognizer *test_recognizer_create(TestImplData *test_impl_data, void *user_data) {
s_test_impl = (Recogn... |
Y, s_every_day_schedule);
id = alarm_create(&(AlarmInfo) { .hour = 5, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 5, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
id = alarm_create(&(AlarmInfo) { .hour = 6, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_con... | prv_assert_alarm_config(id, 6, 14, false, ALARM_KIND_CUSTOM, custom_schedule4) | ;
}
void test_alarm__alarm_set_time(void) {
AlarmId id1, id2;
id1 = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id1, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
alarm_set_time(id1, 5, 6);
prv_assert_alarm_config(id1, 5, 6, false, ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_set_fullscreen(window, true) | |
ult_common(msg->result, app_initiated, msg->session_id,
&msg->attr_list, attr_list_size, &app_uuid)) {
return;
}
if (app_uuid) {
PBL_LOG(LOG_LEVEL_WARNING, "Got an app UUID in a NLP result msg. Ignoring and continuing");
}
// The timestamp attribute is optional
time_t... | generic_attribute_add_attribute(attr, VEAttributeIdAppUuid, app_uuid, sizeof(Uuid)) | ;
}
attr = generic_attribute_add_attribute(attr, VEAttributeIdAudioTransferInfoSpeex, info,
sizeof(AudioTransferInfoSpeex));
size_t actual_size = (uint8_t *)attr - (uint8_t *)msg;
PBL_ASSERTN(actual_size == size);
comm_session_send_data(comm_session, VOICE_CONTROL_ENDPOINT, (uint8_t *)msg,
... |
/*
* 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... | sys_get_current_resource_num() | ;
return kino_reel_gbitmap_create_with_resource_system(app_num, resource_id);
}
KinoReel *kino_reel_gbitmap_create_with_resource_system(ResAppNum app_num, uint32_t resource_id) {
GBitmap *bitmap = gbitmap_create_with_resource_system(app_num, resource_id);
if (bitmap == NULL) {
return NULL;
}
return kino_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return s_is_connected_as_slave;
} |
void ble_legacy_discovery_enable(uint32_t timeout_secs) {
}
void gap_le_slave_reconnect_stop(void) {
}
void gap_le_slave_reconnect_start(void) {
}
void gatt_service_changed_server_cleanup_by_connection(GAPLEConnection *connection) {
}
int HCI_LE_Set_Advertise_Enable(unsigned int BluetoothStackID, ...) {
return ... |
t it's going to continue running.
cl_assert_equal_i(s_last_to_app_event.type, PEBBLE_PROCESS_DEINIT_EVENT);
cl_assert(app_manager_get_current_app_md() == (PebbleProcessMd*) &s_launch_app);
s_last_to_app_event = (PebbleEvent) {0};
// Now the app sets the safe_to_kill flag to true and sends a kill event back to
... | (app_exit_reason_get(), default_exit_reason) | ;
app_exit_reason_set(NUM_EXIT_REASONS);
cl_assert_equal_i(app_exit_reason_get(), default_exit_reason);
app_exit_reason_set((AppExitReason)-1);
cl_assert_equal_i(app_exit_reason_get(), default_exit_reason);
// Specify the exit reason to be that an action was performed successfully
app_exit_reason_set(APP_E... |
property_animation->values.from.gtransform.a,
property_animation->values.to.gtransform.a);
result.b = interpolate_fixed32(
distance_normalized,
property_animation->values.from.gtransform.b,
property_animation->values.to.gtransform.b);
result.c = interpolate_fixed32(
distance_normalize... | memset(&property_animation->values, 0xff, sizeof(property_animation->values)) | ;
property_animation->animation.implementation = (AnimationImplementation*) implementation;
property_animation->subject = subject;
if (implementation->accessors.getter.int16) {
if (property_animation->animation.implementation->update
== (AnimationUpdateImplementation) property_animation_update_int16) ... |
{
graphics_context_set_fill_color(ctx, command->fill_color);
gpath_draw_filled(ctx, &path);
}
if ((command->stroke_color.a != 0) && (command->stroke_width > 0)) {
graphics_context_set_stroke_color(ctx, command->stroke_color);
graphics_context_set_stroke_width(ctx, command->stroke_width);
gpath_d... | {
return;
} |
command->radius = radius;
}
uint16_t gdraw_command_get_radius(GDrawCommand *command) {
if (!command || (command->type != GDrawCommandTypeCircle)) {
return 0;
}
return command->radius;
}
void gdraw_command_set_path_open(GDrawCommand *command, bool path_open) {
if (!command ||
((command->type != GD... |
case WorkoutMetricType_Duration:
{
const size_t buffer_size = sizeof("00:00:00");
GTextNodeText *number_text_node = health_util_create_text_node(buffer_size, number_font,
TEXT_COLOR, container);
active_window->workout_controlle... | {
action_bar_layer_clear_icon(action_bar, BUTTON_ID_SELECT);
action_bar_layer_set_icon(action_bar, active_window->pause_button,
active_window->action_bar_pause);
} |
if (active_window->num_scrollable_metrics > 1) {
action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, active_window->action_bar_next);
}
}
static void prv_update_ui(WorkoutActiveWindow *active_window) {
if (window_manager_is_window_visible(&active_window->window)) {
layer_mark_dirty(&active_window->ba... |
{
if (!prv_event_service_send_event(service->subscribers[i], e)) {
PBL_LOG(LOG_LEVEL_INFO, "Queue full! %d not delivered to task %d!",
(int)e->type, (int)i);
#if !RELEASE
// For 3rd party apps, just close them. For a 1st party app or other task, reboot
// the watc... |
}
}
if (!prv_task_is_masked_out(e, cur_task) && service->subscribers[cur_task]) {
// we are on the current task, so we just tell the client to handle it inline
event_service_client_handle_event(e);
}
if (stolen) {
// we stole the buffer from the event, NULL it out
*buf_ptr = NULL;
}
}
... | |
;
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 6);
test_num = (int32_t)((float)-0.125 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 7);
test_num = (int32_t)... | (-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-5))) | ;
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-8)));
cl_assert_equal_i(-2, Fixed_S16_3_rounded_int(Fixed_S16_3(-12)));
}
void test_math_fixed__S16_3_rounding(void) {
Fixed_S16_3 num;
int16_t test_num;
// This test shows how the in between fractional values evaluate to the fixed representation
... |
er;
static uint16_t s_volume;
static bool s_running = false;
static bool s_main_pending = false;
static bool s_bg_pending = false;
static int s_overflow_cnt;
static bool s_initialized = false;
static uint8_t s_discarded;
static CircularBuffer s_circ_buffer;
// A mutex is needed to protect against a race condition b... | if (BOARD_CONFIG.mic_config.mic_gpio_power.gpio) {
gpio_output_set(&BOARD_CONFIG.mic_config.mic_gpio_power, false);
} else {
set_ldo3_power_state(false);
} |
}
void mic_init(MicDevice *this) {
PBL_ASSERTN(!s_initialized);
s_main_pending = false;
s_bg_pending = false;
s_running = false;
s_subscriber = (struct Subscriber){0};
s_volume = BOARD_CONFIG.mic_config.gain;
s_pdm_filter.Fs = MIC_SAMPLE_RATE;
s_pdm_filter.LP_HZ = 8000;
s_pdm_filter.HP_HZ = 10;
... |
ics
activity_metrics_prv_minute_handler(utc_sec);
// Call the algorithm's minute handler. This gives it an opportunity to log minute data
// to data logging. etc. In case the user settings have changed, pass the current ones in.
ActivityGender gender = activity_prefs_get_gender();
uint16_t weight_dag = activ... | {
// Init the record header now if necessary
if (data->record.num_samples == 0) {
data->record = (ActivityRawSamplesRecord) {
.version = ACTIVITY_RAW_SAMPLES_VERSION,
.session_id = s_activity_state.sample_collection_session_id,
.len = sizeof(ActivityRawSamplesRecord),
.time... |
ACTIVITY_RAW_SAMPLE_SET_RUN_SIZE(data->prev_sample, data->run_size);
data->record.entries[data->record.num_entries++] = data->prev_sample;
data->run_size = 0;
}
} else {
// Finish the old run, start a new one
ACTIVITY_RAW_SAMPLE_SET_RUN_SIZE(data->prev_sample... |
/*
* 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... | (AlertInvalid) | );
cl_assert(!alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_notify_for_type(AlertReminder));
cl_assert(!alerts_should_notify_for_type(AlertPhoneCall));
}
void test_alerts__do_not_disturb(void) {
cl_assert(alerts_get_mask() == AlertMaskAllOn);
// We now allow notifications to come thr... |
/*
* 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... | GColorARGB8FromHEX(0xe9967a) | },
{"darkseagreen", GColorARGB8FromHEX(0x8fbc8f)},
{"darkslateblue", GColorARGB8FromHEX(0x483d8b)},
{"darkslategray", GColorARGB8FromHEX(0x2f4f4f)},
{"darkslategrey", GColorARGB8FromHEX(0x2f4f4f)},
{"darkturquoise", GColorARGB8FromHEX(0x00ced1)},
{"darkviolet", GColorARGB8FromHEX(0x9400d3)},
{"deeppink", ... |
ect dest_rect,
GPoint src_origin_offset,
GCompOp compositing_mode,
GColor8 tint_color) {
const int16_t dest_begin_y = dest_rect.origin.y;
const int16_t dest_end_y = g... | {
// Wrap-around source bitmap vertically
if (src_y >= src_end_y) {
src_y = src_begin_y;
}
const GBitmapDataRowInfo dest_row_info = gbitmap_get_data_row_info(dest_bitmap, dest_y);
uint8_t *dest = dest_row_info.data;
const int16_t dest_delta_begin_x = MAX(dest_r... |
// keep correct bounds alignment for circular when tiling
src_x = src_bitmap->bounds.origin.x +
(((src_x - src_bitmap->bounds.origin.x)) % src_bitmap->bounds.size.w);
} else {
// Increment source but don't draw
continue;
}
... |
;
// 2.5 hours of sleep, put's us at 8:30pm. The cut-off for the next day is
// ACTIVITY_LAST_SLEEP_MINUTE_OF_DAY, currently set for 9pm so this session should be
// registered for today
prv_feed_cannned_accel_data(150 * SECONDS_PER_MINUTE, 0, ActivitySleepStateLightSleep);
// Awake for 30 minutes which put... | for (int i = 0; i < k_raw_samples; i++) {
// We store multiples of 8 because the compression algorithm divides by 8.
raw_data[i].x = value * 8;
raw_data[i].y = -value * 8;
raw_data[i].z = (value + 1) * 8;
if ((i % 7) == 0) {
value += 1;
}
} | |
ltering
PFSFileListEntry *dir_list;
dir_list = pfs_create_file_list(NULL);
// Should have 4 entries in it
cl_assert_equal_i(list_count(&dir_list->list_node), 4);
cl_assert(list_find(&dir_list->list_node, prv_find_name, "a_test_0"));
cl_assert(list_find(&dir_list->list_node, prv_find_name, "a_test_1"));
c... | ("a_test_1") | , false);
cl_assert_equal_b(prv_file_exists("b_test_0"), true);
cl_assert_equal_b(prv_file_exists("b_test_1"), true);
}
void test_pfs__doesnt_give_out_fd_zero(void) {
for (int i = 5; i > 0; --i) {
char filename[20];
sprintf(filename, "test%d", i);
int fd = pfs_open(filename, OP_FLAG_WRITE, FILE_TYPE_... |
DITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "services/common/shared_prf_storage/shared_prf_storage.h"
#include "services/common/shared_prf_storage/v3_sprf/shared_prf_storage_private.h"
#include "fl... | (flash_buf, FLASH_REGION_SHARED_PRF_STORAGE_BEGIN, SPRF_REGION_SIZE) | ;
shared_prf_storage_init();
shared_prf_storage_set_getting_started_complete(true);
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), true);
}
void test_shared_prf_storage_v3__find_first_valid_sector(void) {
SharedPRFData data;
// These are the pages that this test will place a valid head... |
_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-80, 4, 72, 32),
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_ellipsis_clip_outside_x(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColo... | layer_add_child(&canvas, &layer) | ;
// Corner cases
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_nx_zero_y_offset);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_nx_zero_y_offset.${BIT_DEPTH_NAME}.pbi"... |
t_size - num_pages * page_hdr_size;
// make sure the logs are of an appropriate size such that each page will
// be entirely filled
int log_len = 2;
cl_assert((page_size - page_hdr_size) % (2 + log_len) == 0);
// fill up all of our log record space
int num_logs;
char **logs = generate_unique_logs(space_... | (s_completed_success) | ;
cl_assert_equal_i(s_long_lived_last_val, loop_count);
}
//! Check error handling for some of the different edge cases
void test_flash_logging__errors(void) {
flash_logging_init();
uint32_t start_addr = flash_logging_log_start(0);
cl_assert_equal_i(start_addr, FLASH_LOG_INVALID_ADDR);
char *msg = "01234... |
/*
* 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... | dbgserial_print("ASSERT: ") | ;
dbgserial_print(expr);
dbgserial_print(" ");
dbgserial_print(filename);
dbgserial_print(":");
dbgserial_print_hex(line_number);
if (fmt) {
dbgserial_print(" ");
dbgserial_print(fmt);
}
dbgserial_putstr("");
reset_due_to_software_failure();
}
static __attribute__((noreturn)) void handle_pa... |
{
s_pri_mask = __get_BASEPRI();
__set_BASEPRI((TASK_WATCHDOG_PRIORITY + 1) << (8 - __NVIC_PRIO_BITS));
s_interrupts_disabled_by_heap = true;
} |
}
static void prv_heap_unlock(void *ctx) {
if (s_interrupts_disabled_by_heap) {
__set_BASEPRI(s_pri_mask);
s_interrupts_disabled_by_heap = false;
}
}
void kernel_heap_init(void) {
extern int _heap_start;
extern int _heap_end;
heap_init(&s_kernel_heap, &_heap_start, &_heap_end, true);
heap_set_lo... | |
/*
* 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... | strcmp(vibe_score_info_get_name(VibeScoreId_Reveille), "Reveille") | == 0);
}
void test_vibe_score_info__get_name_returns_empty_string_for_invalid_score(void) {
cl_assert(strcmp(vibe_score_info_get_name(VibeScoreId_Invalid), "") == 0);
}
static void prv_test_cycle_next(VibeClient client, const VibeScoreId scores[], size_t scores_size,
VibeScoreId sta... |
x=<%u>",
cursor.origin.x, line->origin.x);
const int glyph_width_px = prv_codepoint_get_horizontal_advance(&ctx->font_cache,
text_box_params->font, codepoint);
line->width_px = (cursor.origin.x + glyph_width_px) - line->origin.x;
PBL_ASSERT(line->width_px <= text_box_params->box.size.w,
"Line... | {
break;
} |
walked_width_px -= next_glyph_width_px;
if (!iter_prev(&char_iter)) {
break;
}
current_codepoint = utf8_iter_state->codepoint;
}
}
if (line->suffix_codepoint) {
GRect cursor = {
.origin = line->origin,
.size.w = next_glyph_width_px,
.size.h = fonts_get_fo... |
inder) {
return 1;
} else if (type_b != NotificationReminder && type_a != NotificationReminder) {
return 1;
} else {
return -1;
}
}
static void prv_notification_window_add_notification(Uuid *id, NotificationType type) {
if (do_not_disturb_is_active()) {
notifications_presented_list_add_sorted(i... | (data, item) | );
}
static void prv_hide_peek_layer(void *context) {
NotificationWindowData *data = context;
// get the frame of the swap_layer and set its destination
const GRect *swap_frame = &data->swap_layer.layer.frame;
int16_t swap_frame_animation_dy = STATUS_BAR_LAYER_HEIGHT - swap_frame->origin.y;
// duration of ... |
qspi_use(dev->qspi);
prv_write_enable(dev);
prv_write_cmd_no_addr(dev, dev->state->part->instructions.block_unlock_all);
qspi_release(dev->qspi);
return S_SUCCESS;
}
#if !RELEASE
#include "console/prompt.h"
#include "drivers/flash.h"
#include "kernel/pbl_malloc.h"
#include "system/profiler.h"
#include "util... | {
++failures;
prompt_send_response("ERROR: flash_read_verify failed");
} |
}
qspi_release(QSPI);
bool was_busy = false;
// write a few bytes to the sector we're going to erase so it's not empty
uint8_t dummy_data = 0x55;
flash_write_bytes(&dummy_data, FLASH_REGION_FIRMWARE_SCRATCH_BEGIN, sizeof(dummy_data));
profiler_start();
status_t result = flash_impl_erase_sector_begin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.