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... | (prefs_out) | ;
}
void test_ios_notif_pref_db__read_flags(void) {
// Make a local copy of dict since ios_notif_pref_db_insert() modifies val
uint8_t val[sizeof(s_ios_pref_db_insert_dict)];
memcpy(val, s_ios_pref_db_insert_dict, sizeof(s_ios_pref_db_insert_dict));
ios_notif_pref_db_insert(key, sizeof(key), val, sizeof(val))... |
PinSource7, GPIO_AF_SPI1);
GPIO_InitTypeDef gpio_cfg;
gpio_cfg.GPIO_OType = GPIO_OType_PP;
gpio_cfg.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio_cfg.GPIO_Mode = GPIO_Mode_AF;
gpio_cfg.GPIO_Speed = GPIO_Speed_50MHz;
gpio_cfg.GPIO_Pin = FLASH_PIN_MISO | FLASH_PIN_MOSI;
GPIO_Init(FLASH_GPIO, &gpio_cfg);
// Configu... | {
flash_unlock();
return 0;
} | |
(this, LinkState_Stopped) | ;
} else if (this->state->link_state == LinkState_AckReceived) {
prv_transition_to(this, LinkState_RequestSent);
} else if (this->state->link_state == LinkState_Opened) {
PBL_LOG(LOG_LEVEL_WARNING, "Terminate-Ack received on an open connection");
prv_send_configure_request(this);
prv_transition_to(t... | |
.num_values = ARRAY_LENGTH(s_values),
.values = s_values,
},
};
// Get the message size and pointer to encoded data
PLogMessageHdr *hdr = (PLogMessageHdr *)buffer;
bool success = protobuf_log_private_mset_decode(
&s_parsed_msg.type,
(uint8_t *)buffer + sizeof(*hdr),
hdr->msg_size... | LOG("payload_sender_id: %s", s_parsed_msg.payload_sender_id) | ;
LOG("payload_sender_version: major: %"PRIu32", minor: %"PRIu32", patch: %s",
s_parsed_msg.payload_sender_v_major,
s_parsed_msg.payload_sender_v_minor,
s_parsed_msg.payload_sender_version_patch);
LOG("payload_send_time: %"PRIu32"", s_parsed_msg.payload_send_time);
const int num_eve... |
/*
* 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(s_addr_result, UserSpaceBuffer_Valid) | |
00, 1080, 328},
{ 864, 552, -24},
{ 952, 792, -56},
{ 1120, 824, 288},
{ 976, 528, 144},
{ 1048, 664, 200},
// 175 seconds
{ 1120, 568, 160},
{ 832, 408, 0},
{ 696, 376, -32},
{ 848, 384, -88},
{ 1152, 344, 48},
{ 1400, 424, 88},
{ 1312, 320, -48},
{ 1160, 328, 24... | { -512, 1240, 368},
{ -552, 584, -64},
{ -680, 624, -336},
{ -664, 312, -184},
{ -264, -368, -328},
{ -224, -1512, -576},
{ -224, -480, -616},
{ -184, -1256, -504},
{ -176, -1136, -520},
{ -152, -880, -552},
{ -120, -1152, -384},
{ -80, -936, -536},
{ -48, -1056, -472... |
{ -296, 848, 392},
{ -256, 840, 368},
// 183 seconds
{ -248, 752, 384},
{ -264, 800, 376},
{ -264, 760, 368},
{ -288, 680, 344},
{ -320, 672, 320},
{ -344, 752, 384},
{ -360, 872, 376},
{ -336, 720, 472},
{ -280, 760, 392},
{ -232, 656, 304},
{ -112, 672, 472},
... |
s(data,
length,
s_fetched_app_attributes,
NUM_FETCHED_APP_ATTRIBUTES,
app_attrs,
... | buffer_add(request_buffer,
(const uint8_t *) &cmd_header,
sizeof(cmd_header)) | ;
PBL_ASSERTN(written_size == sizeof(cmd_header));
prv_add_attributes_to_request(request_buffer);
bool retrying = (s_ancs_client->state == ANCSClientStateRetrying);
prv_set_state(ANCSClientStateRequestedNotification);
bool success = prv_write_control_point_request((const CPDSMessage *) request_buffer->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 (*str != '\r') {
s_message_buffer[s_message_length++] = *str;
} |
}
}
void dbgserial_newline(void) {
uint32_t crc;
size_t raw_length = sizeof(PulseFrame) + sizeof(PushPacket) +
sizeof(s_message_header) + s_message_length + sizeof(crc);
unsigned char raw_packet[raw_length];
PulseFrame *frame = (PulseFrame *)raw_packet;
frame->protocol = hton16(PULS... |
24, 640, 1088},
{ 624, 496, 840},
{ 624, 352, 648},
{ 504, 232, 768},
{ 296, 352, 608},
{ 232, 184, 504},
{ 200, 192, 408},
{ 224, 152, 296},
{ 224, 160, 368},
{ 184, 272, 488},
{ 144, 384, 736},
{ 144, 312, 800},
{ -288, 712, 1376},
{ -272, 576, 1632},
{ -336, 18... | { -264, 160, 1128},
{ -248, 192, 1064},
{ -160, 224, 800},
{ -88, 264, 528},
// 105 seconds
{ -64, 248, 464},
{ -32, 216, 576},
{ 48, 256, 592},
{ 16, 368, 744},
{ 104, 344, 832},
{ 248, 448, 832},
{ 472, 632, 952},
{ 592, 640, 1048},
{ 656, 800, 904},
{ 456, ... |
{ -1448, 256, 320},
{ -1072, 304, 384},
{ -872, 272, 280},
{ -928, 232, 224},
{ -976, 88, 256},
{ -1008, 8, 312},
{ -936, -64, 392},
{ -1088, -24, 456},
{ -1168, -120, 680},
{ -1432, -48, 648},
{ -1216, -168, 720},
{ -1032, 536, 368},
// 108 seconds
{ -1272, 368,... |
bpm_quality,
led_current,
hrm->debug->ppg_data.num_samples,
hrm->debug->accel_data.num_samples);
led_current = bpm = bpm_quality = 0;
prv_send_msg();
} else if (hrm->event_type == HRMEvent_SubscriptionExpiring) {
PBL_LOG(LOG_LEVEL_INFO, "Got subscription... | PBL_LOG(LOG_LEVEL_ERROR, "Unable to open app message! %i %s",
result, prv_translate_error(result)) | ;
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Successfully opened app message");
}
if (!sys_hrm_manager_is_hrm_present()) {
text_layer_set_text(quality_tl, "No HRM Present");
} else {
text_layer_set_text(quality_tl, "Loading...");
prv_enable_hrm();
}
app_message_register_inbox_received(prv_message_... |
tx;
test_graphics_context_init(&ctx, fb);
// Test odd and even cols draw appropriately
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(12, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 6), 10);
graphics_draw_vertical_l... | GPoint(12, 6) | , 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 7), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(24, 7), 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_no_clip")));
//... |
/*
* 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... | setup_pbi_test(TEST_PBI_FILE) | ;
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE));
}
// Tests 4-bit transparent palettized PBI loading into gbitmap
// Result:
// - gbitmap matches platform loaded PBI
void test_pbi__color_4_bit_transparent(void) {
GBitmap *bitmap = setup_pbi_test(TEST_PBI_FILE);
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE... |
/*
* 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... | (&(AppLaunchEventConfig) {
.id = app_node->install_id,
.common.reason = APP_LAUNCH_USER,
.common.button = BUTTON_ID_SELECT,
}) | ;
}
static int16_t get_cell_height_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index,
SettingsWatchfacesData *data) {
return menu_layer_is_index_selected(menu_layer, cell_index) ?
MENU_CELL_ROUND_FOCUSED_TALL_CELL_HEIGHT : MENU_CELL_ROUND_UNFOCUSED_SHORT_CE... |
/*
* 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... | (m_wrapper.m) | ;
do_stuff2();
mutex_unlock(m_wrapper.m);
}
void nest2() {
mutex_lock(global_lock);
printf("blah %p", global_lock);
mutex_unlock(global_lock);
}
void nest() {
nest2();
}
void cond(void *glob_ptr) {
mutex_lock(global_lock);
while (glob_ptr) {
printf("blah %p", glob_ptr);
}
mutex_unlock(glo... |
16_t y,
uint8_t bpp, int16_t line_stride) {
const uint8_t ppb = 8 / bpp;
uint8_t idx = y*line_stride + (x/(ppb));
const uint8_t shift = (8 - bpp) - bpp * (x % ppb);
const uint8_t mask = ~(((1 << bpp) - 1) << shift);
buf[idx] = buf[idx] & mask;
buf[idx] |= ((color_index & ((1 << bpp) - ... | {
for (int x = 0; x < WIDTH; ++x) {
snprintf(print_buf, sizeof(print_buf), "Failed index = %d, %d", x, y);
cl_check_(gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]), print_buf);
cl_check_(gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]), print_buf);
}
} |
#endif
bitblt_bitmap_into_bitmap(&dest_bitmap, &s_bmp, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(prv_check_source_stripe_blit(dest_bitmap_data, &s_bmp, GColorWhite));
}
static void prv_opaque_2bit_simple(GCompOp compositing_mode) {
const int BITS_PER_PIXEL = 2;
const int PIXELS_PER_BYTE = (8 / BITS... |
tLayoutCacheRef *layout_cache) {
*layout_cache = MOCKED_CREATED_LAYOUT;
}
void graphics_text_layout_cache_deinit(GTextLayoutCacheRef *layout_cache) {}
void graphics_text_layout_set_line_spacing_delta(GTextLayoutCacheRef layout, int16_t delta) {}
int16_t graphics_text_layout_get_line_spacing_delta(const GTextLayoutC... | ((MockValues){}) | ;
cl_assert(text_layer.layout_cache == NULL);
}
void test_text_layer__enable_text_flow(void) {
text_layer.layer.window = &window;
text_layer_enable_screen_text_flow_and_paging(&text_layer, 8);
cl_assert_mocks_called(((MockValues){
.enable_text_flow.layout = text_layer.layout_cache,
.enable_text_flow.i... |
_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_stroke_width(ctx, 10);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(20, 20), GPoint(20, 20));
}
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define... | {
// TODO: Fix blending and reenable this - PBL-16509
/*
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 10);
graphics_context_set_stroke_color(&ctx, GColorBlack);
graphics_draw_line(&ctx, COLOR_START_POINT, COLOR_END_POINT);
... | |
The current width change depends on how far we are through the animation
int current_cell_width_change =
(total_cell_width_change * (int) selection_layer->slide_amin_progress) / 100;
// And finally our current width is the starting width plus any change
int current_cell_width = cur_cell_width + current_ce... | prv_get_font_top_padding(selection_layer->font) | ) / 100;
if (selection_layer->bump_is_upwards) {
delta *= -1;
}
y_offset += delta;
}
GRect rect = GRect(current_x_offset, y_offset, selection_layer->cell_widths[i], height);
graphics_draw_text(ctx, text, selection_layer->font,
rect, GTextOve... |
/*
* 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... | (269, -356) | |
ime_end_utc;
*decoder_info->utc_to_local = mset.utc_to_local;
return success;
}
typedef struct PLogEventsDecoderArg {
uint32_t max_num_events;
uint32_t *num_events;
pebble_pipeline_Event *events;
Uuid *event_uuids;
uint32_t max_num_sessions;
uint32_t *num_sessions;
ActivitySession *sessions;
} PLogE... | (encoded_buf, encoded_buf_size) | ;
const uint32_t max_num_types = *num_types;
const uint32_t max_num_values = *num_values;
const uint32_t max_num_samples = *num_samples;
*num_values = 0;
*num_samples = 0;
*num_types = 0;
PLogTypesDecoderArg types_decoder_arg = {
.max_num_types = max_num_types,
.num_types = num_types,
.type... |
nt16_t free_space =
circular_buffer_get_read_space_remaining(&s_manager_state.system_task_event_buffer);
if (free_space < sizeof(PebbleHRMEvent)) {
circular_buffer_consume(&s_manager_state.system_task_event_buffer, sizeof(PebbleHRMEvent));
++s_manager_state.dropped_events;
}
circular_buffer_write(&s... | {
continue;
} |
// Only send BPM and HRV events if the sensor is stable
if (!stable_sensor && (feature == HRMFeature_BPM || feature == HRMFeature_HRV)) {
continue;
}
if (state->callback_handler) {
// For kernel BG subscribers, we only queue one event of each type (which is then
// dispa... |
ert_equal_i(test_value, end_value);
int16_t set_value;
set_value = 42;
property_animation_set_from_int16(prop_h, &set_value);
property_animation_get_from_int16(prop_h, &test_value);
cl_assert_equal_i(test_value, set_value);
set_value = 43;
property_animation_set_to_int16(prop_h, &set_value);
property... | (50, 101, 151, 202, 252, 303) | ;
value = end_value;
prop_h = property_animation_create(&implementation, &value, &start_value, NULL);
Animation *h = property_animation_get_animation(prop_h);
void *context = &value;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
prv_clear_handler_histories();
uint64... |
ds[j], &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
// Fill up storage again
for (++i; i < count + erase_count; i++) {
e.header.id = uuids[i % count];
e.header.timestamp = timestamp + i;
notification_storage_store(&e);
cl_assert(notification_storage_get(&uuids[i % count], &r))... | (uuid_equal(&u, &e4.header.id)) | |
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = 300;
kino_player_play(test_player);
animation_set_elapsed(test_player->animation, 20);
animation_set_duration(test_player->animation, ANIMATION_DURATION_INFINITE);
prv_play_animation_update(test_player->animation,... | (test_player->animation, 20) | ;
prv_play_animation_update(test_player->animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), ANIMATION_DURATION_INFINITE);
}
void test_kino_player__create_finite_animation_infinite_reel_reverse(void) {
// Choose duration and elapsed to have clean division for
// ANIM... |
nse for the specific language governing permissions and
* limitations under the License.
*/
#include "app_glance_service.h"
#include "applib/app_glance.h"
#include "applib/event_service_client.h"
#include "drivers/rtc.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "os/mutex.h"
#include "proce... | (e->app_cache_event.install_id, &app_uuid) | ;
app_glance_db_delete_glance(&app_uuid);
}
}
//////////////////////
// Public API
//////////////////////
void app_glance_service_init_glance(AppGlance *glance) {
if (!glance) {
return;
}
*glance = (AppGlance) {};
}
void app_glance_service_init(void) {
static EventServiceInfo s_blob_db_event_info ... |
e(seq);
// Start A
prv_advance_to_ms_with_timers(start_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_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert... | (prv_count_handler_entries(&s_stopped_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
// Complete A the first time
prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 2);
cl_assert_equal_i(prv_count_handler_e... |
t & desired) {
graphics_private_draw_horizontal_line(ctx, y, start, end);
}
}
static void prv_stroke_circle_quadrant_full(GContext* ctx, GPoint p, uint16_t radius,
uint8_t stroke_width, GCornerMask quadrant) {
// This algorithm will draw stroked circle with vairable ... | (ctx, p, radius, GCornersAll) | ;
p.x += ctx->draw_state.drawing_box.origin.x;
p.y += ctx->draw_state.drawing_box.origin.y;
graphics_private_set_pixel(ctx, GPoint(p.x, p.y + radius));
graphics_private_set_pixel(ctx, GPoint(p.x, p.y - radius));
graphics_private_set_pixel(ctx, GPoint(p.x + radius, p.y));
graphics_private_set_pixel(ctx, GP... |
/*
* 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... | handle_passert_failed_vargs(filename, line_number,
(uintptr_t)__builtin_return_address(0), "ASSERT", message, fmt_args) | ;
va_end(fmt_args);
}
void passert_failed_no_message(const char* filename, int line_number) {
handle_passert_failed(filename, line_number,
(uintptr_t)__builtin_return_address(0), "ASSERTN", NULL);
}
void wtf(void) {
uintptr_t saved_lr = (uintptr_t) __builtin_return_address(0);
dbgserial_print("*** WTF ")... |
istributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "menu_layer_right_icon.h"
#include "applib/app.h"
#include ... | app_malloc_check(sizeof(AppData)) | ;
app_state_set_user_data(data);
push_window(data);
}
static void handle_deinit() {
AppData *data = app_state_get_user_data();
menu_layer_deinit(&data->menu_layer);
app_free(data);
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* menu_layer_righ... |
state->aux->iter_next = list_get_next(&animation->list_node);
// If only running from a specific top-level animation, see if this animation is the target
// one or one of it's children, and if so advance it
if (!top_level_animation || animation == top_level_animation
|| prv_is_descenden... | if (!used_children[i]) {
continue;
} |
// Undo setting of the parent and child_idx on the components we modified.
AnimationPrivate *component = prv_find_animation_by_handle(state, animation_array[i],
false /*quiet*/);
if (component) {
component->parent = NULL;
... |
/ the watermark. Read an extra item from the fifo and just throw it away.
int read_num_bytes = num_bytes + 6;
uint8_t start_addr = 1 << 7 | LIS3DH_OUT_X_L;
uint8_t buffer[read_num_bytes];
lis3dh_read(start_addr, read_num_bytes, buffer);
for (uint8_t *ptr = buffer; ptr < (buffer + num_bytes); ptr+=6) {
da... | {
s_running = running;
} | |
, ICE40LP->spi.rcc_bit);
// Configure CR1 first:
// * TX-only mode (BIDIMODE | BIDIOE)
// * software control NSS pin (SSM | SSI)
// * master mode (MSTR)
// * clock polarity high / 2nd edge (CPOL | CPHA)
ICE40LP->spi.periph->CR1 = SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE | SPI_CR1_SSM | SPI_CR1_SSI |
... | gpio_output_set(&ICE40LP->spi.scs, true) | ; // SCS asserted (low)
delay_us(100);
prv_spi_write(&cmd, sizeof(cmd));
if (arg_len) {
prv_spi_write(arg, arg_len);
}
gpio_output_set(&ICE40LP->spi.scs, false); // SCS not asserted (high)
}
|
ubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_rtc.h"
void bt_driver_reconnect_notify_platform_bitfield(uint32_t p) {}
static bool s_session_is_system;
bool comm_session_is_system(CommSession *session) {
return s_session_is_system;
}
static bool s_session_is_valid;
bool comm_ses... | cl_assert_equal_i(fake_event_get_count(), 1) | ;
PebbleEvent e = fake_event_get_last();
cl_assert_equal_i(e.type, PEBBLE_REMOTE_APP_INFO_EVENT);
cl_assert_equal_i(s_capability_flags, s_expected_capabilities);
}
void test_session_remote_version__app_session(void) {
s_session_is_system = false;
prv_receive_v3_response(3, 2, 1, s_expected_capabilities);
/... |
s_le_conn_params = (LeConnectionParams){};
}
static void prv_update_conn_params(uint16_t slave_latency_events,
uint16_t supervision_to_10ms) {
bt_lock();
s_le_conn_params.slave_latency_events += slave_latency_events;
s_le_conn_params.supervision_to_ms += (supervision_to_10ms *... | (ANALYTICS_DEVICE_METRIC_BLE_CONNECT_TIME) | |
callback should not have been called:
cl_assert_equal_i(s_unscheduled_cb_count, 0);
// Unschedule and expect not to be advertising any more:
gap_le_advert_unschedule(job);
cl_assert(!gap_le_is_advertising_enabled());
// Unschedule callback should have been called once:
cl_assert_equal_i(s_unscheduled_cb_c... | (regular_timer_seconds_count(), 1) | |
,
SettingsRecordInfo *info, void *context) {
// check entry is valid
if (info->val_len == 0 || info->key_len != sizeof(BTBondingID)) {
return true; // continue iterating
}
BTBondingID *first_ancs_supported_bonding_found = (BTBondingID *) context;
BtPersistBondi... | (prv_ble_pairing_internal_for_each_itr, &internal_itr_data) | ;
}
void analytics_external_collect_ble_pairing_info(void) {
unsigned int ble_pairings_count = prv_get_num_pairings_by_type(BtPersistBondingTypeBLE);
analytics_set(ANALYTICS_DEVICE_METRIC_BLE_PAIRING_RECORDS_COUNT,
ble_pairings_count, AnalyticsClient_System);
analytics_set(ANALYTICS_DEVICE_BT_P... |
if (S_VIBE_MAP[x].id == id) {
return &S_VIBE_MAP[x];
} |
}
return NULL;
}
uint32_t vibe_score_info_get_resource_id(VibeScoreId id) {
const VibeScoreInfo *info = prv_vibe_score_find_info(id);
return info ? info->resource_id : RESOURCE_ID_INVALID;
}
const char *vibe_score_info_get_name(VibeScoreId id) {
const VibeScoreInfo *info = prv_vibe_score_find_info(id);
r... | |
.html
static const PmicMonConfig MON_CONFIG[] = {
{ "+VBAT", 3, 0b001 }, // 3:1
// We only care about non-battery rails in MFG where we have the command_pmic_rails function.
#ifdef RECOVERY_FW
{ "+VSYS", 4, 0b010 }, // 4:1
{ "+1V2", 1, 0b011 }, // 1:1, BUCK1
{ "+1V8", 2, 0b100 }, ... | prv_set_mon_config_register(register_value) | ;
// Need to wait a short period of time for the reading to settle due to capacitance on the line.
delay_us(200);
return result;
}
bool pmic_enable_battery_measure(void) {
prv_mon_config_lock();
return prv_set_mon_config(&MON_CONFIG[PMIC_MON_CONFIG_VBAT_INDEX]);
// Don't prv_unlock, we don't want anyon... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
prv_create_window_and_render(2);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
} | |
ake_event_init();
touch_reset();
}
void test_touch__cleanup(void) {
}
void prv_test_touch_event(TouchEvent *touch_event, TouchIdx idx, TouchEventType type, GPoint *start_pos,
uint64_t start_time_ms, TouchPressure start_pressure, GPoint *diff_pos,
uint64_t diff_ti... | cl_assert_equal_i(event.type, PEBBLE_TOUCH_EVENT) | ;
cl_assert_equal_i(event.touch.type, PebbleTouchEvent_TouchesAvailable);
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
prv_test_touch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(10, 10), 20, 5, true);
fake_event_reset_count();
touch... |
on_private_current_interpolate_override(void) {
return s_animation_private_current_interpolate_override;
}
void test_animation_interpolate__initialize(void) {
s_animation_private_current_interpolate_override = NULL;
}
void test_animation_interpolate__override_is_null(void) {
cl_assert_equal_i(-10000, interpolat... | {
cl_assert_equal_i(330, interpolate_moook_custom_duration(&s_custom_moook));
cl_assert_equal_i(-20000, interpolate_moook_custom(0, -20000, 20000, &s_custom_moook));
// mid frame is closer to end due to more end frames
cl_assert_equal_i(6683, interpolate_moook_custom(ANIMATION_NORMALIZED_MAX / 2, -20000, 2000... | |
/*
* 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(diff < 2) | ;
}
}
void test_compass_cal__sphere_fit(void) {
int num_entries = sizeof(s_sample_data) / sizeof(SampleData);
int16_t solution[3];
int rv;
for (int i = 0; i < num_entries; i++) {
for (int j = 0; j < 4; j++) {
rv = ecomp_corr_add_raw_mag_sample(s_sample_data[i].raw_samples[j],
NULL, solut... |
mv = battery_curve_lookup_voltage_by_percent(0, false);
fake_battery_init(good_mv, false, false);
battery_monitor_init();
periodic_timer_trigger(1);
cl_assert(!battery_monitor_critical_lockout());
fake_battery_set_millivolts(critical_mv);
periodic_timer_trigger(25);
cl_assert(battery_monitor_critical_l... | battery_curve_lookup_voltage_by_percent(charge_percent, true) | ;
int discharge_mv = battery_curve_lookup_voltage_by_percent(100 - charge_percent, false);
//
// test as if the battery is plugged and charging
//
bool charging = charge_percent < 100;
fake_battery_init(charge_mv, true, charging);
battery_monitor_init();
periodic_timer_trigger(1);
re... |
dot_color,
GColor final_dot_color,
GColor background_color,
CompositorTransitionDirection direction,
uint32_t durati... | if (timeline_is_future) {
if (timeline_is_destination) {
static const CompositorTransition s_impl = {
.init = prv_dot_transition_to_timeline_future_animation_init,
.update = prv_static_dot_transition_animation_update,
};
return &s_impl;
} else {
static const CompositorTra... |
}
const CompositorTransition* compositor_dot_transition_app_fetch_get(void) {
if (compositor_transition_app_to_app_should_be_skipped()) {
return NULL;
}
static const CompositorTransition s_impl = {
.init = prv_dot_transition_from_app_fetch_animation_init,
.update = prv_static_dot_transition_animat... |
flash_write_bytes(
buffer, s_region_list[idx].start + offset - curr_virt_offset_begin, bytes) | ;
} else if (operation == FTLEraseSubsector) {
PBL_ASSERTN(size == SUBSECTOR_SIZE_BYTES);
flash_erase_subsector_blocking(
s_region_list[idx].start + offset - curr_virt_offset_begin);
} else if (operation == FTLEraseSector) {
PBL_ASSERTN(size == SECTOR_SIZE_BYTES);
... | |
lse,
TemplateStringErrorStatus_InvalidEscapeCharacter,
3,
},
{ "\\e", 1000000000,
"e",
0,
true,
},
{ "\\\\\\{}", 1000000000,
"\\{}",
0,
true,
},
{ "\\\\{end()}", 1000000000,
"\\",
0,
true,
},
{ "\\{end()}", 1000000000,
"{end()}",
0,
true,
},
{ ... | cl_assert_equal_b(cond.force_eval_on_time, true) | ;
} else {
cl_assert_equal_b(cond.force_eval_on_time, false);
}
if (!rv) {
cl_assert_equal_i(err.status, s_full_tests[i].expect_status);
cl_assert_equal_i(err.index_in_string, s_full_tests[i].expect_index);
}
}
}
|
ry) {
return (entry->sdk_version.major == PROCESS_INFO_CURRENT_SDK_VERSION_MAJOR &&
entry->sdk_version.minor <= PROCESS_INFO_CURRENT_SDK_VERSION_MINOR);
}
T_STATIC ListNode *s_head_callback_node_list = NULL;
void app_install_register_callback(struct AppInstallCallbackNode *callback_node) {
PBL_ASSERTN(c... | (LOG_LEVEL_INFO, "Deleting app with id %"PRId32"", id) | ;
app_cache_remove_entry(id);
}
}
static void prv_delete_pending_id(AppInstallId *app_id) {
if (*app_id != INSTALL_ID_INVALID) {
// app cache will delete the app binaries even if the entry for the app_id does not exist
app_cache_remove_entry(*app_id);
*app_id = INSTALL_ID_INVALID;
}
}
static voi... |
/*
* 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_s(dstbuf, "There are 04 lights, -04") | ;
// Minimum digits output (zero digits)
snprintf(dstbuf, 256, "%.0dzero%.0d", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.dzero%.d", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits,... |
oid *context) {
PBL_ASSERT_TASK(PebbleTask_KernelBackground);
bool test_mode = (bool)context;
activity_prefs_set_activated();
s_activity_state.should_be_started = true;
if (!prv_activity_allowed_to_be_enabled() || s_activity_state.started) {
return;
}
AccelSamplingRate sampling_rate;
if (activity_... | activity_tracking_on() | |
} else {
/// Step count less than 1000
snprintf(data->steps_buffer, sizeof(data->steps_buffer), i18n_get("%d", data),
hundreds);
}
layer_mark_dirty(&data->base_layer);
}
static void prv_update_current_steps(KickstartData *data) {
data->current_steps = health_service_sum_today(HealthMetricSt... | (&data->shoe_green_small, RESOURCE_ID_STRIDE_SHOE_GREEN_SMALL) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
const uint8_t text_height = fonts_get_font_height(small_font);
const GTextOverflowMode overflow_mode = GTextOverflowModeFill;
const GTextAlignment alignment = GTextAlignmentCenter;
const GRect text_box = GRect(drawing_bounds.origin.x, y_offset,
drawing_bounds.size.w, text_heigh... | |
se /*quiet*/);
if (!animation) {
return NULL;
}
return (animation->curve == curve) ? animation->custom_function : NULL;
}
// -------------------------------------------------------------------------------------------
AnimationCurveFunction animation_get_custom_curve(Animation *animation_h) {
return prv_an... | (state, animation_h, false /*quiet*/) | ;
if (!animation) {
return false;
}
if (animation->play_count == ANIMATION_PLAY_COUNT_INFINITE_STORED) {
return ANIMATION_PLAY_COUNT_INFINITE;
} else {
return animation->play_count;
}
}
// -------------------------------------------------------------------------------------------
bool animation... |
window_has_status_bar(context->window_from) | &&
window_has_status_bar(context->window_to);
}
// Transitioning Context Functions
////////////////////////////////////
// @note: This function prototypes exist in window_stack_private.h
bool window_transition_context_has_legacy_window_to(WindowStack *stack, Window *window) {
return (stack->transition_conte... | |
me, MAX_RELATIVE_HRS);
cl_assert_equal_s("Tue, 12:00 PM", time_buf);
// June 16th 2015, 13:00:00 (T+7DAY+01:00:00)
rtc_set_time(event_time + (7 * SECONDS_PER_DAY) + (1 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Jun 9, ... | clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("IN 2 H", time_buf);
// June 9th 2015, 15:59:00 (T-00:01:00)
rtc_set_time(event_time - (1 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 1 MIN", time_buf);
// June 9th 2015, 15:58:00 (T-00:02:00)... |
;
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
#endif
}
// Tests APNG file with 8-bit color, 5 frames and loop = 1
// Tests gbitmap_sequence_update_bitmap_by_elapsed with 0 delay frames for 1, 4 and 5
// and 2 & 3 have delay 1000ms
// Result:
// - gbitmaps matches platform decoded APNG
void test_gbitmap_sequ... | cl_assert(resource_id != UINT32_MAX) | ;
GBitmapSequence *bitmap_sequence = gbitmap_sequence_create_with_resource(resource_id);
GBitmap *bitmap = gbitmap_create_blank(gbitmap_sequence_get_bitmap_size(bitmap_sequence),
GBitmapFormat8Bit);
status = gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL... |
/*
* 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... | (key, SETTINGS_KEY_MAX_LEN) | + 1, val, val_len);
settings_file_close(&file);
cleanup:
return (rv == S_SUCCESS);
}
bool shell_prefs_get_clock_24h_style(void) {
return s_is_24h_style;
}
void shell_prefs_set_clock_24h_style(bool is_24h_style) {
mutex_lock(s_mutex);
if (prv_pref_set(PREF_KEY_CLOCK_24H, &s_is_24h_style, sizeof(s_is_24h_sty... |
ocky_app_validate_resources(*md) == RockyResourceValidation_Invalid) {
PBL_LOG(LOG_LEVEL_DEBUG, "App has incompatible JavaScript bytecode");
// TODO: do we need to purge the app cache here?
return true;
}
return false;
}
#endif
void process_manager_launch_process(const ProcessLaunchConfig *config) {... | {
analytics_inc(ANALYTICS_APP_METRIC_BG_CRASHED_COUNT, AnalyticsClient_Worker);
} |
if (context->app_md->is_rocky_app) {
analytics_inc(ANALYTICS_DEVICE_METRIC_APP_ROCKY_CRASHED_COUNT, AnalyticsClient_System);
}
analytics_inc(ANALYTICS_DEVICE_METRIC_APP_CRASHED_COUNT, AnalyticsClient_System);
}
if (task == PebbleTask_App) {
analytics_stopwatch_stop(ANALYTICS_APP_METRIC_FRONT_... |
/*
* 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... | {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharine Berry", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine B.");
} |
void test_phone_formatting__name_trailing_space(void) {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharine Berry ", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine B.");
memset(dest, 0, NAME_LENGTH);
phone_format_caller_name("Katharine Berry ", dest, NAME_LENGTH);
cl_assert_equal_s(des... |
/*
* 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... | {
// Uninitialized context or decoding has already failed.
return false;
} |
if (UNLIKELY(in == '\0')) {
// Zero byte is never allowed in a COBS stream.
ctx->output = NULL;
return false;
}
if (UNLIKELY(ctx->payload_remaining == 0)) {
// Incoming byte is a code byte.
ctx->payload_remaining = (uint8_t)in - 1;
if (ctx->decoded_length + ctx->payload_remaining +
... |
) {
prv_add_handler_entry(&s_stopped_handler_calls, animation, finished, context);
animation_unschedule(animation);
}
// --------------------------------------------------------------------------------------
// Test that animation_unschedule can be called from the stopped handler
void test_animation__unschedule_f... | cl_assert(seq != NULL) | ;
// Setup started/stopped handlers for the sequence
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
animation_set_handlers(seq, handlers, seq);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
/... |
for the worker to die
psleep(3);
}
launcher_task_add_callback(factory_reset_fast, NULL);
}
static bool prv_serial_dump_chunk_callback(uint8_t* msg, uint32_t total_length) {
LogBinaryMessage* message = (LogBinaryMessage *)msg;
char buffer[256];
char time_buffer[TIME_STRING_BUFFER_SIZE];
message->mess... | {
struct WasteTimerData data;
memcpy(&data, &context, sizeof data);
for (int i = 0; i < data.delay; ++i) delay_us(1000);
if (--data.count > 0) {
memcpy(&context, &data, sizeof context);
new_timer_start(s_abusive_timer, 1, prv_waste_time_cb, context, 0);
}
} |
void command_waste_time(const char *count_arg, const char *delay_arg) {
int count = atoi(count_arg);
int delay = atoi(delay_arg);
if (count <= 0 || count > 0xFFFF || delay <= 0 || delay > 0xFFFF) {
prompt_send_response("Nope.");
return;
}
struct WasteTimerData data = { count, delay };
uintptr_t ... |
out* const layout) {
PBL_ASSERTN(layout);
bool success = false;
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, text);
if (!success) {
layout->max_used_size = GSizeZero;
PBL_LOG(LOG_LEVEL_DEBUG, "Invalid UTF8");
return;
}
int str_len_bytes = (utf8_bounds.end - utf8_bounds.start);
Co... | (box, ctx) | ;
GRect temp_box = global_box;
grect_clip(&temp_box, &ctx->draw_state.clip_box);
if (temp_box.size.h <= 0) {
// the text is not ever going to make it on screen. Bail early.
return;
}
if (layout) {
layout->box.origin = global_box.origin;
}
WalkLinesCallbacks callbacks = {
.render_line_c... |
344, 768, -192},
{ 440, 984, 16},
{ 312, 784, -376},
{ 304, 784, -520},
{ 264, 752, -544},
{ 200, 680, -616},
// 65 seconds
{ 128, 640, -672},
{ 40, 480, -736},
{ 8, 440, -832},
{ -80, 280, -864},
{ -104, 264, -912},
{ -144, 224, -904},
{ -160, 120, -968},
{ -152,... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25478_2
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ 208, -112, -952},
{ 1... |
{ 72, -280, -952},
{ 80, -296, -944},
{ 48, -288, -936},
{ 24, -304, -952},
{ 40, -280, -920},
{ 8, -288, -960},
{ 8, -280, -952},
{ 16, -224, -992},
{ 24, -264, -1016},
{ 32, -216, -1016},
{ 40, -240, -1056},
{ 64, -240, -1000},
{ 0, -240, -1008},
{ 24, -416, -9... |
nt_Liftoff);
cl_assert_equal_b(updated, true);
cl_assert_equal_i(rec_event, RecognizerEvent_Completed);
r->state = RecognizerState_Possible;
updated = false;
new_state = RecognizerState_Started;
recognizer_handle_touch_event(r, &(TouchEvent) { .type = TouchEvent_Touchdown });
cl_assert_equal_i(last_touch... | (!recognizer_should_evaluate_simultaneously(NULL, r2)) | ;
cl_assert(!recognizer_should_evaluate_simultaneously(r1, r2));
recognizer_set_simultaneous_with(r1, prv_simultaneous_with_cb);
cl_assert(!recognizer_should_evaluate_simultaneously(NULL, NULL));
cl_assert(!recognizer_should_evaluate_simultaneously(r1, NULL));
cl_assert(!recognizer_should_evaluate_simultaneo... |
_assert_equal_b(true, app_install_get_uuid_for_install_id(music_id, &uuid));
cl_assert_equal_uuid(uuid, music_uuid);
cl_assert_equal_b(true, app_install_get_uuid_for_install_id(sports_id, &uuid));
cl_assert_equal_uuid(uuid, sports_uuid);
cl_assert_equal_b(false, app_install_get_uuid_for_install_id(CRAZY_ID, &... | app_install_release_md(menu_layer_md) | ;
}
static bool prv_each(AppInstallEntry *entry, void *data) {
uint8_t *num_entries = (uint8_t *)data;
*num_entries = *num_entries + 1;
cl_assert(entry->install_id != INSTALL_ID_INVALID);
return true;
}
void test_app_install_manager__enumerate_entries(void) {
uint8_t num_entries = 0;
app_install_enumerate... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&layer, &GRect(0, 0, 10, 10)) | ;
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_pixel_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_x_layer_update_callback);
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... | {
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_CURRENT_COLOR, 0, current_fill);
} |
#if PBL_COLOR
if (!behind_typical) {
health_progress_bar_mark(ctx, &data->progress_bar, PROGRESS_TYPICAL_COLOR, typical_fill);
}
#else
health_progress_bar_mark(ctx, &data->progress_bar, PROGRESS_TYPICAL_COLOR, typical_fill);
#endif
// This needs to be done after drawing the progress bars or else the prog... |
ples;
*timestamp_ms = state->timestamp_ms;
mutex_unlock_recursive(s_accel_manager_mutex);
return result;
}
DEFINE_SYSCALL(bool, sys_accel_manager_consume_samples,
AccelManagerState *state, uint32_t samples) {
bool success = true;
mutex_lock_recursive(s_accel_manager_mutex);
if (samples > s... | {
PebbleEvent e = {
.type = PEBBLE_ACCEL_SHAKE_EVENT,
.accel_tap = {
.axis = axis,
.direction = direction,
},
};
event_put(&e);
} |
void accel_cb_double_tap_detected(IMUCoordinateAxis axis, int32_t direction) {
PebbleEvent e = {
.type = PEBBLE_ACCEL_DOUBLE_TAP_EVENT,
.accel_tap = {
.axis = axis,
.direction = direction,
},
};
event_put(&e);
}
static void prv_handle_accel_driver_work_cb(void *data) {
// The accel m... |
// the change and therefore we don't want it to visually update yet. prv_worker_launch_handler
// will update the choice if it fires.
option_menu_set_choice(&data->option_menu, prv_get_chosen_row_index(data));
// Switching to a different worker, display confirmation dialog
switch_worker_c... | {
SettingsActivityTrackerData *data = context;
event_service_client_unsubscribe(&data->worker_launch_info);
app_menu_data_source_deinit(data->data_source);
app_free(data->data_source);
data->data_source = NULL;
option_menu_deinit(&data->option_menu);
i18n_free_all(data);
app_free(data);
} |
static Window *prv_init(void) {
SettingsActivityTrackerData *data = app_zalloc_check(sizeof(SettingsActivityTrackerData));
const OptionMenuCallbacks option_menu_callbacks = {
.unload = prv_unload_cb,
.draw_row = prv_draw_row_cb,
.select = prv_select_cb,
.get_num_rows = prv_get_num_rows_cb... |
/*
* 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... | va_end(fmt_args) | ;
}
|
cl_assert(result == DICT_OK);
result = dict_write_int8(&iter, SOME_INT8_KEY, -8);
cl_assert(result == DICT_OK);
result = dict_write_int16(&iter, SOME_INT16_KEY, -16);
cl_assert(result == DICT_OK);
result = dict_write_int32(&iter, SOME_INT32_KEY, -32);
cl_assert(result == DICT_OK);
result = dict_write_cstr... | (num_bits % 8 == 0) | ;
// Test that the .value field isn't part of the header:
cl_assert(sizeof(Tuple) == sizeof(t.key) + sizeof(t.length) + (num_bits / 8));
}
static void *CONTEXT = (void *)0xabcdabcd;
static const char *NEW_STRING = "Bye, bye, World";
static bool is_int8_updated = false;
static bool is_string_updated = false;
static... |
List *attr_list_to_serialize,
const uint8_t *expected_attr_list_serialized,
size_t expected_attr_list_serialized_size) {
uint8_t buffer[expected_attr_list_serialized_size];
const size_t size = attribute_list_serialize(attr_list_to_seria... | cl_assert_equal_i(list.num_attributes, 2) | ;
attribute_list_add_uint32(&list, AttributeIdLastUpdated, value_uint32);
attribute_list_add_uint8(&list, AttributeIdBgColor, value_uint8);
cl_assert_equal_i(value_uint32, attribute_get_uint32(&list, AttributeIdLastUpdated, 0));
cl_assert_equal_i(value_uint8, attribute_get_uint8(&list, AttributeIdBgColor, 0));... |
t(TEST_PNG_FILE);
GBitmap *native_framebuffer = graphics_context_get_bitmap(ctx);
cl_assert(native_framebuffer->info.format == GBitmapFormat8BitCircular);
cl_assert(DISPLAY_FRAMEBUFFER_BYTES == 25944);
bitblt_bitmap_into_bitmap(native_framebuffer, bitmap, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(gbi... | (ctx, GColorBlack) | |
OMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "send all sessions: empty %s connected %s counter %u",
bool_to_str(check_counter == 0),
bool_to_str(comm_session_get_system_session() != NULL),
check_counter);
system_task_add_callback(prv_send_all_sessions_system_task_cb,
(void*)(uint... | (&prv_check_all_sessions_timer_info,
DATALOGGING_DO_FLUSH_CHECK_INTERVAL_MINUTES) | ;
}
// ----------------------------------------------------------------------------------------
void dls_init(void) {
dls_endpoint_init();
dls_list_init();
// rebuild data logging_sessions
dls_storage_rebuild();
// add callbacks to empty and check logging_sessions
dls_resume();
s_initialized = true;
}... |
ess_md.h"
#include "resource/resource.h"
#include "resource/resource_storage.h"
#include "resource/resource_storage_file.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/app_cache.h"
#include "services/normal/blob_db/app_db.h"
#include "util/build_id.h"
#include "util/time/time.h"
#include <std... | {
return false;
} |
return app_install_entry_is_watchface(&entry);
}
bool app_install_has_worker(AppInstallId id) {
AppInstallEntry entry;
bool exists = app_install_get_entry_for_install_id(id, &entry);
if (!exists) {
return false;
}
return app_install_entry_has_worker(&entry);
}
bool app_install_is_hidden(AppInstallId ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GRect(10, 20, 100, 600) | );
cl_assert_equal_grect(l.bounds, GRect(1, 1, 200, 599));
// act as 2.x once bounds.size isn't same as frame.size
layer_set_bounds(&l, &GRect(0, 0, 150, 600));
layer_set_frame(&l, &GRect(10, 20, 100, 700));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 150, 700));
}
|
ak;
}
if (time_search >= node->time_start && time_search <= node->time_end) {
rc = true;
break;
}
node = (VibeHistory*)list_get_next((ListNode*)node);
}
mutex_unlock(s_vibe_history_mutex);
return rc;
}
// @param cutoff The time to cut off the list at. 0 means to clear the list.
static... | (s_vibe_pattern_mutex) | |
, 360, 56},
{ 808, 176, -16},
{ 1112, -24, 72},
{ 912, -48, 248},
{ 720, -128, 184},
{ 832, 88, 160},
{ 760, 200, 104},
{ 760, 184, 80},
{ 776, 104, 136},
{ 848, 32, 160},
{ 992, 96, 112},
{ 1136, 104, 128},
{ 1704, -72, 312},
{ 1480, 296, 8},
{ 928, 472, -136},
... | { 888, 104, 200},
{ 824, 120, 176},
{ 800, 72, 160},
{ 688, 80, 104},
{ 680, 64, 80},
{ 728, 32, 152},
{ 888, 56, 184},
{ 1112, -8, 376},
{ 1024, 216, 32},
{ 1320, -208, 288},
{ 1624, -8, 224},
{ 1216, 600, -168},
{ 896, 512, -160},
{ 824, 368, -128},
{ 808, 1... |
{ 768, 168, 104},
// 36 seconds
{ 792, 272, 88},
{ 768, 232, 80},
{ 728, 224, 32},
{ 736, 288, -48},
{ 832, 200, 24},
{ 880, 216, 24},
{ 1088, 216, 24},
{ 1232, 200, 80},
{ 1560, 208, 192},
{ 1568, 328, 272},
{ 872, 528, 192},
{ 928, 376, -184},
{ 1096, 232, ... |
ate_read_backing(const uint8_t *key, size_t key_len, void *value, int value_len) {
const PrefsTableEntry *entry = prv_prefs_entry(key, key_len);
if (!entry) {
return false;
}
if (value_len != entry->value_len) {
PBL_LOG(LOG_LEVEL_WARNING, "Attempt to read %s using invalid value_len of %"PRIu32"",
... | {
#if INFINITE_BACKLIGHT
return false;
#endif
return s_backlight_ambient_sensor_enabled;
} |
void backlight_set_ambient_sensor_enabled(bool enabled) {
prv_pref_set(PREF_KEY_BACKLIGHT_AMBIENT_SENSOR_ENABLED, &enabled, sizeof(enabled));
}
uint32_t backlight_get_timeout_ms(void) {
#if INFINITE_BACKLIGHT
return UINT32_MAX;
#endif
return s_backlight_timeout_ms;
}
void backlight_set_timeout_ms(uint32_t tim... |
|
* |
* -------+--------
* |
* |
* x2 | x3
* |
*
* + center point
* - x coordiante mirror line
* | y coordinate mirror line
* x given offset point
* xn mirrored points
*/
for (unsigned int i=0; i < ARRAY_LENGTH(quadra... | (edge.integer - 1, progress) | ,
weighting, stroke_color, quadrant);
prv_plot8(framebuffer, &ctx->draw_state.clip_box, p, GPoint(edge.integer, progress),
weighting ^ weighting_compliment_mask, stroke_color, quadrant);
} else {
prv_plot8(framebuffer, &ctx->draw_state.clip_box, p, GPoint(edge.integer, p... |
de <string.h>
#include "clar.h"
#include "drivers/system_flash.h"
#define KiB *1024
// Set bits n..0 in a bit-vector (zero-indexed)
#define BITS(n) ((((uint32_t)(1 << ((n) + 1)))) - 1)
// Set bits y..x in a bit-vector (x <= y; x, y >= 0)
#define BITS_BETWEEN(x, y) (BITS(y) & ~BITS(x-1))
// Yo dawg, I heard you lik... | (flash_written_data) | ;
flash_written_flag = malloc(size * sizeof(bool));
cl_assert(flash_written_flag);
}
void assert_flash_unwritten(uint32_t start, uint32_t length) {
for (uint32_t i = 0; i < length; ++i) {
cl_assert(flash_written_flag[start + i] == false);
}
}
void test_system_flash__write_simple(void) {
const char testd... |
scribe(BUTTON_ID_SELECT, select_click_handler);
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}
// -------------------------------------------------------------------------------
static void cur_temp_update_text(TemperatureDemoAppD... | (window_layer, text_layer_get_layer(data->cur_temp_layer)) | ;
// Current temp range
data->temp_range_layer = text_layer_create(TEMP_RANGE_RECT);
text_layer_set_text_alignment(data->temp_range_layer, GTextAlignmentCenter);
text_layer_set_font(data->temp_range_layer,
fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS));
text_layer_set_background_... |
_spi_configure_default(void) {
spi_slave_set_frequency(ICE40LP->spi_port, ICE40LP->base_spi_frequency);
}
void display_start() {
periph_config_acquire_lock();
gpio_output_init(&ICE40LP->creset, GPIO_OType_OD, GPIO_Speed_25MHz);
gpio_input_init(&ICE40LP->cdone);
gpio_input_init(&ICE40LP->busy);
periph_con... | periph_config_release_lock() | ;
return success;
}
void display_power_enable(void) {
// The display requires us to wait 1ms between each power rail coming up. The PMIC
// initialization brings up the 3.2V rail (VLCD on the display, LD02 on the PMIC) for us, but
// we still need to wait before turning on the subsequent rails.
psleep(2);
... |
= &s_time_selection_config_large,
};
static const TimeSelectionSizeConfig *prv_selection_config(void) {
const PreferredContentSize runtime_platform_default_size =
system_theme_get_default_content_size_for_runtime_platform();
return s_time_selection_configs[runtime_platform_default_size];
}
// FROM selection... | selection_layer_set_active_bg_color(from_selection_layer, color) | |
(void *) characteristic_ref);
}
// -------------------------------------------------------------------------------------------------
static bool prv_has_pending_cccd_write(GATTClientSubscriptionNode *subscription) {
for (GAPLEClient c = 0; c < GAPLEClientNum; ++c) {
if (subscription... | {
// OOM
return BTErrnoNotEnoughResources;
} |
// Initialize it:
*subscription = (const GATTClientSubscriptionNode) {
.characteristic = characteristic_ref,
.att_handle = att_handle,
};
// Prepend to the list of subscriptions of the connection:
ListNode *head = &connection->gatt_subscriptions->node;
connection->gatt_subscriptions... |
C_BUFFER_LENGTH) != 0;
bool artist_changed = strncmp(data->artist_buffer, artist_buffer, MUSIC_BUFFER_LENGTH) != 0;
if (title_changed || artist_changed) {
// Animating nothing looks weird, so don't do that.
if (data->artist_buffer[0] == 0 && data->title_buffer[0] == 0) {
strncpy(data->artist_buffer, a... | (&data->window.layer, &data->artist_text_layer.layer) | ;
prv_configure_music_text_layer(&data->position_text_layer, data->position_buffer, &time_rect,
TIME_BOUNDS_OFFSET, GTextAlignmentLeft,
fonts_get_system_font(config->music_time_font_key));
layer_add_child(&data->window.layer, &data->position_text_la... |
{ 0, 0x54, 489, 0x0},
{ 0, 0x44, 239, 0x0},
{ 0, 0x44, 0, 0x0},
{ 0, 0x43, 3745, 0x0},
{ 9, 0x52, 7624, 0x0},
{ 0, 0x45, 2783, 0x0},
{ 0, 0x40, 306, 0x0},
{ 0, 0x43, 3192, 0x0},
{ 0, 0x47, 612, 0x0},
{ 8, 0x56, 8141, 0x0},
{ 0, 0x61, 6267, 0x0},
{ 0, 0x6e, 2769, 0x0},
... | { 0, 0x6f, 250, 0x0},
{ 0, 0x6e, 63, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{ 0, 0x6e, 0, 0x0},
{... |
{ 0, 0x6a, 275, 0x0},
// 420: Local time: 01:58:00 AM
{ 0, 0x5b, 0, 0x0},
{ 0, 0x5b, 0, 0x0},
{ 0, 0x5b, 0, 0x0},
{ 0, 0x6a, 128, 0x0},
{ 0, 0x6a, 0, 0x0},
{ 0, 0x6a, 16, 0x0},
{ 0, 0x6a, 0, 0x0},
{ 0, 0x6a, 0, 0x0},
{ 0, 0x6a, 864, 0x0},
{ 0, 0x60, 2251, 0x0},
{ 0, ... |
const uint32_t delay_ms = 100;
progress_window_set_result_failure(data->progress_window, timeline_res_id, message,
delay_ms);
}
} else {
prv_show_result_window(data, timeline_res_id, message, success);
}
return true;
}
static void prv_timeout_handler(void *c... | prv_cleanup_action_result(data, false /* succeeded */) | ;
return;
}
ChainingWindowCBData *cb_data = applib_malloc(sizeof(ChainingWindowCBData));
if (!cb_data) {
timeline_item_destroy(item);
prv_cleanup_action_result(data, false /* succeeded */);
return;
}
*cb_data = (ChainingWindowCBData) {
.item = item,
// Claim the buffer so it doesn't g... |
distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gap_le_connection.h"
#include "comm/bt_conn_mgr.h"
#include "comm/bt_lock.h"
#include "k... | gap_le_connection_find(prv_find_connection_by_irk_filter, (void *)irk) | ;
}
// -------------------------------------------------------------------------------------------------
//! bt_lock() is expected to be taken by the caller
void gap_le_connection_set_irk(GAPLEConnection *connection, const SMIdentityResolvingKey *irk) {
if (connection->irk) {
kernel_free(connection->irk);
}
... |
/*
* 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... | prvSetupHardware() | ;
/* Set system clock */
cm_sys_clk_set(sysclk_XTAL16M);
// Set the desired sleep mode.
// It's important to do this *AFTER* setting up the system clock. This is because cm_sys_clk_set()
// has the potential to block this task while waiting for the xtal to settle. When using deep
// sleep, you'd fall into... |
play_name_attr, s_title_attr);
cl_assert(s_performed_store);
// Make sure the our existing prefs got updated
iOSNotifPrefs expected_prefs = {
.attr_list = expected_attributes,
};
prv_compare_notif_prefs(existing_prefs, &expected_prefs);
}
void test_ancs_filtering__record_app_existing_display_name(void) ... | (&mute_weekends) | );
cl_assert(ancs_filtering_is_muted(&mute_weekdays));
}
void test_ancs_filtering__record_app_no_display_name(void) {
iOSNotifPrefs *existing_prefs = NULL;
// No display name so we expect the app name to be the title
AttributeList expected_attributes = {
.num_attributes = 3,
.attributes = (Attribute[]... |
pfs_close(fd);
}
}
// force partial garbage collection
test_force_reboot_during_garbage_collection(start_page);
// reset our state variables, there should be no files found
pfs_reset_all_state();
for (int i = 0; i < pages_to_write; i++) {
snprintf(file_small, sizeof(file_small), "file%d", i);... | test_force_recalc_of_gc_region() | ;
pfs_init(false);
int expected_remaing_files = pages_per_sector - 1;
// scatter files across two sectors
for (int i = 0; i < (pages_per_sector + start_page_offset); i++) {
char filename[20];
sprintf(filename, "test%d", i + start_page_offset);
int fd = pfs_open(filename, OP_FLAG_WRITE, FILE_TYPE_S... |
ng at
PFSFileListEntry *next = (PFSFileListEntry *)iter->list_node.next;
if (app_file_parse_app_id(iter->name) == id) {
// the AppInstallId of the file matches the one in the cache so we can remove this
// entry from the resource_list (since we don't want to delete it)
// note: resource_list m... | mutex_unlock_recursive(s_app_cache_mutex) | ;
return rv;
}
//! Tests if an entry with the given AppInstallId is in the cache
bool app_cache_entry_exists(AppInstallId app_id) {
bool exists = false;
mutex_lock_recursive(s_app_cache_mutex);
{
SettingsFile file;
status_t rv = settings_file_open(&file, APP_CACHE_FILE_NAME, APP_CACHE_MAX_SIZE);
if... |
See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "drivers/rtc.h"
#include "syscall/syscall.h"
#include "kernel/logging_private.h"
#include "kernel/kernel_applib_state.h"
#include "process_state/app_state/app_state.h"
#include "process_state/worker_st... | prv_use_default_log_msg(msg, max_message_length) | ) {
prv_sprintf_to_msg(msg, max_message_length, fmt, args);
}
return sizeof(*msg) + msg->message_length;
}
int pbl_log_get_bin_format(char* buffer, int buffer_len, const uint8_t log_level,
const char* src_filename_path, int src_line_number, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
... |
ed));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Updated));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Cancelled));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Completed));
r->state = RecognizerState_Started;
event_type = -1;
recognizer_trans... | cl_assert_equal_b(cancelled, false) | |
prv_action_jump_table[s_current_state](action) | ;
}
static void prv_setup_callback_info(void) {
//! Timer callback to check whether the watch is stationary every minute
s_accel_stationary_timer_info = (RegularTimerInfo) {
.cb = prv_stationary_check_timer_cb
};
//! Button press events
s_button_event_info = (EventServiceInfo) {
.type = PEBBLE_BUTTO... | |
E(GColorWhite, GColorBlack));
status_bar_layer_set_separator_mode(status_layer, StatusBarLayerSeparatorModeNone);
layer_add_child(root_layer, (Layer *)status_layer);
// bubble on right for action button
layer_init(&data->action_button_layer, &data->window.layer.bounds);
data->action_button_layer.update_proc ... | {
// Don't remove the action menu here. The timeline actions module also handles this event
// and will remove it as well as put a result dialog
prv_remove_notification(data, &action_result->id, false /* close am */);
prv_refresh_pop_timer(data);
} |
}
static void prv_handle_notification_removed_common(Uuid *id, NotificationType type) {
NotificationWindowData *data = &s_notification_window_data;
if (s_in_use && data->is_modal && !data->window_frozen) {
prv_remove_notification(data, id, true /* close am */);
}
}
static void prv_handle_notification_acte... |
{
uint32_t bit = (1 << flag);
val = ((connection->flags & bit) == bit);
} |
prv_unlock();
return val;
}
bool connection_is_subscribed_to_connection_status_notifications(const Connection *connection) {
return prv_get_flag(connection, ConnectionFlag_IsSubscribedToConnectionStatusNotifications);
}
bool connection_should_pin_address(const Connection *connection) {
return prv_get_flag(co... | |
//! Writes the log record header to flash and advances the
//! s_curr_state.offset_in_log_page field
//!
//! @param msg_length - the length of the message to be written
static void prv_write_flash_log_record_header(uint8_t msg_length) {
LogRecordHeader record_hdr;
memset((uint8_t *)&record_hdr, 0xff, sizeof(recor... | {
goto exit;
} |
} else {
// Go into reading the log messages now.
state->sent_build_id = true;
state->retry_count = 0;
state->page_offset = sizeof(FlashLoggingHeader);
}
status = DumpStatus_InProgress;
goto exit;
}
// Read next log message and send it out
LogRecordHeader rec;
flash_rea... |
e the License for the specific language governing permissions and
* limitations under the License.
*/
#include "settings_raw_iter.h"
#include "kernel/pbl_malloc.h"
#include "services/normal/filesystem/pfs.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
//////////////////////////... | sfs_read(iter, (uint8_t*)&iter->file_hdr, sizeof(iter->file_hdr)) | ;
iter->hdr_pos = -1;
iter->resumed_pos = -1;
}
void settings_raw_iter_write_file_header(SettingsRawIter *iter, SettingsFileHeader *file_hdr) {
sfs_seek(iter, 0, FSeekSet);
sfs_write(iter, (uint8_t*)file_hdr, sizeof(*file_hdr));
iter->file_hdr = *file_hdr;
iter->hdr_pos = -1;
iter->resumed_pos = -1;
}
vo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.