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... | sys_ble_characteristic_get_properties(characteristic) | &
BLEAttributePropertyIndicate);
}
|
ck.h"
#include "stubs_watchface.h"
#include "stubs_worker_manager.h"
#include "stubs_worker_state.h"
char __APP_RAM__[1024*128];
char *__APP_RAM_end__ = &__APP_RAM__[1024*128];
char __WORKER_RAM__[1024*12];
char *__WORKER_RAM_end__ = &__APP_RAM__[1024*12];
typedef struct {
AppInstallEntry entry;
bool should_pass;... | cl_fail("unexpected") | ; }
void event_reset_from_process_queue(PebbleTask task) { cl_fail("unexpected"); }
void test_process_manager__initialize(void) {
s_app_install_get_md__result = NULL;
s_process_metadata_get_res_bank_num__result = 123;
s_rocky_app_validate_resources__result = RockyResourceValidation_NotRocky;
s_app_manager_lau... |
= {0};
snprintf(unit_test_result_image_file_base_name, PATH_STRING_LENGTH,
"%s_%s", unit_test_name, test_data->test_name);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap,
namecat(unit_test_result_image_file_base_name, ".pbi")));
if (test_data->need_to_destroy_bitmap) {
gbitma... | prv_composite_test(__func__, GCompOpAssignInverted) | ;
}
void test_graphics_draw_bitmap__composite_or(void) {
prv_composite_test(__func__, GCompOpOr);
}
void test_graphics_draw_bitmap__composite_and(void) {
prv_composite_test(__func__, GCompOpAnd);
}
void test_graphics_draw_bitmap__composite_clear(void) {
prv_composite_test(__func__, GCompOpClear);
}
void test_... |
= gap_le_connection_by_gatt_id(TEST_GATT_CONNECTION_ID);
// Expect one service, Blood Pressure:
cl_assert_equal_i(list_count(&connection->gatt_remote_services->node), 1);
fake_event_clear_last();
// Re-discovery:
cl_assert_equal_i(gatt_client_discovery_rediscover_all(&device), BTErrnoOK);
// Expect "Data... | fake_gatt_put_discovery_complete_event(GATT_SERVICE_DISCOVERY_STATUS_SUCCESS,
TEST_GATT_CONNECTION_ID) | ;
// Only one event should have been pended since we were not rediscovering the
// same handle range
cl_assert_equal_i(1, fake_event_get_count());
prv_assert_event(&device, BTErrnoOK);
// Nothing discovered for final query
fake_gatt_put_discovery_complete_event(GATT_SERVICE_DISCOVERY_STATUS_SUCCESS,
... |
HOW_BEFORE_TIME_S;
CHECK_EVENT( .count = 3, .item_id = item->header.id, .num_concurrent = 0,
.timeout_ms = timeout_s * MS_PER_SECOND,
.time_type = TimelinePeekTimeType_ShowWillStart, .is_first_event = true );
prv_invoke_timer(timeout_s);
timeout_s = item->header.duration * SECONDS_PE... | (timeout_s) | ;
timeout_s = TIMELINE_PEEK_HIDE_AFTER_TIME_S;
CHECK_EVENT( .count = 5, .item_id = item->header.id, .num_concurrent = 0,
.timeout_ms = timeout_s * MS_PER_SECOND,
.time_type = TimelinePeekTimeType_ShowStarted, .is_first_event = true );
prv_invoke_timer(timeout_s);
item = &s_back_to_... |
k used
// by the task.
// The information for this task is going to be incorrect: the values of
// R4-R11 will be completely bogus. The only way to recover them is to
// properly unwind the full exception stack in a debugger with unwind
// information available. Unfortunately mainline GDB ... | (&temp, s_flash_addr,
sizeof(temp)) | ;
watchdog_feed();
}
} else {
uint32_t bytes_remaining = regions[i].length;
for (uint32_t offset = 0; offset < regions[i].length; offset += SECTOR_SIZE_BYTES) {
uint32_t bytes_to_write = MIN(bytes_remaining, SECTOR_SIZE_BYTES);
s_flash_addr += prv_flash_write_bytes(
... |
address. Otherwise, we'd need to
// send a repeated start, which we don't want to do.
const bool reload = bus->state->transfer.direction == I2CTransferDirection_Write;
bus->hal->i2c->CR2 = (bus->state->transfer.device_address & I2C_CR2_SADD) |
(1 << CR2_NBYTES_OFFSET) |
... | (bus, I2CTransferEvent_Error) | ;
}
void i2c_hal_event_irq_handler(I2CBus *bus) {
portEND_SWITCHING_ISR(prv_event_irq_handler(bus));
}
void i2c_hal_error_irq_handler(I2CBus *bus) {
portEND_SWITCHING_ISR(prv_error_irq_handler(bus));
}
|
/*
* 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... | (&ICE40LP->creset, true) | |
under the License.
*/
#include "../bitblt_private.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/profiler.h"
#include "util/graphics.h"
#include "util/bitset.h"
#include "util/math.h"
#if !defined(__clang__)
#pragma GCC optimize("O2")
#endif
// Size is based on color palette
#define L... | raw_image_get_value_for_bitdepth(src, src_x, 0, 0, src_bpp) | ;
GColor src_color = palette[cindex];
GColor dest_color = (GColor) dest[dest_x];
switch (compositing_mode) {
case GCompOpAssign:
dest[dest_x] = src_color.argb;
break;
case GCompOpSet:
dest[dest_x] = gcolor_alpha_blend(src_color, dest_color).argb;
... |
alid);
cl_assert_equal_b(pairing_info->is_remote_identity_info_valid,
pairing_info_out.is_remote_identity_info_valid);
cl_assert_equal_b(pairing_info->is_remote_encryption_info_valid,
pairing_info_out.is_remote_encryption_info_valid);
cl_assert_equal_b(pairing_info->is_loca... | memset(device_name_out, 0, BT_DEVICE_NAME_BUFFER_SIZE) | ;
SM128BitKey link_key_out = {};
uint8_t platform_bits_out = 0;
cl_assert_equal_p(shared_prf_storage_get_bt_classic_pairing_data(&out_addr, device_name_out,
&link_key_out,
&platfor... |
/*
* 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... | (&versions_msg.running_fw_metadata) | ;
prv_fixup_running_firmware_metadata(&versions_msg.running_fw_metadata);
version_copy_recovery_fw_metadata(&versions_msg.recovery_fw_metadata);
prv_fixup_firmware_metadata(&versions_msg.recovery_fw_metadata);
// Note: Don't worry about the null terminator if it doesn't fit, the other side should deal with it... |
ropery CESU-8 => UTF-8 conversion.
jerry_size_t jerry_object_to_string_to_char_buffer(const jerry_value_t object,
jerry_char_t *buffer_p,
jerry_size_t buffer_size) {
return jerry_object_to_string_to_utf8_char_buffer(... | __jerryRefs.ref(rv) | ;
}, value);
}
jerry_value_t jerry_value_to_string(const jerry_value_t value) {
if (jerry_value_has_error_flag(value)) {
return TYPE_ERROR_FLAG;
}
return (jerry_value_t)EM_ASM_INT({
return __jerryRefs.ref(String(__jerryRefs.get($0)));
}, value);
}
int jerry_obj_refcount(jerry_value_t o) {
re... |
/*
* 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... | (s_output, 'Z', sizeof(s_output)) | ;
template_string_evaluate(s_truncation_tests[i].instr, s_output, s_truncation_tests[i].size,
&cond, &vars, &err);
cl_assert_equal_s(s_output, s_truncation_tests[i].output);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
... |
e_remove_info->num_descriptors +
service_remove_info->num_characteristics;
service_remove_info =
(PebbleBLEGATTClientServiceHandles *)&service_remove_info->char_and_desc_handles[num_hdls];
}
}
static void prv_handle_all_services_invalidated(void) {
for (int c = 0; c < KernelLEClientNum; c++) {
... | {
for (int c = 0; c < KernelLEClientNum; ++c) {
const KernelLEClient * const client = &s_clients[c];
if (client->can_handle_characteristic && client->can_handle_characteristic(characteristic)) {
return client;
}
}
return NULL;
} |
typedef void (*ConsumeFuncPtr)(BLECharacteristic characteristic_ref,
uint8_t *value_out, uint16_t value_length, GAPLEClient client);
typedef void (*ReadNotifyHandler)(BLECharacteristic characteristic, const uint8_t *value,
size_t value_length, BLEGATTErro... |
ation_storage_get(const Uuid *id, TimelineItem *item_out) {
PBL_ASSERTN(item_out && (s_notif_storage_mutex != NULL));
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return false;
}
bool rv = true;
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
char uuid_string[UUID_STRING... | PBL_ASSERTN(s_notif_storage_mutex != NULL) | ;
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return false;
}
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
// Find the most recent notification which matches this ANCS UID - this will be the last entry in
// the db. iOS can reset ANCS UIDs on reconnect, so we want to a... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (bonding->name, name, BT_DEVICE_NAME_BUFFER_SIZE) | ;
s_head = (FakeBonding *) list_prepend(&s_head->node, &bonding->node);
return bonding->id;
}
BTBondingID bt_persistent_storage_store_ble_pairing(const SMPairingInfo *pairing_info, bool is_gateway,
const char *device_name, bool requires_address_pinning, uint8_t flags) {
const SMIdentityResolvingKey *I... |
, 296},
{ 1184, 400, 416},
{ 984, 432, 360},
{ 840, 280, 176},
{ 896, 392, 56},
{ 872, 488, 8},
{ 1112, 472, -48},
{ 1208, 512, 24},
{ 1664, 512, 104},
{ 1640, 528, 40},
{ 1088, 344, 48},
{ 1216, 224, 112},
{ 1416, 144, 256},
// 47 seconds
{ 1296, 104, 280},
{... | { 848, 512, -48},
{ 1088, 488, -48},
{ 1240, 392, 8},
{ 1776, 384, 80},
{ 1640, 464, 96},
{ 1016, 304, 56},
{ 1160, 192, 104},
{ 1400, 88, 208},
{ 1240, 104, 200},
{ 1080, 64, 176},
{ 968, 56, 128},
{ 856, 32, 136},
{ 832, 8, 136},
{ 784, 0, 88},
{ 744, -24, 4... |
{ 776, -40, 72},
{ 736, -64, 24},
{ 784, 16, -64},
{ 1112, -96, -48},
{ 1384, -136, 168},
{ 1184, 96, 104},
{ 1160, 248, -96},
{ 1296, 176, -16},
{ 1320, 152, 296},
{ 1320, 192, 272},
{ 1296, 584, 168},
{ 1072, 584, 144},
{ 880, 400, 64},
{ 872, 376, -16},
{ ... |
hrm_info.protocol_version_minor);
dict_write_uint8(app_data->out_iter, AppMessageKey_HRMSoftwareVersionMajor,
hrm_info.sw_version_major);
dict_write_uint8(app_data->out_iter, AppMessageKey_HRMSoftwareVersionMinor,
hrm_info.sw_version_minor);
di... | if (hrm->event_type == HRMEvent_SubscriptionExpiring) {
PBL_LOG(LOG_LEVEL_INFO, "Got subscription expiring event");
// Subscribe again if our subscription is expiring
const uint32_t update_time_s = 1;
app_data->session = sys_hrm_manager_app_subscribe(APP_ID_HRM_DEMO, update_time_s,
... |
}
}
static void prv_enable_hrm(void) {
AppData *app_data = app_state_get_user_data();
app_data->hrm_event_info = (EventServiceInfo) {
.type = PEBBLE_HRM_EVENT,
.handler = prv_handle_hrm_data,
};
event_service_client_subscribe(&app_data->hrm_event_info);
// TODO: Let the mobile app control this?
... |
cl_assert(s_manager_state_change);
cl_assert_equal_i(event_type, -1);
r->state = RecognizerState_Possible;
s_manager_state_change = false;
recognizer_transition_state(r, RecognizerState_Completed);
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert(s_manager_state_change);
cl_assert_equ... | (event_type, RecognizerEvent_Completed) | ;
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert(!s_manager_state_change);
r->state = RecognizerState_Possible;
recognizer_transition_state(r, RecognizerState_Completed);
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert(!s_manager_state_change);
}
void test_recognizer__... |
tack.h"
#include "applib/ui/window.h"
#include "applib/ui/window_private.h"
#include "applib/ui/path_layer.h"
#include "applib/ui/text_layer.h"
#include "kernel/pbl_malloc.h"
#include "mfg/mfg_info.h"
#include "process_state/app_state/app_state.h"
#include "process_management/pebble_process_md.h"
#include "util/bitset.... | text_layer_init(title, &window->layer.bounds) | ;
text_layer_set_font(title, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(title, GTextAlignmentCenter);
text_layer_set_text(title, "BUTTON TEST");
layer_add_child(&window->layer, &title->layer);
TextLayer *status = &data->status;
text_layer_init(status,
&... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (command, length) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERTN((addr & ERASE_FLAGS_MASK) == 0) | |
state = (AccelManagerState *)state->list_node.next;
continue;
}
// if subscribed but not looking for any samples then just drop the data
if (state->samples_per_update == 0) {
uint16_t len = shared_circular_buffer_get_read_space_remaining(
&s_buffer, &state->buffer_client.buffer_cli... | (&s_buffer, s_buffer_storage,
sizeof(s_buffer_storage)) | ;
event_service_init(PEBBLE_ACCEL_SHAKE_EVENT, &prv_shake_add_subscriber_cb,
&prv_shake_remove_subscriber_cb);
event_service_init(PEBBLE_ACCEL_DOUBLE_TAP_EVENT, &prv_double_tap_add_subscriber_cb,
&prv_double_tap_remove_subscriber_cb);
// we always listen for motion events to decide whether or not t... |
0; i < ARRAY_LENGTH(s_composite_tests); i++) {
const CompositeTest *test_data = &s_composite_tests[i];
// Skip invalid GBitmapFormat and GCompOp combinations
if (!prv_gbitmap_format_and_compositing_mode_combo_is_valid(
test_data->expected_test_image_bitmap_format, compositing_mode)) {
break;
... | (GPoint(25, 0)) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_layer_across_nx(void) {
prv_offset_layer_test(GPoint(-25, 0));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_layer_across_y(void) {
prv_offset_layer_t... |
- 1] = '\0';
}
}
static GTextNode *prv_create_pin_view_node(TimelineLayout *layout) {
const AttributeList *attributes = layout->layout_layer.attributes;
const size_t num_vertical_nodes = 3;
GTextNodeVertical *vertical_node = graphics_text_node_create_vertical(num_vertical_nodes);
const bool is_future = (la... | layout_create_text_node_from_config(
&layout->layout_layer, &secondary_config.text.extent.node) | ;
if (is_peek) {
secondary_node->node.offset = peek_text_offset;
secondary_node->max_size.w = peek_text_width;
} else {
secondary_node->text = secondary_text;
}
secondary_node->overflow = overflow;
graphics_text_node_container_add_child(&vertical_node->container, &secondary_node->n... |
/*
* 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... | (
task, (uint8_t *)buf + num_bytes -1, user_stack_end) | ) {
return;
}
APP_LOG(APP_LOG_LEVEL_ERROR, "syscall failure! %p..%p is not in app space.", buf, (char *)buf + num_bytes);
PBL_LOG(LOG_LEVEL_ERROR, "syscall failure! %p..%p is not in app space.", buf, (char *)buf + num_bytes);
syscall_failed();
}
// Drop privileges and return to the address stored in threa... |
/*
* 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(4, 16) | ;
GRect drawing_rect = grect_inset(layer->bounds, GEdgeInsets(0, rl_margin));
const GSize icon_size = kino_reel_get_size(icon);
const int icon_x = drawing_rect.origin.x + PBL_IF_RECT_ELSE(0, (rl_margin / 2))
+ (drawing_rect.size.w / 2) - (icon_size.w / 2);
const int icon_y = PBL_IF_RECT_ELS... |
// 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_confirm(app_node->install_id, true /* set as default */,
app_state_get_wi... | (&data->option_menu) | |
id timeline_layer_unfold_day_sep(TimelineLayer *timeline_layer) {
const bool slide = false;
prv_show_day_sep(timeline_layer, slide);
}
void timeline_layer_slide_day_sep(TimelineLayer *timeline_layer) {
const bool slide = true;
prv_show_day_sep(timeline_layer, slide);
}
static void prv_day_sep_anim_stopped(Ani... | {
kino_layer_rewind(&timeline_layer->end_of_timeline);
} | |
ining >= 2; bytes_remaining -= 2, buffer += 2) {
uint16_t buffer_word;
memcpy(&buffer_word, buffer, sizeof buffer_word);
*flash_write_dest++ = buffer_word;
}
// Handle trailing byte if present. This will be present if we started out
// aligned and we wrote an odd number of bytes or if we started out ... | if (flash_clock_freq < wait_cycle[wait_state-4]) {
break;
} |
}
return wait_state;
}
status_t flash_impl_set_burst_mode(bool burst_mode) {
const uint32_t MAX_FREQ = MHZ_TO_HZ(108); // max frequency of the flash 108MHZ
const uint32_t TAVDP_MIN = 60; // min addr setup time in tenths of ns
const uint32_t TADVO_MIN = 40; // min addr hold time in 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... | {
if (alert_mask == AlertMaskPhoneCalls) {
new_connectivity_icon_id = RESOURCE_ID_CONNECTIVITY_BLUETOOTH_CALLS_ONLY;
}
} | |
clear_handler_histories();
uint64_t start_ms = prv_now_ms();
// Create the animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
animation_set_delay(a, delay_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
animation_set_de... | (b, &implementation) | ;
animation_set_duration(b, duration_a);
animation_set_delay(b, delay_a);
animation_set_auto_destroy(b, auto_destroy);
animation_schedule(b);
Animation *c = prv_create_test_animation();
animation_set_duration(c, duration_a);
animation_set_delay(c, delay_a);
animation_set_auto_destroy(c, auto_destroy);
... |
/*
* 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... | CREATE_DMA_STREAM(1, 6) | ; // DMA1_STREAM6_DEVICE - Accessory UART RX
CREATE_DMA_STREAM(2, 0); // DMA2_STREAM0_DEVICE - Compositor DMA
CREATE_DMA_STREAM(2, 5); // DMA2_STREAM5_DEVICE - ICE40LP TX
// DMA Requests
static DMARequestState s_dbg_uart_dma_request_state;
static DMARequest DBG_UART_RX_DMA_REQUEST = {
.state = &s_dbg_uart_dma_reque... |
"License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
... | (wakeup_id) | , sys_get_time() + (i * WAKEUP_EVENT_WINDOW));
}
// Test that the 9th wakeup event fails to schedule (E_DOES_NOT_EXIST)
wakeup_id = sys_wakeup_schedule(sys_get_time() + ((MAX_WAKEUP_EVENTS_PER_APP + 1) * WAKEUP_EVENT_WINDOW), 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST);
}
void ... |
gothic_18_handle = RESOURCE_ID_GOTHIC_18;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
int8_t horiz_advance = text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info);
cl_assert(horiz_advance != 0);
cl_assert_equal_i(horiz_advance,
text_resources_get_glyph_ho... | cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info)) | ;
int8_t horiz_advance = text_resources_get_glyph_horiz_advance(&s_font_cache,
WILDCARD_CODEPOINT,
&s_font_info);
cl_assert(horiz_advance != 0);
cl_assert_equal_i(horiz_advance,
t... |
{
copied_points[i] = gpoint_add(points[i], offset);
}
return copied_points;
}
static bool prv_compare_points(GPoint *a, GPoint *b, uint16_t num_points) {
return (memcmp(a, b, sizeof(GPoint) * num_points) == 0);
}
// Stubs
void graphics_context_set_stroke_color(GContext* ctx, GColor color) {
s_stroke_color... | cl_assert(prv_compare_points(points, s_stroke_points, s_path_num_points)) | ;
cl_assert(prv_compare_points(points, s_fill_points, s_path_num_points));
prv_reset();
// set stroke width to zero - fill should be drawn, but not outline
gdraw_command_set_stroke_width(command, 0);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorClearARGB8);
cl_assert_eq... |
tPRIVILEGE_BIT);
PBL_LOG(LOG_LEVEL_DEBUG, "Ending App Throttling");
}
static void prv_app_task_throttle_start(void) {
static char last_throttled_task[configMAX_TASK_NAME_LEN];
const char *curr_task = pebble_task_get_name(PebbleTask_App);
// if an app results in system throttling, log it at the INFO level at l... | if (prescale != RCC_CFGR_PPRE1_DIV1) {
// per the stm32 'clock tree' diagram, if the prescaler for APBx is not 1, then
// the timer clock is at double the APBx frequency
timer_clock *= 2;
} | |
352, -968},
{ -168, 280, -992},
{ -120, 376, -960},
{ -152, 280, -1016},
{ -144, 328, -880},
{ -120, 288, -1032},
{ -192, 272, -880},
{ -112, 424, -1032},
{ -200, 296, -864},
{ -96, 312, -1072},
{ -216, 312, -928},
{ -160, 408, -1088},
{ -144, 312, -904},
{ -88, 352,... | { -160, 280, -928},
{ -112, 360, -960},
{ -144, 336, -1008},
{ -144, 312, -960},
{ -160, 312, -1024},
{ -160, 456, -992},
// 137 seconds
{ -160, 328, -896},
{ -80, 424, -1032},
{ -136, 336, -912},
{ -120, 392, -1056},
{ -152, 376, -888},
{ -112, 408, -1080},
{ -18... | |
31},
{ -889, 669, -9},
{ -963, 632, -12},
{ -844, 626, 39},
{ -667, 485, -50},
{ -481, 459, -127},
{ -405, 644, -178},
{ -361, 721, -238},
{ -252, 523, -269},
{ -175, 566, -325},
{ -313, 838, -429},
{ -563, 1197, -431},
{ -882, 1009, -503},
{ -577, 644, -495},
{ ... | { -484, 763, -1},
{ -455, 820, -53},
{ -510, 886, -83},
{ -580, 858, -81},
{ -657, 744, -142},
{ -514, 903, -134},
{ -528, 1209, -110},
{ -449, 1110, -112},
{ -591, 714, -244},
{ -735, 493, -140},
{ -905, 656, -73},
{ -752, 747, -86},
{ -545, 666, -141},
{ -440, 6... |
{ -677, 863, -115},
{ -604, 996, -98},
{ -630, 1125, -130},
{ -536, 812, -127},
{ -656, 576, -151},
{ -834, 491, -104},
{ -960, 625, -60},
{ -771, 607, -98},
{ -551, 560, -216},
{ -431, 572, -293},
{ -397, 589, -362},
{ -410, 599, -343},
{ -430, 530, -323},
{ -49... |
tions under the License.
*/
#include "pbl_malloc.h"
#include "kernel_heap.h"
#include "pebble_tasks.h"
#include "process_management/app_manager.h"
#include "process_state/app_state/app_state.h"
#include "process_state/worker_state/worker_state.h"
#include "system/passert.h"
#include "util/heap.h"
#include <string.... | heap_realloc(app_state_get_heap(), ptr, bytes, saved_lr) | ;
}
void *app_zalloc(size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_zalloc(app_state_get_heap(), size, saved_lr);
}
void *app_zalloc_check(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap = app_state_get_heap();
void *mem = ... |
/*
* 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_layer_set_text(&data->text_layer, TEXT_DELTA_BUF) | ;
data->gothic_14_bold = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
text_layer_set_font(&data->text_layer, data->gothic_14_bold);
text_layer_set_text_alignment(&data->text_layer, GTextAlignmentCenter);
data->line_spacing_delta = 0;
text_layer_set_line_spacing_delta(&data->text_layer, data->line_spacing_d... |
{ // Create a 2 hour session that starts before 12pm ==> should be regular sleep
ActivitySession sessions[] = {
{
.start_utc = start_of_today + (11 * SECONDS_PER_HOUR), // 11am
.length_min = 2 * MINUTES_PER_HOUR,
.type = ActivitySessionType_Sleep,
},
};
uint16_t session... | activity_algorithm_metrics_changed_notification() | ;
uint16_t steps_asleep_60m;
uint16_t steps_asleep_100m;
uint16_t steps_asleep_120m;
// Call the minute handler, which should zero out steps that occur while sleeping
prv_feed_minute_data(60, &minute_data[0], false /*simulate_bg_delays*/);
activity_algorithm_get_steps(&steps_asleep_60m);
prv_feed_minute... |
is_dst != was_dst) {
PebbleEvent e = {
.type = PEBBLE_SET_TIME_EVENT,
.set_time_info = {
.utc_time_delta = 0,
.gmt_offset_delta = 0,
.dst_changed = true,
}
};
event_put(&e);
s_dst_checker.cb_data = (void*)is_dst;
}
}
void clock_init(void) {
if (clock_is_tim... | (number_buffer, "", number_buffer_size) | ;
} else if (difference <= SECONDS_PER_HOUR) {
snprintf(number_buffer, number_buffer_size, "%ld", difference / SECONDS_PER_MINUTE);
i18n_get_with_buffer(" MIN. TO", word_buffer, word_buffer_size);
} else {
prv_copy_time_string_timestamp(number_buffer, number_buffer_size, word_buffer,
... |
/*
* 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(0 == strcmp(buf, "365")) | ;
itoa_int(-365, buf, 10);
cl_assert(0 == strcmp(buf, "-365"));
// max int32
itoa_int(2147483647, buf, 10);
cl_assert(0 == strcmp(buf, "2147483647"));
// min int32
itoa_int(-2147483647, buf, 10);
cl_assert(0 == strcmp(buf, "-2147483647"));
}
void test_string__test_byte_stream_to_hex_string(void) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (0b00111000, BITS_BETWEEN(3, 5)) | ;
cl_assert_equal_i(0b00010000, BITS_BETWEEN(4, 4));
}
// Flash memory is organized into twelve sectors of unequal sizes.
// Sectors 0-3 are 16 KiB. Sector 4 is 64 KiB.
// The remaining sectors are 128 KiB.
// Bitset of sectors that have been "erased"
static uint32_t erased_sector;
static bool flash_locked, flash_f... |
/*
* 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... | transcription_validate(validate_test, test_size) | ;
cl_assert_equal_p(result, false);
s_test_transcription_example[23] = 3; // restore word count of the second sentence
s_test_transcription_example[26] = 0; // invalidate word length of first word in second sentence
result = transcription_validate(validate_test, test_size);
cl_assert_equal_p(result, false)... |
h"
#include "process_management/app_manager.h"
#include "process_management/sdk_shims.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
typedef struct AppState {
Window window;
ScrollLayer scroll_layer;
TextLayer text_layer_1;
TextLayer text_layer_2;
TextLayer box;
} AppState;
st... | (window, data) | ;
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void handle_init(void) {
struct AppState* data = app_zalloc_check(sizeof(struct AppState));
app_... |
) {
ReliablePacket *packet = pulse_link_send_begin(
PULSE2_RELIABLE_TRANSPORT_RESPONSE);
packet->s = (struct ReliableSupervisoryPacket) {
.is_supervisory = true,
.kind = kind,
.poll_or_final = final,
.ack_number = s_receive_variable,
};
pulse_link_send(packet, sizeof(packet->s));
}
static... | system_task_add_callback(prv_send_port_closed_message,
(void *)bad_port) | |
alues are 1-4.
uint8_t ratio;
//! The binary value we need to put in the register to select the rail.
uint8_t source_config;
} PmicMonConfig;
// Using the Binary constants GCC extension here, supported in GCC and Clang
// https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html
static const PmicMonConfig MON_CO... | {
prv_mon_config_lock();
return prv_set_mon_config(&MON_CONFIG[PMIC_MON_CONFIG_VBAT_INDEX]);
// Don't prv_unlock, we don't want anyone else mucking with the mon config until
// pmic_disable_battery_measure is called.
} | |
w_utc - time_start) <= HS_MAX_MINUTE_DATA_SEC);
if (metric == HealthMetricHeartRateBPM) {
if (query_cur_minute) {
// If the client is querying the service for the most recent Stable/Median/Filtered value
// and it is within the last X minutes, return it. If it's older than X minutes, return 0.
... | if (scope == HealthServiceTimeScopeDailyWeekdayOrWeekend) {
if (is_weekend != prv_is_weekend(day)) {
continue;
}
}
if (prv_get_intraday_averages(state, metric, &averages, day)) {
result += prv_sum_intraday_averages(&averages, time_start, time_end);
... |
// ----------------------------------------------------------------------------------------------
bool health_service_events_subscribe(HealthEventHandler handler, void *context) {
#if !CAPABILITY_HAS_HEALTH_TRACKING
return false;
#else
HealthServiceState *state = prv_get_state(true);
if (!state) {
return fa... |
prv_timer_get_ticks();
while (prv_timer_check_delta(start_ticks, TIMER0_1_MS)) {};
}
static NORETURN prv_low_power_mode(void) {
// Give the host a few seconds to reboot the chip before we attempt to power everthing off (If
// everything gets powered off the BT reboot reason persisted in RAM (and flushed to anal... | if (tx_index == sizeof(core_dump_connect_response)) {
return true;
}
}
}
// Pulse the INT line to wake the host
host_transport_set_mcu_int(true);
prv_timer_delay_1ms(); // The timer IRQ just fired so the counter won't be near roll-over
host_transport_set_mcu_int(fals... | |
assert_nack_count(0);
}
void test_put_bytes__init_worker_okay_while_not_in_fw_update_mode(void) {
s_firmware_update_is_in_progress = false;
prv_receive_init_cookie(VALID_OBJECT_SIZE, ObjectWatchWorker, EXPECTED_COOKIE);
assert_ack_count(1);
assert_nack_count(0);
cl_assert_equal_i(EXPECTED_COOKIE, put_byte... | assert_nack_count(0) | ;
fake_pb_storage_mem_assert_contents_written(chunk, sizeof(chunk));
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_PUT_BYTES_EVENT);
cl_assert_equal_i(event.put_bytes.type, PebblePutBytesEventTypeProgress);
cl_assert_equal_i(event.put_bytes.object_type, ObjectFirmware);
c... |
(&ctx, GColorGreen) | ;
graphics_draw_arc_internal(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG, angle_start, angle_end);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_arc_origin_aa_letter_c_color_1px.8bit.pbi"));
// Letter C SW 4
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 4);
graphics_context_set_fil... | |
ecting();
}
// reconfig for the common subset of requirements among remaining subscribers
prv_update_driver_config();
}
mutex_unlock_recursive(s_accel_manager_mutex);
return event_outstanding;
}
DEFINE_SYSCALL(int, sys_accel_manager_set_sampling_rate,
AccelManagerState *state, AccelSa... | (&s_last_accel_data, &s_last_analytics_position) |
< ACCEL_MAX_IDLE_DELTA);
}
// The accelerometer should issue a shake/tap event with any slight movements when stationary.
// This will allow the watch to immediately return to normal mode, and attempt to reconnect to
// the phone.
void accel_enable_high_sensitivity(bool high_sensitivity) {
mutex_loc... |
tions under the License.
*/
#include "debug_db.h"
#include "drivers/flash.h"
#include "flash_region/flash_region.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/attributes.h"
#include "util/math.h"
#include "system/version.h"
#include <inttypes.h>
//! @file debug_db.c
//!
//! The flash sp... | {
*current_file_id = get_next_file_id(file_id[i - 1]);
} |
return;
}
if (i != 0) {
// If we find a reduction in an id, this is the end of the sequence and we've found
// the oldest file. For example, if the IDs are (5, 6, 3, 4), when we find three we'll
// see that the ids have stopped increasing. We should be using index 2 with an id of 7.
... |
get_time(), 1388563200);
sys_wakeup_cancel_all_for_app();
// Schedule a wakeup in 10 seconds
wakeup_id = sys_wakeup_schedule(sys_get_time() + 10, 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + 10);
// Cancel wakeup event
sys_wakeup_delete(wakeup_id);
cl_assert_equal_i(sys_wa... | sys_wakeup_cancel_all_for_app() | ;
// Schedule 1 event in a minute
time_t first_event = sys_get_time() + WAKEUP_EVENT_WINDOW;
WakeupId first_wakeup_id = sys_wakeup_schedule(first_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(first_wakeup_id), first_event);
TimerID first_timer = wakeup_get_current();
// Schedule another a minute a... |
ta, 0);
cl_assert(job);
gap_le_advert_deinit();
cl_assert_equal_i(s_unscheduled_cb_count, 1);
cl_assert_equal_p(s_unscheduled_job, job);
cl_assert_equal_b(s_unscheduled_completed, false);
cl_assert_equal_i(regular_timer_seconds_count(), 0);
free(ad);
}
void test_gap_le_advert__cant_schedule_after_deinit(... | cl_assert_equal_i(s_unscheduled_cb_count, 4) | ;
cl_assert_equal_b(gap_le_is_advertising_enabled(), false);
free(ad);
}
|
x - 1 < (int)ARRAY_LENGTH(s_rounded_corner_width)) {
return s_rounded_corner_width[num_rows - row_index - 1];
}
return 0;
}
void compositor_set_modal_transition_offset(GPoint modal_offset) {
s_animation_state.modal_offset = modal_offset;
}
void compositor_render_app(void) {
PBL_ASSERT_TASK(PebbleTask_Kern... | (compositor) | ;
framebuffer_dirty_all(&s_framebuffer);
}
void compositor_render_modal(void) {
GContext *ctx = kernel_ui_get_graphics_context();
// We make this GDrawState static to save stack space, thus the declaration and init must be
// performed on two separate lines because the initializer value is not constant
st... |
"
#include "stubs_tick.h"
void analytics_event_ams(uint8_t type, int32_t aux_info) {
}
struct {
ResponseTimeState state;
uint16_t max_period_secs;
} s_conn_mgr_states[NumBtConsumer];
void conn_mgr_set_ble_conn_response_time(GAPLEConnection *hdl, BtConsumer consumer,
Respo... | (music_get_connected_server_debug_name(), ams_music_server_debug_name()) | ;
// Rediscovery will disconnect music service (until resubscribed):
ams_invalidate_all_references();
prv_discover_ams(1 /* num_instances */);
cl_assert_equal_s(music_get_connected_server_debug_name(), NULL);
}
void test_ams__dont_connect_music_service_if_subscribe_entity_update_characteristic_fails(void) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ble_gap_conn_param_update(conn_idx, &conn_params) | |
h>
#include <clar.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
// Stubs & Fakes
#include "fake_event_service.h"
#include "fake_pebble_tasks.h"
#include "fake_pbl_malloc.h"
#include "fake_regular_timer.h"
#include "stubs_analytics.h"
#include "stubs_bt_lock... | callback(data) | ;
}
bool sys_hrm_manager_is_hrm_present(void) {
return true;
}
static int s_sys_hrm_manager_unsubscribe_call_count;
bool sys_hrm_manager_unsubscribe(HRMSessionRef session) {
++s_sys_hrm_manager_unsubscribe_call_count;
cl_assert_equal_i(session, s_last_session_ref);
return true;
}
////////////////////////////... |
turn the maximum rounded corner radius allowed for a given rectangle size
T_STATIC uint16_t prv_clamp_corner_radius(GSize size, GCornerMask corner_mask, uint16_t radius) {
if (corner_mask == GCornerNone) {
return 0;
}
int16_t min_size = MIN(size.w, size.h);
if (min_size >= 2 * radius) {
return radius;... | {
return;
} |
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
// Antialiased (not suppported on 1-bit color)
prv_fill_rect_aa(ctx, rect, radius, corner_mask, ctx->draw_state.fill_color);
return;
}
#endif
prv_fill_rect_non_aa(ctx, rect, radius, corner_mask, ctx->draw_state.fill_color);
}
void graphics_fill_round... |
d;
local_is_master = connection->local_is_master;
connected_device = &connection->device;
}
intent = prv_get_intent_by_bonding_id(request->bonding.id);
} else {
is_already_connected = gap_le_connection_is_connected(request->device);
intent = prv_get_intent_by_device(request->device);
}
... | (LOG_LEVEL_ERROR, "Ble disconnect failed: %d", result) | ;
}
} else {
if (prv_is_intent_using_whitelist(intent)) {
// Remove from white-list:
prv_mutate_whitelist_safely(device, false /* remove */);
}
}
}
if (should_send_disconnection_event) {
// Send virtual disconnection event:
const PebbleTaskBitset task_mask = ~gap_l... |
.dest_bitmap, "draw_round_rect_origin_rmax2_aa_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
#endif
}
void test_graphics_draw_round_rect_${BIT_DEPTH_NAME}__origin_radius_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_... | (&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11) | ;
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax2_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
}
#define OFFSET_RECT_NO_CLIP GRect(20, 10, 144, 168)
#define OFFSET_RECT_CLIP_XY GRect... |
/*
* 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... | (VibeScoreId_Invalid) | |
r = &data->name_text_layer;
text_layer_init_with_parameters(name_text_layer,
&data->launch_app_window.layer.frame,
NULL, fonts_get_system_font(name_font_key),
GColorBlack, name_bg_color, GTextAlignmentCenter,
... | (&data->button_combo_state, prv_select_combo_callback) | ;
prv_push_window(data);
}
static void handle_deinit(void) {
RecoveryFUAppData *data = app_state_get_user_data();
getting_started_button_combo_deinit(&data->button_combo_state);
kino_layer_deinit(&data->kino_layer);
event_service_client_unsubscribe(&data->pebble_mobile_app_event_info);
event_service_cl... |
sert_equal_s(dstbuf, "zero1");
// Length modifiers
int64_t hurf = 0x123456789ABCDEF0ULL;
snprintf(dstbuf, 256, "%hhd,%hd,%d,%ld", hurf, hurf, hurf, hurf);
cl_assert_equal_s(dstbuf, "-16,-8464,-1698898192,-1698898192");
snprintf(dstbuf, 256, "%lld,%jd", hurf, hurf);
cl_assert_equal_s(dstbuf, "13117684674637... | cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292") | ;
// Space for positive signed
// No signed conversion occurs, so this is a no-op
snprintf(dstbuf, 256, "There are % u lights, the absolute value of % u", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, the absolute value of 4294967292");
// Plus for positive signed
// No signed conversion occurs, ... |
GPoint){0}, GCompOpOr, GColorLightGray);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_compor-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Setup:
// - Source is a 1bit image of a white cross with a black background
// Result:
// - The image names describe the expected result of ea... | ("test_bitblt__1bit_to_8bit_wrap_x.1bit.pbi") | ;
uint8_t dest_data[100*100];
GBitmap dest_bitmap = {
.addr = dest_data,
.row_size_bytes = 100,
.info.format = GBitmapFormat8Bit,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = { { 0, 0 }, { 100, 100 } }
};
memset(dest_data, GColorBlue.argb, sizeof(dest_data));
GRect dest_rect = GRect... |
x_used_space));
cl_assert_equal_i(file.max_used_space, file_copy.max_used_space);
cl_assert_equal_i(file.max_space_total, file_copy.max_space_total);
cl_assert_equal_i(file.used_space, file_copy.used_space);
cl_assert_equal_i(file.dead_space, file_copy.dead_space);
}
void test_settings_file__max_storage(void) ... | set_and_verify(&file, key, key_len, big_val, 511) | ;
}
typedef enum {
RecordResultOld,
RecordResultNew,
RecordResultEnd,
} RecordResult;
static RecordResult write_and_change_record_aborting_after_bytes(int after_n_bytes) {
fake_spi_flash_init(0, 0x1000000);
// Wednesday (the 1st) at 00:00
// date -d "2014/01/01 00:00:00" "+%s" ==> 1388563200
fake_rtc_in... |
EventTypeTrackPosChanged);
char artist[MUSIC_BUFFER_LENGTH];
char album[MUSIC_BUFFER_LENGTH];
char title[MUSIC_BUFFER_LENGTH];
music_get_now_playing(title, artist, album);
cl_assert_equal_s(artist, "one");
cl_assert_equal_s(album, "two");
cl_assert_equal_s(title, "three");
uint32_t t... | (data_length, 1) | ;
if (!s_is_playback_cmd_sent) {
s_playback_cmd_sent = data[0];
s_is_playback_cmd_sent = true;
} else {
// Playback command is always followed by:
cl_assert_equal_i(data[0], 0x08); // MusicEndpointCmdIDGetAllInfo
}
}
// Tests
///////////////////////////////////////////////////////////
Transport... |
/*
* 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 RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER);
} | |
/*
* 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... | (fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
}
// Teardown
void test_graphics_draw_circle_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics... |
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(pin_config.gpio, &GPIO_InitStructure);
}
//! Configure bus pins for use by I2C peripheral
//! Lock bus and peripheral config access before configuring pins
static void bus_pin_cfg_i2c(AfConfig pin_config) {
GPIO_InitTypeDef gpio_init_struct;
gpio_init_s... | (RCC_APB1PeriphClockCmd, BOARD_CONFIG.i2c_bus_configs[bus_idx].clock_ctrl) | |
er, uint8_t size, time_t timestamp) {
struct tm time;
sys_localtime_r(×tamp, &time);
return clock_format_time(buffer, size, time.tm_hour, time.tm_min, true);
}
void clock_copy_time_string(char *buffer, uint8_t size) {
time_t t = sys_get_time();
clock_copy_time_string_timestamp(buffer, size, t);
}
stati... | {
time_t end_time = timestamp + duration * SECONDS_PER_MINUTE;
if (all_day) {
// all day event, multiday or single day
prv_get_relative_all_day_string(word_buffer, word_buffer_size, current_day);
strncpy(number_buffer, "", number_buffer_size);
} else if (time_util_get_midnight_of(timestamp) == current... | |
int8_t byte_in = spi_ll_slave_read_write(slave, byte_out);
if (inp) {
*(inp++) = byte_in;
}
}
}
void spi_ll_slave_burst_read_write_scatter(const SPISlavePort *slave,
const SPIScatterGather *sc_info,
size_t num_sg) {
... | (slave->slave_state->acquired) | ;
PBL_ASSERTN(slave->slave_state->dma_state == SPISlavePortDMAState_Idle);
slave->slave_state->dma_complete_handler = handler;
slave->slave_state->dma_complete_context = context;
if (out) {
dma_request_set_memory_increment_disabled(slave->tx_dma, false);
} else {
dma_request_set_memory_increment_disa... |
-184, 264, -888},
{ -152, 328, -1064},
{ -200, 408, -824},
{ -184, 304, -1024},
{ -200, 368, -976},
{ -144, 424, -976},
{ -240, 280, -976},
{ -176, 416, -960},
{ -176, 408, -912},
// 231 seconds
{ -200, 312, -904},
{ -184, 280, -1008},
{ -184, 312, -848},
{ -144, 352... | { -144, 416, -1072},
{ -216, 280, -920},
// 236 seconds
{ -144, 520, -1080},
{ -208, 200, -856},
{ -120, 560, -1128},
{ -248, 264, -1024},
{ -160, 440, -1048},
{ -224, 328, -928},
{ -152, 480, -1120},
{ -232, 344, -816},
{ -176, 504, -968},
{ -184, 328, -880},
{ -... |
{ -240, 384, -984},
{ -232, 416, -864},
{ -208, 440, -1040},
{ -272, 376, -744},
{ -160, 376, -888},
{ -192, 312, -872},
{ -208, 360, -896},
{ -168, 400, -896},
{ -160, 280, -960},
{ -120, 368, -984},
{ -136, 264, -1072},
{ -136, 352, -1032},
{ -136, 336, -1120},
... |
/*
* 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_app_outbox_sender_defs[tag].sent_handler == sent_handler) {
if (tag_out) {
*tag_out = tag;
}
return &s_app_outbox_sender_defs[tag];
}
} | |
r, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
PBL_ASSERTN(!auto_destroy);
return true;
}
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!prv_is_mutable(state, animation)) {
return false;
}
animation->au... | {
if (!animation_h) {
return false;
}
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_using_legacy_2(state)) {
// We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0... |
// -------------------------------------------------------------------------------------------
bool animation_set_handlers(Animation *animation_h, AnimationHandlers handlers,
void *context) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_us... |
h the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or... | prv_full_year(t->tm_year) | ;
const int hour_12h = (t->tm_hour % 12 == 0) ? 12 : (t->tm_hour % 12);
// Only use i18n if we're in the kernel, or the app locale is the system locale.
const bool use_i18n = !locale ||
(strncmp(locale, app_get_system_locale(), ISO_LOCALE_LENGTH) == 0);
while (left) {
// Copy up to ... |
nt s_system_font;
static GFont s_fonts[8];
static int s_font_selection = 0;
static const char* ALL_CODEPOINTS =
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿıŁłŒœŠšŸŽžƒˆˇ˘... | fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD) | ;
s_fonts[6] = fonts_get_system_font(FONT_KEY_GOTHIC_28);
s_fonts[7] = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
s_system_font = s_fonts[0];
struct AppState* data = app_malloc_check(sizeof(struct AppState));
app_state_set_user_data(data);
push_window(data);
}
static void handle_deinit(void) {
stru... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | fonts_get_font_height(text_font) | ;
const GTextOverflowMode text_overflow_mode = GTextOverflowModeTrailingEllipsis;
const GSize text_size = app_graphics_text_layout_get_content_size("00:00", text_font,
s_low_power_data->low_power_window.layer.bounds, text_alignment,
text_overflow_mode);
cons... |
break;
}
// Run a particular test only. This code was added on top of base clar.
case 't': {
int offset = (argument[2] == '=') ? 3 : 2;
char *test_name = argument + offset;
const struct clar_suite *suite = &_clar_suites[0];
const struct clar_func *test_funcs = suite->tests;
... | clar__assert(0, file, line, err, buf, should_abort) | ;
}
}
void clar__assert_equal_i(
int i1,
int i2,
const char *file,
int line,
const char *err,
int should_abort)
{
if (i1 != i2) {
char buf[128];
snprint_eq(buf, 128, "%d != %d", i1, i2);
clar__assert(0, file, line, err, buf, should_abort);
}
}
void clar__assert_equal_d(
double d1,
d... |
/*
* 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_state.last_time.tm_mon != currtime.tm_mon) {
units_changed |= MONTH_UNIT;
} |
if (s_state.last_time.tm_year != currtime.tm_year) {
units_changed |= YEAR_UNIT;
}
}
}
s_state.last_time = currtime;
s_state.first_tick = false;
if ((s_state.tick_units & units_changed) || (units_changed == 0)) {
s_state.handler(&currtime, units_changed);
}
}
static void prv_sc... |
(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), 0);
cl_assert_equal_i... | prv_count_handler_entries(&s_teardown_handler_calls, d) | , 1);
#endif
}
// --------------------------------------------------------------------------------------
// Test a spawn animation with a play count of 0
void test_animation__spawn_with_0_play_count(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_... |
/*
* 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... | (RCC->AHB1ENR, (0x1 << idx)) | |
/*
* 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... | (distance_normalized,
flip_boundary_from_x,
flip_boundary_to_x) | ;
const GPoint circle_center = GPoint(current_flip_boundary_x - circle_radius + 1,
display_center.y);
if (dir == CompositorTransitionDirectionLeft) {
graphics_fill_radial_internal(ctx, circle_center, circle_radius,
DISP_COLS - ci... |
, 56, 40},
{ 1008, 96, 40},
{ 1128, 176, 24},
{ 1136, 272, -24},
{ 1152, 272, 0},
{ 1512, 376, 104},
{ 1144, 728, 240},
// 68 seconds
{ 1056, 496, -40},
{ 1088, 336, 56},
{ 944, 392, -40},
{ 1024, 384, 24},
{ 1280, 384, 96},
{ 1256, 288, 64},
{ 1168, 136, 96},
... | { 1056, 664, 112},
{ 1320, 424, -112},
{ 1016, 320, -88},
{ 1040, 304, -40},
{ 1176, 328, 48},
{ 1376, 288, 56},
{ 1168, 144, 48},
{ 1112, 24, 104},
{ 1168, -16, 56},
{ 1136, 40, 8},
{ 1088, 64, 16},
{ 944, 16, 24},
// 74 seconds
{ 1048, -16, 56},
{ 1056, -8, ... | |
8, .offset = 0 },
};
void command_flash_apicheck(const char *len_str) {
QSPIFlash *dev = QSPI_FLASH;
const int buf_size = 64;
char buf[buf_size];
int failures = 0;
int passes = 0;
profiler_init();
prompt_send_response("Check whoami");
if (!qspi_flash_check_whoami(dev)) {
++failures;
prompt_... | prompt_send_response_fmt(buf, buf_size, "FAILED: run %d tests and %d failed",
passes + failures,
failures) | ;
}
}
#endif
#if RECOVERY_FW
#include "console/prompt.h"
#include "drivers/flash.h"
#define SIGNAL_TEST_MAGIC_PATTERN (0xA5)
#define TEST_BUFFER_SIZE (1024)
static uint8_t s_test_buffer[TEST_BUFFER_SIZE];
static const uint32_t s_test_addr = FLASH_REGION_FIRMWARE_SCRATCH_END - SECTOR_SIZE_BYTES;
static bool s_signa... |
ne_layer, true);
}
window_set_on_screen(&window, true, true);
window_render(&window, fake_graphics_context_get_context());
timeline_layer_deinit(&timeline_layer);
timeline_model_deinit();
pin_db_flush();
}
// Tests
//////////////////////
static void prv_create_and_render_title_and_subtitle(bool past, ui... | {
prv_create_and_render_day_sep_tomorrow(true /* past */);
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE();
} |
void prv_create_and_render_pin_and_fin(bool past) {
prv_create_list_view_and_render(&(ListViewConfig) {
.pins = {
&(TimelineItemConfig) {
.relative_timestamp = (11 * SECONDS_PER_HOUR) + (30 * SECONDS_PER_MINUTE),
.title = "Jon Byrd birthday party",
.duration = MINUTES_PER_HOUR,
... |
ent task
static void prv_update_and_cleanup_struct(void *data, size_t size, size_t offset) {
prv_apply_patch_to_struct(data, size, offset, true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Custom Local Device Name
bool shared_prf_storage_get_local_devic... | if (flags) {
// Not supported in v2
*flags = 0;
} |
result = true;
done:
prv_cleanup_struct(&data);
return result;
}
static void prv_load_ble_pairing_data(BLEPairingData *data,
const SMPairingInfo *pairing_info,
const char *name) {
*data = (BLEPairingData) {
.local_ediv = pairing_i... |
a.hrm_bpm);
cl_assert_equal_i(s_cb_events_1[0].bpm.quality, s_hrm_event_data.hrm_quality);
cl_assert_equal_i(s_num_cb_events_1, 1);
cl_assert_equal_i(s_cb_events_1[0].event_type, HRMEvent_BPM);
cl_assert_equal_i(s_cb_events_1[0].bpm.bpm, s_hrm_event_data.hrm_bpm);
cl_assert_equal_i(s_cb_events_1[0].bpm.quali... | fake_system_task_callbacks_invoke_pending() | ;
cl_assert_equal_b(hrm_is_enabled(HRM), false);
// 2. Subscribing while disabled should not enable the hrm
hrm_manager_enable(false);
fake_system_task_callbacks_invoke_pending();
HRMSessionRef session_ref = sys_hrm_manager_app_subscribe(1, 1, SECONDS_PER_MINUTE,
... |
/*
* 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... | {
s_write_head = write;
} | |
n_aa(ctx, tr, br, stroke_width);
graphics_line_draw_stroked_non_aa(ctx, bl, br, stroke_width);
}
void graphics_draw_rect(GContext* ctx, const GRect *rect) {
PBL_ASSERTN(ctx);
if (!rect || ctx->lock) {
return;
}
if (ctx->draw_state.stroke_width <= 2) {
// Note: stroke width == 2 is rounded down to st... | prv_draw_round_rect(ctx, rect, radius) | ;
}
#endif // SCREEN_COLOR_DEPTH_BITS
T_STATIC void prv_draw_round_rect_stroked(GContext* ctx, const GRect *rect, uint16_t radius,
uint8_t stroke_width) {
// Assumes AA and stroke_width is set appropriately in ctx
prv_draw_round_rect(ctx, rect, radius);
}
static void prv_... |
{ -1184, 344, 8},
{ -1080, 352, 48},
{ -1104, 560, 64},
{ -952, 656, 104},
{ -1536, 472, 0},
{ -1104, 424, -88},
{ -1224, 360, -80},
{ -1552, 480, 16},
{ -1656, 408, -88},
{ -1320, 248, -168},
{ -1200, 264, -80},
{ -1248, 216, 96},
{ -1280, 80, 112},
{ -1200, 56, 24},... | { -1304, 272, -88},
{ -1712, 256, -96},
{ -1152, 272, -192},
{ -1272, 408, -136},
{ -1480, 360, 0},
// 44 seconds
{ -1296, 176, -16},
{ -1104, 96, -24},
{ -1152, 96, 32},
{ -1256, 72, 80},
{ -1200, 80, 16},
{ -1080, 72, 64},
{ -1048, -40, 128},
{ -1040, -160, 88},... |
{ -264, 264, -16},
{ -416, -32, -48},
{ -552, -48, -16},
{ -744, 64, -24},
{ -1592, 32, 576},
{ -2696, 432, 456},
{ -2560, 1032, -152},
{ -2064, 744, 176},
{ -1352, 376, -56},
{ -1064, 48, 72},
{ -1032, 360, 56},
{ -1008, 368, -72},
{ -992, 248, -112},
{ -888, 49... |
{
case PebbleTask_App:
return FAKE_APP_QUEUE;
case PebbleTask_KernelBackground:
return NULL;
default:
WTF;
} |
}
// -----------------------------------------------------------------------------
// Fakes
// -----------------------------------------------------------------------------
bool mfg_info_is_hrm_present(void) {
return true;
}
static bool s_activity_prefs_heart_rate_is_enabled = true;
bool activity_prefs_heart_rate_... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | mutex_unlock(mutex_1) | ;
cl_assert_equal_b(fake_mutex_all_unlocked(), 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... | board_has_chg_en() | ) {
gpio_use(BOARD_CONFIG_POWER.chg_en.gpio);
GPIO_WriteBit(BOARD_CONFIG_POWER.chg_en.gpio, BOARD_CONFIG_POWER.chg_en.gpio_pin, charging_enabled?Bit_SET:Bit_RESET);
gpio_release(BOARD_CONFIG_POWER.chg_en.gpio);
PBL_LOG(LOG_LEVEL_DEBUG, "Charging:%s", charging_enabled?"enabled":"disabled");
}
}
// 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... | {
return config->subtitle_font ?:
system_theme_get_font_for_default_size(TextStyleFont_MenuCellSubtitle);
} |
static ALWAYS_INLINE GFont prv_get_cell_value_font(const MenuCellLayerConfig *config) {
return config->value_font ?: prv_get_cell_title_font(config);
}
static ALWAYS_INLINE void prv_draw_icon(GContext *ctx, GBitmap *icon, const GRect *icon_frame,
bool is_legacy2) {
if (!is... |
for (unsigned int i = 0; i < ARRAY_LENGTH(BOARD_CONFIG_ACCEL.accel_ints); i++) {
EXTI_ClearFlag(BOARD_CONFIG_ACCEL.accel_ints[i].exti_line);
EXTI_ClearITPendingBit(BOARD_CONFIG_ACCEL.accel_ints[i].exti_line);
}
}
static int16_t raw_to_mgs(int16_t raw, Lis3dhScale scale) {
int16_t mgs_per_digit;
switch (... | PBL_ASSERTN(!s_initialized) | ;
lis3dh_init_mutex();
s_initialized = true;
if (!accel_start()) {
s_initialized = false;
return;
}
if (!lis3dh_config_set_defaults()) {
// accel write will call reset if it fails, so just try again
if (!lis3dh_config_set_defaults()) {
s_initialized = false;
return;
}
}
... |
r_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_last_update_... | (&s_stopped_handler_calls, b) | , 0);
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX);
// Complete B
prv_advance_to_ms_with_timers(start_ms + duration_total + 5 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.