prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | fake_event_clear_last() | ;
music_protocol_msg_callback(NULL, data, length);
}
static void prv_receive_and_assert_now_playing(bool expect_is_handled) {
uint8_t msg[] = { 0x10, 3, 'o', 'n', 'e', 3, 't', 'w', 'o', 5, 't', 'h', 'r', 'e', 'e', 0xAA,
0x00, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0x00 };
prv_receive_pp_data(msg, size... |
/*
* 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... | (msg, len) | ;
break;
default:
PBL_LOG(LOG_LEVEL_WARNING, "Unexpected command received, 0x%x", cmd);
return;
}
#else
prv_send_ack_nack(false /*ok*/);
#endif
}
|
/kernel_le_client/ams/ams.h"
#include "comm/bt_conn_mgr.h"
#include "services/normal/music.h"
#include "services/normal/music_internal.h"
#include "clar.h"
// Stubs & Fakes
///////////////////////////////////////////////////////////
#include "fake_events.h"
#include "fake_gatt_client_operations.h"
#include "fake_g... | fake_gatt_client_subscriptions_assert_subscribe(entity_update,
BLESubscriptionNotifications, GAPLEClientKernel) | ;
}
void test_ams__connect_to_music_service_upon_subscribing_entity_update_characteristic(void) {
prv_discover_ams(1 /* num_instances */);
// Not connected yet (still need to subscribe):
cl_assert_equal_s(music_get_connected_server_debug_name(), NULL);
// Simulate successful subscription:
BLECharacteristic ... |
ilable[ContentIndicatorDirectionDown]);
// WTF?!
menu_layer_set_selected_index(&l, MenuIndex(0, 1), MenuRowAlignNone, false);
cl_assert_equal_i(2 * FOCUSED - NORMAL, l.selection.y);
cl_assert_equal_i(NORMAL, l.selection.h);
cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]);
cl_asse... | (0, l.selection.y) | ;
menu_layer_set_selected_next(&l, false, MenuRowAlignNone, false);
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).section);
cl_assert_equal_i(2, menu_layer_get_selected_index(&l).row);
const int16_t basic_cell_height = menu_cell_basic_cell_height();
cl_assert_equal_i(2 * basic_cell_height, l.selecti... |
/*
* 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_ctl_reset_bluetooth() | ;
}
const PebbleProcessMd* mfg_bt_sig_rf_app_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &s_main,
// UUID: 278f66e0-11a1-4139-a5f4-fceb64efcf55
.common.uuid = { 0x27, 0x8f, 0x66, 0xe0, 0x11, 0xa1, 0x41, 0x39,
0xa5, 0xf4, 0xfc, 0xeb, 0x64, 0x... |
(ctx, data->circle_color) | ;
graphics_context_set_stroke_color(ctx, data->circle_color);
graphics_draw_circle(ctx, data->circle_origin, data->circle_radius);
} else if (shape == GPATH_TRIANGLE) {
gpath_draw_outline(ctx, data->triangle);
} else if (shape == GPATH_OPEN_BUCKET) {
gpath_draw_outline_open(ctx, data->bu... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (s_i18n_translate) {
return "Hola";
} else {
return msgid;
} |
}
void i18n_get_with_buffer(const char *string, char *buffer, size_t length) {
strncpy(buffer, i18n_get(string, NULL), length);
}
size_t i18n_get_length(const char *string) {
return strlen(i18n_get(string, NULL));
}
void i18n_free(const char *original, const void *owner) {
}
void i18n_free_all(const void *owne... |
const GRect *bounds = &graph_card->layer.bounds;
// Calculate the custom info text size
GSize custom_text_size;
const TextLayoutExtended text_layout = {};
graphics_text_layout_get_max_used_size(ctx, text, graph_card->legend_font, *bounds,
GTextOverflowModeWordWrap, GTex... | {
graph_card->info_avg = i18n_get(config->info_avg, graph_card);
} |
if (config->graph_data) {
graph_card->stats = config->graph_data->stats;
memcpy(graph_card->day_data, config->graph_data->day_data, sizeof(graph_card->day_data));
graph_card->data_timestamp = config->graph_data->timestamp;
graph_card->data_max = MAX(config->graph_data->default_max,
... |
ntry *db_entry = kernel_malloc_check(sizeof(AppDBEntry));
bool rv = (app_db_get_app_entry_for_install_id(install_id, db_entry) == S_SUCCESS);
if (rv) {
rv = prv_app_install_entry_from_app_db_entry(install_id, db_entry, entry);
}
kernel_free(db_entry);
return rv;
}
PBL_LOG(LOG_LEVEL_ERROR,... | {
process_manager_put_kill_process_event(PebbleTask_App, gracefully);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, NULL, NULL)) | ;
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_some_sectors_from_beginning(void) {
cl_assert(system_flash_erase(FLASH_BASE, 128 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 4), erased_sector);
cl_assert(flash_locked);
}
void test_syst... |
/*
* 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... | (menu_layer, data, &(MenuLayerCallbacks) {
.get_num_sections = (MenuLayerGetNumberOfSectionsCallback) menu_get_num_sections_callback,
.get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback) menu_get_num_rows_callback,
.get_cell_height = (MenuLayerGetCellHeightCallback) menu_get_cell_height_callback,
... | ;
menu_layer_set_highlight_colors(&data->menu_layer, GColorJaegerGreen, GColorWhite);
menu_layer_set_click_config_onto_window(menu_layer, window);
layer_add_child(&window->layer, menu_layer_get_layer(menu_layer));
}
static void push_window(AppData *data) {
PBL_LOG(LOG_LEVEL_INFO, "PUSHING WINDOW");
Window *w... |
te.pin.header.id, &s_items[2].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
// check rollover behaviour
... | timeline_init(&head) | ;
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
s_feb_5_midnight + 5 * 60 * 60), 2);
}
// 8:16 am. 8:15 event is in future but not 8:00 event
void test_timeline__extra_case_middle_future(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIte... |
lor background_color;
bool show_notification_timestamp;
bool is_reminder;
struct {
AttributeList attr_list;
TimelineItem timeline_item;
} statics;
} NotificationWindowTestData;
static NotificationWindowTestData s_test_data;
void clock_get_since_time(char *buffer, int buf_size, time_t timestamp) {
if... | property_animation_create(&s_frame_layer_implementation, layer, from_frame, to_frame) | ;
if (from_frame) {
animation->values.from.grect = *from_frame;
PropertyAnimationImplementation *impl =
(PropertyAnimationImplementation *)animation->animation.implementation;
impl->accessors.setter.grect(animation->subject, animation->values.from.grect);
}
if (to_frame) {
animation->values.... |
}
return true;
}
static bool prv_has_long_name(GFont font) {
// Figure out if it's a "long name"
// (i.e. one that won't fit a single line at the default font size).
const int16_t fudge_some_pixels = 30;
const bool line_contains_newline = (strchr(s_phone_ui_data->caller_id_text_buf, '\n') != NULL);
int16_... | if (!s_phone_ui_data->vibe_score) {
return;
} |
unsigned int vibe_interval_ms = vibe_score_get_duration_ms(s_phone_ui_data->vibe_score) +
vibe_score_get_repeat_delay_ms(s_phone_ui_data->vibe_score);
vibe_repeat_interval_sec = DIVIDE_CEIL(vibe_interval_ms, MS_PER_SECOND);
#else
vibe_repeat_interval_sec = 2;
#endif
prv_ring(NULL);
regular_timer_add_mu... |
//! @note this is the same as Large until ExtraLarge is designed
/* extralarge */ 1), // title margin height
};
static const LayoutNodeTextAttributeConfig s_subtitle_config = {
.attr_id = AttributeIdSubtitle,
.text.font_key = PREFERRED_CONTENT_SIZE_SWITCH(PreferredContentSizeDefault,
//! @... | &s_vertical_config.container.extent.node);
} |
//////////////////////////////////////////
// LayoutLayer API
//////////////////////////////////////////
bool weather_layout_verify(bool existing_attributes[]) {
return (existing_attributes[AttributeIdTitle] && existing_attributes[AttributeIdLocationName]);
}
LayoutLayer *weather_layout_create(const LayoutLayerCo... |
PBL_IF_RECT_ELSE(LAYOUT_BANNER_HEIGHT_RECT, LAYOUT_TOP_BANNER_HEIGHT_ROUND) | ) {
prv_scroll_to_top(swap_layer);
} else {
prv_attempt_swap(swap_layer, ScrollDirectionUp, true /* to_top */);
}
}
static void prv_down_multi_click_handler(ClickRecognizerRef recognizer, void *context) {
SwapLayer *swap_layer = (SwapLayer *)context;
prv_finish_animation(swap_layer);
// If our first... | |
GCornerMask corner_mask) {
s_graphics_fill_rect.call_count++;
s_graphics_fill_rect.last_call = (MockCallRecording) {
.ctx = ctx,
.rect = rect,
.radius = radius,
.corner_mask = corner_mask,
};
}
GPointPrecise gpoint_from_polar_precise(const GPointPrecise *precise_cente... | cl_assert(*s_log_internal__expected == NULL) | ;
}
AppTimer *rocky_timer_get_app_timer(void *data);
void test_js__init_deinit(void) {
// PBL-40702: test_js__init_deinit is leaking memory...
s_skip_mem_leak_check = true;
prv_deinit();
char *script =
"var num_times = 0;"
"var extra_arg = 0;"
"var timer = setInterval(function(extra) {"
"n... |
er* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-80, 4, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_outside_x(Layer* me, GContext* ctx) {
gra... | test_graphics_context_reset(&ctx, fb) | |
/*
* 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... | {
gpio_analog_init(&device->input);
} |
//! It takes ~12µs to get our ADC readings. From time to time, we're busy
//! processing elsewhere for upwards of 25µs and end up getting overrun issues.
//!
//! When OVR occurs, we clear both the OVR flag and the EOC flag.
//! The OVR flag always needs to be cleared so that conversion can be restarted.
//!
//!
//! F... |
menu_layer->scroll_layer.layer.frame.size;
const int16_t content_top_y = -scroll_layer_get_content_offset(&menu_layer->scroll_layer).y;
const int16_t content_bottom_y = content_top_y + frame_size.h;
if (!process_manager_compiled_with_legacy2_sdk()) {
prv_draw_background(menu_layer, ctx, &menu_layer->scroll_... | {
menu_layer_init(layer, &frame);
} |
return layer;
}
void menu_layer_pad_bottom_enable(MenuLayer *menu_layer, bool enable) {
menu_layer->pad_bottom = enable;
}
void menu_layer_deinit(MenuLayer *menu_layer) {
prv_cancel_selection_animation(menu_layer);
layer_deinit(&menu_layer->inverter.layer);
scroll_layer_deinit(&menu_layer->scroll_layer);
}... |
*timestamp_attr = generic_attribute_find_attribute(&msg->attr_list,
VEAttributeIdTimestamp, attr_list_size);
if (timestamp_attr && timestamp_attr->length == sizeof(uint32_t)) {
uint32_t *timestamp_ptr = (uint32_t*)timestamp_attr->data;
timestamp = *timestamp_ptr;
}
GenericAttribute *reminder_attr ... | (comm_session, VOICE_CONTROL_ENDPOINT, (uint8_t *)msg,
size, COMM_SESSION_DEFAULT_TIMEOUT) | |
nclude "clar.h"
// Fakes
//////////////////////////////////////////////////////////
#include "fake_app_manager.h"
#include "fake_rtc.h"
#include "fake_new_timer.h"
#include "fake_pbl_malloc.h"
#include "fake_spi_flash.h"
#include "fake_system_task.h"
#include "fake_time.h"
#include "stubs_analytics.h"
#include "stubs... | cl_assert_equal_i(sys_wakeup_query(wakeup_id), E_DOES_NOT_EXIST) | |
0},
{ 1024, -8, -16},
{ 1112, -72, -48},
{ 1120, -24, -72},
{ 1056, 0, -120},
{ 1128, 16, -136},
{ 1232, 56, -96},
{ 1200, 104, 8},
// 140 seconds
{ 1000, 120, 8},
{ 1008, 144, -56},
{ 1048, 168, -128},
{ 1088, 152, -176},
{ 1056, 128, -184},
{ 1008, 120, -184},
... | { 1024, -64, -184},
{ 1224, -112, -88},
{ 1056, -120, -56},
{ 920, -104, -32},
{ 928, -88, -32},
{ 960, -136, 8},
{ 992, -136, -8},
{ 1024, -144, -16},
{ 1040, -120, -40},
{ 1032, -88, -64},
{ 1064, -64, -88},
{ 1088, -88, -88},
{ 1096, -72, -112},
{ 1160, -96, -1... |
{ 1040, 392, -256},
// 148 seconds
{ 1080, 400, -280},
{ 1040, 600, -232},
{ 888, 624, -48},
{ 800, 480, 96},
{ 784, 520, 168},
{ 736, 464, 336},
{ 800, 552, 168},
{ 824, 448, 200},
{ 840, 448, 200},
{ 936, 456, 152},
{ 960, 440, 48},
{ 1016, 432, -32},
{ 992... |
app_attributes) {
PBL_ASSERTN(notif_attributes && app_attributes);
const ANCSAttribute *app_id = notif_attributes[FetchedNotifAttributeIndexAppID];
if (!app_id || app_id->length == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Can't handle notifications without an app id");
return;
}
const ANCSAttribute *title = n... | if (is_notification_from_phone_app && has_missed_call_property) {
TimelineItem *missed_call_pin =
ancs_item_create_and_populate(notif_attributes, app_attributes, app_metadata,
app_notif_prefs, timestamp, properties);
if (missed_call_pin == NULL) { goto cleanup; }
... |
cleanup:
ios_notif_pref_db_free_prefs(app_notif_prefs);
}
void ancs_notifications_handle_notification_removed(uint32_t ancs_uid, ANCSProperty properties) {
// Dismissal from phone is only properly supported on iOS 9 and up
// The presence of the DIS service tells us we have at least iOS 9
const bool ios_9 = ... |
PP_LAST_ACTIVITY_INVALID) {
// The recent app should never expire and we haven't been manually expired yet.
rv = true;
}
}
}
mutex_unlock_recursive(s_recent_apps.mutex);
return rv;
}
void app_install_unmark_prioritized(AppInstallId install_id) {
if (install_id == INSTALL_ID_INVALID) {... | callback_node->callbacks[event_type](install_id, callback_node->data) | ;
}
callback_node = (struct AppInstallCallbackNode *) list_get_next(&callback_node->node);
}
}
typedef struct {
AppInstallEnumerateCb cb;
void *data;
AppInstallEntry *entry_buf;
} EnumerateData;
static void prv_app_install_enumerate_app_db(AppInstallId install_id, AppDBEntry *db_entry,
void *data)... |
_level_char = pbl_log_get_level_char(log_level);
contents->task_char = pebble_task_get_char(task);
if (mcu_state_is_privileged()) {
contents->task_char = toupper(contents->task_char);
}
contents->time_ms = timestamp_ms;
// Obtain the filename
strncpy(contents->src_filename, GET_FILE_NAME(src_filename)... | circular_buffer_get_write_space_remaining(&s_isr_log_buffer) | < required_space) {
// Not enough space for the full message, just write an empty message with only the length
// word to indicate we're dropping the message.
const uint32_t insufficient_space_length = sizeof(uint32_t);
circular_buffer_write(&s_isr_log_buffer,
&insufficient_sp... |
ion] = available;
}
void graphics_context_set_compositing_mode(GContext* ctx, GCompOp mode) {}
void graphics_draw_bitmap_in_rect(GContext *ctx, const GBitmap *bitmap, const GRect *rect){}
int16_t menu_cell_basic_cell_height(void) {
return 44;
}
// Tests
//////////////////////
static uint16_t s_num_rows;
void te... | menu_cell_basic_cell_height() | |
/*
* 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... | (val1, val2) | > 0) {
prv_swap(val1, val2, elem_size);
}
}
}
}
|
"
#include "clar.h"
// Fakes
////////////////////////////////////
#include "fake_resource_syscalls.h"
// Stubs
////////////////////////////////////
#include "stubs_app_state.h"
#include "stubs_applib_resource.h"
#include "stubs_compiled_with_legacy2_sdk.h"
#include "stubs_gpath.h"
#include "stubs_graphics.h"
#includ... | {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = 300;
kino_player_play(test_player);
animation_set_reverse(test_player->animation, true);
animation_set_elapsed(test_player->animation, 1234); // intenti... |
void test_kino_player__create_finite_animation_finite_reel_reverse(void) {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
test_reel_data->duration_ms = 300;
Animation *animation = (Animation *)kino_player_create_play_animation(test_pla... |
agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "connection.h"
#include ... | prv_unlock() | |
fore_deep;
PBL_LOG(LOG_LEVEL_DEBUG, "total: %d, deep: %d", (int)total_sleep / SECONDS_PER_MINUTE,
(int)deep_sleep / SECONDS_PER_MINUTE);
const int k_min_total_sleep_min = 240;
const int k_max_total_sleep_min = 280;
const int k_min_deep_sleep_min = 40;
const int k_max_deep_sleep_min = 80;
if ((tot... | activity_prefs_sleep_insights_set_enabled(true) | ;
const time_t now_utc = rtc_get_time();
PBL_LOG(LOG_LEVEL_DEBUG, "test start time: %d", (int)now_utc);
const time_t midnight_utc = time_util_get_midnight_of(now_utc);
const time_t nap_time_start = midnight_utc + (ALG_PRIMARY_MORNING_MINUTE * SECONDS_PER_MINUTE);
const time_t nap_time_end = midnight_utc + (... |
HEIGHT)) / 2) - 1, GCornerBottomLeft);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_bottomleft.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / ... | cl_assert_equal_i(prv_clamp_corner_radius(GSize(1, 10), GCornersAll, 4), 0) | ;
cl_assert_equal_i(prv_clamp_corner_radius(GSize(2, 10), GCornersAll, 4), 1);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(3, 10), GCornersAll, 4), 1);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(4, 10), GCornersAll, 4), 2);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(5, 10), GCornersAll, 4), 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... | {
return !flash_sanity_check();
} | |
addr);
if (!firmware_storage_check_valid_firmware_description(&firmware_description)) {
dbgserial_print("Desclen ");
dbgserial_print_hex(firmware_description.description_length);
dbgserial_print("\nFirmlen ");
dbgserial_print_hex(firmware_description.firmware_length);
dbgserial_print("\nXsum ");
... | ("Failed to load recovery firmware, strike two. Try again.") | ;
boot_bit_set(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO);
boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
system_reset();
} else {
dbgserial_putstr("Failed to load recovery firmware, strike three. SAD WATCH");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT... |
);
memcpy(resp + response_len, cmd, command_len);
response_len += command_len;
pulse_reliable_send(resp, response_len);
}
static void prv_respond_internal_error(Command *cmd, size_t length,
status_t status_code) {
InternalErrorResponse *resp = pulse_reliable_send_beg... | (cmd, length) | ;
if (!pulse_fd) {
// prv_get_fd has already sent an error response
return;
}
status_t status = pulse_fd->impl->close_proc(pulse_fd->domain_state);
if (FAILED(status)) {
prv_respond_internal_error(cmd, length, status);
return;
}
CloseResponse *resp = pulse_reliable_send_begin(PULSE2_BULKI... |
nt(prop_h, &test_value);
cl_assert_equal_point(test_value, set_value);
// Destroy it
animation_destroy(h);
#endif
}
// --------------------------------------------------------------------------------------
// Test a basic gtransform property animation
void test_animation__property_gtransform(void) {
#ifdef TE... | prv_now_ms() | ;
animation_schedule(h);
// Test the accessor functions
Fixed_S32_16 test_value;
property_animation_get_from_fixed_s32_16(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, en... |
////////////////////////////////////////////
// Stubs
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_app_state.h"
#include "stubs_fonts.h"
#include "stubs_graphics_context.h"
#include "stubs_gbitmap.h"
#include "stubs_heap.h"
#include "stubs_text_resources.h"
#include "stubs_text_render.h"
#inc... | (&word_iter) | );
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == '\n');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == 'N');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current... |
layer_mark_dirty((Layer*) layer);
}
#define TIMELINE_NUM_REL_BARS (TIMELINE_NUM_VISIBLE_ITEMS + 1)
static void prv_update_rel_bars(TimelineLayer *layer) {
// Store prev, current, and next item relationship bar types
RelationshipBarType rel_bar_types[TIMELINE_NUM_REL_BARS];
layer->relbar_layer.prev_rel_bar.... | (layer, NULL, NULL) | |
rm t_new;
GTransform t1;
GTransform t2;
GTransform t_c; // matrix to compare against
// Test identity concatenation
t1 = GTransformIdentity();
t2 = GTransformIdentity();
t_c = GTransformIdentity();
gtransform_concat(&t_new, &t1, &t2);
cl_assert(gtransform_is_equal(&t_new, &t_c));
// Test identity... | (&t1, &t2) | ); // ensure t1 has not changed
// Test pointer re-use
gtransform_rotate(&t1, &t1, DEG_TO_TRIGANGLE(45));
cl_assert(gtransform_is_equal(&t1, &t_c));
}
|
ERROR_RANGE:
error_ref = JERRY_ERROR(RangeError, message_p, message_size);
break;
case JERRY_ERROR_REFERENCE:
error_ref = JERRY_ERROR(ReferenceError, message_p, message_size);
break;
case JERRY_ERROR_SYNTAX:
error_ref = JERRY_ERROR(SyntaxError, message_p, message_size);
break... | {
return TYPE_ERROR_ARG;
} |
return (jerry_value_t)EM_ASM_INT({
var obj = __jerryRefs.get($0);
var name = __jerryRefs.get($1);
return __jerryRefs.ref(obj[name]);
}, obj_val, prop_name_val);
}
jerry_value_t jerry_get_property_by_index(const jerry_value_t obj_val, uint32_t index) {
if (!jerry_value_is_object(obj_val)) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (prv_convert_1bit_addr_to_8bit_x(bitmap, block_addr, dest_y),
prv_get_8bit_x_from_1bit_x(dest_x)) | ;
dest_x = 0;
dest_y = 50;
block_addr = (uint32_t *)(uintptr_t)(((dest_y * row_1bit_size_words) + (dest_x / 32)) * 4);
cl_assert_equal_i(prv_convert_1bit_addr_to_8bit_x(bitmap, block_addr, dest_y),
prv_get_8bit_x_from_1bit_x(dest_x));
dest_x = 20;
dest_y = 100;
block_addr = (uint32_t... |
finished) {
prv_set_state(data, TimelineAppStateStationary);
}
}
static void prv_hide_day_sep_stopped(Animation *animation, bool finished, void *context) {
TimelineAppData *data = context;
if (!finished || !prv_set_state(data, TimelineAppStateStationary)) {
return;
}
data->current_animation = NULL;
... | {
if (!timeline_model_iter_prev(&new_idx, &has_new)) {
prv_exit(data);
goto done;
}
if (has_new) {
timeline_layer_set_prev_item(&data->timeline_layer, new_idx);
}
timeline_layer_move_data(&data->timeline_layer, -1);
} |
// If we interrupted a previous scroll, hasten this scroll
const bool is_hasted = !was_stationary;
const uint32_t duration = TIMELINE_UP_DOWN_ANIMATION_DURATION_MS;
const InterpolateInt64Function interpolate = is_hasted ?
timeline_animation_interpolate_moook_second_half :
timeline_animation_interp... |
(ANALYTICS_DEVICE_METRIC_CPU_RUNNING_TIME, ms_running, AnalyticsClient_System) | ;
s_last_ticks = now_ticks;
s_analytics_device_sleep_cpu_cycles = 0;
s_analytics_device_stop_ticks = 0;
}
void analytics_external_collect_app_cpu_stats(void) {
static uint32_t s_last_ticks = 0;
uint32_t sleep_ms = mcu_cycles_to_milliseconds(s_analytics_app_sleep_cpu_cycles);
uint32_t now_ticks = rtc_get... | |
window, window_get_debug_name(window));
}
static Window *prv_remove_item(WindowStackItem *pop_item,
const WindowTransitionImplementation *transition) {
PBL_ASSERTN(pop_item->window);
WindowStack *window_stack = pop_item->window->parent_window_stack;
// Do a transition from element ... | if (window_stack->lock_push) {
return;
} |
const WindowTransitionImplementation *transition_to = &g_window_transition_none_implementation;
const WindowTransitionImplementation *transition_pop =
window_transition_get_default_pop_implementation();
prv_insert_with_function(window_stack, window, prv_next_inserter, transition_to, transition_pop);
}
Wi... |
/*
* 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... | delay_ms(20) | |
04, 104, -32},
{ 1112, 96, -40},
{ 1072, 56, -8},
{ 1048, 88, -32},
{ 1096, 96, -16},
{ 872, 64, -64},
{ 1112, 112, -144},
{ 864, 88, -184},
{ 888, 32, -312},
{ 1088, 112, -416},
{ 1008, 80, -312},
{ 776, 80, -280},
{ 792, 160, -400},
{ 912, 240, -448},
{ 1064, 28... | { 728, 80, -304},
{ 720, 144, -352},
{ 840, 160, -384},
{ 1000, 176, -352},
{ 1096, 152, -344},
{ 1280, 184, -376},
{ 1424, 360, -272},
// 21 seconds
{ 1256, 448, -496},
{ 1416, 504, -528},
{ 1008, 344, -472},
{ 984, 264, -360},
{ 1128, 176, -312},
{ 1192, 128, -1... |
{ 1232, 80, -8},
{ 1232, 160, -136},
{ 1232, 120, -64},
{ 1088, 56, 8},
{ 1072, 24, -64},
{ 1112, -64, -48},
{ 840, -192, -96},
{ 1128, -232, 8},
{ 1072, -176, -48},
{ 1096, -8, -224},
{ 1200, 8, -200},
{ 1184, 64, -232},
{ 1008, 104, -248},
{ 1000, 128, -312},
... |
52, -984},
{ -160, -160, -1000},
{ -168, -160, -976},
{ -168, -160, -984},
{ -128, -128, -1016},
{ -128, -120, -1016},
// 282 seconds
{ -136, -112, -992},
{ -144, -104, -976},
{ -168, -112, -1032},
{ -184, -152, -984},
{ -184, -128, -992},
{ -168, -160, -976},
{ -152,... | { -176, -160, -968},
{ -168, -152, -1000},
{ -152, -152, -984},
{ -144, -160, -1008},
// 287 seconds
{ -160, -160, -976},
{ -160, -128, -992},
{ -152, -136, -1008},
{ -168, -152, -992},
{ -152, -160, -1008},
{ -160, -152, -976},
{ -168, -144, -968},
{ -160, -152, -100... |
{ -168, -152, -992},
{ -160, -136, -992},
{ -160, -136, -992},
{ -160, -144, -992},
{ -160, -144, -992},
{ -160, -144, -1000},
{ -160, -144, -992},
{ -152, -152, -1000},
{ -152, -152, -992},
{ -160, -144, -984},
{ -152, -136, -992},
{ -160, -152, -1000},
{ -160, -152... |
("-2147483649", NULL, 10) | , INT_MIN);
}
static const struct {
intmax_t value;
int base;
const char *str;
} s_base_test_data[] = {
{ 2147483646LL, 2, "1111111111111111111111111111110", },
{ 2147483646LL, 2, "1111111111111111111111111111110", },
{ -2147483647LL, 2, "-1111111111111111111111111111111", },
{ -2147483647LL, 2, "-111111... | |
fied
accel_set_shake_sensitivity_high(false /* sensitivity_high */);
bma255_write_register(BMA255Register_INT_5,
BMA255_INT_5_SLOPE_DUR_MASK << BMA255_INT_5_SLOPE_DUR_SHIFT);
prv_enable_operating_mode(AccelOperatingMode_ShakeDetection, BMA255SampleInterval_83HZ);
}
static void prv_disabl... | PBL_LOG(LOG_LEVEL_ERROR, "Self test failed for axis %c: %d < %d",
AXIS_NAMES[axis], delta, SELFTEST_THRESHOLDS[axis]) | |
;
BTErrno e = gap_le_connect_cancel(&device, GAPLEClientApp);
cl_assert_equal_i(e, BTErrnoInvalidParameter);
}
void test_gap_le_connect__unregister_unowned_intent(void) {
BTDeviceInternal device = prv_dummy_device(1);
BTErrno e;
// Register connection intent owned by kernel:
e = gap_le_connect_connect(&de... | cl_assert_equal_i(e, BTErrnoOK) | |
popup_timer(void) {
prv_stop_popup_timer();
s_ble_hrm_timer = (RegularTimerInfo) {
.cb = prv_reminder_popup_timer_cb,
};
regular_timer_add_multiminute_callback(&s_ble_hrm_timer, BLE_HRM_REMINDER_POPUP_DELAY_MINS);
}
static void prv_update_is_sharing(GAPLEConnection *connection, bool prev_is_sharing) {
co... | gap_le_slave_reconnect_hrm_stop() | ;
break;
default:
break;
}
}
}
static void prv_reset_subscriptions(void) {
bt_lock();
if (s_ble_hrm_subscription_count) {
s_ble_hrm_subscription_count = 0;
prv_stop_popup_timer();
bt_unlock();
prv_execute_on_kernel_main(prv_stop_hrm_kernel_main);
} else {
bt_unloc... |
typedef struct {
PollRemoteService service;
//! The minimum interval between two "poll services" requests.
//! Calls to poll_remote_send_request() will be no-ops if min_interval_minutes has not been reached.
uint8_t min_interval_minutes;
//! The maximum interval between two "poll services" requests.
//! T... | for_each_context(start) | |
pp_message_sender.h"
#include "services/normal/app_outbox_service.h"
#include "syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/list.h"
static PebbleRecursiveMutex *s_app_outbox_mutex;
typedef struct {
AppOutboxMessage *head;
AppOutbox... | if (!sent_handler) {
return;
} |
PebbleEvent event = {
.type = PEBBLE_APP_OUTBOX_SENT_EVENT,
.app_outbox_sent = {
.sent_handler = sent_handler,
.cb_ctx = cb_ctx,
.status = status,
},
};
process_manager_send_event_to_process(PebbleTask_App, &event);
}
//! @note This executes on App Task
static void prv_schedule_con... |
/*
* 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... | delay_ms(20) | ;
gpio_release(gpio);
} else {
gpio_use(gpio);
// disable the bus supply
GPIO_WriteBit(gpio, gpio_pin, active_high ? Bit_RESET : Bit_SET);
gpio_release(gpio);
}
}
// SNOWY
/////////
void snowy_i2c_rail_1_ctl_fn(bool enable) {
set_ldo3_power_state(enable);
}
// bb2
/////////
void bb2_rail_ctl... |
d()
{
tempa[0] = getSBoxValue(tempa[0]);
tempa[1] = getSBoxValue(tempa[1]);
tempa[2] = getSBoxValue(tempa[2]);
tempa[3] = getSBoxValue(tempa[3]);
}
tempa[0] = tempa[0] ^ Rcon[i/Nk];
}
else if (Nk > 6 && i % Nk == 4)
{
// Function Subword()
{
... | Multiply(b, 0x0e) | ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d);
(*state)[i][2] = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b);
(*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e);
}
}
// The SubBytes Function Substitutes the values in the
// state matrix... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "Gatt: Got a read complete event: handle=%d, len=%d",
r_data->att_handle, r_data->value_length) | ;
PBL_HEXDUMP(LOG_LEVEL_DEBUG, r_data->value, r_data->value_length);
GattClientOpReadReponse r_resp = {
.hdr = {
.type = GattClientOpResponseRead,
.error_code = r_data->status,
.context = (void *)r_data->context_ref,
},
.value_length = r_data->value_leng... |
plugged) {
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BATTERY_PLUGGED_TIME, AnalyticsClient_System);
} else {
analytics_stopwatch_stop(ANALYTICS_DEVICE_METRIC_BATTERY_PLUGGED_TIME);
}
}
static void prv_update_done_charging(void) {
prv_update_plugged_change();
// Amount in mV to drop the "Full" ... | prv_is_stable(&s_last_battery_state) | ;
uint32_t new_charge_percent =
battery_curve_sample_ratio32_charge_percent(s_last_battery_state.voltage, charging);
#ifndef TARGET_QEMU
// If QEMU, allow updates to always occur for ease of testing otherwise
// Allow updates iff:
// - We are charging
// - We are discharging and:
// - The readings... |
/*
* 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_ERROR, "Failed to malloc stored order install_id list") | ;
goto cleanup;
}
// read in entire list into array
const int read_size = list_length * sizeof(AppInstallId);
int rd_sz;
if ((rd_sz = pfs_read(fd, (uint8_t *)storage->id_list, read_size)) != read_size) {
PBL_LOG(LOG_LEVEL_ERROR, "Corrupted ordered install_id list (Rd %d of %d bytes)",
rd_sz, ... |
/*
* 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... | accessory_set_baudrate(AccessoryBaud115200) | ;
accessory_set_power(false);
accessory_mfg_mode_start();
break;
case AccessoryInputStateIdle:
// restore accessory to default state
accessory_enable_input();
accessory_set_baudrate(AccessoryBaud115200);
accessory_set_power(false);
break;
case AccessoryInputStateImaging:
accessor... |
(workout_service_get_current_workout_hr_zone_time(hr_zone_time_s)) | ;
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone1], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone2], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 10);
prv_inc_time(10);
prv_put_bpm_event(ZONE_1_HR, HRMQuality_Good);
workout_service_get_curren... | |
&ctx, GColorBlue);
graphics_fill_rect(&ctx, &GRect(0, 0, 20, 10));
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPoint(30, 30), DEG_TO_TRIGANGLE(45), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_color_set_cent... | (
test_image->bounds.size.w / 2 - 1,
test_image->bounds.size.h / 2 - 1) | ,
DEG_TO_TRIGANGLE(0), center);
cl_check(gbitmap_pbi_eq(&ctx->dest_bitmap, "draw_rotated_bitmap_stamp_0deg.Xbit.pbi"));
// Top-left corner rotation point, Angle 45
setup_test_rotate_bitmap(ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_b... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | jmem_heap_free_block(ctx->headroom, ctx->headroom_size) | ;
ctx->headroom = NULL;
ctx->headroom_size = 0;
}
static void prv_resize_headroom_if_needed(RockyMemoryAPIContext *ctx) {
// If needed, try to get our headroom back at the level where we want it to be.
if (ctx->headroom &&
ctx->headroom_size < ROCKY_API_MEMORY_HEADROOM_DESIRED_SIZE_BYTES) {
prv_deall... |
efine ROCKY_CONTEXT2D_FILL "fill"
#define MINIMUM_ARRAY_LEN (8)
// TODO: PBL-35780 make this part of app_state_get_rocky_runtime_context()
SECTION(".rocky_bss") T_STATIC RockyAPIPathStep *s_rocky_path_steps;
SECTION(".rocky_bss") T_STATIC size_t s_rocky_path_steps_array_len;
SECTION(".rocky_bss") T_STATIC size_t s_ro... | graphics_draw_arc_precise_internal(ctx, step->arc.center, step->arc.radius,
angle_start, angle_end) | ;
const GPointPrecise pt_to = gpoint_from_polar_precise(
&step->arc.center, (uint16_t)step->arc.radius.raw_value, step->arc.angle_end);
ASSIGN_P(pt_to);
break;
}
default:
WTF;
}
}
#undef ASSIGN_P
return jerry_create_undefined();
}
static void prv_fill_po... |
o_string = workout_data_fill_metric_value,
.get_metric_value = workout_data_get_metric_value,
.get_distance_string = health_util_get_distance_string,
};
typedef struct SportsData {
int32_t current_bpm;
char *duration_string;
char *distance_string;
char *pace_string;
char *custom_label_string;
char *cus... | (active_window, 0) | |
&start,
&stop);
Animation *content_in = property_animation_get_animation(prop_anim);
animation_set_duration(content_in, IN_OUT_ANIMATION_DURATION);
#if !defined(PLATFORM_TINTIN)
// animate the dots
Animation *crumbs_anim = crumbs_layer_ge... | (&data->crumbs_layer, &frame, data->config.colors.background,
data->config.colors.foreground) | ;
// Add them to the tree
layer_add_child(window_get_root_layer(window), (Layer *)action_menu_layer);
layer_add_child(window_get_root_layer(window), (Layer *)crumbs_layer);
// Click config
window_set_click_config_provider_with_context(window, prv_click_config_provider, data);
// Init the view model
data->... |
emoryHeader);
if (flash_addr_max < (flash_addr + sizeof(chunk_hdr) + chunk_hdr.size)) {
PBL_LOG(LOG_LEVEL_ERROR, "Insufficient space for BLE core dump -- RAM");
goto powerdown;
}
flash_write_bytes((const uint8_t *)&chunk_hdr, flash_addr, sizeof(chunk_hdr));
flash_addr += sizeof(chunk_hdr);
... | prv_core_dump() | ;
#if REBOOT_ON_BT_CRASH
RebootReason reboot_reason = {
.code = RebootReasonCode_BtCoredump,
};
reboot_reason_set(&reboot_reason);
// Just reset the board, we don't want to wind up adding a normal coredump for the MCU
system_hard_reset();
#else
// Core dump has completed. T... |
/*
* 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... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME pbl_27921
//> TEST_VERSION 2
//> TEST_TOTAL -1
//> TEST_TOTAL_MIN -1
//> TEST_TOTAL_MAX -1
//> TEST_DEEP -1
//> TEST_DEEP_MIN -1
//> TEST_DEEP_MAX -1
//> TEST_START_AT -1
//> TEST_START_AT_MIN -1
//> TEST_START_A... |
{ 20, 0x44, 2807, 0x0},
{ 0, 0x52, 3184, 0x0},
// 30: Local time: 01:05:00 PM
{ 6, 0x52, 1515, 0x0},
{ 12, 0x52, 3288, 0x0},
{ 0, 0x51, 1882, 0x0},
{ 0, 0x76, 90, 0x0},
{ 0, 0x62, 1332, 0x0},
{ 0, 0x51, 908, 0x0},
{ 0, 0x4f, 481, 0x0},
{ 0, 0x40, 186, 0x0},
{ 0, 0x4f, 38... |
alloc_storage(session, new_size);
}
} else {
prv_release_session_file(session);
}
return true;
}
// -----------------------------------------------------------------------------------------
// Make sure there is at least 'needed' bytes available in our file system space
// allowed for data logging
stati... | {
// If no extra space needed, we are done because we successfully opened the file.
return true;
} |
// Get the file size
size_t file_size = prv_pfs_get_file_size(session->storage.fd);
if (file_size == 0) {
prv_release_session_file(session);
return false;
}
// Add a minium buffer to needed. This gives us a little insurance and also allows for the
// extra space needed for the chunk header byte t... |
/*
* 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... | {
*out_error = false;
return false;
} |
return ancs_util_get_attr_ptrs(data, length,
s_fetched_app_attributes,
ARRAY_LENGTH(s_fetched_app_attributes),
NULL, out_error);
}
bool ancs_util_get_attr_ptrs(const uint8_t* data, const size_t length, const FetchedAt... |
_cb, NULL);
mutex_unlock_recursive(s_manager_state.lock);
return state->session_ref;
}
DEFINE_SYSCALL(HRMSessionRef, sys_hrm_manager_app_subscribe,
AppInstallId app_id, uint32_t update_interval_s, uint16_t expire_sec, HRMFeature features) {
return hrm_manager_subscribe_with_callback(app_id, update_interval_... | if (s_tia_count++ == 5) { // Need to leave time for TIA to ramp up
system_task_add_callback(prv_console_unsubscribe_callback, NULL);
char buf[32];
prompt_send_response_fmt(buf, 32, "TIA: %"PRIu16, event->led.tia);
prompt_send_response_fmt(buf, 32, "LED: %"PRIu16"uA", event->led.current_ua);
... |
}
}
void command_hrm_read(void) {
s_tia_count = 0;
sys_hrm_manager_unsubscribe(s_console_session);
s_console_session = hrm_manager_subscribe_with_callback(
INSTALL_ID_INVALID, 1 /*update_interval_s*/, 0 /*expire_s*/, HRMFeature_LEDCurrent,
prv_console_read_callback, NULL);
prompt_command_continu... |
/*
* 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... | delay_us(100) | ;
}
return true;
}
static void prv_screen_on(void) {
prv_start_command(CMD_DISPLAY_ON);
prv_end_command();
}
static void prv_screen_off(void) {
prv_start_command(CMD_DISPLAY_OFF);
prv_end_command();
}
void prv_draw_scene(uint8_t scene) {
prv_start_command(CMD_DRAW_SCENE);
prv_send_command_arg(scene);... |
alue_t object,
jerry_char_t *buffer_p,
jerry_size_t buffer_size) {
jerry_value_t str_ref = (jerry_value_t)EM_ASM_INT({
var str = __jerryRefs.ref(String(__jerryRefs.get($0)));
return str;
}, object... | (__jerryRefs.get($0)) | );
}, value);
}
jerry_value_t jerry_value_to_primitive(const jerry_value_t value) {
if (jerry_value_has_error_flag(value)) {
return TYPE_ERROR_FLAG;
}
return (jerry_value_t)EM_ASM_INT({
var val = __jerryRefs.get($0);
var rv;
if ((typeof val === 'object' && val != null)
|| (typ... |
/*
* 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... | (&characteristic_uuid, uuid_buffer) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&text_layer->layer, &frame) | ;
#if PBL_ROUND
const int inset = 4;
text_layer_enable_screen_text_flow_and_paging(text_layer, inset);
#endif
const GSize content_size = app_text_layer_get_content_size(text_layer);
if (content_size.h > lines * line_height) {
frame = text_layer->layer.frame;
frame.origin.y += -line_height / 2 + extra_li... |
t_idx++;
cur_node = (AlarmNode* )list_get_next((ListNode*) cur_node);
}
return 0;
}
static void prv_update_menu_layer(AlarmsAppData* data, AlarmId select_alarm) {
MenuIndex selected_menu_index = {0, prv_get_list_idx_of_alarm_id(data, select_alarm)};
menu_layer_reload_data(&data->menu_layer);
menu_l... | if (menu_cell_layer_is_highlighted(cell_layer)) {
if (data->show_limit_reached_text) {
// Trying to add a new alarm when list is already full
const GFont font =
system_theme_get_font_for_default_size(TextStyleFont_MenuCellSubtitle);
box = GRect(0, 0, cell_layer->boun... |
}
if (new_bitmap_resource != data->current_plus_icon_resource_id) {
// Change the icon to the dotted one
data->current_plus_icon_resource_id = new_bitmap_resource;
gbitmap_deinit(&data->plus_icon);
gbitmap_init_with_resource(&data->plus_icon, data->current_plus_icon_resource_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 (flash_hdr.unformatted & (1 << i)) {
continue;
} | |
ce/voice.h"
#include "shell/normal/watchface.h"
#include "syscall/syscall.h"
#include "system/logging.h"
#include "system/passert.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/modals/modal_manager.h"
#include "util/heap.h"
#include "syscall/syscall_internal.h"
#include "apps/system_apps/app_fetch_ui.h"
#in... | (task, &event) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"A\": %s", buf);
} | |
re rendering in truncation mode (e.g. GTextOverflowModeFill or
// GTextOverflowModeTrailingEllipsis), we can immediately cut the text off below the box height
// if we're not rendering the first line.
// - This, because the user does not expect to see more text drawn below, after the '...'.
// - The first... | while (true) {
if (utf8_iter_state->current <= utf8_iter_state->bounds->start) {
// EOS while searching for valid codepoint
return false;
}
bool is_utf8_advanced = iter_prev(utf8_iter);
codepoint = utf8_iter_state->codepoint;
if (!is_utf8_advanced) {
return is_utf8_advanced;
... |
}
////////////////////////////////////////////////////////////
// Helper functions
//! Trim given codepoint from the start of the word
//! Used to remove whitespace and newlines
//! @return is_trimmed
bool word_trim_preceeding_codepoint(GContext* ctx, Word* word, const Codepoint codepoint,
... |
{
int16_t inner_edge =
prv_get_ellipsis_border(y, radius_inner_y_sq, radius_inner_x_sq).raw_value;
int16_t inner_left = center.x.raw_value - inner_edge;
int16_t inner_right = center.x.raw_value + inner_edge;
// Using top/bottom flags we make sure to not draw outside of given angles r... | else {
// If theres nothing in the middle, draw top and bottom parts of the circle
if (draw_top) {
prv_draw_scanline_collision_points(ctx, center.y.integer - i - special_line_offset_top,
left, right, top_starting_edge, top_ending_edge,
... | |
OG(fmt, ...) \
do { \
PBL_LOG(LOG_LEVEL_DEBUG, fmt, ## __VA_ARGS__); \
} while (0)
#define HRM_HEXDUMP(data, length) \
do { \
PBL_HEXDUMP(LOG_LEVEL_DEBUG, (uint8_t *)data, length); \
} while (0)
#else
#define HRM_LOG(fmt, ...)
#define HRM_HEXDUMP(data, length)
#endif
static struct HRMManagerState s_man... | (write_ptr, s_manager_state.accel_manager_buffer, num_new_samples * sizeof(AccelRawData)) | ;
s_manager_state.accel_data.num_samples += num_new_samples;
mutex_unlock(s_manager_state.accel_data_lock);
sys_accel_manager_consume_samples(s_manager_state.accel_state, num_new_samples);
}
// Return true if this is a stable BPM reading. This is called each time we power the sensor off
// or receive a new HR... |
s_test_data, BUFFER_SIZE));
app_inbox_service_cancel(AppInboxServiceTagUnitTest);
// No events expected:
assert_num_callback_events(0);
// The buffer should be completely available again:
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
... | cl_assert_equal_b(true, app_inbox_service_write(AppInboxServiceTagUnitTest, s_test_data,
BUFFER_SIZE)) | ;
cl_assert_equal_b(true, app_inbox_service_end(AppInboxServiceTagUnitTest));
// One callback event scheduled:
assert_num_callback_events(1);
prv_process_callback_events();
assert_num_callback_events(0);
}
void test_app_inbox__consume_inbox_closed_in_mean_time(void) {
prv_create_test_inbox_and_begin_writ... |
WindowTransitionRoundImplementation *implementation =
(WindowTransitionRoundImplementation *)context->implementation;
Window *window_to = context->window_to;
if (window_to) {
// move framebuffer by amount of pixels the window_to moves
// => gives impression of a moving window_from
const int16_t new_... | (animation, PORT_HOLE_TRANSITION_DURATION_MS) | ;
return animation;
}
const WindowTransitionRoundImplementation g_window_transition_default_push_implementation_round = {
.implementation = {
.create_animation = prv_window_transition_create_animation,
.render = prv_window_transition_render,
},
.transition_direction = CompositorTransitionDirectionLef... |
-----------------
extern void analytics_external_collect_app_cpu_stats(void);
extern void analytics_external_collect_app_flash_read_stats(void);
static void prv_handle_app_stop_analytics(const ProcessContext *const context,
PebbleTask task, bool gracefully) {
if (!gracefully)... | if (gracefully) {
if (context->closing_state == ProcessRunState_Running) {
context->closing_state = ProcessRunState_GracefullyClosing;
PBL_LOG(LOG_LEVEL_DEBUG, "Attempting to gracefully deinit %s", pebble_task_get_name(task));
// Send deinit event to app:
PebbleEvent deinit_event = {
... |
// process_manager_force_close_syscall_exit_trap to check whether
// it is about to return control to a misbehaving app. This
// function checks the process context's closing state and makes
// the process safe to kill if its state is set to ForceClosing.
// All we have to do is set the s... |
~GC_DATA_VALID;
pfs_seek(fd, offsetof(GCData, flags), FSeekSet);
pfs_write(fd, &gcdata.flags, sizeof(gcdata.flags));
return (fd);
}
static NOINLINE status_t garbage_collect_sector(uint16_t *free_page,
uint16_t sector_start_page, uint32_t sectors_active) {
// if no sectors are active in the region, just e... | {
allocated_space += free_bytes_in_page(pg);
} |
}
// A full filesystem is bad for wear leveling since the same sectors will
// wind up getting written repeatedly. We should really be enforcing this
// within pfs_open but for now we will just let external callers use this
// routine before allocating large files
uint32_t tot_capacity = (pfs_get_size() *... |
/*
* 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... | (0x55aaff) | |
/*
* 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 (UNLIKELY(c == 0x3)) { // CTRL-C
// FIXME: Clean this up so this logic doesn't need to be duplicated here
s_prompt_context.write_index = 0;
prv_display_prompt();
} | |
qual_i(S_SUCCESS, app_db_read((uint8_t*)&app1.uuid,
sizeof(Uuid), (uint8_t*)&temp, sizeof(AppDBEntry)));
cl_assert_equal_i(5, app_db_check_next_unique_id());
// check app 1
memset(&temp, 0, sizeof(AppDBEntry));
cl_assert_equal_i(S_SUCCESS, app_db_get_app_entry_for_uuid(&app1.uuid, &temp));
cl_assert_e... | cl_assert_equal_b(true, app_db_exists_install_id(1)) | ;
cl_assert_equal_b(true, app_db_exists_install_id(2));
cl_assert_equal_b(true, app_db_exists_install_id(3));
cl_assert_equal_b(false, app_db_exists_install_id(4));
}
static const uint8_t some_data[] = {0x01, 0x02, 0x17, 0x54};
void prv_enumerate_entries(AppInstallId install_id, AppDBEntry *entry, void *data) {... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (new_state == SmartstrapStateUnsubscribed) {
} else if ((prev_state == SmartstrapStateUnsubscribed) &&
(new_state == SmartstrapStateReadReady)) {
} else if ((prev_state == SmartstrapStateReadReady) &&
(new_state == SmartstrapStateNotifyInProgress)) {
} else if ((prev_state == Smar... | |
1440, 328, -40},
{ 1160, 440, -328},
{ 944, 160, -32},
{ 864, 48, 176},
{ 816, 272, 136},
{ 888, 320, 112},
{ 880, 344, 96},
{ 800, 376, 64},
{ 768, 368, 24},
{ 864, 424, -56},
{ 1056, 328, -8},
{ 1184, 384, 40},
{ 1520, 352, 200},
{ 1688, 368, 232},
{ 1200, 472, ... | // 33 seconds
{ 888, 352, 16},
{ 1072, 384, -24},
{ 1224, 296, 48},
{ 1472, 240, 120},
{ 1832, 368, 160},
{ 1176, 488, 80},
{ 792, 232, 88},
{ 1064, 104, 176},
{ 1144, 56, 184},
{ 952, 40, 216},
{ 816, 56, 184},
{ 768, 48, 136},
{ 728, 40, 136},
{ 704, 24, 128... |
{ 912, 56, -128},
{ 1152, -104, -40},
{ 1440, -184, 168},
{ 1336, 168, 56},
// 36 seconds
{ 1304, 424, -224},
{ 1176, 296, -16},
{ 944, 216, 232},
{ 944, 152, 224},
{ 984, 216, 232},
{ 976, 408, 64},
{ 848, 408, -24},
{ 776, 432, -56},
{ 880, 424, -72},
{ 112... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | layer_set_hidden(action_bar_layer_get_layer(data->action_bar), !connected) | |
rt_address, uint32_t ending_address) {
uint16_t starting_page = start_address / PFS_PAGE_SIZE;
uint16_t ending_page = (ending_address) / PFS_PAGE_SIZE;
for (uint16_t pg = starting_page; pg < ending_page; pg++) {
PageHeader hdr;
// read version first, check magic, then check version and make sure it mak... | (filechg_node->name, (char *)data) | == 0);
}
PFSCallbackHandle pfs_watch_file(const char* filename, PFSFileChangedCallback callback,
uint8_t event_flags, void* data) {
mutex_lock_recursive(s_pfs_mutex);
PFSFileChangedCallbackNode *node = kernel_malloc_check(sizeof(PFSFileChangedCallbackNode));
*node = (PFSFileCha... |
try->cursor->begin;
}
static void move_cursor_to_active_registry(Registry* registry) {
// Search for an active registry, starting at the start of the registry sector
// in flash (`REGISTRY_FLASH_BEGIN`).
// If cursor loops back to the start of the registry sector, then the
// entire sector has been scanned and... | {
if (record_compare(r, key, key_length, uuid)) {
return i;
}
} | |
const int32_t progress_max = MAX(data->current_steps, data->daily_average_steps);
if (!progress_max) {
health_progress_bar_outline(ctx, &data->progress_bar, PROGRESS_OUTLINE_COLOR);
return;
}
const int current_fill = data->current_steps * HEALTH_PROGRESS_BAR_MAX_VALUE / progress_max;
const int typical_... | (RESOURCE_ID_HEALTH_APP_ACTIVITY) | ,
.progress_bar = {
.num_segments = ARRAY_LENGTH(s_activity_summary_progress_segments),
.segments = s_activity_summary_progress_segments,
},
};
return base_layer;
}
void health_activity_summary_card_select_click_handler(Layer *layer) {
HealthActivitySummaryCardData *health_activity_summary_c... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(child_a.next_sibling == &child_b) | ;
cl_assert(child_a.parent == &parent);
cl_assert(child_b.parent == &parent);
layer_add_child(&parent, &child_c);
cl_assert(child_c.parent == &parent);
cl_assert(child_b.next_sibling == &child_c);
layer_add_child(&child_a, &grand_child_a);
cl_assert(grand_child_a.parent == &child_a);
// Remove non-firs... |
/*
* 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... | kernel_zalloc(size_needed) | ;
if (!receiver) {
PBL_LOG(LOG_LEVEL_WARNING, "Could not allocate receiver, handler:%p size:%d",
endpoint->handler, (int)size_needed);
return NULL;
}
const bool should_use_kernel_main =
(endpoint->receiver_opt == &g_default_kernel_receiver_opt_main);
*receiver = (DefaultReceiverImpl)... |
/*
* 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... | gpio_release(af_config->gpio) | ;
}
void gpio_input_init(const InputConfig *input_config) {
if (input_config->gpio == NULL) {
// TODO: PBL-15063
return;
}
gpio_input_init_pull_up_down(input_config, GPIO_PuPd_NOPULL);
}
void gpio_input_init_pull_up_down(const InputConfig *input_config, GPIOPuPd_TypeDef pupd) {
GPIO_InitTypeDef gpio_... |
/*
* 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... | {
config->peek_timer = app_timer_register(PEEK_TIMEOUT_MS,
prv_peek_timeout_callback, NULL);
} | |
ef struct PACKED InternalErrorResponse {
uint8_t opcode;
int32_t status_code;
uint8_t bad_command[0];
} InternalErrorResponse;
#define REGISTER_BULKIO_HANDLER(domain_type, domain_id, vtable) \
extern PulseBulkIODomainHandler vtable;
#include "pulse_bulkio_handler.def"
#undef REGISTER_BULKIO_HANDLER
static P... | (resp, read_len + sizeof(ReadResponse)) | ;
if (pulse_fd->transfer_state.bytes_left > 0) {
system_task_add_callback(prv_domain_read_cb, (void*)(uintptr_t)fd_num);
}
} else {
pulse_reliable_send_cancel(resp);
Command cmd = {
.opcode = BULKIO_CMD_DOMAIN_READ,
.read = {
.fd = fd_num
}
};
prv_respond_int... |
/////////////////////////////////////////////
// Fakes
#include "fake_gbitmap_get_data_row.h"
// Setup
////////////////////////////////////
static GBitmap *test_image_bw;
static GBitmap *test_image_color;
static FrameBuffer *fb = NULL;
#if SCREEN_COLOR_DEPTH_BITS == 1
extern bool get_bitmap_bit(GBitmap *bmp, int x, i... | 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,
GPointZero, DEG_TO_TRIGANGLE(0), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_origin_b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.