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... | (text, i18n_owner) | |
allowed;
static PebbleEvent s_last_event_put;
bool battery_is_usb_connected_raw(void) {
return false;
}
void low_power_standby(void) {
s_entered_standby = true;
}
void low_power_exit(void) {
s_in_low_power = false;
}
void low_power_enter(void) {
s_in_low_power = true;
}
bool low_power_is_active(void) {
r... | battery_curve_lookup_voltage_by_percent(low_percent, true) | ;
fake_battery_init(high_mv, true, true);
battery_monitor_init();
periodic_timer_trigger(1);
// For the first sample, it will be identical
cl_assert_equal_i(battery_get_charge_state().charge_percent, high_percent);
// ...and should stay that way
periodic_timer_trigger(10);
cl_assert_equal_i(battery_g... |
activity_test_run_minute_callback();
minute_idx = samples_remaining / (60 * SAMPLES_PER_SECOND);
prv_clear_event_queue();
}
}
}
// -------------------------------------------------------------------------------
// Feed in N minutes of light sleep
static void prv_feed_light_sleep_min(uint32_t minut... | PBL_LOG(LOG_LEVEL_DEBUG, "start total: %d, start deep: %d", (int)before_total, (int)before_deep) | |
/*
* 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... | {
// Don't show relationship bar when event is across days
return RelationshipBarTypeNone;
} | |
rv_flash_send_and_receive_byte(FLASH_CMD_DUMMY);
return result;
}
static void prv_flash_wait_for_write_bounded(volatile int cycles_to_wait) {
prv_flash_start_cmd();
prv_flash_send_and_receive_byte(FLASH_CMD_READ_STATUS_REG);
uint8_t status_register = 0;
do {
if (cycles_to_wait-- < 1) {
break;
... | prv_flash_start_cmd() | |
ke_points, s_path_num_points));
cl_assert_equal_p(s_fill_points, NULL);
prv_reset();
// restore radius and set hidden - nothing should be drawn
gdraw_command_set_radius(command, 300);
gdraw_command_set_hidden(command, true);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColor... | (s_path_stroke_count, 0) | ;
cl_assert_equal_i(s_path_fill_count, 0);
cl_assert_equal_i(s_circle_stroke_count, 0);
cl_assert_equal_i(s_circle_fill_count, 0);
free(command_list);
}
void test_gdraw_command__validate_list(void) {
GDrawCommandList *command_list = prv_create_command_list_3();
size_t size = sizeof(GDrawCommandList) + (3 ... |
prv_touch_context_reset(TouchContext *ctx) {
ctx->state = TouchState_FingerUp;
prv_touch_queue_reset(ctx);
}
static bool prv_queue_is_full(TouchContext *ctx) {
return ctx->touch_queue.count == ARRAY_LENGTH(ctx->touch_queue.events);
}
// Note: Do not call if the queue count is zero
static uint32_t prv_get_idx_l... | if (ctx->update_cancelled) {
ctx->update_cancelled = false;
goto unlock;
} | |
box = *bounds;
if (icon_align == GAlignRight) {
left_margin = horizontal_margin;
box.size.w -= config->icon->bounds.size.w;
} else {
left_margin = !config->icon ? horizontal_margin :
config->icon_form_fit ? (left_margin + config->icon->bounds.size.w +
(config->i... | fonts_get_font_height(subtitle_font) | |
/*
* 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... | BITS_BETWEEN(0, 0) | |
ame), "file%d", num++);
fd = pfs_open(file_name, OP_FLAG_WRITE, FILE_TYPE_STATIC, sizeof(file_name));
cl_assert((fd >= 0) || (fd == E_OUT_OF_STORAGE));
if (fd == E_OUT_OF_STORAGE) {
break;
}
cl_assert_equal_i(pfs_close(fd), S_SUCCESS);
}
// the file system is full, lets delete a file
sn... | 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[i] = i;
}
rv = pfs_write(fd, NULL, sizeof(buf));
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(fd, buf, sizeof(buf) / 2);
int off = s... |
G_LEVEL_DEBUG, "->IN");
PBL_HEXDUMP(LOG_LEVEL_DEBUG, (uint8_t *)&remote_status_in, sizeof(remote_status_in));
prv_core_dump();
}
HOST_TRANSPORT_DEBUG_LOG("Local Status: %u bytes sendable, %u bytes receivable",
local_status_out.bytes_sendable_count,
... | HOST_TRANSPORT_DEBUG_LOG("prv_host_transport_main loop unblocked, about to read..") | ;
spi_device dev = ad_spi_open(PEBBLE_HOST);
ad_spi_device_acquire(dev);
host_transport_configure_spi_scs_pin(SCSPinFunction_SPI_CS);
while (prv_transact(dev)) {};
// Re-enable interrupt handling before processing,
// so that endpoint handlers can cause the loop to get unblocked immediately:... |
ither express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "layout_node.h"
#include "timeline_layout.h"
#include "kernel/pbl_malloc.h"
#include "services/common/i18n/i18n.h"
#include "system/passert.h"
#include "util/size.h"
#include... | (text_node, layout, &config->text) | |
NAME}__init(void) {
GTransform t;
GTransform t_c; // matrix to compare against
// Test Identity Matrix
t = GTransformIdentity();
t_c = GTransformFromNumbers(1, 0, 0, 1, 0, 0);
cl_assert(gtransform_is_equal(&t, &t_c));
cl_assert(gtransform_is_identity(&t));
cl_assert(gtransform_is_identity(&t_c));
/... | GTransformFromNumbers(10, 20, 600, 800, 5, 6) | ;
gtransform_scale(&t_new, &t1, GTransformNumberFromNumber(10), GTransformNumberFromNumber(200));
cl_assert(gtransform_is_equal(&t_new, &t_c));
cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has not changed
gtransform_scale_number(&t_new, &t1, 10, 200);
cl_assert(gtransform_is_equal(&t_new, &t_c));
... |
tations under the License.
*/
#include <stdbool.h>
#include <stdint.h>
#include "board/board.h"
#include "drivers/flash.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "util/delay.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_qspi.h"
#define MX25U_FASTREAD_DUMMYCYCLES 4
typedef enum ... | for (unsigned i = 0; i < QSpiPinCount; ++i) {
gpio_af_init(&BOARD_CONFIG_FLASH_PINS[i], GPIO_OType_PP, GPIO_Speed_100MHz, GPIO_PuPd_NOPULL);
} |
// Init QSPI peripheral
QSPI_InitTypeDef qspi_config;
QSPI_StructInit(&qspi_config);
qspi_config.QSPI_SShift = QSPI_SShift_HalfCycleShift;
qspi_config.QSPI_Prescaler = 0x0;
qspi_config.QSPI_CKMode = QSPI_CKMode_Mode0;
qspi_config.QSPI_CSHTime = QSPI_CSHTime_1Cycle;
qspi_config.QSPI_FSize = 22; // 2^23... |
/*
* 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_emoji_table, "👍\xf0\x9f\x8f\xbe") | |
nclude <string.h>
#include "clar.h"
#include "drivers/system_flash.h"
#define KiB *1024
// Set bits n..0 in a bit-vector (zero-indexed)
#define BITS(n) ((((uint32_t)(1 << ((n) + 1)))) - 1)
// Set bits y..x in a bit-vector (x <= y; x, y >= 0)
#define BITS_BETWEEN(x, y) (BITS(y) & ~BITS(x-1))
// Yo dawg, I heard you... | {
flash_data_length = size;
flash_written_data = malloc(size * sizeof(uint8_t));
cl_assert(flash_written_data);
flash_written_flag = malloc(size * sizeof(bool));
cl_assert(flash_written_flag);
} |
void assert_flash_unwritten(uint32_t start, uint32_t length) {
for (uint32_t i = 0; i < length; ++i) {
cl_assert(flash_written_flag[start + i] == false);
}
}
void test_system_flash__write_simple(void) {
const char testdata[] = "The quick brown fox jumps over the lazy dog.";
malloc_flash_data(100);
flas... |
_handlers = {
.started = NULL,
.stopped = prv_next_level_anim_stopped,
};
AnimationContext *anim_ctx = applib_type_malloc(AnimationContext);
*anim_ctx = (AnimationContext) {
.window = &data->action_menu.window,
.next_level = level,
};
animation_set_handlers(content_out, anim_handlers, anim_c... | {
if (!action_menu) return NULL;
ActionMenuData *data = window_get_user_data(&action_menu->window);
return (ActionMenuLevel *)data->config.root_level;
} | |
nimation->implementation->teardown(animation->handle);
}
animation->did_setup = false;
}
animation->calling_end_handlers = false;
#ifdef UNITTEST
// Make sure this animation didn't get deleted as a side effect of running the stopped handler
PBL_ASSERTN(list_contains(state->unscheduled_head, &animation-... | (state, animation, child_idx) | ;
if (!child) {
break;
}
uint32_t duration = prv_get_total_duration(state, child, true /*delay*/, true /*play_count*/);
// It is allowed that the first child may have already been scheduled and played a bit. If
// this is the case, backup the start time by reducing delay according... |
cl_assert(num.integer == -1);
cl_assert(num.fraction == 4);
test_num = (int32_t)((float)-0.375 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 5);
test_num = (int32_t)((float)-0.250 * (1 << FIXED_S16_3_PRECISION));
... | Fixed_S16_3(4) | ));
cl_assert_equal_i(1, Fixed_S16_3_rounded_int(Fixed_S16_3(8)));
cl_assert_equal_i(2, Fixed_S16_3_rounded_int(Fixed_S16_3(12)));
cl_assert_equal_i(0, Fixed_S16_3_rounded_int(Fixed_S16_3(-3)));
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-4)));
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixe... |
,
{ 248, -168, -872},
{ 352, -112, -992},
{ 200, -88, -944},
{ 264, -80, -904},
{ 144, -112, -864},
{ 184, -64, -896},
{ 200, 96, -1072},
{ 160, 160, -1008},
{ 200, 120, -968},
{ 152, 88, -944},
{ 208, 96, -952},
{ 304, 72, -968},
{ 160, 0, -896},
{ 136, -40, -848... | { 168, -72, -952},
{ 120, -128, -912},
{ 160, 24, -1008},
{ 272, 120, -1056},
{ 280, 96, -976},
{ 152, 72, -896},
{ 88, 8, -888},
{ 184, 48, -976},
// 70 seconds
{ 216, 200, -968},
{ 232, 96, -912},
{ 176, 16, -872},
{ 152, -40, -880},
{ 144, -8, -904},
{ 120,... |
{ 168, 104, -952},
{ 144, 80, -944},
{ 136, 56, -904},
{ 104, 64, -912},
{ 136, 96, -920},
{ 216, 120, -960},
{ 208, 96, -936},
{ 168, 64, -928},
{ 184, 80, -928},
{ 168, 72, -928},
{ 152, 56, -912},
{ 176, 72, -952},
{ 184, 32, -928},
{ 176, 48, -928},
{ 232... |
except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF AN... | (e.app_cache_event.install_id, app3.id) | ;
cl_assert_equal_i(fake_event_get_count(), 2);
// ensure the only one remaining is the one evicted
cl_assert_equal_i(app2.id, app_cache_get_next_eviction());
cl_assert_equal_i(fake_event_get_count(), 2);
}
/*************************************
* Add 3, update 2, evict 1 *
********************************... |
432, -848},
{ -120, 592, -928},
{ -168, 464, -816},
{ -144, 448, -936},
{ -192, 488, -928},
{ -120, 592, -840},
{ -128, 416, -952},
{ -104, 512, -864},
{ -112, 424, -936},
{ -96, 504, -840},
{ -80, 448, -928},
{ -112, 440, -840},
{ -120, 448, -1048},
{ -160, 496, -82... | { -128, 448, -888},
{ -128, 504, -960},
{ -128, 608, -1008},
{ -176, 496, -928},
{ -176, 488, -944},
{ -184, 624, -912},
{ -152, 528, -896},
{ -144, 544, -976},
{ -112, 408, -904},
{ -136, 552, -952},
// 127 seconds
{ -128, 504, -896},
{ -128, 504, -848},
{ -112, ... |
{ -144, 120, -1072},
{ -160, 160, -1008},
{ -160, 168, -1008},
{ -144, 112, -1056},
{ -136, 160, -1016},
{ -152, 152, -1024},
{ -136, 216, -1040},
{ -144, 192, -1016},
{ -160, 200, -1032},
{ -168, 200, -1016},
{ -152, 232, -936},
{ -144, 160, -1064},
{ -192, 200, -99... |
/*
* 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... | (&app_notif_prefs->attr_list, AttributeIdMuteDayOfWeek) | |
/*
* 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 (length < DIRTY_DATABASES_LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a dirty databases with an invalid length: %"PRIu32"", length);
return;
} |
struct PACKED DirtyDatabasesResponseMsg {
BlobDBCommand cmd;
BlobDBToken token;
BlobDBResponse result;
uint8_t num_ids;
BlobDBId db_ids[NumBlobDBs];
} response = {
.cmd = BLOB_DB_COMMAND_DIRTY_DBS_RESPONSE,
.token = *(BlobDBToken *)data,
.result = BLOB_DB_SUCCESS,
};
blob_db_... |
div = enc_info->ediv;
memcpy(ltk->key, enc_info->ltk.data, sizeof(ltk->key));
ltk->key_size = sizeof(ltk->key);
return ltk;
}
void bonding_sync_handle_hc_add(const BleBonding *bonding) {
storage_acquire();
const SMPairingInfo *info = &bonding->pairing_info;
bd_address_t addr;
dialog_utils_bt_device_to_bd... | dialog_utils_bd_address_to_bt_device(&dev->addr, &info->identity) | ;
}
info->is_mitm_protection_enabled = dev->mitm;
bonding.is_gateway = connection_is_gateway(connection);
if (connection_should_pin_address(connection)) {
bonding.should_pin_address = true;
connection_get_local_address(connection, &bonding.pinned_address);
}
BleBondingFlag flags = ... |
{ "McuTim3", 0, 0, false},
[PowerSystemMcuTim4] = { "McuTim4", 0, 0, false},
[PowerSystemMcuUsart1] = { "McuUsart1", 0, 0, false},
[PowerSystemMcuUsart3] = { "McuUsart3", 0, 0, false},
[PowerSystemMcuI2C1] = { "McuI2C1", 0, 0, false},
[PowerSystemMcuI2C2] = { ... | {
PBL_LOG(LOG_LEVEL_WARNING, "Stop ticks before start called: probably losing profile accuracy in %s", current_profile->name);
// Someone was careless: two cases:
// 1) someone forgot to call start
// 2) someone re-entered a function that called stop already, so it is called twice.
return;
} |
current_profile->total_ticks += (rtc_get_ticks() - current_profile->start_ticks);
current_profile->start_ticks = 0;
}
#endif // SW_POWER_TRACKING
|
buted on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/app.h"
#include "applib/app_timer.h"
#include "applib/fonts/fonts.h"
#include "applib/grap... | {
graphics_context_set_stroke_color(ctx, i ? GColorWhite : GColorWhite);
graphics_draw_line(ctx, (GPoint) {.x = mid_pixel_minus_one + i, .y = pixel_min},
(GPoint) {.x = mid_pixel_minus_one + i, .y = pixel_min + TICK_LENGTH});
graphics_draw_line(ctx, (GPoint) {.x = mid_pixel_minu... |
}
static void prv_draw_border_stripes(Layer *layer, GContext *ctx) {
AppData *data = app_state_get_user_data();
const GRect *bounds = &data->window.layer.bounds;
const int pixel_min = bounds->origin.x;
const int pixel_max = bounds->origin.x + bounds->size.w - 1;
for (int j = 0; j < 2; j++) {
graphics_... |
ion_cb(ctx, line, text_box_params)) {
break;
}
}
if (!is_text_remaining) {
break;
}
// Shouldn't have rendered the line if there was insufficient space
PBL_ASSERTN(iter_next(line_iter));
}
}
////////////////////////////////////////////////////////////
// Text layout
//! @re... | (word_iter_state->ctx, line, &next_word,
word_iter_state->text_box_params) | ;
if (!is_added) {
word_iter_state->current = next_word;
// Check if word was trimmed until the null termination
if (next_word.start == NULL) {
is_text_remaining = false;
} else {
is_text_remaining = true;
}
break;
}
is_text_remaining = iter_next(word_it... |
layer_deinit(&launcher_menu_layer->container_layer) | ;
}
| |
= clip_min_y + ctx->draw_state.clip_box.size.h;
const int16_t y_min = CLIP(top_point >> FIXED_S16_3_PRECISION, clip_min_y, clip_max_y);
const int16_t y_max = CLIP(bottom_point >> FIXED_S16_3_PRECISION, clip_min_y, clip_max_y);
// Blending of first line
if (fraction_for_top != 0) {
int16_t y = y_... | if (fraction_for_bottom != 0) {
int16_t y = y_max + 1;
// Starting and ending point of the line, initialized with extremes
Fixed_S16_3 left_margin = {.raw_value = INT16_MAX};
Fixed_S16_3 right_margin = {.raw_value = INT16_MIN};
// Find edges for bottom cap
GPointPrecise bottom_poin... |
} else {
// PBL-14798: refactor this.
// Top and bottom most point helpers for main loop
GPointPrecise tm_p0 = far_left;
GPointPrecise tm_p1 = far_top;
GPointPrecise bm_p0 = far_left;
GPointPrecise bm_p1 = far_bottom;
const int8_t fraction_for_left = (MIN(p0.x.raw_value, p1.x.raw_value) ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | list_find(state->scheduled_head, prv_handle_list_filter, (void*)handle) | ;
}
if (!node) {
if (!quiet) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Animation %d does not exist", (int)handle);
}
return NULL;
}
return (AnimationPrivate *)node;
}
// -------------------------------------------------------------------------------------------
// Find animation by parent and child id... |
nfo_out,
char *name_out, bool *requires_address_pinning_out,
uint8_t *flags) {
SharedPRFData data;
prv_fetch_struct(&data);
const BLEPairingData *ble_data = &data.ble_data;
bool result = false;
if (!ble_data->is_local_... | prv_shared_prf_reschedule_writeback_timer() | ;
}
prv_unlock_pending_bonding();
#endif
}
void shared_prf_storage_erase_ble_pairing_data(void) {
BLEPairingData empty_data = {};
// Call the version that doesn't do a flash erase because we are only writing zeros.
prv_update_and_cleanup_struct_no_erase(&empty_data, sizeof(empty_data),
... |
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 writing, softw... | (GRect(10, 40, 30, 0), grect_inset_internal(rect, 0, 20)) | |
ey, key_len, val, val_len);
}
void test_settings_file__set_get_one(void) {
printf("\nTesting setting and retreiving a single key a single time...\n");
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_set_get_one", 4096));
uint8_t key[4];
int key_len = sizeof(key) - 1;
memcpy(key, "key",... | prv_print_stats(&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... | {
return &s_connection;
} |
GAPLEConnection *gap_le_connection_by_addr(const BTDeviceAddress *addr) {
return &s_connection;
}
GAPLEConnection *gap_le_connection_by_gatt_id(unsigned int connection_id) {
return &s_connection;
}
bool gap_le_connection_is_valid(const GAPLEConnection *conn) {
return true;
}
GAPLEConnection *gap_le_connectio... |
settings_file_set(file, PREF_KEY_BACKLIGHT_AMBIENT_SENSOR_ENABLED,
sizeof(PREF_KEY_BACKLIGHT_AMBIENT_SENSOR_ENABLED), &temp, sizeof(temp)) | ;
settings_file_delete(file, PREF_KEY_BACKLIGHT_BEHAVIOUR_DEPRECATED,
sizeof(PREF_KEY_BACKLIGHT_BEHAVIOUR_DEPRECATED));
}
}
// ------------------------------------------------------------------------------------
void shell_prefs_init(void) {
s_backlight_intensity =
prv_convert_b... | |
overning permissions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/event_service_client.h"
#include "services/normal/accessory/smartstrap_attribute.h"
#include "kernel/pbl_malloc.h"
#include "fake_smartstrap_profiles.h"
#include "fake_smartstrap_state.h"
#include "fake_system_task.h"
... | app_smartstrap_attribute_get_attribute_id(NULL) | == 0);
// smartstrap_attribute_begin_write()
uint8_t *buffer;
size_t buffer_len;
assert_result_invalid(app_smartstrap_attribute_begin_write(NULL, NULL, NULL));
assert_result_invalid(app_smartstrap_attribute_begin_write(NULL, &buffer, NULL));
assert_result_invalid(app_smartstrap_attribute_begin_write(NULL,... |
if (midnight <= (today_midnight + (5 * SECONDS_PER_DAY))) {
// Use weekday name up to 5 days in the future, aka "Sunday"
prv_format_time(buffer, buf_size, i18n_noop("%A"), timestamp);
} else {
// Otherwise use "Month Day", aka "June 21"
prv_format_time(buffer, buf_size, i18n_noop("%B %d"), timestamp);... |
}
enum {
RoundTypeHalfUp,
RoundTypeHalfDown,
RoundTypeAlwaysUp,
RoundTypeAlwaysDown,
};
static time_t prv_round(time_t round_me, time_t multiple, int round_type) {
switch (round_type) {
case RoundTypeHalfDown:
return ((round_me + multiple / 2 - 1) / multiple) * multiple;
case RoundTypeAlwaysU... | |
fs(serialized_prefs);
return NULL;
}
const size_t alloc_size =
attributes_actions_get_required_buffer_size(serialized_prefs->num_attributes,
serialized_prefs->num_actions,
attributes_per_action,
... | settings_file_get_len(&file, key, key_len) | ;
prv_file_close_and_unlock(&file);
return length;
}
status_t ios_notif_pref_db_read(const uint8_t *key, int key_len,
uint8_t *val_out, int val_out_len) {
SettingsFile file;
status_t rv = prv_file_open_and_lock(&file);
if (rv != S_SUCCESS) {
return rv;
}
rv = prv_re... |
firmware_description)) {
dbgserial_print("Desclen ");
dbgserial_print_hex(firmware_description.description_length);
dbgserial_print("\nFirmlen ");
dbgserial_print_hex(firmware_description.firmware_length);
dbgserial_print("\nXsum ");
dbgserial_print_hex(firmware_description.checksum);
dbgser... | if (!boot_bit_test(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE)) {
dbgserial_putstr("Failed to load recovery firmware, strike one. Try again.");
boot_bit_set(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
system_reset();
} else if (!boot_bit_test(BOOT_B... |
break;
}
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
return recovery_fw_ok;
}
|
////////////////////////////////////////////////
// Stubs
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_app_state.h"
#include "stubs_fonts.h"
#include "stubs_graphics_context.h"
#include "stubs_gbitmap.h"
#include "stubs_heap.h"
#include "stubs_text_resources.h"
#include "stubs_text_render.h"
... | iter_next(&word_iter) | );
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == '\n');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == 'N');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current... |
, s_parsed_msg.msrmt.num_types);
for (unsigned i = 0; i < s_parsed_msg.msrmt.num_types; i++) {
LOG(" %d", (int)s_parsed_msg.msrmt.types[i]);
}
LOG(" %"PRIu32" measurements: ", s_parsed_msg.msrmt.num_samples);
for (unsigned i = 0; i < s_parsed_msg.msrmt.num_samples; i++) {
LOG(" offset... | cl_assert_equal_i(a->payload_sender_v_minor, b->payload_sender_v_minor) | ;
cl_assert_equal_s(a->payload_sender_version_patch, b->payload_sender_version_patch);
// Ensure they are the same type
cl_assert_equal_i(a->type, b->type);
// MeasurementSet Specific
if (a->type == ProtobufLogType_Measurements) {
cl_assert_equal_i(a->msrmt.time_utc, b->msrmt.time_utc);
cl_assert_eq... |
| | | | | | | |
// | | | | | | | |
// ------- ------- ------- --------
//
// The resulting waveform has a frequency of PWM_OUTPUT_FREQUENCY_HZ. Inside each period, the timer
// ... | {
if (!s_backlight_pwm_enabled) {
prv_backlight_pwm_enable(true);
}
// By setting higher values in the TIM_Pulse register, we're causing the output waveform
// to be low for a longer period of time, which causes the backlight to be brighter.
//
// The brightness value has a ... | |
we receive
// (making it the checksum byte), so we always keep a 1 byte temporary buffer before storing the
// byte in the MBuf. This avoids us potentially overrunning a conservatively sized payload buffer;
if (s_read_info.length > 0) {
// copy the previous byte from the footer_byte field into the payload
... | {
// make sure there's still a notification pending
if (smartstrap_fsm_state_get() == SmartstrapStateNotifyInProgress) {
PBL_ASSERTN(new_timer_start(s_read_timer, NOTIFY_TIMEOUT, prv_notify_timeout, NULL, 0));
}
} |
bool smartstrap_handle_break_from_isr(void) {
// NOTE: THIS IS RUN WITHIN AN ISR
bool should_context_switch = false;
// we should only accept notifications if we're in the ReadReady state
if (smartstrap_fsm_state_test_and_set(SmartstrapStateReadReady,
SmartstrapStateNot... |
(session, NULL, 0 /*numbytes*/, &write_offset) | ;
if (num_bytes < 0) {
goto bad_session;
}
session->storage.num_bytes = num_bytes;
session->storage.write_offset = write_offset;
// To update the read offset, we pass 0 as num_bytes into dls_storage_consume()
if (dls_storage_consume(session, 0) < 0) {
goto bad_session;
}
PB... | |
fd = pfs_open("b_test_0", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
fd = pfs_open("b_test_1", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
// Get a directory listing with no filtering
PFSFileListEntry *dir_list;
dir_list = pfs_create_file_list(NULL);
// Should have 4 entr... | (prv_file_exists("b_test_1"), true) | ;
pfs_remove_files(prv_filename_filter_a_prefix_cb);
// Should have only files starting with b_
cl_assert_equal_b(prv_file_exists("a_test_0"), false);
cl_assert_equal_b(prv_file_exists("a_test_1"), false);
cl_assert_equal_b(prv_file_exists("b_test_0"), true);
cl_assert_equal_b(prv_file_exists("b_test_1"),... |
own to adjust\nSelect to proceed"),
[DisplayCalibrationState_Y_Adjust] = i18n_noop("Up/Down to adjust\nSelect to proceed"),
[DisplayCalibrationState_Confirm] = i18n_noop("Select to confirm alignment changes")
};
const char *title_text = i18n_get(titles[data->state], data);
const char *instruction_text = ... | (ctx, GCompOpSet) | ;
const int16_t margin = 8;
const GRect bounds = grect_inset_internal(layer->bounds, margin, margin);
GRect box = arrow_bitmap->bounds;
grect_align(&box, &bounds, alignment, true);
graphics_draw_bitmap_in_rect(ctx, arrow_bitmap, &box);
}
static void prv_draw_arrows(Layer *layer, GContext *ctx) {
DisplayCal... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return otp_get_slot(index);
} |
}
return DUMMY_PCBA_SERIAL;
}
static MfgSerialsResult prv_mfg_write_data_to_slot(const uint8_t *slot_indices, size_t num_slots,
const char *data, size_t data_size,
uint8_t *out_index) {
for (unsigned int i = 0;... |
ote_encryption_info = {
.ltk = (const SMLongTermKey) {
.data = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
},
},
.rand = 0x11223344,
.ediv = 9876,
},
.irk = (const SMIdentityResolvingKey) {
.... | memcmp(&pairing_info->remote_encryption_info.ltk,
&pairing_info_out.remote_encryption_info.ltk, sizeof(SMLongTermKey)) | , 0);
cl_assert_equal_i(memcmp(&pairing_info->irk, &pairing_info_out.irk,
sizeof(SMIdentityResolvingKey)), 0);
cl_assert_equal_i(memcmp(&pairing_info->csrk, &pairing_info_out.csrk,
sizeof(SM128BitKey)), 0);
}
void test_shared_prf_storage_v2__bt_classic_and_le_... |
tall_manager.h"
#include "util/attributes.h"
#include "clar.h"
// Fakes
//////////////////////////////////////////////////////////
#include "fake_app_manager.h"
#include "fake_new_timer.h"
#include "fake_pbl_malloc.h"
#include "fake_rtc.h"
#include "fake_spi_flash.h"
#include "fake_system_task.h"
#include "fake_time.... | cl_assert_equal_i(settings_file_get_len(&file, (uint8_t*)&wakeup_id, sizeof(wakeup_id)),
sizeof(WakeupEntryV2)) | |
/*
* 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(-10000, interpolate_int16(0, -10000, 10000));
cl_assert_equal_i(10000, interpolate_int16(ANIMATION_NORMALIZED_MAX, -10000, 10000));
} |
static AnimationProgress s_override_progress;
static int64_t s_override_from;
static int64_t s_override_to;
int64_t prv_override_capture_args(AnimationProgress p, int64_t a, int64_t b) {
s_override_progress = p;
s_override_from = a;
s_override_to = b;
return 1;
}
void test_animation_interpolate__override_ge... |
ts own ending.");
return 0;
} else if ((resource_offset + num_bytes) > entry->length) {
PBL_LOG(LOG_LEVEL_ERROR, "offset + length > resource size, truncated.");
return entry->length - resource_offset;
} else {
return num_bytes;
}
}
static uint32_t prv_read(ResourceStoreEntry *entry, uint32_t offs... | {
return;
} |
}
PBL_LOG(LOG_LEVEL_WARNING,
"get_store_entry(%"PRIu32",%"PRIu32") failed to find appropriate store",
app_num, resource_id);
entry->impl = NULL;
}
static bool prv_validate_entry(ResourceStoreEntry *entry, ResourceManifest *manifest,
uint32_t resource_id) {
if... |
_disappear_count(), 0);
}
// Description:
// This test ensures that when we push windows onto modal window stacks, that
// only the appropriate window is visible at a given time.
void test_window_stack__modal_priority(void) {
Window *windows[NumModalPriorities];
WindowStack *window_stacks[NumModalPriorities];
Mo... | cl_assert_equal_i(windows[2][1]->is_click_configured, true) | |
ex = OTP_SERIAL_SLOT_INDICES[i];
if (otp_is_locked(index)) {
return otp_get_slot(index);
}
}
return DUMMY_SERIAL;
}
const char* mfg_get_hw_version(void) {
// Trying from "most recent" slot to "least recent":
for (int i = ARRAY_LENGTH(OTP_HWVER_SLOT_INDICES) - 1; i >= 0; --i) {
const uint8_t i... | {
MfgSerialsResult result;
uint8_t index = 0;
size_t pcba_serial_len = strlen(pcba_serial);
if ((pcba_serial_len > 0) && (pcba_serial_len <= MFG_PCBA_SERIAL_NUMBER_SIZE)) {
result = mfg_write_pcba_serial_number(pcba_serial, pcba_serial_len, &index);
} else {
result = MfgSerialsResultFailIncorrectLeng... |
static void mfg_print_feedback(const MfgSerialsResult result, const uint8_t index,
const char *value, const char *name) {
switch (result) {
case MfgSerialsResultAlreadyWritten: {
char buffer[48];
const char * const field = otp_get_slot(index);
prompt_send_respons... |
icense.
* 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, either express or implie... | PBL_ASSERT(i < QSPI_WAIT_TIME, "Waited too long for the QSPI to become not busy") | ;
}
#else
static void prv_wait_for_transfer_complete(void) {
while (QSPI_GetFlagStatus(QSPI_FLAG_TC) == RESET) { }
}
static void prv_wait_for_not_busy(void) {
while (QSPI_GetFlagStatus(QSPI_FLAG_BUSY) != RESET) { }
}
#endif
static void prv_read_bytes(uint8_t *buffer, size_t buffer_size) {
for (size_t i = 0; ... |
ino_layer, false);
layer_add_child((Layer *)peek_layer, (Layer *)&peek_layer->kino_layer);
const GTextAlignment text_alignment = GTextAlignmentCenter;
GRect text_rect = GRect(0, NUMBER_OFFSET_Y, frame->size.w, 40);
// number layer
text_layer_init_with_parameters(&peek_layer->number.text_layer,
... | kino_reel_transform_set_to_frame(kino_reel, icon_to) | ;
kino_reel_transform_set_transform_duration(kino_reel, PEEK_LAYER_UNFOLD_DURATION);
const int16_t expand = 8;
kino_reel_scale_segmented_set_deflate_effect(kino_reel, expand);
layer_set_hidden((Layer *)&peek_layer->kino_layer, true);
peek_layer->show_dot = prv_is_dot_size(icon_from.size);
if (peek_layer->s... |
atus;
uint8_t *flash_written_data;
bool *flash_written_flag;
void *source_buffer;
uint32_t flash_data_start, flash_data_length;
bool callback_called;
void test_system_flash__initialize(void) {
erased_sector = 0;
flash_locked = true;
flash_flags_set = false;
return_status = FLASH_COMPLETE;
flash_written_data ... | cl_assert(!system_flash_write(FLASH_BASE, "abc", 3, NULL, NULL)) | |
y
return true;
} else if ((status != AS7000LoaderStatus_Busy1) && (status != AS7000LoaderStatus_Busy2)) {
// error
PBL_LOG(LOG_LEVEL_ERROR, "Error status: %"PRIx8, status);
return false;
}
psleep(1);
} while (prv_get_time_ms() < end_time_ms);
PBL_LOG(LOG_LEVEL_ERROR, "Timed out ... | (dev->state->lock) | ;
if (dev->state->enabled_state == HRMEnabledState_Disabled) {
// Enable was cancelled before this callback fired.
goto done;
} else if (dev->state->enabled_state != HRMEnabledState_PoweringOn) {
PBL_LOG(LOG_LEVEL_ERROR, "Enable KernelBG callback fired while HRM was in "
"an unexpected state... |
ume(timer_id, &timer_cb, &timer_cb_data);
if (!timer_cb) {
// We've already cancelled this timer, just abort.
return;
}
timer_cb(timer_cb_data);
}
//! Called on the timer task. From here we need to generate a callback on the client's task.
static void prv_sys_timer_callback(void* cb_data) {
PBL_ASSE... | (new_timer->sys_timer_id, timeout_ms, prv_sys_timer_callback,
(void*)(intptr_t)new_timer->sys_timer_id, flags) | ;
PBL_ASSERTN(success);
mutex_unlock(s_mutex);
return new_timer->sys_timer_id;
}
bool evented_timer_reschedule(EventedTimerID timer_id, uint32_t timeout_ms) {
if (timeout_ms == 0) {
timeout_ms = 1;
}
mutex_lock(s_mutex);
// This will detect an invalid timer ID, or one that already ran on the clien... |
L;
// We dynamically allocate one of these for every service UUID that either a client subscribes to or a service
// publishes an event to.
typedef struct {
ListNode list_node;
uint16_t service_index; // index of the service
Uuid uuid; // UUID
} EventPluginUU... | {
return (false);
} | |
9104");
}
void test_sprintf__percent_o(void) {
char dstbuf[256];
// Simple %o
snprintf(dstbuf, 256, "There are %o lights, %o", 8, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, 37777777774");
// Alternate form (adds 0 prefix)
snprintf(dstbuf, 256, "There are %#o lights, %#o", 8, -4);
cl_assert_eq... | cl_assert_equal_s(dstbuf, "There are 10 lights, the absolute value of fffffffc") | ;
// Minimum digits output
snprintf(dstbuf, 256, "There are %.3x lights, %.3x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 010 lights, fffffffc");
// Minimum digits output (zero digits)
snprintf(dstbuf, 256, "%.0xzero%.0x", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspeci... |
/*
* 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... | (builder, x1, y1, x2, y2, x3, y3, x4, y4) | ) {
return gpath_builder_line_to_point(builder, p4);
}
return false;
}
GPathBuilder *gpath_builder_create(uint32_t max_points) {
// Allocate enough memory to store all the points - points are stored contiguously with the
// GPathBuilder structure
const size_t required_size = sizeof(GPathBuilder) + max_po... |
bounds->size.w, bounds->size.h),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
static void prv_display_saving_message(Layer *layer, GContext *ctx) {
AppData *data = app_state_get_user_data();
const GRect *bounds = &data->window.layer.bounds;
graphics_context_set_text_... | layer_mark_dirty(&app_data->window.layer) | |
t);
s_last_sharing_request = NULL;
}
void test_ble_hrm__sub_unsub(void) {
cl_assert_equal_i(s_hrm_manager_subscribe_with_callback_call_count, 0);
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count, 0);
prv_assert_event_service_subscribed(false);
// Device A subscribes:
bt_driver_cb_hrm_service_upd... | prv_assert_event_service_subscribed(false) | ;
prv_assert_last_disconnected(s_device_a);
}
void test_ble_hrm__revoke_all(void) {
// Device A subscribes:
bt_driver_cb_hrm_service_update_subscription(s_device_a, true);
// Expect permissions UI to be presented:
prv_assert_permissions_ui_and_respond(true /* is_granted */);
// Device B subscribes:
bt_... |
-1352, 464, -48},
{ -1200, 432, 16},
{ -1320, 592, -104},
{ -1064, 656, -128},
{ -1000, 472, -184},
{ -1408, 392, -96},
{ -1808, 320, 40},
{ -1848, 184, 56},
{ -1680, 120, 64},
{ -1584, 112, 80},
{ -1528, 88, 88},
{ -1472, 72, 104},
// 51 seconds
{ -1400, 40, 120},
... | { -784, -504, -280},
{ -1632, 1176, -176},
// 56 seconds
{ -1720, 336, 48},
{ -1496, 168, -72},
{ -1184, 256, -40},
{ -984, 120, 48},
{ -880, 128, 40},
{ -824, 80, 40},
{ -912, 56, 80},
{ -1128, 72, 104},
{ -1104, -208, 264},
{ -1224, -192, 80},
{ -1472, 32, -96},... |
{ -1280, -96, -176},
{ -1480, 32, -160},
{ -1448, 56, -144},
{ -1504, -48, 24},
{ -1624, 120, 72},
{ -1656, 288, 192},
{ -1600, 440, 224},
{ -1400, 704, 40},
{ -1272, 472, -8},
{ -1400, 784, 0},
{ -1168, 624, 176},
{ -1152, 824, 200},
// 59 seconds
{ -1080, 840, ... |
, 0, (uint8_t *)&image_header,
sizeof(image_header)) != sizeof(image_header)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to read HRM FW image header!");
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "FW update image is v%" PRIu8 ".%" PRIu8 ".%" PRIu8,
HRM_SW_VERSION_PART_MAJOR(image_header.sw_version_major),... | {
if (!dev->state->lock) {
PBL_LOG(LOG_LEVEL_DEBUG, "Not an HRM Device.");
return;
}
mutex_lock(dev->state->lock);
if (!prv_get_and_log_device_info(dev, info_out, true /* log_version */)) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to read AS7000 version info");
}
mutex_unlock(dev->state->lock);
} |
// Prompt Commands
// ===============
#include "console/prompt.h"
#include <string.h>
void command_hrm_wipe(void) {
// HEX records to write 0xFFFFFFFF to the magic number region.
const char *erase_magic_record = ":047FFC00FFFFFFFF85";
const char *eof_record = ":00000001FF";
mutex_lock(HRM->state->lock);
... |
esourceInfo timeline_res = {
.res_id = TIMELINE_RESOURCE_DAY_SEPARATOR,
};
peek_layer_set_icon(&layer->day_separator, &timeline_res);
// reset the layouts
prv_reset_layouts(layer);
prv_destroy_nonvisible_items(layer);
timeline_layer_set_layouts_hidden(layer, false);
// PBL-18815: Reset the current d... | {
Animation *animations[TIMELINE_NUM_VISIBLE_ITEMS + 2] = {};
int num_animations = 0;
for (int i = 0; i < TIMELINE_NUM_VISIBLE_ITEMS; i++) {
TimelineLayout *layout = layer->layouts[s_visible_items[i]];
if (layout) {
GRect frame;
prv_get_frame(layer, i + 1, &frame);
animations[num_animat... |
void timeline_layer_set_layouts_hidden(TimelineLayer *layer, bool hidden) {
for (int i = 0; i < TIMELINE_NUM_ITEMS_IN_TIMELINE_LAYER; i++) {
TimelineLayout *layout = layer->layouts[i];
if (layout) {
prv_set_layout_hidden(layout, hidden);
}
}
layer_set_hidden((Layer *)&layer->end_of_timeline, ... |
/*
* 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... | snprintf(data->status_text, STATUS_TEXT_SIZE, "Test Running") | ;
break;
case FLASH_TEST_STATUS_STOPPED:
snprintf(data->status_text, STATUS_TEXT_SIZE, "Test Stopped");
break;
case FLASH_TEST_STATUS_PASSED:
snprintf(data->status_text, STATUS_TEXT_SIZE, "Test Passed");
break;
case FLASH_TEST_STATUS_FAILED:
snprintf(data->status_text, ST... |
= prv_skip_odd_rows,
});
menu_layer_reload_data(&l);
const int16_t basic_cell_height = menu_cell_basic_cell_height();
const int initial_scroll_offset = (DISP_ROWS - basic_cell_height) / 2;
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).section);
cl_assert_equal_i(0, menu_layer_get_selected_index(&l)... | menu_layer_set_center_focused(&l, true) | ;
s_num_rows = 3;
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks) {
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
.get_cell_height = prv_get_row_height_depending_on_selection_state,
});
menu_layer_set_center_focused(&l, true);
menu_layer_reload_data(&l);
const int focused_... |
.layout = LayoutIdCalendar,
},
.attr_list = {
.num_attributes = 1,
.attributes = &title_attr,
},
};
static TimelineItem item3 = {
.header = {
.id = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 25*60,
.duration ... | (timer_id) | );
cl_assert_equal_i(5*60, stub_new_timer_timeout(timer_id) / 1000);
}
void test_calendar_handle__ongoing_event_added_and_removed(void) {
rtc_set_time(15 * 60);
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1);
cl_assert(!prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get... |
oid prv_offset_bitmap_layer_test(GPoint bounds_origin) {
prv_bitmap_layer_test(TEST_LAYER_OFFSET_ORIGIN, bounds_origin);
}
// Composite Test Support
////////////////////////////////////
static GBitmap *prv_create_bitmap_from_png_file(const char *png_filename_without_extension) {
GBitmap *result = NULL;
char pn... | GPoint(COMPOSITE_TEST_OFFSET_X,
COMPOSITE_TEST_OFFSET_Y) | );
graphics_context_set_compositing_mode(ctx, compositing_mode);
graphics_draw_bitmap_in_rect(ctx, bitmap, &destination);
}
static void prv_composite_test(const char *unit_test_name, GCompOp compositing_mode) {
for (size_t i = 0; i < ARRAY_LENGTH(s_composite_tests); i++) {
const CompositeTest *test_data = &s... |
N_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 2);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw2_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 2);
graphics_draw_rect(&ctx, &O... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 1) | ;
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 1);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_... |
eceive_init(VALID_OBJECT_SIZE * num_ops, ObjectFirmware);
fake_comm_session_process_send_next();
fake_system_task_callbacks_invoke_pending();
uint8_t buffer[num_ops * VALID_OBJECT_SIZE];
for (size_t i = 0; i < sizeof(buffer); i += VALID_OBJECT_SIZE) {
uint32_t towrite = i;
memcpy(&buffer[i], &towrite, ... | prv_receive_abort(s_last_response_cookie) | ;
assert_ack_count(1);
assert_nack_count(0);
assert_cleanup_event(ObjectFirmware, VALID_OBJECT_SIZE);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Install Message
void test_put_bytes__install_message_while_not_idle(void) {
prv_receive_init(VALID_OB... |
*PREF_KEY_SEND_TEXT_APP;
#define SEND_TEXT_KEY ((uint8_t *)PREF_KEY_SEND_TEXT_APP)
#define SEND_TEXT_KEY_LEN (strlen(PREF_KEY_SEND_TEXT_APP))
#define INVALID_KEY ((uint8_t *)"thisIsNotAnApp")
#define INVALID_KEY_LEN strlen((char *)INVALID_KEY)
#define NUM_SEND_TEXT_CONTACTS (5)
#define SEND_TEXT_DATA_LEN (sizeof(Ser... | (WEATHER_KEY, WEATHER_KEY_LEN, s_weather_prefs,
(data_len - sizeof(SerializedWeatherAppPrefs))) | , E_INVALID_ARGUMENT);
}
void test_watch_app_prefs_db__insert_remove(void) {
cl_assert_equal_i(watch_app_prefs_db_insert(SEND_TEXT_KEY, SEND_TEXT_KEY_LEN, s_send_text_prefs,
sizeof(s_send_text_prefs)), S_SUCCESS);
cl_assert_equal_i(watch_app_prefs_db_delete(SEND_TEXT_K... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_ASSERTN(dev->state->use_count > 0);
if (--dev->state->use_count == 0) {
periph_config_disable(QUADSPI, dev->clock_ctrl);
}
} |
static void prv_set_num_data_bytes(uint32_t length) {
// From the docs: QSPI_DataLength: Number of data to be retrieved, value+1.
// so 0 is 1 byte, so we substract 1 from the length. -1 is read the entire flash length.
PBL_ASSERTN(length > 0);
QSPI_SetDataLength(length - 1);
}
#if DEBUG_QSPI_WAITS
#define ... |
o reschedule the timer
// for 1 minute intervals rather than create it as a repeating timer. This is because
// we occasionally want the callback to get triggered immediately
// (in response to the charging cable being plugged in). In these instances, we reschedule it
// from the main task.
prv_schedule_updat... | battery_curve_lookup_percent_with_scaling_factor(battery_mv, false,
scaling_factor) | ;
int32_t d_percent = curr_percent - start_percent;
s_analytics_previous_mv = battery_mv;
analytics_set(ANALYTICS_DEVICE_METRIC_BATTERY_PERCENT_DELTA, d_percent, AnalyticsClient_System);
analytics_set(ANALYTICS_DEVICE_METRIC_BATTERY_PERCENT,
ratio32_to_percent(s_last_battery_state.percent),
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_SET) | ; // SCS -> HIGH
// Send dummy clocks
for (unsigned int i = 0; i < 8; ++i) {
display_write_byte(0x00);
}
if (!GPIO_ReadInputDataBit(DISP_GPIO, DISP_PIN_CDONE)) {
PBL_LOG(LOG_LEVEL_WARNING, "CDONE not high after programming!");
return false;
}
return true;
}
void display_power_enable(void) {
... |
id_equal(&state.pin.header.id, &s_items[0].header.id));
// check second
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
// check second a... | cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[0].header.id)) | ;
// check next
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[2].header.id));
cl_assert(!iter_next(&iterator));
}
// 5am, no events passed
voi... |
prop_h);
void *context = &layer;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
animation_set_auto_destroy(h, false);
prv_clear_handler_histories();
animation_schedule(h);
uint64_t start_ms = prv_now_ms();
uint64_t unschedule_time = 0;
uint64_t time_ms;
for (... | cl_assert(s_stopped_handler_calls.entries[0].finished) | ;
// Destroy it
animation_destroy(h);
#endif
}
// --------------------------------------------------------------------------------------
// Test that we can reschedule an animation from the stopped handler
void test_animation__reschedule_from_stopped_handler(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation ... |
v_create_command_list_3();
memcpy(&image->command_list, command_list, sizeof(GDrawCommandList) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6));
free(command_list);
image->version = 1;
image->size = GSize(20, 20);
cl_assert(gdraw_command_image_validate(image, size));
cl_assert(!gdraw_command_imag... | cl_assert(prv_compare_points(points, s_fill_points, s_path_num_points)) | ;
free(frame);
}
static int s_iterations = 0;
static bool prv_iterate(GDrawCommand *command, uint32_t index, void *context) {
s_iterations++;
return true;
}
void test_gdraw_command__iterate(void) {
GDrawCommandList *command_list = prv_create_command_list_3();
void *end = gdraw_command_list_iterate_private... |
orizontal_line_dotted(&ctx, GPoint(0, 20), 143);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 22), 145);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_even_rows_no_clip")));
// Odd rows of different lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_N... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 18), 22) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 20), MAX_NUM_COLS - 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 22), MAX_NUM_COLS + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_even_offset_even_rows_no_clip")));
// Odd rows of different ... |
oid click_manager_reset(ClickManager *click_manager) {
return;
}
void watchface_reset_click_manager(void) {
return;
}
Animation *window_transition_default_pop_create_animation(WindowTransitioningContext *context) {
window_transition_context_disappear(context);
window_transition_context_appear(context);
retu... | 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) {
s_last_click_configured_window = NULL;
... |
menu_layer->scroll_layer.layer.frame.size;
const int16_t content_top_y = -scroll_layer_get_content_offset(&menu_layer->scroll_layer).y;
const int16_t content_bottom_y = content_top_y + frame_size.h;
if (!process_manager_compiled_with_legacy2_sdk()) {
prv_draw_background(menu_layer, ctx, &menu_layer->scroll_... | menu_layer_init(layer, &frame) | ;
}
return layer;
}
void menu_layer_pad_bottom_enable(MenuLayer *menu_layer, bool enable) {
menu_layer->pad_bottom = enable;
}
void menu_layer_deinit(MenuLayer *menu_layer) {
prv_cancel_selection_animation(menu_layer);
layer_deinit(&menu_layer->inverter.layer);
scroll_layer_deinit(&menu_layer->scroll_laye... |
tion are then returned to the caller.
static ResponseTimeState prv_determine_latency_for_connection(
ConnectionStateRequest *requests, uint16_t *secs_to_wait, BtConsumer *consumer_out) {
ResponseTimeState state = ResponseTimeMax;
uint32_t timeout = 0;
BtConsumer responsible_consumer = BtConsumerNone;
Conne... | regular_timer_add_multisecond_callback(
watchdog_cb_info, secs_til_max_latency + 1);
}
hdl->conn_mgr_info->curr_requested_state = state;
} |
static void prv_bt_le_gateway_response_latency_watchdog_handler(void *data) {
bt_lock();
GAPLEConnection *hdl = (GAPLEConnection *)data;
// Let's make sure our connection handle is still valid in case we
// disconnected before this CB had a chance to execute
if (!gap_le_connection_is_valid(hdl)) {
goto... |
tack_pop(stack, false);
cl_assert_equal_i(window_stack_count(stack), 0);
// Ensure the disappear handler was called
cl_assert_equal_i(prv_get_appear_disappear_count(), 0);
// Ensure the unload handler was called
cl_assert_equal_i(prv_get_load_unload_count(), 0);
}
void test_window_stack__dump(void) {
Wi... | (prv_get_load_unload_count(), 1) | ;
}
// Description:
// In this test we push two windows that push windows during their unload handlers.
// We want to verify that those two windows stay on the stack after calling
// `window_stack_pop_all`.
void test_window_stack__push_during_window_unload_multiple(void) {
Window *window1 = window_create();
Window... |
/*
* 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 >> 28) ^ (input >> 4)) & 0x0f];
crc = (crc << 4) ^ s_lookup_table[((crc >> 28) ^ (input >> 0)) & 0x0f];
return crc;
} |
void legacy_defective_checksum_init(LegacyChecksum *checksum) {
*checksum = (LegacyChecksum) {
.reg = 0xffffffff,
};
}
void legacy_defective_checksum_update(
LegacyChecksum * restrict checksum,
const void * restrict data, size_t length) {
const char * restrict data_bytes = data;
uint32_t * restri... |
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 distributed on a... | (LOG_LEVEL_DEBUG, "ERROR: Did not successfully write the data") | ;
return FLASH_TEST_ERR_DATA_WRITE;
}
return FLASH_TEST_SUCCESS;
}
static FlashTestErrorType prv_write_read_verify_halfword(uint32_t write_addr,
uint16_t write_val,
uint16_t expected_val,
... |
er *r = g_put_bytes_receiver_impl.prepare(session, &s_put_bytes_endpoint, length);
if (r) {
if (s_do_before_write) {
s_do_before_write();
}
g_put_bytes_receiver_impl.write(r, data, length);
g_put_bytes_receiver_impl.finish(r);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "No receiver returned!");
}... | prv_process_and_reset_test_counters() | ;
}
static void prv_receive_init_put_and_commit_fw_object(void) {
prv_receive_init_and_put_fw_object();
prv_receive_commit(s_last_response_cookie, EXPECTED_CRC);
prv_process_and_reset_test_counters();
}
static void prv_receive_init_put_commit_and_install(PutBytesObjectType object_type) {
prv_receive_init(VALI... |
/*
* 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... | {
registry_private_remove_all(uuid, &s_factory_registry);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "Sending HCI CMD to ROM stack:") | ;
PBL_HEXDUMP(LOG_LEVEL_DEBUG, (uint8_t *)hci_cmd, msg_buf->msg_size);
bool result = (ad_ble_command_queue_send(&msg_buf, OS_QUEUE_FOREVER) == pdPASS);
return result;
}
void hci_rom_passthrough_handle_evt(hci_evt_msg_t *hci_evt) {
uint16_t payload_len = sizeof(hci_evt_msg_t) + hci_evt->param_length - sizeof(h... |
nit(&ctx, fb);
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 10);
graphics_line_draw_precise_stroked_non_aa(&ctx, START_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_origin_layer_non_aa.${BIT_DEPTH_NAME}.pbi"));
set... | graphics_line_draw_precise_stroked_non_aa(&ctx, END_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT, 10) | |
xfd, 0xfe, 0xe0, 0xac, 0x77},
.info_flags = PROCESS_INFO_STANDARD_APP,
.app_version = {
.major = 2,
.minor = 0,
},
.sdk_version = {
.major = 5,
.minor = 13,
},
.app_face_bg_color = {0},
.template_id = 0,
.icon_resource_id = 0,
};
static const Uuid tictoc_uuid = { 0x8f, 0x3c, 0x86, 0x86... | cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry)) | |
ffer;
}
static void prv_populate_attributes(TimelineItem *item,
uint8_t **buffer,
const ANCSAttribute *title,
const ANCSAttribute *display_name,
const ANCSAttribute *subtitle,... | (app_id, subtitle) | |
/*
* 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... | system_task_add_callback(prv_timeout_kernelbg_callback, data) | ;
}
static void prv_send_writeback(BlobDBSyncSession *session) {
// we want to write-back the first item in the dirty list
BlobDBDirtyItem *dirty_item = session->dirty_list;
int item_size = blob_db_get_len(session->db_id, dirty_item->key, dirty_item->key_len);
if (item_size == 0) {
// item got removed duri... |
36, -152},
{ 712, 144, -224},
{ 856, 160, -336},
{ 1088, 184, -456},
{ 832, 88, -504},
{ 1176, 240, -584},
{ 1496, 320, -440},
// 13 seconds
{ 1336, 360, -152},
{ 1240, 552, -256},
{ 1088, 664, -432},
{ 832, 648, -392},
{ 728, 520, -448},
{ 664, 552, -520},
{ 672,... | { 736, 96, -128},
{ 608, 64, -128},
{ 616, 144, -136},
{ 744, 200, -96},
{ 912, 264, -112},
{ 992, 272, -120},
{ 1088, 360, -168},
{ 1128, 272, -88},
{ 1080, 248, -136},
{ 1296, 88, 24},
{ 864, 136, -152},
{ 1032, 216, -312},
{ 1392, 160, -216},
{ 1144, 240, -264}... |
// 21 seconds
{ 1224, 112, -232},
{ 1328, 8, -176},
{ 968, -32, -208},
{ 736, 40, -176},
{ 640, 152, -152},
{ 648, 232, -120},
{ 712, 312, -136},
{ 848, 368, -152},
{ 896, 352, -184},
{ 1008, 368, -352},
{ 1064, 216, -328},
{ 1320, 200, -224},
{ 1536, 216, -120},... |
/*
* 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... | (VREF_ADC) | |
layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(4, -5, 18, 10), 4, GCornersAll);
}
void corners_all_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiase... | GRect(0, 0, 100, 100) | );
layer_set_update_proc(&layer, &corners_clipped_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_clipped.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__color(void) {
GContext ctx;
Layer layer;
test_graphics_context_init(&... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | assert_decode_completed(6) | ;
assert_output_equal("\0A\0\0B\0", 6);
}
void test_cobs_decode__max_length_block(void) {
decode_start(254);
assert_decode_char_succeeds(0xff);
for (int c = 0x01; c <= 0xfe; ++c) {
assert_decode_char_succeeds(c);
}
assert_decode_completed(254);
const unsigned char *iter = out;
for (int c = 0x01; c ... |
he License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "local_addr_impl.h"
#include "ble_task.h"
#include "advert.h"
#include "system... | {
OwnAddressUpdateInfo update_info = {};
prv_get_desired_own_address(&update_info.desired_own_address);
if (!prv_current_address_is_already_pinned_address()) {
// FIXME - PBL-36339: Pause scanning too when we start using it for BLE Central APIs
if (!advert_execute_cb_if_adverts_are_paused(prv_try_set_ow... |
// @note: Everything below executes on ble_task to avoid locking.
static void prv_assert_is_executing_on_ble_task(void) {
ble_task_assert_is_executing_on_ble_task();
}
void local_addr_set(bool allow_cycling, const BTDeviceAddress *pinned_address) {
prv_assert_is_executing_on_ble_task();
s_local_addr_desired_p... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return gpoint_from_polar_precise(center, distance << GPOINT_PRECISE_PRECISION, angle);
} |
static void prv_graphics_draw_centered_text(GContext *ctx, const GSize *max_size,
const GPoint *center, const GFont font,
const GColor color, const char *text) {
GSize text_size = app_graphics_text_layout_get_content_size(
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.