prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
>w * 2 / 5, bitmap_bounds_size->h / 4);
const int16_t right_rects_x = bitmap_bounds->size.w * 3 / 5;
const int16_t right_rects_y_offset = ((bitmap_bounds_size->h / 2) - right_rects_size.h) / 2;
GColor top_right_rect_color = GColorGreen;
top_right_rect_color.a = 2;
const GRect top_left_rect = (GRect) {
.or... | (&ctx->dest_bitmap, y, x1_fixed, x2_fixed, gradient_width,
gradient_width, ctx->draw_state.clip_box.origin.x,
grect_get_max_x(&ctx->draw_state.clip_box) - 1, color) | ;
}
void test_graphics_draw_core__assign_horizontal_line_delta_raw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, false, 1);
prv_draw_hline_test_pattern(&ctx, prv_hline_pattern_assign_horizontal_line_delta_raw);
cl_check(gbitma... |
/*
* 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... | kino_reel_scale_segmented_set_from_stroke_width(reel, from, GStrokeWidthOpSet) | ;
kino_reel_scale_segmented_set_stroke_width_curve(reel, prv_ease_in_out_first_quarter);
}
|
e_Possible);
cl_assert(!recognizer_get_manager(r1));
recognizer_set_manager(r1, &manager);
r1->state = RecognizerState_Possible;
r2->state = RecognizerState_Started;
manager.active_layer = &layer_a;
manager.triggered = r2;
manager.state = RecognizerManagerState_RecognizersTriggered;
recognizer_manager_... | cl_assert_equal_i(r[1]->state, RecognizerState_Possible) | ;
r[0]->state = RecognizerState_Completed;
manager.active_layer = &layer_a;
manager.state = RecognizerManagerState_RecognizersActive;
manager.triggered = NULL;
recognizer_manager_handle_state_change(&manager, r[0]);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equa... |
{
PBL_LOG(LOG_LEVEL_WARNING, "pmap add uuid (open) failed: %d", fd);
return (fd);
} |
int end_offset = (id * sizeof(PersistMapIdField)) + sizeof(PersistMapHeader);
size_t file_sz = pfs_get_file_size(fd);
if ((end_offset + sizeof(PersistMapIdField)) > file_sz) {
status_t rv;
file_sz = ((file_sz / PMAP_FILE_SIZE) + 1) * PMAP_FILE_SIZE;
// TODO: The file is most likely corrupted in th... | |
/*
* 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... | {
static int8_t s_refcount = 0;
portENTER_CRITICAL();
PBL_ASSERTN(BOARD_CONFIG_MCO1.output_enabled);
if (on) {
gpio_af_init(
&BOARD_CONFIG_MCO1.af_cfg, GPIO_OType_PP, GPIO_Speed_2MHz, GPIO_PuPd_NOPULL);
// LSE is 32kHz, we want 32kHz for our external clock and is used by:
// - The cc2564 ... | |
ap_sequence_destroy(bitmap_sequence);
}
return bitmap_sequence;
}
bool gbitmap_sequence_restart(GBitmapSequence *bitmap_sequence) {
return prv_gbitmap_sequence_restart(bitmap_sequence, true);
}
void gbitmap_sequence_destroy(GBitmapSequence *bitmap_sequence) {
if (bitmap_sequence) {
upng_destroy(bitmap_se... | if (upng_state != UPNG_EOK) {
APP_LOG(APP_LOG_LEVEL_ERROR,
(upng_state == UPNG_ENOMEM) ? APNG_MEMORY_ERROR : APNG_DECODE_ERROR);
goto cleanup;
} |
applib_free(buffer);
bitmap_sequence->current_frame++;
const uint32_t width = bitmap_sequence->bitmap_size.w;
const uint32_t height = bitmap_sequence->bitmap_size.h;
const bool bitmap_supports_transparency = (bitmap_format != GBitmapFormat1Bit);
// DISPOSE_OP_BACKGROUND sets the background to black wit... |
n't detected the end of sleep, the last KALG_MAX_UNCERTAIN_SLEEP_M minutes are
// uncertain
*stats = (KAlgOngoingSleepStats) {
.sleep_start_utc = s_kalg_sleep_start_utc,
.sleep_len_m = (now - s_kalg_sleep_start_utc) / SECONDS_PER_MINUTE
- KALG_MAX_UNCERTAIN_SLEEP_M,
... | activity_algorithm_minute_handler(rtc_get_time(), &minute_record) | ;
if (simulate_bg_delays) {
rtc_set_time(rtc_get_time() - delay);
}
}
}
// =============================================================================================
// Start of unit tests
void test_activity_algorithm_kraepelin__initialize(void) {
time_t utc_sec = mktime(&s_start_time_tm);
fake... |
(!state) {
PBL_LOG(LOG_LEVEL_WARNING, "not subscribed");
goto unlock;
}
if (samples != state->num_samples) {
PBL_LOG(LOG_LEVEL_WARNING, "Wrong number of samples");
success = false;
} else {
// Default timestamp for next chunk
state->timestamp_ms += samples * 1000 / state-... | prv_subscriber_state(session) | ;
if (state != NULL) {
// Remove this subscriber and free up it's state variables
accel_remove_consumer(&state->buffer_client);
list_remove(&state->list_node, &s_data_subscribers /* &head */, NULL /* &tail */);
kernel_free(state);
// All data subscribes are also tap subscribers
... |
/*
* 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... | memcpy(buffer_out, temp_buffer, length_bytes) | ;
if (!rv) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to read OTP %p", (void *)otp_addr);
}
return rv;
}
bool dialog_chip_id_copy(DialogChipID *chip_id_out) {
hw_otpc_init();
#if dg_configEXT_CRYSTAL_FREQ == EXT_CRYSTAL_IS_16M
HW_OTPC_SYS_CLK_FREQ freq = HW_OTPC_SYS_CLK_FREQ_16;
#elif dg_configEXT_CRYSTAL_FRE... |
can still receive notifications
prv_send_notification((uint8_t *)&s_complete_dict);
cl_assert_equal_i(s_num_requested_notif_attributes, 2);
cl_assert_equal_i(s_num_ds_notifications_received, 1);
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 1);
}
void test_ancs__notification_... | cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0) | ;
}
void test_ancs__handle_unexpected_notifications(void) {
NSNotification ns_notification = {
.event_id = EventIDNotificationAdded,
.event_flags = 0,
.category_id = CategoryIDSocial,
.category_count = 1,
.uid = s_get_wrong_data_uid,
};
prv_fake_receiving_ns_notification(sizeof(ns_notificatio... |
/*
* 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... | {
strncpy(buffer, "15 minutes ago", buf_size);
buffer[buf_size - 1] = '\0';
} |
}
// Stubs
/////////////////////
#include "stubs_action_menu.h"
#include "stubs_analytics.h"
#include "stubs_animation_timing.h"
#include "stubs_app_install_manager.h"
#include "stubs_app_timer.h"
#include "stubs_app_window_stack.h"
#include "stubs_bootbits.h"
#include "stubs_click.h"
#include "stubs_event_service_c... |
);
// Create a spawn
Animation *spawn = animation_sequence_create(a, b, NULL);
cl_assert(spawn != NULL);
animation_set_play_count(spawn, play_count_spawn);
// Check the duration
cl_assert_equal_i(animation_get_duration(spawn, true, true), 0);
prv_clear_handler_histories();
uint64_t start_ms = prv_n... | (seq, true, true) | , duration_total);
animation_destroy(seq);
#endif
}
// --------------------------------------------------------------------------------------
// Test the get_duration call on a spawn animation
void test_animation__spawn_get_duration(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int del... |
emId *parent_id) {
return (timeline_item_storage_delete_with_parent(&s_pin_db_storage, parent_id, NULL));
}
//! Caution: CommonTimelineItemHeader .flags & .status are stored inverted and not auto-restored
status_t pin_db_each(SettingsFileEachCallback each, void *data) {
return timeline_item_storage_each(&s_pin_db_... | (item, false /* emit_event */) | ;
}
status_t pin_db_set_status_bits(const TimelineItemId *id, uint8_t status) {
return timeline_item_storage_set_status_bits(&s_pin_db_storage, (uint8_t *)id, sizeof(*id),
status);
}
status_t pin_db_get(const TimelineItemId *id, TimelineItem *pin) {
int size = pin_db_... |
NDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "services/common/phone_pp.h"
#include "services/normal/phone_call_util.h"
#include "services/common/comm_session/session.h"
#include... | (s_session, pp_msg, sizeof(pp_msg)) | ;
fake_system_task_callbacks_invoke_pending();
prv_assert_last_event(PhoneEventType_Start, true /* check_cookie */, false /* check_name_number */,
NULL, NULL);
}
void test_phone_pp__end(void) {
uint8_t pp_msg[] = {0x09, 0x1a, 0xd4, 0x77, 0x08};
phone_protocol_msg_callback(s_session, pp_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_workout_data.current_workout->hr_samples_sum,
s_workout_data.current_workout->hr_samples_count) | ;
}
static void prv_update_duration(void) {
// We can't just increment the time on a second callback because of the inaccuracy of our timer
// system. PBL-32523
// Instead, we keep track of a start_utc, paused_time, and last_paused_utc. With these
// we can accurately keep track of the total duration of the wo... |
/*
* 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(b->bytes_written, i * sizeof(test_data));
cl_assert_equal_i(buffer_get_bytes_remaining(b), buffer_size - (i * sizeof(test_data)));
bytes_written += buffer_add(b, (uint8_t *) test_data, sizeof(test_data));
cl_assert_equal_i(bytes_written, (i + 1) * sizeof(test_data));
cl_assert_eq... |
cl_assert(buffer_get_bytes_remaining(b) > 0);
bytes_written = buffer_add(b, (uint8_t *) test_data, sizeof(test_data));
cl_assert_equal_i(bytes_written, 0);
free(b);
}
void test_buffer__cannot_remove_beyond_written(void) {
Buffer *b = buffer_create(5);
cl_assert_equal_i(0, buffer_remove(b, 0, 0));
cl_a... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (int i = 0; i < s_command_list_index; ++i) {
cl_assert_equal_i(s_command_list[i].addr, commands[i].addr);
cl_assert_equal_i(s_command_list[i].type, commands[i].type);
} |
}
static int s_dummy_value = 42;
static int *s_callback_ctx = &s_dummy_value;
static void prv_callback(void *context, status_t status) {
cl_assert_equal_p(context, s_callback_ctx);
cl_assert_equal_i(s_erase_mutex_locked, false);
s_callback_status = status;
s_callback_called_count++;
}
static void prv_assert... |
sessions_is_session_type_ongoing(ActivitySessionType_Run));
cl_assert_equal_i(0, health_service_peek_current_activities());
// Start on known boundary
struct tm start_tm = {
// Jan 1, 2015, 5am
.tm_hour = 5,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
time_t utc_sec = mktime(&start_tm);
... | activity_sessions_is_session_type_ongoing(ActivitySessionType_Run) | );
cl_assert_equal_b(false, activity_sessions_is_session_type_ongoing(ActivitySessionType_Walk));
cl_assert_equal_b(false, activity_sessions_is_session_type_ongoing(ActivitySessionType_Sleep));
cl_assert_equal_i(0, health_service_peek_current_activities());
// Start on known boundary
struct tm start_tm = {
... |
gnal
// and allows deep-sleep mode (if the AS7000 is configured for this).
// 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... | PBL_LOG(LOG_LEVEL_DEBUG, " - GSR") | ;
}
if (app_ids & AS7000AppId_NTC) {
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, in... |
ription_info;
}
void event_service_client_subscribe(EventServiceInfo * service_info) {
}
void sys_send_pebble_event_to_kernel(PebbleEvent* event) {
cl_assert_equal_i(event->type, PEBBLE_APP_OUTBOX_MSG_EVENT);
event->callback.callback(event->callback.data);
}
static int s_num_app_outbox_events_sent;
bool process_... | {
prv_register();
app_outbox_service_unregister(AppOutboxServiceTagUnitTest);
app_outbox_send(s_test_data, s_test_data_length,
test_app_outbox_sent_handler, s_expected_cb_ctx);
assert_sent_cb_last_status(AppOutboxStatusConsumerDoesNotExist);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "STT normal callback %d executed", idx) | |
cl_assert_equal_i(actual->orientation, expected->base.orientation) | ;
cl_assert_equal_i(actual->vmc, expected->base.vmc);
cl_assert_equal_i(actual->light, ambient_light_level_to_enum(
expected->base.light * ALG_RAW_LIGHT_SENSOR_DIVIDE_BY));
cl_assert_equal_i(actual->heart_rate_bpm, expected->heart_rate_bpm);
}
// -------------------------------------------------------------... | |
able_count;
size_t bytes_sendable_count;
bool should_transact_after_consuming_rx;
uint8_t *rx_write_ptr;
const uint8_t *tx_read_ptr;
CircularBuffer rx;
CircularBuffer tx;
SemaphoreHandle_t semph;
TaskHandle_t task;
volatile bool task_should_deinit;
volatile bool task_is_running;
SPITransportMsgSta... | {
dbgserial_putstr("BT Trans TO!");
prv_watchdog_stop();
prv_trigger_core_dump_from_isr();
TIM_ClearITPendingBit(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update);
} |
static void prv_give_semamphore_from_isr(bool *should_context_switch) {
portBASE_TYPE was_higher_task_woken = pdFALSE;
xSemaphoreGiveFromISR(s_spi_transport.semph, &was_higher_task_woken);
*should_context_switch = (was_higher_task_woken != pdFALSE);
}
static void prv_handle_sending_footer_complete_isr(bool *sh... |
{ -88, 928, -24},
// 245 seconds
{ -96, 936, -24},
{ -88, 928, -24},
{ -88, 928, -24},
{ -96, 928, -24},
{ -96, 928, -24},
{ -88, 936, -24},
{ -88, 928, -24},
{ -96, 936, -24},
{ -96, 928, -24},
{ -96, 936, -24},
{ -96, 928, -24},
{ -96, 928, -32},
{ -96, 928,... | { -128, -344, -976},
{ -128, -328, -984},
{ -128, -336, -976},
{ -128, -336, -968},
{ -128, -328, -976},
{ -120, -344, -968},
{ -120, -336, -976},
{ -128, -336, -968},
{ -136, -336, -976},
{ -136, -328, -968},
{ -128, -328, -976},
{ -128, -312, -976},
{ -120, -312, -9... | |
/*
* 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... | _Static_assert(AttributeIdRecordAway + 1 == AttributeIdRecordHome,
"Sports layout requires that all Home attributes are directly after Away") | ;
_Static_assert(AttributeIdScoreAway + 1 == AttributeIdScoreHome,
"Sports layout requires that all Home attributes are directly after Away");
#if !TINTIN_FORCE_FIT
//////////////////////////////////////////
// Card Mode
//////////////////////////////////////////
#define CARD_MARGIN_TOP 3
#define CARD... |
ity_test_feed_samples(s_walk_30_steps, ARRAY_LENGTH(s_walk_30_steps));
// Check new step count
int32_t steps;
steps = health_service_sum_today(HealthMetricStepCount);
steps -= before;
PBL_LOG(LOG_LEVEL_DEBUG, "steps: %"PRId32, steps);
if (steps >= 27 && steps <= 33) {
passed = true;
}
prv_test_en... | if ((deep_sleep < k_min_deep_sleep_min * SECONDS_PER_MINUTE)
|| (deep_sleep > k_max_deep_sleep_min * SECONDS_PER_MINUTE)) {
passed = false;
} |
// Check other sleep metrics
activity_get_metric(ActivityMetricSleepEnterAtSeconds, 1, &value);
PBL_LOG(LOG_LEVEL_DEBUG, "entry minute: %d", (int)(value / SECONDS_PER_MINUTE));
activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value);
PBL_LOG(LOG_LEVEL_DEBUG, "exit minute: %d", (int)(value / SECOND... |
n.y = line.origin.y;
line2.size.w = REL_BAR_LINE_CHECK_LENGTH + REL_BAR_LINE_WIDTH;
line2.size.h = REL_BAR_LINE_WIDTH;
graphics_fill_rect(ctx, &line2);
}
#define REL_BAR_DOT_SIZE 2
static void prv_draw_rel_bar_dotted(TimelineLayer *timeline_layer, GContext* ctx,
bool current, ... | (timeline_layer, &first_icon_frame, &second_icon_frame) | ;
int16_t line_length = rel_bar_value;
int16_t y_offset = 0;
if (!current) {
line_length = full_line_length;
y_offset = (((full_line_length - rel_bar_value) * REL_BAR_PREV_ANIM_OFFSET) /
full_line_length) * timeline_layer->move_delta;
}
if (((line_length <= 0) && current) ||
((!... |
/*
* 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 (SHELL_SDK && CAPABILITY_HAS_SDK_SHELL4)
// We want the newest installed developer app to appear at the top
// This works at the moment because there is only one system app, Watchfaces
return app_menu_data_source_get_count(data_source) - 1 - original_index;
#else
return original_index;
#endif
} |
/////////////////////
// Window callbacks
static void prv_window_load(Window *window) {
LauncherAppWindowData *data = window_get_user_data(window);
Layer *window_root_layer = window_get_root_layer(window);
AppMenuDataSource *data_source = &data->app_menu_data_source;
app_menu_data_source_init(data_source, ... |
const GSize text_size = graphics_text_layout_get_max_used_size(ctx, item->label, font,
*content_box, overflow_mode,
text_alignment, NULL);
GRect text_box = (GRect) { .size = text_size };
... | (ctx, PBL_IF_COLOR_ELSE(GColorWhite, 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... | toggle_color(window) | ;
(void)recognizer;
}
static void select_long_click_release_handler(ClickRecognizerRef recognizer, Window *window) {
ClickAppData *data = window_get_user_data(window);
sniprintf(data->text_buffer, TEXT_BUFFER_SIZE, "Long Click Released!");
PBL_LOG(LOG_LEVEL_DEBUG, "Long Click Released!");
text_layer_set_text... |
0, -1112},
{ -176, 464, -912},
{ -200, 456, -1064},
{ -144, 480, -808},
{ -152, 504, -856},
{ -136, 464, -752},
{ -96, 448, -680},
{ -64, 432, -960},
{ -168, 328, -800},
{ -104, 528, -928},
{ -216, 368, -872},
{ -136, 520, -952},
{ -248, 440, -1000},
{ -160, 464, -976... | { -136, 480, -744},
{ -112, 464, -928},
{ -184, 320, -632},
{ -176, 576, -968},
{ -240, 336, -824},
{ -168, 744, -1080},
{ -288, 392, -888},
{ -120, 688, -1016},
{ -248, 472, -920},
{ -152, 392, -1008},
{ -128, 392, -1072},
// 104 seconds
{ -224, 344, -936},
{ -88... |
{ -232, 384, -736},
{ -208, 488, -816},
{ -176, 424, -816},
{ -144, 568, -1016},
{ -152, 440, -880},
{ -152, 552, -968},
{ -184, 448, -944},
{ -168, 464, -896},
{ -152, 488, -1040},
{ -136, 528, -1032},
{ -160, 400, -888},
{ -144, 480, -952},
{ -168, 408, -776},
... |
{ -864, 424, 72},
{ -1072, 416, 128},
{ -1104, 472, 8},
{ -1184, 512, -72},
{ -1088, 528, -64},
{ -768, 544, -296},
{ -824, 536, -344},
{ -688, 384, -152},
{ -456, 200, -120},
{ -376, 288, -216},
{ -424, 384, -256},
{ -528, 320, -136},
{ -656, 320, -128},
{ -648, 392... | { -552, 272, 104},
{ -648, 344, 80},
{ -1016, 400, 56},
{ -1064, 416, 40},
{ -1304, 472, -80},
{ -1296, 520, -72},
{ -944, 568, -312},
{ -960, 568, -328},
{ -744, 360, -160},
// 29 seconds
{ -456, 176, -72},
{ -336, 280, -136},
{ -360, 392, -192},
{ -408, 328, -88... |
{ -432, 360, -160},
{ -432, 400, -200},
{ -456, 352, -160},
{ -504, 296, -96},
{ -552, 320, -80},
{ -584, 400, -112},
{ -808, 456, -152},
{ -1064, 464, -112},
{ -1408, 488, -80},
{ -1560, 640, -240},
{ -1088, 560, -40},
{ -904, 536, -120},
{ -912, 592, -176},
{ -... |
ted_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_st... | (b, play_count_b) | |
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... | |
opy_service_refs_matching_uuid(&s_device, &service, 1,
&service_uuid);
cl_assert_equal_i(num_copied, 1);
// UUID for Characteristic that has no CCCD:
Uuid characteristic_uuid = UuidMake(0xF7, 0x68, 0x09, 0x5B, 0x1B, 0xFA, 0x4F, 0x63,
... | (prv_get_indicatable_characteristic(),
BLESubscriptionIndications,
GAPLEClientKernel) | ;
cl_assert_equal_i(e, BTErrnoNotEnoughResources);
fake_kernel_malloc_mark_assert_equal();
prv_assert_no_event();
}
void test_gatt_client_subscriptions__subscribe_cccd_write_error(void) {
s_write_descriptor_cccd_result = -1;
fake_kernel_malloc_mark();
// Try to subscribe for indications to the indicatable... |
;
}
PebbleHRMEvent out_event[NUM_TEST_EVENTS];
for (int i = 0; i < NUM_TEST_EVENTS; ++i) {
prv_read_event_from_buffer_and_consume(&cb, &out_event[i]);
cl_assert_equal_b(memcmp(&event[i], &out_event[i], sizeof(PebbleHRMEvent)), false);
}
}
}
#undef NUM_TEST_EVENTS
// Test the enable and di... | fake_system_task_callbacks_invoke_pending() | |
points[i];
if (!endpoint || endpoint->endpoint_id > endpoint_id) {
break;
}
if (endpoint->endpoint_id == endpoint_id) {
return endpoint;
}
}
return NULL;
}
static bool prv_is_endpoint_allowed_with_session(const PebbleProtocolEndpoint* endpoint,
... | (rtr, payload_length) | |
iceAccessibilityMaskNotSupported }
},
{
.desc = "Valid time range with ScopeOnce and Min. Available",
.in = { HealthMetricHeartRateBPM, now - 10, now, HealthAggregationMin,
HealthServiceTimeScopeOnce },
.out = { HealthServiceAccessibilityMaskAvailable }
},
{
.desc... | (&session, HealthActivityMaskAll, now,
now + (10 * SECONDS_PER_MINUTE)) | );
// range that starts before matches
cl_assert_equal_b(true, fun(&session, HealthActivityMaskAll, now - (20 * SECONDS_PER_MINUTE),
now - (9 * SECONDS_PER_MINUTE)));
// range that ends after matches
cl_assert_equal_b(true, fun(&session, HealthActivityMaskAll, now - (1 * SECONDS_... |
1].uint8, 1);
timeline_item_destroy(item);
}
static Attribute action1_attributes[] = {
{.id = AttributeIdTitle, .cstring = "Dismiss"},
};
static Attribute action2_attributes[] = {
{.id = AttributeIdTitle, .cstring = "Like"},
{.id = AttributeIdAncsAction, .int8 = 1}
};
static Attribute attributes[] = {
{.... | string_list_get_at(list, 2) | );
cl_assert_equal_s("", string_list_get_at(list, 3));
// 2 strings (last is not terminated and will fall through) will return 2 strings
// when deserializing, the deserializer puts a \0 at the end
// this case demonstrates the problem with incorrectly initialized data
list->serialized_byte_length = 3;
lis... |
00},
{ 48, 8, -1016},
{ 48, 8, -992},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 40, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
... | { 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{... |
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 40, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
... |
of time for busy bit to clear
static bool prv_wait_for_not_busy(I2CBus *bus) {
static const int WAIT_DELAY = 10; // milliseconds
if (i2c_hal_is_busy(bus)) {
psleep(WAIT_DELAY);
if (i2c_hal_is_busy(bus)) {
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for bus %s to become non-busy", bus->name);
r... | i2c_hal_abort_transfer(bus);
complete = true;
PBL_LOG(LOG_LEVEL_ERROR, "Transfer timed out on bus %s", bus->name);
break;
} |
} while (!complete);
// Return semaphore token so another transfer can be started
prv_semaphore_give(bus->state);
// Wait for bus to to clear the busy flag before a new transfer starts
// Theoretically a transfer could complete successfully, but the busy flag never clears,
// which would cause the next t... |
layer_create_play_animation(&data->peek_layer);
#else
// Play only a section to reduce the duration to the scaling, ignoring the PDCS duration
return (Animation *)peek_layer_create_play_section_animation(&data->peek_layer, 0, duration);
#endif
}
static Animation *prv_create_sidebar_animation(TimelineAppData *data,... | animation_unschedule(data->current_animation) | |
();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
// Complete A and start B. This should unschedule the parent
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, b), 0);
cl_assert_equal_i... | (&s_stopped_handler_calls, c) | , 1);
// A should be at the end
int32_t update_a_after = prv_last_update_distance(a);
cl_assert_equal_i(update_a_after, ANIMATION_NORMALIZED_MAX);
// B should be in the middle
int32_t update_b_after = prv_last_update_distance(b);
cl_assert(abs(update_b_after - ANIMATION_NORMALIZED_MAX/2) < 5000);
// C ... |
nt sleep_end = (sleep_end_12h * HEALTH_PROGRESS_BAR_MAX_VALUE / TWELVE_HOURS);
const int typical_sleep_start_24h = health_data_sleep_get_typical_start_time(data->health_data);
const int typical_sleep_start_12h = typical_sleep_start_24h % TWELVE_HOURS;
const int typical_sleep_end_24h = health_data_sleep_get... | (ctx, buffer, font, rect, GTextOverflowModeFill, GTextAlignmentCenter, NULL) | ;
}
}
static void prv_render_typical_sleep_text(GContext *ctx, Layer *base_layer) {
HealthSleepSummaryCardData *data = layer_get_data(base_layer);
const int typical_sleep = health_data_sleep_get_cur_wday_average(data->health_data);
char sleep_text[32];
if (typical_sleep) {
health_util_format_hours_and... |
/*
* 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 (button < 0 || button >= NUM_BUTTONS) {
prompt_send_response("Invalid button");
return;
} | |
---------------------------------
static void prv_debug_cmd_distance_history(int index, void *context) {
HealthAPITestAppData *data = context;
prv_display_scalar_history_alert(data, "Distance(m)", HealthMetricWalkedDistanceMeters);
}
// -----------------------------------------------------------------------------... | strftime(time_start_text, sizeof(time_start_text), "%F %r", local_tm) | ;
char time_end_text[64];
local_tm = localtime(&utc_end);
strftime(time_end_text, sizeof(time_end_text), "%F %r", local_tm);
if (num_minutes > 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Got %d minutes: %s to %s", num_minutes, time_start_text,
time_end_text);
} else {
APP_LOG(APP_LO... |
92, 8, -288},
// 10 seconds
{ 976, -56, -272},
{ 824, -104, -160},
{ 672, -24, -216},
{ 816, 64, -296},
{ 1176, 144, -368},
{ 1136, 200, -264},
{ 960, 224, -184},
{ 904, 280, -176},
{ 968, 336, -192},
{ 1064, 328, -200},
{ 984, 336, -160},
{ 1088, 376, -128},
{ 13... | { 1192, 56, -120},
{ 936, 40, -96},
{ 744, 120, -184},
{ 984, 224, -408},
{ 1136, 248, -400},
{ 976, 216, -168},
{ 824, 224, -120},
{ 864, 288, -136},
{ 992, 296, -152},
{ 1008, 264, -112},
// 16 seconds
{ 856, 240, -56},
{ 960, 280, -72},
{ 1160, 320, -32},
{... | |
raw_state;
}
}
void layer_property_changed_tree(Layer *node) {
layer_process_tree(node, NULL, layer_property_changed_tree_node);
}
void layer_set_update_proc(Layer *layer, LayerUpdateProc update_proc) {
PBL_ASSERTN(layer != NULL);
layer->update_proc = update_proc;
}
void layer_set_frame(Layer *layer, const G... | (parent != NULL) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (data_length >= 4) {
const unsigned int num_words = data_length / 4;
prv_calculate_incremental_words((uint32_t*) data, num_words);
data += num_words * 4;
data_length -= num_words * 4;
} |
if (data_length) {
uint32_t last_word = 0;
for (unsigned int i = 0; i < data_length; ++i) {
last_word = (last_word << 8) | data[i];
}
crc_value = CRC_CalcCRC(last_word);
} else {
crc_value = CRC_GetCRC();
}
return crc_value;
}
static void prv_calculate_incremental_stop(void) {
pr... |
tall_id,
.crash_ticks = rtc_get_ticks()
};
// Re-launch immediately
watchface_launch_default(NULL);
return;
}
SimpleDialog *crash_dialog = simple_dialog_create("Watchface crashed");
Dialog *dialog = simple_dialog_get_dialog(crash_dialog);
const char *text_fmt = i18n_get("%.*s is not respo... | prv_app_cleanup() | ;
// If we had to ungracefully kill the current app, switch to the launcher app
if (!gracefully) {
app_install_release_md(s_next_app.md);
s_next_app = (NextApp) {
.md = system_app_state_machine_get_default_app(),
};
} else {
// Get the next app to launch
if (!s_next_app.md) {
// 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... | {
const size_t BUFFER_SIZE = 24;
new_timer_delete(s_start_timer);
s_test_buffer = kernel_malloc(BUFFER_SIZE * sizeof(int16_t));
if (!s_test_buffer) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to malloc buffer for 'mic start' command");
return;
}
uint32_t width = s_is_8_bit ? 8 : 16;
uint32_t rate = s_i... | |
IntervalTicks after) {
int32_t result = after - before;
if (result < 0) {
result = (TICKS_IN_AN_INTERVAL - before) + after;
}
return result;
}
static void restore_rtc_time_state(void) {
// Recover the previously set time from the RTC backup registers.
RtcIntervalTicks last_save_time_ticks = RTC_ReadBac... | elapsed_ticks(get_last_save_time_ticks(), rtc_ticks) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (app_state_get_graphics_context(),
text->text, text->font,
GRect(0, 0, text->layer.bounds.size.w, SHRT_MAX),
text->overflow_mode, text->text_alignment, NULL) | ;
text_layer_set_size(text, max_size);
static const int vert_scroll_padding = 4;
scroll_layer_set_content_size(scroll_layer, GSize(144, max_size.h + vert_scroll_padding));
}
#if 0
static void select_long_click_handler(ClickRecognizerRef recognizer, struct AppState* data) {
(void) data;
(void) recognizer;
... |
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 "gatt_local_services.h"
#include "dis_impl.h"
#include "hrm_impl.h"
#include "pebble_pairing_service_impl.... | {
if (!s_has_registered) {
// Avoid registering at this time, gatt_local_services_register() hasn't been called before.
return;
}
mutex_lock(s_svc_register_mutex);
// Under the hood all the API calls below can invoke the GAPM_SET_DEV_CONFIG_CMD. Within the RW
// stack this will often result in an att... |
////////////////////////////////////////////////////////////////////////////////////////////////////
// The functions below are wrappers for API calls that are known to clear out the ROM stack's
// ATT table. All the wrappers do is call the original API and then re-registering our services.
extern ble_error_t __real... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_did_notify) | ;
cl_assert(success = s_notify_success);
cl_assert(profile = s_notify_profile);
s_did_notify = false;
}
SmartstrapResult smartstrap_profiles_handle_request(const SmartstrapRequest *request) {
s_request = *request;
s_did_request = true;
return SmartstrapResultOk;
}
void fake_smartstrap_profiles_check_reque... |
168, 88},
{ 832, 160, 88},
{ 784, 160, 32},
{ 744, 40, 112},
{ 688, 8, 136},
// 22 seconds
{ 656, 32, 128},
{ 824, -24, 80},
{ 1048, 144, 24},
{ 1216, 168, 104},
{ 1824, 24, 360},
{ 1608, 400, 120},
{ 832, 672, -232},
{ 888, 424, -232},
{ 728, 192, 80},
{ 848,... | { 648, 112, 72},
{ 616, 112, -32},
{ 696, 128, 32},
{ 856, 184, 32},
{ 952, 304, 0},
{ 1240, 312, 80},
{ 1768, 208, 248},
{ 1376, 704, 48},
// 28 seconds
{ 1200, 704, -96},
{ 824, 560, 32},
{ 688, 336, 136},
{ 728, 392, 104},
{ 704, 336, 192},
{ 688, 320, 312}... | |
ared_prf_storage_get_getting_started_complete(), false);
}
void test_shared_prf_storage_v3__ble_pairing(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_ble_pairing_data(NULL, NULL, NULL, NULL), false);
shared_prf_storage_store_ble_pairing_data(&PAIRING_INFO, DEVICE_NAME,
... | (DEVICE_NAME, device_name_out) | ;
}
// Test that setting a local_name to NULL will rewrite the field with 0xFF and allow it to
// be rewritten without causing a new page to be written
void test_shared_prf_storage_v3__local_device_name_NULL_new_erased_field(void) {
shared_prf_storage_set_local_device_name(DEVICE_NAME);
char device_name_out[BT_DE... |
/*
* 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(atoi("+500"), 500) | ;
cl_assert_equal_i(atoi("-765"), -765);
cl_assert_equal_i(atoi(" -573888"), -573888);
cl_assert_equal_i(atoi(" +713713"), +713713);
}
void test_atoi__error(void) {
cl_assert_equal_i(atoi("2147483647"), 2147483647); // last valid value
cl_assert_equal_i(atoi("4294967287"), (int)4294967287); // signed inte... |
{ -120, 952, -392},
{ -160, 1264, -672},
{ -176, 1080, -680},
{ -312, 976, -752},
{ -376, 1464, -600},
{ 112, 1368, -504},
{ 56, 832, -392},
{ -16, 704, -424},
{ -64, 536, -336},
{ -152, 416, -232},
{ -264, 480, -272},
{ -368, 648, -320},
{ -400, 832, -384},
{ -464, ... | { -144, 488, -280},
{ -288, 528, -256},
{ -448, 648, -256},
{ -544, 832, -352},
{ -520, 904, -464},
{ -528, 1088, -568},
{ -304, 1152, -608},
{ -408, 1456, -760},
{ 24, 1272, -608},
{ 0, 784, -448},
{ -32, 800, -400},
// 26 seconds
{ 0, 688, -328},
{ -40, 552, -31... |
{ -176, 608, -280},
{ -248, 896, -352},
{ -224, 1120, -504},
{ -288, 1312, -608},
{ -232, 1208, -608},
{ -248, 1088, -600},
{ -128, 1248, -520},
{ 192, 1120, -512},
{ 72, 904, -456},
{ 8, 744, -424},
{ -96, 608, -336},
{ -168, 584, -272},
{ -296, 600, -264},
{ -3... |
const int k_num_records = 2;
const int num_minutes = k_num_records * ALG_MINUTES_PER_DLS_RECORD;
// The test data
AlgMinuteDLSSample minute_data[num_minutes];
prv_create_test_data(num_minutes, minute_data);
// Call the minute handler, which computes the minute stats and saves them to data logging
// as... | activity_algorithm_handle_accel(samples, s_sample_rate, timestamp) | ;
s_alg_next_vmc = 0x11;
s_alg_next_orientation = 0x22;
AlgMinuteRecord minute_record = {};
activity_algorithm_minute_handler(rtc_get_time(), &minute_record);
}
// Get the size of the sleep data and make sure it is within the expected range
uint32_t num_records;
uint32_t data_bytes;
uint32_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... | (rect, GEdgeInsets(0, 18)) | ;
#endif
const GColor bg_color = PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack);
const GColor text_color = PBL_IF_COLOR_ELSE(GColorBlack, GColorWhite);
const GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
graphics_context_set_fill_color(ctx, bg_color);
graphics_fill_round_rect(ctx, &rect, 3, GCo... |
{
uint32_t num_entries = ARRAY_LENGTH(s_prefs_table);
const PrefsTableEntry *entry = s_prefs_table;
for (uint32_t i = 0; i < num_entries; i++, entry++) {
if (!strncmp((const char *)key, entry->key, key_len)) {
return entry;
}
}
PBL_LOG(LOG_LEVEL_WARNING, "Unrecognized key: %s", (const char *)ke... | (&file, entry->key, key_len + 1, value, value_len) |
== S_SUCCESS);
settings_file_close(&file);
}
}
mutex_unlock(s_mutex);
return success;
}
// ------------------------------------------------------------------------------------
// Called from KernelMain when we get a blob DB event. We take this opportunity to update ... |
land on to be killed when it shouldn't be.
launcher_cancel_force_quit();
// Make sure the process is safe to kill. If this method returns false, it will have set a timer to post
// another KILL event in a few seconds, thus giving the process a chance to clean up.
if (!process_manager_make_process_safe_to_kil... | if (process_metadata_get_run_level(app_md) < s_minimum_run_level) {
PBL_LOG(LOG_LEVEL_WARNING,
"Ignoring launch for app <%s>, minimum run level %d, app run level %d",
process_metadata_get_name(app_md), s_minimum_run_level,
process_metadata_get_run_level(app_md));
app_install_release_md(... |
s_next_app = (NextApp) {
.md = app_md,
.common = config->common,
};
s_next_app.common.transition = prv_get_transition(&config->common, new_app_id);
if ((config->common.reason == APP_LAUNCH_WAKEUP) && (config->common.args != NULL)) {
WakeupInfo *wakeup_info = (WakeupInfo *)config->common.args;
... |
;
pfs_init(false);
weather_db_init();
weather_shared_data_init();
}
void test_weather_db__cleanup(void) {
weather_shared_data_cleanup();
}
// Tests
////////////////////////////////////////////////////////////////
static void prv_db_iterator_cb(WeatherDBKey *key, WeatherDBEntry *entry, void *unused) {
weathe... | {
WeatherDBKey keys[WEATHER_DATA_SHARED_WEATHER_DB_NUM_DB_ENTRIES];
cl_assert_equal_i(S_SUCCESS, weather_db_get_keys(keys));
for(int x = 0; x < WEATHER_DATA_SHARED_WEATHER_DB_NUM_DB_ENTRIES; x++) {
cl_assert(weather_shared_data_get_key_exists(&keys[x]));
}
} |
void test_weather_db__read_stale_entries(void) {
WeatherDBKey key = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
size_t entry_size = weather_shared_data_insert_stale_entry(&key);
uint8_t *buf = task_zalloc_check(entry_size);
cl_assert_equal_i(E_DOES_NOT_EXIST, weather_db_read((uint8_t*)&key,
... |
aitingUserConfirmation) {
prv_exit_awaiting_user_confirmation(data);
} else if (data->ui_state != BTPairingUIStateAwaitingResult) {
PBL_LOG(LOG_LEVEL_WARNING,
"Got completion (%u) but not right state", success);
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Got Completion! %u", success);
data->ui... | {
PebbleBluetoothPairEvent pair_event = {
.type = PebbleBluetoothPairEventTypePairingComplete,
.ctx = ctx,
.success = success,
};
prv_put_pairing_event(&pair_event);
} | |
{
case LinkState_Stopping:
case LinkState_RequestSent:
case LinkState_AckReceived:
case LinkState_AckSent:
prv_transition_to(this, LinkState_Stopped);
break;
case LinkState_Closing:
prv_transition_to(this, LinkState_Closed);
break;
default:
bre... |
}
mutex_unlock(this->state->lock);
}
static bool prv_handle_configure_request(PPPControlProtocol *this,
struct LCPPacket *packet) {
if (ntoh16(packet->length) == LCP_HEADER_LEN) { // The request has no options
prv_send_configure_ack(this, packet);
return true;
... | |
rt -= SECONDS_PER_DAY;
}
prv_display_alert(data->debug_card.dialog_text);
}
// -------------------------------------------------------------------------------
static void sleep_select_click_handler(ClickRecognizerRef recognizer, void *context) {
}
// ------------------------------------------------------------... | (data->sleep_card.text_layer) | ;
data->sleep_card.text_layer = NULL;
}
// -------------------------------------------------------------------------------
static void steps_select_click_handler(ClickRecognizerRef recognizer, void *context) {
HealthAPITestAppData *data = (HealthAPITestAppData *)context;
data->lap_steps = data->cur_steps;
pe... |
0 degrees (-90 * 5 -> -90) should be (-5, 0)
result = gpoint_from_polar_internal(¢er, radius, -(TRIG_MAX_ANGLE * 5 / 4));
cl_assert_equal_gpoint(result, GPoint(-5, 0));
// 450 degrees (90 * 5 -> 90) should be (0, 5)
result = gpoint_from_polar_internal(¢er, radius, (TRIG_MAX_ANGLE * 5 / 4));
cl_assert... | GRect(-5, -5, 0, 0) | , grect_centered_internal(&p4, GSize(0, 0)));
cl_assert_equal_grect(GRect(-6, -6, 1, 2), grect_centered_internal(&p4, GSize(-1, -2)));
// handles fixed point
cl_assert_equal_grect(GRect(-6, -6, 2, 2), grect_centered_internal(&p4, GSize(2, 2)));
p4.x.raw_value += FIXED_S16_3_HALF.raw_value;
cl_assert_equal_gr... |
/*
* 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... | (max_text_container_frame.size.w,
max_text_container_frame.size.h - title_line_height) |
};
instruction_frame.size = graphics_text_layout_get_max_used_size(ctx, instruction_text,
instruction_font,
instruction_frame,
... |
de "drivers/spi_dma.h"
#include "drivers/dma.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "system/passert.h"
#include "util/math.h"
#include "util/units.h"
#define STM32F2_COMPATIBLE
#define STM32F4_COMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
//! Deduced by looking at the presc... | {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI5;
bus->state->spi_clock_periph_speed = clocks.PCLK2_Frequency;
bus->state->spi_apb = SpiAPB_2;
#endif
#ifdef SPI6
} | else if (bus->spi == SPI6) {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI6;
bus->state->spi_clock_periph_speed = clocks.PCLK2_Frequency;
bus->state->spi_apb = SpiAPB_2;
#endif
}
}
static uint16_t prv_spi_find_prescaler(const SPIBus *bus) {
int lg;
if (bus->state->spi_clock_speed_hz > (bus->stat... |
ion.end, region.end);
bool failed = true;
if (stress_data.stress_index == FILE_WRITE_STRESS) {
failed = (!check_region_erased(region) || !check_region_write(region, true, true));
} else if (stress_data.stress_index == FILE_SUBSECTOR_STRESS) {
failed = (!check_region_erased(region) || !check_subsector_bit... | {
s_flash_regions[1].name = "Unused Resources";
} | |
utRequest *put_msg = (PutRequest *)buffer;
*put_msg = (PutRequest) {
.cmd = CmdPut,
.cookie = htonl(cookie),
.payload_size = htonl(payload_size),
};
memcpy(&put_msg->payload[0], payload, payload_size);
prv_receive_data(s_session, buffer, sizeof(buffer));
}
static void prv_receive_commit(uint32_t co... | fake_event_reset_count() | ;
Transport *transport = fake_transport_create(TransportDestinationSystem, NULL,
prv_system_msg_sent_callback);
s_session = fake_transport_set_connected(transport, true /* connected */);
cl_assert_equal_p(comm_session_get_system_session(), s_session);
prv_process... |
window_get_user_data(window) | ;
kino_layer_deinit(&data->logo_layer);
// Execute conditional only if the user presses back while the splash screen is showing
if (data->timer) {
app_timer_cancel(data->timer);
const bool animated = true;
app_window_stack_pop_all(animated);
}
app_free(data);
}
static void prv_window_load(Window ... | |
b->tag), gap_le_connect_is_connected_as_slave());
// Set to next job (round-robin) that isn't silent (unless there is no non-silent one):
s_jobs = (GAPLEAdvertisingJob *) job->node.next;
while (prv_is_current_term_silent(s_jobs) &&
s_jobs != job /* looped around */) {
s_jobs = (GAPLEAdvert... | (next->tag) | |
ion *session) {
// we want to write-back the first item in the dirty list
BlobDBDirtyItem *dirty_item = session->dirty_list;
int item_size = blob_db_get_len(session->db_id, dirty_item->key, dirty_item->key_len);
if (item_size == 0) {
// item got removed during the sync. Go to the next one
blob_db_sync_n... | if (session) {
// already have a session in progress!
return E_BUSY;
} | |
-112, 896, -256},
{ -112, 904, -248},
{ -120, 896, -256},
// 15 seconds
{ -120, 904, -256},
{ -120, 904, -256},
{ -120, 904, -248},
{ -112, 904, -248},
{ -120, 896, -256},
{ -112, 904, -256},
{ -112, 904, -248},
{ -120, 904, -256},
{ -112, 904, -248},
{ -120, 904, -24... | { -112, 928, -40},
{ -120, 928, -40},
{ -120, 928, -40},
{ -120, 928, -40},
{ -120, 936, -32},
{ -120, 928, -40},
{ -120, 928, -40},
{ -120, 928, -40},
{ -120, 928, -40},
{ -112, 928, -32},
{ -128, 944, -32},
{ -128, 928, -32},
{ -120, 928, -32},
{ -112, 920, -40}... |
{ -112, 936, -32},
{ -112, 928, -24},
{ -112, 936, -32},
{ -112, 936, -32},
{ -112, 928, -32},
{ -112, 928, -24},
{ -112, 928, -24},
{ -112, 936, -32},
{ -112, 928, -24},
{ -104, 912, -24},
{ -112, 928, -16},
{ -112, 920, -32},
{ -112, 936, -24},
{ -112, 928, -16... |
ual_b(shared_prf_storage_get_getting_started_complete(), false);
}
void test_shared_prf_storage_v3__ble_pairing(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_ble_pairing_data(NULL, NULL, NULL, NULL), false);
shared_prf_storage_store_ble_pairing_data(&PAIRING_INFO, DEVICE_NAME,
... | cl_assert_equal_s(DEVICE_NAME, device_name_out) | ;
}
// Test that setting a local_name to NULL will rewrite the field with 0xFF and allow it to
// be rewritten without causing a new page to be written
void test_shared_prf_storage_v3__local_device_name_NULL_new_erased_field(void) {
shared_prf_storage_set_local_device_name(DEVICE_NAME);
char device_name_out[BT_DE... |
ndow(39, &data->channel, "Channel", data);
break;
#if CAPABILITY_HAS_BUILTIN_HRM
case RXMenuIdx_HRM:
data->is_hrm_enabled = !data->is_hrm_enabled;
menu_layer_reload_data(menu_layer);
break;
#endif
#if CAPABILITY_HAS_MICROPHONE
case RXMenuIdx_Microphone:
data->is_mic_e... | xSemaphoreCreateBinary() | ,
};
app_state_set_user_data(data);
window_init(&data->main_menu_window, "");
window_init(&data->txrx_window, "");
window_init(&data->payload_window, "");
prv_status_window_init(data);
prv_init_main_menu(data);
app_window_stack_push(&data->main_menu_window, true);
app_event_loop();
}
const Pebbl... |
ay = true;
result->expected_size = size;
// Read back:
DictionaryIterator iter;
Tuple *tuple = dict_read_begin_from_buffer(&iter, data, size);
cl_assert(tuple != NULL);
cl_assert(iter.dictionary->count == 3);
}
void test_dict__tuplets_utils(void) {
Tuplet tuplets[] = {
TupletBytes(SOME_DATA_KEY, SOM... | (SOME_STRING) | ] == 0);
string_found = true;
break;
case SOME_UINT8_KEY:
cl_assert(tuple->length == sizeof(uint8_t));
cl_assert(tuple->value->uint8 == 8);
uint8_found = true;
break;
case SOME_UINT16_KEY:
cl_assert(tuple->length == sizeof(uint16_t));
cl_assert... |
Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*... | {
char *msg = msg_arr[i];
uint32_t addr = flash_logging_log_start(strlen(msg));
cl_assert(addr != FLASH_LOG_INVALID_ADDR);
bool rv = flash_logging_write((uint8_t *)msg, addr, strlen(msg));
cl_assert(rv);
} |
ExpectedMessage newmsg = {
.msg_arr = msg_arr,
.curr_msg_idx = 0,
.num_items = (num_items + 1), // + 1 for build id line
.num_processed = 0,
};
s_msg = newmsg;
s_completed = false;
bool success = flash_dump_log_file(log_gen, prv_flash_log_line_dump,
prv... |
dress(void) {
cl_will_return(bt_persistent_storage_has_pinned_ble_pairings, false);
cl_will_return(bt_persistent_storage_set_ble_pinned_address, true);
cl_will_return(bt_driver_set_local_address, 0);
s_last_bt_persist_pinned_addr_is_null = true;
bt_local_addr_init();
}
static void prv_assert_driver_addr_is_n... | (bt_driver_set_local_address, 0) | ;
bt_local_addr_pause_cycling();
cl_assert_equal_b(false, s_last_driver_allow_cycling);
prv_assert_driver_addr_is_addr1();
// Pin, expect pinned address to be sent to BT driver:
cl_will_return(bt_driver_set_local_address, 0);
cl_will_return(bt_persistent_storage_has_pinned_ble_pairings, true);
bt_local_a... |
(idx == count) | ;
}
}
return count;
}
| |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_WARNING, "Unexpected command received, 0x%x", cmd) | ;
return;
}
#else
prv_send_ack_nack(false /*ok*/);
#endif
}
|
,
.qspi_id = 0xAF,
.block_lock = 0xE5,
.block_lock_status = 0xE8,
},
.status_bit_masks = {
.busy = 1 << 0,
.write_enable = 1 << 1,
},
.flag_status_bit_masks = {
.erase_suspend = 1 << 6,
},
.dummy_cycles = {
.fast_read = 10,
.fast_read_ddr = 8,
},
.block_lock = {
.has... | (QSPI_FLASH, buffer, start_addr, len) | ;
}
status_t flash_impl_get_write_status(void) {
return qspi_flash_get_write_status(QSPI_FLASH);
}
status_t flash_impl_enter_low_power_mode(void) {
qspi_flash_set_lower_power_mode(QSPI_FLASH, true);
return S_SUCCESS;
}
status_t flash_impl_exit_low_power_mode(void) {
qspi_flash_set_lower_power_mode(QSPI_FLASH,... |
{ 1240, 424, -144},
{ 1608, 376, 16},
// 16 seconds
{ 1648, 488, 48},
{ 1096, 408, -8},
{ 1032, 256, 48},
{ 1256, 152, 136},
{ 1320, 80, 272},
{ 1104, 104, 224},
{ 992, 80, 168},
{ 904, 80, 120},
{ 872, 32, 136},
{ 792, 48, 64},
{ 712, -16, 64},
{ 664, -48, 0},
... | { 1424, 448, 104},
{ 1064, 232, 80},
{ 1328, 200, 120},
{ 1480, 72, 248},
{ 1424, 64, 256},
{ 1232, -8, 296},
{ 1088, -8, 232},
{ 984, 0, 216},
// 22 seconds
{ 856, 8, 176},
{ 808, -32, 144},
{ 808, -88, 120},
{ 848, -48, -8},
{ 936, 0, -144},
{ 1440, -232, 80... |
{ 1568, -144, 184},
{ 1536, 152, 160},
{ 1288, 376, -8},
{ 1376, 288, 80},
{ 1224, 312, 248},
{ 1040, 280, 272},
{ 1008, 224, 240},
{ 936, 248, 160},
{ 824, 280, 88},
{ 816, 312, 32},
{ 880, 544, -24},
{ 1048, 696, -8},
{ 1216, 632, 32},
// 25 seconds
{ 1368,... |
/*
* 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(ancs_util_get_attr_ptrs(msg->attributes_data, attributes_length, s_fetched_notif_attributes,
NUM_FETCHED_NOTIF_ATTRIBUTES, attr_ptrs, &error)) | ;
cl_assert(!error);
ANCSAttribute* message = (ANCSAttribute*) attr_ptrs[3];
cl_assert(strncmp((char*) message->value, expected_message, message->length) == 0);
free(b);
}
void test_ancs_util__should_detect_duplicate_message(void) {
#if(0)
// Extract the dict
static const char* expected_message = "This ... |
/*
* 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... | (true == text_layer_calc_text_flow_paging_values(&text_layer, NULL, &page)) | ;
cl_assert(true == text_layer_calc_text_flow_paging_values(&text_layer, NULL, NULL));
cl_assert(false == text_layer_calc_text_flow_paging_values(NULL, NULL, NULL));
cl_assert_equal_gpoint(origin, text_layer.layer.frame.origin);
cl_assert_equal_gpoint(page.origin, origin);
cl_assert_equal_gsize(page.size, GS... |
state == ANCSClientStateRequestedApp) {
prv_handle_app_attributes_response(data, length);
} else if (s_ancs_client->state == ANCSClientStateRequestedNotification ||
s_ancs_client->state == ANCSClientStateReassemblingNotification) {
prv_reassemble_ds_notification(length, data);
}
}
void ancs_ha... | (sizeof(PerformNotificationActionMsg)) | ;
*action_msg_ptr = (const PerformNotificationActionMsg) {
.command_id = CommandIDPerformNotificationAction,
.notification_uid = notification_uid,
.action_id = action_id,
};
if (is_kernel_main) {
prv_serialize_action(action_msg_ptr);
} else {
launcher_task_add_callback(prv_serialize_action_l... |
/*
* 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... | {
// Need to disable button wakeup functionality
// or the buttons don't register input
PWR_WakeUpPinCmd(PWR_WakeUp_Pin1, DISABLE);
PWR_WakeUpPinCmd(PWR_WakeUp_Pin2, DISABLE);
PWR_WakeUpPinCmd(PWR_WakeUp_Pin3, DISABLE);
periph_config_enable(RCC_APB2PeriphClockCmd, RCC_APB2Periph_SYSCFG);
initialize_butt... | |
--------------------------------------------------------
// Structures
typedef struct {
TextLayer *text_layer;
char text[256];
} ResultsCard;
typedef struct {
char dialog_text[256];
SimpleMenuItem *menu_items;
SimpleMenuLayer *menu_layer;
} DebugCard;
typedef struct {
TextLayer *cur_step_layer;
TextLay... | (metric, day_start, day_start + SECONDS_PER_DAY) | ;
char elapsed[8];
prv_convert_seconds_to_time(value, elapsed, sizeof(elapsed));
APP_LOG(APP_LOG_LEVEL_DEBUG, "%d: %s", i, elapsed);
char temp[32];
snprintf(temp, sizeof(temp), "\n%d: %s", i, elapsed);
prv_safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text));
... |
CENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under... | cl_assert_equal_i(s_flush_addr, 0x20) | ;
cl_assert_equal_i(s_flush_size, 0x08);
cl_assert_equal_i(s_invalidate_addr, 0x20);
cl_assert_equal_i(s_invalidate_size, 0x08);
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Invalid);
}
void test_cpu_cache__userspace_ignore(void) {
cl_will_return(icache_is_enabled, true);
cl_will_return(dcache_is_enab... |
/*
* 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... | for (int i = 0; i < metric_values->num_values; i++) {
cl_assert_equal_i(metric_values->values[i], other->values[i]);
} |
}
static void prv_check_attribute_list_serialize(AttributeList *attr_list_to_serialize,
const uint8_t *expected_attr_list_serialized,
size_t expected_attr_list_serialized_size) {
uint8_t buffer[expected_attr_list_serialized_size];
con... |
/*
* 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... | strncpy(data.model, model, sizeof(data.model)) | ;
data.model[MFG_INFO_MODEL_STRING_LENGTH - 1] = '\0';
prv_update_struct(&data);
}
GPoint mfg_info_get_disp_offsets(void) {
// Not implemented. Can just assume no offset
return (GPoint) {};
}
void mfg_info_set_disp_offsets(GPoint p) {
// Not implemented.
}
void mfg_info_update_constant_data(void) {
// No... |
_up_down_click_handler(ClickRecognizerRef recognizer, void *context) {
TimelineAppData *data = context;
prv_inactive_timer_refresh(data);
ButtonId button = click_recognizer_get_button_id(recognizer);
const bool next = (button == BUTTON_ID_UP) ^
(data->timeline_model.direction == TimelineIterDirectionFutur... | {
for (int i = 0; i < TIMELINE_NUM_VISIBLE_ITEMS; i++) {
if (timeline_model_get_iter_state(i)->node &&
uuid_equal(&timeline_model_get_iter_state(i)->pin.header.id, id)) {
prv_refresh_pin(data, i);
}
}
prv_update_timeline_layer(data);
} | |
continue;
}
// If buffer has room, read more data
uint32_t samples_drained = 0;
while (state->num_samples < state->samples_per_update) {
// Read available data.
AccelManagerBufferData data;
if (!shared_circular_buffer_read_subsampled(
&s_buffer, &state->buffer_client, siz... | prv_shake_add_subscriber_cb(PebbleTask_KernelMain) | ;
analytics_external_collect_accel_xyz_delta();
}
static void prv_copy_accel_sample_to_accel_data(AccelDriverSample const *accel_sample,
AccelData *accel_data) {
*accel_data = (AccelData) {
.x = accel_sample->x,
.y = accel_sample->y,
.z = accel_sample->z... |
ERTN(payload != NULL);
uint8_t *buf_end = (uint8_t *)string_buffer + string_buffer_size;
return attributes_actions_deserialize(&item->attr_list, &item->action_group,
(uint8_t*) string_buffer, buf_end, payload, payload_size);
}
void timeline_item_destroy(TimelineItem* item)... | prv_item_find_action(item, prv_action_dismiss_compare_func, NULL) | ;
}
static bool prv_action_reply_compare_func(const TimelineItemAction *action, void* data) {
return (action->type == TimelineItemActionTypeAncsResponse) ||
(action->type == TimelineItemActionTypeResponse);
}
TimelineItemAction *timeline_item_find_reply_action(const TimelineItem *item) {
return prv_item_fin... |
// allowed for data logging
static bool prv_make_file_system_space(uint32_t needed) {
// Make sure we have at least 'needed' bytes free in the file system
uint32_t used_space = prv_get_total_file_system_bytes();
if (used_space + needed >= DLS_MAX_DATA_BYTES) {
dls_list_for_each_session(prv_compact_session_cb... | {
bool success = false;
PBL_ASSERTN(session->storage.fd == DLS_INVALID_FILE);
// Open/create the file
// We always reserve enough space to create a file of DLS_FILE_INIT_SIZE_BYTES, so no need to
// check the quota (see calculation of DLS_MAX_DATA_BYTES).
if (!prv_open_file(&session->storage, OP_FLAG_WRITE... |
+ prv_get_desired_free_bytes(session);
target_file_size = MAX(target_file_size, DLS_FILE_INIT_SIZE_BYTES);
uint32_t optimum_delta_size = target_file_size - file_size;
bool have_space_to_grow = prv_make_file_system_space(optimum_delta_size);
if (!have_space_to_grow) {
// If we d... |
def struct TestReelData {
uint32_t elapsed_ms;
uint32_t duration_ms;
} TestReelData;
static int s_num_destructor_calls;
static void prv_destructor(KinoReel *reel) {
s_num_destructor_calls++;
free(kino_reel_custom_get_data(reel));
}
static uint32_t prv_elapsed_getter(KinoReel *reel) {
return ((TestReelData*... | (animation,
ANIMATION_NORMALIZED_MAX - ANIMATION_NORMALIZED_MAX * 20 / 300) | |
////////////////////////////////
//! Detected Workout
static void prv_detected_workout_up_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutAppData *data = context;
if (workout_service_takeover_activity_session(&data->ongoing_session)) {
prv_prep_and_open_active_window(data->ongoing_session... | {
/// Health disabled text
static const char *msg = i18n_noop("Enable Pebble Health in the mobile app to track workouts");
health_tracking_ui_show_message(RESOURCE_ID_HEART_TINY, msg, true);
return;
} | |
_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_... | (prv_count_handler_entries(&s_stopped_handler_calls, complex), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1);
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_last_update_distance(c), ANIMATION_NORMALIZED_MAX);
// Mak... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.