prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
draw_horizontal_line_dotted(&ctx, GPoint(6, 23), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 13), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 24), 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_odd_offset_no_clip")));
// Even rows ... | GPoint(24, 7) | , 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_no_clip")));
// Even cols of different lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(0, 0), MAX_NUM_ROWS);
graph... |
ics_draw_arc_precise = (MockCallRecordings){0};
s_gpath_draw_filled = (MockCallRecordings){0};
}
void test_rocky_api_graphics_path2d__cleanup(void) {
fake_app_timer_deinit();
// Frees the internal path steps array ():
rocky_api_graphics_path2d_reset_state();
// some tests deinitialize the engine, avoid dou... | (GPoint(0, 1), lc->path.points[0]) | ;
cl_assert_equal_point(GPoint(2, 3), lc->path.points[1]);
cl_assert_equal_point(GPoint(4, 5), lc->path.points[2]);
s_gpath_draw_filled.call_count = 0;
EXECUTE_SCRIPT(
"ctx.lineTo(11.5, 12.7);\n"
"ctx.fill();\n"
);
// still only the first part (before the .moveTo()) as the second only has two point... |
tions under the License.
*/
#include "services/common/firmware_update.h"
#include "apps/core_apps/progress_ui_app.h"
#include "flash_region/flash_region.h"
#include "kernel/event_loop.h"
#include "kernel/system_message.h"
#include "kernel/ui/modals/modal_manager.h"
#include "process_management/app_manager.h"
#includ... | {
return s_update_status;
} |
void firmware_update_init(void) {
vSemaphoreCreateBinary(s_firmware_update_semaphore);
PBL_ASSERTN(s_firmware_update_semaphore != NULL);
}
static void prv_initialize_completion_status(PebbleSystemMessageEvent *event) {
if (prv_legacy_completion_status_init(event)) {
return;
}
s_current_completion_stat... |
;
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == 0);
cl_assert(num.fraction == 6);
test_num = (int32_t)((float)0.875 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == 0);
cl_assert(num.fraction == 7);
test_num = (int16_t)((... | cl_assert(num.fraction == 1) | ; // rounds down to 1.125
}
void test_math_fixed__S16_3_add(void) {
Fixed_S16_3 num1, num2;
Fixed_S16_3 sum, sum_c;
// Test number addition
num1 = FIXED_S16_3_ONE;
num2 = FIXED_S16_3_ONE;
sum = Fixed_S16_3_add(num1, num2);
sum_c = (Fixed_S16_3){ .raw_value = (int16_t)((float)2 * (1 << FIXED_S16_3_PRECI... |
, int16_t x,
Fixed_S16_3 y1, Fixed_S16_3 y2,
GColor color) {
// first pixel with blending
if (y1.fraction != 0) {
prv_blend_color_and_update_mask(ctx, y1.integer, x, x, color,
... | prv_update_mask(ctx, y, x1.integer, x2.integer, color) | ;
}
// last pixel with blending (don't render first *and* last pixel if line length is 1)
if (right_aa_offset <= 1) {
if (x1.integer <= clip_box_max_x) {
prv_blend_color_and_update_mask(ctx, y, x1.integer, x1.integer, color, (uint8_t)x2.fraction);
}
// or last AA gradient with blending
} else... |
int_icon = (icon && (gbitmap_get_format(icon) == GBitmapFormat1Bit));
if (tint_icon) {
graphics_context_set_compositing_mode(ctx, GCompOpTint);
} else if (ctx->draw_state.compositing_mode == GCompOpAssign) {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
}
}
graphics_draw_bitmap_in... | if (config->value && (icon_align != GAlignRight)) {
value_box.size.w -= horizontal_margin;
const GFont value_font = prv_get_cell_value_font(config);
const GSize text_size = graphics_text_layout_get_max_used_size(
ctx, config->value, value_font, value_box, config->overflow_mode,
GTextAlign... |
// This function duplicates `grect_inset()` but helps us save some stack space by using pointer
// arguments and always inlining the function
static ALWAYS_INLINE void prv_grect_inset(GRect *rect, GEdgeInsets *insets) {
grect_standardize(rect);
const int16_t new_width = rect->size.w - insets->left - insets->right... |
ayOfWeek, .uint8 = MuteBitfield_Always },
{ .id = AttributeIdAppName, .cstring = "Awesome" },
{ .id = AttributeIdLastUpdated, .uint32 = s_now },
}
};
s_expected_attributes = &expected_attributes;
ancs_filtering_record_app(&existing_prefs, s_app_id_attr, s_display_name_attr, s_title_attr);
cl_as... | cl_assert(ancs_filtering_is_muted(&mute_always)) | ;
cl_assert(ancs_filtering_is_muted(&mute_weekends));
cl_assert(!ancs_filtering_is_muted(&mute_weekdays));
s_now += SECONDS_PER_DAY; // Monday Jan 4, 2016
cl_assert(ancs_filtering_is_muted(&mute_always));
cl_assert(!ancs_filtering_is_muted(&mute_weekends));
cl_assert(ancs_filtering_is_muted(&mute_weekdays)... |
------------
// NOTE: We are explicitly avoiding use of vsniprintf and cohorts to reduce our stack
// requirements
static void prv_debug_str_str(const char* msg, const char* s) {
#if PULSE_EVERYWHERE
void *ctx = pulse_logging_log_sync_begin(LOG_LEVEL_ALWAYS, __FILE_NAME__, 0);
pulse_logging_log_sync_append(ctx, msg... | if (region_hdr.magic == CORE_DUMP_FLASH_HDR_MAGIC && region_hdr.last_used > max_last_used) {
max_last_used = region_hdr.last_used;
last_used_idx = i;
} |
}
// If simply trying to find most recently used image, return that now.
if (!new) {
if (max_last_used > 0) {
CD_ASSERTN(last_used_idx >= 0);
return core_dump_get_slot_address(last_used_idx);
} else {
return CORE_DUMP_FLASH_INVALID_ADDR;
}
}
// --------------------------------... |
/*
* 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... | RCC_APB1PeriphResetCmd(bus->hal->clock_ctrl, ENABLE) | ;
RCC_APB1PeriphResetCmd(bus->hal->clock_ctrl, DISABLE);
}
void i2c_hal_init(I2CBus *bus) {
NVIC_SetPriority(bus->hal->ev_irq_channel, I2C_IRQ_PRIORITY);
NVIC_SetPriority(bus->hal->er_irq_channel, I2C_IRQ_PRIORITY);
NVIC_EnableIRQ(bus->hal->ev_irq_channel);
NVIC_EnableIRQ(bus->hal->er_irq_channel);
prv_i2c... |
*text_box_out = GRect(text_x, text_y, text_w, text_h);
}
static void prv_simple_dialog_load(Window *window) {
SimpleDialog *simple_dialog = window_get_user_data(window);
Dialog *dialog = &simple_dialog->dialog;
// Ownership of icon is taken over by KinoLayer in dialog_init_icon_layer() call below
KinoReel *... | window_set_user_data(window, simple_dialog) | ;
}
SimpleDialog *simple_dialog_create(const char *dialog_name) {
SimpleDialog *simple_dialog = applib_malloc(sizeof(SimpleDialog));
if (simple_dialog) {
simple_dialog_init(simple_dialog, dialog_name);
}
return simple_dialog;
}
void simple_dialog_set_buttons_enabled(SimpleDialog *simple_dialog, bool enabl... |
date handler
// implemented in Animation.c
AnimationPrivate *prv_animation_get_current(void);
void prv_update_handler(Animation *animation, const AnimationProgress distance) {
// always ensure that animation state gives access to the current animation
cl_assert_equal_p(animation_private_animation_find(animation),... | {
fake_rtc_init(1024*200 /*ticks */, 200 /*seconds */);
AnimationState *state = kernel_applib_get_animation_state();
animation_private_state_init(state);
// Insure that at least some time elapsed after init so that state->last_frame_time is
// in the past.
prv_advance_by_ms_no_timers(10);
// Clear hand... |
// -------------------------------------------------------------------------------------
// Cleanup, called after each test executes
void test_animation__cleanup(void) {
// Make sure no animations were left over
cl_assert_equal_i(prv_count_animations(), 0);
}
// -----------------------------------------------... |
ent_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1]);
cl_assert_equal_p(aaa, stack[2]);
// go to child if possible
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaaa, actual);
cl_assert_equal_i(3, current_sta... | GPoint(0, 0) | |
-------------------------------------------------------------------------------
// Make sure we don't push a pin when we have no history to compare against
void test_activity_insights__sleep_summary_no_history(void) {
// Tests init with zero history
activity_insights_init(rtc_get_time());
// Make sure we don't ... | rtc_get_time() | );
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR);
prv_add_nap_session(0.5, 1.5);
activity_insights_process_minute_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 2);
#endif
}
// Make sure that when the watch resets, we retain state properly
void test_activity_insights__walk_session_power_cycle... |
Layer *menu_layer, MenuIndex *cell_index,
LauncherMenuData *data) {
AppMenuNode *node = app_menu_data_source_get_node_at_index(&data->data_source, cell_index->row);
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = node->install_id,
.common.reason = APP_LAUNCH_USER... | kino_layer_deinit(&data->battery_icon) | ;
// Save the current state of the menu so we can restore it later.
s_launcher_menu_persisted_data = (LauncherMenuPersistedData) {
.valid = true,
.scroll_offset_y = scroll_layer_get_content_offset(&data->menu_layer.scroll_layer).y,
.menu_index_row = menu_layer_get_selected_index(&data->menu_layer).row,... |
{ 1408, 360, -344},
{ 1304, 288, -200},
{ 1008, 192, -56},
{ 808, 384, -80},
{ 768, 328, -120},
{ 752, 424, -120},
{ 824, 320, -184},
{ 960, 400, -224},
{ 1088, 504, -272},
{ 1376, 528, -296},
{ 1664, 456, -136},
{ 1840, 512, -136},
// 11 seconds
{ 1256, 496, -120... |
{ 1720, 464, -80},
{ 1504, 480, -72},
{ 1048, 384, -56},
{ 1176, 336, -32},
{ 1248, 288, 8},
{ 1168, 208, 80},
{ 992, 192, 104},
{ 896, 240, 96},
{ 872, 192, 104},
{ 888, 192, 96},
{ 856, 200, 88},
{ 832, 120, 40},
{ 816, 80, -16},
{ 912, 104, 0},
{ 1032, 168... | |
d, &s_long_items[0].header.id));
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[1].header.id));
#if !CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[2].header.id));
#endif
cl_assert(!iter_pr... | iter_prev(&iterator) | );
cl_assert(uuid_equal(&first_all_day_event, &state.pin.header.id));
cl_assert(state.node->all_day);
// correct end of line behaviour
cl_assert(!iter_prev(&iterator));
}
void test_timeline__all_day_future_with_others(void) {
prv_insert_all_day_items();
Iterator iterator = {0};
TimelineIterState state ... |
esource_ids.auto.h"
#include "services/common/analytics/analytics.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "shell/prefs.h"
#include "system/passert.h"
#include "util/math.h"
static const int16_t MAX_OFFSET_MAGNITUDE = 10;
typedef enum {
DisplayCalibrationState_X_Adjust,
... | GSize(layer_bounds->size.w, stripe_width) |
: GSize(stripe_width, layer_bounds->size.h)
};
for (int i = stripe_inset - stripe_width; i >= -MAX_OFFSET_MAGNITUDE; i -= stripe_width) {
// alternate yellow and red stripes
graphics_context_set_stroke_color(ctx, (i % (2 * stripe_width)) ? GColorRed : GColorYellow);
const G... |
-16},
{ 1840, 704, 32},
{ 1776, 608, -40},
{ 1688, 520, 16},
{ 1800, 376, 8},
{ 1744, 392, -232},
{ 1544, 216, -216},
{ 1328, -136, -184},
{ 888, -312, -136},
{ 664, -224, -264},
{ 1016, -96, -224},
{ 1080, 32, -64},
{ 1224, 224, -48},
{ 1480, 304, -88},
{ 1776, ... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-09-22 12:00:16 local
AccelRawData *activity_sample_100_steps_heather_2(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_heather_2
//> TEST_EXP... |
/*
* 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_user_data(window, data) | |
ONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gpath_builder.h"
#include "gpath.h"
#include "applib/applib_malloc.auto.h"
#include "util/trig.h"
#include <string.h>
const int fixedpoint_base = 16;
// ... | memset(result, 0, sizeof(GPath)) | ;
result->num_points = num_points;
// Set the points pointer within the GPath structure to point just after the GPath structure
// since that is where memory has been allocated for the array.
result->points = (GPoint*)(result + 1);
memcpy(result->points, builder->points, size_of_points);
return result;
}
b... |
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,
text_layer->text_alignment, prv_text_layer_get_cache_handle(text_layer));
}
}
... | (text_layer) | ;
if (text_alignment == text_layer->text_alignment) {
return;
}
text_layer->text_alignment = text_alignment;
layer_mark_dirty(&(text_layer->layer));
}
void text_layer_set_overflow_mode(TextLayer *text_layer, GTextOverflowMode overflow_mode) {
PBL_ASSERTN(text_layer);
if (overflow_mode == text_layer->ov... |
s_actions_serialize_payload(attr_list, action_group, new_prefs->data, payload_size);
// Add the new entry to the DB
rv = prv_save_serialized_prefs(&file, app_id, length, new_prefs, serialized_prefs_size);
prv_file_close_and_unlock(&file);
if (rv == S_SUCCESS) {
char buffer[length + 1];
strncpy(buffer,... | (&file, app_id, key_len, &prefs) | ;
uint32_t flags = prefs->flags;
prv_free_serialzed_prefs(prefs);
prv_file_close_and_unlock(&file);
return flags;
}
#endif
// ----------------------------------------------------------------------------------------------
static bool prv_print_notif_pref_db(SettingsFile *file, SettingsRecordInfo *info, void *co... |
og->buffer[0];
prv_start_text_animation(context);
}
}
static void prv_transcription_dialog_select_cb(void *context) {
TranscriptionDialog *transcription_dialog = context;
if (transcription_dialog->keep_alive_on_select) {
action_bar_layer_clear_icon(&transcription_dialog->e_dialog.action_bar, BUTTON_ID_SE... | (&dialog->status_layer, GColorLightGray, GColorBlack) | ;
}
|
/*
* 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... | timeline_item_create_with_attributes(alarm_time, 0, TimelineItemTypePin,
LayoutIdAlarm, &pin_attr_list, &action_group) | ;
item->header.from_watch = true;
item->header.parent_id = (Uuid)UUID_ALARMS_DATA_SOURCE;
pin_db_insert_item_without_event(item);
i18n_free_all(&pin_attr_list);
i18n_free_all(&edit_attr_list);
attribute_list_destroy_list(&pin_attr_list);
attribute_list_destroy_list(&edit_attr_list);
task_free(action_g... |
UND_ELSE(63, background_width);
const int16_t back_value_y_offset = STATUS_BAR_LAYER_HEIGHT + PBL_IF_ROUND_ELSE(24, 0);
const int16_t mid_value_y_offset = back_value_y_offset + PBL_IF_ROUND_ELSE(30, 26);
const int16_t front_value_y_offset = mid_value_y_offset + PBL_IF_ROUND_ELSE(30, 40);
const int16_t disconnec... | (text_layer_get_layer(data->disconnected_text), true) | |
_point_precise(PP(10.5, 11.5), s_graphics_line_draw_precise_stroked.last_call.pp1);
EXECUTE_SCRIPT(
"ctx.fill();\n"
);
// only first shape has at least 3 points
cl_assert_equal_i(1, s_gpath_draw_filled.call_count);
MockCallRecording *lc = &s_gpath_draw_filled.last_call;
cl_assert_equal_i(4, lc->path.nu... | (1, s_graphics_line_draw_precise_stroked.call_count) | ;
cl_assert_equal_i(1, s_graphics_draw_arc_precise.call_count);
MockCallRecording *lc = &s_graphics_draw_arc_precise.last_call;
cl_assert_equal_point_precise(PP(59.5, 79.5), lc->draw_arc.center);
cl_assert_equal_i(20 * 8, lc->draw_arc.radius.raw_value);
cl_assert_equal_i(TRIG_MAX_ANGLE * 3 / 4, lc->draw_arc.... |
},
.allocated_buffer = NULL,
}, {
.header = {
.id = {0x02},
.parent_id = {0},
.timestamp = 1421107200, // Tue Jan 13 midnight 2015 UTC
.duration = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.all_day = 1,
.layout = LayoutIdTest,
},
.attr_... | iter_prev(&iterator) | );
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
}
void test_timeline__forward_and_back(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
// Note: 1421178000 = Tue Jan 13 11:40:00 PST 2015
// check first
timeline_init(&head);
cl_assert_equa... |
e(first_valid_time - 12, first_valid_time + 13,
&range);
cl_assert_equal_b(result, true);
cl_assert_equal_range(range, ((HealthServiceTimeRange){
.last_day_idx = ACTIVITY_HISTORY_DAYS - 1,
.num_days = 1,
.seconds_first_day = 13,
.seconds_last_day = 13,
.second... | prv_adjust_value_boundaries(values, ARRAY_LENGTH(values), &range) | ;
cl_assert_equal_i(values[0], 1000);
cl_assert_equal_i(values[1], 1000 / 5);
cl_assert_equal_i(values[2], 1000);
cl_assert_equal_i(values[3], 1000 / 10);
}
void test_health__sum_fraction_days(void) {
// use values structured as binary mask so we can detect if we sum up currect days
s_sys_activity_get_metr... |
-936, 96, -352},
{ -1168, 264, -312},
{ -1448, 352, -408},
{ -1640, 192, -464},
{ -1760, 64, -168},
{ -1752, 408, -64},
{ -1280, 688, 400},
{ -1344, 424, -96},
{ -1296, 392, 8},
{ -1304, 312, 88},
{ -1080, 376, 64},
{ -944, 368, 104},
{ -1064, 560, 120},
{ -1000, 608... | { -1064, 144, 88},
{ -1024, -32, 120},
{ -816, -496, 40},
{ -672, -264, -704},
// 29 seconds
{ -1448, 88, -440},
{ -1704, 72, -512},
{ -1672, 104, -248},
{ -1600, 8, -56},
{ -1520, 264, -144},
{ -1432, 392, 56},
{ -1384, 224, 80},
{ -1416, 376, 32},
{ -1256, 336, ... |
{ -1416, 392, 200},
{ -1336, 488, 8},
{ -1208, 512, -48},
{ -1048, 368, -16},
{ -912, 544, -128},
{ -1000, 608, -104},
{ -1176, 640, -64},
{ -1232, 680, -96},
{ -968, 464, -200},
{ -1136, 480, -184},
{ -1456, 520, -64},
{ -1768, 408, -104},
{ -1816, 184, 8},
{ -2... |
s &= commit_succeeded;
prv_mark_pb_jobs_complete(1);
prv_cleanup_and_send_response((commit_succeeded) ? ResponseAck : ResponseNack);
}
static bool prv_is_valid_command_for_current_state(PutBytesCommand command) {
switch (s_pb_state.current_command) {
case PutBytesIdle:
return (command == PutBytesInit || co... | new_timer_start(s_pb_state.timer_id, PUT_TIMEOUT_MS, prv_timer_callback,
&s_pb_state, 0 /*flags*/) | );
prv_mark_pb_jobs_complete(num_put_jobs);
// At this point we have updated the outstanding jobs. Check to see if a job started to arrive in
// the meantime which needs to be ack'ed now that space is free
bool do_ack;
prv_lock_pb_job_state();
{
do_ack = put_jobs->need_to_ack_later;
put_jobs->need... |
cl_assert(gcolor_equal(context.draw_state.fill_color, GColorWhite));
// Compositing Mode
graphics_context_set_compositing_mode(&context, GCompOpOr);
cl_assert(context.draw_state.compositing_mode == GCompOpOr);
// Text Color
graphics_context_set_text_color(&context, GColorClear);
cl_assert_equal_i(contex... | graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4) | |
("Notifications", "Enabled", __FILE__) | ;
cl_assert(strcmp(first, "Activée") == 0);
const char *second = i18n_ctx_get("Quiet Time", "Enabled", __FILE__);
cl_assert(strcmp(second, "Activé") == 0);
const char *third = i18n_get(ctxt_txt_1, __FILE__);
cl_assert(third == first);
const char *fourth = i18n_get(ctxt_txt_2, __FILE__);
cl_assert(fourth =... | |
/*
* 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... | (is_invalid == true) | ;
}
void test_hdlc__decode_escaped_special(void) {
// 2 escaped special characters
uint8_t data;
bool should_store, is_invalid, is_complete;
HdlcStreamingContext ctx;
hdlc_streaming_decode_reset(&ctx);
// escaped escape character
data = HDLC_ESCAPE;
is_complete = hdlc_streaming_decode(&ctx, &data, &sh... |
e_v2__getting_started_complete(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), false);
shared_prf_storage_set_getting_started_complete(true);
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), true);
shared_prf_storage_wipe_all();
... | (strcmp(device_name_out, device_name_classic), 0) | ;
cl_assert_equal_i(memcmp(&out_addr, &addr, sizeof(addr)), 0);
cl_assert_equal_i(memcmp(&link_key_out, &link_key_out, sizeof(link_key)), 0);
}
void test_shared_prf_storage_v2__bt_classic_pairing(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_bt_classic_pairing_data(NULL, NULL,... |
360, 808, -216},
{ 224, 832, -160},
{ 104, 784, -80},
{ -24, 992, -208},
{ -16, 1088, -80},
{ -64, 880, -152},
{ -32, 1080, -216},
// 5 seconds
{ -32, 1096, -160},
{ 64, 992, -64},
{ -32, 1112, -288},
{ 240, 656, -128},
{ 320, 984, -72},
{ 448, 736, 112},
{ 320, 1... | { 1096, -48, -24},
{ 1160, 48, -200},
{ 1400, 176, -272},
{ 1480, 112, -328},
{ 1152, 152, -320},
{ 808, 216, -352},
{ 816, 232, -344},
{ 1008, 224, -352},
{ 1152, 280, -456},
{ 1208, 424, -608},
{ 1600, 560, -760},
{ 1144, 672, -528},
{ 1504, 752, -320},
{ 1208, ... |
{ 1344, 280, -288},
{ 1184, 200, -104},
{ 1032, 112, -64},
{ 1056, 192, -160},
{ 1256, 200, -152},
// 13 seconds
{ 1240, 184, -136},
{ 1184, 168, -176},
{ 1168, 48, -120},
{ 824, -48, -160},
{ 928, -24, -104},
{ 888, 56, -160},
{ 1160, 128, -280},
{ 1560, 64, -34... |
ic_service_if_subscribe_entity_update_characteristic_fails(void) {
prv_discover_ams(1 /* num_instances */);
// Simulate failed subscription:
BLECharacteristic entity_update = s_characteristics[0][AMSCharacteristicEntityUpdate];
ams_handle_subscribe(entity_update, BLESubscriptionNotifications, BLEGATTErrorUnlik... | cl_assert(s_launcher_task_callback != NULL) | ;
s_launcher_task_callback(s_launcher_task_callback_data);
// Expect to have written the command to register for the Player entity:
fake_gatt_client_op_assert_write(entity_update, s_register_player_entity,
sizeof(s_register_player_entity), GAPLEClientKernel,
... |
/*
* 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... | while (tmp) {
ListNode *next = list_get_next((ListNode *)tmp);
kernel_free(tmp);
tmp = next;
} |
if (connection->ppogatt_wa_state) {
ppogatt_destroy_state(connection->ppogatt_wa_state);
}
kernel_free(connection);
}
}
prv_unlock();
}
bool connection_is_valid(Connection *connection) {
bool rv;
prv_lock();
{
rv = list_contains((ListNode *)s_connections, (const ListNode ... |
imprecise_center_point = (GPoint) {
.x = bounds->size.w / 2,
.y = bounds->size.h / 4,
};
case CLOCK_LOCATION_RIGHT:
imprecise_center_point = (GPoint) {
.x = bounds->size.w * 3 / 4 - 5,
.y = bounds->size.h / 2,
};
case CLOCK_LOCATION_BOTTOM:
imprecis... | if (!did_focus) {
return;
} |
app_focus_service_unsubscribe();
watch_model_start_intro();
}
static void prv_init(void) {
MultiWatchData *data = app_zalloc_check(sizeof(*data));
app_state_set_user_data(data);
data->text_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
window_init(&data->window, "TicToc");
window_set_window_ha... |
ta.fields) {
// The pairing stored is empty
rv = false;
goto unlock;
}
if (pairing_info_out) {
*pairing_info_out = (SMPairingInfo) {
.local_encryption_info.ltk = data.l_ltk,
.local_encryption_info.ediv = data.l_ediv,
.local_encryption_info.rand = data.l_rand,
... | {
SprfPinnedAddress data;
rv = SPRF_FETCH_FIELD(data, pinned_address);
if (!rv) {
goto unlock;
}
if (address_out) {
*address_out = data.pinned_address;
}
rv = true;
} |
unlock:
prv_unlock();
return rv;
}
//! Stores the new BLE Pinned Address in the shared storage.
void shared_prf_storage_set_ble_pinned_address(const BTDeviceAddress *address) {
prv_lock();
{
if (address) {
SprfPinnedAddress data = {
.pinned_address = *address,
};
SPRF_PERSIST_FI... |
/*
* 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... | mutex_lock_recursive(s_music_ctx.mutex) | ;
if (connected) {
if (s_music_ctx.implementation == NULL) {
change_type = Connected;
s_music_ctx.implementation = implementation;
PBL_LOG(LOG_LEVEL_INFO, "Music server connected: %s", implementation->debug_name);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Server <0x%p> connected, but another... |
it and cause it to be freed before we grab the session->data->mutex below.
session->data->open_count++;
mutex_unlock_recursive(s_list_mutex);
mutex_lock(session->data->mutex);
return true;
}
// ---------------------------------------------------------------------------------------
// Callback used to free a... | mutex_lock_recursive(s_list_mutex) | ;
DataLoggingSession **iter = &s_logging_sessions;
while (*iter != NULL) {
if (*iter == logging_session) {
*iter = (*iter)->next;
mutex_unlock_recursive(s_list_mutex);
if (logging_session->data) {
mutex_destroy(logging_session->data->mutex);
kernel_free(logging_session->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... | text_layer_init(&text_layer, &GRect(10, 20, 30, 40)) | ;
text_layer.layer.window = &window;
scroll_layer_is_instance_value = NULL;
}
void test_text_layer_flow__cleanup(void) {
}
void test_text_layer_flow__return_value_handling(void) {
GPoint origin;
GRect page;
cl_assert(false == text_layer_calc_text_flow_paging_values(&text_layer, &origin, &page));
layer_add... |
nd callbacks
typedef struct DialogNode {
const char *label;
void (*show)(DialogsData *data);
} DialogNode;
static const DialogNode nodes[] = {
{ .label = "D1 - Confirm", .show = prv_show_confirm_dialog, },
{ .label = "D2 - Decline", .show = prv_show_decline_dialog, ... | app_free(data) | ;
}
////////////////////
// App boilerplate
static void s_main(void) {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
}
const PebbleProcessMd* dialogs_demo_get_app_info() {
static const PebbleProcessMdSystem s_app_md = {
.common = {
.main_func = s_main,
// UUID: ab470e5f-5ffd-46f2-... |
_key, 0x00);
// change the classic addr
addr.octets[0] = 0x99;
shared_prf_storage_store_bt_classic_pairing_data(&addr, device_name_classic, &link_key, 0x00);
// Store an LE pairing
char device_name_le[BT_DEVICE_NAME_BUFFER_SIZE] = "LE";
shared_prf_storage_store_ble_pairing_data(&s_pairing_info, device_n... | cl_assert_equal_b(shared_prf_storage_get_root_key(key_type, &keys_out[key_type]), true) | ;
// It's a byte array inside, so memcmp should be OK to use:
cl_assert_equal_i(memcmp(&keys[key_type], &keys_out[key_type], sizeof(keys[0])), 0);
}
}
void test_shared_prf_storage_v2__local_device_name(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_local_device_name(NULL... |
t_actioned_flag(void) {
Uuid i;
uuid_generate(&i);
TimelineItem e = {
.header = {
.id = i,
.type = TimelineItemTypeNotification,
.status = 0,
.ancs_uid = 0,
.layout = LayoutIdGeneric,
.timestamp = 0x53f0dda5,
},
.attr_list = {
.num_attributes = ARRAY_LENGTH(at... | (r.allocated_buffer) | ;
cl_assert_equal_b(notification_storage_get(&i2, &r), false);
cl_assert(notification_storage_get(&i3, &r));
compare_notifications(&e3, &r);
free(r.allocated_buffer);
e2.header.timestamp = e3.header.timestamp + 1;
notification_storage_store(&e2);
cl_assert(notification_storage_get(&i1, &r));
compare... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ERROR, "Could not start timer.") | ;
}
}
static bool prv_should_use_item(TimelineEventState *state, SerializedTimelineItemHeader *header) {
// Use the new item if ...
return ((uuid_is_invalid(&state->filter_header->common.id)) || // There is no old item
(state->impl->comparator && // Or the comparator chooses the new item
(st... |
nst uint8_t *attributes_per_group_type_element) {
if (num_group_type_elements > 0) {
if (type == AttributeGroupType_Action) {
((TimelineItemActionGroup *) group_ptr)->num_actions = num_group_type_elements;
((TimelineItemActionGroup *) group_ptr)->actions = (TimelineItemAction *)*buffer;
*buffer ... | prv_deserialize_action(
&((TimelineItemActionGroup *)group_ptr)->actions[i], &cursor, payload_end,
buffer, buf_end) | ;
} else {
group_type_element_attribtue_list = prv_deserialize_address(
&((AddressList *)group_ptr)->addresses[i], &cursor, payload_end,
buffer, buf_end);
}
if (!attribute_deserialize_list((char**)&buffer, (char *)buf_end, &cursor,
payload_end, ... |
= (const SerializedAppGlanceHeader *)val;
size_t len = val_len;
status_t rv = prv_validate_glance(app_uuid, serialized_glance, &len);
if (rv != S_SUCCESS) {
return rv;
}
// Fetch app if it's in the app DB, but not cached. If it's not in the app db and not a system app
// reject the glance insert
App... | (&s_app_glance_db.settings_file, key, key_len, val, val_len) | |
ndeterminate state.
// - written: The typical state for a record. == !partially_written
// - partially_overwritten: This record has been superceeded by another, which
// we are currently in the process of writing out to flash. Records in
// this state are restored on bootup.
// - overwritten: This record has be... | uint8_t *key = kernel_malloc(hdr->key_len);
settings_raw_iter_read_key(&file->iter, key);
uint8_t *val = kernel_malloc(hdr->val_len);
settings_raw_iter_read_val(&file->iter, val, hdr->val_len);
// Include in re-written file if it passes the filter
if (!filter_cb || filter_cb(key, hdr->key_len, ... |
T_STATIC status_t settings_file_compact(SettingsFile *file) {
return settings_file_rewrite_filtered(file, NULL, NULL);
}
static bool key_matches(SettingsRawIter *iter, const uint8_t *key, int key_len) {
SettingsRecordHeader *hdr = &iter->hdr;
if (key_len != hdr->key_len) {
return false;
}
if (crc8_calc... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | i18n_get("Remove", &pin_attr_list) | |
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
setup_test_aa_sw(&ctx, fb, RECT_NULL_H, RECT_... | (&ctx.dest_bitmap, "draw_text_color_set.8bit.pbi") | );
}
void test_graphics_draw_text_8bit__data_row_offsets(void) {
GContext ctx;
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */);
r... |
FIG_1 = 0x83,
PmicRegisters_CHARGE_CONFIG_2 = 0x84,
PmicRegisters_CHARGE_SUPERVISION = 0x85,
PmicRegisters_CHARGE_STATUS_1 = 0x86,
PmicRegisters_CHARGE_STATUS_2 = 0x87,
PmicRegisters_LOCK_REG = 0x8e,
PmicRegisters_CHIP_ID = 0x90,
PmicRegisters_CHIP_REV = 0x91,
PmicRegisters_FUSE_5 = 0xa5,
PmicRegis... | (PmicRegisters_INT_STATUS_2, &throwaway_read_result) | ;
}
static void prv_pmic_state_change_cb(void *null) {
prv_clear_pending_interrupts();
new_timer_start(s_debounce_charger_timer, CHARGER_DEBOUNCE_MS,
prv_handle_charge_state_change, NULL, 0 /*flags*/);
}
static void prv_as3701b_interrupt_handler(bool *should_context_switch) {
system_task_add_c... |
ails we need to clean up, and if the item contains garbage
// data we will try to free a garbage allocated buffer field and crash.
memset(item_out, 0, sizeof(TimelineItem));
size_t string_alloc_size;
char *buffer;
if (!timeline_item_create_from_serial_data(item_out,
... | PBL_LOG(LOG_LEVEL_ERROR, "Could not deserialize attributes to verify") | ;
return false;
}
// verify that the layout of the item has the attribute it requires
LayoutId layout = hdr->common.layout;
PBL_LOG(LOG_LEVEL_DEBUG, "Number of attributes: %d for layout: %d", hdr->num_attributes, layout);
return layout_verify(has_attribute, layout);
}
bool timeline_item_action_is_dismiss... |
issions and
* limitations under the License.
*/
#include "health_progress.h"
#include "applib/graphics/gpath_builder.h"
#include "system/logging.h"
// Scales a total shape offset to an individual segment offset.
// @param total_offset should not be larger than the segment's percent of total
static int prv_total_o... | {
if (prv_is_segment_corner(segment)) {
// Fully fill corner segments for now
prv_fill_segment(ctx, segment, color, 0, HEALTH_PROGRESS_BAR_MAX_VALUE);
segment++;
continue;
}
const int from_total = MAX(start, amount_traversed) - amount_traversed;
const int to_total = MIN(end, amo... |
}
void health_progress_bar_mark(GContext *ctx, HealthProgressBar *progress_bar, GColor color,
HealthProgressBarValue value_to_mark) {
if (value_to_mark < 0) {
// This ensures we don't deal with negative values
value_to_mark += HEALTH_PROGRESS_BAR_MAX_VALUE;
}
HealthProgres... |
/*
* 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... | (CRG_TOP, CLK_AMBA_REG, AES_CLK_ENABLE) | |
PBL_LOG(LOG_LEVEL_DEBUG, "Got DIRTY DBs");
prv_handle_get_dirty_databases(session, data, data_length);
break;
case BLOB_DB_COMMAND_START_SYNC:
PBL_LOG(LOG_LEVEL_DEBUG, "Got SYNC");
prv_handle_start_sync(session, data, data_length);
break;
case BLOB_DB_COMMAND_WRITE_RESPONSE:
... | (LOG_LEVEL_DEBUG, "Sending sync done for db: %d", db_id) | ;
comm_session_send_data(comm_session_get_system_session(),
BLOB_DB2_ENDPOINT_ID,
(uint8_t *)&msg,
sizeof(msg),
COMM_SESSION_DEFAULT_TIMEOUT);
}
void blob_db2_protocol_msg_callback(CommSession *session, const uint8_t... |
r, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
return animation_legacy2_is_scheduled((AnimationLegacy2 *)animation_h);
}
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, true /*quiet*/);
if (!animation) {
return false;
}
return prv... | prv_find_animation_by_handle(NULL, animation_h, false /*quiet*/) | ;
if (!animation) {
return NULL;
}
return animation->context;
}
// -------------------------------------------------------------------------------------------
bool animation_set_delay(Animation *animation_h, uint32_t delay_ms) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (ani... |
top_margin.raw_value = tm_p0.y.raw_value + ((tm_p1.y.raw_value - tm_p0.y.raw_value)
* (x - ((tm_p0.x.raw_value + add_top) / FIXED_S16_3_ONE.raw_value)))
* FIXED_S16_3_ONE.raw_value / (tm_p1.x.raw_value - tm_p0.x.raw_value);
} else {
top_margin.raw_value = tm_p0.y.ra... | prv_draw_stroked_line_override_aa(ctx, p0, p1, stroke_width, false) | ;
}
void graphics_line_draw_precise_stroked(GContext* ctx, GPointPrecise p0, GPointPrecise p1) {
if (ctx->draw_state.stroke_width >= MINIMUM_PRECISE_STROKE_WIDTH) {
prv_draw_stroked_line_precise(ctx, p0, p1, ctx->draw_state.stroke_width);
} else {
graphics_draw_line(ctx, GPointFromGPointPrecise(p0), GPoint... |
up_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2), GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax1_aa_clip_xy.${BIT_DEPTH_NAME}.pbi"));
// Should draw same as r... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1) | ;
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1, GCornersRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_right.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_fill_ro... |
ettings_glance->battery_percent_text), buffer_size);
strncpy(buffer, settings_glance->battery_percent_text, buffer_size);
buffer[buffer_size - 1] = '\0';
}
}
static GTextNode *prv_wrap_text_node_in_vertically_centered_container(GTextNode *node) {
const size_t max_vertical_container_nodes = 1;
GTextNodeVe... | (&settings_glance->hrm_sharing_event_info) | ;
#endif
kino_reel_destroy(settings_glance->icon);
kino_reel_destroy(settings_glance->charging_indicator_icon);
}
app_free(settings_glance);
}
static void prv_set_glance_icon(LauncherAppGlanceSettings *settings_glance,
uint32_t new_icon_resource_id) {
if (settings_glance->... |
/*
* 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... | {
AppWorkerResult result = app_worker_launch();
if (result == APP_WORKER_RESULT_SUCCESS) {
message = WORKER_LAUNCHED;
} else {
message = WORKER_LAUNCH_ERROR;
}
} | |
/*
* 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... | {
char *str = context;
strcat(str, entry->name);
strcat(str, "\n");
} |
void prv_each_app_ids(uint32_t num_ids, AppInstallId *ids, EachCb cb, void *context) {
for (uint32_t i = 0; i < num_ids; i++) {
// app_title +1 to add newline per line
AppInstallId app_id = ids[i];
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(app_id, &entry)) {
continue;
... |
state->dp = opendir(state->res_path);
if (state->dp == NULL) {
printf("\nCould not open directory %s", state->res_path);
return false;
}
state->type = samples_type;
return true;
}
// ---------------------------------------------------------------------------------------
// Advance to the next fil... | strcmp(entry_a->name, entry_b->name) | ;
}
}
// --------------------------------------------------------------------------------------
// Callback provided to the qsort() routine for sorting sleep tests by name
int prv_qsort_sleep_test_entry_cb(const void *a, const void *b) {
SleepFileTestEntry *entry_a = (SleepFileTestEntry *)a;
SleepFileTestEntry ... |
top_metric, middle_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics,
&s_sports_data, &s_sports_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_no_hrm(void) {
s_hrm_is_present = false;
... | cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_workout_active__sports_custom_field(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
.custom_label_string = "CUSTOM",
.custom_value_string = "000000",
};
WorkoutMetricType top_metric = Wor... |
ottom.y.raw_value) {
prv_swap_precise_points(&end_top, &end_bottom);
} else if (end_top.y.raw_value == end_bottom.y.raw_value &&
(config.end_quadrant.quadrant & GCornersBottom)) {
// Special case to make bottom edge to be on left side and keep masking algorithm happy
prv_swap_precise_points(&... | if (odd_line) {
int16_t starting_edge = center.x.raw_value - radius_outer_x.raw_value;
int16_t ending_edge = center.x.raw_value + radius_outer_x.raw_value;
if (!is_full_circle) {
// Following code finds crossing points slightly above and below center point
// as the radial angles will appear ... | |
->subscriber.filter(recognizer, touch_event);
}
static void prv_send_subscriber_event(Recognizer *recognizer) {
RecognizerEvent event;
switch (recognizer->state) {
case RecognizerState_Started:
event = RecognizerEvent_Started;
break;
case RecognizerState_Updated:
event = RecognizerEvent_... | (recognizer->state == RecognizerState_Possible) | ;
prv_set_state(recognizer, RecognizerState_Failed);
if (recognizer->impl->on_fail) {
recognizer->impl->on_fail(recognizer);
}
}
void recognizer_set_manager(Recognizer *recognizer, RecognizerManager *manager) {
PBL_ASSERTN(recognizer);
recognizer->manager = manager;
}
RecognizerManager *recognizer_get... |
ROR_INVALID_VALUE_LENGTH) {
PBL_LOG(LOG_LEVEL_ALWAYS, "Invalid value length %"PRIu16, evt->length);
}
return rv;
}
static void prv_pps_handle_write_request(ble_service_t *svc, const ble_evt_gatts_write_req_t *evt) {
att_error_t rv = ATT_ERROR_INVALID_HANDLE;
if (evt->handle == s_pps_ctx.att_hdl.trigger_pai... | PBL_ASSERTN(ble_gatts_add_characteristic(&uuid, GATT_PROP_READ | GATT_PROP_WRITE, ATT_PERM_RW,
sizeof(uint8_t), enable_read_cb_flag, NULL,
&ctx->att_hdl.trigger_pairing) == BLE_STATUS_OK) | ;
// GATT MTU characteristic + CCCD:
prv_convert_uuid_to_little_endian(
(const uint8_t[]){PEBBLE_BT_PAIRING_SERVICE_GATT_MTU_UUID}, &uuid);
PBL_ASSERTN(ble_gatts_add_characteristic(&uuid, GATT_PROP_READ | GATT_PROP_NOTIFY |
GATT_PROP_WRITE,
... |
s/normal/weather/weather_types.h"
#include "util/pstring.h"
// Fixture
////////////////////////////////////////////////////////////////
// Fakes
////////////////////////////////////////////////////////////////
#include "fake_pbl_malloc.h"
#include "fake_spi_flash.h"
// Stubs
/////////////////////////////////////////... | while (current) {
cl_assert_equal_i(current->id, id);
prv_assert_forecast_equal(¤t->forecast, &s_forecasts[id]);
id++;
current = (WeatherDataListNode *)current->node.next;
} |
cl_assert_equal_i(count_out, 4);
cl_assert_equal_i(id, 4);
weather_service_locations_list_destroy(head);
}
void test_weather_service__get_default_location_forecast_from_weather_db_update(void) {
WeatherLocationForecast *forecast = weather_service_create_default_forecast();
// no blob db events were fired ... |
ey = {};
if (0 == memcmp(&nil_key, &data.keys[key_type], sizeof(nil_key))) {
rv = false;
goto unlock;
}
if (key_out) {
memcpy(key_out, &data.keys[key_type], sizeof(*key_out));
}
rv = true;
}
unlock:
prv_unlock();
return rv;
}
void shared_prf_storage_set_root_keys(SM128BitK... | SPRF_FLAG_GET_BIT(pairing_info->is_remote_identity_info_valid,
SprfValidFields_RemoteIdentityInfoValid) | |
SPRF_FLAG_GET_BIT(pairing_info->is_remote_signing_info_valid,
SprfValidFields_RemoteSigningInfoValid),
};
SPRF_PERSIST_FIELD(data, ble_pairing_data);
if (name) {
// only persist name if one is actually included
SprfBlePairingName name_data =... |
timeline resources
.sdk_version = {TIMELINE_RESOURCE_PBW_SUPPORT_FIRST_SDK_VERSION_MAJOR,
TIMELINE_RESOURCE_PBW_SUPPORT_FIRST_SDK_VERSION_MINOR - 1},
},
.resource_lut = s_app_lut,
},
{
.install_entry = {
.install_id = TimelineResourceTestAppId_ValidApp,
.uuid = {... | {
AppResourceInfo res_info;
// Calling the function with an invalid TimelineResourceId should return false
cl_assert(!timeline_resources_get_id_system(TIMELINE_RESOURCE_INVALID, TimelineResourceSizeTiny,
TimelineResourceTestAppId_ValidApp, &res_info));
// Calling the function with an invalid size ... |
cl_assert_equal_i(res_info.res_app_num, TimelineResourceTestAppId_ValidApp);
cl_assert_equal_i(res_info.res_id, RESOURCE_ID_ALARM_CLOCK_TINY);
// Calling the function with valid args should return true even if no AppResourceInfo is provided
cl_assert(timeline_resources_get_id_system(
(TimelineResourceId... |
);
return GRect(config->horizontal_margin, config->title_field.origin_y,
prv_text_layer_width(), config->title_field.size_h);
}
static GRect prv_time_rect(void) {
const MusicAppSizeConfig *config = prv_config();
return GRect(config->horizontal_margin, config->time_field.origin_y,
pr... | music_is_command_supported(MusicCommandVolumeDown) | ) {
return;
}
MusicAppData *data = app_state_get_user_data();
prv_show_volume_image(volume_is_up ? &data->image_volume_up : &data->image_volume_down);
music_command_send(volume_is_up ? MusicCommandVolumeUp : MusicCommandVolumeDown);
}
static Animation* prv_create_layer_upwards_animation(Layer *layer, int1... |
/*
* 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... | gap_le_connection_by_device(&payload->address) | ;
if (connection == NULL) {
PBL_LOG(LOG_LEVEL_WARNING, "Discovery complete but no device connected?");
return;
}
BTErrno e = (payload->status == HciStatusCode_Success) ? BTErrnoOK :
(BTErrnoInternalErrorBegin + payload->status);
bt_driver_cb_gatt_client_discovery_complete(connection, e);
}
stat... |
N_VERY_LOW_LARGE
};
static void prv_update_ui_fully_charged(Dialog *dialog, void *ignored) {
dialog_set_text(dialog, i18n_get("Fully Charged", dialog));
dialog_set_background_color(dialog, GColorKellyGreen);
dialog_set_icon(dialog, RESOURCE_ID_BATTERY_ICON_FULL_LARGE);
}
static void prv_update_ui_charging(Dialo... | (stack, prv_update_ui_fully_charged, NULL) | |
l_caps), "EVERY DAY");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_WEEKDAYS, all_caps), "WEEKDAYS");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_WEEKENDS, all_caps), "WEEKENDS");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_JUST_ONCE, all_caps), "ONCE");
cl_assert_equal_s(alarm_g... | (next_alarm_time, 0) | |
_COMPOSITOR_RADIUS 7
#define DOT_OFFSET 25
#define UPDATE_INTERVAL 200
#define UPDATE_AMOUNT 2
#define FAILURE_PERCENT 15
#define INITIAL_PERCENT 0
//! App data
typedef struct {
//! UI
ProgressWindow window;
//! App fetch result
AppFetchResult result;
//! Data
AppInstallEntry install_entry;
AppFetchUIA... | prv_app_fetch_launch_app(data) | |
)value);
// See how many steps we took during sleep. The light sleep simulator ends up providing about
// 12 steps every 10 minutes, so without the "no steps during sleep" logic in the activity
// service, we would end up with about 180/10 * 12 = 216 steps during sleep. With the
// "no steps during sleep" logi... | (&session_entries, sessions) | ;
if (!success) {
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Looking for sessions...");
for (uint32_t i = 0; i < session_entries; i++) {
ActivitySession *session = &sessions[i];
PBL_LOG(LOG_LEVEL_DEBUG, " Found session type: %d, start_min: %d, length_min: %"PRIu16" ",
(int)session->type, time... |
_context) {
AlarmsAppData *data = (AlarmsAppData *)callback_context;
if (prv_is_add_alarm_cell(&old_index)) {
data->show_limit_reached_text = false;
}
}
#if CAPABILITY_HAS_HEALTH_TRACKING
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Smart Alarm first... | event_service_client_subscribe(&data->alarm_event_info) | ;
if (prv_are_alarms_scheduled(data)) {
app_window_stack_push(&data->window, true);
menu_layer_set_selected_index(&data->menu_layer, MenuIndex(0, 1),
PBL_IF_RECT_ELSE(MenuRowAlignNone, MenuRowAlignCenter), false);
} else {
Window *editor = alarm_editor_create_new_alarm... |
zeof(s_test_impl_data), dummy,
NULL));
s_test_impl.reset = dummy;
s_test_impl.cancel = NULL;
cl_assert_passert(recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
sizeof(s_test_impl_data), dummy,
... | (recognizer_transition_state(r, RecognizerState_Possible)) | ;
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Started));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Updated));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Cancelled));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Completed));
... |
/*
* 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... | progress_layer_set_progress(progress_layer, data->progress) | ;
layer_add_child(&window->layer, &progress_layer->layer);
progress_layer_set_corner_radius(progress_layer, PBL_IF_COLOR_ELSE(2, 3));
}
static void handle_init(void) {
ProgressAppData *data = app_zalloc_check(sizeof(ProgressAppData));
app_state_set_user_data(data);
Window* window = &data->window;
window_... |
/*
* 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 remaining_length = length;
const SessionSendQueueJob *job = session->send_queue_head;
while (job && remaining_length) {
const size_t job_length = job->impl->get_length(job);
if (job_length <= start_offset) {
start_offset -= job_length;
} else {
const size_t copied_length = job->im... | |
(&s_desired_ad_data.ad_data, ad_data,
sizeof(BLEAdData) + ad_data->ad_data_length + ad_data->scan_resp_data_length) | ;
s_desired_ad_data.needs_updating = true;
}
prv_unlock();
}
static void prv_resume_if_needed(void) {
if (s_desired_host_adv_state == AdvertState_Running) {
PBL_LOG(LOG_LEVEL_DEBUG, "Unpausing advertisements");
}
s_adv_state = AdvertState_Off;
prv_try_to_enter_host_desired_state();
}
void advert_h... | |
selection) {
case ATTRIBUTE_HUE:
++data->hue;
if (data->hue >= HUE_COUNT) {
data->hue = 0;
}
break;
case ATTRIBUTE_PIXEL_BIT:
++data->pixel_bit;
if (data->pixel_bit >= PIXEL_BIT_COUNT) {
data->pixel_bit = 0;
}
break;
case ATTRIBUTE_X:
if ... | if (data->hue == HUE_GREEN) {
g = 1;
} else if (data->hue == HUE_BLUE) {
b = 1;
} else if (data->hue == HUE_WHITE) {
r = 1;
g = 1;
b = 1;
} | |
,
void *callback_context) {
AlarmEditorData *data = (AlarmEditorData *)callback_context;
data->day_picker_was_completed = false;
if (cell_index->row == DayPickerMenuItemsCustom) {
prv_handle_custom_day_selection(cell_index->row, callback_context);
} else {
da... | gbitmap_init_with_resource(&data->checkmark_icon, data->current_checkmark_icon_resource_id) | ;
}
box.origin = GPoint((((cell_layer->bounds.size.w)/2)-((data->checkmark_icon.bounds.size.w)/2)),
(((cell_layer->bounds.size.h)/2)-((data->checkmark_icon.bounds.size.h)/2)));
box.size = data->checkmark_icon.bounds.size;
graphics_context_set_compositing_mode(ctx, GCompOpTint);
... |
_persistent_storage_get_bt_classic_pairing_by_id(key, NULL, link_key_out,
name_out, platform_bits_out)) {
return BT_BONDING_ID_INVALID;
}
return key;
}
bool bt_persistent_storage_has_active_bt_classic_gateway_bonding(void) {
return prv_has_active_gateway_by... | (&nil_key, &keys[key_type], sizeof(nil_key)) | ) {
return false;
}
if (key_out) {
memcpy(key_out, &keys[key_type], sizeof(keys[key_type]));
}
return true;
}
void bt_persistent_storage_set_root_keys(SM128BitKey *keys_in) {
if (!keys_in) {
return;
}
shared_prf_storage_set_root_keys(keys_in);
prv_file_set(&ROOT_KEYS_KEY, sizeof(ROOT_KEY... |
nt_put(&event);
}
prv_wakeup_timer_next_pending();
}
// This callback is the system dispatcher that wakes up the application by AppInstallId
// OR queues a wakeup callback for that application
// and is triggered by NewTimer
static void prv_wakeup_dispatcher(void *data) {
// Place actual work on system_task to ... | if (entry.utc == false) {
entry.timestamp -= *((int*)utc_diff);
entry.utc = true;
if (wakeup_id == s_wakeup_state.current_wakeup_id) {
s_wakeup_state.timestamp = entry.timestamp;
}
} | |
TransportDestinationHybrid == TransportDestinationSystem,
"When passing NULL app_uuid, the destination can only be System or Hybrid");
} else {
cl_assert_(TransportDestinationSystem == destination ||
TransportDestinationHybrid == TransportDestinationSystem,
"When pa... | {
cl_assert_(s_fake_transport_head == NULL,
"Didn't clean up the fake transports? \
Call fake_comm_session_cleanup() if you don't want to clean them up manually.");
s_session_close_call_count = 0;
s_session_open_call_count = 0;
s_last_responsiveness_granted_handler = NULL;
} |
void fake_comm_session_cleanup(void) {
FakeTransport *fake_transport = s_fake_transport_head;
while (fake_transport) {
FakeTransport *next = (FakeTransport *) fake_transport->node.next;
fake_transport_destroy((Transport *) fake_transport);
fake_transport = next;
}
}
|
, i);
int fd = pfs_open(name, OP_FLAG_WRITE, FILE_TYPE_STATIC, 300);
if (i % 5 == 0) {
pfs_close_and_remove(fd);
} else {
pfs_close(fd);
}
}
}
#endif
#endif
static GAPLEConnection *prv_get_le_connection_and_print_info(void) {
GAPLEConnection *conn = gap_le_connection_any();
if (!conn)... | (packet_payload_type) | );
}
void command_btle_test_rx_start(char *rx_channel) {
bt_driver_le_receiver_test(atoi(rx_channel));
}
void command_btle_test_end(void) {
bt_driver_le_test_end();
}
//# if PLATFORM_ROBERT
static const char *s_btle_pa_config_strings[3] = { "disable", "enable", "bypass" };
void command_btle_pa_set(char *command... |
ertising_enabled());
free(ad_a);
free(ad_b);
}
void test_gap_le_advert__expiring_job(void) {
// Test that a job is expired correctly after the set duration:
uint16_t seconds_left = 5;
GAPLEAdvertisingJobTerm advert_term = {
.min_interval_slots = 160,
.max_interval_slots = 320,
.duration_secs = s... | (job, NULL) | ;
// No ad data:
advert_term.min_interval_slots = 200;
advert_term.max_interval_slots = 200;
advert_term.duration_secs = 1;
job = gap_le_advert_schedule(NULL, &advert_term,
sizeof(advert_term)/sizeof(GAPLEAdvertisingJobTerm),
unscheduled_callback,... |
cks, curr_ticks) < delta_ticks);
return s;
}
static void prv_timer_delay_1ms(void) {
uint16_t start_ticks = prv_timer_get_ticks();
while (prv_timer_check_delta(start_ticks, TIMER0_1_MS)) {};
}
static NORETURN prv_low_power_mode(void) {
// Give the host a few seconds to reboot the chip before we attempt to po... | if (tx_index == sizeof(core_dump_connect_response)) {
return true;
} |
}
}
// Pulse the INT line to wake the host
host_transport_set_mcu_int(true);
prv_timer_delay_1ms(); // The timer IRQ just fired so the counter won't be near roll-over
host_transport_set_mcu_int(false);
}
return false;
}
// Callback for SPI DMA complete
static void prv_spi_dma_tx_cb(voi... |
/*
* 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_copy_points((GPoint*)points, num_points, s_offset) | ;
s_path_fill_precise_count++;
}
void gpath_draw_filled(GContext* ctx, GPath *path) {
s_fill_points = prv_copy_points(path->points, path->num_points, s_offset);
s_path_fill_count++;
}
void gpath_draw_outline_precise_internal(GContext *ctx, GPointPrecise *points, size_t num_points,
... |
cl_assert_equal_p(r->impl, &s_test_impl);
cl_assert_equal_m(r->impl_data, &s_test_impl_data, sizeof(s_test_impl_data));
cl_assert_equal_p(r->subscriber.event, dummy);
cl_assert_equal_p(r->subscriber.data, &sub_data);
cl_assert_equal_i(r->state, RecognizerState_Possible);
cl_assert_equal_i(r->flags, 0);
cl_... | (r->state, RecognizerState_Updated) | ;
cl_assert_equal_i(event_type, RecognizerEvent_Updated);
cl_assert(!s_manager_state_change);
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Failed));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Possible));
cl_assert_passert(recognizer_transition_state(r, RecognizerState... |
_buffer2 = NULL;
size_t write_length2 = 0;
assert_result_busy(app_smartstrap_attribute_begin_write(attr, &write_buffer2, &write_length2));
cl_assert(write_buffer2 == NULL);
cl_assert(write_length2 == 0);
// end the write request without sending anything
assert_result_invalid(app_smartstrap_attribute_end_wr... | smartstrap_attribute_send_event(SmartstrapNotifyEvent, SmartstrapProfileGenericService,
SmartstrapResultOk, 0x1111, 0x3333, 0) | ;
// destroy the attribute
app_smartstrap_attribute_destroy(attr);
// send a notification for the destroyed attribute which shouldn't cause a notified handler call
smartstrap_attribute_send_event(SmartstrapNotifyEvent, SmartstrapProfileGenericService,
SmartstrapResultOk, 0x11... |
/*
* 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 (progress_callback) {
progress_callback(0, count, progress_context);
} |
FLASH_Unlock();
for (int sector = first_sector; sector <= last_sector; ++sector) {
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
if (FLASH_EraseSector(s_sectors[sector], VoltageRange_1) != FLASH_COMPL... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kernel_malloc_check(buffer_size) | ;
shared_circular_buffer_init(&state->isr_buffer, buffer_data, buffer_size);
shared_circular_buffer_add_client(&state->isr_buffer, &state->isr_buffer_client);
// Allocate buffer for the received message
state->msg_buffer = kernel_malloc_check(QEMU_MAX_DATA_LEN);
state->msg_buffer_bytes = 0;
}
// --------... |
ase_addr > FLASH_TEST_ADDR_END)) {
PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Cannot test address bit for base_addr");
return FLASH_TEST_ERR_ADDR_RANGE;
}
// erase (base_addr | test_addr) and start of test space
flash_erase_sector_blocking(test_addr);
flash_erase_sector_blocking(special_case_addr);
// Verify ... | {
break;
} |
status = prv_read_verify_byte(test_addr2, data_pattern, FLASH_TEST_ERR_STUCK_AT_LOW, bitpos2,
false /*display_logs*/);
if (status != FLASH_TEST_SUCCESS) {
stuck_at_low = true;
}
}
if (stuck_at_low) {
// Restore data back to original if stuck... |
pebble_task_get_current() | ;
}
if (task == PebbleTask_App) {
return app_state_get_battery_state_service_state();
} else if (task == PebbleTask_Worker) {
return worker_state_get_battery_state_service_state();
} else {
WTF;
}
}
static void do_handle(PebbleEvent *e, void *context) {
BatteryStateServiceState *state = prv_g... | |
a_length) {
strncpy((char *) ad->data,
ad_data, ad_data_length);
}
if (scan_resp_data_length) {
strncpy((char *) ad->data + ad_data_length,
scan_resp_data, scan_resp_data_length);
}
return ad;
}
void test_gap_le_advert__single_job(void) {
const char ad_data[] = "ad data";
con... | cl_assert_equal_i(s_unscheduled_cb_count, 0) | |
ad, &animation->list_node);
}
static void animation_legacy2_private_run(AnimationLegacy2Scheduler *animation_legacy2_scheduler) {
AnimationLegacy2 *animation = (AnimationLegacy2 *) animation_legacy2_scheduler->head;
const uint32_t now = animation_legacy2_get_ms_since_system_start();
while (animation) {
con... | PBL_ASSERTN(animation->abs_start_time_ms == 0) | |
// The AS7000 wants Accel Frequency given in 0.001Hz increments, this can be used to scale
#define AS7000_ACCEL_FREQUENCY_SCALE (1000)
//! Thresholds for quality conversion. These are upper bounds on readings.
enum AS7000SQIThreshold {
AS7000SQIThreshold_Excellent = 2,
AS7000SQIThreshold_Good = 5,
AS7000SQIThres... | (dev->i2c_slave, register_address, length, buffer) | ;
i2c_release(dev->i2c_slave);
return rv;
}
static bool prv_set_host_one_second_time_register(HRMDevice *dev, uint32_t average_ms) {
PPG_DBG("host one second time: %"PRIu32" ms", average_ms);
// Register takes a reading in 0.1ms increments
uint16_t value = average_ms * 10;
const uint8_t msb = (value >> 8... |
/*
* 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_flash_erase(FLASH_BASE, 1, NULL, NULL) | );
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sector(void) {
cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.