prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_did_send_byte) | ;
}
}
void fake_accessory_get_buffer(uint8_t **buffer, int *length) {
*buffer = s_buffer;
*length = s_buffer_index;
}
|
);
}
uint32_t app_inbox_service_unregister_by_storage(uint8_t *storage) {
uint32_t num_messages_lost = 0;
prv_lock();
{
AppInboxNode *node = prv_find_inbox_by_storage(storage);
if (node) {
list_remove((ListNode *)node, (ListNode **)&s_app_inbox_head, NULL);
num_messages_lost = node->num_faile... | prv_unlock() | ;
return success;
}
static void prv_finish(AppInboxNode *inbox) {
inbox->writer = NULL;
inbox->buffer.current_offset = 0;
}
void app_inbox_service_init(void) {
s_app_inbox_mutex = mutex_create_recursive();
}
bool app_inbox_service_end(AppInboxServiceTag tag) {
bool success = false;
prv_lock();
{
Ap... |
AGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS
};
memcpy(&s_data.metric_history[ActivityMetricStepCount], &step_history, sizeof(step_history));
}
void prv_set_sleep_history_avg() {
const ActivityScalarStore AVERAGE_SLEEP = 5 * MINUTES_PER_HOUR;
static const int32_t sleep... | fake_kernel_services_notifications_ancs_notifications_count() | , 0);
}
// ---------------------------------------------------------------------------------------
// Make sure we don't push an activity pin when we have no history to compare against
void test_activity_insights__activity_summary_no_history(void) {
// Tests init with zero history
// Set time to be after 8:30PM
... |
de "services/common/analytics/analytics_logging.h"
#include "services/common/bluetooth/bluetooth_ctl.h"
#include "services/common/system_task.h"
#include "system/hexdump.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/reset.h"
#include "util/assert.h"
#include "util/circular_buffer.h"
#inclu... | {
TIM_Cmd(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, DISABLE);
TIM_ITConfig(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update, DISABLE);
periph_config_disable(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, RCC_APB1Periph_TIM6);
s_spi_transport.watchdog_timer_active = false;
} |
static void prv_watchdog_start(void) {
prv_lock();
if (!s_spi_transport.watchdog_timer_active) {
TIM_SetCounter(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, 0); // Reset the count to 0.
TIM_Cmd(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, ENABLE);
s_spi_transport.watchdog_timer_active = true;
// Preven... |
const GBitmap* src_bitmap, GRect dest_rect,
GPoint src_origin_offset,
GCompOp compositing_mode,
GColor tint_color) {
bitblt_into_1bit_setup_compositing_mode(&compositin... | if (src_bits_left == 0 && row_bits_left != 0) {
++src_block;
if (src_block == src_block_end) {
// Wrap-around source bitmap horizontally:
src_block = src_block_begin;
src_bits_left = src_bits_left_at_line_begin;
src_dest_shift = (src_dest_shift + src_bitmap->bound... | |
omRight);
bottom_rect_size_w -= radius;
}
// Top Rect
prv_fill_rect_legacy2(ctx, GRect(top_rect_origin_x, rect->origin.y, top_rect_size_w, radius),
0, GCornerNone, fill_color);
// Middle Rect
prv_fill_rect_legacy2(ctx, GRect(rect->origin.x, rect->origin.y + radius,
... | {
const GPoint tl = GPoint(rect->origin.x, rect->origin.y);
const GPoint tr = GPoint(rect->origin.x + rect->size.w - 1, rect->origin.y);
const GPoint bl = GPoint(rect->origin.x, rect->origin.y + rect->size.h - 1);
const GPoint br = GPoint(rect->origin.x + rect->size.w - 1, rect->origin.y + rect->size.h - 1);
... |
void graphics_draw_rect(GContext* ctx, const GRect *rect) {
PBL_ASSERTN(ctx);
if (!rect || ctx->lock) {
return;
}
if (ctx->draw_state.stroke_width <= 2) {
// Note: stroke width == 2 is rounded down to stroke width of 1
prv_draw_rect(ctx, rect);
return;
}
#if PBL_COLOR
if (ctx->draw_state.... |
t_context(a));
animation_set_duration(a, duration_a);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_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
}
// ---------------------... | (&s_stopped_handler_calls, seq) | |
n.header.id, &s_items[1].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
// check sixth
cl_assert(!iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
cl_assert(uuid_equal(&state.node->i... | cl_assert_equal_i(state.current_day, midnight_march_3_pst) | |
! Always lock the bus before reset
static void prv_bus_reset(I2CBus *bus) {
prv_bus_disable(bus);
prv_bus_enable(bus);
}
/*---------------INIT/USE/RELEASE/RESET FUNCTIONS----------------------*/
void i2c_init(I2CBus *bus) {
PBL_ASSERTN(bus);
*bus->state = (I2CBusState) {};
i2c_hal_init(bus);
if (bus->r... | prv_bus_reset(bus) | |
pdate_proc(&layer, &draw_text_single_line_wordwrap_clip_across_ny);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wo... | setup_test_aa_sw(&ctx, fb, RECT_TEXT_2_0, RECT_TEXT_2_0, false, 1) | ;
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_2_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_jja22.${BIT_DEPTH_NAME}.pbi"));
// Test when clipping/drawin... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | mutex_unlock(s_state_mutex) | ;
return false;
}
s_input_state = state;
switch (s_input_state) {
case AccessoryInputStateMfg:
accessory_enable_input();
accessory_set_baudrate(AccessoryBaud115200);
accessory_set_power(false);
accessory_mfg_mode_start();
break;
case AccessoryInputStateIdle:
// restore accessory t... |
Color color) {
prv_set_mic_window_state(data, StateError);
SimpleDialog *simple_dialog = &data->short_error_dialog;
simple_dialog_init(simple_dialog, "Dictation Error");
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
prv_init_dialog(data, dialog, text, resource_id, true, color);
simple_dialog_pu... | prv_handle_error_retries(data) | |
t_equal_p(s_last_click_configured_window, window2);
// Switch to modal happens via the compositor
compositor_transition(NULL);
// Call the upkeep function so the change in state is handled
modal_manager_event_loop_upkeep();
// The app is now obstructed by an opaque modal, it should be idle
cl_assert_equal... | cl_assert_equal_b(s_app_idle, false) | ;
// Assert that the window pushed onto the app stack has regained focus,
// this is also done by checking the last event.
event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_APP_WILL_CHANGE_FOCUS_EVENT);
cl_assert_equal_i(event.app_focus.in_focus, true);
cl_assert_equal_i(window1->on_scr... |
/*
* 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 (anim_percent_complete) {
return SETTLE_HEIGHT_DIFF - ((SETTLE_HEIGHT_DIFF * anim_percent_complete) / 100);
} else {
return 0;
}
} | |
;
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX);
// reset line
line = (Line) { 0 };
line.max_width_px = text_box_params.box.size.w;
line.height_px = text_box_params.box.size.h;
cl_assert(line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_a... | cl_assert(*word_iter_state.current.end == '\0') | ;
cl_assert(word_iter_state.current.width_px == HORIZ_ADVANCE_PX * 11);
line_reset(&line, utf8_bounds.start);
cl_assert(line_add_words(&line, &word_iter, NULL));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 4);
cl_assert(line.origin.x == 0);
cl_assert(line.suffix_codepoi... |
ame);
} else {
// Show something like UTC-4 or UTC-10.25
// This will typically happen in the emulator when we know the UTC offset, but not
// the timezone (fallback case).
int gmt_offset_m = time_get_gmtoffset() / SECONDS_PER_MINUTE;
int hour_offset = gmt_offset_m / MINUTES_PER_HOUR;
... | {
switch (style) {
case FullStyleLower12h:
case FullStyleCapital12h:
if (with_fulltime) {
time_fmt = i18n_noop("Yesterday, %l:%M %p");
} else {
time_fmt = i18n_noop("Yesterday");
}
break;
case FullStyleLower24h:
case FullStyleCapital24h:
... | else if (timestamp_midnight <= last_week_midnight || timestamp_midnight >= next_week_midnight) {
switch (style) {
case FullStyleLower12h:
case FullStyleCapital12h:
if (with_fulltime) {
time_fmt = i18n_noop("%b %e, %l:%M %p");
} else {
time_fmt = i18n_noop("%B %e");
... |
sed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under th... | app_state_get_unobstructed_area_state() | ->handlers.change);
cl_assert(!app_state_get_unobstructed_area_state()->handlers.did_change);
}
void test_unobstructed_area_service__will_change(void) {
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_change,
};
app_unobstructed_area_service_subscribe(handlers, s_data.context);
cl_assert(fa... |
's to the first half of a flash sector and confirms that everything
// reads as 0. Then uses 8 subsector erases to erase the second half of the
// sector. Then re-reads the first half to see if any bits have flipped
static bool check_subsector_bitflip(struct Region region) {
#if !CAPABILITY_USE_PARALLEL_FLASH
bool s... | text_layer_set_text(stress_data.text_layer, "Starting Stress Test") | ;
abort_stress_test = false;
app_timer_register(500, app_timer_cb, NULL);
};
static void stress_window_unload(Window *data) {
abort_stress_test = true;
}
static void file_system_stress_callback(int index, void *data) {
stress_data.stress_iteration = 0;
stress_data.stress_index = index;
window_init(&stress... |
(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text)) | ;
day_start -= SECONDS_PER_DAY;
}
prv_display_alert(data->debug_card.dialog_text);
}
// -------------------------------------------------------------------------------
static void sleep_select_click_handler(ClickRecognizerRef recognizer, void *context) {
}
// -----------------------------------------------... | |
/*
* 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 (rv != BLE_STATUS_OK) {
prv_pop_errored_op(conn_idx);
} | |
haracteristic characteristic_ref,
GAPLEConnection *connection) {
ListNode *head = (ListNode *) connection->gatt_subscriptions;
return (GATTClientSubscriptionNode *) list_find(head, prv_find_subscription_cb,
... | if (subscription_type == BLESubscriptionNone) {
// No subscription, so nothing to unsubscribe from...
return BTErrnoInvalidState;
} |
// No subscriptions for the characteristic yet, go create one:
subscription = (GATTClientSubscriptionNode *) kernel_malloc(sizeof(GATTClientSubscriptionNode));
if (!subscription) {
// OOM
return BTErrnoNotEnoughResources;
}
// Initialize it:
*subscription = (const GATTClientSubscrip... |
data_size, false);
// Validate the loaded command sequence
if (!gdraw_command_sequence_validate(draw_command_sequence, data_size)) {
gdraw_command_sequence_destroy(draw_command_sequence);
return NULL;
}
return draw_command_seque... | {
return PLAY_COUNT_INFINITE;
} |
return sequence->play_count;
}
void gdraw_command_sequence_set_play_count(GDrawCommandSequence *sequence, uint32_t play_count) {
if (!sequence) {
return;
}
sequence->play_count = MIN(play_count, GDRAW_COMMAND_SEQUENCE_PLAY_COUNT_INFINITE_STORED);
}
uint32_t gdraw_command_sequence_get_total_duration(GDra... |
now_utc - (session->start_utc + SECONDS_PER_MINUTE * session->length_min) <
s_activity_session_settings.session.activity.trigger_cooldown_minutes * SECONDS_PER_MINUTE) {
INSIGHTS_LOG_DEBUG("Not adding session pin - cooldown not yet elapsed");
return;
}
if (prv_get_sleep_state() != ActivitySleepStateA... | if (!activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_SLEEP_REWARD,
&s_sleep_reward_settings)) {
s_sleep_reward_settings.enabled = false; // worst-case, we disable the insight
} |
if (!activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_SLEEP_SUMMARY,
&s_sleep_summary_settings)) {
s_sleep_summary_settings.enabled = false; // worst-case, we disable the insight
}
if (!activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_SUMM... |
ointer);
cl_assert_equal_i(TEST_EXPECTED_PP_MSG[i], *read_pointer);
// Expect that the header and payload will be non-contiguous:
if (i < sizeof(PebbleProtocolHeader)) {
cl_assert_equal_i(sizeof(PebbleProtocolHeader) - i, length_available);
} else {
cl_assert_equal_i(length - i, length_avail... | {
cl_assert_equal_i(bytes_out[intact_size + i], 0x00);
} |
app_free(outbox_data);
}
void test_app_message_sender__cancelled_message_in_flight_header_and_payload_not_finished(void) {
// Expect header to get sent out normally, then a payload with all zeroes
prv_quit_app_after_pp_msg_byte(sizeof(PebbleProtocolHeader) - 1);
}
void test_app_message_sender__cancelled_messa... |
(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_health_activity_summary_card__render_current_above_typical1(void) {
HealthData health_data = {
.step_data = 340,
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,... | |
NULL));
s_test_impl.handle_touch_event = dummy;
s_test_impl.reset = NULL;
cl_assert_passert(recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
sizeof(s_test_impl_data), dummy,
... | (event_type, RecognizerEvent_Cancelled) | ;
cl_assert_equal_i(r->state, RecognizerState_Cancelled);
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... |
t pointer.
if (strcmp(cursor, "Etc") == 0) { // Filter out 'Etc' fake-continent
continue;
}
// Set pointer for the continent name
continent_names[continent_index] = last_cursor;
// Set the new continent name
last_cursor = cursor;
// Set the starting region ID for the new continent.
... | {
title = i18n_noop("Time Format");
subtitle = clock_is_24h_style() ? i18n_noop("24h") : i18n_noop("12h");
break;
} |
case TimeRow_TimezoneSource: {
title = i18n_noop("Timezone Source");
subtitle = clock_timezone_source_is_manual() ? i18n_noop("Manual") :
i18n_noop("Automatic");
break;
}
case TimeRow_Timezone: {
title = i18n_noop("Timezone");
... |
ivityMetricActiveSeconds, Monday, &val_out));
cl_assert(!health_db_get_typical_value(ActivityMetricRestingKCalories, Monday, &val_out));
cl_assert(!health_db_get_typical_value(ActivityMetricActiveKCalories, Monday, &val_out));
cl_assert(!health_db_get_typical_value(ActivityMetricDistanceMeters, Monday, &val_ou... | ARRAY_LENGTH(entries) | |
TextStyleFont_Title] = FONT_KEY_GOTHIC_36_BOLD,
[TextStyleFont_Body] = FONT_KEY_GOTHIC_36,
#endif
//! @note this is the same as Large until ExtraLarge is designed
[TextStyleFont_Subtitle] = FONT_KEY_GOTHIC_28,
[TextStyleFont_Caption] = FONT_KEY_GOTHIC_24,
[TextStyleFont_Footer] = FONT_KEY_... | ARRAY_LENGTH(s_platform_default_content_sizes) | ;
PBL_ASSERTN(from_platform < num_platform_default_content_sizes);
PBL_ASSERTN(to_platform < num_platform_default_content_sizes);
const PreferredContentSize from_platform_default_size =
s_platform_default_content_sizes[from_platform];
const PreferredContentSize to_platform_default_size =
s_platform... |
/*
* 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... | {
i++;
} |
}
}
|
address(BTDeviceAddress *address_out) {
BTDeviceAddress address;
int read_size = prv_file_get(&BLE_PINNED_ADDRESS_KEY, sizeof(BLE_PINNED_ADDRESS_KEY),
&address, sizeof(address));
if (!read_size) {
return false;
}
if (address_out) {
*address_out = address;
}
return tr... | (&bonding, stored_data) | ;
bonding.is_gateway = stored_data->ble_data.is_gateway;
bonding.flags = stored_data->ble_data.flags;
bt_driver_handle_host_added_bonding(&bonding);
}
void bt_persistent_storage_register_existing_ble_bondings(void) {
ForEachBLEPairingInternalData internal_itr_data = {
.cb = prv_register_bondings_for_each_b... |
t-vector (x <= y; x, y >= 0)
#define BITS_BETWEEN(x, y) (BITS(y) & ~BITS(x-1))
// Yo dawg, I heard you like tests so I put tests in your tests so you can test
// your tests while you test!
void test_system_flash__bit_range_macros(void) {
cl_assert_equal_i(0b1, BITS(0));
cl_assert_equal_i(0b00011111, BITS(4));
cl... | {
for (uint32_t i = 0; i < length; ++i) {
cl_assert(flash_written_flag[start + i] == false);
}
} |
void test_system_flash__write_simple(void) {
const char testdata[] = "The quick brown fox jumps over the lazy dog.";
malloc_flash_data(100);
flash_data_start = FLASH_BASE;
cl_assert(system_flash_write(
FLASH_BASE + 10, testdata, sizeof(testdata), callback_is_called_cb,
(void *)8675309));
cl_... |
er output
snprintf(dstbuf, 256, "There are %*u lights", 3, 4);
cl_assert_equal_s(dstbuf, "There are 4 lights");
// Variable length digits output
snprintf(dstbuf, 256, "There are %.*u lights", 3, 4);
cl_assert_equal_s(dstbuf, "There are 004 lights");
// Variable length digits output (negative digits, act... | cl_assert_equal_s(dstbuf, "There are 0x10 lights, 0xfffffffc") | ;
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %03x lights, %03x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 010 lights, fffffffc");
// Space padded minimum character output
snprintf(dstbuf, 256, "There are %3x lights, %3x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 10... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return;
} |
int32_t num_values = 0;
int32_t sum = 0;
int32_t min = INT32_MAX;
int32_t max = INT32_MIN;
int32_t consecutive_max = 0;
int32_t consecutive_current = 0;
int32_t consecutive_first = 0;
bool calc_consecutive_first = (op & StatsBasicOp_ConsecutiveFirst);
for (size_t i = 0; i < num_data; i++) {
cons... |
from prv_minute_system_task_cb()
ActivityScalarStore prev_steps = s_activity_state.step_data.steps;
mutex_lock_recursive(s_activity_state.mutex);
{
activity_algorithm_get_steps(&s_activity_state.step_data.steps);
// Are we logging raw accel samples?
if (s_activity_state.sample_collection_enabled) {
... | activity_prefs_get_gender() | ;
uint16_t weight_dag = activity_prefs_get_weight_dag();
uint16_t height_mm = activity_prefs_get_height_mm();
uint8_t age_years = activity_prefs_get_age_years();
activity_algorithm_set_user(height_mm,
weight_dag * 10,
gender,
... |
i/app_window_stack.h"
#include "applib/ui/option_menu_window.h"
#include "applib/ui/ui.h"
#include "drivers/battery.h"
#include "kernel/pbl_malloc.h"
#include "popups/notifications/notification_window.h"
#include "services/common/analytics/analytics.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/no... | alerts_get_vibrate() | ) {
selected = 0;
}
settings_option_menu_push(
title, OptionMenuContentType_SingleLine, selected, &callbacks,
ARRAY_LENGTH(strings_for_vibe_intensities), true /* icons_enabled */,
strings_for_vibe_intensities, data);
}
#endif /* !CAPABILITY_HAS_VIBE_SCORES */
// Text Size
///////////////////... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
void (*foobar)(void) = NULL;
foobar();
app_event_loop();
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (s_exti_locked) {
__enable_irq();
s_exti_locked = false;
}
} |
static IRQn_Type prv_get_irq_enum(int exti_line) {
if (exti_line <= 4) {
return EXTI0_IRQn + exti_line;
}
if (exti_line <= 9) {
return EXTI9_5_IRQn;
}
if (exti_line <= 15) {
return EXTI15_10_IRQn;
}
if (exti_line == ExtiLineOther_RTCAlarm) {
return RTC_Alarm_IRQn;
}
if (exti_line == ... |
r.h"
#include "services/common/analytics/analytics.h"
#include "services/common/comm_session/session.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/system_task.h"
#include "services/normal/process_management/app_storage.h"
#include "system/bootbits.h"
#include "system/hexdump... | flash_dump_log_file(s_bt_dump_chunk_callback_data.generation, prv_bt_log_dump_line_cb,
prv_bt_log_dump_completed_cb) | ;
flash_logging_set_enabled(true);
}
void dump_log_protocol_msg_callback(CommSession *session, const uint8_t* data, size_t length) {
uint32_t cookie;
int generation = 0;
if (data[0] == 0x10 || data[0] == 0x11) {
if (length != 6) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid dump log message received -- length ... |
soryBaud9600,
AccessoryBaud14400,
AccessoryBaud19200,
AccessoryBaud28800,
AccessoryBaud38400,
AccessoryBaud57600,
AccessoryBaud62500,
AccessoryBaud115200,
AccessoryBaud125000,
AccessoryBaud230400,
AccessoryBaud250000,
AccessoryBaud460800
};
_Static_assert(ARRAY_LENGTH(BAUDS) - 1 == AccessoryBaud46... | {
PBL_LOG(LOG_LEVEL_WARNING, "No profiles specified");
smartstrap_link_control_disconnect();
success = false;
} | else {
prv_do_send(LinkControlTypeStatus);
}
} else {
// length is invalid (should be an even multiple of the size of the profile value)
PBL_LOG(LOG_LEVEL_WARNING, "Got invalid profiles length (%"PRIu32")", data_length);
smartstrap_link_control_disconnect();
success = false;
... |
//////////////////////////////////////////////
//! Common Setup
static void prv_create_window_common(WorkoutActiveWindow *active_window,
void *workout_data,
WorkoutController *workout_controller) {
active_window->workout_data = workout_data;
... | status_bar_layer_set_colors(status_layer, GColorClear, GColorBlack) | ;
layer_add_child(&window->layer, status_bar_layer_get_layer(status_layer));
#if PBL_RECT
GRect status_layer_bounds = window->layer.bounds;
status_layer_bounds.size.w -= ACTION_BAR_WIDTH;
layer_set_frame(&status_layer->layer, &status_layer_bounds);
#endif
ActionBarLayer *action_bar = &active_window->action_... |
d_to_string(&event_blob.pin_app_launch.parent_id, uuid_string);
ANALYTICS_LOG_DEBUG("pin app launch event: timestamp: %"PRIu32", uuid:%s",
event_blob.pin_app_launch.time_utc, uuid_string);
#endif
analytics_logging_log_event(&event_blob);
}
// ------------------------------------------------... | {
AnalyticsEventBlob event_blob = {
.event = type,
};
event_blob.bt_connection_disconnection.reason = reason;
ANALYTICS_LOG_DEBUG("Event %d - BT (dis)connection: Reason: %"PRIu8,
event_blob.event,
event_blob.bt_connection_disconnection.reason);
analytics_logg... |
void analytics_event_bt_le_disconnection(uint8_t reason, uint8_t remote_bt_version,
uint16_t remote_bt_company_id,
uint16_t remote_bt_subversion) {
AnalyticsEventBlob event_blob = {
.event = AnalyticsEvent_BtLeDisconnect,
.ble... |
/*
* 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... | {
psleep(100);
} |
s_pending_count++;
system_task_add_callback(send_bluetooth, NULL);
}
PBL_LOG(LOG_LEVEL_INFO, "Bluetooth disconnected");
} else if (index == 1) {
PBL_LOG(LOG_LEVEL_DEBUG, "Not implemented");
}
}
// =================================================================================
static v... |
return (new_state == ANCSClientStateRequestedNotification ||
new_state == ANCSClientStateRetrying ||
new_state == ANCSClientStatePerformingAction ||
new_state == ANCSClientStateAliveCheck);
case ANCSClientStateRequestedNotification:
return (new_state == ANCSClientSta... | list_remove((ListNode *)s_ancs_client->queue,
(ListNode **)&s_ancs_client->queue,
NULL) | ;
kernel_free(temp);
}
}
static void prv_notif_queue_next(void) {
if (s_ancs_client->alive_check_pending) {
prv_check_ancs_alive();
return;
}
if (s_ancs_client->queue == NULL) {
// empty
return;
}
prv_do_notif_queue_operation();
}
// --------------------------------------------------... |
set(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 16:00:00
// Now - one day
const int event_time = jun10th_noon_2015 - SECONDS_PER_DAY + (4 * SECONDS_PER_HOUR);
// if the event is within 24 hours, then show the actual time instead of "X hours ago"
const int MAX_RELATIVE_HRS =... | clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("2 hours ago", time_buf);
// June 9th 2015, 16:01:00 (T+00:01:00)
rtc_set_time(event_time + (1 * SECONDS_PER_MINUTE));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 minute ago", time_buf);
// June 9th 2015, 16:02:00 (T+00:02:00)
... |
fake_gatt_client_subscriptions_assert_subscribe(s_characteristics[0][PPoGATTCharacteristicData],
BLESubscriptionNotifications,
GAPLEClientKernel);
// Simulate getting the subscription confirmation:
ppogatt_handle_sub... | prv_receive_reset_request(s_characteristics[0][PPoGATTCharacteristicData]) | |
(APP_LOG_LEVEL_ERROR, "Invalid timer %u used in app_timer_reschedule", (unsigned)timer) | ;
syscall_failed();
}
}
return evented_timer_get_data((EventedTimerID)timer);
}
| |
/*
* 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... | CD_ASSERTN(manufacturer == 0x20 && type == 0xbb && (capacity >= 0x16)) | ;
}
static void prv_flash_write_enable(void) {
prv_flash_start_cmd();
prv_flash_send_and_receive_byte(FLASH_CMD_WRITE_ENABLE);
prv_flash_end_cmd();
}
static void prv_flash_send_24b_address(uint32_t start_addr) {
// Ensure the high bits are not set.
prv_flash_send_and_receive_byte((start_addr & 0xFF0000) >> ... |
*generic_glance =
launcher_app_glance_structured_get_data(structured_glance);
// Reset the timer
generic_glance->slice_subtitle_template_string_reeval_timer = NULL;
prv_cancel_subtitle_reeval_timer(generic_glance);
// Notify the service that the glance changed
launcher_app_glance_structured_notify_se... | (generic_glance, &resource_info) | ;
prv_cancel_subtitle_reeval_timer(generic_glance);
// The glance will automatically be redrawn after this function is called (which will also update
// the glance's state regarding its subtitle template string), so no need to mark it as dirty
// (see launcher_app_glance_update_current_slice())
}
static cons... |
, 504, -928},
{ 144, 488, -928},
{ 144, 488, -920},
{ 144, 488, -912},
{ 152, 488, -912},
{ 152, 488, -912},
{ 152, 496, -928},
{ 152, 488, -928},
{ 152, 480, -920},
{ 152, 504, -928},
{ 152, 480, -912},
{ 160, 496, -928},
{ 152, 504, -920},
{ 152, 488, -912},
{ 1... | { -656, 816, -136},
{ -584, 760, 8},
{ -544, 744, -72},
{ -584, 608, -112},
{ -608, 544, -152},
{ -648, 552, -272},
{ -672, 544, -344},
// 239 seconds
{ -648, 528, -344},
{ -696, 472, -312},
{ -688, 520, -432},
{ -744, 568, -464},
{ -760, 608, -472},
{ -744, 584, ... |
{ 72, 664, -136},
{ 296, 952, -112},
{ 688, 832, -384},
{ 472, 656, 184},
{ -848, 1272, 736},
{ 648, 888, -1400},
{ 88, 256, -480},
{ 80, 1216, -560},
{ 272, 904, -600},
{ 208, 800, -640},
{ 200, 752, -592},
{ 176, 856, -536},
{ 168, 952, -544},
{ 176, 920, -552}... |
/*
* 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_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_across_nx_origin_layer.${BIT_DEPTH_NAME}.pbi")) | |
/*
* 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... | ((uint8_t *) key, key_len, (void *) &val, val_len) | |
/*
* 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(NULL != bmp) | ;
cl_assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette
bmp = gbitmap_create_blank(s10, GBitmapFormat2BitPalette);
cl_assert(NULL != bmp);
cl_assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette
bmp = gbitmap_create_blank(s10, GBitmap... |
/*
* 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... | reschedule_ack_timeout() | |
PBL_LOG(LOG_LEVEL_DEBUG, "advert_handle_completed %"PRIu8, evt->status) | ;
if (s_adv_state == AdvertState_Pausing) {
s_adv_state = AdvertState_Paused;
} else {
s_adv_state = AdvertState_Off;
}
// Note: Ideally, the controller would inform us why the advertisement had stopped. For
// example, if we knew that the reason was due to a slave device connecting we ... | |
/*
* 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 (event->bluetooth.comm_session_event.is_open &&
event->bluetooth.comm_session_event.is_system) {
progress_window_pop(&data->window);
} |
}
static 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... |
AlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
setup_test_aa_sw(&ctx, fb, RECT_NULL_H, RECT_NULL_H, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
GTextOverflowModeTr... | pfs_init(false) | ;
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */);
resource_init();
memset(&s_font_info, 0, sizeof(s_font_info));
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18_BOLD;
cl_assert(text_resources_init_fo... |
/*
* 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_timer_cancel(data->poweroff_timer);
} | else if (!charge.is_plugged && data->was_plugged) {
data->poweroff_timer = app_timer_register(
CHARGER_DISCONNECT_TIMEOUT_MS, prv_power_off_timer_expired, NULL);
}
DialogState next_dialog_state = DialogState_Uninitialized;
if (charge.is_charging) {
next_dialog_state = DialogState_Charging;
} ... |
allback callback, void *context, const Tuplet * const tuplets, const uint8_t tuplets_count) {
if (tuplets_count == 0) {
const Dictionary dict = { .count = 0 };
callback((const uint8_t *)&dict, sizeof(Dictionary), context);
return DICT_OK;
}
uint32_t size = dict_calc_buffer_size_from_tuplets(tuplets, t... | if (dict_find(new_iter, orig->key) != NULL) continue; |
total_size_required += sizeof(*orig) + orig->length;
}
return total_size_required;
}
DictionaryResult dict_merge(DictionaryIterator* dest_iter,
uint32_t* dest_buf_length_in_out,
DictionaryIterator* new_iter,
const bool update... |
/*
* 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_message_outbox_begin(&iter) | ;
if (iter == NULL) {
return -1;
}
dict_write_tuplet(iter, &value);
dict_write_end(iter);
int result = app_message_outbox_send();
return result;
}
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
int result;
APP_LOG(APP_LOG_LEVEL_DEBUG, "Sending messages");
for ... |
13, 0x0},
{ 0, 0x8f, 25, 0x0},
{ 0, 0x8f, 0, 0x0},
{ 0, 0x8f, 31, 0x0},
{ 0, 0x8f, 26, 0x0},
{ 0, 0x66, 1312, 0x0},
{ 0, 0x48, 193, 0x0},
// 30: Local time: 10:00:00 PM
{ 0, 0x48, 753, 0x0},
{ 0, 0x58, 778, 0x0},
{ 0, 0x57, 1237, 0x0},
{ 0, 0x57, 1102, 0x0},
{ 0, 0x58, 1... | { 0, 0x68, 0, 0x0},
{ 0, 0x68, 19, 0x0},
{ 0, 0x68, 547, 0x0},
{ 0, 0x68, 1013, 0x0},
{ 0, 0x68, 0, 0x0},
{ 0, 0x58, 1075, 0x0},
{ 0, 0x68, 1811, 0x0},
{ 0, 0x68, 20, 0x0},
{ 0, 0x68, 0, 0x0},
{ 0, 0x68, 0, 0x0},
// 150: Local time: 12:01:00 AM
{ 0, 0x68, 0, 0x0},
{ 0... |
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0, 0x48, 0, 0x0},
{ 0... |
{ -760, 528, -168},
{ -952, 560, -192},
{ -1056, 544, -168},
{ -1184, 544, -240},
{ -1128, 608, -360},
{ -960, 520, -280},
{ -944, 544, -232},
{ -920, 496, -112},
{ -720, 400, 16},
{ -544, 376, 16},
{ -496, 392, 0},
{ -552, 352, 72},
{ -624, 344, 104},
{ -648, 36... | { -784, 816, 80},
{ -824, 1120, -192},
{ -920, 952, -352},
{ -960, 1024, -360},
// 73 seconds
{ -920, 568, -432},
{ -680, 208, -232},
{ -480, 56, -368},
{ -296, -56, -376},
{ -328, -64, -600},
{ -256, -104, -584},
{ -200, -88, -672},
{ -104, -136, -784},
{ -56, -2... |
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 15:47:21 local
AccelRawData *activity_sample_walk_100_pbl_25655_4(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25655_4
//> TEST_EXPECTED 100
//> T... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (APP_LOG_LEVEL_ERROR, GPATH_ERROR) | ;
}
return path;
}
void gpath_destroy(GPath* gpath) {
applib_free(gpath);
}
static GPoint rotate_offset_point(const GPoint *orig, int32_t rotation, const GPoint *offset) {
int32_t cosine = cos_lookup(rotation);
int32_t sine = sin_lookup(rotation);
GPoint result;
result.x = (int32_t)orig->x * cosine / TR... |
/*
* 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... | status_bar_layer_deinit(&data->status_layer) | ;
#endif
kernel_free(data);
}
static void prv_chaining_window_load(Window *window) {
ChainingWindowData *data = window_get_user_data(window);
const GRect bounds = grect_inset(data->window.layer.bounds, (GEdgeInsets) {
.top = STATUS_BAR_LAYER_HEIGHT,
#if PBL_ROUND
.bottom = STATUS_BAR_LAYER_HEIGHT
#endif... |
= prv_fill_native_ancs_action(buffer, action, ActionIDPositive,
positive_action, app_id, properties);
action++;
}
if (negative_action) {
*buffer = prv_fill_native_ancs_action(buffer, action, ActionIDNegative,
negative_action... | prv_should_hide_reply_because_group_sms(action, app_id, subtitle) | ) {
continue;
}
required_space_for_strings += attribute_list_get_buffer_size(&action->attr_list);
num_pebble_actions++;
}
}
int num_native_actions = (positive_action ? 1 : 0) + (negative_action ? 1 : 0);
int num_actions = num_native_actions + num_pebble_actions;
const int max_num... |
ON_C99 1
// Our current strftime lacks a few things and has some bugs.
// It does not support %s, nor %+
// %z totally breaks down if the GMT offset is in the range -1s ~ -59m
// This is because for minute it does an abs(), but doesn't change the sign of the output.
// We support the 0 and + (sorta) flag and minimum... | (strftime(tmbuf, sizeof(tmbuf), "%a %A %b %B", &jan_2_2015__13_00_00), 22) | ;
cl_assert_equal_s(tmbuf, "Fri Friday Jan January");
}
void test_strftime__abusive(void) {
char tmbuf[512];
struct tm gobbledygook = {
.tm_hour = 13, .tm_min = 0, .tm_sec = 0, // 13:00:00
.tm_year = 2015 - 1900, .tm_mon = 0+MONTHS_PER_YEAR, .tm_mday = 2, // 2015/01/02
.tm_wday = 5+DAYS_PER_WEEK, .t... |
atic so it goes in BSS, since stack is only 8192 bytes
static uint8_t buffer[MAX_CHUNK_SIZE];
uint32_t chunk_size;
for (uint32_t i = 0; i < firmware_length; i += chunk_size) {
chunk_size = MIN(MAX_CHUNK_SIZE, firmware_length - i);
flash_read_bytes(buffer, flash_new_fw_start + i, chunk_size);
if (!syst... | boot_bit_clear(BOOT_BIT_NEW_FW_AVAILABLE);
boot_bit_set(BOOT_BIT_NEW_FW_INSTALLED);
} |
bool switch_to_recovery_fw() {
dbgserial_putstr("Loading recovery firmware");
UpdateFirmwareResult result = update_fw(FLASH_REGION_SAFE_FIRMWARE_BEGIN);
bool recovery_fw_ok = true;
switch (result) {
case UPDATE_FW_SUCCESS:
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_... |
.disabled = true,
#endif
},
[BlobDBIdiOSNotifPref] = {
.init = ios_notif_pref_db_init,
.insert = ios_notif_pref_db_insert,
.get_len = ios_notif_pref_db_get_len,
.read = ios_notif_pref_db_read,
.del = ios_notif_pref_db_delete,
.flush = ios_notif_pref_db_flush,
.is_dirty = ios_notif_p... | prv_db_valid(db_id) | ) {
return E_RANGE;
}
const BlobDB *db = &s_blob_dbs[db_id];
if (db->del) {
status_t rv = db->del(key, key_len);
if (rv == S_SUCCESS) {
blob_db_event_put(BlobDBEventTypeDelete, db_id, key, key_len);
}
return rv;
}
return E_INVALID_OPERATION;
}
status_t blob_db_flush(BlobDBId db_id... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("s2", "23:04:05.000") | |
0;
prv_lock();
{
AppInboxNode *node = prv_find_inbox_by_storage(storage);
if (node) {
list_remove((ListNode *)node, (ListNode **)&s_app_inbox_head, NULL);
num_messages_lost = node->num_failed + node->num_success + (node->writer ? 1 : 0);
kernel_free(node);
}
}
prv_unlock();
retu... | {
inbox->writer = NULL;
inbox->buffer.current_offset = 0;
} |
void app_inbox_service_init(void) {
s_app_inbox_mutex = mutex_create_recursive();
}
bool app_inbox_service_end(AppInboxServiceTag tag) {
bool success = false;
prv_lock();
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(tag);
if (!inbox) {
goto unlock;
}
prv_mark_faile... |
/*
* 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... | (calculated, actual) | ;
ANCSAttribute *invalid_date = prv_create_ancs_attr("b4150403T123456");
calculated = ancs_notifications_util_parse_timestamp(invalid_date);
prv_destroy_ancs_attr(invalid_date);
cl_assert_equal_i(calculated, 0);
ANCSAttribute *crazy_bad_date = prv_create_ancs_attr("F");
calculated = ancs_notifications_uti... |
_data) {
uint8_t raw_buf[2];
bma255_burst_read(AXIS_REGISTERS[axis], raw_buf, sizeof(raw_buf));
int16_t reading = prv_conv_raw_to_12bit(raw_buf);
if (new_data) {
*new_data = raw_buf[0] & 0x01;
}
return reading;
}
static bool prv_selftest_axis(BMA255Axis axis) {
uint8_t axis_bits;
switch (axis) {
... | prompt_send_response_fmt(buf, 64, " lowpower_en: 0x%"PRIx8, (lpw & (1 << 6)) != 0) | ;
prompt_send_response_fmt(buf, 64, " deep_suspend: 0x%"PRIx8, (lpw & (1 << 5)) != 0);
prompt_send_response_fmt(buf, 64, " sleep_dur: 0x%"PRIx8, (lpw & 0b11110) >> 1);
prompt_send_response_fmt(buf, 64, "(0x12) Low_Power: 0x%"PRIx8, lp);
prompt_send_response_fmt(buf, 64, " lowpower_mode: 0x%"PRIx8, (lp & (1 ... |
break;
}
}
return true;
}
static size_t prv_get_attribute_length(const Attribute *attr) {
switch (prv_attribute_type(attr->id)) {
case AttributeTypeString:
return strlen(attr->cstring) + 1; // +1 for null char
case AttributeTypeStringList:
return sizeof(StringList) + attr->string_list... | (LOG_LEVEL_WARNING, "Adding attribute with type ResourceId for non-ResourceId " \
"attribute") | ;
}
prv_add_attribute(list, id)->uint32 = resource_id;
}
void attribute_list_add_uint8(AttributeList *list, AttributeId id, uint8_t uint8) {
if (prv_attribute_type(id) != AttributeTypeUint8) {
PBL_LOG(LOG_LEVEL_WARNING, "Adding attribute with type uint8 for non-uint8_t attribute");
}
prv_add_attribute(li... |
object's section in flash (exclusive)
uint32_t end_address;
//! An optional offset from the beginning of the object's section in flash. This is useful if
//! you need to insert some derived metadata after the object has been written to flash.
uint32_t start_offset;
} MemoryLayout;
static const MemoryLayout* ... | task_watchdog_mask_clear(PebbleTask_KernelBackground) | ;
}
if (append_offset == 0) {
// By erasing the entire region we make it more likely for 'pb_storage_raw_get_status' to
// recover the correct location.
flash_region_erase_optimal_range(layout->start_address, layout->start_address,
layout->end_address, layout->end_address);
} else {
// So... |
t(&postpone_attr_list);
attribute_list_destroy_list(&remove_attr_list);
timeline_item_destroy(item);
}
static void prv_push_success_dialog(void) {
SimpleDialog *simple_dialog = simple_dialog_create("Reminder Added");
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
dialog_set_text(dialog, i18n_get("... | (&utc_sec, &local_tm) | ;
local_tm.tm_min -= (local_tm.tm_min % 15);
local_tm.tm_sec = 0;
data->timestamp = mktime(&local_tm);
}
// If the user doesn't accept the transcription, try again.
data->ui_state = ReminderAppUIState_Start;
prv_build_transcription_dialog_text(data);
prv_push_transcription_dialo... |
/*
* 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... | ((int16_t)((y3 - y2) / fixedpoint_base),
(int16_t)((x3 - x2) / fixedpoint_base)) | ;
int32_t da1 = abs(a23 - atan2_lookup((int16_t)((y2 - y1) / fixedpoint_base),
(int16_t)((x2 - x1) / fixedpoint_base)));
int32_t da2 = abs(atan2_lookup((int16_t)((y4 - y3) / fixedpoint_base),
(int16_t)((x4 - x3) / fixedpoint_base)) - a23);
i... |
t_equal_i(item->action_group.actions[1].attr_list.attributes[1].id, AttributeIdAncsAction);
cl_assert_equal_i(item->action_group.actions[1].attr_list.attributes[1].uint8, 1);
timeline_item_destroy(item);
}
static Attribute action1_attributes[] = {
{.id = AttributeIdTitle, .cstring = "Dismiss"},
};
static Attrib... | (4, string_list_count(list)) | ;
cl_assert_equal_s("", string_list_get_at(list, 0));
cl_assert_equal_s("b", string_list_get_at(list, 1));
cl_assert_equal_s("", string_list_get_at(list, 2));
cl_assert_equal_s("", string_list_get_at(list, 3));
// 2 strings (last is not terminated and will fall through) will return 2 strings
// when deseri... |
ROR, "No subscription found for ATT handle %u", att_handle);
}
goto unlock;
}
// Mask to mask out all tasks
const PebbleTaskBitset task_mask_none = ~0;
PebbleTaskBitset task_mask = task_mask_none;
for (GAPLEClient c = 0; c < GAPLEClientNum; ++c) {
if (UNLIKELY(subscription->subscriptions[c] == B... | {
subscription->pending_confirmation[c] = false;
if (subscription->subscriptions[c] == BLESubscriptionNone) {
// Client unsubscribed in the mean-time. Confirmation should already have been sent.
continue;
}
if (has_error) {
// Subscribe failed. Record that the client is n... |
}
if (task_mask != task_mask_none) {
prv_send_subscription_event(subscription->characteristic, task_mask, type, error);
}
// In the error case, clean up the subscription data structure, if no longer used:
if (has_error && prv_prevailing_subscription_type(subscription) == BLESubscriptionNone) {
prv_... |
e specific language governing permissions and
* limitations under the License.
*/
#include "services/common/put_bytes/put_bytes.h"
#include "services/common/comm_session/session_receive_router.h"
#include "os/tick.h"
#include "system/bootbits.h"
#include "system/firmware_storage.h"
#include "system/logging.h"
#incl... | {
PBL_LOG(LOG_LEVEL_ERROR, "No receiver returned!");
} |
}
static void prv_receive_init(uint32_t total_size, PutBytesObjectType object_type) {
InitRequest init_msg = (InitRequest) {
.cmd = CmdInit,
.total_size = htonl(total_size),
.type = object_type,
.cookie = htonl(1),
};
prv_receive_data(s_session, (const uint8_t *) &init_msg, sizeof(init_msg));
}
... |
/*
* 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_model") | |
&ending_edge, &starting_edge, end_top, end_bottom);
}
}
int16_t outer_edge = prv_get_ellipsis_border(y, radius_outer_y_sq, radius_outer_x_sq).raw_value;
int16_t left = center.x.raw_value - outer_edge;
int16_t right = center.x.raw_value + outer_edge;
if (!no_innner_ellipsis && radius_inne... | prv_draw_scanline_collision_points(ctx, center.y.integer + i + special_line_offset_bottom,
inner_right, right, bottom_starting_edge,
bottom_ending_edge, ignore_close_angles) | |
ion
hrm_manager_process_cleanup(PebbleTask_App, app_id);
cl_assert(sys_hrm_manager_get_app_subscription(app_id) == session_ref);
sys_hrm_manager_get_subscription_info(session_ref, NULL, NULL, &ret_expire_s, NULL);
cl_assert_equal_i(ret_expire_s, HRM_MANAGER_APP_EXIT_EXPIRATION_SEC);
sys_hrm_manager_unsubscr... | for (int i = 0; i < num_refs; ++i) {
cl_assert(prv_get_subscriber_state_from_ref(session_refs[i]));
cl_assert(prv_get_subscriber_state_from_app_id(PebbleTask_App, app_ids[i]));
} | |
nterval_min_1_25ms = atoi(interval_min_1_25ms),
.interval_max_1_25ms = atoi(interval_max_1_25ms),
.slave_latency_events = atoi(slave_latency_events),
.supervision_timeout_10ms = atoi(timeout_10ms),
};
GAPLEConnection *conn = prv_get_le_connection_and_print_info();
BTDeviceInternal addr = ... | if (index >= BtlePaConfigCount) {
prompt_send_response_fmt(buffer, sizeof(buffer), "BTLE PA options are: %s, %s, %s",
s_btle_pa_config_strings[BtlePaConfig_Disable],
s_btle_pa_config_strings[BtlePaConfig_Enable],
s_btle_pa_config... |
}
//# endif
#endif
extern void hc_endpoint_logging_set_level(uint8_t level);
void command_ble_logging_set_level(const char *level) {
char buffer[32];
int log_level = atoi(level);
if (log_level < 0) {
log_level = 0;
} else if (log_level > 255) {
log_level = 255;
}
hc_endpoint_logging_set_level(log_... |
0AppId_PRV = 0x04,
AS7000AppId_GSR = 0x08,
AS7000AppId_NTC = 0x10,
} AS7000AppId;
typedef enum AS7000LoaderStatus {
AS7000LoaderStatus_Ready = 0x00,
AS7000LoaderStatus_Busy1 = 0x3A,
AS7000LoaderStatus_Busy2 = 0xFF,
// all other values indicate an error
} AS7000LoaderStatus;
typedef struct PACKED AS7000FWU... | MIN(num_ppg_samples, MAX_PPG_SAMPLES) | ;
for (int i = 0; i < num_ppg_samples; ++i) {
struct PACKED {
uint8_t idx;
uint16_t ppg;
uint16_t tia;
} ppg_reading;
// Reading PPG data from the chip is a little weird. We need to read the PPG block of registers
// which maps to the ppg_reading struct above. We then need to verif... |
/*
* 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... | {
// Init worker state variables
worker_state_init();
task_init();
// about to start the worker in earnest. No longer safe to kill.
s_worker_task_context.safe_to_kill = false;
// Enter unprivileged mode!
const bool is_unprivileged = s_worker_task_context.app_md->is_unprivileged;
if (is_unprivileged) {... |
//! Heap locking function for our app heap. Our process heaps don't actually
//! have to be locked because they're the sole property of the process and no
//! other tasks should be touching it. All this function does is verify that
//! this condition is met before continuing without locking.
static void prv_heap_lock... |
.h>
#include <stdlib.h>
#define GPATH_ERROR "Unable to allocate memory for GPath call"
void prv_fill_path_with_cb_aa(GContext *ctx, GPath *path, GPathDrawFilledCallback cb,
void *user_data);
typedef struct Intersection {
Fixed_S16_3 x;
Fixed_S16_3 delta;
} Intersection;
void gpath_... | (&path->points[i], path->rotation, &path->offset) | |
_bt_classic_pairing_data(
BTClassicPairingData *data, BTDeviceAddress *addr, const char *device_name,
SM128BitKey *link_key, uint8_t platform_bits) {
*data = (BTClassicPairingData) {
.address = *addr,
.link_key = *link_key,
.platform_bits = platform_bits
};
strncpy(data->name, device_name, BT_... | prv_update_and_cleanup_struct_async(
&data->ble_data, sizeof(BLEPairingData) + sizeof(BTClassicPairingData),
offsetof(SharedPRFData, ble_data)) | ;
} else if (classic_bonding_update) {
prv_update_and_cleanup_struct_async(&data->bt_classic_data, sizeof(BTClassicPairingData),
offsetof(SharedPRFData, bt_classic_data));
} else if (le_bonding_update) {
prv_shared_prf_storage_store_ble_pairing_data(&data->ble... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
const GColor replace_color = GColorGreen;
const GColor stroke_color = TIMELINE_DOT_COLOR;
compositor_transition_pdcs_animation_update(
ctx, s_data.animation_sequence, distance_normalized, replace_color, stroke_color,
s_data.outer_color /* overdraw color */, inner, NULL);
} |
void prv_render_modal_if_necessary(void) {
// Since modal windows don't have a framebuffer that we can use in the compositor animation,
// draw the modal now (if one exists) so the modal compositor animations can draw on top of it,
// revealing the relevant parts of the modal window throughout the animation
i... |
if (attribute->id == AttributeIdSubtitleTemplateString) {
attr_length = MIN((uint16_t)ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN, attribute->length);
} else {
attr_length = attribute->length;
} |
*buffer += attr_length + 1;
PBL_ASSERTN(*buffer <= buf_end);
memcpy(notif_attr->cstring, *cursor, attr_length);
notif_attr->cstring[attr_length] = '\0';
break;
}
case AttributeTypeUint8:
if (attribute->length != sizeof(uint8_t)) {
return false;
}
notif_at... | |
/*
* 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... | atoi("-21474836471") | , -(int)4294967287);
}
// atol will actually behave _exactly_ the same as atoi, so these tests are just copy-pasted
// Would probably be good to make these more DRY
void test_atol__basic(void) {
cl_assert_equal_i(atol("500"), 500);
cl_assert_equal_i(atol("765"), 765);
cl_assert_equal_i(atol("573888"), 573888);
... |
andle clipping at the top of the character. We need to skip a number of bits in our source data.
const unsigned int bits_to_skip = glyph_metrics.size.w * (clipped_glyph_target.origin.y - glyph_target.origin.y);
if (bits_to_skip) {
glyph_block += bits_to_skip / 32;
src = *glyph_block;
// Simulate the ro... | if (ctx->draw_state.compositing_mode == GCompOpSet) {
// Blend (i.e. for transparency) if GCompOpSet
dest_color = gcolor_alpha_blend(ctx->draw_state.text_color,
(GColor) {.argb = dest_addr[bitindex]});
} else {
dest_colo... |
dest_addr[bitindex] = dest_color.argb;
}
}
}
#else
if (gcolor_equal(ctx->draw_state.text_color, GColorBlack)) {
*(dest_block) &= ~(mask & src);
} else {
*(dest_block) |= mask & src;
}
#endif
dest_shift = (dest_shift + number_of_bits) % 32;
... |
/*
* 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... | line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params) | );
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX);
cl_assert(iter_next(&word_iter));
cl_assert(line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 7 * HORIZ_ADVANCE_PX);
cl_assert(!line... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG, (uint8_t *)erk, sizeof(SM128BitKey));
} | |
map_from_png_file,
.need_to_destroy_bitmap = true,
},
#if PBL_COLOR
{
.test_name = "4bitTrns",
.expected_test_image_bitmap_format = GBitmapFormat4BitPalette,
.bitmap_create_func = prv_create_bitmap_from_png_file,
.need_to_destroy_bitmap = true,
},
{
.test_name = "8bitTrns",
.expected... | (&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_graphics_draw_bitmap__origin_layer_across_x(void) {
prv_origin_layer_test(GPoint(25, 0));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__origin_layer_across_nx(void) {
prv_origin_layer_test(GPoint(-25, 0));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitm... |
_handlers) {
if (window->on_screen) {
prv_window_load(window);
// In our load handler, we may unload ourselves; this is perfectly fine! However,
// if we do that, we never appear on the screen! In that case, window->on_screen
// may have changed between the time we checked and after we cal... | {
// TODO return the app's recognizer manager
// https://pebbletechnology.atlassian.net/browse/PBL-30957
return 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... | (FLASH_GPIO, &gpio_cfg) | ;
// Configure SCS to be controlled in software; pull up to high when inactive
gpio_cfg.GPIO_Mode = GPIO_Mode_OUT;
gpio_cfg.GPIO_Pin = FLASH_PIN_SCS;
gpio_cfg.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(FLASH_GPIO, &gpio_cfg);
// Set up a SPI bus on SPI1
SPI_InitTypeDef spi_cfg;
SPI_I2S_DeInit(FLASH_SPI);
s... |
ack(&s_shared_prf_writeback_timer);
}
regular_timer_add_multiminute_callback(&s_shared_prf_writeback_timer, 5);
}
// Helper to wipe memory to avoid leaking secrets stored in PRF shared storage through used stack
static void prv_cleanup_struct(SharedPRFData *data_out) {
*data_out = (SharedPRFData){};
}
static vo... | memcpy(key_out, &data.root_keys[key_type], sizeof(*key_out)) | ;
}
result = true;
done:
prv_cleanup_struct(&data);
return result;
}
void shared_prf_storage_set_root_keys(SM128BitKey *keys_in) {
#ifdef RECOVERY_FW
// This can't be async because after it is set, sm.c accesses this key right away and will assert
// if it isn't available yet.
prv_update_and_cleanup_stru... |
/*
* 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... | (type, PlatformTypeBasalt) | |
/*
* 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... | analytics_storage_give_lock() | ;
printf("Battery change period: %"PRId64"\n", value);
// 1024 ticks === 1000 ms
cl_assert(value == 1000);
}
static bool dls_log_called = false;
static int64_t expected_value = 254307546;
void test_analytics__minimal_logging_test(void) {
analytics_set(ANALYTICS_DEVICE_METRIC_BATTERY_CHARGE_TIME, expected_val... |
Index *cell_index) {
return cell_index->row == 0;
}
static uint16_t prv_alarm_list_get_num_sections_callback(struct MenuLayer *menu_layer,
void *callback_context) {
return 1;
}
static uint16_t prv_alarm_list_get_num_rows_callback(struct MenuLayer *menu_laye... | graphics_context_set_tint_color(ctx, !node->info.is_smart ? GColorClear :
(cell_layer->is_highlighted ? GColorWhite : GColorBlack)) | ;
char alarm_day_text[32] = {0};
MenuCellLayerConfig config = {
.title = alarm_time_text,
.value = enabled,
#if CAPABILITY_HAS_HEALTH_TRACKING
.icon = &data->smart_alarm_icon,
.icon_align = MenuCellLayerIconAlign_TopLeft,
.icon_box_model = &(GBoxModel) { .offset = { 0, 5 }, .margin = { 6, 0 } }... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.