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... | {
// String. TODO: the string is null terminated for now.
BinLogMessage_StringParam *str_param = (BinLogMessage_StringParam *)arg;
// Send the string pointer!
args[arg_index] = (uint32_t)str_param->string;
arg += (str_param->length + 1 + (sizeof(uint32_t) - 1)) / sizeof(uint32_t);
} | else {
// Integer
args[arg_index] = *arg;
arg++;
}
arg_index++;
}
// Fixup the hash (add the #args, ignore the task id for now, leave the level 0) TODO.
uint32_t hash = ((msg->body.msgid.msg_id & MSGID_STR_AND_HASH_MASK) |
((arg_index & PACKED_NUM_FMT_MASK) << PACKED... |
/*
* 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 (handle_sentence && !handle_sentence(sentence, data)) {
// end iteration if callback returns false
break;
} |
sentence = transcription_iterate_words(sentence->words, sentence->word_count, NULL, NULL);
}
return (void *)sentence;
}
void *transcription_iterate_words(const TranscriptionWord *words, size_t count,
TranscriptionWordIterateCb handle_word, void *data) {
uint8_t *cursor = (uint8_t *)words;
for (size_... |
is must be a multiple of 8 so that we are word-aligned when using a 1-bit bitmap.
#define GRID_CELL_PADDING 8
static void prv_prepare_canvas_and_render_notification_windows(unsigned int num_down_scrolls) {
// Initialize the notification window module before rendering anything
notification_window_init(false /* is_m... | (PBL_IF_RECT_ELSE(2, 1) /* num_down_scrolls */) | ;
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE();
}
void test_notification_window__reminder(void) {
s_test_data = (NotificationWindowTestData) {
.icon_id = TIMELINE_RESOURCE_NOTIFICATION_REMINDER,
.title = "Feed Humphrey",
.location_name = "RWC Office",
.body = "Only the best!",
.reminder_times... |
/*
* 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... | pfs_get_file_size(fd) | ;
return GET_BYTES_OK;
}
bool gb_storage_file_read_next_chunk(GetBytesStorage *storage, uint8_t *buffer, uint32_t len) {
const int fd = (int) storage->impl_data;
storage->current_offset += len;
return (pfs_read(fd, buffer, len) > 0);
}
void gb_storage_file_cleanup(GetBytesStorage *storage, bool successful) {
... |
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_IDLE_HYST, 0x4);
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_IDLE_MIN, 0x10);
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_V18P_RET_CYCLES, 0x5);
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_V18P_CUR_LIM_RET, 0xA);
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_VDD_RET_CYCLES, 0x5);
REG_SETF(DCDC,... | (QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO3_DAT, 0x0) | ;
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO2_DAT, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO3_OEN, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO2_OEN, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_CLK_MD, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_AUTO_MD, 0x0);
REG_SETF(QSPIC, QSPIC... |
; gen++) {
// Check to make sure the most recent log gens are around
snprintf(log, 100, "Generation 0x%x", i - gen);
setup_and_test_expected_msg(&log, gen, 1, 1);
}
}
free(log);
}
//! Test the case where the most recent log generation has wrapped the logging
//! region many times. Confirm t... | ((uint8_t *)&curr_msg[offset], addr,
bytes_to_write) | ;
cl_assert(rv);
bytes_remaining -= bytes_to_write;
}
// try to write something past the end to ensure it doesn't take
uint8_t buf[128] = { 0 };
rv = flash_logging_write(&buf[0], addr, sizeof(buf));
cl_assert(!rv);
}
setup_and_test_expected_msg(logs, 0, num_logs, num_logs);
}
|
/*
* 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... | fake_rtc_increment_time_ms(1030) | ;
interval_timer_take_sample(&timer);
// = 1000 + (0.5 * (1030 - 1000))
// = 1000 + (0.5 * 30)
// = 1015
num_intervals = interval_timer_get(&timer, &average_ms);
cl_assert_equal_i(num_intervals, 3);
cl_assert_equal_i(average_ms, 1015);
}
void test_interval_timer__invalid_samples(void) {
IntervalTimer... |
ACTIVATION_DELAY_INSIGHTS[i].hour,
ACTIVATION_DELAY_INSIGHTS[i].minute);
if (!activity_prefs_has_activation_delay_insight_fired(i) && (now >= trigger_time_t)) {
prv_trigger_activation_delay_insig... | (now_utc, &SLEEP_REWARD_NOTIF_CONFIG) | ;
}
// -----------------------------------------------------------------------------------------
// Format a time given in seconds after midnight
static void prv_strcat_formatted_time(int32_t time_seconds, char *out_buf, size_t buf_length,
const void *i18n_owner) {
struct tm tim... |
---------------------------------------------------------
void worker_manager_close_current_worker(bool gracefully) {
// This method can be called as a result of receiving a PEBBLE_PROCESS_KILL_EVENT notification
// from an app, telling us that it just finished it's deinit.
// Shouldn't be called from app. Use ... | worker_preferences_set_default_worker(id) | ;
}
// ------------------------------------------------------------------------------------------------
void worker_manager_enable(void) {
if (!s_workers_enabled) {
s_workers_enabled = true;
AppInstallId id = worker_manager_get_default_install_id();
if (id != INSTALL_ID_INVALID) {
worker_manager_p... |
prentice_Syndrome
// We'll rely on the ACK timeout for the next data packet to fire and roll back.
PBL_LOG(LOG_LEVEL_WARNING, "Received retransmitted Ack for sn:%"PRIu32". Ignoring it.", sn);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Ack'd packet out of range %"PRIu32", [%u-%u].",
sn, client->out.nex... | if (!uuid_is_system(&meta->app_uuid)) {
PBL_LOG(LOG_LEVEL_ERROR, "Found PPoGATT server from non-Pebble app, not connecting in PRF..");
goto handle_error;
} |
#endif
// Use the highest version that both ends support:
client->version = MIN(meta->ppogatt_max_version, PPOGATT_MAX_VERSION);
// Parse additional v1 metadata fields:
PPoGATTSessionType session_type = PPoGATTSessionType_InferredFromUuid;
if (/*meta->ppogatt_max_version >= 0x01 &&*/ value_length >= sizeof... |
acros(void) {
cl_assert_equal_i(0b1, BITS(0));
cl_assert_equal_i(0b00011111, BITS(4));
cl_assert_equal_i(0b00111111, BITS_BETWEEN(0,5));
cl_assert_equal_i(0b00111000, BITS_BETWEEN(3,5));
cl_assert_equal_i(0b00010000, BITS_BETWEEN(4,4));
}
// Flash memory is organized into twelve sectors of unequal sizes.
// ... | (flash_written_data) | ;
flash_written_flag = malloc(size * sizeof(bool));
cl_assert(flash_written_flag);
}
void assert_flash_unwritten(uint32_t start, uint32_t length) {
for (uint32_t i = 0; i < length; ++i) {
cl_assert(flash_written_flag[start + i] == false);
}
}
void test_system_flash__write_simple(void) {
const char testd... |
/*
* 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... | dbgserial_print_hex(button_id) | |
| ModalProperty_CompositorTransitions |
ModalProperty_RenderRequested | ModalProperty_Unfocused);
// Checks are listed from top to bottom
cl_assert_equal_i(windows[2][1]->on_screen, true);
cl_assert_equal_i(windows[2][1]->is_click_configured, false);
cl_assert_equal_i(windows[2][0]->on_scree... | cl_assert_equal_i(modal_manager_get_properties(),
ModalProperty_Exists | ModalProperty_CompositorTransitions |
ModalProperty_RenderRequested) | ;
// Disable all modals
modal_manager_set_min_priority(ModalPriorityMax);
modal_manager_event_loop_upkeep();
cl_assert_equal_i(modal_manager_get_properties(),
ModalProperty_Transparent | ModalProperty_Unfocused);
// Re-enable all modals
modal_manager_set_min_priority(ModalPriorityMin)... |
< FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 3);
test_num = (int32_t)((float)-0.500 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 4)... | cl_assert(num.fraction == 0) | ;
}
void test_math_fixed__Fixed_S16_3_rounded_int(void) {
cl_assert_equal_i(0, Fixed_S16_3_rounded_int(Fixed_S16_3(0)));
cl_assert_equal_i(0, Fixed_S16_3_rounded_int(Fixed_S16_3(3)));
cl_assert_equal_i(1, Fixed_S16_3_rounded_int(Fixed_S16_3(4)));
cl_assert_equal_i(1, Fixed_S16_3_rounded_int(Fixed_S16_3(8)));
... |
tx, CENTER_OF_ORIGIN_RECT_NXNY, RADIUS_MIN_CALCULATED);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_origin_aa_r3_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Radius of 2 - ending point for precomputed edges
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_draw_circle(&... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_aa_r8_clip_nxny.${BIT_DEPTH_NAME}.pbi")) | ;
// Small circles
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 1);
graphics_draw_circle(&ctx, CENTER_OF_OFFSET_RECT, RADIUS_SMALL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_aa_r1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP... |
// The rest of worker_ram is available for worker state to use as it sees fit.
if (!worker_state_configure(&worker_ram)) {
PBL_LOG(LOG_LEVEL_ERROR, "Worker state configuration failed");
return false;
}
// The remaining space in worker_segment is assigned to the worker's
// heap. Worker state needs to ... | PBL_LOG(LOG_LEVEL_DEBUG, "Worker not ready to exit") | |
nt.h>
#include "board/board.h"
#include "drivers/button.h"
#include "drivers/dbgserial.h"
#include "drivers/display.h"
#include "drivers/flash.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "drivers/pmic.h"
#include "drivers/pwr.h"
#include "drivers/watchdog.h"
#include "boot_tests.h"
#includ... | prv_get_fw_reset_vector(&reset_handler, &initial_stack_pointer) | |
.pbi"));
// Top-left corner rotation point, Angle 45
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_bw,
GPointZero, DEG_TO_TRIGANGLE(45), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitma... | (&ctx, test_image_color,
GPointZero, DEG_TO_TRIGANGLE(0), GPointZero) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_origin_color_set_0.Xbit.pbi"));
// Top-left corner rotation point, Angle 45
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
... |
rvices/common/system_task.h"
#include "system/passert.h"
#include "system/reboot_reason.h"
#include "system/reset.h"
EventServiceInfo bt_state_change_event_info;
typedef enum {
BtTestStateInit = 0,
BtTestStateStopped,
BtTestStateStarting,
BtTestStateStopping,
BtTestStateStarted,
BtTestStateFailed,
BtTes... | text_layer_set_font(title, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)) | |
NULL; row = (StatsRow *)row->node.next, row_idx++) {
fprintf(file, "\"%s\"", test_name);
StatsEpochType epoch_type;
if (!is_stepping) {
epoch_type = StatsEpochTypeNonStepping;
} else if (row_idx == 0 || !row->node.next) {
// We consider the first and last epoch of each sample as a "partial ... | (&orientation, &vmc) | ;
samples_in_minute = 0;
}
}
// leftover data, if any
if (chunk_size > 0) {
steps = ref_accel_data_handler(accel_buf, chunk_size);
}
steps = ref_finish_epoch();
ref_minute_stats(&orientation, &vmc);
PBL_LOG(LOG_LEVEL_DEBUG, "processed %d samples (%d seconds) of data: %d steps",
n... |
_IO uint16_t*) (FMC_BANK_1_BASE_ADDRESS + sector_address))[COMMAND_ADDRESS] = cmd;
}
static void prv_software_reset(void) {
prv_issue_command(0, S29VSCommand_SoftwareReset);
}
// Note: If this command has been executed at least once, all sectors are
// locked. They then must be unlocked before and relocked after ea... | for (uint8_t pin_source = 0; pin_source < 16; ++pin_source) {
if (pin_source == 2) {
continue;
}
GPIO_PinAFConfig(GPIOD, pin_source, GPIO_AF_FMC);
} |
gpio_init.GPIO_Pin = GPIO_Pin_All & (~GPIO_Pin_2);
GPIO_Init(GPIOD, &gpio_init);
for (uint8_t pin_source = 2; pin_source < 16; ++pin_source) {
GPIO_PinAFConfig(GPIOE, pin_source, GPIO_AF_FMC);
}
gpio_init.GPIO_Pin = GPIO_Pin_All & (~GPIO_Pin_0) & (~GPIO_Pin_1);
GPIO_Init(GPIOE, &gpio_init);
// We h... |
void test_flash_logging__initialize(void) {
fake_spi_flash_init(0, FLASH_SIZE);
}
void test_flash_logging__cleanup(void) {
uint32_t size = FLASH_REGION_DEBUG_DB_BEGIN - 0;
fake_flash_assert_region_untouched(0, size);
size = FLASH_SIZE - FLASH_REGION_DEBUG_DB_END;
fake_flash_assert_region_untouched(FLASH_RE... | (*num_logs * sizeof(char *)) | |
/*
* 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 Uuid system = UUID_SYSTEM;
const Uuid invalid = UUID_INVALID;
const Uuid test_uuid_1 = (Uuid) {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5
};
cl_assert(uuid_is_invalid(&invalid));
cl_assert(!uuid_is_invalid(&system));
cl_assert(!uuid_is_invalid(&test_uuid_1));
} |
void test_uuid__string(void) {
char buffer[UUID_STRING_BUFFER_LENGTH];
const Uuid test_uuid_1 = (Uuid) {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5
};
uuid_to_string(&test_uuid_1, buffer);
cl_assert_equal_s(buffer, "{00010203-0405-0607-0809-000102030405}");
const Uuid system = UUID_SYSTEM;
uu... |
(const uint8_t *command, uint32_t length) {
s_sending_endpoint_id = 0;
s_sending_data_length = 0;
blob_db_protocol_msg_callback(s_session, command, length);
fake_system_task_callbacks_invoke_pending();
fake_comm_session_process_send_next();
cl_assert(BLOB_DB_ENDPOINT_ID == s_sending_endpoint_id);
return ... | (TEST_VALUE_SIZE == *(uint16_t*)cmd_ptr) | ;
cmd_ptr += sizeof(uint16_t);
// go past value_bytes
cmd_ptr += TEST_VALUE_SIZE;
cl_assert((cmd_ptr - s_insert_cmd_success) == sizeof(s_insert_cmd_success));
// Process Command
uint8_t *resp_ptr = process_blob_db_command(s_insert_cmd_success, sizeof(s_insert_cmd_success));
// Check Response
cl_asse... |
0; i < ARRAY_LENGTH(test_config); i++) {
TestConfig c = test_config[i];
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
GPoint pt = CENTER_OF_ORIGIN_RECT;
// draw multiple quads with different radiuses
for (int r = 0; r <= 15; r++) {
graphics_circle_quadrant_draw... | {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Draw red circles with different alpha values in the stroke color with antialiasing enabled
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 0);
graphics_context_set_stroke_color(&ctx, GColorRed);
prv_draw_circles(&ctx);
c... | |
/*
* 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... | (out_metadata, &TINTIN_METADATA, sizeof(FirmwareMetadata)) | ;
return true;
}
static bool prv_version_copy_flash_fw_metadata(FirmwareMetadata *out_metadata,
uint32_t flash_address, bool check_crc) {
FirmwareDescription firmware_description =
firmware_storage_read_firmware_description(flash_address);
if (check_crc &&
... |
r example, if the current index is (section: 0, row: 0), the section_callback for section 0
// will only be called when walking upward.
static void prv_menu_layer_walk_downward_from_iterator(MenuIterator *it) {
const uint16_t num_sections = prv_menu_layer_get_num_sections(it->menu_layer);
it->should_continue = tru... | {
// If top-most row, layout the section header
it->cursor.h = prv_menu_layer_get_header_height(it->menu_layer, it->cursor.index.section);
it->cursor.sep = prv_menu_layer_get_separator_height(it->menu_layer, &it->cursor.index);
if (it->cursor.h > 0) {
// Bottom of previous cell is y of ... |
if (it->should_continue == false) {
return;
}
// Previous section:
if (it->cursor.index.section == 0) {
// Reached top
break;
}
--(it->cursor.index.section);
// -1 will happen when entering for() rows
it->cursor.index.row = it->menu_layer->callbacks.get_num_rows(it->... |
ess) {
return out_min + (out_max - out_min) * (progress - in_min) / (in_max - in_min);
}
static void prv_draw_banner_round(NotificationLayout *notification_layout, GContext *ctx,
const GRect *const notification_layout_frame,
LayoutColors colors) {
... | graphics_context_set_text_color(ctx, GColorBlack) | ;
(text_visible ? graphics_text_node_draw :
graphics_text_node_get_size)(layout->view_node, ctx, &box, &config,
&layout->view_size);
#if PBL_ROUND
if (render) {
// restore original clip box
ctx->draw_state.clip_box.size.h = orig_clip_height;
... |
/*
* 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... | GRect(4, -5, 18, 10) | |
us) {
case HciStatusCode_Success: {
// Disconnection! Update our records:
GAPLEConnection *connection = gap_le_connection_by_device(&event->peer_address);
#if CAPABILITY_HAS_BUILTIN_HRM
ble_hrm_handle_disconnection(connection);
#endif
const bool local_is_master = connection->local_is_master;... | gap_le_connection_by_addr(&event->dev_address) | ;
if (connection->is_encrypted) {
PBL_LOG(LOG_LEVEL_INFO, "Encryption refreshed!");
goto unlock;
}
const bool local_is_master = connection->local_is_master;
connection->is_encrypted = true;
if (!local_is_master) {
PBL_LOG(LOG_LEVEL_INFO, "Hurray! LE Security established.");
bluetooth_analyti... |
st KernelLEClient *client) {
const uint16_t value_length = event->value_length;
uint8_t *buffer = NULL;
if (value_length) {
// This is ugly and causes double-copying the data...
// TODO: https://pebbletechnology.atlassian.net/browse/PBL-14164
buffer = (uint8_t *) kernel_malloc(value_length);
if (... | client->handle_subscribe(event->object_ref, event->subscription_type, event->gatt_error) | ;
return;
case PebbleBLEGATTClientEventTypeCharacteristicRead:
if (!client->handle_read_or_notification) {
goto log_error;
}
prv_consume_read_response(event, client);
return;
default:
break;
}
log_error:
PBL_LOG(LOG_LEVEL_ERROR,
"Unhandled GATT event:... |
nt num_bytes) {
uint8_t buffer[num_bytes];
uint32_t read_bytes = dls_test_read(logging_session, buffer, num_bytes);
cl_assert(read_bytes == num_bytes);
uint32_t session_crc = legacy_defective_checksum_memory(buffer, num_bytes);
cl_assert(crc == session_crc);
dls_test_consume(logging_session, num_bytes);
... | {
item_size[i] = 50 + (rand() % 250);
logging_sessions[i] = data_logging_create(i, DATA_LOGGING_BYTE_ARRAY, item_size[i], false);
cl_assert(logging_sessions[i]);
fake_system_task_callbacks_invoke_pending();
} |
// Log Consume
for (int i = 0; i < 10; i++) {
prv_log_consume_random(logging_sessions[i], item_size[i], rand() % 123);
}
}
// ----------------------------------------------------------------------------------------
// Test writing and consuming so much that we are forced to reallocate the file partway
// ... |
(bitmap, GET_PBI_NAME(3)) | );
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(4)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_s... | |
Point(5, 5), GPoint(45, 10)));
#else
ASSERT_CALLED(graphics_line_draw_1px_non_aa(&context, GPoint(5, 5), GPoint(45, 10)));
#endif
setup_test(&context, true, 1, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));... | GPoint(45, 10) | |
_data_size)
: SPRF_UNWRITTEN_CRC;
const bool same_data =
(0 == memcmp(SPRF_FIELD_DATA(field), SPRF_FIELD_DATA(((uint8_t *)data) + offset),
field_data_size));
if (data->magic == SprfMagic_UnpopulatedEntry) {
// Struct that is written is currently un... | {
prv_lock();
prv_invalidate_current_page();
prv_unlock();
} |
//!
//! Custom Local Device Name APIs
//!
bool shared_prf_storage_get_local_device_name(char *local_device_name_out, size_t max_size) {
bool rv;
prv_lock();
{
SprfLocalName data;
rv = SPRF_FETCH_FIELD(data, local_name);
if (!rv) {
goto unlock;
}
if (local_device_name_out) {
str... |
selection_window->time_data.hour;
const int minute_end = time_selection_window->time_data.minute;
int hour_start = hour_end;
int minute_start = minute_end;
clock_hour_and_minute_add(&hour_start, &minute_start,
-time_selection_window->range_duration_m);
char start_buf[TIME_STRING_T... | (time_selection_window) | ;
}
static void prv_text_layer_init(Layer *window_layer, TextLayer *text_layer, const GFont font) {
text_layer_init_with_parameters(text_layer, &GRectZero, NULL, font, GColorBlack, GColorClear,
GTextAlignmentCenter, GTextOverflowModeTrailingEllipsis);
layer_add_child(window_layer,... |
tr_list->attributes = (Attribute *)*buffer;
*buffer += attributes_per_group_type_element * sizeof(Attribute);
}
static void prv_init_group_type(AttributeGroupType type,
void *group_ptr,
uint8_t **buffer,
uint8_t num_group... | if (type == AttributeGroupType_Action) {
num_group_type_elements = ((TimelineItemActionGroup *)group_ptr)->num_actions;
} else {
num_group_type_elements = ((AddressList *)group_ptr)->num_addresses;
} |
for (int i = 0; i < num_group_type_elements; i++) {
AttributeList *group_type_element_attribtue_list;
if (type == AttributeGroupType_Action) {
group_type_element_attribtue_list = prv_deserialize_action(
&((TimelineItemActionGroup *)group_ptr)->actions[i], &cursor, payload_end,
buff... |
starting normally.");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
return false;
}
// We failed to start our firmware successfully!
if (watchdog_check_reset_flag()) {
dbgserial_putstr("Watchdog caused a reset");
}
if (boot_bit_test(BO... | {
check_and_handle_resuming_from_standby();
dbgserial_init();
dbgserial_putstr("");
dbgserial_putstr(" ____ __");
dbgserial_putstr("/\\ _`\\ /'__`\\");
dbgserial_putstr("\\ \\,\\L\\_\\ ___ /\\ \\/\\ \\ __ __ __ __ __");
dbgserial_putstr(" \\/_\\__ \\ /' _ `\\ \\ \\ \\ \... |
flash_init();
button_init();
display_init();
#ifdef DISPLAY_DEMO_LOOP
while (1) {
for (int i=0; i < 92; ++i) {
display_firmware_update_progress(i, 91);
delay_us(80000);
}
for (uint32_t i=0; i <= 0xf; ++i) {
display_error_code(i * 0x11111111);
delay_us(200000);
}
fo... |
buffer
struct stat st;
cl_assert(stat(in_path, &st) == 0);
FILE *file = fopen(in_path, "r");
cl_assert(file);
uint8_t buf[st.st_size];
// copy file to fake flash storage
cl_assert(fread(buf, 1, st.st_size, file) > 0);
pfs_remove(pfs_name);
int fd = pfs_open(pfs_name, OP_FLAG_WRITE, FILE_TYPE_STATIC... | prv_feed_cannned_accel_data(15 * SECONDS_PER_MINUTE, 0, ActivitySleepStateAwake) | ;
prv_feed_cannned_accel_data(60 * SECONDS_PER_MINUTE, 0, ActivitySleepStateLightSleep);
prv_feed_cannned_accel_data(50 * SECONDS_PER_MINUTE, 0, ActivitySleepStateRestfulSleep);
// Wait long enough for our recompute sleep logic to run.
prv_feed_cannned_accel_data(SECONDS_PER_MINUTE * ACTIVITY_SESSION_UPDATE_M... |
);
}
void test_put_bytes__install_message_too_short(void) {
prv_receive_init_put_and_commit_fw_object();
const uint8_t incomplete_install_msg = CmdInstall;
prv_receive_data(s_session, (const uint8_t *) &incomplete_install_msg,
sizeof(incomplete_install_msg));
assert_ack_count... | fake_event_reset_count() | |
f (task == PebbleTask_Unknown) {
task = pebble_task_get_current();
}
if (task == PebbleTask_App) {
return app_state_get_accel_state();
} else if (task == PebbleTask_Worker) {
return worker_state_get_accel_state();
} else {
WTF;
}
}
void accel_service_cleanup_task_session(PebbleTask task) {
... | {
if (state->deferred_free) {
PBL_LOG(LOG_LEVEL_DEBUG, "Deferred free");
kernel_free(state);
}
// event queue is handled kernel-side, so an event may fire after we've unsubscribed
return;
} |
PBL_ASSERTN(state->data_handler != NULL || state->raw_data_handler != NULL
|| state->raw_data_handler_deprecated != NULL);
uint16_t time_interval_ms = 1000 / state->sampling_rate;
// Process in chunks to limit the amount of stack space we use up.
uint32_t num_processed;
do {
num_processe... |
UNK_KEY_THREAD, etc.
// uint32_t chunk_size // # of bytes of data that follow
// uint8_t chunk[chunk_size] // data for the above chunk
//
// uint32_t chunk_key
// uint32_t chunk_size
// uint8_t chunk[chunk_size]
// ...
// uint32_t 0x... | {
return E_INTERNAL;
} |
// Totally bogus size?
if (current_offset > CORE_DUMP_MAX_SIZE) {
return E_INTERNAL;
}
}
*size = current_offset;
return S_SUCCESS;
}
void core_dump_mark_read(uint32_t flash_base) {
CoreDumpFlashRegionHeader region_hdr;
flash_read_bytes((uint8_t *)®ion_hdr, flash_base, sizeof(region_hd... |
e_get(&wakeup_settings, (uint8_t*)&wakeup_id, sizeof(WakeupId),
(uint8_t*)&entry, sizeof(WakeupEntry));
settings_file_close(&wakeup_settings);
}
}
mutex_unlock(s_mutex);
return entry;
}
DEFINE_SYSCALL(void, sys_wakeup_delete, WakeupId wakeup_id) {
WakeupEntry entry = prv_wake... | (void, sys_wakeup_cancel_all_for_app, void) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | get_gbitmap_from_pbi("test_rotated_bitmap_redstar.Xbit.pbi") | ;
cl_assert(test_image_color != NULL);
}
void test_graphics_draw_rotated_bitmap__cleanup(void) {
free(fb);
if (test_image_bw) {
if (test_image_bw->addr) {
free(test_image_bw->addr);
}
free(test_image_bw);
}
if (test_image_color) {
if (test_image_color->addr) {
free(test_image_col... |
if (!success) {
if (retrying) {
prv_reset_and_flush();
} else {
prv_set_state(ANCSClientStateRetrying);
evented_timer_register(ANCS_RETRY_TIME_MS, false, prv_reset_and_retry, NULL);
}
}
}
static void prv_handle_notification_attributes_response(const uint8_t *data, size_t length) {
// ... | (characteristics) | ; // should only be called if we found something!
analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_DISCOVERED_COUNT, AnalyticsClient_System);
// Pause while re-subscribing, it will be resumed when re-subscribed:
prv_ancs_is_alive_stop_timer();
if (s_ancs_client->characteristics[0] != BLE_CHARACTERISTIC... |
/*
* 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... | (sizeof(int32_t *) * N_SAMPS) | |
_file, SETTINGS_FILE_NAME,
SETTINGS_FILE_SIZE);
if (rv != S_SUCCESS) {
mutex_unlock(s_app_glance_db.mutex);
}
return rv;
}
static void prv_close_file_and_unlock_mutex(void) {
settings_file_close(&s_app_glance_db.settings_file);
mutex_unlock(s_app_glance_db.mutex);... | (app_uuid, serialized_glance, &len) | ;
if (rv != S_SUCCESS) {
return rv;
}
// Fetch app if it's in the app DB, but not cached. If it's not in the app db and not a system app
// reject the glance insert
AppInstallId app_id = app_install_get_id_for_uuid(app_uuid);
if (app_install_id_from_app_db(app_id)) {
// Bump the app's priority by ... |
ibute__cleanup(void) {
}
// tests
void test_generic_attribute__find_attribute(void) {
uint8_t data1[] = {
0x02, // attribute list - num attributes
0x02, // attribute type - transcription
0x2F, 0x00, // attribute length
// Transcription
0x01, // Transcription type
... | (attr2->data, &data2[offset]) | ;
GenericAttribute *attr3 = generic_attribute_find_attribute(attr_list1, VEAttributeIdAppUuid,
sizeof(data1) - 1);
cl_assert(!attr3);
attr3 = generic_attribute_find_attribute(attr_list1, VEAttributeIdAppUuid,
... |
twice, sequence_number is
// filled with the sequence number of the expired timer, and 0 is returned.
static TickType_t prv_poll_timer(uint8_t *const sequence_number) {
mutex_lock(s_reliable_timer_state_lock);
RtcTicks timer_expiry_tick = s_reliable_timer_expiry_time_tick;
TickType_t timeout = portMAX_DELAY;
i... | xSemaphoreCreateBinary() | ;
s_reliable_timer_state_lock = mutex_create();
TaskParameters_t task_params = {
.pvTaskCode = prv_pulse_task_main,
.pcName = "PULSE",
.usStackDepth = 1024 / sizeof( StackType_t ),
.uxPriority = (tskIDLE_PRIORITY + 3) | portPRIVILEGE_BIT,
.puxStackBuffer = NULL,
};
pebble_task_create(Pebbl... |
(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 59 MIN", time_buf);
// June 10th 2015, 13:30:00 (T-00:30:00)
rtc_set_time(event_time - (30 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("I... | ("Fri, 12:00 PM", time_buf) | ;
// June 11th 2015, 23:59:30 (T-12:00:30)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) - 30);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Fri, 12:00 PM", time_buf);
// June 11th 2015, 23:59:59 (T-12:00:01)
rtc_set_time(event_time - (... |
ing"
CommSession *session = s_bt_dump_chunk_callback_data.comm_session;
if (!success && comm_session_has_capability(session, CommSessionInfiniteLogDumping)) {
header.command = 0x82;
comm_session_send_data(s_bt_dump_chunk_callback_data.comm_session, ENDPOINT_ID,
(uint8_t *) &header... | (&last_launched_app,
build_id,
(AppInstallId)last_launched_app_slot,
PebbleTask_App) | ;
if (result == GET_APP_INFO_SUCCESS) {
DEBUG_LOG(LOG_LEVEL_INFO, "Last launched app: %s", last_launched_app.name);
PBL_HEXDUMP(LOG_LEVEL_INFO, build_id, sizeof(build_id));
}
}
}
|
__layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaaa, actual);
cl_assert_equal_i(3, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1]);
cl_assert_equal_p(aaa, stack[2]);
cl_assert_equal_p(aaaa, stack[3]);
// go b... | cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(10, 10)), &parent) | ;
layer_add_child(&child_a, &child_f);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(9, 9)), &child_f);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(1, 1)), &child_f);
// child layers are subject to their parents' bounds as well as their own (parent layers clip t... |
int16_t y2, GColor color) {
// y1 and y2 here will be the integer start/end of the line, so we need to adjust them so we see
// the same blending on the first and last pixel
y2--;
const Fixed_S16_3 y1_fixed = (Fixed_S16_3) {
.integer = y1,
.fraction = 4,
};
const Fixed_S16... | cl_assert_equal_p(ctx->draw_state.draw_mask, NULL) | ;
graphics_context_mask_destroy(ctx, mask1);
graphics_context_mask_destroy(ctx, mask2);
}
void test_graphics_context_mask__basic_use(void) {
GContext *ctx = s_ctx;
// Should be safe to call use with NULL values, will return false
cl_assert(!graphics_context_mask_use(NULL, NULL));
// Should start with de... |
buffer,
buf_end);
}
// -----------------------------------------------------------------------------
static int prv_get_serialized_action_group_size(TimelineItemActionGroup *action_group) {
int size = action_group->num_actions * sizeof(SerializedActionHeader);
for (in... | (type, group_ptr, buffer, buf_end) | ;
}
return buffer - buf_start;
}
|
/*
* 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 prv_get_asynchronous_prescaler() == 0x7f && prv_get_synchronous_prescaler() == 0xff;
} | |
as, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_x.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_outside_ny);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.de... | prv_setup_resources() | ;
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18_BOLD;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
test_graphics_context_init(&ctx, fb);
// Test zero text bounds size - ensure nothing is rendered
setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1);
graphic... |
ULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
s_feb_5_midnight + 11 * 60 * 60), 0);
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[2].header.id));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.heade... | (uuid_equal(&state.pin.header.id, &s_items[4].header.id)) | ;
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
// check second again
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check fourth
cl_assert(iter_next(&iterator));
cl_assert(it... |
/*
* 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... | {
// Clients are not required to cleanup due to prior code, so do so here.
fake_spi_flash_cleanup();
s_state.offset = offset;
s_state.length = length;
s_state.storage = malloc(length);
s_state.write_count = 0;
// Note: this is a harness failure, not a code failure.
cl_assert(s_state.storage != NULL);
... | |
erState state = {};
TimelineNode *head = NULL;
cl_assert_equal_i(timeline_init(&head), S_SUCCESS);
const time_t time_21_00_march_1_pst = 1425272400;
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
time_21_00_march_1_pst), S_SUCC... | (&state.node->id, &all_day_item.header.id) | );
cl_assert(state.node->all_day);
cl_assert_equal_i(state.node->timestamp, midnight_march_2_pst);
cl_assert_equal_i(state.node->duration, MINUTES_PER_DAY);
cl_assert_equal_i(state.current_day, midnight_march_2_pst);
// no more
cl_assert(!iter_next(&iterator));
// 1 delete
cl_assert(timeline_iter_remo... |
buf);
// June 9th 2015, 13:00:00 (T+01:00:00)
rtc_set_time(event_time + SECONDS_PER_HOUR);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 H AGO", time_buf);
// June 9th 2015, 13:29:29 (T+01:29:29)
rtc_set_time(event_time + SECONDS_PER_HOUR ... | (event_time + (2 * SECONDS_PER_HOUR)) | |
("NotifVibe", "Low"),
i18n_ctx_noop("NotifVibe", "Medium"),
i18n_ctx_noop("NotifVibe", "High")
};
static void prv_vibe_menu_select(OptionMenu *option_menu, int selection, void *context) {
const bool enable_vibration = (selection != 0);
const VibeIntensity new_vibe_intensity = enable_vibration ? (selection - IN... | (&option_menu->window, true /* animated */) | ;
}
static void prv_window_timeout_menu_push(SettingsNotificationsData *data) {
const int index = prv_window_timeout_get_selection_index();
const OptionMenuCallbacks callbacks = {
.select = prv_window_timeout_menu_select,
};
/// Status bar title for the Notification Window Timeout settings screen
const c... |
app_state.h"
#include "applib/applib_malloc.auto.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/hash.h"
#include "util/iterator.h"
#include "util/math.h"
#include "process_management/process_manager.h"
#include <stdint.h>
#include <string.h>
#i... | {
word->width_px = 0;
if (*start == NULL_CODEPOINT) {
word->start = start;
word->end = start;
return false;
}
// Set up iterator
Iterator char_iter;
CharIterState char_iter_state;
char_iter_init(&char_iter, &char_iter_state, text_box_params, start);
Utf8IterState* utf8_iter_state = (Utf8It... |
void word_iter_init(Iterator* word_iter, WordIterState* word_iter_state, GContext* ctx,
const TextBoxParams* const text_box_params, utf8_t* start) {
*word_iter_state = (WordIterState) {
.ctx = ctx,
.text_box_params = text_box_params
};
word_init(ctx, &word_iter_state->current, text_... |
_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(4));
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(5));
cl_assert(timeline_model_iter_next(&new_idx, &has_next));
cl_assert(!has_next);
cl_assert_equal_i(timeline_model_ge... | (timeline_model_get_iter_state(2) == timeline_model_get_iter_state_with_timeline_idx(3)) | |
_manager_state.sensor_stable = true;
s_manager_state.off_wrist_when_stable = (quality == HRMQuality_OffWrist);
}
}
return s_manager_state.sensor_stable;
}
T_STATIC bool prv_can_turn_sensor_on(void) {
#if IS_BIGBOARD || RECOVERY_FW
return true;
#endif
return s_manager_state.enabled_run_level &&
... | (s_manager_state.update_enable_timer_id) | ;
}
}
}
mutex_unlock_recursive(s_manager_state.lock);
}
// Timer callback that we use to re-enable the HR sensor in case we turned it off for a while
static void prv_update_enable_timer_cb(void *context) {
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
}
//! The system task needs its... |
r[health_card_view->current_card_index](
card_layer);
layer_set_hidden(&health_card_view->select_indicator_layer, is_hidden);
}
static void prv_content_indicator_setup_direction(HealthCardView *health_card_view,
ContentIndicator *content_indicator,
... | {
HealthCardView *health_card_view = context;
for (int i = 0; i < CardCount; i++) {
if (i != health_card_view->current_card_index) {
layer_set_hidden(health_card_view->card_layers[i], true);
}
}
if (!finished) {
prv_set_window_background_color(health_card_view);
} else {
prv_refresh_se... |
static const AnimationImplementation prv_bg_animation_implementation = {
.update = &prv_bg_animation_update
};
static int64_t prv_interpolate_moook_soft(int32_t normalized, int64_t from, int64_t to) {
return interpolate_moook_soft(normalized, from, to, NUM_MID_FRAMES);
}
static Animation* prv_create_slide_ani... |
);
// Should not allow any notifications through
alerts_set_mask(AlertMaskAllOff);
cl_assert(!alerts_should_notify_for_type(AlertInvalid));
cl_assert(!alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_notify_for_type(AlertReminder));
cl_assert(!alerts_should_notify_for_type(AlertPhoneC... | alerts_set_notification_vibe_timestamp() | ;
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertReminder));
cl_assert(alerts_should_notify_for_type(AlertOther));
cl_assert(!alerts_should_vibrate_for_type(AlertOther));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_t... |
// Before we run, the context should be non NULL
cl_assert(animation_get_context(h) == context);
animation_schedule(h);
int max_loops = 20;
uint64_t start_ms = prv_now_ms();
uint64_t time_ms;
while (s_stopped_handler_calls.num_calls == 0) {
prv_fire_animation_timer();
time_ms = prv_now_ms();
... | (h, handlers, context) | |
RANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "launcher_app_glance_service.h"
#include "launcher_app_glance.h"
#include "launcher_app_glance_alarms.h"
#include "launcher_app_glance_gen... | (service, glance->current_slice.expiration_time) | ;
// Continue iterating until we've looked at all of the glances in the cache
return true;
}
static void prv_slice_expiration_timer_cb(void *data) {
LauncherAppGlanceService *service = data;
PBL_ASSERTN(service);
// Reset the timer
prv_reset_slice_expiration_timer(service);
// Iterate over the glances... |
cl_assert(notification_storage_get(&i, &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
notification_storage_remove(&i);
cl_assert_equal_b(notification_storage_get(&i, &r), false);
}
void test_notification_storage__set_actioned_flag(void) {
Uuid i;
uuid_generate(&i);
TimelineItem e = {
... | compare_notifications(&e1, &r) | ;
free(r.allocated_buffer);
cl_assert_equal_b(notification_storage_get(&i2, &r), false);
notification_storage_store(&e3);
cl_assert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_buffer);
cl_assert_equal_b(notification_storage_get(&i2, &r), false);
cl_assert(no... |
;
}
////////////////////////////////////////////////////////////
// Windows
static void prv_update_background_image_and_url_text(RecoveryFUAppData *data) {
uint32_t icon_res_id;
const char *url_string;
GColor background;
GRect kino_area;
int16_t icon_x_offset;
int16_t icon_y_offset;
int16_t text_y_offse... | text_layer_set_text(&data->name_text_layer, data->name_text_buffer) | ;
// Set the name font
#if !PLATFORM_ROBERT && !PLATFORM_CALCULUS
const bool first_use_is_complete = shared_prf_storage_get_getting_started_complete();
const char *name_font_key;
if (first_use_is_complete || data->has_pebble_mobile_app_connected || data->is_showing_version) {
name_font_key = FONT_KEY_GOTHI... |
callback data */);
PropertyAnimation *a_rev = property_animation_clone(a);
animation_set_handlers((Animation*) a_rev, (AnimationHandlers) {
.started = (AnimationStartedHandler) animation_started,
.stopped = (AnimationStoppedHandler) animation_stopped,
}, NULL /* callback data */);
animation_set_delay(... | animation_destroy(s_animation) | ;
window_stack_remove(window, false);
window_destroy(window);
text_layer_destroy(s_text_layer_a);
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
i18n_get_with_buffer("PM", buf, 3);
} |
return buf;
default:
return "";
}
}
void date_time_handle_time_change(TimeData *data, TimeInputIndex index, int delta) {
switch (index) {
case TimeInputIndexHour:
data->hour = date_time_selection_step_hour(data->hour, delta);
break;
case TimeInputIndexMinute:
data->minute... |
ess or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bluetooth/gap_le_connect.h"
#include "comm/ble/gap_le_connect.h"
#include "comm/ble/gap_le_connection.h"
#include "comm/ble/gap_le_task.h"
#include "kernel/events.h"
#include "service... | fake_bt_persistent_storage_add(irk, &identity_device, "Dummy", true /* is_gateway */) | ;
}
static void prv_assert_no_event(void) {
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_NULL_EVENT);
}
static void prv_fake_connect(const BTDeviceInternal *device, bool is_master) {
// Simulate getting a Connection Complete event for the device from Bluetopia:
fake_gap_put_... |
LARM_KIND_EVERYDAY, s_every_day_schedule);
cl_assert_equal_i(s_num_timeline_adds, 3);
cl_assert_equal_i(s_num_timeline_removes, 0);
// Begin light sleep
s_sleep_state = ActivitySleepStateLightSleep;
s_sleep_state_seconds = SMART_ALARM_MAX_LIGHT_SLEEP_S - 15 * SECONDS_PER_MINUTE;
// Smart alarms are first ... | cl_assert_equal_i(s_num_alarm_events_put, 1) | ;
cl_assert_equal_i(s_num_timeline_adds, 2);
cl_assert_equal_i(s_num_timeline_removes, 1);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
|
context) {
NotificationWindowData *data = context;
// get the frame of the swap_layer and set its destination
const GRect *swap_frame = &data->swap_layer.layer.frame;
int16_t swap_frame_animation_dy = STATUS_BAR_LAYER_HEIGHT - swap_frame->origin.y;
// duration of animation of both peek layer and swap layer ... | notification_layout_get_fallback_icon_id(
item->header.type) | ;
timeline_res_id = attribute_get_uint32(&item->attr_list, AttributeIdIconTiny,
fallback_icon_id);
data->peek_icon_info = (TimelineResourceInfo) {
.res_id = timeline_res_id,
.app_id = &data->notification_app_id, // This is set earlier when we reload the layout
.... |
-----------------------
// Sample captured: 2015-10-05 15:46:25 local
AccelRawData *activity_sample_walk_100_pbl_25660_3(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25660_3
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
... | { 384, 232, -152},
{ 608, 288, -264},
{ 984, 320, -280},
// 5 seconds
{ 1160, 376, -368},
{ 1104, 392, -312},
{ 1112, 408, -280},
{ 1184, 400, -248},
{ 1248, 424, -240},
{ 1208, 408, -216},
{ 1248, 352, -192},
{ 1080, 296, -128},
{ 808, 200, -120},
{ 664, 168, -72... |
{ 1248, 304, -168},
{ 1072, 280, -168},
{ 784, 264, -96},
{ 632, 120, -24},
{ 520, 24, 0},
{ 600, 32, -32},
{ 776, 48, -64},
{ 928, 24, -56},
{ 1080, 40, -112},
{ 1144, 16, -80},
{ 1360, 32, -152},
{ 1416, 96, -32},
// 8 seconds
{ 1216, 152, -120},
{ 1328, 20... |
censed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under... | {
return true;
} |
return false;
}
static bool prv_should_ignore_because_time_reminder(const ANCSAttribute *app_id,
time_t timestamp,
const ANCSAttribute *title,
uint32_t uid,
... |
/*
* 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;
} |
storage->impl_data = kernel_zalloc_check(sizeof(*info));
memcpy(storage->impl_data, info, sizeof(*info));
return true;
}
GetBytesInfoErrorCode gb_storage_flash_get_size(GetBytesStorage *storage, uint32_t *size) {
*size = ((GetBytesStorageInfo *)storage->impl_data)->flash_len;
return GET_BYTES_OK;
}
bool g... |
), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("12 H AGO", time_buf);
// June 10th 2015, 00:00:00 (T+12:00:00)
rtc_set_time(event_time + (12 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Yesterday, 12:00 PM", time_buf... | (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_PER_HOUR);
// if the 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);
// J... |
ol enable_heap_fuzzing = (sdk_type == ProcessAppSDKType_System);
Heap *app_heap = app_state_get_heap();
PBL_LOG(LOG_LEVEL_DEBUG, "App heap init %p %p",
app_segment.start, app_segment.end);
heap_init(app_heap, app_segment.start, app_segment.end, enable_heap_fuzzing);
heap_set_lock_impl(app_heap, (HeapL... | app_install_cleanup_registered_app_callbacks() | ;
app_install_notify_app_closed();
timeline_peek_handle_process_kill();
}
// ---------------------------------------------------------------------------------------------
//! On watchface crashes, we want to signal to the user that the watchface has crashed so that
//! they understand why are being jettisoned int... |
essage_send_job);
} else {
read_pointer = (const uint8_t *)&app_message_send_job->header;
num_bytes_available = (sizeof(PebbleProtocolHeader) - offset);
}
read_pointer += offset;
*data_out = read_pointer;
return num_bytes_available;
}
static size_t prv_send_job_impl_get_length(const SessionSendQueue... | if (!prv_is_endpoint_allowed(endpoint_id)) {
return AppMessageSenderErrorEndpointDisallowed;
} |
const size_t pp_payload_length = (message->length - offsetof(AppMessageAppOutboxData, payload));
AppMessageSendJob *app_message_send_job = (AppMessageSendJob *)message->consumer_data;
app_message_send_job->header = (const PebbleProtocolHeader) {
.endpoint_id = htons(endpoint_id),
.length = htons(pp_payl... |
/*
* 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... | rocky_runtime_context_deinit() | ;
fake_pbl_malloc_check_net_allocs(); // Make sure no memory was leaked
}
void test_rocky_api_util_args__missing_args(void) {
JERRY_ARGS_MAKE(/* argc == 0 */);
uint8_t v;
ROCKY_ARGS_ASSIGN(ROCKY_ARG(v));
ASSERT_JS_ERROR(error_value, "TypeError: Not enough arguments");
}
void test_rocky_api_util_args__numb... |
d", i);
int fd = pfs_open(name, OP_FLAG_WRITE, FILE_TYPE_STATIC, 300);
if (i % 5 == 0) {
pfs_close_and_remove(fd);
} else {
pfs_close(fd);
}
}
}
#endif
#endif
static GAPLEConnection *prv_get_le_connection_and_print_info(void) {
GAPLEConnection *conn = gap_le_connection_any();
if (!con... | atoi(packet_payload_type) | );
}
void command_btle_test_rx_start(char *rx_channel) {
bt_driver_le_receiver_test(atoi(rx_channel));
}
void command_btle_test_end(void) {
bt_driver_le_test_end();
}
//# if PLATFORM_ROBERT
static const char *s_btle_pa_config_strings[3] = { "disable", "enable", "bypass" };
void command_btle_pa_set(char *command... |
RTS_LABEL_KEY = 0x5, // TUPLE_UINT(8)
SPORTS_HRM_KEY = 0x6, // TUPLE_UINT(8)
SPORTS_CUSTOM_LABEL_KEY = 0x7, // TUPLE_CSTRING
SPORTS_CUSTOM_VALUE_KEY = 0x8, // TUPLE_CSTRING
};
enum {
STATE_INIT_VALUE = 0x00,
STATE_RUNNING_VALUE = 0x01,
STATE_PAUSED_VALUE = 0x02,
STATE_END_VALU... | (data->custom_label_string,
new_tuple->value->cstring,
sizeof(data->custom_label_string)) | |
return;
}
data->is_finished = true;
layer_set_hidden(&data->percent_done_text_layer.layer, true);
layer_set_hidden(&data->progress_layer.layer, true);
uint32_t res_id;
uint32_t end_screen_timeout;
if (success) {
res_id = RESOURCE_ID_GENERIC_CONFIRMATION_LARGE;
end_screen_timeout = COMPLETE_SCRE... | PBL_IF_RECT_ELSE(55, 62) | ;
#endif
const GRect progress_bounds = GRect(x_offset, y_offset_progress, load_bar_length, 8);
ProgressLayer *progress_layer = &data->progress_layer;
progress_layer_init(progress_layer, &progress_bounds);
progress_layer_set_corner_radius(progress_layer, 3);
layer_add_child(&window->layer, &progress_layer->lay... |
sys_hrm_manager_unsubscribe(data->hrm_session);
#endif
#if CAPABILITY_HAS_MICROPHONE
prv_stop_mic_and_cleanup(data);
#endif
if (failed) {
snprintf(data->status_string, STATUS_STRING_LENGTH, "Test Failed");
app_window_stack_push(&data->status_window, true);
}
}
static bool prv_test_is_running(AppData *d... | (&data->status_text, &bounds) | ;
text_layer_set_text(&data->status_text, data->status_string);
text_layer_set_text_alignment(&data->status_text, GTextAlignmentCenter);
text_layer_set_font(&data->status_text, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
layer_add_child(window_layer, text_layer_get_layer(&data->status_text));
}
//--------... |
/*
* 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 (int i=64; i < 128; i++) {
prv_test_plot_horizontal_line(&ctx.dest_bitmap,
GRect(OFFSET_X, OFFSET_Y + i, STRIPE_WIDTH, STRIPE_HEIGHT),
(GColor){.argb = color | alpha});
color++;
} | |
/*
* 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... | animation_set_duration(animation, TIMELINE_CARD_TRANSITION_MS / 2) | ;
return animation;
}
static void prv_pin_window_load(Window *window) {
TimelinePinWindow *pin_window = window_get_user_data(window);
Layer *window_layer = window_get_root_layer(window);
layer_init(&pin_window->layer, &window_layer->bounds);
layer_add_child(window_layer, &pin_window->layer);
TimelineItemL... |
/*
* 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... | fake_app_timer_init() | ;
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
}
void test_rocky_api_datetime__cleanup(void) {
jerry_cleanup();
rocky_runtime_context_deinit();
}
static const RockyGlobalAPI *s_api[] = {
&DATETIME_APIS,
NULL,
};
void test_rocky_api_datetime__jerry_script_default(void) {
static const Rock... |
on *session = comm_session_open(transport, &s_transport_imp,
TransportDestinationSystem);
cl_assert_equal_b(comm_session_is_valid(session), true);
// Expect assert when Transport didn't clean up after itself:
cl_assert_passert(comm_session_deinit());
comm_session_close... | (comm_session_is_current_task_send_next_task(session), false) | ;
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
}
void test_session__reset_valid_session(void) {
Transport *transport = (Transport *) TransportID1;
CommSession *session = comm_session_open(transport, &s_transport_imp,
TransportDestinationS... |
ssion = blob_db_sync_get_session_for_id(db_id);
cl_assert(session != NULL);
if (s_num_until_timeout != 0 && s_num_writebacks >= s_num_until_timeout) {
fake_regular_timer_trigger(&session->timeout_timer);
} else {
system_task_add_callback(prv_handle_response_from_phone, session);
}
return 12345;
}
Bl... | {
char *keys[] = { "key1", "key2", "key3", "key4", "key5" };
int key_len = strlen(keys[0]);
char *values[] = { "val1", "val2", "val3", "val4", "val5" };
int value_len = strlen(values[0]);
// insert all keys
for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
blob_db_insert(BlobDBIdTest, (uint8_t *)keys[i], ... | |
/*
* 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;
} |
static void prv_handle_touch_event (Recognizer *recognizer, const TouchEvent *touch_event) {
}
static bool prv_cancel(Recognizer *recognizer) {
return false;
}
static void prv_reset (Recognizer *recognizer) {
}
static RecognizerImpl s_dummy_impl;
static void prv_clear_recognizers_processed(ListNode **list) {
... |
FreeRTOS.h" /* FreeRTOS Kernal Prototypes/Constants. */
#include "semphr.h"
#define STM32F4_COMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
//! The default baudrate for the accessory UART.
#define DEFAULT_BAUD AccessoryBaud115200
//!... | mcu_state_is_isr() | ) {
// assume we're in an ISR for the UART and don't need to worry about being blocked
return;
}
mutex_unlock_recursive(s_blocked_lock);
}
static void prv_enable_dma(void) {
PBL_ASSERTN(!s_dma_enabled);
s_dma_enabled = true;
uart_start_rx_dma(ACCESSORY_UART, s_rx_buffer, sizeof(s_rx_buffer));
}
stat... |
// PBL-23045 Eventually remove perimeter debugging
// Draw a red horizontal line to show the range of the current lines perimeter
if (app_state_get_text_perimeter_debugging_enabled()) {
#if !defined(UNITTEST) && !defined(PLATFORM_TINTIN)
const Fixed_S16_3 fixed_x1 = (Fixed_S16_3) {
.integer = h_range->... | TEXT_LINE_CAP_LINE(line) |
};
GRangeHorizontal perimeter_horizontal_range =
flow_data->perimeter.impl->callback(flow_data->perimeter.impl, &ctx_size, vertical_range,
flow_data->perimeter.inset);
prv_debug_perimeter(ctx, &perimeter_horizontal_range, line);
// protect 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... | mutex_lock_recursive(s_alg_state->mutex) | |
p->end) {
heap->begin->PrevSize = heap_info_ptr->Size;
}
else {
next_next_block->PrevSize = heap_info_ptr->Size;
}
}
}
}
heap_unlock(heap);
}
bool heap_is_allocated(Heap* const heap, void* ptr) {
bool rc = false;
if (!heap_contains_address(heap, ptr)) {
... | {
heap->begin->PrevSize = second_block->Size;
} | else {
next_next_block->PrevSize = second_block->Size;
}
return second_block;
}
//! Allocated the block in the given HeapInfo_t segment.
//! @param n_units number of ALIGNMENT_SIZE units this segment requires (including space for the beginer).
//! @param heap_info_ptr the segment where the block shou... |
de "util/math.h"
#include "util/size.h"
#include "util/string.h"
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MAX_FILTER_NAME_LENGTH 16
#define SUPPORT_MONTH 0
#define SUPPORT_YEAR 0
typedef enum ... | if (state->error->status != TemplateStringErrorStatus_Success) {
return false;
} |
switch (*cond) {
case PredicateCondition_G:
return (state->filter_state > *value);
case PredicateCondition_GE:
return (state->filter_state >= *value);
case PredicateCondition_L:
return (state->filter_state < *value);
case PredicateCondition_LE:
return (state->filter_state <= ... |
/*
* 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... | {
SerializedReminderAppPrefs *result = NULL;
mutex_lock_recursive(s_watch_app_prefs_db.mutex);
if (s_watch_app_prefs_db.is_cached_reminder_app_prefs_valid) {
result = task_zalloc(sizeof(*result));
if (result) {
*result = s_watch_app_prefs_db.cached_reminder_app_prefs;
}
} else {
result = p... |
void watch_app_prefs_destroy_weather(SerializedWeatherAppPrefs *prefs) {
if (prefs) {
task_free(prefs);
}
}
// BlobDB APIs
////////////////////////////////////////////////////////////////////////////////
void watch_app_prefs_db_init(void) {
s_watch_app_prefs_db.mutex = mutex_create_recursive();
}
// All e... |
d __disabled_test_gap_le_connect__two_clients_one_without_autoreconnect(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register auto-reconnecting connection intent for kernel:
gap_le_connect_connect(&device,
true /* auto_reconnect */,
false /* is_pairing... | prv_assert_no_event() | |
kup(pitch)) / TRIG_MAX_RATIO) * sin_lookup(roll)) /
TRIG_MAX_RATIO;
mx_rot += (((mz * sin_lookup(pitch)) / TRIG_MAX_RATIO) * cos_lookup(roll)) /
TRIG_MAX_RATIO;
my_rot = mz * sin_lookup(roll) - my * cos_lookup(roll);
my_rot /= TRIG_MAX_RATIO;
int32_t heading = (atan2_lookup(-my_rot, mx_rot) + corr... | event_service_init(PEBBLE_COMPASS_DATA_EVENT, &prv_compass_data_service_start,
&prv_compass_data_service_stop) | ;
}
void ecompass_service_handle(void) {
static int samples_collected = 0;
// read magnetometer sample
MagData mag_data;
MagReadStatus rv = mag_read_data(&mag_data);
if (rv != MagReadSuccess) {
if (rv == MagReadCommunicationFail) {
// heavy hammer fix for now
// FIXME: move the restart logic... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.