prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
= 0; } } // ------------------------------------------------------------------------------------- // Prepare a minute record for writing. Either file_record or dls_record should be non-NULL, // never both. // Returns true if we have enough data to prepare a record, false if not enough data. // We use NOINLINE to re...
prv_prepare_minute_data(uncertain_m, sleep_start_utc, sleep_len_m, file_record, dls_record, force_send)
_process_sleep_data(rtc_get_time()); // cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 2); // // // Fall back asleep, make sure we get the reward // s_data.metric_history[ActivityMetricSleepState][0] = ActivitySleepStateLightSleep; // activity_insights_process_sleep_data(rtc_get_ti...
{ prv_set_step_history_avg(); activity_insights_init(rtc_get_time()); // Make sure that being above average but not active doesn't trigger s_data.steps_per_minute = 0; s_data.metric_history[ActivityMetricStepCount][0] = HIGH_STEPS; prv_minute_update(ACTIVE_MINUTES); cl_assert_equal_i(fake_kernel_services...
void test_activity_insights__activity_reward_trigger(void) { prv_set_step_history_avg(); activity_insights_init(rtc_get_time()); // This would trigger the insights if they weren't disabled s_data.steps_per_minute = 80; s_data.metric_history[ActivityMetricStepCount][0] = HIGH_STEPS; prv_minute_update(ACTI...
/* * 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...
{ // busy loop until the worker is killed psleep(3); }
rtc_timezone_clear(); } void factory_reset_set_reason_and_reset(void) { RebootReason reason = { RebootReasonCode_FactoryResetReset, 0 }; reboot_reason_set(&reason); system_reset(); } static void prv_factory_reset_post(bool should_shutdown) { if (should_shutdown) { enter_standby(RebootReasonCode_Factor...
.size.h / 2 - radial_padding_size; ++i) { const GBitmapDataRowInfoInternal *data_row_infos = g_gbitmap_spalding_data_row_infos; const uint8_t mask = data_row_infos[i].min_x + radial_padding_size; const int offset = i + radial_padding_size; // Draw both row-wise and column-wise to fill in any discontinui...
(layer, ctx, RESOURCE_ID_TEST_IMAGE_VEGGIES)
; break; #endif default: break; } } static void prv_button_click_handler(ClickRecognizerRef recognizer, void *data) { AppData *app_data = app_state_get_user_data(); app_data->test_pattern = (app_data->test_pattern + 1) % NumTestPatterns; layer_mark_dirty(&app_data->window.layer); #if MFG_INFO_RECO...
48}, { 776, 320, -656}, { 768, 312, -640}, // 372 seconds { 776, 304, -640}, { 768, 304, -640}, { 776, 304, -640}, { 768, 312, -664}, { 760, 320, -648}, { 768, 304, -656}, { 768, 320, -664}, { 760, 304, -656}, { 760, 312, -656}, { 768, 296, -648}, { 768, 312, -656...
{ -632, 256, 576}, { -640, 240, 536}, { -688, 320, 480}, { -752, 368, 472}, { -768, 552, 528}, { -760, 648, 512}, { -688, 664, 424}, { -768, 880, 304}, { -728, 680, 280}, { -608, 280, -96}, { -424, 240, -384}, { -448, 384, -616}, { -528, 496, -616}, // 378 seconds...
1", .uuid = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4}, .app_version = { .major = 1, .minor = 1, }, .sdk_version = { .major = 1, .minor = 1, }, .info_flags = 0, .icon_resource_id = 0, }; static const AppDBEntry app2 = { .nam...
(app_two_id, &temp)
); cl_assert_equal_b(true, uuid_equal(&app2.uuid, &temp.uuid)); // check app_db_get_install_id_for_uuid for app 3 memset(&temp, 0, sizeof(AppDBEntry)); AppInstallId app_three_id = app_db_get_install_id_for_uuid(&app3.uuid); cl_assert(app_one_id > 0); cl_assert_equal_i(S_SUCCESS, app_db_get_app_entry_for_in...
CALCULUS const int32_t info_text_y_offset = 36; #else const int32_t info_text_y_offset = PBL_IF_RECT_ELSE(10, 12); #endif KinoLayer *kino_layer = &data->kino_layer; kino_layer_init(kino_layer, &window->layer.bounds); layer_add_child(&window->layer, &kino_layer->layer); #if PLATFORM_ROBERT || PLATFORM_CALCUL...
{ kino_layer_deinit(&data->kino_layer); text_layer_deinit(&data->info_text_layer); text_layer_deinit(&data->device_name_text_layer); text_layer_deinit(&data->code_text_layer); gbitmap_destroy(data->approve_bitmap); gbitmap_destroy(data->decline_bitmap); action_bar_layer_deinit(&data->action_...
s_data_ptr = NULL; } static void prv_show_failure_kernel_main_cb(void *unused) { prv_handle_pairing_complete(false /* success */); } static void prv_pairing_timeout_timer_callback(void *unused) { PBL_LOG(LOG_LEVEL_WARNING, "SSP timeout fired!"); launcher_task_add_callback(prv_show_failure_kernel_main_cb, NU...
.read_length); } else if ((event.type == SmartstrapNotifyEvent) && state->handlers.notified) { state->handlers.notified(attr); } sys_smartstrap_attribute_event_processed(attr); } } // Subscription functions //////////////////////////////////////////////////////////////////////////////// static bo...
(attr, NULL, &attribute_id, NULL)
; return attribute_id; #else return 0; #endif } SmartstrapResult app_smartstrap_attribute_read(SmartstrapAttribute *attr) { #if USE_SMARTSTRAP if (!attr) { return SmartstrapResultInvalidArgs; } SmartstrapConnectionState *state = app_state_get_smartstrap_state(); return sys_smartstrap_attribute_do_reque...
/* * 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_DEBUG, "STT reg_timer_2_callback deleting from callback")
; regular_timer_remove_callback(&s_app_data->reg_timers[0]); } } // ================================================================================= // Try and delete, then re-add a regular timer from its callback static int s_reg_timer_3_callback_count = 0; static void reg_timer_3_callback(void* data) { s_r...
.attr_list = { .num_attributes = ARRAY_LENGTH(attributes), .attributes = attributes, }, .action_group = { .num_actions = ARRAY_LENGTH(actions), .actions = actions, } }; notification_storage_store(&e); TimelineItem r; cl_assert(notification_storage_get(&id, &r)); compare_n...
notification_storage_set_status(&i, TimelineItemStatusActioned)
; cl_assert(notification_storage_get(&i, &r)); cl_assert(uuid_equal(&e.header.id, &r.header.id)); cl_assert_equal_i(e.header.ancs_uid, r.header.ancs_uid); cl_assert_equal_i(TimelineItemStatusActioned, r.header.status); cl_assert_equal_i(e.header.timestamp, r.header.timestamp); cl_assert_equal_i(e.header.lay...
timeline/actions_endpoint.h" #include "system/logging.h" #include "system/passert.h" #include "util/list.h" #include "util/math.h" #include "util/order.h" #include "util/size.h" #include "util/time/time.h" struct TimelineNode { ListNode node; int index; Uuid id; time_t timestamp; uint16_t duration; bool al...
((ListNode *)head)
; while (current) { if (prv_show_event(current, timestamp, today_midnight, TimelineIterDirectionPast, show_all_day_events)) { break; } current = (TimelineNode *)current->node.prev; } return current; } static TimelineNode *prv_find_first_future(TimelineNode *head, time_t timestamp, time_t...
airing_info_out.is_remote_encryption_info_valid); cl_assert_equal_b(PAIRING_INFO.is_local_encryption_info_valid, pairing_info_out.is_local_encryption_info_valid); cl_assert_equal_i(PAIRING_INFO.local_encryption_info.ediv, pairing_info_out.local_encryption_info.ediv); cl_ass...
{ shared_prf_storage_set_ble_pinned_address(&DEVICE_ADDR); BTDeviceAddress addr_buf; bool rv = shared_prf_storage_get_ble_pinned_address(&addr_buf); cl_assert_equal_b(rv, true); cl_assert_equal_m(&DEVICE_ADDR, &addr_buf, sizeof(DEVICE_ADDR)); shared_prf_storage_set_ble_pinned_address(&DEVICE_ADDR); cl_as...
void test_shared_prf_storage_v3__rewrite_pages_and_wrap_around(void) { bool toggle = false; shared_prf_storage_wipe_all(); // Make sure to wrap around a few times and confirm that works for (uint32_t iter = 0; iter < 3; iter++) { toggle = false; // Iterate through all possible pages and keep writing...
true); // Simulate discovery of 1 service: fake_gatt_put_discovery_indication_blood_pressure_service(TEST_GATT_CONNECTION_ID); fake_gatt_put_discovery_complete_event(GATT_SERVICE_DISCOVERY_STATUS_SUCCESS, TEST_GATT_CONNECTION_ID); cl_assert_equal_b(fake_gatt_is_service...
fake_event_clear_last()
nt prv_qsort_activity_test_entry_cb(const void *a, const void *b) { ActivityFileTestEntry *entry_a = (ActivityFileTestEntry *)a; ActivityFileTestEntry *entry_b = (ActivityFileTestEntry *)b; return strcmp(entry_a->name, entry_b->name); } // ======================================================================...
prv_accel_sample_discovery_next(&test_entry[num_tests])
) { StepFileTestEntry *entry = &test_entry[num_tests]; #ifdef STEP_TEST_ONLY if (strcmp(entry->name, STEP_TEST_ONLY)) { continue; } #endif entry->test_idx = num_tests; printf("\n\n========================================================"); printf("\nRunning sample set: \"%s\"\n", entry->...
/* * 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 0; }
-976}, { 160, 16, -952}, { 152, -176, -896}, { 152, -264, -800}, { 136, -408, -840}, { 128, -360, -864}, { 144, -376, -840}, { 152, -376, -864}, { 152, -376, -864}, { 152, -392, -856}, { 144, -408, -864}, { 160, -336, -880}, { 184, -320, -880}, { 168, -400, -864}, ...
{ 184, -384, -848}, { 192, -392, -856}, { 184, -368, -848}, { 200, -384, -864}, { 192, -376, -856}, { 184, -360, -864}, { 184, -384, -856}, { 192, -352, -856}, { 184, -376, -864}, { 192, -392, -848}, // 149 seconds { 152, -408, -888}, { 192, -400, -832}, { 192, -4...
ayer_c; prv_cancel_layer_tree_recognizers(&manager, &layer_a, &layer_c); cl_assert_equal_i(recognizers[0]->state, RecognizerState_Started); cl_assert_equal_i(recognizers[1]->state, RecognizerState_Started); cl_assert_equal_i(recognizers[2]->state, RecognizerState_Started); cl_assert_equal_i(recognizers[3]->st...
recognizer_manager_handle_touch_event(&e, &manager)
has not been written to (both CRC and field data are blank) // 2. The CRC and the written data match static bool prv_field_valid(const uint8_t *field, size_t field_size) { const bool empty = prv_buffer_empty(field, field_size); if (empty) { return true; } const uint32_t field_crc = *(uint32_t*)field; ...
prv_current_page_flash_addr()
, sizeof(*data_out)); if (!prv_valid_struct(data_out)) { PBL_LOG(LOG_LEVEL_WARNING, "Shared PRF Storage sector # %"PRIu32" is corrupted. Invalidating" " and starting a new one", s_valid_page_idx); prv_invalidate_current_page(); memset(data_out, 0xFF, sizeof(*data_out)); }...
/* * 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 (item) { pin_db_insert_item(item); timeline_item_destroy(item); }
} static void prv_create_list_view_and_render(ListViewConfig *config) { pin_db_init(); for (int i = 0; i < (int)ARRAY_LENGTH(config->pins); i++) { if (config->pins[i]) { prv_add_timeline_item(config->pins[i], config->past); } } s_data.model = (TimelineModel) {}; s_data.model.direction = conf...
/* * 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...
(void, sys_profiler_start, void)
{ profiler_start(); } DEFINE_SYSCALL(void, sys_profiler_stop, void) { profiler_stop(); } DEFINE_SYSCALL(void, sys_profiler_print_stats, void) { profiler_print_stats(); } DEFINE_SYSCALL(void, sys_profiler_node_start, ProfilerNode *node) { if (PRIVILEGE_WAS_ELEVATED) { if (!list_contains(g_profiler.nodes,...
} WorkoutActiveWindow *active_window = app_zalloc_check(sizeof(WorkoutActiveWindow)); active_window->layout = WorkoutLayout_TwoStaticAndScrollable; active_window->top_metric = top_metric; active_window->middle_metric = middle_metric; prv_add_scrollable_metrics(active_window, num_scrollable_metrics, scrollab...
workout_active_create_double_layout(top_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics, workout_data, ...
; } } default: return NULL; } } void workout_active_window_push(WorkoutActiveWindow *active_window) { app_window_stack_push(&active_window->window, true); } void workout_active_update_scrollable_metrics(WorkoutActiveWindow *active_window, int num_s...
int id; bool *freed; } TestCacheItem; // Stubs static bool s_free_flags[NUM_TEST_ITEMS]; static CircularCache s_test_cache; static TestCacheItem s_cache_buffer[NUM_TEST_ITEMS]; static TestCacheItem s_test_item[NUM_TEST_ITEMS] = { { .id = 1, .freed = &s_free_flags[0] }, { .id = 2, .freed = &s_free_flags[1] }...
(circular_cache_contains(&s_test_cache, &s_test_item[1]))
{ (void)data; (void)menu_layer; switch (section_index) { default: case 0: return 2; case 1: return 3; case 2: return 4; case 3: return 5; } }
static int16_t get_cell_height_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index, AppData *data) { (void)data; (void)menu_layer; (void)cell_index; // Variable row heights demo: switch (cell_index->row % 3) { default: case 0: return 44; case 1: return 64; case 2: ...
harge_state().charge_percent, 50); // Should be stable by now // Shouldn't update percent (actually, shouldn't even send events.) PBL_LOG(LOG_LEVEL_DEBUG, "Shouldn't be any updates"); PBL_LOG(LOG_LEVEL_DEBUG, "▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼"); fake_battery_set_millivolts(high_mv); periodic_timer_trigger(20); c...
battery_get_charge_state()
32_t max_chunk_bytes, uint8_t *output_buffer) { const uint32_t bytes_per_row = SCREEN_COLOR_DEPTH_BITS * DISP_COLS / 8; const uint32_t cols_per_byte = DISP_COLS / bytes_per_row; uint32_t remaining_chunk_bytes = max_chunk_bytes; uint8_t *output_buffer_with_offset = output_buffer; while (remaining_chunk_bytes...
prv_request_fast_connection(session)
; system_task_add_callback(screenshot_send_next_chunk, state); } void screenshot_protocol_msg_callback(CommSession *session, const uint8_t* msg_data, unsigned int msg_len) { uint8_t sub_command = msg_data[0]; if (sub_command != 0x00) { PBL_LOG(LOG_LEVEL_ERROR, "first byte can't be %u", sub_command); prv...
d 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 "animated_demo.h" #include "applib/app.h" #include "process_state/ap...
(BUTTON_ID_SELECT, (ClickHandler)click_handler)
; window_single_click_subscribe(BUTTON_ID_DOWN, (ClickHandler)click_handler); (void)window; } static void handle_init(void) { AnimatedDemoData *data = (AnimatedDemoData*) app_malloc_check(sizeof(AnimatedDemoData)); data->toggle = false; app_state_set_user_data(data); Window *window = &data->window; wind...
PBL_LOG(LOG_LEVEL_DEBUG, "Rewriting wakeup file")
; // Update settings file removing expired events settings_file_rewrite(&wakeup_settings, prv_update_events_callback, &missed_events); } else { PBL_LOG(LOG_LEVEL_DEBUG, "Not rewriting wakeup file because no entries were found"); } settings_file_close(&wakeup_settings); // If wakeup events were miss...
data previously existed // ... such as a migration from legacy firmware or after the RTC backup // domain had completely powered down) if (tz_info) { prv_handle_timezone_set(tz_info); } if (t) { rtc_set_time(*t); } int new_gmt_offset = time_get_gmtoffset(); int new_utc_time = rtc_get_time(); ...
rtc_get_time()
), }; regular_timer_add_seconds_callback(&s_dst_checker); } void clock_get_time_tm(struct tm* time_tm) { rtc_get_time_tm(time_tm); } size_t clock_format_time(char *buffer, uint8_t size, int16_t hours, int16_t minutes, bool add_space) { if (size == 0 || buffer == NULL) { return 0; ...
L; } static TimelineItem item1 = { .header = { .id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4}, .parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0x01}, .timestamp = 1, ...
cl_assert(!is_dirty)
; dirty_list = pin_db_get_dirty_list(); cl_assert(!dirty_list); } void test_pin_db__set_status_bits(void) { pin_db_insert_item(&item1); TimelineItem item; cl_must_pass(pin_db_read_item_header(&item, &item1.header.id)); cl_assert_equal_i(item.header.status, 0); cl_must_pass(pin_db_set_status_bits(&item1...
ocess_send_queue(s_app_session_ptr); assert_consumed(AppMessageSenderErrorSuccess, 1); app_free(outbox_data); } void test_app_message_sender__auto_select_js_app(void) { s_process_md.allow_js = true; AppMessageAppOutboxData *outbox_data = prv_create_and_send_outbox_message(NULL /* auto-select */, ALLOWED...
memset(bytes_out, 0xff, length)
; // Consume byte by byte: for (int c = 0; c < length; ++c) { // Shift offset byte by byte: for (int o = 0; o < (length - c); ++o) { size_t length_to_copy = (length - c - o); cl_assert_equal_i(length_to_copy, comm_session_send_queue_copy(s_app_session_ptr, o, ...
on(uint32_t notification_uid, uint8_t action_id) { } void notifications_handle_notification_action_result( PebbleSysNotificationActionResult *action_result) { } void notification_storage_set_status(const Uuid *id, uint8_t status) { } void notifications_handle_notification_acted_upon(Uuid *notification_id) { re...
fake_pbl_malloc_clear_tracking()
; for (unsigned int i = 0; i < ARRAY_LENGTH(s_items); ++i) { cl_assert_equal_i(pin_db_insert_item(&s_items[i]), 0); } cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0); } void test_timeline_model__cleanup(void) { } // Tests /////////////////////////// static int s_correct_order[] = {0, 4, 5, 2, 1, 3};...
, size_t length, uint32_t timeout_ms) { SendBuffer *sb = comm_session_send_buffer_begin_write(session, endpoint_id, length, timeout_ms); if (!sb) { return false; } comm_session_send_buffer_write(sb, data, length); comm_session_send_buffer_end_write(sb); return true; } CommSession * comm_session_open(Tr...
{ // Already writing, fake doesn't support multiple tasks trying to write at the same time return NULL; }
0x00, 0xff, 0xff, 0xff, 0xff, /* bytes 2960 - 2976 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* bytes 2976 - 2992 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bytes 2992 - 3008 */ 0xff, 0xff, 0x00, 0...
(pug_size, sizeof(pug))
; uint8_t pug_buf[pug_size]; cl_assert_equal_i( resource_load_byte_range_system(SYSTEM_APP, RESOURCE_ID_PUG, 0, pug_buf, pug_size), pug_size); for (unsigned int i = 0; i < sizeof(pug); i++) { cl_assert(pug[i] == pug_buf[i]); } } static const uint32_t resource_bank = 5; static const uint32_t no_...
= animation_sequence_create(a, b, NULL); cl_assert(seq != NULL); animation_set_delay(seq, delay_seq); prv_clear_handler_histories(); uint64_t start_ms = prv_now_ms(); animation_schedule(seq); // Test the elapsed int32_t elapsed_ms; animation_get_elapsed(seq, &elapsed_ms); cl_assert_equal_i(elaps...
{ #ifdef TEST_INCLUDE_COMPLEX const int duration_a = 300; const int delay_a = 100; const int duration_b = 500; const int delay_b = 200; const int delay_spawn = 150; int duration_total = MAX(duration_a + delay_a, duration_b + delay_b) + delay_spawn; // Create 2 test animations Animation *a = prv_create...
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0); // Start A prv_advance_to_ms_with_timers(start_ms + delay_spawn + delay_a + 2 * MIN_FRAME_INTERVAL_MS); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_st...
, &r)); compare_notifications(&e3, &r); free(r.allocated_buffer); } void test_notification_storage__remove_add_compress(void) { time_t timestamp = 0x10000000; TimelineItem e = { .header = { .type = TimelineItemTypeNotification, .status = 0, .ancs_uid = 0, .layout = LayoutIdGeneric, ...
(notification_storage_get(&uuids[j], &r), false)
; } } void test_notification_storage__find_ancs_id(void) { Uuid i1; uuid_generate(&i1); TimelineItem e1 = { .header = { .id = i1, .type = TimelineItemTypeNotification, .status = 0, .ancs_uid = 0, .layout = LayoutIdGeneric, .timestamp = 0x53f0dda5, }, .attr_list =...
ion_toggle.h" #include "kernel/events.h" #include "resource/resource.h" #include "services/common/new_timer/new_timer.h" #include "services/common/system_task.h" #include "services/common/system_task.h" #include "services/normal/filesystem/pfs.h" #include "services/normal/notifications/alerts_preferences_private.h" #in...
pfs_format(false)
; rtc_set_time(s_thursday_00_00); alerts_preferences_init(); do_not_disturb_init(); do_not_disturb_set_manually_enabled(false); do_not_disturb_set_schedule_enabled(WeekdaySchedule, false); do_not_disturb_set_schedule_enabled(WeekendSchedule, false); if (do_not_disturb_is_smart_dnd_enabled()) { do_no...
ListNode *found_node, void *data) { return uuid_equal(&((NotifList*)found_node)->notif.id, (Uuid *)data); } static NotifList *prv_find_listnode_for_notif(Uuid *id) { return (NotifList*) list_find((ListNode *) s_presented_notifs, prv_filter_presented_notification_by_id, id); } Uuid ...
callback(&head->notif.id, head->notif.type, cb_data)
(const uint8_t *) s_client_reset_request, s_client_reset_request_size, GAPLEClientKernel, false /* is_response_required */); } static void prv_assert_sent_reset_complete(BLECharacteristic characteristic) { struct PA...
(s_characteristics[0][PPoGATTCharacteristicMeta], (const uint8_t *) &s_meta_v0_system, sizeof(s_meta_v0_system), BLEGATTErrorSuccess)
; cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true); ppogatt_handle_read_or_notification(s_characteristics[1][PPoGATTCharacteristicMeta], (const uint8_t *) &s_meta_v0_app, sizeof(s_meta_v0_app), BLEGATTErrorS...
/* * 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...
(&timer, &average_ms)
; cl_assert_equal_i(num_intervals, 3); cl_assert_equal_i(average_ms, 1015); } void test_interval_timer__invalid_samples(void) { IntervalTimer timer; interval_timer_init(&timer, 800, 1200, 2); uint32_t num_intervals; uint32_t average_ms; interval_timer_take_sample(&timer); fake_rtc_increment_time_ms(...
/* * 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(output)
; cl_assert(*output == 0); // check that entry 1 got evicted output = lru_cache_get(&s_cache, 1); cl_assert(output == NULL); // check that the others are still around for (int i = 2; i <= CACHE_BUFFER_SIZE / (sizeof(CacheEntry) + sizeof(uint32_t)); ++i) { output = lru_cache_get(&s_cache, i); // ch...
/* * 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...
(SCENE_ERROR)
; if (prv_wait_busy()) { prv_screen_on(); return true; } else { return false; } } void boot_display_screen_off(void) { prv_screen_off(); prv_draw_scene(SCENE_BLACK); prv_wait_busy(); }
"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 <string.h> #include <stdlib.h> #include "drivers/flash.h" #include "flash_region/flash_region.h" #include "se...
{ snprintf(file_small, sizeof(file_small), "file%d", i); uint8_t buf[PFS_SECTOR_SIZE * 2]; uint8_t bufcmp[PFS_SECTOR_SIZE * 2]; memset(&bufcmp[0], i, sizeof(bufcmp)); int fd = pfs_open(file_small, OP_FLAG_READ, FILE_TYPE_STATIC, sizeof(buf)); cl_assert(fd >= 0); cl_assert_equal_i(pfs_rea...
} void test_pfs__garbage_collection_when_full(void) { char file_name[10]; int num = 0; int fd; while (1) { snprintf(file_name, sizeof(file_name), "file%d", num++); fd = pfs_open(file_name, OP_FLAG_WRITE, FILE_TYPE_STATIC, sizeof(file_name)); cl_assert((fd >= 0) || (fd == E_OUT_OF_STORAGE)); if...
ip"))); // Odd rows of different lengths setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 3), MAX_NUM_COLS + 4); graphics_draw_horizontal_line_dotted(&ctx, GPo...
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS)
; graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 3), MAX_NUM_COLS + 4); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 7), 1); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2); graphics_draw_horizontal_line_dotted(&ctx, GPoint...
d) { prv_insert_extra_case_items(); Iterator iterator = {0}; TimelineIterState state = {0}; TimelineNode *head = NULL; timeline_init(&head); cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast, s_feb_5_midnight + 11 * 60 * 60), 0); cl_assert(uuid_equal(&state.pin...
(uuid_equal(&state.pin.header.id, &s_items[0].header.id))
header, void* data), void* data, int fd) { for (;;) { int result = pfs_read(fd, (uint8_t *)header, sizeof(*header)); // Restore flags & status header->common.flags = ~header->common.flags; header->common.status = ~header->common.status; if ((result < 0) || (uuid_is_invalid(&header->common.id)))...
{ int result = pfs_read(iter_state->fd, (uint8_t *)&iter_state->header, sizeof(iter_state->header)); // Restore flags & status iter_state->header.common.flags = ~iter_state->header.common.flags; iter_state->header.common.status = ~iter_state->header.common.status; if ((result == E_RANGE) || (uuid_is_invali...
static bool prv_rewrite_iter_next(NotificationIterState *iter_state) { int result = 0; result = pfs_read(iter_state->fd, (uint8_t*)&iter_state->header, sizeof(iter_state->header)); // Restore flags & status iter_state->header.common.flags = ~iter_state->header.common.flags; iter_state->header.common.statu...
4}, { 352, 1000, 128}, { 256, 1096, 136}, { 296, 1152, 448}, { 104, 1368, 376}, { 304, 1192, 344}, { 376, 872, 232}, { 328, 792, 232}, { 240, 808, 328}, { 240, 776, 304}, { 272, 752, 336}, { 304, 800, 304}, { 320, 840, 288}, { 344, 840, 296}, { 400, 864, 232}, ...
{ 120, 976, 184}, { 160, 936, 152}, { 192, 912, 160}, { 232, 888, 176}, { 264, 920, 168}, { 272, 912, 160}, { 280, 896, 144}, { 296, 880, 128}, { 320, 872, 104}, { 312, 912, 88}, { 304, 912, 56}, { 320, 936, 48}, { 296, 992, 56}, { 344, 1048, 16}, { 280, 1224,...
// 66 seconds { 232, 960, -32}, { 224, 816, 48}, { 296, 760, 40}, { 344, 760, 48}, { 384, 792, 64}, { 440, 808, 32}, { 464, 840, -16}, { 504, 728, -24}, { 440, 1032, 152}, { 400, 1032, 360}, { 312, 1592, 472}, { 152, 1176, 384}, { 392, 928, 224}, { 408, 872, ...
age_open() called with app_message_outbox_size_maximum()."); APP_LOG(LOG_LEVEL_INFO, "This consumes %"PRIu32" bytes of heap memory, potentially more in the future!", (uint32_t)size_maximum); } if (size_outbound == 0) { return APP_MSG_OK; } // Extra space needed by App Message pr...
{ // Reply was received and handled in the mean time, or app message was closed. return; }
uint32_t flags) { s_num_timer_register_calls++; s_snooze_timer_timeout_ms = timeout_ms; return true; } bool new_timer_stop(TimerID timer_id) { s_snooze_timer_timeout_ms = 0; return true; } void new_timer_delete(TimerID timer_id) { s_snooze_timer_timeout_ms = 0; } /////////////////////////////////...
{ AlarmId id; // It's currently Thursday @ 00:00 bool just_once_schedule_thursday[7] = {false, false, false, false, true, false, false}; id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_JUST_ONCE }); prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_JUST_ONCE, just_once_schedule...
void test_alarm__alarm_create_recurring_custom(void) { AlarmId id; bool custom_schedule1[7] = {true, false, true, false, false, true, true}; id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &custom_schedule1 }); prv_assert_alarm_config(id, 3, 14, false, AL...
t_session = NULL; DataLoggingSessionRef s_event_session = NULL; static void prv_schedule_retry(); static void prv_create_event_session_cb(void *ignored); static void prv_reset_local_session_ptrs(void) { s_device_heartbeat_session = NULL; s_app_heartbeat_session = NULL; s_event_session = NULL; } static void prv...
analytics_heartbeat_kind_data_size(ANALYTICS_HEARTBEAT_KIND_APP)
; s_app_heartbeat_session = prv_create_dls(ANALYTICS_BLOB_KIND_APP_HEARTBEAT, size); if (!s_app_heartbeat_session) return; } // Tell the watchdog timer that we are still awake. dls_create() could take up to 4 seconds if // we can't get the ispp send buffer system_task_watchdog_feed(); analytics_exte...
tionAttributesMsg*)s_complete_dict)->notification_uid; const uint32_t chunked_dict_uid = ((GetNotificationAttributesMsg*)s_chunked_dict_part_one)->notification_uid; const uint32_t message_size_attr_dict_uid = ((GetNotificationAttributesMsg*)s_message_size_attr_dict)->notification_uid; const uint32_t invalid_dict_...
(ARRAY_LENGTH(s_this_message_has_no_content_response), (uint8_t*) s_this_message_has_no_content_response)
; s_num_ds_notifications_received++; } else if (uid == s_invalid_param_uid) { ancs_handle_write_response(0, 0xA2); s_num_ds_notifications_received++; } else if (uid == multiple_complete_dict_uid) { prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_multiple_complete_dicts), (uint8_t*) s_multiple_com...
tt_set_start_return_value(BTGATT_ERROR_INVALID_PARAMETER); // Fire the watchdog timer: const TimerID watchdog_timer = bt_driver_gatt_get_watchdog_timer_id(); stub_new_timer_fire(watchdog_timer); // Stopping did not fail, but restarting did. In this case we need to generate an event that // the discovery pro...
cl_assert_equal_b(fake_gatt_is_service_discovery_running(), true)
; // BP service was discovered fake_gatt_put_discovery_indication_blood_pressure_service(TEST_GATT_CONNECTION_ID); // start another job, should be pended gatt_client_discovery_discover_range(connection, &range); fake_gatt_put_discovery_complete_event(GATT_SERVICE_DISCOVERY_STATUS_SUCCESS, ...
start_ms = prv_now_ms(); prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS); // Should not have run at all cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 0); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0); cl_assert_equal_...
(prv_count_handler_entries(&s_started_handler_calls, seq), 1)
; cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 0); // Complete A and start B prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS + 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_...
er_Unchecked, UserSpaceBuffer_Valid, UserSpaceBuffer_Invalid, UserSpaceBuffer_NotRun, } UserSpaceBufferValidity; static UserSpaceBufferValidity s_addr_result; uint32_t dcache_line_size(void) { return cl_mock_type(size_t); } uint32_t icache_line_size(void) { return cl_mock_type(size_t); } bool dcache_is_ena...
(s_flush_size, 0x10)
; cl_assert_equal_i(s_invalidate_addr, 0x00); cl_assert_equal_i(s_invalidate_size, 0x10); cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Unchecked); } void test_cpu_cache__without_icache(void) { cl_will_return(icache_is_enabled, false); cl_will_return(dcache_is_enabled, true); cl_will_return(icache_lin...
/* * 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_DEBUG, "Dialog: Invalid reboot reason")
; goto clear; }; switch (reason.code) { // Normal stuff case RebootReasonCode_Unknown: PBL_LOG(LOG_LEVEL_ALWAYS, "Dialog: Rebooted due to Unknown."); break; case RebootReasonCode_Shutdown: // FIXME PBL-38181: For some reason, the reboot reason shutdown never gets persisted/recover...
morphs to the size of the next cell + padding causing the illusion that the selector // overshoot it's mark (it will settle back to the correct size in a different animation). // This means the the width change is the width difference between the two cells plus padding int total_cell_width_change = next_cell_widt...
if (selection_layer->selected_cell_idx == i && selection_layer->bump_is_upwards) { y_offset -= prv_get_pixels_for_bump_settle(selection_layer->bump_settle_anim_progress); }
// If we are performing an increment or decrement animation then update the // y offset with our progress if (selection_layer->selected_cell_idx == i) { int delta = (selection_layer->bump_text_anim_progress * prv_get_font_top_padding(selection_layer->font)) / 100; ...
alytics_inc(ANALYTICS_APP_METRIC_ACCEL_PEEK_COUNT, AnalyticsClient_CurrentTask); } if (!accel_running()) { return (-1); } mutex_lock_recursive(s_mutex); { if (s_accel_samples_per_update == 0) { // If we are not in FIFO mode, can peek result = (accel_peek(accel_data)); accel_data->...
{ // Read available data. We have to ask for a multiple of state->subsample_numerator uint32_t num_samples; uint32_t ask_for = state->samples_per_update - state->num_samples; ask_for = MAX(ask_for, state->subsample_numerator); ask_for = ask_for / state->subsample_numerator * sta...
// If buffer is full, notify subscriber to process it if (state->num_samples >= state->samples_per_update) { prv_call_data_callback(state); ACCEL_LOG_DEBUG("full set of %d samples for session %d", state->num_samples, (int)state->session_ref); } state = ...
= 0, .to_hour = 6, }; #define PREF_KEY_LEGACY_DND_SCHEDULE_ENABLED "dndEnabled" static bool s_legacy_dnd_schedule_enabled = false; #define PREF_KEY_LEGACY_DND_MANUAL_FIRST_USE "dndManualFirstUse" #define PREF_KEY_LEGACY_DND_SMART_FIRST_USE "dndSmartFirstUse" /////////////////////////////////// //! Variables //////...
SET_PREF_ALREADY_OPEN(PREF_KEY_VIBE_SCORE_INCOMING_CALLS, s_vibe_score_incoming_calls)
; SET_PREF_ALREADY_OPEN(PREF_KEY_VIBE_SCORE_ALARMS, s_vibe_score_alarms); #undef SET_PREF_ALREADY_OPEN } static VibeScoreId prv_return_default_if_invalid(VibeScoreId id, VibeScoreId default_id) { return vibe_score_info_is_valid(id) ? id : default_id; } // Uses the default vibe pattern id if the given score isn'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...
(LOG_LEVEL_DEBUG, "invalid length, num_uuids does not match with the length of message")
/* * 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...
battery_charge_controller_thinks_we_are_charging()
>value; } void test_list__sort_ascending(void) { IntNode bar1 = { .value = 1 }; IntNode bar2 = { .value = 2 }; IntNode bar3 = { .value = 3 }; ListNode* head = 0; head = list_sorted_add(head, &bar2.list_node, (Comparator) sorting_comparator, true); cl_assert(head == &bar2.list_node); head = list_sorted...
list_concatenate(&d, &f)
, &d); cl_assert_equal_p(list_concatenate(&f, &d), &d); cl_assert_equal_p(list_concatenate(NULL, &d), &d); cl_assert_equal_p(list_concatenate(NULL, &f), &d); cl_assert_equal_p(list_concatenate(&f, NULL), &d); cl_assert_equal_p(list_concatenate(&d, NULL), &d); cl_assert_equal_p(list_concatenate(&a, &d), &a...
76}, { -472, 312, -208}, { -472, 320, -152}, { -528, 352, -128}, { -592, 400, -136}, { -616, 424, -120}, // 52 seconds { -608, 456, -144}, { -720, 504, -192}, { -848, 504, -184}, { -840, 472, -144}, { -888, 536, -192}, { -1224, 592, -248}, { -1112, 608, -184}, { -...
{ -1224, 624, -152}, { -1016, 560, -72}, { -1016, 560, -152}, { -936, 424, -32}, { -752, 304, 24}, { -560, 336, -64}, { -504, 232, -16}, { -480, 288, -8}, { -544, 280, 8}, { -616, 320, 16}, { -664, 344, 8}, { -712, 392, -32}, { -1056, 472, -56}, { -1112, 456, 40},...
rv = false; goto unlock; } if (pairing_info_out) { *pairing_info_out = (SMPairingInfo) { .local_encryption_info.ltk = data.l_ltk, .local_encryption_info.ediv = data.l_ediv, .local_encryption_info.rand = data.l_rand, .remote_encryption_info.ltk = data.r_ltk, ...
if (address_out) { *address_out = data.pinned_address; }
rv = true; } unlock: prv_unlock(); return rv; } //! Stores the new BLE Pinned Address in the shared storage. void shared_prf_storage_set_ble_pinned_address(const BTDeviceAddress *address) { prv_lock(); { if (address) { SprfPinnedAddress data = { .pinned_address = *address, }; ...
/* * 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...
(&pstring16_list, WeatherDbStringIndex_ShortPhrase)
_samples != 0; bool use_fifo = num_samples > 1; prv_configure_accel_sampling(enable_int, use_fifo); } int accel_peek(AccelDriverSample *data) { prv_read_curr_accel_data(data); return 0; } void accel_set_shake_sensitivity_high(bool sensitivity_high) { // Configure the threshold level at which the BMI160 will...
prv_disable_operating_mode(AccelOperatingModeDoubleTapDetection)
; } void accel_enable_shake_detection(bool on) { PBL_LOG(LOG_LEVEL_DEBUG, "enable shake detection %d", on); if (s_shake_detection_enabled == on) { // the requested change matches what we already have! return; } prv_update_accel_interrupts(on); if (on) { prv_enable_shake_detection(); } else { ...
UALS_S("s", "8:04:05 PM"); s_clock_is_24h_style = true; EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {hour: 'numeric'});"); ASSERT_JS_GLOBAL_EQUALS_S("s", "20"); EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, " "{hour: 'numeric', hour12: true});"); ASSERT_JS_GLOBAL_EQUALS_S("s...
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {hour: 'numeric'});")
; ASSERT_JS_GLOBAL_EQUALS_S("s", "8 PM"); EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {hour: '2-digit'});"); ASSERT_JS_GLOBAL_EQUALS_S("s", "08 PM"); s_clock_is_24h_style = true; EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {hour: 'numeric'});"); ASSERT_JS_GLOBAL_EQUALS_S("s", "20"); EXECUT...
; const int icon_y = PBL_IF_RECT_ELSE(45, 49); kino_reel_draw(icon, ctx, GPoint(icon_x, icon_y)); const int name_x = drawing_rect.origin.x + PBL_IF_RECT_ELSE(0, (rl_margin / 2)); const int name_y = PBL_IF_RECT_ELSE(107, 109); GRect name_rect = GRect(name_x, name_y, drawing_rect.size.w, 32); graphics_conte...
(action_bar, window)
; summary_window->action_bar_start = gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_START); summary_window->action_bar_more = gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_MORE); action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, summary_window->action_bar_start); action_bar_...
on *b = prv_create_test_animation(); animation_set_duration(b, duration_b); animation_set_delay(b, delay_b); Animation *seq = animation_sequence_create(a, b, NULL); animation_set_delay(seq, delay_seq); animation_set_handlers(seq, handlers, seq); animation_schedule(seq); // The duration of seq should inc...
(spawn, delay_spawn)
; animation_set_handlers(spawn, handlers, spawn); animation_schedule(spawn); // Check the duration and position of the spawn uint32_t duration = animation_get_duration(spawn, true /*delay*/, true /*play_count*/); cl_assert_equal_i(duration, 1300 - 310); int32_t position; animation_get_elapsed(spawn, &p...
--------------------------------------------------------------------------- static bool prv_intialize_sdk_process(PebbleTask task, const PebbleProcessInfo *info, MemorySegment *destination) { if (!prv_verify_checksum(info, destination->start)) { PBL_LOG(LOG_LEVEL_DEBUG, "Calc...
(destination)
py; } else { // Reliable transport went down while waiting to send. // The CommSession has already been closed so simply return without doing // anything further. break; } } } static void prv_reset(Transport *transport) { PBL_LOG(LOG_LEVEL_INFO, "Unimplemented"); } static void prv_...
pulse_reliable_send_begin(PULSE2_PEBBLE_PROTOCOL)
; memcpy(resp, &cb_data->packet, cb_data->packet_length); pulse_reliable_send(resp, cb_data->packet_length); kernel_free(data); } static void prv_pulse_pp_send(uint8_t opcode, uint8_t *data, size_t data_length) { size_t packet_length = sizeof(PulsePPCallbackPacket) + data_length; PulsePPCallbackPacket *cb_da...
gattc_read_by_uuid(conn_idx, start_h, end_h, uuid); prv_pop_if_failing_rv(conn_idx, rv); return rv; } ble_error_t gatt_wrapper_write(uint16_t conn_idx, uint16_t handle, uint16_t length, const uint8_t *value, uintptr_t context_ref, GattReqSource source) { GATT_LOG_DEBUG("gatt_wrapp...
{ case GattRespDestHost: hc_endpoint_gatt_send_write_complete(&addr, evt->handle, status, context_ref); break; case GattRespDestController: PBL_ASSERTN(context_ref); ((gatt_wrapper_write_cb) context_ref)(evt); break; default: break; }
------------------------------------------------------------------------------- static void steps_select_click_handler(ClickRecognizerRef recognizer, void *context) { HealthAPITestAppData *data = (HealthAPITestAppData *)context; data->lap_steps = data->cur_steps; persist_write_int(AppPersistKeyLapSteps, data->l...
steps_update_text(data)
; } else if (event == HealthEventSleepUpdate) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Got sleep update event"); } else if (event == HealthEventHeartRateUpdate) { prv_hr_update_text(data); } else if (event == HealthEventMetricAlert) { HealthValue now_bpm = health_service_peek_current_value(HealthMetricHeart...
workout_service_get_current_workout_info(&workout_data->steps, &workout_data->duration_s, &workout_data->distance_m, &workout_data->bpm, &workout_data->hr_zone)
; if (workout_data->duration_s && workout_data->distance_m) { workout_data->avg_pace = health_util_get_pace(workout_data->duration_s, workout_data->distance_m); } } void workout_data_fill_metric_value(WorkoutMetricType type, char *buffer, size_t buffer_size, ...
"services/normal/notifications/notification_storage.h" #include "services/normal/notifications/notification_types.h" #include "services/normal/notifications/notifications.h" #include "services/normal/timeline/attribute.h" #include "services/normal/timeline/notification_layout.h" #include "services/normal/timeline/swap_...
{ if (regular_timer_is_scheduled(&data->reminder_watchdog_timer_id)) { regular_timer_remove_callback(&data->reminder_watchdog_timer_id); } }
static void prv_cleanup_timers(NotificationWindowData *data) { prv_cleanup_timer(&data->pop_timer_id); prv_cancel_reminder_watchdog(data); prv_cleanup_timer(&data->peek_layer_timer); } static void prv_pop_notification_window(NotificationWindowData *data) { if (data->window_frozen || !s_in_use) { return; ...
2, 592, -96}, { -1248, 344, -72}, { -1288, 248, 0}, { -1536, 304, 96}, // 49 seconds { -1528, 256, 88}, { -1296, 200, 56}, { -1184, 104, 168}, { -1120, -40, 232}, { -1080, 64, 144}, { -1024, 80, 112}, { -1032, 72, 200}, { -1136, -8, 328}, { -1072, -272, 448}, { -1...
{ -1304, 384, 240}, { -1200, 320, 240}, { -1184, 184, 256}, { -1112, 40, 232}, { -1016, -48, 224}, { -872, -64, 208}, { -928, -56, 264}, { -848, -32, 200}, { -1096, 112, 184}, { -1216, 384, -136}, { -1152, 608, -472}, { -1408, 336, 112}, { -1360, -400, 312}, { -12...
// 57 seconds { -960, 1136, -128}, { -360, 424, -184}, { -64, 288, -216}, { 160, 264, -1112}, { 144, -672, -216}, { -88, -608, -384}, { -680, 120, -744}, { -1112, 216, -936}, { -832, 416, -576}, { -808, 712, -544}, { -592, 416, -528}, { -1216, 760, -1136}, { -976...
lback(Layer* me, GContext* ctx) { graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_pixel(ctx, GPoint(-5, 15)); } void outside_x_ny_layer_update_callback(Layer* me, GContext* ctx) { graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_pixel(ctx, GPoint(15, -5)); } void outside_n...
layer_init(&layer, &GRect(0, 0, 10, 10))
----------------- static void steps_base_layer_update_proc(Layer *layer, GContext* ctx) { const GRect bounds = layer_get_bounds(layer); graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, bounds, 0, GCornerNone); // Show the battery level in the outer circle BatteryChargeState charge_...
health_service_sum_today(HealthMetricStepCount)
; data->cur_steps = peek_steps + data->steps_offset; data->lap_steps = persist_read_int(AppPersistKeyLapSteps); if (data->lap_steps > data->cur_steps) { // Probably left over since a midnight rollover, reset the persistent storage data->lap_steps = data->cur_steps; persist_write_int(AppPersistKeyLapSt...
///////// // Awaiting Reset Complete Local Initiated //////////////////////////////////////////////////////////////////////////////// static void prv_send_reset_request(void) { prv_control_message_queue_add(PostMessageKeyResetRequest, NULL, 0); } static void prv_awaiting_reset_complete_local_initiated__enter(bool s...
prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorMalformedResetComplete)
; return; } const PostMessageResetCompletePayload *rc = (const PostMessageResetCompletePayload *) tuple->value[0].data; // Check overlap in supported versions if (!prv_is_version_supported(rc)) { prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorUnsupporte...
ble_process_md.h" #include "services/normal/filesystem/pfs.h" #include "services/normal/blob_db/app_db.h" // Fixture //////////////////////////////////////////////////////////////// // Fakes //////////////////////////////////////////////////////////////// #include "fake_spi_flash.h" // Stubs ////////////////////////...
memset(&temp, 0, sizeof(AppDBEntry))
; cl_assert_equal_i(S_SUCCESS, app_db_get_app_entry_for_uuid(&app1.uuid, &temp)); cl_assert_equal_b(true, uuid_equal(&app1.uuid, &temp.uuid)); cl_assert_equal_i(0, strncmp((char *)&app1.name, (char *)&temp.name, APP_NAME_SIZE_BYTES)); // check app 3 memset(&temp, 0, sizeof(AppDBEntry)); cl_assert_equal_i(S...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ char buffer[30]; itoa_int(id, buffer, 10); pfs_remove(buffer); }
bool app_storage_app_exists(AppInstallId id) { return true; } AppInstallId s_test_id_ql_up; AppInstallId s_test_id_ql_down; AppInstallId s_test_id_watchface; AppInstallId s_test_id_worker; AppInstallId quick_launch_get_app(ButtonId button) { if (button == BUTTON_ID_UP) { return s_test_id_ql_up; } else { ...
ityMetricStepCount, Thursday, 5555); activity_get_metric(ActivityMetricStepCount, 1, metric_values); cl_assert_equal_i(metric_values[0], 4444); } // Test that we report the that a run session is ongoing. void test_activity__activity_sessions_run_ongoing_then_end(void) { // Start activity tracking. This method as...
cl_assert_equal_i(0, health_service_peek_current_activities())
; } // --------------------------------------------------------------------------------------- // Test that we report the that multiple sessions are ongoing. void test_activity__activity_sessions_ongoing_multiple(void) { // Start activity tracking. This method assumes it can be called from any task, so we must // ...
/* * 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 0; }
static int16_t prv_get_max_scroll_offset(TimelineItemLayer *item_layer) { int16_t max_scroll = prv_get_height(item_layer) - prv_get_frame_size(item_layer).h; if (max_scroll > 0) { int16_t first_scroll = prv_get_first_scroll_offset(item_layer); return MAX(first_scroll, max_scroll); } else { return MA...
return SYSTEM_APP; } else { return entry->install_id; } } bool app_install_is_app_running(AppInstallId id) { return app_manager_get_task_context()->install_id == id; } bool app_install_is_worker_running(AppInstallId id) { return worker_manager_get_task_context()->install_id == id; } void app_install_noti...
GColorFromHEX(0xaa0000)
}; uint8_t uuid_byte_sum = 0; for (uint8_t *b = &uuid->byte0; b <= &uuid->byte15; b++) { uuid_byte_sum += *b; } return fall_back_colors[uuid_byte_sum % ARRAY_LENGTH(fall_back_colors)]; } static bool prv_app_install_entry_from_app_db_entry(AppInstallId id, AppDBEntry *db_entry, ...
he attribute order swapped uint8_t data2[] = { 0x02, // attribute list - num attributes 0x03, // attribute type - App UUID 0x10, 0x00, // attribute length 0xa8, 0xc5, 0x63, 0x17, 0xa2, 0x89, 0x46, 0x5c, 0xbe, 0xf1, 0x5b, 0x98, 0x0d, 0xfd, 0xb0, 0x8a, 0x02, // attri...
cl_assert_equal_m(&data_out[sizeof(GenericAttribute)], data, sizeof(data))
; Uuid uuid; uuid_generate(&uuid); next = generic_attribute_add_attribute(next, VEAttributeIdAppUuid, &uuid, sizeof(uuid)); cl_assert_equal_p((uint8_t*)next, data_out + sizeof(data_out)); expected = (GenericAttribute) { .id = VEAttributeIdAppUuid, .length = sizeof(Uuid) }; cl_assert_equal_m(&expe...
_state == HRMEnabledState_Uninitialized); dev->state->lock = mutex_create(); dev->state->timer = new_timer_create(); dev->state->enabled_state = HRMEnabledState_Disabled; // Boot up the HRM so that we can read off the firmware version to see // if it needs to be updated. // First, read the version from t...
if (!dev->state->lock) { PBL_LOG(LOG_LEVEL_DEBUG, "Not an HRM Device."); return; }
mutex_lock(dev->state->lock); prv_enable(dev); mutex_unlock(dev->state->lock); } void hrm_disable(HRMDevice *dev) { if (!dev->state->lock) { PBL_LOG(LOG_LEVEL_DEBUG, "Not an HRM Device."); return; } mutex_lock(dev->state->lock); prv_disable(dev); mutex_unlock(dev->state->lock); } bool hrm_i...
r, int32_t angle_start, int32_t angle_end) {} void gpath_draw_filled(GContext* ctx, GPath *path) {} void layer_get_unobstructed_bounds(const Layer *layer, GRect *bounds_out) { *bounds_out = layer->bounds; } GFont fonts_get_system_font(const char *font_key) { return (GFo...
(buffer, 0, length + 1)
; cl_assert(buffer); fread (buffer, 1, length, f); fclose (f); return buffer; } void test_js__call_cleanup_twice(void) { prv_deinit(); char *script = "function f(i) { return i * 4; } f(5);"; bool result = rocky_event_loop_with_string_or_snapshot(script, strlen(script)); cl_assert(result); } static boo...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(&window->layer, layer_update_proc)
; const bool animated = true; app_window_stack_push(window, animated); data->box_rect = GRect(10, 10, 40, 40); data->x_velocity = 1; data->y_velocity = 1; app_timer_register(33, prv_redraw_timer_cb, NULL); app_event_loop(); } const PebbleProcessMd* bouncing_box_demo_get_app_info(void) { static con...
_polar_internal(&origin_center, radius, (TRIG_MAX_ANGLE * 3 / 4)); cl_assert_equal_gpoint(result, GPoint(-5, 0)); const GPoint offset_center = GPoint(1, 1); // 90 degrees should be (6, 1) result = gpoint_from_polar_internal(&offset_center, radius, (TRIG_MAX_ANGLE / 4)); cl_assert_equal_gpoint(result, GPoint(...
cl_assert_equal_grect(GRect(5, 4, 2, 2), grect_centered_internal(&p2, GSize(2, 2)))
; // Repeat for a positive offset center point with 0.5 fractions GPointPrecise p3 = GPointPreciseFromGPoint(GPoint(5, 5)); p3.x.raw_value += FIXED_S16_3_HALF.raw_value; p3.y.raw_value += FIXED_S16_3_HALF.raw_value; // GRectZero + standardize cl_assert_equal_grect(GRect(6, 6, 0, 0), grect_centered_interna...
/* * 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...
(i2c_timingr_calculate(MHZ_TO_HZ(20), I2CBusMode_Standard, KHZ_TO_HZ(100), 500, 500), 1, 94, 80, 15)
; } void test_i2c_timingr__data_delay_requires_prescaler(void) { // We'll increase the rise time enough that the required SCLDEL will exceed the max value with // no prescaler, forcing the use of the prescaler even though the SCLL and SCLH values wouldn't // otherwise require it. // // With prescaler 1: SCLD...
} } return last_visited_char; } //////////////////////////////////////////////////////////// // Walk Lines void set_ellipsis_on_overflow_last_line_cb(GContext* ctx, Line* line, const TextBoxParams* const text_box_params, c...
TEXT_LINE_CAP_LINE(line)
, fixed_x1, fixed_x2, GColorRed); graphics_private_draw_horizontal_line_prepared(ctx, &ctx->dest_bitmap, &ctx->dest_bitmap.bounds, line->origin.y + TEXT_LINE_BASE_...
} if ((rv = pfs_write(new_fd, buf, bytes_to_read)) != (int)bytes_to_read) { rv = (rv > 0) ? E_INTERNAL : rv; break; } curr_file_len -= bytes_to_read; } pfs_close(*fd); pfs_close(new_fd); *fd = prv_pmap_open_debug_wrapper(s_map_filename, OP_FLAG_READ | OP_FLAG_WRITE, 0, 0); if (*f...
if ((fd = prv_pmap_open_debug_wrapper(name, OP_FLAG_WRITE, FILE_TYPE_STATIC, PMAP_FILE_SIZE)) < 0) { PBL_LOG(LOG_LEVEL_WARNING, "pmap create failed: %d", fd); return (fd); }
PersistMapHeader header = { .version = PERSIST_MAP_VERSION, }; status = pfs_write(fd, (uint8_t *)&header, sizeof(header)); } else { prv_pmap_grab_debug_fd_data(fd); // if the file exists, grab diagnostic data } pfs_close(fd); return (status); }
il_get_hr_zone(wrkt_data->current_bpm); wrkt_data->current_bpm_timestamp_ts = time_get_uptime_seconds(); if (!workout_service_is_paused()) { // TODO: Maybe apply smoothing wrkt_data->hr_zone_time_s[wrkt_data->current_hr_zone] += wrkt_data->current_bpm_timestamp_ts - prev_bpm_timestamp_ts;...
(PebbleTask_App)
; prv_lock(); { #if CAPABILITY_HAS_BUILTIN_HRM s_workout_data.hrm_session = sys_hrm_manager_app_subscribe(app_get_app_id(), 1, 0, HRMFeature_BPM); #endif // CAPABILITY_HAS_BUILTIN_HRM s_workout_data.frontend_last_opened_ts = time_get_uptime_seconds(); prv_put_event(PebbleWorkoutEvent_FrontendOpe...
OG(LOG_LEVEL_ERROR, "AppInbox already registered for storage <%p>", storage); has_error = true; } // This check effectively caps the kernel RAM impact of this service, // so it's not possible to abuse the syscall and cause kernel OOM. if (prv_find_inbox_by_tag(tag)) { PBL_LOG(LOG_LEVEL_ERRO...
prv_send_event_if_needed(inbox)
; goto unlock; } inbox->writer = writer; inbox->write_failed = false; // Leave space at the beginning for the header, which we'll write in the end inbox->buffer.current_offset = sizeof(AppInboxMessageHeader); success = true; } unlock: prv_unlock(); return success; } bool app_inbox_...
// for every layer for (unsigned int level = 0; level <= current_depth; level++) { const Layer *levels_layer = stack[level]; if (levels_layer->clips) { const GRect levels_layer_frame_in_ctx_space = { .origin = { // drawing_box is expected to be setup as the bounds ...
unobstructed_area_service_get_area(app_state_get_unobstructed_area_state(), &area)
; // Convert the area from screen coordinates to layer coordinates gpoint_sub_eq(&area.origin, layer_convert_point_to_screen(layer->parent, GPointZero)); layer_get_bounds(layer, bounds_out); grect_clip(bounds_out, &area); } GRect layer_get_unobstructed_bounds_by_value(const Layer *layer) { GRect bounds; la...
= 0; i < 30; i++) { HealthValue value = health_service_sum(metric, day_start, day_start + SECONDS_PER_DAY); APP_LOG(APP_LOG_LEVEL_DEBUG, "%d: %d", i, (int)value); char temp[32]; snprintf(temp, sizeof(temp), "\n%d: %d", i, (int)value); prv_safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->...
(data->sleep_card.text, sizeof(data->sleep_card.text), "Zzz..\ntotal: %s\ndeep: %s\nenter: %s\nexit: %s", total_sleep_str, deep_sleep_str, bed_time_str, wake_time_str)
; text_layer_set_text(data->sleep_card.text_layer, data->sleep_card.text); } // ------------------------------------------------------------------------------- static void sleep_window_load(Window *window) { HealthAPITestAppData *data = window_get_user_data(window); Layer *window_layer = window_get_root_layer(w...
ATE, .spi_bus = &DIALOG_SPI_BUS, .spi_scs = { GPIOE, GPIO_Pin_11, false }, .spi_direction = SpiDirection_2LinesFullDuplex, .spi_cpol = SpiCPol_Low, .spi_cpha = SpiCPha_1Edge, .spi_first_bit = SpiFirstBit_MSB, .rx_dma = &DIALOG_SPI_RX_DMA_REQUEST, .tx_dma = &DIALOG_SPI_TX_DMA_REQUEST }; SPISlavePort * co...
i2c_init(&I2C_TOUCH_ALS_BUS)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ graphics_context_set_fill_color(ctx, command->fill_color); graphics_fill_circle(ctx, command->points[0], command->radius); }
if ((command->stroke_color.a != 0) && (command->stroke_width > 0)) { graphics_context_set_stroke_color(ctx, command->stroke_color); graphics_context_set_stroke_width(ctx, command->stroke_width); graphics_draw_circle(ctx, command->points[0], command->radius); } } static void prv_draw_precise_path(GCont...
_LOOP_DETECT_ONE); switch (++counter) { case 1: boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE); break; case 2: boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE); boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO); break; case 3: boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE); break; case 4: ...
dbgserial_newline()
; if (RCC_GetFlagStatus(RCC_FLAG_BORRST) == SET) { dbgserial_putstr("Brown out reset"); } } // SystemInit does this for the firmware, but since the bootloader isn't using // the vendor SystemInit, initialize the flash cache here static void prv_configure_system_flash(void) { // Enable flash instruction and d...
er the License. */ #include "poll_remote.h" #include "services/common/comm_session/protocol.h" #include "services/common/comm_session/session.h" #include "services/common/system_task.h" #include "system/logging.h" #include "system/passert.h" #include "util/attributes.h" #include <string.h> /* * Private */ static...
(&s_poll_remote_contexts[msg->service])
; break; } case LEGACY_CMD_REQUEST_INTERVAL: { PollLegacySetIntervalMessage *msg = (PollLegacySetIntervalMessage *)data; poll_remote_set_intervals(POLL_REMOTE_SERVICE_MAIL, MIN_INTERVAL_MINUTES, msg->interval_minutes); break; } case CMD_SET_INTERVAL: { PollSetIntervalMessag...
TH_NAME}.pbi")); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &across_x_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi")); test_graphics_context_reset(&ctx, fb); layer_s...
(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 2)
; graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw2_clip_xy.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 2); graphics_draw_round_rect(&ctx, &ORIGIN_DR...
This step must be the last read for this handshake-pulse. static void prv_handle_handshake_pulse(void *unused_data) { PPG_DBG("Handshake handle"); mutex_lock(HRM->state->lock); if (!hrm_is_enabled(HRM)) { mutex_unlock(HRM->state->lock); return; } // We keep track of the number of handshakes so th...
PBL_LOG(LOG_LEVEL_DEBUG, " - NTC")
; } } } static bool prv_get_and_log_device_info(HRMDevice *dev, AS7000InfoRecord *info, bool log_version) { // get the device info if (!prv_read_register_block(dev, ADDR_INFO_START, info, sizeof(AS7000InfoRecord))) { return false; } if (log_version) { // p...