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... | {
strncpy(buffer, notifications_glance->subtitle, buffer_size);
buffer[buffer_size - 1] = '\0';
} |
}
static GTextNode *prv_create_subtitle_node(LauncherAppGlanceStructured *structured_glance) {
return launcher_app_glance_structured_create_subtitle_text_node(
structured_glance, prv_notifications_glance_subtitle_dynamic_text_node_update);
}
static void prv_destructor(LauncherAppGlanceStructured *structured_... |
];
memset(&buf[0], i, sizeof(buf));
int fd = pfs_open(file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, sizeof(buf));
printf("fd=%d\n", fd);
cl_assert(fd >= 0);
cl_assert_equal_i(pfs_write(fd, &buf[0], sizeof(buf)), sizeof(buf));
if (i == 0) {
start_page = test_get_file_start_page(fd);
}
... | cl_assert(pfs_remove(file_small) == S_SUCCESS) | ;
}
}
// We limit this number because we would overflow our uint8_t.
const int num_regions = MIN(UINT8_MAX, (num_pages() * 5) / 10);
int fd = pfs_open("page_lookup", OP_FLAG_WRITE, FILE_TYPE_STATIC, PFS_SECTOR_SIZE * num_regions);
cl_assert(fd >= 0);
char buf[PFS_SECTOR_SIZE];
for (int i = 0; i < nu... |
/*
* 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_update_status() | ;
}
static void prv_update_status_async(void) {
if (__atomic_test_and_set(&s_cb_scheduled, __ATOMIC_RELAXED)) {
return; // we already have a cb scheduled
}
system_task_add_callback(prv_update_status_system_task_callback, NULL);
}
static void prv_new_timer_callback(void *unused) {
prv_update_status_async(... |
/*
* 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... | FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR) | ;
const uint8_t *data_array = data;
for (uint32_t i = 0; i < length; ++i) {
if (FLASH_ProgramByte(address + i, data_array[i]) != FLASH_COMPLETE) {
dbgserial_print("failed to write address ");
dbgserial_print_hex(address);
dbgserial_newline();
FLASH_Lock();
return false;
}
... |
qual_i(regular_timer_seconds_count(), 0);
regular_timer_deinit();
fake_gatt_client_op_deinit();
fake_gatt_client_subscriptions_deinit();
// Check for leaks:
fake_pbl_malloc_check_net_allocs();
fake_pbl_malloc_clear_tracking();
fake_comm_session_cleanup();
free(s_client_reset_request);
free(s_client_... | ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristicMeta],
(const uint8_t *) &future_meta_non_compatible,
sizeof(future_meta_non_compatible),
BLEGATTErrorSuccess) | ;
// No client created:
cl_assert_equal_i(ppogatt_client_count(), 0);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&future_meta_non_compatible.app_uuid), false);
}
void test_ppogatt__handles_invalid_uuid_meta(void) {
PPoGATTMetaV0 meta_invalid_uuid = s_meta_v0_system;
meta_invalid_uuid.app_uuid = UUID_INVAL... |
connected;
s_music_ctx.implementation = NULL;
PBL_LOG(LOG_LEVEL_INFO, "Music server disconnected: %s", implementation->debug_name);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Unknown server <%p> disconnected", implementation);
}
}
if (change_type != None) {
// Upon connect and disconnect, res... | (title, s_music_ctx.title) | ;
}
if (artist) {
strcpy(artist, s_music_ctx.artist);
}
if (album) {
strcpy(album, s_music_ctx.album);
}
mutex_unlock_recursive(s_music_ctx.mutex);
}
bool music_get_player_name(char *player_name_out) {
mutex_lock_recursive(s_music_ctx.mutex);
const bool has_player_name = (s_music_ctx.player_n... |
ffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 2);
cl_assert_equal_i(items_read, 2);
cl_assert_equal_m(out_buffer, "0k3o", 4);
items_read = shared_circular_buffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 2);
cl_assert_equal_i(items_read, 1);
cl_assert_equal_m(out_... | cl_assert_equal_i(shared_circular_buffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 3), 3) | ;
cl_assert_equal_m(out_buffer, "0a2c4e", 6);
// This should be a no-op. the "5f" sample should still be skipped on the next
// read.
subsampled_shared_circular_buffer_client_set_ratio(&client, 1, 2);
cl_assert_equal_i(shared_circular_buffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 1),... |
eader chunk_hdr;
// Reached the end of the file?
// NOTE: we don't do this check if we are scanning for the last written byte (buffer == NULL)
if (buffer) {
if (read_offset >= logging_session->storage.write_offset) {
break;
}
}
// Read the chunk header
if (!prv_pfs_seek(log... | if (chunk_hdr.valid) {
if (reset_read_offset) {
// If we are only resetting the read offset, break out now.
break;
}
if (chunk_hdr.num_bytes > num_bytes) {
// Somehow the caller tried to consume less than they read?
PBL_LOG(LOG_LEVEL_WARNING, "Read/consume out of sync")... |
logging_session->storage.read_offset += sizeof(DLSChunkHeader) + chunk_hdr.num_bytes;
consumed_bytes += chunk_hdr.num_bytes;
}
exit:
if (consumed_bytes > 0) {
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG,
"Consumed %d bytes from session %d", (int)consumed_bytes,
logg... |
t:
return UUID_INVALID;
}
}
uint8_t gatt_client_service_get_characteristics_matching_uuids(BLEService service_ref,
BLECharacteristic characteristics_out[],
const Uuid matching_characteristic_uuids[... | (info->services_added_data.services, s_service_handles, sizeof(s_service_handles)) | ;
PebbleEvent e = (PebbleEvent) {
.type = PEBBLE_BLE_GATT_CLIENT_EVENT,
.bluetooth.le.gatt_client_service = {
.info = info,
.subtype = PebbleBLEGATTClientEventTypeServiceChange,
},
};
kernel_le_client_handle_event(&e);
// Found one complete service instance:
cl_assert_equal_i(s_serv... |
/*
* 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... | (!circular_buffer_read(&buffer, 1, &out_buffer, &out_length)) | ;
cl_assert(circular_buffer_write(&buffer, (uint8_t*) "123", 3));
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 5);
cl_assert(circular_buffer_write(&buffer, (uint8_t*) "456", 3));
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(!circular_buffer_writ... |
("s = d.toLocaleDateString(undefined, {year: '2-digit'});") | ;
ASSERT_JS_GLOBAL_EQUALS_S("s", "05");
}
void test_rocky_api_datetime__locale_date_string_time_options(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT("var d = new Date();");
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {hour: 'numeric'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "07/25/05, 8 PM");
}
vo... | |
/*
* 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... | layer_add_child(&window->layer, simple_menu_layer_get_layer(menu)) | ;
}
static void handle_init(void) {
AppData *data = app_malloc_check(sizeof(AppData));
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Simple Menu Demo"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load ... |
for (int i = 0; i < NUM_POLL_REMOTE_SERVICES; i++) {
poll_remote_function(&s_poll_remote_contexts[i]);
} |
}
static bool has_min_interval_passed(PollRemoteContext *ctx) {
return (ctx->counted_minutes >= ctx->min_interval_minutes);
}
static bool has_max_interval_passed(PollRemoteContext *ctx) {
return (ctx->counted_minutes >= ctx->max_interval_minutes);
}
// SystemTaskCallback
static void prv_send_request(PollRemoteC... | |
BLECharacteristic *characteristic_hdls_out,
BLEDescriptor *descriptor_hdls_out) {
}
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
callback(data);
}
// Helpers
///////////////////////////////////////////////////////////
static const BTDevi... | prv_expect_service_changed_indication_api_call_count(0) | |
/*
* 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... | framebuffer_init(fb, &(GSize) { DISP_COLS, DISP_ROWS }) | ;
}
void test_graphics_window_stack_animation__cleanup(void) {
free(fb);
}
// Helpers
////////////////////////////////////
typedef void (*ClippingMaskDrawFunc)(GContext *ctx);
static void prv_test_clipping_mask(ClippingMaskDrawFunc draw_func, const char *expected_image) {
GContext *ctx = malloc(sizeof(GContext)... |
void prv_put_outgoing_call_event(uint32_t call_identifier, const char *caller_id) {
PebbleEvent event = {
.type = PEBBLE_PHONE_EVENT,
.phone = {
.type = PhoneEventType_Outgoing,
.source = PhoneCallSource_ANCS_Legacy,
.call_identifier = call_identifier,
.caller = phone_call_util_create... | prv_find_first(*head, direction, timestamp, iter_state->midnight,
iter_state->show_all_day_events) | |
round);
smartstrap_state_assert_locked_by_current_task();
// we expect the arguments to be valid
const bool is_read = (read_mbuf != NULL);
PBL_ASSERTN((profile > SmartstrapProfileInvalid) && (profile < NumSmartstrapProfiles));
PBL_ASSERTN(!is_read || (mbuf_get_chain_length(read_mbuf) > 0));
PBL_ASSERTN((!wr... | {
// Enter a critical region to prevent anybody else changing the state.
portENTER_CRITICAL();
SmartstrapState state = smartstrap_fsm_state_get();
if ((state != SmartstrapStateReadDisabled) && (state != SmartstrapStateReadInProgress) &&
(state != SmartstrapStateReadComplete)) {
// we aren't in a state... | |
!prv_read_register(PmicRegisters_STATUSA, &status_a) ||
!prv_read_register(PmicRegisters_STATUSB, &status_b)) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to read status registers");
return;
}
PBL_LOG(LOG_LEVEL_INFO, "%s: StatusA = 0x%"PRIx8"; StatusB = 0x%"PRIx8, preamble, status_a,
status_b);
}
stat... | (PmicRail_LDO3, enabled) | ;
i2c_release(I2C_MAX14690);
}
void set_4V5_power_state(bool enabled) {
gpio_output_set(&BOARD_CONFIG_POWER.rail_4V5_ctrl, enabled);
}
void set_6V6_power_state(bool enabled) {
PBL_ASSERTN(BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio);
gpio_output_set(&BOARD_CONFIG_POWER.rail_6V6_ctrl, enabled);
}
|
connection events
void __disabled_test_gap_le_connect__connection_event_for_registered_client(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent:
BTErrno e = gap_le_connect_connect(&device,
true /* auto_reconnect */,
... | (e, BTErrnoOK) | ;
// Simulate getting a Connection Complete event for the device from Bluetopia:
prv_fake_connect(&device, false /* is_master*/);
// Verify the kernel task got a (virtual) connection event:
prv_assert_client_event(&device, true /* connected */, (1 << PebbleTask_KernelMain),
HCI_ERROR... |
/*
* 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... | flash_erase_subsector_blocking(FLASH_REGION_MFG_INFO_BEGIN) | ;
flash_write_bytes((const uint8_t*) data, FLASH_REGION_MFG_INFO_BEGIN, sizeof(*data));
}
static MfgData prv_fetch_struct(void) {
MfgData result;
flash_read_bytes((uint8_t*) &result, FLASH_REGION_MFG_INFO_BEGIN, sizeof(result));
switch (result.data_version) {
case CURRENT_DATA_VERSION:
// Our 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... | {
WorkoutCountdownWindow *countdown_window = window_get_user_data(layer_get_window(layer));
KinoReel *image = countdown_window->images[countdown_window->current_image];
const GSize icon_size = kino_reel_get_size(image);
GPoint offset;
offset.x = (layer->bounds.size.w / 2) - (icon_size.w / 2);
offset.y = ... | |
or(ctx, GColorClear);
graphics_fill_round_rect(ctx, &GRect(2, 2, 28, 20), 4, GCornersAll);
}
void corners_clipped_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(-19, 0, 20, 20), 4,... | layer_set_update_proc(&layer, &corners_all_update_callback) | ;
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_corners_all.${BIT_DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &clear_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("clear_over_black", ctx.parent_framebuffer, GColorWhite));
}... |
ms to play it safe.
#define DIALOG_BOOTROM_DEFAULT_CHAR_TIMEOUT_MS (100)
// For the revAE silicon, usually it takes ~220ms from deasserting RST to getting the
// first chip ID character over the UART RX, but I've observed it taking ~400ms at other times.
#define DIALOG_BOOTROM_FIRST_CHAR_TIMEOUT_MS (600)
// Some platf... | {
uint8_t running_xor = 0;
uint32_t curr_offset = 0;
while (curr_offset < bootloader_size) {
const size_t bytes_left = bootloader_size - curr_offset;
uint8_t data_buf[256] = { 0 };
const size_t read_len = MIN(bytes_left, sizeof(data_buf));
if (!resource_load_byte_range_system(SYSTEM_APP, RESOUR... |
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((bootloader_size >> 8) & 0xff); // LEN_MSB
char c;
if (!prv_bootrom_wait_for_char(&c)) {
PBL_LOG(LOG_LEVEL_ERROR, "E... |
ged = 0;
last_reset_counter_ticks = rtc_get_ticks();
}
if (num_events_logged > 100) { // don't log a ridiculous amount of tightly looped disconnects
return;
}
// It's okay to log to analytics directly from the BT02 callback thread
// because flash writes are dispatched to KernelBG if the datalogging... | serial_distance32(orig_stats->num_type_errors, stats_buf->num_type_errors) | |
), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_some_sectors_from_beginning(void) {
cl_assert(system_flash_erase(FLASH_BASE, 128 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 4), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_full_flash(void) {
cl... | IS_VOLTAGERANGE(voltage_range) | );
cl_check_(flash_flags_set == false, "Forgot to clear flags before erasing");
cl_check_((erased_sector & (1 << sector/8)) == 0,
"Re-erasing an already erased sector");
flash_flags_set = true;
if (return_status == FLASH_COMPLETE) {
erased_sector |= (1 << sector/8);
}
return return_status;
}... |
/*
* 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... | (ADC1, RCC_APB2Periph_ADC1) | ;
ADC_TempSensorVrefintCmd(ENABLE);
ADC_CommonInitTypeDef ADC_CommonInitStruct;
// Single ADC mode
ADC_CommonStructInit(&ADC_CommonInitStruct);
ADC_CommonInitStruct.ADC_Mode = ADC_Mode_Independent;
// ADCCLK = PCLK2/2
ADC_CommonInitStruct.ADC_Prescaler = ADC_Prescaler_Div4;
// Available only for multi ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | system_task_add_callback(prv_send_meta_response_kernelbg_cb, meta_response_info_heap_copy) | ;
}
void meta_protocol_msg_callback(CommSession *session, const uint8_t* data, size_t length) {
PBL_LOG(LOG_LEVEL_INFO, "Meta endpoint callback called");
}
|
e prv_is_invalid_command_for_current_state() test.
break;
}
finally:
prv_receiver_reset();
xSemaphoreGive(s_pb_semaphore);
}
void put_bytes_init(void) {
vSemaphoreCreateBinary(s_pb_semaphore)
PBL_ASSERTN(s_pb_semaphore != NULL);
}
void put_bytes_cancel(void) {
PBL_ASSERT_TASK(PebbleTask_KernelBackg... | {
if (total_payload_length > PUT_BYTES_PP_BUFFER_SIZE) {
PBL_LOG(LOG_LEVEL_ERROR, "Put Bytes message too big");
return false;
}
if (!s_pb_state.receiver.buffer) {
if (!prv_init_put_job_queue_if_necessary()) {
return false; // OOM
}
s_pb_state.receiver.buffer = prv_get_next_pb_job_buffer... |
Receiver *prv_receiver_prepare(CommSession *session, const PebbleProtocolEndpoint *endpoint,
size_t total_payload_length) {
// This receiver should only be used for the Put Bytes endpoint (which has a NULL handler,
// because this receiver calls the internal, static functions in thi... |
platform use two different UART peripherals! This means things need
// to be initialized and torn down seperately!
static bool prv_platform_uses_two_uart_peripherals(void) {
return (BT_RX_BOOTROM_UART != BT_TX_BOOTROM_UART);
}
static void prv_init_dialog_bootrom_interface(void) {
periph_config_acquire_lock();
... | if (!prv_bootrom_wait_for_char(&c)) {
PBL_LOG(LOG_LEVEL_ERROR, "Error waiting for CRC response");
return false;
} |
if (c == running_xor) {
prv_send_char(0x06);
return true;
}
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
... |
f
}
#define RADIUS_DEFAULT 4
#define RECT_WIDTH 30
#define RECT_HEIGHT 40
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 20, 20)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 144, 168)
#define ORIGIN_DRAW_RECT_NO_CLIP ... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw4_clip_xy.${BIT_DEPTH_NAME}.pbi")) | ;
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 4);
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_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// AA = true, SW = 5
setup_... |
/*
* 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... | (&connection->device, is_confirmed) | ;
}
void pairing_confirm_handle_request(const BTDeviceInternal *device) {
GAPLEConnection *connection = gap_le_connection_by_device(device);
if (!connection) {
PBL_LOG(LOG_LEVEL_ERROR, "No connection found for pairing request");
return;
}
// PBL-38595: Make the connection fast during the pairing:
co... |
RECT_NO_CLIP GRect(6, 6, 30, 40)
#define OFFSET_DRAW_RECT_CLIP_XY GRect(6, 6, 30, 40)
#define OFFSET_DRAW_RECT_CLIP_NXNY GRect(-16, -16, 30, 40)
void test_graphics_draw_rect_${BIT_DEPTH_NAME}__offset_aa_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// AA = true, SW = 1
setup_test_aa_sw(&c... | (&ctx.dest_bitmap, "draw_rect_offset_aa_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi") | );
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// AA = true, SW = 11
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 11);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_o... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (app_install_id_from_system(entry->install_id)) {
return true;
} |
char buffer[120];
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(&entry->uuid, uuid_buffer);
prompt_send_response_fmt(buffer, sizeof(buffer), "%"PRIi32": %s %s", entry->install_id,
entry->name, uuid_buffer);
return true;
}
void command_app_list(void) {
app_install_enumerate_entries(p... |
tatic void prv_send_configure_request(PPPControlProtocol *this) {
this->state->restart_count--;
prv_start_timer(this);
// Don't try to be fancy about changing the request identifier only when
// necessary; keep it simple and increment it for every request sent.
uint8_t id = this->state->last_configure_request... | if (this->state->link_state == LinkState_AckReceived) {
prv_transition_to(this, LinkState_RequestSent);
} |
break;
default:
break;
}
} else { // TO-
switch (this->state->link_state) {
case LinkState_Stopping:
case LinkState_RequestSent:
case LinkState_AckReceived:
case LinkState_AckSent:
prv_transition_to(this, LinkState_Stopped);
break;
case Lin... |
/*
* 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_lock(mutex) | ;
cl_assert_equal_b(fake_mutex_all_unlocked(), false);
}
void test_fake_mutex__double_lock(void) {
fake_mutex_set_should_assert(false);
PebbleMutex *mutex = mutex_create();
mutex_lock(mutex);
mutex_lock(mutex);
cl_assert_equal_b(true, fake_mutex_get_assert_triggered());
}
void test_fake_mutex__double_unl... |
(result, num_sums);
}
return result;
}
// --------
// Default handling is to use daily totals
if (scope == HealthServiceTimeScopeOnce) {
return prv_compute_aggregate_using_daily_totals(state, metric, time_start, time_end,
aggregation);
} else {
... | if (interval_sec == 0) {
HRMSessionRef hrm_session = sys_hrm_manager_get_app_subscription(app_id);
if (hrm_session != HRM_INVALID_SESSION_REF) {
sys_hrm_manager_unsubscribe(hrm_session);
}
return true;
} |
// Subscribe now
HRMSessionRef hrm_session = sys_hrm_manager_app_subscribe(app_id, interval_sec, 0 /*expire_sec*/,
HRMFeature_BPM);
if (hrm_session == HRM_INVALID_SESSION_REF) {
PBL_LOG(LOG_LEVEL_ERROR, "Error subscribing");
return false;
}
... |
collected data
AccelRawData captured_data[k_raw_samples];
prv_uncompress_captured_data(captured_data, k_raw_samples);
cl_assert_equal_m(raw_data, captured_data, k_raw_samples * sizeof(AccelRawData));
}
// ---------------------------------------------------------------------------------------
// Fee... | {
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
const uint32_t exp_num_records = 10;
HealthMinuteData minutes[... |
time_t oldest_to_fetch = rtc_get_time() - (ALG_MINUTES_PER_FILE_RECORD * SECONDS_PER_MINUTE);
for (int i = 0; i < ALG_MINUTES_PER_FILE_RECORD; i++) {
// Ask for the last ALG_MINUTES_PER_RECORD minutes of data
num_records = ALG_MINUTES_PER_FILE_RECORD;
time_t start_time = oldest_to_fetch + (i * SECONDS... |
n another client.
static bool prv_update_rail_state(PmicRail rail, bool enable);
static void prv_mon_config_lock(void) {
}
static void prv_mon_config_unlock(void) {
}
static bool prv_read_register(uint8_t register_address, uint8_t *result) {
i2c_use(I2C_MAX14690);
bool rv = i2c_read_register(I2C_MAX14690, regist... | prv_read_register(PmicRegisters_STATUSA, &val) | ) {
// NOTE: When running on QEMU, i2c reads return false. For now, just assume a failed
// i2c read means we are charging
return true;
}
uint8_t chgstat = val & 0x07; // Mask off only charging status
if (chgstat == 0x02 || // Pre-charge in progress
chgstat == 0x03 || // Fast charge, CC
... |
NULL,
},
.action_group = {
.num_actions = 0,
.actions = NULL,
},
.allocated_buffer = NULL,
}, {
.header = { // [4]
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb5},
.parent_id = {0},
.tim... | timeline_model_get_iter_state(1) | == timeline_model_get_iter_state_with_timeline_idx(3));
cl_assert(timeline_model_iter_next(&new_idx, &has_next));
cl_assert(has_next);
cl_assert_equal_i(new_idx, 4);
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_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... | test_write_short() | |
/*
* 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... | (data->reading_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)) | ;
text_layer_set_text(data->reading_text_layer, data->ambient_reading);
text_layer_set_text_alignment(data->reading_text_layer, GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(data->reading_text_layer));
#if MFG_INFO_RECORDS_TEST_RESULTS
mfg_results_ui_init(&data->results_ui, MfgTest_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gpio_input_read(&creset_input) | ) {
dbgserial_putstr("CRESET not high after reset");
return false;
}
delay_ms(1);
// Program the FPGA
prv_spi_write(fpga_bitstream, bitstream_size);
// Set SCS high so that we don't process any of these clocks as commands.
gpio_output_set(&ICE40LP->spi.scs, false); // SCS not asserted (high)
... |
AG_REPEATING)) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not start the phone call watchdog timer");
prv_handle_call_end(true /* Treat this as a disconnection */);
} else {
PBL_LOG(LOG_LEVEL_INFO, "Phone call watchdog timer started");
pp_get_phone_state_set_enabled(true);
}
} else {
PBL_LOG... | (LOG_LEVEL_INFO, "Ignoring hide call. Call identifier %"PRIu32" doesn't match %"PRIu32,
s_call_identifier, event->call_identifier) | ;
return;
}
prv_call_end_common();
phone_ui_handle_call_hide();
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient_System);
}
static void prv_handle_call_end(bool disconnected) {
if (!disconnected) {
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient... |
t LayoutColors *colors = layout_get_colors(layout);
switch (config->color) {
case LayoutColor_None:
break;
case LayoutColor_Primary:
text_node->color = colors->primary_color;
break;
case LayoutColor_Secondary:
text_node->color = colors->secondary_color;
break;
case Layout... | (&container_node->node, &config->extent) | ;
}
static GTextNodeHorizontal *prv_create_horizontal_container_node_from_config(
const LayoutLayer *layout, const LayoutNodeHorizontalConfig *config) {
const int capacity = config->container.num_nodes + config->container.extra_capacity;
GTextNodeHorizontal *horizontal_node = graphics_text_node_create_horizont... |
-------------
//! @return True on success, False if:
//! - We fail to start the app. No app is running and the caller is responsible for starting
//! a different app.
//!
//! @note Side effects: trips assertions if:
//! - The app manager was not init,
//! - The app's task handle or event queue aren't ... | process_metadata_get_app_sdk_type(app_md) | ;
// The rest of app_ram is available for app_state to use as it sees fit.
if (!app_state_configure(&app_ram, sdk_type, timeline_peek_get_obstruction_origin_y())) {
PBL_LOG(LOG_LEVEL_ERROR, "App state configuration failed");
return false;
}
// The remaining space in app_segment is assigned to the app's... |
eantime which needs to be ack'ed now that space is free
bool do_ack;
prv_lock_pb_job_state();
{
do_ack = put_jobs->need_to_ack_later;
put_jobs->need_to_ack_later = false;
}
prv_unlock_pb_job_state();
if (do_ack) { // If we did not pre-ack, we need to ack the packet now!
prv_send_response(Respon... | xSemaphoreGive(s_pb_semaphore) | ;
}
void put_bytes_handle_comm_session_event(const PebbleCommSessionEvent *
comm_session_event) {
if (comm_session_event->is_system) {
prv_cleanup_async();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Recei... |
/*
* 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 (!advance_slackers) {
return false;
} |
// Delete data from the biggest slacker
slacker->read_index = buffer->write_index;
max_data = prv_get_max_data_length(buffer, &slacker);
avail_space = buffer->buffer_size - max_data;
}
const uint16_t remaining_length = buffer->buffer_size - buffer->write_index;
if (remaining_length < length) {... |
/*
* 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... | (is_app_file_name("12345678/abc") == false) | ;
}
void test_app_file__is_app_file_name_tricky_false_3(void) {
cl_assert(is_app_file_name("@12345678\\foo") == false);
}
void test_app_file__is_app_file_name_tricky_false_4(void) {
cl_assert(is_app_file_name("@abcdefg1/def") == false);
}
void test_app_file__is_app_file_name_tricky_false_5(void) {
cl_assert(is... |
/*
* 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 (codepoint == WORD_JOINER_CODEPOINT) {
new_state = WordStateJoining;
} else {
new_state = WordStateEnd;
} |
case WordStateGrowing:
if (codepoint == WORD_JOINER_CODEPOINT) {
new_state = WordStateJoining;
} else if (codepoint_is_ideograph(codepoint) || codepoint_is_end_of_word(codepoint)) {
new_state = WordStateEnd;
} else {
new_state = WordStateGrowing;
}
break;
c... |
efine MAX_CONFIGURED_ALARMS (10)
#define ALARM_FILE_NAME "alarms"
#define ALARM_MAX_FILE_SIZE KiBYTES(1) // ~50 alarms or so
#define NUM_ALARM_PINS_PER_ALARM (3)
#define ALARM_ENTRY_SIZE (UUID_SIZE * NUM_ALARM_PINS_PER_ALARM)
// All alarm preferences are saved in the file under separate keys to simplify
// backward c... | if (!success) {
mutex_unlock(s_mutex);
} |
return success;
}
// ----------------------------------------------------------------------------------------------
static void prv_file_close_and_unlock(SettingsFile *file) {
settings_file_close(file);
mutex_unlock(s_mutex);
}
// -------------------------------------------------------------------------------... |
if (((read_buffer != 0xFF) && (read_buffer != 0xAA)) || (test_addr == base_addr)) {
if (display_logs) {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Erasing Addr 0x%"PRIx32, test_addr);
}
flash_erase_sector_blocking(test_addr);
// Verify data was erased
status = prv_read_v... |
}
// After the base address, go up by power of 2's
if (bit_offset == 0) {
bit_offset = 1;
}
}
}
if (display_logs) { PBL_LOG(LOG_LEVEL_DEBUG, ">>> Erasing sectors...complete"); }
// Write default data pattern to each power-of-two offset within the test region
for (bit_offs... | |
nu_cell_basic_draw_with_value
// (that unfortunately doesn't respect bounds.origin.x)
const int16_t title_height = 24;
GRect box = cell_layer->bounds;
box.origin.x += offset;
box.origin.y = (box.size.h - title_height) / 2;
box.size.w -= offset;
box.size.h = title_height + 4;
const GFont title_font = fo... | (&data->action_list2, NULL, &(MenuLayerCallbacks){
.get_num_rows = prv_get_num_rows,
.draw_row = prv_draw_row_2,
.get_separator_height = prv_get_separator_height,
}) | ;
scroll_layer_set_shadow_hidden(&data->action_list2.scroll_layer, true);
data->prv_orig_content_offset_changed =
data->action_list2.scroll_layer.callbacks.content_offset_changed_handler;
data->action_list2.scroll_layer.callbacks.content_offset_changed_handler =
prv_syncing_content_offset_changed;
m... |
panic_app_get_app_info() | ;
}
#if CAPABILITY_HAS_SDK_SHELL4
const AppInstallId watchface_app_id = watchface_get_default_install_id();
if (watchface_app_id != INSTALL_ID_INVALID) {
return app_install_get_md(watchface_app_id, false /* worker */);
}
#endif
return sdk_app_get_info();
}
#if CAPABILITY_HAS_SDK_SHELL4
//! @return True... | |
ic_disable_battery_measure is called.
}
bool pmic_disable_battery_measure(void) {
bool result = prv_set_mon_config_register(0);
// Releases the lock that was previously aquired in pmic_enable_battery_measure.
prv_mon_config_unlock();
return result;
}
uint16_t pmic_get_vsys(void) {
prv_mon_config_lock();
... | prv_clear_any_pending_interrupts() | |
break;
}
}
if (test == NULL) {
clar_print_onabort("No test named '%s'.\n", argument);
exit(-1);
}
_clar.active_suite = suite->name;
_clar.suite_errors = 0;
_clar.active_test = test->name;
clar_run_test(test, &suite->initialize, &suite->cleanu... | {
if (d1 != d2) {
char buf[128];
snprint_eq(buf, 128, "%f != %f", d1, d2);
clar__assert(0, file, line, err, buf, should_abort);
}
} |
void clar__assert_within(
int n,
int min,
int max,
const char *file,
int line,
const char *err,
int should_abort)
{
if (!CL_WITHIN(n, min, max)) {
char buf[256];
snprint_eq(buf, 256, "%d not within [%d, %d]", n, min, max);
clar__assert(0, file, line, err, buf, should_abort);
}
}
void cl... |
gion_found) {
if (multiple_gens_found || (prv_get_start_of_log_file(prev_log_id,
&s_curr_state.page_start_addr) == 0)) {
s_curr_state.page_start_addr = FLASH_REGION_DEBUG_DB_BEGIN;
}
s_curr_state.page_start_addr = prv_get_unit_base_address(s_curr_state.page_start_addr);
prv_erase_unit(s_c... | ((uint8_t *)build_id, build_id_addr, sizeof(build_id)) | ;
byte_stream_to_hex_string((char *)&state->msg_buf[off], MAX_MSG_LEN - off, (uint8_t *)build_id,
sizeof(build_id), false);
int len = pbl_log_get_bin_format((char *)state->msg_buf, MAX_MSG_LEN, LOG_LEVEL_INFO, "", 0,
"Build ID: %s", &state->msg_... |
break;
}
continue;
}
hw_spi_fifo_write8(s_spi->bus_id, core_dump_connect_response[tx_index++]);
if (tx_index == sizeof(core_dump_connect_response)) {
return true;
}
}
}
// Pulse the INT line to wake the host
host_transport_set_mcu_in... | printf("low power mode\n");
prv_low_power_mode();
break;
default:
break;
}
} |
}
NORETURN core_dump(bool user_requested) {
// Feed the watchdog before we continue
hw_watchdog_set_pos_val(0xFF);
// Disable interrupts, should we not have been called from fault context
portDISABLE_INTERRUPTS();
// Reconfig debug serial
debug_uart_init();
printf("\n\nStarting Core Dump\n");
// B... |
ert_equal_s("Yesterday, 4:00 PM", time_buf);
// June 9th 2015, 02:00:00 (T-14:00:00)
rtc_set_time(event_time - (14 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s(" 4:00 PM", time_buf);
// June 8th 2015, 16:00:00 (T-48:00:0... | clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Jun 9, 16:00", time_buf);
} |
void test_clock__time_12h_lower_style(void) {
char time_buf[64];
const int 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 int event_time = jun10th_noon_2015 - SECONDS_PER_DAY + (4 * SECONDS_PE... |
/*
* 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... | {
LauncherAppGlanceSettings *settings_glance =
launcher_app_glance_structured_get_data(structured_glance);
return NULL_SAFE_FIELD_ACCESS(settings_glance, title, NULL);
} |
static void prv_charging_icon_node_draw_cb(GContext *ctx, const GRect *rect,
UNUSED const GTextNodeDrawConfig *config, bool render,
GSize *size_out, void *user_data) {
LauncherAppGlanceStructured *structured_glance = user_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... | advert_disable() | ;
prv_send_response(msg, BLE_STATUS_OK);
}
static void prv_handle_advert_set_adv_data(const HcProtocolMessage *msg) {
advert_set_data((const BLEAdData *)&msg->payload[0]);
prv_send_response(msg, BLE_STATUS_OK);
}
void hc_endpoint_advert_handler(const HcProtocolMessage *msg) {
switch (msg->command_id) {
ca... |
(&word_iter) | );
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == '\n');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == 'N');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current... | |
ze) { DISP_COLS, DISP_ROWS });
}
void test_graphics_window_stack_animation__cleanup(void) {
free(fb);
}
// Helpers
////////////////////////////////////
typedef void (*ClippingMaskDrawFunc)(GContext *ctx);
static void prv_test_clipping_mask(ClippingMaskDrawFunc draw_func, const char *expected_image) {
GContext *... | compositor_round_flip_transitions_flip_animation_update(ctx, ANIMATION_NORMALIZED_MAX * 3 / 4,
CompositorTransitionDirectionLeft,
GColorWhite) | ;
}
void test_graphics_window_stack_animation__left_flip_third_quarter_frame_clipping(void) {
prv_test_clipping_mask(prv_left_flip_third_quarter_frame_clipping,
"left_flip_third_quarter_frame_clipping");
};
// This test records a clipping mask of the last frame of the left "round flip" comp... |
yer_get_content_size(ctx, header_layer);
header_size.h += 4; // See PBL-1741
header_size.w = w;
header_content_height = header_size.h;
text_layer_set_size(header_layer, header_size);
}
// Set up the text.
const uint16_t TEXT_OFFSET = 6;
x = left_margin_px;
y = (icon ? icon_offset + icon_size.... | scroll_layer_get_content_indicator(scroll_layer) | ;
content_indicator_configure_direction(
indicator, ContentIndicatorDirectionUp,
&(ContentIndicatorConfig) {
.layer = &expandable_dialog->dialog.status_layer.layer,
.times_out = true,
.colors.foreground = dialog->text_color,
.colors.background = ... |
/*
* 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... | fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD) | ;
snprintf(buffer, sizeof(buffer), EM_DASH);
}
const int y = PBL_IF_RECT_ELSE(PBL_IF_BW_ELSE(85, 83), 88);
graphics_context_set_text_color(ctx, CURRENT_TEXT_COLOR);
graphics_draw_text(ctx, buffer, font,
GRect(0, y, base_layer->bounds.size.w, 35),
GTextOverflowModeF... |
/*
* 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_resource_load_range(sys_get_current_resource_num(),
(uint32_t)h, 0, buffer, max_length);
} |
size_t applib_resource_load_byte_range(
ResHandle h, uint32_t start_offset, uint8_t *buffer, size_t num_bytes) {
return sys_resource_load_range(sys_get_current_resource_num(),
(uint32_t)h, start_offset, buffer, num_bytes);
}
void *applib_resource_mmap_or_load(ResAppNum app_num,... |
= (AnimationPrivate *)node;
ParentChildInfo *info = (ParentChildInfo *)data;
return animation->parent == info->parent && animation->child_idx == info->child_idx;
}
static AnimationPrivate* prv_find_animation_by_parent_child_idx(AnimationState *state,
AnimationPrivate *parent, int child_idx) {
if (!pa... | prv_get_total_duration(state, child, true, true) | ;
if (child_duration == PLAY_DURATION_INFINITE) {
return PLAY_DURATION_INFINITE;
}
max_child_duration = MAX(max_child_duration, child_duration);
}
duration += max_child_duration;
} else {
PBL_ASSERTN(animation->type == AnimationTypePrimitive);
duration += animation->duration... |
ice_handle_last();
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
cl_assert_passert(fake_event_service_handle_last());
}
void test_unobstructed_area_service__change(void) {
UnobstructedAreaHandlers handlers = {
.change = prv_change,
};
app_unobstructed_area_service_subscribe(ha... | app_unobstructed_area_service_subscribe(handlers, s_data.context) | ;
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
unobstructed_area_service_did_change(to_area.size.h);
fake_event_service_handle_last();
cl_assert_equal_i(s_data.num_will_change_... |
down_handler_calls, h), 1);
// Make sure the frame reached the "to" state
cl_assert_equal_i(prv_last_update_distance(h), ANIMATION_NORMALIZED_MAX);
// This should return NULL now if the animation got destroyed
cl_assert(animation_private_animation_find(h) == NULL);
// Make sure no animations exist
cl_ass... | prv_count_handler_entries(&s_setup_handler_calls, a) | |
left_hereafter, msg->crc32, num_bytes);
break;
}
default:
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Message type 0x%x not recognized", message[0]);
}
}
bool dls_endpoint_open_session(DataLoggingSession *session) {
CommSession *comm_session = comm_session_get_system_session();
if (!... | PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_WARNING, "Received ack for non-existent session id: %"PRIu8, session_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... | cron_job_schedule(job) | ;
cl_assert_equal_i((uintptr_t)job->cb_data, 0);
cl_assert_equal_i(job->cached_execute_time, target);
cl_assert_equal_i(cron_service_get_job_count(), 1);
// Mutate the execute time to see if we actually effect change.
job->cached_execute_time = UINT32_MAX;
job->clock_change_tolerance = 10;
prv_clock_chan... |
d) {
prv_init_and_goto_session_open();
EXECUTE_SCRIPT("var isCalled = false;"
"_rocky.on('postmessagedisconnected', function() { isCalled = true; });");
ASSERT_JS_GLOBAL_EQUALS_B("isCalled", false);
RCV_RESET_COMPLETE();
cl_assert_equal_i(rocky_api_app_message_get_state(),
... | (jerry_get_number_value(number), 1.0) | ;
JS_VAR object = prv_json_parse("{ \"x\" : 42 }");
cl_assert(jerry_value_is_object(object));
JS_VAR x = jerry_get_object_field(object, "x");
cl_assert(jerry_value_is_number(x));
cl_assert_equal_d(jerry_get_number_value(x), 42.0);
}
void test_rocky_api_app_message__json_parse_stress(void) {
const int num_... |
rors.
//! @param hold_down_time_ms The time (in ms) to hold down the button for each press. If NULL,
//! defaults to 20 ms. If < 0, errors.
//! @param delay_between_presses_ms The time (in ms) to delay between successive button presses.
//! If NULL, defaults to 0. If < 0, errors.
static void prv_button_pr... | prv_button_press_multiple(button_index, num_presses, hold_down_time_ms, delay_between_presses_ms) | |
V_APP_MESSAGE(TupletBytes(PostMessageKeyChunk, (const uint8_t *) &chunk, sizeof(chunk))); \
} while(0);
//! Asserts whether the outbox has a pending message containing the tuples passed to this macro.
//! The value and type of the tuples is also asserted.
//! @note Only asserts if expected tuples are MISSING. It wil... | {
prv_init_api(false /* start_connected */);
prv_simulate_transport_connection_event(true /* is_connected */);
prv_simulate_transport_connection_event(false /* is_connected */);
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateDisconnected);
} |
static void prv_init_and_goto_awaiting_reset_complete_remote_initiated(void) {
prv_init_api(true /* start_connected */);
RCV_RESET_REQUEST();
EXPECT_OUTBOX_RESET_COMPLETE_PENDING();
prv_rcv_app_message_ack(APP_MSG_OK);
cl_assert_equal_i(rocky_api_app_message_get_state(),
PostMessageSt... |
uint8_t *)attr, event.read_length);
} else if ((event.type == SmartstrapNotifyEvent) && state->handlers.notified) {
state->handlers.notified(attr);
}
sys_smartstrap_attribute_event_processed(attr);
}
}
// Subscription functions
//////////////////////////////////////////////////////////////////////... | {
#if USE_SMARTSTRAP
SmartstrapServiceId attribute_id;
sys_smartstrap_attribute_get_info(attr, NULL, &attribute_id, NULL);
return attribute_id;
#else
return 0;
#endif
} |
SmartstrapResult app_smartstrap_attribute_read(SmartstrapAttribute *attr) {
#if USE_SMARTSTRAP
if (!attr) {
return SmartstrapResultInvalidArgs;
}
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
return sys_smartstrap_attribute_do_request(attr, SmartstrapRequestTypeRead, state->timeout_... |
;
pfs_init(false);
s_ble_bonding_change_add_count = 0;
s_ble_bonding_change_update_count = 0;
s_ble_bonding_change_delete_count = 0;
s_analytics_ble_pairings_count = 0;
fake_shared_prf_storage_reset_counts();
bt_persistent_storage_init();
}
void test_bluetooth_persistent_storage__cleanup(void) {
bon... | cl_assert_equal_m(&device_out, &pairing_1.identity, sizeof(device_out)) | |
/*
* 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 true;
} |
return false;
}
static int16_t prv_get_chosen_row_index_for_id(SettingsActivityTrackerData *data,
AppInstallId worker_id) {
if (worker_id == INSTALL_ID_INVALID) {
return 0;
}
const uint16_t current_worker_app_index =
app_menu_data_source_get_index_of_a... |
lock(storage->mutex);
status_t rv = settings_file_each(&storage->file, each, data);
mutex_unlock(storage->mutex);
return rv;
}
void timeline_item_storage_init(TimelineItemStorage *storage,
char *filename, uint32_t max_size, uint32_t max_age) {
*storage = (TimelineItemStorage){
.name = filename,
.ma... | if (key_len != UUID_SIZE) {
return E_INVALID_ARGUMENT;
} |
mutex_lock(storage->mutex);
int offset = offsetof(SerializedTimelineItemHeader, common.status);
// Invert status to store on flash
status = ~status;
status_t rv = settings_file_set_byte(&storage->file, key, key_len, offset, status);
mutex_unlock(storage->mutex);
return rv;
}
status_t timeline_item_st... |
d
// frees up more slots for outbound data packets. As long as we send an Ack
// before the in-flight window fills, the phone can keep pushing data.
// If very little data is in flight, flushing Acks periodically will have no
// ... | prv_set_payload_size_for_sn(client, sn, 0) | |
tted(&ctx, GPoint(23, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 7), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(24, 7), 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_no_clip")));
// Even cols of different lengths
setup_tes... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_no_clip"))) | |
, 560, 736},
{ 216, 584, 744},
{ 216, 560, 704},
{ 224, 528, 672},
{ 256, 584, 696},
{ 288, 600, 728},
{ 280, 664, 824},
{ 208, 576, 744},
{ 152, 648, 584},
{ 136, 664, 608},
{ 144, 608, 592},
{ 144, 616, 544},
{ 168, 736, 584},
{ 160, 760, 600},
{ 112, 744, 640},... | { 48, 520, -424},
{ -8, 504, -560},
{ -64, 264, -664},
{ -168, 448, -744},
{ -240, 240, -800},
{ -232, 448, -808},
{ -296, 448, -840},
{ -256, 440, -816},
{ -272, 488, -864},
{ -328, 416, -872},
{ -312, 480, -816},
// 98 seconds
{ -344, 408, -872},
{ -296, 512, -8... | |
pace);
kernel_free(name);
return status;
}
T_STATIC status_t settings_file_compact(SettingsFile *file) {
return settings_file_rewrite_filtered(file, NULL, NULL);
}
static bool key_matches(SettingsRawIter *iter, const uint8_t *key, int key_len) {
SettingsRecordHeader *hdr = &iter->hdr;
if (key_len != hdr->ke... | (&file->iter, key, key_len) | ) {
memset(val_out, 0, val_out_len);
return E_DOES_NOT_EXIST;
}
if (deleted_and_expired(&file->iter.hdr)) {
memset(val_out, 0, val_out_len);
return E_DOES_NOT_EXIST;
}
size_t val_len = file->iter.hdr.val_len;
if (val_out_len > val_len) {
memset(val_out, 0, val_out_len);
return E_RANGE;... |
640},
{ 584, 480, 560},
{ 592, 456, 560},
{ 600, 440, 560},
{ 616, 488, 528},
{ 616, 488, 560},
{ 616, 456, 544},
{ 608, 464, 560},
{ 600, 480, 568},
{ 592, 464, 520},
{ 576, 480, 552},
{ 584, 448, 648},
{ 608, 544, 584},
// 90 seconds
{ 624, 536, 624},
{ 592,... | { 416, 104, -856},
{ 440, 128, -888},
{ 440, 120, -904},
{ 432, 80, -864},
{ 432, 104, -856},
{ 424, 104, -824},
{ 408, 120, -768},
{ 376, 160, -728},
{ 344, 288, -624},
{ 328, 232, -280},
{ 416, 920, 48},
{ 440, 1128, 208},
{ 552, 776, 336},
{ 664, 704, 272},
... |
{ 656, 600, 152},
{ 656, 592, 144},
{ 664, 576, 120},
{ 664, 592, 136},
{ 664, 688, 136},
{ 648, 640, 104},
{ 640, 616, 120},
{ 656, 608, 96},
{ 664, 656, 96},
{ 664, 680, 104},
{ 656, 656, 104},
{ 656, 632, 88},
{ 648, 664, 112},
{ 648, 608, 104},
{ 672, 648... |
ta_shared.h"
#include "applib/event_service_client.h"
#include "kernel/events.h"
#include "services/common/comm_session/session_remote_version.h"
#include "services/normal/blob_db/weather_db.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/weather/weather_service.h"
#include "services/normal/we... | (to_check->tomorrow_weather_type, original->tomorrow_weather_type) | ;
}
void test_weather_service__get_data_for_all_locations(void) {
size_t count_out;
WeatherDataListNode *head = weather_service_locations_list_create(&count_out);
WeatherLocationID id = 0;
WeatherDataListNode *current = head;
while (current) {
cl_assert_equal_i(current->id, id);
prv_assert_forecast_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_create_card_and_render(&(HealthData) {}) | |
ian);
activity_get_metric(ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1, &last_update_utc);
cl_assert_equal_i(last_median, 0);
cl_assert_equal_i(last_update_utc, 0);
// Simulate some HRM callbacks with no heart rate, should get 0 median
prv_advance_time_hr(10 /*sec*/, 0 /*hr*/, HRMQuality_Good, true /*for... | (s_last_hr_event.data.heart_rate_update.quality, HRMQuality_OffWrist) | ;
// Should fire off an event. Good HR and Good Quality
prv_advance_time_hr(1 /*sec*/, 120 /*hr*/, HRMQuality_Excellent, true /*force_continuous*/);
cl_assert_equal_i(s_num_hr_events, 4);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 120);
cl_assert_equal_i(s_last_hr_event.data.heart_... |
o find out
// why the QSPI driver is locking up when doing development
static void prv_wait_for_transfer_complete(void) {
int i = 0;
while (QSPI_GetFlagStatus(QSPI_FLAG_TC) == RESET) {
if (++i > QSPI_WAIT_TIME) {
break;
}
}
PBL_ASSERT(i < QSPI_WAIT_TIME, "Waited too long for the QSPI transfer to ... | prv_wait_for_not_busy() | ;
}
void qspi_indirect_read_no_addr(QSPIPort *dev, uint8_t instruction, uint8_t dummy_cycles,
void *buffer, uint32_t length, bool is_ddr) {
prv_indirect_read(dev, instruction, QSPI_ADDR_NO_ADDR, dummy_cycles, buffer, length, is_ddr);
}
void qspi_indirect_read(QSPIPort *dev, uint8_t in... |
b_malloc.auto.h"
#include "applib/ui/status_bar_layer.h"
#include "applib/ui/window.h"
#include "applib/ui/window_stack.h"
#include "process_state/app_state/app_state.h"
#include "services/normal/timeline/timeline.h"
#include "services/common/i18n/i18n.h"
#define ACTION_MENU_DEFAULT_BACKGROUND_COLOR GColorWhite
stati... | crumbs_layer_width() | ;
PropertyAnimation *prop_anim =
property_animation_create_layer_frame((Layer *)&data->action_menu_layer,
&start,
&stop);
Animation *content_in = property_animation_get_animation(prop_anim);
animation_set_duration(conten... |
/*
* 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... | jerry_create_error(JERRY_ERROR_TYPE, msg) | ;
}
jerry_value_t rocky_error_argument_invalid(const char *msg) {
return jerry_create_error(JERRY_ERROR_TYPE, (jerry_char_t *)msg);
}
jerry_value_t rocky_error_argument_invalid_at_index(uint32_t arg_idx, const char *error_msg) {
char buffer[100] = {0};
snprintf(buffer, sizeof(buffer), "Argument at index %"PRIu3... |
/*
* 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... | CTYPE_THEIRS(isascii) |
CTYPE_THEIRS(toascii)
// We have to do this because glibc throws specification to the wind.
// Quoting from the C99 spec:
// If the argument is a character for which isupper is true and there are one or more
// corresponding characters, as specified by the current locale, for which islower is true,
// the tolo... |
/*
* 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... | utf8_peek_codepoint(valid_gothic_codepoints_utf8, NULL) | ;
uint32_t actual_codepoint = s_valid_gothic_codepoints[i];
cl_assert_equal_i(decoded_codepoint, actual_codepoint);
valid_gothic_codepoints_utf8 = utf8_get_next(valid_gothic_codepoints_utf8);
}
}
void test_utf8__emoji_codepoints(void) {
cl_assert(utf8_is_valid_string("\xF0\x9F\x98\x84"));
cl_assert(u... |
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 "applib/graphics/graphics.h"
#include "applib/g... | cl_assert(gvectorprecise_equal(&vectorP, &vectorP_c)) | |
e);
fake_battery_set_connected(true);
periodic_timer_trigger(1);
cl_assert(!s_in_low_power);
cl_assert_equal_i(s_power_state, PowerStateGood);
// good -> critical
fake_battery_set_millivolts(critical_mv);
fake_battery_set_charging(false);
fake_battery_set_connected(false);
periodic_timer_trigger(20);... | battery_curve_lookup_voltage_by_percent(50, false) | |
ngKey) {
.data = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00,
},
},
.identity = (BTDeviceInternal) {
.address = (BTDeviceAddress) {
.octets = {
0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
},
},
.... | bt_persistent_storage_store_bt_classic_pairing(&addr_1, &link_key_1,
name_1, &platform_bits_1) | ;
cl_assert(id_1 != BT_BONDING_ID_INVALID);
cl_assert_equal_i(fake_shared_prf_storage_get_bt_classic_store_count(), 1);
// Read it back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id_1, &addr_out, &link_key_out,
name_out, &platform_bits_out);
c... |
prv_vibe_score_get_pattern_length(pattern_attribute); i++) {
if (pattern_list[i] >= num_note_types) {
return false;
}
}
GenericAttribute *repeat_delay_attribute =
generic_attribute_find_attribute(&score->attr_list, VibeAttributeId_RepeatDelay,
score->attr_... | for (unsigned int i = 0; i < pattern_length; i++) {
VibeNote *note = ¬e_list[pattern_list[i]];
if (note->vibe_duration_ms > 0) {
sys_vibe_pattern_enqueue_step_raw(note->vibe_duration_ms, note->strength);
}
if (note->brake_duration_ms > 0) {
sys_vibe_pattern_enqueue_step_raw(note->brake_du... |
sys_vibe_pattern_trigger_start();
}
VibeScore *vibe_score_create_with_resource(uint32_t resource_id) {
ResAppNum app_num = sys_get_current_resource_num();
return vibe_score_create_with_resource_system(app_num, resource_id);
}
void vibe_score_destroy(VibeScore *score) {
if (!score) {
return;
}
applib... |
(result, false) | ;
}
void test_health__range_to_day_id_clamps_values(void) {
const time_t now = rtc_get_time();
bool result;
HealthServiceTimeRange range;
// clamps value that goes into the future
result = prv_calculate_time_range(now - 10, now + 11, &range);
cl_assert_equal_b(result, true);
cl_assert_equal_range(range,... | |
/*
* 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... | serial_console_write_log_message(":") | ;
serial_console_write_log_message(line_number_buffer);
serial_console_write_log_message("> ");
}
// Write the actual log message.
serial_console_write_log_message(message);
// Append our newlines and our trailing null
serial_console_write_log_message("\r\n");
}
#endif // PULSE_EVERYWHERE
void kern... |
= next_resting_calories++;
minute_data[i].distance_cm = next_distance_cm++;
minute_data[i].base.active = (minute_data[i].base.steps >= ACTIVITY_ACTIVE_MINUTE_MIN_STEPS)
? 1 : 0;
minute_data[i].heart_rate_bpm = next_heart_rate_bpm++;
minute_data[i].heart_rate_total_weight... | (s_dls_records[j].hdr.version, ALG_DLS_MINUTES_RECORD_VERSION) | |
nt8_t age_years;
ActivityGender gender;
uint16_t weight_dag;
uint16_t height_mm;
} HumanPrefs;
#define ACTIVITY_DEFAULT_HEIGHT_MM 1620 // 5'3.8"
// dag - decagram (10 g)
#define ACTIVITY_DEFAULT_WEIGHT_DAG 7539 // 166.2 lbs
#define ACTIVITY_DEFAULT_GENDER Acti... | cl_assert_within(short_guy_distance, 36000, 44000) | ;
cl_assert_gt(long_run_distance_m, short_guy_distance);
// And finally throw in a specific value so that anyone who touches the function will have to
// check up on the unit tests
cl_assert_equal_i(short_guy_distance, 36845);
}
// ------------------------------------------------------------------------------... |
/*
* 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;
} |
FirmwareDescription firmware_description = firmware_storage_read_firmware_description(flash_address);
if (!firmware_storage_check_valid_firmware_description(&firmware_description)) {
memset(out_metadata, 0, sizeof(FirmwareMetadata));
return false;
}
// The FirmwareMetadata is stored at the end of the ... |
c
Animation *spawn = animation_spawn_create(b, c, NULL);
cl_assert(spawn != NULL);
// Create a sequence by putting a in front and repeat it 5 times
// We now have a -> (b | c)
Animation *seq = animation_sequence_create(a, spawn, NULL);
animation_set_play_count(seq, repeat_count);
// Now, clone it
An... | prv_count_handler_entries(&s_stopped_handler_calls, a0) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a1), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a1), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a2), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.