prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ic language governing permissions and
* limitations under the License.
*/
#include "text_clipping.h"
#include "applib/app.h"
#include "applib/fonts/fonts.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "process_management/app_manager.h"
#include "process_state/app_state/app_state.h"
#include "s... | text_layer_set_text(&data->word_wrap_layer, "Overflow: Ellipsis") | ;
text_layer_set_overflow_mode(&data->text_layer, GTextOverflowModeTrailingEllipsis);
}
}
static void config_provider(Window *window) {
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, (ClickHandler)click_handler);
window_single_repeating_click_subscribe(BUTTON_ID_SELECT, 100, (ClickHandler)click_h... |
tatic void prv_update_now_playing_info(CommSession *session, const uint8_t* msg, size_t length) {
// Read all the lengths from the message so we know how to break it up.
const uint8_t* read_iter = msg;
const char* artist_ptr;
size_t artist_length;
read_iter = prv_read_ptr_and_length_from_buffer(read_iter, ms... | if (!read_iter) {
return;
} |
// Not doing anything with player package name
music_update_player_name(player_name_ptr, player_name_length);
}
void music_protocol_msg_callback(CommSession *session, const uint8_t* msg, size_t length) {
if (!s_connected) {
return;
}
--length;
switch (*(msg++)) {
case MusicEndpointCmdIDNowPlaying... |
erry_value_t val,
void (*apply)(const jerry_value_t,
const RockyArgBinding *),
const RockyArgBinding *binding) {
jerry_value_t str_val;
bool should_release = false;
if ... | jerry_value_is_string(argv[0]) | ) {
return true;
}
*type_error_out = (RockyArgTypeCheckError) {
.expected_type_name = COLOR_TYPES,
.arg_offset = 0,
};
return false;
}
static void prv_init_arg_assign_imp(RockyArgType arg_type, RockyArgAssignImp *imp_out) {
// Defaults:
imp_out->expected_num_args = 1;
switch (arg_type) {
... |
ro is ignored
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_stroke_width(&context, 0);
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
// Check draw state
memset(&draw_state, 0x5A, sizeof(GDrawState));
graphics_context_set_drawing_state(&conte... | GRect(10, 20, 40, 10) | , SW_EVEN));
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle_draw_stroked_non_aa(&context, GPoint(50, 50), 10, SW_EVEN));
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_d... |
static PhoneCallSource s_call_source;
// When using Android this is the cookie, when using ANCS this is the NotificationUUID
static uint32_t s_call_identifier;
// If the mobile app is closed we won't receive PP messages and thus might miss a call end event
// which puts us in a bad state until BT disconnects
static ... | phone_ui_handle_outgoing_call(event->caller) | ;
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_OUTGOING_COUNT, AnalyticsClient_System);
} else {
// PBL_LOG(LOG_LEVEL_DEBUG, "Ignoring outgoing call. A call is already in progress: %d, "
// "the mobile app is connected: %d", s_call_in_progress, s_mobile_app_is_connected);
}
}
static void prv_ha... |
.timestamp = 18000,
.duration = 30,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
}
}
};
// all day item
static TimelineItem s_all_day_items[] = {
{
.header = {
.id = {0x01},
.parent_id = {0},
.timestamp = 1421020800, // midnight jan 1... | cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id)) | |
izer_manager_init(&manager);
// ensure this runs without crashing even if there are no recognizer lists
prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL);
RecognizerList app_list = {};
s_app_list = &app_list;
Window window = {};
layer_init(&window.layer, &GRectZero);
manager.wind... | (!ctx.triggered) | ;
r->state = RecognizerState_Completed;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(!handled);
cl_assert(!ctx.triggered);
r->state = RecognizerState_Started;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert_equal_p(ctx.triggered, r);
ctx.triggered = NULL;
han... |
Add the next button event to the queue
PebbleEvent next_button_event = {
.type = next_event_type,
.button.button_id = context->button_id,
};
event_put(&next_button_event);
// Decrement the number of presses remaining if the button is currently held down (because we
// just pushed it up by adding tha... | }
// Construct our new_timer context, will be freed in command_button_press_callback()
ButtonPressNewTimerContext *new_timer_context = kernel_malloc(sizeof(ButtonPressNewTimerContext));
if (!new_timer_context) {
goto error;
}
*new_timer_context = (ButtonPressNewTimerContext) {
.button_id = button_i... | |
/*
* 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... | dialog_spi_receive_data((uint8_t *)&received_crc, sizeof(received_crc)) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "VT Crc. Expected: 0x%x Received CRC: 0x%x",
(int)expected_crc, (int)received_crc);
return (received_crc == expected_crc);
}
static bool prv_send_hi_cmd(void) {
uint8_t send[] = {'H', 'I'};
dialog_spi_transmit_data(send, sizeof(send));
uint8_t response[4] = {};
dialog... |
hrm->debug->accel_data.num_samples);
led_current = bpm = bpm_quality = 0;
prv_send_msg();
} else if (hrm->event_type == HRMEvent_SubscriptionExpiring) {
PBL_LOG(LOG_LEVEL_INFO, "Got subscription expiring event");
// Subscribe again if our subscription is expiring
const uint32_t upda... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Successfully opened app message");
} |
if (!sys_hrm_manager_is_hrm_present()) {
text_layer_set_text(quality_tl, "No HRM Present");
} else {
text_layer_set_text(quality_tl, "Loading...");
prv_enable_hrm();
}
app_message_register_inbox_received(prv_message_received_cb);
app_message_register_outbox_sent(prv_message_sent_cb);
app_mess... |
/*
* 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_zalloc(
sizeof(*result) + num_bytes_needed_for_mask_row_infos + num_bytes_needed_for_pixel_mask_data) | ;
if (result) {
// We store the mask_row_infos first in the .data buffer, followed by the pixel_mask_data
*result = (GDrawMask) {
.mask_row_infos = (GDrawMaskRowInfo *)result->data,
.pixel_mask_data = ((uint8_t *)result->data) + num_bytes_needed_for_mask_row_infos,
};
// Initialize the ma... |
/*
* 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... | ALL_INTERRUPT_FLAGS_L(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... | (NULL, NULL, NULL) | );
cl_assert_equal_gpoint(origin, text_layer.layer.frame.origin);
cl_assert_equal_gpoint(page.origin, origin);
cl_assert_equal_gsize(page.size, GSize(text_layer.layer.frame.size.w,
TEXT_LAYER_FLOW_DEFAULT_PAGING_HEIGHT));
}
void test_text_layer_flow__paging_container(void... |
/ 2, SCREEN_HEIGHT);
graphics_context_set_antialiased(&ctx, true);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_left_clipped_aa.${BIT_DEPTH_NAME}.pbi"));
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_house_path;
ctx.draw_state... | (&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... | {
// Failed to load BT bootloader. Shutdown if we haven't tried this already.
PBL_LOG(LOG_LEVEL_ERROR, "Failed to load BLE Second Stage Bootloader - shutting down");
if (reboot_reason_get_last_reboot_reason() != RebootReasonCode_DialogBootFault) {
enter_standby(RebootReasonCode_DialogBootFault);
}... | else if (dialog_spi_bootloader_load_image() && host_transport_init()) {
hc_protocol_init();
bt_local_id_generate_address_from_serial(&config->identity_addr);
bool result = hc_endpoint_ctl_init_sync(config);
// Nothing good comes from a failure here. BT gets partially initialized and you won't even see
... |
ed(MICRO_FAMILY_STM32F4)
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_adc.h"
#endif
#include <stdint.h>
/* PMIC Bus Information */
#define MAX14690_ADDR 0x50
//! The addresses of the registers that we can read using i2c
typedef enum PmicRegisters {
PmicRegisters_CHIP_ID = 0x00,
Pmic... | {
WTF;
} |
uint8_t register_value;
bool success = prv_read_register(rail_control_reg, ®ister_value);
if (!success) {
// Failed to read the current register value
return false;
}
if (enable) {
if (*ref_count) {
(*ref_count)++;
return true;
} else {
// Set the register byte to XXXX... |
one 3 HR Label
return i18n_noop("PERFORMANCE");
default:
/// Default/Zone 0 HR Label
return i18n_noop("HEART RATE");
}
}
static const char* prv_get_label_for_metric(WorkoutMetricType metric_type,
WorkoutActiveWindow *active_window) {
switch (metric_... | (number_font) | - fonts_get_font_height(units_font);
switch (metric_type) {
case WorkoutMetricType_Hr: {
GPoint heart_node_offset = GPoint(2, prefer_larger_font ? 5 : 0);
GTextNodeCustom *heart_node;
if (active_window->workout_controller->get_metric_value(
metric_type, active_window->workout_data) >... |
#if 0 /* temporarily disabled */
static void
clar_run_single(const struct clar_func *test,
const struct clar_suite *suite)
{
_clar.suite_errors = 0;
_clar.active_suite = suite->name;
_clar.active_test = test->name;
clar_run_test(test, &suite->initialize, &suite->cleanup);
}
#endif
static void
clar_usage(con... | for (j = 0; j < _clar_suite_count; ++j) {
const struct clar_suite *suite = &_clar_suites[j];
for (int i = 0; i < suite->test_count; i++) {
printf(" %s\n", suite->tests[i].name);
}
} |
printf("\n");
exit(0);
}
default:
clar_usage(argv[0]);
}
}
}
static int
clar_test(int argc, char **argv)
{
clar_print_init(
(int)_clar_callback_count,
(int)_clar_suite_count,
""
);
if (clar_sandbox() < 0) {
clar_print_onabort("Failed to sandbox the test runner.... |
break;
case WATCH_INFO_COLOR_TIME_STEEL_SILVER:
model_name = SNOWY_MODEL("pebble_time_steel_silver");
break;
case WATCH_INFO_COLOR_TIME_STEEL_BLACK:
model_name = SNOWY_MODEL("pebble_time_steel_black");
break;
case WATCH_INFO_COLOR_TIME_STEEL_GOLD:
model_name = S... | (version_object) | ;
}
static void prv_fill_watchinfo(jerry_value_t watchinfo) {
JS_VAR platform_name = prv_get_platform_name();
JS_VAR model_name = prv_get_model_name();
JS_VAR language = prv_get_language();
JS_VAR fw_version = prv_get_fw_version();
jerry_set_object_field(watchinfo, ROCKY_WATCHINFO_PLATFORM, platform_name);
... |
MAP_NATIVE_FORMAT, which
// wouldn't work for Spalding since it uses GBitmapFormat8BitCircular
GBitmap* graphics_capture_frame_buffer(GContext *ctx) {
PBL_ASSERTN(ctx);
return graphics_capture_frame_buffer_format(ctx, CANVAS_GBITMAP_FORMAT);
}
// Overrides same function in graphics.c; we need to do this so we can ... | {
ActionMenuConfig config = {
.root_level = root_level,
.colors.background = GColorChromeYellow,
.did_close = prv_action_menu_did_close_cb,
};
ActionMenu *action_menu_window = app_action_menu_open(&config);
// Set the window on screen so its window handlers will be called
window_set_on_screen(&a... |
#define GRID_CELL_PADDING 5
typedef void (*RenderCallback)(SettingsContentSize content_size, const ActionMenuLevel *root_level,
unsigned int selected_index, unsigned int additional_crumbs);
static void prv_prepare_canvas_and_render_for_each_size(RenderCallback callback,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, clipped_rect) | |
}
// tests
void test_recognizer__create_with_data(void) {
int sub_data;
void *dummy = &sub_data;
RecognizerImpl s_test_impl = {
.handle_touch_event = dummy,
.cancel = dummy,
.reset = dummy
};
Recognizer *r = recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
... | cl_assert_equal_i(r->state, RecognizerState_Started) | ;
cl_assert_equal_i(event_type, RecognizerEvent_Started);
cl_assert(!s_manager_state_change);
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Failed));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Possible));
cl_assert_passert(recognizer_transition_state(r, RecognizerState... |
xt(data);
prv_update_name_text(data);
}
static void prv_push_window(struct RecoveryFUAppData* data) {
Window* window = &data->launch_app_window;
window_init(window, WINDOW_NAME("First Use / Recovery"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers){
.load = prv... | (&data->ble_device_name_updated_event_info) | ;
app_window_stack_pop_all(false);
prv_allow_pairing(data, false);
app_free(data);
s_fu_app_data = NULL;
launcher_block_popups(false);
}
static void prv_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* recovery_first_use_app_get_app_info(void) {
static co... |
/*
* 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 (int i = 0; i < list->serialized_byte_length; i++) {
if (list->data[i] == '\0') {
result++;
}
} | |
assert_result_invalid(app_smartstrap_attribute_begin_write(attr, &buffer, NULL));
assert_result_invalid(app_smartstrap_attribute_begin_write(attr, NULL, &buffer_len));
// smartstrap_attribute_end_write()
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 0, false));
assert_result_invalid(app_sma... | (app_smartstrap_attribute_read(attr)) | ;
uint8_t *write_buffer2 = NULL;
size_t write_length2 = 0;
assert_result_busy(app_smartstrap_attribute_begin_write(attr, &write_buffer2, &write_length2));
cl_assert(write_buffer2 == NULL);
cl_assert(write_length2 == 0);
// end the write request without sending anything
assert_result_invalid(app_smartstra... |
/*
* 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... | connection_by_idx(conn_idx) | |
/*
* 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... | (&pwm->output, GPIO_OType_PP, GPIO_Speed_100MHz) | ;
// The ".active_high" attribute determines the idle state of the PWM output
gpio_output_set(&pwm->output, false /* force low */);
}
const FunctionalState state = (enable) ? ENABLE : DISABLE;
if (IS_LPTIM(pwm->timer.peripheral)) {
LPTIM_Cmd(pwm->timer.lp_peripheral, state);
} else {
TIM_Cmd(pw... |
worker_manager_get_default_install_id() | ;
if (id != INSTALL_ID_INVALID) {
worker_manager_put_launch_worker_event(id);
}
}
}
// ------------------------------------------------------------------------------------------------
void worker_manager_disable(void) {
if (s_workers_enabled) {
s_workers_enabled = false;
process_manager_put_... | |
m_callback_events(0);
// The buffer should be completely available again:
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer));
}
void test_app_inbox__app_inbox_service_cancel_non_existing_inbox(void) {
app_inbox_se... | app_inbox_service_end(AppInboxServiceTagUnitTest) | |
15
};
time_t utc_sec = mktime(&start_tm);
rtc_set_time(utc_sec);
// Add a run session
const time_t time_elapsed = (20 * SECONDS_PER_MINUTE);
ActivitySession run_activity = {
.start_utc = utc_sec - time_elapsed,
.length_min = time_elapsed,
.type = ActivitySessionType_Run,
.ongoing = true,
... | health_service_peek_current_activities() | );
// Start on known boundary
struct tm start_tm = {
// Jan 1, 2015, 5am
.tm_hour = 5,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
time_t utc_sec = mktime(&start_tm);
rtc_set_time(utc_sec);
const time_t time_elapsed = (20 * SECONDS_PER_MINUTE);
// Add a run session
ActivitySessio... |
current_value(HealthMetric metric) {
time_t now_utc = sys_get_time();
return health_service_aggregate_averaged(metric, now_utc, now_utc, HealthAggregationAvg,
HealthServiceTimeScopeOnce);
}
static HealthValue prv_hr_aggregate_averaged(HealthServiceState *state, HealthMet... | prv_sum_intraday_averages(&averages, time_start, time_end) | ;
num_sums++;
}
} else if ((scope == HealthServiceTimeScopeDaily)
|| (scope == HealthServiceTimeScopeDailyWeekdayOrWeekend)) {
for (DayInWeek day = Sunday; day <= Saturday; day++) {
if (scope == HealthServiceTimeScopeDailyWeekdayOrWeekend) {
if (is_weekend != prv_is_week... |
rtc_set_time(rtc_get_time() + SECONDS_PER_MINUTE);
prv_clear_event_queue();
}
}
// -------------------------------------------------------------------------------
static void prv_test_steps(void *context) {
bool passed = false;
// Reset all stored data
activity_test_reset(true /*reset_settings*/, true ... | (ActivityMetricSleepRestfulSeconds, 1, &deep_sleep) | ;
deep_sleep -= before_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_... |
{ 272, 0, -288},
// 2 seconds
{ 536, 56, -152},
{ 672, 224, -120},
{ 712, 232, -152},
{ 1056, 144, -184},
{ 1368, 240, -496},
{ 2056, 320, -680},
{ 2712, 312, -800},
{ 2448, 288, -568},
{ 1784, 328, -592},
{ 1288, 448, -536},
{ 848, 504, -488},
{ 616, 288, -376},
... | { 1136, 416, -192},
{ 1016, 728, -80},
{ 904, 1224, 288},
{ 600, 1192, 176},
{ 664, 816, 136},
{ 1048, 912, 104},
{ 1480, 696, -80},
{ 2176, 856, -64},
{ 2680, 728, -8},
{ 2464, 408, 72},
{ 1992, 48, -24},
{ 1528, 40, -224},
{ 1224, 80, -192},
{ 1128, 40, -248},
... | |
atic void prv_set_progress_failure(AppFetchUIData *data) {
uint32_t icon;
const char *message;
switch (data->result) {
case AppFetchResultNoBluetooth:
icon = TIMELINE_RESOURCE_WATCH_DISCONNECTED;
message = i18n_get("Not connected", data);
// Subscribe to the BT remote app connect event
... | {
AppFetchUIData *data = app_state_get_user_data();
PebbleAppFetchEvent *af_event = (PebbleAppFetchEvent *) event;
// We have starting the App Fetch Process
if (af_event->type == AppFetchEventTypeStart) {
PBL_LOG(LOG_LEVEL_DEBUG, "App Fetch: Got the start event");
// We have received a new progress even... |
// TODO: Use appropriate transitions to and from watchfaces or apps
static void prv_click_handler(ClickRecognizerRef recognizer, Window *window) {
AppFetchUIData *data = app_state_get_user_data();
if (data->failed) {
app_window_stack_pop(true);
} else {
app_fetch_cancel(data->install_entry.install_id);
... |
e + 1) % MODULUS;
if (ntoh16(packet->i.length) <= length) {
size_t info_length = ntoh16(packet->i.length) - sizeof(ReliablePacket);
// This variable is read in the macro-expansion below, but linters
// have a hard time figuring that out.
(void)info_length;
switch (ntoh16(p... | if (!s_layer_up) {
return NULL;
} |
xSemaphoreTake(s_tx_lock, portMAX_DELAY);
if (!s_layer_up) {
// Transport went down while waiting for the lock
PBL_LOG(LOG_LEVEL_DEBUG, "Transport went down while waiting for lock");
xSemaphoreGive(s_tx_lock);
return NULL;
}
s_tx_buffer->app_protocol = app_protocol;
return &s_tx_buffer->infor... |
;
}
break;
}
update_session_state(logging_session, DataLoggingSessionCommStateIdle, true /*reschedule*/);
mutex_unlock(s_endpoint_data.mutex);
// reopen the session that was NACK'ed
dls_endpoint_open_session(logging_session);
}
//! System task callback executed which reopens the next session i... | (LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Phone requested empty of session %u",
session_id) | ;
DataLoggingSession *logging_session = dls_list_find_by_session_id(session_id);
if (logging_session) {
dls_private_send_session(logging_session, true /*empty_all_data*/);
}
}
//! data_logging_protocol_msg_callback runs on Bluetooth task. Keep it quick.
void data_logging_protocol_msg_callback(CommSession *s... |
areDescription* desc) {
dbgserial_putstr("Checksumming firmware update");
const uint32_t crc = flash_calculate_checksum(flash_address, desc->firmware_length);
dbgserial_print("Calculated checksum: ");
dbgserial_print_hex(crc);
dbgserial_newline();
return crc == desc->checksum;
}
static void prv_display_era... | ("New firmware is available!") | ;
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO);
UpdateFirmwareResult result = update_fw(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN);
switch (resu... |
-----------------------
AnimationCurveFunction animation_get_custom_curve(Animation *animation_h) {
return prv_animation_get_custom_function(animation_h, AnimationCurveCustomFunction);
}
// -------------------------------------------------------------------------------------------
InterpolateInt64Function animation_... | {
return animation->play_count;
} | |
/*
* 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... | (MUSIC_BUFFER_LENGTH - 1, src_length) | ;
if (src) {
memcpy(dest, src, cropped_length);
}
dest[cropped_length] = 0;
}
static void prv_put_now_playing_changed_event(void) {
PebbleEvent e = {
.type = PEBBLE_MEDIA_EVENT,
.media.type = PebbleMediaEventTypeNowPlayingChanged
};
event_put(&e);
}
bool music_set_connected_server(const MusicS... |
ch layer is visible
if (node == NULL) {
layer_set_hidden((Layer *) &data->menu_layer, true);
layer_set_hidden((Layer *) &data->text_layer, false);
} else {
layer_set_hidden((Layer *) &data->menu_layer, false);
layer_set_hidden((Layer *) &data->text_layer, true);
}
}
static void prv_handle_notific... | layer_add_child(&window->layer, text_layer_get_layer(text_layer)) | ;
#if PBL_ROUND
GColor bg_color = GColorClear;
GColor fg_color = GColorBlack;
StatusBarLayer *status_bar = &data->status_bar_layer;
status_bar_layer_init(status_bar);
status_bar_layer_set_colors(status_bar, bg_color, fg_color);
layer_add_child(&window->layer, &status_bar->layer);
#endif
menu_layer_set_... |
6600;
static TimerID s_timer = TIMER_INVALID_ID;
static bool s_event_ongoing = false;
void calendar_init() {
s_timer = new_timer_create();
}
bool calendar_event_is_ongoing() {
return s_event_ongoing;
}
void do_not_disturb_toggle_push(ActionTogglePrompt prompt, bool set_exit_reason) {
do_not_disturb_set_manual... | cl_assert(do_not_disturb_is_manually_enabled() == true) | ;
cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == false);
cl_assert(do_not_disturb_is_smart_dnd_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == true);
// Manual && Scheduled && !Smart
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
DoNotDisturbSc... |
_CONFIG_1, 0); // power down the fifo
curr_fifo_num_samples_wm = 0;
} else {
curr_fifo_num_samples_wm = num_samples;
// Set the new fifo watermark
// TODO: I think we will want to try and make this a multiple of the frame size
uint8_t fifo_wm = (num_samples * fifo_frame_size) / BMI160_FIFO_WM_UNIT... | prv_read_modify_write(BMI160_REG_INT_MAP_0, en_val, en_val) | ;
// Actually enable the double tap interrupt
uint8_t int_en = BMI160_INT_EN_0_D_TAP_EN;
prv_read_modify_write(BMI160_REG_INT_EN_0, int_en, int_en);
BMI160_DBG("ACC_CONF = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_ACC_CONF));
prv_enable_operating_mode(AccelOperatingModeDoubleTapDetection, BMI160SampleRate_200_H... |
C_CR1_RXIE |
I2C_CR1_TCIE |
I2C_CR1_NACKIE |
I2C_CR1_ERRIE);
}
void i2c_hal_abort_transfer(I2CBus *bus) {
// Disable all interrupts on the bus
prv_disable_all_interrupts(bus);
// Generate a stop condition
bus->hal->i2c->CR2 |= I2C_CR... | (bus, I2CTransferEvent_NackReceived) | ;
}
break;
case I2CTransferState_ReadData:
if ((i2c->ISR & I2C_ISR_RXNE) != 0) {
transfer->data[transfer->idx++] = i2c->RXDR;
}
if ((i2c->ISR & I2C_ISR_TCR) != 0) {
prv_resume_transfer(bus, false /* !generate_start */);
}
if ((i2c->ISR & I2C_ISR_TC) != 0) {... |
tfulSeconds, 1, &value);
cl_assert_equal_i(value, 100 * SECONDS_PER_MINUTE);
cl_assert_equal_i(health_service_sum_today(HealthMetricSleepRestfulSeconds),
100 * SECONDS_PER_MINUTE);
activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value);
cl_assert_equal_i(value, 2 * SECONDS_PER_HOU... | (false, true, &enabled, &session_id, &num_samples, &seconds) | ;
cl_assert(!enabled);
cl_assert_equal_i(num_samples, k_raw_samples);
cl_assert_equal_i(seconds,
(k_raw_samples + ALGORITHM_SAMPLING_RATE - 1) / ALGORITHM_SAMPLING_RATE);
// Verify the collected data
AccelRawData captured_data[k_raw_samples];
prv_uncompress_captured_data(c... |
IN_RECT_CLIP_NXNY, true, 5);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// AA = true, SW = 11
set... | (&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// SW = 5
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 5);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_ori... |
56, 488, -312},
{ 800, 568, -320},
{ 784, 520, -368},
{ 768, 440, -416},
{ 864, 408, -416},
{ 936, 344, -408},
{ 928, 264, -240},
{ 1048, 336, -200},
{ 1144, 536, -416},
{ 1448, 736, -288},
{ 1920, 1160, 24},
{ 2024, 256, 176},
{ 1784, 264, -24},
{ 1648, 544, -16},
... | { 360, 256, -952},
{ 312, 296, -928},
// 128 seconds
{ 320, 288, -944},
{ 304, 296, -984},
{ 296, 312, -1008},
{ 296, 288, -1032},
{ 264, 288, -1040},
{ 232, 256, -1040},
{ 200, 184, -1016},
{ 160, 128, -928},
{ 128, 112, -912},
{ 80, 96, -888},
{ 48, 48, -896},
... | |
1240, 352, -336},
{ 1200, 312, -272},
{ 1256, 360, -208},
{ 1384, 376, -144},
{ 1192, 168, -16},
// 29 seconds
{ 1064, 208, -16},
{ 1160, 192, -48},
{ 1296, 272, -56},
{ 1184, 192, 24},
{ 1264, -24, 120},
{ 1088, -8, 64},
{ 856, -56, 88},
{ 1072, 0, 256},
{ 1184, ... | { 1232, -24, 176},
{ 1224, 152, -16},
{ 1280, 64, -88},
{ 1232, 176, -96},
{ 1064, 200, -240},
{ 816, 136, -160},
{ 856, 224, -192},
{ 1088, 232, -208},
{ 1224, 304, -280},
{ 1312, 400, -320},
{ 1600, 760, -776},
{ 1168, 408, -352},
{ 1360, 184, -360},
{ 1360, 560... |
// 37 seconds
{ 1416, 176, -136},
{ 1184, 40, -8},
{ 1128, 200, -128},
{ 1288, 320, -120},
{ 1152, 240, 8},
{ 984, 0, 24},
{ 1232, -40, -32},
{ 888, 24, -120},
{ 984, -128, 152},
{ 1224, 104, -8},
{ 1328, 8, -72},
{ 1536, 128, -104},
{ 1416, 72, -224},
{ 1040... |
window->workout_data);
if (bpm == 0 && !active_window->hr_measuring_timer) {
active_window->cur_hr_measuring_width_idx = 0;
prv_hr_measuring_timer_callback(active_window);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Drawing
static void prv_d... | graphics_draw_rect(ctx, &zone_rect) | |
ctet,
[1] = octet,
[2] = octet,
[3] = octet,
[4] = octet,
[5] = octet,
},
};
BTDevice device = bt_device_init_with_address(address, true /* is_random */);
return *(BTDeviceInternal *)(&device);
}
static BTDeviceInternal prv_connected_dummy_device(uint8_t octet) {
BTDeviceInter... | {
BLECharacteristic characteristic_ref = characteristic_refs[c];
const Characteristic *expected_characteristic = &expected_service->characteristics[c];
// Test gatt_client_characteristic_get_uuid():
const Uuid uuid = gatt_client_characteristic_get_uuid(characteristic_ref);
cl_assert(uuid_... |
// Test gatt_client_descriptor_get_uuid():
const Uuid uuid = gatt_client_descriptor_get_uuid(descriptor_ref);
cl_assert(uuid_equal(&uuid, &expected_descriptor->uuid));
// Test gatt_client_descriptor_get_characteristic():
cl_assert_equal_i(gatt_client_descriptor_get_characteris... |
/*
* 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... | {
// Can't erase any full sectors, just erase subsectors the whole way.
for (int32_t i = subsector_start; i < subsector_end; i += SUBSECTOR_SIZE_BYTES) {
flash_erase_subsector_blocking(i);
}
} |
}
void flash_region_erase_optimal_range(uint32_t min_start, uint32_t max_start,
uint32_t min_end, uint32_t max_end) {
prv_erase_optimal_range(min_start, max_start, min_end, max_end);
}
void flash_region_erase_optimal_range_no_watchdog(uint32_t min_start, uint32_t max_start,
... |
s
while (animation) {
if (!animation->parent) {
break;
}
animation = (AnimationPrivate *) list_get_next(&animation->list_node);
}
// There had to be at least 1 top-level animation
PBL_ASSERTN(animation);
prv_unschedule_animation(state, animation, false /*finished*/, true /*... | if (animation_private_using_legacy_2(NULL)) {
// We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
return (const AnimationImplementation*)((AnimationLegacy2 *)animation_h)->implementation;
} |
AnimationPrivate *animation = prv_find_animation_by_handle(NULL, animation_h, false /*quiet*/);
if (!animation) {
return NULL;
}
return animation->implementation;
}
// -------------------------------------------------------------------------------------------
void *animation_get_context(Animation *animat... |
layer->clips) {
const GRect levels_layer_frame_in_ctx_space = {
.origin = {
// drawing_box is expected to be setup as the bounds of the parent:
.x = ctx->draw_state.drawing_box.origin.x + levels_layer->frame.origin.x,
.y = ctx->draw_state.drawing_box.o... | gpoint_sub_eq(&area.origin, layer_convert_point_to_screen(layer->parent, GPointZero)) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | grect_shortest_side(GRect(0, 0, 10, 20)) | );
cl_assert_equal_i(10, grect_shortest_side(GRect(0, 0, 20, 10)));
cl_assert_equal_i(10, grect_shortest_side(GRect(0, 0, 10, -20)));
cl_assert_equal_i(10, grect_shortest_side(GRect(0, 0, -20, 10)));
}
void test_gtypes__grect_inset(void) {
GRect rect = GRect(10, 20, 30, 40);
cl_assert_equal_grect(GRect(12, 2... |
a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for ... | (timeout_ms) | ;
RtcTicks current_time = rtc_get_ticks();
// Grab lock on timer structures
mutex_lock(manager->mutex);
// Find this timer
TaskTimer* timer = prv_find_timer(manager, timer_id);
PBL_ASSERTN(!timer->defer_delete);
// If this timer is currently executing it's callback, return false if
// TIMER_START_FLA... |
id(void);
#define TEST_GATT_CONNECTION_ID (1234)
static BTDeviceInternal prv_dummy_device(uint8_t octet) {
BTDeviceAddress address = {
.octets = {
[0] = octet,
[1] = octet,
[2] = octet,
[3] = octet,
[4] = octet,
[5] = octet,
},
};
BTDevice device = bt_device_init_with... | prv_assert_event(&device, BTErrnoOK) | ;
fake_event_clear_last();
// Start discovery again, expect not to run (already discovered):
cl_assert_equal_i(gatt_client_discovery_discover_all(&device), BTErrnoOK);
cl_assert_equal_b(fake_gatt_is_service_discovery_running(), false);
// Expect event:
prv_assert_event(&device, BTErrnoOK);
}
void test_g... |
lear-expect.8bit.pbi"));
// Verify that if the source is transparent, it should not affect the destination bitmap
prv_set_opacity(src_bitmap, 0);
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpTint, GColorRed);
cl_assert(gbitmap_eq(&dest_bitmap, &expect_bmp, "test_bitblt__8bit_comptint... | (0, 0, 4, 1) | ,
.info.format = GBitmapFormat8Bit,
.info.version = GBITMAP_VERSION_CURRENT
};
for (uint8_t rgb_half = 0; rgb_half < NUM_COLORS / 2; rgb_half++) {
const int16_t x = rgb_half * NUM_OPACITIES + LEGEND_WIDTH;
const int8_t legend_height = 3;
// Upper row with destination colors from 0..31
cons... |
Rect next_start = window_bounds;
next_start.origin.y = slide_up ? -window_bounds.size.h : window_bounds.size.h;
Animation *curr_out = prv_create_slide_animation(current_card_layer, &window_bounds, &curr_stop);
Animation *next_in = prv_create_slide_animation(next_card_layer, &next_start, &window_bounds);
Anima... | layer_add_child(window_root, &health_card_view->select_indicator_layer) | ;
layer_set_update_proc(&health_card_view->select_indicator_layer,
prv_select_indicator_layer_update_proc);
// setup content indicators
const int content_indicator_height = PBL_IF_ROUND_ELSE(18, 11);
const GRect down_arrow_layer_frame = grect_inset(window_root->frame,
GEdgeInsets(... |
, BTErrno errno) {
if (errno != BTErrnoOK) {
// Handle failure -- cleanup and dispatch event:
prv_free_service_nodes(connection);
gatt_client_subscriptions_cleanup_by_connection(connection, false /* should_unsubscribe */);
}
prv_remove_current_discovery_job(connection);
connection->gatt_is_service_... | prv_free_service_nodes(connection) | ;
}
}
//! extern for gatt_service_changed.c
//! Same as gatt_client_discovery_discover_all, but cleans up existing service discovery
//! state and stops any existing service discovery process.
BTErrno gatt_client_discovery_rediscover_all(const BTDeviceInternal *device) {
BTErrno ret_val = BTErrnoServiceDiscoveryDi... |
draw_circle(&context, GPoint(50, 50), 10);
#if PBL_COLOR
ASSERT_CALLED(graphics_circle_draw_stroked_aa(&context, GPoint(50, 50), 10, 2));
#else
ASSERT_CALLED(graphics_circle_draw_stroked_non_aa(&context, GPoint(50, 50), 10, 2));
#endif
setup_test(&context, true, 2, GColorBlack, GColorBlack, false);
graphics_dr... | GPoint(50, 50) | , 10));
setup_test(&context, false, 5, GColorBlack, GColorBlack, false);
graphics_fill_round_rect(&context, &GRect(20, 80, 40, 10), 4, GCornersAll);
ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GRect(20, 80, 40, 10), 4, GCornersAll, GColorBlack));
}
void test_graphics_context_${BIT_DEPTH_NAME}__fill_antialiase... |
/*
* 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_set_text_alignment(text_layer, GTextAlignmentCenter) | ;
data->count = 0;
prv_set_tap_text(data, 0, 0);
layer_add_child(&window->layer, (Layer *)text_layer);
}
static void prv_handle_tap(AccelAxisType axis, int32_t direction) {
AppData *data = app_state_get_user_data();
prv_set_tap_text(data, ++data->count, axis);
prv_show_thumbsup(data);
}
static void prv_ha... |
ar *strdup(const char *s1);
void
clar__assert(
int condition,
const char *file,
int line,
const char *error_msg,
const char *description,
int should_abort)
{
struct clar_error *error;
if (condition)
return;
#ifndef _WIN32
#ifdef UNITTEST_DEBUG
// Break in debugger:
raise(SIGINT);
#endif
#endi... | printf(" %04x ", i) | |
test_graphics_context_reset(&ctx, fb) | ;
layer_set_update_proc(&layer, &across_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
... | |
d_info.id = (uint32_t)task_info->taskHandle;
packed_info.running = (current_task_id == task_info->taskHandle);
for (int i = 0; i < portCANONICAL_REG_COUNT; i++) {
// registers [r0-r12, sp, lr, pc, sr]
packed_info.registers[i] = task_info->registers[i];
}
// If this is the current task, adjust the regis... | prv_flash_write_bytes(&chunk_hdr, s_flash_addr,
sizeof(chunk_hdr)) | ;
CoreDumpMemoryHeader mem_hdr;
mem_hdr.start = (uint32_t)regions[i].start;
s_flash_addr += prv_flash_write_bytes(&mem_hdr, s_flash_addr,
sizeof(mem_hdr));
if (regions[i].word_reads_only) {
// Copy the memory into a temporary buffer before writing it to f... |
color(ctx, status_bar_layer_get_foreground_color(&data->status_layer));
graphics_context_set_compositing_mode(ctx, GCompOpTint);
graphics_draw_bitmap_in_rect(ctx, &data->dnd_icon, &data->dnd_icon.bounds);
}
static void prv_update_status_layer(NotificationWindowData *data) {
const int notif_count = notifications_... | (¬if_list[i].id, id, sizeof(Uuid)) | ;
notif_list[i].type = notifications_presented_list_get_type(id);
}
PBL_LOG(LOG_LEVEL_DEBUG, "Dismissing %d notifications", num_notifications);
window_data->window_frozen = true;
timeline_actions_dismiss_all(notif_list,
num_notifications,
action... |
ef struct {
void* start;
uint32_t length;
bool word_reads_only; // Some peripherals can only be read 32 bits at a
// time, or you BusFault (maybe). Set this to true
// for memory regions where reads smaller than 32
// b... | {
char buffer[12];
itoa(i, buffer, sizeof(buffer));
#if PULSE_EVERYWHERE
void *ctx = pulse_logging_log_sync_begin(LOG_LEVEL_ALWAYS, __FILE_NAME__, 0);
pulse_logging_log_sync_append(ctx, msg);
pulse_logging_log_sync_append(ctx, buffer);
pulse_logging_log_sync_send(ctx);
#else
int max_length = 256;
while... | |
tateStopped] = "Stopped",
[BtTestStateStarting] = "Starting",
[BtTestStateStopping] = "Stopping",
[BtTestStateStarted] = "Started",
[BtTestStateFailed] = "Failed",
[BtTestStateResetting] = "Resetting",
};
typedef struct {
Window window;
TextLayer title;
TextLayer status;
BtTestState test_state;
Tim... | layer_add_child(&window->layer, &status->layer) | ;
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
app_window_stack_push(window, true /* Animated */);
bt_state_change_event_info = (EventServiceInfo) {
.type = PEBBLE_BT_STATE_EVENT,
.handler = prv_bt_event_handler,
.context = data,
};
event_service_client_subs... |
(don't render first *and* last pixel if line length is 1)
if (y2.fraction != 0) {
// Only draw the pixel if its within the bitmap data row range
if (WITHIN(x, data_row_info.min_x, data_row_info.max_x)) {
graphics_private_raw_blend_color_factor(ctx, output, data_row_offset, color, x,
... | if (x1.integer > x2.integer) {
return;
} |
GColor8 *output = (GColor8 *)(data_row_info.data + x1.integer);
// first pixel with blending
const unsigned int data_row_offset = data_row_info.data - (uint8_t *)framebuffer->addr;
if (left_aa_offset == 1) {
// To prevent bleeding of left-hand AA below clip_box
if (x1.integer >= clip_box_min_x) {
... |
/*
* 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... | (response) | ;
return true;
}
static void prv_log_string_v1(BinLogMessage_String_v1 *msg) {
PBL_LOG(LOG_LEVEL_ALWAYS, "%s", msg->string);
}
#if PBL_LOGS_HASHED
static void prv_log_param_v1(BinLogMessage_Param_v1 *msg) {
// HACK ALERT: we want to call a var-args function but we don't want to create our own stack
// frame.... |
;
app_message_ctx->inbox.user_context = context;
app_message_ctx->outbox.user_context = context;
return retval;
}
AppMessageInboxReceived app_message_register_inbox_received(
AppMessageInboxReceived received_callback) {
AppMessageCtx *app_message_ctx = app_state_get_app_message_ctx();
AppMessageInboxRece... | app_message_outbox_close(&app_message_ctx->outbox) | ;
app_message_inbox_close(&app_message_ctx->inbox);
app_message_deregister_callbacks();
}
// -------- Testing Interface (only) ------------------------------------------------------------ //
AppTimer *app_message_ack_timer_id(void) {
AppMessageCtx *app_message_ctx = app_state_get_app_message_ctx();
return ap... |
{
.input = jerry_create_undefined(),
.expected_output = "undefined",
},
{
.input = jerry_create_array(0),
.expected_output = "", // Kinda weird?
},
{
.input = jerry_create_object(),
.expected_output = "[object Object]",
},
};
for (int i = 0; i < ARRAY_LENGTH(... | memset(&output, 0x55, sizeof(output)) | ;
ROCKY_ARGS_ASSIGN(ROCKY_ARG(output));
ASSERT_JS_ERROR(error_value, cases[i].error_msg);
if (!cases[i].error_msg) {
cl_assert_equal_i(output.origin.x.raw_value, cases[i].expected_output.origin.x.raw_value);
cl_assert_equal_i(output.origin.y.raw_value, cases[i].expected_output.origin.y.raw_valu... |
;
settings_file_each(&wakeup_settings, prv_check_count_and_availability_callback, &check);
if (check.wakeup_count < S_SUCCESS) {
status = check.wakeup_count;
} else if (check.wakeup_count >= MAX_WAKEUP_EVENTS_PER_APP) {
status = E_OUT_OF_RESOURCES;
} else {
settings_file... | if (settings_file_open(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) == S_SUCCESS) {
settings_file_rewrite(&wakeup_settings, prv_migrate_events_callback, (void*)&utc_diff);
settings_file_close(&wakeup_settings);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Error: could not open wakeup settings")... |
}
mutex_unlock(s_mutex);
}
static void prv_wakeup_rewrite_kernel_bg_cb(void *data) {
// Update each wakeup entry via prv_update_events_callback and record any missed events
struct prv_missed_events_s missed_events = { 0, NULL };
mutex_lock(s_mutex);
{
SettingsFile wakeup_settings;
if (settings_fi... |
(&bd_addr, name, &link_key, &platform_bits) | ) {
// No pairing available, check to see if we have a pairing in the gapDB
prv_push_bt_persist_to_shared_prf(BtPersistBondingTypeBTClassic);
return;
}
bt_persistent_storage_store_bt_classic_pairing(&bd_addr, &link_key, name, &platform_bits);
}
static void prv_load_ble_pairing_from_prf(void) {
SMPai... | |
);
cl_assert_equal_i(0, lc->fill_radial_precise.radius_inner.raw_value);
cl_assert_equal_i(20 * 8, lc->fill_radial_precise.radius_outer.raw_value);
// inner radius capped to >= 0
EXECUTE_SCRIPT(
"ctx.rockyFillRadial(30, 40, -10, 20, 0, Math.PI);\n"
);
cl_assert_equal_i(2, s_graphics_fill_radial_precise... | rocky_api_graphics_get_gcontext() | ->draw_state.fill_color = GColorRed;
EXECUTE_SCRIPT(
"ctx.fillText('some text', 10, 10);\n"
);
cl_assert_equal_i(1, s_graphics_draw_text.call_count);
cl_assert_equal_s("some text", s_graphics_draw_text.last_call.draw_text.text);
cl_assert_equal_i(GColorRedARGB8, s_graphics_draw_text.last_call.draw_text.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... | while (required_array_len > len) {
len *= 2;
} |
return len;
}
static jerry_value_t prv_try_allocate_steps(const size_t num_steps_increment) {
const size_t required_array_len = (s_rocky_path_steps_num + num_steps_increment);
if (required_array_len <= s_rocky_path_steps_array_len) {
goto success;
}
const size_t new_array_len = prv_get_realloc_array_len... |
n, LayoutIdWeather, &pin_attr_list,
HealthCardType_Sleep, num_responses, response_items);
kernel_free(response_items);
kernel_free(time_range);
kernel_free(end_time);
kernel_free(start_time);
kernel_free(short_subtitle);
kernel_free(elapsed);
i18n_free_all(&pin_attr_list);
attribute_list_destroy_... | (ActivitySettingsKeyInsightSleepSummaryState, &s_sleep_pin_state,
sizeof(s_sleep_pin_state)) | ;
}
// -----------------------------------------------------------------------------------------
static void prv_do_sleep_summary(time_t now_utc) {
if (!s_sleep_summary_settings.enabled) {
return;
}
// Don't bother adding a summary if we don't have any history for an average
if (s_sleep_stats.total_days =... |
/*
* 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_transport_create(TransportDestinationSystem, NULL, NULL) | |
/*
* 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... | (&in_stream) | ;
if (code == 0) {
// end of stream
break;
} else if (code == 1) {
// literal escape byte
prv_byte_stream_write(&out_stream, escape);
} else {
// a sequence of zeros
uint16_t count;
if ((code & 0x80) == 0) {
// the count is only 1 byte (1-127)
count ... |
manager.h"
// Stubs
#include "stubs_analytics.h"
#include "stubs_bootbits.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_passert.h"
#include "stubs_print.h"
#include "stubs_prompt.h"
#include "stubs_queue.h"
#include "stubs_serial.h"... | (&s_font_cache, 'a', &s_font_info) | ;
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(a_glyph_data_bytes, glyph->data, glyph_size_bytes);
glyph = text_resources_get_glyph(&s_font_cache, 'b', &s_font_info);
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(b_glyph_data_bytes, glyph->data, glyph_size_bytes);
... |
0);
uint8_t buf[rd_len];
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
pfs_close(fd);
fd = pfs_open("newfile", OP_FLAG_READ, 0, 0);
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == rd_len);
rv = pfs_read(fd, buf, 1);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, 0, FSeekSet);
... | (pfs_read(fd, b, sz) == sz) | ;
for (int j = 0; j < large_file_size / 4; j++) {
uint32_t *val = ((uint32_t *)((uint8_t *)b)) + j;
cl_assert(*val == (curr | (curr << 16)));
curr++;
}
cl_assert(pfs_close(fd) == S_SUCCESS);
free(b);
}
}
void test_pfs__file_span_regions(void) {
pfs_format(false /* write erase he... |
ll running, fast-foward to 300ms from the end
if (animation_is_scheduled(s_animation)) {
uint32_t duration = animation_get_duration(s_animation, true, true);
animation_set_elapsed(s_animation, duration - 300);
APP_LOG(APP_LOG_LEVEL_INFO, "Advancing to 300ms from the end of %d ms", (int)duration);
retu... | layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_text_layer_b)) | ;
// Animate text layer a from top-left to bottom right and back
PropertyAnimation *a = property_animation_create_layer_frame(
text_layer_get_layer(s_text_layer_a), &from_rect_a, &to_rect_a);
animation_set_duration((Animation*)a, DURATION);
PropertyAnimation *a_rev = property_animat... |
4, 72, -80},
{ 1104, 80, -32},
{ 872, 128, -184},
{ 832, 184, -160},
{ 920, 176, -56},
{ 1040, 192, -32},
{ 1088, 264, -120},
{ 928, 312, -176},
// 57 seconds
{ 1200, 320, -48},
{ 1264, 512, -24},
{ 1144, 832, 16},
{ 1216, 232, -152},
{ 824, 104, -24},
{ 1088, 256... | { 1448, 320, -200},
{ 1248, 296, -208},
{ 1176, 48, -56},
{ 992, 16, 16},
{ 816, 120, -320},
{ 752, 264, -120},
{ 872, 200, 128},
{ 992, 240, 24},
{ 960, 264, -32},
{ 984, 240, 8},
{ 1464, 368, 24},
{ 1072, 728, 224},
{ 1312, 536, -160},
{ 1088, 184, -80},
{ 1... |
{ 1144, 248, -128},
{ 1008, 352, -80},
{ 1088, 392, 0},
{ 1352, 376, 32},
{ 1208, 248, 48},
{ 1136, 120, 144},
{ 1184, -8, 128},
{ 1216, -32, 24},
{ 1112, 24, 0},
{ 968, 56, 32},
{ 1080, 8, 80},
{ 1144, 40, 56},
{ 872, 24, 0},
{ 976, 24, -72},
{ 1144, -24, -8... |
// Normally a reboot reason would be set before initiating a core dump. In
// case this isn't true, set a default reason so that we know the reboot was
// because of a core dump.
RebootReason reason;
reboot_reason_get(&reason);
if (reason.code == RebootReasonCode_Unknown) {
reason = (RebootReason) { R... | prv_flash_write_bytes(&chunk_hdr, s_flash_addr,
sizeof(chunk_hdr)) | ;
s_flash_addr += prv_flash_write_bytes(&s_saved_registers.extra_reg,
s_flash_addr, chunk_hdr.size);
// Write out each of the thread chunks ----------------------------------
// Note that we leave the threads for last just in case we encounter corrupted FreeRTOS structures... |
e-enter here - it likely means we encountered an
// exception during the core dump
if (s_core_dump_initiated) {
prv_debug_str("CD: re-entered");
prv_reset();
}
s_core_dump_initiated = true;
s_core_dump_is_forced = is_forced;
if (is_forced) {
RebootReason reason = { RebootReasonCode_ForcedCoreDu... | cd_flash_init() | ;
// If there is a fairly recent unread core image already present, don't replace it. Once it is read through
// the get_bytes_protocol_msg_callback(), the unread flag gets cleared out.
uint32_t flash_base;
flash_base = prv_flash_start_address(false /*new*/);
if (!s_core_dump_is_forced && flash_base != CORE_... |
{ return NULL; } |
bool notification_layout_verify(bool existing_attributes[]) { return false; }
#endif
TimelineResourceId notification_layout_get_fallback_icon_id(TimelineItemType item_type) {
return (item_type == TimelineItemTypeNotification) ? NOTIF_FALLBACK_ICON :
REMINDER_F... | |
_prev(ListNode* node) {
if (node == NULL) {
return NULL;
}
return node->prev;
}
ListNode* list_get_tail(ListNode* node) {
if (node == NULL) {
return NULL;
}
while (node->next != NULL) {
node = node->next;
}
return node;
}
ListNode* list_get_head(ListNode* node) {
if (node == NULL) {
... | if (list_a == NULL) {
return head_b;
} |
if (head_a == head_b) {
// list b is already in list a!
return head_a;
}
ListNode *tail_a = list_get_tail(list_a);
head_b->prev = tail_a;
tail_a->next = head_b;
return head_a;
}
void list_foreach(ListNode *head, ListForEachCallback each_cb, void *context) {
if (!each_cb) {
return;
}
... |
nts.h"
#include "kernel/util/sleep.h"
#include "kernel/util/stop.h"
#include "os/mutex.h"
#include "os/tick.h"
#include "services/common/system_task.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/profiler.h"
#include "util/circular_buffer.h"
#define STM32F4_COMPATIBLE
#define STM32F7_COMPA... | (&DFSDM_FilterInitStruct) | ;
DFSDM_FilterInitStruct.DFSDM_SincOrder = sinc_order;
DFSDM_FilterInitStruct.DFSDM_FilterOversamplingRatio = oversampling_ratio;
DFSDM_FilterInitStruct.DFSDM_IntegratorOversamplingRatio = 1;
DFSDM_FilterInit(this->filter, &DFSDM_FilterInitStruct);
DFSDM_ConfigClkOutputSource(DFSDM_ClkOutSource_SysClock);
... |
368, 720, -544},
{ 376, 712, -552},
{ 384, 704, -496},
{ 392, 720, -552},
{ 384, 704, -568},
// 66 seconds
{ 392, 672, -584},
{ 392, 696, -584},
{ 392, 672, -608},
{ 384, 536, -664},
{ 432, 688, -680},
{ 472, 520, -680},
{ 400, 312, -752},
{ 424, 256, -760},
{ 424... | { 416, 664, -552},
{ 408, 672, -560},
{ 408, 696, -552},
{ 416, 696, -552},
{ 416, 704, -544},
{ 416, 680, -552},
{ 408, 688, -552},
{ 416, 696, -552},
{ 416, 696, -552},
{ 416, 688, -544},
{ 424, 704, -552},
{ 416, 664, -560},
{ 416, 696, -552},
{ 416, 696, -544}... | |
ent *e, void *context) {
ActionResultData *data = (ActionResultData *)context;
if (e->sys_notification.type != NotificationActionResult) {
// Not what we want
return;
}
PebbleSysNotificationActionResult *action_result = e->sys_notification.action_result;
if (action_result == NULL ||
(data->re... | if (!data) {
return NULL;
} |
data->action_menu = action_menu;
data->chaining_data.notif = timeline_item_copy((TimelineItem *)pin);
const bool ignore_failures = false;
prv_subscribe_to_action_results_and_timeouts(data, ignore_failures);
if (action_menu) {
TimelineActionMenu *timeline_action_menu = action_menu_get_context(action_me... |
, window->layer.bounds.size.w - PBL_IF_RECT_ELSE(ACTION_BAR_WIDTH, 0),
STATUS_BAR_LAYER_HEIGHT));
status_bar_layer_set_colors(&s_phone_ui_data->status_bar,
PBL_IF_COLOR_ELSE(GColorClear, GColorWhite),
GColorBlack);
layer_add_child(... | {
actions |= PhoneCallActions_Answer;
} |
prv_action_bar_setup(actions);
prv_start_ringing();
}
void phone_ui_handle_outgoing_call(PebblePhoneCaller *caller) {
if (s_phone_ui_data) {
// In this case we are waiting to pop the window and a new event has come in.
// Pop it immediately and then set up for the new event
prv_window_pop();
}
... |
==================================================================================
// Support for capturing activity sessions detected by the algorithm
typedef struct {
uint16_t steps;
uint32_t resting_calories;
uint32_t active_calories;
uint32_t distance_mm;
} KAlgTestActivityMinute;
#define MAX_CAPTURED_SESS... | ("\n\n========================================================") | ;
printf("\nRunning sample set: \"%s\"\n", entry->name);
// Run the step algorithm
int minute_data_len = 100;
TestMinuteData minute_data[minute_data_len];
prv_stats_reinit();
int steps = prv_feed_kalg_samples(entry->samples, entry->num_samples, minute_data,
... |
ing(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
activity_metrics_prv_reset_hr_stats();
cl_assert_equal_b(prv_is_hr_elevated(), false);
activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes);
cl_assert_equal_i(zone1_minutes, 0);
activity_get_metric(ActivityMetricH... | rtc_set_time(utc_sec) | ;
prv_minute_system_task_cb(NULL);
cl_assert_equal_b(prv_is_hr_elevated(), true); // stays elevated
activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes);
cl_assert_equal_i(zone1_minutes, 0);
activity_get_metric(ActivityMetricHeartRateZone2Minutes, 1, &zone2_minutes);
cl_assert_equal_i... |
/*
* 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 (font == fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)) {
font_height = 18;
} else if (font == fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)) {
font_height = 14;
} | |
/
layer_remove_from_parent(&child_a);
cl_assert(parent.first_child == &child_c);
cl_assert(child_c.parent == &parent);
cl_assert(child_a.parent == NULL);
cl_assert(child_a.next_sibling == NULL);
cl_assert(grand_child_a.parent == &child_a);
// Return early when (parent->paren == NULL):
layer_remove_from... | (aa, stack[1]) | ;
cl_assert_equal_p(aaa, stack[2]);
// go to child if possible
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaaa, actual);
cl_assert_equal_i(3, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1]);
cl_... |
/*
* 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... | (&window, &s_ctx) | ;
}
// Tests
//////////////////////
void test_health_sleep_summary_card__render_no_data(void) {
prv_create_card_and_render(&(HealthData) {});
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_sleep_summary_card__render_no_typical(void) {
HealthData health_data = {
.monthly_sle... |
, -184},
{ 1472, 592, 8},
{ 1872, 752, 184},
{ 1920, 368, 176},
{ 1536, 104, 64},
{ 1304, 24, 144},
{ 1216, 96, 64},
{ 1112, 160, 8},
{ 936, 232, -56},
{ 936, 128, 24},
{ 896, 48, -8},
{ 704, 24, -144},
{ 960, 40, 24},
{ 1232, 176, -8},
{ 1552, 240, -160},
// ... | { -160, -128, -664},
{ -56, -24, -696},
{ 32, -16, -768},
{ 304, -96, -752},
{ 584, -216, -496},
{ 808, -8, 0},
{ 1544, 288, 248},
{ 2488, 768, 48},
{ 2392, 960, -16},
{ 1976, 576, 144},
{ 1448, 560, -288},
{ 1280, 392, -232},
{ 1224, 472, 184},
{ 1208, 304, 288},... |
{ 1016, 392, 0},
{ 1104, 472, 0},
{ 1304, 616, 72},
{ 912, 848, 40},
{ 1304, 928, -256},
{ 1208, 496, -128},
// 16 seconds
{ 960, 456, -120},
{ 1384, 592, -40},
{ 1936, 720, -88},
{ 2024, 424, 376},
{ 1248, -344, 320},
{ 992, -152, 136},
{ 912, 56, 56},
{ 920... |
h"
#include "kernel/pebble_tasks.h"
#include "services/common/bluetooth/bluetooth_ctl.h"
#include "services/common/bluetooth/bluetooth_persistent_storage.h"
#include "services/common/bluetooth/local_addr.h"
#include "services/common/bluetooth/pairability.h"
#include "services/common/regular_timer.h"
#include "services/... | {
bt_pairability_use();
s_pairable_due_to_no_gateway_bondings = true;
} |
} else {
if (s_pairable_due_to_no_gateway_bondings) {
bt_pairability_release();
s_pairable_due_to_no_gateway_bondings = false;
}
}
}
void bt_pairability_init(void) {
bt_pairability_update_due_to_bonding_change();
prv_schedule_evaluation();
}
|
memcmp(header, s_active_header, REGISTRY_HEADER_SIZE_BYTES) | == 0;
}
static uint32_t get_next_cursor_position(uint32_t old_address, Registry* registry) {
const uint32_t new_address =
round_up_to_nearest_subsector(old_address + registry->total_buffer_size_bytes);
const bool is_space_for_registry =
new_address + registry->total_buffer_size_bytes < registry->curs... | |
/*
* 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, sizeof(msg)) | |
S,
* 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 <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "clar.h"
#include "drivers/system_flash.... | {
int countdown = 3;
cl_assert(!system_flash_erase(FLASH_BASE, 512 KiB, error_in_middle_cb,
&countdown));
cl_assert(flash_locked);
cl_assert_(countdown <= 0, "Callback not called enough times");
} |
void malloc_flash_data(uint32_t size) {
flash_data_length = size;
flash_written_data = malloc(size * sizeof(uint8_t));
cl_assert(flash_written_data);
flash_written_flag = malloc(size * sizeof(bool));
cl_assert(flash_written_flag);
}
void assert_flash_unwritten(uint32_t start, uint32_t length) {
for (uin... |
(iter_state.fd, iter_state.header.payload_length, FSeekCur) | ;
if (result < 0) {
break;
}
}
kernel_free(payload);
prv_file_close(fd);
return rv;
}
void notification_storage_rewrite(void (*iter_callback)(TimelineItem *notification,
SerializedTimelineItemHeader *header, void *data), void *data) {
PBL_ASSERTN(s_notif_storage_mutex != NULL);
if (i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.