prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (strstr(testbuf, "log"), NULL) | ;
}
void test_strstr__weird(void) {
char testbuf[8] = "He\0llo!B";
cl_assert_equal_p(strstr(testbuf, "l"), NULL);
cl_assert_equal_p(strstr(testbuf, "He"), testbuf);
}
|
_s(tmbuf, "+0000");
#endif
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%12d", &jan_2_10015__13_00_00);
cl_assert_equal_s(tmbuf, "000000000002");
#if EXTENSION_C99
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%123F", &jan_2_10015__13_00_00);
cl_assert_equal_s(tmbuf, "10015-01-02");
#endif
#if EXT... | (tmbuf, "Fri Friday Jan January") | ;
tmbuf[0] = '\0';
localized_strftime(tmbuf, sizeof(tmbuf), "%c", &jan_2_2015__13_00_00, i18n_get_locale());
cl_assert_equal_s(tmbuf, "Fri Jan 2 13:00:00 2015");
s_i18n_translate = true;
s_i18n_locale_other = true;
tmbuf[0] = '\0';
localized_strftime(tmbuf, sizeof(tmbuf), "%a %A %b %B", &jan_2_2015__13_... |
/*
* 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... | strcat(destbuf, "larity") | , destbuf);
}
void test_strcat__n_basic(void) {
char destbuf[9] = "hi";
char expectbuf[9] = "hilarity";
strncat(destbuf, "larity", 6);
cl_assert_equal_m(expectbuf, destbuf, 9);
}
void test_strcat__n_overlarge(void) {
char destbuf[9] = "hi";
char expectbuf[9] = "hilariou";
strncat(destbuf, "lariousness",... |
H];
phone_format_caller_name("Katharine Berry", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine B.");
}
void test_phone_formatting__name_trailing_space(void) {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharine Berry ", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine B.");
memset... | {
char test_number[] = "+1 (608) 555-1212"; // typical format on iOS
int dest_len = sizeof(test_number) + 1;
char *dest = malloc(dest_len); // malloc'd memory is protected by DUMA
phone_format_phone_number(test_number, dest, dest_len);
cl_assert_equal_s(dest, "+1 (608)\n555-1212");
} |
void test_phone_formatting__phone_number_long_distance_parens_plus_leading_ltor_ancs(void) {
char test_number[] = "+1 (608) 555-1212"; // typical format on iOS
int dest_len = sizeof(test_number) + 1;
char *dest = malloc(dest_len); // malloc'd memory is protected by DUMA
phone_format_phone_number(test_numbe... |
BContext;
T_STATIC bool prv_gdraw_command_scale(GDrawCommand *command, uint32_t index, void *context) {
ScaleCBContext *scale = context;
const uint16_t num_points = gdraw_command_get_num_points(command);
for (uint16_t i = 0; i < num_points; i++) {
command->points[i] = gpoint_scale_by_gsize(command->points[i]... | if (!points) {
return NULL;
} |
gpoint_sort(points, num_points, comparator, context, reverse);
GPointIndexLookup *lookup = applib_malloc(sizeof(GPointIndexLookup)
+ num_points * sizeof(uint16_t));
if (!lookup) {
applib_free(points);
return lookup;
}
lookup->num_points = num_points;
lookup->max_index = num_points - 1;
... |
service_uuid, 1);
if (num_services) {
result->has_services = true;
// Look for Heart Rate Monitor service:
// See https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
Uuid hrm_uuid = bt_uuid_expand_16bit(0x180D);
result->has_heart_rate_service = ble_ad_includes_service(ad_data, &... | if (e) {
APP_LOG(APP_LOG_LEVEL_INFO, "ble_central_connect: %d", e);
} | |
ess, we've done all we need
// data->peek_layer is only ever not null between the start and end of the peek
// animation; it's cleaned up by prv_peek_anim_stopped, and initialized here
if (data->peek_layer) {
return;
}
// get root layer of window and make the peek layer the full size
const GRect *peek_l... | layout_destroy(layout) | ;
}
T_STATIC LayoutLayer *prv_get_layout_handler(SwapLayer *swap_layer, int8_t rel_position,
void *context) {
NotificationWindowData *data = context;
Uuid *id = notifications_presented_list_relative(
notifications_presented_list_current(), rel_position);
// if ... |
cl_assert(flash_locked);
}
void test_system_flash__erase_16KB_sectors(void) {
cl_assert(system_flash_erase(FLASH_BASE, 48 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 2), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_sectors_1_thru_10(void) {
cl_assert(system_flash_erase(FLA... | {
cl_assert_(!flash_locked, "Attempted to write to a locked flash");
cl_assert_(address >= flash_data_start &&
address < flash_data_start + flash_data_length,
"Address out of range");
cl_assert_(flash_written_flag[address - flash_data_start] == false,
"Overwriting an already... |
extern void dbgserial_print(char *str) {
fprintf(stderr, "%s", str);
}
extern void dbgserial_print_hex(uint32_t num) {
fprintf(stderr, "0x%.08x", num);
}
extern void dbgserial_putstr(char *str) {
fprintf(stderr, "%s\n", str);
}
|
buffer_size = sizeof("00:00:00");
GTextNodeText *number_text_node = health_util_create_text_node(buffer_size, number_font,
TEXT_COLOR, container);
active_window->workout_controller->metric_to_string(metric_type,
(char *)number_t... | {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
graphics_draw_bitmap_in_rect(ctx, icon, rect);
} |
if (size_out) {
*size_out = rect->size;
}
}
static void prv_draw_heart_node_callback(GContext *ctx, const GRect *box,
const GTextNodeDrawConfig *config, bool render,
GSize *size_out, void *user_data) {
WorkoutActiveWindow *act... |
(true, false) | ;
prv_render_layer(&peek->window.layer,
&(GRect) { gpoint_neg(layer->frame.origin), layer->frame.size },
use_screen);
timeline_item_destroy(item);
}
// Visual Layout Tests
//////////////////////
void test_timeline_peek__peek(void) {
prv_render_timeline_peek(&(TimelinePeekI... | |
L) {
return;
}
// check that at least enough time has elapsed since the last turn-off
// TODO: is this necessary in bootloader?
static const uint32_t MIN_STOP_TIME_MS = 10;
delay_ms(MIN_STOP_TIME_MS);
bus_pin_cfg_input(BOARD_CONFIG.i2c_bus_configs[bus_idx].i2c_scl);
bus_pin_cfg_input(BOARD_CONFIG.i2... | (s_initialized) | ;
PBL_ASSERT(device_id < BOARD_CONFIG.i2c_device_count, "I2C device ID out of bounds %d (max: %d)",
device_id, BOARD_CONFIG.i2c_device_count);
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
bus_lock(bus);
if (bus->user_count == 0) {
bus_enable(bus_idx... |
TimerInfo s_regular = {
.cb = prv_timer_callback,
};
// List of jobs sorted from soonest to farthest.
static ListNode *s_scheduled_jobs;
// -------------------------------------------------------------------------------------------
static bool prv_is_scheduled(CronJob *job) {
// Assumes mutex lock is already take... | list_insert_after(&job->list_node, &new_job->list_node) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "Cron job scheduled for %ld", job->cached_execute_time);
mutex_unlock(s_list_mutex);
return job->cached_execute_time;
}
// ------------------------------------------------------------------------------------------
bool cron_job_is_scheduled(CronJob *job) {
PBL_ASSERTN(s_list_mutex)... |
.stopped = prv_intro_anim_stopped,
}, data);
data->current_animation = intro;
animation_schedule(intro);
if (!layer_get_hidden((Layer *)&data->peek_layer)) {
prv_scale_peek_to_first_pin_icon(data, duration, was_mini_peek);
}
}
static void prv_open_did_focus_handler(PebbleEvent *e, void *context) {... | peek_layer_set_icon_with_size(peek_layer, &first_timeline_layout->icon_info,
TimelineResourceSizeTiny, icon_from) | ;
} else {
const bool use_pin = false;
prv_setup_peek_animation(data, &first_timeline_layout->icon_info, use_pin);
}
}
static void NOINLINE prv_setup_peek(TimelineAppData *data) {
TimelineIterState *state = timeline_model_get_current_state();
TimelineItem *first_pin = state ? &state->pin : NULL;
Even... |
(PEEK_LAYER_UNFOLD_DURATION + factory_reset_start_delay,
start_factory_reset, NULL) | ;
}
//! Wipe registry + Enter Standby (for factory)
static void confirm_long_click_handler(ClickRecognizerRef recognizer, Window *window) {
// Need to lock-out inputs after starting the factory reset.
prv_lockout_back_button(window);
factory_reset(true /* should_shutdown */);
}
static void decline_click_handle... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(strcmp(without_newlines, string_strip_leading_whitespace(with_newlines)) == 0) | ;
const char *with_both = "\n\n \n \nalbuquerque is a lovely town, not!\n";
const char *with_neither = "albuquerque is a lovely town, not!\n";
cl_assert(strcmp(with_neither, string_strip_leading_whitespace(with_both)) == 0);
}
void test_string__strip_trailing_whitespace(void) {
char string_out[100];
const... |
/*
* 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... | (0, 0, 60, 60) | ;
GRect to_rect_a = GRect(84, 92, 60, 60);
GRect from_rect_b = GRect(84, 0, 60, 60);
GRect to_rect_b = GRect(0, 92, 60, 60);
GRect tmp;
if (toggle) {
tmp = to_rect_b;
to_rect_b = from_rect_b;
from_rect_b = tmp;
}
toggle = !toggle;
animation_destroy(s_animation);
s_animation = NULL;
P... |
#include "stubs_memory_layout.h"
#include "stubs_menu_layer.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_persist.h"
#include "stubs_pin_db.h"
#include "stubs_process_loader.h"
#include "stubs_process_manager.h"
#include "stubs_proc... | cl_assert_equal_i(BG_COUNTER_APP_ID, bg_counter_app_id) | ;
// simulate installing menu_layer_app on flash
app_db_insert((uint8_t *)&menu_layer_app.uuid, sizeof(Uuid),
(uint8_t *)&menu_layer_app, sizeof(AppDBEntry));
menu_layer_app_id = app_db_get_install_id_for_uuid(&menu_layer_app.uuid);
app_cache_add_entry(menu_layer_app_id, 10701);
cl_assert_equ... |
,
{ 144, 704, 64},
{ 200, 488, 64},
{ 184, 360, 32},
{ 200, 192, 128},
{ 232, 288, -32},
{ 200, 448, 80},
{ 256, 504, 208},
{ 256, 888, 344},
{ 248, 1456, 440},
{ 328, 1472, 656},
{ 328, 1520, 624},
{ 280, 1144, 416},
{ 248, 856, 432},
{ 272, 824, 544},
{ 224,... | { -1592, 256, 96},
{ -1504, 616, -352},
{ -1528, 384, -184},
{ -1448, -72, 8},
{ -1376, 104, -136},
{ -1216, 312, -32},
{ -1136, 328, 40},
// 65 seconds
{ -1032, 368, 32},
{ -1032, 264, 112},
{ -976, 208, 144},
{ -944, 264, 232},
{ -1128, 320, 288},
{ -1040, 504, ... |
{ -1104, 240, 16},
{ -1064, 328, 64},
{ -1192, 456, 80},
{ -1088, 480, 176},
{ -1208, 520, 136},
{ -1216, 512, 24},
{ -1072, 376, 56},
{ -1304, 400, 24},
{ -1544, 376, 88},
{ -1608, 336, 120},
{ -1352, 200, 160},
{ -1288, 200, 136},
{ -1264, 112, 136},
{ -1208, 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 (!res_info) {
return NULL;
} |
KinoReel *icon = kino_reel_create_with_resource_system(res_info->res_app_num, res_info->res_id);
if (!icon) {
return NULL;
}
const GSize size = kino_reel_get_size(icon);
// Not const to deal with horrifying GCC bug
GSize max_size = legacy_icon_size_limit ? LAUNCHER_APP_GLANCE_STRUCTURED_ICON_LEGACY_M... |
/*
* 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(stub_new_timer_is_scheduled(timer_id)) | ;
return stub_new_timer_timeout(timer_id);
}
void enter_standby(RebootReasonCode reason) {
s_entered_standby = true;
}
void event_put(PebbleEvent* event) {
s_last_event_put = *event;
if (event->type == PEBBLE_BATTERY_STATE_CHANGE_EVENT) {
battery_monitor_handle_state_change_event(event->battery_state.new... |
k_count + s_coarse_ticks;
if (ints_enabled) {
__enable_irq();
}
return ret_value;
}
void rtc_set_time(time_t time) {
struct tm t;
gmtime_r(&time, &t);
// Just die if sanitization is necessary.
PBL_ASSERTN(!rtc_sanitize_struct_tm(&t));
RTC_TimeTypeDef rtc_time_struct = {
.RTC_Hours = t.tm_hou... | (RTC_IT_WUT, DISABLE) | |
e we don't push a pin when we have no history to compare against
void test_activity_insights__sleep_summary_no_history(void) {
// Tests init with zero history
activity_insights_init(rtc_get_time());
// Make sure we don't trigger as soon as we're awake
s_data.metric_history[ActivityMetricSleepState][0] = Activ... | (0.5, 1.5) | ;
activity_insights_process_minute_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 2);
#endif
}
// Make sure that when the watch resets, we retain state properly
void test_activity_insights__walk_session_power_cycle(void) {
activity_insights_init(rtc_get_time());
// Common metrics
s_data.metric_hi... |
anim_progress = 0;
}
static Animation* prv_create_slide_animation(SelectionLayer *selection_layer) {
Animation *animation = animation_create();
animation_set_curve(animation, AnimationCurveEaseIn);
animation_set_duration(animation, SLIDE_DURATION_MS);
AnimationHandlers anim_handler = {
.stopped = prv_slide... | window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler) | ;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! API
void selection_layer_init(SelectionLayer *selection_layer, const GRect *frame,
unsigned num_cells) {
if (num_cells > MAX_SELECTION_LAYER_CELLS) {
num_cells = MAX_SELECTION_LAY... |
ol existing_attributes[]) {
return true;
}
const TimelineEventImpl *timeline_peek_get_event_service(void) {
return NULL;
}
// Helpers
////////////////////////////////////////////////////////////////
static bool s_in_calendar_event = false;
static bool prv_get_calendar_ongoing(void) {
PebbleEvent event = fake_e... | (10*60, stub_new_timer_timeout(timer_id) / 1000) | |
advance_to_ms_with_timers(start_ms + delay_spawn + delay_a + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls,... | (&s_started_handler_calls, a) | , 2);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
// Complete sequence
prv_advance_to_ms_with_timers(start_ms + duratio... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | comm_session_get_current_app_session() | ;
*session_in_out = ((!*session_in_out) ||
(*session_in_out == permitted_session)) ? permitted_session : NULL;
}
// Helpers
////////////////////////////////////////////////////////////////////////////////////////////////////
static void prv_send_outbox_raw_data(const uint8_t *data, size_t lengt... |
_values[1], 33);
cl_assert_equal_i(activity_metrics_prv_get_active_calories(), 22 * ACTIVITY_CALORIES_PER_KCAL);
activity_metrics_prv_set_metric(ActivityMetricRestingKCalories, Thursday, 2000);
activity_metrics_prv_set_metric(ActivityMetricRestingKCalories, Wednesday, 44);
activity_get_metric(ActivityMetricRes... | (false, activity_sessions_is_session_type_ongoing(ActivitySessionType_Sleep)) | ;
cl_assert_equal_i(0, health_service_peek_current_activities());
// Start on known boundary
struct tm start_tm = {
// Jan 1, 2015, 5am
.tm_hour = 5,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
time_t utc_sec = mktime(&start_tm);
rtc_set_time(utc_sec);
// Add a Sleep session
const... |
// Exceed max # of children allowed?
return NULL;
}
bool success = true;
AnimationPrivate *parent = animation_private_animation_find(parent_h);
parent->type = type;
// Keep track of which children we added so we can restore them in case of error
bool used_children[array_len];
memset(used_childr... | {
PropertyAnimationPrivate *prop = property_animation_private_clone(
(PropertyAnimationPrivate *)from);
if (prop) {
clone = &prop->animation;
clone->is_property_animation = true;
}
} | else {
clone = applib_type_malloc(AnimationPrivate);
}
if (!clone) {
return NULL;
}
clone_h = animation_private_animation_init(clone);
}
// Copy the values into the clone
clone->implementation = from->implementation;
clone->handlers = from->handlers;
clone->context = from->contex... |
of(GetNotificationAttributesMsg);
bool error = false;
const bool did_get_attrs = ancs_util_get_attr_ptrs(data, length,
s_fetched_notif_attributes,
NUM_FETCHED_NOTIF_ATTRIBUTES,
... | ancs_invalidate_all_references() | ;
}
// Keep around the BLECharacteristic references:
memcpy(s_ancs_client->characteristics, characteristics,
sizeof(BLECharacteristic) * NumANCSCharacteristic);
// Subscribe to Data, then to Notification characteristics:
for (int c = ANCSCharacteristicData; c >= ANCSCharacteristicNotification; --c)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (s_get_bytes_impls[i].type == prv_get_storage_type_for_object(object_type)) {
storage->impl = &s_get_bytes_impls[i];
if (storage->impl->setup) {
return storage->impl->setup(storage, object_type, info);
}
}
} | |
(4));
cl_assert_equal_i(0b00111111, BITS_BETWEEN(0,5));
cl_assert_equal_i(0b00111000, BITS_BETWEEN(3,5));
cl_assert_equal_i(0b00010000, BITS_BETWEEN(4,4));
}
// Flash memory is organized into twelve sectors of unequal sizes.
// Sectors 0-3 are 16 KiB. Sector 4 is 64 KiB.
// The remaining sectors are 128 KiB.
//... | (flash_written_flag) | ;
}
void assert_flash_unwritten(uint32_t start, uint32_t length) {
for (uint32_t i = 0; i < length; ++i) {
cl_assert(flash_written_flag[start + i] == false);
}
}
void test_system_flash__write_simple(void) {
const char testdata[] = "The quick brown fox jumps over the lazy dog.";
malloc_flash_data(100);
f... |
HOST_TRANSPORT_DEBUG_LOG("Received %u bytes:", rx_len);
PBL_HEXDUMP(LOG_LEVEL_DEBUG, rx_buffer_ptr, rx_len);
#endif
} else {
HOST_TRANSPORT_DEBUG_LOG("Nothing to receive.");
}
bool has_more_rx_data = (remote_status_in.bytes_sendable_count > rx_bytes_available);
bool should_continue_to_rx_data =
... | hw_wkup_init(NULL) | ;
hw_wkup_set_counter_threshold(1);
hw_wkup_set_debounce_time(0);
hw_wkup_configure_pin(HOST_SPI->spi.cs.port, HOST_SPI->spi.cs.pin,
true /* enabled */, HW_WKUP_PIN_STATE_LOW);
hw_wkup_reset_interrupt();
hw_wkup_reset_counter();
hw_wkup_register_interrupt(prv_spi_chip_select_interrup... |
--------------------------------
// FIXME: We should probably handle this on KernelBG and not use the official app subscription
void workout_service_frontend_closed(void) {
PBL_ASSERT_TASK(PebbleTask_App);
prv_lock();
{
int32_t hr_time_left;
if (workout_service_is_workout_ongoing()) {
// The workou... | prv_unlock() | |
TON_DOWN_EVENT,
.button.button_id = button
};
event_put(&e);
e = (PebbleEvent) {
.type = PEBBLE_BUTTON_UP_EVENT,
.button.button_id = button
};
event_put(&e);
}
void command_button_press_short(const char* button_index) {
uintptr_t button = (uintptr_t)atoi(button_index);
launcher_task_add_callb... | flash_erase_sector_blocking(addr) | ; // exercise already erased check
}
flash_write_bytes(&buf[0], addr, sizeof(buf));
flash_expect_program_failure(false);
watchdog_feed();
}
}
task_watchdog_bit_set(pebble_task_get_current());
__enable_irq();
}
#endif
static TimerID s_abusive_timer = TIMER_INVALID_ID;
struct WasteT... |
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_NUM_PAGES (SPRF_REGION_SIZE / sizeof(SharedPRFData))
#define SPRF_PAGE_FLASH_OFFSET(idx) (FLASH_REGION_SHARED_PRF_STORAGE_BEGIN + \
(idx * sizeof(SharedPRFData)))
// Stubs
/////////////////////////////////////////////... | ((uint8_t *) &data, SPRF_PAGE_FLASH_OFFSET(page_idx[i]), sizeof(data)) | ;
// Call init and see if it found the valid page
shared_prf_storage_init();
uint32_t desired_page_idx = page_idx[i];
if (page_idx[i] > SPRF_MAX_NUM_PAGES_MULT(SPRF_NUM_PAGES)) {
desired_page_idx = 0;
}
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), desired_page_idx);
}
... |
aphics_draw_circle(ctx, GPoint(14, 14), 12);
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorClear);
graphics_context_set_antialiased(ctx, false);
graphics_draw_circle(ctx, GPoint(14, 14), 12);
}
void across_x_layer_update_callback(Layer* me, GContext*... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_origin_aa_r8_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1);
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_origin_aa_r8_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_REC... |
gsValueHistory old_history = { 0 };
ActivitySettingsValueHistory new_history = { 0 };
// In case we change the length of the history, fetch the old size
int fetch_size = sizeof(old_history);
fetch_size = MIN(fetch_size, settings_file_get_len(file, &m_info.settings_key,
si... | activity_private_settings_open() | ;
if (!file) {
PBL_LOG(LOG_LEVEL_ERROR, "Settings file DNE. No need to continue getting metric");
success = false;
goto unlock;
}
settings_file_get(file, &m_info.settings_key, sizeof(m_info.settings_key), &setting_history,
sizeof(setting_history));
... |
break;
}
// Only call the subscriber when the buffer is full. This takes away the
// overhead of handling this in the subscriber module
this->state->subscriber.idx += (size / sizeof(int16_t));
if (this->state->subscriber.idx == this->state->subscriber.size) {
this->state->subscriber.call... | {
if (!circular_buffer_write(&this->state->circ_buffer,
(const uint8_t *) &sample,
sizeof(int16_t))) {
this->state->overflow_cnt++;
break;
}
} |
}
// Post a callback to KernelBG and KernelMain for faster servicing (check out PBL-40943 for more
// details)
bool main_switch_context = false;
bool system_task_switch_context = false;
if (!this->state->main_pending) {
this->state->main_pending = true;
PebbleEvent e = {
.type = PEBBLE_CALLB... |
/*
* 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 s_open_status;
} |
static bool s_has_cache;
static bool s_get_called;
static uint64_t s_get_value;
status_t settings_file_get(SettingsFile *file, const void *key, size_t key_len,
void *val_out, size_t val_out_len) {
s_get_called = true;
if (!s_has_cache) {
return E_DOES_NOT_EXIST;
}
*((uint64_t *)... |
P_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 */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase h... | prv_set_data(&s_data, 0, 1098, 8, 0) | ;
window_set_on_screen(&s_data.window, true, true);
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_kickstart__render_PBL_43717(void) {
prv_set_data(&s_data, 7, 0, 7, 0);
window_set_on_screen(&s_data.window, true, true);
window_render(&s_dat... |
app_window_stack_push(&data->window, animated) | ;
// Request the default forecast separately instead of using the forecast list in `data` to avoid
// any potential race conditions
WeatherLocationForecast *default_forecast = weather_service_create_default_forecast();
const bool is_default_forecast_data_recent = prv_is_weather_forecast_recent(default_forecast... | |
ng <= 0) {
prv_attempt_swap(swap_layer, direction, false /* to_top */);
swap_layer->swap_delay_remaining = MESSAGE_SWAP_DELAY;
} else {
swap_layer->swap_delay_remaining--;
}
}
T_STATIC void prv_attempt_scroll(SwapLayer *swap_layer, ScrollDirection direction,
bool is_rep... | {
prv_scroll_to_top(swap_layer);
} | else {
prv_attempt_swap(swap_layer, ScrollDirectionUp, true /* to_top */);
}
}
static void prv_down_multi_click_handler(ClickRecognizerRef recognizer, void *context) {
SwapLayer *swap_layer = (SwapLayer *)context;
prv_finish_animation(swap_layer);
// If our first click caused a swap, then ignore the doub... |
/*
* 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... | (&simple_menu->menu, frame) | ;
}
simple_menu->sections = sections;
simple_menu->num_sections = num_sections;
simple_menu->callback_context = callback_context;
// use this SimpleMenuLayer as the callback context
menu_layer_set_callbacks(&simple_menu->menu, simple_menu, &(MenuLayerCallbacks) {
.get_num_sections = get_num_sections,
... |
{ 1960, 480, -152},
{ -1992, 312, 8},
{ 1736, 592, 144},
{ 1536, 1120, 552},
{ 912, -1744, 128},
{ 728, 824, 128},
{ 816, 1184, 288},
{ 1024, 1152, 152},
{ 1320, 960, 32},
{ 1776, 984, 72},
{ -1616, 880, 184},
{ -1440, 800, 152},
{ -1416, 648, 448},
{ -1208, 656, 24... | { 872, 808, -40},
{ 1160, 968, -80},
{ 1112, 760, -104},
{ 1720, 656, 0},
{ -1896, 752, 88},
{ -1760, 656, 80},
{ -1808, 472, 72},
{ -1872, 344, 200},
{ 2024, 320, 144},
{ 1744, 360, -24},
{ 1360, 264, -216},
{ 1120, -176, 16},
{ 584, -624, 104},
{ 392, -504, -376... |
{ 776, -464, 48},
{ 1320, 104, -216},
{ 1888, 152, -112},
{ -1656, 232, 96},
{ -1312, 384, -80},
{ -1608, 528, -56},
{ 1920, 1048, 184},
{ 1784, 528, -192},
{ 1872, 248, 48},
{ 1752, 1120, 40},
{ 968, -1768, -432},
{ 1056, 1152, -320},
{ 504, 1064, -352},
{ 1120,... |
PBL_LOG(LOG_LEVEL_INFO, "Some Mag Sample Data was overwritten, "
"dr_status=0x%x", raw_data[0]) | ;
rv = MagReadClobbered; // we still need to read the data to clear the int
}
// map raw data to watch coord system
data->x = align_coord_system(0, &raw_data[1]);
data->y = align_coord_system(1, &raw_data[1]);
data->z = align_coord_system(2, &raw_data[1]);
done:
mutex_unlock(s_mag_mutex);
return (rv... | |
icenses/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 specific language governing permissions and
* limitat... | (attr_list2, VEAttributeIdAppUuid, sizeof(data2)) | ;
cl_assert(attr1);
cl_assert_equal_i(attr1->id, VEAttributeIdAppUuid);
cl_assert_equal_i(attr1->length, 16);
offset = sizeof(GenericAttributeList) + sizeof(GenericAttribute);
cl_assert_equal_p(attr1->data, &data2[offset]);
attr2 = generic_attribute_find_attribute(attr_list2, VEAttributeIdTranscription, si... |
GAPLEClientApp, &has_more);
cl_assert_equal_i(handle_out, BLE_CHARACTERISTIC_INVALID);
cl_assert_equal_i(value_length, 0);
// Notification will be eaten, regardless of whether it was copied:
cl_assert_equal_b(has_more, false);
cl_assert_equal_i(next_length, 0);
}
void test_... | cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientApp), true) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
GRect result;
result.origin.x = distance_interpolate(
distance_normalized,
property_animation->values.from.grect.origin.x,
property_animation->values.to.grect.origin.x);
result.origin.y = distance_interpolate(
distance_normalized,
property_animation->values.from.grect.origin.y,
... |
void property_animation_legacy2_init(
PropertyAnimationLegacy2 *property_animation,
const PropertyAnimationLegacy2Implementation *implementation,
void *subject, void *from_value, void *to_value) {
animation_legacy2_init(&property_animation->animation);
memset(&property_animation->values, 0xff, sizeof(... |
yer.update_proc = (LayerUpdateProc)text_layer_update_proc;
text_layer->text_color = text_color;
text_layer->background_color = back_color;
text_layer->overflow_mode = overflow_mode;
layer_set_clips(&text_layer->layer, true);
text_layer->text_alignment = text_align;
// Default font
if (font == NULL) {
... | PBL_ASSERTN(text_layer) | ;
if (!text_layer->should_cache_layout) {
text_layer_set_should_cache_layout(text_layer, true);
}
GTextLayoutCacheRef layout = prv_text_layer_get_cache_handle(text_layer);
PBL_ASSERTN(layout);
// content size now depends on position on screen due perimeter text flow
GRect box;
layer_get_global_frame(&... |
// Don't render if modals are transparent while the app is not ready yet
return;
}
if (s_state == CompositorState_Modal) {
compositor_render_modal();
prv_compositor_flush();
} else if (s_state == CompositorState_AppAndModal) {
prv_send_app_render_request();
}
}
void compositor_transition_r... | prv_release_app_framebuffer() | ;
}
s_deferred_render.transition_start.pending = true;
s_deferred_render.transition_start.compositor_animation = compositor_animation;
return;
}
if (compositor_animation) {
// Set up our animation state and schedule it
s_animation_state = (CompositorTransitionState) {
.animation = a... |
"
#include "util/units.h"
//
// SPI bootloader protocol
//
static bool prv_load_data(uint32_t address, const uint8_t *data, size_t data_len) {
// PBL_LOG(LOG_LEVEL_DEBUG, "Loading %d bytes start at 0x%x", (int)data_len, (int)address);
uint8_t mem_write[] = {'L', 'D'};
dialog_spi_transmit_data(mem_write, sizeof... | while (image_size != 0) {
const size_t send_len = MIN(image_size, data_buf_size);
if (!resource_load_byte_range_system(
SYSTEM_APP, RESOURCE_ID_BT_FW_IMAGE,
curr_send_offset + vt_and_info_blob_size,
data_buf, send_len)) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to read fw i... |
success = true;
cleanup:
kernel_free(data_buf);
return success;
}
static bool prv_transfer_main_image(void) {
// TODO: Would be nice to just leverage memory mapping to avoid the double
// copy in the future
// Get the basic info about the image we are going to transfer
uint32_t image_size = resource_... |
_list_get_at(list, 0));
// 1 string (null terminated) => 2 strings, last is empty
list->serialized_byte_length = 3;
list->data[0] = 'a';
list->data[1] = 'b';
list->data[2] = '\0'; // end of data
list->data[3] = '\0';
cl_assert_equal_i(2, string_list_count(list));
cl_assert_equal_s("ab", string_list_get... | {
// Make sure we're resilient to NULL items
cl_assert_equal_p(timeline_item_find_action_by_type(NULL, TimelineItemActionTypeGeneric), NULL);
// Make sure we can handle timeline items with no actions
TimelineItem item = {};
cl_assert_equal_p(timeline_item_find_action_by_type(&item, TimelineItemActionTypeGene... |
void test_timeline_item__find_dismiss_action(void) {
// Make sure we're resilient to NULL items
cl_assert_equal_p(timeline_item_find_dismiss_action(NULL), NULL);
// Make sure we can handle timeline items with no actions
TimelineItem item = {};
cl_assert_equal_p(timeline_item_find_dismiss_action(&item), NUL... |
root_layer->update_proc(root_layer, &ctx);
if (s_tictoc_callback_is_color) {
cl_assert_equal_i(1, s_graphics_fill_rect.call_count);
cl_assert_equal_i(4, s_graphics_line_draw_precise_stroked.call_count);
cl_assert_equal_i(0, s_graphics_draw_line.call_count);
cl_assert_equal_i(1, s_graphics_context_set... | ASSERT_JS_GLOBAL_EQUALS_D("local_hour", 14.0) | ; // 1pm
}
void test_js__log_exception(void) {
char *script =
"var e1;\n"
"var f1 = function(){throw new Error('test')};\n"
"var f2 = function(){throw new 'test';};\n"
"var f2 = function(){throw new 123;};\n"
"try {f1();} catch(e) {e1 = e;}\n"
"try {f2();} catch(e) {e2 = e;}\n"
"try {f3()... |
/*
* 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... | {
// Approximately +1.01ppm
RTCCalibConfig config = rtc_calibration_get_config(32768033, TARGET_FREQUENCY_mHZ);
cl_assert_equal_i(config.units, 0);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&s_data.app) | ;
peek_layer_play(&s_data.app.peek_layer);
fake_animation_complete(s_data.app.peek_layer.kino_layer.player.animation);
fake_evented_timer_trigger(s_data.app.peek_layer.hidden_fields_timer);
window_set_on_screen(window, true, true);
window_render(window, fake_graphics_context_get_context());
}
// Tests
/////... |
valuate each test case
for (int i = 0; i < ARRAY_LENGTH(tests); i++) {
DistanceTestParams *params = &tests[i];
// Advance to new day to reset the distance
utc_sec += SECONDS_PER_DAY;
rtc_set_time(utc_sec);
prv_activity_init_and_set_enabled(true);
// Set the user's dimensions
activity_pre... | {
prv_minute_system_task_cb(NULL);
} |
}
}
// ---------------------------------------------------------------------------------------
// Test that we subscribe to the HR events at the expected times
void test_activity__hrm_sampling_period(void) {
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke sy... |
/*
* 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(5, 35) | , GPoint(45, 40));
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorClear);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphic... |
ad_byte)), sizeof(read_byte));
cl_assert_equal_i(read_byte, 0xff - i);
}
}
pfs_close(fd);
}
void test_pfs__write(void) {
int rv = pfs_write(-1, NULL, 0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(1000000, NULL, 0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(0, NULL, 0);
... | (rv == E_RANGE) | ;
}
void test_pfs__close(void) {
// shouldn't be able to close fds that are not open
int rv = pfs_close(-1);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_close(0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_close(1000000);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = pfs_open("file", OP_FLAG_WRIT... |
72},
{ 1112, 384, 128},
{ 1288, 608, 136},
{ 1704, 520, 168},
{ 1792, 464, 144},
{ 1024, 288, 120},
{ 1016, 112, 136},
{ 1320, 48, 224},
{ 1304, 48, 256},
{ 1128, 72, 248},
{ 968, 64, 152},
{ 856, 32, 120},
{ 768, 48, 40},
{ 688, 24, 0},
// 100 seconds
{ 624, ... | { 1688, 744, 128},
{ 1816, 416, 152},
{ 1176, 296, 88},
{ 1096, 192, 168},
{ 1608, 336, -56},
{ 1448, 8, 496},
{ 1248, 120, 224},
{ 1104, 24, 256},
{ 976, 16, 232},
{ 808, -8, 176},
{ 704, -24, 144},
{ 632, -24, 64},
{ 584, -80, -24},
{ 744, -56, -104},
{ 928,... |
{ 784, -56, -128},
{ 944, -136, -296},
{ 1344, -240, -24},
{ 1504, -152, 128},
{ 1592, 200, -248},
{ 1920, 304, -104},
{ 1776, 392, 256},
{ 1312, 600, 248},
{ 1032, 352, 184},
{ 944, 200, 224},
{ 944, 280, 176},
{ 800, 328, 88},
{ 792, 496, -64},
{ 952, 520, 40},... |
/*
* 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... | property_animation_get_to_grect(property_animation, &to) | &&
property_animation_get_subject(property_animation, (void **)&layer)) {
layer_set_frame(layer, &to);
}
}
|
ll be the current item in the list
//! }
#define FOREACH_VALID_ATTR(item) \
for (item = s_attr_head; item; item = NEXT_ATTR(item)) \
if (!item->deferred_delete)
// This file relies on the ServiceId/AttributeId being uint16_t as the protocol defines it as such.
_Static_assert(sizeof(SmartstrapServiceId) == size... | prv_set_attribute_state(attr, SmartstrapAttributeStateRequestPending) | |
ndScrollable) {
// Two metrics. 1 big static metric above a smaller scrollable metric
GRect top_metric_bounds = base_layer_bounds;
top_metric_bounds.size.h = PBL_IF_RECT_ELSE(90, 77);
layer_init(&active_window->top_metric_layer, &top_metric_bounds);
layer_set_update_proc(&active_window->top_metric_l... | (1000, prv_update_timer_callback, active_window) | ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Public API
WorkoutActiveWindow *workout_active_create_single_layout(WorkoutMetricType metric,
void *workout_data,
... |
now >= state->expire_utc)) {
// Ignore expired subscriptions
continue;
}
int64_t subscriber_age_ticks;
if (state->last_valid_ticks) {
subscriber_age_ticks = cur_ticks - state->last_valid_ticks;
} else {
// Never got an update yet
subscrib... | {
if (!state->callback_handler) {
// Not a KernelBG subscriber
continue;
}
// If this subscription is ready to expire, send an "expiring" event
if (prv_needs_expiring_event(state, utc_now)) {
PebbleHRMEvent expiring_event = (PebbleHRMEvent) {
.event_type = HRMEvent_Subscriptio... |
mutex_unlock_recursive(s_manager_state.lock);
}
// Assumes that s_manager_state.lock is held
static void prv_queue_system_task_event(const PebbleHRMEvent *event) {
const uint16_t free_space =
circular_buffer_get_read_space_remaining(&s_manager_state.system_task_event_buffer);
if (free_space < sizeof(Pebbl... |
));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[2].header.id));
#endif
cl_assert(!iter_prev(&iterator));
}
static int prv_num_items(Iterator iterator) {
int n = 1;
while (iter_next(&iterator)) {
n++;
}
return n;
}
void test_timeline__gc_past(void) {
Iterator iterator = {0};
TimelineI... | (&first_all_day_event, &state.pin.header.id) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | test_db_read(key, key_len, val_out, val_len) | |
{ 1240, -88, -128},
{ 1096, -56, -232},
{ 904, -16, -224},
// 53 seconds
{ 1008, -16, -216},
{ 1168, -32, -152},
{ 1120, -40, -88},
{ 1024, -24, -104},
{ 968, -16, -112},
{ 952, -32, -104},
{ 960, -56, -80},
{ 1024, -64, -112},
{ 968, -88, -128},
{ 952, -96, -144... | { 1216, 72, -72},
{ 1080, 64, -280},
{ 1208, 144, -304},
{ 1280, 104, -16},
{ 1200, -40, 128},
{ 1080, -104, 88},
{ 1048, -32, 32},
{ 976, 24, 0},
{ 1008, 64, -56},
{ 1032, 40, -32},
{ 1032, 8, -88},
// 59 seconds
{ 1032, 0, -72},
{ 1120, 8, -160},
{ 1120, 0, ... |
{ 1408, 64, -48},
{ 1344, 80, -80},
{ 1128, 112, -264},
{ 1056, 184, -232},
{ 1240, 120, -120},
{ 1288, -48, 88},
{ 1192, -48, 0},
{ 1104, 0, -80},
{ 1008, 40, -104},
{ 912, 16, -72},
{ 992, -8, -64},
{ 1008, -8, -64},
{ 992, 0, -64},
{ 1008, 0, -48},
{ 1048,... |
// Before we run, the context should be non NULL
cl_assert(animation_get_context(h) == context);
animation_schedule(h);
int max_loops = 20;
uint64_t start_ms = prv_now_ms();
uint64_t time_ms;
while (s_stopped_handler_calls.num_calls == 0) {
prv_fire_animation_timer();
time_ms = prv_now_ms();
... | (h, handlers, context) | ;
animation_set_implementation(h, &implementation);
animation_set_duration(h, duration);
animation_set_auto_destroy(h, auto_destroy);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(h);
prv_advance_to_ms_with_timers(start_ms + duration + 2 * MIN_FRAME_INTERVAL_MS);
... |
+ MIN_FRAME_INTERVAL_MS*2);
cl_assert_equal_gtransform(value, end_value);
#endif
}
// --------------------------------------------------------------------------------------
// Test a basic Fixed_S32_16 property animation
void test_animation__property_fixed_s32_16(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimati... | cl_assert_equal_i(test_value, start_value) | ;
property_animation_get_to_uint32(prop_h, &test_value);
cl_assert_equal_i(test_value, end_value);
uint32_t set_value = 1;
property_animation_set_from_uint32(prop_h, &set_value);
property_animation_get_from_uint32(prop_h, &test_value);
cl_assert_equal_i(test_value, 1);
property_animation_set_from_uint32... |
ess_manager_compiled_with_legacy2_sdk(void) {
return false;
}
const uint8_t *resource_get_builtin_bytes(ResAppNum app_num, uint32_t resource_id,
uint32_t *num_bytes_out) {
return NULL;
}
// Get the path of the filename before the extension
size_t prv_get_base_path(const c... | fread(&size, sizeof(size), 1, f) | != 1) {
printf("Failed to read PDC size: %s\n", filename);
fclose(f);
return;
}
// Read data into memory
void *data = malloc(size);
if (fread(data, size, 1, f) != 1) {
printf("Failed to read PDC content: %s\n", filename);
free(data);
fclose(f);
return;
}
fclose(f);
if (strnc... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (layer_bounds.size.w, layer_bounds.size.h) | / 2);
const GSize shape_size = GSize(shape_width, shape_width);
for (unsigned int i = 0; i < num_mask_levels; i++) {
// Calculate the angle of the mask shape using the current animation progress
// Offset the angle to space each of the mask shapes equally apart
const uint32_t starting_angle = (i * TRI... |
if (watchdog_check_reset_flag()) {
dbgserial_putstr("Watchdog caused a reset");
}
if (boot_bit_test(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED)) {
dbgserial_putstr("Software failure caused a reset");
}
// Clean up after the last failure.
boot_bit_clear(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
// We have a "... | (BOOT_BIT_FW_STABLE) | ) {
dbgserial_putstr("Last firmware boot was stable; clear strikes");
boot_bit_clear(BOOT_BIT_FW_STABLE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_RECOVE... |
/*
* 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;
} |
// check if attr_list_size is correct
if (score->attr_list_size != (data_size - (sizeof(VibeScore) - sizeof(GenericAttributeList)))) {
return false;
}
// check exact file size to contain all flexible-sized data
for (unsigned int i = 0; i < score->attr_list.num_attributes; i++) {
GenericAttribute * ... |
pplicable 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 specific language governing permissions and
* limitations under the License.
*/
#include "apps/sy... | timeline_model_deinit() | ;
pin_db_flush();
}
// Tests
//////////////////////
static void prv_create_and_render_title_and_subtitle(bool past, uint16_t first_duration_m) {
prv_create_list_view_and_render(&(ListViewConfig) {
.pins = {
&(TimelineItemConfig) {
.relative_timestamp = (11 * SECONDS_PER_HOUR) + (30 * SECONDS_PER... |
ata) {
FocusedContext *ctx = data;
ctx->focused = ((iter->current_top_window == ctx->window) &&
(iter->current_idx == iter->first_focus_idx));
return !ctx->focused;
}
bool modal_manager_is_window_focused(Window *window) {
FocusedContext context = { .window = window };
prv_each_modal_stack(p... | (&s_modal_window_stacks[idx], 0, sizeof(ModalContext)) | ;
}
s_modal_min_priority = ModalPriorityDiscreet;
modal_manager_init();
}
|
DeviceInternal *device_from_le_connection(GAPLEConnection *conn) {
return &conn->device;
}
bool gap_le_connection_is_valid(const GAPLEConnection *conn) {
for (int i = 0; i < ARRAY_LENGTH(s_connections); ++i) {
if (s_connections[i] == conn) {
return true;
}
}
return false;
}
void gap_le_connectio... | (s_device_a, true) | ;
// Expect HRM manager NOT to be subscribed to yet, need to grant permission first:
cl_assert_equal_i(s_hrm_manager_subscribe_with_callback_call_count, 0);
prv_assert_event_service_subscribed(false);
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a));
// Expect permissions UI to be prese... |
, 240},
{ -856, 64, 96},
{ -728, -88, -88},
// 104 seconds
{ -816, 152, -192},
{ -776, 128, -168},
{ -1032, -56, 16},
{ -1008, -32, 24},
{ -1032, 112, 152},
{ -1488, 184, 264},
{ -2096, 192, 400},
{ -2360, 232, 536},
{ -2008, 80, 688},
{ -1424, 616, 320},
{ -1728,... | { 40, 400, 448},
{ 128, 296, 344},
{ 224, 248, 280},
{ 248, 320, 336},
{ 288, 312, 376},
{ 328, 432, 512},
{ 264, 712, 792},
{ 280, 816, 1104},
{ 296, 1208, 1264},
{ 280, 1120, 1216},
{ 248, 888, 784},
{ 208, 488, 808},
// 110 seconds
{ 240, 440, 816},
{ 200, ... |
{ 216, 432, 752},
{ 136, 384, 832},
{ 72, 432, 744},
{ 80, 352, 568},
{ 80, 280, 488},
{ 160, 160, 592},
{ 168, 256, 712},
{ 128, 328, 720},
{ 144, 496, 936},
{ 136, 392, 960},
{ 192, 552, 1120},
{ 320, 592, 1312},
{ 264, 824, 1272},
{ 184, 800, 1000},
{ 128,... |
expect the pointer to the slice but rather the data behind the pointer
const AppGlanceSliceInternal *expected_slice_data = &glance.slices[0];
// Since there's only one slice in the glance, check that we get it 100 seconds before its
// expiration time
prv_check_expected_slice_data(expected_slice_data, expecte... | (no_expire_slice_data, expiring_slice_data->expiration_time + 5) | ;
// Check that going super far into the future still returns the slice with no expiration time
prv_check_expected_slice_data(no_expire_slice_data,
expiring_slice_data->expiration_time + 9999999);
}
|
1. Bring down TOP of cell by TOP_DOWN_PX.
GRect from;
if (menu_layer->animation.animation) {
from = menu_layer->animation.target;
prv_cancel_selection_animation(menu_layer);
} else {
from = menu_layer->inverter.layer.frame;
}
GRect target = (GRect) {
.origin = {
.x = 0,
.y = from.... | {
case MenuRowAlignTop:
y = - menu_layer->selection.y;
break;
case MenuRowAlignBottom:
y = frame_size.h - menu_layer->selection.y - menu_layer->selection.h;
break;
default:
case MenuRowAlignCenter:
y = (frame_size.h / 2) - menu_layer->selection.y - (menu... |
if (menu_layer->center_focused) {
// animation on center_focus will not happen via scrolling
// see prv_schedule_center_focus_animation()
animated = false;
}
// scroll layer will take care of clipping if necessary
scroll_layer_set_content_offset(&menu_layer->scroll_layer, GPoint(0, y... |
/*
* 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... | (FLASH_GPIO) | ;
// Init the hardware
flash_hw_init();
gpio_release(FLASH_GPIO);
periph_config_release_lock();
}
void flash_start_cmd(void) {
gpio_use(FLASH_GPIO);
GPIO_ResetBits(FLASH_GPIO, FLASH_PIN_SCS);
gpio_release(FLASH_GPIO);
}
void flash_end_cmd(void) {
gpio_use(FLASH_GPIO);
GPIO_SetBits(FLASH_GPIO, FLAS... |
ffer_write_index], data, length);
sendbuffer_write_index += length;
return true;
}
void comm_session_send_buffer_end_write(SendBuffer *sb) {
cl_assert(sendbuffer_length > 0);
cl_assert_equal_m(sendbuffer, s_expected_msg, sendbuffer_length);
}
bool comm_session_send_data(CommSession *session, uint16_t endpoint... | (NULL, s_start_writeback_response_success,
sizeof(s_start_writeback_response_success)) | ;
cl_assert(did_sync_next);
blob_db2_protocol_msg_callback(NULL, s_start_writeback_response_error,
sizeof(s_start_writeback_response_error));
cl_assert(did_sync_cancel);
}
static const uint8_t s_sync_done_response[] = {
BLOB_DB_COMMAND_SYNC_DONE_RESPONSE, // cmd
0x56, 0x78,... |
cl_assert_equal_i(s_hrm_expiration, 0);
prv_inc_time(1 * SECONDS_PER_MINUTE);
cl_assert(workout_service_start_workout(ActivitySessionType_Run));
// Workout of 120 seconds duration. Should be valid
prv_inc_time(2 * SECONDS_PER_MINUTE);
cl_assert(workout_service_stop_workout());
prv_inc_time(2 * SECONDS_PE... | (hr_zone_time_s[HRZone_Zone3], 10) | ;
// Pause the workout. Don't accumulate time in zones
cl_assert(workout_service_pause_workout(true));
prv_inc_time(10);
prv_put_bpm_event(ZONE_3_HR, HRMQuality_Good);
cl_assert(workout_service_get_current_workout_hr_zone_time(hr_zone_time_s));
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 10);
cl_ass... |
include "system/passert.h"
enum {
#ifdef ANALYTICS_DEBUG
HEARTBEAT_INTERVAL = 10 * 1000, // 10 seconds
#else
HEARTBEAT_INTERVAL = 60 * 60 * 1000, // 1 hour
#endif
};
static int s_heartbeat_timer;
static uint32_t s_previous_send_ticks;
DataLoggingSessionRef s_device_heartbeat_session = NULL;
DataLoggingSessionRef... | prv_create_dls(ANALYTICS_BLOB_KIND_DEVICE_HEARTBEAT, size) | ;
if (!s_device_heartbeat_session) return;
}
// Tell the watchdog timer that we are still awake. dls_create() could take up to 4 seconds if
// we can't get the ispp send buffer
system_task_watchdog_feed();
if (!s_app_heartbeat_session) {
uint32_t size = analytics_heartbeat_kind_data_size(ANALYTICS_H... |
{
frame = prv_next_frame(frame);
} |
return frame;
}
size_t gdraw_command_sequence_get_data_size(GDrawCommandSequence *sequence) {
if (!sequence) {
return 0;
}
size_t size = sizeof(GDrawCommandSequence);
GDrawCommandFrame *frame = sequence->frames;
for (uint32_t i = 0; i < sequence->num_frames; i++) {
size += gdraw_command_frame_get... | |
/*
* 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... | (RunLevel_BareMinimum) | ;
Window *window = &data->window;
window_init(window, WINDOW_NAME("Panic"));
window_set_overrides_back_button(window, true);
window_set_background_color(window, GColorBlack);
window_set_click_config_provider(window, prv_panic_click_config_provider);
#if CAPABILITY_HAS_HARDWARE_PANIC_SCREEN
display_show_p... |
file->used_space += record_size(&file->iter.hdr);
}
if (file->iter.hdr.last_modified > file->last_modified) {
file->last_modified = file->iter.hdr.last_modified;
}
}
}
status_t settings_file_rewrite_filtered(
SettingsFile *file, SettingsFileRewriteFilterCallback filter_cb, void *context) {... | if (prv_is_desired_hdr(iter, key, key_len)) {
return true;
} |
}
// If we got here, we didn't find it between `resumed_pos` and the last record in the file.
// Wrap around to the beginning and search until we get to the `resumed_pos`
settings_raw_iter_begin(iter);
for (; settings_raw_iter_get_current_record_pos(iter) < resumed_pos;
settings_raw_iter_next(iter)... |
/*
* 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... | (SYSTEM_APP, &SYSTEM_RESOURCE_VERSION) | ;
}
#define NUM_SYSTEM_FONTS ARRAY_LENGTH(s_font_resource_keys)
// Total number of fonts = NUM_SYSTEM_FONTS + 1 for the fallback font
FontInfo s_system_fonts_info_table[NUM_SYSTEM_FONTS + 1] KERNEL_READONLY_DATA;
static GFont prv_load_system_font(const char *font_key) {
if (font_key == NULL) {
PBL_LOG(LOG_LEVE... |
s_phone_ui_data->status_bar.layer,
&GRect(0, 0, window->layer.bounds.size.w - PBL_IF_RECT_ELSE(ACTION_BAR_WIDTH, 0),
STATUS_BAR_LAYER_HEIGHT));
status_bar_layer_set_colors(&s_phone_ui_data->status_bar,
PBL_IF_COLOR_ELSE(GColorClear, GColorWhite)... | {
actions |= PhoneCallActions_Reply;
} | |
39 seconds
{ -240, 440, -952},
{ -280, 480, -896},
{ -248, 568, -760},
{ -272, 640, -784},
{ -352, 712, -872},
{ -360, 544, -728},
{ -368, 648, -704},
{ -312, 664, -688},
{ -360, 608, -536},
{ -304, 696, -584},
{ -320, 424, -648},
{ -384, 736, -672},
{ -448, 800, -496... | { -272, 432, -880},
{ -264, 464, -920},
{ -272, 432, -896},
{ -288, 416, -880},
{ -288, 384, -888},
{ -280, 368, -888},
{ -280, 376, -880},
{ -280, 384, -904},
{ -288, 400, -896},
{ -288, 392, -896},
{ -288, 400, -912},
{ -288, 384, -888},
{ -280, 408, -904},
{ -2... |
{ -264, 448, -968},
{ -272, 368, -920},
// 147 seconds
{ -288, 328, -896},
{ -336, 336, -888},
{ -328, 328, -888},
{ -320, 376, -904},
{ -320, 368, -936},
{ -336, 296, -880},
{ -288, 312, -888},
{ -288, 400, -936},
{ -272, 376, -928},
{ -272, 384, -912},
{ -280, ... |
ader.id));
cl_assert(state.node->all_day);
cl_assert_equal_i(state.node->timestamp, 1425369600);
cl_assert_equal_i(state.node->duration, MINUTES_PER_DAY);
cl_assert_equal_i(state.current_day, midnight_march_2_pst + SECONDS_PER_DAY);
// no more
cl_assert(!iter_next(&iterator));
// 4 deletes
cl_assert(t... | cl_assert(timeline_iter_remove_node_with_id(&head, &all_day_item.header.id)) | |
has_more = false;
GATTBufferedNotificationHeader next_header = {};
prv_lock();
{
if (!prv_check_buffer(client)) {
has_more = false; // the client went away
goto unlock;
}
GATTBufferedNotificationHeader header = {};
const bool has_notification = prv_get_next_notification_header(clien... | {
bool rv = true;
prv_lock();
{
if (s_circular_buffer_retain_count[client] == 0) {
// First subscription for this client to require the circular buffer, go ahead and create it:
PBL_ASSERTN(s_circular_buffer[client] == NULL);
const size_t size = sizeof(CircularBuffer) + GATT_CLIENT_SUBSCRIPTI... |
// -------------------------------------------------------------------------------------------------
static bool prv_find_subscription_cb(ListNode *node, void *data) {
const GATTClientSubscriptionNode *subscription = (const GATTClientSubscriptionNode *) node;
const BLECharacteristic characteristic_ref = (BLEChar... |
/*
* 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... | (title, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)) | ;
text_layer_set_text_alignment(title, GTextAlignmentCenter);
text_layer_set_text(title, "Certification");
layer_add_child(&window->layer, &title->layer);
InverterLayer *inverter = &data->inverter;
inverter_layer_init(inverter, &window->layer.frame);
layer_add_child(&window->layer, &inverter->layer);
ap... |
0x48, 0x44,
0xb3, 0x94, 0x1f, 0x87, 0xb6, 0xbe, 0xae, 0x67},
.info_flags = PROCESS_INFO_HAS_WORKER | PROCESS_INFO_STANDARD_APP,
.app_version = {
.major = 1,
.minor = 0,
},
.sdk_version = {
.major = 5,
.minor = 13,
},
.app_face_bg_color = {0},
.template_id = 0,
.icon_resource_... | (INSTALL_ID_INVALID, app_install_get_id_for_uuid(&made_up)) | ;
cl_assert_equal_i(INSTALL_ID_INVALID, app_install_get_id_for_uuid(&UUID_INVALID));
cl_assert_equal_i(INSTALL_ID_INVALID, app_install_get_id_for_uuid(&(const Uuid)UUID_SYSTEM));
}
void test_app_install_manager__compare_app_entry_retrieve_methods(void) {
AppInstallEntry id_entry;
AppInstallEntry uuid_entry;
... |
ata from flash and output the data directly to serial port in segmented chunks
int32_t address = str_to_address(address_str);
if (address == -1) {
prompt_send_response("Invalid address");
return;
}
int length = atoi(length_str);
if (length == 0) {
prompt_send_response("Invalid length");
retu... | (buffer, 0, BUFFER_SIZE) | ;
const uint32_t addr = TEST_ADDR + offset;
flash_read_bytes(buffer, addr, BUFFER_SIZE);
for (uint32_t i = 0; i < BUFFER_SIZE; i++) {
if (buffer[i] != i) {
char err_buf[80];
prompt_send_response_fmt(err_buf, sizeof(err_buf), "FAIL: Incorrect value at 0x%"PRIx32,
... |
rv_is_weekend(DayInWeek day) {
return (day == Sunday) || (day == Saturday);
}
// ----------------------------------------------------------------------------------------------
// Return the activity metric that maps to the given health metric. We separate the two because
// in the future, the health APIs may need to... | {
memcpy(daily, &state->cache->steps_daily, sizeof(*daily));
// Get updated value for today. Getting only today's value is MUCH faster than getting
// the historical values
sys_activity_get_metric(prv_get_activity_metric(metric), 1, &daily->totals[0]);
return true;
} |
// Read in the metric history
if (!sys_activity_get_metric(prv_get_activity_metric(metric),
ARRAY_LENGTH(daily->totals), daily->totals)) {
PBL_LOG(LOG_LEVEL_ERROR, "Error fetching metric data");
return false;
}
// Store in cache if we have space for it.
if (state->cac... |
"kernel/pbl_malloc.h"
#include "process_management/app_install_manager.h"
#include "process_management/app_manager.h"
#include "services/common/analytics/analytics.h"
#include "services/common/comm_session/session.h"
#include "services/common/comm_session/session_receive_router.h"
#include "services/normal/app_inbox_se... | {
kernel_free(rcv);
return NULL;
} | |
se if (segment->type == HealthProgressSegmentType_Horizontal) {
p1 = prv_get_point_between_points(segment->points[0], segment->points[1], start);
p2 = prv_get_point_between_points(segment->points[3], segment->points[2], start);
p3 = prv_get_point_between_points(segment->points[3], segment->points[2], end);
... | prv_get_adjusted_gpoint_precise_from_gpoint(segment->points[2]) | ;
GPointPrecise p3 = prv_get_adjusted_gpoint_precise_from_gpoint(segment->points[3]);
if (segment->type == HealthProgressSegmentType_Vertical) {
graphics_line_draw_precise_stroked(ctx, p0, p3);
graphics_line_draw_precise_stroked(ctx, p1, p2);
} else if (segment->type == HealthProgressSegmentTyp... |
IC, sizeof(file_hdr.magic));
file_hdr.version = SETTINGS_FILE_VERSION;
settings_raw_iter_write_file_header(&file->iter, &file_hdr);
}
if (memcmp(&file_hdr.magic, SETTINGS_FILE_MAGIC, sizeof(file_hdr.magic)) != 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted to open %s, not a settings file.", name);
pfs_cl... | (hdr, SETTINGS_FLAG_OVERWRITE_STARTED) |
&& flag_is_set(hdr, SETTINGS_FLAG_OVERWRITE_COMPLETE);
}
static uint32_t utc_time() {
return rtc_get_time();
}
static bool deleted_and_expired(SettingsRecordHeader *hdr) {
return (hdr->val_len == 0)
&& (hdr->last_modified <= (utc_time() - DELETED_LIFETIME));
}
static void compute_stats(SettingsFile ... |
de "services/normal/accessory/smartstrap_comms.h"
#include "services/normal/accessory/smartstrap_link_control.h"
#include "services/normal/accessory/smartstrap_profiles.h"
#include "services/normal/accessory/smartstrap_state.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/size.h"
#include <in... | if (!s_profiles) {
smartstrap_link_control_disconnect();
} |
return false;
}
s_strikes = 0;
if (header->type == LinkControlTypeStatus) {
// status message
const LinkControlStatus status = header->data[0];
if (status == LinkControlStatusOk) {
PBL_LOG(LOG_LEVEL_DEBUG, "Got link control status: Ok");
smartstrap_connection_state_set(true);
} e... |
tion);
animation_set_handlers(a, handlers, a);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(a);
prv_advance_to_ms_with_timers(start_ms + duration + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_... | (prv_count_handler_entries(&s_started_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq)... |
*prv_load_js(char *suffix) {
char path[512] = {0};
snprintf(path, sizeof(path), "%s/js/tictoc~rect~%s.js", CLAR_FIXTURE_PATH, suffix);
FILE *f = fopen(path, "r");
cl_assert(f);
fseek(f, 0, SEEK_END);
size_t length = (size_t)ftell(f);
fseek (f, 0, SEEK_SET);
char *buffer = malloc(length + 1);
memset(bu... | (prv_js_global_get_value("s2")) | );
cl_assert_equal_i(150, jerry_get_int32_value(prv_js_global_get_value("c1")));
cl_assert_equal_i(150, jerry_get_int32_value(prv_js_global_get_value("c2")));
}
void test_js__date(void) {
const time_t cur_time = 1458250851; // Thu Mar 17 21:40:51 2016 UTC
// Thu Mar 17 14:40... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.