prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
lth_card_view->window)->bounds;
Layer *current_card_layer = health_card_view->card_layers[health_card_view->current_card_index];
Layer *next_card_layer = health_card_view->card_layers[next_card_index];
GRect curr_stop = window_bounds;
curr_stop.origin.y = slide_up ? window_bounds.size.h : -window_bounds.size.... | prv_set_window_background_color(health_card_view) | ;
// position current card
layer_set_frame(health_card_view->card_layers[health_card_view->current_card_index],
&window_root->frame);
// setup select indicator
layer_init(&health_card_view->select_indicator_layer, &window_root->frame);
layer_add_child(window_root, &health_card_view->select... |
i) {
if (!(button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK))) {
// stop waiting if not held down any longer
return false;
}
delay_ms(1);
}
return true;
}
void *reset_vector, *initial_sp;
prv_get_fw_reset_vector(&reset_vector, &initial_sp);
if ((uin... | for (uint32_t i=0; i <= 0xf; ++i) {
display_error_code(i * 0x11111111);
delay_us(200000);
} |
for (uint32_t i=0; i < 8; ++i) {
for (uint32_t j=1; j <= 0xf; ++j) {
display_error_code(j << (i*4));
delay_us(200000);
}
}
display_error_code(0x01234567);
delay_us(200000);
display_error_code(0x89abcdef);
delay_us(200000);
display_error_code(0xcafebabe);
dela... |
384, -664},
{ -152, -368, -672},
{ -112, -344, -736},
{ -104, -352, -824},
{ -168, -352, -928},
{ -216, -376, -976},
{ -160, -392, -1160},
{ -184, -296, -1312},
{ -232, -248, -1216},
{ -128, -184, -1192},
{ -208, -120, -1120},
{ -288, -80, -952},
// 65 seconds
{ -224,... | { 64, 1032, 520},
{ 104, 1144, 632},
{ 40, 1064, 664},
{ 168, 808, 608},
{ 136, 696, 680},
{ 112, 744, 688},
{ 8, 760, 536},
{ 80, 552, 360},
{ 184, 496, 232},
{ 216, 480, 304},
{ 152, 648, 344},
{ 128, 744, 416},
{ 88, 864, 520},
{ 128, 952, 488},
{ 216, 1072... |
{ -104, 632, 120},
{ 120, 448, 96},
{ 256, 416, 64},
// 73 seconds
{ 360, 440, 64},
{ 352, 488, 80},
{ 384, 552, 128},
{ 472, 632, 120},
{ 472, 800, 160},
{ 440, 840, 344},
{ 536, 1200, 544},
{ 328, 1296, 664},
{ 304, 1064, 536},
{ 328, 968, 448},
{ 224, 880,... |
28},
{ -224, 272, -696},
{ -160, 480, -1000},
{ -336, 336, -936},
{ -216, 408, -976},
{ -224, 344, -1136},
{ -152, 288, -872},
{ -88, 488, -888},
{ -32, 264, -1016},
{ -88, 304, -1040},
{ -208, 496, -1080},
{ -224, 320, -1088},
{ -112, 544, -936},
{ -104, 272, -952},
... | { -272, 96, -1104},
{ -192, 296, -984},
{ -144, 248, -944},
{ -168, 144, -1048},
{ -288, 176, -896},
{ -232, 216, -976},
{ -216, 232, -768},
// 259 seconds
{ -152, 272, -968},
{ -168, 152, -928},
{ -176, 192, -976},
{ -152, 224, -992},
{ -152, 240, -1048},
{ -192,... |
{ -296, 480, -984},
{ -232, 424, -912},
{ -200, 336, -1008},
{ -216, 368, -960},
{ -184, 344, -888},
{ -256, 312, -872},
{ -232, 336, -688},
{ -160, 344, -944},
{ -192, 208, -752},
{ -136, 400, -1056},
{ -256, 232, -880},
{ -168, 576, -944},
{ -248, 448, -1024},
... |
include "stubs_mutex.h"
#include "stubs_hexdump.h"
#include "stubs_passert.h"
// Fakes
///////////////////////////////////////////////////////////
static TimerID s_debounce_timer;
static bool s_default_connection_state;
static unsigned int s_event_count = 0;
static PebbleEvent s_cached_event;
static Transport *s_tra... | check_waiting_to_send_disconnect() | ;
// No event put
cl_assert_equal_i(s_event_count, 0);
//! Get connected event before timer fires
prv_send_connection_event(true);
check_connected();
// No event put
cl_assert_equal_i(s_event_count, 0);
}
|
e as analog inputs to save some power
// SCLK
InputConfig sclk = { .gpio = bus->spi_sclk.gpio, .gpio_pin = bus->spi_sclk.gpio_pin };
gpio_analog_init(&sclk);
// MOSI
InputConfig mosi = { .gpio = bus->spi_mosi.gpio, .gpio_pin = bus->spi_mosi.gpio_pin };
gpio_analog_init(&mosi);
// MISO
if (is_bidirect... | (slave->spi_bus, prv_is_bidrectional(slave)) | |
wake until 11:45pm
rtc_set_time(rtc_get_time() + 15 * SECONDS_PER_MINUTE);
s_data.metric_history[ActivityMetricSleepState][0] = ActivitySleepStateAwake;
s_data.metric_history[ActivityMetricSleepStateSeconds][0] = 15 * SECONDS_PER_MINUTE;
// Should generate a pin
activity_insights_process_sleep_data(rtc_get_t... | rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR) | ;
prv_add_sleep_session(0.5, 1.5);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 2);
cl_assert(uuid_equal(&orig_id, &s_last_timeline_id));
// Nap sessions shouldn't be added
rtc_set_time(rtc_get_time() + 3 * SECONDS_PER_HOUR);
prv_add_nap_session(2, 1);
acti... |
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test odd and even rows draw appropriately
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 12), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 23), 10);
graphics_... | (&ctx, fb, OFFSET_RECT_ODD, OFFSET_RECT_ODD, false, 1) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 12), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(6, 23), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 13), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 24), 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_N... |
.started = prv_started_handler,
.stopped = prv_stopped_handler_reschedule
};
memset(&layer, 0, sizeof(layer));
from_r = GRect(0, 0, 100, 200); // x, y, width, height
to_r = GRect(1000, 2000, 100, 200); // x, y, width, height
prop_h = property_animation_create_layer_frame(&layer, &from_r, &to_r);
... | property_animation_get_animation(prop_h) | ;
void *context = &layer;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
prv_clear_handler_histories();
animation_schedule(h);
int max_loops = 20;
uint64_t start_ms = prv_now_ms();
bool detected_reset_of_elapsed = false;
bool reached_end_elapsed = false;
uint64... |
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 "gpath.h"
#include "graphics.h"
#include "graphics_private.h"
#inclu... | gpath_draw_stroke(ctx, path, false) | ;
}
void gpath_draw_outline_open(GContext* ctx, GPath* path) {
gpath_draw_stroke(ctx, path, true);
}
void gpath_draw_stroke(GContext* ctx, GPath* path, bool open) {
if (!path || path->num_points < 2) {
return;
}
// for each line segment (do not draw line returning to the first point if open is true)
for... |
ontentSizeExtraLarge] = FONT_KEY_GOTHIC_18_BOLD,
};
void text_layer_init_with_parameters(TextLayer *text_layer, const GRect *frame, const char *text,
GFont font, GColor text_color, GColor back_color,
GTextAlignment text_align, GTextOverflowMode ... | (text_layer) | ;
if (should_cache_layout == text_layer->should_cache_layout) {
return;
}
text_layer->should_cache_layout = should_cache_layout;
if (text_layer->should_cache_layout) {
PBL_LOG(LOG_LEVEL_DEBUG, "Init layout");
graphics_text_layout_cache_init(&text_layer->layout_cache);
} else {
graphics_text_... |
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 "applib/app.h"
#include "applib/tick_timer_service.h"
#include "util/trig.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui... | app_state_set_user_data(data) | ;
Window *window = &data->window;
window_init(window, "");
window_set_fullscreen(window, true);
window_set_overrides_back_button(window, true);
window_set_click_config_provider(window, prv_config_provider);
TextLayer *title = &data->title;
text_layer_init(title, &window->layer.bounds);
text_layer_set_... |
/*
* 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... | {
BTErrno rv = BTErrnoOK;
HcGattHdr *hdr = (HcGattHdr *)&msg->payload[0];
Connection *conn = connection_by_address(&hdr->addr);
if (!conn) {
rv = BTErrnoInvalidParameter;
goto respond;
}
const uint16_t conn_idx = connection_get_idx(conn);
if (ppogatt_emulated_server_handle_msg(conn_idx, conn, ms... | |
/*
* 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 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... | {
MorphSquareData *data = context;
AnimationProgress curved;
if (!kino_reel_transform_get_to_reel(data->reel)) {
curved = animation_timing_curve(normalized, AnimationCurveEaseInOut);
} else if (normalized < ANIMATION_NORMALIZED_MAX / 2) {
curved = animation_timing_curve(2 * normalized, AnimationCurveEa... |
static const TransformImpl MORPH_SQUARE_TRANSFORM_IMPL = {
.destructor = prv_destructor,
.apply = prv_apply_transform,
};
KinoReel *kino_reel_morph_square_create(KinoReel *from_reel, bool take_ownership) {
MorphSquareData *data = applib_malloc(sizeof(MorphSquareData));
if (!data) {
return NULL;
}
GR... |
agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kernel/pbl_malloc.h"
#... | QEMU_LOG_DEBUG("got header signature LSB") | ;
} else {
state->recv_state = QemuRecvState_WaitingHdr;
}
}
break;
case QemuRecvState_WaitingHdr: {
// We already read in the header signature
uint16_t req_bytes = sizeof(state->hdr) - sizeof(state->hdr.signature);
if (bytes_avail < req_bytes) {
... |
_HZ)), ticks_to_time(s_coarse_ticks));
//save_rtc_time_state(0);
}
void rtc_init(void) {
periph_config_acquire_lock();
rtc_enable_backup_regs();
periph_config_release_lock();
restore_rtc_time_state();
initialize_fast_mode_state();
#ifdef PBL_LOG_ENABLED
char buffer[TIME_STRING_BUFFER_SIZE];
PBL_LOG(L... | RTC_AlarmCmd(RTC_Alarm_A, ENABLE) | ;
RTC_ClearFlag(RTC_FLAG_ALRAF);
EXTI_ClearITPendingBit(EXTI_Line17);
RTC_ClearITPendingBit(RTC_IT_ALRA);
}
RtcTicks rtc_alarm_get_elapsed_ticks(void) {
return rtc_get_ticks() - s_alarm_set_time;
}
bool rtc_alarm_is_initialized(void) {
return s_tick_alarm_initialized;
}
//! Handler for the RTC alarm inte... |
ColorRed.b == 0b00);
cl_assert(GColorRed.a == 0b11);
}
void test_graphics_colors__green(void) {
cl_assert(GColorGreen.r == 0b00);
cl_assert(GColorGreen.g == 0b11);
cl_assert(GColorGreen.b == 0b00);
cl_assert(GColorGreen.a == 0b11);
}
void test_graphics_colors__blue(void) {
cl_assert(GColorBlue.r == 0b00);... | gcolor_get_bw(GColorClear) | .argb);
cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_bw(GColorWhite).argb);
cl_assert_equal_i(GColorBlackARGB8, gcolor_get_bw(GColorBlack).argb);
cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_bw(GColorLightGray).argb);
cl_assert_equal_i(GColorBlackARGB8, gcolor_get_bw(GColorDarkGray).argb);
cl_assert_equal... |
ptr;
consumer_info->it = inbox->buffer.storage;
consumer_info->end = inbox->buffer.storage + remaining_size;
if (remaining_size) {
// New data has been written in the mean-time, move it all to the front of the buffer:
memmove(inbox->buffer.storage, consumed_up_to_ptr, remaining_size);
}
... | PBL_LOG(LOG_LEVEL_ERROR, "AppInbox already registered for tag <%d>", tag) | ;
has_error = true;
}
if (has_error) {
kernel_free(new_node);
new_node = NULL;
} else {
new_node->tag = tag;
new_node->message_handler = message_handler;
new_node->dropped_handler = dropped_handler;
new_node->event_handler_task = pebble_task_get_current();
ne... |
orage_set_unfaithful(false);
ret = bt_persistent_storage_is_unfaithful();
cl_assert(!ret);
}
void test_bluetooth_persistent_storage__test_root_keys(void) {
SM128BitKey keys[2] = {
{{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16}},
{{0x21, 0x22, 0x23, 0x14, 0x15,... | (id_2, NULL, NULL, NULL, NULL) | ;
cl_assert(!ret);
ret = bt_persistent_storage_get_ble_pairing_by_id(id_3, NULL, NULL, NULL);
cl_assert(!ret);
ret = bt_persistent_storage_get_ble_pairing_by_id(id_4, NULL, NULL, NULL);
cl_assert(!ret);
}
// Test to make sure we don't accidentally change the serialized data formats.
void test_bluetooth_persi... |
/*
* 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... | gdraw_command_sequence_get_frame_by_elapsed(sequence, elapsed) | ;
if (!frame) {
return;
}
// Original SVGs use Islamic Green for the overdraw color, if we are filling the inner ring
// if it's the outer ring (inner == false) this "key color" is GColorGreen,
// also we don't render the app's framebuffer in this case
// it's a bit weird but just they way how these S... |
/*
* 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(session_id == s_session_id);
} |
Transport *s_transport;
void test_audio_endpoint__initialize(void) {
fake_comm_session_init();
s_setup_complete_call_count = 0;
s_transport = fake_transport_create(TransportDestinationSystem, NULL, NULL);
s_session = fake_transport_set_connected(s_transport, true);
s_session_id = audio_endpoint_setup_tran... |
= {0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 100*60,
.duration = 10,
.type = TimelineItemTypePin,
.all_day = true,
.layout = LayoutIdCalendar,
},
.attr_list = {
.num_attributes = 1,
.attributes = &title_attr,... | (!stub_new_timer_is_scheduled(timer_id)) | ;
}
void test_calendar_handle__past_event_added_and_removed(void) {
rtc_set_time(30 * 60);
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1);
cl_assert(!prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get_next();
cl_assert_equal_i(timer_id, TIMER_INVALID_ID);
cl_assert(!s... |
ing insights settings");
if (s_pfs_cb_handle) {
activity_insights_settings_unwatch(s_pfs_cb_handle);
}
if (!activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD,
&s_activity_reward_settings)) {
s_activity_reward_settings.enabled = false; // wo... | INSIGHTS_LOG_DEBUG("Last sleep reward state: %ld",
s_sleep_reward_state.common.last_triggered_utc) | ;
INSIGHTS_LOG_DEBUG("Last activity reward state: %ld",
s_activity_reward_state.common.last_triggered_utc);
// Recalculate metric stats
activity_insights_recalculate_stats();
// If the pin we loaded was created on the previous day, we don't bother loading the UUID
const time_t midnight_... |
"
#include "kernel/events.h"
#include "system/logging.h"
#include "util/attributes.h"
#include "util/math.h"
#include <stddef.h>
#include <limits.h>
extern AppTimer *app_message_outbox_get_ack_nack_timer(void);
// Stubs
////////////////////////////////////
#include "stubs_logging.h"
#include "stubs_passert.h"
#inclu... | cl_assert_equal_p(context, &s_context) | ;
prv_assert_dict_equal(sent, &s_expected_iter);
// When the outbox sent callback is called, the outbox should be in the
// ACCEPTING state again.
cl_assert_equal_b(app_message_is_accepting_outbound(), true);
}
static void prv_out_failed_callback(DictionaryIterator *failed,
AppMessageResult reason, vo... |
ActivitySession *sessions) {
}
void activity_algorithm_minute_handler(time_t utc_sec, AlgMinuteRecord *record_out) {
s_test_alg_state.last_sleep_utc = utc_sec;
record_out->data.base.orientation = s_test_alg_state.orientation;
}
bool activity_algorithm_dump_minute_data_to_log(void) ... | {
num_steps--;
} | |
VoiceEventTypeSessionResult, status, NULL);
return false;
}
// Make sure that if this is an app initiated session, we're expecting a response for an app
// initiated session and that if this is an app initiated session, the app UUID matches the
// expected UUID
if ((app_initiated != s_from_app) || (s_fro... | if (s_from_app && (s_session_id != AUDIO_ENDPOINT_SESSION_INVALID_ID)) {
prv_cancel_session();
} |
mutex_unlock(s_lock);
}
|
t_equal_i(s_num_alarm_events_put, 2);
cl_assert_equal_i(s_num_timeline_adds, 5);
cl_assert_equal_i(s_num_timeline_removes, 3);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm__custom_alarm_everyday(void) {
AlarmId id1;
bool schedule_1[7] = {true, true, true... | cl_assert_equal_i(s_num_timeline_adds, 6) | |
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_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("2 MIN AGO", time_buf);
// June 9th 2015, 15:00:00 (T-01:00:00)
rtc_set_time(event_time - (... | rtc_set_time(event_time - (1 * SECONDS_PER_MINUTE)) | ;
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("In 1 minute", time_buf);
// June 9th 2015, 15:58: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_asser... |
bi"));
}
#define RADIUS_BIG 15
#define RADIUS_MEDIUM 8
#define RADIUS_MIN_CALCULATED 3
#define RADIUS_MAX_PRECOMPUTED 2
#define RADIUS_SMALL 1
#define RADIUS_NONE 0
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 30, 40)
#define ORIGIN_RECT_CLIP_NXNY GRect(... | GRect(10, 15, 28, 28) | |
[TestString_Worst] = {
.string = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%%^&*()_+QWERTYUIOP{}|A"
"SDFGHJKL:\"ZXCVBNM<>?èéêëēėęÿûüùúūîïíī"
"įìôöòóœøōõàáâäæãåāßśšłžźżçćčñń∑´®†¥¨ˆπ"
"∂ƒ©˙∆˚¬…Ω≈√∫˜µ≤≥÷¡™£¢∞§¶•ªº–≠`“‘"
"«ÈÉÊËĒĖĘŸÛÜÙÚŪÎÏÍĪĮÌÔÖÒÓŒØŌÕÀ... | if (strcmp(s_perftest_text_arguments.string_type, "typical") == 0) {
text_index = TestString_Typical;
} else {
prompt_send_response("Incorrect type argument, must be 'best', 'typical', or 'worst'.");
return;
} |
if (strcmp(s_perftest_text_arguments.font_key, "RESOURCE_ID_GOTHIC_18") == 0) {
font_index = TestStringFont_Gothic18;
} else if (strcmp(s_perftest_text_arguments.font_key, "RESOURCE_ID_GOTHIC_24_BOLD") == 0) {
font_index = TestStringFont_Gothic24B;
} else {
font_index = TestStringFont_Other;
}
#if... |
/*
* 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, "App idle timeout hit! launching watchface") | ;
launcher_task_add_callback(prv_kernel_callback_watchface_launch, NULL);
}
static void prv_start_timer(bool create) {
if (create) {
s_timer = new_timer_create();
}
if (s_timer != TIMER_INVALID_ID && !s_app_paused && s_app_started) {
bool success = new_timer_start(s_timer, WATCHFACE_TIMEOUT_MS, prv_ti... |
0) {
return;
}
// Make sure it's not before the trigger time and the pin hasn't already been removed
const int minute_of_day = time_util_get_minute_of_day(now_utc);
if ((minute_of_day < s_activity_summary_settings.summary.activity.trigger_minute) ||
s_activity_pin_state.removed) {
INSIGHTS_LOG_D... | ("Keepin' that heart healthy! ❤") | ,
},
};
return prv_get_variant(&s_open_intros, VARIANT_RANDOM);
}
default: {
break;
}
}
return "";
}
// ------------------------------------------------------------------------------------------------
static const char *prv_get_distance_unit(void *i18n_owner) {
return heal... |
}
prev = result;
result = result->next;
}
}
//! Finds ScanResult based on BTDevice. If found, unlink and return ScanResult.
static ScanResult *list_unlink(const BTDevice *device) {
ScanResult *prev = NULL;
ScanResult *result = s_head;
while (result) {
if (bt_device_equal(&result->device, device)... | list_link_sorted_by_rssi(result) | ;
// Tell the menu to update:
menu_layer_reload_data(s_menu_layer);
}
void toggle_scan(void) {
if (s_is_scanning) {
ble_scan_stop();
s_is_scanning = false;
} else {
ble_scan_start(ble_scan_handler);
s_is_scanning = true;
}
menu_layer_reload_data(s_menu_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... | (rocky, ROCKY_LISTENERS,
rocky_creator_object,
NULL, NULL) | ;
return rocky_get_or_create_object(all_listeners, event_name,
rocky_creator_empty_array,
NULL, NULL);
}
// callback while iterating over listeners
// @param event_listeners the array this listener is part of
// @param idx position within the ar... |
nclude "fake_gatt_client_subscriptions.h"
#include "fake_pebble_tasks.h"
#include "fake_rtc.h"
#include "stubs_app_install_manager.h"
#include "stubs_app_manager.h"
#include "stubs_bt_lock.h"
#include "stubs_hexdump.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_m... | cl_assert_equal_s(music_get_connected_server_debug_name(), NULL) | |
the boxes caused by the inset need to overlap each other
return box->origin.x + box->size.w - bar_inset;
}
static bool prv_bar_should_be_wide(int draw_weekday, int current_weekday) {
// The graph begins on Monday, so all bars from Monday until current (inclusive) should be wide
return (positive_modulo(draw_week... | (graph_card, ctx, graph_card->stats.weekend.avg, bounds->size.w - weekend_width,
weekend_width) | ;
}
static int32_t prv_get_info_data_point(HealthGraphCard *graph_card) {
// Show today's data point if the selection is a day of the week, otherwise show the weekday
// average if the current day is a weekday or weekend average if the current day is on the weekend
if (graph_card->selection == HealthGraphIndex_A... |
f:
//! - The app manager was not init,
//! - The app's task handle or event queue aren't null
//! - The app's metadata is null
static bool prv_app_start(const PebbleProcessMd *app_md, const void *args,
const AppLaunchReason launch_reason) {
PBL_ASSERT_TASK(PebbleTask_KernelMain);
PBL_ASSERTN(app_md)... | PBL_LOG(LOG_LEVEL_ERROR, "App state configuration failed") | ;
return false;
}
// The remaining space in app_segment is assigned to the app's heap.
// app_state needs to be configured before initializing the app heap
// as the AppState struct holds the app heap's Heap object.
// Don't fuzz 3rd party app heaps because likely many of them rely on accessing free'd me... |
d[i].x; yp = d[i].y; zp = d[i].z;
x += xr;
y += yr;
z += zr;
}
x /= (int)num_samples;
y /= (int)num_samples;
z /= (int)num_samples;
// TODO: could this ever be called in the middle of ecompass_service_handle?
// map accel data to NED coordinate system
s_accel_data.x = y;
s_accel_dat... | (&s_cb_info, 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... | (&session->timeout_timer) | ;
} else {
system_task_add_callback(prv_handle_response_from_phone, session);
}
return 12345;
}
BlobDBToken blob_db_endpoint_send_write(BlobDBId db_id,
time_t last_updated,
const void *key,
... |
/*
* 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(0, 0, 640, 64) | ;
static const GRect BITMAP_LAYER_BOUNDS = GRect(-32, 0, 640, 64);
static const GRect BITMAP_BOUNDS = GRect(0, 0, 640, 64);
GBitmap bitmap = {
.bounds = BITMAP_BOUNDS,
};
BitmapLayer layer;
bitmap_layer_init(&layer, &BITMAP_LAYER_FRAME);
bitmap_layer_set_bitmap(&layer, &bitmap);
// set bounds with... |
TextNodeVertical *)prv_create_container(GTextNodeType_Vertical,
sizeof(GTextNodeVertical), max_nodes);
}
GTextNodeCustom *graphics_text_node_create_custom(GTextNodeDrawCallback callback,
void *user_data) {
GTextNodeC... | (ctx->gcontext, &text_node->text.node, &ctx->box, ctx->config, ctx->render,
(char *)text_node->text.text, text_node->buffer_size, text_node->user_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... | GPoint(1, 13) | , 3686401, 5,
&GPointZero, 0, 0, true);
}
void test_touch__handle_update_liftoff(void) {
// Test first touch
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 3686380, 0);
touch_handle_update(0, TouchState_FingerUp, &GPoint(15, 100), 0, 3686400);
PebbleEvent event = fake_event_... |
r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 4.5, 4.5);
cl_assert_fixedS16_3(radius, 4.5);
r = GRect(1, 1, 9, 9);
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 5, 5);
cl_assert_fixedS16_3(radius, 4);
r = GRect(2, 2, 8, 8);
grect_polar_calc_values... | (DEG_TO_TRIGANGLE(0), 0) | ;
}
void test_graphics_circle__TRIGANGLE_TO_DEG(void) {
cl_assert_equal_i(TRIGANGLE_TO_DEG(TRIG_MAX_ANGLE * 2), 720);
cl_assert_equal_i(TRIGANGLE_TO_DEG(-TRIG_MAX_ANGLE * 2), -720);
cl_assert_equal_i(TRIGANGLE_TO_DEG(TRIG_MAX_ANGLE), 360);
cl_assert_equal_i(TRIGANGLE_TO_DEG(-TRIG_MAX_ANGLE), -360);
cl_asse... |
.h"
#include "stubs_system_reset.h"
#include "stubs_task_watchdog.h"
#include "stubs_memory_layout.h"
static bool s_prefs_24h_style;
#define TIMEZONE_FIXTURE_PATH "timezones"
// Setup
/////////////////////////
void test_clock__initialize(void) {
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(fa... | rtc_get_time() | |
snprintf(dstbuf, 256, "%.*dzero%.*d", -3, 0, -3, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Length modifiers
int64_t hurf = 0x123456789ABCDEF0ULL;
snprintf(dstbuf, 256, "%hhd,%hd,%d,%ld", hurf, hurf, hurf, hurf);
cl_assert_equal_s(dstbuf, "-16,-8464,-1698898192,-1698898192");
snprintf(dstbuf, 256, "%lld,... | snprintf(dstbuf, 256, "There are %2u lights, %2u", 4, -4) | ;
cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292");
// Space for positive signed
// No signed conversion occurs, so this is a no-op
snprintf(dstbuf, 256, "There are % u lights, the absolute value of % u", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, the absolute value of 4294967292");
... |
mer_id()), 1800 * MS_PER_SECOND);
rtc_set_time(s_saturday_00_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Saturday. (0.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 1800 * MS_PER_SECOND)... | (stub_new_timer_timeout(get_dnd_timer_id()), 36000 * MS_PER_SECOND) | ;
rtc_set_time(s_saturday_10_30);
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. (13.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 48600 * MS_PER_SECOND);
rtc_set_time(s_sunday_9_30)... |
block_size = file_size / 4;
int erase_count = block_size / notif_size + (((block_size % notif_size) > 0) ? 1 : 0);
int j;
for (j = 0; 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);
}
e.header.i... | (notification_storage_find_ancs_notification_id(84, &u)) | ;
cl_assert(uuid_equal(&u, &e3.header.id));
// Add a new notification with the same ANCS UID as an existing notification to make sure we
// return the new notification instead of the old one
TimelineItem e4 = e3;
uuid_generate(&e4.header.id);
notification_storage_store(&e4);
cl_assert(notification_storag... |
/*
* 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... | gdraw_command_image_attract_to_square(l, t += dt) | ;
gdraw_command_image_draw(&ctx, l, GPoint(0, 48));
l = weather_app_resource_create_sun();
gdraw_command_image_attract_to_square(l, t += dt);
gdraw_command_image_draw(&ctx, l, GPoint(48, 48));
l = weather_app_resource_create_sun();
gdraw_command_image_attract_to_square(l, t += dt);
gdraw_command_image_d... |
e can push `data` into the circular cache.
memcpy(font_cache->glyph_buffer, data, sizeof(LineCacheData));
font_cache->glyph_buffer_key = cache_key;
final_data = (LineCacheData *)(font_cache->glyph_buffer);
#else
final_data = data;
#endif
if (need_bitmap &&
!prv_load_glyph_bitmap(codepoint, font_res, f... | {
// Assuming we are using base
FontInfo *emoji_font = fonts_get_system_emoji_font_for_size(font_info->max_height);
if (emoji_font) {
return &emoji_font->base;
}
} |
return (&font_info->base);
}
static void prv_resource_changed_callback(void *data) {
FontInfo *font_info = (FontInfo *)data;
font_info->loaded = false;
font_info->extended = false;
}
///////////////////////////
// Public API
bool text_resources_init_font(ResAppNum app_num, uint32_t font_resource,
... |
/*
* 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_encode_char(((data[i] & 0x03) << 4) | (data[i + 1] >> 4)) | |
token) + 1, "%s", state->test_entry.name);
}
}
// If this is a "static AccelRawData samples[] = {" line, skip it
if (strcmp(token, "static") == 0) {
continue;
}
// Grab a sample
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
int x, y, z;
... | strcmp(token, "TEST_END_AT_MIN") | == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.end_at.min);
} else if (strcmp(token, "TEST_END_AT_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.end_at.max);
} else if (strcmp(token, "TEST_CUR_STATE_ELAPSED") == 0) {
sscanf(token + str... |
health_data);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_sleep_summary_card__render_sleep_late_start_early_end2(void) {
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
HealthData health_data = {
// Used for text
.sleep_data[0] = (8 * SECONDS_PER_H... | (s_now_utc) | ;
HealthData health_data = {
// Used for text
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
.typical_sleep = (10 * SECONDS_PER_HOUR),
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
// Used for typical
.sleep_start = -4 * SECONDS_PER_HOUR,
.sleep_end = 4 * SECON... |
n;
}
/* Loop until we have walked the entire list. */
while (((n_units < LARGE_SIZE) || (heap_info_ptr > heap->begin)) && (heap_info_ptr < heap->end)) {
prv_sanity_check_block(heap, heap_info_ptr);
/* Check to see if the current entry is free and is large*/
/* enough to hold the data ... | {
#if !defined(MALLOC_INSTRUMENTATION)
client_pc = 0;
#endif
// Get a pointer to the Heap Info.
void *new_ptr = heap_malloc(heap, nbytes, client_pc);
if (new_ptr && ptr) {
// Copy over old data.
const HeapInfo_t *heap_info_ptr = HEAP_INFO_FOR_PTR(ptr);
const uint16_t original_size = heap_info_ptr->S... | |
C_AHB3PeriphResetCmd(ahb3_periphs, DISABLE);
const uint32_t apb1_periphs = 0
| RCC_APB1Periph_TIM2
| RCC_APB1Periph_TIM3
| RCC_APB1Periph_TIM4
| RCC_APB1Periph_TIM5
| RCC_APB1Periph_TIM6
| RCC_APB1Periph_TIM7
| RCC_APB1Periph_TIM12
| RCC_APB1Periph_TIM13
| RCC_APB1Periph_TIM14
... | boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE) | ;
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
return false;
}
// We failed to start our firmware successfully!
if (watchdog_check_reset_flag()) {
dbgserial_putstr("Watchdog caused a reset");
}
if (boot_bit_test(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED)) {
dbgserial_putstr("Software failure c... |
e = NULL;
// Common for most tests:
s_firmware_update_is_in_progress = true;
fake_spi_flash_init(0, 0x1000000);
put_bytes_init();
}
void test_put_bytes__cleanup(void) {
put_bytes_deinit();
fake_comm_session_cleanup();
fake_system_task_callbacks_cleanup();
fake_event_clear_last();
fake_pbl_malloc... | assert_nack_count(1) | |
/*
* 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 ((slice.expiration_time != APP_GLANCE_SLICE_NO_EXPIRATION) &&
slice.expiration_time <= current_time) {
result |= APP_GLANCE_RESULT_EXPIRES_IN_THE_PAST;
} |
// If we haven't failed at this point, we're ready to add the slice to the glance!
if (result == APP_GLANCE_RESULT_SUCCESS) {
AppGlanceSliceInternal *slice_dest = &glance->slices[glance->num_slices];
*slice_dest = (AppGlanceSliceInternal) {
.expiration_time = slice.expiration_time,
.type = App... |
nt();
if (task == PebbleTask_App || task == PebbleTask_Worker) {
state->in_progress = false;
} else {
kernel_applib_release_log_state(state);
}
}
static void prv_log_internal(bool async, uint8_t log_level, const char* src_filename,
int src_line_number, const char* fmt, va_list a... | if (num_fmt_conversions != 0) {
char expanded_fmt_buffer[64];
// Fix the fmt string to include spaces before each % and `` around %s
memset(expanded_fmt_buffer, 0, sizeof(expanded_fmt_buffer));
for (unsigned index = 0; index < num_fmt_conversions; ++index) {
if (((str_index_1 != 0) && ((... |
}
sys_pbl_log((LogBinaryMessage*) state->buffer, async);
prv_release_log_state(state);
}
#endif /* PBL_LOGS_HASHED */
void pbl_log_vargs(uint8_t log_level, const char *src_filename,
int src_line_number, const char *fmt, va_list args) {
const bool async = true;
prv_log_internal(async, lo... |
ert_alarm_config(id, 10, 30, false, ALARM_KIND_WEEKDAYS, s_weekday_schedule);
// 2 pins should be added (for Thursday / Friday)
cl_assert_equal_i(s_num_timeline_adds, 2);
alarm_set_kind(id, ALARM_KIND_WEEKENDS);
// Alarm should not go off on Thursday anymore
s_current_hour = 10;
s_current_minute = 30;
c... | cron_service_wakeup() | ;
cl_assert_equal_i(s_num_alarms_fired, 1);
// The other alarm should not go off
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
}
// TODO:
// - Test disable while snoozing
// - Test delete while snoozing
|
ta->day_picker_menu_layer,
(MenuIndex) { 0, prv_alarm_kind_to_index(data->alarm_kind) },
MenuRowAlignCenter, false);
}
static uint16_t prv_custom_day_picker_get_num_sections(struct MenuLayer *menu_layer,
... | menu_layer_get_layer(menu_layer) | );
} else {
data->custom_day_picker_was_completed = true;
if (data->creating_alarm) {
const AlarmInfo info = {
.hour = data->alarm_hour,
.minute = data->alarm_minute,
.kind = ALARM_KIND_CUSTOM,
.scheduled_days = &data->scheduled_days,
.is_smart =... |
AppInbox *app_message_inbox;
EventServiceInfo app_outbox_subscription_info;
ApplibInternalEventsInfo applib_internal_events_info;
AnimationState animation_state;
AppMessageCtx app_message_ctx;
WindowStack window_stack;
FrameBuffer framebuffer;
GContext graphics_context;
EventServiceInfo even... | framebuffer_init(&s_app_state_ptr->framebuffer, &fb_size) | ;
framebuffer_clear(&s_app_state_ptr->framebuffer);
const GContextInitializationMode init_mode =
(s_app_state_ptr->sdk_type == ProcessAppSDKType_System) ? GContextInitializationMode_System :
GContextInitializationMode_App;
graphics_context_init(&... |
/*
* 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_context_get_bitmap(ctx) | ;
// translate to absolute bitmap coordinates:
rect.origin.x += ctx->draw_state.drawing_box.origin.x;
rect.origin.y += ctx->draw_state.drawing_box.origin.y;
// clip it to avoid drawing outside of the bitmap memory:
GRect clipped_rect = rect;
grect_standardize(&clipped_rect);
grect_clip(&clipped_rect, &b... |
/*
* 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... | syscall_assert_userspace_buffer(event_blob, sizeof(*event_blob)) | ;
}
if (!prv_is_event_allowed(event_blob)) {
syscall_failed();
}
analytics_logging_log_event(event_blob);
}
DEFINE_SYSCALL(void, sys_analytics_max, AnalyticsMetric metric, int64_t val,
AnalyticsClient client) {
analytics_max(metric, val, client);
}
|
ead_back_glance), S_SUCCESS);
cl_assert_equal_i(read_back_glance.slices[0].expiration_time, APP_GLANCE_SLICE_NO_EXPIRATION);
}
// Glance Tests
////////////////////////////////////////////////////////////////
void test_app_glance_db__basic_glance_insert_and_read(void) {
const AppGlance glance = (AppGlance) {
.... | (app_glance_db_read_creation_time(&APP_GLANCE_TEST_UUID, NULL),
E_INVALID_ARGUMENT) | ;
}
void test_app_glance_db__empty_glance_insert_after_basic_glance_insert_succeeds(void) {
// Call the basic glance insert test to insert the basic glance
test_app_glance_db__basic_glance_insert_and_read();
// Let some time pass so the creation time of this next glance insertion is newer
rtc_set_time(rtc_get... |
cl_assert_equal_i(prv_count_scheduled_animations(), 0);
// Make sure just the setup and teardown handlers were called
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler... | animation_get_implementation(h) | == &implementation2.base);
// Custom Curve
cl_assert(animation_get_custom_curve(h) != prv_custom_curve);
animation_set_custom_curve(h, prv_custom_curve);
cl_assert(animation_get_custom_curve(h) == prv_custom_curve);
// Reverse
cl_assert(animation_get_reverse(h) == false);
animation_set_reverse(h, tru... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | memcpy(serialized_contact, s_contact_1, sizeof(s_contact_1)) | ;
cl_assert_equal_i(contacts_db_insert((uint8_t *)&uuid, UUID_SIZE,
(uint8_t *)&serialized_contact,
sizeof(serialized_contact)), 0);
cl_assert(contacts_db_get_len((uint8_t *)&uuid, UUID_SIZE) > 0);
Contact *contact = contacts_get_cont... |
lected_next() the
// selection.index.section could be MENU_INDEX_NOT_FOUND (a very large value)
// in this case, walk forward from {0, 0| to avoid a very long loop run
const bool is_invalid_section = menu_layer->selection.index.section == MENU_INDEX_NOT_FOUND;
const int16_t comp = is_invalid_section ? 1 :
... | {
menu_layer_update_caches(menu_layer);
} |
bool menu_cell_layer_is_highlighted(const Layer *cell_layer) {
return cell_layer->is_highlighted;
}
void menu_layer_set_normal_colors(MenuLayer *menu_layer, GColor background, GColor foreground) {
menu_layer->normal_colors[MenuLayerColorBackground] = background;
menu_layer->normal_colors[MenuLayerColorForegrou... |
lude "settings_vibe_patterns.h"
#include "settings_window.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "services/common/analytics/analytics_event.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/notifications/alerts_preferences_private.h"
#include "services/normal/vibes/vibe_... | {
PBL_LOG(LOG_LEVEL_ERROR, "Null VibeScore!");
return;
} | |
er, &out_length));
cl_assert_equal_i(out_length, 1);
cl_assert(memcmp(out_buffer, (uint8_t*) "a", 1) == 0);
cl_assert(shared_circular_buffer_consume(&buffer, &client, 1));
// Consume one without reading it
cl_assert(shared_circular_buffer_consume(&buffer, &client, 1));
// Read the last little bit
cl_ass... | memcmp(out_buffer, "gh", 2) | == 0);
cl_assert(shared_circular_buffer_consume(&buffer, &client1, 2));
cl_assert_equal_i(shared_circular_buffer_get_read_space_remaining(&buffer, &client1), 3);
cl_assert_equal_i(shared_circular_buffer_get_read_space_remaining(&buffer, &client2), 5);
cl_assert_equal_i(shared_circular_buffer_get_write_space_r... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (QemuProtocol_SPP, sizeof(msg_data)) | ;
prv_send_bytes(msg_data, sizeof(msg_data));
prv_send_footer();
}
for (int i=0; i<2; i++) {
rcv_msg = qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol);
cl_assert(rcv_msg);
cl_assert_equal_i(rcv_protocol, QemuProtocol_SPP);
cl_assert_equal_i(rcv_bytes, sizeof(msg_dat... |
prv_draw_round_rect_aa_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
#else
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__fill(void) {
// Fill shape, non-antialiased (Stroke width/color N/A)
setup_test(&cont... | (&context, true, 1, GColorBlack, GColorBlack, true) | |
w_timer_start(s_erase_poll_timer, remaining_ms, prv_flash_erase_timer_cb, NULL, 0);
}
}
static void prv_flash_erase_async(
uint32_t sector_addr, bool is_subsector, FlashOperationCompleteCb on_complete_cb,
void *context) {
uint32_t remaining_ms = prv_flash_erase_start(sector_addr, on_complete_cb,
... | flash_impl_write_protect(
FLASH_REGION_SAFE_FIRMWARE_BEGIN,
(FLASH_REGION_SAFE_FIRMWARE_END - SECTOR_SIZE_BYTES)) | ;
} else {
status = flash_impl_unprotect();
}
PBL_ASSERT(PASSED(status), "flash_prf_set_protection failed: %" PRId32, status);
mutex_unlock(s_flash_lock);
}
#if 0
void flash_erase_bulk(void) {
mutex_lock(s_flash_lock);
flash_impl_erase_bulk_begin();
while (flash_impl_erase_is_in_progress()) {
psl... |
"FreeRTOS.h"
#include "semphr.h"
#include "task.h"
#include <stdint.h>
// Design doc & State Machine Diagram at:
// https://docs.google.com/document/d/1or2Ygs3sWt_5XNW_Mpe3Vxmhwuh3DTzdgZr6QlEe7iQ
// Core Dump doc at:
// https://docs.google.com/document/d/1UiasJyyQTD66mdpELfr7oLZjekOZn-o33E4iN5lQNic
// We want TIM6 ... | (BOARD_BT_WATCHDOG_TIMER.timer.peripheral, ENABLE) | ;
s_spi_transport.watchdog_timer_active = true;
// Prevent us from entering stop mode (and disabling the clock timer)
stop_mode_disable(InhibitorBluetoothWatchdog);
}
prv_unlock();
}
static void prv_watchdog_stop(void) {
prv_lock();
if (s_spi_transport.watchdog_timer_active) {
TIM_Cmd(BOARD_BT... |
i_eq(&ctx.dest_bitmap, "draw_rect_offset_sw3_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// SW = 4
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 4);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_... | graphics_context_set_stroke_color(&ctx, GColorBlack) | ;
// Draw rectangles around boundaries of clipping box - AA false
prv_draw_rects(&ctx, 1, 0, 0);
prv_draw_rects(&ctx, 2, CLIP_OFFSET, 0);
prv_draw_rects(&ctx, 3, 2 * CLIP_OFFSET, 0);
prv_draw_rects(&ctx, 4, 3 * CLIP_OFFSET, 0);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_clip_rect.${BIT_DEPTH_NAME... |
m_session_event_put;
void event_put(PebbleEvent* event) {
if (event->type == PEBBLE_COMM_SESSION_EVENT &&
event->bluetooth.comm_session_event.is_system) {
s_comm_session_event_put = true;
};
}
void app_launch_trigger(void) {
}
void session_remote_version_start_requests(CommSession *session) {
}
static ... | (transport, &s_transport_imp,
TransportDestinationSystem) | ;
cl_assert_equal_i(comm_session_get_type(session), CommSessionTypeSystem);
cl_assert_equal_p(comm_session_get_system_session(), session);
cl_assert_equal_p(comm_session_get_by_type(CommSessionTypeSystem), session);
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
fake_system_task_... |
state->header.common.status;
if ((result == E_RANGE) || (uuid_is_invalid(&iter_state->header.common.id))) {
return false;
} else if (result < 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Error reading notification header while iterating %d", result);
return false;
}
if (iter_state->header.common.status & Timeli... | (s_notif_storage_mutex && notification && header_out) | ;
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return false;
}
//Serialize notification attributes and actions for easy comparison
size_t payload_size = timeline_item_get_serialized_payload_size(notification);
uint8_t *payload = kernel_malloc_check(payload_size);
timeline_item_serialize_paylo... |
ime(void) {
return now;
}
RtcTicks rtc_get_ticks(void) {
return 0;
}
typedef void (*CallbackEventCallback)(void *data);
void launcher_task_add_callback(CallbackEventCallback callback, void *data) {
callback(data);
}
void event_put(PebbleEvent* event) {
num_events_put++;
}
// Stubs
/////////////////////////... | (get_reminder_timer_id()) | , sizeof(TimelineItemId));
cl_assert(stub_new_timer_timeout(get_reminder_timer_id()) == 200 * 1000);
now += 200;
stub_pebble_tasks_set_current(PebbleTask_NewTimers);
cl_assert(stub_new_timer_fire(get_reminder_timer_id()));
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
fake_system_task_callback... |
er.h"
#include "services/common/new_timer/new_timer.h"
#include "services/common/system_task.h"
#include "services/normal/accessory/smartstrap_attribute.h"
#include "services/normal/accessory/smartstrap_comms.h"
#include "services/normal/accessory/smartstrap_connection.h"
#include "services/normal/accessory/smartstrap_... | pebble_task_get_current() | == PebbleTask_KernelBackground;
} else if ((current_state == SmartstrapAttributeStateRequestPending) &&
(new_state == SmartstrapAttributeStateRequestInProgress)) {
return pebble_task_get_current() == PebbleTask_KernelBackground;
} else if ((current_state == SmartstrapAttributeStateRequestInProgres... |
/*
* 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 (field->id > *max_used_id) {
*max_used_id = field->id;
} |
return false;
}
static int get_next_id() {
int max_used_id = -1;
search_map(walk_max_used_id, &max_used_id);
return (max_used_id + 1);
}
// grows the size of the pmap file to the new_size specified
static status_t enlarge_pmap_file(int *fd, size_t new_size) {
const size_t hunk_size = 256;
uint8_t *buf = ... |
ased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(50, 40), GPoint(70, 35));
}
void across_... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_inside_origin_layer"))) | ;
layer_set_update_proc(&layer, &white_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("white_over_black", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&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... | {
units_changed |= DAY_UNIT;
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | RCC_GetClocksFreq(&RCC_ClocksStatus) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | printf("\nbkpt %"PRIu8"! no dbgr?\n\n", arg) | ;
return true;
}
void HardFault_HandlerC(uint32_t *fault_args) {
// Save the fault_args pointer for later
g_stacked_regs = fault_args;
bool is_bkpt = prv_handle_hardfault_due_to_bkpt();
uint32_t stacked_lr = g_stacked_regs[Stacked_Register_LR];
RebootReason reason = {
.code = is_bkpt ? RebootReasonCo... |
path->rotation = angle % TRIG_MAX_ANGLE;
}
void gpath_move_to(GPath *path, GPoint point) {
if (!path) {
return;
}
path->offset = point;
}
void gpath_move(GPath *path, GPoint delta) {
if (!path) {
return;
}
path->offset.x += delta.x;
path->offset.y += delta.y;
}
GRect gpath_outer_rect(GPath *pat... | {
goto cleanup;
} |
// x-intersections of path segments whose direction is up
intersections_up = applib_zalloc(path->num_points * sizeof(Intersection));
// x-intersections of path segments whose direction is down
intersections_down = applib_zalloc(path->num_points * sizeof(Intersection));
// If either malloc failed, log messa... |
/*
* 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 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... | ("Button id ") | ;
dbgserial_print_hex(button_id);
dbgserial_putstr("is stuck!");
result = true;
}
}
if (button_counter_register != 0) {
dbgserial_print("Button was pushed on boot. Button counter: ");
dbgserial_print_hex(button_counter_register);
dbgserial_newline();
}
RTC_WriteBackupRegister... |
om);
}
int32_t scale_int32(int32_t value, int32_t from, int32_t to) {
return (int32_t) ((int64_t) value * to / from);
}
// -------------------------------------------------------
// these values are directly taken from "easing red line 001.mov"
// _in will be added to first value (easing in, anticipation)
// _out ... | ARRAY_LENGTH(s_delta_moook_out) | , 0, true);
}
int64_t interpolate_moook_soft(int32_t normalized, int64_t from, int64_t to,
int32_t num_frames_mid) {
return prv_interpolate_moook(normalized, from, to,
s_delta_moook_in, ARRAY_LENGTH(s_delta_moook_in),
s_delt... |
prv_lock();
list_remove((ListNode *)expectation, (ListNode **)&s_expectations_head, NULL);
prv_unlock();
vSemaphoreDelete(expectation->semaphore);
kernel_free(expectation);
}
static HcProtocolMessage *prv_expect(HcExpectation *expectation) {
HcProtocolMessage *response = NULL;
// Save for debugging
co... | {
const HcProtocolMessageHandler handler = prv_get_handler_for_endpoint_id(message->endpoint_id);
if (!handler) {
PBL_LOG(LOG_LEVEL_ERROR, "No handler for endpoint ID %u", message->endpoint_id);
return;
}
hc_protocol_cb_dispatch_handler(handler, message, should_free);
} |
static bool prv_expectation_for_message_list_filter_cb(ListNode *found_node, void *data) {
HcExpectation *expectation = (HcExpectation *)found_node;
const HcProtocolMessage *message = (const HcProtocolMessage *)data;
if (!expectation->request) {
// Already being handled or timed out.
return false;
}
... |
B8},
{"cyan", GColorCyanARGB8},
{"bulgarianrose", GColorBulgarianRoseARGB8},
{"imperialpurple", GColorImperialPurpleARGB8},
{"indigo", GColorIndigoARGB8},
{"electricultramarine", GColorElectricUltramarineARGB8},
{"armygreen", GColorArmyGreenARGB8},
{"darkgray", GColorDarkGrayARGB8},
{"liberty", GColorLi... | {
*parsed_color = GColorClear;
} |
return true;
}
}
case 7: { // #RRGGBB
if (prv_parse_hex_comps(color_value + 1, 2, &r, &g, &b, NULL)) {
*parsed_color = GColorFromRGB(r, g, b);
return true;
}
}
case 9: { // #RRGGBBAA
if (prv_parse_hex_comps(color_value + 1, 2, &r, &g, &b, &a)) {
*... |
,
s_workout_data.current_workout->duration_s / SECONDS_PER_MINUTE);
ActivitySession session = {
.type = s_workout_data.current_workout->type,
.start_utc = s_workout_data.current_workout->start_utc,
.length_min = len_min,
.ongoing = false,
.manual = true,
... | prv_lock() | ;
{
if (!workout_service_is_workout_ongoing()) {
rv = false;
} else {
if (steps_out) {
*steps_out = s_workout_data.current_workout->steps;
}
if (duration_s_out) {
*duration_s_out = s_workout_data.current_workout->duration_s;
}
if (distance_m_out) {
*... |
fs_table;
for (uint32_t i = 0; i < num_entries; i++, entry++) {
if (!strncmp((const char *)key, entry->key, key_len)) {
return entry;
}
}
PBL_LOG(LOG_LEVEL_WARNING, "Unrecognized key: %s", (const char *)key);
return NULL;
}
// ---------------------------------------------------------------------... | settings_file_close(&file) | ;
}
}
mutex_unlock(s_mutex);
return success;
}
// ------------------------------------------------------------------------------------
// Called from KernelMain when we get a blob DB event. We take this opportunity to update the state
// of the given pref
void prefs_private_handle_blob_db_event(PebbleBlobDB... |
b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(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 ... | prv_count_handler_entries(&s_started_handler_calls, a) | , 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b)... |
dex, void *context) {
TimeSelectionWindowData *data = context;
date_time_handle_time_change(&data->time_data, index, -1);
prv_update_range_text_layer(data);
}
// Public Functions
void time_selection_window_set_to_current_time(TimeSelectionWindowData *time_selection_window) {
struct tm current_time;
clock_get... | fonts_get_system_font(size_config->subtitle_font_key) | );
// Status setup
status_bar_layer_init(&time_selection_window->status_layer);
status_bar_layer_set_colors(&time_selection_window->status_layer,
PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack),
PBL_IF_COLOR_ELSE(GColorBlack, GColorWhite));
status_bar_lay... |
>font_cache,
text_box_params->font, line->suffix_codepoint);
}
if (available_horiz_px < suffix_width_px) {
return NULL;
}
// Set up iterator
Iterator char_iter;
CharIterState char_iter_state;
char_iter_init(&char_iter, &char_iter_state, text_box_params, line->start);
Utf8IterState* utf8_it... | (ctx, line, text_box_params, (CharVisitorCallback) render_chars_char_visitor_cb) | ;
}
void update_all_layout_update_cb(TextLayout* layout, Line* line,
const TextBoxParams* const text_box_params) {
PBL_ASSERTN(line);
if (layout) {
layout->max_used_size.h = (line->origin.y - layout->box.origin.y) + line->height_px +
text_box_param... |
AGE = 0x23,
PmicRegisters_REG_CNTL = 0x24,
PmicRegisters_GPIO_CNTL1 = 0x25,
PmicRegisters_GPIO_CNTL2 = 0x26,
PmicRegisters_SD_CNTL1 = 0x30,
PmicRegisters_BATT_VOLTAGE_MON = 0x32,
PmicRegisters_STARTUP_CNTL = 0x33,
PmicRegisters_REFERENCE_CNTL = 0x35,
PmicRegisters_RESET_CNTL = 0x36,
PmicRegisters_OV... | {
// Sync the state of the PMIC GPIO output register with the value that we
// think it has.
if (!prv_set_pmic_gpio_outputs(0, 0)) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not initialize PMIC GPIO outputs");
}
} |
static void prv_handle_charge_state_change(void *null) {
const bool is_charging = pmic_is_charging();
const bool is_connected = pmic_is_usb_connected();
PBL_LOG(LOG_LEVEL_DEBUG, "AS3701b Interrupt: Charging? %s Plugged? %s",
is_charging ? "YES" : "NO", is_connected ? "YES" : "NO");
PebbleEvent event = ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(6676, interpolate_moook_soft(ANIMATION_NORMALIZED_MAX / 2, -20000,
20000, moook_num_soft_frames)) | ;
cl_assert_equal_i(20000, interpolate_moook_soft(ANIMATION_NORMALIZED_MAX, -20000,
20000, moook_num_soft_frames));
}
static const int32_t s_custom_moook_in[] = {0, 2, 8};
static const int32_t s_custom_moook_out[] = {21, 9, 3, 0};
static const MoookConfig s_custom_m... |
olor color) {
// Extended sides AA calculations
uint8_t left_aa_offset = (delta1.integer > 1) ?
((delta1.raw_value + (FIXED_S16_3_ONE.raw_value / 2)) / FIXED_S16_3_ONE.raw_value) : 1;
uint8_t right_aa_offset = (delta2.integer > 1) ?
((delta2.raw_value + (FIXED_S16_3_ONE.raw_value / 2)) / FIXED_S... | if (!fb) {
return;
} |
prv_replicate_column_row_raw(fb, src_x, dst_x1, dst_x2);
graphics_release_frame_buffer(ctx, fb);
}
void graphics_private_move_pixels_horizontally(GBitmap *bitmap, int16_t delta_x,
bool patch_garbage) {
if (!bitmap || delta_x == 0) {
return;
}
const int b... |
othConnection, prv_bluetooth_connection_msg_callback },
{ QemuProtocol_Compass, prv_compass_msg_callback },
{ QemuProtocol_Battery, qemu_battery_msg_callack },
{ QemuProtocol_Accel, qemu_accel_msg_callack },
{ QemuProtocol_TimeFormat, prv_time_format_msg_callback },
{ QemuProtocol_TimelinePeek, prv_timeline_p... | (dev, false) | ;
buffer_full = true;
}
// Is it time to wake up the main thread?
bool should_context_switch = false;
if (s_qemu_state.recv_error_count || buffer_full ||
(byte == QEMU_FOOTER_LSB && s_qemu_state.prev_byte == QEMU_FOOTER_MSB)) {
if (!s_qemu_state.callback_pending) {
s_qemu_state.callback_pen... |
},
{ -1304, 136, -384},
{ -1512, -224, -80},
{ -1648, 0, -88},
{ -1448, 328, -136},
{ -1216, 520, -136},
{ -1128, 400, -136},
{ -1184, 304, -112},
{ -1096, 280, -216},
{ -888, 264, -256},
{ -1096, 384, -160},
{ -1072, 584, -184},
{ -1288, 384, -280},
{ -1240, 400, -25... | { -1008, 160, -56},
{ -1056, 56, -40},
{ -864, -392, -48},
{ -936, -120, -176},
{ -1152, 88, -248},
// 28 seconds
{ -1176, 168, -424},
{ -1360, 240, -376},
{ -1416, -120, -200},
{ -1552, -48, -192},
{ -1384, 208, -192},
{ -1240, 424, -160},
{ -1248, 384, -136},
{ ... |
{ -144, 1032, 304},
{ -16, 1024, 168},
{ 216, 632, 336},
{ 304, 728, 152},
{ 296, 568, 280},
{ 328, 608, 272},
{ 336, 720, 216},
{ 304, 752, 376},
{ 272, 1192, 440},
{ 368, 1136, 544},
{ 432, 1176, 448},
{ 456, 1008, 216},
{ 424, 728, 136},
{ 360, 680, 144},
... |
zers(void) {
const int k_rec_count = 7;
Recognizer **recognizers = prv_create_recognizers(k_rec_count);
RecognizerManager manager;
recognizer_manager_init(&manager);
// ensure this runs without crashing even if there are no recognizer lists
prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event... | cl_assert(!ctx.triggered) | ;
r->state = RecognizerState_Cancelled;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(!handled);
cl_assert(!ctx.triggered);
r->state = RecognizerState_Completed;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(!handled);
cl_assert(!ctx.triggered);
r->state = RecognizerState_Starte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.