prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
TREAM1_DEVICE,
.channel = 4,
.irq_priority = IRQ_PRIORITY_INVALID, // no interrupts
.priority = DMARequestPriority_High,
.type = DMARequestType_PeripheralToMemory,
.data_size = DMARequestDataSize_Byte,
};
static DMARequestState s_sharp_spi_tx_dma_request_state;
static DMARequest SHARP_SPI_TX_DMA_REQUEST = {
... | IRQ_MAP(I2C2_ER, i2c_hal_error_irq_handler, &I2C_2V5_BUS) | ;
// VOLTAGE MONITOR DEVICES
static const VoltageMonitorDevice VOLTAGE_MONITOR_ALS_DEVICE = {
.adc = ADC2,
.adc_channel = ADC_Channel_12,
.clock_ctrl = RCC_APB2Periph_ADC2,
.input = {
.gpio = GPIOC,
.gpio_pin = GPIO_Pin_2,
},
};
static const VoltageMonitorDevice VOLTAGE_MONITOR_BATTERY_DEVICE = {
... |
/*
* 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... | (str, STR_SIZE, "ab%%c % E zz", 1.0) | ;
cl_assert_equal_s(str, fp_msg);
pbl_snprintf(str, STR_SIZE, "ab%%c % d zz", 42);
cl_assert_equal_s(str, "ab%c 42 zz");
//----------------------------------------------------
pbl_snprintf(str, STR_SIZE, "abc %-5e%s", "a", 1.0, "b");
cl_assert_equal_s(str, fp_msg);
pbl_snprintf(str, STR_SIZE, "abc %-5d%... |
manager__subscription(void) {
AppInstallId app_id = 1;
const uint32_t update_interval_s = 1;
const uint16_t expire_s = SECONDS_PER_MINUTE;
HRMFeature features = HRMFeature_BPM;
HRMSessionRef session_ref = sys_hrm_manager_app_subscribe(app_id, update_interval_s, expire_s,
... | cl_assert_equal_i(s_events_received[2].type, PEBBLE_HRM_EVENT) | |
oke_width = 1,
.fill_color = GColorOrange,
.radius = 300,
.num_points = 1,
};
command->points[0] = (GPoint) { 1, 2 };
command = gdraw_command_list_get_command(&frame->command_list, 2);
GPoint points2[] = { { 6, 7 }, {5, 5}, { 0, 0 } };
*command = (GDrawCommand) {
.type = GDrawCommandTypePath,... | (sequence, 0) | );
frame = gdraw_command_sequence_get_frame_by_elapsed(sequence, (45 + 15) * 5);
cl_assert_equal_p(frame, gdraw_command_sequence_get_frame_by_index(sequence, 1));
// test that the sequence returns the last frame if the play count is zero
sequence->play_count = 0;
frame = gdraw_command_sequence_get_frame_by_e... |
/*
* 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[12] = { };
itoa(val, buffer, sizeof(buffer));
debug_print_str(buffer);
} |
void debug_print_str_and_int(char *str, int value) {
debug_print_str(str);
debug_print_hex(value);
debug_print_str("\n");
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
window_destroy(window);
} |
int main(void) {
init();
app_event_loop();
deinit();
}
|
-936},
{ -416, 184, -936},
{ -416, 192, -936},
{ -416, 184, -936},
{ -408, 192, -936},
{ -416, 192, -936},
{ -424, 192, -936},
{ -416, 184, -936},
{ -416, 184, -936},
{ -416, 184, -936},
{ -408, 184, -936},
{ -416, 184, -936},
{ -416, 192, -936},
{ -416, 184, -936},
... | { -416, 184, -936},
{ -416, 184, -928},
{ -416, 192, -944},
{ -408, 192, -936},
{ -416, 192, -936},
{ -408, 184, -936},
{ -416, 184, -936},
{ -416, 184, -928},
{ -416, 192, -936},
{ -416, 184, -936},
{ -416, 192, -936},
{ -408, 184, -936},
// 141 seconds
{ -416, 1... |
{ -448, 256, -920},
{ -440, 304, -888},
{ -440, 368, -880},
{ -432, 384, -848},
{ -448, 400, -816},
{ -448, 384, -832},
{ -456, 392, -824},
{ -464, 416, -824},
{ -440, 376, -832},
{ -456, 368, -832},
{ -456, 368, -840},
{ -456, 408, -832},
{ -464, 392, -824},
{ -... |
for (int i = 0; i < NUM_RX_BUFFERS; ++i) {
if (s_buffers[i].is_free) {
s_buffers[i].is_free = false;
s_curr_buf = &s_buffers[i];
break;
}
} |
if (!s_curr_buf) {
// no available buffer :(
if (!has_no_buffer) {
s_no_buffer_count++;
}
has_no_buffer = true;
s_dropped_char_count++;
return false;
}
}
has_no_buffer = false;
return prv_handle_data((uint8_t)c);
}
// Other exported functions
///////////////... | |
(BlobDBIdTest) == S_SUCCESS);
prv_generate_responses_from_phone();
cl_assert_equal_i(s_num_writebacks, 5);
}
void test_blob_db_sync__sync_oom(void) {
char *keys[] = { "key1", "key2", "key3", "key4", "key5" };
int key_len = strlen(keys[0]);
char *values[] = { "val1", "val2", "val3", "val4", "val5" };
int v... | (BlobDBIdReminders) | ;
// check we can conjure them by id
BlobDBSyncSession *test_session = blob_db_sync_get_session_for_id(BlobDBIdTest);
cl_assert(test_session);
cl_assert_equal_i(test_session->db_id, BlobDBIdTest);
BlobDBSyncSession *pins_session = blob_db_sync_get_session_for_id(BlobDBIdPins);
cl_assert(pins_session);
cl... |
wn event
cl_assert_passert(touch_handle_update(0, TouchState_FingerDown, NULL, 5, 3686400));
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 0, 0);
// NULL position not valid for position update event
cl_assert_passert(touch_handle_update(0, TouchState_FingerDown, NULL, 5, 3686400));
}
void test_t... | GPoint(13, 13) | , 6, 3686420);
touch_handle_update(0, TouchState_FingerDown, &GPoint(15, 15), 6, 3686440);
touch_handle_update(1, TouchState_FingerDown, &GPoint(55, 55), 2, 3686480);
touch_handle_update(1, TouchState_FingerDown, &GPoint(33, 33), 7, 3686500);
touch_handle_driver_event(TouchDriverEvent_ControllerError);
Pebbl... |
/*
* 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(config.units, 0) | ;
}
void test_rtc_calibration__just_fast_enough_to_calibrate(void) {
// Approximately +1.04ppm
RTCCalibConfig config = rtc_calibration_get_config(32768034, TARGET_FREQUENCY_mHZ);
cl_assert_equal_i(config.units, 1);
cl_assert_equal_i(config.sign, RTC_CalibSign_Negative);
}
void test_rtc_calibration__out_of_bou... |
sion_entries; i++) {
time_t end_utc;
if (activity_sessions_prv_is_sleep_activity(sessions[i].type)) {
end_utc = sleep_earliest_end_utc;
} else {
end_utc = step_earliest_end_utc;
}
// See if we should keep this activity
time_t end_time = sessions[i].start_utc + (sessions[i].length_mi... | activity_private_state() | ;
mutex_lock_recursive(state->mutex);
{
if (!session->ongoing) {
state->need_activities_saved = true;
}
// Modifying a sleep session?
if (activity_sessions_prv_is_sleep_activity(session->type)) {
state->sleep_sessions_modified = true;
}
// If this is an existing activity, updat... |
r) {
*max_subsequent_failures = s_max_subsequent_error_count_since_last_log;
s_should_log_about_mic_error = false;
s_max_subsequent_error_count_since_last_log = 0;
return true;
}
return false;
}
static void prv_mic_error_resilience_workaround(struct co_buf_rx_desc *rxdesc) {
// MT: PBL-39297 -- ... | _Static_assert(ARRAY_LENGTH(s_orig_functions) == ARRAY_LENGTH(s_patched_functions), "") | ;
void __wrap_patch_rom_functions(void) {
// Disable all patches:
PATCH->PATCH_VALID_RESET_REG = ~0;
// Execute original first:
__real_patch_rom_functions();
const size_t max_patches = 28;
const size_t bits_in_reg = sizeof(uint32_t) * 8;
uint32_t patch_enabled_bits = PATCH->PATCH_VALID_REG;
// Use co... |
x83, 0x1d, 0x3a,
0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef,
0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,
0x83, 0... | for(i = 0; i < 4; ++i)
{
for(j = 0; j < 4; ++j)
{
(*state)[j][i] = getSBoxValue((*state)[j][i]);
}
} |
}
// The ShiftRows() function shifts the rows in the state to the left.
// Each row is shifted with different offset.
// Offset = Row number. So the first row is not shifted.
static void ShiftRows(void)
{
uint8_t temp;
// Rotate first row 1 columns to left
temp = (*state)[0][1];
(*state)[0][1] = (*... |
mber of retries. In that case, we will start dropping the oldest
// minute data from data logging.
PBL_LOG(LOG_LEVEL_ERROR, "Circular buffer overrun");
success = shared_circular_buffer_write(&s_alg_state->minute_data_cbuf, (uint8_t *)minute_rec,
sizeof(*minute_rec)... | if (session->type == ActivitySessionType_Nap) {
most_recent_nap_session = session;
} | |
_caption_dict);
s_num_ds_notifications_received++;
} else if (uid == mms_with_caption_dict_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_mms_with_caption_dict), (uint8_t *)s_mms_with_caption_dict);
s_num_ds_notifications_received++;
} else if (uid == s_get_wrong_data_uid) {
// We wanted a... | (s_num_ds_notifications_received, 1) | ;
// Assert it got filtered out:
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
// Get notification for which we'll get a "This message has no content." response:
prv_send_notification((uint8_t *)&s_this_message_has_no_content_response);
cl_assert_equal_i(s_num_requested... |
PBL_IF_RECT_ELSE(GCornerNone, GCornersAll) | ,
.corner_radius = PBL_IF_RECT_ELSE(1, (cell_height / 2) - 1),
};
}
static int16_t prv_centered_offset_x(SelectionLayer *selection_layer) {
uint16_t total_width = 0;
for (uint32_t i = 0; i < selection_layer->num_cells; i++) {
if (selection_layer->cell_widths[i] == 0) {
continue;
}
total_wid... | |
ItemHeader header = { .common.id = UUID_INVALID };
bool found = prv_find_next_notification(&header, prv_uuid_equal_func, (void *)id, fd);
prv_file_close(fd);
return found;
}
static bool prv_get_notification(TimelineItem *notification,
SerializedTimelineItemHeader* header, int fd) {
notification->allocat... | {
PBL_LOG(LOG_LEVEL_ERROR, "Error writing status to notification header %d", result);
} |
// Seek to the end of the header
pfs_seek(fd, ((int)sizeof(*header) - (int)offsetof(CommonTimelineItemHeader, status) -
sizeof(header->common.status)), FSeekCur);
}
bool notification_storage_get_status(const Uuid *id, uint8_t *status) {
int fd = prv_file_open(OP_FLAG_READ);
bool rv = false;
if (fd < ... |
t = {
.num_attributes = 1,
.attributes = &title_attr,
},
};
static TimelineItem item4 = {
.header = {
.id = {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 100*60,
.duration = 10,
.type = TimelineItemTypePin,
.all... | (timer_id) | );
cl_assert(timeline_add(&item1));
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(5*60, stub_new_timer_timeout(timer_id) / 1000);
cl_assert(timeline_remove(&it... |
FLASH_TEST_CASE_RUN_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Addr Bus Test");
break;
case FLASH_TEST_CASE_RUN_STRESS_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Stress Addr Test");
break;
case FLASH_TEST_CASE_RUN_PERF_DATA_TEST:
text_layer_set_text(msg_text_layer, "Perf... | PBL_LOG(LOG_LEVEL_DEBUG, ">>>>>FAILED TEST CASE<<<<<") | |
sistent_storage_set_ble_pinned_address(const BTDeviceAddress *addr) {
shared_prf_storage_set_ble_pinned_address(addr);
return true;
}
bool bt_persistent_storage_has_pinned_ble_pairings(void) {
bool requires_address_pinning_out = false;
shared_prf_storage_get_ble_pairing_data(NULL, NULL, &requires_address_pinni... | shared_prf_storage_get_ble_pairing_data(&data, name, NULL, NULL) | |
tateSessionOpen;
prv_stop_session_closed_object_queue_timer();
prv_emit_post_message_connection_event(true /* is_connected */);
// Kick the object queue upon entering SessionOpen:
prv_outbox_try_send_next();
DBG("SessionOpen enter");
}
static void prv_session_open__after_exit(void) {
DBG("After Session... | dict_find(it, PostMessageKeyResetComplete) | ;
if (tuple) {
if (!prv_is_tuple_valid_reset_complete(tuple)) {
// TODO: document this in statechart
prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorMalformedResetComplete);
return;
}
const PostMessageResetCompletePayload *rc =
(const PostMessageRese... |
#include "clar.h"
#include "process_management/app_install_types.h"
#include "process_management/pebble_process_info.h"
#include "process_management/pebble_process_md.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/blob_db/app_db.h"
// Fixture
/////////////////////////////////////////////////... | uuid_equal(&app1.uuid, &temp.uuid) | );
cl_assert_equal_i(0 , strncmp((char *)&app1.name, (char *)&temp.name, APP_NAME_SIZE_BYTES));
// check app 2
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... |
/*
* 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... | {
struct {
uint32_t SCLL:8;
uint32_t SCLH:8;
uint32_t SDADEL:4;
uint32_t SCLDEL:4;
uint32_t reserved:4;
uint32_t PRESC:4;
};
uint32_t reg;
} | TIMINGR;
_Static_assert(sizeof(TIMINGR) == sizeof(uint32_t), "Invalid TIMINGR size");
uint32_t i2c_timingr_calculate(uint32_t i2c_clk_frequency,
I2CBusMode bus_mode,
uint32_t target_bus_frequency,
uint32_t rise_time_ns,
... |
g(ClickRecognizerRef recognizer_ref) {
ClickRecognizer *recognizer = (ClickRecognizer*)recognizer_ref;
return &recognizer->config;
}
static void prv_long_click_callback(void *data) {
ClickRecognizer *recognizer = (ClickRecognizer *) data;
recognizer->hold_timer = NULL;
const bool needs_reset = false;
prv_... | prv_is_long_click_enabled(recognizer) | ;
const bool local_is_multi_click_enabled = prv_is_multi_click_enabled(recognizer);
//const bool local_is_hold_to_repeat_enabled = is_hold_to_repeat_enabled(recognizer);
if (false == local_is_long_click_enabled &&
false == local_is_multi_click_enabled) {
// Handler already fired in button down.
prv... |
);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
// Setup content indicator
ContentIndicatorsBuffer *buffer... | (&card->window, &s_ctx) | |
= time_get_gmtoffset();
time_t orig_utc_time = rtc_get_time();
TimezoneInfo tz_adjust_info = {{0}};
if (clock_is_timezone_set()) { // We'll need to update timezone stamps.
time_t tz_adjust_time;
// Get the time that we need to adjust for.
if (t) {
tz_adjust_time = *t;
} else {
tz_adj... | {
PBL_LOG(LOG_LEVEL_WARNING, "Set timezone message invalid length");
return;
} | |
(s_ancs_client->attributes, 0, sizeof(s_ancs_client->attributes)) | ;
buffer_clear(&s_ancs_client->reassembly_ctx.buffer);
}
static bool prv_is_reassembly_in_progress(void) {
return (s_ancs_client->state == ANCSClientStateReassemblingNotification);
}
static bool prv_reassembly_start(const uint8_t* const data, const size_t length) {
PBL_ASSERTN(!prv_is_reassembly_in_progress());... | |
o { \
PostMessageChunkPayload chunk = {}; \
RCV_APP_MESSAGE(TupletBytes(PostMessageKeyChunk, (const uint8_t *) &chunk, sizeof(chunk))); \
} while(0);
//! Asserts whether the outbox has a pending message containing the tuples passed to this macro.
//! The value and type of the tuples is also asserted.
//! @no... | (true /* is_connected */) | ;
prv_simulate_transport_connection_event(false /* is_connected */);
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateDisconnected);
}
static void prv_init_and_goto_awaiting_reset_complete_remote_initiated(void) {
prv_init_api(true /* start_connected */);... |
ervice_refs,
num_services,
&bp_service->uuid);
cl_assert_equal_i(num_found_services, num_services);
// Test that the UUID matches the Blood Pressure UUID:
const Uu... | uuid_equal(&uuid1, &thermo_service->uuid) | ||
uuid_equal(&uuid1, &random_128bit_service->uuid));
cl_assert(uuid_equal(&uuid2, &thermo_service->uuid) ||
uuid_equal(&uuid2, &random_128bit_service->uuid));
}
|
en.size_h != 0;
const bool uses_perimeter = flow_data->perimeter.impl != NULL;
const GPoint perimeter_paging_offset =
uses_paging ? gpoint_sub(flow_data->paging.origin_on_screen, line->origin) : GPointZero;
Word prev_line_word = WORD_EMPTY;
while (!prv_line_iter_is_vertical_overflow(line_iter_state, text_bo... | // pushes down the remaining text far enough so it ends up on yet another page. This would
// enter an infinite loop.
// To avoid that, we only apply this strategy, when it's "safe" to do so (in theory, there's
// still the propability to run into this scenario if the perimeter isn't vertically symmetri... |
(line_is_first_line_page && prev_line_word.start && !is_text_remaining);
if (is_orphan) {
*current_word_ref = prev_line_word;
prv_apply_orphan_state(&orphan_state, line);
avoiding_orphans = false; // prevent infinte loops
goto render_line;
}
}
... |
/*
* 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... | args.push(arg) | ;
}
// FIXME: need to escape args?
var out = child_process.execSync(args.join(' '));
return 0;
} catch (e) {
console.error(e);
return -1;
}
}, argv);
}
#else // #ifdef EMSCRIPTEN
static int
shell_out(char * const argv[])
{
int status;
pid_t pid;
pid = fork();
if (pid... |
NOT_PERMITTED_MSG_HANDLER,
test_dropped_handler));
}
void test_app_inbox__app_inbox_create_and_register_drop_handler_not_permitted(void) {
// The syscall_failed() fake will trigger passert:
cl_assert_passert(app_inbox_create_and_r... | cl_assert_equal_b(false, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer)) | ;
cl_assert_equal_b(false, app_inbox_service_is_being_written_for_tag(AppInboxServiceTagUnitTest));
}
void test_app_inbox__app_inbox_service_begin_already_being_written(void) {
prv_create_test_inbox();
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
... |
/*
* 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... | __enable_irq() | |
d_data(&aml->menu_layer);
prv_set_selected_index(aml, selected_index, false /* animated */);
}
// Public API
/////////////////////
void action_menu_layer_click_config_provider(ActionMenuLayer *aml) {
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, prv_scroll_handler);
window_set_click_context(BUTTON_... | (aml, default_selected_item) | ;
}
|
ght_of(rtc_get_time()) + 1 * SECONDS_PER_DAY);
ActivityInsightSettings original_settings;
activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD, &original_settings);
ActivityInsightSettings disabled_settings = original_settings;
disabled_settings.enabled = false;
activity_insights_setti... | {
ActivityTestAppData *data = (ActivityTestAppData *)context;
// Test the sum function
if (event == HealthEventMovementUpdate) {
int32_t steps_today = health_service_sum_today(HealthMetricStepCount);
APP_LOG(APP_LOG_LEVEL_DEBUG, "Got steps update event.(today value: %d)",
(int) steps_today... |
// -------------------------------------------------------------------------------
// Tests
typedef struct {
const char *title;
AppTimerCallback callback;
} TestEntry;
static TestEntry s_test_entries[] = {
{
.title = "steps",
.callback = prv_test_steps,
}, {
.title = "30m walk",
.callback = ... |
e++;
cl_assert(stage < ARRAY_LENGTH(s_sys_activity_get_minute_history_values.out));
sys_activity_get_minute_history_out_values *out =
&s_sys_activity_get_minute_history_values.out[stage];
cl_assert_equal_b(out->asserts, false);
cl_assert(minute_data);
cl_assert(num_records);
cl_assert(utc_start);
... | cl_assert(result) | ;
cl_assert_equal_range(range, ((HealthServiceTimeRange){
.last_day_idx = 0,
.num_days = 1,
.seconds_first_day = 33142,
.seconds_last_day = 33142,
.seconds_total_last_day = 33142,
}));
// yesterday
result = prv_calculate_time_range(
time_util_get_midnight_of(now - SECONDS_PER_DAY), time... |
/*
* 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... | layer_set_hidden(action_bar_layer_get_layer(data->action_bar), !connected) | ;
#endif
layer_set_hidden(text_layer_get_layer(data->disconnected_text), connected);
if (!connected) {
// blank out text if we have no up-to-date data
text_layer_set_text(text[TextBack], NULL);
text_layer_set_text(text[TextMid], NULL);
text_layer_set_text(text[TextFront], NULL);
text_layer_set_... |
conds_to_ticks(I2C_ERROR_TIMEOUT_MS);
return (xSemaphoreTake(bus->event_semaphore, timeout_ticks) == pdPASS);
}
static void prv_semaphore_give(I2CBusState *bus) {
// If this fails, something is very wrong
(void)xSemaphoreGive(bus->event_semaphore);
}
static portBASE_TYPE prv_semaphore_give_from_isr(I2CBusState ... | {
// Don't power up rail if the bus is already in use (enable can be called to reset bus)
if (bus->state->user_count == 0) {
prv_bus_rail_power_up(bus);
}
prv_bus_pins_cfg_i2c(bus);
i2c_hal_enable(bus);
} |
//! De-initialize and gate the clock to the peripheral
//! Power down rail if the bus supports that and no devices are using it
//! Always lock the bus and peripheral config access before disabling it
static void prv_bus_disable(I2CBus *bus) {
i2c_hal_disable(bus);
// Do not de-power rail if there are still devi... |
/*
* 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... | (model_buffer) | ;
}
void command_model_write(const char* model) {
// mfg_info_set_model will truncate if the string is too long, so no need to check
mfg_info_set_model(model);
char written_model[MFG_INFO_MODEL_STRING_LENGTH];
mfg_info_get_model(written_model);
if (!strncmp(model, written_model, MFG_INFO_MODEL_STRING_LENGTH)... |
rt_equal_i(s_sys_activity_get_metric_values.in.history_len, ACTIVITY_HISTORY_DAYS);
}
#define cl_assert_equal_range(a, b) \
do { \
HealthServiceTimeRange r_a = (a); \
HealthServiceTimeRange r_b = (b); \
bool success = memcmp(&r_a, &r_b, sizeof(r_a)) == 0; \
if (!success) { \
char error_msg[256]... | (now - 100, now - 200, NULL) | ;
cl_assert_equal_b(result, false);
}
void test_health__range_to_day_id_clamps_values(void) {
const time_t now = rtc_get_time();
bool result;
HealthServiceTimeRange range;
// clamps value that goes into the future
result = prv_calculate_time_range(now - 10, now + 11, &range);
cl_assert_equal_b(result, t... |
e_repeat_interval_sec;
#if CAPABILITY_HAS_VIBE_SCORES
s_phone_ui_data->vibe_score = vibe_client_get_score(VibeClient_PhoneCalls);
if (!s_phone_ui_data->vibe_score) {
return;
}
unsigned int vibe_interval_ms = vibe_score_get_duration_ms(s_phone_ui_data->vibe_score) +
vibe_score_get_repeat_delay_ms(s_pho... | ("Disconnected", s_phone_ui_data->call_status_text_buf,
CALL_STATUS_BUFFER_LENGTH) | ;
} else {
if (s_phone_ui_data->call_start_time) {
i18n_get_with_buffer("Call Ended", s_phone_ui_data->call_status_text_buf,
CALL_STATUS_BUFFER_LENGTH);
} else {
i18n_get_with_buffer("Call Declined", s_phone_ui_data->call_status_text_buf,
CALL_... |
izerState_Completed);
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert(s_manager_state_change);
cl_assert_equal_i(event_type, RecognizerEvent_Completed);
s_manager_state_change = false;
r->handling_touch_event = true;
r->state = RecognizerState_Possible;
event_type = -1;
recognizer_tra... | recognizer_transition_state(r, RecognizerState_Completed) | ;
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert(!s_manager_state_change);
}
void test_recognizer__set_failed(void) {
bool failed = false;
s_test_impl_data.failed = &failed;
NEW_RECOGNIZER(r) = test_recognizer_create(&s_test_impl_data, NULL);
recognizer_set_failed(r);
cl_assert_equal_... |
system_reset() | ;
} else {
dbgserial_putstr("Failed to load recovery firmware, strike three. SAD WATCH");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_... | |
-56, -104, -1008},
{ -40, -56, -1024},
{ -64, -8, -1000},
{ -56, 40, -1024},
{ -72, 72, -1008},
{ -88, 80, -984},
{ -88, 112, -1000},
{ -112, 144, -1000},
{ -112, 192, -1024},
{ -120, 216, -1000},
{ -128, 184, -1000},
{ -144, 56, -912},
{ -104, -96, -896},
{ -96, -24... | { -240, 408, -888},
{ -208, 296, -904},
{ -232, 216, -960},
{ -232, 256, -976},
{ -160, 88, -984},
{ -112, 72, -1064},
{ -168, 176, -1072},
{ -192, 200, -1008},
{ -240, 240, -920},
{ -248, 320, -864},
// 218 seconds
{ -288, 440, -832},
{ -192, 360, -864},
{ -240, ... | |
he same ballpark but cover less distance
prv_set_user(Human_ShortMale);
int short_guy_distance = activity_private_compute_distance_mm(steps, time_ms) / MM_PER_METER;
cl_assert_within(short_guy_distance, 36000, 44000);
cl_assert_gt(long_run_distance_m, short_guy_distance);
// And finally throw in a specific v... | cl_assert_equal_i(5, activity_private_compute_resting_calories(short_time_m) / ACTIVITY_CALORIES_PER_KCAL) | |
http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing pe... | QSPI_ReceiveData8() | << (8 * i);
}
prv_wait_for_qspi_not_busy();
const uint32_t expected_whoami = 0x3725c2;
if (read_whoami == expected_whoami) {
return true;
} else {
return false;
}
}
void flash_init(void) {
prv_enable_qspi_clock();
// init GPIOs
for (unsigned i = 0; i < QSpiPinCount; ++i) {
gpio_af_init... |
rom_pbi("test_bitblt_palette_1bit__1bit_palette_to_1bit.pbi");
bitblt_bitmap_into_bitmap(&s_dest_bitmap, src_bitmap, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi_eq(&s_dest_bitmap,
"test_bitblt_palette_1bit__1bit_palette_to_1bit_assign-expect.pbi"));
gbitmap_destroy(src_bitma... | gbitmap_destroy(src_bitmap) | ;
}
// Tests assign, from same size to same size.
// Setup:
// - Source is 50x50, alternating lines between orange and blue for the top half.
// The bottom half is a diagonal orange line over blue.
// The left half is semi-transparent and the right half is completely opaque
// - Dest is 100x100, white.
// ... |
/*
* 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... | sys_app_comm_get_sniff_interval() | ;
}
|
ert(ret_features == features);
sys_hrm_manager_unsubscribe(session_ref);
fake_system_task_callbacks_invoke_pending();
cl_assert(prv_get_subscriber_state_from_ref(session_ref) == NULL);
cl_assert_equal_b(hrm_is_enabled(HRM), false);
}
// When we cleanup after an app process, its subscription, if any, should ge... | prv_fake_send_new_data() | ;
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(s_num_cb_events_1, 3);
cl_assert_equal_i(s_cb_events_1[1].event_type, HRMEvent_SubscriptionExpiring);
cl_assert_equal_i(s_cb_events_1[2].event_type, HRMEvent_BPM);
// Now advance time to past expiration time
rtc_set_time(rtc_get_time() + ex... |
false /* requires_address_pinning */,
false /* auto_accept_re_pairing */);
cl_assert_equal_i(id_1, id_X);
cl_assert_equal_i(s_ble_bonding_change_update_count, 1);
cl_assert_equal_i(fake_shared_prf_storage_get_ble_store_count(), 1);
//... | (id != BT_BONDING_ID_INVALID) | ;
// Read it back
ret = bt_persistent_storage_get_ble_pairing_by_addr(&pairing.identity, &irk_out, NULL);
cl_assert(ret);
cl_assert_equal_m(&irk_out, &pairing.irk, sizeof(irk_out));
}
void test_bluetooth_persistent_storage__delete_ble_pairing_by_id(void) {
bool ret;
// Output variables
SMIdentityR... |
defective_checksum_memory(
&frame->data, frame->length - sizeof(fcs));
if (fcs == crc) {
prv_reset_keepalive_timer();
uint8_t protocol = (uint8_t)frame->data[0];
bool protocol_found = false;
for (unsigned int i = 0; i < ARRAY_LENGTH(s_supported_protocols); ++i) {
if (s_supported_protocols... | (s_tx_buffer_mutex) | |
e) {
return prv_graphics_get_color_string(rocky_api_graphics_get_gcontext()->draw_state.stroke_color);
}
JERRY_FUNCTION(prv_set_fill_style) {
return prv_graphics_set_color(argc, argv, graphics_context_set_fill_color);
}
JERRY_FUNCTION(prv_get_fill_style) {
return prv_graphics_get_color_string(rocky_api_graphics... | (ctx_prototype) | ;
rocky_api_graphics_text_add_canvas_methods(ctx_prototype);
// Create the CanvasElement constructor:
JS_UNUSED_VAL = rocky_add_constructor(ROCKY_CANVAS_CONSTRUCTOR, prv_canvas_constructor);
}
static void prv_init_apis(void) {
prv_configure_top_window_and_create_constructors();
JS_VAR rocky = rocky_get_rock... |
/*
* 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 (characteristic == s_app_launch_characteristic);
} | |
graphics_draw_vertical_line_dotted(&ctx, GPoint(71, 91), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(67, 96), 5);
// T facing left - even vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(100, 90), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(100, 95), 5);
// T facing le... | graphics_context_set_stroke_width(ctx, 1) | |
/*
* 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 modal_manager_get_window_stack(ModalPriorityAlert);
} |
// ---------------------------------------------------------------------------
static void prv_select_handler(ClickRecognizerRef recognizer, void *context) {
ExpandableDialog *expandable_dialog = context;
expandable_dialog_pop(expandable_dialog);
}
// -------------------------------------------------------------... |
16Getter) prv_int16_getter },
},
};
prop_h = property_animation_create(&implementation, &value, &start_value, &end_value);
Animation *h = property_animation_get_animation(prop_h);
void *context = &value;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
animation_set_... | ("%"PRIu64": value at: (%d, %d)\n", time_ms - start_ms, value.x, value.y) | ;
cl_assert(max_loops > 0);
max_loops--;
}
// Make sure the frame reached the "to" state
cl_assert_equal_point(value, end_value);
// -------------------------------------------------------------------------------------------
// Test the GPoint accessor functions
GPoint test_value;
property_ani... |
,
uint8_t stroke_width,
GCornerMask quadrant) {
prv_stroke_circle_quadrant_full_override_aa(ctx, p, radius, stroke_width, quadrant, false);
}
void graphics_circle_quadrant_draw(GContext* ctx, GPoint ... | (ctx, p, radius) | ;
}
}
#if defined(PLATFORM_TINTIN)
NOINLINE // Save space on tintin
#else
ALWAYS_INLINE // Optimize for speed on other platforms
#endif
static void prv_fill_horizontal_line(GContext *ctx, GPoint p, int16_t width) {
graphics_fill_rect(ctx, &(GRect) { .origin = p, .size = { width, 1 } });
}
void graphics_circle_qua... |
RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 2);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 2);
graphics_draw_rect(&ctx, &ORIGIN_... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1) | ;
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 1);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq... |
.w;
const int16_t text_x_offset = (window_width - content_size.w) / 2;
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
const int16_t text_y_offset = 33;
#else
const int16_t text_y_offset = 22;
#endif
const GRect frame = { { text_x_offset, text_y_offset }, content_size };
layer_set_frame(&data->name_text_layer.layer,... | {
prv_show_spinner(s_fu_app_data);
} | else {
prv_hide_spinner(s_fu_app_data);
}
}
////////////////////
// App boilerplate
static void handle_init(void) {
launcher_block_popups(true);
RecoveryFUAppData *data = app_malloc_check(sizeof(RecoveryFUAppData));
s_fu_app_data = data;
*data = (RecoveryFUAppData){};
app_state_set_user_data(data);... |
__disable_irq() | ;
}
RtcTicks rtc_interval_ticks = get_rtc_interval_ticks();
check_and_handle_rollover(rtc_interval_ticks);
if (ints_enabled) {
__enable_irq();
}
return s_coarse_ticks + rtc_interval_ticks;
}
void rtc_set_time(time_t time) {
#ifdef PBL_LOG_ENABLED
char buffer[TIME_STRING_BUFFER_SIZE];
PBL_LOG(LOG... | |
/*
* 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_contacts_db.settings_file, key, key_len) | ;
prv_close_file_and_unlock_mutex();
return rv;
}
status_t contacts_db_read(const uint8_t *key, int key_len, uint8_t *val_out, int val_out_len) {
if (key_len != UUID_SIZE || val_out == NULL) {
return E_INVALID_ARGUMENT;
}
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
return... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
window_single_click_subscribe(BUTTON_ID_BACK, prv_button_click_handler);
window_single_click_subscribe(BUTTON_ID_UP, prv_button_click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, prv_button_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_button_click_handler);
} | |
andler = dropped_handler;
new_node->event_handler_task = pebble_task_get_current();
new_node->buffer.storage = storage;
new_node->buffer.size = storage_size;
s_app_inbox_head = (AppInboxNode *)list_prepend((ListNode *)s_app_inbox_head,
(ListN... | prv_mark_failed_if_no_writer(inbox) | ;
if (inbox->write_failed) {
goto unlock;
}
if (!prv_check_space_remaining(inbox, length)) {
inbox->write_failed = true;
goto unlock;
}
memcpy(inbox->buffer.storage + inbox->buffer.write_index + inbox->buffer.current_offset,
data, length);
inbox->buffer.current_offse... |
(/* argc == 0 */);
uint8_t v;
ROCKY_ARGS_ASSIGN(ROCKY_ARG(v));
ASSERT_JS_ERROR(error_value, "TypeError: Not enough arguments");
}
void test_rocky_api_util_args__numbers_get_rounded_when_converting_to_integer(void) {
struct {
double input;
int16_t expected_output;
} cases[] = {
{
.input = 0... | jerry_create_number(c->s32) | |
;
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, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 0);
// ------------------------------------------------------------------------... | (duration_b, duration_c) | ;
// Create 3 animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
Animation *c = prv_create_test_animation();
animation_set_duration(c, duration_c);
// Create a spawn out of b... |
ons and
* limitations under the License.
*/
#if !PULSE_EVERYWHERE
#include "pulse.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "console/cobs.h"
#include "console/console_internal.h"
#include "console/dbgserial.h"
#include "console/pulse_internal.h"
#include "console/pulse_llc.h"
#inclu... | (s_receive_buffers) | ; ++i) {
kernel_free(s_receive_buffers[i]);
}
s_current_receive_buffer = NULL;
new_timer_delete(s_keepalive_timer);
s_keepalive_timer = TIMER_INVALID_ID;
mutex_destroy(s_tx_buffer_mutex);
dbgserial_restore_baud_rate();
serial_console_set_state(SERIAL_CONSOLE_STATE_LOGGING);
}
void pulse_prepare_to... |
er_launch_new_worker_with_args(md, NULL);
} else {
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = md,
.common = config->common,
.forcefully = config->forcefully,
});
}
}
// ---------------------------------------------------------------------------------------------
extern void ana... | {
context->closing_state = ProcessRunState_GracefullyClosing;
PBL_LOG(LOG_LEVEL_DEBUG, "Attempting to gracefully deinit %s", pebble_task_get_name(task));
// Send deinit event to app:
PebbleEvent deinit_event = {
.type = PEBBLE_PROCESS_DEINIT_EVENT,
};
process_manager_send_e... |
// Else we're already in the gracefully closing state, just let the timer run out or the
// app to mark itself as safe_to_kill.
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Check if we can force stop the %s task", pebble_task_get_name(task));
if (prv_force_stop_task_if_unprivileged(context)) {
PBL_LOG(L... |
rv = true;
}
timeline_add(item);
timeline_item_destroy(item);
}
return rv;
}
// ------------------------------------------------------------------------------------------------
static bool prv_push_summary_pin(time_t pin_time_utc, time_t now_utc, Uuid *existing_uuid,
... | (LOG_LEVEL_ERROR, "Insight qualifying history length is too long: %"PRIu32,
history_len) | ;
return false;
}
ActivityScalarStore target =
((uint32_t)(stats->median * insight_settings->reward.target_percent_of_median)) / 100;
int32_t history[history_len];
activity_get_metric(stats->metric, history_len, history);
// Make sure enough days have been above the target
// (start at 1 since ... |
/*
* 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 (!s_data_ptr) {
return;
} |
// Reset the text box positions
layer_set_frame(&s_data_ptr->info_text_layer.layer, &s_data_ptr->pair_text_area);
layer_set_frame(&s_data_ptr->info_text_layer2.layer, &s_data_ptr->above_pair_text_area);
if (s_data_ptr->ui_state == BTPairingUIStateAwaitingUserConfirmation) {
// Reschedule animations
p... |
/*
* 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... | (buf, "app1") | ;
concat_str_int("app", 255, buf, sizeof(buf));
cl_assert_equal_s(buf, "app255");
concat_str_int("res_bank", 1, buf, sizeof(buf));
cl_assert_equal_s(buf, "res_bank1");
concat_str_int("res_bank", 255, buf, sizeof(buf));
cl_assert_equal_s(buf, "res_bank255");
}
void test_string__test_itoa_int(void) {
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... | {
char line_buffer[LINE_BUFFER_LENGTH];
unsigned int offset = 0;
while (offset < length) {
unsigned int buffer_offset = 0;
// Print data line offset
snprintf(line_buffer, LINE_BUFFER_LENGTH, "%04x ", offset);
buffer_offset += 6;
// Print the hex bytes
const unsigned int num_line_bytes ... | |
*emoji_str = PBL_IF_RECT_ELSE(" " MULTIMEDIA_EMOJI, "\n" MULTIMEDIA_EMOJI);
#endif
return snprintf(buffer, length, "%s%s", i18n_get("sent an attachment", __FILE__),
emoji_str);
}
//! @param buffer Pointer to a buffer large enough to hold all attribute strings required by
//! the action. If buffer p... | (*buffer, title, TITLE_MAX_LENGTH,
&item->attr_list.attributes[attr_idx],
AttributeIdSender) | ;
attr_idx++;
}
// The sender is in the title for iMessage
const ANCSAttribute *sender = title;
if (has_multimedia) {
// Move the title (sender) to the body for MMS
if (ancs_notifications_util_is_group_sms(app_id, subtitle)) {
// Promote the subtitle (group name) for Group MMS
title = s... |
vent *e) {
BLEAppState *ble_app_state = app_state_get_ble_app_state();
prv_consume_read_response(e, ble_app_state->gatt_characteristic_read_handler);
}
static void prv_handle_characteristic_write(const PebbleBLEGATTClientEvent *e) {
BLEAppState *ble_app_state = app_state_get_ble_app_state();
const BLEClientWri... | prv_set_handler(handler, offset) | ;
}
BTErrno ble_client_set_write_response_handler(BLEClientWriteHandler handler) {
const off_t offset = offsetof(BLEAppState, gatt_characteristic_write_handler);
return prv_set_handler(handler, offset);
}
BTErrno ble_client_set_subscribe_handler(BLEClientSubscribeHandler handler) {
const off_t offset = offsetof... |
) {
return new_address;
}
return registry->cursor->begin;
}
static void move_cursor_to_active_registry(Registry* registry) {
// Search for an active registry, starting at the start of the registry sector
// in flash (`REGISTRY_FLASH_BEGIN`).
// If cursor loops back to the start of the registry sector, t... | {
for (int i = 0; i < registry->num_records; i++) {
Record* r = registry->records + i;
if (r->active) {
if (record_compare(r, key, key_length, uuid)) {
return i;
}
}
}
return -1;
} |
Record* registry_private_get(const char* key, const uint8_t key_length,
const uint8_t* uuid, Registry* registry) {
const int idx = record_get_index(key, key_length, uuid, registry);
PBL_ASSERTN(idx < registry->num_records);
if (idx >= 0) {
return registry->records + idx;
}
... |
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 in writing, software
* distributed und... | {
SettingsActivityTrackerData *data = context;
if (app_menu_data_source_get_count(data->data_source) == 0) {
return;
}
if (row == 0) {
// Killing current worker
process_manager_put_kill_process_event(PebbleTask_Worker, true /* graceful */);
worker_manager_set_default_install_id(INSTALL_ID_INVALI... |
static void prv_draw_no_activities_cell_rect(GContext *ctx, const Layer *cell_layer,
const char *no_activities_string) {
const GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
GRect box = cell_layer->bounds;
const GTextOverflowMode overflow = GTextOverfl... |
/*
* 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 *((ClickHandler*)(((uint8_t*)&recognizer->config) + offset));
} |
static void prv_cancel_timer(AppTimer **timer) {
if (*timer) {
app_timer_cancel(*timer);
*timer = NULL;
}
}
static void prv_click_reset(ClickRecognizerRef recognizer_ref) {
ClickRecognizer *recognizer = (ClickRecognizer *)recognizer_ref;
recognizer->number_of_clicks_counted = 0;
recognizer->is_butt... |
e_args;
const bool is_up = (click_recognizer_get_button_id(recognizer) == BUTTON_ID_UP);
if (is_up) {
PBL_LOG(LOG_LEVEL_DEBUG, "Launching timeline in past mode.");
s_timeline_args.direction = TimelineIterDirectionPast;
analytics_inc(ANALYTICS_DEVICE_METRIC_TIMELINE_PAST_LAUNCH_COUNT, AnalyticsClient_Sys... | watchface_get_default_install_id() | ,
.common.transition = animation,
});
}
static void kernel_callback_watchface_launch(void* data) {
watchface_launch_default(NULL);
}
void command_watch(void) {
launcher_task_add_callback(kernel_callback_watchface_launch, NULL);
}
void watchface_start_low_power(void) {
app_manager_set_minimum_run_level(Pr... |
/*
* 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... | (ADCx, ADC_FLAG_OVR) | ;
return false;
}
}
return true;
}
void voltage_monitor_read(VoltageMonitorDevice *device, VoltageReading *reading_out) {
mutex_lock(s_adc_mutex);
bool same_adc = (device->adc == VREF_ADC);
// Enable ADC's APB interface clock
periph_config_enable(VREF_ADC, VREF_ADC_CLOCK);
if (!same_adc) {
... |
ributed 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 "gdraw_command_list.h"
#include "gdraw_command_private.h"
#include "applib/applib_malloc.auto.h... | {
size_t *size = ctx;
const size_t command_size = gdraw_command_get_data_size(command);
if (command_size > *size) {
*size = command_size;
}
return true;
} | |
econds
{ 16, 600, -800},
{ 16, 600, -800},
{ 24, 600, -800},
{ 24, 608, -792},
{ 16, 600, -800},
{ 16, 600, -800},
{ 16, 600, -800},
{ 16, 600, -800},
{ 16, 600, -800},
{ 24, 600, -800},
{ 24, 600, -800},
{ 24, 600, -800},
{ 24, 600, -800},
{ 24, 600, -800},
{... | { 24, 600, -800},
{ 24, 608, -792},
{ 24, 608, -792},
// 128 seconds
{ 24, 600, -800},
{ 16, 600, -800},
{ 24, 608, -792},
{ 24, 608, -784},
{ 16, 608, -792},
{ 24, 592, -800},
{ 16, 608, -792},
{ 24, 608, -792},
{ 24, 600, -792},
{ 24, 608, -792},
{ 16, 608, ... | |
return false;
}
uint8_t ch_tmr = 1 << 4 | // 1: Set maintain charge timeout to 15 min
2 << 2 | // 2: Set fast charge timeout to 300 min
0 << 0; // 0: Set precharge timeout to 30 min
return prv_write_register(PmicRegisters_CH_TMR, ch_tmr);
}
/* Public Functions */
uint3... | prv_set_mon_config_register(register_value) | ;
// Need to wait a short period of time for the reading to settle due to capacitance on the line.
delay_us(200);
return result;
}
bool pmic_enable_battery_measure(void) {
prv_mon_config_lock();
return prv_set_mon_config(&MON_CONFIG[PMIC_MON_CONFIG_VBAT_INDEX]);
// Don't prv_unlock, we don't want anyon... |
onst uint16_t expire_s = SECONDS_PER_MINUTE;
HRMSessionRef session_ref = sys_hrm_manager_app_subscribe(app_id, 1, expire_s, HRMFeature_BPM);
cl_assert(sys_hrm_manager_get_app_subscription(app_id) == session_ref);
prv_fake_send_new_data();
// We should get the BPM event
cl_assert_equal_i(s_event_count, 1);
... | {
sys_hrm_manager_unsubscribe(session_refs[i]);
cl_assert(prv_get_subscriber_state_from_ref(session_refs[i]) == NULL);
cl_assert(prv_get_subscriber_state_from_app_id(PebbleTask_App, app_ids[i]) == NULL);
} |
cl_assert_equal_b(hrm_is_enabled(HRM), false);
}
void test_hrm_manager__feature_callbacks(void) {
const int num_refs = 2;
HRMSessionRef session_refs[num_refs];
AppInstallId app_id = 1;
for (int i = 0; i < num_refs; ++i, app_id++) {
const uint16_t expire_s = SECONDS_PER_MINUTE;
session_refs[i] = sy... |
oot_bit_set(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
FirmwareDescription firmware_description =
firmware_storage_read_firmware_description(flash_new_fw_addr);
if (!firmware_storage_check_valid_firmware_description(&firmware_description)) {
dbgserial_print("Desclen ");
dbgserial_print_hex(firmware_descri... | {
case UPDATE_FW_SUCCESS:
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO);
boot_bit_set(BOOT_BIT_RECOVERY_START_IN_PROGRESS);
break;
case UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED:
case UPDATE_FW_ERROR_MICRO_FLASH_MANGLED:
// Keep us b... |
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
return recovery_fw_ok;
}
|
/*
* 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... | (test_image_bw, 8, 24) | , GColorBlack));
cl_check(gcolor_equal(get_bitmap_color(test_image_color, 30, 2), GColorClear));
cl_check(gcolor_equal(get_bitmap_color(test_image_color, 30, 10), GColorRed));
cl_check(gcolor_equal(get_bitmap_color(test_image_color, 30, 30), GColorScreaminGreen));
#endif
}
void test_graphics_draw_rotated_bitmap... |
register(uint8_t register_address, uint8_t *result) {
return i2c_read_register(I2C_DEVICE_MAX14690, MAX14690_ADDR, register_address, result);
}
static bool prv_write_register(uint8_t register_address, uint8_t value) {
return i2c_write_register(I2C_DEVICE_MAX14690, MAX14690_ADDR, register_address, value);
}
/* Pu... | {
// NOTE: When running on QEMU, i2c reads return false. For now, just assume a failed
// i2c read means we are charging
return true;
} | |
400, 400, -800},
// 82 seconds
{ 392, 392, -808},
{ 384, 376, -808},
{ 376, 320, -816},
{ 416, 520, -768},
{ 376, 384, -808},
{ 352, 328, -800},
{ 392, 368, -816},
{ 384, 400, -816},
{ 392, 384, -808},
{ 400, 360, -808},
{ 392, 352, -816},
{ 392, 368, -816},
{ 392... | { 384, 336, -808},
{ 392, 384, -792},
{ 392, 464, -792},
{ 392, 392, -792},
{ 384, 392, -792},
{ 384, 416, -800},
{ 384, 432, -784},
{ 384, 384, -800},
{ 392, 416, -792},
{ 392, 408, -800},
{ 360, 392, -816},
{ 416, 408, -768},
// 88 seconds
{ 408, 424, -776},
... |
{ 400, 440, -768},
{ 392, 448, -776},
{ 400, 432, -776},
{ 400, 440, -776},
{ 400, 432, -776},
{ 392, 432, -776},
{ 392, 448, -768},
{ 392, 424, -776},
{ 400, 440, -776},
{ 392, 440, -776},
{ 400, 432, -768},
{ 400, 432, -776},
{ 400, 432, -768},
{ 400, 440, -776... |
/*
* 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 (strncmp(s1, s2, len) == 0) {
return (char*)s1;
}
s1++;
} |
return NULL;
}
|
helper_check_buffer_for_content_indicator(i, &content_indicator);
}
// Initializing more content indicators than the buffer can hold should assert
cl_assert_passert(content_indicator_init(&content_indicator));
}
void test_content_indicator__deinit_should_remove_from_buffer(void) {
ContentIndicatorsBuffer... | content_indicator_set_content_available(&content_indicator, direction, false) | ;
cl_assert_equal_p(dummy_config.layer->update_proc, direction_data->original_update_proc);
cl_assert_equal_p(direction_data->original_update_proc,
s_content_indicator_dummy_layer_update_proc);
}
void test_content_indicator__creating_for_scroll_layer(void) {
ScrollLayer scroll_layer;
Conten... |
may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIE... | {
const size_t buffer_length = 9;
char dest[NAME_LENGTH];
memset(dest, GUARD_CHAR, NAME_LENGTH);
// This wouldn't overflow if E_ACUTE was one byte.
phone_format_caller_name("Donut " E_ACUTE "clair", dest, buffer_length);
cl_assert_equal_s(dest, "Donut");
cl_assert_equal_m(dest + buffer_length, GUARD_REF... |
void test_phone_formatting__phone_number_intl_std(void) {
char test_number[] = "+55 408-555-1212";
int dest_len = sizeof(test_number) + 1;
char *dest = malloc(dest_len); // malloc'd memory is protected by DUMA
phone_format_phone_number(test_number, dest, dest_len);
cl_assert_equal_s(dest, "+55 408\n555-1... |
.kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id2, 11, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
// Delete the 10:30 alarm
alarm_delete(id1);
// The 10:30 alarm should not go off
s_current_hour = 11;
s_current_minute = 0;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fir... | (alarm_is_next_enabled_alarm_smart(), false) | ;
}
void test_alarm__skip_two_alarms(void) {
AlarmId id1, id2;
bool just_once_schedule_thursday[7] = {false, false, false, false, true, false, false};
id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 10, .kind = ALARM_KIND_JUST_ONCE });
prv_assert_alarm_config(id1, 10, 10, false, ALARM_KIND_JUST_ONCE, j... |
mation) {
return (animation->abs_start_time_ms != 0);
}
// -------------------------------------------------------------------------------------------
// Return true if animation is mutable
static bool prv_is_mutable(AnimationState *state, AnimationPrivate *animation) {
return (animation && !animation->immutable &... | prv_reschedule_timer(state, 0) | ;
}
// Reset these fields, before calling .stopped(), so that this animation
// instance can be rescheduled again in the .stopped() handler, if needed.
animation->abs_start_time_ms = 0;
animation->is_completed = false;
animation->times_played = 0;
bool did_start = animation->started;
animation->started... |
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_desc... | cl_assert_equal_i(s_last_cccd_value, (uint16_t) ~0) | ;
fake_event_clear_last();
// Simulate getting confirmation from remote:
prv_confirm_cccd_write(BLEGATTErrorSuccess);
// Expect one event for both Kernel + App:
prv_assert_subscription_event(characteristic, BLESubscriptionIndications, BLEGATTErrorSuccess,
true /* kernel */, true /* app *... |
0x0);
REG_SETF(DCDC, DCDC_TRIM_REG, DCDC_N_COMP_MAN_TRIM, 0x0);
REG_SETF(DCDC, DCDC_TRIM_REG, DCDC_N_COMP_TRIM, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_COMP_CLK, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_CURRENT, 0x0);
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_OUTPUT_MONITOR, 0x0);
REG_SETF(DCDC... | REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_INST, 0x0) | |
/*
* 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 (s_state.last_time.tm_year != currtime.tm_year) {
units_changed |= YEAR_UNIT;
} | |
quest) + payload_size];
PutRequest *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 pr... | fake_comm_session_init() | |
/*
* 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 (!animation) {
return false;
} | |
/*
* 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... | (str, STR_SIZE, "%s%f%s", "a", 1.0, "b") | |
-------------
bool workout_service_is_workout_ongoing(void) {
prv_lock();
bool rv = (s_workout_data.current_workout != NULL);
prv_unlock();
return rv;
}
// ---------------------------------------------------------------------------------------
bool workout_service_takeover_activity_session(ActivitySession *ses... | {
*active = ROUND(s_workout_data.current_workout->active_calories, ACTIVITY_CALORIES_PER_KCAL);
} |
}
void workout_service_reset(void) {
if (s_workout_data.current_workout) {
kernel_free(s_workout_data.current_workout);
}
s_workout_data = (WorkoutServiceData) {};
}
#endif
|
/*
* 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(GColorGreen.r == 0b00);
cl_assert(GColorGreen.g == 0b11);
cl_assert(GColorGreen.b == 0b00);
cl_assert(GColorGreen.a == 0b11);
} |
void test_graphics_colors__blue(void) {
cl_assert(GColorBlue.r == 0b00);
cl_assert(GColorBlue.g == 0b00);
cl_assert(GColorBlue.b == 0b11);
cl_assert(GColorBlue.a == 0b11);
}
void test_graphics_colors__equal(void) {
cl_assert(gcolor_equal(GColorBlue, GColorBlue));
cl_assert(gcolor_equal(GColorRed, GColorR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.