prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
cl_assert(uuid_equal(&state.pin.header.id, &s_items[0].header.id));
cl_assert(state.node);
}
void test_timeline__none_forwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, T... | (uuid_equal(&state.pin.header.id, &s_long_items[1].header.id)) | ;
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[0].header.id));
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[1].header.id));
#if !CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(... |
(value, &legacy->values.from, size) | ;
}
return true;
}
PropertyAnimationPrivate *property_animation = prv_find_property_animation(property_animation_h);
if (!property_animation) {
return false;
}
if (size > MEMBER_SIZE(PropertyAnimationPrivate, values.from)) {
APP_LOG(APP_LOG_LEVEL_WARNING, "invalid size");
return false;
... | |
32, -104},
{ -1344, 600, -240},
{ -1056, 544, -96},
{ -968, 656, -224},
{ -784, 520, -96},
{ -600, 400, -40},
{ -488, 424, -104},
{ -504, 384, -48},
{ -504, 320, 0},
{ -560, 288, 40},
{ -616, 272, 32},
{ -680, 296, 40},
{ -960, 320, 32},
{ -1312, 384, 0},
{ -1248,... | { -680, 360, -256},
{ -400, 328, -144},
{ -312, 344, -152},
{ -312, 312, -64},
{ -392, 376, -32},
{ -520, 432, -48},
{ -712, 504, -48},
{ -696, 592, -96},
{ -824, 664, -240},
// 29 seconds
{ -912, 616, -224},
{ -1296, 680, -248},
{ -1392, 856, -240},
{ -1088, 848,... |
{ -672, 632, -200},
{ -880, 728, -344},
{ -1120, 728, -192},
{ -1392, 832, -320},
{ -1144, 848, -288},
{ -984, 608, -64},
{ -1016, 712, -272},
{ -920, 560, -144},
{ -664, 432, -32},
{ -536, 400, -48},
{ -544, 336, 0},
{ -512, 280, 64},
{ -488, 248, 88},
{ -472, 2... |
tes message, but got a app attributes message...
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_message_app_info_dict),
(uint8_t *)s_message_app_info_dict);
s_num_ds_notifications_received++;
}
return BTErrnoOK;
}
// Tests
//////////////////////////////////////... | (s_num_requested_notif_attributes, 2) | ;
cl_assert_equal_i(s_num_ds_notifications_received, 2);
// Assert it got filtered out:
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
}
void test_ancs__should_filter_out_duplicate_messages(void) {
// With an empty db, new notifications should be added as usual
prv_send_... |
http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing pe... | if (direction_vertical) {
graphics_private_move_pixels_vertically(&ctx->dest_bitmap, diff);
} else {
graphics_private_move_pixels_horizontally(&ctx->dest_bitmap, diff,
false /* patch_garbage */);
} | |
/*
* 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_set_fill_color(ctx, command->fill_color) | ;
gpath_draw_filled(ctx, &path);
}
if ((command->stroke_color.a != 0) && (command->stroke_width > 0)) {
graphics_context_set_stroke_color(ctx, command->stroke_color);
graphics_context_set_stroke_width(ctx, command->stroke_width);
gpath_draw_stroke(ctx, &path, command->path_open);
}
}
static void ... |
prv_show_progress_window(void *data_ptr) {
ActionResultData *data = data_ptr;
data->progress_window = applib_zalloc(sizeof(ProgressWindow));
if (!data->progress_window) {
const bool success = false;
prv_cleanup_action_result(data, success);
return;
}
progress_window_init(data->progress_window);
... | prv_cleanup_action_result(data, true /* succeeded */) | ;
}
static void prv_cleanup_do_response_menu(ActionMenu *action_menu, const ActionMenuItem *item,
void *context) {
timeline_item_destroy(context);
}
static void prv_handle_do_response_response(ActionResultData *data) {
TimelineItem *item = timeline_item_copy(data->chaining... |
nt_reset_complete_size += sizeof(PPoGATTResetCompleteClientIDPayloadV1);
}
s_client_reset_complete = (PPoGATTPacket *) malloc(s_client_reset_complete_size);
*s_client_reset_complete = (const PPoGATTPacket) {
.sn = 0,
.type = PPoGATTPacketTypeResetComplete,
};
if (s_ppogatt_version > 0) {
*((PPoG... | (sizeof(PPoGATTPacket) + length) | ;
packet->sn = sn;
packet->type = PPoGATTPacketTypeData;
memcpy(packet->payload, data, length);
fake_gatt_client_op_assert_write(characteristic, (const uint8_t *) packet,
sizeof(PPoGATTPacket) + length,
GAPLEClientKernel, false /* is_response... |
runcating mode, or on the first line of a truncating mode.
// So, only include the extent of the previous line in next_line_y_extent (making it more of
// a "last_line_y_extent").
// Putting aside the misleading variable name, this will cause us to lay out one more line than
// will completely fit in th... | {
PBL_ASSERTN(*word->end == NULL_CODEPOINT);
word->start = NULL;
return false;
} | |
s > state->num_samples) {
PBL_LOG(LOG_LEVEL_ERROR, "Consuming more samples than exist %d vs %d!",
(int)samples, (int)state->num_samples);
success = false;
} else if (samples != state->num_samples) {
PBL_LOG(LOG_LEVEL_DEBUG, "Dropping %d accel samples", (int)(state->num_samples - samples));
... | event_put(&e) | ;
}
static void prv_handle_accel_driver_work_cb(void *data) {
// The accel manager is responsible for handling locking
mutex_lock_recursive(s_accel_manager_mutex);
AccelOffloadCallback cb = data;
cb();
mutex_unlock_recursive(s_accel_manager_mutex);
}
void accel_offload_work_from_isr(AccelOffloadCallback cb,... |
lTicks after) {
int32_t result = after - before;
if (result < 0) {
result = (TICKS_IN_AN_INTERVAL - before) + after;
}
return result;
}
static void restore_rtc_time_state(void) {
// Recover the previously set time from the RTC backup registers.
RtcIntervalTicks last_save_time_ticks = RTC_ReadBackupRegi... | (get_last_save_time_ticks(), rtc_ticks) | > SAVE_TIME_FREQUENCY) {
// If we didn't do this, we would have an edge case where if the watch reset
// immediately before rollover and then rolled over before we booted again,
// we wouldn't be able to detect the rollover and we'd think the saved state
// is very fresh, when really it's over an inter... |
(address_str) | ;
if (address == -1) {
prompt_send_response("Invalid address");
return;
}
uint32_t word = *(uint32_t*) address;
char buffer[32];
prompt_send_response_fmt(buffer, sizeof(buffer), "0x%"PRIx32" = 0x%"PRIx32, address, word);
}
void command_format_flash(void) {
flash_erase_bulk();
}
void command_eras... | |
/*
* 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... | {
AmbientLightAppData *data = app_state_get_user_data();
prv_update_reading(data);
layer_mark_dirty(window_get_root_layer(data->window));
app_timer_register(500, prv_timer_callback, NULL);
} |
static void prv_record_als_reading(void) {
AmbientLightAppData *data = app_state_get_user_data();
mfg_info_write_als_result(data->latest_als_value);
}
static void prv_handle_init(void) {
AmbientLightAppData *data = task_zalloc_check(sizeof(AmbientLightAppData));
data->window = window_create();
Layer *win... |
s, resume.
prv_handle_modal_to_app_transition_hidden_and_unfocused();
}
// We have modal windows and we should render them, either because they asked to or because
// they recently became the top window in their respective modal stacks and haven't noticed yet.
// See the handling for off screen windows in ... | {
// There is a visible opaque window, remove the transparent property
ctx->properties &= ~ModalProperty_Transparent;
} |
if (window->is_render_scheduled) {
// There is a visible window that will render, add the render requested property
ctx->properties |= ModalProperty_RenderRequested;
}
}
if (is_focused) {
// There is a modal with focus, remove the unfocused property
ctx->properties &= ~ModalProperty_Un... |
uint32_t lr;
LightMutexHandle_t freertos_mutex;
} PebbleMutexCommon;
struct pebble_mutex_t {
PebbleMutexCommon common;
};
struct pebble_recursive_mutex_t {
PebbleMutexCommon common;
};
// macros should only be called while we hold the mutex we are logging so no
// additional locking is needed
#define LOG_LOC... | __builtin_return_address(0) | |
up to
// become the top banner in the notifications window
#if PBL_ROUND
// Use a radius equal to that of the notification banner to make the transition seamless
const int32_t peek_circle_diameter = BANNER_CIRCLE_RADIUS * 2;
GRect peek_circle_frame = (GRect) {
.size = GSize(peek_circle_diameter, ... | (FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM) | ,
GColorBlack, GColorClear, text_alignment,
GTextOverflowModeTrailingEllipsis);
layer_add_child((Layer *)peek_layer, (Layer *)&peek_layer->number.text_layer);
// title layer
text_rect.origin.y = TEXT_OFFSET_Y;
text_layer_init_with_parameters(&p... |
s: Executing started handler for %d\n", prv_now_ms(), (int)animation);
}
// --------------------------------------------------------------------------------------
// Stopped handler
static void prv_stopped_handler(Animation *animation, bool finished, void *context) {
prv_add_handler_entry(&s_stopped_handler_calls, a... | kernel_applib_get_animation_state() | ;
return list_count(state->scheduled_head);
}
// --------------------------------------------------------------------------------------
static void prv_int16_setter(int16_t *p, int16_t value) {
*p = value;
}
static int16_t prv_int16_getter(int16_t *p) {
return *p;
}
// -----------------------------------------... |
/*
* 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... | (bounds, window, sections, ARRAY_LENGTH(sections), NULL) | |
ator) { 0 };
WordIterState word_iter_state = (WordIterState) { 0 };
Line line = (Line) { 0 };
// Allocate immutable types
bool success = false;
const char *sentence = NIHAO_JOINED NIHAO NIHAOMA_JOINED NIHAO_JOINED NIHAO_JOINED;
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, sentence);
cl_asser... | (word_iter_state.current.width_px == HORIZ_ADVANCE_PX * 3) | ;
line_reset(&line, utf8_bounds.start);
cl_assert(line_add_words(&line, &word_iter, NULL));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 3);
cl_assert(line.origin.x == 0);
cl_assert(line.origin.y == 0);
cl_assert(line.suffix_codepoint == 0);
cl_assert(*line.start == 'F... |
SConfig.h"
#define NUM_MENU_ITEMS 13
static bool s_call_core_dump_from_isr = false;
// =================================================================================
// Application Data
typedef struct {
Window *window;
SimpleMenuLayer *menu_layer;
SimpleMenuSection menu_section;
SimpleMenuItem menu_items... | (false /* don't force overwrite */) | ;
} else if (index == 7) {
PBL_LOG(LOG_LEVEL_INFO, "Forcing inf loop during core dump");
core_dump_test_force_inf_loop();
core_dump_reset(false /* don't force overwrite */);
} else if (index == 8) {
PBL_LOG(LOG_LEVEL_INFO, "Forcing assert loop during core dump");
core_dump_test_force_assert(... |
();
if (app_id == INSTALL_ID_INVALID) {
return 0;
}
// If not subscribed, return 0
HRMSessionRef hrm_session = sys_hrm_manager_get_app_subscription(app_id);
if (hrm_session == HRM_INVALID_SESSION_REF) {
return 0;
} else {
return HRM_MANAGER_APP_EXIT_EXPIRATION_SEC;
}
#endif
}
// ------------... | prv_activity_session_matches(session, activity_mask,
time_start, time_end) | ) {
HealthActivity session_activity = HealthActivityNone;
switch (session->type) {
case ActivitySessionType_Sleep:
case ActivitySessionType_Nap:
session_activity = HealthActivitySleep;
break;
case ActivitySessionType_RestfulSleep:
case ActivitySessionType_... |
const size_t num_vertical_icon_nodes = 1;
GTextNodeHorizontal *horizontal_icon_node =
graphics_text_node_create_horizontal(num_horizontal_icon_nodes);
GTextNodeVertical *vertical_icon_node =
graphics_text_node_create_vertical(num_vertical_icon_nodes);
graphics_text_node_container_add_child... | layout_node_create_kino_layer_wrapper((void *)&layout->icon_layer) | ;
}
static void prv_last_updated_update(const LayoutLayer *layout,
const LayoutNodeTextDynamicConfig *config, char *buffer,
bool render) {
AttributeList *attributes = layout->attributes;
const time_t last_updated_time = attribute_get_uint32(at... |
uint16_t opacity, GColor color) {
// Plots pixel directly to framebuffer
// Pixel position have to be adjusted to drawing_box before calling this!
// Checking for clip box
const GPoint point = GPoint(x, y);
if (!grect_contains_point(clip_box, &point)) {
return;
}
#if PBL_COLOR
// C... | {
int16_t x1_rounded = (x1.raw_value + (FIXED_S16_3_ONE.raw_value / 2))
/ FIXED_S16_3_ONE.raw_value;
int16_t x2_rounded = (x2.raw_value + (FIXED_S16_3_ONE.raw_value / 2))
/ FIXED_S16_3_ONE.raw_value;
prv_assign_line_horizontal_non_aa(ctx, y, x1_rounded, x... | |
sert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0055)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x55aa55)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5555)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0x0055aa)).argb);
cl_assert_equal_i(GColorBlack... | {
GColor8 tint_color = GColorClear;
GColor8 lookup_table_out[GCOLOR8_COMPONENT_NUM_VALUES];
// Passing in NULL for lookup_table_out should assert
cl_assert_passert(gcolor_tint_luminance_lookup_table_init(tint_color, NULL));
// Setting the tint color to black should result in a gradient from black to white
... |
static void prv_test_tint_using_luminance_and_perform_lookup_using_color_luminance(
GColor8 src_color, GColor8 tint_color, GColor8 expected_result_color) {
GColor8 lookup_table[GCOLOR8_COMPONENT_NUM_VALUES];
gcolor_tint_luminance_lookup_table_init(tint_color, lookup_table);
cl_assert(gcolor_equal(
gco... |
{ 1064, 24, -16},
{ 976, 0, -24},
{ 1144, 80, -144},
{ 1296, 96, -176},
{ 1096, 88, -160},
{ 1208, 0, -56},
{ 1192, 0, -72},
{ 1112, 88, -136},
{ 888, 144, -232},
{ 768, 120, -304},
// 76 seconds
{ 840, 120, -248},
{ 976, 160, -152},
{ 1152, 272, -136},
{ 1224, ... | { 1632, 152, -72},
{ 1560, 272, -288},
{ 1480, 288, -168},
{ 1408, 264, -32},
{ 1208, 360, 112},
{ 1448, 552, 200},
{ 1208, 728, 256},
{ 1144, 776, 56},
{ 856, 584, -104},
{ 992, 352, -56},
{ 1256, 360, 112},
{ 1920, 416, 200},
{ 1832, 248, 128},
{ 1672, 64, 104},... |
// 84 seconds
{ 1840, 176, 328},
{ 1704, 32, 144},
{ 1472, 208, -128},
{ 1160, 256, -120},
{ 760, 160, -128},
{ 512, -16, -264},
{ 424, -88, -512},
{ 288, -80, -688},
{ 152, -280, -696},
{ 96, -200, -992},
{ 208, 48, -1200},
{ 264, -32, -1080},
{ 200, -128, -928}... |
verride) {
system_task_add_callback(prv_try_update_schedule_mode, (void*)(uintptr_t) clear_manual_override);
}
static void prv_update_schedule_mode_timer_callback(void* not_used) {
prv_try_update_schedule_mode_callback(true);
}
static DoNotDisturbScheduleType prv_current_schedule_type(void) {
struct tm time;
... | {
return true;
} |
return false;
}
bool do_not_disturb_is_manually_enabled(void) {
return alerts_preferences_dnd_is_manually_enabled();
}
void do_not_disturb_set_manually_enabled(bool enable) {
const bool is_auto_dnd = prv_is_current_schedule_enabled() ||
do_not_disturb_is_smart_dnd_enabled();
const ... |
nsition_layout = NULL;
}
void timeline_layout_transition_pin_to_card(TimelineLayout *pin_timeline_layout,
TimelineLayout *card_timeline_layout) {
KinoReel *from_reel = kino_reel_create_with_resource_system(
pin_timeline_layout->icon_res_info.res_app_num,
pin_ti... | kino_reel_transform_get_to_frame(prev_reel) | ;
frame.origin = gpoint_add(frame.origin, gpoint_sub(icon_to.origin, global_frame.origin));
layer_set_frame((Layer *)&layout->icon_layer, &frame);
// Clip for the static icon
layer_set_clips(&layout->icon_layer.layer, true);
}
KinoReel *new_reel = kino_reel_create_with_resource_system(layout->icon_... |
for (int i = 0; i < HOURS_PER_DAY; i++) {
int value = 0;
for (int j = i * k_avgs_per_hour; j < (i + 1) * k_avgs_per_hour; j++) {
if (averages->average[j] == ACTIVITY_METRIC_AVERAGES_UNKNOWN) {
averages->average[j] = 0;
}
value += averages->average[j];
}
char temp[32];
snp... | {
ActivityDemoAppData *data = context;
prv_set_steps(CURRENT_STEP_AVG - 250, data);
} |
// -----------------------------------------------------------------------------------------
static void prv_debug_cmd_set_steps_at_avg(int index, void *context) {
ActivityDemoAppData *data = context;
prv_set_steps(CURRENT_STEP_AVG, data);
}
// ------------------------------------------------------------------... |
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_CUSTOM, custom_schedule1) | ;
bool custom_schedule2[7] = {false, false, false, false, false, true, false};
id = alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &custom_schedule2 });
prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_CUSTOM, custom_schedule2);
bool custom_schedule3[7] =... | |
t32_t size = dls_test_get_num_bytes(logging_sessions[i]);
PBL_LOG(LOG_LEVEL_INFO, "Size of session %d: %d", i, size);
total_bytes += size;
}
PBL_LOG(LOG_LEVEL_INFO, "total bytes: %d", total_bytes);
cl_assert(total_bytes < DLS_TOTAL_STORAGE_BYTES);
}
// --------------------------------------------------... | (data_logging_log(0, data, ARRAY_LENGTH(data)), DATA_LOGGING_INVALID_PARAMS) | |
CT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_bw,
GPointZero, DEG_TO_TRIGANGLE(45), GPoint(20, 20));
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_offset_bw_corner_45.Xbit.pbi"));
// Top-left center rotation point, Angle 45
setup_test... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_color_set_center_45_transparent.Xbit.pbi")) | ;
}
void test_graphics_draw_rotated_bitmap__offset_color(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
... |
.sample_collection_session_id++;
s_activity_state.sample_collection_seconds = rtc_get_time();
s_activity_state.sample_collection_num_samples = 0;
s_activity_state.sample_collection_enabled = true;
}
if (disable && s_activity_state.sample_collection_enabled) {
// Finish up the current rec... | if (file) {
settings_file_set(file, &key, sizeof(key), history, sizeof(*history));
activity_private_settings_close(file);
} |
}
// ------------------------------------------------------------------------------------------------
// Used by unit tests to init state. Clears all stored data and re-initializes.
bool activity_test_reset(bool reset_settings, bool tracking_on,
const ActivitySettingsValueHistory *sleep_hist... |
include "kernel/util/factory_reset.h"
#include "mcu/fpu.h"
#include "pebble_errors.h"
#include "process_management/app_install_manager.h"
#include "process_management/app_manager.h"
#include "process_management/app_run_state.h"
#include "process_management/process_manager.h"
#include "process_management/worker_manager.... | app_manager_get_current_app_md() | ) == ProcessAppRunLevelNormal) {
// Start timer for force-quitting app
bool success = new_timer_start(s_back_hold_timer, FORCE_QUIT_HOLD_MS, back_button_force_quit_handler, NULL,
0 /*flags*/);
PBL_ASSERTN(success);
}
light_button_pressed();
} else if (e->... |
prv_is_auto_accept_repairing_mode(conn, conn_idx) | ) {
PBL_LOG(LOG_LEVEL_DEBUG, "Auto-accepting pairing request");
extern void pair_reply(uint16_t conn_idx, bool is_confirmed);
pair_reply(conn_idx, true);
return;
}
hc_endpoint_pairing_send_pairing_request(&device);
}
static void prv_handle_address_resolved(const ble_evt_gap_address_resolved_t *evt... | |
;
TimelineItemActionSource current_timeline_item_action_source;
GBitmap *legacy2_framebuffer;
} AppState;
KERNEL_READONLY_DATA static AppState *s_app_state_ptr;
bool app_state_configure(MemorySegment *app_state_ram,
ProcessAppSDKType sdk_type,
int16_t obstructio... | app_state_get_health_service_state() | );
#endif
unobstructed_area_service_deinit(app_state_get_unobstructed_area_state());
}
Heap *app_state_get_heap(void) {
return &s_app_state_ptr->heap;
}
struct tm *app_state_get_gmtime_tm(void) {
return &s_app_state_ptr->gmtime_tm;
}
struct tm *app_state_get_localtime_tm(void) {
return &s_app_state_ptr->local... |
Fixed_S16_3 radius_inner, Fixed_S16_3 radius_outer,
int32_t angle_start, int32_t angle_end) {}
void gpath_draw_filled(GContext* ctx, GPath *path) {}
void layer_get_unobstructed_bounds(const Layer *layer, GRect *bounds_out) {
*bounds_out = layer->bounds... | fseek (f, 0, SEEK_SET) | |
nt32_t standby_timer_get_timeout() {
TimerID timer_id = battery_monitor_get_standby_timer_id();
cl_assert(timer_id != TIMER_INVALID_ID);
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;
}
voi... | battery_curve_lookup_voltage_by_percent(percent, false) | ;
fake_battery_init(discharge_mv, false, false);
battery_monitor_init();
periodic_timer_trigger(1);
cl_assert_equal_i(battery_get_charge_state().charge_percent, percent);
fake_battery_set_charging(true);
fake_battery_set_millivolts(charge_mv);
fake_battery_set_connected(true);
cl_assert_equal_i(batte... |
U V W X Y Z "
"a b c d e f g h j k l m n o p q r s t u";
char fourth_page_one_line[] = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
"a b c d e f g h j k l m n o p q r s t u v w x y z "
"A B C D E F G H I J K L M N O P... | (gbitmap_pbi_eq(s_dest_bitmap, namecat(namecat(__func__, "__clipped"), ".pbi"))) | ;
prv_prepare_fb_steps_xy(GSize(180, 300), 1, 1);
ctx.draw_state.avoid_text_orphans = false;
graphics_draw_text(&ctx, text, &s_font_info, GRect(0, 0, 180, 1000),
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter,
(GTextAttributes *const) &layout);
cl_check(gbitma... |
transcription_dialog)->scroll_layer;
TextLayer *text_layer = &dialog->text_layer;
const GSize size = text_layer_get_content_size(graphics_context_get_current_context(),
text_layer);
const uint16_t font_height = fonts_get_font_height(text_layer->font);
text_layer_set_size(text_layer, (GSize) { text_layer... | (&transcription_dialog->e_dialog.action_bar, BUTTON_ID_SELECT) | |
equal_i(s_circle_stroke_count, 0);
cl_assert_equal_i(s_circle_fill_count, 0);
free(command_list);
}
void test_gdraw_command__validate_list(void) {
GDrawCommandList *command_list = prv_create_command_list_3();
size_t size = sizeof(GDrawCommandList) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6);
c... | (points, s_fill_points, s_path_num_points) | |
t_equal_i(GColorWhiteARGB8, s_graphics_context_set_stroke_color.last_call.color.argb);
// ignores invalid values
EXECUTE_SCRIPT(
"ctx.fillStyle = 'unknown';\n"
"ctx.strokeStyle = '4%2F';\n"
);
cl_assert_equal_i(1, s_graphics_context_set_fill_color.call_count);
cl_assert_equal_i(1, s_graphics_context_... | cl_assert_equal_i(3, s_graphics_draw_text.call_count) | ;
cl_assert_equal_rect((GRect(-9900, 100, large_int, large_int)),
s_graphics_draw_text.last_call.draw_text.box);
}
void test_rocky_api_graphics__text_align(void) {
prv_global_init_and_set_ctx();
// intial value
cl_assert_equal_i(GTextAlignmentLeft, s_rocky_text_state.alignment);
s_ro... |
e slices, creating attribute lists and summing the size we need for the
// overall serialized slice
size_t serialized_glance_size = sizeof(SerializedAppGlanceHeader);
for (unsigned int slice_index = 0; slice_index < glance->num_slices; slice_index++) {
SliceSerializationAttributeListData *current_attr_list_da... | attribute_list_destroy_list(&attr_lists[i].attr_list) | ;
}
kernel_free(attr_lists);
return rv;
}
//////////////////////////////////
// Serialized Slice Validation
//////////////////////////////////
static bool prv_is_serialized_slice_valid(const SerializedAppGlanceSliceHeader *serialized_slice) {
if (!serialized_slice ||
!prv_is_slice_type_valid(serialized_... |
/*
* 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, 60, 60) | |
icense, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distribut... | if (rail == PmicRail_LDO2) {
rail_control_reg = PmicRegisters_LDO2_CONFIG;
ref_count = &s_ldo2_ref_count;
} else if (rail == PmicRail_LDO3) {
rail_control_reg = PmicRegisters_LDO3_CONFIG;
ref_count = &s_ldo3_ref_count;
} else {
WTF;
} |
uint8_t register_value;
bool success = prv_read_register(rail_control_reg, ®ister_value);
if (!success) {
// Failed to read the current register value
return false;
}
if (enable) {
if (*ref_count) {
(*ref_count)++;
return true;
} else {
// Set the register byte to XXXX... |
----------------------------------------------------------------------
bool alarm_get_time_until(AlarmId id, time_t *time_out) {
SettingsFile file;
if (!prv_file_open_and_lock(&file)) {
return false;
}
bool alarm_is_scheduled = false;
AlarmConfig config;
bool rv = prv_alarm_get_config(&file, id, &confi... | {
return;
} |
ForEachAlarmItrData itr_data = {
.cb = cb,
.cb_data = context,
};
settings_file_each(&file, alarm_for_each_itr, &itr_data);
prv_file_close_and_unlock(&file);
}
// ----------------------------------------------------------------------------------------------
bool alarm_can_schedule(void) {
SettingsF... |
#include "stubs_property_animation.h"
#include "stubs_scroll_layer.h"
#include "stubs_serial.h"
#include "stubs_shell_prefs.h"
#include "stubs_sleep.h"
#include "stubs_status_bar_layer.h"
#include "stubs_syscalls.h"
#include "stubs_task_watchdog.h"
#include "stubs_timeline_event.h"
#include "stubs_timeline_layer.h"
#i... | timeline_peek_set_item(item, timestamp >= now, config ? config->num_concurrent : 0,
false /* first */, animated) | |
interval_slots = GAPLE_ADVERTISING_SILENCE_INTERVAL_SLOTS,
.max_interval_slots = GAPLE_ADVERTISING_SILENCE_INTERVAL_SLOTS,
.duration_secs = 1,
},
{
.min_interval_slots = 32,
.max_interval_slots = 64,
.duration_secs = 1,
},
{
.min_interval_slots = GAPLE_ADVERTISING_SIL... | (ad_a,
advert_terms, sizeof(advert_terms)/sizeof(GAPLEAdvertisingJobTerm),
unscheduled_callback, s_unscheduled_cb_data, 0) | ;
cl_assert(job_a);
assert_ad_data("A");
// Schedule job "B":
BLEAdData *ad_b = create_ad("B", NULL);
GAPLEAdvertisingJobRef job_b;
job_b = gap_le_advert_schedule(ad_b,
advert_terms, sizeof(advert_terms)/sizeof(GAPLEAdvertisingJobTerm),
unsc... |
44},
{ 576, 200, -136},
{ 504, 208, -96},
{ 544, 216, -48},
{ 656, 264, -72},
{ 816, 384, -128},
{ 1184, 496, -208},
{ 1152, 488, -224},
{ 1072, 400, -200},
// 48 seconds
{ 1256, 408, -192},
{ 1192, 424, -184},
{ 1136, 424, -168},
{ 1120, 368, -128},
{ 1168, 312, ... | { -344, 632, 400},
{ -352, 712, 536},
{ -304, 896, 672},
{ -312, 824, 688},
{ -296, 816, 720},
{ -384, 696, 592},
{ -272, 496, 480},
{ -96, 688, 56},
{ -48, 712, 432},
{ -24, 880, 448},
{ 24, 808, 424},
{ 24, 1008, 608},
{ 80, 816, 352},
{ 120, 632, 416},
{ 12... |
// 56 seconds
{ 872, 336, -16},
{ 880, 336, -16},
{ 920, 328, -24},
{ 912, 312, -8},
{ 928, 320, -32},
{ 904, 320, -56},
{ 896, 320, -72},
{ 888, 304, -80},
{ 864, 272, -56},
{ 864, 256, -64},
{ 856, 264, -72},
{ 856, 256, -88},
{ 848, 256, -88},
{ 840, 248, ... |
st_relative(
notifications_presented_list_first(), +1);
if (second_id) {
// On rectangular displays, get the notification below the one we want to focus,
// set it as the current notification, then swap up. This allows us
// to accomplish the animation effect, while still pleasing the Swap... | prv_reload_swap_layer(data) | ;
}
}
}
alerts_incoming_alert_analytics();
if (alerts_should_vibrate_for_type(prv_alert_type_for_notification_type(type))) {
#if CAPABILITY_HAS_VIBE_SCORES
VibeScore *score = vibe_client_get_score(VibeClient_Notifications);
if (score) {
vibe_score_do_vibe(score);
vibe_score_destroy(... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_rel_bar_reset_offsets(&layer->relbar_layer, RelationshipBarOffsetTypeBoth) | |
/*
* 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... | bt_device_equal(&connection->device.opaque, &device->opaque) | ;
}
static GAPLEConnection * prv_find_connection(const BTDeviceInternal *device) {
return (GAPLEConnection *) list_find(&s_connections->node,
prv_list_filter_for_device,
(void *) device);
}
// ---------------------------------------------... |
(text_resources_init_font(0, font_fallback, 0, &s_font_info)) | ;
cl_assert_equal_i(FONT_VERSION(s_font_info.base.md.version), 3);
cl_assert_equal_i(s_font_info.base.md.wildcard_codepoint, WILDCARD_CODEPOINT);
}
void test_text_resources__test_backup_wildcard(void) {
const uint8_t wildcard_bytes[] = {0x3f, 0xc6, 0x18, 0x63, 0x8c, 0x31, 0xc6, 0x0f};
uint32_t font_fallback =... | |
4, -240},
{ 1144, -160, -192},
{ 1592, -120, -320},
{ 1360, -120, -208},
{ 1048, -96, -168},
// 58 seconds
{ 784, -72, -152},
{ 1016, 24, -160},
{ 1352, 0, -80},
{ 1304, -56, 0},
{ 1088, -80, 8},
{ 1008, -112, 16},
{ 984, -72, 0},
{ 936, -56, -16},
{ 912, -48, -32... | { 960, -24, -80},
{ 936, 16, -96},
{ 984, 8, -88},
{ 1016, -48, -72},
{ 1056, -64, -88},
{ 1032, -80, -128},
{ 984, -56, -136},
{ 968, -56, -176},
{ 1032, -64, -176},
{ 1040, -72, -168},
{ 1096, -72, -152},
{ 1096, -48, -128},
{ 1184, -64, -64},
{ 1472, -16, -144}... |
{ 1016, 24, 32},
{ 1016, 48, 24},
{ 1040, 56, 32},
{ 1104, 80, 0},
{ 1080, 72, 16},
{ 1072, 56, 16},
{ 1104, 56, -8},
{ 1112, 32, -8},
{ 1072, 16, -24},
{ 1048, 8, -16},
{ 1072, 8, -16},
{ 1064, 0, 0},
{ 1080, 0, 8},
{ 1072, 0, 0},
{ 1032, 24, 8},
{ 1048,... |
ks only on 8bit
void test_graphics_gpath_8bit__filled_bolt_aa(void) {
// NOTE: Those tests are being performed only in 8bits due to differences caused by AA,
// performing them in both 1bit and 8bit would create differences on the edges
// and fail unit tests as a result
GContext ctx;
Layer layer;
// B... | graphics_context_set_antialiased(&ctx, true) | |
FSET; i < FD_INDEX_OFFSET+PFS_FD_SET_SIZE; i++) {
mark_fd_free(i);
}
// clear out all pages
filesystem_regions_erase_all();
prv_invalidate_page_flags_cache_all();
if (write_erase_headers) {
prv_write_erased_header_on_page_range(0, s_pfs_page_count, 1);
}
mutex_unlock_recursive(s_pfs_mutex);
P... | {
pages_in_use += IS_PAGE_TYPE(pg_hdr.page_flags,
PAGE_FLAG_CONT_PAGE) ? 1 : 0;
continue; // only start pages contain file name info
} |
pages_in_use++;
if (read_header(pg, &pg_hdr, &file_hdr) != PageAndFileHdrValid) {
snprintf(display_buf, sizeof(display_buf), "%3d: Corrupt Sector", pg);
prompt_send_response(display_buf);
}
char file_name[file_hdr.file_namelen + 1];
file_name[file_hdr.file_namelen] = '\0';
prv_fl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
} |
// Teardown
void test_graphics_draw_line__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(... |
eate(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_JUST_ONCE });
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday);
id = alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_JUST_ONCE });
prv_assert_alarm_config(id, 4, 14, false, ALARM_KIN... | {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
alarm_set_kind(id, ALARM_KIND_WEEKENDS);
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_WEEKENDS, s_weekend_schedu... |
void test_alarm__alarm_set_recurring_weekdays(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
alarm_set_kind(id, ALARM_KIND_WEEKDAYS);
prv_assert_alarm_config(i... |
e ActivityMetricSleepRestfulSeconds:
*value_out = data.typical_deep_sleep_duration;
break;
case ActivityMetricSleepEnterAtSeconds:
*value_out = data.typical_fall_asleep_time;
break;
case ActivityMetricSleepExitAtSeconds:
*value_out = data.typical_wakeup_time;
break;
case ... | PBL_HEXDUMP(LOG_LEVEL_DEBUG, val, val_len) | ;
#endif
// Only store typicals / averages in this settings file. "Current" values are stored in the
// activity settings file.
// Sleep data contains a mix of current and typical values. The current values are just stored
// for convience and can't be accessed from this settings file.
status_t rv = S_SUCCES... |
own, true);
(void)recognizer;
}
static void scroll_layer_click_config_provider(ScrollLayer *scroll_layer) {
// Config UP / DOWN button behavior:
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, scroll_layer_scroll_up_click_handler);
window_single_repeating_click_subscribe(BUTTON_ID_DOWN, 100, scroll_... | (scroll_layer) | , false);
}
bool scroll_layer_get_clips_content_offset(ScrollLayer *scroll_layer) {
return scroll_layer->content_sublayer.clips;
}
|
istic, BLESubscriptionNone, GAPLEClientKernel);
// Kernel should get event immediately:
prv_assert_subscription_event(characteristic, BLESubscriptionNone, BLEGATTErrorSuccess,
true /* kernel */, false /* app */);
// CCCD value should not be written, because app is still subscribed:
cl_assert... | gatt_client_subscriptions_get_notification_header(GAPLEClientApp, NULL) | ;
cl_assert_equal_b(has_notification, false);
}
void test_gatt_client_subscriptions__notification_app_and_kernel_subscribers(void) {
// Subscribe app:
BLECharacteristic characteristic = prv_get_indicatable_characteristic();
BTErrno e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndicati... |
-------------------------------------------------------------------
// Test a basic gtransform property animation
void test_animation__property_gtransform(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation *prop_h;
GTransform value;
GTransform start_value, end_value, mid_value;
const int duration = 1000;
co... | (prop_h, &test_value) | ;
cl_assert_equal_fixed_s32_16(test_value, start_value);
property_animation_get_to_fixed_s32_16(prop_h, &test_value);
cl_assert_equal_fixed_s32_16(test_value, end_value);
Fixed_S32_16 set_value;
set_value = FIXED_S32_16_ONE;
property_animation_set_from_fixed_s32_16(prop_h, &set_value);
property_animatio... |
t pins
return;
}
BlobDBEventType type = blobdb_event->type;
Uuid *id = (Uuid *)blobdb_event->key;
if (type == BlobDBEventTypeDelete) {
if (prv_pin_in_card(data, id)) {
// remove the pin window if we just removed the pin
app_window_stack_remove((Window *)&data->pin_window, false);
prv_... | (&data->peek_layer, duration + ((num_frames_skip + num_frames_extend) *
ANIMATION_TARGET_FRAME_INTERVAL_MS)) | |
our firmware is screwed. Boot into recovery mode.
dbgserial_putstr("Boot failed, strike 3");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
return true;
} else if (boot_bit_test(BOOT_BIT_FW_START_FAIL_STRIKE_ONE)) {
dbgserial_putstr("Boot fai... | boot_version_write() | ;
// Write the bootloader version to serial-out
dbgserial_print("Bootloader version: ");
dbgserial_print_hex(boot_version_read());
dbgserial_newline();
if (boot_bit_test(BOOT_BIT_FW_STABLE)) {
dbgserial_putstr("Last firmware boot was stable; clear strikes");
boot_bit_clear(BOOT_BIT_FW_STABLE);
... |
======================================
// Application Data
typedef struct {
Window *window;
SimpleMenuLayer *menu_layer;
SimpleMenuSection menu_section;
SimpleMenuItem menu_items[NUM_MENU_ITEMS];
} TestTimersAppData;
static TestTimersAppData *s_app_data = 0;
// ===============================================... | core_dump_test_force_inf_loop() | ;
core_dump_reset(false /* don't force overwrite */);
} else if (index == 8) {
PBL_LOG(LOG_LEVEL_INFO, "Forcing assert loop during core dump");
core_dump_test_force_assert();
core_dump_reset(false /* don't force overwrite */);
} else if (index == 9) {
PBL_LOG(LOG_LEVEL_INFO, "Calling core_du... |
/*
* 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... | (expected_app_id, expected_message) | |
length:
AppMessageAppOutboxData data = {};
prv_send_outbox_raw_data((const uint8_t *)&data, sizeof(data));
assert_consumed(AppMessageSenderErrorDataTooShort, 1);
}
void test_app_message_sender__disallowed_endpoint(void) {
AppMessageAppOutboxData *outbox_data =
prv_create_and_send_outbox_message(s_system_... | prv_create_and_send_outbox_message(NULL /* auto-select */, ALLOWED_ENDPOINT_ID,
TEST_PAYLOAD, sizeof(TEST_PAYLOAD)) | |
if (event->type == VoiceEventTypeSessionSetup) {
prv_handle_ready_event(data, event);
}
break;
case StateWaitForResponse:
if (event->type == VoiceEventTypeSessionResult) {
prv_handle_dictation_result(data, event);
}
break;
case StateRecording:
if (event... | animation_set_curve((Animation *) anim, AnimationCurveEaseInOut) | |
/*
* 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... | bt_local_addr_resume_cycling() | ;
}
s_cycling_paused_due_to_dependent_bondings = has_pinned_ble_pairings;
}
}
void bt_local_addr_init(void) {
s_pra_cycling_pause_count = 0;
s_cycling_paused_due_to_dependent_bondings = false;
// Load pinned address from settings file or generate one if it hasn't happened before:
if (!bt_persistent_... |
alculate the distance delta
const time_t delta_ms = (now_ts - wrkt_data->last_movement_event_time_ts) * MS_PER_SECOND;
const int32_t delta_distance_mm = activity_private_compute_distance_mm(delta_steps, delta_ms);
wrkt_data->distance_m += (delta_distance_mm / MM_PER_METER);
// Calculate active calories... | {
return;
} | |
.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "system/passert.h"
#include <string.h>
#include <stdio.h>
typedef struct AnimatedDemoData {
Window window;
TextLayer text_layer;
PropertyAnimation *prop_animation;
bool toggle;
} AnimatedDemoData;
static void animation_started(Animation *a... | window_set_user_data(window, data) | ;
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
window_set_window_handlers(window, &(WindowHandlers){
.load = animated_demo_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);
}
static void handle_deinit(void) {
AnimatedDemoData *data... |
;
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();
DPRINTF("%"PRIu64": frame at: %d, %d, %d %d\n", time_ms - start_ms,
layer.frame.origi... | (h, duration) | |
/*
* 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... | uart_deinit(BT_TX_BOOTROM_UART) | ;
} else {
uart_deinit(BT_RX_BOOTROM_UART);
}
periph_config_release_lock();
}
static void prv_setup_dialog_reset_gpio(void) {
periph_config_acquire_lock();
// configure the GPIO for RST:
gpio_output_init(&BOARD_CONFIG_BT_COMMON.reset, GPIO_OType_PP, GPIO_Speed_25MHz);
periph_config_release_lock();
... |
ransport (iAP) isn't aware of the app UUID, so don't set anything:
Transport *legacy_transport = (Transport *) TransportID2;
CommSession *legacy_app_session = comm_session_open(legacy_transport, &s_transport_imp,
TransportDestinationApp);
Uuid modern_app_uuid ... | (fake_system_task_count_callbacks(), 0) | ;
cl_assert_equal_i(s_send_next_count, 0);
}
static bool prv_schedule_send_next(CommSession *session) {
return true;
}
static bool s_is_current_task_schedule_task = false;
static bool prv_is_current_task_schedule_task(Transport *transport) {
return s_is_current_task_schedule_task;
}
void test_session__transpor... |
(0b00011111, BITS(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.
// ... | |
----------------------------------------------------
// Test that average heart rate is reported correctly
void test_activity__hrm_median(void) {
int32_t median, total_weight;
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its Kerne... | {
int32_t median, total_weight;
s_num_hr_events = 0;
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
fake_eve... | |
at(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */);
resource_init();
prv_initialize_icons();
}
void test_menu_layer_system_cells__cleanup(void) {
free(fb);
fb = NULL;
gbitmap_deinit(&s_tictoc_icon_bitmap);
gbit... | {
old_icon_bounds = config->icon->bounds;
if (icon_subbitmap) {
gpoint_add_eq(&config->icon->bounds.origin, GPoint(4, 4));
config->icon->bounds.size.w -= 8;
config->icon->bounds.size.h -= 8;
}
} |
switch (cell_type) {
case MenuCellType_Basic:
// These should be ignored, we want to make sure they are!
menu_cell_basic_draw(ctx, cell_layer, config->title, config->subtitle, config->icon);
break;
case MenuCellType_BasicCustom:
menu_cell_basic_draw_custom(
ctx, cell_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... | graphics_context_get_bitmap(ctx) | ;
const int32_t x = (int32_t)((int16_t)cursor.origin.x + (int16_t)glyph_metrics.origin.x);
// Now clip that box against the screen/other UI elements. This rect will be the rect that we
// actually fill with bits on the screen.
GRect clipped_glyph_target = glyph_target;
grect_clip(&clipped_glyph_target, &ctx-... |
_registration_cmd_for_entity(entity_id, &cmd_length);
const BTErrno e = gatt_client_op_write(entity_update_characteristic,
cmd_value, cmd_length,
GAPLEClientKernel);
if (e != BTErrnoOK) {
if (e == BTErrnoNotEnoughResources) {
... | ams_util_csv_parse(update->value_str, value_length, &state,
prv_handle_player_playback_info_value) | ;
const bool success = (num_results == 3);
if (success) {
music_update_player_playback_state(&state);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Expected CSV with 3 values:");
PBL_HEXDUMP(LOG_LEVEL_ERROR, (const uint8_t *) update->value_str, value_length);
prv_analytics_log_event_with_info(AMSAnalyticsEve... |
a = window_get_user_data(s_window);
GRect bounds = data->canvas_layer->bounds;
switch (data->selection) {
case ATTRIBUTE_HUE:
++data->hue;
if (data->hue >= HUE_COUNT) {
data->hue = 0;
}
break;
case ATTRIBUTE_PIXEL_BIT:
++data->pixel_bit;
if (data->pixel_bit >= PIX... | {
r = 1;
} | else if (data->hue == HUE_GREEN) {
g = 1;
} else if (data->hue == HUE_BLUE) {
b = 1;
} else if (data->hue == HUE_WHITE) {
r = 1;
g = 1;
b = 1;
}
GColor line_color = GColorFromRGB(r * saturation, g * saturation,
b * saturation);
graphics_context_set_stro... |
xtNodeBaseImpl s_text_impl = {
.destructor = prv_destroy_text_node_base,
.will_draw = prv_draw_noop,
.did_draw = prv_draw_noop,
.draw = prv_draw_text_node_text,
};
static const GTextNodeBaseImpl s_text_dynamic_impl = {
.destructor = prv_destroy_text_node_base,
.will_draw = prv_draw_noop,
.did_draw = prv_... | (ctx->draw_box->origin, ctx->gcontext->draw_state.drawing_box.origin) | ,
.size = ctx->draw_box->size,
};
grect_clip(&ctx->gcontext->draw_state.clip_box, &draw_box);
}
}
static void prv_iter_did_draw(GTextNodeDrawContext *ctx, GTextNodeDrawContext *parent_ctx) {
GTextNode *node = ctx->node;
prv_base(node)->did_draw(ctx);
if (!ctx->cached) {
if (node->clip) {
... |
cl_assert(circular_buffer_write(&buffer, (uint8_t*) "abc", 3)) | ;
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 0);
cl_assert(!circular_buffer_write(&buffer, (uint8_t*) "d", 1)); // too full
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 0);
// Try a wrapped read
cl_assert(circular_buffer_read(&buffer, 6, &out_buffer, &out_l... | |
te_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, NULL);
RecognizerList app_list = {};
s_app_list = &app_list;
Window wi... | 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_Started;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert_equa... |
/*
* 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... | (&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 10) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | mutex_lock(s_pending_data_mutex) | ;
}
static void prv_unlock_pending_bonding(void) {
mutex_unlock(s_pending_data_mutex);
}
static void prv_shared_prf_reschedule_writeback_timer(void) {
if (regular_timer_is_scheduled(&s_shared_prf_writeback_timer)) {
regular_timer_remove_callback(&s_shared_prf_writeback_timer);
}
regular_timer_add_multimin... |
p_sec_level_changed(const ble_evt_gap_sec_level_changed_t *evt) {
PBL_LOG(LOG_LEVEL_INFO, "Security level changed to: %u", evt->level);
Connection *conn = connection_by_idx(evt->conn_idx);
if (conn == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "No connection for idx=%d", evt->conn_idx);
return;
}
pebble_pairin... | {
const bool success = (evt->status == BLE_STATUS_OK);
if (success && evt->bond) {
// Sync the new bonding:
bonding_sync_handle_pairing_completed(conn, conn_idx);
}
BTDeviceInternal device = {};
connection_get_address(conn, &device);
hc_endpoint_pairing_send_pairing_complete(&device,... |
// Convert to BT Spec error codes and update Pebble Pairing Service's Conn Status characteristic:
const uint8_t smp_status = SMP_GET_PAIR_FAIL_REASON(evt->status);
connection_set_last_pairing_result(conn_idx, smp_status);
pebble_pairing_service_handle_status_change(conn, conn_idx);
}
static void prv_handle_g... |
th_hr_summary_card_segments.h"
#include "health_hr_detail_card.h"
#include "health_progress.h"
#include "services/normal/activity/health_util.h"
#include "applib/pbl_std/pbl_std.h"
#include "applib/ui/kino/kino_reel.h"
#include "applib/ui/text_layer.h"
#include "apps/system_apps/timeline/text_node.h"
#include "kernel/... | (101, 109) | ;
graphics_text_node_draw(&container->node, ctx,
&GRect(0, offset_y, base_layer->bounds.size.w,
fonts_get_font_height(data->bpm_font)), NULL, NULL);
graphics_text_node_destroy(&container->node);
}
static void prv_render_timstamp(GContext *ctx, Layer *base_layer) {
HealthHrSummaryCardData *dat... |
/*
* 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... | (af_config->gpio, af_config->gpio_pin_source,
af_config->gpio_af) | |
// The test data
AlgMinuteDLSSample minute_data[num_minutes];
prv_create_test_data(num_minutes, minute_data);
// Call the minute handler, which computes the minute stats and saves them to data logging
// as well as to the sleep PFS file.
prv_feed_minute_data(num_minutes, minute_data, false /*simulate_bg_del... | printf("\nReceived %d minute records", (int)num_records) | ;
for (int j = 0; j < num_records; j++) {
printf("\nRecord:%d, steps: %d", j, (int)received_records[j].steps);
}
// Verify the contents of the records
for (int j = 0; j < num_records; j++) {
prv_assert_minute_data(&received_records[j], &minute_data[next_read_minute_idx + j]);
}
// ... |
onst GSize framebuffer_size = ctx->dest_bitmap.bounds.size;
for (int16_t x = 0; x < framebuffer_size.w; x++) {
for (int16_t y = 0; y < framebuffer_size.h; y++) {
cl_assert_equal_i(test_graphics_context_mask_get_value_for_coordinate(ctx, mask,
... | (ctx, NULL) | );
cl_assert_equal_p(ctx->draw_state.draw_implementation, &g_default_draw_implementation);
cl_assert_equal_p(ctx->draw_state.draw_mask, NULL);
graphics_context_mask_destroy(ctx, mask1);
graphics_context_mask_destroy(ctx, mask2);
}
void test_graphics_context_mask__basic_destroy(void) {
// Should be safe to c... |
if (0 == memcmp(&nil_key, &keys[key_type], sizeof(nil_key))) {
return false;
}
if (key_out) {
memcpy(key_out, &keys[key_type], sizeof(keys[key_type]));
}
return true;
}
void bt_persistent_storage_set_root_keys(SM128BitKey *keys_in) {
if (!keys_in) {
return;
}
shared_prf_storage_set_root_ke... | kernel_malloc_check(info->val_len) | ;
info->get_val(old_file, data, info->val_len);
settings_file_set(new_file, key, info->key_len, &data, info->val_len);
kernel_free(key);
kernel_free(data);
}
void bt_persistent_storage_delete_all_pairings(void) {
prv_lock();
{
SettingsFile fd;
status_t rv = settings_file_open(&fd, BT_PERSISTENT_S... |
00, 0x07, 0x00, 0x24, 0x01, 0x0c, 0x02, 0x7c, 0x01, 0xa4, /* bytes 16 - 32 */
0x00, 0x44, 0x01, 0x6c, 0x00, 0x64, 0x00, 0x6c, 0x00, 0x0c, 0x00, 0xd4, 0x01, 0x44, 0x00, 0x0c, /* bytes 32 - 48 */
0x02, 0x24, 0x01, 0x0c, 0x02, 0x03, 0x00, 0xc0, 0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0xac, 0x00, /* bytes 48 - 64 */
0x6c... | aligned (8) | ))
static const uint8_t VOICE_MICROPHONE_LARGE_builtin_bytes[] = {
0x50, 0x44, 0x43, 0x49, 0x09, 0x01, 0x00, 0x00, 0x01, 0x00, 0x50, 0x00, 0x50, 0x00, 0x0d, 0x00, /* bytes 0 - 16 */
0x03, 0x00, 0xc0, 0x04, 0xff, 0x00, 0x00, 0x09, 0x00, 0x64, 0x01, 0xdc, 0x01, 0xa4, 0x01, 0x9c, /* bytes 16 - 32 */
0x01, 0xa4, 0x01... |
------------------------
// Close the settings file and free the file struct
static void prv_minute_data_file_close(SettingsFile *file) {
settings_file_close(file);
kernel_free(file);
}
// --------------------------------------------------------------------------------------------
// Return the settings file key ... | (file, info, context->oldest_key, context->newest_key, &chunk) | ) {
return true;
}
// if in the wrong time range, skip it
if (chunk.hdr.time_utc < (uint32_t)context->oldest_valid_utc
|| chunk.hdr.time_utc > (uint32_t)context->newest_valid_utc) {
ACTIVITY_LOG_DEBUG("Minute chunk time out of range, skipping it");
return true;
}
// We need to make it 33% ... |
,
"145 Williams John\n"
"Palo Alto");
static StringList headings = StringListLiteral("Attendees\0Organizer");
static StringList paragraphs = StringListLiteral("Ryan Case\nBrad Murray\0Sarah Otten");
attribute_list_add_string_list(&list, AttributeIdHeadings... | (10 * 60 + 15) | ;
prv_add_sports_pin(10 * 60 + 17, GColorWhite, !is_ingame, has_broadcaster);
// Future pins
prv_add_calendar_pin(30 * 60, 3 * 24 * 60, is_all_day, !recurring,
TIMELINE_RESOURCE_SCHEDULED_EVENT, 0);
prv_add_calendar_pin(60 * 60, 3 * 24 * 60, is_all_day, recurring,
... |
/*
* 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... | {
HealthValue steps = health_service_sum_today(HealthMetricStepCount);
APP_LOG(APP_LOG_LEVEL_INFO, "worker: movement event, steps: %"PRIu32"",
(uint32_t)steps);
} | else if (event == HealthEventSleepUpdate) {
HealthValue total_sleep = health_service_sum_today(HealthMetricSleepSeconds);
HealthValue restful_sleep = health_service_sum_today(HealthMetricSleepRestfulSeconds);
APP_LOG(APP_LOG_LEVEL_INFO, "worker: New sleep event: total: %"PRIu32", restful: %"PRIu32" ",
... |
var d = new Date();\n"
"var s = d.toLocaleTimeString();\n"
);
ASSERT_JS_GLOBAL_EQUALS_S("s", "8:04:05 PM");
s_time += 4 * SECONDS_PER_HOUR;
EXECUTE_SCRIPT(
"var d = new Date();\n"
"var s = d.toLocaleTimeString();\n"
);
ASSERT_JS_GLOBAL_EQUALS_S("s", "12:04:05 AM");
}
void test_rocky_api_date... | ("s = d.toLocaleTimeString(undefined, {day: 'short'});") | ;
ASSERT_JS_GLOBAL_EQUALS_S("s", "Mon, 8:04:05 PM");
}
void test_rocky_api_datetime__locale_date_string(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT(
"var d = new Date();\n"
"var s = d.toLocaleDateString();\n"
);
ASSERT_JS_GLOBAL_EQUALS_S("s", "07/25/05");
}
void test_rocky_api_datetime__locale... |
se this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR COND... | ("AlarmDelete") | ;
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
const char *delete_text = i18n_noop("Alarm Deleted");
dialog_set_text(dialog, i18n_get(delete_text, dialog));
i18n_free(delete_text, dialog);
dialog_set_icon(dialog, RESOURCE_ID_RESULT_SHREDDED_LARGE);
dialog_set_background_color(dialog, ALARMS_APP... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_send_vt(vt_buf, vector_table_size) | ) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to send VT!");
goto cleanup;
}
success = true;
cleanup:
kernel_free(vt_buf);
return success;
}
static bool prv_transfer_main_image_code_and_data(
uint32_t image_size, ObjectBinInfo *info) {
bool success = false;
int vt_and_info_blob_size = info->vector_t... |
ompliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eith... | DEG_TO_TRIGANGLE(45) | , bitmap_64_center);
}
static void prv_teardown(Window *window) {
gbitmap_destroy(s_gfx_rotated_bitmap_bitmap);
gbitmap_destroy(s_gfx_rotated_bitmap_64_bitmap);
}
GfxTest g_gfx_test_rotated_bitmap_0_assign = {
.name = "RotBit 0-A-full",
.duration = 5,
.unit_multiple = 1,
.test_proc = prv_test_0_assign,
... |
"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 "launcher_app_glance_workout.h"
#include "launcher_app_glance_structured.h"
#include "applib/template_strin... | launcher_app_glance_structured_get_data(structured_glance) | ;
PBL_ASSERTN(workout_glance);
ActivitySession automatic_session = {};
const bool has_automatic_session =
workout_utils_find_ongoing_activity_session(&automatic_session);
ActivitySessionType workout_type;
int32_t workout_duration_s = 0;
if (workout_service_is_workout_ongoing()) {
// Manual work... |
Couldn't capture framebuffer
return;
}
// Make sure the line runs top to bottom
if (y1 > y2) {
tmp = y1; y1 = y2; y2 = tmp;
tmp = x1; x1 = x2; x2 = tmp;
}
// Draw the initial pixel
// TODO: PBL-14743: Make a unit test that will test case of .frame.origin != {0,0}
graphics_private_plot_pixel(... | (framebuffer, &ctx->draw_state.clip_box, x1, y1 + 1,
(weighting ^ weighting_complement_mask), stroke_color) | ;
}
// Draw the final pixel
graphics_private_plot_pixel(framebuffer, &ctx->draw_state.clip_box, x2, y2, MAX_PLOT_OPACITY,
stroke_color);
}
}
// Release the framebuffer after we're done
graphics_release_frame_buffer(ctx, framebuffer);
}
#endif // PBL_COLOR
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.