prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
b/graphics/graphics.h"
#include "applib/graphics/framebuffer.h"
#include "clar.h"
///////////////////////////////////////////////////////////
// Stubs
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_hexdump.h"
#include "stubs_heap.h"
#include "stubs_pebble_tasks.h"
#include "stubs_pbl_malloc.h... | cl_assert_equal_i(layout.max_used_size.h, 3 * FONT_HEIGHT) | ; // 3 lines - but not 4, since the fourth has no chance of appearing ("Jr\nWho-\npper")
}
void test_text_layout__cache_vert_overflow_first_line(void) {
GContext gcontext = (GContext) { };
GFont font = (GFont) { 0 };
GRect box = (GRect) { (GPoint) { 0, 0 }, (GSize) { 5 * HORIZ_ADVANCE_PX + 1, 7 } };
TextLayout... |
data that is passed to the controller is the same that
// was given when calling the API:
assert_ad_data(ad_data);
// Check that the scan resp data that is passed to the controller is the same
// that was given when calling the API:
Scan_Response_Data_t scan_resp_data_out;
cl_assert_equal_i(gap_le_get_scan... | (gap_le_is_advertising_enabled()) | ;
// Check that the ad data that is passed to the controller is the same that
// was given when calling the API:
assert_ad_data(ad_data);
// Check that the scan resp data that is passed to the controller is the same
// that was given when calling the API:
Scan_Response_Data_t scan_resp_data_out;
cl_asse... |
c_timer);
}
//! How frequently we save the time state to the backup registers in ticks.
#define SAVE_TIME_FREQUENCY (30 * RTC_TICKS_HZ)
static void check_and_handle_rollover(RtcIntervalTicks rtc_ticks) {
bool save_needed = false;
const RtcIntervalTicks last_ticks = s_last_ticks;
s_last_ticks = rtc_ticks;
if... | (RTC_Alarm_A, DISABLE) | ;
RTC_ClearITPendingBit(RTC_IT_ALRA);
EXTI_ClearITPendingBit(EXTI_Line17);
}
}
|
return;
}
GRect glance_frame = (GRect) { .origin = offset, .size = structured_glance->glance.size };
#if PLATFORM_ROBERT
const int16_t horizontal_inset = 10;
#else
const int16_t horizontal_inset = PBL_IF_RECT_ELSE(6, 23);
#endif
glance_frame = grect_inset_internal(glance_frame, horizontal_inset, 0);
GTe... | if (!structured_glance) {
return;
} |
launcher_app_glance_notify_service_glance_changed(&structured_glance->glance);
}
void launcher_app_glance_structured_set_icon_max_size(
LauncherAppGlanceStructured *structured_glance, GSize new_size) {
if (!structured_glance) {
return;
}
structured_glance->icon_max_size = new_size;
const int width... |
tx));
cl_assert(!handled);
recognizer_set_simultaneous_with(r, prv_simultaneous_with_cb);
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert_equal_p(ctx.triggered, s);
}
bool prv_fail_recognizer(Recognizer *recognizer, void *context);
void test_recognizer_manager__fail_recognizer(... | cl_assert_equal_i(recognizers[0]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Cancelled);
cl_assert_equal_i(recognizers[2]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Cancelled);
// Layer C's and layer A's recognizer... |
static RecognizerState s_next_state = RecognizerStateCount;
static int s_idx_to_change = -1;
static void prv_handle_touch_event_test(Recognizer *recognizer, const TouchEvent *touch_event) {
int *idx = recognizer_get_impl_data(recognizer, &s_dummy_impl);
prv_store_recognizer_idx(recognizer, &s_recognizers_handled)... |
/*
* 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... | ("blendtest_0_100_backdrop.pbi") | ;
GBitmap *background_33_66 = get_gbitmap_from_pbi("blendtest_33_66_backdrop.pbi");
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_bitmap_in_rect(&ctx, background_0_100, &ORIGIN_RECT_NO_CLIP);
#if SCREEN_COLOR_DEPTH_BITS == 8
// Sanity check
cl_check(gbitmap_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... | (ctx, &DISP_FRAME) | ;
}
const GPoint dest_bitmap_blit_offset = GPoint(app_fb_origin_x, 0);
GBitmap src_bitmap = compositor_get_app_framebuffer_as_bitmap();
GBitmap dest_bitmap = compositor_get_framebuffer_as_bitmap();
bitblt_bitmap_into_bitmap(&dest_bitmap, &src_bitmap, dest_bitmap_blit_offset, GCompOpAssign,
... |
/*
* 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... | ("Boot bits: ") | ;
dbgserial_print_hex(RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR));
dbgserial_newline();
}
void boot_version_write(void) {
if (boot_version_read() == s_bootloader_timestamp) {
return;
}
RTC_WriteBackupRegister(BOOTLOADER_VERSION_REGISTER, s_bootloader_timestamp);
}
uint32_t boot_version_read(void) {
re... |
{ 1200, 552, -248},
{ 1208, 416, -144},
{ 1424, 368, -160},
{ 1312, 240, 24},
{ 1016, 272, -24},
{ 864, 248, -64},
// 54 seconds
{ 832, 184, -24},
{ 816, 160, 16},
{ 760, 128, 16},
{ 720, 104, 0},
{ 768, 48, 32},
{ 960, 112, -24},
{ 1280, 24, -16},
{ 1504, 256, ... | { 1552, 592, -192},
{ 1272, 624, -216},
{ 1056, 544, -224},
{ 1336, 456, -224},
{ 1432, 352, -120},
{ 1216, 272, -32},
{ 984, 264, -56},
{ 904, 272, -8},
{ 856, 232, 8},
{ 776, 152, 32},
{ 728, 136, 64},
{ 648, 96, 48},
{ 744, 104, 64},
{ 952, 152, 8},
{ 1216,... |
{ 872, 216, 24},
{ 784, 136, 72},
{ 664, 128, 48},
{ 632, 136, 8},
{ 736, 96, -32},
{ 912, 136, -88},
{ 1208, 64, -32},
{ 1824, 344, -216},
{ 1328, 464, -424},
{ 1104, 488, -456},
{ 1400, 656, -400},
{ 1312, 424, -136},
{ 1088, 408, -88},
{ 872, 328, -40},
{ ... |
N) {
PBL_LOG(LOG_LEVEL_WARNING, "Longer HCI CMD than expected!");
s_hci_cmd_info = (HciCmdInfo) { }; // reset
return;
}
}
// We've received an expected byte, so store it
s_hci_cmd_info.data_buf[s_hci_cmd_info.write_offset] = c;
s_hci_cmd_info.write_offset++;
if (s_hci_cmd_info.write_of... | prv_in_test_mode() | |
-----------------------------------------------
// Log a health insight created event.
void analytics_event_health_insight_created(time_t timestamp,
ActivityInsightType insight_type,
PercentTier pct_tier) {
// Format the event spe... | if (!prv_get_connection_details(session, &is_ppogatt, &conn_interval)) {
return;
} | |
obs *put_jobs = &s_pb_state.pb_pending_jobs;
PutBytesJob *job;
prv_lock_pb_job_state();
{
PBL_ASSERTN(put_jobs->num_ops_pending != put_jobs->num_allocated_pb_jobs);
uint8_t write_idx = (put_jobs->read_idx + put_jobs->num_ops_pending) %
put_jobs->num_allocated_pb_jobs;
job = &put_jobs->job[wri... | pb_storage_deinit(&s_pb_state.storage, s_pb_state.is_success) | ;
// Stay at ResponseTimeMin for a bit so that we don't force a quick transition between
// Min -> Max -> Min. The Dialog chip would disconnect with reasons 0x1f. Also, it doesn't really
// make sense to transition for just 2 seconds anyways. However, during an App/File install
// PutBytes, we will stay at Min... |
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bytes 3232 - 3248 */
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bytes 3248 - 3264 */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bytes 3264 - 3280 */
0x... | (resource_bank, no_litter_res_id, image_size,
image_buf, 1) | , 0);
return;
}
static uint32_t s_watch_res_callback_called_count = 0;
static void prv_res_changed_callback(void *data) {
s_watch_res_callback_called_count++;
}
void test_resource__watch(void) {
load_resource_fixture_on_pfs(RESOURCES_FIXTURE_PATH, PUG_FIXTURE_NAME, "pug");
ResourceCallbackHandle cb_handle... |
const char ad_data[] = "ad data";
const char scan_resp_data[] = "scan resp data";
BLEAdData *ad = create_ad(ad_data, scan_resp_data);
GAPLEAdvertisingJobTerm advert_terms[3] =
{
{
.min_interval_slots = 160,
.max_interval_slots = 240,
.duration_secs = 4,
},
{
.min_interval... | cl_assert(infinite_job_c) | ;
assert_ad_data("C");
// Round-robin 5 times:
for (int i = 0; i < 5; ++i) {
regular_timer_fire_seconds(1);
assert_ad_data("A");
regular_timer_fire_seconds(1);
assert_ad_data("B");
regular_timer_fire_seconds(1);
assert_ad_data("C");
}
// Introduce a second non-infinite job "D" for 10... |
ed = true;
return true;
}
static const GlyphData *prv_get_glyph_metadata_from_spi(Codepoint codepoint,
FontCache *font_cache,
const FontResource *font_res,
... | {
PBL_LOG(LOG_LEVEL_WARNING,
"Failed to load glyph metadata from resources; cp: %"PRIx32", offset: %"PRIx32,
codepoint, data->resource_offset);
return NULL;
} |
LineCacheData *final_data;
#if !CAPABILITY_HAS_GLYPH_BITMAP_CACHING
// Copy the info into the glyph_buffer.
// This must be done _before_ loading the bitmap, otherwise loading the bitmap may modify the
// metadata! We will use `glyph_buffer` as the final data, and leave `data` as the uncooked
// version, 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... | if (state->last_time.tm_mday != currtime.tm_mday) {
units_changed |= DAY_UNIT;
} |
if (state->last_time.tm_mon != currtime.tm_mon) {
units_changed |= MONTH_UNIT;
}
if (state->last_time.tm_year != currtime.tm_year) {
units_changed |= YEAR_UNIT;
}
}
state->last_time = currtime;
state->first_tick = false;
if ((state->tick_units & units_changed) || (units_changed == ... |
/*
* 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(count, 32810) | ;
}
void test_sle__escape_byte(void) {
SLEDecodeContext ctx;
uint8_t buf[] = {
0xfd, // escape code
0xfd, 0x01, // literal escape byte
0xfd, 0x00 // end
};
sle_decode_init(&ctx, buf);
uint8_t byte;
uint32_t count = 0;
while (sle_decode(&ctx, &byte)) {
cl_assert_equal_i(byte, 0xfd);
+... |
canning the flash to find a given file.
static status_t locate_flash_file(const char *name, uint16_t *page) {
const int file_namelen_offset = FILEHEADER_OFFSET +
offsetof(FileHeader, file_namelen);
uint8_t namelen = strlen(name);
for (uint16_t pg = 0; pg < s_pfs_page_count; pg++) {
PageHeader pg_hdr;
... | _Static_assert((sizeof(uint32_t) * 8) >= PFS_PAGES_PER_ERASE_SECTOR,
"Number of PFS pages is larger than bitmask") | |
oid) {
return &s_app_state_ptr->app_outbox_subscription_info;
}
AnimationState* app_state_get_animation_state() {
return &s_app_state_ptr->animation_state;
}
AppMessageCtx *app_state_get_app_message_ctx(void) {
return &s_app_state_ptr->app_message_ctx;
}
#if !defined(PLATFORM_TINTIN)
BLEAppState* app_state_get... | {
s_app_state_ptr->rocky_runtime_context_buffer = unaligned_buffer;
s_app_state_ptr->rocky_runtime_context = rocky_runtime_context;
} |
RockyMemoryAPIContext *app_state_get_rocky_memory_api_context(void) {
return s_app_state_ptr->rocky_memory_api_context;
}
void app_state_set_rocky_memory_api_context(RockyMemoryAPIContext *context) {
s_app_state_ptr->rocky_memory_api_context = context;
}
ApplibInternalEventsInfo *app_state_get_applib_internal_e... |
Sometimes if there's no sleep, sleep session rendered as "16:00 - 16:00" so for a quick
// fix, we assume there's no sleep if the start and end times are the same.
// https://pebbletechnology.atlassian.net/browse/PBL-40031
if (sleep_start <= 0 || sleep_end <= 0 || sleep_start == sleep_end) {
strncpy(buffer, ... | *heading = (HealthDetailHeading) {
.primary_label = (char *)i18n_get("DEEP SLEEP", card_data),
.primary_value = app_zalloc_check(buffer_len),
.fill_color = PBL_IF_COLOR_ELSE(GColorCobaltBlue, GColorWhite),
#if PBL_BW
.outline_color = GColorBlack,
#endif
};
prv_set_deep_sleep(heading->primary_valu... |
void health_sleep_detail_card_destroy(Window *window) {
HealthDetailCard *card = (HealthDetailCard *)window;
HealthSleepDetailCardData *card_data = card->data;
for (int i = 0; i < card_data->num_headings; i++) {
app_free(card_data->headings[i].primary_value);
app_free(card_data->headings[i].secondary_va... |
delete_bt_classic_pairing_by_id(9);
cl_assert_equal_i(fake_shared_prf_storage_get_bt_classic_delete_count(), 3);
// Make sure the pairing is actually still there
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
name_out, &p... | cl_assert(ret) | ;
cl_assert_equal_i(id_out, id_1);
cl_assert_equal_i(type_out, BtPersistBondingTypeBTClassic);
ret = bt_persistent_storage_has_active_bt_classic_gateway_bonding();
cl_assert(ret);
ret = bt_persistent_storage_has_active_ble_gateway_bonding();
cl_assert(!ret);
// Store another BT Classic pairing
BTDevic... |
clude "stubs_hexdump.h"
#include "stubs_language_ui.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_prompt.h"
#include "stubs_serial.h"
#include "stubs_sleep.h"
#include "stubs_system_reset.h"
#include "stubs_task_watchdog.h"
#include ... | (strlen(second), i18n_ctx_get_length("Quiet Time", "Disabled")) | |
/*
* 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 (low_power_is_active()) {
// If we're in low power mode we dont allow any interaction
return true;
} |
return false;
}
static void prv_launch_app_via_button(AppLaunchEventConfig *config,
ClickRecognizerRef recognizer) {
config->common.button = click_recognizer_get_button_id(recognizer);
app_manager_put_launch_app_event(config);
}
static void prv_quick_launch_handler(ClickRe... |
void *i18n_owner) {
StringList *responses_list =
attribute_get_string_list(&action->attr_list,
AttributeIdCannedResponses);
uint16_t canned_responses_count = responses_list ?
string_list_count(responses_list) : 0;
ActionMenuLevel ... | {
case ReplyOption_Voice:
#if CAPABILITY_HAS_MICROPHONE
return true;
#else
return false;
#endif
case ReplyOption_Template:
return true;
case ReplyOption_Emoji:
// If this attribute isn't found, we want to support emoji by default
return attribute_get_uint8(&action->attr_list, A... |
}
static ActionMenuLevel *prv_create_responses_level(TimelineItemAction *action,
ActionMenuLevel *root_level,
bool reply_prefix) {
uint16_t num_items = 0;
for (ReplyOption reply = 0; reply < ReplyOptionCount; rep... |
/*
* 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... | TINTIN_MODEL("pebble_white") | ;
break;
case WATCH_INFO_COLOR_RED:
model_name = TINTIN_MODEL("pebble_red");
break;
case WATCH_INFO_COLOR_ORANGE:
model_name = TINTIN_MODEL("pebble_orange");
break;
case WATCH_INFO_COLOR_GRAY:
model_name = TINTIN_MODEL("pebble_gray");
break;
... |
der_compress);
g = prv_decompress_glyph_data(g, target);
SYS_PROFILER_NODE_STOP(text_render_compress);
}
}
data->is_bitmap_loaded = true;
return true;
}
static const GlyphData *prv_get_glyph_metadata_from_spi(Codepoint codepoint,
FontCache ... | SYS_PROFILER_NODE_STOP(text_render_flash) | ;
}
if (!num_bytes_loaded) {
PBL_LOG(LOG_LEVEL_WARNING,
"Failed to load glyph metadata from resources; cp: %"PRIx32", offset: %"PRIx32,
codepoint, data->resource_offset);
return NULL;
}
LineCacheData *final_data;
#if !CAPABILITY_HAS_GLYPH_BITMAP_CACHING
// Copy the info into ... |
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)) | ;
// -----------------------------------------------------------------------------
// Send garbage before a good packet
prv_send_bytes(msg_data, sizeof(msg_data));
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
prv_send_hdr(QemuProtocol_SPP, sizeof(msg_data));
cl_as... | |
u_layer_walk_upward_from_iterator(it);
} else if (direction > 0) {
// new index comes after current selection
prv_menu_layer_walk_downward_from_iterator(it);
}
// potentially restore previous state of selection
if (menu_layer->selection.index.section == MENU_INDEX_NOT_FOUND) {
menu_layer->selection... | (progress, 0, half_progress) | ;
prv_center_focus_animation_update_impl(animation, second_half, adjusted_progress);
}
void prv_center_focus_animation_update_out_only(Animation *animation,
const AnimationProgress progress) {
// anwalys only render the bounce back
prv_center_focus_animation_update... |
of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the spe... | cl_will_return_count(rand, 0x55, sizeof(SM128BitKey)) | |
/*
* 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... | i18n_get(name_i18n, i18n_owner) | ,
metric_group->max_item_string_size);
string_list_add_string(metric_group->values, max_list_size, value,
metric_group->max_item_string_size);
metric_group->icons->values[metric_group->num_items++] = icon;
metric_group->icons->num_values = metric_group->num_items;... |
e after the other at whatever sample rate the
//! accel manager happens to request. This means that depending on the
//! sample rates that the samples were recorded and the current
//! configured sample rate, the samples could be replayed anywhere from
//! 10x slower to 10x faster than they were recorded (100 Hz record... | {
s_latest_reading = s_rcv_buffer[s_current_rcv_sample++];
} |
// Keep it simple; this accelerometer has no FIFO.
if (s_num_fifo_samples > 0) {
AccelDriverSample sample;
prv_construct_driver_sample(&sample);
ACCEL_LOG_DEBUG("Accel sample to manager: %d, %d, %d", sample.x, sample.y, sample.z);
accel_cb_new_sample(&sample);
}
if (s_num_fifo_samples == 0 &&... |
sessions[i].steps, sessions[i].resting_calories, sessions[i].active_calories,
sessions[i].distance_mm);
}
printf("\nLooking for: type: %d, start_utc: %d, len: %"PRIu16", steps: %"PRIu16", "
"rest_cal: %"PRIu32", active_cal: %"PRIu32", dist: %"PRIu32" ",
(int)exp_session->activity, (int)... | fprintf(file, "\n") | ;
} else {
file = fopen(filename, "a");
cl_assert(file);
}
// Write out the column values for each row
StatsRow *row = s_stat_rows;
int row_idx = 0;
for (; row != NULL; row = (StatsRow *)row->node.next, row_idx++) {
fprintf(file, "\"%s\"", test_name);
StatsEpochType epoch_type;
if (!is_... |
sizeof(uint8_t));
//! Message Length Constants
static const uint8_t MIN_INSERT_LENGTH = 8;
static const uint8_t MIN_DELETE_LENGTH = 6;
static const uint8_t MIN_CLEAR_LENGTH = 3;
static bool s_bdb_accepting_messages;
static void prv_send_response(CommSession *session, BlobDBToken token, BlobDBResponse result) {
st... | if (length < MIN_DELETE_LENGTH) {
prv_send_response(session, prv_try_read_token(data, length), BLOB_DB_INVALID_DATA);
return;
} |
const uint8_t *iter = data;
BlobDBToken token;
BlobDBId db_id;
// Read token and db_id
iter = endpoint_private_read_token_db_id(iter, &token, &db_id);
// Read key length and key bytes
uint8_t key_size;
const uint8_t *key_bytes = NULL;
iter = prv_read_key_size(iter, data + length, &key_size);
ite... |
/*
* 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... | (crc, 0xCBF43926) | |
ting, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "console/prompt.h"
#include "drivers/fpc_... | (versions_msg.hw_version, sizeof(versions_msg.hw_version)) | ;
mfg_info_get_serialnumber(versions_msg.serial_number, sizeof(versions_msg.serial_number));
strncpy(versions_msg.iso_locale, i18n_get_locale(), ISO_LOCALE_LENGTH - 1);
versions_msg.iso_locale[ISO_LOCALE_LENGTH - 1] = '\0';
versions_msg.lang_version = htons(i18n_get_version());
PBL_LOG(LOG_LEVEL_DEBUG, "Send... |
e.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 permissions and
* ... | prv_event_service_subscribe(subscription) | |
e.origin.y += title_vertical_adjust_px;
graphics_draw_text(ctx, title_text, title_font, title_frame,
overflow_mode, text_alignment, NULL);
graphics_draw_text(ctx, instruction_text, instruction_font,
instruction_frame, overflow_mode, text_alignment, NULL);
}
void prv_draw_... | if (data->state == INITIAL_STATE) {
// exit the calibration window without changing the prefs
window_stack_remove(&data->window, true /* animated */);
return;
} |
data->state--;
layer_mark_dirty(&data->window.layer);
}
static void prv_up_down_click_handler(ClickRecognizerRef recognizer, void *context) {
DisplayCalibrationData *data = context;
int to_add = (click_recognizer_get_button_id(recognizer) == BUTTON_ID_UP) ? -1 : 1;
switch (data->state) {
case Display... |
uint8_t want = (offset + i) & 0xff;
if (memmap_buffer[i] != want) {
char err_buf[80];
prompt_send_response_fmt(err_buf, sizeof(err_buf), "FAIL at ADDR %d Got: %d Wanted %d",
(int)offset, (int)memmap_buffer[i], (int)want);
break;
}
}
}
... | system_hard_reset() | ;
}
void command_boot_prf(void) {
prompt_command_finish();
RebootReason reason = { RebootReasonCode_Serial, 0 };
reboot_reason_set(&reason);
boot_bit_set(BOOT_BIT_FORCE_PRF);
system_reset();
}
void command_infinite_loop(void) {
while(1);
}
void stuck_timer_cb(void* data) {
while(1);
}
#include "servi... |
ist_prepend((ListNode *) s_session_head, &session->node);
prv_log_session_event(session, true /* is_open */);
// Request capabilities for both the Pebble app and 3rd party companion apps:
session_remote_version_start_requests(session);
comm_session_analytics_open_session(session);
prv_put_comm_session_eve... | {
schedule_func = bt_driver_comm_schedule_send_next_job;
} |
if (schedule_func(session)) {
session->is_send_next_call_pending = true;
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to schedule comm_session_send_next callback");
}
}
//! extern'd for session_send_buffer.c
void comm_session_send_next_immediately(CommSession *session) {
prv_send_next(session, false /* ... |
graphics_draw_line(ctx, GPoint(0, DISP_ROWS/3), GPoint(DISP_COLS, DISP_ROWS)) | ;
// ~53 degrees
graphics_draw_line(ctx, GPoint(DISP_COLS/4, 0), GPoint(DISP_COLS, DISP_ROWS));
// ~39 degrees
graphics_draw_line(ctx, GPoint(0, DISP_ROWS/5), GPoint(DISP_COLS, DISP_ROWS));
profiler_stop();
uint32_t total_time = profiler_get_total_duration(false);
uint32_t us = profiler_get_total_duratio... | |
312, -960},
{ -280, 280, -944},
{ -280, 272, -936},
{ -280, 304, -936},
{ -280, 304, -944},
{ -280, 280, -944},
{ -288, 304, -944},
{ -288, 320, -936},
{ -296, 280, -928},
{ -280, 296, -952},
{ -280, 320, -944},
{ -296, 304, -936},
{ -296, 296, -944},
{ -288, 320, -9... | { -280, 304, -928},
{ -288, 320, -936},
{ -280, 296, -936},
{ -288, 304, -944},
{ -280, 304, -936},
{ -280, 320, -936},
{ -280, 304, -944},
{ -288, 312, -936},
{ -288, 320, -936},
{ -288, 304, -944},
{ -288, 304, -936},
{ -272, 320, -928},
// 186 seconds
{ -280, 3... | |
/*
* 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, "incompatible JS snapshot version %"PRIu8" (expected: %"PRIu8")",
actual_version, expected_version) | ;
return false;
}
return jerry_is_snapshot(buffer + header_length, buffer_size - header_length);
#else
return false;
#endif
}
static bool prv_rocky_eval_buffer(const uint8_t *buffer, size_t buffer_size) {
jerry_value_t rv;
if (rocky_is_snapshot(buffer, buffer_size)) {
buffer += sizeof(ROCKY_EXPECTED... |
d length (%"PRIu32")", length);
return;
}
const FlashCRCRequest *request = payload;
const uint32_t num_entries = length / sizeof(FlashCRCRequest);
// this is just static cause it's potentially too big to put on the stack
static FlashCRCResponse response[MAX_DATA_LENGTH / sizeof(FlashCRCResponse)];
for... | if (is_complete) {
if (s_curr_buf->is_valid && s_curr_buf->checksum == CRC32_RESIDUE && s_curr_buf->index) {
// queue up processing of this frame and clear s_curr_buf so we'll switch to a new one
system_task_add_callback_from_isr(prv_process_frame, s_curr_buf, &should_context_switch);
} else {
... | |
_prefs(serialized_prefs);
return notif_prefs;
}
void ios_notif_pref_db_free_prefs(iOSNotifPrefs *prefs) {
kernel_free(prefs);
}
status_t ios_notif_pref_db_store_prefs(const uint8_t *app_id, int length, AttributeList *attr_list,
TimelineItemActionGroup *action_group) {
Sett... | {
SettingsFile file;
if (S_SUCCESS != prv_file_open_and_lock(&file)) {
return NULL;
}
BlobDBDirtyItem *dirty_list = NULL;
settings_file_each(&file, sync_util_build_dirty_list_cb, &dirty_list);
prv_file_close_and_unlock(&file);
return dirty_list;
} |
status_t ios_notif_pref_db_mark_synced(const uint8_t *key, int key_len) {
if (key_len == 0) {
return E_INVALID_ARGUMENT;
}
SettingsFile file;
status_t rv = prv_file_open_and_lock(&file);
if (rv != S_SUCCESS) {
return rv;
}
rv = settings_file_mark_synced(&file, key, key_len);
prv_file_close_... |
/*
* 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... | f(third, half, ANIMATION_NORMALIZED_MAX) | );
cl_assert_equal_i(21845, f(two_third, half, ANIMATION_NORMALIZED_MAX));
cl_assert_equal_i(109224, f(four_third, half, ANIMATION_NORMALIZED_MAX));
}
|
TIMEOUT_MS);
uint8_t fake_data[max_length];
memset(fake_data, 0, max_length);
comm_session_send_buffer_write(write_sb, fake_data, max_length);
comm_session_send_buffer_end_write(write_sb);
// Set a yield callback that gives the semph in time but closes the session:
SemaphoreHandle_t write_sem... | (header->endpoint_id, htons(ENDPOINT_ID)) | ;
cl_assert_equal_i(memcmp(pp_data_out + sizeof(PebbleProtocolHeader),
fake_data_payload, max_payload_length), 0);
// ..._copy() with offset:
int offset = 2;
bytes_copied =
s_default_kernel_send_job_impl.copy(job, offset,
expected_bytes... |
he Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License i... | {
rx_tan /= cos_sq;
} |
int32_t sqrt_x = integer_sqrt((radius_yy + rx_tan) << FIXED_S16_3_PRECISION);
int16_t x = 0;
if (sqrt_x > 0) {
x = radius_xy / sqrt_x;
}
// Between 90° and 270° we flip the x
if (angle >= (TRIG_MAX_ANGLE / 4) && angle < (TRIG_MAX_ANGLE * 3 / 4)) {
x *= -1;
}
// And y in this case is just x ... |
l_i(value, 330 * SECONDS_PER_MINUTE);
activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value);
cl_assert_equal_i(value, 4 * SECONDS_PER_HOUR + 45 * SECONDS_PER_MINUTE /* 4:45am */);
// Assert that we got the same sleep sessions using the activity service as we do using
// the health API
prv_assert_... | time_start_of_today() | + (elapsed_today / 2));
cl_assert_equal_i(steps, 1500);
}
// ---------------------------------------------------------------------------------------
// Test distance using various speeds and user dimensions
typedef struct {
int height_in;
int gender;
int steps;
float seconds;
int exp_distance_m; // expe... |
/*
* 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... | {
OS_ASSERT(handle != NULL);
LightMutexHandle_t mutex = handle->common.freertos_mutex;
vLightMutexDelete(mutex);
os_free(handle);
} |
void mutex_lock(PebbleMutex * handle) {
uintptr_t myLR = (uintptr_t) __builtin_return_address(0);
OS_ASSERT(!mcu_state_is_isr());
xLightMutexLock(handle->common.freertos_mutex, portMAX_DELAY);
LOG_LOCKED(handle->common.lr, myLR);
}
bool mutex_lock_with_timeout(PebbleMutex * handle, uint32_t timeout_ms) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (buffer_size) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_draw_rect(ctx, &GRect(4, 5, 18, 10)) | |
t_args_for_mock();
}
// Setup
void test_graphics_context_${BIT_DEPTH_NAME}__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
test_graphics_context_init(&context, fb);
}
// Teardown
void test_graphics_context_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb)... | (context.draw_state.antialiased == true) | ;
#endif
// Stroke Width
graphics_context_set_stroke_width(&context, 11);
cl_assert(context.draw_state.stroke_width == 11);
// Make sure setting to zero is ignored
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_stroke_width(&context, 0);
cl_assert(memcmp(&draw_state, &... |
:
case 0x02: {
time_t new_time = ntohl(*(uint32_t*)data);
prv_handle_set_time_msg(new_time);
break;
}
// Set timezone:
case 0x03: {
// Verify that the message length is correct
const size_t header_size = offsetof(TimezoneCBData, region_name);
const uint8_t *timezone_l... | {
clock_get_time_number(number_buffer, number_buffer_size, timestamp);
clock_get_time_word(word_buffer, word_buffer_size, timestamp);
} | |
e clock edge
spi_ll_slave_drive_clock(DIALOG_SPI, true);
spi_ll_slave_release(DIALOG_SPI);
}
static void prv_init_spi(void) {
spi_slave_port_init(DIALOG_SPI);
}
//
// DMA
//
static void prv_cleanup_after_dma_transfer(void) {
dialog_spi_assert_chip_select(false);
// FIXME: PBL-32865: The "OVR" (overrun) st... | dialog_spi_wait_for_int() | ;
dialog_spi_receive_data_no_wait(receive_buf, buf_len);
}
void dialog_spi_init(ExtiHandlerCallback int_exti_cb) {
// reset the interrupt count
s_int_fired = 0;
s_dma_pending_transfer = false;
periph_config_acquire_lock();
prv_init_spi();
periph_config_release_lock();
prv_init_exti(int_exti_cb ?: prv... |
t infinite and animation is reversed
animation_get_elapsed(animation, &animation_elapsed_ms);
elapsed_ms = MAX(0, (int32_t)player->to_elapsed_ms - animation_elapsed_ms);
} else {
elapsed_ms = player->to_elapsed_ms;
}
bool frame_changed = kino_reel_set_elapsed(player->reel, elapsed_ms);
prv_announc... | {
if (player && player->reel) {
animation_unschedule(player->animation);
player->animation = NULL;
}
} | |
where given point means
// center of the point
center.x.raw_value += 4;
center.y.raw_value += 4;
radius.raw_value += 4;
// Same for radius:
radius.raw_value -= radius.raw_value % (FIXED_S16_3_ONE.raw_value / 2);
if (stroke_width < 1 || angle_start > angle_end) {
// Dont draw anything
return;... | if (angle_start > angle_end || radius_outer.raw_value < radius_inner.raw_value) {
// Nothing will be drawn...
return;
} |
// TODO: Adapt this to support new precision, for now this is faked by regular fill
// This will be done with PBL-24777
/*
if (radius_outer.raw_value - radius_inner.raw_value == FIXED_S16_3_ONE.raw_value) {
// Color hack
GColor tmp_color = ctx->draw_state.stroke_color;
ctx->draw_state.stroke_color =... |
/*
* 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... | text_layer_set_text(&data->text_layer_2, QUOTE_BUF_2) | ;
text_layer_set_background_color(&data->text_layer_2, GColorCyan);
text_layer_set_font(&data->text_layer_2, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(&data->text_layer_2, GTextAlignmentCenter);
// Add second text layer to scroll layer (required to get correct content size ... |
attributes_per_group_type_element_out);
}
// -----------------------------------------------------------------------------
static int prv_get_action_group_buffer_size(AttributeGroupType type,
uint8_t num_group_type_elements,
... | prv_init_group_type(type,
group_ptr,
buffer,
num_group_type_elements,
attributes_per_group_type_element) | ;
}
// -----------------------------------------------------------------------------
static AttributeList *prv_deserialize_action(TimelineItemAction *action,
const uint8_t **cursor,
const uint8_t *payload_end,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return 0;
} |
const uint8_t * restrict bytes = data;
crc ^= 0xffffffff;
while (length--) {
crc = (crc >> 4) ^ s_lookup_table[(crc ^ *bytes) & 0xf];
crc = (crc >> 4) ^ s_lookup_table[(crc ^ (*bytes >> 4)) & 0xf];
bytes++;
}
crc ^= 0xffffffff;
return crc;
}
|
error_st)
);
}
static void
clar_run_suite(const struct clar_suite *suite)
{
const struct clar_func *test = suite->tests;
size_t i;
if (!clar_category_is_suite_enabled(suite))
return;
if (_clar.exit_on_error && _clar.total_errors)
return;
if (!_clar.report_errors_only)
clar_print_onsuite... | (_clar_suite_count, _clar_suites) | ;
else
clar_category_enable(argument + offset);
break;
}
case 'l': {
size_t j;
printf("Test suites (use -s<name> to run just one):\n");
for (j = 0; j < _clar_suite_count; ++j)
printf(" %3d: %s\n", (int)j, _clar_suites[j].name);
printf("\nCategories (use -i<c... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (global_lock) | ;
}
void timeout() {
mutex_lock_with_timeout(global_lock);
mutex_unlock(global_lock);
}
void good_timeout() {
if (mutex_lock_with_timeout(global_lock)) {
mutex_unlock(global_lock);
}
}
void stupid_timeout() {
if (!mutex_lock_with_timeout(global_lock)) {
mutex_unlock(global_lock);
}
}
void rever... |
Init) {
return 0;
}
return ntohl(header->token);
}
static bool prv_check_for_state_error(PutBytesCommand cmd, uint32_t token, uint32_t req_length) {
const bool has_error = (prv_is_invalid_command_for_current_state(cmd) ||
prv_has_invalid_request_length(cmd, req_length) ||
... | (cmd, (const SharedHeader *)s_pb_state.receiver.buffer) | |
, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}};
char name_1[BT_DEVICE_NAME_BUFFER_SIZE] = "Device 1";
uint8_t platform_bits_1 = 0x11;
BTBondingID id_1 = bt_persistent_storage_store_bt_classic_pairing(&addr_1, &link_key_1,
... | bt_persistent_storage_store_bt_classic_pairing(&addr_3, &link_key_3,
name_3, &platform_bits_3) | ;
cl_assert(id_3 != BT_BONDING_ID_INVALID);
cl_assert_equal_i(fake_shared_prf_storage_get_bt_classic_store_count(), 3);
// Read all three pairings back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id_1, &addr_out, &link_key_out,
name_out, &platfo... |
ring = "title",
};
static TimelineItem item1 = {
.header = {
.id = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 10*60,
.duration = 10,
.type = TimelineItemTypePin,
.all_day = false,
.layout = LayoutIdCalendar,
},
... | stub_new_timer_timeout(timer_id) | |
bal_has_event_handlers("secondchange"));
cl_assert_equal_b(true, rocky_global_has_event_handlers("minutechange"));
cl_assert_equal_b(true, rocky_global_has_event_handlers("hourchange"));
cl_assert_equal_b(true, rocky_global_has_event_handlers("daychange"));
cl_assert_equal_i(5, s_tick_timer_service_subscribe.ca... | ASSERT_JS_GLOBAL_EQUALS_D("m", 40.0) | |
4, 8, -56},
{ -816, 96, -120},
{ -944, 72, -64},
{ -784, 128, -208},
{ -848, 168, -472},
{ -904, 552, -656},
{ -752, 568, -544},
{ -704, 792, -848},
{ -736, 296, -752},
// 62 seconds
{ -696, -56, -568},
{ -760, -280, -496},
{ -848, -328, -488},
{ -752, -368, -304},
... | { -896, 368, 472},
{ -904, 304, 208},
{ -800, 184, 0},
{ -880, 184, -128},
{ -864, 120, -216},
{ -856, 160, -224},
{ -920, 64, -152},
{ -920, -192, 56},
{ -960, -112, 8},
{ -1096, 8, 16},
{ -880, 152, 24},
{ -848, 328, -224},
{ -808, 312, -296},
{ -888, 320, -296}... |
{ -616, 408, -1184},
{ -640, 136, -1072},
{ -648, 16, -776},
{ -664, -128, -512},
{ -744, -64, -472},
{ -920, -24, -344},
{ -848, -16, -216},
{ -912, 8, -120},
{ -920, 176, -64},
// 70 seconds
{ -824, 264, -120},
{ -872, 344, -200},
{ -856, 304, -192},
{ -832, 10... |
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT W... | cl_assert_equal_i(
string_list_count(list_a),
string_list_count(list_b)
) | ;
uint32_t count = string_list_count(list_a);
for (uint32_t idx = 0; i<count; i++) {
cl_assert_equal_s(
string_list_get_at(list_a, idx),
string_list_get_at(list_b, idx)
);
}
break;
}
default:
cl_assert(false);
b... |
data;
MagReadStatus rv = mag_read_data(&mag_data);
if (rv != MagReadSuccess) {
if (rv == MagReadCommunicationFail) {
// heavy hammer fix for now
// FIXME: move the restart logic to driver
PBL_LOG(LOG_LEVEL_WARNING, "Read after %d samples failed, "
"restarting compass", samples_co... | {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(data, sizeof(*data));
}
*data = (CompassHeadingData) {
.magnetic_heading = s_last_heading,
.true_heading = s_last_heading,
.compass_status = s_current_cal_status,
.is_declination_valid = false
};
} |
//////////////////////////////////////////////////////////////////////////////////
// Recovery firmware commands
#ifdef RECOVERY_FW
static void prv_ecompass_start_callback(void *context) {
s_accel_session = accel_session_create();
accel_session_raw_data_subscribe(s_accel_session, ACCEL_SAMPLING_25HZ, 5,
... |
se
if (session_ref == HRM_INVALID_SESSION_REF) {
session_ref = ++s_manager_state.next_session_ref;
}
HRMSubscriberState *state = kernel_malloc_check(sizeof(*state));
*state = (HRMSubscriberState) {
.session_ref = session_ref,
.app_id = app_id,
.task = current_task,
.queue = pebble_task_get_... | (s_manager_state.lock) | ;
s_manager_state.enabled_run_level = on;
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
mutex_unlock_recursive(s_manager_state.lock);
}
static HRMSessionRef s_console_session = HRM_INVALID_SESSION_REF;
static uint8_t s_tia_count = 0;
static void prv_console_unsubscribe_callback(void *data) {
... |
SleepData *data = (SleepData *)val;
if (!prv_is_last_processed_timestamp_valid(data->last_processed_timestamp)) {
return;
}
PBL_LOG(LOG_LEVEL_INFO, "Got SleepData for wday: %d, cur_wday: %d, sleep: %"PRIu32"",
wday, cur_wday, data->sleep_duration);
activity_metrics_prv_set_metric(... | if (prv_file_open_and_lock(&file) != S_SUCCESS) {
return false;
} |
char key[HEALTH_DB_MAX_KEY_LEN];
snprintf(key, HEALTH_DB_MAX_KEY_LEN, "average%s", (metric == ActivityMetricStepCount) ?
STEP_AVERAGE_KEY_SUFFIX : SLEEP_AVERAGE_KEY_SUFFIX);
const int key_len = strlen(key);
status_t s = settings_file_get(&file, key, key_len, value_out, sizeof(uint32_t));
prv_fi... |
if (strcmp((const char *)cmd_header->data, "com.tests.NotAnApp") == 0) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_fake_app_info_dict),
(uint8_t *)s_fake_app_info_dict);
} else {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_message_app_info_dict... | (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 notification attributes message, but got a app attributes message...
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_message_app_info_dict),
... |
time_util_update_timezone(&tz_info);
result = prv_calculate_time_range(now - SECONDS_PER_DAY, now, &range);
cl_assert(result);
cl_assert_equal_range(range, ((HealthServiceTimeRange){
.last_day_idx = 0,
.num_days = 2,
.seconds_first_day = 53258 - utc_to_local_delta,
.seconds_last_day = 33142 + ... | cl_assert_equal_i(values[0], 1000 / 5) | ;
cl_assert_equal_i(values[1], 1000);
cl_assert_equal_i(values[2], 1000 / 10);
// ensure we look at seconds_total_last_day
values[0] = 1000;
values[2] = 1000;
range.seconds_total_last_day = SECONDS_PER_DAY / 4;
prv_adjust_value_boundaries(values, ARRAY_LENGTH(values), &range);
cl_assert_equal_i(values[... |
return &node_copy;
}
uint16_t app_menu_data_source_get_count(AppMenuDataSource *source) {
cl_assert(source);
return ARRAY_LENGTH(s_fake_app_nodes);
}
static GBitmap s_default_app_icon_bitmap;
void app_menu_data_source_enable_icons(AppMenuDataSource *source, uint32_t fallback_icon_id) {
cl_assert(source);
s... | (&s_ctx, fb) | ;
graphics_context_set_antialiased(&s_ctx, true);
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
... |
/*
* 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... | otp_get_slot(index) | |
struct _tagHeapInfo_t
{
//! Size of the preceding segment, measured in units of ALIGNMENT_SIZE, including the size of this beginer
uint16_t PrevSize;
//! Whether or not this block is currently allocated (vs being free).
bool is_allocated:1;
//! Size of this segment, measured in units of ALIGNMENT_SIZE, incl... | UTIL_ASSERT(heap_info_ptr == heap->end) | ;
char format_str[80];
snprintf(format_str, sizeof(format_str), "alloc: %u (%u bytes), free: %u (%u bytes)",
alloc_segments, *used, free_segments, *free);
util_dbgserial_str(format_str);
}
void heap_calc_totals(Heap* const heap, unsigned int *used, unsigned int *free, unsigned int *max_free) {
UTIL... |
!next_plugged_in;
minute_data[i].active_calories = next_active_calories++;
minute_data[i].resting_calories = next_resting_calories++;
minute_data[i].distance_cm = next_distance_cm++;
minute_data[i].base.active = (minute_data[i].base.steps >= ACTIVITY_ACTIVE_MINUTE_MIN_STEPS)
... | cl_assert_equal_i(s_num_dls_records, 2) | ;
for (int j = 0; j < k_num_records; j++) {
cl_assert_equal_i(s_dls_records[j].hdr.version, ALG_DLS_MINUTES_RECORD_VERSION);
for (int i = 0; i < ALG_MINUTES_PER_DLS_RECORD; i++) {
cl_assert_equal_m(&s_dls_records[j].samples[i],
&minute_data[(j * ALG_MINUTES_PER_DLS_RECORD) + i],
... |
ert(!iter_next(&iterator));
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[3].header.id));
#if CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[2].header.id));
#endif
cl_assert(!iter_prev(&it... | (iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_all_day_items[1].header.id) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
cl_assert(!uuid_equal(&first_all_day_event, &state.pin.header.id));
cl_assert(state.node->all_day);
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state... |
clude "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_persist.h"
#include "stubs_plugin_service.h"
#include "stubs_print.h"
#include "stubs_process_manager.h"
#include "stubs_prompt.h"
#include "stubs_queue.h"
#include "stubs_resources.h"
#include "stubs_syscalls.h"
#include "stubs_unobstructed_area.h"
//... | {
Window *window = modal_manager_get_top_window();
if (window) {
GContext ctx;
memset(&ctx, 0, sizeof(GContext));
modal_manager_render(&ctx);
}
} |
void app_click_config_setup_with_window(ClickManager *click_manager, struct Window *window) {
s_last_click_configured_window = window;
}
// Helpers
////////////////////////////////////
static int16_t prv_get_load_unload_count(void) {
return s_load_count - s_unload_count;
}
static int16_t prv_get_appear_disappea... |
/*
* 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... | {
// "1.23456" * 3 is approx 3.7036800000000003, round up to 4
assert_float_parse("1,23456", 3, true, 4);
} |
void test_ams_util__float_string_parse_period_decimal_separator(void) {
// "1.23456" * 3 is approx 3.7036800000000003, round up to 4
assert_float_parse("1.23456", 3, true, 4);
}
void test_ams_util__float_string_parse_round_down(void) {
// "0.74995" * 2 is approx 1.4999, round down to 1
assert_float_parse("0.... |
"task.h"
#include "queue.h"
TaskHandle_t g_task_handles[NumPebbleTask] KERNEL_READONLY_DATA = { 0 };
static void prv_task_register(PebbleTask task, TaskHandle_t task_handle) {
g_task_handles[task] = task_handle;
}
void pebble_task_unregister(PebbleTask task) {
g_task_handles[task] = NULL;
}
const char* pebble_t... | memory_layout_get_worker_region() | ,
false /* allow_user_access */);
break;
case PebbleTask_Worker:
mpu_init_region_from_region(&app_region, memory_layout_get_app_region(),
false /* allow_user_access */);
mpu_init_region_from_region(&worker_region, memory_layout_ge... |
/*
* 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... | (CRG_TOP, SYS_STAT_REG, BLE_IS_UP) | ) {}
// Start the CW pattern
hw_rf_start_continuous_wave(0x1, cmd->tx_channel);
}
extern void cm_lp_clk_force_available(bool force_available);
static void prv_handle_sleep_test_cmd(const HcProtocolMessage *msg) {
const HcTestSleep *sleep_test = (HcTestSleep *)&msg->payload[0];
// Dialog gives the 32K clock ... |
tive_window = workout_active_create_tripple_layout(
top_metric, middle_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics,
&s_sports_data, &s_sports_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_ac... | prv_create_window_and_render(active_window, 1) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_custom_field(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
.custom_label_string = "CUSTOM",
.custom_valu... |
-----------------------------
#define TO_SESSION_REF(x) ((HRMSessionRef)(long)(x))
static const HRMData s_hrm_event_data = {
.led_current_ua = 243,
.hrm_bpm = 82,
.hrm_quality = HRMQuality_Excellent,
};
static void prv_fake_send_new_data(void) {
hrm_manager_new_data_cb(&s_hrm_event_data);
}
static PebbleHRM... | (session_ref, NULL, NULL, &ret_expire_s, NULL) | ;
cl_assert_equal_i(ret_expire_s, 0);
// Now, call the process cleanup. This should place an expiration time on the subscription
hrm_manager_process_cleanup(PebbleTask_App, app_id);
cl_assert(sys_hrm_manager_get_app_subscription(app_id) == session_ref);
sys_hrm_manager_get_subscription_info(session_ref, NUL... |
87},
{ -309, 39, -1567},
{ -199, 118, -1325},
{ -35, 69, -1060},
{ 148, 113, -738},
{ 262, 183, -543},
{ 368, 104, -359},
{ 428, -88, -151},
{ 463, -168, -151},
{ 504, -171, -190},
{ 484, -265, -139},
{ 463, -282, -214},
{ 445, -232, -301},
{ 509, -215, -248},
{ 4... | { 425, -113, -278},
{ 433, -136, -384},
{ 440, -14, -344},
{ 301, 192, -573},
{ 200, 381, -1021},
{ 123, 379, -1026},
{ -61, 459, -1467},
{ -320, 547, -1623},
{ -456, 485, -1655},
{ -500, 502, -1680},
{ -447, 379, -1518},
{ -367, 266, -1369},
{ -376, 244, -1340},
... |
// ----------------------------------------------------------------
// Sample captured: 2015-08-06 18:38:11 GMT
AccelRawData *activity_sample_working_at_desk(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME working_at_desk
//> TEST_EXPECTED 0
//> TEST_EXPECTED_MIN... |
cl_assert_equal_s(tmbuf, "Fri Jan 2 13:00:00 2015") | ;
}
void test_strftime__small_buffer(void) {
char tmbuf[8];
struct tm jan_2_2015__13_00_00 = {
.tm_hour = 13, .tm_min = 0, .tm_sec = 0, // 13:00:00
.tm_year = 2015 - 1900, .tm_mon = 0, .tm_mday = 2, // 2015/01/02
.tm_wday = 5, .tm_yday = 1, // Friday, 2nd day of the year
.tm_gmtoff = 0, .tm_isdst ... | |
/*
* 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... | periph_config_enable(BOARD_CONFIG.mic_config.spi,
BOARD_CONFIG.mic_config.spi_clock_ctrl) | ;
periph_config_release_lock();
gpio_use(BOARD_CONFIG.mic_config.i2s_ck.gpio);
gpio_use(BOARD_CONFIG.mic_config.i2s_sd.gpio);
// Configure pins as SPI/I2S pins
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStru... |
!= FLASH_RESET_WORD_VALUE) {
return false;
}
}
}
return true;
}
#endif
static bool prv_blank_check_mmap(QSPIFlash *dev, uint32_t addr, bool is_subsector) {
const uint32_t size_bytes = is_subsector ? SUBSECTOR_SIZE_BYTES : SECTOR_SIZE_BYTES;
bool result = true;
uint8_t instruction;
uint8_t... | (dev->qspi) | ;
prv_write_enable(dev);
prv_write_cmd_no_addr(dev, dev->state->part->instructions.block_unlock_all);
qspi_release(dev->qspi);
return S_SUCCESS;
}
#if !RELEASE
#include "console/prompt.h"
#include "drivers/flash.h"
#include "kernel/pbl_malloc.h"
#include "system/profiler.h"
#include "util/size.h"
static bool ... |
v_draw_rel_bar_dotted(TimelineLayer *timeline_layer, GContext* ctx,
bool current, int16_t rel_bar_value) {
int16_t prev_offset = 0; // Used to animate the previous animation offset
if (!current) {
prev_offset = REL_BAR_PREV_ANIM_OFFSET - rel_bar_value;
prev_offset = (time... | {
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) ||
((!current) && ((y_offset >= REL_BAR_PREV_ANIM_OFFSET) ||
(y_offset <= -REL_BAR_PREV_ANIM_OFFSET)))) {
return;
}
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, false);
GRect layer_bounds = timel... |
LL;
}
return prv_find_subscription_for_characteristic(characteristic_ref, *connection_out);
}
//! Internally used by gatt_client_operations.c, should not be called otherwise.
//! This function handles the completion of pending (un)subscriptions (confirmations of the writing
//! to the remote CCCD).
//! @note bt_lo... | (header_out->value_length <= read_space - sizeof(*header_out)) | ;
}
unlock:
prv_unlock();
return has_notification;
}
// -------------------------------------------------------------------------------------------------
uint16_t gatt_client_subscriptions_consume_notification(BLECharacteristic *characteristic_ref_out,
uin... |
rogress_bar;
loading_layer_init(loading_layer, &loading_frame);
progress_layer_set_foreground_color((ProgressLayer *)loading_layer, GColorBlack);
const GColor progress_bg_color = PBL_IF_COLOR_ELSE(GColorDarkGray, GColorWhite);
progress_layer_set_background_color((ProgressLayer *)loading_layer, progress_bg_colo... | ("Voice Window") | );
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_mic_window_load,
.unload = prv_mic_window_unload,
.appear = prv_mic_window_appear,
.disappear = prv_mic_window_disappear
});
window_set_user_data(window, data);
prv_window_push(window);
}
// External interface
//////////////... |
atusFailureConnectivityError);
}
}
static void prv_handle_bt_conn_result(bool connected, void *context) {
VoiceUiData *data = context;
if (connected) {
if (data->state == StateError) {
// We got here after a dictation result timeout, so restart the dictation
prv_start_dictation(data);
} else ... | {
data->timestamp = event->data->timestamp;
} |
if (!data->message) {
VOICE_LOG("Empty sentence received");
return false;
}
VOICE_LOG("New sentence: %s", data->message);
return true;
}
static void prv_handle_dictation_error(VoiceUiData *data, VoiceStatus error_status) {
uint64_t elapsed = prv_get_time_ms() - data->start_ms;
const bool speech_... |
/*
* 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... | GRect(2, 2, 28, 20) | , 4, GCornersAll);
}
void corners_clipped_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(-19, 0, 20, 20), 4, GCornersAll);
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__origin_l... |
/ ble_ad_set_service_uuids() will be "smart" and include only the 16-bit UUID, but only if the
// BT SIG Base UUID is used.
Uuid service_uuids[2];
size_t num_uuids = 0;
#if CAPABILITY_HAS_BUILTIN_HRM
// NOTE: The HRM service has to be first in the list because otherwise the Pebble won't
// show up as an HRM ... | {
// Always stop and re-start, so we start with the high rate again:
gap_le_advert_unschedule(s_discovery_advert_job);
if (discoverable) {
prv_schedule_ad_job();
}
} | |
}
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
analytics_read_count++;
analytics_read_bytes_count += buffer_size;
power_tracking_start(PowerSystemFlashRead);
enable_flash_spi_clock();
handle_sleep_when_idle_begin();
flash_wait_for_writ... | enable_flash_spi_clock() | |
.section >= num_sections) {
index.section = num_sections - 1;
}
// check to make sure this callback has been set, return early if not
if (menu_layer->callbacks.get_num_rows == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "Please set menu layer callbacks before running menu_layer_set_selected_index.");
return;
}... | prv_apply_selection_change(menu_layer, scroll_align, up, it.did_change_selection,
&before_state.prev_selection, before_state.was_animating, animated) | ;
}
MenuIndex menu_layer_get_selected_index(const MenuLayer *menu_layer) {
return menu_layer->selection.index;
}
bool menu_layer_is_index_selected(const MenuLayer *menu_layer, MenuIndex *index) {
MenuIndex selected_index = menu_layer_get_selected_index(menu_layer);
return menu_index_compare(&selected_index, ind... |
ce;
static BLEService s_service_handles[] = {
TestServiceInstanceComplete,
TestServiceInstanceIncomplete,
TestServiceInstanceUnsupported,
};
typedef enum {
TestCharacteristicInstanceCompleteOne = 11,
TestCharacteristicInstanceCompleteTwo = 12,
TestCharacteristicInstanceIncompleteOne = 21,
TestCharacteri... | kernel_le_client_handle_event(&e) | ;
cl_assert_equal_i(s_read_responses_consumed_count, 0);
}
void test_kernel_le_client__service_added(void) {
uint8_t num_services_added = ARRAY_LENGTH(s_service_handles);
PebbleBLEGATTClientServiceEventInfo *info =
kernel_malloc(sizeof(PebbleBLEGATTClientServiceEventInfo) +
(num_servic... |
d) {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = ANIMATION_DURATION_INFINITE;
kino_player_play(test_player);
animation_set_elapsed(test_player->animation, 20);
animation_set_duration(test_player->ani... | prv_play_animation_update(test_player->animation, 0) | ; // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 300 - 20);
}
void test_kino_player__create_infinite_animation_finite_reel_reverse(void) {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->... |
boot_bit_test(BOOT_BIT_RESET_LOOP_DETECT_ONE);
switch (++counter) {
case 1:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 2:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO);
break;
case 3:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_O... | dbgserial_print_hex(RCC->CSR) | ;
dbgserial_newline();
if (RCC_GetFlagStatus(RCC_FLAG_BORRST) == SET) {
dbgserial_putstr("Brown out reset");
}
}
// SystemInit does this for the firmware, but since the bootloader isn't using
// the vendor SystemInit, initialize the flash cache here
static void prv_configure_system_flash(void) {
// Enable ... |
stNode *)conn_mgr_info->requests,
prv_find_source, (void *)consumer);
bool is_already_granted = (gap_le_connect_params_get_actual_state(hdl) >= state);
if (consumer_request == NULL) {
if (state == ResponseTimeMax) {
// No changes: there was no previous node and... | new_timer_start(s_chaos_monkey_timer, delay_ms, prv_mode_chaos_monkey_callback, data, 0) | ;
unlock:
bt_unlock();
}
void command_le_mode_chaos_monkey(char *enabled_str) {
bool new_enabled = atoi(enabled_str);
bool is_enabled = (s_chaos_monkey_timer != TIMER_INVALID_ID);
if (new_enabled == is_enabled) {
return;
}
bt_lock();
if (new_enabled) {
GAPLEConnection *conn_hdl = gap_le_connec... |
0x55, 0x65, 0x72, 0x22, 0xb4, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0... | (BLOB_DB_INVALID_DATA == *resp_ptr) | ;
resp_ptr += sizeof(uint8_t);
cl_assert((resp_ptr - s_data) == s_sending_data_length);
}
/**************************************************
* Checking for below minimum size INSERT command *
**************************************************/
static const uint8_t s_insert_cmd_no_value_size[] = {
// Message... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.