prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
(0, false) | ));
cl_assert(PASSED(persist_write_int(1, 2)));
cl_assert(persist_read_int(1) == 2);
}
/*
* Confirm that loading a smaller amount of data, then a larger amount of data,
* always returns the appropriate amount of data.
*/
void test_persist__partial_read_extension(void) {
char buffer[] = "Hello thar";
// Wri... | |
ure the transition can do render by its own
WindowTransitioningContext *const transition_context = &stack->transition_context;
transition_context->implementation->render(transition_context, ctx);
} else {
PROFILER_NODE_START(render_modal);
window_render(window, ctx);
PROFILER_NODE_STOP(render_moda... | for (ModalPriority priority = 0;
priority < NumModalPriorities;
++priority) {
WindowStack *window_stack = modal_manager_get_window_stack(priority);
info->counts[priority] = window_stack_dump(window_stack,
&info->dumps[priority]);
} |
} else {
info->disabled = true;
}
xSemaphoreGive(info->interlock);
}
void command_modal_stack_info(void) {
WindowStackInfoContext info = {
.interlock = xSemaphoreCreateBinary(),
};
if (!info.interlock) {
prompt_send_response("Couldn't allocate semaphore for modal stack");
return;
}
la... |
/*
* 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_service_sum(HealthMetricStepCount, day_start,
day_start + (seconds_today_so_far / 2)) | |
/*
* 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(*output == input) | ;
}
void test_lru_cache__flush(void) {
uint32_t input = 0xdeadbeef;
lru_cache_put(&s_cache, 1, &input);
lru_cache_flush(&s_cache);
uint32_t *output = lru_cache_get(&s_cache, 1);
cl_assert(output == NULL);
}
void test_lru_cache__evict(void) {
for (int i = 0; i <= CACHE_BUFFER_SIZE / (sizeof(CacheEntry) + s... |
is invalid: Value out of bounds for native type"
);
}
void test_rocky_api_graphics__fill_and_stroke_styles(void) {
prv_global_init_and_set_ctx();
EXECUTE_SCRIPT(
"ctx.fillStyle = '#f00';\n"
"ctx.strokeStyle = 'white';\n"
"var c = ctx.fillStyle;\n"
);
cl_assert_equal_i(1, s_graphics_context_set... | GRect(100, 100, large_int, large_int) | ),
s_graphics_draw_text.last_call.draw_text.box);
EXECUTE_SCRIPT(
"ctx.textAlign = 'center';\n"
"ctx.fillText('some text', 100, 100);\n"
);
cl_assert_equal_i(2, s_graphics_draw_text.call_count);
cl_assert_equal_rect((GRect(-4900, 100, large_int, large_int)),
... |
= PBL_IF_RECT_ELSE(10, 12);
#endif
KinoLayer *kino_layer = &data->kino_layer;
kino_layer_init(kino_layer, &window->layer.bounds);
layer_add_child(&window->layer, &kino_layer->layer);
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
GRect pair_text_area = GRect(0, -2, width, 44);
#else
GRect pair_text_area = GRect(... | if (data->ui_state == BTPairingUIStateAwaitingUserConfirmation) {
prv_send_response(false /* is_confirmed */);
} |
prv_deinitialize_info_text(data);
property_animation_destroy(data->info_text_in_animation);
property_animation_destroy(data->info_text_out_animation);
kernel_free(data);
}
s_data_ptr = NULL;
}
static void prv_show_failure_kernel_main_cb(void *unused) {
prv_handle_pairing_complete(false /* succe... |
_t mask = ~(((1 << bpp) - 1) << shift);
buf[idx] = buf[idx] & mask;
buf[idx] |= ((color_index & ((1 << bpp) - 1)) << shift);
}
static bool prv_check_source_stripe_blit(const uint8_t *data,
const GBitmap *src_bmp, GColor surround_color) {
for (uint8_t y = 0; y < (FRAMEBUFF... | 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_PER_PIXEL);
const int WIDTH = 4;
const int HEIGHT = 4;
const int ROW_STRIDE = (WIDTH + (PIX... |
fill_color = GColorClear;
s_stroke_color = GColorClear;
s_stroke_width = 0;
s_path_num_points = 0;
if (s_stroke_points) {
free(s_stroke_points);
s_stroke_points = NULL;
}
if (s_fill_points) {
free(s_fill_points);
s_fill_points = NULL;
}
s_path_open = false;
s_radius = 0;
s_path_stro... | (command, GColorGreen) | ;
color = gdraw_command_get_stroke_color(command);
color.a = 0;
gdraw_command_set_stroke_color(command, color);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorClearARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorGreenARGB8);
cl_assert_equal_i(s_stroke_width, 0);
cl_as... |
d = 0;
head = list_sorted_add(head, &bar2.list_node, (Comparator) sorting_comparator, true);
cl_assert(head == &bar2.list_node);
head = list_sorted_add(head, &bar3.list_node, (Comparator) sorting_comparator, true);
cl_assert(head == &bar2.list_node);
cl_assert(list_get_tail(head) == &bar3.list_node);
hea... | (NULL, &f) | , &d);
cl_assert_equal_p(list_concatenate(&f, NULL), &d);
cl_assert_equal_p(list_concatenate(&d, NULL), &d);
cl_assert_equal_p(list_concatenate(&a, &d), &a);
cl_assert_equal_p(list_get_head(&e), &a);
cl_assert_equal_p(list_get_tail(&b), &f);
c.next = NULL;
d.prev = NULL;
cl_assert_equal_p(list_concat... |
/*
* 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... | (&currtime, units_changed) | ;
}
}
static void prv_schedule_next_update(void) {
// Schedule this to fire again at the top of the next second
const int ms_into_s = EM_ASM_INT_V({
return Date.now().getMilliseconds;
});
const double wait_ms = 1000 - ms_into_s;
const bool is_update_due_to_time_change = false;
emscripten_async_ca... |
/*
* 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_dropped_reports = 0;
success = bt_driver_start_le_scan(
true /* active_scan */, false /* use_white_list_filter */,
true /* filter_dups */, 10240, 10240);
if (success) {
// Allocate report buffers if advertising started successfully
const size_t buffer_size = G... |
}
bt_unlock();
return success;
}
// -----------------------------------------------------------------------------
bool gap_le_stop_scan(void) {
bool success = false;
bt_lock();
{
if (s_is_scanning) {
success = bt_driver_stop_le_scan();
kernel_free(s_reports_buffer);
s_reports_buffer... |
size_t request_payload_length) {
if (!prv_check_initialized()) {
return false;
}
HcProtocolMessage *message = prv_create_message(endpoint_id, command_id, request_payload,
request_payload_length);
const bool rv = hc_proto... | PBL_ASSERTN(!to_request->transaction_id.is_response) | ;
size_t message_length = sizeof(HcProtocolMessage) + response_payload_length;
HcProtocolMessage *response = kernel_malloc_check(message_length);
response->message_length = message_length;
response->endpoint_id = to_request->endpoint_id;
response->command_id = to_request->command_id;
response->transaction_i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (test_image_bw != NULL) | ;
test_image_color = get_gbitmap_from_pbi("test_rotated_bitmap_redstar.Xbit.pbi");
cl_assert(test_image_color != NULL);
}
void test_graphics_draw_rotated_bitmap__cleanup(void) {
free(fb);
if (test_image_bw) {
if (test_image_bw->addr) {
free(test_image_bw->addr);
}
free(test_image_bw);
}
... |
/*
* 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... | status_bar_layer_init(&status_bar) | ;
cl_assert_status_bar_height(status_bar);
GRect frame = status_bar.layer.frame;
GRect bounds = status_bar.layer.bounds;
frame.size.h = STATUS_BAR_LAYER_HEIGHT - 5;
layer_set_frame(&status_bar.layer, &frame);
cl_assert_status_bar_height(status_bar);
bounds.size.h = STATUS_BAR_LAYER_HEIGHT + 5;
layer... |
st_val = st_val + i;
rv = pfs_write(fd, (uint8_t *)&st_val, sizeof(st_val));
cl_assert_equal_i(rv, sizeof(st_val));
}
pfs_close(fd);
idx++;
}
cl_assert_equal_i((status_t)fd, E_OUT_OF_STORAGE);
// read back files to make sure they are all correct
st_val = 0;
for (int i = 0; i < id... | pfs_open(file_name, OP_FLAG_READ, 0, 0) | |
¬if, portMAX_DELAY);
configASSERT(ret == pdTRUE);
sys_watchdog_resume(s_ble_perip_wdog_id);
hc_protocol_process_receive_buffer();
extern bool should_log_about_mic_error(uint32_t *max_subsequent_failures);
uint32_t num_subsequent_failures = 0;
if (should_log_about_mic_error(&num_subsequent... | break;
case BLE_EVT_GATTC_READ_COMPLETED:
gatt_wrapper_handle_read_completed((const ble_evt_gattc_read_completed_t *)hdr);
break;
case BLE_EVT_GATTC_WRITE_COMPLETED:
gatt_wrapper_handle_write_completed((const ble_evt_gattc_write_completed_t *)hdr);
bre... |
void ble_task_init(const BTDriverConfig *config) {
const BleTaskInitInfo init_info = {
.semph = xSemaphoreCreateBinary(),
.config = config,
};
PBL_ASSERTN(init_info.semph);
PBL_LOG(LOG_LEVEL_INFO, "Starting BLE Task...");
OS_TASK_CREATE("BT", prv_ble_peripheral_task, (void *)&init_info,
... |
/*
* 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... | (protocol) | ,
.len = htons(data_len)
};
prv_send_bytes(&hdr, sizeof(hdr));
}
static void prv_send_footer(void) {
QemuCommChannelFooter footer = (QemuCommChannelFooter) {
.signature = htons(QEMU_FOOTER_SIGNATURE)
};
prv_send_bytes(&footer, sizeof(footer));
}
// --------------------------------------------------... |
/*
* 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 (!space) {
strncpy(destination, full_name, length);
destination[length - 1] = '\0';
return;
} |
// Copy the first name to the destination, as long as it fits.
size_t pos = MIN((size_t)(space - full_name), length - 1);
strncpy(destination, full_name, pos);
// Then keep adding the character after the space until we run out of spaces.
do {
space++;
// Abort if it is impossible for us to fit a spac... |
attributes.h"
#include "util/circular_buffer.h"
#include "util/crc32.h"
#include "mcu/interrupts.h"
#include <hw_wkup.h>
#include <osal.h>
#include <platform_devices.h>
#include <sdk_defs.h>
#include <stdio.h>
#include <string.h>
#include <sys_watchdog.h>
// Design doc:
// https://docs.google.com/document/d/1or2Ygs3... | (HOST_SPI->spi.clk.port, HOST_SPI->spi.clk.pin,
HW_GPIO_MODE_INPUT, HOST_SPI->spi.clk.function) | ;
hw_gpio_set_pin_function(HOST_SPI->spi.mosi_di.port, HOST_SPI->spi.mosi_di.pin,
HW_GPIO_MODE_INPUT, HOST_SPI->spi.mosi_di.function);
hw_gpio_set_pin_function(HOST_SPI->spi.miso_do.port, HOST_SPI->spi.miso_do.pin,
HW_GPIO_MODE_OUTPUT, HOST_SPI->spi.miso_do.func... |
0, -296},
{ -496, -840, -304},
{ -496, -840, -288},
{ -496, -840, -296},
{ -496, -840, -296},
{ -504, -840, -304},
{ -496, -832, -296},
{ -504, -840, -304},
{ -496, -840, -296},
{ -504, -840, -296},
{ -496, -840, -296},
{ -496, -832, -296},
{ -496, -840, -296},
{ -496... | { -504, -840, -296},
{ -504, -840, -296},
{ -504, -840, -296},
{ -504, -832, -296},
{ -504, -840, -296},
{ -496, -840, -296},
{ -496, -832, -296},
{ -496, -848, -288},
{ -496, -840, -296},
{ -496, -840, -288},
{ -504, -832, -296},
{ -496, -832, -296},
// 102 seconds
... | |
settings file format with known data to the local file system so that it can
// be checked in and used for migration tests.
static void prv_save_known_settings_file(const char *filename) {
// Let's include 3 days of history by start at s_init_time_tm - 3 days
struct tm time_tm = s_init_time_tm;
time_t utc_sec = ... | (st.st_size == bytes_written) | |
es off. Second one should be up
s_current_hour = 10;
s_current_minute = 30;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
prv_assert_alarm_config(id1, 10, 30, true, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_... | alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_1 }) | ;
prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_CUSTOM, schedule_1);
// Only 1 pin should be added (for Saturday)
cl_assert_equal_i(s_num_timeline_adds, 1);
id2 = alarm_create(&(AlarmInfo) { .hour = 11, .minute = 30, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_1 });
prv_assert_alarm_conf... |
hics_draw_horizontal_line_dotted(&ctx, GPoint(0, 0), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 2), 148);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 4), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 6), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 8), 2)... | (&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 0), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 2), MAX_NUM_COLS + 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 4), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 6), 1);
graphics_draw_horizontal_line_dotted(&... |
char *text, GFont font, GColor color,
GTextNodeContainer *container) {
GTextNodeText *text_node = health_util_create_text_node(0, font, color, container);
text_node->text = text;
return text_node;
}
void health_util_duration_to_hours_and_minutes_text_node(in... | health_util_get_distance_factor() | );
}
void health_util_convert_distance_to_whole_and_decimal_part(int distance_m, int *whole_part,
int *decimal_part) {
const int conversion_factor = health_util_get_distance_factor();
health_util_convert_fraction_to_whole_and_decimal_part(distance_m, conv... |
nder the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Lic... | cl_assert_equal_i(e.app_cache_event.cache_event_type, PebbleAppCacheEvent_Removed) | ;
cl_assert_equal_i(e.app_cache_event.install_id, app3.id);
cl_assert_equal_i(fake_event_get_count(), 2);
// ensure the only one remaining is the one evicted
cl_assert_equal_i(app2.id, app_cache_get_next_eviction());
cl_assert_equal_i(fake_event_get_count(), 2);
}
/*************************************
* ... |
ge_too_short(void) {
prv_receive_init_and_put_fw_object();
const uint8_t incomplete_put_msg = CmdCommit;
prv_receive_data(s_session, (const uint8_t *) &incomplete_put_msg,
sizeof(incomplete_put_msg));
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__commit_... | assert_ack_count(0) | ;
assert_nack_count(1);
}
void test_put_bytes__install_message_cookie_mismatch(void) {
prv_receive_init_put_and_commit_fw_object();
prv_receive_install(~s_last_response_cookie);
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__install_message_prf_boot_bit_set(void) {
prv_receive_init_put_... |
ponse;
const char *text_neutral_response;
const char *text_negative_response;
uint32_t icon_positive_response;
uint32_t icon_neutral_response;
uint32_t icon_negative_response;
} RewardNotifConfig;
static const RewardNotifConfig SLEEP_REWARD_NOTIF_CONFIG = {
.state = &s_sleep_reward_state.common,
.insight... | i18n_noop("Sleep Summary") | ,
.short_subtitle = s_pin_subtitle_buffer,
.detail_text = s_sleep_period_buffer,
.health_card_type = HealthCardType_Sleep,
.icon = TIMELINE_RESOURCE_SLEEP,
.percent_config = {
{ // PercentTier_AboveAverage
.body = i18n_noop("You had a good night! Feel the energy 😃"),
},
{ // PercentTier_On... |
25, 42, and 47 because they are my favorite numbers
uint32_t after_free = t_data[16].size + t_data[24].size + t_data[41].size + t_data[46].size;
s_test_id_ql_up = 17;
s_test_id_ql_down = 25;
s_test_id_watchface = 42;
s_test_id_worker = 47;
// test removing all and more bytes
prv_cleanup();
to_free = S... | prv_res_filename(filename, sizeof(filename), id) | ;
prv_check_file_exists(filename);
}
// finally, make sure the 'standard' files are all there
for (uint32_t i = 0; i < ARRAY_LENGTH(descriptions); ++i) {
prv_check_file_exists(descriptions[i].name);
}
}
void test_app_cache__purge_orphaned_files_no_apps(void) {
// make sure nothing goes awry if there ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (text_layer, g_text) | ;
} else if (type == 1) {
snprintf(g_text, sizeof(g_text), "BAT: %d, %d, %d", (int)data->data0, (int)data->data1, (int)data->data2);
text_layer_set_text(text_layer, g_text);
}
}
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
AppWorkerResult result = app_worker_launch();
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... | (DISP_COLS, DISP_ROWS) | ;
framebuffer_init(&s_framebuffer, &fb_size);
framebuffer_clear(&s_framebuffer);
s_state = CompositorState_App;
s_deferred_render = (DeferredRender) {
.animation.pending = false,
.app.pending = false
};
s_animation_state = (CompositorTransitionState) { 0 };
s_framebuffer_frozen = false;
}
// ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (!prv_find_combo_timer()) | |
/*
* 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_center_point(&data->to) | );
return gpoint_sub(offset, GPoint(size.w / 2, size.h / 2));
}
static bool prv_image_size_eq_rect_size(KinoReelTransformData *data, GRect rect) {
GSize size = kino_reel_get_size(prv_get_current_reel(data));
return gsize_equal(&size, &rect.size);
}
static void prv_free_list_copy(KinoReelTransformData *data) {
... |
_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 1);
#endif
}
// ---------------------------------------------------------------------------... | (animation_get_custom_curve(h) == prv_custom_curve) | ;
// Reverse
cl_assert(animation_get_reverse(h) == false);
animation_set_reverse(h, true);
cl_assert(animation_get_reverse(h) == true);
animation_set_reverse(h, false);
// Position
int32_t elapsed_ms = 0;
AnimationProgress progress = 0;
animation_schedule(h);
cl_must_pass(animation_get_elapsed(h... |
urb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Sunday. (14.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 52200 * MS_PER_SECOND);
do_not_disturb_set_schedule_enabled(WeekendSchedule, false);
rtc_set_time(s... | do_not_disturb_handle_clock_change() | ;
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Sunday. (14 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 50400 * MS_PER_SECOND);
rtc_set_time(s_sunday_23_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_activ... |
in 24 hours, then show the actual time instead of "X hours ago"
const int MAX_RELATIVE_HRS = 13;
clock_set_24h_style(true);
// June 9th 2015, 17:00:00 (T+01:00:00)
rtc_set_time(event_time + SECONDS_PER_HOUR);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_ass... | clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("1 minute ago", time_buf);
// June 9th 2015, 16:02:00 (T+00:02:00)
rtc_set_time(event_time + (2 * SECONDS_PER_MINUTE));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("2 minutes ago", time_buf);
// June 9th 2015, 15:00:00 (T-01:00:00)
... |
ess or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bluetooth/gatt.h>
#include "gatt_client_operations.h"
#include "gatt_client_accessors.h"
#include "comm/bt_lock.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include ... | list_contains(&s_client_event_ctxs[GAPLEClientApp]->node, &context->node) | ||
list_contains(&s_client_event_ctxs[GAPLEClientKernel]->node, &context->node));
return exists;
}
void bt_driver_cb_gatt_client_operations_handle_response(GattClientOpResponseHdr *event) {
const GattClientEventContext *data = event->context;
bt_lock();
{
//! Special case: writes to the "Client Cha... |
andle: %d, context_ref: %d, source: %d",
handle, context_ref, source);
const GattRespDest resp_dest = prv_dest_from_source(source);
if (!prv_enqueue(conn_idx, context_ref, resp_dest, GattOpType_Write)) {
return BLE_ERROR_NOT_CONNECTED;
}
ble_error_t rv = ble_gattc_write(conn_idx, handle, 0... | {
BTDeviceInternal addr;
Connection *conn = connection_by_idx_check(evt->conn_idx);
connection_get_address(conn, &addr);
hc_endpoint_gatt_send_notification(&addr, evt->handle, evt->length, evt->value);
} |
void gatt_wrapper_handle_indication(const ble_evt_gattc_indication_t *evt) {
BTDeviceInternal addr;
Connection *conn = connection_by_idx_check(evt->conn_idx);
connection_get_address(conn, &addr);
hc_endpoint_gatt_send_indication(&addr, evt->handle, evt->length, evt->value);
// GATT Indications are already ... |
/*
* 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;
} |
va_list args;
va_start(args, format);
app_log_vargs(log_level, "JERRY-LOG", 0, format, args);
va_end(args);
}
/**
* Provide console message implementation for the engine.
*/
void jerry_port_console(const char *format, ...) {
if (format[0] == '\n' && strlen(format) == 1) {
return;
}
va_list args;
... |
ervices[BLE_GATT_MAX_SERVICES_CHANGED];
uint8_t num_services = sys_ble_client_copy_services(device, services,
BLE_GATT_MAX_SERVICES_CHANGED);
if (num_services != 0) {
handler(device.opaque, BLEClientServicesAdded, services, num_services, status);
}
}
//... | (value_length, 64 /* arbitrary min size.. */) | ;
applib_free(value);
value = (uint8_t *) applib_malloc(new_heap_buffer_size);
heap_buffer_size = value ? new_heap_buffer_size : 0;
}
if (!value) {
gatt_error = BLEGATTErrorLocalInsufficientResources;
value_length = 0;
}
uintptr_t object_ref;
// Consume, even if we didn... |
_size) {
int read_size = prv_file_get(&DEVICE_NAME_KEY, sizeof(DEVICE_NAME_KEY),
local_device_name_out, max_size);
if (!read_size) {
return false;
}
return true;
}
void bt_persistent_storage_set_local_device_name(char *local_device_name, size_t size) {
if (!local_device_nam... | settings_file_close(&fd) | |
ote TINTIN_BUILD_ID;
extern const uint32_t __CCM_RAM_size__[];
extern const uint32_t __DTCM_RAM_size__[];
void cd_flash_init(void);
uint32_t cd_flash_write_bytes(const void* buffer_ptr, uint32_t start_addr, uint32_t buffer_size);
void cd_flash_erase_region(uint32_t start_addr, uint32_t total_bytes);
void cd_flash_rea... | (__FILE_NAME__, 0, msg) | ;
}
// -------------------------------------------------------------------------------------------------
// NOTE: We are explicitly avoiding use of vsniprintf and cohorts to reduce our stack
// requirements
static void prv_debug_str_str(const char* msg, const char* s) {
#if PULSE_EVERYWHERE
void *ctx = pulse_loggin... |
Header));
layer_add_child(&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... | app_state_get_user_data() | |
e than MAX_FROM_KERNEL_MAIN_EVENTS events to itself while processing another
// event.
// 2.) The ONLY task that posts events to s_from_kernel_event_queue is the KernelMain task.
// 3.) Whenever KernelMain wants to post an event to itself, it MUST use this queue.
// 4.) The KernelMain task will always service this ... | if (!xQueueSendToBackFromISR(queue, event, &should_context_switch)) {
prv_log_event_put_failure(queue_type, saved_lr, event);
#ifdef NO_WATCHDOG
enable_mcu_debugging();
while (1);
#endif
reset_due_to_software_failure();
} |
return should_context_switch;
}
static bool prv_try_event_put(QueueHandle_t queue, PebbleEvent *event) {
PBL_ASSERTN(queue);
return (xQueueSendToBack(queue, event, milliseconds_to_ticks(3000)) == pdTRUE);
}
static void prv_event_put(QueueHandle_t queue,
const char* queue_type,
... |
/*
* 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 (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "Error prv_handle_update_request: %d", (int)e);
BleConnectionParams params = {};
hc_endpoint_responsiveness_notify_update(
¶ms, &req->address, ble_error_to_hci_status_error(e));
} |
}
void hc_endpoint_responsiveness_notify_update(
const BleConnectionParams *params, const BTDeviceInternal *addr,
HciStatusCode status) {
uint8_t response_len = sizeof(HcProtocolMessage) +
sizeof(BleConnectionUpdateCompleteEvent);
uint8_t buf[response_len];
HcProtocolMessage *msg = (HcProtocolMes... |
/*
* 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... | RTC_WriteBackupRegister(BOOTLOADER_VERSION_REGISTER, TINTIN_METADATA.version_timestamp) | |
/*
* 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... | strcmp(hw_version, "XXXXXXXX") | == 0);
// Test writing & reading back:
const char* written_hw_version1 = "ABCDEFG";
command_hwver_write(written_hw_version1);
hw_version = mfg_get_hw_version();
cl_assert(strcmp(written_hw_version1, hw_version) == 0);
#if (BOARD_SILK_BB || BOARD_CALCULUS)
// Write a second time, too long.
const char* w... |
uest != NULL) {
if (curr_request->req_state > state) {
// reset our tracker, we have found a higher power mode requested
timeout = curr_request->timeout;
state = curr_request->req_state;
responsible_consumer = curr_request->consumer;
} else if (curr_request->req_state == state) {
i... | if (!gap_le_connection_is_valid(hdl)) {
goto unlock;
} |
ConnectionMgrInfo *conn_mgr_info = hdl->conn_mgr_info;
// if we are executing this cb, we have timed out running at the currently
// selected state so check and see what consumer timeouts have expired
ConnectionStateRequest *curr_request = conn_mgr_info->requests;
uint32_t curr_ticks = rtc_get_ticks();
... |
tem/logging.h"
extern void gap_le_connect_params_re_evaluate(GAPLEConnection *connection);
static void prv_convert_pps_request_params(const PebblePairingServiceConnParamSet *pps_params_in,
GAPLEConnectRequestParams *params_out) {
const uint16_t min_1_25ms = pps_params_in->... | {
bt_lock();
{
GAPLEConnection *connection = gap_le_connection_by_device(device);
if (!connection) {
goto unlock;
}
const size_t length = (conn_params_length - offsetof(PebblePairingServiceConnParamsWrite,
remote_desired_state));
swi... |
void bt_driver_cb_pebble_pairing_service_handle_ios_app_termination_detected(void) {
app_launch_trigger();
}
|
ion_ms;
music_get_pos(&track_pos_ms, &track_duration_ms);
cl_assert_equal_i(track_pos_ms, 0);
cl_assert_equal_i(track_duration_ms, 0);
cl_assert_equal_i(music_get_playback_rate_percent(), 0);
}
void test_ams__receive_non_numeric_player_playback_info_update(void) {
prv_connect_ams();
// Receive: 'A', 'B.0... | (music_needs_user_to_start_playback_on_phone(), true) | ;
for (MusicCommand cmd = 0; cmd < NumMusicCommand; ++cmd) {
cl_assert_equal_b(music_is_command_supported(cmd), true);
}
cl_assert_equal_b(music_is_command_supported(NumMusicCommand), false);
}
// Tests: Create & Destroy
///////////////////////////////////////////////////////////
void test_ams__create_agai... |
LC
*
* 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 in writing, software
* distri... | ancs_notifications_handle_message(37, properties, notif_attributes, app_attributes) | ;
// We just processed an incomming phone call event, there better be a phone event scheduled!
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_PHONE_EVENT);
cl_assert_equal_i(event.phone.type, PhoneEventType_Incoming);
cl_assert_equal_i(event.phone.source, PhoneCallSource_ANC... |
/*
* 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... | (write_sb, NULL) | ;
}
TickType_t prv_session_closed_yield_cb(QueueHandle_t handle) {
if (s_valid_session) {
comm_session_send_queue_cleanup(s_valid_session);
s_valid_session = NULL;
}
return 10;
}
TickType_t prv_receive_but_no_bytes_freed_yield_cb(QueueHandle_t handle) {
fake_rtc_increment_ticks(100);
xSemaphoreGive(... |
:
case TimelineResourceSizeTiny:
card_attr_id = AttributeIdIconTiny;
break;
case TimelineResourceSizeSmall:
card_attr_id = AttributeIdIconSmall;
break;
case TimelineResourceSizeLarge:
card_attr_id = AttributeIdIconLarge;
break;
}
const bool is_card = (mode == LayoutLa... | time_util_get_midnight_of(info->timestamp) | != current_day &&
time_util_get_midnight_of(info->end_time) == current_day)
? info->end_time : info->timestamp;
}
void timeline_layout_get_icon_frame(const GRect *bounds, TimelineScrollDirection scroll_direction,
GRect *frame) {
const GSize size = timeli... |
////
int g_pbl_log_level = 0;
void pbl_log(int level, const char* src_filename, int src_line_number, const char* fmt, ...) { }
// Tests
///////////////////////////////////////////////////////////
void test_list__initialize(void) {
}
void test_list__cleanup(void) {
}
void test_list__insert_after(void) {
ListNode *... | list_get_tail(head) | == &bar2.list_node);
head = list_sorted_add(head, &bar1.list_node, (Comparator) sorting_comparator, false);
cl_assert(head == &bar3.list_node);
cl_assert(list_get_next(head) == &bar2.list_node);
cl_assert(list_get_tail(head) == &bar1.list_node);
}
static bool is_odd(IntNode *node, void *data) {
return (nod... |
448, -88},
{ 1712, 368, 8},
{ 1624, 304, 40},
{ 1328, 272, -88},
{ 984, -968, 128},
{ 808, -488, 136},
{ 648, -376, -416},
{ 992, -112, -296},
{ 1288, 24, -120},
{ 1608, 104, 72},
{ 1800, 408, 8},
// 5 seconds
{ 1848, 760, -336},
{ 1848, 1008, -352},
{ 1768, 1032,... | { 1624, 840, -368},
{ 1120, 800, -624},
{ 888, 1408, -648},
{ 872, 2016, -560},
{ 1072, 1064, -208},
{ 1368, 936, -192},
{ 1736, 984, -104},
{ 1952, 808, 24},
{ 1960, 792, 344},
{ 2168, 1520, 544},
{ 2680, 816, 472},
{ 2360, 760, 216},
{ 2048, 784, 104},
{ 1328, 5... |
{ 1360, 320, 72},
{ 1360, 240, -96},
{ 1176, -936, 240},
{ 720, -472, 384},
{ 896, -296, -488},
{ 1160, -16, -344},
// 13 seconds
{ 1544, 104, -16},
{ 1592, 216, 104},
{ 1640, 408, -120},
{ 1752, 704, -96},
{ 1760, 1056, -264},
{ 1704, 880, -344},
{ 1400, 904, -2... |
}
GRect grect_to_global_coordinates(const GRect rect, GContext *ctx) {
GRect translated_rect = {
.origin.x = ctx->draw_state.drawing_box.origin.x + rect.origin.x,
.origin.y = ctx->draw_state.drawing_box.origin.y + rect.origin.y,
.size = rect.size,
};
return translated_rect;
}
GRect grect_to_local_c... | {
Heap * heap = app_state_get_heap();
return (BitmapInfo) {
.is_bitmap_heap_allocated =
bitmap->info.is_bitmap_heap_allocated && heap_is_allocated(heap, bitmap->addr),
};
} |
return bitmap->info;
}
bool gcolor_is_invisible(GColor8 color) {
return (color.a == 0);
}
#define RGB_LOOKUP_TABLE_SIZE (64)
const GColor8Component g_color_luminance_lookup[RGB_LOOKUP_TABLE_SIZE] = {
0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
1, 1, 1, 1... |
FLASH_REGION_MFG_INFO_END - FLASH_REGION_MFG_INFO_BEGIN);
}
void test_spalding_mfg_info__cleanup(void) {
fake_spi_flash_cleanup();
}
void test_spalding_mfg_info__color(void) {
cl_assert_equal_i(mfg_info_get_watch_color(), 0);
mfg_info_set_watch_color(WATCH_INFO_COLOR_RED);
cl_assert_... | mfg_info_get_disp_offsets() | .x, -2);
cl_assert_equal_i(mfg_info_get_disp_offsets().y, 1);
cl_assert_equal_i(mfg_info_get_watch_color(), 3);
cl_assert_equal_i(mfg_info_get_rtc_freq(), 4);
mfg_info_get_model(buffer);
cl_assert_equal_s(buffer, "test_model");
}
void test_spalding_mfg_info__2_to_3_conversion(void) {
// Force in an o... |
ap);
}
{ // Create a 2 hour session that ends after 9pm ==> should be regular sleep
ActivitySession sessions[] = {
{
.start_utc = start_of_today + (20 * SECONDS_PER_HOUR), // 8pm
.length_min = 2 * MINUTES_PER_HOUR,
.type = ActivitySessionType_Sleep,
},
};
uint16_t ... | ("\n Total: %d\n", steps_awake_120m) | ;
// Compute the expected number of steps
int exp_steps = 0;
for (int i = 0; i < num_minutes; i++) {
exp_steps += minute_data[i].base.steps;
}
cl_assert_equal_i(steps_awake_120m, exp_steps);
// -------------------------------------------------------------------------------
// Try again while sleepi... |
+ 1;
notification_storage_store(&e2);
cl_assert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_buffer);
cl_assert(notification_storage_get(&i2, &r));
compare_notifications(&e2, &r);
free(r.allocated_buffer);
cl_assert(notification_storage_get(&i3, &r));
compare... | (&uuids[i], &r) | );
compare_notifications(&e, &r);
free(r.allocated_buffer);
// Check that an expected number of notifications were removed
erase_count += j;
for (; j < erase_count; j++) {
e.header.id = uuids[j];
e.header.timestamp = timestamp + j;
cl_assert_equal_b(notification_storage_get(&uuids[j], &r), false)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// Setup graphics context
framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
... | |
offsetof(PageHeader, hdr_crc));
}
static uint32_t compute_file_header_crc(FileHeader *hdr) {
return legacy_defective_checksum_memory(hdr, offsetof(FileHeader, hdr_crc));
}
// the start page is written to, the end page is not written to.
static void prv_write_erased_header_on_page_range(uint16_t start, uint16_t ... | (hdr, 0xff, sizeof(*hdr)) | |
g(s_valid_test_string);
cl_assert(is_valid);
utf8_t* valid_test_string_utf8 = (utf8_t*)s_valid_test_string;
for (int i = 0; i < NUM_VALID_CODEPOINTS; ++i) {
uint32_t decoded_codepoint = utf8_peek_codepoint(valid_test_string_utf8, NULL);
uint32_t actual_codepoint = s_valid_test_codepoints[i];
cl_asse... | cl_assert_equal_i(0, utf8_get_size_truncate(" ", 1)) | ;
cl_assert_equal_i(2, utf8_get_size_truncate("ab", 3));
cl_assert_equal_i(2, utf8_get_size_truncate("abc", 3));
cl_assert_equal_i(17, utf8_get_size_truncate("Hello World! \xF0\x9F\x98\x84", 100));
cl_assert_equal_i(13, utf8_get_size_truncate("Hello World! \xF0\x9F\x98\x84", 17));
cl_assert_equal_i(16, utf8_g... |
/*
* 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... | {
int32_t cosine = cos_lookup(angle);
int32_t sine = sin_lookup(angle);
int64_t cosine_val = (cosine * ((int64_t)GTransformNumberOne.raw_value)) / TRIG_MAX_RATIO;
int64_t sine_val = (sine * ((int64_t)GTransformNumberOne.raw_value)) / TRIG_MAX_RATIO;
GTransformNumber a = (GTransformNumber) { .raw_val... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ALWAYS, "__TINTIN__") | |
/*
* 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_system_event_queue_set == NULL) | ;
// This assert is to make sure we don't accidentally bloat our PebbleEvent unecessarily. If you hit this
// assert and you have a good reason for making the event bigger, feel free to relax the restriction.
//PBL_LOG(LOG_LEVEL_DEBUG, "PebbleEvent size is %u", sizeof(PebbleEvent));
// FIXME:
_Static_assert(... |
_list_add_cstring(&list, AttributeIdNameAway, "GSW");
attribute_list_add_cstring(&list, AttributeIdRecordAway, "114-152");
attribute_list_add_cstring(&list, AttributeIdScoreAway, "86");
attribute_list_add_cstring(&list, AttributeIdNameHome, "CHI");
attribute_list_add_cstring(&list, AttributeIdRecordHome, "110-1... | (&list, AttributeIdBody, "Body message") | ;
attribute_list_add_uint32(&list, AttributeIdLastUpdated, now);
TimelineItem *item = timeline_item_create_with_attributes(now + delta_time_s, 0,
TimelineItemTypePin, LayoutIdGeneric,
&list, NULL)... |
know what parser to call later on:
reassembly_ctx->command_id = cmd_header->command_id;
// Append the partial response to the reassembly buffer:
const int bytes_written = buffer_add(&reassembly_ctx->buffer, data, length);
// If this gets hit, NOTIFICATION_ATTRIBUTES_MAX_BUFFER_LENGTH is too small:
... | if (*data++ == 0) {
break;
} |
}
ANCSAttribute *app_attrs[NUM_FETCHED_APP_ATTRIBUTES] = {0};
if (length == 0) {
goto fail;
}
bool error = false;
const bool complete = ancs_util_get_attr_ptrs(data,
length,
s_fetched_app_attributes,
... |
as previously ongoing should not be registered after all.
void activity_sessions_prv_delete_activity_session(ActivitySession *session) {
ActivityState *state = activity_private_state();
mutex_lock_recursive(state->mutex);
{
// Look for this activity
int found_session_idx = -1;
ActivitySession *stored_... | if (result != DATA_LOGGING_SUCCESS) {
PBL_LOG(LOG_LEVEL_WARNING, "Error %"PRIi32" while logging activity to DLS", (int32_t)result);
} |
PBL_LOG(LOG_LEVEL_INFO, "Logging activity event %d, start_time: %"PRIu32", "
"elapsed_min: %"PRIu16", end_time: %"PRIu32" ",
(int)session->type, (uint32_t)session->start_utc, session->length_min,
(uint32_t)session->start_utc + (session->length_min * SECONDS_PER_MINUTE));
}
// This str... |
/*
* 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... | vibe_intensity_get_string_for_intensity(current_system_default_vibe_intensity) | ;
break;
}
default: {
WTF;
}
}
// We need to set the subtitle to the name of a vibe score if it's NULL at this point
if (!subtitle) {
subtitle = vibe_score_info_get_name(alerts_preferences_get_vibe_score_for_client(client));
if (subtitle && IS_EMPTY_STRING(subtitle)) {
subti... |
ta->volume_repeat_timer = app_timer_register(VOLUME_REPEAT_INTERVAL_MS,
prv_handle_volume_repeat, data);
prv_change_volume(data->volume_is_up);
prv_do_haptic_feedback_vibe(context);
}
static void prv_volume_long_click_start_handler(ClickRecognizerRef recognizer, voi... | window_set_window_handlers(&window->window, &(WindowHandlers) {
.unload = prv_unload_no_music_window
}) | ;
const MusicAppSizeConfig *config = prv_config();
gbitmap_init_with_resource(&window->bitmap, RESOURCE_ID_MUSIC_IMAGE_NO_MUSIC);
const GSize NO_MUSIC_IMAGE_SIZE = window->bitmap.bounds.size;
const GRect NO_MUSIC_IMAGE_RECT = GRect(config->no_music_img_pos.x,
config->... |
/*
* 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... | {
// TODO: PBL-15063
return;
} |
gpio_input_init_pull_up_down(input_config, GPIO_PuPd_NOPULL);
}
void gpio_input_init_pull_up_down(const InputConfig *input_config, GPIOPuPd_TypeDef pupd) {
GPIO_InitTypeDef gpio_init = {
.GPIO_Mode = GPIO_Mode_IN,
.GPIO_PuPd = pupd,
.GPIO_Pin = input_config->gpio_pin
};
prv_init_common(input_con... |
32f4xx_rcc.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_usart.h"
#endif
#include "util/attributes.h"
#include "util/cobs.h"
#include "util/crc32.h"
#include "util/net.h"
#include "util/misc.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#define MAX_MESSAGE (256)
#define FRAME_DELIMITER '\x55'
#... | for (size_t i = 0; i < cooked_length; ++i) {
if (cooked_packet[i] == FRAME_DELIMITER) {
prv_putchar('\0');
} else {
prv_putchar(cooked_packet[i]);
}
} |
prv_putchar(FRAME_DELIMITER);
s_message_length = 0;
}
void dbgserial_putstr(const char* str) {
if (!s_initialized) {
return;
}
dbgserial_print(str);
prv_flush();
}
void dbgserial_print(const char* str) {
if (!s_initialized) {
return;
}
for (; *str && s_message_length < MAX_MESSAGE; ++str... |
ASSERT_JS_GLOBAL_EQUALS_S("s", "Mon, 8:04:05 PM");
}
void test_rocky_api_datetime__locale_date_string(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT(
"var d = new Date();\n"
"var s = d.toLocaleDateString();\n"
);
ASSERT_JS_GLOBAL_EQUALS_S("s", "07/25/05");
}
void test_rocky_api_datetime__locale_... | ASSERT_JS_GLOBAL_EQUALS_S("s", "Jul") | |
iance 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,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either e... | (should_store == false) | ;
cl_assert(is_invalid == false);
data = HDLC_FLAG ^ HDLC_ESCAPE_MASK;
is_complete = hdlc_streaming_decode(&ctx, &data, &should_store, &is_invalid);
cl_assert(is_complete == false);
cl_assert(should_store == true);
cl_assert(is_invalid == false);
cl_assert(data == HDLC_FLAG);
}
void test_hdlc__encode_dec... |
"stubs_sleep.h"
#include "stubs_task_watchdog.h"
#include "stubs_vibe_score_info.h"
#include "stubs_vibes.h"
#include "stubs_window_manager.h"
#include "fake_new_timer.h"
#include "fake_pbl_malloc.h"
#include "fake_rtc.h"
#include "fake_spi_flash.h"
#define PREF_KEY_DND_MANUALLY_ENABLED "dndManuallyEnabled"
static i... | do_not_disturb_is_active() | == false);
bool enabled = do_not_disturb_is_manually_enabled();
cl_assert(enabled == false);
do_not_disturb_set_manually_enabled(true);
enabled = do_not_disturb_is_manually_enabled();
cl_assert(enabled == true);
cl_assert(do_not_disturb_is_active() == true);
prv_assert_manually_dnd_setting_val(true);
... |
to read it back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
name_out, &platform_bits_out);
cl_assert(!ret);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Local... | bt_persistent_storage_get_active_gateway(&id_out, &type_out) | ;
cl_assert(!ret);
ret = bt_persistent_storage_has_active_bt_classic_gateway_bonding();
cl_assert(!ret);
ret = bt_persistent_storage_has_active_ble_gateway_bonding();
cl_assert(!ret);
// Manually set the active gateway
bt_persistent_storage_set_active_gateway(id_1);
ret = bt_persistent_storage_get_acti... |
SS(workout_glance, title, NULL);
}
static void prv_workout_glance_subtitle_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *node, UNUSED const GRect *box,
UNUSED const GTextNodeDrawConfig *config, UNUSED bool render, char *buffer, size_t buffer_size,
void *user_data) {
LauncherAppGlanceS... | prv_set_glance_icon(workout_glance, prv_get_workout_icon_resource_id_for_type(workout_type)) | ;
// Zero out the glance's subtitle buffer
memset(workout_glance->subtitle, 0, sizeof(workout_glance->subtitle));
// Set subtitle
health_util_format_hours_minutes_seconds(workout_glance->subtitle,
sizeof(workout_glance->subtitle), workout_duration_s, true, workout_glance);
i18n_free_all(workout_glanc... |
96},
{ 640, 648, 64},
{ 640, 616, 72},
{ 648, 704, 72},
{ 632, 664, 72},
{ 632, 632, 56},
// 101 seconds
{ 640, 680, 64},
{ 656, 672, 72},
{ 640, 624, 56},
{ 648, 680, 40},
{ 648, 640, 40},
{ 640, 648, 48},
{ 640, 696, 56},
{ 640, 648, 40},
{ 648, 632, 40},
... | { 608, 416, 568},
{ 592, 488, 544},
{ 592, 552, 512},
{ 616, 584, 680},
{ 600, 560, 584},
{ 600, 456, 544},
// 107 seconds
{ 584, 400, 544},
{ 568, 456, 496},
{ 600, 408, 448},
{ 752, 608, -16},
{ 688, 784, 352},
{ 600, 696, 624},
{ 520, 680, 424},
{ 544, 280,... |
{ 600, 944, -8},
{ 520, 904, 208},
{ 496, 712, 224},
{ 472, 640, 232},
{ 488, 608, 232},
{ 552, 600, 248},
{ 600, 560, 256},
{ 600, 664, 368},
{ 648, 704, 352},
{ 592, 632, 320},
// 110 seconds
{ 552, 784, 464},
{ 536, 672, 496},
{ 512, 672, 464},
{ 576, 712,... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_draw_bitmap_in_rect_processed(ctx, src_bitmap, &rect, NULL) | |
-----------------------------------
//! Helper to reduces a 128-bit UUID to 32-bits. Note: this function does not
//! check whether the original UUID is based on the Bluetooth base.
static uint32_t prv_convert_to_32bit_uuid(const Uuid *uuid) {
uint32_t uuid_32bits = 0;
// Use bytes 0-3 of the Uuid:
for (int i = 0... | memcpy(element->data, data, size) | ;
return prv_write_element_to_ad_data(ad, (const BLEAdElement *) element);
}
// -----------------------------------------------------------------------------
bool ble_ad_set_flags(BLEAdData *ad, uint8_t flags) {
struct __attribute__((__packed__)) BLEAdElementManufacturerSpecific {
BLEAdElementHeader header;
... |
tUseDialog;
static void prv_alarms_app_opened_click_handler(ClickRecognizerRef recognizer, void *context) {
ExpandableDialog *expandable_dialog = context;
expandable_dialog_pop(expandable_dialog);
}
static void prv_push_alarms_app_opened_dialog(AlarmsAppData *data) {
const char *first_use_text = i18n_get(
... | (editor, true) | ;
app_window_stack_insert_next(&data->window);
}
#if CAPABILITY_HAS_HEALTH_TRACKING
uint32_t version = alarm_prefs_get_alarms_app_opened();
if (version == 0) {
prv_push_alarms_app_opened_dialog(data);
}
alarm_prefs_set_alarms_app_opened(CURRENT_ALARMS_APP_VERSION);
#endif
}
static void prv_handle_de... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_create() | ;
app_window_stack_push(window, true /* Animated */);
Layer *window_layer = window_get_root_layer(window);
text_heap_info = text_layer_create(window_layer->frame);
text_layer_set_text_color(text_heap_info, GColorWhite);
text_layer_set_background_color(text_heap_info, GColorBlack);
text_layer_set_font(text_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return interpolate_int16(animation_timing_scaled(normalized_progress, 0,
discontinuity_progress), 0, to);
} | else {
return interpolate_int16(animation_timing_scaled(normalized_progress, discontinuity_progress,
ANIMATION_NORMALIZED_MAX), -to, 0);
}
}
static void prv_port_hole_transition_animation_init(Animation *animation) {
animation_set_duration(animation, PORT_H... |
ult);
cl_assert_equal_i(result, 362);
}
static void *s_context = NULL;
static bool prv_filter(int index, int32_t value, void *context) {
cl_assert_equal_p(context, &s_context);
return (value > 0);
}
void test_stats__filtered_count(void) {
const int32_t data[] = { 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, ... | {
const int32_t data[] = { 0, 0, 0, 0, 0 };
const size_t num_data = ARRAY_LENGTH(data);
const StatsBasicOp op =
(StatsBasicOp_Sum | StatsBasicOp_Average | StatsBasicOp_Min | StatsBasicOp_Max |
StatsBasicOp_Count | StatsBasicOp_Consecutive | StatsBasicOp_ConsecutiveFirst |
StatsBasicOp_Me... |
void test_stats__all_basic_one_value(void) {
const int32_t data[] = { 42 };
const size_t num_data = ARRAY_LENGTH(data);
const StatsBasicOp op =
(StatsBasicOp_Sum | StatsBasicOp_Average | StatsBasicOp_Min | StatsBasicOp_Max |
StatsBasicOp_Count | StatsBasicOp_Consecutive | StatsBasicOp_Consecuti... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "State: Draw Non-Antialiased; SW: %d", data->stroke_width) | ;
break;
case APP_STATE_DRAW_AA_SW:
PBL_LOG(LOG_LEVEL_DEBUG, "State: Draw Antialiased; SW: %d", data->stroke_width);
break;
default:
PBL_LOG(LOG_LEVEL_DEBUG, "Unknown State");
break;
}
}
static bool stroke_width_enabled(AppStateIndex state_index) {
return ((state_index == APP_... |
/*
* 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... | led_controller_init() | ;
s_initialized = true;
}
}
// TODO: PBL-36077 Move to a generic 4v5 enable
void led_enable(LEDEnabler enabler) {
if (s_led_enable == 0) {
gpio_output_set(&BOARD_CONFIG_BACKLIGHT.ctl, true);
}
s_led_enable |= enabler;
}
// TODO: PBL-36077 Move to a generic 4v5 disable
void led_disable(LEDEnabler enabl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | rocky_global_has_event_handlers("secondchange") | );
cl_assert_equal_b(false, rocky_global_has_event_handlers("minutechange"));
cl_assert_equal_b(false, rocky_global_has_event_handlers("hourchange"));
cl_assert_equal_b(true, rocky_global_has_event_handlers("daychange"));
cl_assert_equal_i(1, s_tick_timer_service_subscribe.call_count);
cl_assert_equal_i(DAY_U... |
t8_t level, const char* src_filename, int src_line_number, const char* fmt, ...) {}
int time_util_get_num_hours(int hours, bool is24h) {return 0;}
bool sys_clock_is_24h_style(void) {return false;}
void event_service_init(PebbleEventType type, EventServiceAddSubscriberCallback start_cb,
EventSe... | (early_wakeup_id) | , early_event);
cl_assert_equal_i(early_wakeup_id, wakeup_get_next_scheduled());
// Set time 5 minutes into the future, early_event should fire
rtc_set_time(early_event);
// Force wakeup to check for current wakeup event.
wakeup_enable(false);
wakeup_enable(true);
// Simulate the firing of the early e... |
ame);
// Blocked/unknown numbers on Android start with a '-'
if ((name[0] == '-') || (length == 0)) {
return false;
}
for (size_t i = 0; i < length; ++i) {
unsigned char chr = name[i];
if ((chr != '(') && (chr != ')') && (chr != '+') && (chr != ' ') && (chr != '-') && (chr != '.')
&& !isdi... | light_enable_interaction() | ;
}
}
static void prv_start_ringing(void) {
alerts_incoming_alert_analytics();
s_phone_ui_data->ring_timer = (const RegularTimerInfo) {
.cb = prv_ring,
};
unsigned int vibe_repeat_interval_sec;
#if CAPABILITY_HAS_VIBE_SCORES
s_phone_ui_data->vibe_score = vibe_client_get_score(VibeClient_PhoneCalls);
... |
= s_tx_window_size - 1), which will be interpreted as Ack'ing all
// the packets before it too:
prv_receive_ack(s_characteristics[0][PPoGATTCharacteristicData],
s_tx_window_size - 1 /* sn */);
// We should now be able to submit s_tx_window_size packets again:
for (sn = s_tx_window_size; sn < ... | ppogatt_client_for_uuid(&s_meta_v0_system.app_uuid) | |
_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
// All of our tests start at 5pm. Let's enter a sleep cycle where the user has a sleep session
// before the cut-off for the new day
// Light walking, 50 steps/minute, until 6pm
prv_feed_cannned_accel_data(1 * SECONDS_PER_HOUR... | cl_assert(enabled) | ;
cl_assert_equal_i(num_samples, 0);
// Feed in 510 values to test entire dynamic range
const int k_raw_samples = 510;
AccelRawData raw_data[k_raw_samples];
int value = 0;
for (int i = 0; i < k_raw_samples; i++) {
// We store multiples of 8 because the compression algorithm divides by 8.
... |
/*
* 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 (uint16_t) ARRAY_LENGTH(s_tests);
} |
static void prv_draw_row(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index,
void *callback_context) {
PBL_ASSERTN(cell_index->row < ARRAY_LENGTH(s_tests));
menu_cell_title_draw(ctx, cell_layer, s_tests[cell_index->row]->name);
}
static void prv_click_handler(struct MenuLayer ... |
/*
* 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... | OS_ASSERT(!mcu_state_is_isr()) | ;
TickType_t timeout_ticks = milliseconds_to_ticks(timeout_ms);
LightMutexHandle_t mutex = handle->common.freertos_mutex;
if (xLightMutexLock(mutex, timeout_ticks) == pdTRUE) {
LOG_LOCKED(handle->common.lr, myLR);
return (true);
}
return (false);
}
void mutex_lock_with_lr(PebbleMutex * handle, uin... |
of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the sp... | {
WTF;
return NULL;
} | |
ns off right after we leave the app.
void test_workout_service__app_open_wait_close_valid_workout(void) {
// Put some time into the clock
prv_inc_time(1 * SECONDS_PER_MINUTE);
// Open the app, confirm that we are now subscribed with no end in sight
workout_service_frontend_opened();
cl_assert_equal_b(s_hrm_s... | cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 10) | ;
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone1], 20);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone2], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 10);
// Unpause workout
cl_assert(workout_service_pause_workout(false));
prv_inc_time(10);
prv_put_bpm_event(ZONE_3_HR, HRMQuality_Good);
cl_assert... |
"stubs_window_stack.h"
// Setup and Teardown
////////////////////////////////////
void test_selection_windows__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
test_graphics_context_init(&s_ctx, fb);
framebuffer_clear(fb);
load_system_resources_fix... | gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE) | );
}
void test_selection_windows__time_range_selection_window(void) {
prv_prepare_canvas_and_render_for_each_size(prv_render_time_range_selection_window);
cl_check(gbitmap_pbi_eq(s_dest_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... | fake_gatt_init() | ;
fake_event_init();
gap_le_connection_init();
}
void test_gatt_client_accessors__cleanup(void) {
gap_le_connection_deinit();
}
void test_gatt_client_accessors__copy_service_refs(void) {
BTDeviceInternal device = prv_connected_dummy_device(1);
// Start discovery:
cl_assert_equal_i(gatt_client_discovery_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... | {
// A bogus intensity returns NULL
cl_assert_equal_p(vibe_intensity_get_string_for_intensity(VibeIntensityNum), NULL);
cl_assert_equal_s(vibe_intensity_get_string_for_intensity(VibeIntensityLow), "Standard - Low");
cl_assert_equal_s(vibe_intensity_get_string_for_intensity(VibeIntensityMedium),
... |
void test_vibe_intensity__cycle_next(void) {
// Low -> Medium
cl_assert(vibe_intensity_cycle_next(VibeIntensityLow) == VibeIntensityMedium);
// Medium -> High
cl_assert(vibe_intensity_cycle_next(VibeIntensityMedium) == VibeIntensityHigh);
// High -> Low
cl_assert(vibe_intensity_cycle_next(VibeIntensityH... |
cl_assert(parent.first_child == &child_a);
layer_add_child(&parent, &child_b);
cl_assert(parent.first_child == &child_a);
cl_assert(child_a.next_sibling == &child_b);
cl_assert(child_a.parent == &parent);
cl_assert(child_b.parent == &parent);
layer_add_child(&parent, &child_c);
cl_assert(child_c.parent... | cl_assert(child_c.next_sibling == &child_a) | ;
cl_assert(child_a.next_sibling == NULL);
}
void test_layer__traverse(void) {
Layer *stack[5];
uint8_t current_stack = 0;
Layer *a = layer_create(GRectZero);
Layer *aa = layer_create(GRectZero);
Layer *aaa = layer_create(GRectZero);
Layer *aaaa = layer_create(GRectZero);
Layer *ab = layer_create(GRec... |
if (gsize_equal(&rect.size, &icon_frame_size)) {
// round has never worked with legacy2 apps
static const bool is_legacy2 = false;
// Reuse container_rect as icon frame
container_rect = (GRect) {
.origin = rect.origin,
.size = icon_bitmap_size,
};
if (config->icon... | (
ctx, config->value, value_font, *cell_layer_bounds, config->overflow_mode,
GTextAlignmentRight, NULL) | ;
} else {
right_element_size = icon_size;
}
// We reuse this rect to save stack space; here it is the rect of the left column content
GRect rect = *cell_layer_bounds;
prv_grect_inset(&rect, &GEdgeInsets(0, right_element_size.w, 0, 0));
// We overwrite rect to store the rect of the title text frame dra... |
{ 1024, 192, -120},
{ 1000, 216, -32},
{ 1312, 144, 0},
{ 1264, 208, -192},
{ 1144, 144, -160},
{ 1224, 120, -56},
{ 1208, 168, -184},
{ 1280, 184, -232},
{ 1400, 224, -320},
{ 1008, 216, -368},
// 29 seconds
{ 688, 184, -256},
{ 696, 224, -224},
{ 776, 264, -152... | { 1288, 112, -112},
{ 1160, 144, -272},
{ 1304, 168, -352},
{ 1160, 200, -320},
{ 880, 208, -192},
{ 808, 280, -176},
{ 864, 328, -80},
{ 936, 360, -104},
{ 976, 360, -136},
{ 1040, 384, -128},
{ 1384, 432, 0},
{ 1208, 512, 40},
{ 1064, 680, -136},
{ 1376, 744, -3... |
{ -160, -240, -1144},
{ -40, -16, -1064},
{ -80, -56, -800},
{ -144, -176, -600},
// 37 seconds
{ -56, 104, -776},
{ -32, 328, -968},
{ -96, 248, -816},
{ -128, 40, -560},
{ 8, -72, -456},
{ 224, -32, -384},
{ 592, 56, -304},
{ 1376, 144, -120},
{ 2248, 416, 216}... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.