prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
/* * 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...
{ set_ldo3_power_state(enable); }
g(&data, true /* is_gateway */, requires_address_pinning, flags, device_name, BtPersistBondingOpDidChange)); } static void prv_remove_ble_bonding_from_bt_driver(void) { if (!bt_ctl_is_bluetooth_running()) { ...
(*platform_bits)
; } prv_call_bt_classic_bonding_change_handlers(BT_CLASSIC_BONDING_ID, BtPersistBondingOpDidChange); return BT_CLASSIC_BONDING_ID; } return BT_BONDING_ID_INVALID; } void bt_persistent_storage_delete_bt_classic_pairing_by_id(BTBondingID bonding) { shared_prf_storage_erase_bt_classic_pairing_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...
memset(buffer + buf_size, 0, PLOG_DLS_RECORD_SIZE - buf_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...
(LOG_LEVEL_ALWAYS, "__TINTIN__ - MANUFACTURING MODE")
nished, context); animation_destroy(animation); } // -------------------------------------------------------------------------------------- // Test that animation_destroy can be called from the stopped handler static void prv_test_destroy_from_stopped_handler(bool auto_destroy) { Animation *h; const int duratio...
prv_now_ms()
ggregate_averaged(HealthServiceState *state, HealthMetric metric, time_t time_start, time_t time_end, HealthAggregation aggregation) { PBL_ASSERTN(metric == HealthMetricHeartRateBPM || metric == HealthMetricHeartRateRawBPM); ...
if (scope == HealthServiceTimeScopeWeekly) { if (prv_get_intraday_averages(state, metric, &averages, local_tm->tm_wday)) { result += prv_sum_intraday_averages(&averages, time_start, time_end); num_sums++; } } else if ((scope == HealthServiceTimeScopeDaily) || (scope == HealthServi...
if (num_sums > 0) { result = ROUND(result, num_sums); } return result; } // -------- // Default handling is to use daily totals if (scope == HealthServiceTimeScopeOnce) { return prv_compute_aggregate_using_daily_totals(state, metric, time_start, time_end, ...
alized_slice_total_size; } // Check that we fully populated the serialized glance buffer rv = (glance_buffer_cursor == glance_buffer_end) ? S_SUCCESS : E_ERROR; if (rv == S_SUCCESS) { *serialized_glance_out = serialized_glance; *serialized_glance_size_out = serialized_glance_size; } else { kernel...
{ return E_OUT_OF_MEMORY; }
status_t rv = app_glance_db_read(key, key_size, serialized_glance, serialized_glance_size); if (rv != S_SUCCESS) { goto cleanup; } rv = prv_deserialize_glance((SerializedAppGlanceHeader *)serialized_glance, (size_t)serialized_glance_size, glance_out); cleanup: kernel_free...
= NULL; } s_path_open = false; s_radius = 0; s_path_stroke_count = 0; s_path_stroke_precise_count = 0; s_path_fill_count = 0; s_path_fill_precise_count = 0; s_circle_stroke_count = 0; s_circle_fill_count = 0; s_offset = (GPoint){ 0 }; if (s_precise_lines) { free(s_precise_lines); s_preci...
cl_assert_equal_i(s_fill_color.argb, GColorGreenARGB8)
; cl_assert_equal_i(s_stroke_width, 0); cl_assert_equal_i(s_path_num_points, 2); cl_assert_equal_b(s_path_open, false); cl_assert_equal_i(s_path_fill_count, 1); cl_assert_equal_i(s_path_stroke_count, 0); cl_assert_equal_p(s_stroke_points, NULL); cl_assert(prv_compare_points(points, s_fill_points, s_path_n...
rrow(layer, ctx, &data->arrow_down, GAlignBottom); } break; case DisplayCalibrationState_Confirm: break; } } static void prv_layer_update_proc(Layer *layer, GContext *ctx) { DisplayCalibrationData *data = window_get_user_data(layer_get_window(layer)); ctx->draw_state.drawing_box.origin.x +...
window_set_window_handlers(window, &(WindowHandlers) { .unload = prv_window_unload })
; window_set_background_color(window, GColorBlack); Layer *root_layer = window_get_root_layer(window); Layer *layer = &data->layer; layer_init(layer, &root_layer->bounds); layer_set_update_proc(layer, prv_layer_update_proc); layer_add_child(root_layer, layer); prv_init_arrow_bitmap(&data->arrow_down, RE...
ll be cleaned up by the action menu/action callbacks TimelineItem *item = s_phone_ui_data->call_response_item; s_phone_ui_data->call_response_item = NULL; TimelineItemAction *reply_action = timeline_item_find_reply_action(item); if (!reply_action) { return; } switch (reply_action->type) { case Ti...
property_animation_get_animation( property_animation_create_layer_frame(&s_phone_ui_data->action_bar.layer, NULL, &offscreen))
; animation_set_duration(action_bar_animation, ACTION_BAR_DISAPPEAR_ANIMATION_FRAMES * ANIMATION_FRAME_MS); animation_set_curve(action_bar_animation, AnimationCurveEaseIn); GPoint overshoot = GPoint(PBL_IF_RECT_ELSE(ACTION_BAR_WIDTH / 2, 0) + BOUNCEBACK_DISTANCE, 0);...
alue (as the spi flash sets bytes to 0xff when they're erased) typedef struct PACKED { bool invalid:1; //!< Whether or not this chunk is formatted bool valid:1; //!< Set to 0 when the chunk is stale. //! The ID of the current chunk. Each chunk in the gets an auto-incrementing ID. This //! allows the logging in...
(&zero, get_current_address(i, 0), sizeof(zero))
; } s_enabled = true; } // Dumping commands /////////////////////////////////////////////////////////////////////////////// static bool dump_chunk(int generation, int chunk_index, DumpLineCallback cb) { int offset = sizeof(LogChunkHeader); uint8_t* read_buffer = kernel_malloc(256); bool error = false; w...
cal_cleanup)(void *); void *local_cleanup_payload; jmp_buf trampoline; int trampoline_enabled; } _clar; struct clar_func { const char *name; void (*ptr)(void); }; struct clar_suite { int index; const char *name; struct clar_func initialize; struct clar_func cleanup; const char **categories; con...
(" -sXX\t\tRun only the suite number or name XX\n")
; printf(" -i<name>\tInclude category <name> tests\n"); printf(" -q \t\tOnly report tests that had an error\n"); printf(" -Q \t\tQuit as soon as a test fails\n"); printf(" -l \t\tPrint suite, category, and test names\n"); printf(" -tXX\t\tRun a specifc test by name\n"); exit(-1); } static void clar...
%d) or removed (%d)", minute_of_day, s_activity_summary_settings.summary.activity.trigger_minute, s_activity_pin_state.removed); return; } // Make sure we actually have a step count const int32_t steps = prv_get_step_count(); if (steps <= 0) { INSIGHTS_LOG...
health_util_get_distance_string(i18n_get("MI", i18n_owner), i18n_get("KM", i18n_owner))
; } static void prv_add_metric_duration_info(StringList *headings, int headings_buf_size, StringList *values, int values_buf_size, ActivitySession *session) { const size_t duration_buffer_size = sizeof("00:00:00"); char duration_str[...
lude "applib/graphics/gpath_builder.h" #include "applib/graphics/graphics.h" #include "util/trig.h" #include "applib/ui/animation.h" #include "applib/ui/layer.h" #include "applib/ui/property_animation.h" #include "applib/ui/bitmap_layer.h" #include "kernel/pbl_malloc.h" #include "resource/resource_ids.auto.h" #include ...
(data->spinner_animation)
); } } //////////////////////////////////////////////////////////// // Window loading, unloading, initializing static void prv_window_unload_handler(Window* window) { SpinnerUIData *data = window_get_user_data(window); if (data) { gbitmap_destroy(data->bitmap); data->should_cancel_animation = true; ...
312, -56, -224}, { 1128, -160, -376}, { 936, -184, -456}, { 672, -280, -288}, { 736, -240, -40}, { 696, -144, -144}, { 976, -16, -528}, { 1208, 56, -536}, { 1552, 80, -344}, { 1936, 160, -288}, { 1904, 280, -288}, // 5 seconds { 1648, 424, -304}, { 1512, 512, -280}, ...
{ 816, 0, -400}, { 664, -160, -272}, { 696, -240, -72}, { 832, -176, -288}, { 928, -24, -392}, { 1208, 80, -392}, { 1736, 104, -488}, { 1744, 232, -440}, { 1472, 248, -344}, { 1232, 424, -328}, { 1048, 616, -312}, { 968, 488, -288}, { 1032, 456, -176}, { 848, 632,...
{ 1200, 344, -64}, { 1080, 528, -64}, { 752, 680, 40}, { 552, 832, -216}, { 776, 1016, -208}, { 992, 768, -296}, { 928, 384, -504}, // 13 seconds { 1328, 736, -160}, { 2480, 672, -56}, { 2416, 104, 256}, { 1816, -16, 8}, { 1488, 16, -192}, { 1264, 176, -224}, ...
e_buffer[1024]; static uint16_t s_write_length; static bool s_prepare_return_null = false; static Receiver * prv_system_test_receiver_prepare(CommSession *session, const PebbleProtocolEndpoint *endpoint, size_t total...
(s_prepare_count, 1)
; } void test_session_receive_router__system_disallowed_endpoint(void) { // Expect "Disallowed" meta message to be replied to a message for an endpoint that is disallowed // by use over a system session. // The message should get eaten and not interfere with whatever comes next. // Length: 1, Endpoint ID: PUB...
nt)), s_graphics_draw_text.last_call.draw_text.box); EXECUTE_SCRIPT( "ctx.textAlign = 'right';\n" "ctx.fillText('some text', 100, 100);\n" ); cl_assert_equal_i(3, s_graphics_draw_text.call_count); cl_assert_equal_rect((GRect(-9900, 100, large_int, large_int)), ...
while (def->js_name) { const jerry_value_t name_js = jerry_create_string((jerry_char_t *)def->js_name); RockyAPISystemFontDefinition *cmp_def = NULL; bool actual = prv_font_definition_from_value(name_js, &cmp_def); cl_assert_equal_b(true, actual); cl_assert_equal_s(cmp_def->res_key, def->res_key); ...
} void test_rocky_api_graphics__measure_text(void) { prv_global_init_and_set_ctx(); // fill text_state with unique values we can test against s_rocky_text_state = (RockyAPITextState) { .font = (GFont)-1, .overflow_mode = (GTextOverflowMode)-2, .alignment = (GTextAlignment)-3, .text_attributes =...
yer *)&timeline_layer->day_separator, false); peek_layer_set_frame(&timeline_layer->day_separator, frame); } static void prv_show_day_sep(TimelineLayer *timeline_layer, bool slide) { // update the day to show the right date timeline_layer->current_day = timeline_model_get_current_state()->current_day; char fri...
timeline_relbar_layer_create_animation(layer, duration, interpolate)
; if (relbar_animation) { animations[num_animations++] = relbar_animation; } #endif Animation *animation = animation_spawn_create_from_array(animations, num_animations); return animation; } static void prv_place_day_separator(TimelineLayer *layer) { if (!layer_get_hidden((Layer *)&layer->day_separator))...
d = list_sorted_add(head, &bar1.list_node, (Comparator) sorting_comparator, true); cl_assert(head == &bar1.list_node); cl_assert(list_get_next(head) == &bar2.list_node); cl_assert(list_get_tail(head) == &bar3.list_node); } void test_list__sort_descending(void) { IntNode bar1 = { .value = 1 }; IntNode bar2 = ...
cl_assert_equal_p(list_concatenate(&c, &f), &a)
; cl_assert_equal_p(list_get_head(&e), &a); cl_assert_equal_p(list_get_tail(&b), &f); } #define CTX_VALUE 0xdeadbeef #define INT_VALUE 17 static bool prv_list_set_val_each(ListNode *node, void *context) { IntNode *int_node = (IntNode *)node; int_node->value = INT_VALUE; cl_assert_equal_i(CTX_VALUE, (uintptr...
00, 536, -768}, { -392, 536, -776}, { -392, 528, -776}, { -392, 528, -768}, { -392, 528, -768}, { -392, 528, -768}, { -384, 520, -768}, { -392, 528, -784}, { -400, 536, -768}, { -392, 536, -768}, { -392, 536, -760}, { -392, 536, -768}, { -392, 528, -776}, { -392, 552,...
{ -360, 552, -768}, { -352, 560, -760}, { -360, 544, -760}, { -360, 544, -768}, { -360, 552, -768}, { -360, 560, -760}, { -360, 560, -760}, { -368, 560, -776}, { -368, 552, -760}, { -368, 552, -768}, { -360, 552, -768}, { -368, 552, -768}, { -360, 552, -760}, { -3...
// 77 seconds { -328, 552, -768}, { -312, 560, -744}, { -312, 568, -784}, { -320, 544, -792}, { -328, 536, -808}, { -320, 560, -800}, { -312, 536, -808}, { 56, 264, -888}, { -272, 544, -792}, { -272, 536, -776}, { -280, 544, -784}, { -296, 568, -792}, { -304, 560...
// Fakes //////////////////////////////////////////////////////////////// #include "fake_pbl_malloc.h" #include "fake_spi_flash.h" // Stubs //////////////////////////////////////////////////////////////// #include "stubs_analytics.h" #include "stubs_hexdump.h" #include "stubs_logging.h" #include "stubs_mutex.h" #inc...
prv_check_invalid_version_code_not_inserted(version)
; } } void test_weather_db__higher_version_not_inserted(void) { prv_check_invalid_version_code_not_inserted(WEATHER_DB_CURRENT_VERSION + 1); } status_t weather_db_get_num_keys(uint16_t *val_out); void test_weather_db__test_get_num_keys(void) { uint16_t num_keys; cl_assert_equal_i(S_SUCCESS, weather_db_get_nu...
id) { uint8_t pp_msg[] = {0x04, 0x1a, 0xd4, 0x77, 0x08, 0x00, 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_cookie */, true /* check_name_number */, "Unknown...
(memcmp(expected_request_msg, data, sizeof(expected_request_msg)), 0)
ently it's handshaking with us in our // time domain, this will let the sensor do this compensation for us. // The value programmed in here is in units of 0.1ms (value of 10000 = 1 second). #define ADDR_HOST_ONE_SECOND_TIME_MSB (0x0a) #define ADDR_HOST_ONE_SECOND_TIME_LSB (0x0b) #define ADDR_NUM_ACCEL_SAMPLES (0x0e) #...
{ i2c_use(dev->i2c_slave); bool rv = i2c_write_register(dev->i2c_slave, register_address, value); i2c_release(dev->i2c_slave); return rv; }
static bool prv_write_register_block(HRMDevice *dev, uint8_t register_address, const void *buffer, uint32_t length) { i2c_use(dev->i2c_slave); bool rv = i2c_write_register_block(dev->i2c_slave, register_address, length, buffer); i2c_release(dev->i2c_slave); return rv; } s...
c uint8_t s_alarms_app_opened = 0; #define PREF_KEY_ACTIVITY_HRM_PREFERENCES "hrmPreferences" static ActivityHRMSettings s_activity_hrm_preferences = ACTIVITY_HRM_DEFAULT_PREFERENCES; #define PREF_KEY_ACTIVITY_HEART_RATE_PREFERENCES "heartRatePreferences" static HeartRatePreferences s_activity_hr_preferences = ACTIVI...
(!s_language_english)
; return true; } static bool prv_set_s_quick_launch_up(QuickLaunchPreference *pref) { s_quick_launch_up = *pref; return true; } static bool prv_set_s_quick_launch_down(QuickLaunchPreference *pref) { s_quick_launch_down = *pref; return true; } static bool prv_set_s_quick_launch_select(QuickLaunchPreference ...
rve_get_percent_remaining(s_warning_points[s_warning_points_index + 1]))) { s_warning_points_index++; new_warning = true; } if (new_warning) { if (!do_not_disturb_is_active()) { vibes_short_pulse(); } battery_ui_display_warning(percent, s_warning_points_index); } } static void prv_dism...
{ return BatteryGood; }
basic glance blob back with a NULL glance_out argument should fail uint8_t *invalid_glance_out = NULL; cl_assert_equal_i(app_glance_db_read((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE, invalid_glance_out, glance_size), E_INVALID_ARGUMENT); } void test_app_...
cl_assert_equal_i(app_glance_db_read((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE, glance_out, trimmed_glance_size), S_SUCCESS)
; cl_assert_equal_m(glance_out, (uint8_t *)s_app_glance_with_too_many_slices, trimmed_glance_size); } static void prv_check_invalid_version_code_blob_not_inserted(uint8_t version) { const SerializedAppGlanceHeader app_glance = (SerializedAppGlanceHeader) { .version = version, }; cl_assert_equal_i(app_glan...
ill_color = GColorBlack, .path_open = false, .num_points = ARRAY_LENGTH(points2), }; memcpy(command->points, points2, sizeof(points2)); return size; } // tests void test_gdraw_command_sequence__validate(void) { GDrawCommandSequence *sequence; size_t size = prv_create_test_sequence(&sequence); cl_...
(command->fill_color.argb, GColorPurpleARGB8)
; cl_assert_equal_i(command->points[0].x, 6); frame = gdraw_command_sequence_get_frame_by_index(sequence, 1); cl_assert_equal_i(frame->duration, 30); cl_assert_equal_i(frame->command_list.num_commands, 1); command = gdraw_command_list_get_command(&frame->command_list, 0); cl_assert_equal_i(command->type, G...
/* * 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...
GPointPreciseFromGPoint(GPoint(2, 5))
; GPointPrecise pointP_c = GPointPrecise((2 % GPOINT_PRECISE_MAX) << GPOINT_PRECISE_PRECISION, (5 % GPOINT_PRECISE_MAX) << GPOINT_PRECISE_PRECISION); cl_assert(gpointprecise_equal(&pointP, &pointP_c)); GVectorPrecise vectorP = GVectorPreciseFromGVector(GVector(2, 5)); ...
2, &irk_out, &device_out, NULL /* name */); cl_assert(ret); cl_assert_equal_m(&irk_out, &pairing_2.irk, sizeof(irk_out)); cl_assert_equal_m(&device_out, &pairing_2.identity, sizeof(device_out)); ret = bt_persistent_storage_get_ble_pairing_by_id(id_3, &irk_out, &device_out, NULL /* name */); cl_assert(ret); ...
(s_ble_bonding_change_add_count, 2)
; cl_assert_equal_i(fake_shared_prf_storage_get_ble_store_count(), 2); // Delete a pairing that doesn't exist. Delete count should stay at 1 bt_persistent_storage_delete_ble_pairing_by_id(9); cl_assert_equal_i(s_ble_bonding_change_delete_count, 1); cl_assert_equal_i(fake_shared_prf_storage_get_ble_delete_cou...
/* * 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...
animation_timing_segmented( normalized, 0, 2, data->effect_duration)
; gdraw_command_list_scale_segmented_to( list, size, *from, intermediate, first_normalized, data->interpolate, index_lookup, data->point_duration, false); size = intermediate.size; second_normalized = animation_timing_segmented(normalized, 1, 2, data->effect_duration); } else { interm...
ng = "Message"}, {.id = AttributeIdSubtitle, .cstring = "Subject"}, }; bool system_task_add_callback(SystemTaskEventCallback cb, void *data) { return true; } PebblePhoneCaller* phone_call_util_create_caller(const char *number, const char *name) { return NULL; } // Setup //////////////////////////////////// ...
ARRAY_LENGTH(actions)
, .actions = actions, } }; Uuid i2; uuid_generate(&i2); TimelineItem e2 = { .header = { .id = i2, .type = TimelineItemTypeNotification, .status = 0, .ancs_uid = 0, .layout = LayoutIdGeneric, .timestamp = 0x53f0dda6, }, .attr_list = { .num_attribut...
r.call_count); cl_assert_equal_i(GColorRedARGB8, s_graphics_context_set_fill_color.last_call.color.argb); cl_assert_equal_i(1, s_graphics_context_set_stroke_color.call_count); cl_assert_equal_i(GColorWhiteARGB8, s_graphics_context_set_stroke_color.last_call.color.argb); // ignores invalid values EXECUTE_SCRI...
((GRect(-4900, 100, large_int, large_int)), s_graphics_draw_text.last_call.draw_text.box)
; EXECUTE_SCRIPT( "ctx.textAlign = 'right';\n" "ctx.fillText('some text', 100, 100);\n" ); cl_assert_equal_i(3, s_graphics_draw_text.call_count); cl_assert_equal_rect((GRect(-9900, 100, large_int, large_int)), s_graphics_draw_text.last_call.draw_text.box); } void test_rocky_api...
/* * 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...
ASSERT_JS_GLOBAL_EQUALS_B("a", true)
; } void test_rocky_api_global__calls_init_and_notifies_about_apis(void) { static const RockyGlobalAPI api = { .init = prv_api_init, .add_handler = prv_api_add, }; static const RockyGlobalAPI *apis[] = { &api, NULL, }; rocky_global_init(apis); cl_assert_equal_i(1, s_prv_api_init__callcount)...
/* * 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(NULL == bmp)
----------------- static void prv_do_sleep_notification(time_t now_utc, time_t sleep_exit_utc, int32_t sleep_total_seconds) { if (!activity_prefs_sleep_insights_are_enabled()) { return; } if (s_sleep_pin_state.notified) { INSIGHTS_LOG_DEBUG("Not notifying sleep pin -...
("Adding sleep pin")
; prv_push_sleep_summary_pin(now_utc, sleep_exit_utc, sleep_enter_seconds, sleep_exit_seconds, sleep_total_seconds, s_sleep_stats.mean, &s_sleep_pin_state.uuid); // Update sleep pin state s_sleep_pin_state.last_triggered_utc = sleep_exit_utc; s_sleep_pi...
_get_bounds(shoe_icon); icon_bounds.origin = bounds.origin; #if PBL_BW icon_bounds.origin.x += 23; // icon left offset icon_bounds.origin.y += 9; // icon top offset #elif ROBERT_SCREEN_RES icon_bounds.origin.y += (46 - icon_bounds.size.h); // icon top offest #elif SNOWY_SCREEN_RES icon_bounds.origin.x = scree...
graphics_draw_text(ctx, bpm_text, font, bounds, GTextOverflowModeFill, alignment, NULL)
; } #endif //////////////////////////////////////////////////////////////////////////////////////////////////// // Update Proc static void prv_base_layer_update_proc(Layer *layer, GContext *ctx) { KickstartData *data = window_get_user_data(layer_get_window(layer)); GRect bounds = layer->bounds; GRect unobstruc...
gpoint_from_polar(GRect(0, 0, 10, 10), GOvalScaleModeFillCircle, 0); cl_assert_equal_gpoint(result, GPoint(4, 0)); } void test_graphics_circle__grect_centered_from_polar(void) { GOvalScaleMode mode = GOvalScaleModeFillCircle; // Basic container rect with GPointZero origin const GRect container_rect1 = GRect(...
grect_polar_calc_values(&r, mode, NULL, NULL)
; grect_polar_calc_values(&r, mode, &center, NULL); grect_polar_calc_values(&r, mode, NULL, &radius); cl_assert_gpoint_precise(center, 1, 2); cl_assert_fixedS16_3(radius, 1); grect_polar_calc_values(NULL, mode, &center, &radius); cl_assert_gpoint_precise(center, 1, 2); cl_assert_fixedS16_3(radius, 1); }...
cl_assert_equal_i(count, 1)
; assert_result(0, "A", 1); } void test_ams_util__csv_null_in_the_middle(void) { const char null_middle_value[] = "A\x00 BCD,1234"; cl_assert(sizeof(null_middle_value) > 2); const uint8_t count = ams_util_csv_parse(null_middle_value, sizeof(null_middle_value), NULL, p...
ke_remote_action(action_menu, action, pin, (void *)(uintptr_t)new_time); } static void prv_postpone_tomorrow(ActionMenu *action_menu, const ActionMenuItem *action_menu_item, void *context) { TimelineActionMenu *timeline_action_menu = context; cons...
if (timeline_action_menu->did_close) { timeline_action_menu->did_close(action_menu, item, timeline_action_menu->item); }
if (timeline_action_menu->action_result) { timeline_action_menu->action_result->action_menu = NULL; } prv_cleanup_action_menu(action_menu); applib_free(timeline_action_menu); } ActionMenu *timeline_actions_push_action_menu(ActionMenuConfig *base_config, Window...
oup_type_elements; ((TimelineItemActionGroup *) group_ptr)->actions = (TimelineItemAction *)*buffer; *buffer += num_group_type_elements * sizeof(TimelineItemAction); } else { ((AddressList *) group_ptr)->num_addresses = num_group_type_elements; ((AddressList *) group_ptr)->addresses = (Addre...
( &((AddressList *)group_ptr)->addresses[i], &cursor, payload_end, buffer, buf_end)
; } if (!attribute_deserialize_list((char**)&buffer, (char *)buf_end, &cursor, payload_end, *group_type_element_attribtue_list)) { return false; } } return true; } bool attribute_group_deserialize(AttributeGroupType type, Attri...
/* * 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...
fseek(resource_file, 0, SEEK_END)
; size_t resource_size = ftell(resource_file); fseek(resource_file, 0, SEEK_SET); return resource_size; } return 0; } size_t sys_resource_load_range(ResAppNum app_num, uint32_t id, uint32_t start_bytes, uint8_t *buffer, size_t num_bytes) { if (buffer && id < UINT32_MAX...
blobdb_event(); cl_assert_equal_i(fake_event_get_count(), 2); cl_assert(!prv_get_calendar_ongoing()); cl_assert(stub_new_timer_is_scheduled(timer_id)); cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000); cl_assert(timeline_remove(&item1.header.id)); timeline_event_handle_blobdb_event(); cl...
(fake_event_get_count(), 3)
lude "fake_new_timer.h" static bool s_mfg_mode_entered; void mfg_enter_mfg_mode(void) { s_mfg_mode_entered = true; } void mfg_enter_mfg_mode_and_launch_app(void) { mfg_enter_mfg_mode(); } static bool s_factory_reset_called; void factory_reset(bool shutdown) { s_factory_reset_called = true; } Window* spinner...
cl_assert_equal_i(stub_new_timer_timeout(timer->id), 5000)
; stub_new_timer_fire(timer->id); cl_assert(!s_mfg_mode_entered); cl_assert(s_select_cb_called); } void test_getting_started_button_combo__push_complex_and_release_to_simple_and_back_to_complex(void) { // Just up (nothing) -> Up+Select (mfg mode) -> Select (show version) -> Up+Select (mfg mode) prv_press_...
920, 224}, { 1512, 864, 128}, { 1072, 720, -104}, { 728, 312, -112}, { 568, 360, -312}, { 480, 320, -528}, { 488, 272, -472}, { 88, 0, -624}, { 112, 112, -568}, { 8, 200, -464}, { -256, 648, -352}, { -280, 1072, -640}, { -232, 1232, -560}, { -400, 1024, -720}, { ...
{ 1296, -144, 200}, { 1216, -184, 184}, { 1080, -296, 72}, { 920, -392, 48}, { 848, -464, -16}, { 960, -536, -88}, { 704, -496, -48}, { 1328, -352, 56}, { 1368, -272, 16}, // 65 seconds { 1552, -192, 80}, { 1384, -136, 16}, { 1240, -120, 184}, { 1176, 56, 80}, ...
{ 888, 216, 72}, { 1448, 80, 224}, { 1784, -128, 448}, { 1656, -232, 392}, { 1480, -248, 248}, { 1256, -144, 200}, { 1032, -56, 112}, { 1016, -136, 80}, { 1192, -312, 56}, { 1208, -464, -8}, { 936, -472, -152}, { 1168, -640, -224}, { 904, -552, -56}, { 1160, -296...
el/events.h" #include "fake_events.h" #include "fake_session.h" #include "fake_system_task.h" #include "stubs_bt_lock.h" #include "stubs_passert.h" #include "stubs_pbl_malloc.h" #include "stubs_hexdump.h" #include "stubs_serial.h" #include "stubs_logging.h" #include "stubs_mutex.h" #include "stubs_i18n.h" extern voi...
phone_protocol_msg_callback(s_session, pp_msg, sizeof(pp_msg))
te, const ActivityInsightMetricHistoryStats *metric_stats, time_t now_utc) { // Make sure the reward is enabled if (!insight_settings->enabled) { return false; } // Make sure the previous nights met our criteria if (!insight_state->h...
(SLEEP_SUMMARY_PIN_CONFIG.short_subtitle, SUBTITLE_BUFFER_LENGTH, i18n_get("%uH %uM Sleep", &SLEEP_SUMMARY_PIN_CONFIG), hours, minutes)
; i18n_free_all(&SLEEP_SUMMARY_PIN_CONFIG); } // ----------------------------------------------------------------------------------------- static bool prv_push_sleep_summary_pin(time_t now_utc, time_t pin_time_utc, int32_t sleep_enter_seconds, int32_t sleep_exit_seconds, ...
&event->irk : NULL; GAPLEConnection *connection = gap_le_connection_add(&event->peer_address, remote_irk, local_is_master); // Cache the BLE connection parameters connection->conn_params = *params; bool found_match = false; GAPLECo...
prv_put_legacy_connection_event(&event->peer_address, false /* disconnected */)
; } GAPLEConnectionIntent *intent = s_intents; while (intent) { GAPLEConnectionIntent *next = (GAPLEConnectionIntent *) intent->node.next; if (prv_intent_matches_connection(intent, connection)) { // Notify clients: if (prv_update_clients(intent, event->reason, ...
/* * 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...
util_log(filename, line, "*** UTIL ASSERT FAILED")
; exit(EXIT_FAILURE); } WEAK uint32_t rand32(void) { return ((uint32_t)rand() << 1) + (uint32_t)rand; }
b_get_install_id_for_uuid(const Uuid *uuid) { status_t rv = prv_lock_mutex_and_open_file(); if (rv != S_SUCCESS) { return rv; } AppInstallId app_id = prv_find_install_id_for_uuid(&s_app_db.settings_file, uuid); prv_close_file_and_unlock_mutex(); return app_id; } /////////////////////////// // App DB ...
{ if (key_len != UUID_SIZE || val_len != sizeof(AppDBEntry)) { return E_INVALID_ARGUMENT; } status_t rv = prv_lock_mutex_and_open_file(); if (rv != S_SUCCESS) { return rv; } PBL_ASSERTN(key_len == 16); PBL_ASSERTN(val_len > 0); bool new_install = false; AppInstallId app_id = prv_find_...
int app_db_get_len(const uint8_t *key, int key_len) { status_t rv = prv_lock_mutex_and_open_file(); if (rv != S_SUCCESS) { return rv; } PBL_ASSERTN(key_len == 16); // should not increment !!!! AppInstallId app_id = prv_find_install_id_for_uuid(&s_app_db.settings_file, (Uuid *)key); if (app_id == ...
" #include "stubs_pbl_malloc.h" #include "stubs_pebble_tasks.h" #include "stubs_print.h" #include "stubs_prompt.h" #include "stubs_serial.h" #include "stubs_sleep.h" #include "stubs_syscall_internal.h" #include "stubs_system_reset.h" #include "stubs_task_watchdog.h" #include "stubs_app_state.h" #include "stubs_worker_s...
pbl_snprintf(str, STR_SIZE, "abc %hd%s", 42, "b")
; cl_assert_equal_s(str, "abc 42b"); //---------------------------------------------------- pbl_snprintf(str, STR_SIZE, "abc %a%s", "a", 1.0, "b"); cl_assert_equal_s(str, fp_msg); pbl_snprintf(str, STR_SIZE, "abc %jd%s", 42, "b"); cl_assert_equal_s(str, "abc 42b"); //------------------------------------...
/* * 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...
{ /* noop */ (void)suite_index; (void)suite_name; }
static void clar_print_onabort(const char *msg, ...) { va_list argp; va_start(argp, msg); vfprintf(stderr, msg, argp); va_end(argp); }
= layer_create(GRectZero); Layer *b = layer_create(GRectZero); layer_add_child(a, aa); layer_add_child(aa, aaa); layer_add_child(aaa, aaaa); layer_add_child(a, ab); a->next_sibling = b; stack[0] = a; // go to child if possible Layer *actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_L...
(0, 0, 20, 20)
); layer_set_frame(&child_a, &GRect(0, 0, 10, 10)); layer_set_frame(&child_b, &GRect(2, 2, 6, 6)); layer_set_frame(&child_c, &GRect(10, 10, 10, 10)); layer_set_frame(&child_d, &GRect(2, 2, 6, 6)); layer_set_frame(&child_e, &GRect(10, 10, 10, 10)); layer_set_frame(&child_f, &GRect(-10, -10, 40, 40)); layer...
t_create_text_node_from_config(&layout->layout, &vertical_config.container.extent.node); } static void prv_destroy_view(NotificationLayout *layout) { graphics_text_node_destroy(layout->view_node); layout->view_node = NULL; #if !PLATFORM_TINTIN kino_layer_destroy(layou...
(ctx->draw_state.clip_box.origin.y - STATUS_BAR_LAYER_HEIGHT, 0)
; ctx->draw_state.clip_box.size.h = DISP_ROWS; grect_clip(&ctx->draw_state.clip_box, &DISP_FRAME); const int32_t banner_movement_raw_offset = CLIP(BANNER_PEEK_STATIC_Y - notification_layout_frame->origin.y, 0, BANNER_PEEK_STATIC_Y); const int32_t banner_radius = prv_interpolate_linear(BOTTOM_B...
dow_set_background_color(&dialog->window, PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite)); // initial values dialog->icon_anim_direction = DialogIconAnimationFromRight; dialog->destroy_on_pop = true; dialog->text_color = GColorBlack; } void dialog_pop(Dialog *dialog) { window_stack_remove(&dialog->window, ...
icon_duration != PLAY_DURATION_INFINITE && // Don't extend dialogs with infinite animations icon_duration > dialog->timeout) { // The finite image animation is longer, increase the finite dialog timeout dialog_set_timeout(dialog, icon_duration); } return true; }
iting_mode(&window->bitmap_layer, GCompOpSet); const GRect NO_MUSIC_TEXT_RECT = GRect(0, config->no_music_text_field.origin_y, DISP_COLS, config->no_music_text_field.size_h); text_layer_init_with_parameters(&window->text_layer, &NO_MUSIC_T...
{ return; }
workout_dialog_init(workout_dialog, "Workout Detected"); Dialog *dialog = workout_dialog_get_dialog(workout_dialog); dialog_show_status_bar_layer(dialog, true); dialog_set_fullscreen(dialog, true); dialog_set_background_color(dialog, PBL_IF_COLOR_ELSE(GColorYellow, GColorWhite)); dialog_set_text_color(dia...
workout_service_get_current_workout_type(&existing_workout_type)
; prv_prep_and_open_active_window(existing_workout_type); } return; } const bool found_automatic_session = workout_utils_find_ongoing_activity_session(&data->ongoing_session); if (found_automatic_session) { prv_show_workout_detected_dialog(data); } else { workout_push_summary_windo...
BLESubscriptionNotifications, GAPLEClientKernel); // Simulate getting the subscription failure: ppogatt_handle_subscribe(s_characteristics[0][PPoGATTCharacteristicData], BLESubscriptionNotifications,...
(s_characteristics[0][PPoGATTCharacteristicData])
PBL_LOG(LOG_LEVEL_INFO, "Adding activity session %d, start_time: %"PRIu32, (int)session->type, (uint32_t)session->start_utc); state->activity_sessions[state->activity_sessions_count++] = *session; } unlock: mutex_unlock_recursive(state->mutex); } // ------------------------------------------------...
{ // We don't need to be buffered since we are logging from the KernelBG task and this // saves having to allocate another buffer from the kernel heap. const bool buffered = false; const bool resume = false; Uuid system_uuid = UUID_SYSTEM; state->activity_dls_session = dls_create( DlsSys...
1 #define TIMEOUT_MS 100 //! The largest message for attributes which we support internally (the app has its own buffer) #define BUFFER_LENGTH 20 #define MIN_SERVICE_DISCOVERY_INTERVAL 1 typedef struct { uint16_t service_id; uint16_t attribute_id; } ReadInfo; typed...
PBL_LOG(LOG_LEVEL_DEBUG, "Read of management attribute was not successful (0x%x)", attr)
; return false; } if (attr == ManagementServiceAttributeServiceDiscovery) { if (length % sizeof(uint16_t)) { PBL_LOG(LOG_LEVEL_WARNING, "Service discovery response is invalid length: %"PRIu32, length); return false; } // validate and mark the services as connected uint32_t i; uin...
break; case TimelineResourceSizeSmall: card_attr_id = AttributeIdIconSmall; break; case TimelineResourceSizeLarge: card_attr_id = AttributeIdIconLarge; break; } const bool is_card = (mode == LayoutLayerModeCard); const AttributeId primary_id = is_card ? card_attr_id : Attribute...
time_util_get_midnight_of(info->end_time)
== current_day) ? info->end_time : info->timestamp; } void timeline_layout_get_icon_frame(const GRect *bounds, TimelineScrollDirection scroll_direction, GRect *frame) { const GSize size = timeline_resources_get_gsize(TimelineResourceSizeTiny); const bool is_future = (scro...
{ 838, 150, 195}, { 968, 155, 238}, { 1107, 153, 254}, { 1185, 231, 141}, { 1346, 272, 105}, { 1148, 315, -24}, { 987, 403, -201}, { 999, 290, -55}, { 997, 238, 56}, { 901, 234, 50}, { 856, 269, 26}, { 807, 341, 31}, { 825, 379, 3}, { 805, 357, -43}, { 801, 32...
{ 851, 342, -67}, { 1054, 348, -52}, { 1276, 408, -66}, { 1161, 373, 16}, { 1265, 413, 37}, { 1476, 547, -18}, { 1198, 455, 117}, { 1152, 443, 85}, { 1200, 373, 153}, { 1044, 303, 186}, { 874, 206, 181}, { 811, 173, 194}, { 828, 169, 222}, { 801, 149, 233}, {...
(gap_le_is_advertising_enabled(), true)
; // Simulate stopping advertising because of inbound connection: gap_le_set_advertising_disabled(); s_is_connected_as_slave = true; // Call the connection handler: gap_le_advert_handle_connect_as_slave(); // we should have stopped advertising for reconnection cl_assert_equal_b(gap_le_is_advertising_ena...
= true; } timeline_add(item); timeline_item_destroy(item); } return rv; } // ------------------------------------------------------------------------------------------------ static bool prv_push_summary_pin(time_t pin_time_utc, time_t now_utc, Uuid *existing_uuid, Act...
{ // Make sure we have enough history if ((stats->total_days < insight_settings->reward.min_days_data) || (stats->consecutive_days < insight_settings->reward.continuous_min_days_data)) { INSIGHTS_LOG_DEBUG("History validation failed - total/consecutive days didn't match: " "%"PRIu8"...
// ------------------------------------------------------------------------------------------------ static TimelineItem *prv_create_day_1_insight(time_t notif_time) { if (activity_prefs_get_health_app_opened_version() != 0) { // The user already knows about the Health app return NULL; } AttributeList n...
anymotion interrupt fires! prv_write_reg(BMI160_REG_PMU_TRIGGER, 0x0); // Enable the anymotion detection interrupt uint8_t en_val = BMI160_INT_MAP_ANYMOTION_EN_MASK; prv_read_modify_write(BMI160_REG_INT_MAP_0, en_val, en_val); // Actually enable the anymotion interrupt uint8_t int_en = (BMI160_INT_EN_0_AN...
{ prv_enable_double_tap_detection(); }
else { prv_disable_double_tap_detection(); } s_double_tap_detection_enabled = on; } bool accel_get_shake_detection_enabled(void) { return s_shake_detection_enabled; } bool accel_get_double_tap_detection_enabled(void) { return s_double_tap_detection_enabled; } void accel_toggle_power_mode(void) { stat...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
printf(" line : %d\n", error->line_number)
; if (error->description != NULL) printf(" description: %s\n", error->description); printf(" ...\n"); } static void clar_print_ontest(const char *test_name, int test_number, int failed) { printf("%s %d - %s\n", failed ? "not ok" : "ok", test_number, test_name ); clar_report_errors(); } static void c...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
contacts_get_contact_by_uuid(&uuid)
; cl_assert(contact); cl_assert_equal_m(&contact->id, &uuid, UUID_SIZE); cl_assert_equal_i(contact->flags, 0); cl_assert_equal_i(contact->attr_list.num_attributes, 1); cl_assert_equal_i(contact->addr_list.num_addresses, 1); contacts_free_contact(contact); }
(found_start_direction) { continue; } // use the first non-horizontal path segment's direction as the start direction if (rot_end.y.integer != rot_start.y.integer) { start_is_down = rot_end.y.integer > rot_start.y.integer; found_start_direction = true; } rot_end = rot_start; } ...
{ intersections_down[intersection_down_count].x.raw_value = x.raw_value; intersections_down[intersection_down_count].delta = delta; intersection_down_count++; }
else { intersections_up[intersection_up_count].x.raw_value = x.raw_value; intersections_up[intersection_up_count].delta = delta; intersection_up_count++; } } last_is_down = is_down; } } // sort the intersections sortIntersections(intersec...
s_fb; GContext *graphics_context_get_current_context(void) { return &s_ctx; } void test_workout_active__initialize(void) { s_hrm_is_present = true; s_workout_data = (WorkoutData) {}; s_sports_data = (SportsData) {}; // Setup graphics context framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS}); fr...
health_util_get_pace(84, 0)
, .bpm = 92, .hr_zone = 0, }; WorkoutActiveWindow *active_window = workout_active_create_for_activity_type( ActivitySessionType_Open, &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_...
anager_event_loop_upkeep(); cl_assert_equal_i(modal_manager_get_properties(), ModalProperty_Exists | ModalProperty_CompositorTransitions | ModalProperty_RenderRequested); cl_assert_equal_i(windows[2][0]->on_screen, true); cl_assert_equal_i(windows[2][0]->is_click_configured...
(windows[2][1]->on_screen, true)
; cl_assert_equal_i(windows[2][1]->is_click_configured, false); cl_assert_equal_i(windows[1][0]->on_screen, true); cl_assert_equal_i(windows[1][0]->is_click_configured, false); cl_assert_equal_p(s_last_click_configured_window, windows[3][1]); for (ModalPriority idx = ModalPriorityMin; idx < NumModalPrioritie...
ctZero); Layer *aaaa = layer_create(GRectZero); Layer *ab = layer_create(GRectZero); Layer *b = layer_create(GRectZero); layer_add_child(a, aa); layer_add_child(aa, aaa); layer_add_child(aaa, aaaa); layer_add_child(a, ab); a->next_sibling = b; stack[0] = a; // go to child if possible Layer *act...
layer_init(layers[i], &GRectZero)
; } layer_set_frame(&parent, &GRect(0, 0, 20, 20)); layer_set_frame(&child_a, &GRect(0, 0, 10, 10)); layer_set_frame(&child_b, &GRect(2, 2, 6, 6)); layer_set_frame(&child_c, &GRect(10, 10, 10, 10)); layer_set_frame(&child_d, &GRect(2, 2, 6, 6)); layer_set_frame(&child_e, &GRect(10, 10, 10, 10)); layer_s...
aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1); graphics_context_set_text_color(&ctx, GColorBlack); graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_0_0, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_jja00.${...
setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1)
; graphics_context_set_text_color(&ctx, GColorBlack); graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NEG_W, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); cl_check(framebuffer_is_empty("draw_text_neg_w", fb, GColorWhite)); setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_T...
lowModeTrailingEllipsis, GTextAlignmentLeft, NULL); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_ajj22.${BIT_DEPTH_NAME}.pbi")); // Test when clipping/drawing and text bounds are all at (2, 0) - no negative offset setup_test_aa_sw(&ctx, fb, RECT_TEXT_2_0, RECT_TEXT_2_0, false, 1); graphics_context_set_...
(&ctx, 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...
launcher_task_add_callback(prv_launch_app_cb, (void*) mfg_als_app_get_info())
; } static void prv_select_bt_sig_rf(int index, void *context) { launcher_task_add_callback(prv_launch_app_cb, (void*) mfg_bt_sig_rf_app_get_info()); } static void prv_select_hrm(int index, void *context) { launcher_task_add_callback(prv_launch_app_cb, (void*) mfg_hrm_app_get_info()); } static void prv_select_ce...
/* * 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...
snprintf(data->temp_range_text, sizeof(data->temp_range_text), "%d - %d", data->min_temp, data->max_temp)
; text_layer_set_text(data->temp_range_layer, data->temp_range_text); layer_mark_dirty(window_get_root_layer(data->window)); } // ------------------------------------------------------------------------------- static void handle_second_tick(struct tm* tick_time, TimeUnits units_changed) { int32_t reading = temp...
beginning of the storage. uint8_t *storage; } buffer; } AppInboxNode; typedef struct AppInboxConsumerInfo { AppInboxServiceTag tag; AppInboxMessageHandler message_handler; AppInboxDroppedHandler dropped_handler; uint32_t num_failed; uint32_t num_success; uint8_t *it; uint8_t *end; } AppInboxConsum...
{ if (PRIVILEGE_WAS_ELEVATED) { if (info_out) { syscall_assert_userspace_buffer(info_out, sizeof(*info_out)); } } return prv_get_consumer_info(tag, info_out); }
static void prv_consume(AppInboxConsumerInfo *consumer_info); DEFINE_SYSCALL(void, sys_app_inbox_service_consume, AppInboxConsumerInfo *consumer_info) { if (PRIVILEGE_WAS_ELEVATED) { syscall_assert_userspace_buffer(consumer_info, sizeof(*consumer_info)); } prv_consume(consumer_info); } ///////////////////...
bool success = false; const char *sentence = "Foo bar"; const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, sentence); cl_assert(success); const TextBoxParams text_box_params = (TextBoxParams) { .utf8_bounds = &utf8_bounds, // Width for first word only: .box = (GRect) { (GPoint) { 0, 0 }...
(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params))
; cl_assert(line.height_px == 10); cl_assert(line.width_px == 2 * HORIZ_ADVANCE_PX); cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params)); cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params)); } //! Multi-line, multi-word, multi-hyphenation void...
t r = GRect(0, 5, 0, 0); grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center, 0, 5); cl_assert_fixedS16_3(radius, 0); // 1 pixel width means radius of 0 r = GRect(-1, -5, 1, 1); grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center, -1, -5);...
cl_assert_equal_i(s_angle_end, TRIG_MAX_ANGLE)
; graphics_fill_oval(NULL, GRect(0, 0, 0, 0), GOvalScaleModeFillCircle); cl_assert_gpoint_precise(s_center, 0.0, 0.0); cl_assert_fixedS16_3(s_radius_outer, 0.0); cl_assert(s_radius_inner.integer <= 0); cl_assert_equal_i(s_angle_start, 0); cl_assert_equal_i(s_angle_end, TRIG_MAX_ANGLE); } void graphics_fil...
t(detected_reset_of_elapsed); // Make sure the frame reached the "to" state cl_assert_equal_point(layer.frame.origin, to_r.origin); // This should return a NULL context now if the animation got destroyed cl_assert(animation_get_context(h) == NULL); // Make sure no animations exist cl_assert_equal_i(prv_c...
(prv_count_handler_entries(&s_started_handler_calls, a), 1)
; cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1); // Make sure no animations exist cl_assert_equal_i(prv_count_animations(), 0); } // -------------------------------------------------------------------------------------- // Test setting a play count of 0 void test_animation__basi...
PBL_LOG(LOG_LEVEL_INFO, "Music server connected: %s", implementation->debug_name); } else { PBL_LOG(LOG_LEVEL_ERROR, "Server <0x%p> connected, but another <0x%p> is already registered", implementation, s_music_ctx.implementation); } } else { if (s_music_ctx.implementation == implemen...
prv_put_pos_changed_event()
; } void music_update_track_duration(uint32_t track_duration_ms) { mutex_lock_recursive(s_music_ctx.mutex); s_music_ctx.track_length_ms = track_duration_ms; mutex_unlock_recursive(s_music_ctx.mutex); prv_put_pos_changed_event(); } void music_get_now_playing(char *title, char *artist, char *album) { mutex...
te/app_state/app_state.h" #include "services/common/touch/touch_event.h" #include "system/passert.h" #include "util/list.h" #include <stddef.h> T_STATIC bool prv_process_all_recognizers(RecognizerManager *manager, RecognizerListIteratorCb iter_cb, void *context) { // Proce...
prv_process_all_recognizers(manager, prv_is_active_and_triggered, &triggered)
; return triggered; } static void prv_process_layer_tree_recognizers(RecognizerManager *manager, Layer *top_layer, Layer *bottom_layer, RecognizerListIteratorCb iter_cb) { Layer *root = window_get_root_layer(manager->wind...
/* * 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 (node == NULL) { return 0; } uint32_t count = 1; while ((node = node->next) != NULL) { ++count; } return count; }
uint32_t list_count_to_head_from(ListNode *node) { if (node == NULL) { return 0; } uint32_t count = 1; while ((node = node->prev) != NULL) { ++count; } return count; } uint32_t list_count(ListNode* node) { return list_count_to_tail_from(list_get_head(node)); } ListNode* list_get_at(ListNode *n...
calling dict_write_end() won't screw up the count and will just work: iter->dictionary->count = 0; } Tuple * const next_cursor = cursor_after_tuple_with_data_length(iter, data_length); if (iter->end < (void *)next_cursor) { return DICT_NOT_ENOUGH_STORAGE; } iter->cursor->key = key; iter->cursor->le...
{ return NULL; }
iter->cursor = iter->dictionary->head; return get_safe_cursor(iter); } uint32_t dict_calc_buffer_size(const uint8_t count, ...) { uint32_t total_size = sizeof(Dictionary); if (count == 0) { return total_size; } va_list vl; va_start(vl, count); for (unsigned int i = 0; i < count; ++i) { total_s...
= cursor->h; cell_layer->frame.origin.y = cursor->y; // Callback to get the shared cell instance filled with data: // Save current drawing state: GDrawState prev_state = graphics_context_get_drawing_state(ctx); // Translate the drawing_box to the bounds of the layer: ctx->draw_state.drawing_box.origin.y...
{ it->row_callback_after_geometry(it); }
if (it->should_continue == false) { return; } // Next row: it->cursor.sep = prv_menu_layer_get_separator_height(it->menu_layer, &it->cursor.index); it->cursor.y = it->cell_bottom_y; // Bottom of previous cell is y of the next cell // Don't leave space for the seperator for...
SCALL(void, sys_app_outbox_send, const uint8_t *data, size_t length, AppOutboxSentHandler sent_handler, void *cb_ctx) { if (PRIVILEGE_WAS_ELEVATED) { // Check that data is in app space: syscall_assert_userspace_buffer(data, length); } const AppOutboxSenderDef *def = prv_find_def_and_tag_by...
{ PBL_ASSERTN(!prv_consumer_for_tag(tag)); AppOutboxConsumer *consumer = &s_app_outbox_consumer[tag]; consumer->message_handler = message_handler; consumer->consumer_data_length = consumer_data_length; consumer->consumer_task = consumer_task; }
/* * 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...
(VibeScoreId_Pulse)
terval_slots = 160, .max_interval_slots = 240, .duration_secs = 1, }, { .min_interval_slots = 320, .max_interval_slots = 480, .duration_secs = 1, }, { .min_interval_slots = GAPLE_ADVERTISING_SILENCE_INTERVAL_SLOTS, .max_interval_slots = GAPLE_ADVERTISING_SILENCE...
(s_unscheduled_job, job)
; // Expect no advertisement timer cl_assert_equal_i(regular_timer_seconds_count(), 0); free(ad); } void test_gap_le_advert__job_round_robin(void) { GAPLEAdvertisingJobTerm advert_term = { .min_interval_slots = 160, .max_interval_slots = 320, .duration_secs = GAPLE_ADVERTISING_DURATION_INFINITE, ...
GettingStartedButtonComboState button_combo_state; } RecoveryFUAppData; // Unfortunately, the event_service_client_subscribe doesn't take a void *context... static RecoveryFUAppData *s_fu_app_data; static void prv_update_name_text(RecoveryFUAppData *data); ////////////////////////////////////////////////////////////...
(GColorRed, GColorWhite)
;; #endif } else { url_string = "pebble.com/app"; background = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite); } // Create the icon KinoReel *icon_reel = kino_reel_create_with_resource(icon_res_id); if (!icon_reel) { PBL_CROAK("Couldn't create kino reel"); } // Position the icon kino_area...
/* * 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(byte, 0xfd); ++count; }
deadlock trying to send an event to itself: // 1.) KernelMain must never enqueue more than MAX_FROM_KERNEL_MAIN_EVENTS events to itself while processing another // event. // 2.) The ONLY task that posts events to s_from_kernel_event_queue is the KernelMain task. // 3.) Whenever KernelMain wants to post an event to...
xQueueSendToBackFromISR(queue, event, &should_context_switch)
_aa(ctx, y, x1_rounded, x2_rounded); } // This function will replicate source column in given area T_STATIC void prv_replicate_column_row_raw(GBitmap *framebuffer, int16_t src_x, int16_t dst_x1, int16_t dst_x2) { const GRect column_to_replicate = (GRect) { .origin = GPo...
{ const int rshift = delta_bits; const int lshift = 8 - rshift; for (int i = 0; i < bytes - 1; i++) { buf[i] = (buf[i] >> rshift) | (buf[i+1] << lshift); } if (patch_garbage) { buf[bytes - 1] >>= rshift; buf[bytes - 1]...
_S16_3){}; s_radius_outer = (Fixed_S16_3){}; } void test_graphics_circle__gpoint_from_polar_returns_zero_for_null(void) { const uint16_t radius = 5; const GPoint result = gpoint_from_polar_internal(NULL, radius, 0); cl_assert_equal_gpoint(result, GPointZero); } void test_graphics_circle__gpoint_from_polar_ret...
grect_centered_internal(&p1, GSize(2, 2))
me_tm = s_init_time_tm; time_tm.tm_mday += 1; time_t utc_sec = mktime(&time_tm); rtc_set_time(utc_sec); prv_activity_init_and_set_enabled(true); ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricStepCount, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){0, 100, 0, 0, 0, 0, 0})); ASSERT_EQUAL_METRIC_HISTORY(Activity...
prv_feed_cannned_accel_data(SECONDS_PER_MINUTE * ACTIVITY_SESSION_UPDATE_MIN, 0, ActivitySleepStateAwake)
; ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricStepCount, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){100, 0, 0, 0, 0, 0, 0})); ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricSleepTotalSeconds, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){2 * SECONDS_PER_MINUTE, 0, 0, 0, 0, 0, 0})); ASSERT_EQUAL_METRIC_HISTORY(Act...
/* * 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 (isdigit(c)) return c - '0'; if (isupper(c)) return (c - 'A') + 10; if (islower(c)) return (c - 'a') + 10; return -1; }
static uint8_t ascii_hex_to_uint(const uint8_t msb, const uint8_t lsb) { return 16 * ascii_hex_to_int(msb) + ascii_hex_to_int(lsb); } uintptr_t str_to_address(const char *address_str) { char *endptr; uintptr_t address = strtoul(address_str, &endptr, 0); if (*endptr != '\0') { // A non-address character encou...
graphics_context_set_fill_color(ctx, bg_color); // Use the original height to determine the cell's corner info const CellCornerInfo cell_corner_info = prv_get_cell_corner_info(original_height); graphics_fill_round_rect(ctx, &rect, cell_corner_info.corner_radius, cell_corner_...
graphics_context_set_fill_color(ctx, selection_layer->active_background_color)
; const CellCornerInfo cell_corner_info = prv_get_cell_corner_info(rect.size.h); graphics_fill_round_rect(ctx, &rect, cell_corner_info.corner_radius, cell_corner_info.corner_mask); } static void prv_draw_text(SelectionLayer *selection_layer, GContext *ctx) { int16_t start_x_offset = pr...
ge_file_size); printf("the fd is: %d\n", fd); cl_assert(fd >= 0); cl_assert(pfs_write(fd, bigbuf, large_file_size) == large_file_size); cl_assert(pfs_close(fd) == S_SUCCESS); } free(bigbuf); // now read back the large files curr = 0; for (int i = 0; i < 2; i++) { snprintf(file_large, size...
{ int files_written = run_full_flash_region_test(); if ((i % 2) == 0) { pfs_init(true); // simulate a reboot } // delete all files for (int i = (files_written - 1); i >= 0; i--) { char name[128]; snprintf(name, sizeof(name), "file%d", i); cl_assert_equal_i(pfs_remove(name), S...
LE_SET_TIME_EVENT, .set_time_info = { .utc_time_delta = new_utc_time - orig_utc_time, .gmt_offset_delta = new_gmt_offset - orig_gmt_offset, .dst_changed = false, } }; event_put(&e); } static void prv_handle_set_utc_and_timezone_msg(TimezoneCBData *tz_data) { tz_data->utc_time = ntohl(tz...
clock_is_24h_style()
; const char *format; // [INTL] you want to have layout resources that specify time formatting, // and be able to set a default one for each locale. if (is24h) { format = "%u:%02u"; } else { if (hours < 12) { format = add_space ? "%u:%02u AM" : "%u:%02uAM"; } else { format = add_space...
att_handle) { return false; } if (value_length != sizeof(ATTHandleRange)) { PBL_LOG(LOG_LEVEL_ERROR, "Service Changed Indication incorrect length: %u", value_length); // Pretend we ate the indication. There will be no GAPLECharacteristic in the system that will // match this ATT handle anyway. ...
if (!connection || connection->has_sent_gatt_service_changed_indication) { // Already sent indication once during the lifetime of this connection, don't send again. goto unlock; }
// PRF will always send a "Service Changed" indication: #if !RECOVERY_FW if (s_service_changed_indications_left <= 0) { goto unlock; } #endif PBL_LOG(LOG_LEVEL_INFO, "Indicating Service Changed to remote device"); // Work-around for iOS issue (see comment above), send the indic...
/* * 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_m(&s_cache_buffer[cache_idx], &ZERO_ITEM, sizeof(TestCacheItem))
; } static void prv_test_get_miss(int data_idx) { cl_assert(!prv_get(s_test_data[data_idx].key)); } static void prv_test_get_hit(int data_idx, int cache_idx) { TestCacheItem *data = prv_get(s_test_data[data_idx].key); cl_assert(data); cl_assert_equal_m(data, &s_test_data[data_idx].item, sizeof(TestCacheItem))...
/* * 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...
{ FirmwareDescription firmware_description = firmware_storage_read_firmware_description(FLASH_REGION_SAFE_FIRMWARE_BEGIN); return firmware_storage_check_valid_firmware_description(FLASH_REGION_SAFE_FIRMWARE_BEGIN, &firmware_description); }
const uint8_t * version_get_build_id(size_t *out_len) { if (out_len) { *out_len = TINTIN_BUILD_ID.data_length; } PBL_ASSERTN(TINTIN_BUILD_ID.data_length == BUILD_ID_EXPECTED_LEN); return &TINTIN_BUILD_ID.data[TINTIN_BUILD_ID.name_length]; } void version_copy_build_id_hex_string(char *buffer, size_t buff...
/* * 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...
check_atan2(5, 3)
; check_atan2(10, 10); check_atan2(-153, 217); check_atan2(-28, -133); check_atan2(323, -229); check_atan2(245, 196); check_atan2(65, -3); check_atan2(331, -320); check_atan2(-151, 284); check_atan2(111, -98); check_atan2(-44, -17); check_atan2(269, -356); check_atan2(-78, 268); check_atan2(-2...