prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
s than the max number of slices per glance.
// This can happen for glance entries sent to us by the mobile apps because they don't have a way
// of knowing the max number of slices supported by the firmware, and so they send us as many
// slices as they can fit in a BlobDB packet. We just take as many slices as w... | prv_lock_mutex_and_open_file() | ;
if (rv != S_SUCCESS) {
return rv;
}
if (settings_file_exists(&s_app_glance_db.settings_file, key, (size_t)key_len)) {
rv = settings_file_delete(&s_app_glance_db.settings_file, key, (size_t)key_len);
} else {
rv = S_SUCCESS;
}
prv_close_file_and_unlock_mutex();
return rv;
}
/////////////... |
, &uuid));
cl_assert_equal_uuid(uuid, tictoc_uuid);
cl_assert_equal_b(true, app_install_get_uuid_for_install_id(music_id, &uuid));
cl_assert_equal_uuid(uuid, music_uuid);
cl_assert_equal_b(true, app_install_get_uuid_for_install_id(sports_id, &uuid));
cl_assert_equal_uuid(uuid, sports_uuid);
cl_assert_equa... | cl_assert_equal_i(ProcessStorageFlash, menu_layer_md->process_storage) | ;
app_install_release_md(menu_layer_md);
}
static bool prv_each(AppInstallEntry *entry, void *data) {
uint8_t *num_entries = (uint8_t *)data;
*num_entries = *num_entries + 1;
cl_assert(entry->install_id != INSTALL_ID_INVALID);
return true;
}
void test_app_install_manager__enumerate_entries(void) {
uint8_t... |
, 304},
{ -1144, 488, 272},
// 70 seconds
{ -1384, 360, 320},
{ -1528, 328, 344},
{ -1440, 112, 272},
{ -1248, 160, 424},
{ -1224, 16, 320},
{ -1176, 104, 296},
{ -1128, 32, 264},
{ -1296, 16, 320},
{ -1216, -232, 248},
{ -992, -192, -16},
{ -1264, -136, -72},
{ -... | { -2488, 672, 1472},
{ -1424, 576, 320},
{ -1824, 888, 40},
{ -1496, 480, 440},
{ -768, 400, 416},
{ -392, 224, 128},
{ -448, 120, 264},
{ -424, 296, 56},
{ -520, 328, 96},
{ -672, 280, 176},
{ -1264, 312, 248},
{ -1448, 352, 240},
{ -1768, 336, 256},
{ -1728, 448... |
{ -1384, 192, 608},
// 78 seconds
{ -1144, 720, 1112},
{ -304, 176, 216},
{ -536, 704, 168},
{ -936, 648, 264},
{ -1848, 496, 512},
{ -1672, 264, 104},
{ -1544, 176, 280},
{ -1496, 272, 96},
{ -1408, 72, 296},
{ -1184, 160, 192},
{ -1040, 216, 96},
{ -1008, 240, ... |
00, -128},
{ -528, 360, -296},
{ -872, 208, -160},
{ -1392, 376, -408},
{ -1232, 344, -168},
{ -1536, 568, -464},
{ -1280, 472, -520},
{ -1008, 392, -352},
{ -1144, 528, -176},
{ -968, 384, -16},
// 31 seconds
{ -680, 304, 24},
{ -512, 392, 64},
{ -344, 240, 72},
... | { -424, 256, -64},
{ -488, 296, -56},
{ -640, 288, -64},
{ -792, 368, -16},
{ -888, 520, -72},
{ -1080, 504, -96},
{ -1104, 656, -72},
{ -1656, 456, -320},
{ -1472, 400, -128},
{ -1264, 448, -112},
{ -1144, 304, -56},
{ -808, 288, -8},
{ -536, 256, -40},
{ -344, 2... | |
;
}
break;
case StateRecording:
if ((next_state == StateWaitForResponse) || (next_state == StateTransitionToText)) {
return StateStopRecording;
}
break;
case StateStopRecording:
if (next_state == StateTransitionToText) {
*defer_transition = true;
// ... | (data->state, state, &defer_transition) | ;
if (!defer_transition) {
prv_do_transition(data, state);
}
data->state = state;
VOICE_LOG("State: %d", data->state);
}
static void prv_mic_window_load(Window *window) {
VoiceUiData *data = window_get_user_data(window);
const GColor window_bg_color = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite);
... |
(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) | == S_SUCCESS) {
// Update each wakeup entry via prv_update_events_callback and record any missed events
settings_file_rewrite(&wakeup_settings, prv_update_events_callback, &missed_events);
settings_file_close(&wakeup_settings);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Error: could not open wakeup... | |
Int8:
*((uint8_t *)dest_ptr) = val;
return true;
case RockyArgTypeUInt16:
*((uint16_t *)dest_ptr) = val;
return true;
case RockyArgTypeUInt32:
*((uint32_t *)dest_ptr) = val;
return true;
case RockyArgTypeUInt64:
*((uint64_t *)dest_ptr) = val;
return true;
... | if (rocky_api_graphics_color_from_value(argv[0], (GColor *)binding->ptr)) {
return true;
} |
*value_error_out = (RockyArgValueCheckError) {
.error_msg = COLOR_ERROR_MSG,
.arg_offset = 0,
};
return false;
}
static bool prv_check_type_is_number(const jerry_value_t argv[],
RockyArgTypeCheckError *type_error_out) {
if (jerry_value_is_number(argv[0])) {
re... |
(receiving)
static bool s_input_enabled;
//! We'll store up to the last 3 bytes which were sent for detecting bus contention
typedef struct {
uint8_t data;
bool has_data;
} SendHistory;
static volatile SendHistory s_send_history;
//! Flag which states whether or not we've detected bus contention since last disabli... | {
new_timer_start(s_stop_mode_monitor.timer, ACCESSORY_STOP_INTERVAL_PERIOD_MS,
prv_timer_interval_expired_cb, NULL, TIMER_START_FLAG_REPEATING);
} | |
o in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "resource_storage.h"
#include "re... | (entry, manifest) | ) == 0) {
PBL_LOG(LOG_LEVEL_WARNING, "Resource table check failed. Table or manifest may be corrupted");
return false;
}
uint32_t calculated_crc = prv_get_crc(entry, num_bytes, 0);
if (calculated_crc != manifest->version.crc) {
PBL_LOG(LOG_LEVEL_WARNING, "Resource crc mismatch for app %"PRIu32".", ap... |
/*
* 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... | (data->dialog) | ;
if (next_dialog_state != data->last_dialog_state) {
// Setting the dialog icon to itself restarts the animation, which looks
// bad, so we want to avoid that if we can help it.
switch (next_dialog_state) {
case DialogState_FullyCharged:
dialog_set_text(dialog, i18n_get("Fully Charged", da... |
/*
* 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... | RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR) | ;
current_value &= ~bit;
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, current_value);
}
bool boot_bit_test(BootBitValue bit) {
uint32_t current_value = RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR);
return (current_value & bit);
}
void boot_bit_dump(void) {
dbgserial_print("Boot bits: ");
dbgserial_print_hex(... |
== S_SUCCESS);
settings_file_close(&file);
}
}
mutex_unlock(s_mutex);
return success;
}
// ------------------------------------------------------------------------------------
// Called from KernelMain when we get a blob DB event. We take this opportunity to update the state
// of the given pref
v... | (percent_intensity > 0 && percent_intensity <= 100) | ;
uint16_t intensity = prv_convert_backlight_percent_to_intensity(percent_intensity);
PBL_ASSERTN(intensity > BACKLIGHT_BRIGHTNESS_OFF);
prv_pref_set(PREF_KEY_BACKLIGHT_INTENSITY, &intensity, sizeof(intensity));
}
bool backlight_is_motion_enabled(void) {
return s_backlight_motion_enabled;
}
void backlight_set... |
ta, 1);
// Should be able to write (BUFFER_SIZE) again,
// because the message 1 and 2 are consumed now:
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer));
cl_assert_equal_b(true, app_inbox_service_write(AppInbo... | cl_assert_equal_i(app_inbox_service_unregister_by_storage(storage), 0) | |
SamplingRate)arr[i]) {
case ACCEL_SAMPLING_10HZ:
case ACCEL_SAMPLING_25HZ:
case ACCEL_SAMPLING_50HZ:
case ACCEL_SAMPLING_100HZ:
break;
default:
cl_assert(0);
}
}
}
static void prv_run_accel_test(int *sample_arr, int num_items) {
PebbleTask tasks[] = { PebbleTask_Ke... | (
ACCEL_SAMPLING_10HZ, prv_noop_sample_handler, NULL, PebbleTask_KernelMain) | ;
sys_accel_manager_set_sample_buffer(main_session, fake_buf, 11);
stub_pebble_tasks_set_current(PebbleTask_Worker);
AccelManagerState *worker_session = sys_accel_manager_data_subscribe(
ACCEL_SAMPLING_25HZ, prv_noop_sample_handler, NULL, PebbleTask_KernelMain);
sys_accel_manager_set_sample_buffer(worker... |
MAP_CACHING
if (font_cache->glyph_buffer_key == cache_key) {
cached = (LineCacheData *)(font_cache->glyph_buffer);
}
#endif
PBL_LOG_D(LOG_DOMAIN_TEXT, LOG_LEVEL_DEBUG, "looking up cp: %"PRIx32", key:%"PRIx32,
codepoint, cache_key);
// If the glyph_buffer doesn't match this glyph, or we have bit... | prv_load_glyph_bitmap(codepoint, font_res, final_data) | ) {
return NULL;
}
// We push `data`, which will be cooked data if the bitmap is stored along with it, or
// the uncooked data if it's not. In reality, this only matters to compressed glyphs, since
// compressed glyphs are the only case where the metadata gets modified.
// The only time the data is cooke... |
st GRect *glance_frame) {
// Title node and subtitle node
const size_t max_vertical_nodes = 2;
GTextNodeVertical *vertical_node = graphics_text_node_create_vertical(max_vertical_nodes);
vertical_node->vertical_alignment = GVerticalAlignmentCenter;
GTextNode *title_node = prv_structured_glance_create_title_te... | {
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);
GTextNode *struc... |
VEL_DEBUG, "%s", buf); \
} while (0)
#else
#define PROF_LOG(buf, sz, fmt, ...) dbgserial_putstr_fmt(buf, sz, fmt, ## __VA_ARGS__)
#endif
Profiler g_profiler;
#undef PROFILER_NODE
#define PROFILER_NODE(name) ProfilerNode g_profiler_node_##name = {.module_name = #name};
#include "profiler_list.h"
#undef PROFILER... | {
ProfilerNode *node = (ProfilerNode *)sorted;
uint32_t percent = (((int64_t)node->total) * 100) / total;
PROF_LOG(buf, sizeof(buf),
"%-24s %-8"PRIu32" %-11"PRIu32" %-15"PRIu32" %-8"PRIu32 " %-7"PRIu32,
node->module_name, node->count, node->total, node->total / mhz,
(nod... | |
prv_put_bytes_get_max_batched_pb_ops() | ;
for (int i = 0; i <= max_pb_ops; i++) {
prv_receive_put(s_last_response_cookie, chunk, sizeof(chunk));
}
assert_ack_count(max_pb_ops);
assert_nack_count(1);
}
void test_put_bytes__chunk_too_large(void) {
prv_receive_init_fw_object();
prv_process_and_reset_test_counters();
size_t chunk_size = 1024... | |
ke should be drawn
gdraw_command_set_stroke_color(command, GColorPurple);
gdraw_command_set_radius(command, 0);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorPurpleARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorClearARGB8);
cl_assert_equal_i(s_stroke_width, 2);
cl_ass... | (s_circle_stroke_count, 1) | |
nfirmation_dialog,
prv_information_click_config);
app_confirmation_dialog_push(confirmation_dialog);
}
}
#include "drivers/led_controller.h"
#include "system/rtc_registers.h"
static void prv_color_led_easter_egg(void) {
#if CAPABILITY_HAS_LED
static int i = 0;
// Simple test code to exercise each o... | WINDOW_NAME("System Information") | );
window_set_user_data(&data->window, data);
window_set_window_handlers(&data->window, &(WindowHandlers) {
.load = prv_information_window_load,
.unload = prv_information_window_unload,
});
app_window_stack_push(&data->window, true);
}
// Certification Window
///////////////////////
int16_t prv_cert... |
t_dropped_handler,
}
#endif
};
for (AppInboxServiceTag tag = 0; tag < NumAppInboxServiceTag; ++tag) {
if (s_event_handler_map[tag].message_handler == message_handler &&
s_event_handler_map[tag].dropped_handler == dropped_handler) {
return tag;
}
}
return AppInboxServiceTagInvalid;
}
D... | prv_lock() | ;
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(consumer_info->tag);
if (!inbox) {
goto unlock;
}
uint8_t *const consumed_up_to_ptr = consumer_info->it;
uint8_t * const completed_messages_end = (inbox->buffer.storage + inbox->buffer.write_index);
if (consumed_up_to_p... |
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "battery_ui.h"
#include <stdint.h>
#include "applib/ui/vibes.h"
#include "apps/system_app_ids.h"
#include "apps/system_apps/battery_critical_app.h"
#include "kernel/low_power.h"
#include "kernel/ui/... | ARRAY_LENGTH(s_warning_points) | - 1;
while (s_warning_points_index < num_points && (percent <=
battery_curve_get_percent_remaining(s_warning_points[s_warning_points_index + 1]))) {
s_warning_points_index++;
new_warning = true;
}
if (new_warning) {
if (!do_not_disturb_is_active()) {
vibes_short_pulse();
}
ba... |
// is currently stable
if (stable_sensor) {
state->last_valid_ticks = cur_ticks;
}
PebbleHRMEvent hrm_event;
for (uint8_t i = 0; i < HRMFeatureShiftMax; ++i) {
HRMFeature feature = (1 << i);
if (!(state->features & feature)) {
continue;
}
// Only send BPM and H... | {
PBL_ASSERTN(current_task == PebbleTask_App || current_task == PebbleTask_Worker);
is_app_subscription = true;
} |
mutex_lock_recursive(s_manager_state.lock);
HRMSessionRef session_ref = HRM_INVALID_SESSION_REF;
// If there is already an existing subscription for this app, remove the old one before we
// add another subscription for this app.
if (is_app_subscription) {
HRMSubscriberState * state = prv_get_subscribe... |
PTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, STROKE_SMALL);
graphics_circle_quadrant_draw_stroked_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, STROKE_SMALL,GCornerTopRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_r8_quad_top_right.${... | graphics_circle_quadrant_draw_stroked_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, STROKE_SMALL,GCornersTop) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_aa_r8_quads_top.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, STROKE_SMALL);
graphics_circle_quadrant_draw_stroked_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, STROKE_SMALL,GCornersBottom);
... |
tubs_app_manager.h"
#include "stubs_app_state.h"
#include "stubs_events.h"
#include "stubs_framebuffer.h"
#include "stubs_graphics.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_process_manager.h"
#include "stubs_ui_window.h"
// Fa... | fake_event_service_handle_last() | ;
cl_assert_equal_i(s_data.num_will_change_calls, 1);
const GRect to_area_expected = GRect(0, 0, DISP_COLS, MIN(200, DISP_ROWS));
cl_assert_equal_grect(s_data.last_will_change_final_area, to_area_expected);
}
void test_unobstructed_area_service__will_change_twice(void) {
UnobstructedAreaHandlers handlers = {
... |
(GColorRedARGB8, ctx.draw_state.stroke_color.argb) | ;
graphics_context_set_stroke_color(&ctx, (GColor8){.a= 1, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.stroke_color.argb);
graphics_context_set_stroke_color(&ctx, (GColor8){.a= 0, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.stroke_color.argb);
}
void test_graphics_blending__ct... | |
not enabled, but it
// should be fine to clear errors this way
#if !TARGET_QEMU
// Clear any stale errors that may be in the registers. This can be accomplished
// by reading the status register followed by the data register
(void)dev->periph->SR;
(void)dev->periph->DR;
#endif
dev->periph->CR1 |= USART_CR1... | {
return dev->periph->SR & USART_SR_RXNE;
} | |
ompt.h"
#include "util/size.h"
static const uint8_t OTP_SERIAL_SLOT_INDICES[] = {
OTP_SERIAL1, OTP_SERIAL2, OTP_SERIAL3, OTP_SERIAL4, OTP_SERIAL5
};
static const uint8_t OTP_PCBA_SLOT_INDICES[] = {
OTP_PCBA_SERIAL1, OTP_PCBA_SERIAL2, OTP_PCBA_SERIAL3
};
#if PLATFORM_SILK || PLATFORM_CALCULUS || PLATFORM_ROBERT... | (mfg_get_hw_version()) | ;
}
void command_pcba_serial_read(void) {
prompt_send_response(mfg_get_pcba_serial_number());
}
void command_serial_write(const char *serial) {
MfgSerialsResult result;
uint8_t index = 0;
size_t serial_len = strlen(serial);
if ((serial_len >= 11) && (serial_len <= MFG_SERIAL_NUMBER_SIZE)) {
result = mf... |
"steps: %"PRId32, steps);
if (steps >= 27 && steps <= 33) {
passed = true;
}
prv_test_end(context, passed);
}
// -------------------------------------------------------------------------------
static void prv_test_30_min_walk(void *context) {
bool passed = false;
activity_prefs_activity_insights_set_... | PBL_LOG(LOG_LEVEL_DEBUG, "entry minute: %d", (int)(value / SECONDS_PER_MINUTE)) | ;
activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value);
PBL_LOG(LOG_LEVEL_DEBUG, "exit minute: %d", (int)(value / SECONDS_PER_MINUTE));
activity_get_metric(ActivityMetricSleepState, 1, &value);
PBL_LOG(LOG_LEVEL_DEBUG, "sleep state: %d", (int)value);
activity_get_metric(ActivityMetricSleepState... |
/*
* 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(system_flash_erase(FLASH_BASE, 0, NULL, NULL)) | |
ool prv_find_listener(jerry_value_t event_listeners, uint32_t idx,
jerry_value_t listener, void *data) {
ListenerQueryData *query_data = data;
if (query_data->listener == listener) {
query_data->found = true;
return false;
}
return true;
}
static bool prv_listener_is_registered(c... | (*api_ref)->add_handler(event_name, func) | ;
if (is_relevant) {
break;
}
}
}
if (!is_relevant) {
APP_LOG(LOG_LEVEL_WARNING, "Unknown event '%s'", event_name);
return jerry_create_undefined();
}
prv_add_event_listener_to_list((char *)event_name, func);
return jerry_create_undefined();
}
JERRY_FUNCTION(prv_remove_even... |
t8_t LEGEND_WIDTH = 4;
const uint8_t LEGEND_HEIGHT = 4;
const uint8_t OFFSET = 1;
const uint8_t HEIGHT = WIDTH;
const uint8_t NUM_OPACITIES = 4;
const uint8_t TOTAL_WIDTH = LEGEND_WIDTH * 2 + WIDTH;
const uint8_t TOTAL_HEIGHT = HEIGHT + OFFSET + LEGEND_HEIGHT * 2;
uint8_t dest_data[TOTAL_WIDTH * TOTAL_HE... | {
const int16_t x = rgb_half * NUM_OPACITIES + LEGEND_WIDTH;
const int8_t legend_height = 3;
// Upper row with destination colors from 0..31
const GColor upper_tint_color = (GColor){.argb = 0b11000000 | rgb_half};
const int16_t y_upper = LEGEND_HEIGHT;
const GRect upper_rect = GRect(x, y_upper,... |
bitblt_bitmap_into_bitmap_tiled(&dest_bitmap, &test_bmp, lower_rect, GPointZero, GCompOpTint, lower_tint_color);
}
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_comptint_blend-expect.8bit.pbi"));
}
// Tests assign, clipping, makes sure in bottom right corner.
// Setup:
// - Source is 10x15, bla... |
/*
* 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... | GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1) | |
oves, 0);
alarm_set_enabled(id1, false);
prv_assert_alarm_config(id1, 3, 14, true, ALARM_KIND_EVERYDAY, s_every_day_schedule);
cl_assert_equal_i(s_num_timeline_adds, 3);
cl_assert_equal_i(s_num_timeline_removes, 3);
alarm_set_enabled(id1, true);
prv_assert_alarm_config(id1, 3, 14, false, ALARM_KIND_EVERYD... | (s_num_alarms_fired, 1) | ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Alarm Timeline Pin Tests
void test_alarm__pin_add(void) {
const AlarmId dummy_alarm_id = 0;
const AlarmKind alarm_kind = ALARM_KIND_WEEKENDS;
Uuid added_pin_uuid;
alarm_pin_add(s_monday, dummy_alarm_id... |
ude "rocky_api_errors.h"
#include "applib/graphics/gpath.h"
#include "applib/graphics/graphics_circle.h"
#include "applib/graphics/graphics_line.h"
#include "kernel/pbl_malloc.h"
#include "rocky_api_util.h"
#include "rocky_api_util_args.h"
#include "system/passert.h"
#include "util/size.h"
#include "util/trig.h"
#def... | (
&step->arc.center, (uint16_t)step->arc.radius.raw_value, step->arc.angle_start) | ;
graphics_line_draw_precise_stroked(ctx, pp, pt_from);
}
int32_t angle_start = step->arc.angle_start;
int32_t angle_end = step->arc.angle_end;
if (step->arc.anti_clockwise) {
const int32_t t = angle_start;
angle_start = angle_end;
angle_end = t;
... |
_ERROR, "Failed to start accel service");
}
}
}
mutex_unlock_recursive(s_mutex);
}
// -------------------------------------------------------------------------------------------
// NOTE: This is guaranteed to be only called from the KernelMain task by the event_service
static void prv_tap_remove_subscri... | (PEBBLE_ACCEL_SHAKE_EVENT, &prv_tap_add_subscriber_cb,
&prv_tap_remove_subscriber_cb) | ;
#ifdef TEST_KERNEL_SUBSCRIPTION
accel_data_service_subscribe(5, prv_kernel_data_subscription_handler);
accel_tap_service_subscribe(prv_kernel_tap_subscription_handler);
accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
#endif
imu_power_down();
}
#ifdef RECOVERY_FW
void command_accel_peek(void) {
cons... |
/*
* 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 (!reboot_reason_get(&reason)) {
return 0;
} | ;
switch (reason.code) {
case RebootReasonCode_Assert:
case RebootReasonCode_HardFault:
case RebootReasonCode_RomError:
case RebootReasonCode_Watchdog:
return reason.extra;
default:
return 0;
}
}
RebootReasonCode reboot_reason_get_last_reboot_reason(void) {
RebootReason reason;
... |
pfs_open but for now we will just let external callers use this
// routine before allocating large files
uint32_t tot_capacity = (pfs_get_size() * 8) / 10;
return ((allocated_space >= tot_capacity) ?
0 : (tot_capacity - allocated_space));
}
uint32_t pfs_crc_calculate_file(int fd, uint32_t offset, uint... | {
prompt_send_response_fmt(buf, sizeof(buf), "rd err: %d", num_bytes);
goto cleanup;
} | |
-1000},
{ 56, 16, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 64, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
... | { 56, 8, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 16, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 16, -1000},
{ 56, 16, -1000},
{ 64, 16, -1000},
{ 56, 16, -1000},
{ 64, 16, -1000},
{ 56, 16, -1000},
{ 56, 16,... |
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 56, 16, -1000},
{ 56, 16, -1008},
{ 56, 16, -1000},
{ 56, 32, -1000},
{ 56, 16, -1000},
{ 56, 16, -992},
{ 56, 24... |
.pbi"));
// SW = 3
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 3);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw3_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_REC... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, 1);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw1_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// AA = true, SW = 2
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_C... |
er = reminder_info->reminder_out;
if (timeline_item_storage_get_from_settings_record(file, info, reminder) != S_SUCCESS) {
return true; // continue iteration
}
const char *title = attribute_get_string(&reminder->attr_list, AttributeIdTitle, "");
if (strcmp(title, reminder_info->title) != 0) {
timeline_... | (&s_storage) | ;
}
status_t reminder_db_insert(const uint8_t *key, int key_len, const uint8_t *val, int val_len) {
analytics_inc(ANALYTICS_DEVICE_METRIC_REMINDER_RECEIVED_COUNT, AnalyticsClient_System);
// Records inserted from the phone are synced
const bool mark_synced = true;
return prv_insert_reminder(key, key_len, val,... |
imer();
if (s_ancs_client->characteristics[0] != BLE_CHARACTERISTIC_INVALID) {
PBL_LOG(LOG_LEVEL_WARNING, "Multiple ANCS services registered?!");
ancs_invalidate_all_references();
}
// Keep around the BLECharacteristic references:
memcpy(s_ancs_client->characteristics, characteristics,
sizeof... | ancs_notifications_handle_notification_removed(nsnotification->uid, properties) | |
{ 1056, 216, -8},
{ 968, 224, -80},
{ 872, 160, -96},
{ 1120, 152, -88},
{ 1080, 152, -88},
{ 1208, 232, -168},
{ 1464, 264, -216},
{ 1200, 272, -144},
{ 880, 216, -96},
{ 912, 256, -136},
{ 1072, 288, -32},
// 35 seconds
{ 1256, 352, 24},
{ 1176, 464, -8},
{... | { 904, 192, -80},
{ 1232, 232, -96},
{ 1624, 392, -352},
{ 1408, 464, -344},
{ 1016, 240, -48},
{ 976, 144, -32},
{ 1152, 192, -48},
{ 1304, 272, -128},
{ 1176, 472, -192},
{ 1192, 528, -128},
{ 1368, 608, -64},
{ 1208, 768, 56},
{ 960, 528, -168},
{ 1264, 416, -6... | |
ta = false;
s_bus_contention_detected = false;
prv_unlock();
}
void accessory_enable_input(void) {
// NOTE: This function may be called from an ISR
if (s_input_enabled) {
return;
}
prv_lock();
if (s_sent_data) {
// wait for the TC flag to be set
uart_wait_for_tx_complete(ACCESSORY_UART);
... | (s_did_send_byte) | |
"system/logging.h"
#include "system/passert.h"
#include "system/reboot_reason.h"
#include "system/reset.h"
#include "util/math.h"
#include "util/net.h"
#include "util/string.h"
#define CMSIS_COMPATIBLE
#include <mcu.h>
#include <bluetooth/bt_test.h>
#include <bluetooth/responsiveness.h>
#include <bluetooth/gatt_disco... | if (length < MAX_READ_FLASH_SIZE){
read_length = length;
} |
flash_read_bytes(buffer, address, read_length);
// Output to serial
for (uint32_t i = 0; i < read_length; i++) {
dbgserial_putchar(buffer[i]);
}
address += read_length;
length -= read_length;
}
kernel_free(buffer);
}
void command_flash_switch_mode (const char* mode_str) {
int m... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERT_TASK(PebbleTask_Worker) | ;
}
static size_t prv_get_worker_segment_size(const PebbleProcessMd *app_md) {
// 12 KiB - 640 bytes workerlib static = 11648 bytes
return 11648;
}
static size_t prv_get_worker_stack_size(const PebbleProcessMd *app_md) {
return 1400;
}
// ------------------------------------------------------------------------... |
clude "utf8_test_data.h"
#include "clar.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
// Stubs
///////////////////////////////////////////////////////////
#include "stubs_logging.h"
#include "stubs_passert.h"
// Tests
///////////////////////////////////////////////////////////
... | {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)"\xf0", 5);
cl_assert_equal_i(copied, 0);
cl_assert_equal_s((char *)dest, "");
} |
void test_utf8__invalid_character(void) {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)"\xf0hi", 5);
cl_assert_equal_i(copied, 0);
cl_assert_equal_s((char *)dest, "");
}
void test_utf8__get_size_truncate(void) {
cl_assert_equal_i(0, utf8_get_size_truncate("", ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_DEBUG, "GET_BYTES: checking image %p", (void *)flash_base) | ;
if (flash_base != CORE_DUMP_FLASH_INVALID_ADDR) {
flash_read_bytes((uint8_t *)&image_hdr, flash_base + sizeof(CoreDumpFlashRegionHeader),
sizeof(image_hdr));
}
if (flash_base == CORE_DUMP_FLASH_INVALID_ADDR || image_hdr.magic != CORE_DUMP_MAGIC) {
return GET_BYTES_DOESNT_EXIST;
}
... |
ib/ui/app_window_stack.h"
#include "applib/ui/bitmap_layer.h"
#include "applib/ui/kino/kino_layer.h"
#include "applib/ui/kino/kino_reel.h"
#include "applib/ui/layer.h"
#include "applib/ui/text_layer.h"
#include "applib/ui/window.h"
#include "applib/ui/window_private.h"
#include "applib/ui/window_stack.h"
#include "proc... | (BUTTON_ID_DOWN, prv_raw_down_handler, prv_raw_up_handler, NULL) | ;
}
////////////////////////////////////////////////////////////
// Windows
static void prv_update_background_image_and_url_text(RecoveryFUAppData *data) {
uint32_t icon_res_id;
const char *url_string;
GColor background;
GRect kino_area;
int16_t icon_x_offset;
int16_t icon_y_offset;
int16_t text_y_offse... |
prv_config() | ->horizontal_margin / 2, 0);
}
static GRect prv_artist_rect(void) {
const MusicAppSizeConfig *config = prv_config();
return GRect(config->horizontal_margin, config->artist_field.origin_y,
prv_text_layer_width(), config->artist_field.size_h);
}
static GRect prv_title_rect(void) {
const MusicAppSiz... | |
d, cmd, command_len);
pulse_reliable_send(resp, response_len);
}
static int prv_get_fresh_fd(PulseBulkIODomainHandler *domain_handler, PulseTransferFD **fd) {
for (int i=0; i < MAX_PULSE_FDS; ++i) {
if (s_transfer_fds[i].impl == NULL) {
s_transfer_fds[i] = (PulseTransferFD) {
.impl = domain_handl... | if (cmd->read.length == 0) {
prv_respond_internal_error(cmd, length, E_INVALID_ARGUMENT);
return;
} |
PulseTransferFD *pulse_fd = prv_get_fd(cmd, length);
if (!pulse_fd) {
// prv_get_fd has already sent an error response
return;
}
pulse_fd->transfer_state.offset = cmd->read.address;
pulse_fd->transfer_state.bytes_left = cmd->read.length;
system_task_add_callback(prv_domain_read_cb, (void*)(uintp... |
/*
* 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... | kernel_free(state) | ;
}
#if UNITTEST
// Used by unit tests
T_STATIC TimerID prv_get_timer_id(void) {
return s_manager_state.update_enable_timer_id;
}
// Used by unit tests
T_STATIC uint32_t prv_num_system_task_events_queued(void) {
uint16_t avail_bytes = circular_buffer_get_read_space_remaining(
&s_manager_state.system_task_ev... |
/*
* 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(history_len <= ARRAY_LENGTH(s_sys_activity_get_metric_values.out.history)) | ;
s_sys_activity_get_metric_values.in.metric = metric;
s_sys_activity_get_metric_values.in.history_len = history_len;
// Check if this value is in our overrides. If it is return it and quit.
if (prv_handle_override(metric, history_len, history)) {
return true;
}
// yes, actual implementation can hand... |
de <stdbool.h>
#include <stdio.h>
// Note: Before adding a new header, be sure you actually need it! The goal
// is to keep the driver as unreliant on higher level constructs as possible
#ifdef BMI160_DEBUG
#include "console/dbgserial.h"
#define BMI160_DBG(msg, ...) \
do { ... | {
return BMI160_SCALE_16G;
} |
WTF;
return 0;
}
static void prv_set_accel_scale(Bmi160Scale scale) {
uint8_t cfg_val;
switch (scale) {
case BMI160_SCALE_2G:
cfg_val = BMI160_ACC_RANGE_2G;
break;
case BMI160_SCALE_4G:
cfg_val = BMI160_ACC_RANGE_4G;
break;
case BMI160_SCALE_8G:
cfg_val = BMI160_ACC_... |
_sent_data();
// No app_message callbacks are expected to be called, as we closed the context
cl_assert_equal_i(s_out_sent_call_count, 0);
cl_assert_equal_b(s_nack_sent_is_called, false);
cl_assert_equal_i(s_out_failed_call_count, 0);
cl_assert_equal_b(app_message_is_closed_outbound(), true);
}
void test_ap... | (&iterator) | |
rtisingJobRef job,
bool completed,
void *data) {
// bt_lock() is still held for us by gap_le_advert
s_reconnect_advert_job = NULL;
}
static bool prv_is_advertising_for_reconnection(void) {
return (s_reconnect_advert_j... | gap_le_connect_is_connected_as_slave() | ) {
// Already connected as slave...
goto unlock;
}
if (!bt_persistent_storage_has_active_ble_gateway_bonding() &&
!bt_persistent_storage_has_ble_ancs_bonding()) {
// No bonded master device that would want to reconnect, do nothing.
goto unlock;
}
prv_set_and_evaluate(&... |
Resetting now.");
analytics_inc(ANALYTICS_DEVICE_METRIC_HRM_WATCHDOG_TIMEOUT, AnalyticsClient_System);
prv_disable(dev);
psleep(SHUT_DOWN_DELAY_MS);
prv_enable(dev);
}
exit:
mutex_unlock(dev->state->lock);
}
// This regular timer callback executes once a second. It is part of the watchdog logic us... | (LOG_LEVEL_ERROR, "Failed to read FW image! "
"(segment header @ 0x%" PRIx32 ")", cursor) | ;
return false;
}
cursor += sizeof(segment_header);
// Write all the data bytes in the segment to the HRM.
uint16_t write_address = segment_header.address;
uint32_t bytes_remaining = segment_header.len_minus_1 + 1;
while (bytes_remaining) {
uint8_t chunk[MAX_HEX_DATA_BYTES];
co... |
et_text(&data->time_text_layer, data->time_buffer);
#endif
}
static void prv_update_info(SdkAppData *data) {
const AppInstallId app_id = shell_sdk_get_last_installed_app();
const char *text;
#if CAPABILITY_HAS_SDK_SHELL4
const unsigned int tip_delay_s = 5;
if ((app_id == INSTALL_ID_INVALID) || shell_sdk_last_i... | (info_text_layer, &frame) | ;
text_layer_set_font(info_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(info_text_layer, GTextAlignmentCenter);
text_layer_set_background_color(&data->info_text_layer, GColorClear);
layer_add_child(&window->layer, &info_text_layer->layer);
#if PBL_ROUND
#if CAPABIL... |
power mode)
static bool s_backlight_allowed = false;
//! Mutex to guard all the above state. We have a pattern of taking the lock in the public functions and assuming
//! it's already taken in the prv_ functions.
static PebbleMutex *s_mutex;
static void prv_change_state(BacklightState new_state);
static void light_... | new_timer_create() | |
360},
{ 1056, 608, -312},
{ 1304, 552, -280},
{ 1528, 488, -128},
{ 1312, 376, -40},
{ 1072, 384, -72},
{ 952, 360, -48},
{ 936, 328, -24},
{ 952, 304, 0},
{ 904, 240, -8},
// 29 seconds
{ 848, 200, -48},
{ 880, 104, -80},
{ 720, -256, -104},
{ 1072, -288, -272},
... | { 1040, 320, -232},
{ 720, 504, -328},
{ 608, 424, -224},
{ 632, 440, -136},
{ 768, 424, -96},
{ 920, 464, -80},
{ 1000, 528, -120},
{ 1048, 560, -208},
{ 976, 640, -288},
{ 1032, 600, -280},
{ 1248, 632, -288},
{ 1104, 712, -464},
{ 1192, 640, -400},
{ 1528, 504,... |
{ 848, 632, -456},
{ 928, 656, -424},
{ 912, 568, -336},
{ 1120, 576, -264},
{ 1288, 664, -384},
// 37 seconds
{ 1480, 584, -192},
{ 1480, 440, -80},
{ 1528, 464, -128},
{ 1392, 400, -72},
{ 1168, 328, -32},
{ 1016, 264, -64},
{ 880, 208, -104},
{ 824, 176, -160}... |
payload_length = length - sizeof(cmd->opcode) - sizeof(cmd->write);
int ret = pulse_fd->impl->write_proc(cmd->write.data, cmd->write.address, payload_length,
pulse_fd->domain_state);
if (FAILED(ret)) {
prv_respond_internal_error(cmd, length, ret);
return;
}
Write... | {
switch (cmd->opcode) {
case BULKIO_CMD_DOMAIN_OPEN:
prv_handle_open(cmd, length);
break;
case BULKIO_CMD_DOMAIN_CLOSE:
prv_handle_close(cmd, length);
break;
case BULKIO_CMD_DOMAIN_READ:
prv_handle_read(cmd, length);
break;
case BULKIO_CMD_DOM... | else {
prv_respond_malformed_command(cmd, length, "Empty command");
}
kernel_free(data);
}
void pulse2_bulkio_packet_handler(void *packet, size_t length) {
BulkIOPacketCallbackData *data = kernel_malloc_check(length + sizeof(length));
data->length = length;
memcpy(&data->packet, packet, length);
syst... |
operty = (data->property + 1) % PROPERTY_MAX;
layer_mark_dirty(s_canvas_layer);
}
static void down_handler(ClickRecognizerRef recognizer, void *context) {
AppData *data = window_get_user_data(s_window);
if (data->property == PROPERTY_FG_COLOR) {
data->fg_color_index = (data->fg_color_index - 1) & 0x3F;
d... | text_layer_get_layer(data->alpha_text) | );
// Other properties
s_color_table = color_table_hsv;
data->alpha = ALPHA_100;
data->fg_color.argb = s_color_table[data->fg_color_index] | ALPHA_100;
data->bg_color = GColorBlack;
set_text_layers(data);
}
static void main_window_unload(Window *window) {
// Destroy Layer
layer_destroy(s_canvas_layer)... |
info->has_history = true;
info->converter = prv_convert_minutes_to_seconds;
break;
case ActivityMetricSleepState:
info->value_p = &state->sleep_data.cur_state;
info->settings_key = ActivitySettingsKeySleepState;
break;
case ActivityMetricSleepStateSeconds:
info->value_p = &s... | (file, &m_info.settings_key, sizeof(m_info.settings_key),
&history, sizeof(history)) | ;
}
activity_private_settings_close(file);
}
if (current_value_updated) {
if (metric == ActivityMetricStepCount) {
PebbleEvent e = {
.type = PEBBLE_HEALTH_SERVICE_EVENT,
.health_event = {
.type = HealthEventMovementUpdate,
.data.movement_update = {
... |
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 "clar.h"
#include "applib/app_message/app_message_internal.h"
#include "kernel/events.h"
#include "system... | if (b_tuple) {
cl_fail("Dictionary `B` contained more tuples than dictionary `A`.");
} else if (a_tuple) {
cl_fail("Dictionary `A` contained more tuples than dictionary `B`.");
} |
}
// Callbacks
////////////////////////////////////
static void prv_out_sent_callback(DictionaryIterator *sent, void *context) {
s_out_sent_call_count++;
cl_assert_equal_p(context, &s_context);
prv_assert_dict_equal(sent, &s_expected_iter);
// When the outbox sent callback is called, the outbox should be in... |
= validate_args(&actual_args, &s_last_args_for_mock); \
cl_assert(cmp_result); \
} while(0)
static void setup_test(GContext* ctx, bool antialiased, uint8_t stroke_width, GColor stroke_color,
GColor fill_color, bool lock) {
graphics_context_set_antialiased(ctx, antialiased);
graphics_c... | (&context, color) | ;
cl_assert_equal_i(context.draw_state.text_color.argb, GColorClear.argb);
color.a = 0;
graphics_context_set_text_color(&context, color);
cl_assert_equal_i(context.draw_state.text_color.argb, GColorClear.argb);
// Text Color - 2-bit
graphics_context_set_text_color_2bit(&context, GColor2White);
cl_assert... |
set(slave->bus);
mutex_unlock(slave->bus->state->bus_mutex);
return recovered;
}
/*--------------------DATA TRANSFER FUNCTIONS--------------------------*/
//! Wait a short amount of time for busy bit to clear
static bool prv_wait_for_not_busy(I2CBus *bus) {
static const int WAIT_DELAY = 10; // milliseconds
... | (LOG_LEVEL_ERROR, "I2C Error: too many NACKs received on bus %s", bus->name) | ;
break;
}
} else {
// Timeout, abort transfer
i2c_hal_abort_transfer(bus);
complete = true;
PBL_LOG(LOG_LEVEL_ERROR, "Transfer timed out on bus %s", bus->name);
break;
}
} while (!complete);
// Return semaphore token so another transfer can be started
prv_sem... |
//! We have our own flash driver for coredump support because it must not use
//! any FreeRTOS constructs & we want to keep it as simple as possible. In
//! addition we want the flexibility to be able to reset the flash driver to
//! get it into a working state
static void prv_flash_start_cmd(void) {
GPIO_ResetBit... | prv_flash_wait_for_write() | ;
prv_flash_start_cmd();
prv_flash_send_and_receive_byte(FLASH_CMD_READ);
prv_flash_send_24b_address(start_addr);
while (buffer_size--) {
*buffer = prv_flash_read_next_byte();
buffer++;
}
prv_flash_end_cmd();
}
uint32_t cd_flash_write_bytes(const void* buffer_ptr, uint32_t start_addr, uint32_t buf... |
ial_pattern(true /*display_logs*/, false /*skip_base_addr*/,
NULL /*erase_addr*/);
VERIFY_TEST_STATUS(status);
// offset of 0
test_addr = base_addr + test_offset;
// Read initial value
read_buffer = 0;
flash_read_bytes((uint8_t*) &read_buffer, test_addr, sizeof(read_buffer... | PBL_LOG(LOG_LEVEL_DEBUG, ">START - ADDR TEST 2: Check for address bits stuck at low or shorted") | |
PM
{ 0, 0x33, 393, 0x0},
{ 0, 0x33, 333, 0x0},
{ 0, 0x33, 335, 0x0},
{ 0, 0x34, 222, 0x0},
{ 0, 0x45, 50, 0x0},
{ 19, 0x44, 8467, 0x0},
{ 54, 0x47, 5363, 0x0},
{ 63, 0x47, 4327, 0x0},
{ 0, 0x35, 3766, 0x0},
{ 0, 0x45, 1173, 0x0},
{ 12, 0x43, 1934, 0x0},
{ 0, 0x43, 1010, ... | { 0, 0x33, 22, 0x0},
{ 0, 0x33, 10, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 0, 0x0},
// 630: Local time: 01:12:00 AM
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 11, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x34, 562, 0x0},
{ 0, 0x45, ... |
{ 0, 0x5f, 902, 0x0},
{ 0, 0x5f, 230, 0x0},
{ 0, 0x5f, 217, 0x0},
{ 0, 0x5f, 187, 0x0},
{ 0, 0x5f, 498, 0x0},
{ 0, 0x5f, 473, 0x0},
{ 0, 0x5f, 318, 0x0},
{ 0, 0x5f, 241, 0x0},
{ 0, 0x5f, 140, 0x0},
// 690: Local time: 02:13:00 AM
{ 0, 0x5f, 575, 0x0},
{ 0, 0x54, 4324, 0x... |
/*
* 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... | {
*address_out = s_last_bt_persist_pinned_addr;
} |
return true;
}
bool bt_persistent_storage_set_ble_pinned_address(const BTDeviceAddress *addr) {
if (addr) {
s_last_bt_persist_pinned_addr_is_null = false;
s_last_bt_persist_pinned_addr = *addr;
} else {
s_last_bt_persist_pinned_addr_is_null = true;
memset(&s_last_bt_persist_pinned_addr, 0x00, si... |
) data;
EventedTimerCallback timer_cb;
void* timer_cb_data;
// Get the user supplied callback pointer and data, remove the timer from our list, and delete it.
sys_evented_timer_consume(timer_id, &timer_cb, &timer_cb_data);
if (!timer_cb) {
// We've already cancelled this timer, just abort.
return;
... | (s_timer_list_head, &new_timer->list_node) | ;
uint32_t flags = repeating ? TIMER_START_FLAG_REPEATING : 0;
bool success = new_timer_start(new_timer->sys_timer_id, timeout_ms, prv_sys_timer_callback,
(void*)(intptr_t)new_timer->sys_timer_id, flags);
PBL_ASSERTN(success);
mutex_unlock(s_mutex);
return new_timer->sys_tim... |
new version
ActivitySettingsKey key = ActivitySettingsKeyVersion;
const uint16_t version = ACTIVITY_SETTINGS_CURRENT_VERSION;
if (version != written_version) {
settings_file_set(file, &key, sizeof(key), &version, sizeof(version));
}
// Init the current day index
time_t utc_now = rtc_get_time();
s_ac... | if (sessions == NULL) {
return false;
} |
mutex_lock_recursive(s_activity_state.mutex);
{
uint32_t num_sessions_to_return = MIN(*session_entries,
s_activity_state.activity_sessions_count);
memcpy(sessions, s_activity_state.activity_sessions,
num_sessions_to_return * sizeof(ActivitySession));
... |
ealthServiceTimeRange r_a = (a); \
HealthServiceTimeRange r_b = (b); \
bool success = memcmp(&r_a, &r_b, sizeof(r_a)) == 0; \
if (!success) { \
char error_msg[256] = {0}; \
snprintf(error_msg, sizeof(error_msg), \
"HealthServiceInternalTimeRange equal\n" \
" a: {last_day_i... | 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, true);
cl_assert_equal_range(range, ((HealthServiceTimeRange){
.last_day_idx = 0,
.num_days = 1,
.seconds_first_day = 1... |
d_space);
}
static bool s_is_current_task_send_next_task = false;
bool comm_session_is_current_task_send_next_task(CommSession *session) {
return s_is_current_task_send_next_task;
}
// Tests
///////////////////////////////////////////////////////////
static const uint16_t ENDPOINT_ID = 1234;
static const uint32_t ... | comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
payload_length, TIMEOUT_MS) | ;
uint8_t fake_data[payload_length];
memset(fake_data, 0, payload_length);
comm_session_send_buffer_write(write_sb[i], fake_data, payload_length);
comm_session_send_buffer_end_write(write_sb[i]);
}
// Can't write another message:
cl_assert_equal_p(NULL, comm_session_send_buffer_begin_write(&s_ses... |
AccelRawData *samples, int num_samples,
TestMinuteData *exp_minutes, int exp_num_minutes) {
int minute_data_len = 100;
TestMinuteData minute_data[minute_data_len];
// Run the step algorithm
prv_feed_kalg_samples(samples, num_samples, minute_data, &minute_data_len);
for (int ... | {
result.weighted_err += prv_compute_test_error(
metrics[j], expected, actual, entry->weight, &result.all_passed);
} |
test_results[num_tests] = result;
num_tests++;
if (num_tests >= k_max_tests) {
printf("RAN INTO MAX NUMBER OF TESTS WE SUPPORT");
break;
}
}
// Make sure we discovered at least 1 test
cl_assert(num_tests > 0);
// Let's sort the tests by name
qsort(&test_entry[0], num_tests, siz... |
w;
KinoLayer kino_layer;
KinoReel *reel;
GBitmap *approve_bitmap;
GBitmap *decline_bitmap;
ActionBarLayer action_bar_layer;
Layer info_text_mask_layer;
PropertyAnimation *info_text_out_animation;
PropertyAnimation *info_text_in_animation;
// The info text layers store show the text that prompts the us... | {
prv_update_text_layer_with_translation(&data->info_text_layer2,
&translations[data->translated_str_idx]);
} |
data->num_strings_shown++;
}
static void prv_animate_info_text(BTPairingUIData *data) {
prv_update_prf_info_text_layers_text(data);
animation_schedule(property_animation_get_animation(data->info_text_in_animation));
animation_schedule(property_animation_get_animation(data->info_text_out_animation));
}
stat... |
adius);
cl_assert_gpoint_precise(center, 0, 5);
cl_assert_fixedS16_3(radius, 0);
// 1 pixel width means radius of 0
r = GRect(-1, -5, 1, 1);
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, -1, -5);
cl_assert_fixedS16_3(radius, 0);
// 2 pixel width means: center is... | (NULL, GRect(0, 0, 0, 0), GOvalScaleModeFillCircle) | ;
cl_assert_gpoint_precise(s_center, 0.0, 0.0);
cl_assert_fixedS16_3(s_radius_outer, 0.0);
cl_assert(s_radius_inner.integer <= 0);
cl_assert_equal_i(s_angle_start, 0);
cl_assert_equal_i(s_angle_end, TRIG_MAX_ANGLE);
}
void graphics_fill_radial_precise_internal(GContext *ctx, GPointPrecise center,
... |
ctx_space);
}
// translate the drawing_box to the bounds of the layer:
ctx->draw_state.drawing_box.origin.x +=
levels_layer->frame.origin.x + levels_layer->bounds.origin.x;
ctx->draw_state.drawing_box.origin.y +=
levels_layer->frame.origin.y + levels_layer->bounds.origin.y;
... | (child, window) | ;
child = child->next_sibling;
}
}
struct Window *layer_get_window(const Layer *layer) {
if (layer) {
return layer->window;
}
return NULL;
}
void layer_remove_from_parent(Layer *child) {
if (!child || child->parent == NULL) {
return;
}
if (child->parent->window) {
window_schedule_render(... |
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_health_activity_summary_card__render_current_above_typical5(void) {
HealthData health_data = {
.step_data = 970,
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,... |
ASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_NUM_PAGES (SPRF_REGION_SIZE / sizeof(SharedPRFData))
#define SPRF_PAGE_FLASH_OFFSET(idx) (FLASH_REGION_SHARED_PRF_STORAGE_BEGIN + \
(idx * sizeof(SharedPRFData)))
// Stubs
//////////////////////////////////////////////////////////
... | (page_idx[i]) | |
as_connection_intent(&device, GAPLEClientApp);
cl_assert_equal_b(registered, true);
}
void test_gap_le_connect__register_same_device_and_bonding(void) {
// Test that it is possible to have 2 intents for the same device, when registering one intent
// using the resolvable address and one with a bonding. Pebble wi... | (e, BTErrnoOK) | ;
// Device isn't connected. Verify no event was caused as a result of the
// registration.
prv_assert_no_event();
// Connect & verify the client task gets the event:
prv_fake_connect(&device, true /* is_master*/);
prv_assert_client_event(&device, true /* connected */, (1 << PebbleTask_App),
... |
/*
* 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_mutex = mutex_create();
mutex_lock(s_mutex);
SettingsFile file = {};
if (settings_file_open(&file, SHELL_PREFS_FILE_NAME, SHELL_PREFS_FILE_LEN) != S_SUCCESS) {
goto cleanup;
}
if (settings_file_get(&file, PREF_KEY_CLOCK_24H, sizeof(PREF_KEY_CLOCK_24H),
&s_is_24h_style, sizeof... | |
rupted
// so the critical section is necessary. taskENTER_CRITICAL() is not used here
// as that method would mask interrupts that should exit the low-power mode.
// The __disable_irq() function sets the PRIMASK bit which globally prevents
// interrupt execution while still allowing interrupts to wake the proce... | {
// This function is called by portSVCHandler with the PC value of the
// function which initiated the SVC call requesting privilege elevation.
// The memory_region.c functions are not used for this check as this function
// is in a hot code-path and needs to execute as quickly as possible.
// All syscall ... | |
/*
* 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... | task_heap_get_for_current_task() | , ptr, saved_lr);
}
void *task_realloc(void* ptr, size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_realloc(task_heap_get_for_current_task(), ptr, size, saved_lr);
}
void *task_zalloc(size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return h... |
aticAndScrollable) {
rect.origin.y = (&active_window->scrollable_metric_layer == layer) ?
PBL_IF_RECT_ELSE(-2, 0) : PBL_IF_RECT_ELSE(-4, -2);
}
// set the rect height so we don't wrap text to the next line
rect.size.h = 40;
#if PBL_ROUND
if (draw_hr_zones) {
// padding between text and zones i... | (BUTTON_ID_UP, prv_end_workout_up_click_handler) | ;
window_single_click_subscribe(BUTTON_ID_DOWN, prv_end_workout_down_click_handler);
}
static void prv_end_workout(void *context) {
WorkoutActiveWindow *active_window = context;
WorkoutDialog *workout_dialog = &active_window->end_workout_dialog;
workout_dialog_init(workout_dialog, "Workout End");
Dialog *d... |
/*
* 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... | (dialog, missed_message, true) | |
/*
* 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... | applib_malloc(size) | ;
if (result) {
memcpy(result, list, size);
}
return result;
}
void gdraw_command_list_destroy(GDrawCommandList *list) {
if (list) {
applib_free(list);
}
}
static GDrawCommand *prv_next_command(GDrawCommand *command) {
return (GDrawCommand *) (command->points + command->num_points);
}
bool gdraw... |
a starts with expected Rocky header
const size_t header_size = sizeof(ROCKY_EXPECTED_SNAPSHOT_HEADER);
cl_assert_equal_i(8, header_size);
// NOTE: the snapshot header in this unit test is fixed to
// CAPABILITY_JAVASCRIPT_BYTECODE_VERSION=1 only use the resulting binary
// if the true JS version m... | (jerry_value_is_string(global_date)) | ;
cl_assert(date_builtin != global_date);
jerry_release_value(global_date);
jerry_release_value(global_object);
jerry_release_value(date_builtin);
}
void test_js__capture_mem_stats_upon_exiting_event_loop(void) {
prv_deinit();
s_app_event_loop_callback = NULL;
const char *source = ";";
cl_assert_equa... |
animation_set_duration(anim, duration) | ;
animation_set_curve(anim, AnimationCurveEaseInOut);
animation_schedule(anim);
if (was_animating) {
// create visual state that's already reflecting the beginning of the "out" animation
prv_center_focus_animation_update_out_only(anim, 0);
}
}
static void prv_apply_selection_change(MenuLayer *menu_lay... | |
/*
* 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 (out_metadata == NULL) {
return false;
}
FirmwareDescription firmware_description = firmware_storage_read_firmware_description(flash_address);
if (!firmware_storage_check_valid_firmware_description(&firmware_description)) {
memset(out_metadata, 0, sizeof(FirmwareMetadata));
return false;
}
... |
bool version_copy_recovery_fw_metadata(FirmwareMetadata *out_metadata) {
return prv_version_copy_flash_fw_metadata(out_metadata, FLASH_REGION_SAFE_FIRMWARE_BEGIN);
}
bool version_copy_update_fw_metadata(FirmwareMetadata *out_metadata) {
return prv_version_copy_flash_fw_metadata(out_metadata, FLASH_REGION_FIRMWAR... |
graphics_private_raw_mask_set_value(ctx, mask, p, new_pixel_value);
}
}
static void prv_blend_color_and_update_mask(GContext *ctx, int16_t y, int16_t min_x, int16_t max_x,
GColor color, uint8_t factor) {
color.a = (GColor8Component)(factor * 3 / (FIXED_S16_3_ONE.ra... | gbitmap_get_data_row_info(framebuffer, (uint16_t)y) | |
pawn != NULL);
animation_set_play_count(spawn, play_count_spawn);
// Check the duration
cl_assert_equal_i(animation_get_duration(spawn, true, true), play_count_spawn * duration_a);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(spawn);
// Start A
prv_advance_to_... | (prv_count_handler_entries(&s_stopped_handler_calls, a), 0) | |
prv_progress_window_finished(ProgressWindow *window, bool success, void *context) {
AppFetchUIData *data = context;
if (success) {
prv_app_fetch_launch_app(data);
}
}
////////////////////////////
// Internal Helper Functions
////////////////////////////
//! Used to clean up the application's data before exi... | progress_window_set_callbacks(&data->window, (ProgressWindowCallbacks) {
.finished = prv_progress_window_finished,
}, data) | ;
window_set_click_config_provider((Window *)&data->window, config_provider);
// retrieve data about the AppInstallId given
if (!app_install_get_entry_for_install_id(data->next_app_args.app_id, &data->install_entry)) {
PBL_LOG(LOG_LEVEL_ERROR, "App Fetch: Error getting entry for id: %"PRIu32"",
data-... |
#define SELFTEST_SIGN_POSITIVE (0x1 << 2)
#define SELFTEST_SIGN_NEGATIVE (0x0)
// The BMA255 is capable of storing up to 32 frames.
// Conceptually each frame consists of three 16-bit words corresponding to the x, y and z- axis.
#define BMA255_FIFO_MAX_FRAMES (32)
#define BMA255_FIFO_FRAME_SIZE_BYTES (3 * 2)
... | (BMA255Register_PMU_RANGE, value) | |
/*
* 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... | ("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(3, s_tick_timer_service_subscribe.call_count);
cl_assert_equal_i(MINUTE_... |
.h += abs_content_offset;
state.menu_layer->inverter.layer.bounds.size = state.menu_layer->inverter.layer.frame.size;
// when scrolling up, bounce back at the top (otherwise at the bottom)
if (!state.up) {
state.menu_layer->inverter.layer.frame.origin.y -= abs_content_offset;
}
}
layer_mark_d... | {
// only show second half of animation if uses presses repetitive
// as it's only the bounce back, then
duration /= 2;
animation_set_delay(anim, duration);
} |
animation_set_duration(anim, duration);
animation_set_curve(anim, AnimationCurveEaseInOut);
animation_schedule(anim);
if (was_animating) {
// create visual state that's already reflecting the beginning of the "out" animation
prv_center_focus_animation_update_out_only(anim, 0);
}
}
static void prv_a... |
et_fifo_frame_size(); // x,y,z accel data
uint16_t max_num_samples = (BMI160_FIFO_LEN_BYTES / fifo_frame_size);
max_num_samples = (max_num_samples / BMI160_FIFO_WM_UNIT_BYTES) *
BMI160_FIFO_WM_UNIT_BYTES;
if (num_samples > max_num_samples) {
num_samples = max_num_samples;
}
uint16_t curr_sample_si... | (BMI160_REG_INT_TAP_0, tap_0_cfg) | ;
// get the current scale
Bmi160Scale scale = prv_get_accel_scale();
// TODO: 4 or 5 bit granularity? - data sheet ambiguous, assume 5
uint32_t threshold = BOARD_CONFIG_ACCEL.accel_config.double_tap_threshold;
const uint32_t STEP = 625; // 62.5 mg step at 2g range
// calculate setting for 2g, then ... |
et);
r[1]->state = RecognizerState_Failed;
recognizer_manager_handle_state_change(&manager, r[1]);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_p(manager.active_layer, NULL);
prv_compare_recognizers_processed((int []) { 0, 1 }, 2, &s_recognizers_reset);
manage... | prv_compare_recognizers_processed(NULL, 0, &s_recognizers_reset) | ;
cl_assert_equal_i(r[0]->state, RecognizerState_Started);
cl_assert_equal_i(r[1]->state, RecognizerState_Completed);
}
|
{ 1072, 192, -320},
{ 1104, 312, -248},
{ 1192, 504, -360},
{ 1304, 600, -328},
{ 1216, 856, -408},
{ 1040, 1024, -424},
{ 832, 680, -264},
{ 992, 1048, -312},
{ 1168, 784, -128},
{ 1320, 688, -88},
{ 1344, 560, -144},
{ 1168, 416, -120},
{ 1032, 328, -120},
{ 1136, 2... | { 1120, 704, 136},
{ 1296, 584, 8},
{ 1016, 432, -56},
{ 952, 400, -136},
// 18 seconds
{ 1144, 272, -80},
{ 1248, 208, -72},
{ 1248, 152, -176},
{ 1296, 168, -72},
{ 1256, 208, -72},
{ 992, 184, -176},
{ 976, 24, -200},
{ 792, -224, 8},
{ 720, -40, -464},
{ 7... |
{ 1288, 264, -376},
{ 1184, 344, -344},
{ 1120, 456, -240},
{ 1184, 520, -280},
{ 1216, 592, -176},
{ 1168, 552, -128},
{ 1144, 656, -160},
{ 1072, 888, -80},
{ 960, 736, 0},
{ 856, 976, -96},
{ 1048, 768, -8},
{ 1168, 616, -24},
// 21 seconds
{ 1208, 480, -144},... |
/*
* 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_INFO,
"Read %d (expected %d) bytes of file %s (size %d), around offset %d.",
actual_read_size, read_size, iter->file_name, file_size, pos) | ;
return contents;
}
static NORETURN fatal_logic_error(SettingsRawIter *iter) {
PBL_LOG(LOG_LEVEL_ERROR,
"settings_raw_iter logic error. "
"Attempting to read affected file into RAM for easier debugging...");
uint8_t *contents = read_file_into_ram(iter);
PBL_LOG(LOG_LEVEL_INFO, "Removing af... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.