prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]);
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
}
static void prv_skip_odd_rows(struct MenuLayer *menu_layer,
MenuIndex *new_index,
MenuIndex old_ind... | cl_assert_equal_i(2 * basic_cell_height, l.selection.y) | ;
cl_assert_equal_i(initial_scroll_offset - 2 * basic_cell_height,
l.scroll_layer.content_sublayer.bounds.origin.y);
animation_unschedule(l.animation.animation);
menu_layer_set_selected_next(&l, false, MenuRowAlignNone, true);
// these values are unchanged until the animation updates them
... |
BL_LOG(LOG_LEVEL_INFO, "Found %"PRIu32" apps. Next ID: %"PRIu32" ", data.num_apps,
s_next_unique_flash_app_id);
prv_close_file_and_unlock_mutex();
}
status_t app_db_insert(const uint8_t *key, int key_len, const uint8_t *val, int val_len) {
if (key_len != UUID_SIZE ||
val_len != sizeof(AppDBEntry))... | (LOG_LEVEL_WARNING, "AppDB Flush finished") | ;
return S_SUCCESS;
}
//////////////////////
// Test functions
//////////////////////
// automated testing and app_install_manager prompt commands
int32_t app_db_check_next_unique_id(void) {
return s_next_unique_flash_app_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... | {
if ((prv_region_size(i) == 0) ||
pfs_active_in_region(known_size, known_size + prv_region_size(i))) {
// if active, increment known flash version and increase size to check next region
flash_version = i + 1;
known_size += prv_region_size(i);
} else {
// if not active, break an... |
// go back to the state we were in before the function
prv_layout_version_add_all_regions(true);
return flash_version;
}
void ftl_add_region(uint32_t region_start, uint32_t region_end, bool erase_new_region) {
// check if this region equals the next region, if so, then add next region
if ((region_start ==... |
S_FD(fd).fd_status = FD_STATUS_IN_USE;
file_found = true;
}
cleanup:
*fd_used = (res >= 0) ? fd : res;
return (file_found);
}
// handles the creation of a file which was not previously on the FS
static NOINLINE status_t pfs_open_handle_create_request(int fd, uint8_t file_type,
size_t start_size) {
if... | prv_update_gc_reserved_region() | ;
}
mutex_unlock_recursive(s_pfs_mutex);
return (res);
}
static int pfs_open_gc_file(uint32_t space_needed, bool create) {
int fd = GC_FD_HANDLE_ID; // the gc fd follows the avail fd
File *file = &PFS_FD(fd).file;
// settings for cached & new fds
file->op_flags = OP_FLAG_READ;
if (create) {
file-... |
{ -1160, 256, 0},
{ -1008, 352, 104},
{ -1064, 384, 32},
{ -1152, 432, -48},
{ -1048, 408, -104},
{ -1072, 424, -128},
{ -1120, 648, -88},
{ -1200, 248, -96},
{ -1464, 392, -120},
{ -1216, 416, -80},
{ -1504, 440, -8},
{ -1664, 304, 16},
{ -1352, 176, -56},
{ -117... | { 880, -224, -1040},
{ 672, -192, -608},
{ 472, -232, -632},
{ 272, -240, -704},
{ 232, -208, -608},
// 83 seconds
{ 288, -296, -384},
{ 288, -240, -472},
{ 448, -160, -536},
{ 632, -40, -1008},
{ 896, -312, -1208},
{ 992, -176, -1528},
{ 808, -520, -1240},
{ 752,... |
{ -552, -352, -1264},
{ -568, -304, -1248},
{ -592, -296, -1024},
{ -512, -328, -824},
{ -400, -344, -640},
{ -328, -376, -520},
{ -240, -384, -488},
{ -200, -400, -424},
{ -176, -328, -528},
{ -168, -312, -656},
{ -192, -248, -920},
{ -320, -184, -1120},
{ -264, -12... |
ue;
} else {
return false;
}
} else if (attr == ManagementServiceAttributeNotificationInfo) {
if (length != sizeof(NotificationInfoData)) {
PBL_LOG(LOG_LEVEL_WARNING, "Notification info response is invalid length: %"PRIu32, length);
return false;
}
const NotificationInfoData *not... | {
// The response was completely valid, but there was a non-Ok error returned
success = false;
// translate the error code to the appropraite SmartstrapResult
if (header->error == GenericServiceResultNotSupported) {
result = SmartstrapResultAttributeUnsupported;
} else {
WTF;
}
} | |
app_install_entry_is_watchface(&entry) | ) {
app_install_enumerate_entries(
prv_set_default_any_watchface_enumerate_callback, NULL);
app_id = app_install_get_id_for_uuid(&s_default_watchface);
}
return app_id;
}
void system_theme_set_content_size(PreferredContentSize content_size) {
if (content_size >= NumPreferredContentSizes) {
PB... | |
e);
}
}
ClickManager *mgr = prv_get_current_click_manager();
ClickConfig *cfg = &mgr->recognizers[button_id].config;
cfg->long_click.delay_ms = (delay_ms == 0) ? 500 : delay_ms;
cfg->long_click.handler = down_handler;
cfg->long_click.release_handler = up_handler;
}
void window_raw_click_subscribe(Butt... | gcolor_equal(background_color, window_bg_color) | ) {
return;
}
window->background_color = background_color;
layer_mark_dirty(&window->layer);
}
void window_set_background_color_2bit(Window *window, GColor2 background_color) {
window_set_background_color(window, get_native_color(background_color));
}
void window_set_fullscreen(Window *window, bool enable... |
, else it reflects the error code
static NOINLINE bool file_found_in_cache(const char *name, uint8_t op_flags, int *fd_used) {
int fd, res;
bool is_tmp = ((op_flags & OP_FLAG_OVERWRITE) != 0);
bool file_found = false;
if ((res = get_avail_fd(name, &fd, is_tmp)) == NoFDAvail) {
res = E_OUT_OF_RESOURCES;
... | {
mark_fd_free(fd);
} | else {
PFS_FD(fd).fd_status = FD_STATUS_IN_USE;
}
return (res);
}
int pfs_open(const char *name, uint8_t op_flags, uint8_t file_type,
size_t start_size) {
size_t namelen = (name == NULL) ? 0 : strlen(name);
if ((namelen < 1) || (namelen > FILE_MAX_NAME_LEN)) {
return (E_INVALID_ARGUMENT);
}
... |
_on_screen == window->on_screen) {
return;
}
// Window went from offscreen to onscreen (or vice versa)
// Provides internal signaling to ui elements of appear/disappear
layer_property_changed_tree(&window->layer);
window->on_screen = new_on_screen;
if (window->on_screen) {
window_schedule_render(w... | (&status_bar->layer) | ;
}
void window_attach_recognizer(Window *window, Recognizer *recognizer) {
if (!window) {
return;
}
layer_attach_recognizer(window_get_root_layer(window), recognizer);
}
void window_detach_recognizer(Window *window, Recognizer *recognizer) {
if (!window) {
return;
}
layer_detach_recognizer(window... |
ist_append(&s_stat_rows->node, &stats->node);
} else {
s_stat_rows = stats;
}
}
// ---------------------------------------------------------------------------------------
// Set a specific column in the last row by name
static void prv_stats_set_last_row_value(const char* name, uint32_t value) {
if (s_stat_... | (s_kalg_state) | |
/*
* 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... | activity_get_sessions(&num_sessions, activity_sessions) | |
pb_decode_varint(stream, &value);
if (*decoder_info->num_types < decoder_info->max_num_types) {
decoder_info->types[(*decoder_info->num_types)++] = value;
}
return success;
}
typedef struct PLogMeasurementsDecoderArg {
uint32_t max_num_samples;
uint32_t *num_samples;
uint32_t *offset_sec;
uint32_t ... | protobuf_log_activity_sessions_decode(&event, &decoder_info->sessions[event_idx]) | ;
(*decoder_info->num_sessions)++;
}
if (success) {
decoder_info->events[event_idx] = event;
(*decoder_info->num_events)++;
}
return true;
}
// -----------------------------------------------------------------------------------------
// Callback used to decode the payload sender type
static boo... |
/*
* 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 (!endpoint) {
return MetaResponseCodeUnhandled;
} |
if (!prv_is_endpoint_allowed_with_session(endpoint, session)) {
return MetaResponseCodeDisallowed;
}
return MetaResponseCodeNoError;
}
static void prv_cleanup_router(ReceiveRouter *rtr) {
memset(rtr, 0, sizeof(*rtr));
}
static bool prv_copy_header(ReceiveRouter *rtr, size_t *data_size_p, const uint8_t **... |
ntext, passed);
}
// -------------------------------------------------------------------------------
static void prv_test_sleep_reward(void *context) {
bool passed = true;
const ActivityScalarStore AVERAGE_SLEEP = 1 * MINUTES_PER_HOUR;
const ActivityScalarStore GOOD_SLEEP = 2 * MINUTES_PER_HOUR;
// Hack to g... | time_util_get_midnight_of(rtc_get_time()) | + 1 * SECONDS_PER_HOUR);
activity_prefs_sleep_insights_set_enabled(true);
const ActivityScalarStore AVERAGE_SLEEP = 2 * MINUTES_PER_HOUR;
// History with low median but good sleep over the past few days
ActivitySettingsValueHistory sleep_history = {
.utc_sec = rtc_get_time(),
.values = {
0, //... |
kout_active__workout_render_walk(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 84,
.distance_m = 1234,
.avg_pace = health_util_get_pace(84, 1234),
.bpm = 71,
.hr_zone = 0,
};
WorkoutActiveWindow *active_window = workout_active_create_for_activity_type(
Activit... | (active_window, 0) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__workout_render_hr_zone_3(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 789,
.distance_m = 234,
.avg_pace = health_util_get_pace(789, 234),
.bpm = 197,
.hr_zone = 3,
};
Work... |
/*
* 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... | for (unsigned int index = 0; index < ARRAY_LENGTH(map); ++index) {
const struct ANCSAppMetadata *mapping = &map[index];
if (pstring_equal_cstring(&app_id->pstr, mapping->app_id)) {
return mapping;
}
} |
// App ID doesn't match any of the known IDs:
return &s_generic_app;
}
time_t ancs_notifications_util_parse_timestamp(const ANCSAttribute *timestamp_attr) {
PBL_ASSERTN(timestamp_attr);
struct PACKED {
char year[4];
char month[2];
char day[2];
char T[1];
char hour[2];
char minute[2];
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_ALWAYS, "LR: %p. Incorrect task! Expected <%s> got <%s>",
(void*) saved_lr, pebble_task_get_name(expected_task),
pebble_task_get_name(pebble_task_get_current())) | ;
trigger_fault(RebootReasonCode_Assert, saved_lr);
}
}
void passert_check_not_task(PebbleTask unexpected_task) {
uintptr_t saved_lr = (uintptr_t) __builtin_return_address(0);
if (pebble_task_get_current() == unexpected_task) {
PBL_LOG(LOG_LEVEL_ALWAYS, "LR: %p. Incorrect task! Can't be <%s>",
... |
he "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 distributed on an "AS IS" BASIS... | open_settings_file(&file) | ;
cl_must_pass(settings_file_get(&file, (uint8_t*)&wakeup_id, sizeof(wakeup_id),
(uint8_t*)&wakeup_entry_v1, sizeof(wakeup_entry_v1)));
cl_assert_equal_i(wakeup_entry_v1.reason, WAKEUP_REASON);
cl_assert_equal_i(wakeup_entry_v1.repeat_hours_missed, 0);
cl_assert(!wakeup_entry_v1.repeating);
cl_assert(w... |
e_init_cookie(VALID_OBJECT_SIZE, ObjectWatchWorker, EXPECTED_COOKIE);
assert_ack_count(1);
assert_nack_count(0);
cl_assert_equal_i(EXPECTED_COOKIE, put_bytes_get_index());
}
void test_put_bytes__init_nack_upon_oom(void) {
fake_malloc_set_largest_free_block(1024); // PutBytes allocates ~2K
prv_receive_init(... | cl_assert_equal_i(event.type, PEBBLE_PUT_BYTES_EVENT) | ;
cl_assert_equal_i(event.put_bytes.type, PebblePutBytesEventTypeProgress);
cl_assert_equal_i(event.put_bytes.object_type, ObjectFirmware);
cl_assert_equal_i(event.put_bytes.bytes_transferred, sizeof(chunk));
cl_assert_equal_i(event.put_bytes.progress_percent, 100 * sizeof(chunk) / VALID_OBJECT_SIZE);
cl_asse... |
"services/common/comm_session/session_send_buffer.h"
#include "services/common/get_bytes/get_bytes_storage.h"
#include "services/common/system_task.h"
#include "services/normal/filesystem/pfs.h"
#include "system/hexdump.h"
#include "system/logging.h"
#include "util/math.h"
#include "util/net.h"
#include <bluetooth/an... | MIN(remaining_bytes, max_buf_len - sizeof(GetBytesRspObjectData)) | ;
packet_len = data_len + sizeof(GetBytesRspObjectData);
}
} else {
packet_len = sizeof(GetBytesRspObjectInfo);
}
SendBuffer *sb;
if (packet_len == 0 ||
!(sb = comm_session_send_buffer_begin_write(state->session, GET_BYTES_ENDPOINT_ID, packet_len,
... |
steps;
int32_t typical_steps;
int32_t daily_average_steps;
} HealthActivitySummaryCardData;
#define PROGRESS_CURRENT_COLOR (PBL_IF_COLOR_ELSE(GColorIslamicGreen, GColorDarkGray))
#define PROGRESS_TYPICAL_COLOR (PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack))
#define PROGRESS_BACKGROUND_COLOR (PBL_IF_COLOR_ELSE(GCol... | (ctx, base_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... | {
if (node == NULL) {
return NULL;
}
ListNode *head = list_get_head(node);
ListNode *new_head = head->next;
list_remove(head, NULL, NULL);
return new_head;
} | |
}
if (flags->has_mexico_nom_nyce) {
prv_append_regulatory_compliance_mark(cd, &cd->nom_nyce_mark);
}
prv_finished_appending_regulatory_compliance_marks(cd);
if (flags->has_japan_telec_r) {
prv_append_certification_menu(cd, &(SystemCertificationMenuItem) {
.draw_cell_fn = prv_draw_rt_cell,
... | (&data->bmp_layer, bmp) | ;
bitmap_layer_set_compositing_mode(&data->bmp_layer, GCompOpAssign);
layer_add_child(window_layer, bitmap_layer_get_layer(&data->bmp_layer));
GRect title_text_frame = (GRect) { .size = title_text_size };
const int16_t title_text_internal_padding = 5;
title_text_frame.origin.y = bmp_frame.origin.y + bmp_size... |
ral
I2C_InitTypeDef i2c_init_struct;
I2C_StructInit(&i2c_init_struct);
if (BOARD_CONFIG.i2c_bus_configs[bus_idx].clock_speed > I2C_NORMAL_MODE_CLOCK_SPEED_MAX) { //Fast mode
i2c_init_struct.I2C_DutyCycle = BOARD_CONFIG.i2c_bus_configs[bus_idx].duty_cycle;
}
i2c_init_struct.I2C_ClockSpeed = BOARD_CONFIG.... | (LOG_LEVEL_ERROR, "Attempted release of disabled bus %d by device %d", bus_idx, device_id) | ;
bus_unlock(bus);
return;
}
bus->user_count--;
if (bus->user_count == 0) {
bus_disable(bus_idx);
}
bus_unlock(bus);
}
void i2c_reset(I2cDevice device_id) {
PBL_ASSERTN(s_initialized);
PBL_ASSERTN(device_id < BOARD_CONFIG.i2c_device_count);
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[d... |
PBL_HEXDUMP_D_SERIAL(LOG_LEVEL_DEBUG, hdr, sizeof(hdr)) | ;
}
void pfs_command_fs_ls(void) {
char display_buf[80];
int pages_in_use = 0;
prompt_send_response("Page:\tFilename\tFile Size\tFile Info\tErase Count\n");
for (uint16_t pg = 0; pg < s_pfs_page_count; pg++) {
PageHeader pg_hdr;
FileHeader file_hdr;
pg_hdr.page_flags = prv_get_page_flags(pg);
... | |
graphics_draw_vertical_line_dotted(&ctx, GPoint(20, 0), MAX_NUM_ROWS - 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(22, 0), MAX_NUM_ROWS + 1 );
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_even_cols_no_clip")));
// Odd cols of different lengths
... | GPoint(10, 70) | , 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(5, 76), 5);
// T facing right - even vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(50, 70), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(45, 75), 5);
// T facing right - odd vert, even horiz
graphics_draw_vertical_line_do... |
_certification_menu(cd, &(SystemCertificationMenuItem) {
.draw_cell_fn = prv_draw_fcc_cell,
.arg1 = "FCC",
.arg2 = prv_get_usa_fcc_id(),
});
}
if (flags->has_canada_ic) {
prv_append_certification_menu(cd, &(SystemCertificationMenuItem) {
.draw_cell_fn = prv_draw_regulatory_id... | window_set_window_handlers(&data->window, &(WindowHandlers) {
.load = prv_certification_window_load,
.unload = prv_certification_window_unload,
}) | ;
app_window_stack_push(&data->window, true);
}
static void prv_kcc_window_load(Window *window) {
SystemCertificationData *data = (SystemCertificationData *) window_get_user_data(window);
Layer *window_layer = window_get_root_layer(window);
const char *title = "South Korea KCC";
prv_init_status_bar(&data->s... |
init_icon(timeline_layout);
layer_deinit(&timeline_layout->layout_layer.layer);
i18n_free_all(timeline_layout);
}
void timeline_layout_init_info(TimelineLayoutInfo *info, TimelineItem *item, time_t current_day) {
*info = (TimelineLayoutInfo) {
.timestamp = item->header.timestamp,
.duration_s = item->head... | layer_add_child(&timeline_layout->layout_layer.layer, &icon_layer->layer);
kino_layer_play(icon_layer);
} |
static void prv_deinit_icon(TimelineLayout *layout) {
kino_layer_deinit(&layout->icon_layer);
}
////////////////////////
// Layout Impl
////////////////////////
GSize timeline_layout_get_content_size(GContext *ctx, LayoutLayer *layout) {
return ((TimelineLayout *)layout)->view_size;
}
static void prv_update_pr... |
handlers got called
cl_assert_equal_i(s_started_handler_calls.num_calls, 1);;
cl_assert(ABSOLUTE_VALUE(s_started_handler_calls.entries[0].fired_time_ms - start_ms - delay) <= 1);
cl_assert_equal_i(s_setup_handler_calls.num_calls, 1);;
cl_assert(s_setup_handler_calls.entries[0].fired_time_ms - start_ms <= 1);
... | animation_destroy(h) | ;
#endif
}
// --------------------------------------------------------------------------------------
// 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... |
.sdk_version = {
.major = 5,
.minor = 13,
},
.app_face_bg_color = {0},
.template_id = 0,
};
// menu layer
static const AppDBEntry menu_layer_app = {
.name = MENU_LAYER_APP_NAME,
.uuid = {0xb8, 0x26, 0x2e, 0x08, 0x57, 0xe9, 0x4e, 0x58,
0x88, 0x02, 0x45, 0xfd, 0xfe, 0xe0, 0xac, 0x77},
.... | app_menu_data_source_get_count(&data_source) | ;
for (uint16_t i = 0; i < num_apps; i++) {
AppMenuNode *node = app_menu_data_source_get_node_at_index(&data_source, i);
cl_assert(node);
}
}
void test_app_menu_data_source__check_default_order_apps(void) {
// settings has to be at the beginning. The app_menu_data_source module enforces it
static cons... |
, 56},
{ 928, 216, 88},
{ 872, 272, 64},
{ 824, 168, 104},
{ 784, 88, 144},
{ 784, 48, 144},
{ 752, 48, 120},
{ 848, 48, 120},
{ 920, 80, 104},
{ 984, 112, 64},
{ 1112, 120, 40},
{ 1304, 152, 136},
{ 1040, 240, 32},
{ 888, 248, -120},
{ 752, 224, -144},
{ 824,... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_ron_2
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 95
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// elapsed: 0 minutes
{ 16, -16, -1000},
{ 32, -24, -1032},
{ 64... |
{ 160, -24, -1000},
{ 200, -8, -1008},
{ 240, -8, -1000},
{ 232, -48, -1016},
{ 232, -48, -992},
{ 224, -40, -968},
{ 232, -56, -976},
{ 248, -32, -952},
{ 248, -24, -952},
{ 240, -40, -952},
{ 224, -32, -928},
{ 232, -56, -928},
{ 240, -40, -912},
{ 256, -48, -8... |
value_length = sizeof(out);
bool has_more = true;
const uint16_t next_length =
gatt_client_subscriptions_consume_notification(&handle_out, out, &value_length,
GAPLEClientApp, &has_more);
cl_assert_equal_i(handle_out, BLE_CHARACTERISTIC_INVALID);
... | gatt_client_get_event_pending_state(GAPLEClientKernel) | , true);
fake_event_clear_last();
// fake pend an event to the app
gatt_client_subscriptions_reschedule(GAPLEClientApp);
cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientApp), true);
fake_event_clear_last();
}
static void prv_assert_no_pending_events_to_kernel_and_app(void) {
cl_assert_equ... |
with sum should return work (return non-zero)
HealthValue value;
value = health_service_aggregate_averaged(HealthMetricRestingKCalories, time_start_of_today(),
time(NULL), HealthAggregationSum,
HealthServiceTimeScopeOnce);
APP... | {
HealthAPITestAppData *data = context;
strcpy(data->debug_card.dialog_text, "HR stats");
// Get various stats
time_t end_time = time(NULL);
// List of time ranges
typedef struct {
uint32_t seconds;
char *desc;
} TimeRange;
TimeRange ranges[] = {
{1 * SECONDS_PER_HOUR, "1 hour"},
{30 ... |
// -----------------------------------------------------------------------------------------
static void debug_window_load(Window *window) {
HealthAPITestAppData *data = window_get_user_data(window);
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
static S... |
.flags;
bt_driver_handle_host_added_bonding(&bonding);
}
void bt_persistent_storage_register_existing_ble_bondings(void) {
ForEachBLEPairingInternalData internal_itr_data = {
.cb = prv_register_bondings_for_each_ble_cb,
};
prv_file_each(prv_ble_pairing_internal_for_each_itr, &internal_itr_data);
}
void an... | if (op == BtPersistBondingOpDidAdd && !link_key) {
// If this is an add, and there is no link key, then don't store anything.
// gap_pair typically sends just a name + addr combo before the link key comes in which should
// be ignored as we aren't fully paired until we have a link key
return BT_BONDING_... |
if (name) {
strncpy(new_data.bt_classic_data.name, name, BT_DEVICE_NAME_BUFFER_SIZE);
}
if (link_key) {
new_data.bt_classic_data.link_key = *link_key;
}
if (platform_bits) {
new_data.bt_classic_data.platform_bits = *platform_bits;
}
GapBondingFileSetStatus status =
prv_file_set(&key, ... |
prv_feed_minute_data(20, &minute_data[100], false /*simulate_bg_delays*/) | ;
activity_algorithm_get_steps(&steps_awake_120m);
// We should get steps counted while not sleeping
printf("\nWhile awake: ");
printf("\n Counted %d steps first 60m", steps_awake_60m);
printf("\n Counted %d steps next 40m", steps_awake_100m - steps_awake_60m);
printf("\n Counted %d steps last 20m", ste... | |
0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 467, 0x0},
{ 0, 0x15, 32, 0x0},
{ 0, 0x15, 0, 0x0},
{ 0, 0x15, 0, 0x0},
// 210: Local time: 12:41:00 AM
{ 0, 0x15, 0, 0x0},
{ 0,... | { 0, 0x65, 0, 0x0},
{ 0, 0x65, 0, 0x0},
{ 0, 0x65, 0, 0x0},
{ 0, 0x65, 0, 0x0},
{ 0, 0x55, 343, 0x0},
{ 0, 0x55, 0, 0x0},
// 330: Local time: 02:41:00 AM
{ 0, 0x55, 113, 0x0},
{ 0, 0x55, 0, 0x0},
{ 0, 0x55, 0, 0x0},
{ 0, 0x55, 0, 0x0},
{ 0, 0x55, 0, 0x0},
{ 0, 0x55, 0... |
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
// 390: Local time: 03:41:00 AM
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 0x0},
{ 0, 0x24, 0, 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... | gpath_draw_outline(ctx, &path_layer->path) | ;
}
}
void path_layer_init(PathLayer *path_layer, const GPathInfo *path_info) {
gpath_init(&path_layer->path, path_info);
const GRect outer_rect = gpath_outer_rect(&path_layer->path);
layer_init(&path_layer->layer, &outer_rect);
path_layer->stroke_color = GColorWhite;
path_layer->fill_color = GColorBlack;
... |
cl_assert(new_tuple->type == TUPLE_BYTE_ARRAY);
cl_assert(new_tuple->length == sizeof(SOME_DATA));
cl_assert(old_tuple->type == TUPLE_BYTE_ARRAY);
cl_assert(old_tuple->length == sizeof(SOME_DATA));
cl_assert(memcmp(new_tuple->value->data, old_tuple->value->data, sizeof(SOME_DATA)) == 0);
... | cl_assert(has_tuple[DATA_IDX] == true) | ;
}
}
|
ListNode *) s_session_head, &session->node));
return circular_buffer_copy_offset(&session->send_buffer, start_off, data_out, length);
}
void comm_session_send_queue_consume(CommSession *session, size_t length) {
circular_buffer_consume(&session->send_buffer, length);
}
static void prv_send_next_kernel_bg_cb(void ... | (session, consumer, state, max_period_secs, NULL) | ;
}
void comm_session_set_responsiveness_ext(CommSession *session, BtConsumer consumer,
ResponseTimeState state, uint16_t max_period_secs,
ResponsivenessGrantedHandler granted_handler) {
s_responsiveness_max_period_s = max_period_secs... |
/*
* 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... | attribute_list_destroy_list(¬if_attr_list) | ;
attribute_list_destroy_list(&end_workout_attr_list);
attribute_list_destroy_list(&open_workout_attr_list);
return item;
}
void workout_utils_send_abandoned_workout_notification(void) {
TimelineItem *item = prv_create_abandoned_workout_notification();
if (item) {
item->header.from_watch = true;
ite... |
read_profile, read_length);
}
}
static void prv_read_timeout(void *context) {
if (smartstrap_fsm_state_test_and_set(SmartstrapStateReadInProgress,
SmartstrapStateReadComplete)) {
// we need to handle the timeout from KernelBG
ReadCompleteContext context = {
.su... | {
prv_store_byte(data);
} |
return should_context_switch;
}
void prv_notify_timeout(void *context) {
if (smartstrap_fsm_state_test_and_set(SmartstrapStateNotifyInProgress,
SmartstrapStateReadComplete)) {
// we need to handle the timeout from KernelBG
ReadCompleteContext context = {
.suc... |
/*
* 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, 0x6d, 0, 121, 0},
{ 0, 0x7d, 1666, 125, 0},
{ 0, 0x7f, 0, 123, 0},
{ 0, 0x7f, 749, 126, 0},
{ 0, 0x7e, 539, 127, 0},
// 30: Local time: 2016-05-15 09:45:00 PM
{ 0, 0x7e, 0, 125, 0},
{ 0, 0x7e, 0, 127, 0},
{ 0, 0x7e, 0, 127, 0},
{ 0, 0x7e, 0, 151, 0},
{ 0, 0x7e, 0, 129, 0... | |
_assert_equal_i(recognizers[1]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[2]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Cancelled);
// Layer C's and layer A's recognizers get reset when layer B becomes the new active layer
prv_set_all_states(... | (manager.active_layer, &layer_c) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersActive);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizer... |
yright 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 in writing... | memset(dest, 0, 5) | ;
size_t copied = utf8_copy_character(dest, (utf8_t *)NIHAO, 3);
cl_assert_equal_i(copied, NIHAO_FIRST_CHARACTER_BYTES);
cl_assert_equal_s((char *)dest, NIHAO_FIRST_CHARACTER);
}
void test_utf8__copy_last_character(void) {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf... |
/*
* 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... | ble_gap_conn_rssi_get(conn_idx, &conn_rssi) | ;
const bool success = (e == BLE_STATUS_OK);
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_conn_rssi_get err: %x", e);
conn_rssi = 0;
}
data = (HcAnalyticsGetConnectionQuality) {
.success = success,
.rssi = conn_rssi,
};
done:
hc_protocol_enqueue_response(msg, (uint8_t *)&data, sizeof(... |
&data_bytes, &minutes);
cl_assert(success);
cl_assert(data_bytes < ALG_MINUTE_DATA_FILE_LEN && data_bytes > ALG_MINUTE_DATA_FILE_LEN / 2);
cl_assert(minutes < ALG_MINUTE_FILE_MAX_ENTRIES * ALG_MINUTES_PER_FILE_RECORD);
cl_assert(minutes > ALG_MINUTE_FILE_MAX_ENTRIES * ALG_MINUTES_PER_FILE_RECORD / 2);
// ... | rtc_set_time(start_utc) | |
_s[HRZone_Zone0], 0);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone1], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone2], 0);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 0);
prv_inc_time(10);
prv_put_bpm_event(ZONE_2_HR, HRMQuality_Good);
cl_assert(workout_service_get_current_workout_hr_zone_time(hr_z... | {
int32_t avg_hr;
cl_assert(!workout_service_get_avg_hr(&avg_hr));
cl_assert(workout_service_start_workout(ActivitySessionType_Run));
prv_put_bpm_event(140, HRMQuality_Good);
prv_put_bpm_event(140, HRMQuality_Good);
cl_assert(workout_service_get_avg_hr(&avg_hr));
cl_assert_equal_i(avg_hr, 140);
prv_p... |
// ---------------------------------------------------------------------------------------
// Open the app, start a workout, close app.
// 55 min - Make sure the notification was sent.
// 60 min - Make sure the workout was ended.
void test_workout_service__abandon_workout(void) {
// Put some time into the clock
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... | 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* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_circle(ctx, GPoint(28, 14), 12);
}
... |
ITE_TIMEOUT_MS;
bool consumed = prv_wait_until_write_space_available(buffer, (sizeof(header) + length),
write_timeout);
bt_lock();
if (!consumed) {
PBL_LOG(LOG_LEVEL_ERROR, "Subscription buffer full. Dropping GATT notification of %u bytes",
... | (LOG_LEVEL_ERROR, "App attempted to consume notifications without buffer.") | ;
return false;
}
return true;
}
// -------------------------------------------------------------------------------------------------
bool prv_get_next_notification_header(GAPLEClient client,
GATTBufferedNotificationHeader *header_out) {
bool has_notification = false;
... |
ile *file = activity_private_settings_open();
if (file) {
rv = settings_file_set(file, &key, sizeof(key), val, val_len);
activity_private_settings_close(file);
}
return rv;
}
// ------------------------------------------------------------------------------------------------
// Builds the base attribute l... | (notif_time, 0,
TimelineItemTypeNotification,
LayoutIdNotification, ¬if_attr_list,
&action_group) | ;
i18n_free_all(¬if_attr_list);
attribute_list_destroy_list(¬if_attr_list);
attribute_list_destroy_list(&positive_attr_list);
attribute_list_destroy_list(&neutral_attr_list);
attribute_list_destroy_list(&negative_attr_list);
return item;
}
// --------------------------------------------------------... |
/*
* 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... | {
progress_callback(sector - first_sector + 1, count, progress_context);
} |
}
FLASH_Lock();
return true;
}
bool system_flash_write(
uint32_t address, const void *data, size_t length,
SystemFlashProgressCb progress_callback, void *progress_context) {
dbgserial_print("system_flash_write(");
dbgserial_print_hex(address);
dbgserial_print(", ");
dbgserial_print_hex(length);
... |
-----------------
//! Try using sessions after we've closed them.
void test_data_logging__invalid_session_use_after_close(void) {
uint32_t data[] = { 1, 2, 3 };
DataLoggingSessionRef session = data_logging_create(0x1234, DATA_LOGGING_UINT, 4, false);
cl_assert(session);
fake_system_task_callbacks_invoke_pendin... | (rcv_buffer, rcv_bytes) | ;
cl_assert(random_crc == session_crc);
// Free buffer
free(rcv_buffer);
}
// ----------------------------------------------------------------------------------------
// Test using the endpoint to empty the session
void test_data_logging__send_session_1(void) {
prv_endpoint_test(true /*buffered*/, 1, 1000);
... |
ption_menu_push(
title, OptionMenuContentType_SingleLine, selected, &callbacks,
ARRAY_LENGTH(s_before_time_strings), true /* icons_enabled */, s_before_time_strings, data);
}
static void prv_deinit_cb(SettingsCallbacks *context) {
i18n_free_all(context);
app_free(context);
}
static uint16_t prv_num_ro... | fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD) | );
#endif
i18n_free_all(i18n_owner);
return &expandable_dialog->dialog.window;
}
static Window *prv_init(void) {
const uint32_t version = timeline_prefs_get_settings_opened();
timeline_prefs_set_settings_opened(TimelineSettingsVersionCurrent);
if (version == TimelineSettingsVersion_InitialVersion) {
retu... |
gister_INT_EN_0, 0);
prv_disable_operating_mode(AccelOperatingMode_ShakeDetection);
}
void accel_enable_shake_detection(bool enable) {
if (s_shake_detection_enabled == enable) {
// the requested change matches what we already have!
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "%s shake detection", enable ? "Ena... | (BMA255Axis_Y) | ;
pass &= prv_selftest_axis(BMA255Axis_Z);
// g-range should be 4g to copy the BMI160
bma255_set_scale(BMA255Scale_4G);
return pass;
}
bool accel_run_selftest(void) {
return bma255_selftest();
}
////////////////////////////////////////////////////////////////////////////////
// Debug Commands
////////////... |
/*
* 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... | {
app_manager_put_launch_app_event(&(AppLaunchEventConfig) { .id = id });
prompt_send_response("OK");
} | else {
prompt_send_response("No app with id");
}
}
void command_worker_launch(const char *id_str) {
int32_t id = atoi(id_str);
if (id == 0) {
prompt_send_response("invalid app number");
return;
}
AppInstallEntry entry;
bool success = app_install_get_entry_for_install_id(id, &entry);
if (su... |
/*
* 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_calculate_incremental_start();
const unsigned int chunk_size = 128;
uint8_t buffer[chunk_size];
while (num_bytes > chunk_size) {
flash_read_bytes(buffer, address, chunk_size);
prv_calculate_incremental_words((const uint32_t*) buffer, chunk_size / 4);
num_bytes -= chunk_size;
address += c... | |
once though, so it's not the end of the world.
char *msg_i18n = i18n_noop("Dismissed");
int res_id = TIMELINE_RESOURCE_RESULT_DISMISSED;
if (action->type == TimelineItemActionTypeAncsDelete) {
msg_i18n = i18n_noop("Deleted");
res_id = TIMELINE_RESOURCE_RESULT_DELETED;
}
prv_put_notifica... | (LOG_LEVEL_INFO, "Opening watch app %s", uuid_buffer) | |
rator, &state, &head, TimelineIterDirectionPast,
14700), 0);
#if !CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[2].header.id));
cl_assert(iter_next(&iterator));
#endif
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[1].header.id));
cl_assert(iter_next(&i... | (iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_all_day_items[1].header.id) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
cl_assert(!uuid_equal(&first_all_day_event, &state.pin.header.id));
cl_assert(state.node->all_day);
cl_assert_equal_i(state.pin.header.timestamp, 1421136000);
/... |
omm_session_send_queue_consume(s_app_session_ptr, length - 1);
comm_session_send_queue_cleanup(s_app_session_ptr);
assert_consumed(AppMessageSenderErrorDisconnected, 1);
cl_assert_equal_i(s_app_install_timestamp_update_count, 0);
app_free(outbox_data);
}
void test_app_message_sender__byte_by_byte_consume(void)... | (first_length, comm_session_send_queue_copy(s_app_session_ptr, 0,
first_length, bytes_out)) | ;
comm_session_send_queue_consume(s_app_session_ptr, first_length);
// App quits with only one header byte consumed:
app_outbox_service_cleanup_all_pending_messages();
// Copy & consume the rest:
size_t second_length = (length - first_length);
cl_assert_equal_i(second_length, comm_session_send_queue_copy(... |
RAME_INTERVAL_MS,
.last_frame_time_ms = prv_get_ms_since_system_start()
};
*state = (AnimationState) {
.signature = ANIMATION_STATE_3_X_SIGNATURE,
.aux = aux_state,
};
}
// -------------------------------------------------------------------------------------------
void animation_private_state_deinit... | prv_find_animation_by_handle(state, animation_h, false /*quiet*/) | ;
if (!animation || animation->parent) {
// Only top-level animations can be destroyed
return false;
}
// If we're being called from the stopped or teardown handler, set the defer_delete flag.
// This will inform us to delete the animation once we return back to the animation code
// from the handler... |
64_t start_ms = prv_now_ms();
animation_schedule(complex);
// -------------------------------------------------------------------------------------
// Start A
prv_advance_to_ms_with_timers(start_ms + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_co... | (prv_count_handler_entries(&s_started_handler_calls, b), 2) | |
_LEVEL_ERROR, "Error opening file %d", fd);
} else {
pfs_close(fd);
}
s_write_offset = 0;
s_notif_storage_mutex = mutex_create_recursive();
}
void notification_storage_lock(void) {
mutex_lock_recursive(s_notif_storage_mutex);
}
void notification_storage_unlock(void) {
mutex_unlock_recursive(s_notif_st... | pfs_seek(fd, iter_state.header.payload_length, FSeekCur) | |
ed int before_time_m) {
if (before_time_m == 0) {
return PeekBeforeTimingMenuIndex_StartTime;
} else if (before_time_m <= 5) {
return PeekBeforeTimingMenuIndex_5Min;
} else if (before_time_m <= 10) {
return PeekBeforeTimingMenuIndex_10Min;
} else if (before_time_m <= 15) {
return PeekBeforeTimin... | PBL_ASSERTN(context) | ;
expandable_dialog_pop(context);
Window *window = prv_create_settings_window();
app_window_stack_push(window, true /* animated */);
}
static Window *prv_create_first_use_dialog(void) {
const void *i18n_owner = prv_create_first_use_dialog; // Use this function as the i18n owner
/// Title for the Timeline Qui... |
nsigned int record_order = 0;
const AppRegistryEntry *reg_entry = prv_get_registry_list_entry(install_id, &record_order);
if (reg_entry) {
bool rv = false;
// switch on registry type
switch (reg_entry->type) {
case AppInstallStorageFw:
rv = prv_app_install_entry_from_fw_registry_entry(reg_... | {
const AppRegistryEntry *reg_entry = prv_get_registry_list_entry(id, NULL /* record_order */);
if (reg_entry) {
return prv_get_md_for_reg_entry(reg_entry);
} else if (app_db_exists_install_id(id)) {
return prv_get_md_for_flash_id(id, worker);
}
// Not a registered app, fail.
PBL_LOG(LOG_LEVEL_ERRO... |
void app_install_release_md(const PebbleProcessMd *md) {
if (!md) {
return;
}
switch (md->process_storage) {
case ProcessStorageBuiltin:
break;
case ProcessStorageFlash:
case ProcessStorageResource:
kernel_free((PebbleProcessMd*) md);
}
}
static void prv_enumerate_app_db_delete(AppInstallI... |
6_t x2_rounded = (x2.raw_value + (FIXED_S16_3_ONE.raw_value / 2)) / FIXED_S16_3_ONE.raw_value;
if (x1_rounded > x2_rounded) {
// AA algorithm will draw lines in one way only, so non-AA should reject those too
return;
}
prv_assign_line_horizontal_non_aa(ctx, y, x1_rounded, x2_rounded);
}
void graphics_p... | grect_get_max_x(clip_box) | - 1)) {
return;
}
int16_t y_min = MAX(MIN(y0, y1), clip_box->origin.y);
int16_t y_max = MIN(MAX(y0, y1), clip_box->origin.y + clip_box->size.h);
#if PBL_COLOR
color.a = (uint8_t)(MAX_PLOT_BRIGHTNESS - opacity);
#else
if (opacity > (MAX_PLOT_BRIGHTNESS / 2)) {
// We're not plotting anything, bail
... |
/*
* 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_app_db.settings_file,
SETTINGS_FILE_NAME,
SETTINGS_FILE_SIZE) | ;
if (rv != S_SUCCESS) {
mutex_unlock(s_app_db.mutex);
}
return rv;
}
static void prv_close_file_and_unlock_mutex(void) {
settings_file_close(&s_app_db.settings_file);
mutex_unlock(s_app_db.mutex);
}
static status_t prv_cancel_app_fetch(AppInstallId app_id) {
if (pebble_task_get_current() == PebbleTas... |
tery charge state, and when to automatically dismiss the status
// modal window.
#define MAX_TRANSITIONS 6
typedef void (*EntryFunc)(void *);
typedef void (*ExitFunc)(void);
typedef enum BatteryUIStateID {
BatteryInvalid,
BatteryGood,
BatteryWarning,
BatteryLowPower,
BatteryCritical,
BatteryCharging,
B... | (get_strength_for_intensity(VibeIntensityMedium)) | ;
#else
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = prf_low_power_app_get_info(),
});
#endif
}
static void prv_exit_low_power(void) {
#ifndef RECOVERY_FW
modal_manager_set_min_priority(ModalPriorityMin);
watchface_launch_default(NULL);
vibe_intensity_set(vibe_intensity_get());
#else
app_manag... |
uart_clear_all_interrupt_flags(dev) | ;
} else {
const bool has_byte = uart_is_rx_ready(dev);
// read the data register regardless to clear the error flags
const uint8_t data = uart_read_byte(dev);
if (has_byte) {
if (dev->state->rx_irq_handler(dev, data, &err_flags)) {
should_context_switch = true;
}
... | |
}
}
static void prv_draw_processed_in_local(KinoReelTransformData *data, GContext *ctx, GPoint offset,
KinoReelProcessor *processor) {
KinoReel *reel = prv_get_current_reel(data);
GDrawCommandList *source_list = kino_reel_get_gdraw_command_list(reel);
GDrawCommandList *l... | if (!data) {
return;
} |
if (data->owns_from_reel) {
kino_reel_destroy(data->from_reel);
}
data->from_reel = from_reel;
data->owns_from_reel = take_ownership;
prv_free_list_copy(data);
}
KinoReel *kino_reel_transform_get_from_reel(KinoReel *reel) {
KinoReelTransformData *data = kino_reel_custom_get_data(reel);
if (data) {
... |
{
#if PLATFORM_TINTIN || PLATFORM_SILK
return GColorClear;
#endif
color = gcolor_closest_opaque(color);
if (!gcolor_equal(color, GColorClear)) {
return color;
}
color = prv_hard_coded_color_for_3rd_party_apps(uuid);
if (!gcolor_equal(color, GColorClear)) {
return color;
}
// if color isn't pr... |
static bool prv_app_install_entry_from_app_db_entry(AppInstallId id, AppDBEntry *db_entry,
AppInstallEntry *entry) {
*entry = (AppInstallEntry) {
.install_id = id,
.type = AppInstallStorageFlash,
.visibility = process_metadata_flags_visibility(db_entr... | |
/*
* 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... | 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 headers */);
load_resource_fixture_... |
tionAttributesMsg);
length -= sizeof(GetNotificationAttributesMsg);
bool error = false;
const bool did_get_attrs = ancs_util_get_attr_ptrs(data, length,
s_fetched_notif_attributes,
NUM_FETCHED_NOTIF_ATTRIBUT... | {
PBL_LOG(LOG_LEVEL_WARNING, "Multiple ANCS services registered?!");
ancs_invalidate_all_references();
} | |
/*
* 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... | applib_malloc(size) | |
CompositorTransitionDirectionLeft,
GColorWhite);
}
void test_graphics_window_stack_animation__left_flip_half_frame_clipping(void) {
prv_test_clipping_mask(prv_left_flip_half_frame_clipping, "left_flip_half_frame_clipping");
};
// This... | {
prv_test_clipping_mask(prv_right_flip_half_frame_clipping, "right_flip_half_frame_clipping");
} | ;
// This test records a clipping mask of the 3/4 progress frame of the right "round flip" compositor
// transition animation and then clips a full-screen red rectangle to the resulting mask
static void prv_right_flip_third_quarter_frame_clipping(GContext *ctx) {
// The 3/4 progress frame is ANIMATION_NORMALIZED_MA... |
head(false /* should_free_data_buffer */);
JS_VAR event = rocky_global_create_event(ROCKY_EVENT_ERROR);
jerry_set_object_native_handle(event, (uintptr_t)json_data_buffer,
prv_free_json_buffer_associated_with_postmessageerror_event);
rocky_define_property(event, ROCKY_EVENT_MESSAG... | memset(&s_state, 0, sizeof(s_state)) | ;
// Pebble comm session events to transition in & out of PostMessageStateDisconnected
s_state.comm_session_event_info = (EventServiceInfo) {
.type = PEBBLE_COMM_SESSION_EVENT,
.handler = prv_handle_comm_session_event,
};
event_service_client_subscribe(&s_state.comm_session_event_info);
if (sys_app_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... | CLIP(val, INT8_MIN, INT8_MAX) | ;
return;
}
case ANALYTICS_METRIC_ELEMENT_TYPE_INT16:
{
*((int16_t*)location) = (int16_t)CLIP(val, INT16_MIN, INT16_MAX);
return;
}
case ANALYTICS_METRIC_ELEMENT_TYPE_INT32:
{
*((int32_t*)location) = (int32_t)CLIP(val, INT32_MIN, INT32_MAX);
return;
}
}
WTF; // Should... |
&GPointZero, 0, 0, true);
touch_event = touch_event_queue_get_event(0, 1);
cl_assert_equal_p(touch_event, NULL);
}
void test_touch__handle_update_pressure(void) {
//TODO: We're not passing pressure updates to the UI yet (not so useful?)
}
typedef struct TouchEventContext {
TouchEvent touch_events[4];
ui... | (0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420) | ;
touch_handle_driver_event(TouchDriverEvent_ControllerError);
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_TOUCH_EVENT);
cl_assert_equal_i(event.touch.type, PebbleTouchEvent_TouchesCancelled);
touch_handle_update(0, TouchState_FingerDown, &GPoint(15, 15), 6, 3686440);
// ... |
;
} else if (uid == split_timestamp_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_split_timestamp_dict_part_one), (uint8_t*) s_split_timestamp_dict_part_one);
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_split_timestamp_dict_part_two), (uint8_t*) s_split_timestamp_dict_part_two);
s_num_ds_... | prv_send_notification((uint8_t *)&s_complete_dict) | ;
prv_send_notification((uint8_t *)&s_chunked_dict_part_one);
cl_assert_equal_i(s_num_requested_notif_attributes, 8 + 4);
cl_assert_equal_i(s_num_ds_notifications_received, 12 + 1 + 2 + 1 + 2);
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 4 + 4 + 4);
// Send a "corrupted" ... |
ransport *system_transport2 = (Transport *) TransportID2;
CommSession *system_session2 = comm_session_open(system_transport2, &s_transport_imp,
TransportDestinationSystem);
cl_assert(system_session2);
cl_assert_equal_p(s_last_closed_transport, system_transport);... | cl_assert_equal_i(s_send_next_count, 1) | ;
comm_session_send_next(session);
cl_assert_equal_i(fake_system_task_count_callbacks(), 1);
comm_session_send_next(session);
cl_assert_equal_i(fake_system_task_count_callbacks(), 1);
cl_assert_equal_i(s_send_next_count, 1);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(s_send_next_coun... |
;
flash_read_bytes((uint8_t *)&read, i, sizeof(read));
if (read != 0xffffffff) {
PBL_LOG_SYNC(LOG_LEVEL_INFO, ">>>> Address 0x%lx failed to erase: 0x%lx", i, read);
success = false;
}
}
return success;
}
// region: region to check (and possibly write)
// use_rand: write random values
// pe... | check_region_erased(region) | || !check_region_write(region, true, true));
} else if (stress_data.stress_index == FILE_SUBSECTOR_STRESS) {
failed = (!check_region_erased(region) || !check_subsector_bitflip(region));
} else {
PBL_LOG(LOG_LEVEL_WARNING, "Unknown stress test %d!", stress_data.stress_index);
}
if (!abort_stress_test) ... |
/*
* 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... | scroll_layer_set_click_config_onto_window(&data->scroll_layer, window) | ;
// Initialize the first text layer
text_layer_init(&data->text_layer_1, &GRect(0, 20, scroll_bounds.size.w, 2000));
text_layer_set_text(&data->text_layer_1, QUOTE_BUF_1);
text_layer_set_background_color(&data->text_layer_1, GColorYellow);
text_layer_set_font(&data->text_layer_1, fonts_get_system_font(FONT_... |
till stable
if (s_manager_state.sensor_stable) {
// If we just went on-wrist or off-wrist, reset the stable state
bool off_wrist_now = (data->hrm_quality == HRMQuality_OffWrist);
if (off_wrist_now != s_manager_state.off_wrist_when_stable) {
s_manager_state.sensor_stable = false;
s_manager_stat... | HRM_LOG("Need sensor on again in %"PRIu32" sec", remaining_ms / MS_PER_SECOND) | ;
turn_sensor_on = (remaining_ms <= 0);
}
if (turn_sensor_on && !hrm_is_enabled(HRM)) {
// Turn on the sensor now
HRM_LOG("Turning on HR sensor");
s_manager_state.accel_state = sys_accel_manager_data_subscribe(
ACCEL_SAMPLING_25HZ, prv_handle_accel_data, NULL, PebbleTask_NewT... |
ATCH");
char error_code_buffer[12];
itoa_hex(error_code, error_code_buffer, sizeof(error_code_buffer));
dbgserial_putstr(error_code_buffer);
display_error_code(error_code);
static uint8_t prev_button_state = 0;
prev_button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
while (1) {
// See if... | dbgserial_putstr("Force-booting recovery mode...") | ;
}
if (force_boot_recovery_mode || check_for_fw_start_failure()) {
if (!switch_to_recovery_fw()) {
// We've failed to load recovery mode too many times.
sad_watch(ERROR_CANT_LOAD_FW);
}
} else {
check_update_fw();
}
if (check_and_increment_reset_loop_detection_bits()) {
sad_watc... |
fetch_size);
uint16_t day = time_util_get_day(old_history.utc_sec);
int old_age = state->cur_day_index - day;
// If this is resting kcalories, the default for each day is not 0
if (metric == ActivityMetricRestingKCalories) {
uint32_t full_day_resting_calories =
activity_pr... | for (uint32_t i = 1; i < history_len; i++) {
history[i] = m_info.converter(setting_history.values[i]);
ACTIVITY_LOG_DEBUG("get metric %"PRIi32" %"PRIu32" days ago: %"PRIi32"", (int32_t)metric,
i, history[i]);
} |
activity_private_settings_close(file);
}
}
unlock:
mutex_unlock_recursive(state->mutex);
return success;
}
// ------------------------------------------------------------------------------------------------
DEFINE_SYSCALL(bool, sys_activity_get_metric, ActivityMetric metric,
uint32_t h... |
bool has_privileged_access) {
return NULL;
}
static bool resource_storage_file_find_resource(ResourceStoreEntry *entry, ResAppNum app_num,
uint32_t resource_id) {
if (app_num != SYSTEM_APP) {
return false;
}
for (unsigned int i = 0; i < ... | (LOG_LEVEL_WARNING, "Could not open resource pfs file <%s>, fd: %d", filename, fd) | ;
}
return fd;
}
static bool resource_storage_app_file_find_resource(ResourceStoreEntry *entry, ResAppNum app_num,
uint32_t resource_id) {
if (app_num == SYSTEM_APP) {
return false;
}
// Need to cast to uintptr_t first to make test compiling on 64-bit ... |
/*
* 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... | ((param >> 24) & 0xff) | ;
prv_end_command();
}
void boot_display_show_boot_splash(void) {
prv_wait_busy();
prv_draw_scene(SCENE_SPLASH);
// Don't turn the screen on until the boot-splash is fully drawn.
prv_wait_busy();
prv_screen_on();
}
void boot_display_show_firmware_update_progress(
uint32_t numerator, uint32_t denominat... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
const GRect *bounds = &scroll_layer_get_layer(scroll_layer)->bounds;
GPoint offset = { .y = bounds->size.h - new_height };
#if PBL_ROUND
// do paging on round display
offset.y = ROUND_TO_MOD_CEIL(offset.y, scroll_layer->layer.frame.size.h);
#endif
scroll_layer_set_content_size(scroll_layer,
... | |
, &(MenuLayerCallbacks) {
.get_num_rows = prv_menu_layer_get_num_rows,
.draw_row = prv_menu_layer_draw_row,
.select_click = prv_menu_layer_select,
.get_cell_height = prv_menu_layer_get_cell_height,
.selection_will_change = prv_menu_layer_selection_will_change,
});
// Only setup the content indi... | GPoint(0, new_state->scroll_offset_y) | ;
scroll_layer_set_content_offset(&launcher_menu_layer->menu_layer.scroll_layer, new_scroll_offset,
animated);
}
void launcher_menu_layer_get_selection_vertical_range(const LauncherMenuLayer *launcher_menu_layer,
GRangeVertical *... |
printf("}");
ListNode *node = *list;
int list_num = list_count(node);
bool failed = list_num != count;
if (failed) {
count = list_num;
}
if (!failed) {
for (uint32_t i = 0; (i < count) && !failed; i++) {
failed = (indices[i] != ((RecognizerHandled *)node)->idx);
node = list_get_next(... | ((int[]) {0, 1}, 2, &s_recognizers_handled) | ;
// Recognizers that attached to layers other than the active layer and its ancestors will not be
// processed
recognizer_add_to_list(recognizers[2], &layer_a.recognizer_list);
recognizer_add_to_list(recognizers[3], &layer_a.recognizer_list);
recognizer_add_to_list(recognizers[4], &layer_b.recognizer_list);... |
e didn't find a sample, just give up on reading PPG for this handshake
break;
}
data_out->num_samples++;
}
PPG_DBG("num_samples reg: %"PRIu8" read: %u",
num_ppg_samples, data_out->num_samples);
}
static void prv_write_accel_sample(HRMDevice *dev, uint8_t sample_idx, AccelRawData *data) {
... | interval_timer_get(&s_handshake_interval_timer,
&average_handshake_interval_ms) | ;
// Try to write the register frequently early on, and then every half second to accommodate
// changes over time.
if (num_intervals == 2 ||
num_intervals == 10 ||
(num_intervals % 30) == 0) {
prv_set_host_one_second_time_register(HRM, average_handshake_interval_ms);
}
// Read the SYNC byte ... |
/*
* 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... | {
// Each byte block_addr corresponds to 8 pixels (i.e. 4-bytes in the 8-bit frame buffer).
// Thus multiply by 8 to get the word offset within the destination 8-bit frame buffer.
// Also need to account for the fact that the 1-bit frame buffer has 16 bits of unused space
// on each row (thus 16 bytes need to b... |
// PRO TIP: if you have to modify this function, expect to waste the rest of your day on it
void render_glyph(GContext* const ctx, const uint32_t codepoint, FontInfo* const font,
const GRect cursor) {
if (codepoint_is_special(codepoint)) {
TextRenderState *state = app_state_get_text_render_sta... |
/*
* 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 (periph_clock == SpiPeriphClockAPB1) {
clock = clocks.PCLK1_Frequency;
} else if (periph_clock == SpiPeriphClockAPB2) {
clock = clocks.PCLK2_Frequency;
} else {
WTF;
} |
int lg;
if (bus_frequency > (clock / 2)) {
lg = 1; // Underclock to the highest possible frequency
} else {
uint32_t divisor = clock / bus_frequency;
lg = ceil_log_two(divisor);
}
// Prescalers only exists for values in [2 - 256] range
PBL_ASSERTN(lg > 0);
PBL_ASSERTN(lg < 9);
// return ... |
ndif
return (rv == S_SUCCESS);
}
static void prv_prune_ordered_timeline_list(TimelineNode **head) {
TimelineNode *node = *head;
TimelineNode *next_node;
while (node) {
next_node = (TimelineNode *)list_get_next((ListNode *)node);
time_t end_time = node->timestamp + (node->duration * SECONDS_PER_MINUTE);... | prv_find_by_uuid(*head, key) | ;
if (node) {
timeline_iter_remove_node(head, node);
return true;
} else {
return false;
}
}
status_t timeline_iter_init(Iterator *iter, TimelineIterState *iter_state, TimelineNode **head,
TimelineIterDirection direction, time_t timestamp) {
iter_state->direction = direction;
iter_state->star... |
/*
* 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 (strncmp(s1, s2, len) == 0) {
return (char*)s1;
} |
s1++;
}
return NULL;
}
|
e "8bit/test_framebuffer.h"
#endif
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
///////////////////////////////////////////////////////////
// Fakes
#include "fake_gbitmap_get_data_row.h"
// Setup
////////////////////////////////////
static GBitm... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_bw_assign_center_45.Xbit.pbi")) | ;
}
void test_graphics_draw_rotated_bitmap__origin_bw_set(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, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_bw,
... |
l_event();
state = (AccelSubscriberState *)s_data_subscribers;
while (state) {
if (!state->raw_buffer || state->samples_per_update == 0) {
state = (AccelSubscriberState *)state->list_node.next;
continue;
}
// If buffer has room, read more data
if (state->num_samples < s... | {
return -1;
} |
mutex_lock_recursive(s_mutex);
{
AccelSubscriberState* state = prv_subscriber_state(session);
if (!state) {
PBL_LOG(LOG_LEVEL_WARNING, "not subscribed");
goto unlock;
}
state->sampling_rate = rate;
prv_update_driver_config();
}
unlock:
mutex_unlock_recursive(s_mutex);
return 0... |
event_type == HRMEvent_LEDCurrent) {
led_current = hrm->led.current_ua;
} else if (hrm->event_type == HRMEvent_Diagnostics) {
if (!app_data->ready_to_send) {
return;
}
AppMessageResult result = app_message_outbox_begin(&app_data->out_iter);
PBL_ASSERTN(result == APP_MSG_OK);
... | {
AppData *app_data = app_state_get_user_data();
app_data->ready_to_send = true;
} |
static void prv_message_failed_cb(DictionaryIterator *iterator,
AppMessageResult reason, void *context) {
PBL_LOG(LOG_LEVEL_DEBUG, "Out message send failed - reason %i %s",
reason, prv_translate_error(reason));
AppData *app_data = app_state_get_user_data();
app_data->rea... |
GETTING_STARTED_COMPLETE = !GETTING_STARTED_COMPLETE;
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), i % SPRF_NUM_PAGES);
shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), (i + 1) % SPRF_NUM_PAGES);
... | (shared_prf_storage_get_valid_page_number()) | |
h"
#include "syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "os/mutex.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/list.h"
#include "util/mbuf.h"
//! Currently, we only support attributes being created by the App task
#define CONSUMER_TASK PebbleTask_App
//! Gets the nex... | if ((current_state == SmartstrapAttributeStateRequestInProgress) &&
(new_state == SmartstrapAttributeStateIdle)) {
return pebble_task_get_current() == PebbleTask_KernelBackground;
} else {
return false;
} |
}
static void prv_set_attribute_state(SmartstrapAttributeInternal *attr,
SmartstrapAttributeState new_state) {
PBL_ASSERTN(prv_is_valid_fsm_transition(attr, new_state));
attr->state = new_state;
}
//! Note; This should only be called from the consumer task
static bool prv_star... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.