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... | {
HealthData health_data = {
.hr_zone1_minutes = 30,
.hr_zone2_minutes = 35,
.hr_zone3_minutes = 40,
};
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
#if PBL_ROUND
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);... | |
0, 16},
{ 1488, 400, 32},
{ 1408, 208, 144},
{ 1376, -120, 224},
{ 1264, 216, -48},
// 40 seconds
{ 1008, 152, 64},
{ 1048, 280, 56},
{ 1152, 360, -120},
{ 800, 288, -64},
{ 1232, 104, 160},
{ 960, -40, 216},
{ 1160, 216, -88},
{ 1384, 288, -40},
{ 1376, 312, -48}... | { 888, 40, -72},
{ 1064, -16, 32},
{ 1136, 168, 0},
{ 1288, 256, -128},
{ 1568, 248, -104},
{ 1704, 336, -224},
{ 1248, 328, -200},
{ 1048, 272, -232},
{ 1208, 256, -64},
{ 1256, 312, 8},
{ 1224, 408, 16},
{ 1312, 504, 48},
{ 1560, 664, 96},
// 46 seconds
{ 11... |
{ 960, 520, 152},
{ 992, 592, 96},
{ 1056, 696, 216},
{ 1480, 688, 320},
{ 1528, 384, 240},
{ 1432, 224, 176},
{ 1336, 144, 96},
{ 1288, 168, -8},
{ 1168, 200, -48},
{ 1088, 184, -32},
{ 1216, 176, -48},
{ 1024, 200, -192},
{ 936, 88, -136},
{ 1024, 104, -128},
... |
// Update the completion percent of the animation. This is a reverse animation. It starts
// fully drawn, then the amount drawn decreases
selection_layer->slide_settle_anim_progress =
100 - (100 * distance_normalized) / ANIMATION_NORMALIZED_MAX;
layer_mark_dirty(&selection_layer->layer);
}
static void pr... | window_set_click_context(BUTTON_ID_DOWN, selection_layer) | ;
window_set_click_context(BUTTON_ID_SELECT, selection_layer);
window_single_repeating_click_subscribe(BUTTON_ID_UP,
BUTTON_HOLD_REPEAT_MS,
prv_up_down_click_handler);
window_single_repeating_click_subscribe(BUTTON_ID_DOWN,
... |
ied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ble_demo_scan.h"
static MenuLayer *s_menu_layer;
struct ScanResult;
typedef struct ScanResult {
struct ScanResult *next;
BTDevice device;
int8_t rssi;
int8_t tx_power_level;
char loc... | if (ble_ad_get_tx_power_level(ad_data, &tx_power_level)) {
APP_LOG(APP_LOG_LEVEL_INFO, "TX Power: %d", tx_power_level);
result->tx_power_level = tx_power_level;
} | |
reset");
}
}
// SystemInit does this for the firmware, but since the bootloader isn't using
// the vendor SystemInit, initialize the flash cache here
static void prv_configure_system_flash(void) {
// Enable flash instruction and data caches
FLASH->ACR = FLASH_ACR_ICEN | FLASH_ACR_DCEN;
}
// RTC and bootbit assu... | prv_sad_watch(ERROR_CANT_LOAD_FW) | |
/*
* 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(context.okay == true) | ;
cl_assert(context.expected_size == size);
}
void test_dict__write_read(void) {
// Stack allocated buffer:
const uint8_t key_count = 10;
const uint32_t size = dict_calc_buffer_size(key_count,
sizeof(SOME_DATA),
strlen(... |
_legend;
bitblt_bitmap_into_bitmap_tiled(&dest_bitmap, &test_bmp, upper_legend_rect, GPointZero, GCompOpAssign, GColorWhite);
test_bmp.addr = test_blend_colors;
bitblt_bitmap_into_bitmap_tiled(&dest_bitmap, &test_bmp, upper_rect, GPointZero, GCompOpTint, upper_tint_color);
// Lower row with destination... | GRect(0, 0, src_bitmap->bounds.size.w, src_bitmap->bounds.size.h*2 + 4) | ;
bitblt_bitmap_into_bitmap_tiled_8bit_to_8bit(
&dest_bitmap, src_bitmap, dest_rect, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_wrap_y-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test src_origin_offset, shouldn't see any red in dest_bitma... |
ense");
* 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 an "AS IS" BASIS,
* WI... | {
LOCK_AND_GET_STORE(store);
status_t result = settings_file_set(store, &key, sizeof(key),
&value, sizeof(value));
return PASSED(result) ? (status_t)sizeof(value) : result;
} |
// FIXME: PBL-23877 Disallow and document persist write data of length 0 edge case
DEFINE_SYSCALL(int, persist_write_data, const uint32_t key,
const void *buffer, const size_t buffer_size) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(buffer, buffer_size);
}
const si... |
/*
* 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... | prompt_send_response("OK") | ;
} else {
prompt_send_response("No worker with id");
}
}
|
le/dbgserial.h"
#include "console/pulse_internal.h"
#include "console/pulse_llc.h"
#include "console/pulse_protocol_impl.h"
#include "kernel/pbl_malloc.h"
#include "os/mutex.h"
#include "services/common/new_timer/new_timer.h"
#include "services/common/system_task.h"
#include "system/passert.h"
#include "util/attributes... | dbgserial_restore_baud_rate() | ;
serial_console_set_state(SERIAL_CONSOLE_STATE_LOGGING);
}
void pulse_prepare_to_crash(void) {
}
static void prv_process_received_frame(void *frame_ptr) {
IncomingPulseFrame *frame = frame_ptr;
uint32_t fcs;
// Comply with strict aliasing rules. The memcpy is optimized away.
memcpy(&fcs, &frame->data[frame... |
/*
* 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 false;
} |
GDrawState graphics_context_get_drawing_state(GContext *ctx) {
return (GDrawState) { };
}
bool graphics_release_frame_buffer(GContext *ctx, GBitmap *buffer) {
return false;
}
void graphics_context_set_drawing_state(GContext *ctx, GDrawState draw_state) {
}
void window_schedule_render(struct Window *window) {
}... |
tarting_ticks;
uint32_t count_per_sec;
AnalyticsClient client;
} AnalyticsStopwatchNode;
static ListNode *s_stopwatch_list = NULL;
static bool prv_is_stopwatch_for_metric(ListNode *found_node, void *data);
void analytics_init(void) {
analytics_metric_init();
analytics_storage_init();
analytics_logging_init(... | analytics_storage_take_lock() | ;
// Stopwatch metrics must be UINT32!
PBL_ASSERTN(analytics_metric_element_type(metric) == ANALYTICS_METRIC_ELEMENT_TYPE_UINT32);
if (prv_find_stopwatch(metric)) {
// TODO: Increment this back up to LOG_LEVEL_WARNING when it doesn't happen
// on every bootup (PBL-5393)
PBL_LOG(LOG_LEVEL_DEBUG, "Ana... |
;
const int play_count_b = 3;
const int total_duration_b = play_count_b * (delay_b + duration_b);
const int delay_seq = 150;
const int play_count_seq = 2;
int duration_total = play_count_seq * (total_duration_a + total_duration_b + delay_seq);
// Create 2 test animations
Animation *a = prv_create_test... | (spawn, false, true) | ,
play_count_spawn * (MAX(total_duration_a, total_duration_b)));
cl_assert_equal_i(animation_get_duration(spawn, true, false),
delay_spawn + MAX(total_duration_a, total_duration_b));
cl_assert_equal_i(animation_get_duration(spawn, true, true), duration_total);
animation_de... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | applib_free(custom_reel) | |
tations under the License.
*/
#include "ice40lp.h"
#include "board/board.h"
#include "drivers/gpio.h"
#include "drivers/spi.h"
#include "drivers/pmic.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/delay.h"
#include "stm32f4xx.h"
#include "misc.h"
#include <string.h>
// We want the SPI c... | PBL_LOG(LOG_LEVEL_DEBUG, "Enabling 6v6 (Display VDDC)") | ;
set_6V6_power_state(true);
delay_ms(2);
PBL_LOG(LOG_LEVEL_DEBUG, "Enabling 4v5 (Display VDDP)");
set_4V5_power_state(true);
}
void display_power_disable(void) {
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling 4v5 (Display VDDP)");
set_4V5_power_state(false);
delay_ms(2);
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling 6... |
/*
* 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... | (BUTTON_ID_UP, prv_click_confirm_decline_callback) | ;
window_single_click_subscribe(BUTTON_ID_DOWN, prv_click_confirm_decline_callback);
window_single_click_subscribe(BUTTON_ID_BACK, prv_click_confirm_decline_callback);
}
void switch_worker_confirm(AppInstallId new_worker_id, bool set_as_default,
WindowStack *window_stack) {
AppInstallI... |
ll_cols(GContext *ctx, uint8_t color, int16_t *row, int16_t column,
uint8_t num_pixels) {
const GRect rect = { { column, *row }, { 1, num_pixels } };
// Set alpha bits to make it opaque
graphics_context_set_fill_color(ctx, (GColor) { .argb = (0b11000000 | color) });
graphics_fill_rect... | prv_draw_solid(layer, ctx, GColorBlue) | ;
break;
#endif
#if PBL_ROUND
case TestPattern_Border1:
prv_draw_crosshair_screen(layer, ctx, 2);
break;
case TestPattern_Border2:
prv_draw_crosshair_screen(layer, ctx, 3);
break;
case TestPattern_Border3:
prv_draw_crosshair_screen(layer, ctx, 4);
break;
#endif
#if PBL_COLOR
case Tes... |
cantUpdate) {
if (state->cache) {
state->cache->valid_flags = 0;
}
}
// If this is a step update, update the cached value for today
else if (e->health_event.type == HealthEventMovementUpdate) {
if (state->cache) {
state->cache->steps_daily.totals[0] = e->health_event.data.movement_update.... | {
return (index > 0 && value > 0);
} |
bool health_service_private_weekday_filter(int index, int32_t value, void *tm_weekday_ref) {
const int tm_weekday = (int)(uintptr_t)tm_weekday_ref;
return (health_service_private_non_zero_filter(index, value, NULL) &&
IS_WEEKDAY(positive_modulo(tm_weekday - index, DAYS_PER_WEEK)));
}
bool health_service_priv... |
te_with_resource_system(res_info->res_app_num, res_info->res_id);
const KinoReelType reel_type = kino_reel_get_type(reel);
if ((reel_type != KinoReelTypeGBitmap) && (reel_type != KinoReelTypePDCI)) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Invalid published icon type");
is_valid = false;
} else {
const size_t r... | {
goto fail;
} |
if (res_info_out->res_id == RESOURCE_ID_INVALID) {
goto fail;
}
} else {
const AppInstallId install_id = app_install_get_id_for_uuid(timeline_res->app_id);
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(install_id, &entry)) {
goto fail;
}
// Only try to loa... |
/*
* 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... | gdraw_command_image_attract_to_square(l, t += dt) | ;
gdraw_command_image_draw(&ctx, l, GPoint(48, 0));
l = weather_app_resource_create_sun();
gdraw_command_image_attract_to_square(l, t += dt);
gdraw_command_image_draw(&ctx, l, GPoint(0, 48));
l = weather_app_resource_create_sun();
gdraw_command_image_attract_to_square(l, t += dt);
gdraw_command_image_dr... |
HcProtocolMessage *msg,
PPoGATTWorkAroundState *state) {
PBL_ASSERTN(msg->command_id == HcMessageID_Gatt_Write);
HcGattHdr *hdr = (HcGattHdr *)&msg->payload[0];
BTErrno rv = BTErrnoOK;
hc_protocol_enqueue_response(msg, (uint8_t *)&rv, sizeof(rv)); // ack the write
... | prv_convert_uuid_to_little_endian((const uint8_t[]){PEBBLE_BT_UUID_EXPAND(
PEBBLE_BT_PPOGATT_WATCH_SERVER_SERVICE_UUID_32BIT)}, &uuid) | ;
PBL_ASSERTN(ble_gatts_add_service(&uuid, GATT_SERVICE_PRIMARY, num_attr, start_hdl) == 0);
prv_convert_uuid_to_little_endian((const uint8_t[]){PEBBLE_BT_UUID_EXPAND(
PEBBLE_BT_PPOGATT_WATCH_SERVER_DATA_CHARACTERISTIC_UUID_32BIT)}, &uuid);
PBL_ASSERTN(ble_gatts_add_characteristic(&uuid, GATT_PROP_WRITE_NO... |
e "stubs_ui_window.h"
#include "stubs_unobstructed_area.h"
// Tests
////////////////////////////////////
/////////////////////////////////
/// Generic matrix tests
/////////////////////////////////
void test_graphics_gtransform_${BIT_DEPTH_NAME}__types_gtransformnumber(void) {
GTransform t_c; // matrix to compare ... | gtransform_is_equal(&t, &t_c) | );
cl_assert(gtransform_is_only_translation(&t));
cl_assert(gtransform_is_only_translation(&t_c));
t_c = GTransformTranslationFromNumber(2, 5);
cl_assert(gtransform_is_equal(&t, &t_c));
// Test Rotation Matrix
int32_t angle = DEG_TO_TRIGANGLE(45);
t = GTransformRotation(angle);
int32_t cosine = cos_l... |
mplex = animation_spawn_create(seq, c, NULL);
cl_assert(complex != NULL);
animation_set_handlers(complex, handlers, complex);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(complex);
// ----------------------------------------------------------------------------------... | cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 1);... |
/*
* 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_ERROR, "Failed to enqueue callback; aborting erase");
prv_unlock_erase_mutex();
s_erase_state.on_complete(s_erase_state.on_complete_context, E_INTERNAL);
} |
} else {
prv_unlock_erase_mutex();
s_erase_state.on_complete(s_erase_state.on_complete_context, result);
}
}
static void prv_erase_next_async(void *ignored) {
uint32_t addr = s_erase_state.next_erase_addr;
if ((addr & ~SECTOR_ADDR_MASK) == 0 &&
addr + SECTOR_SIZE_BYTES <= s_erase_state.end_addr)... |
s_and_reset_test_counters();
s_last_response_cookie = 0;
s_boot_bits_orred = 0;
s_do_before_write = NULL;
// Common for most tests:
s_firmware_update_is_in_progress = true;
fake_spi_flash_init(0, 0x1000000);
put_bytes_init();
}
void test_put_bytes__cleanup(void) {
put_bytes_deinit();
fake_comm_se... | {
const uint8_t incomplete_init_msg = CmdInit;
prv_receive_data(s_session, (const uint8_t *) &incomplete_init_msg,
sizeof(incomplete_init_msg));
assert_ack_count(0);
assert_nack_count(1);
} |
void test_put_bytes__init_invalid_object_type(void) {
PutBytesObjectType invalid_object_type = 0xff;
prv_receive_init(VALID_OBJECT_SIZE, invalid_object_type);
// Fail due to massive total_size in our init message
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__init_firmware_object_while_... |
/*
* 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 (s_counter == 0) {
prv_execute_gibberish();
} |
prv_update_text();
app_timer_register(1000, prv_timer_callback, 0);
}
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
text_layer = text_layer_create((GRect) { .origin = { 0, 72 }, .size = { bounds.size.w, 20 } }... |
/*
* 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_theme_get_font_for_default_size(TextStyleFont_MenuCellSubtitle) | ;
}
static ALWAYS_INLINE GFont prv_get_cell_value_font(const MenuCellLayerConfig *config) {
return config->value_font ?: prv_get_cell_title_font(config);
}
static ALWAYS_INLINE void prv_draw_icon(GContext *ctx, GBitmap *icon, const GRect *icon_frame,
bool is_legacy2) {
if (... |
n 4;
default:
WTF;
return 0;
}
}
static void prv_set_constant_config(DMARequest *this) {
uint32_t cr_value = 0;
uint32_t fcr_value = 0;
// set the channel
PBL_ASSERTN((this->channel & (DMA_SxCR_CHSEL >> CHSEL_OFFSET)) == this->channel);
cr_value |= this->channel << CHSEL_OFFSET;
// set ... | {
// If a cache line within the dst gets evicted while we do the transfer, it'll corrupt SRAM, so
// just invalidate it now.
dcache_invalidate(dst, length);
// since the dst address is cachable, it needs to be aligned to a cache line and
// the length must be an even multiple of cache lines
cons... | else {
PBL_ASSERTN(((length & alignment_mask) == 0) &&
(((uintptr_t)dst & alignment_mask) == 0) &&
(((uintptr_t)src & alignment_mask) == 0));
}
#if PLATFORM_ROBERT
// There is an erratum in the STM32F7xx MCUs in which causes DMA transfers
// that read from the DTCM to read ... |
ents can be placed between the top of APP_RAM
// and the end of stack. Stacks always grow towards lower memory addresses, so
// we want a stack overflow to touch the stack guard region before it begins
// to clobber actual data. And syscalls assume that the stack is always at the
// top of APP_RAM; violating th... | process_metadata_get_name(s_app_task_context.app_md) | );
TaskParameters_t task_params = {
.pvTaskCode = prv_app_task_main,
.pcName = task_name,
.usStackDepth = stack_size / sizeof(portSTACK_TYPE),
.pvParameters = entry_point,
.uxPriority = APP_TASK_PRIORITY | portPRIVILEGE_BIT,
.puxStackBuffer = stack,
};
PBL_LOG(LOG_LEVEL_DEBUG, "Starting ... |
e->test_entry.num_samples++] = (AccelRawData) {
.x = x,
.y = y,
.z = z,
};
continue;
}
// End of a sample
if (strcmp(token, "}") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
break;
}
}
// Did we get samples?
if (state->test_entry.num_sample... | {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.cur_state_elapsed.min);
} | else if (strcmp(token, "TEST_CUR_STATE_ELAPSED_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.cur_state_elapsed.max);
} else if (strcmp(token, "TEST_IN_SLEEP") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.value);
} else if (strcmp(t... |
e) {
goto exit;
}
session->data->write_request_pending = false;
int bytes_remaining = shared_circular_buffer_get_read_space_remaining(
&session->data->buffer, &session->data->buffer_client);
if (bytes_remaining == 0) {
goto exit;
}
got_session_file = prv_get_session_file(session, bytes_remain... | {
PBL_LOG(LOG_LEVEL_ERROR, "Nuking storage for session %d", logging_session->comm.session_id);
dls_storage_delete_logging_storage(logging_session);
} | |
g since power-on or off-wrist
if (s_manager_state.sensor_start_ticks == 0) {
s_manager_state.sensor_start_ticks = rtc_get_ticks();
}
// When first powering up, we can get "Excellent" quality readings the first few seconds, even
// though the BPM is 0. Let's fix the quality if the BPM is too low to be valid... | accel_manager_set_jitterfree_sampling_rate(s_manager_state.accel_state,
HRM_MANAGER_ACCEL_RATE_MILLIHZ) | ;
sys_accel_manager_set_sample_buffer(
s_manager_state.accel_state, s_manager_state.accel_manager_buffer,
HRM_MANAGER_ACCEL_MANAGER_SAMPLES_PER_UPDATE);
hrm_enable(HRM);
// Don't need the re-enable timer to fire
new_timer_stop(s_manager_state.update_enable_timer_id);
}... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_pause_reconnect_if_needed() | |
to using a TimelineResourceId
music_glance->icon = kino_reel_create_with_resource(new_icon_resource_id);
PBL_ASSERTN(music_glance->icon);
music_glance->icon_resource_id = new_icon_resource_id;
}
static bool prv_should_display_music_state(MusicPlayState play_state,
uint3... | (music_glance->title, node->name, title_size) | |
((resp_ptr - s_data) == s_sending_data_length) | ;
}
/**************************************************
* Checking for key size zero INSERT command *
**************************************************/
static const uint8_t s_insert_cmd_zero_key_size[] = {
// Message Header
0x01, // Pebble protocol message ID: INSERT
0x17, 0x00, ... | |
e License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/graphics/graphics_circle.h"
#include "util/trig.h"
#include "clar.h"
#include "pebble_asserts.h"
#include <stdio.h>
// stubs
#include "stubs_process_manager.h"
#include "stubs_passert.h"
#include "st... | GRect(0, 0, 10, 10) | ;
const GRect resulting_rect1 = grect_centered_from_polar(container_rect1, mode, 0, GSize(3, 5));
cl_assert_equal_grect(resulting_rect1, GRect(3, -2, 3, 5));
// Container rect is offset from GPointZero
const GRect container_rect2 = GRect(2, 2, 4, 4);
const GRect resulting_rect2 = grect_centered_from_polar(co... |
ANIMATION_NORMALIZED_MAX);
prv_modal_transition_fill_update(ctx, distance_normalized, true /* fill inner */);
}
}
static void prv_modal_transition_animation_update_rect(GContext *ctx, Animation *animation,
uint32_t ... | {
// NOTE: This initialization will set .expanding to false so we default to contracting to a dot
s_data = (CompositorModalTransitionData) {
.modal_is_destination = modal_is_destination,
// TODO: PBL-19849
// Decide on the logistics of the background color of the modal pop animation, including
// pr... |
const CompositorTransition *prv_modal_transition_get_round(bool modal_is_destination) {
s_data = (CompositorModalTransitionData) {
.modal_is_destination = modal_is_destination,
};
if (!modal_is_destination) {
return compositor_round_flip_transition_get(false /* flip_to_the_right */);
} else {
sta... |
/*
* 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_append((ListNode *)s_subscribe_head, &subscribe->node);
} | else {
s_subscribe_head = subscribe;
}
return s_subscribe_return_value;
}
bool gatt_client_subscriptions_get_notification_header(GAPLEClient client,
GATTBufferedNotificationHeader *header_out) {
return false;
}
uint16_t gatt_client_subscriptions_consum... |
-256},
{ 816, 712, -304},
{ 968, 824, -392},
{ 936, 808, -344},
{ 856, 696, -264},
// 58 seconds
{ 1120, 736, -232},
{ 1096, 808, -280},
{ 1304, 864, -328},
{ 1576, 792, -112},
{ 1456, 560, -40},
{ 1216, 424, -112},
{ 1048, 392, -88},
{ 992, 352, -96},
{ 944, 296... | { 688, 512, -408},
{ 832, 552, -456},
{ 896, 592, -488},
{ 1032, 688, -448},
{ 1016, 752, -360},
{ 1208, 824, -312},
{ 1120, 808, -312},
{ 1392, 688, -288},
{ 1728, 664, -216},
{ 1464, 528, -160},
{ 1008, 384, -200},
{ 856, 296, -200},
{ 776, 224, -240},
{ 696, 15... |
{ 1336, 488, -24},
{ 1168, 384, -8},
// 66 seconds
{ 1032, 360, -32},
{ 952, 336, -24},
{ 896, 304, 8},
{ 840, 272, 16},
{ 824, 248, -40},
{ 864, 232, -40},
{ 848, 208, -64},
{ 864, 184, -120},
{ 1008, 248, -208},
{ 1008, 264, -360},
{ 776, 256, -512},
{ 1032... |
/*
* 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... | strtol(" 500", NULL, 10) | , 500);
cl_assert_equal_i(strtol(" 765", NULL, 10), 765);
cl_assert_equal_i(strtol(" 573888", NULL, 10), 573888);
cl_assert_equal_i(strtol(" 713713", NULL, 10), 713713);
}
void test_strtol__suffix(void) {
cl_assert_equal_i(strtol("500hurf", NULL, 10), 500);
cl_assert_equal_i(strtol("76... |
----------------------------------------------------
// Event service handler for double tap events
static void prv_session_do_double_tap_handle(PebbleEvent *e, void *context) {
AccelServiceState *state = context;
if (state->double_tap_handler != NULL) {
state->double_tap_handler(e->accel_tap.axis, e->accel_tap... | {
// There is a pending event posted. Only session tasks allocate memory for their state in the
// first place so only free the memory if this is true
state->deferred_free = prv_is_session_task();
} |
applib_free(state->raw_data);
state->manager_state = NULL;
state->raw_data = NULL;
state->data_handler = NULL;
state->raw_data_handler = NULL;
state->raw_data_handler_deprecated = NULL;
}
// -----------------------------------------------------------------------------------------------
int accel_session... |
tsBasicOp_Min | StatsBasicOp_Max |
StatsBasicOp_Count | StatsBasicOp_Consecutive | StatsBasicOp_ConsecutiveFirst |
StatsBasicOp_Median);
struct {
int32_t sum;
int32_t avg;
int32_t min;
int32_t max;
int32_t count;
int32_t max_streak;
int32_t first_streak;
int32_t median;
... | {
const int32_t data[] = {};
const size_t num_data = 0;
const StatsBasicOp op =
(StatsBasicOp_Sum | StatsBasicOp_Average | StatsBasicOp_Min | StatsBasicOp_Max |
StatsBasicOp_Count | StatsBasicOp_Consecutive | StatsBasicOp_ConsecutiveFirst |
StatsBasicOp_Median);
struct {
int32_t su... | |
/*
* 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... | SDL_SetVideoMode(DISP_COLS, DISP_ROWS, 8 /* bits/pixel */, SDL_HWSURFACE) | |
tem_out) {
PBL_ASSERTN(item_out && (s_notif_storage_mutex != NULL));
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return false;
}
bool rv = true;
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
char uuid_string[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(id, uuid_string... | prv_file_open(OP_FLAG_READ) | ;
if (fd < 0) {
return false;
}
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
// Find the most recent notification which matches this ANCS UID - this will be the last entry in
// the db. iOS can reset ANCS UIDs on reconnect, so we want to avoid finding an old notification
bool f... |
ot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
}
return false;
}
static bool prv_prf_button_combination_is_pressed(void) {
return (button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK)
&& button_is_pressed(BUTTON_ID_SELECT) && !button_is_pressed(BUTTON_ID_DOWN));
}
static bool check_force_... | (0x01234567) | ;
delay_us(200000);
display_error_code(0x89abcdef);
delay_us(200000);
display_error_code(0xcafebabe);
delay_us(200000);
display_error_code(0xfeedface);
delay_us(200000);
display_error_code(0x8badf00d);
delay_us(200000);
display_error_code(0xbad1ce40);
delay_us(200000);
di... |
/*
* 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(gbitmap_init_with_resource_system(&bitmap, 0, 0)) | ;
// However, if we corrupt the row_size_bytes field we should fail.
s_fake_bitmap_data.row_size_bytes = 12;
cl_assert(!gbitmap_init_with_resource_system(&bitmap, 0, 0));
// Corrupt it the other way, so that there's not enough data
s_fake_bitmap_data.row_size_bytes = 4;
cl_assert(!gbitmap_init_with_resour... |
nt prv_qsort_activity_test_entry_cb(const void *a, const void *b) {
ActivityFileTestEntry *entry_a = (ActivityFileTestEntry *)a;
ActivityFileTestEntry *entry_b = (ActivityFileTestEntry *)b;
return strcmp(entry_a->name, entry_b->name);
}
// ======================================================================... | prv_accel_sample_discovery_next(&test_entry[num_tests]) | |
nager.h"
#include "services/common/compositor/compositor_transitions.h"
#define WATCHFACE_SHUTTER_COLOR GColorWhite
#define HEALTH_SHUTTER_COLOR PBL_IF_COLOR_ELSE(GColorBlack, GColorWhite)
#define ACTION_SHUTTER_COLOR PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite)
static const CompositorTransition *prv_get_watchface... | if (current_app_id == APP_ID_LAUNCHER_MENU) {
res = prv_app_launcher_transition_animation(CompositorTransitionDirectionRight);
goto done;
} |
// If we get here, we don't use a compositor animation for the transition
done:
kernel_free(app_entry);
return res;
}
|
end = 1 << 3,
},
.dummy_cycles = {
.fast_read = 4,
},
.block_lock = {
.has_lock_data = false,
.locked_check = 0xff,
.protection_enabled_mask = (1 << 7),
},
.reset_latency_ms = 13,
.suspend_to_read_latency_us = 20,
.standby_to_low_power_latency_us = 10,
.low_power_to_standby_latency_us... | qspi_flash_get_write_status(QSPI_FLASH) | ;
}
status_t flash_impl_enter_low_power_mode(void) {
qspi_flash_set_lower_power_mode(QSPI_FLASH, true);
return S_SUCCESS;
}
status_t flash_impl_exit_low_power_mode(void) {
qspi_flash_set_lower_power_mode(QSPI_FLASH, false);
return S_SUCCESS;
}
status_t flash_impl_set_burst_mode(bool burst_mode) {
// NYI
r... |
_progress = false;
return false;
}
if (result != GET_BYTES_ALREADY_IN_PROGRESS) {
s_get_bytes_in_progress = false;
}
prv_put_status_event(DebugInfoStateFinished);
return true;
}
static void prv_gather_and_record_stats(GetBytesState *state) {
uint32_t elapsed_time_ms = ticks_to_milliseconds(rtc_g... | (DebugInfoStateFinished) | |
iptionDialog *transcription_dialog = transcription_dialog_create();
static char transcription[500] = {0};
uint16_t len = strlen(data->long_message);
strncpy(transcription, data->long_message, len);
transcription_dialog_update_text(transcription_dialog, transcription, len);
app_transcription_dialog_push(transc... | app_zalloc_check(sizeof(DialogsData)) | ;
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Dialogs"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);... |
/! running (scheduled) this value will be zero.
RtcTicks expire_time;
RtcTicks period_ticks;
TaskTimerID id; //<! ID assigned to this timer
//! client provided callback function and argument
TaskTimerCallback cb;
void* cb_data;
//! True if this timer should automatically be rescheduled for ... | list_contains(manager->idle_timers, &timer->list_node) | );
list_remove(&timer->list_node, &manager->idle_timers /* &head */, NULL /* &tail */);
}
// Set timer variables
timer->cb = cb;
timer->cb_data = cb_data;
timer->expire_time = current_time + timeout_ticks;
timer->repeating = flags & TIMER_START_FLAG_REPEATING;
timer->period_ticks = timeout_ticks;
... |
(LOG_LEVEL_WARNING, "Adding attribute with type ResourceId for non-ResourceId " \
"attribute") | ;
}
prv_add_attribute(list, id)->uint32 = resource_id;
}
void attribute_list_add_uint8(AttributeList *list, AttributeId id, uint8_t uint8) {
if (prv_attribute_type(id) != AttributeTypeUint8) {
PBL_LOG(LOG_LEVEL_WARNING, "Adding attribute with type uint8 for non-uint8_t attribute");
}
prv_add_attribute(li... | |
poll_or_final:1;
uint8_t ack_number:7;
} s;
} ReliablePacket;
static PulseControlMessageProtocol s_reliable_pcmp = {
.send_begin_fn = pulse_reliable_send_begin,
.send_fn = pulse_reliable_send,
};
_Static_assert(sizeof((ReliablePacket){0}.i) == 6,
"sizeof ReliablePacket.i is wrong");
_Static_... | ntoh16(packet->i.length) | <= length) {
size_t info_length = ntoh16(packet->i.length) - sizeof(ReliablePacket);
// This variable is read in the macro-expansion below, but linters
// have a hard time figuring that out.
(void)info_length;
switch (ntoh16(packet->i.protocol)) {
case PULSE_CONTROL_M... |
ntf(data->percent_done_text_buffer,
sizeof(data->percent_done_text_buffer), "%u%%", data->percent_complete);
layer_mark_dirty(&data->percent_done_text_layer.layer);
}
static void prv_update_progress(ProgressUIData *data) {
switch (data->progress_source) {
case PROGRESS_UI_SOURCE_COREDUMP: {
b... | (sizeof(ProgressUIData)) | ;
Window* window = &data->window;
window_init(window, WINDOW_NAME("Progress UI App"));
window_set_user_data(window, data);
window_set_overrides_back_button(window, true);
window_set_background_color(window, PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite));
window_set_window_handlers(window, &(WindowHandler... |
are
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/app_message/app_message_internal.h"
#include... | (app_message_send_job->session) | ;
const size_t length_available = prv_get_length(app_message_send_job);
const size_t length_after_offset = (length_available - start_offset);
const size_t length_to_copy = MIN(length_after_offset, length);
size_t length_remaining = length_to_copy;
while (length_remaining) {
const uint8_t *part_data;
... |
EXECUTE_SCRIPT("_rocky.on('draw', function(e) {});") | ;
Layer *l = &app_window_stack_get_top_window()->layer;
l->update_proc(l, NULL);
cl_assert_equal_i(1, s_fonts_get_system_font.call_count);
cl_assert_equal_i(GTextAlignmentLeft, s_rocky_text_state.alignment);
cl_assert_equal_i(GTextOverflowModeWordWrap, s_rocky_text_state.overflow_mode);
cl_assert_equal_p(N... | |
16G:
mgs_per_digit = 12;
break;
default:
WTF;
}
// least significant 4 bits need to be removed
return ((raw >> 4) * mgs_per_digit);
}
static int16_t get_axis_data(AccelAxisType axis, uint8_t *raw_data) {
// each sample is 2 bytes for each axis
int offset = 2 * BOARD_CONFIG_ACCEL.accel_... | accel_stop() | ;
prv_accel_configure_interrupts();
}
void lis3dh_power_up(void) {
if (accel_start()) {
uint8_t ctrl_reg1;
if (prv_read_register(LIS3DH_CTRL_REG1, &ctrl_reg1)) {
ctrl_reg1 &= ~LPen;
if (prv_write_register(LIS3DH_CTRL_REG1, ctrl_reg1)) {
// Write successful, low power mode disabled
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (uint16_t i = 0; i < region_count; i++, cursor += TIMEZONE_NAME_LENGTH) {
timezone_database_load_region_name(i, cursor);
prv_format_region_name(cursor);
// Split 'Continent/City' into the two parts
const int sep_pos = strcspn(cursor, "/");
cursor[sep_pos] = '\0';
// Store pointer to region n... |
// Save the last continent name
continent_names[continent_index] = last_cursor;
data->region_names_buffer = region_names_buffer;
data->region_names = region_names;
data->continent_names = continent_names;
}
static char *prv_get_timezone_title(void) {
/// Title of the menu for changing the watch's timezon... |
the bottom-most ISR.
if (sp[7] & 0x200) {
packed_info.registers[portCANONICAL_REG_INDEX_SP] = (uint32_t)(&sp[9]);
} else {
packed_info.registers[portCANONICAL_REG_INDEX_SP] = (uint32_t)(&sp[8]);
}
} else {
// If current task called core_dump_reset directly, then jam in the
... | if (s_core_dump_initiated) {
prv_debug_str("CD: re-entered");
prv_reset();
} |
s_core_dump_initiated = true;
s_core_dump_is_forced = is_forced;
if (is_forced) {
RebootReason reason = { RebootReasonCode_ForcedCoreDump, 0};
reboot_reason_set(&reason);
}
// Pend the Non-Maskable Interrupt, as the NMI handler performs the core dump.
SCB->ICSR = SCB_ICSR_NMIPENDSET_Msk;
__DSB(... |
/*
* 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 timeout_ticks - elapsed;
} |
return 0;
}
static bool prv_still_processing_enqueues(void) {
bool done;
prv_lock();
{
done = (s_outstanding_enqueues != 0);
}
prv_unlock();
return done;
}
// Only to be called by prv_enqueue(). This function keeps track of how many
// enqueues are outstanding. If an enqueue is about to start but t... |
firmware, and so they send us as many
// slices as they can fit in a BlobDB packet. We just take as many slices as we support and trim
// the excess.
if (validation_context.validated_size < *len) {
PBL_LOG(LOG_LEVEL_WARNING,
"Trimming AppGlanceDB entry of excess slices before insertion");
*len... | (&s_app_glance_db.settings_file, key, (size_t)key_len) | ;
} else {
rv = S_SUCCESS;
}
prv_close_file_and_unlock_mutex();
return rv;
}
/////////////////////////
// Testing code
/////////////////////////
#if UNITTEST
void app_glance_db_deinit(void) {
app_glance_db_flush();
mutex_destroy(s_app_glance_db.mutex);
}
status_t app_glance_db_insert_stale(const u... |
g, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "session_receive_router.h"
#include "kernel... | {
PBL_LOG(LOG_LEVEL_WARNING, "Got fewer bytes than expected for handler %p",
impl->endpoint->handler);
} |
// Note: At the moment we unconditionally spawn a new callback upon
// completion of each individual payload. If we are getting a flood of
// events, this may generate too many CBs and overflow the queue. We could keep a list
// of pending receiver events and only schedule the CB if there isn't one
// alrea... |
memset(fake_data, 0, payload_length) | ;
comm_session_send_buffer_write(write_sb[i], fake_data, payload_length);
comm_session_send_buffer_end_write(write_sb[i]);
}
// Can't write another message:
cl_assert_equal_p(NULL, comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
... | |
6, "-7fffffff", },
{ 2147483646LL, 17, "53G7F547", },
{ 2147483646LL, 17, "53g7f547", },
{ -2147483647LL, 17, "-53G7F548", },
{ -2147483647LL, 17, "-53g7f548", },
{ 2147483646LL, 18, "3928G3H0", },
{ 2147483646LL, 18, "3928g3h0", },
{ -2147483647LL, 18, "-3928G3H1", },
{ -2147483647LL, 18, "-3928g3h1", ... | cl_assert_equal_i(strtol(" -+123", NULL, 10), 0) | |
*ctx, const Layer *cell_layer,
uint16_t device_index, SettingsBluetoothData *data) {
const uint32_t num_remotes = list_count(data->remote_list_head);
PBL_ASSERT(device_index < num_remotes, "Got index %" PRId16 " only have %" PRId32,
device_index, num_remotes);
Stor... | {
subtitle = (data->toggle_state == ToggleStateDisablingBluetooth)
? i18n_get("Disabling...", data) : i18n_get("Enabling...", data);
icon = &data->icon_heap_bitmap[BluetoothAltIconIdx];
} |
menu_cell_basic_draw(ctx, cell_layer, title, subtitle, icon);
// TODO PBL-23111: Decide how we should show these strings on round displays
#if PBL_RECT
// Hack: the pairing instruction is drawn in the cell callback, but outside of the cell...
if (!data->remote_list_head) {
const GDrawSt... |
/*
* 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 (sys_ble_characteristic_get_properties(characteristic) &
BLEAttributePropertyWriteWithoutResponse);
} | |
event is within 24 hours, then show the actual time instead of "X hours ago"
const int MAX_RELATIVE_HRS = 13;
clock_set_24h_style(true);
// June 9th 2015, 17:00:00 (T+01:00:00)
rtc_set_time(event_time + SECONDS_PER_HOUR);
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_as... | (time_buf, sizeof(time_buf), format_time) | ;
cl_assert_equal_s("June 16", time_buf);
}
void test_clock__month_named_abbrev_date(void) {
char time_buf[64];
const time_t jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 16:00:00
// Now - one day
const time_t event_time =... |
tionIDPositive,
positive_action, app_id, properties);
action++;
}
if (negative_action) {
*buffer = prv_fill_native_ancs_action(buffer, action, ActionIDNegative,
negative_action, app_id, properties);
action++;
}
if (p... | {
continue;
} |
required_space_for_strings += attribute_list_get_buffer_size(&action->attr_list);
num_pebble_actions++;
}
}
int num_native_actions = (positive_action ? 1 : 0) + (negative_action ? 1 : 0);
int num_actions = num_native_actions + num_pebble_actions;
const int max_num_actions = 8; // Arbitratily ... |
/*
* 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... | {
WorkerCrashDialogData *data = context;
// Have the worker manager launch the next worker
worker_manager_launch_next_worker(data->app_install_id);
// Pop the worker crash dialog
actionable_dialog_pop(data->actionable_dialog);
} |
static void prv_worker_crash_click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_UP, prv_worker_crash_button_up_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_worker_crash_button_down_handler);
}
//! Configure a crash dialog with the given crash reason text
//! @param dial... |
&bpm, &hr_zone));
cl_assert_equal_i(steps, 0);
cl_assert_equal_i(duration_s, 0);
cl_assert_equal_i(distance_m, 0);
cl_assert_equal_i(bpm, 0);
cl_assert_equal_i(hr_zone, 0);
// Get some step info
prv_inc_time(5 * SECONDS_PER_MINUTE);
prv_inc_steps_and_put_event(900 /* ... | workout_service_get_active_kcalories(&new_active_kcalories) | |
/*
* 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_free(data) | ;
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* progress_app_get_info() {
static const PebbleProcessMdSystem progress_app_info = {
.common.main_func = &s_main,
.name = "Progress Bar Test"
};
return (const PebbleProcessMd*) &progress_app_i... |
der_schedule(void) {
const time_t start_time = sys_get_time();
sys_wakeup_cancel_all_for_app();
// Schedule a wakeup for 10 windows into the future
time_t late_event = start_time + WAKEUP_EVENT_WINDOW * 10;
WakeupId late_wakeup_id = sys_wakeup_schedule(late_event, 0, false);
cl_assert_equal_i(sys_wakeup_qu... | (third_event) | ; // manually move time forward to after third event
stub_new_timer_fire(wakeup_get_current());
wakeup_dispatcher_system_task((void *)(uintptr_t)third_wakeup_id);
// Catchup should be finished, gap should be back to >= WAKEUP_CATCHUP_WINDOW seconds
gap_timer = wakeup_get_current();
cl_assert_equal_b((stub_n... |
#include <string.h>
static QueueHandle_t s_kernel_event_queue = NULL;
static QueueHandle_t s_from_app_event_queue = NULL;
static QueueHandle_t s_from_worker_event_queue = NULL;
// The following conventions insure that the s_from_kernel_event_queue queue will always have sufficient space and that
// KernelMain will n... | prv_get_fancy_type_from_event(event) |
}
};
reboot_reason_set(&reason);
}
static bool prv_event_put_isr(QueueHandle_t queue, const char* queue_type, uintptr_t saved_lr,
PebbleEvent* event) {
PBL_ASSERTN(queue);
portBASE_TYPE should_context_switch = pdFALSE;
if (!xQueueSendToBackFromISR(queue, event, &should... |
;
activity_sessions_prv_add_activity_session(&new_activity);
ASSERT_NUM_ACTIVITY_SESSIONS(4); // 2 sleep sessions + 2 activity sessions
ASSERT_STEP_ACTIVITY_SESSION_PRESENT(&old_activity);
ASSERT_STEP_ACTIVITY_SESSION_PRESENT(&new_activity);
// Wait long enough for our midnight rollover to occur. We init ti... | (HealthMetricStepCount) | , k_exp_steps);
activity_get_metric(ActivityMetricActiveSeconds, 1, &value);
cl_assert_equal_i(value, SECONDS_PER_HOUR);
cl_assert_equal_i(health_service_sum_today(HealthMetricActiveSeconds), SECONDS_PER_HOUR);
activity_get_metric(ActivityMetricActiveKCalories, 1, &value);
// The following determined from a... |
T_STATIC GColor get_bitmap_color(GBitmap *bmp, int x, int y) {
const GBitmapFormat format = gbitmap_get_format(bmp);
const GBitmapDataRowInfo row_info = gbitmap_get_data_row_info(bmp, y);
const uint8_t *src = row_info.data;
const uint8_t src_bpp = gbitmap_get_bits_per_pixel(format);
uint8_t cindex = raw_imag... | GRect(dest_ic.x + min_x, dest_ic.y + min_y, size_x, size_y) | ;
grect_clip(&dest_clip, &dest_clip_min);
}
for (int y = dest_clip.origin.y; y < dest_clip.origin.y + dest_clip.size.h; ++y) {
for (int x = dest_clip.origin.x; x < dest_clip.origin.x + dest_clip.size.w; ++x) {
// only draw if within the dest range
const GBitmapDataRowInfo dest_info = gbitmap_ge... |
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_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_bit... | (&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1) | |
(ScrollLayer *)context;
scroll_layer_scroll(scroll_layer, ScrollDirectionDown, true);
(void)recognizer;
}
static void scroll_layer_click_config_provider(ScrollLayer *scroll_layer) {
// Config UP / DOWN button behavior:
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, scroll_layer_scroll_up_click_hand... | {
scroll_layer->content_sublayer.clips = clips;
scroll_layer_set_content_offset(scroll_layer,
scroll_layer_get_content_offset(scroll_layer), false);
} |
bool scroll_layer_get_clips_content_offset(ScrollLayer *scroll_layer) {
return scroll_layer->content_sublayer.clips;
}
|
Y_RAW_SAMPLES_MAX_ENTRIES) {
// Decrement num_samples if we already started building another run with the current sample
data->record.num_samples -= data->run_size;
if (finish) {
data->record.flags |= ACTIVITY_RAW_SAMPLE_FLAG_LAST_RECORD;
}
DataLoggingResult result = dls_log(data->... | if (s_activity_state.step_data.steps != prev_steps) {
// Post a steps changed event
PebbleEvent e = {
.type = PEBBLE_HEALTH_SERVICE_EVENT,
.health_event = {
.type = HealthEventMovementUpdate,
.data.movement_update = {
.steps = s_activity_state.step_data.steps,
},
... |
}
// ------------------------------------------------------------------------------------------------
// Used by activity_test_feed_samples() to feed in accel samples manually for testing
static void prv_feed_samples_system_cb(void *context_in) {
ActivityFeedSamples *context = (ActivityFeedSamples *)context_in;
... |
}
case WorkoutMetricType_Duration:
{
strncpy(buffer, data->duration_string, buffer_size);
break;
}
case WorkoutMetricType_Custom:
{
strncpy(buffer, data->custom_value_string, buffer_size);
break;
}
// Not supported by the sports API
case WorkoutMetricType_Ste... | (&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_workout_active__workout_render_run(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 84,
.distance_m = 1234,
.avg_pace = health_util_get_pace(84, 1234),
.bpm = 71,
.hr_zone = 0,
};
WorkoutActiveWindow *active_window = workout_active_create_for_activity_t... |
},
{ 912, 568, 88},
{ 960, 704, -16},
// 16 seconds
{ 1176, 568, 56},
{ 1344, 440, 104},
{ 1720, 424, 136},
{ 1520, 440, 168},
{ 1096, 272, 64},
{ 1360, 120, 144},
{ 1560, -8, 352},
{ 1368, 56, 272},
{ 1104, 24, 208},
{ 896, -24, 160},
{ 760, -8, 104},
{ 664, ... | { 1728, 648, 88},
{ 1352, 496, 48},
{ 1216, 320, 56},
{ 1512, 216, 128},
{ 1608, 104, 248},
{ 1400, 72, 280},
{ 1216, 0, 264},
{ 1080, 0, 224},
{ 952, -16, 200},
// 22 seconds
{ 864, -24, 168},
{ 776, -32, 112},
{ 688, -64, 0},
{ 752, 40, -104},
{ 984, 40, -16... |
{ 1720, -24, 304},
{ 1656, 400, 72},
{ 1304, 304, -176},
{ 1608, 504, -144},
{ 1432, 400, 64},
{ 1456, 368, 160},
{ 1224, 792, 152},
{ 960, 528, 176},
{ 840, 360, 144},
{ 840, 392, 56},
{ 880, 528, -104},
{ 952, 616, -64},
{ 1056, 544, -120},
{ 1456, 584, -112},
... |
cl_assert_equal_rect(*global_clipped_grect_used, GRectZero) | ;
// Check that bitmap_used is what we expect it to be (the expected value is set in .pre)
cl_assert_equal_p(bitmap_used, processor_with_data->expected_bitmap_in_post);
// Record that the .post function was called
processor_with_data->post_func_called = true;
}
//! Helper function for testing that the .post ... | |
/*
* 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 *ext = strrchr(filename, '.');
size_t len;
if (ext == NULL) {
len = strlen(filename);
} else {
len = ext - filename;
}
strncpy(base, filename, len);
base[len] = '\0';
return len;
} | |
dule_enabled(WeekdaySchedule) == true);
cl_assert(do_not_disturb_is_smart_dnd_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == true);
// !Manual && Scheduled && !Smart
do_not_disturb_set_manually_enabled(false);
cl_assert(do_not_disturb_is_active() == false);
do_not_disturb_... | do_not_disturb_is_schedule_enabled(WeekdaySchedule) | == true);
active = do_not_disturb_is_active();
cl_assert(active == true); // ON due to manual only
do_not_disturb_set_manually_enabled(false);
cl_assert(do_not_disturb_is_manually_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == false); // Both OFF
do_not_disturb_set_manual... |
/*
* 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... | (round(1.7976931348623157e+308), 1.7976931348623157e+308) | ;
cl_assert_equal_d(round(2.2250738585072014e-308), -0.0);
}
|
_Worker);
// Notify the app install manager that we finally exited
app_install_notify_worker_closed();
// If the worker was closed gracefully, launch any next/default worker and return
if (gracefully) {
// Reset the data tracking the last worker that crashed since the closing worker did not crash
prv_... | {
return worker_manager_get_current_worker_id();
} | |
HRMFeature_BPM | HRMFeature_LEDCurrent | HRMFeature_Diagnostics);
}
static void prv_disable_hrm(void) {
AppData *app_data = app_state_get_user_data();
event_service_client_unsubscribe(&app_data->hrm_event_info);
sys_hrm_manager_unsubscribe(app_data->session);
}
static void prv_handle_mobile_status_reques... | {
static const PebbleProcessMdSystem s_hrm_demo_app_info = {
.name = "HRM Demo",
.common.uuid = { 0xf8, 0x1b, 0x2a, 0xf8, 0x13, 0x0a, 0x11, 0xe6,
0x86, 0x9f, 0xa4, 0x5e, 0x60, 0xb9, 0x77, 0x3d },
.common.main_func = &prv_main,
};
// Only show in launcher if HRM is present
return... | |
dles_skipped_rows_animated(void) {
MenuLayer l;
menu_layer_init(&l, &GRect(10, 10, DISP_COLS, DISP_ROWS));
menu_layer_set_center_focused(&l, true);
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks) {
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
.selection_will_change = prv_skip... | cl_assert_equal_i(2, prv_num_sublayers(layer)) | ;
layer->update_proc(layer, &ctx);
cl_assert_equal_i(2, prv_num_sublayers(layer));
}
void test_menu_layer__center_focused_updates_height_on_reload(void) {
MenuLayer l;
const int height = DISP_ROWS;
menu_layer_init(&l, &GRect(10, 10, height, DISP_COLS));
menu_layer_set_center_focused(&l, true);
s_num_rows... |
/*
* 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... | {
const uintptr_t saved_lr = (uintptr_t) __builtin_return_address(0);
return heap_malloc(&s_kernel_heap, bytes, saved_lr);
} |
void *kernel_malloc(size_t bytes) {
return prv_heap_malloc(bytes);
}
void *kernel_zalloc(size_t bytes) {
void *ptr = prv_heap_malloc(bytes);
if (ptr) {
memset(ptr, 0, bytes);
}
return ptr;
}
void *kernel_malloc_check(size_t bytes) {
void *ptr = prv_heap_malloc(bytes);
PBL_ASSERTN(ptr);
return pt... |
/*
* 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... | (test0, 7, 0, 1, 1) | == 0);
cl_assert(raw_image_get_value_for_bitdepth(test0, 0, 0, 1, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test0, 0, 0, 1, 4) == 12);
cl_assert(raw_image_get_value_for_bitdepth(test0, 0, 0, 1, 8) == 192);
cl_assert(raw_image_get_value_for_bitdepth(test0, 0, 0, 1, 1) == 1);
cl_assert(raw_image_get... |
sizeof(GDrawCommandList) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6));
*command_list = (GDrawCommandList) {
.num_commands = 3
};
GDrawCommand *command;
command = gdraw_command_list_get_command(command_list, 0);
*command = (GDrawCommand) {
.type = GDrawCommandTypePath,
.hidden = false... | gdraw_command_list_get_command(command_list, 2) | ;
command->num_points = 4;
cl_assert(!gdraw_command_list_validate(command_list, size));
command->num_points = 3;
command->type = GDrawCommandTypeCircle;
cl_assert(!gdraw_command_list_validate(command_list, size));
command->type = GDrawCommandTypePrecisePath;
cl_assert(gdraw_command_list_validate(command_l... |
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 "clar.h"
#include "services/normal/notifications/alerts_preferences.h"
#include "services/... | (event.phone.source, PhoneCallSource_ANCS_Legacy) | ;
}
void test_ancs_notifications__handle_phone_call_removed(void) {
const uint32_t uid = 5;
// Make sure we don't send any events when this isn't iOS9
ancs_notifications_handle_notification_removed(uid, ANCSProperty_IncomingCall);
cl_assert_equal_i(fake_event_get_count(), 0);
// Make sure that we trigger 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... | ble_gap_adv_mode_set(disc_mode) | ;
if (rv != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "Error: ble_gap_adv_mode_set - rv: %d", rv);
// Not returning, probably better to try to advertise regardless of this error.
}
rv = ble_gap_adv_data_set(adv_bytes_len, adv_bytes,
ad_data->scan_resp_data_length,
... |
': multiplier = SECONDS_PER_DAY; break;
case 'H': multiplier = SECONDS_PER_HOUR; break;
case 'M': multiplier = SECONDS_PER_MINUTE; break;
case 'S': multiplier = 1; break;
default:
state->error->status = TemplateStringErrorStatus_InvalidTimeUnit;
return 0;
}
state->positio... | {
return;
} |
// len needs +1 in order for snprintf to write all the characters we want.
// It's ok that it writes the NUL at the end because we've already reserved that space.
snprintf(state->output, len + 1, fmt, value);
state->output += len;
state->output_remaining -= len;
}
static void prv_append_char(TemplateStringS... |
{ 904, 632, -80},
{ 1320, 704, -56},
{ 1224, 776, -32},
{ 904, 656, -88},
{ 1264, 648, -128},
{ 1024, 592, -152},
{ 1264, 552, -48},
{ 1736, 520, -56},
{ 1976, 384, -96},
// 5 seconds
{ 1512, -72, -56},
{ 1168, 56, -56},
{ 1152, 200, -176},
{ 1176, 208, -176},
... | { 1152, 288, -432},
{ 1360, 552, -288},
{ 1152, 64, -48},
{ 920, -8, -16},
{ 872, 32, -80},
{ 944, 168, -112},
{ 1040, 224, -88},
{ 1016, 264, -64},
{ 1360, 248, -48},
{ 1216, 240, -208},
{ 1320, 184, -224},
{ 1272, 64, -120},
{ 992, 104, -304},
{ 1000, 72, -328},... |
{ 1512, 232, -240},
{ 1096, 336, -296},
{ 784, 344, -248},
{ 800, 376, -176},
// 13 seconds
{ 944, 368, -192},
{ 1104, 376, -168},
{ 1176, 416, -80},
{ 1520, 600, -32},
{ 1064, 800, -120},
{ 1464, 824, -168},
{ 1208, 648, -144},
{ 1056, 528, -272},
{ 1320, 520, -... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_convert_millivolts_to_12bit_reading(VREF_VOLTAGE) | ,
.vmon_total = prv_convert_millivolts_to_12bit_reading(1800)
};
uint32_t result = battery_convert_reading_to_millivolts(reading, 3, 1);
cl_assert_equal_i(result, prv_legacy_f4_calculation_millivolts(reading));
}
|
hdog_handler, data);
}
static bool prv_find_source(ListNode *found_node, void *data) {
return (((ConnectionStateRequest *)found_node)->consumer == (BtConsumer)data);
}
/*
* Exported APIs
*/
void conn_mgr_set_ble_conn_response_time(
GAPLEConnection *hdl, BtConsumer consumer, ResponseTimeState state,
uint1... | {
// assume we only have one connection for debug
GAPLEConnection *conn_hdl = gap_le_connection_any();
ResponseTimeState state = atoi(mode);
conn_mgr_set_ble_conn_response_time(
conn_hdl, BtConsumerPrompt, state, MAX_PERIOD_RUN_FOREVER);
} |
static TimerID s_chaos_monkey_timer;
static ResponseTimeState s_chaos_monkey_last_state;
static void prv_mode_chaos_monkey_stop(void) {
new_timer_delete(s_chaos_monkey_timer);
s_chaos_monkey_timer = TIMER_INVALID_ID;
}
static void prv_mode_chaos_monkey_callback(void *data) {
bt_lock();
GAPLEConnection *hdl... |
-------------------------------------------------------
// Leftover data in epoch, if any
total_steps += kalg_analyze_finish_epoch(s_kalg_state);
TestMinuteData minute_data = {
.steps = minute_steps,
};
bool still;
kalg_minute_stats(s_kalg_state, &minute_data.vmc, &minute_data.orientation, &still);
P... | if (!line) {
// EOF
break;
} |
//printf("\nGot line: %s", line);
// Find first token
char *token = strtok(line, " \t\n");
if (!token) {
continue;
}
// If this is a pre-processor directive, skip it
if (token[0] == '#') {
continue;
}
// If this is a comment skip it
if (strcmp(token, "//") == 0) {... |
id test_flash_region__erase_optimal_range_sectors_simple(void) {
// Erase one sector 0x10000 - 0x20000
flash_region_erase_optimal_range(64 * 1024, 64 * 1024, 2 * 64 * 1024, 2 * 64 * 1024);
cl_assert_equal_i(s_command_list_index, 1);
cl_assert_equal_i(s_command_list[0].addr, 64 * 1024);
cl_assert_equal_i(s_co... | (s_command_list[1].type, SubsectorEraseCommand) | ;
cl_assert_equal_i(s_command_list[2].addr, 40 * 1024);
cl_assert_equal_i(s_command_list[2].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[3].addr, 44 * 1024);
cl_assert_equal_i(s_command_list[3].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[4].addr, 48 * 1024);
cl_assert... |
tStateResponse = 0x83,
PhoneCmdIncoming = 0x04,
PhoneCmdOutgoing = 0x05,
PhoneCmdMissed = 0x06,
PhoneCmdRing = 0x07,
PhoneCmdStart = 0x08,
PhoneCmdEnd = 0x09
};
typedef struct {
uint32_t cookie;
char caller_number[CALLER_BUFFER_LENGTH];
ch... | (LOG_LEVEL_ERROR, "Failed to read caller information from 'Incoming' phone event") | ;
return false;
}
#ifndef RELEASE
print_call_info(&call_info);
#endif
type = PhoneEventType_Incoming;
caller = phone_call_util_create_caller(call_info.caller_number, call_info.caller_name);
did_parse = true;
break;
}
case PhoneCmdStart: {
type = PhoneEventTyp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.