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... | {
// the state is already set by somebody else
mutex_unlock(s_state_mutex);
return false;
} |
s_input_state = state;
switch (s_input_state) {
case AccessoryInputStateMfg:
accessory_enable_input();
accessory_set_baudrate(AccessoryBaud115200);
accessory_set_power(false);
accessory_mfg_mode_start();
break;
case AccessoryInputStateIdle:
// restore accessory to default state
acc... |
.num_points = 11,
.points = (GPoint []) {
{-40, 0}, {0, -40}, {40, 0}, {28, 0}, {28, 40}, {10, 40},
{10, 16}, {-10, 16}, {-10, 40}, {-28, 40}, {-28, 0},
},
};
static const GPathInfo s_bolt_path_info = {
.num_points = 6,
.points = (GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}}
};... | gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_top_clipped.${BIT_DEPTH_NAME}.pbi") | |
order(Fixed_S16_3 offset, uint32_t offset_radius_sq,
uint32_t opposite_radius_sq) {
if (offset_radius_sq == opposite_radius_sq) {
// We're dealing with a circle
return (Fixed_S16_3){.raw_value = integer_sqrt((offset_radius_sq << FIXED_S16_3_PRECISION) -
... | if (quadrant & GCornerBottomRight) {
graphics_private_set_pixel(ctx, GPoint(p.x + x, p.y + y));
graphics_private_set_pixel(ctx, GPoint(p.x + y, p.y + x));
} | |
/*
* 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... | sniprintf(data->status_string, sizeof(data->status_string),
"TIME REMAINING: %"PRIu32"s", data->seconds_remaining) | ;
data->seconds_remaining--;
}
text_layer_set_text(&data->status, data->status_string);
}
static void prv_button_click_handler(ClickRecognizerRef recognizer, void *data) {
AppData *app_data = app_state_get_user_data();
ButtonId button_id_pressed = click_recognizer_get_button_id(recognizer);
bitset32_se... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (text_layer) | ;
}
static void init(void) {
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(window, animated);
app_timer_register(1000, prv_timer_callback, 0);
}
static void deinit(voi... |
/, NULL /* &tail */);
} else {
PBL_ASSERTN(list_contains(manager->idle_timers, &timer->list_node));
list_remove(&timer->list_node, &manager->idle_timers /* &head */, NULL /* &tail */);
}
// Set timer variables
timer->cb = cb;
timer->cb_data = cb_data;
timer->expire_time = current_time + timeout_tic... | kernel_free(timer) | |
/*
* 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... | worker_manager_disable() | ;
services_set_runlevel(RunLevel_LowPower);
} else {
analytics_stopwatch_stop(ANALYTICS_DEVICE_METRIC_WATCH_ONLY_TIME);
worker_manager_enable();
services_set_runlevel(RunLevel_Normal);
}
s_prev_low_power_active = s_low_power_active;
}
static void prv_low_power_toggle_timer_callback(void* data) {... |
update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_nx);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_nx.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_e... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_outside_nx.${BIT_DEPTH_NAME}.pbi")) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_outside_x);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_outside_x.${BIT_DEPTH_NAME}.pbi"));
}
#define RECT_TEXT_0_0 GRect(0, 0, 140, ... |
448, -352, 336},
{ 1576, -576, 312},
{ 1208, -336, 120},
// 58 seconds
{ 928, -112, 152},
{ 1464, 768, -696},
{ 2424, 3984, -2392},
{ 1336, 3480, -2208},
{ 136, 1696, -1456},
{ -432, 928, -680},
{ -528, 224, -352},
{ -752, -240, 144},
{ -1480, -256, 120},
{ -1184, 72,... | { -544, 3792, -2752},
{ 288, 2424, -2112},
{ 600, 1328, -768},
{ 1032, 448, -208},
{ 1496, -64, 48},
{ 1560, -600, 240},
{ 1344, -440, 208},
{ 1152, -104, 160},
{ 1408, 984, -912},
{ 1488, 3576, -2544},
{ 696, 3664, -2712},
{ -304, 1904, -1568},
{ -760, 1016, -1016},
... |
{ 952, -40, 184},
{ 1320, 568, -432},
{ 2064, 2824, -2168},
{ 1280, 3112, -2512},
{ 384, 1568, -1752},
{ 16, 920, -1224},
{ -304, 608, -784},
{ -648, -48, -288},
{ -1232, -176, -24},
// 66 seconds
{ -1408, 48, -232},
{ -1256, 336, -56},
{ -912, 1512, -640},
{ -80... |
ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPointZero, DEG_TO_TRIGANGLE(0), GPointZero);
cl_check(gbitmap_pbi_... | {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPointZero, DEG_TO_TRIGANGLE(0), GPoint(20, 20));
cl_ch... | |
Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writ... | if (uuid_equal(&pin.header.parent_id, &uuid_reminders_data_source)) {
return true;
} |
return false;
}
static bool prv_should_ignore_because_time_reminder(const ANCSAttribute *app_id,
time_t timestamp,
const ANCSAttribute *title,
uint32_t uid,
... |
initialize(void) {
memset(s_ad_data, 0, sizeof(s_buffer_size));
}
// -----------------------------------------------------------------------------
// Consuming BLEAdData:
// -----------------------------------------------------------------------------
void test_ble_ad_parse__16_bit_uuid_and_device_name(void) {
//... | (expected_scan_resp_data,
ad->data + ad->ad_data_length,
ad->scan_resp_data_length) | , 0);
ble_ad_destroy(ad);
}
void test_ble_ad_parse__set_service_uuids_128_bit(void) {
BLEAdData *ad = ble_ad_create();
uint8_t uuid_bytes[] = "\x97\x6e\xbb\x18\xd3\xe9\x43\xc0\x8a\x63\x8d\x2b" \
"\x60\xd9\x04\x2a";
Uuid uuid[2];
uuid[0] = UuidMakeFromBEBytes(uuid_bytes);
uuid[1] = UuidMakeFromLEBytes(u... |
il/dict.h"
#include "util/uuid.h"
extern void launcher_app_message_reset(void);
extern void launcher_app_message_protocol_msg_callback_deprecated(CommSession *session,
const uint8_t* data,
... | prv_receive(RUN_STATE_KEY, RUNNING) | ;
assert_ack(true);
cl_assert_equal_i(APP_RUN_STATE_RUN_COMMAND, s_last_cmd);
}
void test_launcher_app_message__receive_push_stop(void) {
prv_receive(RUN_STATE_KEY, NOT_RUNNING);
assert_ack(true);
cl_assert_equal_i(APP_RUN_STATE_STOP_COMMAND, s_last_cmd);
}
void test_launcher_app_message__receive_push_fetch... |
/*
* 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... | (&gcontext,
"Twitter\n@pebble is talking about a lot of really really cool important stuff.\n",
font, box,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, (void*)&layout) | ;
cl_assert_equal_i(layout.box.size.w, box.size.w);
cl_assert_equal_i(layout.max_used_size.w, 8 * HORIZ_ADVANCE_PX);
graphics_draw_text(&gcontext, "Twitter\n\n\n\n\n\n\n\n", font, box,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, (void*)&layout);
cl_assert_equal_i(layout.box.size... |
prv_outbox_try_send_next();
DBG("SessionOpen enter");
}
static void prv_session_open__after_exit(void) {
DBG("After SessionOpen exit");
prv_cleanup_inbound_reassembly_buffer();
if (s_state.out.object_queue) {
// Make sure we'll re-transfer the object from the start when re-opening:
OutgoingObject *he... | prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorMalformedResetComplete) | ;
return;
}
const PostMessageResetCompletePayload *rc =
(const PostMessageResetCompletePayload *) tuple->value[0].data;
// Check overlap in supported versions
if (!prv_is_version_supported(rc)) {
// Don't send an error here! The initiating side is supposed have detected the version
... |
.tm_gmtoff = -3600;
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "-0100");
jan_2_2015__13_00_00.tm_gmtoff = -4200;
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "-0110");
jan_2_2015__13_0... | strftime(tmbuf, sizeof(tmbuf), "%3H %4I", &jan_2_10015__13_00_00) | ;
cl_assert_equal_s(tmbuf, "013 0001");
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%01j %05m %03M %05p", &jan_2_10015__13_00_00);
cl_assert_equal_s(tmbuf, "002 00001 000 PM");
#if EXTENSION_GNU
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%05P", &jan_2_10015__13_00_00);
cl_assert_equal_s(tmbuf... |
TRANSFER_STATE_WRITE_ADDRESS_RX:
// Write the I2C device address again, but this time in read mode.
bus->i2c->DR = bus->transfer.device_address | I2C_READ_WRITE_BIT;
if (bus->transfer.size == 1) {
// Last byte, we want to NACK this one to tell the slave to stop sending us bytes.
bus->... | portEND_SWITCHING_ISR(irq_event_handler(&i2c_buses[0])) | ;
}
void I2C1_ER_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_error_handler(&i2c_buses[0]));
}
void I2C2_EV_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_event_handler(&i2c_buses[1]));
}
void I2C2_ER_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_error_handler(&i2c_buses[1]));
}
void I2C3_EV_IRQHandler(void) {
... |
if (!this->state->running) {
goto unlock;
}
prv_dfsdm_disable(this);
prv_disable_gpio(this);
if (this->mic_power_state_fn) {
this->mic_power_state_fn(false);
}
stop_mode_enable(InhibitorMic);
this->state->running = false;
PBL_LOG(LOG_LEVEL_DEBUG, "Stopped microphone, dropped samples: %"PR... | {
// move 24-bit value stored in upper 24-bits down to lower 24 bits
int32_t sample = dfsdm_buffer[i] >> 8;
// Single pole IIR filter to remove DC offset (cutoff frequency: 10Hz)
// Filter coefficients pre-calculated
const int64_t b1 = 32639; // b1 = exp(2 * PI * Fc) where Fc is 10/16000, scaled by... |
this->state->prev_r = r;
tpdf >>= this->final_right_shift - 1; // Shift to 2-LSB size relative to sample
sample += tpdf;
// Shift result to final bit depth and clip
sample >>= this->final_right_shift;
__SSAT(sample, 16); // saturate because we're clipping off the top of a 32-bit value
if ... |
/*
* 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... | new_timer_create() | ;
PBL_LOG(LOG_LEVEL_INFO, "Entering infinite loop in Timer callback");
bool success = new_timer_start(timer, 100, stuck_timer_callback, NULL, 0 /*flags*/);
PBL_ASSERTN(success);
} else if (index == 2) {
// call directly
core_dump_reset(false /* don't force overwrite */);
} else if (index == 3... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (argp, msg) | ;
fprintf(stdout, "Bail out! ");
vfprintf(stdout, msg, argp);
va_end(argp);
}
|
&bp_service->uuid);
cl_assert_equal_i(num_found_services, num_services);
// Test that the UUID matches the Blood Pressure UUID:
const Uuid uuid = gatt_client_service_get_uuid(service_refs[0]);
cl_assert(uuid_equal(&uuid, &bp_service->uuid));
}
void test_gatt_client_accessors__get_char... | (uuid_equal(&uuid2, &thermo_service->uuid) ||
uuid_equal(&uuid2, &random_128bit_service->uuid)) | |
conds_to_ticks(SEND_BYTE_TIMEOUT_MS)) != pdPASS) {
if (!s_has_sent_byte) {
// we haven't sent a byte in the last timeout period, so time out the whole send
s_stream_cb = NULL;
s_stream_context = NULL;
success = false;
PBL_LOG(LOG_LEVEL_ERROR, "Timed-out while sending");
break;
... | if (s_send_history.data != data) {
// The byte we are receiving doesn't match the next byte in the send queue.
s_bus_contention_detected = true;
} |
s_send_history.has_data = false;
} else {
// We received a byte without sending and the input is not enabled. This typically indicates
// a race condition between when we disable input and start sending, or between when we
// finish sending and enable input. Either way, we can't trust this ... |
IND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "process_management/app_install_types.h"
#include "process_management/pebble_process_info.h"
#include "process_management/pebble_process_md.h"
#includ... | (&temp, 0, sizeof(AppDBEntry)) | ;
cl_assert_equal_i(S_SUCCESS, app_db_get_app_entry_for_uuid(&app1.uuid, &temp));
cl_assert_equal_b(true, uuid_equal(&app1.uuid, &temp.uuid));
cl_assert_equal_i(0 , strncmp((char *)&app1.name, (char *)&temp.name, APP_NAME_SIZE_BYTES));
// check app 2
memset(&temp, 0, sizeof(AppDBEntry));
cl_assert_equal_i(... |
otificationNode *node = notifications_data->notification_list;
// There's no notifications, don't draw anything
if (!node) {
return 0;
}
// add one for the CLEAR ALL at the top
return list_count((ListNode *)notifications_data->notification_list) + 1;
}
static int16_t prv_get_cell_height(struct MenuLayer... | (body, '\n') | ; // NULL handled gracefully downstream
}
} else if (IS_EMPTY_STRING(title)) {
// no title, but yes subtitle.
title = subtitle;
subtitle = body;
} else if (IS_EMPTY_STRING(subtitle)) {
// no subtitle, but yes title
subtitle = body;
} else {
WTF;
}
draw_cell(ctx, cell_layer, title,... |
lue, exp_value);
// ---
// Compute weekend step average from 4am to 9am. This should use the 15-minute
// step averages that we stuffed in.
exp_value = prv_averages_sum(4 * MINUTES_PER_HOUR, 9 * MINUTES_PER_HOUR,
&s_sys_activity_get_step_averages_values_weekend.out.averages);
// Sinc... | (HealthMetricHeartRateBPM,
now_utc - 60, now_utc - 60,
HealthAggregationAvg, HealthServiceTimeScopeOnce) | ;
cl_assert_equal_i(123, result);
// The function call is the equivalent to `peek_value` with HeartRateBPM except for the
// time stamps, make sure it returns 0 because we haven't filled in that data)
result = health_service_aggregate_averaged(HealthMetricHeartRateBPM,
... |
name_out, &platform_bits_out);
cl_assert_equal_i(id, id_out);
cl_assert_equal_m(&link_key_in, &link_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_in, name_out);
cl_assert_equal_i(platform_bits_in, platform_bits_out);
}
void test_bluetooth_persistent_storage_prf__delete_... | bt_persistent_storage_get_active_gateway(&id_out, &type_out) | ;
cl_assert(!ret);
ret = bt_persistent_storage_has_active_bt_classic_gateway_bonding();
cl_assert(!ret);
ret = bt_persistent_storage_has_active_ble_gateway_bonding();
cl_assert(!ret);
// Store a new BT Classic pairing
BTDeviceAddress addr_1 = {.octets = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16}};
SM128BitKe... |
/*
* 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... | {
while (QSPI_GetFlagStatus(QSPI_FLAG_BUSY) != RESET) { }
} |
static void prv_quad_enable() {
QSPI_ComConfig_InitTypeDef qspi_com_config;
QSPI_ComConfig_StructInit(&qspi_com_config);
qspi_com_config.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write;
qspi_com_config.QSPI_ComConfig_IMode = QSPI_ComConfig_IMode_1Line;
qspi_com_config.QSPI_ComConfig_Ins = MT25QCo... |
another transport may cause
// undesirable behaviour however.
if (!prv_is_transport_type(existing_system_session->transport,
existing_system_session->transport_imp,
CommSessionTransportType_PULSE)
&& !prv_is_transpo... | {
bt_lock();
if (comm_session_is_valid(session)) {
session->transport_imp->set_connection_responsiveness(session->transport, consumer,
state, max_period_secs,
granted_handler);
}
... |
}
// -------------------------------------------------------------------------------------------------
bool comm_session_is_current_task_send_next_task(CommSession *session) {
if (session->transport_imp->schedule) {
return session->transport_imp->is_current_task_schedule_task(session->transport);
}
return ... |
e_proc(&layer, &outside_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_y_origin_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_x_y_layer_update_callback);
layer_render_tree(&layer,... | graphics_draw_pixel(ctx, GPoint(p.x + 0, p.y)) | ;
graphics_draw_pixel(ctx, GPoint(p.x + 1, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 2, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 3, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 4, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 5, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 6, p.y));
graphics_draw_pi... |
clar_func *test,
const struct clar_suite *suite)
{
_clar.suite_errors = 0;
_clar.active_suite = suite->name;
_clar.active_test = test->name;
clar_run_test(test, &suite->initialize, &suite->cleanup);
}
#endif
static void
clar_usage(const char *arg)
{
printf("Usage: %s [options]\n\n", arg);
printf("Optio... | printf(" %s\n", suite->tests[i].name) | |
/*
* 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... | (session->data->mutex) | ;
return true;
}
// ---------------------------------------------------------------------------------------
// Callback used to free a storage buffer from unprivileged mode.
static void prv_free_storage_buffer_cb(void *p) {
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Freeing buffer storage ptr: %p", p);
... |
struct MenuCellDimensions {
int16_t basic_cell_height;
int16_t small_cell_height;
int16_t horizontal_inset;
int16_t title_subtitle_left_margin;
} MenuCellDimensions;
static const MenuCellDimensions s_menu_cell_dimensions[NumPreferredContentSizes] = {
//! @note these are the same as Medium until Small is des... | {
box.origin.x += bounds->size.w - (horizontal_margin + config->icon->bounds.size.w);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | i18n_get(snooze_text, dialog) | , alarm_get_snooze_delay());
i18n_free(snooze_text, dialog);
dialog_set_text(dialog, snooze_buf);
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_CONFIRMATION_LARGE);
dialog_set_background_color(dialog, GColorJaegerGreen);
dialog_set_timeout(dialog, DIALOG_TIMEOUT_DEFAULT);
return simple_dialog;
}
static 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... | cl_assert_equal_i(109224, f(four_third, half, ANIMATION_NORMALIZED_MAX)) | ;
}
|
D_GET_STORE(name) \
SettingsFile *name __attribute__((cleanup(prv_unlock))) \
= prv_lock_and_get_store()
DEFINE_SYSCALL(bool, persist_exists, const uint32_t key) {
LOCK_AND_GET_STORE(store);
return settings_file_exists(store, &key, sizeof(key));
}
DEFINE_SYSCALL(int, persist_get_size, const uint32_t key)... | strlen(cstring) | + 1;
return persist_write_data(key, cstring, cstring_length);
}
DEFINE_SYSCALL(status_t, persist_delete, const uint32_t key) {
LOCK_AND_GET_STORE(store);
status_t result;
if (settings_file_exists(store, &key, sizeof(key))) {
result = settings_file_delete(store, &key, sizeof(key));
if (PASSED(result)) ... |
last pixel with blending (don't render first *and* last pixel if line length is 1)
if (y2.fraction != 0) {
prv_blend_color_and_update_mask(ctx, y1.integer, x, x, color, (uint8_t)y2.fraction);
}
}
T_STATIC void prv_mask_recording_blend_horizontal_line_raw(GContext *ctx, int16_t y, int16_t x1,
... | {
for (int i = 0; i < right_aa_offset; i++) {
if (x1.integer > clip_box_max_x) {
break;
}
prv_blend_color_and_update_mask(ctx, y, x1.integer, x1.integer, color,
(uint8_t)(FIXED_S16_3_ONE.raw_value * (right_aa_offset - i) /
... | |
nfig_release_lock();
}
static void prv_mic_power_enable(void) {
if (BOARD_CONFIG.mic_config.mic_gpio_power.gpio) {
gpio_output_set(&BOARD_CONFIG.mic_config.mic_gpio_power, true);
} else {
set_ldo3_power_state(true);
}
}
static void prv_mic_power_disable(void) {
if (BOARD_CONFIG.mic_config.mic_gpio_pow... | (&s_circ_buffer,
(uint8_t *) &s_subscriber.buffer[s_subscriber.idx],
((s_subscriber.size - s_subscriber.idx) * sizeof(int16_t))) | |
30;
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, 13);
cl_assert_equal_i(s_num_timeline_removes, 6);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm go... | alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKENDS }) | ;
prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_WEEKENDS, s_weekend_schedule);
// Only 1 pin should be added (for Saturday)
cl_assert_equal_i(s_num_timeline_adds, 1);
id2 = alarm_create(&(AlarmInfo) { .hour = 11, .minute = 30, .kind = ALARM_KIND_WEEKENDS });
prv_assert_alarm_config(id2, 11, 30, fals... |
_data[ALGORITHM_SAMPLING_RATE];
int j;
for (j = 0; j < ALGORITHM_SAMPLING_RATE && i < num_samples; j++, i++) {
accel_data[j] = (AccelData) {
.x = samples[i].x,
.y = samples[i].y,
.z = samples[i].z,
.did_vibrate = false,
.timestamp = start_ms
};
}
fak... | (&time_start) | ;
strftime(time_start_text, sizeof(time_start_text), "%F %r", local_tm);
char time_end_text[64];
local_tm = localtime(&time_end);
strftime(time_end_text, sizeof(time_end_text), "%F %r", local_tm);
PBL_LOG(LOG_LEVEL_DEBUG, "Got activity: %d %s to %s (%d min)", (int)activity, time_start_text,
time... |
}
}
f->curr_page = next_page;
}
*pg_offset = data_offset % free_bytes_in_page(f->curr_page);
return (S_SUCCESS);
}
static int mark_fd_free(int fd) {
if (PFS_FD(fd).file.name != NULL) {
kernel_free(PFS_FD(fd).file.name);
PFS_FD(fd).file.name = NULL;
}
if (PFS_FD(fd).file.pg_cache != ... | {
mutex_lock_recursive(s_pfs_mutex);
int res = E_UNKNOWN;
if (!FD_VALID(fd)) {
res = E_INVALID_ARGUMENT;
goto cleanup;
}
int new_offset = PFS_FD(fd).file.offset;
if (seek_type == FSeekSet) {
new_offset = offset;
} else if (seek_type == FSeekCur) {
new_offset += offset;
}
// allow one... | |
ert_equal_m(&DEVICE_ADDR, &addr_buf, sizeof(DEVICE_ADDR));
shared_prf_storage_set_ble_pinned_address(&DEVICE_ADDR);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0);
shared_prf_storage_set_ble_pinned_address(NULL);
rv = shared_prf_storage_get_ble_pinned_address(NULL);
cl_assert_equal_b(rv, f... | cl_assert_equal_b(shared_prf_storage_get_local_device_name(device_name_out,
sizeof(device_name_out)), true) | ;
cl_assert_equal_s(DEVICE_NAME, device_name_out);
}
// Sets the getting started field, then corrupts the getting_started crc
void test_shared_prf_storage_v3__handle_currupt_field_same(void) {
bool GETTING_STARTED_COMPLETE = true;
shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE);
cl_as... |
/*
* 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... | (ps1, ps4) | );
cl_assert(!pstring_equal(ps1, ps2));
cl_assert(!pstring_equal(ps1, ps3));
cl_assert(!pstring_equal(ps2, ps3));
cl_assert(!pstring_equal(ps1, NULL));
cl_assert(!pstring_equal(NULL, NULL));
}
void test_pstring__equal_cstring(void) {
const char *str1 = "Phil";
uint8_t ps1_buf[128];
PascalString16 *ps1 ... |
/*
* 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... | (prefs_db_read((uint8_t *)key, key_len, (uint8_t *)&get_value,
sizeof(get_value)), 0) | ;
cl_assert_equal_i(set_value, get_value);
// If we get the pref setting now, it should still be the old value because we haven't
// issued the blob_db update event yet
uint32_t get_pref = backlight_get_timeout_ms();
cl_assert_equal_i(get_pref, set_value + 1);
// Issue the blob_db update event
PebbleBl... |
20,
},
};
char name_2[BT_DEVICE_NAME_BUFFER_SIZE] = "Device 2";
uint8_t platform_bits_2 = 0x22;
BTBondingID id_2 = bt_persistent_storage_store_bt_classic_pairing(&addr_2, &link_key_2,
name_2, &platform_bits_2);
prv_fire_writeback_timer();
cl_as... | {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key_out;
char name_out[BT_DEVICE_NAME_BUFFER_SIZE];
uint8_t platform_bits_out;
// Store a new pairing
BTDeviceAddress addr_in = {.octets = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16}};
SM128BitKey link_key_in = {
.data = {
... |
name_out, &platform_bits_out);
cl_assert(!ret);
}
void test_bluetooth_persistent_storage_prf__delete_bt_classic_pairing_by_addr(void) {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key_out;
char name_out[BT_DEVICE_NAME_BUFFER_... |
ialized_slice->total_size;
return true;
}
/////////////////////////
// AppGlanceDB API
/////////////////////////
status_t app_glance_db_insert_glance(const Uuid *uuid, const AppGlance *glance) {
if (!uuid || !glance) {
return E_INVALID_ARGUMENT;
}
SerializedAppGlanceHeader *serialized_glance = NULL;
s... | ((uint8_t *)app_uuid, UUID_SIZE, (uint8_t *)&existing_glance,
sizeof(existing_glance)) | ;
if ((rv == S_SUCCESS) && (serialized_glance->creation_time <= existing_glance.creation_time)) {
PBL_LOG(LOG_LEVEL_WARNING,
"Tried to insert AppGlanceDB entry with older creation_time (%"PRIu32")"
" than existing entry (%"PRIu32")", serialized_glance->creation_time,
existing_g... |
/*
* 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... | {
greater++;
if (value < min_gt_guess) {
min_gt_guess = value;
}
} | else {
equal++;
}
}
if (less <= ((num_values + 1) / 2) && greater <= ((num_values + 1) / 2)) {
break;
} else if (less > greater) {
max = max_lt_guess;
} else {
min = min_gt_guess;
}
}
if (less >= ((num_values + 1) / 2)) {
return max_lt_guess;
} else if ((l... |
N_SIZE + 1);
prv_populate_uptime_string(info);
sniprintf(info->language_string, sizeof(info->language_string),
"%s, v%u", i18n_get_locale(), i18n_get_version());
info->subtitle_text[SystemInformationItemBtAddress] = info->bt_mac_addr;
info->subtitle_text[SystemInformationItemFirmware] = (char*)... | (FONT_KEY_GOTHIC_18) | |
text_layer_set_line_spacing_delta(text_layer, -1);
text_layer_enable_screen_text_flow_and_paging(text_layer, 8);
#endif
int32_t text_content_height = text_layer_get_content_size(ctx, text_layer).h;
text_content_height += 4; // See PBL-1741
text_layer_set_size(text_layer, GSize(w, text_content_height));
uin... | (GAlignCenter, GAlignTop) | ,
.colors.foreground = dialog->text_color,
.colors.background = dialog->window.background_color,
});
}
}
dialog_load(dialog);
}
static void prv_expandable_dialog_appear(Window *window) {
ExpandableDialog *expandable_dialog = window_get_user_data(window);
Dialog *dialog = expa... |
/ patch area used by the dialog BT ROM which must be loaded and comes directly
// after the 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... | if (cmd[0] == 'L' && cmd[1] == 'D') {
prv_handle_load_data_command();
} else if (cmd[0] == 'V' && cmd[1] == 'T') {
prv_handle_vector_table_update_command();
} else if (cmd[0] == 'R' && cmd[1] == 'T') {
prv_handle_reboot_command();
} else {
debug_print_str("Unknown CMD:");
debug... |
}
}
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);
hw_gpio_set_pin_function(HOST_SPI->spi.cs_2.port, HOST_SPI->spi.cs_2.pin,
HW_GPI... |
= (i % 50);
if (delta > 25) {
delta = 50 - delta;
}
s_temp_readings[i] = 1600 + delta;
}
#endif
// Draw the last bunch that fit in the window
int first_idx = (int)READ_HISTORY_ENTRIES - PLOT_WIDTH;
first_idx = MAX(first_idx, 0);
// Get the min and max
bool first_valid = true;
int firs... | (data->window, &(WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
}) | ;
app_window_stack_push(data->window, true /* Animated */);
}
// -------------------------------------------------------------------------------
static void s_main(void) {
init();
app_event_loop();
deinit();
}
// -------------------------------------------------------------------------------
const PebblePr... |
},
{ 160, 896, -144},
{ 160, 864, -144},
{ 152, 992, -136},
{ 184, 1040, -152},
{ 136, 1088, -200},
// 229 seconds
{ 56, 1016, -304},
{ 32, 1184, -512},
{ -48, 824, -408},
{ 40, 648, -584},
{ -56, 256, -536},
{ -128, -80, -224},
{ 24, -616, -432},
{ 96, -912, -584... | { 56, -544, -856},
{ 56, -544, -856},
{ 56, -528, -864},
{ 56, -528, -872},
{ 56, -528, -872},
{ 40, -536, -856},
{ 56, -536, -864},
{ 56, -528, -864},
{ 40, -536, -864},
{ 56, -528, -864},
{ 48, -528, -864},
{ 48, -528, -864},
{ 48, -528, -872},
{ 48, -528, -856}... |
{ 112, 632, -704},
{ 168, 680, -704},
{ 288, 832, -648},
{ 320, 752, -344},
{ 288, 824, -136},
{ 144, 608, -184},
{ 8, 624, -256},
{ -112, 552, -496},
{ -168, 504, -480},
{ -232, 632, -416},
{ -240, 720, -456},
{ -232, 640, -560},
{ -176, 656, -552},
{ -304, 784,... |
yName];
ancs_app_name_storage_store(app_id, app_name);
fail:
prv_put_ancs_message(app_attrs);
prv_reset_and_next();
}
// -----------------------------------------------------------------------------
// Get Notification Attributes request
static void prv_add_attributes_to_request(Buffer *request_buffer) {
sta... | prv_set_state(ANCSClientStateRetrying) | ;
evented_timer_register(ANCS_RETRY_TIME_MS, false, prv_reset_and_retry, NULL);
}
}
}
static void prv_handle_notification_attributes_response(const uint8_t *data, size_t length) {
// Skip past the header, don't need it (for now):
data += sizeof(GetNotificationAttributesMsg);
length -= sizeof(GetNotif... |
s that will be erased when the log buffer fills.
//
// On each boot, we create a file to hold all the messages for that boot. This
// file is called a log generation or log.
//
// Within each eraseable unit multiple 'pages' exist. A log generation can span
// one or more pages. Multiple log generations can be stored at... | ((LOG_REGION_SIZE % LOG_PAGE_SIZE) == 0,
"The log page size must be divisible by the log region size") | ;
_Static_assert(((FLASH_REGION_DEBUG_DB_END % ERASE_UNIT_SIZE) == 0) &&
((FLASH_REGION_DEBUG_DB_END % ERASE_UNIT_SIZE) == 0),
"Space for flash logging must be aligned on an erase region boundary");
_Static_assert(LOG_PAGE_SIZE <= ERASE_UNIT_SIZE,
"Log pages must fit within an erase unit");
_Static_assert(... |
C_ACCEL_DOUBLE_TAP_COUNT, AnalyticsClient_System);
state->double_tap_handler(e->accel_tap.axis, e->accel_tap.direction);
}
// -----------------------------------------------------------------------------------------------
// Handle a chunk of data received for a data subscription. Called by prv_do_data_handle.
stat... | sys_accel_manager_data_subscribe(
sampling_rate, prv_do_data_handle, state, handler_task) | ;
accel_session_set_samples_per_update((AccelServiceState *)state, samples_per_update);
}
// ----------------------------------------------------------------------------------------------
void accel_data_service_subscribe(uint32_t samples_per_update, AccelDataHandler handler) {
AccelServiceState * session = acce... |
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 in writing, software
... | (HealthMetricSleepRestfulSeconds) | ;
APP_LOG(APP_LOG_LEVEL_INFO, "worker: New sleep event: total: %"PRIu32", restful: %"PRIu32" ",
total_sleep / SECONDS_PER_MINUTE, restful_sleep / SECONDS_PER_MINUTE);
}
}
// -----------------------------------------------------------------------------------------------
int main(void) {
APP_LOG(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... | cl_assert_(false, "No gatt_client_subscriptions_subscribe() has happened at all") | ;
}
s_subscribe_head = (Subscribe *) list_pop_head(&s_subscribe_head->node);
}
|
_mark();
fake_malloc_set_largest_free_block(sizeof(GATTClientSubscriptionNode));
BTErrno e = gatt_client_subscriptions_subscribe(prv_get_indicatable_characteristic(),
BLESubscriptionIndications,
GAPLEClientKernel);
... | (characteristic, BLESubscriptionIndications,
GAPLEClientApp) | ;
cl_assert_equal_i(e, BTErrnoOK);
// Should not be written again, because BLESubscriptionIndications was already written:
cl_assert_equal_i(s_last_cccd_value, (uint16_t) ~0);
fake_event_clear_last();
// Simulate getting confirmation from remote:
prv_confirm_cccd_write(BLEGATTErrorSuccess);
// Expect o... |
/*
* 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_mfg_mode_entered) | ;
}
void test_getting_started_button_combo__push_combo_and_release_one(void) {
// Up (nothing) -> Up+Select (mfg) -> Up (nothing) -> Up+Select (mfg)
prv_press_button(BUTTON_ID_UP);
prv_press_button(BUTTON_ID_SELECT);
prv_release_button(BUTTON_ID_SELECT);
// We should have cancelled the timer
cl_assert(!... |
smart = config.is_smart,
};
memcpy(&config_out->scheduled_days, config.scheduled_days, sizeof(config.scheduled_days));
return true;
}
return false;
}
// ----------------------------------------------------------------------------------------------
static void prv_alarm_set_config(SettingsFile *file, A... | (&file, id, &config) | ;
if (!rv) {
goto cleanup;
}
if (!callback(id, &config, context)) {
goto cleanup;
}
prv_enable_alarm_config(&config, true /* enabled */);
prv_alarm_set_config(&file, id, &config);
cleanup:
prv_file_close_and_unlock(&file);
}
// ------------------------------------------------------------------... |
/*
* 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_session, msg, length) | ;
}
// Tests
////////////////////////////////////
void test_launcher_app_message__initialize(void) {
launcher_app_message_reset();
s_last_cmd = APP_RUN_STATE_INVALID_COMMAND;
fake_comm_session_init();
s_transport = fake_transport_create(TransportDestinationSystem, NULL, NULL);
s_session = fake_transport_se... |
out_service_start_workout(ActivitySessionType_Run));
// Start with only 10 steps and make sure it updates.
prv_inc_steps_and_put_event(10);
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal... | cl_assert(workout_service_start_workout(ActivitySessionType_Run)) | ;
// Workout of 120 seconds duration. Should be valid
prv_inc_time(2 * SECONDS_PER_MINUTE);
cl_assert(workout_service_stop_workout());
prv_inc_time(2 * SECONDS_PER_MINUTE);
workout_service_frontend_closed();
cl_assert_equal_b(s_hrm_subscribed, true);
cl_assert_equal_i(s_hrm_expiration, 8 * SECONDS_PER_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... | cl_assert(!nexmo_is_reauth_sms(bad_app_id, expected_message)) | ;
cl_assert(!nexmo_is_reauth_sms(expected_app_id, bad_message));
cl_assert(!nexmo_is_reauth_sms(bad_app_id, bad_message));
}
void test_nexmo__handle_reuath_sms(void) {
// UID
const uint32_t uid = 42;
s_expected_uid = uid;
// App ID
uint8_t app_id_buf[128];
ANCSAttribute *app_id = (ANCSAttribute *)&app... |
&bpm, &hr_zone));
cl_assert_equal_i(bpm, 100);
// Put an OffWrist reading. Verify we received it.
prv_put_bpm_event(50, HRMQuality_OffWrist);
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone... | workout_service_start_workout(ActivitySessionType_Run) | );
// Workout of 30 seconds duration. Should be invalid, not keep HR on after leaving
prv_inc_time(30);
cl_assert(workout_service_stop_workout());
workout_service_frontend_closed();
cl_assert_equal_b(s_hrm_subscribed, false);
cl_assert_equal_i(s_hrm_expiration, 0);
}
// -----------------------------------... |
(180),GCornerBottomLeft},
.full_quadrants = GCornersLeft,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerTopRight}
}));
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(270), TO_TRIG(360 + 90)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerT... | prv_calc_draw_config_ellipsis(TO_TRIG(360 + 90 + 45), TO_TRIG(360 + 360 + 45)) | , ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90 + 45),GCornerBottomRight},
.full_quadrants = GCornersLeft,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(45),GCornerTopRight}
}));
// ## Section with negative angles
// Within same quadrant
cl_assert_equal_edc(prv_cal... |
/*
* 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... | prv_setup_data(bounds) | ;
}
static void prv_test_radial(Layer *layer, GContext* ctx) {
GColor color = { .argb = (uint8_t) rand() };
graphics_context_set_fill_color(ctx, color);
graphics_fill_radial(ctx, rect, GOvalScaleModeFillCircle, inset, angle_start, angle_end);
}
static void prv_test_circle(Layer *layer, GContext* ctx) {
GColor... |
/*
* 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... | (0b00111111, BITS_BETWEEN(0, 5)) | ;
cl_assert_equal_i(0b00111000, BITS_BETWEEN(3, 5));
cl_assert_equal_i(0b00010000, BITS_BETWEEN(4, 4));
}
// Flash memory is organized into twelve sectors of unequal sizes.
// Sectors 0-3 are 16 KiB. Sector 4 is 64 KiB.
// The remaining sectors are 128 KiB.
// Bitset of sectors that have been "erased"
static uint... |
/*
* 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... | GSize(DISP_COLS, DISP_ROWS) | ;
framebuffer_init(&s_framebuffer, &fb_size);
framebuffer_clear(&s_framebuffer);
s_state = CompositorState_App;
s_deferred_render = (DeferredRender) {
.animation.pending = false,
.app.pending = false
};
s_animation_state = (CompositorTransitionState) { 0 };
s_framebuffer_frozen = false;
}
// ... |
if (!data->alarm_info.is_smart && !activity_prefs_tracking_is_enabled()) {
// Notify about Health and keep the menu open
health_tracking_ui_feature_show_disabled();
return;
}
#endif
alarm_set_smart(data->alarm_id, !data->alarm_info.is_smart);
if (data->alarm_editor_callback) {
data->alarm_editor_... | ("Change Time", data) | ,
.perform_action = prv_edit_time_handler,
.action_data = data,
};
main_menu->items[DetailMenuItemIndexChangeDays] = (ActionMenuItem) {
.label = i18n_get("Change Days", data),
.perform_action = prv_edit_day_handler,
.action_data = data,
};
#if CAPABILITY_HAS_HEALTH_TRACKING
main_menu->items[... |
item_size);
}
kernel_free(item_buf);
}
BlobDBSyncSession* prv_create_sync_session(BlobDBId db_id, BlobDBDirtyItem *dirty_list,
BlobDBSyncSessionType session_type) {
BlobDBSyncSession *session = kernel_zalloc_check(sizeof(BlobDBS... | (session->db_id) | ;
if (session->dirty_list) {
prv_send_writeback(session);
} else {
PBL_LOG(LOG_LEVEL_INFO, "Finished syncing db %d, session type: %d", session->db_id,
session->session_type);
if (regular_timer_is_scheduled(&session->time... |
OK) {
return s_write_return_value;
}
Write *write = malloc(sizeof(Write));
uint8_t *buffer;
if (value_length) {
cl_assert(value);
buffer = malloc(value_length);
memcpy(buffer, value, value_length);
} else {
cl_assert_equal_p(value, NULL);
buffer = NULL;
}
*write = (const Write) {
... | (memcmp(value, s_write_head->value, value_length), 0) | ;
cl_assert_equal_i(client, s_write_head->client);
cl_assert_equal_b(is_response_required, s_write_head->is_response_required);
} else {
fake_gatt_client_op_assert_write_failed();
}
Write *old_write = s_write_head;
s_write_head = (Write *) list_pop_head(&s_write_head->node);
free(old_write->value)... |
*new_tuple, const Tuple *old_tuple, void *context) {
cl_assert(CONTEXT == context);
switch (key) {
case SOME_INT8_KEY:
is_int8_updated = true;
cl_assert(should_update_existing_keys_only == false);
cl_assert(new_tuple->type == TUPLE_INT);
cl_assert(new_tuple->length == sizeof(int8_t));
... | while (tuple) {
switch (tuple->key) {
case SOME_DATA_KEY:
has_tuple[DATA_IDX] = true;
cl_assert(tuple->type == TUPLE_BYTE_ARRAY);
cl_assert(tuple->length == sizeof(SOME_DATA));
cl_assert(memcmp(tuple->value->data, SOME_DATA, sizeof(SOME_DATA)) == 0);
break... |
if (test_not_enough_storage || should_update_existing_keys_only) {
cl_assert(has_tuple[INT8_IDX] == false);
} else {
cl_assert(has_tuple[INT8_IDX] == true);
}
cl_assert(has_tuple[STRING_IDX] == true);
cl_assert(has_tuple[DATA_IDX] == true);
}
}
|
const uint32_t dialog_timeout_ms = use_simple_dialog ? DIALOG_TIMEOUT_DEFAULT :
DIALOG_TIMEOUT_INFINITE;
dialog_set_timeout(dialog, dialog_timeout_ms);
if (data->action_menu) {
action_menu_set_result_window(data->action_menu, &dialog->window);
} else ... | if (!prv_show_result_window_with_progress(data, icon, msg, success)) {
prv_cleanup_action_result(data, success);
} |
}
typedef struct {
TimelineItem *item;
void *event_ref;
bool standalone_action;
} ChainingWindowCBData;
static void prv_cleanup_chaining_action_menu(void *context) {
ChainingWindowCBData *data = context;
timeline_item_destroy(data->item);
event_service_free_claimed_buffer(data->event_ref);
applib_free(... |
->header.id);
}
static bool prv_item_init(TimelineItem *item, int num_attributes,
int num_actions, uint8_t attributes_per_action[], size_t required_size_for_strings,
uint8_t **string_buffer) {
if (num_actions > 0) {
PBL_ASSERTN(attributes_per_action != NULL);
}
const size_t alloc_size = attributes_... | prv_deep_copy_attributes_actions(&src->attr_list, &src->action_group, item_out) | ) {
timeline_item_destroy(item_out);
return NULL;
}
return item_out;
}
size_t timeline_item_get_serialized_payload_size(TimelineItem *item) {
PBL_ASSERTN(item);
return attributes_actions_get_serialized_payload_size(&item->attr_list, &item->action_group);
}
bool timeline_item_deserialize_item(Timeline... |
it.pbi");
cl_assert(test_image_bw != NULL);
test_image_color = get_gbitmap_from_pbi("test_rotated_bitmap_redstar.Xbit.pbi");
cl_assert(test_image_color != NULL);
}
void test_graphics_draw_rotated_bitmap__cleanup(void) {
free(fb);
if (test_image_bw) {
if (test_image_bw->addr) {
free(test_image_bw->... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_bw_set_corner_45.Xbit.pbi")) | ;
// Top-left center rotation point, Angle 45
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_bw,
GPoint(27, 40), DEG_TO_TRIGANGLE(45), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
... |
/*
* 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... | {
list_remove(&e->node, (ListNode **) &s_head, NULL);
free(e);
return 0;
} | else {
// Doesn't exist
++s_whitelist_error_count;
return -1;
}
}
bool fake_HCIAPI_whitelist_contains(const BTDeviceInternal *device) {
const WhitelistEntry model = {
.Address_Type = device->is_random_address ? 0x01 : 0x00,
.Address = BTDeviceAddressToBDADDR(device->address),
};
return (pr... |
olorWhite));
}
static void prv_opaque_2bit_simple(GCompOp compositing_mode) {
const int BITS_PER_PIXEL = 2;
const int PIXELS_PER_BYTE = (8 / BITS_PER_PIXEL);
const int WIDTH = 4;
const int HEIGHT = 4;
const int ROW_STRIDE = (WIDTH + (PIXELS_PER_BYTE - 1)) / PIXELS_PER_BYTE;
uint8_t s_data[ROW_STRIDE * HEI... | prv_opaque_2bit_simple(GCompOpAssign) | |
------------------------------------------------------
// Count how many entries were entered for the given animation
static uint32_t prv_count_handler_entries(AnimTestHandlerHistory *history, Animation *animation) {
uint32_t count = 0;
for (int i = 0; i < history->num_calls; i++) {
if (!animation || history-... | prv_now_ms() | , (int)animation);
}
// --------------------------------------------------------------------------------------
// update handler
// implemented in Animation.c
AnimationPrivate *prv_animation_get_current(void);
void prv_update_handler(Animation *animation, const AnimationProgress distance) {
// always ensure that a... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (0, 0x1000000) | ;
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */);
resource_init();
prv_initialize_icons();
}
void test_menu_layer_system_cells__cleanup(void) {
free(fb);
fb = NULL;
gbitmap_deinit... |
#define ABSOLUTE_VALUE(x) (((x) > 0) ? (x) : -(x))
#define MIN_FRAME_INTERVAL_MS 33
#define TEST_ANIMATION_NORMALIZED_HIGH 50000
#define TEST_ANIMATION_NORMALIZED_LOW 5000
static PebbleEvent s_last_event;
bool process_manager_send_event_to_process(PebbleTask task, PebbleEvent* e) {
s_last_event = *e;
return t... | DPRINTF("timer not scheduled\n") | ;
return;
}
// Advance time
uint32_t ms_delta = stub_new_timer_timeout(sys_timer_id);
prv_advance_by_ms_no_timers(ms_delta);
// This posts a callback event to the KernelMain event queue
stub_new_timer_fire(sys_timer_id);
// Get the callback event and process it
PebbleEvent evt = fake_event_get_la... |
/*
* 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... | info->get_val(file, &hdr, sizeof(SerializedTimelineItemHeader)) | ;
// Restore flags & status
hdr.common.flags = ~hdr.common.flags;
hdr.common.status = ~hdr.common.status;
if (uuid_equal(&find_info->parent_id, &hdr.common.parent_id)) {
find_info->children_ids[find_info->num_children++] = hdr.common.id;
}
// continue iterating if more children are expected and we want... |
he License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distr... | if (buffer >= buffer_end) {
args.num_args = i;
return args;
} |
// Yay, a param!
args.args[i] = buffer;
// Skip over the param and set us up for the next one.
while (buffer < buffer_end && *buffer != ' ') {
++buffer;
}
*(buffer++) = 0;
}
args.num_args = NUM_SUPPORTED_PARAM_COUNT;
return args;
}
static void prv_execute_given_command(const Com... |
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 MusicAppSizeConfig *config = prv_config();
return GRect(config->horizontal_margi... | {
data->volume_icon_timer = app_timer_register(VOLUME_ICON_TIMEOUT_MS,
prv_handle_volume_icon_timer, data);
} |
prv_trigger_cassette_icon_switch(bitmap, true);
}
static void prv_change_volume(bool volume_is_up) {
if (!music_is_command_supported(MusicCommandVolumeUp) ||
!music_is_command_supported(MusicCommandVolumeDown)) {
return;
}
MusicAppData *data = app_state_get_user_data();
prv_show_volume_image(volu... |
+ 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);
const GPoint left_b = GPoint(origin.x, origi... | {
graphics_draw_round_rect(ctx, &rect, radius);
} |
void graphics_context_init(GContext *context, FrameBuffer *framebuffer,
GContextInitializationMode init_mode) {
PBL_ASSERTN(context);
PBL_ASSERTN(framebuffer);
*context = (GContext) {
// For apps, this is run before the app has a chance to run, so there's no concern here of 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... | (s_reports_buffer) | ;
s_reports_buffer = NULL;
s_is_scanning = false;
if (s_dropped_reports) {
PBL_LOG(LOG_LEVEL_INFO, "LE Scan -- Dropped reports: %" PRIu32, s_dropped_reports);
}
}
}
bt_unlock();
return success;
}
// -----------------------------------------------------------------------------... |
t_remote_param_mgmt_settings_cmd(
const PebblePairingServiceRemoteParamMgmtSettings *settings, size_t length) {
if (length < sizeof(PebblePairingServiceRemoteParamMgmtSettings)) {
return ATT_ERROR_INVALID_VALUE_LENGTH;
}
bool has_param_set =
(length >= PEBBLE_PAIRING_SERVICE_REMOTE_PARAM_MGTM_SETTIN... | {
hc_endpoint_pebble_pairing_service_send_conn_params(connection, conn_params, evt->length);
} | else if (rv == ATT_ERROR_INVALID_VALUE_LENGTH) {
PBL_LOG(LOG_LEVEL_ALWAYS, "Invalid value length %"PRIu16, evt->length);
}
return rv;
}
static void prv_pps_handle_write_request(ble_service_t *svc, const ble_evt_gatts_write_req_t *evt) {
att_error_t rv = ATT_ERROR_INVALID_HANDLE;
if (evt->handle == s_pps_c... |
&hold_down_timeout_ms)) {
goto error;
}
// If delay_between_presses_ms is NULL then default to 0 milliseconds
// Otherwise convert the char string to an integer; error if the converted value is negative
uint32_t delay_between_presses_timeout_ms;
if (!prv_convert_and_validate_timeout_value(delay_b... | (message->log_level) | ,
time_t_to_string(time_buffer, htonl(message->timestamp)),
message->filename,
(int)htons(message->line_number),
message->message);
return true;
}
static void prv_serial_dump_completed_callback(bool success) {... |
ror"), 17);
}
void test_sprintf__percent_d(void) {
char dstbuf[256];
// Simple %d
snprintf(dstbuf, 256, "There are %d lights, %d", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// Alternate form
snprintf(dstbuf, 256, "There are %#d lights, %#d", 4, -4);
cl_assert_equal_s(dstbuf, "There a... | snprintf(dstbuf, 256, "There are %+i lights, the absolute value of %+i", 4, -4) | |
/*
* 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... | check_atan2(234, -253) | |
render_sleep_sessions(ctx, data);
prv_render_typical_markers(ctx, data);
// This is required to get the rounded corners on the outside of the rectangle
graphics_context_set_stroke_width(ctx, 2);
graphics_context_set_stroke_color(ctx, CARD_BACKGROUND_COLOR);
graphics_draw_round_rect(ctx, &s_sleep_summary_mas... | health_sleep_detail_card_destroy(window) | ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// API Functions
//
Layer *health_sleep_summary_card_create(HealthData *health_data) {
// create base layer
Layer *base_layer = layer_create_with_data(GRectZero, sizeof(HealthSleepSummaryCardData));
HealthSl... |
nd(void) {
prv_send_notification((uint8_t *)&memory_with_attribute_id_at_end.attribute_data);
cl_assert_equal_i(s_num_requested_notif_attributes, 1 );
cl_assert_equal_i(s_num_ds_notifications_received, 2);
}
void test_ancs__app_name_cache(void) {
prv_send_notification((uint8_t *)&s_message_dict);
prv_send_no... | cl_assert_equal_i(fake_kernel_services_notifications_acted_upon_count(), 1) | ;
}
void test_ancs__notification_parsing(void) {
// Test a recognized app with a duplicated title
// Run multiple times to make sure we're not corrupting the app name cache
for (int i = 0; i < 4; ++i) {
prv_send_notification((uint8_t *)&s_app_name_title_dict);
prv_cmp_last_received_notification(&s_app_na... |
------------------------------------------------
// update handler
static void prv_update_handler(Animation *animation, const uint32_t distance) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Executing update handler for %d, distance: %d", (int)animation,
(int)distance);
}
// ---------------------------------------------... | animation_schedule(s_animation) | ;
}
static void config_provider(Window *window) {
window_single_click_subscribe(BUTTON_ID_UP, (ClickHandler) click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler) click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, (ClickHandler) click_handler);
}
static void init(void) {
w... |
/*
* 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... | {
prv_create_window_and_render(ActivitySessionType_Run);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
} | |
nt8_t *data, size_t length) {
// NOTE: this may be run within an ISR
prv_lock();
// When sending data, we need to temporarily disable input, as there's only one data line for
// both directions and any data we send on that line will also be interpreted as data we can
// read. This means there's a bit of overh... | prv_unlock() | ;
}
void accessory_set_power(bool on) {
if (on == s_power_enabled) {
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Setting accessory power %s", on?"on":"off");
s_power_enabled = on;
gpio_output_set(&BOARD_CONFIG_ACCESSORY.power_en, on);
}
bool accessory_is_present(void) {
accessory_set_power(true);
gpio_input... |
id) {
if (!s_initializing_storage) {
// The s_initializing_storage is only set during boot, when dls_storage_rebuild() is called.
// That is the only time we allow a task (KernelMain) other than KernelBG access to the storage
// functions.
PBL_ASSERT_TASK(PebbleTask_KernelBackground);
}
}
// -----... | dls_list_for_each_session(prv_accumulate_size_cb, &size) | ;
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Total used space: %d", (int)size);
return size;
}
// ----------------------------------------------------------------------------------------
// Compact all storage files. Used to free up space for new data.
static bool prv_compact_session_cb(DataLoggingSessi... |
_abort)
{
int match = (s1 == NULL || s2 == NULL) ? (s1 == s2) : (strcmp(s1, s2) == 0);
if (!match) {
char buf[4096];
snprint_eq(buf, 4096, "'%s' != '%s'", s1, s2);
clar__assert(0, file, line, err, buf, should_abort);
}
}
void clar__assert_equal_i(
int i1,
int i2,
const char *file,
int line,
... | (0, file, line, err, buf, should_abort) | |
istic_ref = (BLECharacteristic) data;
return (subscription->characteristic == characteristic_ref);
}
static GATTClientSubscriptionNode * prv_find_subscription_for_characteristic(
BLECharacteristic characteristic_ref,
... | if (subscription->pending_confirmation[client] && !is_cleaning_up) {
// Already a pending subscription in flight...
return BTErrnoInvalidState;
} |
previous_prevailing_type = prv_prevailing_subscription_type(subscription);
} else {
if (subscription_type == BLESubscriptionNone) {
// No subscription, so nothing to unsubscribe from...
return BTErrnoInvalidState;
}
// No subscriptions for the characteristic yet, go create one:
subscr... |
(session->reserved != 0) {
PBL_LOG(LOG_LEVEL_WARNING, "Invalid flags: %d", (int)session->reserved);
return false;
}
return true;
}
// ------------------------------------------------------------------------------------
// Return true if two activity sessions are equal in their type and start time
// @par... | (&state->activity_sessions[found_session_idx],
&state->activity_sessions[found_session_idx + 1],
num_to_move * sizeof(ActivitySession)) | |
/*
* 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... | {
record_mock_call(s_gpath_draw_filled) {
.path.num_points = path->num_points,
};
memcpy(s_gpath_draw_filled.last_call.path.points,
path->points, sizeof(path->points[0]) * path->num_points);
} |
void graphics_fill_rect(GContext *ctx, const GRect *rect) {}
void graphics_fill_round_rect_by_value(GContext *ctx, GRect rect, uint16_t corner_radius,
GCornerMask corner_mask) {}
void graphics_draw_rect_precise(GContext *ctx, const GRectPrecise *rect) {}
void graphics_fill_r... |
the License.
*/
#include <time.h>
#include "services/normal/wakeup.h"
#include "syscall/syscall.h"
#include "flash_region/flash_region.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/settings/settings_file.h"
#include "services/common/event_service.h"
#include "process_management/app_install... | sys_get_time() | + WAKEUP_EVENT_WINDOW, 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + WAKEUP_EVENT_WINDOW);
// Test that another event < 1 minute away fails to schedule (E_DOES_NOT_EXIST)
wakeup_id = sys_wakeup_schedule(sys_get_time() + WAKEUP_EVENT_WINDOW + 59, 0, false);
cl_assert_equal_i(sys_wa... |
erState* state = prv_subscriber_state(session);
if (!state) {
PBL_LOG(LOG_LEVEL_WARNING, "not subscribed");
result = -1;
goto unlock;
}
state->raw_buffer = buffer;
state->raw_buffer_size = buffer_size;
state->samples_per_update = samples_per_update;
state->num_samples = 0;
... | mutex_unlock_recursive(s_mutex) | ;
}
#ifdef TEST_KERNEL_SUBSCRIPTION
// -----------------------------------------------------------------------------------------------
static void prv_kernel_data_subscription_handler(AccelData *accel_data, uint32_t num_samples) {
PBL_LOG(LOG_LEVEL_INFO, "Received %d accel samples for KernelMain.", num_samples);
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.