prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
if (payload && length) {
checksum = crc32(checksum, payload, length);
} |
prv_encode_and_send_data(&checksum, sizeof(checksum));
accessory_send_byte(HDLC_FLAG);
accessory_enable_input();
}
// Request processing
////////////////////////////////////////////////////////////////////
static void prv_erase_complete(void *ignored, status_t result) {
s_flash_erase_in_progress = false;
}... | |
s, TouchPressure touch_down_pressure);
// setup and teardown
void test_touch__initialize(void) {
fake_event_init();
touch_reset();
}
void test_touch__cleanup(void) {
}
void prv_test_touch_event(TouchEvent *touch_event, TouchIdx idx, TouchEventType type, GPoint *start_pos,
uint64_t star... | (0, TouchState_FingerDown, &GPoint(10, 10), 5, 3686400) | ;
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_TOUCH_EVENT);
cl_assert_equal_i(event.touch.type, PebbleTouchEvent_TouchesAvailable);
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
prv_test_touch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686... |
/*
* 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_LOG_DEBUG("GATT Connection for " BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE(event->dev_address)) | ;
}
unlock:
bt_unlock();
}
void bt_driver_cb_gatt_handle_disconnect(const GattDeviceDisconnectionEvent *event) {
bt_lock();
{
GAPLEConnection *connection = gap_le_connection_by_addr(&event->dev_address);
if (!connection) {
goto unlock;
}
connection->gatt_connection_id = 0;
connection-... |
to the active layer
recognizer_add_to_list(recognizers[0], &layer_c.recognizer_list);
cl_assert(prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL));
prv_compare_recognizers_processed((int[]) {0}, 1, &s_recognizers_handled);
// Two recognizers attached to the active layer - processed in o... | (r, prv_simultaneous_with_cb) | ;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert_equal_p(ctx.triggered, s);
}
bool prv_fail_recognizer(Recognizer *recognizer, void *context);
void test_recognizer_manager__fail_recognizer(void) {
NEW_RECOGNIZER(r1) = test_recognizer_create(&s_test_impl_data, NULL);
NEW_RECOGNI... |
rage[8];
circular_buffer_init(&buffer, storage, sizeof(storage));
const uint16_t data_out_size = 8;
uint8_t data_out[data_out_size];
// Test copy when there is nothing in the buffer:
cl_assert_equal_i(circular_buffer_copy(&buffer, data_out, data_out_size), 0);
// Write + consume, so read index is at 2:
... | circular_buffer_write_prepare(&buffer, &data_out) | ;
cl_assert_equal_i(contiguous_num_bytes_left, 2);
memcpy(data_out, "AB", 2);
circular_buffer_write_finish(&buffer, 2);
cl_assert_equal_i(circular_buffer_copy(&buffer, copy_out, copy_out_size), 8);
cl_assert_equal_i(memcmp(copy_out, "234567AB", 8), 0);
contiguous_num_bytes_left = circular_buffer_write_pre... |
////////////////////////////////////////////////
status_t timeline_init(TimelineNode **timeline) {
PBL_LOG(LOG_LEVEL_DEBUG, "Starting to build list.");
status_t rv = pin_db_each(prv_each, timeline);
prv_prune_ordered_timeline_list(timeline);
prv_set_indices(*timeline);
PBL_LOG(LOG_LEVEL_DEBUG, "Finished buil... | time_util_get_midnight_of(node->timestamp) | ;
iter_state->index = iter_state->node->index;
if (direction == TimelineIterDirectionPast) {
iter_init(iter, prv_iter_prev, prv_iter_next, iter_state);
} else { // Future
iter_init(iter, prv_iter_next, prv_iter_prev, iter_state);
}
return rv;
}
void timeline_iter_copy_state(TimelineIterState *dst_st... |
buf_size);
const int values_buf_size = 128;
StringList *values = kernel_zalloc_check(values_buf_size);
if (session->type == ActivitySessionType_Run) {
type = ActivityInsightType_ActivitySessionRun;
icon = TIMELINE_RESOURCE_RUN;
prv_add_metric_duration_info(headings, headings_buf_size, values, valu... | (ActivitySettingsKeyInsightActivitySessionTime,
&s_session_pin_state.start_utc,
sizeof(s_session_pin_state.start_utc)) | |
r now, select a distance metric that should work out of the box for a
// majority of the middle of the world. However, if no solution sets are found
// after 45s, fall back to a less aggressive threshold that will work
// anywhere in the world.
#define THRESH_MAX 370 /* 37 uT */
#define THRESH_MIN 220 /* 22 uT */
// ... | if (saved_sample_match == 3) {
saved_sample_match = 0;
calib_idx = 0;
PBL_LOG(LOG_LEVEL_INFO, "Persisting previous values!");
return (MagCalStatusSavedSampleMatch); // locked
} |
}
}
// do we have several solutions in a row that are close to one another
if (calib_idx >= N_COMP_SAMPS) {
x_delta = min_max_diff(calib_val[0], 3);
y_delta = min_max_diff(calib_val[1], 3);
z_delta = min_max_diff(calib_val[2], 3);
if ((x_delta < max_delta_thresh) && (y_delta < max_delta_thre... |
nt_service_handle_last();
const GRect area = GRect(0, 0, DISP_COLS, 200);
const AnimationProgress progress = ANIMATION_NORMALIZED_MAX / 2;
unobstructed_area_service_change(area.size.h, to_area.size.h, progress);
fake_event_service_handle_last();
cl_assert_equal_i(s_data.num_change_calls, 1);
cl_assert_equa... | (fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler) | ;
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_did_change(to_area.size.h);
fake_event_service_handle_last();
cl_assert_equal_i(s_data.num_will_change_calls, 1);
cl_assert_equal_i... |
animation
compositor_app_render_ready();
cl_assert_equal_i(s_count_animation_schedule, 1);
cl_assert_equal_i(s_count_display_update, 3);
}
void test_compositor__modal_transition_cancels_deferred_app(void) {
// Set the display as busy and then render the app. Nothing should update.
s_display_update_in_progres... | compositor_app_render_ready() | ;
cl_assert_equal_i(s_app_window_render_count, 2);
cl_assert_equal_i(s_count_animation_destroy, 1);
}
void test_compositor__cancel_modal_to_app_with_another_modal(void) {
// Show a modal window
s_modal_window_present = true;
compositor_transition(NULL);
cl_assert_equal_i(s_count_display_update, 1);
// N... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return s_process_manager_compiled_with_legacy2_sdk;
} |
// Setup
////////////////////////////////////
void test_layer_rect__initialize(void) {
s_process_manager_compiled_with_legacy2_sdk = false;
}
void test_layer_rect__cleanup(void) {
}
// Tests
////////////////////////////////////
void test_layer_rect__2_x_extend_shrink(void) {
Layer l;
s_process_manager_compi... |
eturn prv_gbitmap_get_data_row_info(bitmap, y);
}
void gbitmap_init_with_data(GBitmap *bitmap, const uint8_t *data) {
BitmapData* bitmap_data = (BitmapData*) data;
memset(bitmap, 0, prv_gbitmap_size());
bitmap->row_size_bytes = bitmap_data->row_size_bytes;
bitmap->info_flags = bitmap_data->info_flags;
// F... | (data_size) | ;
if (bitmap->addr) {
bitmap->info.is_bitmap_heap_allocated = true;
return true;
}
return false;
}
static GBitmap* prv_gbitmap_create_blank(GSize size, GBitmapFormat format) {
GBitmap *bitmap = prv_allocate_gbitmap();
if (bitmap) {
if (!prv_gbitmap_allocate_data_for_size(bitmap, size, format)) {... |
NTS,
.points = (GPoint[PATH_WEDGE_POINTS]) {
// These are just placeholders to allocate the needed space.
// They will be set to the proper values during the animation.
{0, 0}, {0, 0}, {0, 0},
},
};
static GPathInfo s_path_quad = {
.num_points = PATH_QUAD_POINTS,
.points = (GPoint[PATH_QUAD_POINTS]... | (&s_data.path, &s_path_wedge) | ;
gpath_draw_outline(ctx, &s_data.path);
gpath_draw_filled(ctx, &s_data.path);
for (int i = 0; i < PATH_QUAD_POINTS; i++) {
prv_gpoint_interpolate(&s_path_quad.points[i], distance,
&s_path_defs[s_data.direction].quad_verts[i]);
}
gpath_init(&s_data.path, &s_path_quad);
gpath_draw_outline(ctx, &s_... |
////////////////
// Stubs
////////////////////////////////////
#include "stubs_app_state.h"
#include "stubs_applib_resource.h"
#include "stubs_compiled_with_legacy2_sdk.h"
#include "stubs_heap.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#includ... | (2, 0, 0, 5, 0, 0) | |
vertical_spacing_offset = -3;
if (icon_align == GAlignTop) {
// Set the title text's frame origin at the bottom of the icon's frame
title_text_frame_origin_y = grect_get_max_y(&rect);
} else if (icon_on_left) {
// Move content to the right for the icon on the left
cell_layer_bounds_origin_x = grect_... | grect_equal(&rect, &GRectZero) | ) {
return;
}
// Now we store the right element frame in rect
rect = (GRect) {
.origin = GPoint(grect_get_max_x(&rect), rect.origin.y),
.size = right_element_size
};
if (config->value) {
rect.origin.y -= fonts_get_font_cap_offset(value_font);
graphics_draw_text(ctx, config->value, value_... |
obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Lice... | graphics_patch_trace_of_moving_rect(ctx, &context->window_from_last_x,
window_from->layer.frame) | ;
}
Window *window_to = context->window_to;
if (window_to) {
window_render(window_to, ctx);
graphics_patch_trace_of_moving_rect(ctx, &context->window_to_last_x, window_to->layer.frame);
}
}
static Animation *prv_window_transition_move_from_right_create_animation(
WindowTransitioningContext *context)... |
t_minute_fire_ts; // uses
// -------------------------------------------------------------------------------------------
// Passed to list_find() to determine if a callback is already registered or not
static bool prv_callback_registered_filter(ListNode *found_node, void *data) {
return (found_node == (ListNode *)... | (&s_seconds_callbacks, &cb->list_node) | ;
} else {
// If it is marked for deletion, remove the deletion flag
cb->pending_delete = false;
}
mutex_unlock(s_callback_list_semaphore);
}
// --------------------------------------------------------------------------------------------
void regular_timer_add_seconds_callback(RegularTimerInfo* cb) {
... |
/*
* 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... | pfs_format(true /* write erase headers */) | ;
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
}
void test_expandable_dialog__cleanup(void) {
free(fb);
}
// Helpers
//////////////////////
void prv_manual_scroll(ScrollLayer *scroll_layer, int8_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... | attribute_list_add_uint32(&attr_list, AttributeIdIconTiny,
TIMELINE_RESOURCE_BLE_HRM_SHARING) | ;
attribute_list_add_uint8(&attr_list, AttributeIdBgColor, GColorOrangeARGB8);
AttributeList dismiss_action_attr_list = {};
attribute_list_add_cstring(&dismiss_action_attr_list, AttributeIdTitle,
i18n_get("Dismiss", &attr_list));
AttributeList stop_action_attr_list = {};
attribu... |
KernelMain
if (event->type == PebbleWorkoutEvent_FrontendOpened) {
evented_timer_cancel(s_workout_data.current_workout->workout_abandoned_timer);
} else if (event->type == PebbleWorkoutEvent_FrontendClosed) {
s_workout_data.current_workout->workout_abandoned_timer =
evented_timer_register(WORKOUT_AB... | {
if (!workout_service_is_workout_type_supported(type)) {
rv = false;
goto unlock;
}
if (workout_service_is_workout_ongoing()) {
PBL_LOG(LOG_LEVEL_WARNING, "Only 1 workout at a time is supported");
rv = false;
goto unlock;
}
// Before starting this new session we need... |
&s_workout_data.current_workout->last_event_step_count);
s_workout_data.current_workout->last_movement_event_time_ts = time_get_uptime_seconds();
regular_timer_add_seconds_callback(&s_workout_data.second_timer);
// Finally tell our algorithm it should stop automatically tracking a... |
uted on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/graphics/gbitmap_png.h"
#include "clar.h"
#include "util.h"
#include <string.h>
#include ... | {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(4bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(4bitpalette)));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat4BitPalette);
} |
// Tests 8-bit transparent palettized PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_8_bit_transparent(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(8bit));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(8bit)));
cl_assert_equal_i(gbitmap_get... |
session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
max_length /* required_free_length */,
TIMEOUT_MS);
uint8_t fake_data[max_length];
memset(fake_data, 0, max_length);
comm_session_sen... | (bytes_copied, expected_bytes_incl_pebble_protocol_header) | ;
PebbleProtocolHeader *header = (PebbleProtocolHeader *) pp_data_out;
cl_assert_equal_i(header->length, htons(max_payload_length));
cl_assert_equal_i(header->endpoint_id, htons(ENDPOINT_ID));
cl_assert_equal_i(memcmp(pp_data_out + sizeof(PebbleProtocolHeader),
fake_data_payload, max_... |
pping:
if (x1.integer < clip_box_min_x) {
x1.integer++;
continue;
}
if (x1.integer > clip_box_max_x) {
break;
}
prv_blend_color_and_update_mask(ctx, y, x1.integer, x1.integer, color,
(uint8_t)(FIXED_S16_3_ONE.raw_value * i / lef... | gbitmap_get_data_row_info(framebuffer_bitmap, p.y) | ;
// Calculate a pointer to the start of the row of interest in the pixel mask data
const unsigned int data_row_info_offset =
data_row_info.data - (uint8_t *)framebuffer_bitmap->addr;
const uint8_t pixels_per_byte = GDRAWMASK_PIXELS_PER_BYTE;
const unsigned int mask_row_data_offset = data_row_info_offset /... |
nt *pcse = &e->bluetooth.comm_session_event;
if (!pcse->is_system) { // Need pkjs, which runs inside the Pebble app, so need system session.
return;
}
if (pcse->is_open) { // Connection event
prv_handle_connection();
} else { // Disconnect event
prv_handle_disconnection();
}
}
///////////////////... | (s_state.in.reassembly_buffer) | ;
s_state.in.reassembly_buffer = NULL;
}
static bool prv_handle_chunk_received(Tuple *tuple) {
if (tuple->type != TUPLE_BYTE_ARRAY) {
PBL_LOG(LOG_LEVEL_ERROR, "Chunk tuple not a byte array!");
return false;
}
const PostMessageChunkPayload *const chunk = (const PostMessageChunkPayload *) tuple->value;
... |
Fixed_S16_3 start, Fixed_S16_3 end) {
if (quadrant & desired) {
graphics_private_draw_vertical_line(ctx, x, start, end);
}
}
inline void prv_hline_quadrant(GCornerMask quadrant, GCornerMask desired, GContext *ctx, int16_t y,
Fixed_S16_3 start, Fixed_S16_3 end) {
if (q... | graphics_circle_quadrant_draw_stroked_non_aa(ctx, p, radius, stroke_width, quadrant) | ;
} else {
// Non-Antialiased and Stroke Width == 1
graphics_circle_quadrant_draw_1px_non_aa(ctx, p, radius, quadrant);
}
}
T_STATIC void graphics_circle_draw_1px_non_aa(GContext* ctx, GPoint p, uint16_t radius) {
graphics_circle_quadrant_draw_1px_non_aa(ctx, p, radius, GCornersAll);
p.x += ctx->draw_... |
ed*/);
// Disconnect dummy server, to clean up after ourselves:
prv_set_dummy_server_connected(false /* connected */);
}
void test_music_endpoint__ignore_now_playing_from_ios_app(void) {
// iOS app connects:
prv_receive_app_info_event(false /* is_android */);
// iOS app is not supposed to use this endpoint:... | prv_receive_app_info_event(true /* is_android */) | ;
cl_assert_equal_b(fake_comm_session_is_latency_reduced(), false);
music_request_reduced_latency(true);
cl_assert_equal_b(fake_comm_session_is_latency_reduced(), true);
music_request_reduced_latency(false);
cl_assert_equal_b(fake_comm_session_is_latency_reduced(), false);
}
void test_music_endpoint__low_la... |
},
{ 3072, 24, -176},
{ 2432, -48, -424},
{ 1880, -112, -272},
{ 1424, -296, -224},
{ 960, -448, -200},
{ 768, -416, -208},
{ 704, -320, -152},
{ 616, -296, -96},
{ 480, -232, -64},
{ 272, -112, -112},
{ 520, 0, -176},
{ 856, 472, -560},
{ 1280, 240, -344},
{ 2128... | { 656, -280, -8},
{ 480, -216, 0},
{ 384, -168, -88},
{ 976, 8, -184},
{ 1232, 344, -840},
// 26 seconds
{ 1992, 184, -768},
{ 2720, 160, -1064},
{ 2784, 240, -792},
{ 2344, 408, -672},
{ 1616, 544, -376},
{ 1248, 704, -80},
{ 840, 896, 56},
{ 512, 1024, 120},
... | |
se
const int16_t line_height = fonts_get_font_height(aml->layout_cache.font);
const int16_t sep_height = MAX(menu_cell_small_cell_height() - line_height,
default_sep_height) + 1;
return sep_height;
#endif
}
static int16_t prv_get_cell_height_cb(struct MenuLayer *menu_layer,
... | prv_get_cell_padding(aml) | ;
const int16_t max_visible_height = line_height * MAX_NUM_VISIBLE_LINES;
const GRect *bounds = &aml->layer.bounds;
int16_t total_h = 0;
for (int16_t idx = 0; idx < aml->num_items; idx++) {
int16_t item_height = aml->layout_cache.item_heights[idx];
total_h += MIN(max_visible_height, item_height);
}
... |
attribute_idx];
}
int32_t attribute_get_buffer_size_for_serialized_attributes(uint8_t num_attributes,
const uint8_t **cursor, const uint8_t *end) {
int32_t size = 0;
for (unsigned int i = 0; i < num_attributes; i++) {
int32_t result = prv_get_buffer_size_for_serialized_attribute(cursor, end);
if (resul... | (attr->uint32_list->num_values) | ;
default:
// The rest of the types fit within the Attribute struct
return 0;
}
}
static bool prv_deep_copy_attribute(Attribute *dest, const Attribute *src, uint8_t **buffer,
uint8_t *const buffer_end) {
const size_t attribute_length = prv_get_attribute_length(sr... |
"dls_list.h"
#include "dls_storage.h"
#include "services/common/analytics/analytics.h"
#include "services/common/comm_session/protocol.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/system_task.h"
#include "services/common/new_timer/new_timer.h"
#include "services/normal/da... | (s_endpoint_data.mutex) | ;
check_ack_timeout();
mutex_unlock(s_endpoint_data.mutex);
}
static bool find_soonest_ack_timeout_cb(DataLoggingSession *session, void *data) {
RtcTicks *soonest_ack_timeout = (RtcTicks*) data;
if (session->comm.ack_timeout != 0
&& (session->comm.ack_timeout < *soonest_ack_timeout || *soonest_ack_time... |
num_types + j]);
}
}
}
return &s_parsed_msg;
}
// ---------------------------------------------------------------------------------------------
// Parse and encoded message and return a TestPLParsedMsg structure pointer pointing to it's
// parsed contents. The contents are valid until prv_parse_encoded... | cl_assert_equal_m(a->msrmt.types, b->msrmt.types,
b->msrmt.num_types * sizeof(ProtobufLogMeasurementType)) | ;
cl_assert_equal_i(a->msrmt.num_samples, b->msrmt.num_samples);
cl_assert_equal_m(a->msrmt.offset_sec, b->msrmt.offset_sec,
b->msrmt.num_samples * sizeof(uint32_t));
cl_assert_equal_i(a->msrmt.num_values, b->msrmt.num_values);
cl_assert_equal_m(a->msrmt.values, b->msrmt.values, b-... |
clean up a partial delete
update_curr_state(first_page, DELETE_STATE_OFFSET, DELETE_STATE_DONE);
return (rv);
}
static status_t create_flash_file(File *f) {
status_t rv;
uint16_t start_page = INVALID_PAGE;
PageHeader pg_hdr;
memset(&pg_hdr, 0xff, sizeof(pg_hdr));
bool use_gc_allocator = (strcmp(f->na... | {
uint16_t contig_pgs = MIN(close_pg->contiguous_pgs, pages_to_seek);
pages_to_seek -= contig_pgs;
next_page += contig_pgs;
} |
}
for (uint16_t i = 0; i < pages_to_seek; i++) {
if (get_next_page(next_page, &next_page) != S_SUCCESS) {
return (E_RANGE);
}
}
f->curr_page = next_page;
}
*pg_offset = data_offset % free_bytes_in_page(f->curr_page);
return (S_SUCCESS);
}
static int mark_fd_free(int fd) {
... |
t16_t label_height = 10;
const int16_t small_numbers_height = 30;
const int16_t accent_numbers_height = 40;
const int16_t large_numbers_height = 40;
const int16_t disconnected_text_height = 24;
// magic numbers measured from design spec
const int16_t distance_column_x_offset = 0;
const int16_t distance_c... | (GRect(0, disconnected_text_y_offset,
background_width, disconnected_text_height)) | ;
prv_setup_text_layer(data->disconnected_text, font_key_disconnected,
i18n_get("Disconnected", data), GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(data->disconnected_text));
layer_set_hidden(text_layer_get_layer(data->disconnected_text), true);
// Sync setup... |
tion;
Layer *subject;
if (property_animation_get_subject(prop_anim, (void**)&subject) && subject) {
layer_mark_dirty(subject);
}
}
static const PropertyAnimationImplementation s_dirty_layer_implementation = {
.base = {
.update = property_animation_update_mark_dirty,
},
};
PropertyAnimation *... | (&legacy->values.to, value, size) | |
/*
* 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... | {
case RecognizerState_Possible:
PBL_ASSERTN((new_state == RecognizerState_Failed) ||
(new_state == RecognizerState_Possible) ||
(new_state == RecognizerState_Completed) ||
(new_state == RecognizerState_Started));
break;
case RecognizerState_Sta... |
recognizer->state = new_state;
}
static bool prv_should_handle_touches(Recognizer *recognizer, const TouchEvent *touch_event) {
if (recognizer_get_state(recognizer->fail_after) != RecognizerState_Failed) {
return false;
}
if (!recognizer->subscriber.filter) {
return true;
}
return recognizer->sub... |
= (const SMIdentityResolvingKey) {
.data = {
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
},
},
.identity = (const BTDeviceInternal) {
.opaque.opaque_64 = 0x1122334455667788,
},
.csrk = {
.data = {
0xcc, 0xdd, 0xee, 0xff, 0x8... | (shared_prf_storage_get_ble_pairing_data(NULL, NULL, NULL, NULL), false) | ;
}
void test_shared_prf_storage_v3__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);
... |
h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_ui_window.h"
#include "stubs_unobstructed_area.h"
extern void prv_content_indicator_update_proc(Layer *layer, GContext *ctx);
// Helpers
////////////////////////////////////
static L... | cl_assert(content_indicator_configure_direction(&content_indicator, direction, &dummy_config)) | ;
helper_check_configs_for_equality(dummy_config, direction_data[direction].config);
// Should save a reference to the config layer's update proc
cl_assert_equal_p(dummy_config.layer->update_proc, direction_data->original_update_proc);
cl_assert_equal_p(direction_data->original_update_proc,
... |
e "stm32f4xx_adc.h"
#endif
#include <stdint.h>
/* PMIC Bus Information */
#define MAX14690_ADDR 0x50
//! The addresses of the registers that we can read using i2c
typedef enum PmicRegisters {
PmicRegisters_CHIP_ID = 0x00,
PmicRegisters_CHIP_REV = 0x01,
PmicRegisters_STATUSA = 0x02,
PmicRegisters_STATUSB = 0x... | (rail_control_reg, ®ister_value) | ;
if (!success) {
// Failed to read the current register value
return false;
}
if (enable) {
if (*ref_count) {
(*ref_count)++;
return true;
} else {
// Set the register byte to XXXXX01X to enable the rail, mask and set
register_value = (register_value & ~0x06) | 0x02;
... |
ats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
HealthServiceStats daily_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
HealthServiceStats weekday_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
HealthServiceStats weekend_stats = {
.min = INT32_MAX,
.max = INT32_MIN,
};
... | (LOG_LEVEL_INFO, "Testing %-16s %-16s exp_value: %5"PRIi32", act_value: "
"%5"PRIi32" " , scope_str, agg_str, exp_value, result) | ;
if (scope != HealthServiceTimeScopeOnce) {
// Only test scoped results. Non-scoped results for heart rate are computed using
// minute data and verified in the test_health__heart_rate_scope_once()
cl_assert_equal_i(result, exp_value);
}
}
}
}
// ----------------------------... |
ame_out, &platform_bits_out);
cl_assert(ret);
cl_assert_equal_m(&addr_3, &addr_out, sizeof(addr_out));
cl_assert_equal_m(&link_key_3, &link_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_3, name_out);
cl_assert_equal_i(platform_bits_3, platform_bits_out);
}
void test_bluetooth_persistent_storage_prf_... | (id != BT_BONDING_ID_INVALID) | ;
// Delete the Pairing
bt_persistent_storage_delete_bt_classic_pairing_by_addr(&addr_in);
// Try to read it back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
name_out, &platform_bits_out);
cl_assert(!ret);
// A... |
/*
* 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... | ("2pad", buffer, 4, expected, 1) | ;
}
}
|
VENT, NULL, NULL);
// Create single reusable timer for wakeup events
s_current_timer_id = new_timer_create();
s_wakeup_state.next_wakeup_id = rtc_get_time();
s_wakeup_state.timestamp = -1;
SettingsFile wakeup_settings;
if (settings_file_open(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) != S_S... | uuid_equal(&app_manager_get_current_app_md()->uuid, &entry.uuid) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(resource_id != UINT32_MAX) | |
d_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_some_sectors_from_beginning(void) {
cl_assert(system_flash_erase(FLASH_BASE, 128 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 4), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_full_flash(void) {
cl_assert(... | (!flash_locked, "Attempted to write to a locked flash") | ;
cl_assert_(address >= flash_data_start &&
address < flash_data_start + flash_data_length,
"Address out of range");
cl_assert_(flash_written_flag[address - flash_data_start] == false,
"Overwriting an already-written byte");
if (return_status == FLASH_COMPLETE) {
flash_w... |
NULL);
action_menu_level_add_action(root_level,
"I will call back",
prv_noop_action_callback,
NULL);
const unsigned int selected_index = 1;
prv_prepare_canvas_and_render_action_menus_animated(root_level, selected_... | action_menu_level_add_action(template_level,
"This won't be seen",
prv_noop_action_callback,
NULL) | ;
action_menu_level_add_child(root_level, template_level, "Template");
ActionMenuLevel *emoji_level = action_menu_level_create(1);
action_menu_level_add_action(emoji_level,
"This won't be seen",
prv_noop_action_callback,
... |
void *i18n_owner) {
struct tm time = (struct tm) {
.tm_hour = time_seconds / SECONDS_PER_HOUR,
.tm_min = (time_seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE
};
const char *format = clock_is_24h_style() ?
i18n_get("%H:%M", i18n_owner) : i18n_get("%l:%M%p", i18n_owner);
char time_str_buf[TIME_B... | (i18n_noop("YOU NAPPED"),
i18n_noop("Of napping")) | ;
attribute_list_add_cstring(&pin_attr_list,
PBL_IF_RECT_ELSE(AttributeIdTitle, AttributeIdLocationName),
i18n_get(title_i18n, &pin_attr_list));
char *start_time = kernel_zalloc_check(TIME_STRING_TIME_LENGTH);
char *end_time = kernel_zalloc_check(TIME_STR... |
prv_cycle_scrollable_metrics(active_window);
}
Window *window = (Window *)active_window;
window_set_on_screen(window, true, true);
window_render(window, &s_ctx);
}
// Workout Tests
//////////////////////
void test_workout_active__workout_render_no_data(void) {
s_workout_data = (WorkoutData) {};
WorkoutA... | (
ActivitySessionType_Run, &s_workout_data, &s_workout_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__workout_render_hr_zone_2(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 789,
.distance_m = 234,
.avg_pace = health_util_get_pace(789, 23... |
2},
{ 992, 160, 72},
{ 960, 88, 40},
{ 1008, 128, 32},
{ 968, 176, 16},
{ 944, 200, 32},
{ 912, 152, 64},
{ 864, 88, 96},
{ 824, 112, 120},
{ 816, 64, 112},
{ 784, 88, 56},
{ 848, 112, 72},
{ 880, 136, 104},
{ 960, 184, 80},
{ 1000, 184, 40},
{ 1240, 184, 96},... | { 896, 16, 80},
{ 896, 40, 104},
{ 888, 64, 72},
{ 856, 112, 24},
{ 832, 144, -40},
{ 848, 176, -80},
{ 856, 192, -104},
{ 840, 224, -144},
{ 888, 152, -88},
{ 1048, 224, -24},
{ 1008, 184, 48},
{ 1192, 152, 72},
{ 1384, 184, 72},
{ 1136, 240, 88},
{ 1008, 144... |
{ 832, 200, -112},
{ 808, 152, -112},
{ 968, 128, -24},
{ 1080, 128, 64},
{ 1072, 120, 104},
{ 1136, 168, 48},
{ 1200, 224, 56},
{ 1160, 192, 104},
{ 952, 112, 24},
{ 896, 96, 40},
{ 920, 120, 56},
{ 960, 168, 112},
{ 928, 192, 144},
{ 872, 168, 120},
{ 824, ... |
// AA = true, SW = 2
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 2);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGI... | (&ctx, fb) | ;
// SW = 1
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_... |
onImplementation*)
property_animation->animation.implementation)
->accessors.setter.gpoint(property_animation->subject, result);
}
// -----------------------------------------------------------------------------------------
void property_animation_update_grect(PropertyAnimation *property_animation_h,
... | if (!property_animation) {
return;
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | time_get_dstoffset() | ;
} else {
return -time_get_dstoffset();
}
}
int32_t time_get_dstoffset(void) {
return s_dst_adjust;
}
time_t time_get_dst_start(void) {
return s_dst_start;
}
time_t time_get_dst_end(void) {
return s_dst_end;
}
DEFINE_SYSCALL(time_t, sys_time_utc_to_local, time_t t) {
return time_utc_to_local(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... | (fpc_pinstrap_get_value() == 0x8) | ;
}
|
subscriber_age_ticks = milliseconds_to_ticks(state->update_interval_s * MS_PER_SECOND);
}
int64_t subscriber_remaining_ticks =
(int64_t)milliseconds_to_ticks(state->update_interval_s * MS_PER_SECOND)
- subscriber_age_ticks - spin_up_ticks;
subscriber_remaining_tick... | {
continue;
} |
break;
case HRMEvent_Diagnostics:
if (!(state->features & HRMFeature_Diagnostics)) {
continue;
}
break;
case HRMEvent_SubscriptionExpiring:
continue;
}
// Send the event to the subscriber
state->callback_handler(&event, state->callback_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... | if (angle != 0) {
int32_t cosine = cos_lookup(angle);
int32_t sine = sin_lookup(angle);
int64_t cosine_val = (cosine * ((int64_t)GTransformNumberOne.raw_value)) / TRIG_MAX_RATIO;
int64_t sine_val = (sine * ((int64_t)GTransformNumberOne.raw_value)) / TRIG_MAX_RATIO;
GTransformNumber a = (GTransformNu... |
}
//////////////////////////////////////
/// Evaluating Transforms
//////////////////////////////////////
bool gtransform_is_identity(const GTransform * const t) {
if (!t) {
return false;
}
GTransform t_c = GTransformIdentity();
if (memcmp(t, &t_c, sizeof(GTransform)) == 0) {
return true;
}
ret... |
*text,
GFont const font, const GRect box,
const GTextOverflowMode overflow_mode,
const GTextAlignment alignment,
GTextLayoutCacheRef layout... | prv_js_global_get_value("event") | ;
cl_assert_equal_b(true, jerry_value_is_object(event));
const jerry_value_t context_2d = jerry_get_object_field(event, "context");
cl_assert_equal_b(true, jerry_value_is_object(context_2d));
jerry_release_value(context_2d);
jerry_release_value(event);
}
jerry_value_t prv_create_canvas_context_2d_for_layer(... |
/*
* 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 (app_install_id_from_app_db(id)) {
return NULL;
} |
for (int i = 0; i < (int)ARRAY_LENGTH(APP_RECORDS); i++) {
if (APP_RECORDS[i].id == id) {
if (record_order_out) {
*record_order_out = i + 1;
}
return &APP_RECORDS[i];
}
}
return NULL;
}
// optimization: sort the UUID's and then search more quickly. This will most likely
// req... |
_is_service_discovery_running(), false);
}
void test_gatt_client_discovery__already_in_progress(void) {
BTDeviceInternal device = prv_connected_dummy_device(1);
// Start discovery for device:
cl_assert_equal_i(gatt_client_discovery_discover_all(&device), BTErrnoOK);
cl_assert_equal_b(fake_gatt_is_service_disc... | if (i < GATT_CLIENT_DISCOVERY_MAX_RETRY) {
// Check whether GATT_Start_Service_Discovery has been called, except for the last iteration:
cl_assert_equal_i(start_count + 1, fake_gatt_is_service_discovery_start_count());
// No client event:
prv_assert_no_event();
} else {
// Last iterati... |
}
}
void test_gatt_client_discovery__watchdog_error_out_after_max_retries(void) {
BTDeviceInternal device = prv_connected_dummy_device(1);
// Start discovery:
cl_assert_equal_i(gatt_client_discovery_discover_all(&device), BTErrnoOK);
prv_fire_watchdog_timeouts(&device, GATT_CLIENT_DISCOVERY_MAX_RETRY);
}
... |
ous callbacks
s_popup_occurred = false;
wakeup_init();
wakeup_enable(true);
}
void test_wakeup__cleanup(void) {}
void test_wakeup__basic_checks(void) {
WakeupId wakeup_id = 0;
cl_assert_equal_i(sys_get_time(), 1388563200);
sys_wakeup_cancel_all_for_app();
// Schedule a wakeup in 10 seconds
wakeup_i... | wakeup_dispatcher_system_task((void *)(uintptr_t)late_wakeup_id) | ;
// There should now be no scheduled wakeups
cl_assert_equal_i(sys_wakeup_query(late_wakeup_id), E_DOES_NOT_EXIST);
}
void test_wakeup__time_jump(void) {
sys_wakeup_cancel_all_for_app();
// Schedule 1 event in a minute
time_t first_event = sys_get_time() + WAKEUP_EVENT_WINDOW;
WakeupId first_wakeup_id =... |
rase_suspend_timer, 50, prv_erase_suspend_timer_cb, NULL, 0);
while (buffer_size) {
int written = flash_impl_write_page_begin(buffer, start_addr, buffer_size);
PBL_ASSERT(
#ifdef TEST_FLASH_LOCK_PROTECTION
s_assert_write_error ||
#endif
PASSED(written),
"flash_impl_write_page_begin fai... | (context, status) | |
xt;
time_t timestamp = timeline_item_get_tz_timestamp(&hdr.common);
// check if filter callback exists, then check if we should keep the item.
bool filtered_out = false;
if (next_info->filter_cb && !next_info->filter_cb(&hdr, context)) {
filtered_out = true;
}
if (!filtered_out &&
(timestamp < n... | settings_file_delete(&storage->file, key, sizeof(Uuid)) | ;
if (rv != S_SUCCESS) {
goto cleanup;
}
if (child_delete_cb) {
child_delete_cb((Uuid *)key);
}
}
cleanup:
mutex_unlock(storage->mutex);
return rv;
}
//! Caution: CommonTimelineItemHeader .flags & .status are stored inverted and not auto-restored
status_t timeline_item_storage_each... |
ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, -18, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_across_ny_second_line(Layer* me, GContext* ctx) {
graphics... | (&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_ny_descender.${BIT_DEPTH_NAME}.pbi") | |
3,
16251,
16639,
17026,
17413,
17798,
18184,
18568,
18952,
19335,
19717,
20099,
20480,
20860,
21239,
21618,
21996,
22372,
22749,
23124,
23498,
23872,
24244,
24616,
24987,
25356,
25725,
26093,
26460,
26826,
27191,
27555,
27918,
28280,
28641,
29000,
29359,
29717,
30073,
30428,
30783,
31136,
31487,
31838,
32188,
32536,
32... | if ((uint32_t)(lookup_angle + 1) < sizeof(SIN_LOOKUP) / sizeof(int32_t)) {
return mult * (SIN_LOOKUP[lookup_angle] + ((angle * 4) % 0xff) * (SIN_LOOKUP[lookup_angle + 1] - SIN_LOOKUP[lookup_angle]) / 0xff);
} |
return mult * SIN_LOOKUP[lookup_angle];
}
int32_t cos_lookup(int32_t angle) {
return sin_lookup(angle + TRIG_MAX_ANGLE / 4);
}
#define ATAN_LUT_STRIDE 0xff
int32_t atan2_lookup(int16_t y, int16_t x) {
// inspired by http://www.coranac.com/documents/arctangent/
if (y == 0) {
return (x >= 0 ? 0 : TRIG_PI... |
he 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 in writing, software
* distributed under the License i... | prv_file_close_and_unlock(&file) | |
================================
// Try and reschedule a regular timer from it's callback
static void reg_timer_1_callback(void* data) {
PBL_LOG(LOG_LEVEL_DEBUG, "STT running reg_timer_1_callback");
if (s_app_data->reg_timers[0].cb != 0) {
PBL_LOG(LOG_LEVEL_DEBUG, "STT reg_timer_1_callback rescheduling from cal... | PBL_ASSERTN(success) | ;
scheduled = new_timer_scheduled(s_app_data->timer[timer_idx_0], &expire_ms);
PBL_ASSERTN(scheduled && expire_ms <= 500);
PBL_LOG(LOG_LEVEL_DEBUG, "STT firing in %d ms", (int)expire_ms);
}
// =================================================================================
void two_timers_menu_cb(int index, ... |
cell_padding;
// The current distance we have moved depends on how far we are through the animation
int current_slide_distance = (slide_distance * selection_layer->slide_amin_progress) / 100;
// Finally our current x-offset is our starting offset plus our current distance
int current_x_offset = starting_x_off... | for (unsigned i = 0, current_x_offset = start_x_offset; i < selection_layer->num_cells; i++) {
if (selection_layer->callbacks.get_cell_text) {
// Potential optimization: cache the cell text somewhere as this function gets called
// a lot (because of animations). The current users of this modules just ca... | |
cb, NULL);
cl_assert_equal_i(0, s_prv_activity_cb__call_count);
// respect mask for RestfulSleep
s_prv_activity_cb__call_count = 0;
s_sys_activity_get_sessions_values.out.num_sessions = 7;
health_service_activities_iterate(HealthActivityRestfulSleep, now - (100 * SECONDS_PER_MINUTE),
... | rtc_get_time() | ;
// both start at the same time
cl_assert(0 == prv_session_compare(
&(ActivitySession) {.start_utc = now, .length_min = 10},
&(ActivitySession) {.start_utc = now, .length_min = 5},
HealthIterationDirectionFuture));
// a starts earlier
cl_assert(0 > prv_session_compare(
&(ActivitySession) {.st... |
ted to be subscribed to
WTF;
}
static const AnalyticsMetric metric_matrix[2][2] = {
[ANCSCharacteristicNotification] = {
[0] = ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_NS_SUBSCRIBE_COUNT,
[1] = ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_NS_SUBSCRIBE_FAIL_COUNT,
},
[ANCSCharacteristicDat... | BLE_HEXDUMP((uint8_t *)nsnotification, sizeof(NSNotification)) | ;
// Handle the CategoryID
if (nsnotification->category_id == CategoryIDMissedCall) {
properties |= ANCSProperty_MissedCall;
} else if (nsnotification->category_id == CategoryIDIncomingCall) {
properties |= ANCSProperty_IncomingCall;
} else if (nsnotification->category_id == CategoryIDVoicemail) {
... |
ss or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/graphics.h"
#include "stubs_applib_resource.h"
#include "stubs_app_state.h"
#include "stubs_compiled_with_legacy2... | (GColorRedARGB8, ctx.draw_state.fill_color.argb) | ;
graphics_context_set_fill_color(&ctx, (GColor8){.a= 1, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.fill_color.argb);
graphics_context_set_fill_color(&ctx, (GColor8){.a= 0, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.fill_color.argb);
}
|
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_RESET);
delay_ms(1);
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_SET);
return prv_wait_programmed();
}
static bool prv_reset_fpga(void) {
#ifdef BLANK_FPGA
return display_program(s_fpga_bitstream, sizeof(s_fpga_bitstream));
#endif
const struct FlashBitstream *... | dbgserial_putstr(prv_wait_busy()? "Yes" : "No") | |
_stop_tracking_early();
}
mutex_unlock_recursive(s_activity_state.mutex);
return system_task_add_callback(prv_stop_tracking_cb, NULL);
}
// ------------------------------------------------------------------------------------------------
bool activity_tracking_on(void) {
bool result;
mutex_lock_recursive(s_a... | (bool, sys_activity_get_minute_history, HealthMinuteData *minute_data,
uint32_t *num_records, time_t *utc_start) | |
GAPLEClient client,
bool is_response_required) {
if (s_write_return_value != BTErrnoOK) {
return s_write_return_value;
}
Write *write = malloc(sizeof(Write));
uint8_t *buffer;
if (value_length) {
cl_assert(value);
buffer = malloc(value_length);
... | (characteristic, s_write_head->characteristic) | ;
cl_assert_equal_i(s_write_head->value_length, value_length);
cl_assert_equal_i(memcmp(value, s_write_head->value, value_length), 0);
cl_assert_equal_i(client, s_write_head->client);
cl_assert_equal_b(is_response_required, s_write_head->is_response_required);
} else {
fake_gatt_client_op_assert_w... |
text_layer_set_text_color(&data->direction_layer, GColorBlack) | ;
text_layer_set_text(&data->direction_layer, "Direction: Up/Down");
GFont gothic_14_bold = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
text_layer_set_font(&data->direction_layer, gothic_14_bold);
text_layer_set_text_alignment(&data->direction_layer, GTextAlignmentCenter);
text_layer_set_overflow_mode(&da... | |
_t interval_minutes;
} PollLegacySetIntervalMessage;
// Poll a service at a specific interval
typedef struct PACKED {
PollRemoteCommand cmd;
PollRemoteService service;
uint8_t interval_minutes;
} PollSetIntervalMessage;
// Request to poll a service now
typedef struct PACKED {
PollRemoteCommand cmd;
PollRemo... | PBL_ASSERTN(s_running) | ;
for_each_context(context_interval_check);
}
static void poll_service_timer_callback(void *data) {
system_task_add_callback(poll_service_system_task_callback, data);
}
void poll_remote_init(void) {
for (int i = 0; i < NUM_POLL_REMOTE_SERVICES; i++) {
s_poll_remote_contexts[i].service = i;
}
}
void poll_... |
nitor.h"
#include "drivers/periph_config.h"
#include "kernel/util/sleep.h"
#include "mfg/mfg_info.h"
#include "system/logging.h"
#include "system/passert.h"
#define STM32F2_COMPATIBLE
#define STM32F4_COMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
#include <inttypes.h>
static uint32_t s_sensor_light_dark_thre... | {
return AmbientLightLevelVeryLight;
} |
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(abs(a.c.integer - b.c.integer) < 10) | ;
cl_assert(abs(a.d.integer - b.d.integer) < 10);
cl_assert(abs(a.tx.integer - b.tx.integer) < 10);
cl_assert(abs(a.ty.integer - b.ty.integer) < 10);
}
// --------------------------------------------------------------------------------------
static void cl_assert_equal_fixed_s32_16(const Fixed_S32_16 a, const F... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(s_last_event.type, PEBBLE_NULL_EVENT) | ;
}
void test_evented_timer__repeating(void) {
EventedTimerID e_timer = evented_timer_register(100, true, stub_evented_timer_callback, 0);
// NOTE: We are leveraging the fact that we know the system timer ID is the same as the
// EventedTimer ID
TimerID sys_timer_id = e_timer;
cl_assert(stub_new_timer_is_sc... |
se;
static bool s_comm_enabled = false;
static bool s_comm_is_running = false;
static bool s_comm_state_change_eval_is_scheduled;
static BtCtlModeOverride s_comm_override = BtCtlModeOverrideNone;
static PebbleMutex *s_comm_state_change_mutex;
bool bt_ctl_is_airplane_mode_on(void) {
return s_comm_airplane_mode_on;
}... | prv_comm_state_change(NULL) | ;
}
void bt_ctl_set_override_mode(BtCtlModeOverride override) {
if (!s_comm_initialized) {
PBL_LOG(LOG_LEVEL_ERROR, "Error: Bluetooth isn't initialized yet");
return;
}
mutex_lock(s_comm_state_change_mutex);
s_comm_override = override;
mutex_unlock(s_comm_state_change_mutex);
prv_comm_state_change(... |
/*
* 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(global_lock);
while (glob_ptr) {
printf("blah %p", glob_ptr);
}
mutex_unlock(global_lock);
} |
void timeout() {
mutex_lock_with_timeout(global_lock);
mutex_unlock(global_lock);
}
void good_timeout() {
if (mutex_lock_with_timeout(global_lock)) {
mutex_unlock(global_lock);
}
}
void stupid_timeout() {
if (!mutex_lock_with_timeout(global_lock)) {
mutex_unlock(global_lock);
}
}
void reversal... |
"
#include "kernel/core_dump.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "gatt_client_accessors.h"
#include "system/logging.h"
#include <bluetooth/gatt.h>
#include <bluetooth/gatt_discovery.h>
#include <btutil/bt_device.h>
// TODO: virtualize the gatt_client_discovery_discover_all() call
/... | core_dump_reset(true /* is_forced */) | ;
#endif
// Done retrying, just error out:
finalize_result = BTErrnoServiceDiscoveryTimeout;
goto unlock;
}
// Retry transparently (don't let the clients know):
BTErrno ret_val = prv_run_next_job(connection);
if (ret_val != BTErrnoOK) {
// Start failed, just error out
fina... |
terface (control_protocol.h)
// =====================================
void ppp_control_protocol_lower_layer_is_up(PPPControlProtocol *this) {
mutex_lock(this->state->lock);
if (this->state->link_state == LinkState_Initial) {
prv_transition_to(this, LinkState_Closed);
} else if (this->state->link_state == Lin... | (this, packet) | ) {
prv_send_code_reject(this, packet);
}
break;
}
done:
mutex_unlock(this->state->lock);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("%s::%s (%s) [%s:%d] [-t%d]\n",
error->suite,
error->test,
"no description",
error->file,
error->line_number,
error->test_number) | ;
printf(" %s\n", error->error_msg);
if (error->description != NULL)
printf(" %s\n", error->description);
printf("\n");
}
static void clar_print_ontest(const char *test_name, int test_number, int failed)
{
(void)test_name;
(void)test_number;
printf("%c", failed ? 'F' : '.');
}
static void clar_print_onsu... |
/*
* 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... | (GPIOD, &gpio_init) | ;
gpio_init.GPIO_Pin = GPIO_Pin_All & (~GPIO_Pin_0) & (~GPIO_Pin_1);
GPIO_Init(GPIOE, &gpio_init);
gpio_release(GPIOE);
gpio_release(GPIOD);
gpio_release(GPIOB);
}
static uint32_t s_num_flash_uses = 0;
void flash_impl_use(void) {
if (s_num_flash_uses == 0) {
periph_config_enable(FMC_Bank1, RCC_AHB3P... |
, color);
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb);
color.a = 0;
graphics_context_set_fill_color(&context, color);
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb);
// Fill Color - 2-bit
graphics_context_set_fill_color_2bit(&context, GColor2White);
c... | GRect(10, 20, 40, 10) | ));
setup_test(&context, false, 1, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle_draw_1px_non_aa(&context, GPoint(50, 50), 10));
setup_test(&context, false, 1, GColorBlack, GColorBlack, false);
graphics_draw_round_rect(&context, &GRect(20... |
OMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
#include <stdbool.h>
#include <inttypes.h>
static int s_num_items_disallowing_stop_mode = 0;
#ifdef PBL_NOSLEEP
static bool s_sleep_mode_allowed = false;
#else
static bool s_sleep_mode_allowed = true;
#endif
typedef struct {
uint32_t active_count;
RtcTicks t... | PBL_ASSERTN(s_inhibitor_profile[inhibitor].active_count != 0) | ;
--s_num_items_disallowing_stop_mode;
--s_inhibitor_profile[inhibitor].active_count;
if (s_inhibitor_profile[inhibitor].active_count == 0) {
s_inhibitor_profile[inhibitor].total_ticks_while_disabled += rtc_get_ticks() -
s_inhibitor_profile[inhibitor].ticks_when_stop_mode_disabled;
}
portEXIT_CRI... |
uint32_t total_time_spent_waiting_ms = 0;
uint32_t remaining_ms = prv_flash_erase_start(
sector_addr, prv_blocking_erase_complete, NULL, is_subsector, 0);
while (remaining_ms) {
psleep(remaining_ms);
total_time_spent_waiting_ms += remaining_ms;
remaining_ms = prv_flash_erase_poll();
// ch... | (s_flash_lock) | ;
if (s_erase.in_progress) {
new_timer_stop(s_erase_suspend_timer);
prv_erase_resume();
mutex_unlock(s_flash_lock);
while (__atomic_load_n(&s_erase.in_progress, __ATOMIC_SEQ_CST)) {
psleep(10);
}
}
}
void flash_switch_mode(FlashModeType mode) {
mutex_lock(s_flash_lock);
flash_impl_set... |
leep_state()) {
case ActivitySleepStateUnknown:
case ActivitySleepStateAwake:
// The user is awake, just trigger
return true;
case ActivitySleepStateLightSleep:
case ActivitySleepStateRestfulSleep:
// The user is asleep, trigger if VMC > 0
return prv_get_vmc() > 0;
}
return f... | settings_file_set(file, &key, sizeof(key),
settings_file_buffer, UUID_SIZE * num_pin_adds) | |
/*
* 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... | (weather_type) | ]};
};
TimelineResourceId weather_type_get_timeline_resource_id(WeatherType weather_type) {
return s_weather_type_timeline_resource_ids[prv_get_array_index_of_type(weather_type)];
};
|
ting, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "process_manager.h"
#include "app_install... | prv_get_context_for_task(task) | ;
if (context->closing_state == ProcessRunState_ForceClosing) {
PBL_LOG(LOG_LEVEL_DEBUG, "Hit syscall exit trap!");
context->safe_to_kill = true;
process_manager_put_kill_process_event(task, false);
vTaskSuspend(xTaskGetCurrentTaskHandle());
}
}
// -----------------------------------------------... |
pawn a stopped handlers got called before any of the spawn b
// started handlers
uint32_t last_fire_a = 0;
last_fire_a = MAX(last_fire_a,
prv_last_handler_entry(&s_stopped_handler_calls, a0)->fire_order);
last_fire_a = MAX(last_fire_a,
prv_last_handler_entry(&s_stopped_ha... | cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0) | |
/*
* 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... | (__packed__) | |
t_snooze_alarm(void) {
prv_snooze_alarm(s_snooze_delay_m * SECONDS_PER_MINUTE);
}
// ----------------------------------------------------------------------------------------------
uint16_t alarm_get_snooze_delay(void) {
return s_snooze_delay_m;
}
// ----------------------------------------------------------------... | mutex_create() | ;
PBL_ASSERTN(s_mutex != NULL);
s_next_alarm_time = 0;
s_snooze_timer_id = new_timer_create();
SettingsFile file;
if (!prv_file_open_and_lock(&file)) {
return;
}
uint16_t snooze_delay_value;
if (settings_file_get(&file, ALARM_PREF_KEY_SNOOZE_DELAY,
strlen(ALARM_PREF_KEY_SN... |
c void prv_set_pixel_in_row(uint8_t *row_data, GBitmapFormat bitmap_format,
uint32_t x, GColor8 color) {
if (bitmap_format == GBitmapFormat1Bit) {
if (!gcolor_is_invisible(color)) {
const bool pixel_is_white = !gcolor_equal(color, GColorBlack);
bitset8_update(row_data,... | (bitmap, y) | ;
const uint32_t x_origin = bitmap->bounds.origin.x + png_decoder_data->previous_xoffset;
const int16_t min_x = MAX((uint32_t)row_info.min_x, x_origin);
const int16_t max_x = MIN((uint32_t)row_info.max_x,
(x_origin + png_decoder_data->previous_width - 1));
const ... |
uto.h"
#include "services/runlevel.h"
#include "services/common/status_led.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/reboot_reason.h"
#include "system/reset.h"
static const uint32_t CHARGER_DISCONNECT_TIMEOUT_MS = 3000;
typedef enum DialogState {
DialogState_Uninitialized = 0,
Di... | (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: ... |
, 0x2D, 0x35, 0x35, 0x35,
0x2D, 0x35, 0x35, 0x35, 0x35, 0x00, // "555-555-5555"
0x00};
phone_protocol_msg_callback(s_session, pp_msg, sizeof(pp_msg));
fake_system_task_callbacks_invoke_pending();
prv_assert_last_event(PhoneEventType_Incoming, true /* check_cook... | fake_system_task_callbacks_invoke_pending() | ;
prv_assert_last_event(PhoneEventType_End, false /* check_cookie */, false /* check_name_number */,
NULL, NULL);
}
void test_phone_pp__get_phone_call_state_response_one_started_call(void) {
pp_get_phone_state_set_enabled(true);
uint8_t pp_msg[] = {0x83, 0x05, 0x08, 0x1a, 0xd4, 0x77, 0x08... |
ight = 2;
uint16_t next_active_calories = 3;
uint16_t next_resting_calories = 4;
uint16_t next_distance_cm = 5;
uint8_t next_heart_rate_bpm = 6;
uint8_t next_heart_rate_heart_rate_total_weight_x100 = 7;
uint8_t next_heart_rate_zone = 8;
bool next_plugged_in = false;
for (int i = 0; i < num_minutes; i++... | {
fake_system_task_callbacks_invoke_pending();
activity_algorithm_deinit();
} |
// ---------------------------------------------------------------------------------------
// Test to make sure that the minute data gets sent to data logging correctly
void test_activity_algorithm_kraepelin__data_logging_test(void) {
const int k_num_records = 2;
const int num_minutes = k_num_records * ALG_MINUT... |
t(),
.num_types = ARRAY_LENGTH(types),
.types = types,
.num_samples = ARRAY_LENGTH(offset_sec),
.offset_sec = offset_sec,
.num_values = ARRAY_LENGTH(values),
.values = values,
}
};
ProtobufLogRef ref = prv_test_encode_measurements(&input, false /*use_data_lo... | ARRAY_LENGTH(types) | ;
uint32_t offset_sec[num_samples];
uint32_t values[num_samples * num_values_per_sample];
for (unsigned i = 0; i < num_samples; i++) {
offset_sec[i] = i * 2;
}
for (unsigned i = 0; i < num_samples * num_values_per_sample; i++) {
values[i] = i * 3;
}
// Create a session with an artifically small ... |
er_set_frame((Layer *)&layer->day_separator, &day_sep_frame);
layer_set_hidden((Layer *)&layer->day_separator, false);
}
static void prv_place_end_of_timeline(TimelineLayer *timeline_layer) {
const bool was_hidden = layer_get_hidden((Layer *)&timeline_layer->end_of_timeline);
const bool is_hidden = (timeline_lay... | (ctx, &(GRect) { .size = bounds->size }) | |
_t bitmap_offset_8bit = ((uint32_t)block_addr * 8) - (padding * y_offset);
// Calculate just the offset from the start of the target row in the 8-bit bitmap (i.e. "x")
return bitmap_offset_8bit - (dest_bitmap->bounds.size.w * y_offset);
}
// PRO TIP: if you have to modify this function, expect to waste the rest of... | (src, dest_shift) | ;
int8_t src_rotated = dest_shift;
// how many 32-bit blocks do we need to bitblt on each row. If we're not word aligned we'll need to
// modify an extra partial word, as we'll have an incomplete word on either side of the line segment
// we're modifying.
// For 1-bit, each pixel goes into one bit in dest bit... |
// we should be back in the Idle state
cl_assert_equal_i(prv_get_state(), ANCSClientStateIdle);
// Make sure we can still receive notifications
prv_send_notification((uint8_t *)&s_complete_dict);
cl_assert_equal_i(s_num_requested_notif_attributes, 2);
cl_assert_equal_i(s_num_ds_notifications_received, 1);
... | prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_message_app_info_dict),
(uint8_t *)s_message_app_info_dict) | ;
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
}
void test_ancs__handle_unexpected_notifications(void) {
NSNotification ns_notification = {
.event_id = EventIDNotificationAdded,
.event_flags = 0,
.category_id = CategoryIDSocial,
.category_count = 1,
.uid ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(!uuid_is_invalid(&test_uuid_1)) | ;
}
void test_uuid__string(void) {
char buffer[UUID_STRING_BUFFER_LENGTH];
const Uuid test_uuid_1 = (Uuid) {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5
};
uuid_to_string(&test_uuid_1, buffer);
cl_assert_equal_s(buffer, "{00010203-0405-0607-0809-000102030405}");
const Uuid system = UUID_SYSTEM;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.