prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
//////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
gra... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_y_offset_layer"))) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_ny_offset_layer")));
}
void test_graphics_draw_line__clear(void) {
GContext ctx;
... |
CHUNK_SIZE_BYTES)
static int s_current_offset;
static bool s_enabled;
static uint32_t get_current_address(int chunk, int offset) {
return debug_db_get_logs_base_address(0) + (chunk * CHUNK_SIZE_BYTES) + offset;
}
static uint32_t get_generation_address(int generation, int chunk, int offset) {
return debug_db_get_... | kernel_free(read_buffer) | ;
return !error;
}
bool flash_dump_log_file(int generation, DumpLineCallback cb, DumpCompletedCallback completed_cb) {
if (generation < 0 || generation >= DEBUG_DB_NUM_FILES) {
completed_cb(false);
return false;
}
if (!debug_db_is_generation_valid(generation)) {
completed_cb(false);
return (fa... |
if (!str) {
return INVALID_RESOURCE;
} |
Codepoint emoji_codepoint = NULL_CODEPOINT;
utf8_each_codepoint(str, prv_each_emoji_codepoint, &emoji_codepoint);
for (unsigned int i = 0; i < ARRAY_LENGTH(s_emoji_table); i++) {
const EmojiEntry *emoji = &s_emoji_table[i];
if (emoji->codepoint == emoji_codepoint) {
return emoji->resource_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... | kino_reel_destroy(workout_glance->icon) | ;
// Set the new icon and record its resource ID
workout_glance->icon = kino_reel_create_with_resource(new_icon_resource_id);
PBL_ASSERTN(workout_glance->icon);
workout_glance->icon_resource_id = new_icon_resource_id;
return true;
}
static uint32_t prv_get_workout_icon_resource_id_for_type(ActivitySessionT... |
(*state)[3][3];
(*state)[3][3] = (*state)[2][3];
(*state)[2][3] = (*state)[1][3];
(*state)[1][3] = temp;
}
static uint8_t xtime(uint8_t x)
{
return ((x<<1) ^ (((x>>7) & 1) * 0x1b));
}
// MixColumns function mixes the columns of the state matrix
static void MixColumns(void)
{
uint8_t i;
uint8_t Tmp,Tm,t;
... | InvSubBytes() | ;
AddRoundKey(round);
InvMixColumns();
}
// The last round is given below.
// The MixColumns function is not here in the last round.
InvShiftRows();
InvSubBytes();
AddRoundKey(0);
}
static void BlockCopy(uint8_t* output, const uint8_t* input)
{
uint8_t i;
for (i=0;i<KEYLEN;++i)
{
output[... |
rflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_ellipsis_clip_across_nx(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-44, 4, 72, 32),
GTextOverflowModeTrailingEllip... | {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, 40, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
} | |
mutex_lock_recursive(s_pfs_mutex);
// go to offset
pfs_seek(fd, offset, FSeekSet);
const unsigned int chunk_size = 128;
uint8_t buffer[chunk_size];
while (num_bytes > chunk_size) {
pfs_read(fd, buffer, chunk_size);
legacy_defective_checksum_update(&checksum, buffer, chunk_size);
num_bytes -= ... | (fd, num_bytes) | |
mer.h"
#include "services/common/regular_timer.h"
#include "services/common/system_task.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/list.h"
#include "util/math.h"
#include "util/rand.h"
#include <stdlib.h>
//! The Bluetooth Connection Manager is responsible for managing the power
//! sta... | {
prv_schedule_granted_handler(curr_request->granted_handler);
curr_request->granted_handler = NULL;
} |
curr_request = (ConnectionStateRequest *)list_get_next(&curr_request->list_node);
}
}
static void prv_handle_response_latency_for_le_conn(GAPLEConnection *hdl) {
uint16_t secs_til_max_latency;
ResponseTimeState state;
BtConsumer responsible_consumer;
#ifdef RECOVERY_FW
// We don't care if we burn up som... |
s are invalid
WTF;
}
}
bool smartstrap_fsm_state_test_and_set(SmartstrapState expected_state, SmartstrapState next_state) {
const bool did_set = __atomic_compare_exchange_n(&s_fsm_state, &expected_state, next_state, false,
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
... | (s_state_lock, true) | ;
}
|
/*
* 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... | GPoint(-25, 35) | , GPoint(15, 40));
}
void across_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(40, 50), GPoint(35, 70));
}
void across_ny_layer_update_callback(Layer* me, GContext* ctx) {
gr... |
cl_assert(NULL != bmp) | ;
cl_assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette
bmp = gbitmap_create_blank(s10, GBitmapFormat4BitPalette);
cl_assert(NULL != bmp);
cl_assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette
bmp = gbitmap_create_blank(s10, GBitmap... | |
is that you have at least two eraseable flash
// units. However, the more units (i.e sectors) that you have, the smaller % of
// logs that will be erased when the log buffer fills.
//
// On each boot, we create a file to hold all the messages for that boot. This
// file is called a log generation or log.
//
// Within ... | _Static_assert((LOG_REGION_SIZE / ERASE_UNIT_SIZE) >= 2,
"Need to have at least 2 eraseable units for flash logging to work") | |
age*)buffer;
message->command = CMD_PUSH;
message->transaction_id = transaction_id;
message->payload->push.uuid = s_remote_app_uuid;
memcpy(&message->payload->push.dictionary, s_expected_buffer, dict_length);
PBL_LOG(LOG_LEVEL_DEBUG, "message->transaction_id = %"PRIu32, message->transaction_id);
CommSessi... | if (!s_is_app_message_receiver_open) {
return;
} |
cl_assert(s_remote_receive_handler);
s_remote_receive_handler(s_sent_endpoint_id, s_sent_data, s_sent_data_length);
kernel_free(s_sent_data);
s_sent_data = NULL;
}
void sys_get_app_uuid(Uuid *uuid) {
cl_assert(uuid);
*uuid = s_app_uuid;
}
static void (*s_process_manager_callback)(void *data);
static void... |
FSET_RECT_CLIP_XY GRect(10, 10, 30, 40)
#define OFFSET_RECT_CLIP_NXNY GRect(0, 0, 30, 40)
#define CENTER_OF_OFFSET_RECT GPoint(10, 15)
#define CENTER_OF_OFFSET_RECT_NXNY GPoint(0, 5)
void test_graphics_draw_circle_${BIT_DEPTH_NAME}__offset_layer_aa(void) {
GContext ctx;
test_graphics_context_init(... | (&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, GCornerBottomRight) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_r8_quad_bottom_right.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_circle_quadrant_draw_1px_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, GCornersTop);
cl_check(gbitmap_pbi_... |
), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b... | prv_advance_to_ms_with_timers(start_ms + total_duration + 5 * MIN_FRAME_INTERVAL_MS) | ;
// Make sure neither inner_seq, a, nor b played
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, inner_seq), 0);
cl_assert_equal_i(pr... |
return 0;
}
int idx = registry_get_next_available_index(registry);
if (idx < 0) {
PBL_LOG(LOG_LEVEL_WARNING, "Registry full.");
return -1;
}
PBL_ASSERTN(idx >= 0 && idx < registry->num_records);
r = registry->records + idx;
r->active = true;
strncpy(r->key, key, key_length);
r->key[MA... | prv_assert_valid_cursor(registry->cursor) | |
ient_subscriptions_get_notification_header(GAPLEClientKernel, &header);
cl_assert_equal_i(header.value_length, assert_value_length);
cl_assert_equal_i(header.characteristic, characteristic);
if (should_consume) {
uint16_t value_length = assert_value_length;
gatt_client_subscriptions_consume_not... | gatt_client_subscription_cleanup() | |
DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MIN, 0x4);
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_HV, 0x1);
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_LV, 0x0);
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_CUR_LIM_MAX_LV, 0xF);
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_IDLE_HYST, 0x4);
REG_SETF(DCDC, DCDC_V1... | (QSPIC, QSPIC_CTRLMODE_REG, QSPIC_PCLK_MD, 0x0) | |
}
static void prv_draw_header_cb(GContext *ctx, const Layer *cell_layer, uint16_t section_index,
void *callback_context) {
// The header here is just being used for padding, so we don't actually need to draw anything.
return;
}
static void prv_selection_changed_cb(struct MenuLayer ... | (BUTTON_ID_UP, 100, prv_scroll_handler) | |
private_draw_vertical_line(){}
void graphics_private_plot_pixel(){}
void graphics_private_set_pixel(){}
/////////////////////////////
static GPointPrecise s_center;
static Fixed_S16_3 s_radius;
static Fixed_S16_3 s_radius_inner;
static Fixed_S16_3 s_radius_outer;
static int32_t s_angle_start;
static int32_t s_angle_... | DEG_TO_TRIGANGLE(180) | , GSize(2, 4));
cl_assert_equal_grect(resulting_rect3, GRect(3, 4, 2, 4));
}
void test_graphics_circle__grect_centered_internal(void) {
GPointPrecise p1 = GPointPrecise(0, 0);
// GRectZero + standardize
cl_assert_equal_grect(GRect(0, 0, 0, 0), grect_centered_internal(&p1, GSize(0, 0)));
cl_assert_equal_grect... |
phics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-44, 4, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_across_x(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ct... | test_graphics_context_reset(&ctx, fb) | ;
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_outside_ny);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_te... |
errupts
bus->i2c->CR2 |= I2C_CR2_ITEVTEN | I2C_CR2_ITERREN;
// Wait on semaphore until it is released by interrupt or a timeout occurs
if (semaphore_wait(bus)) {
if (bus->transfer.state == TRANSFER_STATE_INVALID) {
// Transfer is complete
result = bus->transfer.result;
if (!r... | {
bus->i2c->CR2 &= ~(I2C_CR2_ITEVTEN | I2C_CR2_ITERREN | I2C_CR2_ITBUFEN);
bus->busy = false;
return pdFALSE;
} | |
usic_ctx.mutex);
copy_and_truncate(s_music_ctx.title, title, title_length);
copy_and_truncate(s_music_ctx.artist, artist, artist_length);
copy_and_truncate(s_music_ctx.album, album, album_length);
mutex_unlock_recursive(s_music_ctx.mutex);
prv_put_now_playing_changed_event();
}
static void prv_update_stri... | (s_music_ctx.mutex) | ;
int32_t playback_rate_percent = s_music_ctx.playback_rate_percent;
mutex_unlock_recursive(s_music_ctx.mutex);
return playback_rate_percent;
}
uint8_t music_get_volume_percent(void) {
mutex_lock_recursive(s_music_ctx.mutex);
int32_t player_volume_percent = s_music_ctx.player_volume_percent;
mutex_unlock_r... |
/*
* 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 I2C_TIMINGR_INVALID_VALUE;
} |
uint32_t min_scl_low_ps = s_timing_data[bus_mode].min_scl_low_ps;
uint32_t min_scl_high_ps = s_timing_data[bus_mode].min_scl_high_ps;
for (uint32_t prescaler = 1; prescaler <= TIMINGR_MAX_PRESC; ++prescaler) {
const uint32_t base_frequency = i2c_clk_frequency / prescaler;
const uint64_t base_period_ps ... |
length;
prv_write_flash_log_record_header(msg_length);
return (s_curr_state.log_start_addr);
}
bool flash_logging_write(const uint8_t *data_to_write, uint32_t flash_addr,
uint32_t read_length) {
if ((s_curr_state.bytes_remaining < read_length) || !s_flash_logging_enabled) {
return (false);
}
uint... | {
// Keep going
system_task_add_callback(prv_dump_log_system_cb, state);
} |
}
bool flash_dump_log_file(int generation, DumpLineCallback line_cb,
DumpCompletedCallback completed_cb) {
uint8_t log_file_id = generation_to_log_file_id(generation);
uint32_t log_start_addr;
int num_log_pages = prv_get_start_of_log_file(log_file_id, &log_start_addr);
PBL_LOG(LOG_L... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&pair->black_layer, black) | |
(uint16_t expected_min_slots, uint16_t expected_max_slots) {
cl_assert_equal_i(s_min_advertising_interval_slots, expected_min_slots);
cl_assert_equal_i(s_max_advertising_interval_slots, expected_max_slots);
}
bool gap_le_is_advertising_enabled(void) {
return s_is_le_advertising_enabled;
}
static Advertising_Dat... | BTDeviceAddressToBDADDR(device->address) | ,
};
GAP_LE_Event_Data_t event = (GAP_LE_Event_Data_t) {
.Event_Data_Type = etLE_Disconnection_Complete,
.Event_Data_Size = sizeof(GAP_LE_Disconnection_Complete_Event_Data_t),
.Event_Data.GAP_LE_Disconnection_Complete_Event_Data = &event_data,
};
if (is_master) {
prv_fake_gap_le_create_connecti... |
timezone(&tz);
uint8_t num_net_allocs = fake_pbl_malloc_num_net_allocs();
for (unsigned int i = 0; i < ARRAY_LENGTH(s_items); ++i) {
cl_assert_equal_i(pin_db_insert_item(&s_items[i]), 0);
}
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), num_net_allocs);
}
void test_timeline__cleanup(void) {
fake_set... | (uuid_equal(&state.pin.header.id, &s_items[0].header.id)) | ;
}
void test_timeline__none_backwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
1421178000), 2);
}
void test_timeline__middle_forwards(void) {... |
to_r.origin.x) {
detected_reset_of_elapsed = true;
}
cl_assert(max_loops > 0);
max_loops--;
}
// Make sure we detected a reset of the elapsed after rescheduling
cl_assert(s_stopped_handler_calls.num_calls == 2);
cl_assert(detected_reset_of_elapsed);
// Make sure the frame reached the "to... | cl_assert_equal_point(layer.frame.origin, to_r.origin) | ;
// This should return a NULL context now if the animation got destroyed
cl_assert(animation_get_context(h) == NULL);
// Make sure no animations exist
cl_assert_equal_i(prv_count_animations(), 0);
#endif
}
// --------------------------------------------------------------------------------------
// Stopped ... |
ssert_equal_b(hrm_is_enabled(HRM), false);
// 3. Enabling with a subscriber should turn HRM on
hrm_manager_enable(true);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_b(hrm_is_enabled(HRM), true);
// 4. Disabling with a Subscriber should disable the HRM
hrm_manager_enable(false);
fake_sys... | (prv_can_turn_sensor_on()) | ;
// Add a subscription so we have a reason to turn the sensor on (if the conditions are right)
sys_hrm_manager_app_subscribe(1, 1, 60, HRMFeature_BPM);
fake_system_task_callbacks_invoke_pending();
// Test run level changes
hrm_manager_enable(false);
cl_assert(!prv_can_turn_sensor_on());
fake_system_tas... |
Md __pbl_app_info = {
.uuid = TEST_UUID_A,
};
const char lipsum[] = "Lorem ipsum dolor sit amet, consectetur "
"adipiscing elit. Nam dignissim ullamcorper sollicitudin. Suspendisse at "
"urna suscipit, congue purus a, posuere eros. Nulla eros urna, vestibulum "
"a dictum a, maximus sed nibh. Ut ut dui finibus,... | (persist_read_data(0, buf, sizeof(buf)),
PERSIST_DATA_MAX_LENGTH) | ;
cl_assert(memcmp(lipsum, buf, PERSIST_DATA_MAX_LENGTH) == 0);
for (size_t i = PERSIST_DATA_MAX_LENGTH; i < sizeof(buf); ++i) {
cl_assert_(buf[i] == '~',
"persist_read_data writes past the end of destination buffer");
}
}
void test_persist__string_does_not_exist(void) {
char string_buffer[P... |
mples + ALGORITHM_SAMPLING_RATE - 1) / ALGORITHM_SAMPLING_RATE);
// Verify the 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));
}
// -------------... | activity_get_minute_history(minutes, &num_records, &utc_start) | ;
cl_assert_equal_i(num_records, exp_num_records);
cl_assert_equal_i(utc_start, exp_utc_start);
cl_assert_equal_i(minutes[0].steps, exp_utc_start % 255);
// ---------------------------------------------------------------------------------------
// Once a minute, retrieve the last ALG_MINUTES_PER_RECORD minu... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | APP_LOG(LOG_LEVEL_WARNING, "used blocks: %zu, free blocks: %zu",
stats->alloc_count, stats->free_count) | |
// If this is a pre-processor directive, skip it
if (token[0] == '#') {
continue;
}
// If this is a comment skip it
if (strcmp(token, "//") == 0) {
continue;
}
// If this is an AlgDlsMinuteData line, get the name
if (strcmp(token, "AlgDlsMinuteData") == 0) {
PBL_ASSERT(... | {
return true;
} | else {
return false;
}
}
// ---------------------------------------------------------------------------------------
// Init the sample discovery iterator
static bool prv_sample_discovery_init(SampleDiscoveryState *state, SampleFileType samples_type,
const char *test_files_p... |
(!alerts_should_notify_for_type(AlertPhoneCall)) | ;
}
void test_alerts__phone_calls_only(void) {
cl_assert(alerts_get_mask() == AlertMaskAllOn);
alerts_set_mask(AlertMaskPhoneCalls);
// Should allow a phone call notification
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
// Should not allow any other notifications through
cl_assert(!alerts_s... | |
e;
}
if (data.type != BtPersistBondingTypeBLE) {
PBL_LOG(LOG_LEVEL_ERROR, "Not getting BLE id %d. Type mismatch", bonding);
return false;
}
if (info_out) {
bt_persistent_storage_assign_sm_pairing_info(info_out, &data.ble_data.pairing_info);
}
*requires_address_pinning = data.ble_data.requires... | prv_has_active_gateway_by_type(BtPersistBondingTypeBLE) | |
/*
* 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... | {
AppFetchUIData *data = app_state_get_user_data();
if (event->bluetooth.comm_session_event.is_open &&
event->bluetooth.comm_session_event.is_system) {
progress_window_pop(&data->window);
}
} |
static void prv_set_progress_failure(AppFetchUIData *data) {
uint32_t icon;
const char *message;
switch (data->result) {
case AppFetchResultNoBluetooth:
icon = TIMELINE_RESOURCE_WATCH_DISCONNECTED;
message = i18n_get("Not connected", data);
// Subscribe to the BT remote app connect event
... |
/*
* 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... | bt_driver_id_set_local_device_name(s_local_device_name) | ;
}
void bt_local_id_configure_driver(void) {
// Request the local address from the BT driver and cache it:
bt_driver_id_copy_local_identity_address(&s_local_address);
if (!prv_has_device_name()) {
if (!bt_persistent_storage_get_local_device_name(s_local_device_name,
... |
EGION_FILESYSTEM_BEGIN) ||
(stress_addr2 >= FLASH_REGION_FILESYSTEM_END)) {
PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Invalid range");
return FLASH_TEST_ERR_ADDR_RANGE;
}
// Erase sectors
flash_erase_sector_blocking(stress_addr1);
status = prv_read_verify_halfword(stress_addr1, 0xFFFF, FLASH_TEST_ERR_ERAS... | (MAX_READ_BUFF_SIZE) | ;
if (!read_buffer) {
PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Not enough memory to run test");
return FLASH_TEST_ERR_OOM;
}
uint32_t addr = FLASH_TEST_ADDR_START;
volatile uint32_t *ptr = (uint32_t *) DWT_CTRL_ADDR;
for (uint32_t num_bytes = 1; num_bytes <= MAX_READ_BUFF_SIZE; num_bytes<<=1) {
// Run te... |
8, 352, -48},
{ 872, 344, -64},
{ 712, 360, -48},
// 49 seconds
{ 600, 400, 0},
{ 648, 440, 8},
{ 832, 456, 24},
{ 1096, 528, 16},
{ 1352, 608, 8},
{ 1472, 472, 128},
{ 1728, 560, 0},
{ 1312, 520, -104},
{ 1360, 408, -24},
{ 1544, 280, 24},
{ 1464, 168, 88},
{... | { 712, 368, -8},
{ 792, 440, 16},
{ 880, 448, 8},
{ 1096, 480, 0},
{ 1344, 512, -8},
{ 1600, 376, 80},
{ 1512, 416, 32},
{ 1272, 496, -72},
// 55 seconds
{ 1152, 408, -32},
{ 1256, 336, 0},
{ 1312, 280, 72},
{ 1088, 208, 88},
{ 920, 240, 104},
{ 848, 256, 88},... | |
__callcount++;
return jerry_create_undefined();
}
void test_rocky_api_global__initialize(void) {
fake_app_timer_init();
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
s_app_window_stack_get_top_window = (Window){};
s_app_event_loop_callback = NULL;
s_log_internal__expected = NULL;
s_prv_... | jerry_obj_refcount(o) | );
jerry_acquire_value(o);
cl_assert_equal_i(2, jerry_obj_refcount(o));
jerry_acquire_value(o);
cl_assert_equal_i(3, jerry_obj_refcount(o));
jerry_release_value(o);
cl_assert_equal_i(2, jerry_obj_refcount(o));
jerry_release_value(o);
cl_assert_equal_i(1, jerry_obj_refcount(o));
jerry_release_value(o);... |
cl_assert_equal_s(serial, "XXXXXXXXXXXX") | ;
// Test writing & reading back:
const char* written_serial1 = "ABCDEFGHIJKL";
command_serial_write(written_serial1);
serial = mfg_get_serial_number();
cl_assert_equal_s(written_serial1, serial);
}
void test_mfg_serials__pcba_serial_number(void) {
const char* pcba_serial;
// Initially, bunch of XXs:
... | |
/*
* 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... | (sys_wakeup_query(wakeup_id), sys_get_time() + 10) | ;
// Cancel all wakeup events
sys_wakeup_cancel_all_for_app();
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST);
}
void test_wakeup__max_events(void) {
WakeupId wakeup_id = 0;
sys_wakeup_cancel_all_for_app();
// Schedule 8 (max), at 1 minute offsets, then fail on 9th
for (int i = 1; i <... |
assert_equal_i(target_start_page, test_get_file_start_page(fd));
cl_assert(fd >= 0);
cl_assert_equal_i(pfs_close(fd), S_SUCCESS);
}
void test_pfs__open(void) {
int fd = pfs_open("dne", OP_FLAG_READ, 0, 0);
cl_assert(fd == E_DOES_NOT_EXIST);
fd = pfs_open("dne", OP_FLAG_OVERWRITE, FILE_TYPE_STATIC, 0);
cl_... | {
cl_assert(buf[i] == i);
} |
pfs_close(fd);
fd = pfs_open("newfile", OP_FLAG_READ, 0, 0);
rv = pfs_write(fd, buf, sizeof(buf));
cl_assert(rv == E_INVALID_ARGUMENT);
}
void test_pfs__overwrite(void) {
const char *file = "testfile";
const char *string = "original file!";
const char *overwrite_string = "overwrite file!";
int rv;
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_cache_add_entry(app3.id, app3.size) | );
// remove 2
cl_assert_equal_i(S_SUCCESS, app_cache_remove_entry(app1.id));
PebbleEvent e = fake_event_get_last();
cl_assert_equal_i(e.type, PEBBLE_APP_CACHE_EVENT);
cl_assert_equal_i(e.app_cache_event.cache_event_type, PebbleAppCacheEvent_Removed);
cl_assert_equal_i(e.app_cache_event.install_id, app1.id... |
[BT_DEVICE_NAME_BUFFER_SIZE];
SM128BitKey link_key;
uint8_t platform_bits;
if (!shared_prf_storage_get_bt_classic_pairing_data(&bd_addr, name, &link_key, &platform_bits)) {
// No pairing available, check to see if we have a pairing in the gapDB
prv_push_bt_persist_to_shared_prf(BtPersistBondingTypeBTClass... | (prv_get_num_pairings_by_type_itr, &itr_data) | ;
return itr_data.count;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! BLE Pairing Info
void gap_le_connection_handle_bonding_change(BTBondingID bonding, BtPersistBondingOp op);
static void prv_call_ble_bonding_change_handlers(BTBondingID bonding,
... |
/*
* 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... | graphics_fill_rect(ctx, &rect) | ;
*row += num_pixels;
}
#if PBL_ROUND
static void prv_draw_round_border(Layer *layer, GContext *ctx, uint8_t radial_padding_size) {
for (int i = 0; i < layer->bounds.size.h / 2 - radial_padding_size; ++i) {
const GBitmapDataRowInfoInternal *data_row_infos = g_gbitmap_spalding_data_row_infos;
const uint8_... |
cl_assert(active == false);
}
void test_do_not_disturb__is_active(void) {
// Time 00:00, Manual and Scheduled DND both OFF
bool active;
// !Manual && !Scheduled && !Smart
cl_assert(do_not_disturb_is_manually_enabled() == false);
cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == false);
cl_... | cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == true) | ;
active = do_not_disturb_is_active();
cl_assert(active == true); // Both OFF
do_not_disturb_set_manually_enabled(false); // turned Manual OFF, scheduled should be overriden
cl_assert(do_not_disturb_is_manually_enabled() == false);
cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == true);
act... |
/*
* 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... | pebble_task_get_current() | ;
// Get info
QueueHandle_t *event_queue;
if (task == PebbleTask_App) {
event_queue = app_manager_get_task_context()->to_process_event_queue;
} else if (task == PebbleTask_Worker) {
event_queue = worker_manager_get_task_context()->to_process_event_queue;
} else if (task == PebbleTask_KernelMain) {
... |
{
gbitmap_destroy(node->icon);
node->icon = NULL;
}
}
static void prv_load_list_if_needed(AppMenuDataSource *source) {
if (source->is_list_loaded) {
return;
}
source->is_list_loaded = true;
PBL_ASSERTN(!source->order_storage);
source->order_storage = app_order_read_order();
app_install_enum... | PBL_ASSERTN(source->default_icon == NULL && fallback_icon_id != RESOURCE_ID_INVALID) | ;
source->show_icons = true;
// The return value will be a valid GBitmap* or NULL (because of an OOM that shouldn't ever happen
// We will handle both gracefully.
source->default_icon = gbitmap_create_with_resource_system(SYSTEM_APP, fallback_icon_id);
}
static uint16_t prv_transform_index(AppMenuDataSource *... |
tps://pebbletechnology.atlassian.net/browse/PBL-32232 should address this
power_tracking_start(PowerSystem2v5Reg);
// wait for the bus supply to stabilize and the peripherals to start up.
// the MFI chip requires its reset pin to be stable for at least 10ms from startup.
psleep(20);
} else {
power... | i2c_hal_init(bus) | ;
if (bus->rail_gpio.gpio) {
gpio_output_init(&bus->rail_gpio, GPIO_OType_PP, GPIO_Speed_2MHz);
}
prv_bus_rail_power_down(bus);
}
void i2c_use(I2CSlavePort *slave) {
PBL_ASSERTN(slave);
mutex_lock(slave->bus->state->bus_mutex);
if (slave->bus->state->user_count == 0) {
prv_bus_enable(slave->bus);... |
xSemaphoreGive(s_pb_semaphore);
}
void put_bytes_expect_init(uint32_t timeout_ms) {
xSemaphoreTake(s_pb_semaphore, portMAX_DELAY);
if (s_pb_state.current_command != PutBytesIdle) {
PBL_LOG(LOG_LEVEL_ERROR, "Called put_bytes_expect while put_bytes is not idle");
xSemaphoreGive(s_pb_semaphore);
retur... | {
prv_pre_ack_if_space_in_put_job_queue();
} |
}
}
void prv_receiver_write(Receiver *receiver, const uint8_t *data, size_t length) {
if (!prv_take_lock_with_short_timeout()) {
s_pb_state.receiver.should_nack = true;
return;
}
if (!prv_is_message_pending_processing()) {
// Could happen if put_bytes_cancel() was called after "prepare"
PBL_LO... |
184, 336, -168},
{ 1144, 304, -128},
{ 1184, 304, -136},
{ 1192, 280, -96},
{ 1008, 256, -40},
{ 784, 200, -48},
{ 696, 192, -64},
{ 704, 168, -48},
{ 816, 160, 0},
{ 872, 152, 0},
{ 1000, 112, -8},
// 40 seconds
{ 1160, 104, -56},
{ 1096, 96, -32},
{ 1216, 80, -6... | { 744, 280, -168},
{ 992, 288, -192},
{ 1128, 320, -272},
{ 1048, 320, -296},
{ 1160, 336, -224},
{ 1272, 352, -224},
{ 1072, 336, -168},
{ 1048, 328, -136},
{ 1152, 336, -136},
{ 1176, 296, -96},
{ 1024, 256, -64},
{ 856, 192, -64},
{ 736, 160, -64},
{ 744, 160, ... |
{ 1168, 304, -80},
{ 1056, 248, -40},
{ 888, 208, -32},
{ 760, 168, -8},
// 48 seconds
{ 736, 160, -32},
{ 768, 152, -8},
{ 784, 136, -16},
{ 904, 136, -32},
{ 1104, 176, -80},
{ 1056, 96, -96},
{ 1080, 88, -120},
{ 1144, 104, -96},
{ 1032, 152, -112},
{ 1128... |
cl_assert_equal_s("2 H AGO", time_buf);
// June 9th 2015, 16:01:00 (T+00:01:00)
rtc_set_time(event_time + (1 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 MIN AGO", time_buf);
// June 9th 2015, 16:02:00 (T+00:02:00... | cl_assert_equal_s("IN 1 H", time_buf) | ;
// June 9th 2015, 14:00:00 (T-02:00:00)
rtc_set_time(event_time - (2 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 2 H", time_buf);
// June 9th 2015, 15:59:00 (T-00:01:00)
rtc_set_time(event_time - (1 * SECONDS_PER... |
(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_RPIPE_EN, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_RXD_NEG, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_HRDY_MD, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO3_DAT, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO2_DAT, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_R... | REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_LOCK_DET_RES_CNT, 0x0) | ;
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_SEL_R_DIV_TEST, 0x0);
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_SEL_N_DIV_TEST, 0x0);
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_CHANGE, 0x0);
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_OPEN_LOOP, 0x0);
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_TEST_VCTR, 0x0);
REG_SETF(GPREG, PLL_SYS_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return 0;
} |
void app_db_enumerate_entries(AppDBEnumerateCb cb, void *data) {
}
AppInstallId app_db_get_install_id_for_uuid(const Uuid *uuid) {
return 0;
}
status_t app_db_get_app_entry_for_install_id(AppInstallId app_id, AppDBEntry *entry) {
return E_INVALID_OPERATION;
}
bool app_db_exists_install_id(AppInstallId app_id) ... |
//////////////////////////////////////////////////
// Private interface
void recognizer_handle_touch_event(Recognizer *recognizer, const TouchEvent *touch_event) {
PBL_ASSERTN(recognizer_is_active(recognizer));
PBL_ASSERTN(recognizer->impl);
PBL_ASSERTN(touch_event);
if (!prv_should_handle_touches(recognizer,... | {
if (!recognizer) {
return;
}
recognizer->subscriber.on_destroy = on_destroy_cb;
} | |
UALS_S("s", "8 PM");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, "
"{hour: 'numeric', hour12: true});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "8 PM");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, "
"{hour: 'numeric', hour12: false});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "... | ASSERT_JS_GLOBAL_EQUALS_S("s", "07/25/05, 8:04:05 PM") | ;
s_clock_is_24h_style = true;
EXECUTE_SCRIPT("s = d.toLocaleString(undefined, {});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "07/25/05, 20:04:05");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {second: 'numeric'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "5");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, ... |
sscanf(token + strlen(token) + 1, "%s", state->test_entry.name);
}
}
// If this is a "static AlgDlsMinuteData samples[] = {" line, skip it
if (strcmp(token, "static") == 0) {
continue;
}
// Grab a sample
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] !... | sscanf(token + strlen(token) + 1, "%d", &state->test_entry.len.max) | ;
} else if (strcmp(token, "TEST_START_AT") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.value);
} else if (strcmp(token, "TEST_START_AT_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.min);
} else if (strcmp(token, "TES... |
/*
* 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_build_push_message(key, value, &length) | ;
launcher_app_message_protocol_msg_callback_deprecated(s_session, msg, length);
}
// Tests
////////////////////////////////////
void test_launcher_app_message__initialize(void) {
launcher_app_message_reset();
s_last_cmd = APP_RUN_STATE_INVALID_COMMAND;
fake_comm_session_init();
s_transport = fake_transpor... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, true, 1) | ;
cl_assert_equal_i(ctx.dest_bitmap.info.format, GBitmapFormat8BitCircular);
memset(ctx.dest_bitmap.addr, GColorRedARGB8, FRAMEBUFFER_SIZE_BYTES);
GRect radial_container_rect = ctx.dest_bitmap.bounds;
radial_container_rect = grect_inset(radial_container_rect, GEdgeInsets(-10));
const uint16_t inset_thicknes... |
r today and the past 6 days
health_service_private_get_metric_history(HealthMetricStepCount, DAYS_PER_WEEK,
health_data->step_data);
// Update distance / calories now that we have our steps
health_data_update_step_derived_metrics(health_data);
// Get the step average... | (ActivityMetricHeartRateZone2Minutes, 1, &health_data->hr_zone2_minutes) | ;
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &health_data->hr_zone3_minutes);
}
int32_t *health_data_steps_get(HealthData *health_data) {
return health_data->step_data;
}
int32_t health_data_current_steps_get(HealthData *health_data) {
return health_data->step_data[0];
}
int32_t health_data_cu... |
common/comm_session/session.h"
#include "system/bootbits.h"
#include "system/passert.h"
#include "system/reset.h"
#include "system/logging.h"
#include "system/version.h"
#include "util/attributes.h"
#include "util/build_id.h"
#include "util/math.h"
#include "util/net.h"
#include "util/size.h"
#include "util/string.h"... | {
if (s_use_cd_flash_driver) {
return cd_flash_write_bytes(buffer_ptr, start_addr, buffer_size);
} else {
flash_write_bytes(buffer_ptr, start_addr, buffer_size);
return buffer_size;
}
} |
static void prv_flash_erase_region(uint32_t start_addr, uint32_t total_bytes) {
if (s_use_cd_flash_driver) {
cd_flash_erase_region(start_addr, total_bytes);
} else {
uint32_t end = start_addr + total_bytes;
flash_region_erase_optimal_range_no_watchdog(start_addr, start_addr, end, end);
}
}
static v... |
0x57, 0xe9, 0x4e, 0x58,
0x88, 0x02, 0x45, 0xfd, 0xfe, 0xe0, 0xac, 0x77},
.info_flags = PROCESS_INFO_STANDARD_APP,
.app_version = {
.major = 2,
.minor = 0,
},
.sdk_version = {
.major = 5,
.minor = 13,
},
.app_face_bg_color = {0},
.template_id = 0,
.icon_resource_id = 0,
};
s... | (&tictoc_uuid, &uuid_entry) | );
cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry));
cl_assert_equal_b(true, app_install_get_entry_for_install_id(music_id, &id_entry));
cl_assert_equal_b(true, app_install_get_entry_for_uuid(&music_uuid, &uuid_entry));
cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uui... |
in.x;
x2.integer += ctx->draw_state.drawing_box.origin.x;
y += ctx->draw_state.drawing_box.origin.y;
GBitmap *framebuffer = graphics_capture_frame_buffer(ctx);
if (!framebuffer) {
// Couldn't capture framebuffer
return;
}
graphics_private_draw_horizontal_line_prepared(ctx, framebuf... | (MIN(x0, x1), clip_box->origin.x) | |
and clipping features.
// Since it easily becomes to costly in terms of RAM to hold a layer for each row in the menu in memory,
// the MenuLayer does not use layers for its rows and headers. When a row is about to be displayed,
// it will call out to the client using a callback to get that row drawn.
// Inside the Men... | (menu_layer, section_index,
menu_layer->callback_context) | ;
} else {
return 1; // default
}
}
static inline int16_t prv_menu_layer_get_separator_height(MenuLayer *menu_layer,
MenuIndex *cell_index) {
if (menu_layer->callbacks.get_separator_height) {
return menu_layer->callbacks.get_separator_height(menu_layer, cell_index, menu_layer->callback_context);
}... |
SE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under th... | codepoint_in_list(codepoint,
NONSTANDARD_EMOJI_CODEPOINTS,
ARRAY_LENGTH(NONSTANDARD_EMOJI_CODEPOINTS)) | ;
if (found) {
return true;
} else {
return ((codepoint >= MIN_SOFTBANK_EMOJI_CODEPOINT &&
codepoint <= MAX_SOFTBANK_EMOJI_CODEPOINT) ||
(codepoint >= MIN_UNIFIED_EMOJI_CODEPOINT &&
codepoint <= MAX_UNIFIED_EMOJI_CODEPOINT));
}
}
bool codepoint_is_special(const Codep... |
tatic bool prv_shared_buffer_empty(void) {
bool empty = true;
mutex_lock_recursive(s_accel_manager_mutex);
{
AccelManagerState *state = (AccelManagerState *)s_data_subscribers;
while (state) {
int left = shared_circular_buffer_get_read_space_remaining(
&s_buffer, &state->buffer_client.buff... | accel_set_num_samples(num) | |
/*
* 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... | (direction, WATCHFACE_SHUTTER_COLOR) | ,
compositor_port_hole_transition_app_get(direction));
}
static const CompositorTransition *prv_get_health_compositor_animation(
CompositorTransitionDirection direction) {
return PBL_IF_RECT_ELSE(compositor_shutter_transition_get(direction, HEALTH_SHUTTER_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... | (gpio, gpio_pin, active_high ? Bit_SET : Bit_RESET) | ;
// wait for the bus supply to stabilize and the peripherals to start up.
// the MFI chip requires its reset pin to be stable for at least 10ms from startup.
delay_ms(20);
gpio_release(gpio);
} else {
gpio_use(gpio);
// disable the bus supply
GPIO_WriteBit(gpio, gpio_pin, active_high ? B... |
0, 0x54, 8088, 0x0},
{ 0, 0x42, 5604, 0x0},
{ 0, 0x42, 926, 0x0},
{ 0, 0x64, 287, 0x0},
{ 7, 0x54, 828, 0x0},
{ 0, 0x68, 674, 0x0},
{ 12, 0x55, 4129, 0x0},
// 30: Local time: 09:41:00 PM
{ 0, 0x67, 1138, 0x0},
{ 0, 0x54, 498, 0x0},
{ 0, 0x54, 389, 0x0},
{ 0, 0x65, 1262, 0x0}... | { 0, 0x62, 362, 0x0},
{ 7, 0x41, 4506, 0x0},
{ 7, 0x22, 5674, 0x0},
{ 0, 0x18, 1653, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 13, 0x0},
// 150: Local time: 11:41:00 PM
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0,... |
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 467, 0x0},
{ 0, 0x15, 32, 0x0},
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0, 0x0},
// 210: Local time: 12:41:00 AM
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0... |
(anim, prv_interpolate_moook_soft);
return anim;
}
// Create animation
static void prv_schedule_slide_animation(HealthCardView *health_card_view,
Card next_card_index, bool slide_up) {
animation_unschedule(health_card_view->slide_animation);
health_card_view->slide_animat... | {
health_card_view->card_layers[i] = s_card_view_create[i](health_data);
layer_add_child(window_root, health_card_view->card_layers[i]);
} |
// set starting card based on launch args
HealthLaunchArgs launch_args = { .args = app_launch_get_args() };
health_card_view->current_card_index =
(launch_args.card_type == HealthCardType_Sleep) ? Card_SleepSummary : Card_ActivitySummary;
// set window background
prv_set_window_background_color(heal... |
////////////////////////////////////////////////////////
#include "stubs_analytics.h"
#include "stubs_layout_layer.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_rand_ptr.h"
#include "stubs_pfs.h"
#include "stubs_blob_db_sync.h"
#include "... | ((uint8_t *)key, key_len) | ;
cl_assert(notif_prefs);
Attribute *title = attribute_find(¬if_prefs->attr_list, AttributeIdShortTitle);
cl_assert(title);
cl_assert_equal_s(title->cstring, "Title");
Attribute *mute = attribute_find(¬if_prefs->attr_list, AttributeIdMuteDayOfWeek);
cl_assert(mute);
cl_assert_equal_i(mute->uint8, 0x... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_IF_RECT_ELSE(if_not, at_top) | , \
/* large */ at_top, \
/* This is the same as Large until ExtraLarge is designed */ \
/* extralarge */ at_top \
)
#define CARD_MARGIN_BOTTOM PBL_IF_RECT_ELSE(7, 0)
static bool prv_should_display_time(c... |
e
// the change and therefore we don't want it to visually update yet. prv_worker_launch_handler
// will update the choice if it fires.
option_menu_set_choice(&data->option_menu, prv_get_chosen_row_index(data));
// Switching to a different worker, display confirmation dialog
switch_worker... | (data->data_source) | |
l.
prv_set_baudrate(s_baudrate, true /* force_update */);
prv_unlock();
}
void accessory_send_byte(uint8_t data) {
// NOTE: this may be run within an ISR
prv_lock();
s_has_sent_byte = true;
s_did_send_byte = true;
PBL_ASSERTN(!s_input_enabled);
while (!(uart_is_tx_ready(ACCESSORY_UART))) continue;
//... | (ACCESSORY_UART) | |
/*
* 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... | printf("Loaded %d suites: %s\n", (int)suite_count, suite_names) | ;
printf("Started\n");
}
static void clar_print_shutdown(int test_count, int suite_count, int error_count)
{
(void)test_count;
(void)suite_count;
(void)error_count;
printf("\n\n");
clar_report_errors();
}
static void clar_print_error(int num, const struct clar_error *error)
{
printf(" %d) Failure:\n", num);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (text, max_size) | ;
static const int vert_scroll_padding = 4;
scroll_layer_set_content_size(scroll_layer, GSize(144, max_size.h + vert_scroll_padding));
scroll_layer_add_child(scroll_layer, &text->layer);
layer_add_child(&window->layer, &scroll_layer->layer);
}
static void push_window(struct AppState *data) {
Window* window ... |
eadings = 1,
.headings = &(HealthDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.fill_color = GColorWhite,
#if PBL_BW
.outline_color = GColorBlack,
#endif
},
.bg_color = BG_COLOR,
.daily_avg = 900,
.weekly_max = 1300,
.num_zones = ARRAY_LENGTH(s_zo... | (&card->window, &s_ctx) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_detail_card__scroll_down(void) {
HealthDetailCardConfig config = {
.num_headings = 1,
.headings = &(HealthDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.fill_color = GColorWhite,
#i... |
);
cl_assert_equal_i(out_length, 2);
cl_assert(memcmp(out_buffer, (uint8_t*) "9a", 2) == 0);
cl_assert(circular_buffer_consume(&buffer, 2));
// Consume one without reading it
cl_assert(circular_buffer_consume(&buffer, 1));
// Read the last little bit
cl_assert(circular_buffer_read(&buffer, 1, &out_buffe... | circular_buffer_get_write_space_remaining(&buffer) | , 0);
cl_assert_equal_i(circular_buffer_get_read_space_remaining(&buffer), 8);
contiguous_num_bytes_left = circular_buffer_write_prepare(&buffer, &data_out);
cl_assert_equal_i(contiguous_num_bytes_left, 0);
cl_assert_equal_p(data_out, NULL);
const uint16_t copy_out_size = 8;
uint8_t copy_out[copy_out_size... |
/*
* 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... | hdlc_streaming_decode(&ctx, (uint8_t *)&c, &should_store, &is_invalid) | ;
cl_assert(is_invalid == false);
if (i == 0 || i == len - 1) {
cl_assert(is_complete == true);
cl_assert(should_store == false);
} else {
cl_assert(is_complete == false);
cl_assert(should_store == true);
cl_assert(c == str[i]);
}
}
}
void test_hdlc__special_characters(v... |
.task_mask = task_mask,
.bluetooth = {
.le = {
.gatt_client = {
.subtype = PebbleBLEGATTClientEventTypeCharacteristicSubscribe,
.object_ref = characteristic_ref,
.subscription_type = type,
.gatt_error = gatt_error,
},
},
},
};
event_put(... | UNLIKELY(subscription->subscriptions[c] == BLESubscriptionNone) | ) {
// Not subscribed, continue
continue;
}
// Write the header first, then write the payload:
GATTBufferedNotificationHeader header = {
.characteristic = subscription->characteristic,
.value_length = length,
};
CircularBuffer *buffer = s_circular_buffer[c];
bt_unlock();
... |
ol exists = (prv_find_by_ids(service_id, attribute_id) || prv_find_by_buffer(buffer));
mutex_unlock(s_attr_list_lock);
if (exists) {
PBL_LOG(LOG_LEVEL_ERROR, "Attribute already exists (0x%x,0x%x)", service_id, attribute_id);
return false;
}
SmartstrapAttributeInternal *new_attr = kernel_zalloc(sizeof(S... | {
return SmartstrapResultBusy;
} |
// clear the write buffer
memset(mbuf_get_data(&attr->mbuf), 0, mbuf_get_length(&attr->mbuf));
return SmartstrapResultOk;
} else if (type == SmartstrapRequestTypeRead) {
// handle read request
if (!prv_start_transaction(attr, AttributeTransactionRead)) {
return SmartstrapResultBusy;
}
... |
tive = true;
alerts_set_dnd_mask(AlertMaskPhoneCalls);
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
cl_assert(alerts_should_vibrate_for_type(AlertPhoneCall));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDO... | (alerts_should_notify_for_type(AlertPhoneCall)) | |
uint16_t *conn_interval) {
bt_lock();
if (!session || !comm_session_is_valid(session)) {
bt_unlock();
return false;
}
const bool tmp_is_ppogatt =
(comm_session_analytics_get_transport_type(session) == CommSessionTransportType_PPoGATT);
uint16_t tmp_conn_interval = 0;
i... | (&event_blob) | ;
}
void analytics_event_get_bytes_stats(CommSession *session, uint8_t type,
uint32_t bytes_transferred, uint32_t elapsed_time_ms,
uint32_t conn_events, uint32_t sync_errors,
uint32_t skip_errors, uint32_t o... |
true;
}
static void prv_filter_time_since(TemplateStringState *state) {
prv_filter_time_until(state);
if (state->error->status != TemplateStringErrorStatus_Success) {
return;
}
state->filter_state = -state->filter_state;
state->time_was_until = false;
}
static void prv_filter_end(TemplateStringState *st... | {
if (*state.position != '{') {
prv_handle_escape_character(&state);
if (state.error->status != TemplateStringErrorStatus_Success) {
break;
}
prv_append_char(&state, *state.position);
state.position++;
} else { // Template
state.position++;
prv_template_eval(&st... |
if (state.error->status != TemplateStringErrorStatus_Success) {
// get the position index.
state.error->index_in_string = state.position - input_template_string;
}
// Null terminator
if (state.output) {
*state.output = '\0';
}
if (state.eval_cond) {
// Adjust eval_time if it never got se... |
one;
}
if (has_new) {
timeline_layer_set_next_item(&data->timeline_layer, new_idx);
}
timeline_layer_move_data(&data->timeline_layer, 1);
} else {
if (!timeline_model_iter_prev(&new_idx, &has_new)) {
prv_exit(data);
goto done;
}
if (has_new) {
timeline_layer_set_pre... | (&data->timeline_layer, true) | ;
#if ANIMATION_DOT
timeline_layer_unfold_day_sep(&data->timeline_layer);
#elif ANIMATION_SLIDE
timeline_layer_slide_day_sep(&data->timeline_layer);
#endif
prv_set_day_sep_timer(data);
} else {
#if CAPABILITY_HAS_TIMELINE_PEEK
GPoint direction = GPoint(0, -1);
#else
GPoint direction = GPoint(1, 0)... |
aredPRFPendingBondings s_pending_bondings = { };
static PebbleMutex *s_pending_data_mutex = NULL;
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Private functions
static void prv_lock_pending_bonding(void) {
mutex_lock(s_pending_data_mutex);
}
static void p... | (SharedPRFData, local_device_name) | ,
offsetof(SharedPRFData, local_device_name));
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! BLE Root Keys
bool shared_prf_storage_get_root_key(SMRootKeyType key_type, SM128BitKey *key_out) {
SharedPRFData data;
prv_... |
NY);
dialog_set_vibe(dialog, true);
}
//! Construct a worker crash reason string
//! @param app_install_id The worker's install id
//! @return The resulting string, which must be freed by the caller
static char *prv_create_worker_crash_reason_string(AppInstallId app_install_id) {
// Get the information about the a... | expandable_dialog_create("Reset") | ;
prv_configure_crash_dialog(expandable_dialog_get_dialog(expandable_dialog), crash_reason);
expandable_dialog_show_action_bar(expandable_dialog, false);
expandable_dialog_push(expandable_dialog, prv_get_window_stack());
light_enable_interaction();
}
//! Restrict only to the two defines above
//! Show the "Yo... |
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_START) | ;
active_window->action_bar_pause =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_PAUSE);
active_window->action_bar_stop =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_STOP);
active_window->action_bar_more =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_MORE);
... | |
/prompt.h"
#include "drivers/dma.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "kernel/events.h"
#include "kernel/util/sleep.h"
#include "kernel/util/stop.h"
#include "os/mutex.h"
#include "os/tick.h"
#include "services/common/system_task.h"
#include "system/logging.h"
#include "system/passer... | DFSDM_TransceiverInit(this->channel, &DFSDM_InitStruct) | ;
DFSDM_FilterInitTypeDef DFSDM_FilterInitStruct;
DFSDM_FilterStructInit(&DFSDM_FilterInitStruct);
DFSDM_FilterInitStruct.DFSDM_SincOrder = sinc_order;
DFSDM_FilterInitStruct.DFSDM_FilterOversamplingRatio = oversampling_ratio;
DFSDM_FilterInitStruct.DFSDM_IntegratorOversamplingRatio = 1;
DFSDM_FilterInit(t... |
/*
* 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... | stub_new_timer_fire(sys_timer_id) | ;
// We know have an event to run on "the app task"
cl_assert_equal_i(s_last_event.type, PEBBLE_CALLBACK_EVENT);
cl_assert(!s_times_callback_executed);
// Run the code on "the app task"
s_last_event.callback.callback(s_last_event.callback.data);
// And we're done!
cl_assert(s_times_callback_executed ==... |
el_data->duration_ms = 300;
Animation *animation = (Animation *)kino_player_create_play_animation(test_player);
cl_assert_equal_i(animation_is_scheduled(animation), false);
animation_schedule(animation);
animation_set_elapsed(animation, 20);
animation_set_duration(animation, ANIMATION_DURATION_INFINITE);
p... | (animation) | ;
animation_set_reverse(animation, true);
animation_set_duration(animation, 300);
animation_set_elapsed(animation, 20);
prv_play_animation_update(animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), ANIMATION_DURATION_INFINITE);
}
void test_kino_player__infinite_ani... |
,
uint16_t endpoint_id,
const uint8_t *payload,
size_t payload_length) {
const size_t outbox_data_size = sizeof(AppMe... | (AppMessageSenderErrorDisconnected, 1) | ;
app_free(outbox_data);
}
void test_app_message_sender__no_sessions_connected(void) {
s_system_session_ptr = NULL;
s_app_session_ptr = NULL;
AppMessageAppOutboxData *outbox_data =
prv_create_and_send_outbox_message(NULL /* auto-select */, ALLOWED_ENDPOINT_ID,
TES... |
/*
* 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... | {
success = new_timer_start(*timer_id, ms, prv_timer_callback, (void *)(uintptr_t)task,
0 /*flags */);
} |
if (!success) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Error scheduling timer");
}
}
// ---------------------------------------------------------------------------
// Used for unit tests only
TimerID animation_service_test_get_timer_id(void) {
return s_kernel_main_timer_id;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (a.attributes[i].id, b.attributes[i].id) | ;
switch (a.attributes[i].id) {
case AttributeIdTitle:
case AttributeIdSubtitle:
case AttributeIdBody:
cl_assert_equal_s(a.attributes[i].cstring, b.attributes[i].cstring);
break;
case AttributeIdAncsAction:
cl_assert_equal_i(a.attributes[i].int8, b.attributes[i].int8)... |
log->zero = '\0';
animation_set_curve(anim, AnimationCurveLinear);
animation_schedule(anim);
}
static void prv_stop_text_animation(TranscriptionDialog *transcription_dialog) {
Dialog *dialog = expandable_dialog_get_dialog((ExpandableDialog *)transcription_dialog);
animation_unschedule(property_animation_get_a... | PBL_ASSERTN(transcription_dialog) | ;
transcription_dialog->keep_alive_on_select = keep_alive_on_select;
}
TranscriptionDialog *transcription_dialog_create(void) {
TranscriptionDialog *transcription_dialog = applib_type_malloc(TranscriptionDialog);
if (!transcription_dialog) {
return NULL;
}
transcription_dialog_init(transcription_dialog)... |
PBL_LOG(LOG_LEVEL_DEBUG, "SELECT clicked!") | ;
(void)data;
(void)recognizer;
}
#if 0
static void select_long_click_handler(ClickRecognizerRef recognizer, ScrollAppData *data) {
PBL_LOG(LOG_LEVEL_DEBUG, "SELECT long clicked!");
(void)data;
(void)recognizer;
}
#endif
static void click_config_provider(ScrollAppData *data) {
// The config that gets pass... | |
/*
* 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_sensor_enable(true);
} |
periph_config_release_lock();
s_initialized = true;
}
uint32_t ambient_light_get_light_level(void) {
if (!s_initialized) {
return BOARD_CONFIG.ambient_light_dark_threshold;
}
if (!BOARD_CONFIG.als_always_on) {
prv_sensor_enable(true);
}
VoltageReading reading;
voltage_monitor_read(VOLTAGE_... |
/*
* 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_set_update_proc(0, 0) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.