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... | (gack, 456) | |
(window1->on_screen, true) | ;
cl_assert_equal_p(s_last_click_configured_window, window1);
// Switch to the kernel to push a modal window
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
window_stack_push(modal_stack, window2, true);
cl_assert_equal_i(window_stack_count(modal_stack), 1);
cl_assert_equal_i(window2->on_screen, tr... | |
on every
// reconnection. @see https://pebbletechnology.atlassian.net/browse/PBL-39369
PBL_LOG(LOG_LEVEL_DEBUG, "Skipping syncing new pairing info...");
} else {
const bool success = (evt->status == BLE_STATUS_OK);
if (success && evt->bond) {
// Sync the new bonding:
bonding_sync_handle_pa... | (LOG_LEVEL_DEBUG, "At least I started") | ;
analytics_init();
hc_endpoint_analytics_send_reboot_info();
debug_reboot_reason_print();
s_ble_perip_wdog_id = sys_watchdog_register(false);
// FIXME:
// srand(time(NULL));
PBL_LOG(LOG_LEVEL_DEBUG, "hope for the best");
connection_module_init();
prv_configure_irk(init_info->config);
ble_erro... |
= { .int16 = prv_set_percent, },
},
};
// animate the progress bar in by growing it from the left (or just show it if animated == false)
static void prv_show_progress_bar(VoiceUiData *data, bool animated) {
static const uint16_t MAX_PROGRESS_FUDGE_AMOUNT = 75;
static const uint32_t PROGRESS_FUDGE_DURATION = 5000... | ((VoiceUiData *)context, DictationSessionStatusSuccess) | ;
}
// Initiates transitions triggered by animations finishing
static void prv_handle_stop_transition(VoiceUiData *data) {
// Transition to next state
switch (data->state) {
case StateStartWaitForReady:
prv_set_mic_window_state(data, StateWaitForReady);
break;
case StateStopWaitForReady:
... |
6 00:00:00 PST 2015
// No items within window
rtc_set_time(1421395200);
head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
1421395200),
S_NO_MORE_ITEMS);
fake_pbl_malloc_clea... | (iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
// check rollover behaviour
cl_assert(!iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].he... |
/*
* 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_putstr("Checksumming firmware update");
uint32_t crc = crc_calculate_flash(flash_address, desc->firmware_length);
return crc == desc->checksum;
} |
// Fills in the first 50% of the progress bar
static void prv_display_erase_progress(
uint32_t progress, uint32_t total, void *ctx) {
display_firmware_update_progress(progress, total * 2);
}
//! Returns true if we're going to install a new world firmware
static bool prv_check_firmware_world(uint32_t flash_new_... |
andler).
#define MESSAGE_SWAP_DELAY 3
typedef enum {
ScrollAnimationCurveKind_Interpolator,
ScrollAnimationCurveKind_Curve
} ScrollAnimationCurveKind;
typedef struct {
ScrollAnimationCurveKind swap_curve_kind;
union {
struct { InterpolateInt64Function interpolator; };
struct { AnimationCurve curve; };... | prv_layout_set_frame(swap_layer->next, &next_frame) | ;
layer_add_child(&swap_layer->layer, (Layer *)swap_layer->next);
layer_insert_below_sibling((Layer *)swap_layer->next, &swap_layer->arrow_layer.layer);
}
}
//////////////////////////
// STATUS LAYER FUNCTIONS
//////////////////////////
static void prv_update_status_bar_color(SwapLayer *swap_layer) {
// S... |
); // 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__numbers_get_rounded_when_converting_to_in... | jerry_create_number(c->u64) | |
ACTIVITY_SESSION_UPDATE_MIN);
// We should have only nap sessions now
prv_count_sleep_sessions(test_start_utc, &sleep_count, &nap_count);
PBL_LOG(LOG_LEVEL_DEBUG, "Found %d sleep sessions and %d nap sessions", sleep_count, nap_count);
if (nap_count == 0 || sleep_count > 0) {
PBL_LOG(LOG_LEVEL_ERROR, "FAILE... | (k_num_minutes) | ;
activity_insights_settings_write(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD, &original_settings);
activity_prefs_activity_insights_set_enabled(prev_insights_enabled);
prv_test_end(context, passed);
}
// -------------------------------------------------------------------------------
static void prv_test_sleep_... |
/*
* 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... | (RESOURCE_ID_WORKOUT_APP_WALK) | ;
case ActivitySessionType_Run:
default:
return kino_reel_create_with_resource(RESOURCE_ID_WORKOUT_APP_RUN);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Drawing
static void prv_render_activity_type(GContext *ctx, Layer *layer, KinoReel *... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(minute, 1) | ;
cl_assert_equal_i(second, 1);
}
{
second = 1;
time_util_split_seconds_into_parts((3 * (24 * 60 * 60)), &day, &hour, &minute, &second);
cl_assert_equal_i(day, 3);
cl_assert_equal_i(hour, 0);
cl_assert_equal_i(minute, 0);
cl_assert_equal_i(second, 0);
}
{
time_util_split_seco... |
//////////////////////////////////
void test_reminders__initialize(void) {
now = 0;
num_events_put = 0;
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
reminder_db_init();
// add all four explicitly out of order
cl_assert(S_SUCCESS == reminders_insert(&item4));
cl_assert(S_SUCCESS == reminders_i... | get_reminder_timer_id() | |
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_pixel_inside_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_... | (ctx, GPoint(p.x + 5, p.y + 1)) | ;
graphics_draw_pixel(ctx, GPoint(p.x + 6, p.y + 1));
graphics_draw_pixel(ctx, GPoint(p.x + 7, p.y + 1));
graphics_draw_pixel(ctx, GPoint(p.x + 0, p.y + 2));
graphics_draw_pixel(ctx, GPoint(p.x + 1, p.y + 2));
graphics_draw_pixel(ctx, GPoint(p.x + 2, p.y + 2));
graphics_draw_pixel(ctx, GPoint(p.x + 3, p.y ... |
static bool prv_bootrom_wait_for_char(char *char_received) {
const uint32_t wait_time_ticks = (DIALOG_BOOTROM_DEFAULT_CHAR_TIMEOUT_MS * RTC_TICKS_HZ) / 1000;
return prv_bootrom_wait_for_char_with_timeout(char_received, wait_time_ticks);
}
static bool prv_download_patch_from_system_resources(uint16_t bootloader_s... | if (!prv_send_header(bootloader_size)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to send header");
success = false;
goto cleanup;
} |
// Transmit SW code bytes, check received CRC, and ack if correct
if (!prv_download_patch_from_system_resources(bootloader_size)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to load second stage BLE bootloader");
success = false;
goto cleanup;
}
cleanup:
// We have loaded the image, disable the peripheral... |
777777777777777777");
}
void test_sprintf__null(void) {
cl_assert_equal_i(snprintf(NULL, 0, "Hello!\nI am error"), 17);
}
void test_sprintf__percent_d(void) {
char dstbuf[256];
// Simple %d
snprintf(dstbuf, 256, "There are %d lights, %d", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// ... | cl_assert_equal_s(dstbuf, "There are 4 lights, the absolute value of -4") | ;
// Plus for positive signed
snprintf(dstbuf, 256, "There are %+i lights, the absolute value of %+i", 4, -4);
cl_assert_equal_s(dstbuf, "There are +4 lights, the absolute value of -4");
// Minimum digits output
snprintf(dstbuf, 256, "There are %.2i lights, %.2i", 4, -4);
cl_assert_equal_s(dstbuf, "There ... |
/*
* 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... | strftime(buf, buf_size, "%j", &good_data) | ;
if (r == 0 || strncmp(buf, "125", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"j\": %s", buf);
}
r = strftime(buf, buf_size, "%m", &good_data);
if (r == 0 || strncmp(buf, "05", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"m\": %s", buf);
}
r = strftime(buf, buf_si... |
is_enabled) {
prv_drain_fifo();
return;
}
AccelDriverSample data;
prv_read_curr_accel_data(&data);
accel_cb_new_sample(&data);
}
static void prv_handle_motion_interrupts(void) {
s_accel_outstanding_motion_work = false;
const uint8_t int0_status = bma255_read_register(BMA255Register_INT_STATUS_0);... | (BMA255Register_PMU_LPW,
s_power_mode[mode].lpw << BMA255_LPW_POWER_SHIFT,
BMA255_LPW_POWER_MASK) | ;
// Workaround for error in transition to Suspend / Standby
if (mode == BMA255PowerMode_Suspend || mode == BMA255PowerMode_Standby) {
// Write to FIFO_CONFIG_1 to exit some unknown "intermittent state"
// NOTE: This will clear the FIFO & FIFO status.
bma255_read_modify_write(BMA255Register_FIFO_... |
/*
* 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... | __profiler_stop() | |
_handle, svc->end_h, blob_size);
uint16_t *att_handles_included_services =
(uint16_t *)((uint8_t *)service + blob_size -
sizeof(uint16_t) * type_counts[GATTC_ITEM_TYPE_INCLUDE]);
uint16_t att_idx = 0;
GATTCharacteristic *char_dest = NULL;
uint8_t *end_ptr = (uint8_t *)service->charact... | {
continue;
} | |
C32_INIT, s_spi_transport.rx_write_ptr,
s_spi_transport.bytes_receivable_count);
if (crc != s_spi_transport.rx_footer.crc) {
PBL_LOG(LOG_LEVEL_ERROR, "CRC failed on remote SPI Receive 0x%08" PRIX32 " != 0x%08" PRIX32,
crc, s_spi_transport.rx_footer.crc);
prv_trigger_core_du... | {
prv_lock();
circular_buffer_read(&s_spi_transport.tx, s_spi_transport.tx.data_length,
&s_spi_transport.tx_read_ptr,
&s_spi_transport.status_local->bytes_sendable_count);
s_spi_transport.status_local->bytes_receivable_count =
circular_buffer_write_prepare(&s_sp... |
static void prv_handle_int_idle(void) {
// We're idle. First do the "status exchange", so we know how much to send & receive.
s_spi_transport.state = SPITransportState_StatusExchange;
prv_update_local_status_msg();
dialog_spi_send_and_receive_dma(s_spi_transport.status_local,
... |
/*
* 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... | smartstrap_link_control_is_profile_supported(info->profile) | ) {
smartstrap_state_unlock();
return SmartstrapResultServiceUnavailable;
}
SmartstrapResult result = info->send(request);
smartstrap_state_unlock();
return result;
}
void smartstrap_profiles_handle_read(bool success, SmartstrapProfile profile, uint32_t length) {
PBL_ASSERT_TASK(PebbleTask_KernelBac... |
/ui.h"
#include "applib/ui/dialogs/dialog.h"
#include "applib/ui/dialogs/expandable_dialog.h"
#include "applib/ui/dialogs/simple_dialog.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/system_icons.h"
#include "popups/ble_hrm/ble_hrm_stop_sharing_popup.h"
#include "resource/resource_ids.auto.h"
#include "services/... | prv_le_connection_for_stored_remote(remote) | ;
ble_hrm_revoke_sharing_permission_for_connection(connection);
app_simple_dialog_push(ble_hrm_stop_sharing_popup_create());
}
#endif // CAPABILITY_HAS_BUILTIN_HRM
void settings_remote_menu_push(struct SettingsBluetoothData *bt_data, StoredRemote *stored_remote) {
SettingsRemoteData *data = app_malloc_check(si... |
[num_logs] = task_strdup("Let's test if wrap around is working!");
logs[num_logs + 1] = task_strdup("This should be on an early page");
int start_log = num_logs / (tot_size / erase_size);
int num_wrapped = num_logs - start_log;
setup_and_test_expected_msg(&logs[start_log], 0, num_wrapped, num_wrapped + 2);
... | flash_logging_write((uint8_t *)msg, start_addr, strlen(msg)) | ;
cl_assert(!rv);
setup_and_test_expected_msg(&msg, 0, 1, 1);
}
//! Make sure that when we chunk up our writes for a log message, the lines
//! are saved as expected and that bogus writes after a record has been written
//! do not take
void test_flash_logging__multi_writes_per_log(void) {
flash_logging_init();
... |
, 288, -72},
{ 1392, 304, -8},
{ 1296, 464, 72},
{ 1336, 520, 32},
{ 1192, 256, -136},
{ 824, 200, -96},
{ 1008, 280, -64},
{ 1264, 280, 8},
{ 1320, 200, 8},
{ 1136, 48, 40},
{ 1104, -64, 40},
{ 1080, -72, 32},
{ 992, -32, 16},
{ 912, 0, 0},
{ 848, -24, 16},
{... | { 1192, 328, 104},
{ 1376, 256, 104},
{ 1064, 160, 120},
{ 1048, -24, 128},
{ 1072, -104, 56},
{ 1112, -56, 0},
{ 1064, 8, 8},
// 27 seconds
{ 1000, 16, 8},
{ 1224, -48, 40},
{ 1008, 0, -16},
{ 1088, -8, -88},
{ 1152, -16, -120},
{ 1064, -24, -168},
{ 1032, 8,... |
{ 1136, 24, -192},
{ 1064, 88, -248},
{ 792, 88, -200},
{ 736, 56, -136},
{ 864, 96, -152},
{ 968, 120, -80},
{ 1040, 168, -176},
{ 1072, 176, -184},
{ 1536, 232, -176},
{ 1216, 280, -128},
{ 1128, 256, -80},
{ 1072, 328, -192},
{ 968, 432, -144},
// 30 seconds
... |
ry section, subtract 32768 for header space.
int fd = pfs_open(name, OP_FLAG_WRITE, FILE_TYPE_STATIC, pfs_get_size() - (num_pages()*128));
printf("%d\n", pfs_get_size() - 1024);
cl_assert(fd >= 0);
cl_assert(pfs_close(fd) == S_SUCCESS);
cl_assert(pfs_remove(name) == S_SUCCESS);
}
void test_pfs__active_regi... | snprintf(buf, sizeof(buf), "This is small buf %d!", i) | ;
int len = strlen(buf);
int fd = pfs_open(file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, len);
cl_assert(fd >= 0);
cl_assert(pfs_write(fd, (uint8_t *)buf, len) == len);
cl_assert(pfs_close(fd) == S_SUCCESS);
if (num_erases != (erase_count - 1)) {
cl_assert(pfs_remove(file_smal... |
t prv_largest_common_bt_uuid_width(const Uuid uuids[],
uint8_t num_uuids) {
uint8_t max_width_bytes = sizeof(uint16_t);
for (unsigned int i = 0; i < num_uuids; ++i) {
const Uuid *uuid = &uuids[i];
const uint8_t width_bytes = prv_smallest_bt_uuid_width_in_bytes(uuid);... | sys_ble_get_advertising_tx_power() | ;
return prv_write_element_to_ad_data(ad, element);
}
// -----------------------------------------------------------------------------
bool ble_ad_set_manufacturer_specific_data(BLEAdData *ad, uint16_t company_id,
const uint8_t *data, size_t size) {
struct __attribute__(... |
&= ~SysTick_CTRL_ENABLE_Msk;
enter_stop_mode();
dbgserial_putstr("woah, failed to enter stop mode");
while (1) { }
}
#ifndef RECOVERY_FW
// Create a bunch of fragmentation in the filesystem by creating a large number
// of small files and only deleting a small number of them
void command_litter_filesystem(voi... | prompt_command_continues_after_returning() | ;
}
void command_btle_unmod_tx_start(char *tx_channel) {
bt_driver_start_unmodulated_tx(atoi(tx_channel));
}
void command_btle_unmod_tx_stop(void) {
bt_driver_stop_unmodulated_tx();
}
void command_btle_test_le_tx_start(
char *tx_channel, char *tx_packet_length, char *packet_payload_type) {
bt_driver_le_tra... |
ntTypeDescriptorRead);
gatt_err_code = prv_handle_response(resp, data, &gatt_value_length);
break;
}
case GattClientOpResponseWrite: {
PBL_ASSERTN(data->subtype == PebbleBLEGATTClientEventTypeCharacteristicWrite ||
data->subtype == PebbleBLEGATTClien... | bt_unlock() | ;
}
BTErrno gatt_client_op_write(BLECharacteristic characteristic,
const uint8_t *value,
size_t value_length,
GAPLEClient client) {
return prv_write(characteristic, value, value_length, client,
gatt_client_chara... |
ps are very low (QA or a brand new pebble user), bump the value
// to a slightly more reasonable number.
// This fixes an integer rounding problem when the value is very small (PBL-43717)
const int min_daily_steps_avg = 100;
data->daily_steps_avg = MAX(data->daily_steps_avg, min_daily_steps_avg);
// increase... | (&data->shoe_blue) | ;
gbitmap_deinit(&data->shoe_green);
#endif
#if PBL_COLOR && SNOWY_SCREEN_RES
gbitmap_deinit(&data->shoe_blue_small);
gbitmap_deinit(&data->shoe_green_small);
#endif
gbitmap_deinit(&data->heart_icon);
layer_deinit(&data->base_layer);
}
/////////////////////////////////////////////////////////////////////////... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (connection) | ;
}
static void prv_handle_set_remote_desired_state(GAPLEConnection *connection,
const PebblePairingServiceRemoteDesiredState *desired_state) {
const ResponseTimeState remote_desired_state = (ResponseTimeState)desired_state->state;
PBL_LOG(LOG_LEVEL_INFO, "PPS: desired_state=%u", remote_desired_state);
// "... |
6"",
(int)session->type, start_minute, session->length_min);
// Skip if not a sleep session
if (!activity_sessions_prv_is_sleep_activity(session->type)) {
ACTIVITY_LOG_DEBUG("Not a sleep session");
continue;
}
// Skip if still ongoing
if (session->ongoing) {
... | activity_algorithm_metrics_changed_notification() | ;
// Return desired sampling rate
*sampling_rate = KALG_SAMPLE_HZ;
return true;
}
static void prv_activity_update_states(time_t utc_sec, AlgMinuteRecord *record_out,
bool shutting_down);
// ----------------------------------------------------------------------------------... |
d(args);
// Make sure the strings don't blow our max message setting
if ((str1_len + str2_len) >= MAX_MSG_STR_LEN) {
str1_len = MIN(str1_len, MAX_MSG_STR_LEN_HALF);
str2_len = MIN(str2_len, MAX_MSG_STR_LEN_HALF);
}
if (str1_len) {
// length + strlen(string) + padding (round up to nea... | MAX((MAX_MSG_LEN + sizeof(HcProtocolMessage) + 40), 130) | ;
uint8_t msg_buffer[msg_buffer_size];
memset(msg_buffer, 0, msg_buffer_size);
HcProtocolMessage *hc_msg = (HcProtocolMessage *)&msg_buffer[0];
BinLogMessage_Unhashed_v1 *msg = (BinLogMessage_Unhashed_v1 *)
&msg_buffer[sizeof(HcProtocolMessage)];
msg->header.version = B... |
.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 10);
graphics_line_draw_precise_stroked_non_aa(&ctx, START_ON_ORIGIN_RECT_XY, END_ON_ORIGIN_RECT_XY, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_across_x_offset_layer_non_aa.${BIT_DEPTH_NAME}.pbi"));
s... | (&ctx, CLOSE_POINTS_AROUND_1PX_START, CLOSE_POINTS_AROUND_1PX_END, 10) | |
?
GTextAlignmentRight : GTextAlignmentCenter));
uint16_t right_aligned_box_reduction = PBL_IF_RECT_ELSE(0, show_action_bar ? 10 : 0);
if (has_header) {
const uint16_t HEADER_OFFSET = 6;
#if PBL_RECT
x = left_margin_px;
w = frame.size.w - right_margin_px - l... | if (expandable_dialog->select_icon) {
action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_SELECT,
expandable_dialog->select_icon, expandable_dialog->show_action_icon_animated);
} | |
e(bool);
}
void syscall_assert_userspace_buffer(const void* buf, size_t num_bytes) {
uintptr_t addr = (uintptr_t)buf;
uintptr_t end = addr + num_bytes - 1;
if ((addr >= s_user_start) && (addr < (s_user_start + s_user_size)) &&
(end >= s_user_start) && (end < (s_user_start + s_user_size))) {
s_addr_resu... | (s_invalidate_size, 0x55AA) | ;
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Invalid);
}
void test_cpu_cache__without_dcache(void) {
cl_will_return(icache_is_enabled, true);
cl_will_return(dcache_is_enabled, false);
cl_will_return(icache_line_size, 1);
cl_will_return(dcache_line_size, 1);
s_invalidate_addr = s_flush_addr = 0xAA5... |
(pfs_read(fd, &read_byte, sizeof(read_byte)), sizeof(read_byte));
cl_assert_equal_i(read_byte, 0xff - i);
}
}
pfs_close(fd);
}
void test_pfs__write(void) {
int rv = pfs_write(-1, NULL, 0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(1000000, NULL, 0);
cl_assert(rv == E_INVALID_ARGUMENT)... | pfs_read(fd, buf, rd_len + 1) | ;
cl_assert(rv == E_RANGE);
}
void test_pfs__close(void) {
// shouldn't be able to close fds that are not open
int rv = pfs_close(-1);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_close(0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_close(1000000);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = p... |
bs_layout_layer.h"
static time_t now = 0;
static int num_events_put = 0;
time_t rtc_get_time(void) {
return now;
}
RtcTicks rtc_get_ticks(void) {
return 0;
}
typedef void (*CallbackEventCallback)(void *data);
void launcher_task_add_callback(CallbackEventCallback callback, void *data) {
callback(data);
}
voi... | (num_events_put, 3) | ;
cl_assert_equal_m(&item3.header.id, stub_new_timer_callback_data(get_reminder_timer_id()), sizeof(TimelineItemId));
cl_assert(stub_new_timer_timeout(get_reminder_timer_id()) == 200 * 1000);
now += 200;
stub_pebble_tasks_set_current(PebbleTask_NewTimers);
cl_assert(stub_new_timer_fire(get_reminder_timer_id(... |
) {
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_change,
.change = prv_change,
};
app_unobstructed_area_service_subscribe(handlers, s_data.context);
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state... | (&root_layer, &unobstructed_bounds) | ;
cl_assert_equal_grect(unobstructed_bounds, GRect(0, 0, 190, 180));
}
void test_unobstructed_area_service__nested_layer_no_clip(void) {
app_state_get_unobstructed_area_state()->area = GRect(0, 0, 400, 400);
Layer root_layer = {
.bounds = GRect(30, 30, 30, 30),
};
Layer layer = {
.bounds = GRect(20,... |
ebbleEvent *e) {
PBL_ASSERTN(queue != NULL);
bool success = (xQueueSendToBack(queue, e, 0) == pdTRUE);
return success;
}
void event_service_handle_subscription(PebbleSubscriptionEvent *subscription) {
if (subscription->subscribe) {
prv_event_service_subscribe(subscription);
} else {
prv_event_service... | prv_task_is_masked_out(e, cur_task) | && service->subscribers[cur_task]) {
// we are on the current task, so we just tell the client to handle it inline
event_service_client_handle_event(e);
}
if (stolen) {
// we stole the buffer from the event, NULL it out
*buf_ptr = NULL;
}
}
// ---------------------------------------------------... |
ssert.h"
#include "string.h"
////////////////////////////////////////////////////////////
// Data structures
typedef struct {
Window window;
GBitmap *bitmap;
bool bitmap_inited;
BitmapLayer bitmap_layer;
Layer anim_layer;
PropertyAnimation *spinner_animation;
AnimationImplementation spinner_anim_impl;
... | {
gbitmap_destroy(data->bitmap);
data->should_cancel_animation = true;
property_animation_destroy(data->spinner_animation);
kernel_free(data);
} |
}
static void prv_window_load_handler(Window* window) {
SpinnerUIData *data = window_get_user_data(window);
GRect spinner_bounds = window->layer.bounds;
spinner_bounds.origin.y += PBL_IF_RECT_ELSE(0, 10);
window_set_background_color(window, PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite));
BitmapLayer *bi... |
est");
// Initialize region that is to be written
uint16_t data_buffer = 0x0;
uint8_t bitpos = 0;
uint16_t read_buffer = 0x0;
// Ensure within test data region and aligned to sector boundary
uint32_t addr_region = (FLASH_TEST_ADDR_START + SECTOR_SIZE_BYTES) & SECTOR_ADDR_MASK;
// Loop on each data bit ... | if (((read_buffer != 0xFF) && (read_buffer != 0xAA)) || (test_addr == base_addr)) {
if (display_logs) {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Erasing Addr 0x%"PRIx32, test_addr);
}
flash_erase_sector_blocking(test_addr);
// Verify data was erased
status = prv_read_v... |
}
// After the base address, go up by power of 2's
if (bit_offset == 0) {
bit_offset = 1;
}
}
}
if (display_logs) { PBL_LOG(LOG_LEVEL_DEBUG, ">>> Erasing sectors...complete"); }
// Write default data pattern to each power-of-two offset within the test region
for (bit_offs... |
216, -552},
{ 2416, 280, -608},
{ 2552, 344, -544},
{ 1920, 376, -528},
{ 1400, 328, -424},
{ 1224, 456, -304},
{ 1136, 416, -192},
{ 1016, 728, -80},
{ 904, 1224, 288},
{ 600, 1192, 176},
{ 664, 816, 136},
{ 1048, 912, 104},
{ 1480, 696, -80},
{ 2176, 856, -64},
... | { 1896, 168, -456},
{ 1912, 336, -392},
{ 1784, 296, -208},
{ 1400, 688, -296},
{ 1288, 568, -264},
{ 1232, 528, -128},
{ 1096, 568, -48},
{ 896, 648, 16},
// 13 seconds
{ 1064, 664, 48},
{ 984, 632, 24},
{ 904, 672, 144},
{ 896, 856, 24},
{ 824, 712, -192},
{... |
{ 1008, 824, -32},
{ 960, 864, 24},
{ 728, 720, 40},
{ 1144, 864, 144},
{ 1144, 632, -136},
{ 1128, 600, -184},
{ 1504, 760, -32},
{ 2040, 632, 64},
{ 2048, 376, 64},
{ 1960, 160, -104},
{ 1632, 88, -88},
{ 1424, 168, -168},
{ 1160, 96, -176},
{ 976, 136, -232},
... |
t "number of messages consumed", because that would force the system to parse
//! the contents of the (app space) buffer, which might have been corrupted by the app.
//! Note that it's in theory possible for a misbehaving app to pass in a consumed_up_to_ptr that is
//! mid-way in a message. If it does so, it won't cras... | (LOG_LEVEL_ERROR, "Corrupted AppInbox message!") | ;
}
++num_message_consumed;
}
if (info.num_failed) {
if (info.dropped_handler) {
info.dropped_handler(info.num_failed);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Dropped %"PRIu32" messages but no dropped_handler",
info.num_failed);
}
}
// Report back up to which byte we'... |
ssions
const uint16_t max_apart_merge_secs = 5 * SECONDS_PER_MINUTE;
time_t end_time = previous->start_utc + previous->length_min * SECONDS_PER_MINUTE;
if ((end_time + max_apart_merge_secs) > current->start_utc) {
current->length_min += previous->length_min +
(current->start_utc - ... | {
ActivitySession *previous_session = NULL;
for (unsigned int i = 0; i < health_data->num_activity_sessions; i++) {
ActivitySession *session = &health_data->activity_sessions[i];
prv_merge_adjacent_sessions(session, previous_session);
previous_session = session;
}
} | |
write_response,
.handle_subscribe = test_client_handle_subscribe,
.handle_read_or_notification = test_client_handle_read_or_notification,
},
#else
[KernelLEClientPPoGATT] = {
.debug_name = "PPoG",
.service_uuid = &s_ppogatt_service_uuid,
.characteristic_uuids = s_ppogatt_characteristic_uuids,
... | bt_unlock() | |
animation_create();
animation_set_curve(animation, AnimationCurveEaseIn);
animation_set_duration(animation, BUMP_TEXT_DURATION_MS);
AnimationHandlers anim_handler = {
.stopped = prv_bump_text_stopped,
};
animation_set_handlers(animation, anim_handler, selection_layer);
selection_layer->bump_text_impl =... | {
Animation *animation = animation_create();
animation_set_curve(animation, AnimationCurveEaseIn);
animation_set_duration(animation, SLIDE_DURATION_MS);
AnimationHandlers anim_handler = {
.stopped = prv_slide_stopped,
};
animation_set_handlers(animation, anim_handler, selection_layer);
selection_laye... |
static Animation* prv_create_slide_settle_animation(SelectionLayer *selection_layer) {
Animation *animation = animation_create();
animation_set_curve(animation, AnimationCurveEaseOut);
animation_set_duration(animation, SLIDE_SETTLE_DURATION_MS);
AnimationHandlers anim_handler = {
.stopped = prv_slide_sett... |
ow(LauncherMenuLayer *launcher_menu_layer, uint16_t row) {
if (!launcher_menu_layer || !launcher_menu_layer->selection_animations_enabled) {
return;
}
// Get the app menu node for the glance that is about to be selected
AppMenuDataSource *data_source = launcher_menu_layer->data_source;
AppMenuNode *node ... | (down_arrow_layer_frame_origin_y, 0, 0, 0) | );
Layer *down_arrow_layer = &launcher_menu_layer->down_arrow_layer;
layer_init(down_arrow_layer, &down_arrow_layer_frame);
layer_add_child(container_layer, down_arrow_layer);
ContentIndicator *content_indicator =
scroll_layer_get_content_indicator(&menu_layer->scroll_layer);
ContentIndicatorConfig con... |
data), NULL, &time_end);
cl_assert_equal_i(0, written);
// empty end before start
time_t early_end = time_start - 20 * SECONDS_PER_MINUTE;
written = health_service_get_minute_history(data, ARRAY_LENGTH(data), &time_start, &early_end);
cl_assert_equal_i(0, written);
// empty end works just fine
s_sys_act... | ARRAY_LENGTH(data) | , &time_start, &time_end);
cl_assert_equal_i(2, s_sys_activity_get_minute_history_values.in[0].num_records);
// respects time_end == time_start => 0 records
s_sys_activity_get_minute_history_values.stage = 0;
time_start = time_almost_next_minute;
time_end = time_start;
health_service_get_minute_history(dat... |
= 0x0;
DCDC->DCDC_TEST_0_REG = 0x0;
DCDC->DCDC_TEST_1_REG = 0x0;
DCDC->DCDC_IRQ_CLEAR_REG = 0x0;
DCDC->DCDC_IRQ_MASK_REG = 0x0;
CRG_TOP->BANDGAP_REG = 0x0;
CRG_TOP->BOD_STATUS_REG = 0x7;
CRG_TOP->FORCE_SLEEP_REG = 0x1;
CRG_TOP->LDOS_DISABLE_REG = 0x0;
CRG_TOP->AON_SPARE_REG = 0x0;
QSPIC->QSPIC_CTRL... | REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_HV, 0x1) | |
he #ifdef and ternary op.
#ifdef APP_ID_SEND_TEXT
versions_msg.capabilities.send_text_support = (APP_ID_SEND_TEXT != INSTALL_ID_INVALID) ? 1 : 0;
#endif
versions_msg.capabilities.notification_filtering_support = 1;
#ifdef APP_ID_WEATHER
versions_msg.capabilities.weather_app_support = (APP_ID_WEATHER != INSTALL_ID... | prompt_send_response_fmt(buffer, sizeof(buffer), "Boot:%"PRIu32"\nHW:%s\nSN:%s",
boot_version_read(), hw_version, serial_number);
ResourceVersion system_resources_version = resource_get_system_version();
prompt_send_response_fmt(buffer, sizeof(buffer),
"Syste... | |
/*
* 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... | (vector, sizeof(vector)) | ;
assert_decode_completed(5);
assert_output_equal("Hello", 5);
}
void test_cobs_decode__zeroes(void) {
const char vector[] = { 0x01, 0x02, 'A', 0x01, 0x02, 'B', 0x01 };
decode_start(6);
assert_decode_succeeds(vector, sizeof(vector));
assert_decode_completed(6);
assert_output_equal("\0A\0\0B\0", 6);
}
vo... |
_is_positive);
uint8_t add_top = (add_on_top)? (FIXED_S16_3_ONE.raw_value / 2) : 0;
uint8_t add_bottom = (!add_on_top)? (FIXED_S16_3_ONE.raw_value / 2) : 0;
const int8_t fraction_mask = 0x7;
if (vertical) {
// Left and right most point helpers for main loop
GPointPrecise lm_p0 = far_top;
GPointPr... | {
right_margin.raw_value = rm_p0.x.raw_value + ((rm_p1.x.raw_value - rm_p0.x.raw_value)
* (y - ((rm_p0.y.raw_value + add_bottom) / FIXED_S16_3_ONE.raw_value)))
* FIXED_S16_3_ONE.raw_value / (rm_p1.y.raw_value - rm_p0.y.raw_value);
} | |
{ 1320, 272, -80},
{ 1544, 304, -96},
{ 1792, 352, -120},
{ 1392, 400, -64},
{ 1008, 288, -160},
{ 1040, 328, -16},
{ 1296, 328, 8},
{ 1464, 400, 32},
// 32 seconds
{ 1296, 504, 24},
{ 1592, 600, 160},
{ 1168, 856, 184},
{ 1008, 1008, -8},
{ 992, 688, -32},
{ 1... | { 1248, 352, -8},
{ 1176, 440, -88},
{ 1384, 488, -24},
{ 1360, 680, 80},
{ 936, 864, -128},
{ 1304, 664, -128},
{ 1128, 640, -160},
{ 1272, 552, -80},
{ 1256, 544, 8},
{ 1440, 520, -32},
{ 1600, 440, 32},
{ 1472, 104, 208},
{ 1280, -64, 192},
{ 1232, 168, 0},
... |
{ 1008, 152, 64},
{ 1048, 280, 56},
{ 1152, 360, -120},
{ 800, 288, -64},
{ 1232, 104, 160},
{ 960, -40, 216},
{ 1160, 216, -88},
{ 1384, 288, -40},
{ 1376, 312, -48},
{ 1144, 288, -136},
{ 904, 256, -192},
{ 984, 288, -72},
{ 1192, 296, -8},
{ 1256, 408, -56},
... |
inggreen", GColorMediumSpringGreenARGB8},
{"cyan", GColorCyanARGB8},
{"bulgarianrose", GColorBulgarianRoseARGB8},
{"imperialpurple", GColorImperialPurpleARGB8},
{"indigo", GColorIndigoARGB8},
{"electricultramarine", GColorElectricUltramarineARGB8},
{"armygreen", GColorArmyGreenARGB8},
{"darkgray", GColorD... | {
const size_t len = strlen(color_value);
if (len < 1 || color_value[0] != '#') {
return false;
}
int32_t r, g, b, a;
switch (len) {
case 4: { // #RGB
if (prv_parse_hex_comps(color_value + 1, 1, &r, &g, &b, NULL)) {
*parsed_color = GColorFromRGB(r * (255/15), g * (255/15), b * (255/15))... |
bool rocky_api_graphics_color_parse(const char *color_value, GColor8 *parsed_color) {
return prv_parse_name(color_value, parsed_color) ||
prv_parse_hex(color_value, parsed_color);
}
bool rocky_api_graphics_color_from_value(jerry_value_t value, GColor *result) {
if (jerry_value_is_number(value)) {
*result... |
#include "applib/ui/app_window_stack.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "system/passert.h"
#include <string.h>
#include <stdio.h>
typedef struct AnimatedDemoData {
Window window;
TextLayer text_layer;
PropertyAnimation *prop_animation;
bool toggle;
} AnimatedDemoData;
static... | WINDOW_NAME("Animated Demo") | );
window_set_user_data(window, data);
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
window_set_window_handlers(window, &(WindowHandlers){
.load = animated_demo_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);
}
static void handle_... |
/*
* 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... | gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_origin_aa_r8_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, STROKE_SMALL);
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_origin_aa_r8_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXN... |
+ SECONDS_PER_DAY;
return health_service_sum(metric, today_midnight, tomorrow_midnight);
#endif
}
// ----------------------------------------------------------------------------------------------
HealthValue health_service_sum(HealthMetric metric, time_t time_start, time_t time_end) {
return health_service_aggreg... | {
return 0;
} | |
_app(),
};
} else {
// Get the next app to launch
if (!s_next_app.md) {
// There is no next app to launch? We're starting up, let's launch the startup app.
app_install_release_md(s_next_app.md);
s_next_app = (NextApp) {
.md = system_app_state_machine_system_start(),
};
... | prv_app_switch(!config->forcefully) | ;
}
// ---------------------------------------------------------------------------------------------
void app_manager_handle_app_fetch_request_event(const PebbleAppFetchRequestEvent *const evt) {
PBL_ASSERTN(evt);
if (!evt->with_ui) {
return;
}
const AppFetchUIArgs *const fetch_args = evt->fetch_args;
ap... |
/*
* 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... | (r->flags, 0) | |
rt_equal_i(s_cond.eval_time, test->expect_eval_time);
#if DEBUG_PRINTING
printf("\n");
#endif
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Test pipeline parser
static const struct {
const char *instr;
time_t intime;
const char *expect_str;
... | printf("err.index: %zu\n", err.index_in_string) | ;
printf("\"%s\"\n", s_full_tests[i].instr);
printf("%*s^\n", (int)err.index_in_string + 1, "");
if (err.status >= TemplateStringErrorStatusCount) {
printf("Invalid status code\n");
} else {
printf("%s\n", s_error_strings[err.status]);
}
}
printf("\n");
#endif
... |
_bytes);
if (bytes_read != (size_t)metadata_bytes) {
goto cleanup;
}
png_decoder_data->read_cursor += metadata_bytes;
upng_load_bytes(upng, buffer, metadata_bytes);
upng_error upng_state = upng_decode_image(upng);
if (upng_state != UPNG_EOK) {
APP_LOG(APP_LOG_LEVEL_ERROR,
(upng_state ... | gbitmap_png_get_transparent_gray_value(upng) | ;
for (uint32_t y = 0; y < fctl.height; y++) {
const uint16_t corrected_y = fctl.y_offset + y + bitmap->bounds.origin.y;
const GBitmapDataRowInfo row_info = gbitmap_get_data_row_info(bitmap, corrected_y);
// delta_x is the first bit of data in this frame relative to the bitmap's coordinate syste... |
eLayout *timeline_layout = timeline_layer_get_current_layout(&data->timeline_layer);
if (!timeline_layout) {
return;
}
// cut to the card window
app_window_stack_push(&data->pin_window.window, false);
prv_set_state(data, TimelineAppStateCard);
TimelineIterState *state = timeline_model_get_current_stat... | prv_exit(data) | ;
}
static void prv_up_down_stopped(Animation *animation, bool finished, void *context) {
TimelineAppData *data = context;
if (finished) {
prv_set_state(data, TimelineAppStateStationary);
}
}
static void prv_hide_day_sep_stopped(Animation *animation, bool finished, void *context) {
TimelineAppData *data =... |
start, angle_end);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_arc_origin_aa_letter_c.${BIT_DEPTH_NAME}.pbi"));
// More negative angle letter C (both angle are actually negative)
angle_end -= TRIG_MAX_ANGLE;
angle_start -= TRIG_MAX_ANGLE;
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLI... | (&ctx, fb) | ;
// Letter C
uint32_t angle_end = TRIG_MAX_ANGLE + (TRIG_MAX_ANGLE / 8);
uint32_t angle_start = (TRIG_MAX_ANGLE / 8) * 3;
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_context_set_fill_color(&ctx, GColorRed);
graphics_context_set_stroke_color(&ctx, GColorGreen);
... |
-------------
// Open the session file, creating it if necessary. If space_needed is > 0, then make sure there is
// enough space in the file to add 'space_needed' more bytes, compacting, growing, or lopping off
// older data in the file if necessary. Returns true if there is enough space and the file was
// successful... | prv_open_file(&session->storage, OP_FLAG_WRITE | OP_FLAG_READ, DLS_FILE_INIT_SIZE_BYTES,
session) | ;
exit:
// If success, double-check that we have enough space.
if (success && space_needed > 0) {
file_size = prv_pfs_get_file_size(session->storage.fd);
PBL_ASSERTN(session->storage.write_offset + space_needed <= file_size);
}
return success;
}
// ----------------------------------------------------... |
}
// -----------------------------------------------------------------------------------------------
static bool prv_protocol_send_err_response(CommSession *session, int8_t transaction_id,
GetBytesInfoErrorCode result) {
const GetBytesRspObjectInfo rsp = (const GetBytesRsp... | // If timeout, try again
// MT: What if the session got disconnected?
system_task_add_callback(prv_protocol_send_next_chunk, state);
return;
}
if (state->sent_header) {
// Send next chunk of data
GetBytesRspObjectData* rsp = (GetBytesRspObjectData *) kernel_zalloc_check(packet_len);
*rs... |
s_get_bytes_in_progress = false;
prv_put_status_event(DebugInfoStateFinished);
comm_session_set_responsiveness(state->session, BtConsumerPpGetBytes, ResponseTimeMax, 0);
return;
} else {
comm_session_set_responsiveness(state->session, BtConsumerPpGetBytes, ResponseTimeMin,
... |
rt(uuid_equal(&u, &e3.header.id));
// Add a new notification with the same ANCS UID as an existing notification to make sure we
// return the new notification instead of the old one
TimelineItem e4 = e3;
uuid_generate(&e4.header.id);
notification_storage_store(&e4);
cl_assert(notification_storage_find_ancs... | notification_storage_store(&e3) | ;
cl_assert_equal_b(notification_storage_get(&i3, &r), false);
Uuid i4;
uuid_generate(&i4);
TimelineItem e4 = e1;
e4.header.id = i4;
e4.header.layout = NumLayoutIds;
notification_storage_store(&e4);
cl_assert_equal_b(notification_storage_get(&i4, &r), false);
}
|
/*
* 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... | {
// zone 0 - b
return GPoint(frame.origin.x + DIV_X(frame.size.w * (500 + (MULT_X(cur, limit_b) / 2))),
frame.origin.y);
} | else if (cur <= limit_c) {
// zone b - c
return GPoint(frame.origin.x + frame.size.w,
frame.origin.y +
DIV_X(frame.size.h * MULT_X((cur - limit_b), (limit_c - limit_b))));
} else if (cur <= limit_d) {
// zone c - d
return GPoint(frame.origin.x +
... |
0xed},
.sdk_version = {TIMELINE_RESOURCE_PBW_SUPPORT_FIRST_SDK_VERSION_MAJOR,
TIMELINE_RESOURCE_PBW_SUPPORT_FIRST_SDK_VERSION_MINOR},
},
// No resource_lut specified because this app has an "invalid" lut
},
{
.install_entry = {
.install_id = TimelineResourceTestAppId_Ap... | (TIMELINE_RESOURCE_INVALID, TimelineResourceSizeTiny,
TimelineResourceTestAppId_ValidApp, &res_info) | );
// Calling the function with an invalid size should return false
cl_assert(!timeline_resources_get_id_system(
(TimelineResourceId)TimelineResourceTestTimelineId_AlarmClock, TimelineResourceSizeCount,
TimelineResourceTestAppId_ValidApp, &res_info));
// Calling the function with the ResAppNum of an... |
const char *label) {
switch (action->type) {
case TimelineItemActionTypeOpenPin:
case TimelineItemActionTypeOpenWatchApp:
prv_invoke_local_action(action, pin);
return NULL;
case TimelineItemActionTypeAncsResponse:
case TimelineItemActionTypeAncsGeneric:
case Ti... | (action_menu, action, pin, item->label) | ;
}
static void prv_invoke_voice_response(VoiceResponseData *voice_data, char *transcription) {
// This is a bit of a hack, but we need all the behaviour of timeline_actions_invoke_action and
// this allows voice responses to be used for other types of responses (i.e. ANCS in the future)
ActionMenuItem item = {
... |
or(ctx, bg_color);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y));
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1));
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
} else if (alpha == ALPHA_0) {
graphics_context_set_stroke_color(ctx, bg_color);
graphics_draw_pixel(ctx, p... | if (s_color_table == color_table_hsv) {
s_color_table = color_table_hvs;
} else if (s_color_table == color_table_hvs) {
s_color_table = color_table_hsv;
} | |
_valid_key = oldest_valid_key,
.newest_valid_key = newest_valid_key,
.watchdog_kicks_left = max_records,
};
// Rewrite the settings file, keeping only the keys we need
PBL_LOG(LOG_LEVEL_DEBUG, "Compacting minute file down to %"PRIu16" records", max_records);
status_t status = settings_file_rewrite_filt... | prv_minute_data_file_close(minute_file) | ;
}
return success;
}
// -------------------------------------------------------------------------------------
static DataLoggingSession *prv_get_dls_minute_session(void) {
// Open up the data logging session if we don't have one
if (s_alg_state->dls_session == NULL) {
// We don't need to be buffered sinc... |
r_and_update_mask(ctx, y1.integer, x, x, color,
(uint8_t)(FIXED_S16_3_ONE.raw_value - y1.fraction));
y1.integer++;
}
// middle pixels
while (y1.integer <= y2.integer) {
prv_update_mask(ctx, y1.integer, x, x, color);
y1.integer++;
}
// last pixel with blending ... | prv_blend_color_and_update_mask(ctx, y, x1.integer, x1.integer, color, (uint8_t)x2.fraction) | ;
}
// or last AA gradient with blending
} else {
for (int i = 0; i < right_aa_offset; i++) {
if (x1.integer > clip_box_max_x) {
break;
}
prv_blend_color_and_update_mask(ctx, y, x1.integer, x1.integer, color,
(uint8_t)(FIXED_S16_3_ONE.raw_val... |
/*
* 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... | (&hdr1.common.id) | ;
SerializedTimelineItemHeader hdr2 = {
.common = {
.ancs_uid = 1,
.layout = 0,
.flags = 0,
.timestamp = 0,
},
};
uuid_generate(&hdr2.common.id);
SerializedTimelineItemHeader hdr3 = {
.common = {
.ancs_uid = 1,
.layout = 0,
.flags = 0,
.timestamp = 0,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | { -24, 448, -936},
{ -24, 424, -904},
{ -16, 448, -912},
{ -16, 456, -928},
{ -24, 432, -920},
{ -8, 424, -896},
{ -16, 464, -904},
{ -16, 440, -904},
{ -32, 448, -920},
{ -16, 440, -920},
{ -8, 464, -928},
{ -8, 448, -920},
{ -24, 440, -896},
{ -24, 432, -912},
... |
{ -16, 440, -904},
{ -16, 448, -904},
{ -8, 448, -904},
{ 0, 432, -912},
// 5 seconds
{ -16, 432, -904},
{ -16, 448, -912},
{ -8, 472, -904},
{ -8, 456, -912},
{ -8, 448, -904},
{ -8, 448, -912},
{ -8, 448, -904},
{ -8, 448, -904},
{ -8, 448, -904},
{ -8, 456... |
me.tm_wday;
if (!curr_schedule_enabled) { // Only next schedule is enabled
is_enable_next = true;
// Depending on the current schedule, determine the first day index of the next schedule
int next_schedule_day = (curr_schedule_type == WeekdaySchedule) ? Saturday : Monday;
// Count the number of full da... | {
prv_toggle_manual_dnd_from_settings_menu(NULL);
} | else {
prv_toggle_manual_dnd_from_action_menu(NULL);
}
}
}
bool do_not_disturb_is_smart_dnd_enabled(void) {
return alerts_preferences_dnd_is_smart_enabled();
}
void do_not_disturb_toggle_smart_dnd(void) {
if (!alerts_preferences_check_and_set_first_use_complete(FirstUseSourceSmartDND)) {
prv_push... |
F7
{ .start = (void *)RAMDTCM_BASE, .length = (uint32_t)__DTCM_RAM_size__ },
#endif
{ .start = (void *)RCC, .length = sizeof(*RCC) },
{ .start = (void *)&NVIC->ISER, .length = sizeof(NVIC->ISER) }, // Enabled interrupts
{ .start = (void *)&NVIC->ISPR, .length = sizeof(NVIC->ISPR) }, // Pending interrupts
{ ... | (&s_stash_data.rcc, RCC, sizeof(RCC_TypeDef)) | ;
memcpy(&s_stash_data.spi1, SPI1, sizeof(SPI_TypeDef));
}
// -----------------------------------------------------------------------------------------------
// Return the start address of the flash region containing the core dump image. We write the core image to
// different regions in flash to avoid premature bur... |
lude "stubs_regular_timer.h"
#include "stubs_serial.h"
#include "stubs_session.h"
#include "stubs_sleep.h"
#include "stubs_system_reset.h"
#include "stubs_task_watchdog.h"
#include "stubs_memory_layout.h"
static bool s_prefs_24h_style;
#define TIMEZONE_FIXTURE_PATH "timezones"
// Setup
/////////////////////////
void... | (jan1st_noon_2005) | ;
cl_assert_equal_i(rtc_get_time(), jan1st_noon_2005);
if (tzinfo.dst_start <= rtc_get_time() && rtc_get_time() < tzinfo.dst_end) {
cl_assert_equal_i(time_utc_to_local(rtc_get_time()), jan1st_noon_2005 + time_get_dstoffset());
} else {
cl_assert_equal_i(time_utc_to_local(rtc_get_time()), jan1st_... |
either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hc_protocol/hc_endpoint_analytics.h"
#include "host_transport_protocol.h"
#include "connection.h"
#include "dialog_analytics/analytics.h"
#include "host_transport.h"
#incl... | memcpy(info.build_id, &DIALOG_BUILD_ID.data[DIALOG_BUILD_ID.name_length], BUILD_ID_EXPECTED_LEN) | |
ert.h"
#include "stubs_process_manager.h"
/////////////////////////////
const void * const g_gbitmap_spalding_data_row_infos = &g_gbitmap_spalding_data_row_infos;
void test_gbitmap_formats__create_blank(void) {
const GSize s10 = GSize(10, 10);
const GSize s180 = GSize(180, 180);
GBitmap *bmp = NULL;
cl_asse... | cl_assert(p == gbitmap_get_palette(bmp)) | ;
bmp = gbitmap_create_blank_with_palette(s10, GBitmapFormat2BitPalette, p, true);
cl_assert(NULL != bmp);
cl_assert(p == gbitmap_get_palette(bmp));
bmp = gbitmap_create_blank_with_palette(s10, GBitmapFormat4BitPalette, p, true);
cl_assert(NULL == bmp);
cl_assert(NULL == gbitmap_create_blank_with_palette... |
st_reel), ANIMATION_DURATION_INFINITE);
}
void test_kino_player__create_finite_animation_infinite_reel_reverse(void) {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = ANIMATION_DURATION_INFINITE;
Animation *... | (test_player->reel, NULL) | ;
cl_assert_equal_i(s_num_destructor_calls, 1);
kino_player_set_reel(test_player, NULL, true);
cl_assert_equal_p(test_player->reel, NULL);
cl_assert_equal_i(s_num_destructor_calls, 1);
test_reel = NULL;
}
void test_kino_player__set_reel_does_not_call_destructor(void) {
test_player->owns_reel = false;
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "HCI CMD Received:") | ;
PBL_HEXDUMP(LOG_LEVEL_DEBUG, (uint8_t *)msg, msg->message_length);
hci_cmd_msg_t *hci_cmd = (hci_cmd_msg_t *)&msg->payload[0];
uint16_t opcode = hci_cmd->op_code;
hci_rom_passthrough_send_cmd(
HCI_OP2OGF(opcode), HCI_OP2OCF(opcode), &hci_cmd->param[0],
hci_cmd->param_length);
}
void hc_endpoint... |
/*
* 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... | (window, false /* animated */) | ;
}
static void prv_view_model_did_change(ActionMenuData *data) {
ActionMenuViewModel *vm = &data->view_model;
const ActionMenuLevel *cur_level = vm->cur_level;
GRect frame = grect_inset(data->action_menu.window.layer.frame, vm->menu_insets);
layer_set_frame(&data->action_menu_layer.layer, &frame);
if (cur_l... |
_ticks = 0;
if (++s_check_counter < 10) {
// Just check occasionally so we don't incur the overhead of reading the RTC on every
// systick
return false;
}
s_check_counter = 0;
// Compute what ticks should be based on the real time clock.
time_t seconds;
uint16_t milliseconds;
rtc_get_time_ms... | analytics_set(ANALYTICS_APP_METRIC_BG_CPU_RUNNING_TIME, awake_ms, AnalyticsClient_Worker) | ;
analytics_set(ANALYTICS_APP_METRIC_BG_CPU_SLEEP_TIME, sleep_ms, AnalyticsClient_Worker);
analytics_set(ANALYTICS_APP_METRIC_BG_CPU_STOP_TIME, stop_ms, AnalyticsClient_Worker);
}
s_last_ticks = now_ticks;
s_analytics_app_sleep_cpu_cycles = 0;
s_analytics_app_stop_ticks = 0;
}
|
font(FONT_KEY_GOTHIC_24_BOLD);
const GSize title_text_size = GSize(window_bounds.size.w, fonts_get_font_height(title_text_font));
const GFont info_text_font = fonts_get_system_font(FONT_KEY_GOTHIC_14);
const GSize info_text_size = GSize(window_bounds.size.w, fonts_get_font_height(info_text_font));
const int16_t... | ("Do you want to shut down?", a_dialog) | |
cl_assert(timeline_add(&item1)) | ;
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(5*60, stub_new_timer_timeout(timer_id) / 1000);
cl_assert(timeline_remove(&item1.header.id));
timeline_event_han... | |
d test_recognizer_manager__fail_recognizer(void) {
NEW_RECOGNIZER(r1) = test_recognizer_create(&s_test_impl_data, NULL);
NEW_RECOGNIZER(r2) = test_recognizer_create(&s_test_impl_data, NULL);
r2->state = RecognizerState_Started;
// copied from recognizer_manager.c
struct FailRecognizerCtx {
Recognizer *tr... | (recognizers, k_rec_count, RecognizerState_Possible) | ;
prv_cancel_layer_tree_recognizers(&manager, NULL, &layer_c);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[2]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, Reco... |
pbi"));
}
void test_graphics_draw_rotated_bitmap__origin_color_set(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
... | (&ctx, test_image_color,
GPoint(1, 30), DEG_TO_TRIGANGLE(2), GPoint(72, 84)) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_offset_leftedge_2.Xbit.pbi"));
// right edge center rotation point, Angle 2
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_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... | (buffer, data->duration_string, buffer_size) | |
data->read_cursor, true, NULL);
if (metadata_bytes <= 0) {
goto cleanup;
}
buffer = applib_zalloc(metadata_bytes);
if (buffer == NULL) {
goto cleanup;
}
ResAppNum app_num = sys_get_current_resource_num();
const size_t bytes_read = sys_resource_load_range(
app_num, bitmap_sequence->resourc... | if (png_format >= UPNG_INDEXED1 && png_format <= UPNG_INDEXED8) {
const GColor8 *palette = png_decoder_data->palette;
for (uint32_t y = 0; y < fctl.height; y++) {
const uint16_t corrected_dst_y = fctl.y_offset + y + bitmap->bounds.origin.y;
const GBitmapDataRowInfo row_info = gbitmap_get_data_row_i... |
// for each pixel in this frame, clipping to the bitmap geometry
for (int32_t x = MAX(0, row_info.min_x - delta_x);
x < MIN((int32_t)fctl.width, row_info.max_x - delta_x + 1);
x++) {
const uint32_t corrected_dst_x = x + delta_x;
uint8_t channel = raw_image_get_value_f... |
id *)next_cursor > iter->end) {
return NULL;
}
return iter->cursor;
}
Tuple * dict_read_begin_from_buffer(DictionaryIterator *iter, const uint8_t * const buffer, const uint16_t length) {
const DictionaryResult result = dict_init(iter, buffer, length);
if (result != DICT_OK) {
return NULL;
}
return ... | {
return dict_serialize_tuplets_to_buffer_with_iter(iter,
tuplets, tuplets_count, buffer, size_in_out);
} |
DictionaryResult dict_serialize_tuplets_to_buffer(const Tuplet * const tuplets, const uint8_t tuplets_count, uint8_t *buffer, uint32_t *size_in_out) {
DictionaryIterator iter;
return dict_serialize_tuplets_to_buffer_with_iter(&iter, tuplets, tuplets_count, buffer, size_in_out);
}
// Legacy version to prevent p... |
/*
* 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... | comm_session_get_system_session() | ;
if (system_session) {
// Are we idle?
bool idle = (battery_is_usb_connected() || accel_is_idle());
PingMsgV2 ping_msg = (PingMsgV2) {
.hdr = {
.cmd = 0,
.cookie = htonl(42)
},
.idle = idle
};
bool success = comm_session_send_data(system_session, PING_ENDPOINT,
... |
a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for ... | grect_get_max_y(&dest_rect) | ;
const uint8_t num_dest_blocks_per_row = (dest_end_x / 32) +
((dest_end_x % 32) ? 1 : 0) - dest_begin_x;
const GColor *palette = src_bitmap->palette;
const uint8_t *src = src_bitmap->addr;
const uint8_t src_bpp = gbitmap_get_bits_per_pixel(gbitmap_get_format(src_bitmap));
const uint8_t src_palette_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... | memcpy(buf, (void *)address, length) | |
local_addr_type, &connection_params,
gap_le_connect_bluetopia_connection_callback,
0 /* callback context: unused */);
if (r) {
PBL_LOG(LOG_LEVEL_ERROR, "GAP_LE_Create_Connection (r=%d)", r);
} else {
s_has... | {
return (GAPLEConnectionIntent *) list_find(&s_intents->node,
prv_intent_filter_by_device,
(void *) device);
} |
static bool prv_intent_filter_by_bonding_id(ListNode *node, void *data) {
const BTBondingID bonding_id = (BTBondingID) (uintptr_t) data;
const GAPLEConnectionIntent *intent = (const GAPLEConnectionIntent *) node;
if (!intent->is_bonding_based) {
return false;
}
return (intent->bonding->id == bonding_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... | strncpy(buffer, i18n_get(string, NULL), length) | ;
}
size_t i18n_get_length(const char *string) {
return strlen(i18n_get(string, NULL));
}
void i18n_free(const char *original, const void *owner) {
}
void i18n_free_all(const void *owner) {
}
void sys_i18n_get_with_buffer(const char *string, char *buffer, size_t length) {
i18n_get_with_buffer(string, buffer, le... |
_flash_file(start_page); // on failure, unallocate
return (rv);
}
pg_hdr.next_page_crc = crc8_next_page(next_page);
pg_hdr.next_page = next_page;
write_pg_header(&pg_hdr, curr_page);
curr_page = next_page;
// continuation page header settings
memset(&pg_hdr, 0xff, size... | strcmp(f->name, name) | |
1
#define TIMEOUT_MS 100
//! The largest message for attributes which we support internally (the app has its own buffer)
#define BUFFER_LENGTH 20
#define MIN_SERVICE_DISCOVERY_INTERVAL 1
typedef struct {
uint16_t service_id;
uint16_t attribute_id;
} ReadInfo;
typedef... | if (!success) {
PBL_LOG(LOG_LEVEL_DEBUG, "Read of management attribute was not successful (0x%x)", attr);
return false;
} |
if (attr == ManagementServiceAttributeServiceDiscovery) {
if (length % sizeof(uint16_t)) {
PBL_LOG(LOG_LEVEL_WARNING, "Service discovery response is invalid length: %"PRIu32, length);
return false;
}
// validate and mark the services as connected
uint32_t i;
uint16_t *services = data;... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (s_fetch_state.app) {
percent += 30;
} |
if (s_fetch_state.worker) {
percent += 10;
}
if (s_fetch_state.resources) {
percent += 60;
}
// add in the progress for the currently transferring piece.
percent += (type_percent / 3);
// store value
return MIN(100, percent);
}
//! Cleans up the state of the app fetch endpoint. Always called... |
ion_buf_size)) {
PBL_LOG(LOG_LEVEL_ERROR, "Unable to get Region Table");
goto spi_failed;
}
memcpy(region_buf, s_rx_buffer, region_buf_size);
// Dump the memory region table
for (int index = 0; index < MemoryRegionTagCount; ++index) {
PBL_LOG(LOG_LEVEL_ERROR, "Memory Region %d: %p - 0x%lx", index, ... | PBL_LOG(LOG_LEVEL_ERROR, "Unable to get Extra Thread Info");
goto spi_failed;
}
flash_write_bytes((const uint8_t *)&chunk_hdr, flash_addr, sizeof(chunk_hdr));
flash_addr += sizeof(chunk_hdr);
flash_write_bytes(s_rx_buffer, flash_addr, sizeof(CoreDumpExtraRegInfo));
flash_addr += sizeof(CoreDumpExtraRe... |
// NB: this function runs on the host_transport thread (BTTrans).
static void prv_core_dump(void) {
// Disable host-transport's use of SPI & interrupts
dialog_spi_deinit();
s_spi_dma_semph = xSemaphoreCreateBinary();
s_spi_int_semph = xSemaphoreCreateBinary();
// Enable SPI. Use our own interrupt handler.... |
if (key_len != UUID_SIZE ||
val_len != sizeof(AppDBEntry)) {
return E_INVALID_ARGUMENT;
} |
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
return rv;
}
PBL_ASSERTN(key_len == 16);
PBL_ASSERTN(val_len > 0);
bool new_install = false;
AppInstallId app_id = prv_find_install_id_for_uuid(&s_app_db.settings_file, (const Uuid *)key);
if (app_id == INSTALL_ID_INVALID) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.