prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
nitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
if (board_has_chg_fast()) {
gpio_use(BOARD_CONFIG_POWER.chg_fast.gpio);
GPIO_Init... | event_put(&event) | ;
}
void battery_set_charge_enable(bool charging_enabled) {
periph_config_acquire_lock();
prv_battery_set_charge_enable(charging_enabled);
periph_config_release_lock();
}
void battery_set_fast_charge(bool fast_charge_enabled) {
periph_config_acquire_lock();
prv_battery_set_fast_charge(fast_charge_enabled);
... |
/*
* 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... | (0b00010000, BITS_BETWEEN(4, 4)) | |
e->spi_first_bit);
// Write result back to CR1
bus->spi->CR1 = tmpreg;
#if MICRO_FAMILY_STM32F7
// On STM32F7 we need to set FRXTH in order to do 8-bit transfers.
// If we don't, the MCU always tries to read 16-bits even though we
// specified that the data is 8-bits.
// Why clear isn't 8-bit is beyond me,... | prv_spi_acquire_helper(slave) | |
// ----------------------------------------------------------------------------------------------
void accel_data_service_subscribe__deprecated(uint32_t samples_per_update, AccelRawDataHandler__deprecated handler) {
AccelServiceState * session = accel_service_private_get_session(PebbleTask_Unknown);
AccelServiceSt... | kernel_malloc_check(sizeof(AccelServiceState)) | ;
*state = (AccelServiceState) {
.sampling_rate = ACCEL_DEFAULT_SAMPLING_RATE,
.accel_shake_info = {
.type = PEBBLE_ACCEL_SHAKE_EVENT,
.handler = &prv_session_do_shake_handle,
.context = state,
},
.accel_double_tap_info = {
.type = PEBBLE_ACCEL_DOUBLE_TAP_EVENT,
... |
rWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_wrap_y-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test src_origin_offset, shouldn't see any red in dest_bitmap.
// This covers src_origin_offset, y-axis and x-axis wraparound.
// Setup:
// - Source 25x25, 2 columns, 2 rows red, rest ... | (src_bitmap) | ;
cl_assert_equal_i(src_bitmap->info.format, GBitmapFormat1Bit);
uint8_t dest_data[bounds.size.w * bounds.size.h];
GBitmap dest_bitmap = {
.addr = dest_data,
.row_size_bytes = bounds.size.w,
.info.format = GBitmapFormat8Bit,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = src_bitmap->boun... |
ody uses these variables outside of the block
// when dealing with round displays, sizes change depending on location.
const GRect probe_rect = GRect(x, y + text_single_line_text_offset_px,
w, max_text_line_height_px);
const uint16_t text_height = graphics_text_layout_get_... | (dialog, icon, GPoint(x, y), true) | ) {
layer_add_child(window_root_layer, &dialog->icon_layer.layer);
}
dialog_load(&actionable_dialog->dialog);
}
static void prv_actionable_dialog_appear(Window *window) {
ActionableDialog *actionable_dialog = window_get_user_data(window);
Dialog *dialog = actionable_dialog_get_dialog(actionable_dialog);
... |
MAX_NUM_COLS + 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 7), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 11), 3);
graphics_draw_horizontal_line_dotted(&ctx, GP... | GPoint(9, 0) | , 2);
graphics_draw_vertical_line_dotted(&ctx, GPoint(11, 0), 3);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 0), 4);
graphics_draw_vertical_line_dotted(&ctx, GPoint(15, 0), 20);
graphics_draw_vertical_line_dotted(&ctx, GPoint(17, 0), 21);
graphics_draw_vertical_line_dotted(&ctx, GPoint(19, 0), 22);
... |
/*
* 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 (!transcription ||
(size <= sizeof(Transcription)) ||
(transcription->type != TranscriptionTypeSentenceList)) {
return false;
} |
uint8_t *end = (uint8_t *)transcription + size;
uint8_t *cursor = NULL;
const TranscriptionSentence *sentence = transcription->sentences;
for (size_t i = 0; i < transcription->sentence_count; i++) {
cursor = (uint8_t *) sentence->words;
// Check that sentence header fits into buffer and length is v... |
le its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
// Reset the median
activity_metrics_prv_reset_hr_stats();
// Our previous median should be since we have no data
int32_t last_median;
int32_t last_update_utc;
activity_get_metric(Activ... | cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.quality, HRMQuality_OffWrist) | ;
// Should fire off an event. OffWrist, tell clients
prv_advance_time_hr(1 /*sec*/, 0 /*hr*/, HRMQuality_OffWrist, true /*force_continuous*/);
cl_assert_equal_i(s_num_hr_events, 3);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 0);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_up... |
event)
if (button_is_held_down) {
context->num_presses_remaining--;
}
if (context->num_presses_remaining > 0) {
// Toggle the state of the button
context->button_is_held_down = !button_is_held_down;
// Restart the timer
new_timer_start(s_console_button_timer, next_timeout_ms, command_button_p... | (s_console_button_timer, 0,
command_button_press_callback, new_timer_context,
0 /* flags */) | |
ror(void) {
prv_global_init_and_set_ctx();
EXECUTE_SCRIPT_EXPECT_ERROR(
"ctx.rockyFillRadial(30, 40, 10, 20, 0, false);\n",
"TypeError: Argument at index 5 is not a Number"
);
}
void test_rocky_api_graphics__fill_radial_range_check(void) {
prv_global_init_and_set_ctx();
EXECUTE_SCRIPT_EXPECT_ER... | EXECUTE_SCRIPT("ctx.restore()\n") | ;
cl_assert_equal_i(1, s_context.draw_state.fill_color.argb);
EXECUTE_SCRIPT("ctx.save()\n"); // 1
s_context.draw_state.fill_color.argb = 2;
EXECUTE_SCRIPT("ctx.save()\n"); // 2
s_context.draw_state.fill_color.argb = 3;
EXECUTE_SCRIPT("ctx.restore()\n"); // -> 2 (one element left)
cl_assert_equal_i(2, s... |
"Select button for 2 seconds from any incoming " \
"notification.", action_menu);
ExpandableDialog *first_use_dialog = expandable_dialog_create_with_params(
"Dismiss First Use", RESOURCE_ID_QUICK_DISMISS, tutorial_msg,
gcolor_legible_ove... | i18n_get(strings[i], i18n_owner) | ;
action_menu_level_add_action(template_level, label, prv_action_menu_cb, action);
}
}
return template_level;
}
static ActionMenuLevel *prv_create_emoji_level_from_action(ActionMenuLevel *parent_level,
TimelineItemAction *action,
... |
_sleep_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 1);
// Make sure we still merge properly after a power cycle
activity_insights_init(rtc_get_time());
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR);
prv_add_sleep_session(0.5, 1.5);
activity_insights_process_sleep_data(rtc_get_time());
... | {
// PBL-36355 Disable nap notifications
// Enable this unit test when re-enabling nap session notifications
#if 0
prv_set_sleep_history_avg();
activity_insights_init(rtc_get_time());
// Common metrics
s_data.metric_history[ActivityMetricSleepState][0] = ActivitySleepStateAwake;
s_data.metric_history[Act... |
// Make sure that when the watch resets, we retain state properly
void test_activity_insights__walk_session_power_cycle(void) {
activity_insights_init(rtc_get_time());
// Common metrics
s_data.metric_history[ActivityMetricSleepState][0] = ActivitySleepStateAwake;
s_data.metric_history[ActivityMetricSleepState... |
criptions_handle_server_notification(s_connection, s_handle,
value, 1 /* one byte */);
// Data will be dropped, no event :(
prv_assert_no_event();
// Receive another GATT notification. Won't fit until consumed.
// Consuming is happening before the timeout ... | cl_assert_equal_i(header.characteristic, BLE_CHARACTERISTIC_INVALID) | ;
cl_assert_equal_b(has_more, false);
BLECharacteristic characteristic_out = ~0;
uint8_t value = 0xff;
value_length = sizeof(value);
gatt_client_subscriptions_consume_notification(&characteristic_out, &value, &value_length,
GAPLEClientKernel, &has_more);
// ... |
/*
* 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... | sys_get_current_resource_num() | , (uint32_t)h);
}
size_t applib_resource_load(ResHandle h, uint8_t *buffer, size_t max_length) {
return sys_resource_load_range(sys_get_current_resource_num(),
(uint32_t)h, 0, buffer, max_length);
}
size_t applib_resource_load_byte_range(
ResHandle h, uint32_t start_offset, uint... |
r(Window *window) {
NotificationsData *data = window_get_user_data(window);
prv_update_text_layer_visibility(data);
}
static void prv_window_disappear(Window *window) {
NotificationsData *data = window_get_user_data(window);
prv_loaded_notification_list_deinit(data->loaded_notification_list);
data->loaded_n... | {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
} |
#else
static void prv_s_main(void) {}
#endif
const PebbleProcessMd* notifications_app_get_info() {
static const PebbleProcessMdSystem s_app_md = {
.common = {
.main_func = prv_s_main,
// UUID: b2cae818-10f8-46df-ad2b-98ad2254a3c1
.uuid = {0xb2, 0xca, 0xe8, 0x18, 0x10, 0xf8, 0x46, 0xdf,
... |
if (rx_index == sizeof(core_dump_connect_ping)) {
if (memcmp(buffer, core_dump_connect_ping, sizeof(core_dump_connect_ping)) == 0) {
// Handshake received. Switch to tx mode.
hw_spi_change_fifo_mode(s_spi->bus_id, HW_SPI_FIFO_TX_ONLY);
rx_mode = false;
tx_i... | prv_send_response((uint8_t *)&DIALOG_BUILD_ID, BUILD_ID_TOTAL_EXPECTED_LEN) | ;
break;
case CoreDumpCmd_ReadRegionTable:
printf("region table\n");
prv_send_response((uint8_t *)s_MemoryRegions, sizeof(s_MemoryRegions));
break;
case CoreDumpCmd_ReadMemory: {
printf("read memory %p %d\n", cmd.addr, cmd.len);
prv_send_response(cmd.addr, c... |
urn (s_ble_hrm_subscription_count > 0);
}
typedef struct {
BTDeviceInternal *next_permitted_device;
size_t slots_left;
} CopySharingDevicesCtx;
static void prv_copy_sharing_devices_for_each_connection_cb(GAPLEConnection *connection,
void *data) {
Cop... | {
// Reschedule to show again after BLE_HRM_REMINDER_POPUP_DELAY_MINS
prv_reschedule_popup_timer();
} |
bt_unlock();
ble_hrm_push_reminder_popup();
analytics_event_ble_hrm(BleHrmEventSubtype_SharingTimeoutPopupPresented);
PBL_LOG(LOG_LEVEL_INFO, "BLE HRM sharing timeout fired!");
}
//! @note executes on timer task
static void prv_reminder_popup_timer_cb(void *unused) {
prv_execute_on_kernel_main(prv_push_re... |
_set_pause_button(WorkoutActiveWindow *active_window) {
bool can_stop = active_window->workout_controller->stop != NULL;
if (can_stop || active_window->num_scrollable_metrics > 1) {
active_window->pause_button = BUTTON_ID_UP;
} else {
active_window->pause_button = BUTTON_ID_SELECT;
}
}
T_STATIC void pr... | layer_add_child(&active_window->base_layer, &active_window->top_metric_layer) | ;
GRect scrollable_metric_bounds = top_metric_bounds;
scrollable_metric_bounds.origin.y = scrollable_metric_bounds.size.h;
scrollable_metric_bounds.size.h = window->layer.bounds.size.h -
scrollable_metric_bounds.origin.y;
layer_init(&active_window->scrollable_metri... |
/*
* 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... | dbgserial_print(":") | ;
dbgserial_print_hex(line_number);
if (fmt) {
dbgserial_print(" ");
dbgserial_print(fmt);
}
dbgserial_putstr("");
reset_due_to_software_failure();
}
static __attribute__((noreturn)) void handle_passert_failed(const char* filename, int line_number,
uintptr_t lr, const char *expr, const char* fmt... |
00:02:00)
rtc_set_time(event_time + (2 * SECONDS_PER_MINUTE));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("2 minutes ago", time_buf);
// June 9th 2015, 15:00:00 (T-01:00:00)
rtc_set_time(event_time - (1 * SECONDS_PER_HOUR));
clock_get_until_time(time_b... | ("Jun 10", time_buf) | |
ad_sender_version: major: %"PRIu32", minor: %"PRIu32", patch: %s",
s_parsed_msg.payload_sender_v_major, s_parsed_msg.payload_sender_v_minor, s_parsed_msg.payload_sender_version_patch);
LOG("payload_send_time: %"PRIu32"", s_parsed_msg.payload_send_time);
LOG("MeasurementSet:");
char uuid_str[UUID_STR... | LOG(" Activity Type: %d, Start Reason: %d", session->type.type.internal_type,
session->start_reason) | ;
// TODO: Add more detailed logging
}
}
}
return &s_parsed_msg;
}
// ---------------------------------------------------------------------------------------------
static void prv_assert_msg_equal(TestPLParsedMsg *a, TestPLParsedMsg *b) {
// Payload Specific
cl_assert_equal_s(a->payload_send... |
adings_buf_size);
const int values_buf_size = 128;
StringList *values = kernel_zalloc_check(values_buf_size);
if (session->type == ActivitySessionType_Run) {
type = ActivityInsightType_ActivitySessionRun;
icon = TIMELINE_RESOURCE_RUN;
prv_add_metric_duration_info(headings, headings_buf_size, value... | prv_save_state(ActivitySettingsKeyInsightActivitySessionTime,
&s_session_pin_state.start_utc,
sizeof(s_session_pin_state.start_utc)) | ;
if (s_activity_session_settings.session.show_notification) {
activity_insights_push_activity_session_notification(now_utc, session, 0, NULL);
}
}
// ------------------------------------------------------------------------------------------------
void prv_process_activity_sessions(time_t now_utc) {
uint32_... |
l_assert_equal_i(s_path_fill_count, 2);
cl_assert_equal_i(s_circle_stroke_count, 1);
cl_assert_equal_i(s_circle_fill_count, 1);
prv_reset();
gdraw_command_list_get_command(command_list, 2)->hidden = true;
gdraw_command_list_draw(ctx, command_list);
cl_assert_equal_i(s_path_stroke_count, 1);
cl_assert_equ... | gdraw_command_list_get_command(command_list, 0) | |
though, so it's not the end of the world.
prv_put_notification_action_result(&item->header.id, i18n_get("Dismissed", &i18n_key),
TIMELINE_RESOURCE_RESULT_DISMISSED, ActionResultTypeSuccess);
}
static void prv_perform_ancs_negative_action(const TimelineItem *item,
... | modal_manager_get_window_stack(ModalPriorityNotification) | ;
window_stack_pop_all(window_stack, true /* animated */);
}
event_service_client_unsubscribe(&ctx->event_info);
kernel_free(ctx);
}
void timeline_invoke_action(const TimelineItem *item, const TimelineItemAction *action,
const AttributeList *attributes) {
char uuid_buffer[UUID_... |
/*
* 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, GPoint(mask, offset)) | ;
graphics_draw_pixel(ctx, GPoint(offset, mask));
// Top-right quadrant
graphics_draw_pixel(ctx, GPoint(mask, layer->bounds.size.h - offset - 1));
graphics_draw_pixel(ctx, GPoint(layer->bounds.size.w - offset - 1, mask));
// Bottom-left quadrant
graphics_draw_pixel(ctx, GPoint(layer->bounds.size... |
_intensity_get_selection_index();
const OptionMenuCallbacks callbacks = {
.select = prv_intensity_menu_select,
};
const char *title = PBL_IF_RECT_ELSE(i18n_noop("INTENSITY"), i18n_noop("Intensity"));
settings_option_menu_push(
title, OptionMenuContentType_SingleLine, index, &callbacks, ARRAY_LENGTH(s_... | {
subtitle = i18n_noop("On");
} | else {
subtitle = i18n_noop("Off");
}
break;
case SettingsDisplayMotionSensor:
title = i18n_noop("Motion Enabled");
if (backlight_is_motion_enabled()) {
subtitle = i18n_noop("On");
} else {
subtitle = i18n_noop("Off");
}
break;
case SettingsDisp... |
/*
* 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... | alerts_preferences_set_vibrate(enable) | ;
}
void alerts_set_mask(AlertMask mask) {
alerts_preferences_set_alert_mask(mask);
}
void alerts_set_dnd_mask(AlertMask mask) {
alerts_preferences_dnd_set_mask(mask);
}
void alerts_set_notification_vibe_timestamp() {
// if we do vibrate, update timestamp of last vibration
s_notification_vibe_tick_timestamp ... |
form_set_from_frame(reel, screen_frame);
kino_reel_transform_set_to_frame(reel, screen_frame);
kino_reel_transform_set_global(reel, true);
} else {
prv_destructor(data);
}
return reel;
}
void kino_reel_scale_segmented_set_delay_lookup_creator(
KinoReel *reel, GPointIndexLookupCreator creator, voi... | grect_center_point(&frame) | , SCALE_SEGMENTED_DOT_SIZE });
const Fixed_S16_3 to = Fixed_S16_3((2 * radius) << FIXED_S16_3_PRECISION);
kino_reel_scale_segmented_set_to_stroke_width(reel, to, GStrokeWidthOpSet);
kino_reel_scale_segmented_set_stroke_width_curve(reel, prv_ease_in_out_last_half);
}
|
e to kill, we're done
if (context->safe_to_kill) {
prv_handle_app_stop_analytics(context, task, gracefully);
return true;
}
PBL_LOG(LOG_LEVEL_DEBUG, "make %s process safe to kill: state %u", pebble_task_get_name(task),
context->closing_state);
if (gracefully) {
if (co... | (task, true) | ;
// Better to die in our sleep ...
vTaskSuspend(NULL /* self */);
// We don't expect someone to resume us.
PBL_CROAK("");
}
// ---------------------------------------------------------------------------------------------
// Get the args for the current process
const void *process_manager_get_current_proces... |
mutex_lock(s_attr_list_lock);
const bool exists = (prv_find_by_ids(service_id, attribute_id) || prv_find_by_buffer(buffer));
mutex_unlock(s_attr_list_lock);
if (exists) {
PBL_LOG(LOG_LEVEL_ERROR, "Attribute already exists (0x%x,0x%x)", service_id, attribute_id);
return false;
}
SmartstrapAttribut... | if (attr->write_blocked || !prv_start_transaction(attr, AttributeTransactionBeginWrite)) {
return SmartstrapResultBusy;
} |
// clear the write buffer
memset(mbuf_get_data(&attr->mbuf), 0, mbuf_get_length(&attr->mbuf));
return SmartstrapResultOk;
} else if (type == SmartstrapRequestTypeRead) {
// handle read request
if (!prv_start_transaction(attr, AttributeTransactionRead)) {
return SmartstrapResultBusy;
}
... |
/*
* 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 "TextLayer";
} | else if (layer->update_proc == (LayerUpdateProc) action_bar_update_proc) {
return "ActionBarLayer";
} else if (layer->update_proc == (LayerUpdateProc) bitmap_layer_update_proc) {
return "BitmapLayer";
} else if (layer->update_proc == (LayerUpdateProc) inverter_layer_update_proc) {
return "InverterLayer... |
e(jan_1);
cl_assert_equal_i(clock_to_timestamp(MONDAY, 17, 30), mktime(&jan_6));
}
void test_clock__clock_to_timestamp(void) {
s_prefs_24h_style = false;
fake_rtc_init(0, 0);
rtc_timezone_clear();
static const time_t jan1st_noon_2005 = 1104580800;
static const int32_t min_gmtoff = -12 * SECONDS_PER_HOUR;
... | (time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("Wed, 2:00 PM", time_buf);
// June 9th 2015, 14:00:00 (T-24:00:00)
rtc_set_time(event_time - (24 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Wed, 2:00 PM", time_buf);
// June 9th 2015, 23:59:58 (... |
TRIBUTES] = {0};
const size_t header_len = sizeof(GetNotificationAttributesMsg);
bool error = false;
const bool complete = ancs_util_get_attr_ptrs(s_sms_ancs_data + header_len,
ARRAY_LENGTH(s_sms_ancs_data) - header_len,
... | (s_group_sms_ancs_data) | - header_len,
s_fetched_notif_attributes,
NUM_FETCHED_NOTIF_ATTRIBUTES,
notif_attributes,
&error);
cl_assert(complete);
cl... |
schedule(a);
// Seek to just after the end of the second A
prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS);
#endif
}
// --------------------------------------------------------------------------------------
// Test creating a sequence where the first argument is already schedule... | prv_last_handler_entry(&s_started_handler_calls, 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... | {
return !flash_sanity_check();
} | |
pp_install_get_id_for_uuid(&sports_uuid);
cl_assert_equal_i(-69, tictoc_id);
cl_assert_equal_i(-3, music_id);
cl_assert_equal_i(-53, sports_id);
// load system resources
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false);
load_resource_fixture_in_flash(RESOURCES_F... | cl_assert_equal_b(false, app_install_is_watchface(music_id)) | ;
cl_assert_equal_b(false, app_install_is_watchface(sports_id));
cl_assert_equal_b(false, app_install_is_watchface(bg_counter_id));
cl_assert_equal_b(false, app_install_is_watchface(menu_layer_id));
cl_assert_equal_b(false, app_install_is_watchface(CRAZY_ID));
}
void test_app_install_manager__is_watchface_via... |
his can happen for glance entries sent to us by the mobile apps because they don't have a way
// of knowing the max number of slices supported by the firmware, and so they send us as many
// slices as they can fit in a BlobDB packet. We just take as many slices as we support and trim
// the excess.
if (validati... | {
return rv;
} |
if (settings_file_exists(&s_app_glance_db.settings_file, key, (size_t)key_len)) {
rv = settings_file_delete(&s_app_glance_db.settings_file, key, (size_t)key_len);
} else {
rv = S_SUCCESS;
}
prv_close_file_and_unlock_mutex();
return rv;
}
/////////////////////////
// Testing code
////////////////... |
if (to_frame) {
animation->values.to.grect = *to_frame;
} |
return (PropertyAnimation *)animation;
}
// Helper Functions
/////////////////////
#include "../graphics/test_graphics.h"
#include "../graphics/util.h"
// Setup and Teardown
////////////////////////////////////
// To easily render multiple windows in a single canvas, we'll use an 8-bit bitmap for color
// displa... | |
n_bar_circle_frame, GOvalScaleModeFitCircle);
}
void action_bar_update_proc(ActionBarLayer *action_bar, GContext* ctx) {
const GColor bg_color = action_bar->background_color;
if (!gcolor_is_transparent(bg_color)) {
graphics_context_set_fill_color(ctx, bg_color);
PBL_IF_RECT_ELSE(prv_draw_background_rect,
... | {
if (action_bar_layer == NULL) {
return;
}
action_bar_layer_deinit(action_bar_layer);
applib_free(action_bar_layer);
} |
Layer* action_bar_layer_get_layer(ActionBarLayer *action_bar_layer) {
return &action_bar_layer->layer;
}
inline static void* action_bar_get_context(ActionBarLayer *action_bar) {
return action_bar->context ? action_bar->context : action_bar;
}
void action_bar_layer_set_context(ActionBarLayer *action_bar, void *c... |
ual_i(event.put_bytes.progress_percent, 0);
cl_assert_equal_b(event.put_bytes.failed, false);
}
void test_put_bytes__init_while_already_busy(void) {
prv_receive_init(VALID_OBJECT_SIZE, ObjectFirmware);
prv_receive_init(VALID_OBJECT_SIZE, ObjectFirmware);
assert_nack_count(1);
}
void test_put_bytes__init_too_l... | htonl(payload_size) | + 1 /* one off! */,
};
memcpy(&put_msg->payload[0], chunk, payload_size);
prv_receive_data(s_session, buffer, sizeof(buffer));
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__invalid_session_cookie(void) {
prv_receive_init_fw_object();
prv_process_and_reset_test_counters();
const u... |
if (buffer) {
if (read_offset >= logging_session->storage.write_offset) {
break;
}
}
// Read the chunk header
if (!prv_pfs_seek(logging_session->storage.fd, read_offset, FSeekSet)) {
last_whole_items_read_bytes = -1;
goto exit;
}
if (!prv_pfs_read(logging_session->... | (logging_session->storage.fd, &chunk_hdr, sizeof(chunk_hdr)) | ) {
consumed_bytes = -1; // error
goto exit;
}
if (logging_session->storage.num_bytes < chunk_hdr.num_bytes) {
PBL_LOG(LOG_LEVEL_ERROR, "Inconsistent tracking of num_bytes");
consumed_bytes = -1; // error
goto exit;
}
logging_session->storage.num_byt... |
memmove(&buffer[0], &buffer[1], rx_index);
}
}
} else { // Tx Mode
if (hw_spi_is_tx_fifo_full(s_spi->bus_id)) {
// Don't spin for too long, just in case the host doesn't clock out our response
if (!prv_timer_check_delta(tx_start_ticks, TIMER0_10_MS)) {
... | prv_send_response((uint8_t *)&s_thread_info.ti, sizeof(s_thread_info.ti)) | ;
break;
case CoreDumpCmd_ReadExtraThreadInfo:
printf("read ExtraTB\n");
prv_send_response((uint8_t *)&s_extra_info, sizeof(s_extra_info));
break;
case CoreDumpCmd_LowPowerMode:
printf("low power mode\n");
prv_low_power_mode();
break;
default:... |
0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 140, 1},
{ 0, 0x62, 0, 151, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 147, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
... | { 0, 0xc, 0, 150, 1},
{ 0, 0xc, 0, 149, 1},
{ 0, 0xc, 0, 146, 1},
{ 0, 0xc, 0, 150, 1},
{ 0, 0xc, 0, 149, 1},
{ 0, 0xc, 0, 150, 1},
{ 0, 0xc, 0, 150, 1},
{ 0, 0xc, 0, 146, 1},
// 555: Local time: 03:51:00 AM
{ 0, 0xc, 0, 150, 1},
{ 0, 0xc, 0, 150, 1},
{ 0, 0xc, 0, 150, 1}... | |
imation_h, false /*quiet*/);
if (!animation) {
return NULL;
}
return (animation->curve == curve) ? animation->custom_function : NULL;
}
// -------------------------------------------------------------------------------------------
AnimationCurveFunction animation_get_custom_curve(Animation *animation_h) {
... | prv_find_animation_by_handle(state, animation_h, false /*quiet*/) | ;
if (!animation) {
return false;
}
if (animation->play_count == ANIMATION_PLAY_COUNT_INFINITE_STORED) {
return ANIMATION_PLAY_COUNT_INFINITE;
} else {
return animation->play_count;
}
}
// -------------------------------------------------------------------------------------------
bool animation... |
// -------------------------------------------------------------------------------
// Run the minute callback enough times to cause everything that is normally periodically
// recomputed (walking rate, sleep, etc.) to be recomputed
static void prv_force_periodic_updates(void) {
for (int i = 0; i < ACTIVITY_SESSION_UP... | (LOG_LEVEL_DEBUG, "steps: %"PRId32, steps) | ;
if (steps >= 27 && steps <= 33) {
passed = true;
}
prv_test_end(context, passed);
}
// -------------------------------------------------------------------------------
static void prv_test_30_min_walk(void *context) {
bool passed = false;
activity_prefs_activity_insights_set_enabled(true);
// Rese... |
plied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "applib/data_logging.h"
#include "comm/bt_lock.h"
#include "drivers/rtc.h"
#include "os/tick.h"
#include "kernel/event_loop.h"
#include "kernel/pbl_malloc.h"
#include "ser... | dls_log(s_device_heartbeat_session, device_hb->data, 1) | ;
#ifdef ANALYTICS_DEBUG
analytics_heartbeat_print(device_hb);
#endif
kernel_free(device_hb);
AnalyticsHeartbeatList *app_hb_node = app_hbs;
while (app_hb_node) {
AnalyticsHeartbeat *app_hb = app_hb_node->heartbeat;
#ifdef ANALYTICS_DEBUG
analytics_heartbeat_print(app_hb);
#endif
dls_log(s_app_hear... |
/*
* 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... | _Static_assert(APP_GLANCE_DB_MAX_USED_SIZE <= SETTINGS_FILE_SIZE, "AppGlanceDB is too small!") | ;
static struct {
SettingsFile settings_file;
PebbleMutex *mutex;
} s_app_glance_db;
//////////////////////////////////////////
// Slice Type Implementation Definition
//////////////////////////////////////////
//! Return true if the type-specific serialized slice's attribute list is valid. You don't have to
//!... |
est_timeline__middle_backwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
// check first
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
1421183640), 0);
cl_assert(uuid_equal(&state.pin.head... | fake_pbl_malloc_num_net_allocs() | , 0);
}
static void prv_insert_all_day_items(void) {
for (int i = 0; i < ARRAY_LENGTH(s_all_day_items); i++) {
cl_assert_equal_i(pin_db_insert_item(&s_all_day_items[i]), 0);
}
}
void test_timeline__all_day_future(void) {
prv_insert_all_day_items();
Iterator iterator = {0};
TimelineIterState state = {0}... |
t_${BIT_DEPTH_NAME}__offset_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// SW = 1
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 1);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw1_no_clip.$... | graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 11);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw11_clip_xy.${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... | {
s_fault_saved_lr = (uint32_t)stacked_args[5];
s_fault_saved_pc = (uint32_t)stacked_args[6];
s_fault_saved_sp = (uint32_t)&stacked_args[8];
} |
static void prv_log_app_lr_and_pc_system_task(void *data) {
CrashInfo* crash_info = (CrashInfo*) data;
char lr_str[16];
if (crash_info->lr_known) {
sniprintf(lr_str, sizeof(lr_str), "%p", (void*) crash_info->lr);
} else {
strncpy(lr_str, "???", sizeof(lr_str));
}
char pc_str[16];
if (crash_inf... |
OUT_APP_WORKOUT_SMALL;
default:
return 0;
}
}
static ActivitySessionType prv_get_activity_type(WorkoutType workout_type) {
switch (workout_type) {
case WorkoutType_Run:
return ActivitySessionType_Run;
case WorkoutType_Walk:
return ActivitySessionType_Walk;
case WorkoutType_OpenWor... | (selection_window) | |
ounter.uuid, sizeof(Uuid),
(uint8_t *)&bg_counter, sizeof(AppDBEntry));
bg_counter_id = app_db_get_install_id_for_uuid(&bg_counter.uuid);
app_cache_add_entry(bg_counter_id, bg_counter_size /* size */);
cl_assert_equal_i(1, bg_counter_id);
// load first app
char filename_buf[32];
app_storage... | cl_assert_equal_b(false, prv_app_install_is_watchface(music_id)) | ;
cl_assert_equal_b(false, prv_app_install_is_watchface(sports_id));
cl_assert_equal_b(false, prv_app_install_is_watchface(bg_counter_id));
cl_assert_equal_b(false, prv_app_install_is_watchface(menu_layer_id));
cl_assert_equal_b(false, prv_app_install_is_watchface(CRAZY_ID));
}
void test_app_install_manager__... |
{ 1072, -88, -64},
{ 1088, -128, -48},
{ 1128, -112, -40},
{ 1144, -80, -72},
{ 1032, -80, -104},
{ 968, -80, -136},
{ 1208, -112, -160},
{ 1448, -72, -224},
{ 1304, -88, -136},
{ 944, -104, -56},
{ 744, -72, -112},
{ 1024, 0, -176},
{ 1136, 24, -88},
// 108 secon... |
{ 1168, 64, -264},
{ 848, 64, -328},
{ 808, 24, -320},
{ 1032, 0, -216},
{ 1104, -24, -112},
{ 1064, 0, -152},
{ 976, 64, -232},
{ 912, 128, -240},
{ 912, 168, -312},
{ 920, 136, -296},
{ 1000, 152, -264},
{ 960, 184, -368},
{ 928, 224, -336},
{ 880, 200, -336},
... | |
der
return (override_cmp_rv);
} else if (app_node->storage_order != new_node->storage_order) {
// Storage order (smallest first)
return prv_comparator_ascending_zero_last(app_node->storage_order, new_node->storage_order);
} else if (app_node->record_order != new_node->record_order) {
// Record order... | (sizeof(InstallData)) | ;
*install_data = (InstallData) {
.id = install_id,
.source = data_source,
.event_type = event_type,
};
process_manager_send_callback_event_to_process(PebbleTask_App,
prv_handle_app_event,
install_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... | test_graphics_context_init(&ctx, fb) | ;
// Test loading GBitmap Kino Reel
uint32_t resource_id = sys_resource_load_file_as_resource(
TEST_IMAGES_PATH, "test_kino_reel__resource_gbitmap.pbi");
cl_assert(resource_id != UINT32_MAX);
KinoReel *kino_reel = kino_reel_create_with_resource(resource_id);
cl_assert(kino_reel);
cl_assert(kino_reel... |
bscriptionNone,
GAPLEClientKernel);
}
void test_ppogatt__cleanup_client_when_meta_read_fails(void) {
fake_gatt_client_op_set_read_return_value(BTErrnoInvalidParameter);
prv_notify_services_discovered(1);
cl_assert_equal_i(ppogatt_client_count(), 0);
}
void test_... | test_ppogatt__open_session_when_found_pebble_app() | ;
// Simulate getting an Ack that's outside of the window of outstanding SNs:
prv_receive_ack(s_characteristics[0][PPoGATTCharacteristicData], PPOGATT_SN_MOD_DIV / 2);
// Expect Reset to be initiated ("Reset Request" sent by FW):
prv_assert_sent_reset_request(s_characteristics[0][PPoGATTCharacteristicData]);
}
... |
false;
static bool s_saved_corr_present = false;
static int16_t s_saved_corr[3] = { 0 };
static int32_t s_last_heading = -1; // the last heading we found
#ifdef RECOVERY_FW
static MagData s_last_mag_sample = { 0 };
#endif
//////////////////////////////////////////////////////////////////////////////////
// Calibratio... | sin_lookup(pitch) | ) / TRIG_MAX_RATIO) * sin_lookup(roll)) /
TRIG_MAX_RATIO;
mx_rot += (((mz * sin_lookup(pitch)) / TRIG_MAX_RATIO) * cos_lookup(roll)) /
TRIG_MAX_RATIO;
my_rot = mz * sin_lookup(roll) - my * cos_lookup(roll);
my_rot /= TRIG_MAX_RATIO;
int32_t heading = (atan2_lookup(-my_rot, mx_rot) + corr) % TRIG_M... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(flash_locked) | ;
}
void test_system_flash__erase_one_byte(void) {
cl_assert(system_flash_erase(FLASH_BASE, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sector(void) {
cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, N... |
_function) {
distance_normalized = animation->custom_curve_function(time_normalized);
} else {
// Just use the unchanged time if curve is AnimationCurveCustomInterpolation or there is no
// custom curve function assigned.
distance_normalized = time_normalized;
}
} else {
distance_n... | prv_get_time_normalized_raw(animation, now) | ;
bool completed = (time_normalized_raw == ANIMATION_NORMALIZED_MAX);
// Call the update procedure?
if (do_update || (completed && !animation->is_completed)) {
animation_private_update(state, animation, time_normalized_raw);
}
// If completed, either reschedule it now if it needs to be repeated or unsc... |
&GPoint(18, 5), 60, 1, true);
}
void test_touch__handle_update_merge_liftoff(void) {
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 3686380, 0);
touch_handle_update(0, TouchState_FingerDown, &GPoint(10, 10), 5, 3686400);
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
prv_te... | cl_assert_equal_i(ctx.idx, 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... | app_event_loop() | |
(file);
if (status < 0) {
return status;
}
}
int overwritten_record = -1;
// Find an existing record, if any, and mark it as overwrite-in-progress.
settings_raw_iter_resume(&file->iter);
if (search_forward(&file->iter, key, key_len)) {
set_flag(&file->iter.hdr, SETTINGS_FLAG_OVERWRITE_START... | (file, &info, context) | ) {
break;
}
settings_raw_iter_set_current_record_pos(&file->iter, file->cur_record_pos);
}
file->cur_record_pos = 0;
return S_SUCCESS;
}
typedef struct {
SettingsFileRewriteCallback cb;
SettingsFile *new_file;
void *user_context;
} RewriteCbContext;
static bool prv_rewrite_cb(SettingsFile ... |
ntcopy; \
} while (0)
#define FMT_RECURSE(FMT) do { \
i18nstr = NULL; \
cpystr = FMT; \
goto _fmt_recurse; \
} while (0)
#define FMT_RECURSE_I18N(FMT) do { \
i18nstr = FMT; \
goto _fmt_recurse; \
} while (0)
// Terrible local state for goto hell
const char *cpystr = NULL;
const char *i18nstr;
... | FMT_STRCOPY_I18N(time_locale->am_pm_downcase[0]) | ;
} else {
FMT_STRCOPY_I18N(time_locale->am_pm_downcase[1]);
}
break;
case 'R': // SU
FMT_RECURSE("%H:%M");
break;
case 'S':
FMT_INTCOPY(t->tm_sec, 2, INTFMT_PADZERO);
break;
case 'T': // SU
FMT_RECURSE("%H:%M:%S");
brea... |
de <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "clar.h"
#include "stubs_passert.h"
// Stubs
///////////////////////////////////////////////////////////
int g_pbl_log_level = 0;
void pbl_log(int level, const char* src_filename, int src_line_number, const char* fmt, ...) { }
// Tests
///////////////////... | (head == &bar2.list_node) | ;
head = list_sorted_add(head, &bar3.list_node, (Comparator) sorting_comparator, false);
cl_assert(head == &bar3.list_node);
cl_assert(list_get_tail(head) == &bar2.list_node);
head = list_sorted_add(head, &bar1.list_node, (Comparator) sorting_comparator, false);
cl_assert(head == &bar3.list_node);
cl_asse... |
b, NULL);
cl_assert_equal_i(num_restfulsleep_sessions, s_prv_activity_cb__call_count);
cl_assert_equal_b(s_prv_activity_cb__args[0].activity, HealthActivityRestfulSleep);
// respect mask for Run/Walk
s_prv_activity_cb__call_count = 0;
s_sys_activity_get_sessions_values.out.num_sessions = 7;
health_service_... | prv_session_compare(
&(ActivitySession) {.start_utc = now, .length_min = 10},
&(ActivitySession) {.start_utc = now + (2 * SECONDS_PER_MINUTE), .length_min = 5},
HealthIterationDirectionFuture) | );
// b starts earlier
cl_assert(0 < prv_session_compare(
&(ActivitySession) {.start_utc = now, .length_min = 10},
&(ActivitySession) {.start_utc = now - (2 * SECONDS_PER_MINUTE), .length_min = 5},
HealthIterationDirectionFuture));
// both end at the same time
cl_assert(0 == prv_session_compare(
... |
nders
layer_set_frame(&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... | (&data->time_data, index, -1) | ;
prv_update_range_text_layer(data);
}
// Public Functions
void time_selection_window_set_to_current_time(TimeSelectionWindowData *time_selection_window) {
struct tm current_time;
clock_get_time_tm(¤t_time);
time_selection_window->time_data.hour = current_time.tm_hour;
time_selection_window->time_data.... |
,
.handler = prv_blobdb_event_handler,
.context = data,
};
event_service_client_subscribe(&data->blobdb_event_info);
const TimelineArgs *args = process_manager_get_current_process_args();
Uuid app_uuid;
sys_get_app_uuid(&app_uuid);
if (uuid_equal(&app_uuid, &(Uuid)TIMELINE_PAST_UUID_INIT)) {
da... | {
static const PebbleProcessMdSystem s_app_md = {
.common = {
.main_func = prv_main,
.uuid = TIMELINE_PAST_UUID_INIT,
.visibility = ProcessVisibilityQuickLaunch,
},
/// The title of Timeline Past in Quick Launch. If the translation is too long, cut out
/// Timeline and only translate... | |
/*
* 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(FLASH_CONFIG.spi_gpio) | ;
}
static void prv_flash_start_cmd(void) {
gpio_use(FLASH_CONFIG.spi_gpio);
GPIO_ResetBits(FLASH_CONFIG.spi_gpio, 1 << FLASH_CONFIG.scs_pin);
gpio_release(FLASH_CONFIG.spi_gpio);
}
static void prv_flash_end_cmd(void) {
gpio_use(FLASH_CONFIG.spi_gpio);
GPIO_SetBits(FLASH_CONFIG.spi_gpio, 1 << FLASH_CONFIG.s... |
/*
* 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... | pebble_task_get_current() | == PebbleTask_Worker) {
// Not allowed from workers
syscall_failed();
}
}
return resource_size(app_num, resource_id);
}
DEFINE_SYSCALL(size_t, sys_resource_load_range, ResAppNum app_num,
uint32_t id, uint32_t start_offset, uint8_t *data, size_t num_bytes) {
if (PRIVILEGE_WAS_ELE... |
/*
* 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... | strlen(key) | ;
const int flags = 0;
const int num_attributes = 0;
const int num_actions = 1;
const int action_id = 12;
const int reply_action_attrs = 2; // Title + Emoji
uint8_t val[] = {0, 0, 0, 0, // Flags (unused for now)
num_attributes, num_actions, action_id,
TimelineItemActio... |
e_get_unobstructed_area_state()->handlers.change, prv_change);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
// Unsubscribing after subscription should cancel subscriptions
app_unobstructed_area_service_unsubscribe();
cl_assert(!app_state_get_unobstructed_area... | (area.size.h, to_area.size.h, progress) | ;
fake_event_service_handle_last();
cl_assert_equal_i(s_data.num_will_change_calls, 1);
cl_assert_equal_i(s_data.num_change_calls, 1);
cl_assert_equal_i(s_data.last_change_progress, progress);
}
void test_unobstructed_area_service__change_no_will(void) {
UnobstructedAreaHandlers handlers = {
.will_change... |
ntervalTicks after) {
int32_t result = after - before;
if (result < 0) {
result = (TICKS_IN_AN_INTERVAL - before) + after;
}
return result;
}
static void restore_rtc_time_state(void) {
// Recover the previously set time from the RTC backup registers.
RtcIntervalTicks last_save_time_ticks = RTC_ReadBack... | get_last_save_time_ticks() | , rtc_ticks) > SAVE_TIME_FREQUENCY) {
// If we didn't do this, we would have an edge case where if the watch reset
// immediately before rollover and then rolled over before we booted again,
// we wouldn't be able to detect the rollover and we'd think the saved state
// is very fresh, when really it's o... |
memcmp(r->key, key, r->key_length) | == 0)) {
return true;
}
return false;
}
static int record_get_index(const char* key, const uint8_t key_length, const uint8_t* uuid, Registry* registry) {
for (int i = 0; i < registry->num_records; i++) {
Record* r = registry->records + i;
if (r->active) {
if (record_compare(r, key, key_length... | |
// client calling `attribute_list_destroy_list()` on `attr_list_out`
Attribute *attribute_buffer = kernel_zalloc(num_attributes * sizeof(*attribute_buffer));
if (!attribute_buffer) {
PBL_LOG(LOG_LEVEL_ERROR,
"Failed to alloc memory for the buffer of Attribute's while deserializing an "
"... | if (!prv_slice_for_each(serialized_glance, serialized_glance_size,
prv_deserialize_slice, &context) ||
context.deserialization_failed) {
return E_ERROR;
} |
return S_SUCCESS;
}
//////////////////////////////////
// Slice Serialization
//////////////////////////////////
typedef struct SliceSerializationAttributeListData {
AttributeList attr_list;
size_t attr_list_size;
} SliceSerializationAttributeListData;
//! Returns S_SUCCESS if the provided glance was success... |
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, d), 1);
// Run to the completion of D
prv_advance_to_ms_with_timers(start_ms + 1300 + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, d), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_st... | animation_schedule(b) | ;
Animation *c = prv_create_test_animation();
animation_set_duration(c, duration_a);
animation_set_delay(c, delay_a);
animation_set_handlers(c, handlers, context);
animation_set_auto_destroy(c, auto_destroy);
animation_schedule(c);
prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTE... |
yout *layout = (TimelineLayout *)layout_ref;
clock_get_time_number(buffer, config->buffer_size, layout->info->pin_time);
}
static void prv_time_word_update(const LayoutLayer *layout_ref,
const LayoutNodeTextDynamicConfig *config, char *buffer,
bool re... | {
graphics_text_node_container_add_child(&vertical_node->container, time_text_node);
} |
const char *secondary_text = prv_get_secondary_text(layout);
const bool is_fat = (layout->layout_layer.mode == LayoutLayerModePinnedFat);
UNUSED const bool is_thin = (layout->layout_layer.mode == LayoutLayerModePinnedThin);
const TimelineLayoutStyle *style = prv_get_style();
const bool thin_can_have_seconda... |
/ when the mic is asleep, so the signal could float around and waste
// power if the pin is configured as a digital input.
gpio_af_configure_low_power(&this->sd_gpio);
}
static void prv_dfsdm_configure(MicDevice *this) {
const uint32_t k_max_sinc4_osr = 255;
PBL_ASSERTN(this->pdm_frequency > 0);
PBL_ASSERTN... | (this->state->mic_mutex) | ;
bool success = false;
if (this->state->running) {
goto unlock;
}
circular_buffer_init(&this->state->circ_buffer,
this->state->circ_buf_store,
DFSDM_CIRC_BUFFER_SIZE);
this->state->subscriber = (struct MicSubscriber) {
.callback = data_handler,
.b... |
tle delay so its easier to catch INT
// on logic analyzer
for (volatile int delay = 0; delay < 50; delay++) { }
while (!s_expected_bytes_received) { };
hw_gpio_set_inactive(HOST_SPI->mcu_int.port, HOST_SPI->mcu_int.pin);
}
static void prv_handle_hi_command(void) {
debug_print_str("HI CMD\n");
... | hw_gpio_configure_pin(HOST_SPI->mcu_int.port, HOST_SPI->mcu_int.pin,
HW_GPIO_MODE_OUTPUT, HOST_SPI->mcu_int.function, false) | ;
}
static void prv_configure_spi_peripheral(void) {
spi_config config = {
.cs_pad = { 0, 0 },
.word_mode = HW_SPI_WORD_8BIT,
.smn_role = HW_SPI_MODE_SLAVE,
.phase_mode = HW_SPI_PHA_MODE_0,
.polarity_mode = HW_SPI_POL_LOW,
.mint_mode = HW_SPI_MINT_DISABLE, // we are not using this feature
... |
ude "util/math.h"
#include "util/units.h"
//
// SPI bootloader protocol
//
static bool prv_load_data(uint32_t address, const uint8_t *data, size_t data_len) {
// PBL_LOG(LOG_LEVEL_DEBUG, "Loading %d bytes start at 0x%x", (int)data_len, (int)address);
uint8_t mem_write[] = {'L', 'D'};
dialog_spi_transmit_data(m... | (LOG_LEVEL_WARNING, "Failed to read fw image data") | ;
goto cleanup;
}
if (!prv_load_data(info->load_start_address + curr_send_offset, data_buf,
send_len)) {
PBL_LOG(LOG_LEVEL_WARNING, "SPI transfer to BLE chip not successful");
goto cleanup;
}
curr_send_offset += send_len;
image_size -= send_len;
}
succ... |
3. If the struct is *not* an UnpopulatedEntry, it ensures that each field is either empty
//! or written with a valid CRC.
static bool prv_valid_struct(SharedPRFData *data) {
if (data->magic == SprfMagic_UnpopulatedEntry &&
prv_buffer_empty((uint8_t *)data, sizeof(*data))) {
return true;
}
if (d... | prv_alloc_and_fetch_struct() | ;
const size_t field_data_size = SPRF_FIELD_DATA_SIZE(field_size);
const uint32_t old_crc = FIELD_CRC_FROM_DATA(data, offset);
const uint32_t new_crc = (calc_crc) ? crc32(CRC32_INIT, SPRF_FIELD_DATA(field), field_data_size)
: SPRF_UNWRITTEN_CRC;
const bool same_data =
... |
ould_vibrate_for_type(AlertOther));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertOther));
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
cl_assert(!alerts_should_vibrate_for_... | fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS) | ;
cl_assert(!alerts_should_enable_backlight_for_type(AlertReminder));
cl_assert(!alerts_should_notify_for_type(AlertOther));
cl_assert(!alerts_should_vibrate_for_type(AlertOther));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!al... |
/*
* 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... | (timestamp.minute) | ;
timestamp.minute[0] = '\0';
time_tm.tm_hour = atoi(timestamp.hour);
timestamp.T[0] = '\0';
time_tm.tm_mday = atoi(timestamp.day);
timestamp.day[0] = '\0';
time_tm.tm_mon = atoi(timestamp.month) - 1;
timestamp.month[0] = '\0';
time_tm.tm_year = atoi(timestamp.year) - STDTIME_YEAR_OFFSET;
// We have ... |
ze_t length) {
AppOutboxMessage *outbox_message = kernel_zalloc(sizeof(AppOutboxMessage) + s_service_data_size);
cl_assert(outbox_message);
outbox_message->data = data;
outbox_message->length = length;
s_outbox_message_handler(outbox_message);
}
static AppMessageAppOutboxData *prv_create_and_send_outbox_mess... | app_free(outbox_data) | ;
}
void test_app_message_sender__app_session_but_js_app(void) {
s_process_md.allow_js = true;
AppMessageAppOutboxData *outbox_data =
prv_create_and_send_outbox_message(s_app_session_ptr, ALLOWED_ENDPOINT_ID,
TEST_PAYLOAD, sizeof(TEST_PAYLOAD));
assert_consumed(AppM... |
cognizer, void *context) {
window_stack_pop(true);
}
// -------------------------------------------------------------------------------
static void results_click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_BACK, prv_results_back_click_handler);
}
// ---------------------------------... | {
if (!data->hr_card.text_layer) {
return;
}
// Get the latest heart rate
HealthValue now_bpm = health_service_peek_current_value(HealthMetricHeartRateBPM);
HealthValue resting_bpm = health_service_peek_current_value(HealthMetricRestingHeartRateBPM);
APP_LOG(APP_LOG_LEVEL_DEBUG, "Got HR data. Now: %"PRI... |
// -------------------------------------------------------------------------------
static void prv_hr_window_load(Window *window) {
HealthAPITestAppData *data = window_get_user_data(window);
Layer *window_layer = window_get_root_layer(window);
GRect root_bounds = layer_get_bounds(window_layer);
data->hr_car... |
t backlight_get_intensity(void) {
return s_backlight_intensity;
}
uint8_t backlight_get_intensity_percent(void) {
return (backlight_get_intensity() * 100) / BACKLIGHT_BRIGHTNESS_MAX;
}
void backlight_set_intensity_percent(uint8_t percent_intensity) {
PBL_ASSERTN(percent_intensity > 0 && percent_intensity <= 100... | {
Uuid uuid;
app_install_get_uuid_for_install_id(app_id, &uuid);
prv_pref_set(PREF_KEY_DEFAULT_WATCHFACE, &uuid, sizeof(uuid));
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("Scroll Demo") | );
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void handle_init(void) {
ScrollAppData *data = app_malloc_che... |
ASIS,
* 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 "mfg_bt_test_app.h"
#include "applib/app.h"
#include "applib/fonts/fonts.h"
#include "applib/ui/ui.h"
#include "applib... | (BUTTON_ID_SELECT, (ClickHandler) select_single_click_handler) | |
disturb_handle_clock_change(); // In scheduled period
active = do_not_disturb_is_active();
cl_assert(active == true); // Both ON
rtc_set_time(s_thursday_13_00);
do_not_disturb_handle_clock_change(); // Out of scheduled period
active = do_not_disturb_is_active();
cl_assert(active == false); // Both should b... | stub_new_timer_timeout(get_dnd_timer_id()) | , 1800 * MS_PER_SECOND);
rtc_set_time(s_saturday_00_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on Saturday. (0.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 1800 * MS_PER_SECOND);
rtc_... |
_assert_equal_b(false, app_install_has_worker(menu_layer_id));
cl_assert_equal_b(false, app_install_has_worker(CRAZY_ID));
}
void test_app_install_manager__is_hidden(void) {
cl_assert_equal_b(false, app_install_is_hidden(tictoc_id));
cl_assert_equal_b(false, app_install_is_hidden(music_id));
cl_assert_equal_b... | cl_assert(true == app_install_get_entry_for_install_id(sports_id, &entry)) | ;
// hidden before communication
cl_assert(true == app_install_entry_is_hidden(&entry));
// simulates multiple messages from app
for (int i = 0; i < 10; i++) {
// visible after communication
app_install_mark_prioritized(sports_id, true /* can_expire */);
cl_assert(false == app_install_entry_is_hidd... |
s_count_compositor_init_func_a = 0;
s_count_compositor_init_func_b = 0;
s_app_window_render_count = 0;
s_modal_manager_render_count = 0;
s_display_update_in_progress = false;
s_render_pending = false;
compositor_init();
}
void test_compositor__cleanup(void) {
}
void test_compositor__simple(void) {
... | (s_count_display_update, 0) | ;
cl_assert_equal_i(s_count_animation_create, 0);
// Now the app has rendered something and we should actually update the display.
compositor_app_render_ready();
cl_assert_equal_i(s_count_display_update, 1);
}
void test_compositor__app_not_ready_modal_push_pop(void) {
// If a modal window is popped revealin... |
(layer, NULL, NULL) | ;
curr_rel_bar_anim = (Animation *)property_animation_create(
&curr_implementation, layer, &curr_from_rel_bar_value, &curr_to_rel_bar_value);
} else if ((layer->relbar_layer.curr_rel_bar.rel_bar_type == RelationshipBarTypeBackToBack) ||
(layer->relbar_layer.curr_rel_bar.rel_bar_type == Relati... | |
d 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 <assert.h>
#include <setjmp.h>... | while (error != NULL) {
next = error->next;
clar_print_error(i++, error);
free(error->description);
free(error);
error = next;
} |
_clar.errors = _clar.last_error = NULL;
}
static void
clar_run_test(
const struct clar_func *test,
const struct clar_func *initialize,
const struct clar_func *cleanup)
{
int error_st = _clar.suite_errors;
clar_on_test();
_clar.trampoline_enabled = 1;
clar_passert_occurred = false;
clar_expecting_... |
isplay.h"
#include "drivers/flash.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "drivers/pmic.h"
#include "drivers/pwr.h"
#include "drivers/watchdog.h"
#include "boot_tests.h"
#include "firmware.h"
#include "fw_copy.h"
#include "pebble_errors.h"
#include "system/bootbits.h"
#include "system/l... | ((uintptr_t)reset_handler) | ;
dbgserial_print("...\r\n\r\n");
prv_hw_reset();
// The Cortex-M user guide states that the reset values for the core registers
// are as follows:
// R0-R12 = Unknown
// MSP = VECTOR_TABLE[0] (main stack pointer)
// PSP = Unknown (process stack pointer)
// LR = 0xFFFFFFFF
// PC... |
ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "health_progress.h"
#include "applib/graphics/gpath_builder.h"
#include "system/logging.h"
// Scales a total shape offset to an individual segment offset.
// @pa... | MIN(end, amount_traversed + segment->amount_of_total) | - amount_traversed;
const int from = prv_total_offset_to_segment_offset(segment, from_total);
const int to = prv_total_offset_to_segment_offset(segment, to_total);
prv_fill_segment(ctx, segment, color, from, to);
amount_traversed += segment->amount_of_total;
if (segment == &progress_bar->segmen... |
Level:
int8_t tx_power_level;
if (ble_ad_get_tx_power_level(ad_data, &tx_power_level)) {
APP_LOG(APP_LOG_LEVEL_INFO, "TX Power: %d", tx_power_level);
result->tx_power_level = tx_power_level;
}
// Try getting Local Name:
if (ble_ad_copy_local_name(ad_data, result->local_name,
... | menu_cell_basic_draw(ctx, cell_layer,
s_is_scanning ? "Disable Scan" : "Enable Scan",
NULL, NULL) | ;
break;
case SectionData:
draw_data_row(ctx, cell_layer, cell_index, data);
break;
default:
break;
}
}
static void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index,
void *data) {
if (cell_index->section == SectionControl) {
togg... |
lMessage) + request_payload_length;
HcProtocolMessage *message = (HcProtocolMessage *)kernel_zalloc_check(message_length);
message->message_length = message_length;
message->endpoint_id = endpoint_id;
message->command_id = command_id;
if (request_payload_length) {
memcpy(message->payload, request_payload,... | prv_set_expectation_for_request(request_message) | ;
if (!prv_enqueue(request_message)) {
prv_cleanup_expectation(expectation);
return NULL;
}
HcProtocolMessage *response_message = prv_expect(expectation);
prv_cleanup_expectation(expectation);
return response_message;
}
#endif
bool hc_protocol_enqueue_response(const HcProtocolMessage *to_request,
... |
tatus) {
PBL_ASSERTN(s_notif_storage_mutex != NULL);
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
int fd = prv_file_open(OP_FLAG_READ | OP_FLAG_WRITE);
if (fd < 0) {
return;
}
if (prv_find_next_notification(&header, prv_uuid_equal_func, (void *) id, fd)) {
prv_set_header_s... | (FILENAME, OP_FLAG_OVERWRITE | OP_FLAG_READ, FILE_TYPE_STATIC,
NOTIFICATION_STORAGE_FILE_SIZE) | |
Y Z "
"a b c d e f g h j k l m n o p q r s t u";
char fourth_page_one_line[] = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
"a b c d e f g h j k l m n o p q r s t u v w x y z "
"A B C D E F G H I J K L M N O P Q R S ... | (s_dest_bitmap, namecat(namecat(__func__, "__clipped"), ".pbi")) | );
prv_prepare_fb_steps_xy(GSize(180, 300), 1, 1);
ctx.draw_state.avoid_text_orphans = false;
graphics_draw_text(&ctx, text, &s_font_info, GRect(0, 0, 180, 1000),
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter,
(GTextAttributes *const) &layout);
cl_check(gbitm... |
f s_disp_gpio_init = {
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_Speed = GPIO_Speed_50MHz,
.GPIO_Pin = DISP_PIN_SCLK | DISP_PIN_SI
};
static SPI_InitTypeDef s_disp_spi_init = {
.SPI_Direction = SPI_Direction_1Line_Tx, // Write-only SPI
.SPI_Mode = SPI_Mo... | prv_draw_bitmap(pebble_logo_bits, 16, 64, pebble_logo_width, pebble_logo_height, buffer) | ;
prv_display_buffer(buffer);
}
static void prv_set_bit(uint8_t x, uint8_t y, uint8_t buffer[DISP_ROWS][DISP_LINE_BYTES]) {
buffer[y][x / 8] |= (1 << (x % 8));
}
static void prv_render_char(unsigned digit, uint8_t x_offset_bits, uint8_t y_offset,
uint8_t buffer[DISP_ROWS][DISP_LINE_BY... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.