prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ual, the I2C peripheral adds 2-3 cycles to sync SCL with I2CCLK. In
// practice, 3 has been observed.
#define I2C_SYNC_CYCLES (3)
#define TIMINGR_MAX_SCLL (0x100) // 8 bits storing (SCLL - 1)
#define TIMINGR_MAX_SCLH (0x100) // 8 bits storing (SCLH - 1)
#define TIMINGR_MAX_SCLDEL (0x10) // 4 bits storing (SCLDEL - 1)
... | {
// 1 less than the SCLL / SCLH / SCLDEL / PRESC values should be stored in the register.
const TIMINGR result = (TIMINGR) {
.SCLL = scl_low - 1,
.SCLH = scl_high - 1,
.SCLDEL = scl_delay - 1,
.PRESC = prescaler - 1,
};
return result.reg;
} |
}
// We tried every possible prescaler and couldn't find valid TIMINGR values.
return I2C_TIMINGR_INVALID_VALUE;
}
|
}
if (p0.x > p1.x) {
swap16(&p0.x, &p1.x);
swap16(&p0.y, &p1.y);
}
int dx = p1.x - p0.x;
int dy = abs(p1.y - p0.y);
int16_t err = dx / 2;
int16_t ystep;
if (p0.y < p1.y) {
ystep = 1;
} else {
ystep = -1;
}
for (; p0.x <= p1.x; p0.x++) {
if (steep) {
graphics_private_... | {
// Y-major line; calculate 16-bit fixed-point fractional part of a
// pixel that X advances each time Y advances 1 pixel, truncating the
// result so that we won't overrun the endpoint along the X axis
error_adj = ((uint32_t)(dx) << 16) / (uint32_t) dy;
// Draw all pixels other than the... | else {
// It's an X-major line
error_adj = ((uint32_t) dy << 16) / (uint32_t) dx;
// Draw all pixels other than the first and last
while (--dx) {
error_acc_temp = error_acc;
error_acc += error_adj;
if (error_acc <= error_acc_temp) {
// The error accumulator t... |
0, -144},
{ 1144, 344, -32},
// 39 seconds
{ 1088, 216, 56},
{ 1168, 216, -32},
{ 1248, 256, -48},
{ 1192, 176, -64},
{ 1328, 160, -80},
{ 1272, 208, -64},
{ 968, 192, -144},
{ 1208, 200, -232},
{ 904, 144, -232},
{ 896, 136, -320},
{ 1080, 144, -336},
{ 1224, 160... | { 1104, 152, -88},
{ 1216, 152, -48},
{ 1208, 152, -72},
{ 1512, 144, -96},
{ 1344, 184, -120},
{ 1080, 120, -200},
{ 1392, 136, -224},
{ 912, 0, -104},
{ 1072, 128, -224},
{ 1280, 160, -280},
{ 1112, 192, -280},
{ 864, 192, -232},
{ 760, 200, -160},
// 45 seconds... |
{ 960, 352, -168},
{ 1064, 424, -120},
{ 1200, 528, 0},
{ 1504, 512, -96},
{ 1184, 432, -40},
{ 1280, 488, -16},
{ 1112, 496, -72},
{ 1024, 528, -160},
{ 992, 440, -224},
{ 1168, 384, -160},
{ 1216, 224, -152},
{ 1008, 192, -160},
{ 976, 216, -176},
{ 1016, 200, ... |
{ 992, 0, -80},
{ 800, -88, -24},
{ 976, -168, 48},
// 104 seconds
{ 664, -160, -32},
{ 752, -80, -144},
{ 1232, -96, 64},
{ 1336, 64, -96},
{ 1504, 112, -120},
{ 1664, 48, -88},
{ 1392, 120, -40},
{ 984, 112, -120},
{ 992, 160, -96},
{ 1184, 184, 32},
{ 1280, ... | ARRAY_LENGTH(samples) | |
l_manager_flush_recent_communication_timestamps(void) {
circular_cache_flush(&s_recent_apps.cache);
memset(&s_recent_apps.cache_buffer, 0, sizeof(s_recent_apps.cache));
}
#endif
bool app_install_entry_is_watchface(const AppInstallEntry *entry) {
return (entry->process_type == ProcessTypeWatchface);
}
bool app_i... | (prv_app_install_enumerate_app_db, &cb_data) | ;
kernel_free(entry);
}
AppInstallId app_install_get_id_for_uuid(const Uuid *uuid) {
if (uuid_is_invalid(uuid) || uuid_is_system(uuid)) {
// Don't allow lookups by system uuid, there will be a bunch of apps with that uuid
return INSTALL_ID_INVALID;
}
// search in system registry first, if found retur... |
e;
}
PBL_LOG(LOG_LEVEL_ERROR, "CRC mismatch! expected=0x%"PRIx8" vs recv'd=0x%"PRIx8, running_xor, c);
return false;
}
static bool prv_send_header(uint16_t bootloader_size) {
// Send the header
prv_send_char(0x01); // Start of Header: 0x01
prv_send_char(bootloader_size & 0xff); // LEN_LSB
prv_send_char(... | {
// Note: It seems that the UART bootloader has a timeout between each
// character receieved. If it does not get a response in time, it will
// restart the bootrom sequence, searching for the device to talk to
// resulting in USART OREs. While we could use a critical section this would
// wind up blocking I... | |
ing = put_jobs->num_ops_pending;
}
prv_unlock_pb_job_state();
// If pre-acking is disabled, only one request can be in flight at any given time!
if (!enable_preack && (jobs_pending > 0)) {
return NULL;
}
if (jobs_pending == put_jobs->num_allocated_pb_jobs) {
return NULL; // Remote has sent data wi... | system_task_add_callback(prv_send_nack_from_system_task, (void *)(uintptr_t)token) | |
120, -216},
{ -496, -808, -248},
{ -568, -832, -256},
{ -544, -824, -288},
{ -536, -760, -320},
{ -592, -816, -120},
{ -560, -776, -160},
{ -584, -712, -264},
{ -568, -712, -400},
{ -568, -768, -328},
{ -512, -784, -328},
{ -488, -816, -304},
{ -512, -840, -264},
{ -4... | { -488, -816, -328},
{ -496, -840, -328},
{ -480, -832, -312},
{ -496, -840, -328},
{ -496, -832, -320},
{ -488, -832, -312},
{ -488, -832, -320},
{ -488, -832, -344},
{ -488, -824, -336},
{ -488, -832, -336},
{ -488, -832, -328},
{ -488, -824, -328},
{ -488, -824, -3... |
{ -488, -832, -320},
{ -488, -832, -312},
{ -496, -832, -312},
// 67 seconds
{ -488, -832, -312},
{ -488, -832, -320},
{ -488, -832, -304},
{ -488, -840, -320},
{ -488, -832, -320},
{ -488, -832, -312},
{ -488, -840, -312},
{ -488, -840, -312},
{ -488, -832, -320},
... |
_count(1);
}
void test_put_bytes__chunk_too_large(void) {
prv_receive_init_fw_object();
prv_process_and_reset_test_counters();
size_t chunk_size = 1024 * 1024;
uint8_t *chunk = kernel_malloc(chunk_size);
prv_receive_put(s_last_response_cookie, chunk, chunk_size);
kernel_free(chunk);
assert_ack_count(0)... | (s_last_response_cookie, EXPECTED_CRC) | ;
assert_ack_count(max_put_ops); // For the Put(s)
assert_nack_count(1); // For the Commit
}
void test_put_bytes__commit_message_cookie_mismatch(void) {
prv_receive_init_and_put_fw_object();
prv_receive_commit(~s_last_response_cookie, EXPECTED_CRC);
assert_ack_count(0);
assert_nack_count(1);
}
void test... |
ndler g_hc_protocol_endpoints_table[HcEndpointIDCount];
typedef struct {
ListNode node;
SemaphoreHandle_t semaphore;
const HcProtocolMessage *request;
HcProtocolMessage *response;
} HcExpectation;
static PebbleRecursiveMutex *s_hc_lock;
static HcProtocolState s_hc_state;
static HcExpectation *s_expectations_h... | if (!prv_check_initialized()) {
return false;
} |
prv_assign_next_transaction_id(message);
return prv_enqueue(message);
}
static HcProtocolMessage *prv_create_message(HcEndpointID endpoint_id, HcCommandID command_id,
const uint8_t *request_payload,
size_t request_payload_l... |
sed 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
* distributed under th... | (LOG_LEVEL_DEBUG, "Long Click Released!") | ;
text_layer_set_text(&data->text, data->text_buffer);
toggle_color(window);
(void)recognizer;
}
static void config_provider(Window *window) {
// See ui/click.h for more information and default values.
// single click / repeat-on-hold config:
window_single_repeating_click_subscribe(BUTTON_ID_SELECT, 1000,... |
s);
layer_add_child(&window->layer, &kino_layer->layer);
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
GRect pair_text_area = GRect(0, -2, width, 44);
#else
GRect pair_text_area = GRect(0, -2, width, 30);
#endif
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
layer_set_frame(&data->info_text_mask_layer, &GRect(x_offset, ... | property_animation_destroy(data->info_text_in_animation) | |
/*
* 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... | {
mutex_unlock_recursive(s_hc_lock);
} | |
pp_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
// Unsubscribing after subscription should cancel subscriptions
app_unobstructed_area_service_unsubscribe();
cl_assert(!app_state_get_unobstructed_area_state()->handlers.will_change);
cl_assert(!app_state_get_unobstructed_area_state(... | cl_assert_equal_i(s_data.num_will_change_calls, 1) | ;
cl_assert_equal_i(s_data.num_change_calls, 1);
cl_assert_equal_i(s_data.last_change_progress, progress);
}
void test_unobstructed_area_service__change_no_will(void) {
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_change,
.change = prv_change,
};
app_unobstructed_area_service_subscri... |
/*
* 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... | aligned (8) | ))
static const uint8_t FONT_FALLBACK_INTERNAL_builtin_bytes[] = {
0x03, 0x0e, 0x13, 0x00, 0xaf, 0x25, 0xff, 0x02, 0x0a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* bytes 0 - 16 */
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, /* bytes 16 - 32 */
0x00, 0x00, 0x06... |
GGING, LOG_LEVEL_WARNING, "Received nack for non-existent session id: %"PRIu8, session_id);
return;
}
mutex_lock(s_endpoint_data.mutex);
switch (logging_session->comm.state) {
case DataLoggingSessionCommStateIdle:
case DataLoggingSessionCommStateOpening:
//Currently, these messages never get NA... | (session_id) | ;
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Phone reported session %u opened", session_id);
// If the phone thinks we're open and we're not, send a close message.
if (logging_session == NULL) {
dls_endpoint_close_session(session_id);
}
}
// If the bluetooth connection is flaky, 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... | analytics_stopwatch_start(metric, client) | |
(20, 80, 40, 10) | , 4));
setup_test(&context, true, 2, GColorBlack, GColorBlack, true);
ASSERT_NO_CHANGE(graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10)));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(gr... | |
/*
* 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... | {
CommSession *session = (CommSession *)data;
bt_driver_run_send_next_job(session, true);
} |
bool bt_driver_comm_schedule_send_next_job(CommSession *session) {
launcher_task_add_callback(prv_send_job, session);
return true; // we croak if a task cannot be scheduled on KernelMain
}
bool bt_driver_comm_is_current_task_send_next_task(void) {
return launcher_task_is_current_task();
}
|
ayer_property_changed_tree_node(Layer *node, void *ctx) {
if (node) {
if (node->property_changed_proc) {
node->property_changed_proc(node);
}
}
return true;
}
static bool layer_process_tree_level(Layer *node, void *ctx, LayerIteratorFunc iterator_func) {
while (node) {
if (!iterator_func(node... | grect_clip(&ctx->draw_state.clip_box, &levels_layer_frame_in_ctx_space);
}
// translate the drawing_box to the bounds of the layer:
ctx->draw_state.drawing_box.origin.x +=
levels_layer->frame.origin.x + levels_layer->bounds.origin.x;
ctx->draw_state.drawing_box.origin.y +=
... |
void layer_property_changed_tree(Layer *node) {
layer_process_tree(node, NULL, layer_property_changed_tree_node);
}
void layer_set_update_proc(Layer *layer, LayerUpdateProc update_proc) {
PBL_ASSERTN(layer != NULL);
layer->update_proc = update_proc;
}
void layer_set_frame(Layer *layer, const GRect *frame) {
... |
"
////////////////////////////////////////////////////////////
// Data structures
typedef struct {
Window window;
GBitmap *bitmap;
bool bitmap_inited;
BitmapLayer bitmap_layer;
Layer anim_layer;
PropertyAnimation *spinner_animation;
AnimationImplementation spinner_anim_impl;
GColor spinner_color;
An... | property_animation_destroy(data->spinner_animation) | ;
kernel_free(data);
}
}
static void prv_window_load_handler(Window* window) {
SpinnerUIData *data = window_get_user_data(window);
GRect spinner_bounds = window->layer.bounds;
spinner_bounds.origin.y += PBL_IF_RECT_ELSE(0, 10);
window_set_background_color(window, PBL_IF_COLOR_ELSE(GColorLightGray, GColo... |
/*
* 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... | (heap, bytes, saved_lr) | |
_REG;
uint16_t FORCE_SLEEP_REG;
uint16_t LDOS_DISABLE_REG;
uint16_t AON_SPARE_REG;
// QSPIC
uint32_t QSPIC_CTRLMODE_REG;
uint32_t QSPIC_BURSTCMDA_REG;
uint32_t QSPIC_BURSTCMDB_REG;
uint32_t QSPIC_WRITEDATA_REG;
uint32_t QSPIC_DUMMYDATA_REG;
uint32_t QSPIC_ERASECTRL_REG;
uint32_t QSPIC_ERAS... | (DCDC, DCDC_V14_1_REG, DCDC_V14_ENABLE_LV, 0x1) | |
, "There are %*i lights", 3, 4);
cl_assert_equal_s(dstbuf, "There are 4 lights");
// Left-align, Variable length character output
snprintf(dstbuf, 256, "There are %*i lights", -3, 4);
cl_assert_equal_s(dstbuf, "There are 4 lights");
// Variable length digits output
snprintf(dstbuf, 256, "There are %.*... | (dstbuf, "There are 010 lights, 037777777774") | ;
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %03o lights, %03o", 8, -4);
cl_assert_equal_s(dstbuf, "There are 010 lights, 37777777774");
// Space padded minimum character output
snprintf(dstbuf, 256, "There are %3o lights, %3o", 8, -4);
cl_assert_equal_s(dstbuf, "There are 1... |
vent_PinAppLaunch, parent_id)) {
return;
}
// Format the event specifc info in the blob. The analytics_logging_log_event() method will fill
// in the common fields
AnalyticsEventBlob event_blob = {
.event = AnalyticsEvent_PinAppLaunch,
.pin_app_launch.time_utc = timestamp,
.pin_app_launch.paren... | analytics_logging_log_event(&event_blob) | |
r it;
bool cache_set;
} MenuPrimeCacheIterator;
static void prv_menu_layer_iterator_noop_callback(MenuIterator *it) {
(void)it;
}
static void prv_menu_layer_iterator_prime_cache_callback(MenuIterator *iterator) {
MenuPrimeCacheIterator *it = (MenuPrimeCacheIterator*)iterator;
if (false == it->cache_set) {
... | {
MenuLayer *menu_layer = (MenuLayer *) context;
menu_layer->animation.animation = NULL;
} |
static bool prv_cancel_selection_animation(MenuLayer *menu_layer) {
const bool result = animation_is_scheduled(menu_layer->animation.animation);
if (result) {
animation_unschedule(menu_layer->animation.animation);
}
menu_layer->animation.animation = NULL;
return result;
}
#define TOP_DOWN_PX 7
#define... |
RockyArgValueCheckError *value_error_out) {
Fixed_S16_3 v[4];
for (int i = 0; i < 4; ++i) {
const double d = jerry_get_number_value(argv[i]);
if (!prv_check_value_number_within_bounds(RockyArgTypeFixedS16_3, &d, value_error_out)) {
value_error_out->arg_offset = i;
retu... | {
return rocky_error_arguments_missing();
} |
// Type check:
RockyArgTypeCheckError type_error;
if (!imp.check_type(&argv[i], &type_error)) {
return rocky_error_unexpected_type(i + type_error.arg_offset,
type_error.expected_type_name);
}
// Check value, transform & assign:
RockyArgValueCheck... |
event_blob.event,
event_blob.bt_error.error_code);
analytics_logging_log_event(&event_blob);
}
// ------------------------------------------------------------------------------------------
//! Log when app_launch trigger failed.
void analytics_event_bt_app_launch_error(uint8_t... | analytics_logging_log_event(&event_blob) | |
456, 104},
{ -1224, 520, 72},
{ -1056, 440, 56},
{ -1000, 416, 16},
{ -1216, 384, 104},
{ -1568, 336, 176},
{ -1584, 288, 200},
{ -1408, 192, 208},
{ -1296, 128, 192},
{ -1256, 128, 152},
{ -1160, 128, 136},
{ -1096, 152, 104},
{ -1120, 40, 72},
{ -920, -312, 48},
... | { -1208, 296, 168},
{ -1096, 328, 112},
{ -1048, 248, 72},
{ -1088, 0, 400},
{ -888, 120, 496},
// 44 seconds
{ -744, 264, 464},
{ -952, 440, 328},
{ -992, 512, 488},
{ -1344, 448, 384},
{ -1080, 256, 264},
{ -848, 512, 136},
{ -1016, 584, 176},
{ -1424, 640, 344}... |
{ -8, 1408, 1048},
{ 72, 1448, 816},
{ 104, 1216, 624},
{ 72, 696, 800},
{ 0, 824, 872},
{ 0, 664, 864},
{ -24, 608, 640},
{ -8, 408, 424},
{ -32, 288, 376},
{ -48, 224, 248},
{ -56, 176, 144},
{ -112, 168, 112},
{ -280, 128, 216},
// 47 seconds
{ -440, 288, ... |
-----
// Return the activity metric that maps to the given health metric. We separate the two because
// in the future, the health APIs may need to go other services besides just the Activity service
// to get information.
static ActivityMetric prv_get_activity_metric(HealthMetric metric) {
switch (metric) {
case... | {
// Return cached data if we have it available.
if (state->cache && (metric == HealthMetricStepCount) && state->cache->step_daily_valid) {
memcpy(daily, &state->cache->steps_daily, sizeof(*daily));
// Get updated value for today. Getting only today's value is MUCH faster than getting
// the historical ... |
// ----------------------------------------------------------------------------------------------
// Compute all stats (weekly, daily, weekend, weekday, etc.) for the given metric.
// @param[in] state our API state
// @param[in] metric which metric to compute stats for
// @param[out] stats the stats for this metric 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... | _Static_assert(offsetof(MovementData, version) == 0, "Version not at the start of MovementData") | ;
_Static_assert(sizeof(MovementData) % sizeof(uint32_t) == 0, "MovementData size is invalid");
typedef struct PACKED SleepData {
uint32_t version;
uint32_t last_processed_timestamp;
uint32_t sleep_duration;
uint32_t deep_sleep_duration;
uint32_t fall_asleep_time;
uint32_t wakeup_time;
uint32_t typical_s... |
/*
* 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(text_layer) | ;
return text_layer->should_cache_layout ? text_layer->layout_cache : NULL;
}
void text_layer_update_proc(TextLayer *text_layer, GContext* ctx) {
PBL_ASSERTN(text_layer);
const GColor bg_color = text_layer->background_color;
if (!(gcolor_equal(bg_color, GColorClear))) {
graphics_context_set_fill_color(ctx,... |
se this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR COND... | {
if (length != sizeof(cmd->erase)) {
prv_respond_malformed_command(cmd, length, NULL);
return;
}
if (s_erase_in_progress) {
EraseAndWriteAck *ack = pulse_best_effort_send_begin(
PULSE_PROTOCOL_FLASH_IMAGING);
*ack = (EraseAndWriteAck) {
.opcode = IMAGING_RESP_ACK_ERASE,
.addr... |
static void prv_erase_complete(void *ignored, status_t result) {
EraseAndWriteAck *message = pulse_best_effort_send_begin(
PULSE_PROTOCOL_FLASH_IMAGING);
*message = (EraseAndWriteAck) {
.opcode = IMAGING_RESP_ACK_ERASE,
.address = s_erase_start_address,
.length = s_erase_length,
.complete = ... |
nter_id));
cl_assert_equal_b(false, prv_app_install_is_watchface(menu_layer_id));
cl_assert_equal_b(false, prv_app_install_is_watchface(CRAZY_ID));
}
void test_app_install_manager__get_uuid_for_install_id(void) {
Uuid uuid = {};
cl_assert_equal_b(false, app_install_get_uuid_for_install_id(INSTALL_ID_INVALID, ... | cl_assert_equal_i(ProcessTypeWorker, bg_counter_md_worker->process_type) | ;
cl_assert_equal_i(ProcessStorageFlash, bg_counter_md_worker->process_storage);
app_install_release_md(bg_counter_md_worker);
const PebbleProcessMd *menu_layer_md = app_install_get_md(menu_layer_id, false);
cl_assert(menu_layer_md != NULL);
cl_assert_equal_b(false, menu_layer_md->has_worker);
cl_assert_eq... |
enabled()) {
#if !defined(UNITTEST) && !defined(PLATFORM_TINTIN)
const Fixed_S16_3 fixed_x1 = (Fixed_S16_3) {
.integer = h_range->origin_x,
};
const Fixed_S16_3 fixed_x2 = (Fixed_S16_3) {
.integer = h_range->origin_x + h_range->size_w,
};
graphics_private_draw_horizontal_line_prepared(ct... | (flow_data->perimeter.impl, &ctx_size, vertical_range,
flow_data->perimeter.inset) | ;
prv_debug_perimeter(ctx, &perimeter_horizontal_range, line);
// protect against range expanding: clip perimeter to the original text range
grange_clip((GRange*)&perimeter_horizontal_range, (GRange*)&text_horizontal_range);
text_horizontal_range = perimeter_horizontal_range;
// convert... |
false;
}
// Tests
///////////////////////////////////////////////////////////
void test_wakeup__initialize(void) {
// Wednesday (the 1st) at 00:00
// date -d "2014/01/01 00:00:00" "+%s" ==> 1388563200
fake_rtc_init(0, 1388563200);
// Init fake filesystem used to load/store wakeup events
fake_spi_flash_ini... | (late_wakeup_id) | , late_event);
// Make sure that the next scheduled timer is now the late wakeup id.
cl_assert_equal_i(late_wakeup_id, wakeup_get_next_scheduled());
// Set time 10 minutes into the future, late_event should fire
rtc_set_time(late_event);
// Force wakeup to check for current wakeup event.
wakeup_enable(fa... |
handle_sleep_when_idle_begin() | ;
uint8_t status_register = prv_flash_get_register(FLASH_CMD_READ_STATUS_REG);
uint8_t lock_register = prv_flash_get_register(FLASH_CMD_READ_LOCK_REGISTER);
uint8_t flag_status_register = prv_flash_get_register(FLASH_CMD_READ_FLAG_STATUS_REG);
uint8_t nonvolatile_config_register =
prv_flash_get_register(... | |
if (enable == s_activity_state.started) {
// No change in enabled state, we're done.
goto cleanup;
} |
if (enable) {
// We just got enabled, re-start activity tracking if it should be in the started state
if (s_activity_state.should_be_started) {
prv_start_tracking_cb(NULL);
}
} else {
// We just got disabled. Turn off activity tracking if necessary and set should_be_started
... | |
/*
* 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... | strnlen(key, SETTINGS_KEY_MAX_LEN) | + 1, val, val_len);
settings_file_close(&file);
cleanup:
return (rv == S_SUCCESS);
}
bool shell_prefs_get_clock_24h_style(void) {
return s_is_24h_style;
}
void shell_prefs_set_clock_24h_style(bool is_24h_style) {
mutex_lock(s_mutex);
if (prv_pref_set(PREF_KEY_CLOCK_24H, &s_is_24h_style, sizeof(s_is_24h_sty... |
/graphics/graphics.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/text.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui/text_layer.h"
#include "applib/ui/window.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
#include <inttype... | graphics_context_set_fill_color(ctx, GColorBlack) | ;
graphics_fill_rect(ctx, &bounds);
// Draw UI
draw_ui_element(ctx, GRect(30, 80, 20, 20), "R", data->hue == HUE_RED,
data->selection == ATTRIBUTE_HUE);
draw_ui_element(ctx, GRect(50, 80, 20, 20), "G", data->hue == HUE_GREEN,
data->selection == ATTRIBUTE_HUE);
draw_ui_elem... |
lId id;
info->get_key(file, (uint8_t *)&id, info->key_len);
info->get_val(file, (uint8_t *)cb_data->entry_buf, info->val_len);
// check return value
cb_data->cb(id, cb_data->entry_buf, cb_data->data);
return true; // continue iteration
}
void app_db_enumerate_entries(AppDBEnumerateCb cb, void *data) {
st... | prv_lock_mutex_and_open_file() | ;
if (rv != S_SUCCESS) {
return rv;
}
PBL_ASSERTN(key_len == 16);
AppInstallId app_id = prv_find_install_id_for_uuid(&s_app_db.settings_file, (Uuid *)key);
if (app_id == INSTALL_ID_INVALID) {
rv = E_DOES_NOT_EXIST;
} else if (app_fetch_in_progress()) {
PBL_LOG(LOG_LEVEL_WARNING, "Tried to del... |
/*
* 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... | expandable_dialog_pop(context) | ;
prv_push_settings_menu();
}
static void prv_quick_launch_app_set_select_handler(ClickRecognizerRef recognizer, void *context) {
expandable_dialog_pop(context);
}
static void prv_push_first_use_dialog(void) {
const void *i18n_owner = prv_push_first_use_dialog; // Use this function as the i18n owner
/// Title... |
ickstart__initialize(void) {
// Setup graphics context
framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */... | cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
#endif
}
void test_kickstart__render_PBL_43681(void) {
prv_set_data(&s_data, 0, 1098, 8, 0);
window_set_on_screen(&s_data.window, true, true);
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_kickstart__render_PBL_43717(void) {
prv_set_data(&... |
14:02 2015 PST
.duration = 10,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
},
.attr_list = {
.num_attributes = 0,
.attributes = NULL,
},
.action_group = {
.num_actions = 0,
.actions = NULL,
},
.allocated_buffer ... | cl_assert(has_next) | ;
cl_assert_equal_i(new_idx, 2);
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[0]].header.id,
&timeline_model_get_iter_state(-1)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[1]].header.id,
&timeline_model_get_iter_state(0)->pin... |
= play_count_spawn * duration_a;
// Create 2 animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
animation_set_play_count(b, 0);
// Create a spawn that repeats
Animation *spaw... | cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
// Complete sequence
prv_advance_to_ms_with_timers(start_ms + duration_a + duration_b + 5 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_equal_i(prv_count_hand... |
est_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_nx_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&lay... | (&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 2) | ;
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// AA = true, SW = 3
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 3);
graphics_dra... |
ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-03 08:54:51 local
AccelRawData *activity_sample_walk_100_pbl_25531_5(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25531_5
//> TEST... | |
p the create new alarm screen.
// We don't want to show an empty alarm list
prv_show_deleted_dialog();
Window *editor = alarm_editor_create_new_alarm(prv_handle_alarm_editor_complete, data);
app_window_stack_insert_next(editor);
} else {
prv_update_menu_layer(data, ALARM_INVALID_ID);
... | GPoint((cell_layer->bounds.size.w - data->plus_icon.bounds.size.w) / 2,
(cell_layer->bounds.size.h - data->plus_icon.bounds.size.h) / 2) | ;
box.size = data->plus_icon.bounds.size;
graphics_context_set_compositing_mode(ctx, GCompOpTint);
graphics_draw_bitmap_in_rect(ctx, &data->plus_icon, &box);
return;
}
AlarmNode *node = (AlarmNode*) list_get_at((ListNode*)data->alarm_list_head, cell_index->row - 1);
// Format 1: 10:34 AM
// F... |
/*
* 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... | {
char buffer[] = "abcd";
const uint8_t expected[] = { 0x69, 0xb7, 0x1d };
prv_test_decode_encode("basic", buffer, 4, expected, 3);
} |
{
char buffer[] = "ABCD";
const uint8_t expected[] = { 0x0, 0x10, 0x83 };
prv_test_decode_encode("upper", buffer, 4, expected, 3);
}
{
char buffer[] = "abcdABCD";
const uint8_t expected[] = { 0x69, 0xb7, 0x1d, 0x0, 0x10, 0x83 };
prv_test_decode_encode("twobyte", buffer, 8, expected, 6);... |
GLOBAL_EQUALS_S("s", "20");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {hour: '2-digit'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "20");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "20:04:05");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, "
... | ("s", "20") | ;
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {day: 'numeric'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "25");
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {day: '2-digit'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "25");
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {day: 'short'});");
ASSERT_JS... |
en stop the compass
// service
if (s_high_freq_calib_active) {
prv_calibration_time_expired_cb(NULL);
s_calib_run = false;
}
accel_session_data_unsubscribe(s_accel_session);
accel_session_delete(s_accel_session);
s_accel_session = NULL;
mag_release();
}
}
... | {
PBL_LOG(LOG_LEVEL_INFO, "%s : %d %d %d (type = %d)", "Mag Corr",
(int)new_corr[0], (int)new_corr[1], (int)new_corr[2], (int)cal_status);
} |
bool locked_sol = (cal_status == MagCalStatusNewLockedSolutionAvail);
if (locked_sol || ((cal_status == MagCalStatusNewSolutionAvail) &&
!s_saved_corr_present)) {
s_current_cal_status = CompassStatusCalibrating;
for (int i = 0; i < 3; i++) {
if ((s_active_corr[i] == 0) || locked_so... |
77774");
// Space for positive signed
// No signed conversion occurs, so this is a no-op
snprintf(dstbuf, 256, "There are % o lights, the absolute value of % o", 8, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, the absolute value of 37777777774");
// Plus for positive signed
// No signed conversion... | (dstbuf, 256, "%.1xzero%.1x", 0, 1) | |
* 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
* distributed ... | memcpy(key, "key", sizeof(key)) | ;
uint8_t val[7];
int val_len = 6;
printf("Setting key 10 times and verifying we get the same value back...\n");
for (int i = 0; i < 10; i++) {
snprintf((char *)val, 7, "val%03d", i);
printf("Iteration %d val %s\n", i, val);
set_and_verify(&file, key, key_len, val, val_len);
}
settings_file_cl... |
}
PBL_LOG(LOG_LEVEL_DEBUG, "Got time format msg: is 24 hour: %d", hdr->is_24_hour);
clock_set_24h_style(hdr->is_24_hour);
}
// -----------------------------------------------------------------------------------------
// Handle incoming timeline peek format data (QemuProtocol_TimelinePeek)
static void prv_time... | (LOG_LEVEL_DEBUG, "Dispatching msg of len %"PRIu32" for protocol %d", msg_bytes,
protocol) | ;
const QemuMessageHandler* handler = prv_find_handler(protocol);
if (!handler) {
PBL_LOG(LOG_LEVEL_WARNING, "No handler for protocol: %d", protocol);
} else {
handler->callback(msg_ptr, msg_bytes);
}
}
}
// --------------------------------------------------------------------------------... |
gth);
s_num_sent_handler_called = 0;
s_num_app_outbox_events_sent = 0;
s_num_message_handler_calls = 0;
s_last_message = NULL;
stubs_syscall_init();
s_app_state_app_outbox_subscription_info = (EventServiceInfo) {};
// set to something that is not expected anywhere in the tests:
s_last_sent_status = Ap... | cl_assert_equal_p(s_test_data, s_last_message->data) | |
/*
* 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 ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
int32_t dt = ANIMATION_NORMALIZED_MAX / 16;
int32_t t = 0;
while (t <= ANIMATION_NORMALIZED_MAX) {
graphics_context_set_fill_color(&ctx, GColorFromHEX(0x55aaff));
graphics_fill_rect(&ctx, &ctx.dest... |
int16_t prv_int_scale_and_translate_to(
int16_t value, int16_t size, int16_t from_range, int16_t to_range,
int16_t from_min, int16_t to_min, int32_t normalized, InterpolateInt64Function interpolate);
int64_t prv_default_interpolate(int32_t normalized, int64_t from, int64_t to);
void test_gdraw_command_trans... |
e_spi_flash.h"
#include "fixtures/load_test_resources.h"
static bool s_clock_is_24h_style = false;
bool clock_is_24h_style(void) {
return s_clock_is_24h_style;
}
// Stubs
/////////////////////
#include "stubs_analytics.h"
#include "stubs_app.h"
#include "stubs_app_install_manager.h"
#include "stubs_app_timer.h"
#i... | cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_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... | check_ceil_log_two(100) | ;
check_ceil_log_two(256);
check_ceil_log_two(123456);
}
void test_math__sign_extend(void) {
cl_assert_equal_i(sign_extend(0, 32), 0);
cl_assert_equal_i(sign_extend(0, 3), 0);
cl_assert_equal_i(sign_extend(1, 32), 1);
cl_assert_equal_i(sign_extend(1, 3), 1);
cl_assert_equal_i(sign_extend(-1, 32), -1);
... |
r_callback,
}, &menu_layer);
uint16_t num_apps = app_menu_data_source_get_count(&data_source);
// cl_assert_equal_i(num_apps, num_entries);
for (uint16_t i = 0; i < num_apps; i++) {
AppMenuNode *node = app_menu_data_source_get_node_at_index(&data_source, i);
cl_assert_equal_i(node->install_id, order[i]... | app_menu_data_source_deinit(&data_source) | ;
}
void test_app_menu_data_source__all_floating_apps(void) {
// settings has to be at the beginning. The app_menu_data_source module enforces it
// This test will move the music app to the second position
AppInstallId written_order[] = {APP_ID_SETTINGS, APP_ID_NOTIFICATIONS, APP_ID_ALARMS,
... |
, "key4", "key5" };
int key_len = strlen(keys[0]);
char *values[] = { "val1", "val2", "val3", "val4", "val5" };
int value_len = strlen(values[0]);
// insert all keys
for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
blob_db_insert(BlobDBIdTest, (uint8_t *)keys[i], key_len, (uint8_t *)values[i], value_len);
... | for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
blob_db_insert(id, (uint8_t *)keys[i], key_len, (uint8_t *)values[i], value_len);
} |
s_num_writebacks = 0;
cl_assert(blob_db_sync_db(id) == S_SUCCESS);
}
void test_blob_db_sync__find_session(void) {
// create a few sync sessions
prv_fill_stop_return_session(BlobDBIdTest);
prv_fill_stop_return_session(BlobDBIdPins);
prv_fill_stop_return_session(BlobDBIdReminders);
// check we can conjur... |
ither express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/graphics/utf8.h"
#include "utf8_test_data.h"
#include "clar.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
// Stubs
/////////////... | cl_assert_equal_s((char *)dest, NIHAO_FIRST_CHARACTER) | ;
}
void test_utf8__copy_invalid_last_character(void) {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)"\xf0", 5);
cl_assert_equal_i(copied, 0);
cl_assert_equal_s((char *)dest, "");
}
void test_utf8__invalid_character(void) {
utf8_t dest[5];
memset(dest, 0, 5);... |
case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
s_feb_5_midnight + 8 * SECONDS_PER_HOUR + 16 * SECONDS_PER_MINUTE), 0);
#if CAPABILITY_HAS_CO... | (&iterator) | );
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
cl_assert(!iter_prev(&iterator));
timeline_iter_deinit(&iterator, &state, &head);
}
void test_timeline__skip_deleted_item(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head... |
(LOG_LEVEL_ERROR, "Invalid region (%"PRIu8")", request->region) | ;
}
prv_send_frame(OPCODE_FLASH_GEOMETRY, &response, sizeof(response));
}
static void prv_handle_flash_erase_request(const void *payload, uint32_t length) {
if (length != sizeof(FlashEraseRequest)) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")", length);
return;
}
const FlashEraseRequest *r... | |
ANIMATION_DURATION_INFINITE);
animation_set_elapsed(animation, 20);
prv_play_animation_update(animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 300 - 20);
}
void test_kino_player__finite_animation_infinite_reel_reverse(void) {
// Choose duration and elapsed to have... | (animation_is_scheduled(animation), true) | |
(mcu_state_is_isr()) {
// assume we're in an ISR for the UART and don't need to worry about being blocked
return;
}
mutex_lock_recursive(s_blocked_lock);
}
static void prv_unlock(void) {
if (mcu_state_is_isr()) {
// assume we're in an ISR for the UART and don't need to worry about being blocked
r... | gpio_output_init(&BOARD_CONFIG_ACCESSORY.power_en, GPIO_OType_PP, GPIO_Speed_2MHz) | ;
gpio_output_set(&BOARD_CONFIG_ACCESSORY.power_en, false); // Turn power off
accessory_set_baudrate(DEFAULT_BAUD);
periph_config_release_lock();
prv_initialize_exti();
}
static void prv_set_baudrate(uint32_t baudrate, bool force_update) {
if ((baudrate != s_baudrate) || force_update) {
PBL_LOG(LOG_L... |
/*
* 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 min_gt_guess;
} |
}
// ------------------------------------------------------------------------------------------------
void stats_calculate_basic(StatsBasicOp op, const int32_t *data, size_t num_data,
StatsBasicFilter filter, void *context, int32_t *basic_out) {
if (!data) {
return;
}
int32_t num_... |
);
break;
case FLASH_TEST_CASE_RUN_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Addr Bus Test");
break;
case FLASH_TEST_CASE_RUN_STRESS_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Stress Addr Test");
break;
case FLASH_TEST_CASE_RUN_PERF_DATA_TEST:
text_layer_set_te... | if (status == FLASH_TEST_SUCCESS) {
data->test_case_status = FLASH_TEST_STATUS_PASSED;
}
else {
PBL_LOG(LOG_LEVEL_DEBUG, ">>>>>FAILED TEST CASE<<<<<");
data->test_case_status = FLASH_TEST_STATUS_FAILED;
} |
update_test_case_status(data);
}
static void select_click_handler(ClickRecognizerRef recognizer, void *unusued) {
struct FlashTestData *data = app_state_get_user_data();
if ((data->test_case == FLASH_TEST_CASE_RUN_STRESS_ADDR_TEST) && (data->test_case_status == FLASH_TEST_STATUS_RUNNING)) {
data->test_cas... |
{ 1112, 224, 96},
{ 1128, 144, 184},
{ 928, 104, 176},
{ 800, 144, 56},
{ 800, 80, 80},
// 25 seconds
{ 760, 56, 56},
{ 792, 56, 32},
{ 872, 0, 32},
{ 968, 0, -56},
{ 1040, 0, -96},
{ 1536, -120, -16},
{ 1424, 96, 112},
{ 1128, 368, -120},
{ 1168, 440, -208},
... | { 1176, 472, -104},
{ 840, 464, 24},
{ 608, 184, 112},
{ 784, 240, 24},
{ 808, 168, 96},
{ 840, 272, 72},
{ 784, 400, -16},
{ 872, 504, -96},
{ 992, 496, -96},
// 31 seconds
{ 1208, 376, -24},
{ 1272, 256, 136},
{ 1776, 464, 88},
{ 1216, 504, 0},
{ 984, 288, 5... | |
_file(void) {
mutex_lock(s_app_db.mutex);
status_t rv = settings_file_open(&s_app_db.settings_file,
SETTINGS_FILE_NAME,
SETTINGS_FILE_SIZE);
if (rv != S_SUCCESS) {
mutex_unlock(s_app_db.mutex);
}
return rv;
}
static void prv_close_file... | prv_lock_mutex_and_open_file() | ;
if (rv != S_SUCCESS) {
return rv;
}
bool exists = settings_file_exists(&s_app_db.settings_file, (uint8_t *)&app_id,
sizeof(AppInstallId));
prv_close_file_and_unlock_mutex();
return exists;
}
typedef struct {
AppDBEnumerateCb cb;
void *data;
AppDBEntry *entry... |
turn false;
}
delay_ms(1);
}
return true;
}
void *reset_vector, *initial_sp;
prv_get_fw_reset_vector(&reset_vector, &initial_sp);
if ((uintptr_t)reset_vector == 0xffffffff ||
(uintptr_t)initial_sp == 0xffffffff) {
dbgserial_putstr("Firmware is erased");
return true;
}
ret... | (ERROR_BAD_SPI_FLASH) | |
type;
int16_t rel_bar_value = current ? timeline_layer->relbar_layer.curr_rel_bar.anim_offset :
timeline_layer->relbar_layer.prev_rel_bar.anim_offset;
switch (rel_bar) {
case RelationshipBarTypeFreeTime:
// Draw dotted line
prv_draw_rel_bar_dotted(time... | (&layer->relbar_layer.layer, true) | ;
} else {
layer_set_hidden(&layer->relbar_layer.layer, false);
}
// This check is to ensure rel bar does not show up while day separator is on screen.
// The force animation is used to ensure the rel bar shows up after the day separator is hidden -
// timeline_create_up_down_animation is called both whe... |
/*
* 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... | CREATE_DMA_STREAM(2, 5) | ; // DMA2_STREAM5_DEVICE - ICE40LP TX
// DMA Requests
static DMARequestState s_dbg_uart_dma_request_state;
static DMARequest DBG_UART_RX_DMA_REQUEST = {
.state = &s_dbg_uart_dma_request_state,
.stream = &DMA1_STREAM1_DEVICE,
.channel = 4,
.irq_priority = IRQ_PRIORITY_INVALID, // no interrupts
.priority = DM... |
GSize(20, 8);
const int zone_padding = 2;
for (HRZone i = HRZone_Zone1; i < HRZoneCount; i++) {
if (i <= hr_util_get_hr_zone(active_window->workout_controller->get_metric_value(
WorkoutMetricType_Hr, active_window->workout_data))) {
graphics_fill_rect(ctx, &zone_rect);
} else {
// dra... | {
prv_render_separator(ctx, layer);
} |
}
static void prv_scrollable_layer_update_proc(struct Layer *layer, GContext *ctx) {
WorkoutActiveWindow *active_window = window_get_user_data(layer_get_window(layer));
if (!active_window->num_scrollable_metrics) {
return;
}
WorkoutMetricType metric_type =
active_window->scrollable_metrics[active_... |
/*
* 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... | {
unsigned hour = data->hour;
if (!clock_is_24h_style()) {
hour = hour % 12;
if (hour == 0) {
hour = 12;
}
}
snprintf(buf, 3, "%02u", hour);
return buf;
} |
case TimeInputIndexMinute:
snprintf(buf, 3, "%02u", data->minute);
return buf;
case TimeInputIndexAMPM: // We should only get this in 12h style
if (data->hour < 12) {
i18n_get_with_buffer("AM", buf, 3);
} else {
i18n_get_with_buffer("PM", buf, 3);
}
return bu... |
/*
* 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... | ("Quick Launch First Use") | , RESOURCE_ID_SUNNY_DAY_TINY, text, GColorBlack,
GColorWhite, NULL, RESOURCE_ID_ACTION_BAR_ICON_CHECK, prv_handle_quick_launch_confirm);
expandable_dialog_set_header(expandable_dialog, header);
#if PBL_ROUND
expandable_dialog_set_header_font(expandable_dialog,
fonts_get_sys... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return 0;
} | |
get_time() + 10,
.type = AppGlanceSliceType_IconAndSubtitle,
.icon_and_subtitle.icon_resource_id = TIMELINE_RESOURCE_HOTEL_RESERVATION,
.icon_and_subtitle.template_string = "Test subtitle",
},
{
.expiration_time = rtc_get_time() + 20,
.type = AppGlanceSliceType_IconAn... | (num_slices_added, limit) | ;
// So adding one more slice to the glance should fail
s_test_state.resource_is_valid = true;
slice = (AppGlanceSlice) {
.expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION,
.layout.subtitle_template_string = NULL,
};
cl_assert(app_glance_add_slice(session, slice) & APP_GLANCE_RESULT_SLICE_CAPACITY_EX... |
const uint16_t value_length) {
music_update_track_artist(update->value_str, value_length);
}
static void prv_handle_track_album_update(const AMSEntityUpdateNotification *update,
const uint16_t value_length) {
music_update_track_album(update->value_str, value_length);
... | {
// We've gotten new characteristic references,
// this means the old ones will have been unsubscribed, so we're disconnected from AMS:
prv_set_connected(false);
// We also need to register for entity updates again:
prv_reset_next_entity_to_register();
for (int c = 0; c < NumAMSCharacteristic; c++) {
... |
void ams_handle_service_removed(BLECharacteristic *characteristics, uint8_t num_characteristics) {
ams_invalidate_all_references();
}
void ams_handle_service_discovered(BLECharacteristic *characteristics) {
if (!s_ams_client) {
return;
}
BLE_LOG_DEBUG("In AMS service discovery CB");
PBL_ASSERTN(charac... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, progress_layer->foreground_color) | ;
graphics_draw_round_rect(ctx, bounds, corner_radius);
#endif
}
void progress_layer_init(ProgressLayer* progress_layer, const GRect *frame) {
*progress_layer = (ProgressLayer){};
layer_init(&progress_layer->layer, frame);
progress_layer->layer.update_proc = (LayerUpdateProc) progress_layer_update_proc;
pro... |
www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permission... | (&data->layer, prv_update_proc) | ;
layer_add_child(window_get_root_layer(&data->window), &data->layer);
#endif
const bool animated = false;
app_window_stack_push(window, animated);
}
static void s_main(void) {
prv_handle_init();
app_event_loop();
}
const PebbleProcessMd* panic_app_get_app_info() {
static const PebbleProcessMdSystem s_ap... |
0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the Lic... | if (!vers_info) { // We expect version info
PBL_LOG(LOG_LEVEL_WARNING, "Le Disconnect but no version info?");
} else {
analytics_event_bt_le_disconnection(reason, vers_info->version_number,
vers_info->company_identifier,
... |
}
num_events_logged++;
}
void bluetooth_analytics_handle_connect(
const BTDeviceInternal *peer_addr, const BleConnectionParams *conn_params) {
analytics_inc(ANALYTICS_DEVICE_METRIC_BLE_CONNECT_COUNT, AnalyticsClient_System);
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BLE_CONNECT_TIME, AnalyticsCl... |
rialized_slice_total_size,
.num_attributes = attr_list->num_attributes,
};
// Serialize the slice's attribute list
attribute_list_serialize(attr_list, serialized_slice_header->data, glance_buffer_end);
// Note that we'll destroy the attribute list's attributes below in the cleanup section
/... | {
return E_INVALID_ARGUMENT;
} |
const uint8_t *key = (uint8_t *)uuid;
const int key_size = UUID_SIZE;
const int serialized_glance_size = app_glance_db_get_len(key, key_size);
if (!serialized_glance_size) {
return E_DOES_NOT_EXIST;
} else if (serialized_glance_size < 0) {
WTF;
}
uint8_t *serialized_glance = kernel_zalloc((siz... |
eauth_sms(app_id, message)) {
nexmo_handle_reauth_sms(uid, app_id, message, app_notif_prefs);
goto cleanup;
}
const time_t timestamp = prv_get_timestamp_from_ancs_date(date, app_id);
if (prv_should_ignore_notification(uid, timestamp, notif_attributes, app_notif_prefs)) {
goto cleanup;
}
// If t... | notification_storage_set_status(notification_id, TimelineItemStatusDismissed) | ;
notifications_handle_notification_acted_upon(notification_id);
} else {
// notification_id is passed into an event if a matching notification was found, so it will
// be freed by the system later
kernel_free(notification_id);
}
if (properties & ANCSProperty_IncomingCall) {
ancs_phone_call_... |
/*
* 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_entry) | ) {
if (current_app_id == APP_ID_LAUNCHER_MENU) {
res = prv_get_watchface_compositor_animation(CompositorTransitionDirectionLeft);
goto done;
} else if (current_app_id == APP_ID_HEALTH_APP) {
res = prv_get_health_compositor_animation(CompositorTransitionDirectionDown);
goto done;
} e... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(day, 3) | ;
cl_assert_equal_i(hour, 0);
cl_assert_equal_i(minute, 0);
cl_assert_equal_i(second, 0);
}
{
time_util_split_seconds_into_parts((3 * (24 * 60 * 60)) + (2 * (60 * 60)) + (4 * 60) + 5, &day, &hour, &minute, &second);
cl_assert_equal_i(day, 3);
cl_assert_equal_i(hour, 2);
cl_assert_equal... |
ontinue parsing
}
bool ble_ad_includes_service(const BLEAdData *ad, const Uuid *service_uuid) {
struct IncludesServiceCtx ctx = {
.service_uuid = service_uuid,
.included = false,
};
const BLEAdParseCallbacks callbacks = (const BLEAdParseCallbacks) {
.services_cb = includes_service_parse_cb,
};
b... | (buffer, ad->data, size_to_copy) | ;
return size_to_copy;
}
// -----------------------------------------------------------------------------
//! ble_ad_get_manufacturer_specific_data() wrapper and helper function:
struct ManufacturerSpecificCtx {
uint16_t company_id;
uint8_t *buffer;
const uint8_t size;
size_t copied_size;
};
static bool co... |
static void prv_handle_call_end(bool disconnected);
static bool prv_call_is_ancs(void) {
return (s_call_source == PhoneCallSource_ANCS_Legacy) || (s_call_source == PhoneCallSource_ANCS);
}
static void prv_poll_phone_for_status(void *context) {
pp_get_phone_state();
}
static void prv_timer_callback(void *context)... | if (s_call_in_progress) {
prv_call_end_common();
phone_ui_handle_missed_call();
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_INCOMING_COUNT, AnalyticsClient_System);
} else {
// PBL_LOG(LOG_LEVEL_DEBUG, "Ignoring missed call. A call is not in progress");
} | |
e) {
if (!buffer_size) {
return;
}
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
analytics_read_count++;
analytics_read_bytes_count += buffer_size;
power_tracking_start(PowerSystemFlashRead);
enable_flash_spi_clock();
handle_sleep_whe... | power_tracking_start(PowerSystemFlashErase) | ;
enable_flash_spi_clock();
handle_sleep_when_idle_begin();
flash_write_enable();
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD_ERASE_SECTOR);
flash_send_24b_address(sector_addr);
flash_end_cmd();
flash_wait_for_write();
prv_check_protection_flag();
disable_flash_spi_clock();
pow... |
t(flash_locked);
}
void test_system_flash__erase_full_flash(void) {
cl_assert(system_flash_erase(FLASH_BASE, 1024 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 7), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_sector_0(void) {
cl_assert(system_flash_erase(FLASH_BASE, 16 KiB, ... | (flash_written_flag[address - flash_data_start] == false,
"Overwriting an already-written byte") | ;
if (return_status == FLASH_COMPLETE) {
flash_written_data[address - flash_data_start] = data;
}
return return_status;
}
extern void dbgserial_print(char *str) {
fprintf(stderr, "%s", str);
}
extern void dbgserial_print_hex(uint32_t num) {
fprintf(stderr, "0x%.08x", num);
}
extern void dbgserial_putst... |
/*
* 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... | (simple_dialog, false) | ;
i18n_free(msg, dialog);
return simple_dialog;
}
|
ind_attribute(&score->attr_list,
VibeAttributeId_Pattern,
score->attr_list_size);
if (!notes_attribute || !pattern_attribute) {
return false;
}
unsigned int num_no... | (&score->attr_list,
VibeAttributeId_Pattern,
score->attr_list_size) | ;
PBL_ASSERTN(notes_attribute && pattern_attribute);
VibeNote *note_list = prv_vibe_score_get_note_list(notes_attribute);
VibeNoteIndex *pattern_list = prv_vibe_score_get_pattern_list(pattern_attribute);
unsigned int pattern_length = prv_vibe_score_get_pattern_length(pattern_attribute);
for (unsigned int i ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, &image->layer.bounds) | |
fields_timer = EVENTED_TIMER_INVALID_ID;
kino_layer_deinit(&peek_layer->kino_layer);
text_layer_deinit(&peek_layer->title.text_layer);
text_layer_deinit(&peek_layer->number.text_layer);
text_layer_deinit(&peek_layer->subtitle.text_layer);
layer_deinit(&peek_layer->layer);
}
void peek_layer_set_frame(PeekLaye... | kino_reel_transform_get_to_frame(prev_reel) |
: kino_reel_transform_get_from_frame(prev_reel);
}
kino_layer_set_reel(&peek_layer->kino_layer, NULL, false);
KinoReel *from_reel = kino_reel_create_with_resource_system(peek_layer->res_info.res_app_num,
... |
aw_border(Layer *layer, GContext *ctx, uint8_t radial_padding_size) {
if (radial_padding_size != 0) {
prv_draw_round_border(layer, ctx, 0);
}
prv_draw_round_border(layer, ctx, radial_padding_size);
// Draw letter to identify screen
if (radial_padding_size >= 2) {
GRect identifier_area = GRect(40, 40,... | (window, prv_config_provider) | |
/*
* 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... | memchr(testbuf, 0x78, 8) | , testbuf+3);
}
void test_memchr__unfound(void) {
uint8_t testbuf[8] = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, };
cl_assert_equal_p(memchr(testbuf, 0xFF, 8), NULL);
}
void test_memchr__short_found(void) {
uint8_t testbuf[8] = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0x78, 0xDE, 0xF0, };
cl_assert_equal_p(mem... |
the health APIs may need to go other services besides just the Activity service
// to get information.
static ActivityMetric prv_get_activity_metric(HealthMetric metric) {
switch (metric) {
case HealthMetricStepCount:
return ActivityMetricStepCount;
case HealthMetricActiveSeconds:
return ActivityM... | (daily->totals) | , daily->totals)) {
PBL_LOG(LOG_LEVEL_ERROR, "Error fetching metric data");
return false;
}
// Store in cache if we have space for it.
if (state->cache && (metric == HealthMetricStepCount)) {
memcpy(&state->cache->steps_daily, daily, sizeof(*daily));
state->cache->step_daily_valid = true;
}
r... |
he appropriate statistic given the scope and aggregation
HealthValue result = 0;
HealthServiceStats *which_stats = NULL;
if (scope == HealthServiceTimeScopeDaily) {
which_stats = &stats.daily;
} else if (scope == HealthServiceTimeScopeDailyWeekdayOrWeekend) {
if (is_weekend) {
which_stats = &stats... | MIN(value, minute_data[i].heart_rate_bpm) | |
w_fd);
*fd = prv_pmap_open_debug_wrapper(s_map_filename, OP_FLAG_READ | OP_FLAG_WRITE, 0, 0);
if (*fd < 0) {
PBL_LOG(LOG_LEVEL_WARNING, "pmap enlarge (re-open) failed: %d", *fd);
}
kernel_free(buf);
return (rv);
}
int persist_map_add_uuid(const Uuid *uuid) {
int id = get_next_id();
int fd = prv_pma... | pfs_write(fd, (uint8_t *)&header, sizeof(header)) | |
e, a_tuple->length);
a_tuple = dict_read_next(a);
b_tuple = dict_read_next(b);
}
if (b_tuple) {
cl_fail("Dictionary `B` contained more tuples than dictionary `A`.");
} else if (a_tuple) {
cl_fail("Dictionary `A` contained more tuples than dictionary `B`.");
}
}
// Callbacks
////////////////////... | if (message->transaction_id == TEST_TRANSACTION_ID_2) {
cl_assert_equal_b(s_nack_received_for_id_2, false);
s_nack_received_for_id_2 = true;
cl_assert_equal_i(message->command, CMD_NACK);
} else {
cl_assert(false);
} |
}
static void prv_no_reply_callback(uint16_t endpoint_id,
const uint8_t* data, unsigned int length) {
}
// Overrides
///////////////////////////////////
bool sys_app_pp_has_capability(CommSessionCapability capability) {
return true;
}
static int s_sys_psleep_last_millis;
void sys_psleep(int millis) {
s... |
/*
* 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_command_list[1].addr, 2 * 64 * 1024) | ;
cl_assert_equal_i(s_command_list[1].type, SectorEraseCommand);
}
void test_flash_region__erase_optimal_range_subsectors(void) {
// Offer a less than full sector range but erase the full range
flash_region_erase_optimal_range(0, 4 * 1024, 64 * 1024, 64 * 1024);
cl_assert_equal_i(s_command_list_index, 1);
c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.