prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* 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... | (&BOARD_CONFIG_POWER.pmic_int_gpio, GPIO_PuPd_UP) | ;
periph_config_release_lock();
return true;
}
//! Interrupt masks for InterruptStatus1 and InterruptMask1 registers
enum PmicInt1 {
PmicInt1_Trickle = (1 << 0), //!< Trickle charge
PmicInt1_NoBat = (1 << 1), //!< Battery detached
PmicInt1_Resume = (1 << 2), //!< Resuming charge on drop after full
Pmic... |
tributeId being uint16_t as the protocol defines it as such.
_Static_assert(sizeof(SmartstrapServiceId) == sizeof(uint16_t),
"SmartstrapServiceId MUST be two bytes in length!");
_Static_assert(sizeof(SmartstrapAttributeId) == sizeof(uint16_t),
"SmartstrapAttributeId MUST be two bytes in le... | prv_set_attribute_state(attr, SmartstrapAttributeStateWritePending) | ;
return true;
} else if ((txn == AttributeTransactionEndWrite) &&
(attr->state == SmartstrapAttributeStateWritePending)) {
prv_set_attribute_state(attr, SmartstrapAttributeStateRequestPending);
return true;
}
return false;
}
//! Note; This should only be called from the consumer task
st... |
nclude "stubs_event_service_client.h"
#include "stubs_layer.h"
#include "stubs_logging.h"
#include "stubs_memory_layout.h"
#include "stubs_modal_manager.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_process_info.h"
#include "stubs_pebble_tasks.h"
#include "s... | (&attr_list, AttributeIdDisplayTime, config->weather_time_type) | |
t.end);
heap_init(worker_heap, worker_segment.start, worker_segment.end,
/* enable_heap_fuzzing */ false);
heap_set_lock_impl(worker_heap, (HeapLockImpl) {
.lock_function = prv_heap_lock,
});
process_heap_set_exception_handlers(worker_heap, app_md);
// Init services required for this proces... | prv_reset_last_worker_crashed_data() | ;
worker_manager_launch_next_worker(closing_worker_install_id);
return;
}
// We arrive here if the worker crashed...
// If the worker's app is in the foreground, close it
if (closing_worker_install_id == app_manager_get_current_app_id()) {
app_manager_force_quit_to_launcher();
} else {
const... |
draw_text_single_line_ellipsis_clip_outside_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_outside_y);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside... | test_graphics_context_init(&ctx, fb) | |
/*
* 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... | {
init();
app_event_loop();
deinit();
} | |
e_create(a, b, NULL);
cl_assert(seq != NULL);
animation_set_play_count(seq, play_count_seq);
// Check the duration
cl_assert_equal_i(animation_get_duration(seq, true, true), play_count_seq * duration_a);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
// St... | (start_ms + duration_a - 1) | |
/console_internal.h"
#include "console/dbgserial.h"
#include "console/pulse_internal.h"
#include "console/pulse_llc.h"
#include "console/pulse_protocol_impl.h"
#include "kernel/pbl_malloc.h"
#include "os/mutex.h"
#include "services/common/new_timer/new_timer.h"
#include "services/common/system_task.h"
#include "system/... | mutex_destroy(s_tx_buffer_mutex) | ;
dbgserial_restore_baud_rate();
serial_console_set_state(SERIAL_CONSOLE_STATE_LOGGING);
}
void pulse_prepare_to_crash(void) {
}
static void prv_process_received_frame(void *frame_ptr) {
IncomingPulseFrame *frame = frame_ptr;
uint32_t fcs;
// Comply with strict aliasing rules. The memcpy is optimized away.... |
prv_event_put(queue, "from app", saved_lr, event) | ;
}
bool event_try_put_from_process(PebbleTask task, PebbleEvent* event) {
QueueHandle_t queue = event_get_to_kernel_queue(task);
return prv_try_event_put(queue, event);
}
bool event_take_timeout(PebbleEvent* event, int timeout_ms) {
PBL_ASSERTN(s_system_event_queue_set);
s_current_event = 0;
// We must p... | |
l/math.h"
#define INTFMT_PADSPACE (0)
#define INTFMT_PADZERO (1)
// Used for wrong specifiers that want Monday as first day of the week.
static int prv_week_of_year(const struct tm *t, bool monday_is_first_day) {
int wday = t->tm_wday; // Week day in range 0-6 (Sun-Sat)
if (monday_is_first_day) {
wday = (wda... | if (*fmt == 'E' || *fmt == 'O') {
// We just drop them on the floor. Uh oh spaghetti-o
// Not like the old implementation really did them either.
fmt++;
} |
// Helper macros to make goto stuff look cleaner
#define FMT_STRCOPY(V) do { \
i18nstr = NULL; \
cpystr = V; \
goto _fmt_strcopy; \
} while (0)
#define FMT_STRCOPY_I18N(V) do { \
i18nstr = V; \
goto _fmt_strcopy; \
} while (0)
#define FMT_INTCOPY(V, L, F) do { \
cpyint_val = V; \
cpyint_len = L; \
cp... |
gpio_output_set(&BOARD_CONFIG_DISPLAY.cs, true);
// setup time > 3us
// this produces a setup time of ~7us
for (volatile int i = 0; i < 32; i++);
}
static void prv_disable_chip_select(void) {
// delay while last byte is emitted by the SPI peripheral (~7us)
for (volatile int i = 0; i < 48; i++);
gpio_outpu... | (s_dma_update_in_progress_semaphore, portMAX_DELAY) | ;
analytics_stopwatch_start(ANALYTICS_APP_METRIC_DISPLAY_WRITE_TIME, AnalyticsClient_App);
analytics_inc(ANALYTICS_DEVICE_METRIC_DISPLAY_UPDATES_PER_HOUR, AnalyticsClient_System);
prv_enable_display_spi_clock();
power_tracking_start(PowerSystemMcuDma1);
SPI_I2S_DMACmd(BOARD_CONFIG_DISPLAY.spi, SPI_I2S_DMAReq... |
ffaaffaa;
s_kernel_receiver_is_receiving = false;
s_kernel_receiver_finish_called = false;
s_kernel_receiver_cleanup_called = false;
s_kernel_receiver_buffer_idx = 0;
memset(s_kernel_receiver_buffer, 0, sizeof(s_kernel_receiver_buffer));
s_app_message_pp_received_length = 0;
memset(s_app_message_pp_buffer... | cl_assert_equal_m(&s_push, s_app_message_pp_buffer, sizeof(s_push)) | ;
cl_assert_equal_i(s_app_message_pp_received_length, sizeof(s_push));
cl_assert_equal_b(true, s_communication_timestamp_updated);
prv_destroy_inbox();
}
void test_app_message_receiver__receive_push_then_cleanup(void) {
Receiver *r = prv_create_inbox_prepare_and_write();
s_rcv_imp->cleanup(r);
cl_assert... |
assert_equal_i(s_num_alarm_events_put, 0);
// Trigger at the right time
prv_set_time(s_current_day, 10, 0);
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 6);
cl_assert_equal_i(s_num_timeline_removes, 3... | (s_num_alarms_fired, 1) | |
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_assigninverted-expect.8bit.pbi"));
memset(dest_data, GColorBlue.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpOr, GColorWhite);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_o... | (&dest_bitmap, "test_bitblt__1bit_to_8bit_comptint_black_cross_white_corners-expect.8bit.pbi") | );
memset(dest_data, GColorBlack.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, (GPoint){0}, GCompOpTint, GColorBlack);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_comptint_black_cross_black_corners-expect.8bit.pbi"));
memset(dest_data, GColorBlack.argb, siz... |
, data->stroke_width,
(int)(data->rotation_angle * 360 / TRIG_MAX_ANGLE));
}
static void down_handler(ClickRecognizerRef recognizer, void *context) {
AppData *data = window_get_user_data(s_window);
switch (data->operation) {
case OP_ROTATE:
data->rotation_angle = (data->rotation_angle - STEP_R... | if (data->operation == OP_TEST3) {
int x1 = 50,
x2 = 100,
y1 = 40,
y2 = 120;
GPoint p0 = GPoint(x1, y1);
GPoint p1 = GPoint(x1, y2);
GPoint p2 = GPoint(x2, y2);
GPoint p3 = GPoint(x2, y1);
// graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(... |
if (data->operation == OP_TEST4 || data->operation == OP_TEST5) {
/*
GRect bounds = layer->bounds;
GPoint center = GPoint(bounds.size.w/2, bounds.size.h/2);
int radius = 40;
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, true);
graphics_... |
s.getter.uint32(subject);
property_animation->values.from.uint32 = from_value ? *((uint32_t *)from_value)
: implementation->accessors.getter.uint32(subject);
} else if (property_animation->animation.implementation->update
== (AnimationUpdat... | {
if (animation_private_using_legacy_2(NULL)) {
// We need to enable other applib modules like sroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
return (PropertyAnimation *)property_animation_legacy2_create(
(PropertyAnimationLegacy2Implementat... |
// -----------------------------------------------------------------------------------------
// Create a new property animation structure, copying just the property animation unique fields
PropertyAnimationPrivate *property_animation_private_clone(PropertyAnimationPrivate *from) {
PBL_ASSERTN(!animation_private_us... |
")));
// Even cols of different lengths
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_ODD, OFFSET_RECT_ODD, false, 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(0, 0), MAX_NUM_ROWS);
graphics_draw_vertical_line_dotted(&ctx, GPoint(2, 0), MAX_NUM_ROWS + 4);
graphics_draw_vertical_line_dotted(&ctx, GPoint(4, 0)... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(96, 16), 10) | |
e assert_result_ok(result) cl_assert(result == SmartstrapResultOk)
#define assert_result_invalid(result) cl_assert(result == SmartstrapResultInvalidArgs)
#define assert_result_busy(result) cl_assert(result == SmartstrapResultBusy)
typedef void (*EventServiceEventHandler)(PebbleEvent *e, void *context);
typedef struct ... | (attr, NULL, NULL) | );
assert_result_invalid(app_smartstrap_attribute_begin_write(attr, &buffer, NULL));
assert_result_invalid(app_smartstrap_attribute_begin_write(attr, NULL, &buffer_len));
// smartstrap_attribute_end_write()
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 0, false));
assert_result_invalid(app_s... |
assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
// Feed in the test cadence for 2 minutes. Compute the expected distance in 2 minutes
// as well
... | fake_system_task_callbacks_invoke_pending() | ;
s_test_alg_state.orientation = 0x11; // Not flat
prv_advance_time_hr(ACTIVITY_DEFAULT_HR_PERIOD_SEC, 100 /*bpm*/, HRMQuality_Good, false /*force_continuous*/);
// Should be 1 second sampling when we start up
cl_assert_equal_i(s_hrm_manager_update_interval, 1);
// The last update time should be 0
int32_... |
_level(TimelineItemAction *action,
ActionMenuLevel *root_level) {
const char *label = attribute_get_string(&action->attr_list, AttributeIdTitle, "[Action]");
if (action->type == TimelineItemActionTypeResponse) {
ActionMenuLevel *responses_level = prv_create_respons... | analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_DISMISS_ALL_COUNT, AnalyticsClient_System) | ;
data->action_complete.callback = dismiss_all_complete_callback;
data->action_complete.callback_data = dismiss_all_cb_data;
// When performing a bulk request (dismiss all) errors are silently ignored because we want to
// show success if 1 or more actions were successful. If every result is an error the
//... |
/*
* 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... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25666_1
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ 96, 136, -960},
{ 152... |
{ 264, 760, -440},
{ 160, 736, -344},
{ 112, 744, -296},
{ 88, 824, -280},
{ 120, 872, -264},
{ 112, 880, -264},
{ 72, 864, -312},
{ 72, 1040, -216},
{ 80, 1008, -168},
{ 80, 1384, 184},
{ 320, 1416, 192},
{ 120, 1144, 200},
{ 88, 936, 272},
{ 88, 952, 360},
... |
.attr_list = postpone_attr_list,
},
{
.id = 2,
.type = TimelineItemActionTypeRemoteRemove,
.attr_list = remove_attr_list,
}
},
};
TimelineItem *item = timeline_item_create_with_attributes(data->timestamp,
... | (data->dialog_text, tmp, buf_space_remaining) | ;
buf_space_remaining = MAX(buf_space_remaining - strlen(tmp), 0);
clock_get_time_word(tmp, date_time_len, data->timestamp);
strncat(data->dialog_text, tmp, buf_space_remaining);
}
static void prv_handle_dictation_event(PebbleEvent *e, void *context) {
ReminderAppData *data = context;
const DictationSession... |
/*
* 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... | (DISP_GPIO, DISP_PIN_SCS, Bit_RESET) | ;
// hold time > 1us
// produce a delay 4ms
delay_us(4);
gpio_release(DISP_GPIO);
}
//! These functions needed to be called around any commands that
//! are sent to the display. NOINLINE only for code size savings.
static NOINLINE void prv_enable_display_access(void) {
prv_enable_display_spi_clock();
prv_e... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
key_ltk_t *ltk = kernel_zalloc_check(sizeof(key_ltk_t));
ltk->rand = enc_info->rand;
ltk->ediv = enc_info->ediv;
memcpy(ltk->key, enc_info->ltk.data, sizeof(ltk->key));
ltk->key_size = sizeof(ltk->key);
return ltk;
} | |
TN(flash_size == (uint32_t)1 << ceil_log_two(flash_size));
// Init QSPI peripheral
QSPI_InitTypeDef qspi_config;
QSPI_StructInit(&qspi_config);
qspi_config.QSPI_SShift = QSPI_SShift_HalfCycleShift;
// QSPI clock = AHB / (1 + QSPI_Prescaler)
qspi_config.QSPI_Prescaler = prescaler - 1;
qspi_config.QSPI_CKM... | {
QSPIPort *dev = context;
QSPI_DMACmd(DISABLE);
signed portBASE_TYPE was_higher_priority_task_woken = pdFALSE;
xSemaphoreGiveFromISR(dev->state->dma_semaphore, &was_higher_priority_task_woken);
return was_higher_priority_task_woken != pdFALSE;
} |
static void prv_config_indirect_read(QSPIPort *dev, uint8_t instruction, uint32_t addr,
uint8_t dummy_cycles, bool is_ddr) {
prv_set_ddr_enabled(is_ddr);
uint32_t modes_bitset = 0;
modes_bitset |= is_ddr ? QSPI_ComConfig_DDRMode_Enable : QSPI_ComConfig_DDRMode_Disable;
mo... |
, half_progress, ANIMATION_NORMALIZED_MAX) :
animation_timing_scaled(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 Anim... | prv_schedule_center_focus_animation(menu_layer, up, prev_selection, was_animating) | |
ENT);
rv = pfs_write(1000000, NULL, 0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(0, NULL, 0);
cl_assert(rv == E_INVALID_ARGUMENT);
uint8_t buf[10];
int fd = pfs_open("newfile", OP_FLAG_WRITE | OP_FLAG_READ,
FILE_TYPE_STATIC, sizeof(buf));
for (int i = 0; i < sizeof(buf); i++) {
buf... | (rv == E_INVALID_ARGUMENT) | ;
rv = pfs_close(1000000);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = pfs_open("file", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
rv = pfs_close(fd);
cl_assert(rv == S_SUCCESS);
rv = pfs_close(fd); // should not be able to double close an fd
cl_assert(rv == E_INVALID_ARGUMENT);
}
voi... |
s32 = 1 + (int16_t)c->s32;
s64 = 1 + (int16_t)c->s64;
d = 1 + (double)c->d;
JERRY_ARGS_MAKE(
jerry_create_number(c->u8),
jerry_create_number(c->u16),
jerry_create_number(c->u32),
jerry_create_number(c->u64),
jerry_create_number(c->s8),
jerry_create_number(... | {
bool output = !cases[i].expected_output;
jerry_value_t input = cases[i].input;
JERRY_ARGS_MAKE(input);
ROCKY_ARGS_ASSIGN(ROCKY_ARG(output));
cl_assert_equal_b(output, cases[i].expected_output);
ASSERT_JS_ERROR(error_value, NULL /* Never errors out! */);
jerry_release_value(input);
c... |
}
void test_rocky_api_util_args__string(void) {
struct {
jerry_value_t input;
char *expected_output;
} cases[] = {
{
.input = jerry_create_boolean(false),
.expected_output = "false",
},
{
.input = jerry_create_number(0.0),
.expected_output = "0",
},
{
.inp... |
+ next_corner_width;
memset(dst, GColorBlack.argb, bezel_length);
dst += bezel_length;
corner_width = next_corner_width;
}
// Set the remaining pixels to black.
const int bottom_bezel_length = (uintptr_t)&s_framebuffer.buffer[DISP_ROWS * DISP_COLS] -
(u... | compositor_render_app() | ;
prv_compositor_flush();
}
// Draw the modal if in the Modal state
if (s_state == CompositorState_Modal) {
compositor_render_modal();
prv_compositor_flush();
}
prv_release_app_framebuffer();
}
static void prv_send_app_render_request(void) {
PebbleEvent event = {
.type = PEBBLE_RENDER_REQ... |
/*
* 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... | (c->item_destructor == NULL) | ;
for (int i = 0; i < c->total_items; ++i) {
memcpy(c->cache + i * c->item_size, item, c->item_size);
}
}
void circular_cache_flush(CircularCache *c) {
// This assumes that the user of this library can differentiate empty entries in the cache from
// valid ones.
for (int i = 0; i < c->total_items; i++) {... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (volatile int delay = 0; delay < 50; delay++) { } |
while (!s_expected_bytes_received) { };
hw_gpio_set_inactive(HOST_SPI->mcu_int.port, HOST_SPI->mcu_int.pin);
}
static void prv_handle_hi_command(void) {
debug_print_str("HI CMD\n");
uint8_t response[] = { 'H', 'E', 'R', 'E' };
prv_write_or_read_bytes(response, sizeof(response), true);
}
static v... |
cl_assert_equal_i(s_capability_flags, s_expected_capabilities) | ;
}
void test_session_remote_version__app_session(void) {
s_session_is_system = false;
prv_receive_v3_response(3, 2, 1, s_expected_capabilities);
// Triggers no event:
cl_assert_equal_i(fake_event_get_count(), 0);
cl_assert_equal_i(s_capability_flags, s_expected_capabilities);
}
| |
bleHRMEvent) {
.event_type = HRMEvent_SubscriptionExpiring,
.expiring.session_ref = state->session_ref,
};
PBL_ASSERTN(prv_event_put(state, &hrm_event));
state->sent_expiration_event = true;
}
if (state->expire_utc && (utc_now >= state->expire_utc)) {
// This subscriptio... | list_insert_before(s_manager_state.subscribers, &state->list_node) | |
_b(gap_le_connect_has_pending_create_connection(), false);
}
void __disabled_test_gap_le_connect__disconnection_event_upon_cancel_connect(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent for app:
gap_le_connect_connect(&device,
false /* no auto_reconne... | prv_add_bonding_for_fake_resolvable_device() | ;
// Register connection intent for app:
gap_le_connect_connect_by_bonding(bonding_id,
true /* no auto_reconnect */,
true /* is_pairing_required */,
GAPLEClientApp);
prv_fake_connect(&device, false /* is_... |
or = ctx->draw_state.fill_color;
ctx->draw_state.fill_color = ctx->draw_state.stroke_color;
graphics_fill_rect(ctx, &GRect(rect->origin.x, rect->origin.y, rect->size.w, 1)); // top
graphics_fill_rect(ctx, &GRect(rect->origin.x, rect->origin.y + rect->size.h - 1,
rect->size.w, 1));... | GPoint(origin.x + radius, origin.y) | ;
const GPoint top_r = GPoint(origin.x + radius + width_actual - 1, origin.y);
const GPoint bottom_l = GPoint(origin.x + radius, origin.y + height - 1);
const GPoint bottom_r = GPoint(origin.x + radius + width_actual - 1, origin.y + height - 1);
const GPoint left_t = GPoint(origin.x, origin.y + radius);
con... |
ING);
}
}
static void prv_handlers_notify_state_changed(PulseLinkState link_state) {
for (unsigned int i = 0; i < ARRAY_LENGTH(s_supported_protocols); ++i) {
s_supported_protocols[i].link_state_handler(link_state);
}
}
void pulse_early_init(void) {
}
void pulse_init(void) {
s_tx_buffer_mutex = mutex_crea... | prv_reset_receive_buffer(s_current_receive_buffer) | ;
}
} else if (s_drop_rest_of_frame) {
// The frame has already been found to be bad and we haven't yet
// seen the start of the next frame.
} else if (UNLIKELY(s_current_receive_buffer->length >=
sizeof(s_current_receive_buffer->data))) {
// Frame too long; invalid.
s_drop_rest_of_... |
(animation_get_curve(a), AnimationCurveDefault) | ;
animation_set_custom_curve(a, curve);
cl_assert_equal_p(animation_get_custom_curve(a), curve);
cl_assert_equal_p(animation_get_custom_interpolation(a), NULL);
cl_assert_equal_i(animation_get_curve(a), AnimationCurveCustomFunction);
animation_set_custom_interpolation(a, interpolation);
cl_assert_equal_p(... | |
-------------------------------------------------------------
int pbl_log_binary_format(char* buffer, int buffer_len,
const uint8_t log_level,
const char* src_filename_path, int src_line_number,
const char* fmt, va_list args) {
PBL_ASSERTN... | pbl_log_hashed_vargs(true, core_number, packed_loghash, fmt_args) | ;
va_end(fmt_args);
}
// Core Number must be shifted to the correct position.
void pbl_log_hashed_vargs(const bool async, const uint32_t core_number,
const uint32_t packed_loghash, va_list fmt_args) {
LogState *state = prv_get_log_state();
if (!state) {
return;
}
unsigned num... |
lick_manager) {
return;
}
void click_manager_clear(ClickManager *click_manager) {
return;
}
void click_manager_reset(ClickManager *click_manager) {
return;
}
void watchface_reset_click_manager(void) {
return;
}
Animation *window_transition_default_pop_create_animation(WindowTransitioningContext *context) {
... | (new_window, &(WindowHandlers){
.load = prv_window_load,
.unload = prv_window_unload,
.appear = prv_window_appear
}) | ;
cl_check(stack);
cl_check(new_window);
window_stack_push(stack, new_window, true);
}
static void prv_pop_window_unload(Window *window) {
window_stack_remove(window, true);
prv_window_unload(window);
}
// Setup and Teardown
////////////////////////////////////
void test_window_stack__initialize(void) {
... |
atic uint8_t prev_button_state = 0;
prev_button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
while (1) {
// See if we should restart
uint8_t button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
if (button_state != prev_button_state) {
system_reset();
}
delay_ms(10);
}... | delay_us(200000) | ;
display_error_code(0xd15ea5e5);
delay_us(200000);
display_error_code(0xdeadbeef);
delay_us(200000);
}
#endif
flash_init();
if (is_button_stuck()) {
prv_sad_watch(ERROR_STUCK_BUTTON);
}
if (is_flash_broken()) {
prv_sad_watch(ERROR_BAD_SPI_FLASH);
}
boot_bit_dump();
// If th... |
essage (N)ACK has been received.
cl_assert_equal_b(app_message_is_accepting_outbound(), false);
prv_call_outbox_sent(AppOutboxStatusSuccess);
// After the ACK has been received, we should have been called
cl_assert_equal_b(s_ack_sent_is_called, true);
// Since that callback schedules another callback, we ha... | (APP_MSG_OK) | ;
// Make fake remote send any outstanding data (none expected)
prv_process_sent_data();
cl_assert_equal_i(s_out_sent_call_count, 0);
// failed_callback not called yet:
cl_assert_equal_i(s_out_failed_call_count, 0);
// Now process the scheduled callback event:
cl_assert(s_process_manager_callback);
s... |
ompliance 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 WARRANTIES OR CONDITIONS OF ANY KIND, eith... | {
s_spi_transport.watchdog_timer_active = false;
// Enable the timer clock
periph_config_enable(BOARD_BT_WATCHDOG_TIMER.timer.peripheral,
BOARD_BT_WATCHDOG_TIMER.timer.config_clock);
// Setup timer 3 to generate Bluetooth Host Transport priority interrupts
NVIC_InitTypeDef NVIC_InitSt... | |
/*
* 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... | phone_format_caller_name("Pankajavalli Balamarugan", dest, buffer_length) | |
__black(void) {
cl_assert(GColorBlack.r == 0b00);
cl_assert(GColorBlack.g == 0b00);
cl_assert(GColorBlack.b == 0b00);
cl_assert(GColorBlack.a == 0b11);
}
void test_graphics_colors__white(void) {
cl_assert(GColorWhite.r == 0b11);
cl_assert(GColorWhite.g == 0b11);
cl_assert(GColorWhite.b == 0b11);
cl_ass... | cl_assert_equal_i(GColorDarkGrayARGB8, gcolor_get_grayscale(GColorDarkGray).argb) | ;
cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_grayscale(GColorYellow).argb);
cl_assert_equal_i(GColorBlackARGB8, gcolor_get_grayscale(GColorBlue).argb);
cl_assert_equal_i(GColorLightGrayARGB8, gcolor_get_grayscale(GColorTiffanyBlue).argb);
cl_assert_equal_i(GColorDarkGrayARGB8, gcolor_get_grayscale(GColorOra... |
&state, &head, TimelineIterDirectionPast,
1421183640), 0);
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[0].header.id));
// check all day events
cl_assert(iter_next(&iterator));
Uuid first_all_day... | (&state.pin.header.id, &s_extra_case_items[2].header.id) | );
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[1].header.id));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[0].header.id));
cl_assert(!iter_next(&iterator));
}
// 11 am
void test_timeline__extra_case_non... |
es to arrive at a given
// frequency. It feeds samples at the right rate into the s_latest_reading
// global (for peek mode) and into the accel driver.
static void prv_timer_cb(void *data) {
mutex_lock(s_accel_mutex);
if (s_current_rcv_sample < s_num_rcv_samples) {
s_latest_reading = s_rcv_buffer[s_current_rcv... | {
prv_stop_timer();
} |
}
mutex_unlock(s_accel_mutex);
}
int accel_peek(AccelDriverSample *data) {
prv_construct_driver_sample(data);
return 0;
}
void accel_enable_shake_detection(bool on) {
}
bool accel_get_shake_detection_enabled(void) {
return false;
}
void accel_enable_double_tap_detection(bool on) {
}
bool accel_get_... |
96, 872, 64},
{ -312, 832, 64},
{ -336, 824, 88},
// 65 seconds
{ -336, 872, 80},
{ -328, 872, 112},
{ -288, 880, 112},
{ -264, 872, 104},
{ -248, 896, 112},
{ -272, 920, 72},
{ -264, 888, 104},
{ -272, 1000, 88},
{ -272, 1040, 72},
{ -280, 1080, 128},
{ -280, 118... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25655_3
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ 88, -200, -936},
{ 11... |
{ 232, 120, -920},
{ 216, 152, -912},
{ 224, 120, -928},
{ 216, 120, -936},
{ 208, 112, -912},
{ 200, 168, -928},
{ 208, 56, -832},
{ 152, 144, -864},
{ 176, 128, -832},
{ 176, 200, -768},
{ 152, 344, -760},
{ 192, 656, -736},
{ 208, 672, -736},
{ 208, 816, -688}... |
ailingEllipsis;
text_node.alignment = GTextAlignmentCenter;
s_data.text_node = &text_node.node;
s_data.max_used_size = TEST_TEXT_SIZE;
GSize size;
graphics_text_node_draw(&text_node.node, ctx, &TEST_TEXT_BOX, NULL, &size);
cl_assert(size.w > 0);
cl_assert(size.h > 0);
cl_assert_equal_i(size.w, TEST_TE... | graphics_text_node_container_add_child(&horizontal_a->container, &text_a->node) | |
----------------------------------------------------------------------------
// Test unschedule all when we have multiple animations, some complex
void test_animation__unschedule_all(void) {
#ifdef TEST_INCLUDE_COMPLEX
// Create animations
// Create a sequence
Animation *a = prv_create_test_animation();
Anima... | cl_assert_equal_i(animation_get_play_count(h), 2) | ;
cl_assert(animation_get_duration(h, true, true) == 2*(duration + delay));
// Curve
cl_assert(animation_get_curve(h) == AnimationCurveDefault);
animation_set_curve(h, AnimationCurveEaseOut);
cl_assert(animation_get_curve(h) == AnimationCurveEaseOut);
static const PropertyAnimationImplementation impleme... |
data->install_entry.install_id) &&
app_install_entry_is_watchface(&data->install_entry)) {
// We failed to fetch a watchface and it was our default.
// Invalidate it and it will be reassigned to one that exists next time around.
PBL_LOG(LOG_LEVEL_WARNING, "Default watchface fetch failed, setting INVAL... | app_progress_window_push(&data->window) | ;
}
static void handle_deinit(void) {
AppFetchUIData* data = app_state_get_user_data();
prv_app_fetch_cleanup(data);
progress_window_deinit(&data->window);
app_free(data);
i18n_free_all(data);
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd *ap... |
vector table, it's 128 bytes
#define IVT_TABLE_SIZE (0x40 + 32 * 4 + 0x80)
static uint8_t s_vector_table[IVT_TABLE_SIZE];
static volatile bool s_expected_bytes_received = false;
static void prv_expect_byte_spi_int_cb(void *user_data, uint16_t transferred) {
s_expected_bytes_received = true;
debug_print_str_and_in... | ("Unknown CMD:") | ;
debug_print_str_and_int(" Byte 0:", cmd[0]);
debug_print_str_and_int(" Byte 1:", cmd[1]);
}
}
}
static void prv_configure_pins_for_spi_transfer(void) {
hw_gpio_set_pin_function(HOST_SPI->spi.cs.port, HOST_SPI->spi.cs.pin,
HW_GPIO_MODE_INPUT, HOST_SPI->spi.cs.function);
... |
(180, 180) | , GBitmapFormat8BitCircular);
cl_assert(bitmap);
// Since frame 1 has 0 delay, it renders then immediately we render frame 2
gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 0);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)));
// Frame 2 has delay 1000 ms, so at time 1000 ms, we expect f... | |
40},
{ 856, 400, -24},
{ 888, 408, -64},
{ 888, 312, 0},
{ 1136, 240, 32},
{ 1224, 216, 120},
{ 1824, 232, 168},
{ 1656, 368, 128},
{ 1096, 256, 120},
{ 1272, 72, 104},
{ 1432, -264, 232},
{ 1152, 40, 256},
{ 968, 32, 192},
{ 832, 8, 136},
{ 680, -40, 168},
{ ... | { 1672, 424, 8},
{ 992, 264, 112},
{ 1048, 120, 104},
{ 1208, 128, 104},
{ 1168, 128, 136},
{ 1008, 88, 152},
{ 912, 72, 120},
{ 872, 0, 192},
{ 872, 0, 176},
{ 832, -32, 144},
{ 768, -32, 64},
{ 816, -16, -16},
{ 960, 80, -112},
{ 1320, -72, -72},
{ 1480, -24... |
{ 1632, 0, 240},
{ 1472, 368, 0},
// 55 seconds
{ 1576, 472, -112},
{ 1384, 352, 232},
{ 1120, 176, 320},
{ 1104, 216, 232},
{ 1048, 264, 200},
{ 944, 376, 80},
{ 848, 432, -16},
{ 840, 496, -48},
{ 880, 472, -8},
{ 1128, 472, 16},
{ 1320, 400, 128},
{ 1816, ... |
96, -248},
{ -608, -272, -280},
{ -656, -272, -304},
{ -752, -232, -312},
{ -736, -232, -184},
{ -808, -120, -232},
{ -848, 120, -8},
// 460 seconds
{ -1056, 512, 296},
{ -1416, 360, 520},
{ -912, 192, 160},
{ -1096, 504, 576},
{ -1104, 336, 496},
{ -928, 320, 256},
... | { -864, 544, 520},
{ -904, 552, 392},
{ -768, 496, 360},
{ -688, 384, 432},
{ -672, 424, 464},
{ -704, 416, 488},
{ -728, 384, 496},
{ -776, 424, 480},
{ -776, 424, 464},
{ -776, 432, 472},
{ -744, 432, 456},
{ -736, 416, 440},
{ -728, 416, 408},
{ -736, 416, 416}... |
// 468 seconds
{ -752, 600, 296},
{ -736, 608, 256},
{ -744, 616, 240},
{ -712, 608, 256},
{ -696, 584, 280},
{ -696, 616, 296},
{ -672, 640, 280},
{ -672, 728, 200},
{ -696, 760, 128},
{ -696, 744, 88},
{ -736, 768, 136},
{ -704, 680, 56},
{ -632, 832, -56},
... |
/*
* 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 = (crc >> 4) ^ s_lookup_table[(crc ^ *bytes) & 0xf];
crc = (crc >> 4) ^ s_lookup_table[(crc ^ (*bytes >> 4)) & 0xf];
bytes++;
} |
crc ^= 0xffffffff;
return crc;
}
|
read matches what we expect
// anyway
if (!errors.framing_error) {
PBL_LOG(LOG_LEVEL_WARNING, "UART ERROR: 0x%x 0x%d", (int)errors.error_mask, (int)dr);
return false;
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Dialog bootrom framing error, continuing onward");
}
}
if (u... | (LOG_LEVEL_ERROR, "Error waiting for chip ID / start message (i=%"PRIu32")", i) | ;
success = false;
goto cleanup;
}
if (c == 0x02) {
// Got start message!
break;
} else if (c == 'D') { // First valid character we expect to receive for AE silicon
wait_time_ms = DIALOG_BOOTROM_DEFAULT_CHAR_TIMEOUT_MS;
}
}
if (c != 0x02) {
PBL_LOG(LOG_LEVEL_ERROR,... |
* 64 * 1024);
cl_assert_equal_i(s_command_list_index, 1);
cl_assert_equal_i(s_command_list[0].addr, 64 * 1024);
cl_assert_equal_i(s_command_list[0].type, SectorEraseCommand);
s_command_list_index = 0;
// Erase one sectors 0x10000 - 0x20000 but allow us to erase more
flash_region_erase_optimal_range(0, 64... | cl_assert_equal_i(s_command_list[3].addr, 44 * 1024) | ;
cl_assert_equal_i(s_command_list[3].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[4].addr, 48 * 1024);
cl_assert_equal_i(s_command_list[4].type, SubsectorEraseCommand);
s_command_list_index = 0;
// App that's in an unaligned bank but larger than than 64k
flash_region_erase_optimal_rang... |
,CORE_NAME=Tintin";
// Confirm the size calculations. If these fail, update tools/loghashing/check_elf_log_strings.py
// We can't currently handle 64 bit values.
_Static_assert(sizeof(long int) <= 4, "long int larger than expected");
_Static_assert(sizeof(size_t) <= 4, "size_t larger than expected");
_Static_asser... | if (log_state->in_progress) {
return NULL;
} |
log_state->in_progress = true;
return log_state;
} else {
return kernel_applib_get_log_state();
}
}
// Release the LogState buffer obtained by prv_get_log_state()
static void prv_release_log_state(LogState *state) {
PebbleTask task = pebble_task_get_current();
if (task == PebbleTask_App || task ==... |
/*
* 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(us_pacific_region != -1) | ;
// Look up the real America/Los_Angeles
const int america_los_angeles_region = FIND_REGION("America/Los_Angeles");
cl_assert(america_los_angeles_region != -1);
// Verify that they're the same underlying region
cl_assert_equal_i(us_pacific_region, america_los_angeles_region);
const int america_new_york_... |
/*
* 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... | (vibe_score_info_get_resource_id(VibeScoreId_Pulse),
RESOURCE_ID_VIBE_SCORE_PULSE) | ;
}
void test_vibe_score_info__get_resource_id_returns_invalid_for_invalid_score(void) {
cl_assert_equal_i(vibe_score_info_get_resource_id(VibeScoreId_Invalid),
RESOURCE_ID_INVALID);
}
void test_vibe_score_info__get_name_returns_correct_name(void) {
cl_assert(strcmp(vibe_score_info_get_name(Vi... |
are "deep" sleep/nap
return;
}
// [FBO]: note that this only works because sleep sessions are
// all we care about and they are sorted. Don't try to extend this to walk
// or run sessions
const uint16_t max_apart_merge_secs = 5 * SECONDS_PER_MINUTE;
time_t end_time = previous->start_utc + previous->le... | &health_data->typical_sleep_end);
activity_get_metric_monthly_avg(ActivityMetricSleepTotalSeconds,
&health_data->monthly_sleep_average);
//! Activity sessions
health_data->num_activity_sessions = ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT;
if (!activit... |
void health_data_update_step_derived_metrics(HealthData *health_data) {
// get distance in meters
health_data->current_distance_meters = health_service_sum_today(HealthMetricWalkedDistanceMeters);
// get calories
health_data->current_calories = health_service_sum_today(HealthMetricActiveKCalories)
... |
(TIMELINE_PEEK_HEIGHT) | ;
prv_set_data(&s_data, 5543, 6500, 8000, 0);
window_set_on_screen(&s_data.window, true, true);
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
#endif
}
void test_kickstart__render_steps_above_typical(void) {
prv_set_data(&s_data, 3528, 2500, 8000, 0);
... | |
= ~USART_CR1_UE;
dev->periph->BRR = brr / DIV_PRECISION;
dev->periph->CR1 |= USART_CR1_UE;
}
// Read / Write APIs
////////////////////////////////////////////////////////////////////////////////
void uart_write_byte(UARTDevice *dev, uint8_t data) {
PBL_ASSERTN(dev->state->initialized);
// wait for us to be ... | if (dev->state->rx_irq_handler && dev->state->rx_int_enabled) {
const UARTRXErrorFlags err_flags = {
.overrun_error = uart_has_rx_overrun(dev),
.framing_error = uart_has_rx_framing_error(dev),
};
if (dev->state->rx_dma_buffer) {
// process bytes from the DMA buffer
const uint32_t dma... | |
/*
* 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... | {
HealthHrSummaryCardData *data = layer_get_data(base_layer);
GDrawCommandFrame *frame = gdraw_command_sequence_get_frame_by_index(
data->pulsing_heart, data->pulsing_heart_frame_index);
if (frame) {
const GPoint offset = GPoint(-1, -23);
gdraw_command_frame_draw(ctx, data->pulsing_heart, frame, of... |
static void prv_render_bpm(GContext *ctx, Layer *base_layer) {
HealthHrSummaryCardData *data = layer_get_data(base_layer);
const int units_offset_y =
fonts_get_font_height(data->bpm_font) - fonts_get_font_height(data->units_font);
GTextNodeHorizontal *horiz_container = graphics_text_node_create_horizont... |
_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible);
// A touchdown occurs and the active layer goes from non-null to null. All layer recognizers get
// reset. All recognizers remain in the possible state.
s_active_layer = &layer_a;
e.type =... | recognizer_get_manager(r1) | );
recognizer_set_manager(r1, &manager);
r1->state = RecognizerState_Possible;
r2->state = RecognizerState_Started;
manager.active_layer = &layer_a;
manager.triggered = r2;
manager.state = RecognizerManagerState_RecognizersTriggered;
recognizer_manager_deregister_recognizer(&manager, r1);
cl_assert_equ... |
xt[] = {
[BtTestStateInit] = "Initializing",
[BtTestStateStopped] = "Stopped",
[BtTestStateStarting] = "Starting",
[BtTestStateStopping] = "Stopping",
[BtTestStateStarted] = "Started",
[BtTestStateFailed] = "Failed",
[BtTestStateResetting] = "Resetting",
};
typedef struct {
Window window;
TextLayer t... | text_layer_set_text(status, status_text[data->test_state]) | ;
layer_add_child(&window->layer, &status->layer);
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
app_window_stack_push(window, true /* Animated */);
bt_state_change_event_info = (EventServiceInfo) {
.type = PEBBLE_BT_STATE_EVENT,
.handler = prv_bt_event_handler,
... |
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_odd_offset_even_clip")));
// Clipping on odd boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_ODD, OFFSET_RECT_ODD, false, 1);
for (int16_t row = 0; row < MAX_NUM_ROWS; row++) {
graphics_draw_hor... | (&ctx, fb, ORIGIN_RECT_CLIP_ODD, ORIGIN_RECT_NO_CLIP, false, 1) | ;
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_odd_clip")));
}
void test_graphics_draw_line___even_offset_vertical_dotted(void) {... |
/*
* 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... | ("abcd abcd abcd abcdX", buffer, sizeof(buffer)) | ;
cl_assert_equal_s(buffer, "abcd abcd abcd abcd");
cl_assert_equal_i(buffer[LEN - 1], '\0');
// Make sure we truncate correctly
i18n_get_with_buffer("Music", buffer, 3);
cl_assert_equal_s(buffer, "Mu");
}
void test_i18n__get_length(void) {
const char *first = i18n_get("Music", __FILE__);
cl_assert_equa... |
////
#include "fake_app_manager.h"
#include "fake_pbl_malloc.h"
#include "fake_session.h"
#include "fake_system_task.h"
// Stubs
////////////////////////////////////
#include "stubs_bt_lock.h"
#include "stubs_hexdump.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_rand_ptr.h"
AppRunStateComma... | (STATE_FETCH_KEY, RUNNING) | ;
assert_ack(true);
cl_assert_equal_i(APP_RUN_STATE_STATUS_COMMAND, s_last_cmd);
}
void test_launcher_app_message__ignore_acks(void) {
const AppMessageAck ack_message = {
.header = {
.command = CMD_ACK,
.transaction_id = TRANSACTION_ID,
},
};
launcher_app_message_protocol_msg_callback_dep... |
ain:
if (s_spi_transport.should_transact_after_consuming_rx) {
s_spi_transport.should_transact_after_consuming_rx = false;
dialog_spi_set_pending_int();
}
}
static void prv_wtf_analytic_cb(void *context) {
#ifndef RECOVERY_FW
ANALYTICS_LOG_DEBUG("Bluetooth Host Transport WTF");
AnalyticsEventBlob event... | (PebbleTask_BTRX) | ;
// Signal host_transport_deinit() that we're done
s_spi_transport.task_is_running = false;
vTaskDelete(NULL);
}
HostTransportEnqueueStatus host_transport_tx_enqueue(const uint8_t *data, size_t length) {
if (!s_is_host_transport_initialized) {
return HostTransportEnqueueStatus_Failure;
}
if (s_spi_t... |
/ Only 1 pin should be added
cl_assert_equal_i(s_num_timeline_adds, 1);
id2 = alarm_create(&(AlarmInfo) { .hour = 11, .minute = 30, .kind = ALARM_KIND_JUST_ONCE });
prv_assert_alarm_config(id2, 11, 30, false, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday);
// Only 1 pin should be added
cl_assert_equal_i(... | cron_service_wakeup() | |
if (header->command == CommandPhoneResponse) {
PhoneResponseMsg *msg = (PhoneResponseMsg *)data;
action_result = prv_action_result_create_from_serial_data(
header, msg->num_attributes, 0, msg->data, length - sizeof(PhoneResponseMsg));
} else {
PhoneActionResponseMsg *msg = (PhoneActionResponseMsg ... |
if (action_result) {
// callee will free memory
notifications_handle_notification_action_result(action_result);
}
}
| |
a);
prv_update_last_accel_data(&data);
}
mutex_unlock_recursive(s_accel_manager_mutex);
return result;
}
DEFINE_SYSCALL(AccelManagerState*, sys_accel_manager_data_subscribe,
AccelSamplingRate rate, AccelDataReadyCallback data_cb, void* context,
PebbleTask handler_task) {
Acc... | {
if (samples_per_update > ACCEL_MAX_SAMPLES_PER_UPDATE) {
return -1;
}
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(buffer, samples_per_update * sizeof(AccelRawData));
}
mutex_lock_recursive(s_accel_manager_mutex);
{
state->raw_buffer = buffer;
state->samples_per_update =... |
DEFINE_SYSCALL(uint32_t, sys_accel_manager_get_num_samples,
AccelManagerState *state, uint64_t *timestamp_ms) {
mutex_lock_recursive(s_accel_manager_mutex);
uint32_t result = state->num_samples;
*timestamp_ms = state->timestamp_ms;
mutex_unlock_recursive(s_accel_manager_mutex);
return ... |
ase puts us 1 day past feb
#define DSTRULE_WDAY_ANY (255)
if ((time_tm.tm_wday == rule->wday || rule->wday == DSTRULE_WDAY_ANY) &&
time_tm.tm_mon == rule->month) {
break;
}
time_tm.tm_mday += (rule->flag & TIMEZONE_FLAG_DAY_DECREMENT) ? -1 : 1;
uxtime = mktime(&time_tm);
gmtime_r(&uxti... | (tz_info.tm_zone, "N/A", TZ_LEN - 1) | ;
return tz_info;
#else
return (TimezoneInfo) {};
#endif
}
// This routine is solely responsible for setting the time and/or timezone for
// the system RTC. After the time is changed, it generates an event for
// consumers interested in time changes
T_STATIC void prv_update_time_info_and_generate_event(time_t *t, ... |
ale_time);
const time_t now = rtc_get_time();
if (stale_time <= now && window_data->is_modal) {
PBL_LOG(LOG_LEVEL_INFO, "Removing stale reminder from notification popup window");
prv_remove_notification(window_data, id, true /* close am */);
}
}
static void prv_clear_stale_reminders(void *data) {
noti... | reminders_snooze((Reminder *) item) | == S_SUCCESS) {
prv_push_snooze_dialog();
}
// Dismiss reminder
const TimelineItemAction *action = timeline_item_find_dismiss_action(item);
if (action) {
timeline_invoke_action(item, action, NULL);
}
}
static void prv_push_muted_dialog(void) {
SimpleDialog *simple_dialog = simple_dialog_create("M... |
T_NO_CLIP, true, 4);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw4_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 4);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl... | (&ctx.dest_bitmap, "draw_rect_offset_sw3_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 3);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw3_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, fal... |
sizeof(WeatherDBKey) ||
val_len < (int) MIN_ENTRY_SIZE ||
val_len > (int) MAX_ENTRY_SIZE) {
return E_INVALID_ARGUMENT;
}
const WeatherDBEntry *entry = (WeatherDBEntry *)val;
if (entry->version != WEATHER_DB_CURRENT_VERSION) {
PBL_LOG(LOG_LEVEL_WARNING,
"Version mismatch on insert... | {
return rv;
} |
rv = settings_file_set(&s_weather_db.settings_file, key, key_len, val, val_len);
prv_close_file_and_unlock_mutex();
return rv;
}
#endif
|
typedef struct FakeFlashState {
uint32_t offset;
uint32_t length;
uint32_t bytes_left_till_write_failure;
jmp_buf *jmp_on_failure;
uint8_t* storage; //! Allocated buffer of length bytes.
uint32_t write_count;
uint32_t erase_count;
} FakeFlashState;
static FakeFlashState s_state = { 0 };
void fake_spi_fl... | if (sector_addr <= BOTTOM_BOOT_REGION_END) {
erase_block(sector_addr, BOTTOM_BOOT_SECTOR_SIZE);
return;
} | |
alloc_check(UUID_STRING_BUFFER_LENGTH);
uuid_to_string(&parent_id, parent_id_string);
PBL_LOG(LOG_LEVEL_ERROR,
"Pin insert for a pin with no app installed, parent id: %s",
parent_id_string);
kernel_free(parent_id_string);
goto done;
}
// Bump the app's priorit... | timeline_item_deserialize_header(item_out, &hdr) | ;
return rv;
}
status_t pin_db_next_item_header(TimelineItem *next_item_out,
TimelineItemStorageFilterCallback filter) {
TimelineItemId id;
status_t rv = timeline_item_storage_next_item(&s_pin_db_storage, &id, filter);
if (rv) {
return rv;
}
rv = pin_db_read_item_header... |
nces registered!?");
return;
}
// Keep around the BLECharacteristic references:
memcpy(s_ams_client->characteristics, characteristics,
sizeof(BLECharacteristic) * NumAMSCharacteristic);
const BLECharacteristic entity_update_characteristic =
characteristics[AMSCharacteristicEntityUpdate];
... | (characteristic,
(const uint8_t *) &command_id, 1, GAPLEClientKernel) | ;
const bool has_error = (error != BTErrnoOK);
if (has_error) {
PBL_LOG(LOG_LEVEL_ERROR, "Couldn't write command: %d", error);
prv_analytics_log_event_with_info(AMSAnalyticsEventErrorSendRemoteCommand, error);
}
}
void ams_send_command(AMSRemoteCommandID command_id) {
prv_perform_on_kernel_main_task(pr... |
til all visible rows have been drawn.
static void prv_menu_scroll_offset_changed_handler(ScrollLayer *scroll_layer,
MenuLayer *menu_layer) {
// TODO: we might need to propagate this event down to MenuLayerCallbacks
}
static void prv_menu_select_click_handler(ClickR... | if (process_manager_compiled_with_legacy2_sdk()) {
return MENU_CELL_LEGACY2_BASIC_SEPARATOR_HEIGHT;
} else {
return MENU_CELL_BASIC_SEPARATOR_HEIGHT;
} |
}
static inline int16_t prv_menu_layer_get_header_height(MenuLayer *menu_layer,
uint16_t section_index) {
if (menu_layer->callbacks.get_header_height) {
return menu_layer->callbacks.get_header_height(menu_layer, section_index, menu_layer->callback_context);
} else {
return 0; // default
}
}
static ... |
fset,
GCompOp compositing_mode,
GColor8 tint_color) {
const int16_t dest_begin_y = dest_rect.origin.y;
const int16_t dest_end_y = dest_begin_y + dest_rect.size.h;
int16_t src_y = src_bitmap->bounds.origin.y + src_... | break;
case GCompOpAnd:
for (int i = src_start_idx; i < src_end_idx; ++i, ++dest_x) {
const uint32_t bit = (1 << i);
const bool set = src & bit;
if (!set) {
dest[dest_x] = GColorBlack.argb;
}
}
break;
... |
src_end_idx = MIN(src_line_wrap_end_idx, src_start_idx + row_bits_left);
} else {
src_start_idx = 0;
src_end_idx = MIN(32, row_bits_left);
}
src = *src_block;
}
}
}
}
void bitblt_bitmap_into_bitmap_tiled(GBitmap* dest_bitmap, const GBitmap* src_bitmap,... |
tate == ANCSClientStateAliveCheck);
case ANCSClientStateRequestedNotification:
return (new_state == ANCSClientStateReassemblingNotification ||
new_state == ANCSClientStateRequestedApp ||
new_state == ANCSClientStateRetrying ||
new_state == ANCSClientStateIdle);
ca... | {
prv_check_ancs_alive();
return;
} |
if (s_ancs_client->queue == NULL) {
// empty
return;
}
prv_do_notif_queue_operation();
}
// -----------------------------------------------------------------------------
// Reset & Error Handling
static void prv_reset_and_idle(void) {
prv_set_state(ANCSClientStateIdle);
prv_reset_reassembly_conte... |
_grect(prop_h, &set_r);
r = GRect(0, 0, 0, 0);
property_animation_get_from_grect(prop_h, &r);
cl_assert_equal_rect(set_r, r);
set_r = GRect(5, 6, 7, 8);
property_animation_set_to_grect(prop_h, &set_r);
r = GRect(0, 0, 0, 0);
property_animation_get_to_grect(prop_h, &r);
cl_assert_equal_rect(set_r, r);
... | (prop_h, &test_value) | ;
cl_assert_equal_i(test_value, set_value);
// Destroy it
animation_destroy(h);
#endif
}
// --------------------------------------------------------------------------------------
// Test a basic gpoint property animation
void test_animation__property_gpoint(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation... |
eate_event(event_type);
rocky_global_call_event_handlers(event);
} else {
DBG("No handler registered for %s", event_type);
}
}
static void prv_session_open__enter(const PostMessageResetCompletePayload *rc) {
PBL_ASSERTN(s_state.state == PostMessageStateAwaitingResetCompleteRemoteInitiated ||
... | PBL_ASSERTN(s_state.state == PostMessageStateAwaitingResetRequest ||
s_state.state == PostMessageStateAwaitingResetCompleteLocalInitiated ||
s_state.state == PostMessageStateSessionOpen) | ;
s_state.state = PostMessageStateAwaitingResetCompleteRemoteInitiated;
prv_send_reset_complete();
}
static bool prv_is_tuple_valid_reset_complete(Tuple *reset_complete) {
if (reset_complete->type != TUPLE_BYTE_ARRAY) {
PBL_LOG(LOG_LEVEL_ERROR, "ResetComplete not a byte array! %u", reset_complete->type);
... |
OUT 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 "app_storage.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "util/uuid.h"
#include "drivers/flash.h"
#in... | pfs_open(process_name, OP_FLAG_READ, 0, 0) | ;
if (fd < 0) {
return false;
}
pfs_close(fd);
// now check resource bank
return resource_storage_check((ResAppNum)id, 0, NULL);
}
void app_storage_get_file_name(char *name, size_t buf_length, AppInstallId app_id,
PebbleTask task) {
const char *task_str = (task == Pebble... |
int len = strlen(buf_small);
int fd = pfs_open(file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, len);
cl_assert(fd >= 0);
cl_assert(pfs_write(fd, (uint8_t *)buf_small, len) == len);
cl_assert(pfs_close(fd) == S_SUCCESS);
// delete every few files and a bunch of pages near the end
if (((i & 0x1) == 0... | cl_assert(fd >= 0) | ;
int rv = pfs_seek(fd, len, FSeekSet);
cl_assert(rv == len);
rv = pfs_seek(fd, 0, FSeekCur);
cl_assert(rv == len);
rv = pfs_seek(fd, -5, FSeekCur);
cl_assert(rv == (len - 5));
rv = pfs_seek(fd, -6, FSeekCur);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, 0, FSeekSet);
cl_assert(rv == 0);
rv = pf... |
n_2005 = 1104580800;
static const int32_t min_gmtoff = -12 * SECONDS_PER_HOUR;
static const int32_t max_gmtoff = 12 * SECONDS_PER_HOUR;
static const int32_t gmtoff_slide = SECONDS_PER_MINUTE;
TimezoneInfo tzinfo = {{0}};
tzinfo.dst_id = 0;
tzinfo.dst_start = tzinfo.dst_end = 0;
tzinfo.timezone_id = 0;
... | (time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("Wed, 2:00 PM", time_buf);
// June 9th 2015, 23:59:58 (T-14:00:02)
rtc_set_time(event_time - (14 * SECONDS_PER_HOUR) - 2);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Wed, 2:00 PM", time_buf);
// June 9th 2015, 23:59:... |
t = (TextLayoutExtended) {
.hash = 0,
.box = (GRect) { (GPoint) { 0, 0 }, (GSize) { 7 * HORIZ_ADVANCE_PX + 1, FONT_HEIGHT - 1 } },
.font = (GFont) { 0 },
.overflow_mode = GTextOverflowModeWordWrap,
.alignment = GTextAlignmentLeft,
.max_used_size = (GSize) { 0, 0 }
};
graphics_text_layout_ge... | (&gcontext, "JR\n\nWhop", font, box, GTextOverflowModeWordWrap, GTextAlignmentLeft, (void*)&layout) | |
o_reel_get_elapsed(test_reel), 300 - 20);
}
void test_kino_player__create_finite_animation_finite_reel_reverse(void) {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = 300;
Animation *animation = (Animation *... | kino_player_create_play_animation(test_player) | ;
cl_assert_equal_i(animation_is_scheduled(animation), false);
animation_schedule(animation);
animation_set_elapsed(animation, 20);
animation_set_duration(animation, ANIMATION_DURATION_INFINITE);
prv_play_animation_update(animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(t... |
12, -336},
{ 1040, 416, -336},
{ 1200, 360, -264},
{ 1376, 280, -248},
{ 1248, 168, -152},
{ 1232, 80, -88},
{ 1384, 72, -72},
{ 1328, 88, -136},
{ 1104, 64, -152},
{ 1000, -48, -184},
{ 1048, -144, -248},
{ 736, -288, -256},
{ 1144, -296, -64},
{ 960, -184, -160},
... | { 1336, 104, -144},
{ 1216, 16, -144},
{ 1320, -96, -184},
{ 840, -328, -72},
{ 1056, -328, -144},
{ 1032, -280, -56},
{ 1080, -120, -184},
{ 1160, -40, -208},
{ 1208, 8, -312},
// 50 seconds
{ 976, 96, -264},
{ 920, 144, -312},
{ 984, 192, -208},
{ 1112, 256, -24... |
{ 1144, 392, -224},
{ 1440, 560, -224},
{ 1120, 712, -200},
{ 1240, 648, -248},
{ 928, 480, -312},
{ 976, 488, -288},
{ 1104, 392, -256},
{ 1264, 336, -200},
{ 1136, 208, -120},
{ 1056, 160, -136},
{ 1192, 136, -136},
{ 1336, 112, -120},
{ 1296, 56, -152},
{ 1144... |
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_window_load,
});
window_set_click_config_provider_with_context(window, prv_click_configure, window);
window_set_fullscreen(window, true);
window_set_overrides_back_button(window, true);
const bool a... | handle_init() | |
atic const PropertyAnimationImplementation implementation = {
.base = {
.update = (AnimationUpdateImplementation) property_animation_update_gpoint,
},
.accessors = {
.setter = { .grect = (const GRectSetter) prv_scroll_layer_set_content_offset_internal, },
.getter = { .grect = (... | {
scroll_layer->callbacks.click_config_provider(get_callback_context(scroll_layer));
} |
}
void scroll_layer_set_click_config_onto_window(ScrollLayer *scroll_layer, struct Window *window) {
window_set_click_config_provider_with_context(window, (ClickConfigProvider) scroll_layer_click_config_provider, scroll_layer);
}
void scroll_layer_set_callbacks(ScrollLayer *scroll_layer, ScrollLayerCallbacks callb... |
/*
* 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_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(4))) | |
gs args = prv_parse_arguments(param_str, param_str_end);
if (args.num_args != cmd->num_params) {
char buffer[128];
prompt_send_response_fmt(buffer, sizeof(buffer),
"Incorrect number of arguments: Wanted %u Got %u",
cmd->num_params, args.num_args);
... | dbgserial_putchar(0x8) | |
-------------
void accel_session_shake_subscribe(AccelServiceState * session, AccelTapHandler handler) {
AccelServiceState *state = (AccelServiceState *)session;
state->shake_handler = handler;
event_service_client_subscribe(&state->accel_shake_info);
}
// -------------------------------------------------------... | APP_LOG(LOG_LEVEL_ERROR, "Not enough memory to subscribe") | ;
state->raw_data = old_buf;
return -1;
}
state->samples_per_update = samples_per_update;
int result = sys_accel_manager_set_sample_buffer(state->manager_state, state->raw_data,
samples_per_update);
applib_free(old_buf);
return result;
}
|
/*
* 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... | {
WordState new_state = state;
switch (state) {
case WordStateStart:
if (codepoint == NEWLINE_CODEPOINT) {
new_state = WordStateEnd;
} else if (codepoint_is_ideograph(codepoint)) {
new_state = WordStateIdeograph;
} else {
new_state = WordStateGrowing;
}
bre... | |
/*
* 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 (msg->message_length > max_message_len) {
msg->message_length = max_message_len;
} |
}
// -------------------------------------------------------------------------------------------
int pbl_log_binary_format(char* buffer, int buffer_len,
const uint8_t log_level,
const char* src_filename_path, int src_line_number,
const cha... |
s = prv_write_register(PmicRegisters_CHARGE_CURRENT_CNTL, cntl);
}
}
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not set pmic charge current.");
}
// Set EOC current to 5% of ConstantCurrent
prv_set_register_bit(PmicRegisters_CHARGE_CONFIG_2, 5, false);
if (BOARD_CONFIG_POWER.charging_cutoff_v... | {
while (1) {}
__builtin_unreachable();
} |
return false;
}
// This is a hard power off, resulting in all rails being disabled.
// Generally, this is not desirable since we'll lose the backup domain.
// You're *probably* looking for pmic_power_off.
bool pmic_full_power_off(void) {
// ResetControl (Fig. 79)
// Bit 1: power_off - Start a reset cycle, and w... |
data by clar */
${clar_callbacks}
${clar_categories}
static const struct clar_suite _clar_suites[] = {
${clar_suites}
};
static size_t _clar_suite_count = ${clar_suite_count};
static size_t _clar_callback_count = ${clar_callback_count};
/* Core test functions */
static void
clar_report_errors(void)
{
int i = 1... | if (is_num) {
if ((size_t)num >= _clar_suite_count) {
clar_print_onabort("Suite number %d does not exist.\n", num);
exit(-1);
}
clar_run_suite(&_clar_suites[num]);
}
else if (!has_colon || argument[-1] == ':') {
for (j = 0; j < (int)_clar_suite_count; ++j)... |
if (_clar.active_suite == NULL) {
clar_print_onabort("No suite matching '%s' found.\n", argument);
exit(-1);
}
break;
}
// Run a particular test only. This code was added on top of base clar.
case 't': {
int offset = (argument[2] == '=') ? 3 : 2;
char *test_na... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.