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... | cl_assert(!iter_next(&char_iter)) | ;
cl_assert(!iter_next(&char_iter));
}
void test_char_iterator__decode_test_string_length_one(void) {
Iterator char_iter;
CharIterState char_iter_state;
Utf8IterState* utf8_iter_state = (Utf8IterState*) &char_iter_state.utf8_iter_state;
// Single-byte/ASCII
bool success = false;
const Utf8Bounds utf8_bo... |
ue;
return true;
}
// --------------------------------------------------------------------------------------------------
static void prv_force_close_timer_callback(void* data) {
PebbleTask task = (PebbleTask)data;
ProcessContext *context = prv_get_context_for_task(task);
if (!prv_force_stop_task_if_unprivile... | (dialog, i18n_get(error_text, expandable_dialog)) | ;
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_WARNING_SMALL);
i18n_free(error_text, expandable_dialog);
if (pebble_task_get_current() == PebbleTask_KernelMain) {
WindowStack *window_stack = modal_manager_get_window_stack(ModalPriorityAlert);
expandable_dialog_push(expandable_dialog, window_stack);
} el... |
'h', 'r', 'e', 'e'
};
const uint8_t malformatted_player[] = {
0x13, 17, 'c', 'o', 'm', '.', 's', 'p', 'o', 't', 'i', 'f', 'y', '.', 'm', 'u', 's', 'i', 'c',
9, 'S', 'p', 'o', 't', 'i', 'f', 'y'
};
struct {
const uint8_t *data;
uint16_t length;
} test_vectors[] = {
{ malformatted_artist, si... | (s_is_playback_cmd_sent, true) | ;
cl_assert_equal_i(s_playback_cmd_sent, opcodes[i]);
s_is_playback_cmd_sent = false;
}
}
void test_music_endpoint__player_name_not_available(void) {
// Android app connects:
prv_receive_app_info_event(true /* is_android */);
cl_assert_equal_b(music_get_player_name(NULL), false);
}
|
include "services/common/comm_session/session.h"
#include "services/common/evented_timer.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "services/common/regular_timer.h"
#include "services/normal/blob_db/ios_notif_pref_db.h"
#include "services/normal/blob_db/pin_db.h"
#include "se... | status_bar_layer_reset_info(&data->status_layer) | ;
} else {
// if more than one, then show the current index in relation to the total number
status_bar_layer_set_info_progress(&data->status_layer,
notifications_presented_list_current_idx() + 1,
notif_count);
}
}
static void prv_cleanup... |
/*
* 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->draw_state.draw_implementation->blend_horizontal_line(ctx, y, x1, x2,
ctx->draw_state.stroke_color) | ;
graphics_release_frame_buffer(ctx, framebuffer);
}
void prv_assign_line_vertical_non_aa(GContext* ctx, int16_t x, int16_t y1, int16_t y2) {
x += ctx->draw_state.drawing_box.origin.x;
y1 += ctx->draw_state.drawing_box.origin.y;
y2 += ctx->draw_state.drawing_box.origin.y;
// To preserve old behaviour we ad... |
42, 5251, 187, 0},
{ 0, 0x44, 4134, 188, 0},
{ 0, 0x31, 4710, 190, 0},
{ 13, 0x43, 6077, 154, 0},
{ 17, 0x42, 7089, 165, 0},
{ 0, 0x34, 2517, 161, 0},
{ 76, 0x44, 8780, 165, 0},
{ 20, 0x64, 11094, 183, 0},
{ 12, 0x65, 7077, 199, 0},
{ 0, 0x56, 2881, 209, 0},
{... | *len = ARRAY_LENGTH(samples);
return samples;
} | |
ta, *cursor, data_length - 1);
notif_attr->string_list->data[data_length - 1] = '\0';
break;
}
case AttributeTypeUint32List: {
notif_attr->uint32_list = (Uint32List *)*buffer;
*buffer += attribute->length;
PBL_ASSERTN(*buffer <= buf_end);
memcpy(notif_attr->uint32_list, *curs... | (attr_list->attributes[i].id) | ) {
case AttributeTypeString:
attribute->length = strlen(attr_list->attributes[i].cstring);
memcpy(buffer, attr_list->attributes[i].cstring, attribute->length);
break;
case AttributeTypeUint32:
case AttributeTypeResourceId:
attribute->length = sizeof(uint3... |
char information[];
} i;
struct PACKED ReliableSupervisoryPacket {
bool is_supervisory:1;
bool is_unnumbered:1; // is_unnumbered=true is unsupported
enum SupervisoryKind kind:2;
char _reserved:4;
bool poll_or_final:1;
uint8_t ack_number:7;
} s;
} ReliablePacket;
static PulseControlMes... | PBL_LOG(LOG_LEVEL_DEBUG, "Received malformed Information packet") | |
n_key),
TIMELINE_RESOURCE_RESULT_DISMISSED, ActionResultTypeSuccess);
}
static void prv_perform_ancs_negative_action(const TimelineItem *item,
const TimelineItemAction *action) {
uint8_t action_id = attribute_get_uint8(&action->attr_li... | event_service_client_unsubscribe(&ctx->event_info) | |
of(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_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("In 1 hour", time_buf);
//... | 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("In 2 minutes", time_buf);
// June 10th 2015, 04:00:00 (T+12:00:00)
rtc_set_time(event_time + (12 * SECONDS_PER_HOUR));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_asse... |
t.h"
#include "board/board.h"
#include "drivers/ambient_light.h"
#include "drivers/backlight.h"
#include "kernel/low_power.h"
#include "services/common/analytics/analytics.h"
#include "services/common/battery/battery_monitor.h"
#include "services/common/new_timer/new_timer.h"
#include "syscall/syscall_internal.h"
#inc... | {
const uint16_t HALF_BRIGHTNESS = (prv_backlight_get_intensity() - BACKLIGHT_BRIGHTNESS_OFF) / 2;
// update the debug stats
if (new_brightness > HALF_BRIGHTNESS && s_current_brightness <= HALF_BRIGHTNESS) {
// getting brighter and have now transitioned past half brightness
analytics_stopwatch_start(ANAL... |
static void prv_change_state(BacklightState new_state) {
s_light_state = new_state;
// Calculate the new brightness and reset any timers based on our state.
int32_t new_brightness = 0;
switch (new_state) {
case LIGHT_STATE_ON:
new_brightness = prv_backlight_get_intensity();
new_timer_stop(s_t... |
(y1.raw_value + (FIXED_S16_3_ONE.raw_value / 2 - 1)) / FIXED_S16_3_ONE.raw_value;
int16_t y2_rounded = (y2.raw_value + (FIXED_S16_3_ONE.raw_value / 2)) / FIXED_S16_3_ONE.raw_value;
if (y1_rounded > y2_rounded) {
// AA algorithm will draw lines in one way only, so non-AA should reject those too
return;
}... | {
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
// apply draw box and clipping
x1.integer += ctx->draw_state.drawing_box.origin.x;
x2.integer += ctx->draw_state.drawing_box.origin.x;
y += ctx->draw_state.drawing_box.origin.y;
// round edges:
x1.raw_value += (FIXED_S16_3_ONE.raw_value / 2);... |
void graphics_private_plot_vertical_line(GContext *ctx, int16_t x, Fixed_S16_3 y1, Fixed_S16_3 y2,
uint16_t opacity) {
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
// apply draw box and clipping
x += ctx->draw_state.drawing_box.origin.x;
y1.integer += ctx->dr... |
ubscribe(void) {
AccelServiceState * session = accel_service_private_get_session(PebbleTask_Unknown);
accel_session_data_unsubscribe(session);
}
// ----------------------------------------------------------------------------------------------
void accel_tap_service_subscribe(AccelTapHandler handler) {
AccelServ... | prv_assert_session_task() | ;
// we better have unsubscribed at this point
PBL_ASSERTN(session->manager_state == NULL);
// A deferred free means one lingering event was posted. We will free the session once the event
// gets drained in 'prv_do_data_handle'
if (!session->deferred_free) {
kernel_free(session);
}
}
// -----------... |
t contain a valid IRK, perhaps we should use and whitelist the
// identity address and treat it as a normal connection intent?
// See note in BT spec "Note: An all zero Identity Resolving Key data field indicates that a
// device does not have a valid resolvable private address." in Security Manager chapter.
re... | {
return BTErrnoNotEnoughResources;
} |
memset(intent, 0, alloc_size);
s_intents = (GAPLEConnectionIntent *) list_prepend(&s_intents->node,
&intent->node);
if (request->is_bonding_based) {
// Create bonding info cache if it has not been created yet:
intent->is_bonding_based = tr... |
croll(scroll_layer, ScrollDirectionDown, true);
(void)recognizer;
}
static void scroll_layer_click_config_provider(ScrollLayer *scroll_layer) {
// Config UP / DOWN button behavior:
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, scroll_layer_scroll_up_click_handler);
window_single_repeating_click_su... | (scroll_layer,
scroll_layer_get_content_offset(scroll_layer), false) | ;
}
bool scroll_layer_get_clips_content_offset(ScrollLayer *scroll_layer) {
return scroll_layer->content_sublayer.clips;
}
|
/*
* 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 HcAdvertEnableResponseData *data = (const HcAdvertEnableResponseData *)resp->payload;
error = data->error;
if (data->current_state != AdvertState_Running) {
PBL_LOG(LOG_LEVEL_INFO, "State was 0x%x after advert enable", data->current_state);
}
} | else {
const ble_error_t *error_ptr = (const ble_error_t *)resp->payload;
error = *error_ptr;
}
if (error == BLE_STATUS_OK) {
rv = true;
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Advert error: 0x%"PRIx8" for cmd: 0x%"PRIx8,
error, request->command_id);
}
} else {
PB... |
= (1 << 7), //!< Low Battery detected. Set when BSUP drops below ResVoltFall
};
enum PmicRail {
PmicRail_SD1, //!< 1.8V
PmicRail_LDO1, //!< 3.0V
PmicRail_LDO2, //!< 2.0V
};
#define AS3701B_CHIP_ID 0x11
#define AS3701B_WRITE_ADDR 0x80
#define AS3701B_READ_ADDR 0x81
static bool prv_read_register(uint8_t regi... | prv_register_set_bit(PmicRegisters_RESET_CNTL, 1) | ) {
while (1) {}
__builtin_unreachable();
}
return false;
}
// On the as3701b, a power_off will cut power to all rails. We want to keep the
// RTC alive, so rather than performing a sw_power_off, enter the pmic's standby
// mode, powering down all but LDO2.
bool pmic_power_off(void) {
// Only enable int... |
ero, GCompOpSet, GColorWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_set-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test GCompOpTint, from same size to size.
// Setup:
// - Source is a 10x10 square, white.
// - Destination is either a black or white square.
// Result:
// - Whe... | (src_data, color.argb, sizeof(src_data)) | ;
color = prv_next_color(color);
const int16_t y_upper = LEGEND_HEIGHT + offset_y;
const GRect upper_rect = GRect(x, y_upper, WIDTH, 1);
const GRect upper_left_legend_rect = GRect(0, y_upper, 3, 1);
const GRect upper_right_legend_rect = GRect(offset_x, y_upper, 3, 1);
bitblt_bitmap_into_bitmap_... |
Stubs
/////////////////////
#include "stubs_app_state.h"
#include "stubs_graphics.h"
#include "stubs_heap.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_ui_window.h"
#include "stubs_process_manager.h"
#include "stubs_unobstructed_a... | menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks){
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
}) | |
void prv_adjust_value_boundaries(HealthValue *values, size_t num_values,
const HealthServiceTimeRange *range);
bool prv_activity_session_matches(const ActivitySession *session, HealthActivityMask mask,
time_t time_start, time_t time_end);
int64_t prv_... | MIN(*num_sessions,
s_sys_activity_get_sessions_values.out.num_sessions) | ;
i++) {
sessions[i] = s_sys_activity_get_sessions_values.out.sessions[i];
}
*num_sessions = s_sys_activity_get_sessions_values.out.num_sessions;
return s_sys_activity_get_sessions_values.out.result;
}
typedef struct {
struct {
uint16_t day_of_week;
} in;
struct {
ActivityMetricAverage... |
out the arguments from the last run
static void reset_last_args_for_mock() {
memset(&s_last_args_for_mock, 0x00, sizeof(s_last_args_for_mock));
}
// Validate the arguments based on the shape that is drawn
static bool validate_args(ArgsForMock *actual_args, ArgsForMock *valid_args) {
if (memcmp(actual_args, valid_... | (&context, GColorClear) | |
/*
* 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... | (&pstring16_list, WeatherDbStringIndex_ShortPhrase) | ;
const bool is_valid_entry_update_time =
(entry->last_update_time_utc != WEATHER_SERVICE_INVALID_DATA_LAST_UPDATE_TIME);
const uint16_t location_pstring_length = location_pstring->str_length;
if (!is_valid_entry_update_time || (location_pstring_length == 0)) {
PBL_LOG(LOG_LEVEL_ERROR,
"In... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (out_error) | ;
const size_t header_len = sizeof(GetNotificationAttributesMsg);
if (length > header_len) {
ANCSAttribute *attributes[NUM_FETCHED_NOTIF_ATTRIBUTES] = {};
bool complete = ancs_util_get_attr_ptrs(data + header_len, length - header_len,
s_fetched_notif_attributes,
... |
s_short_data_fragment,
sizeof(s_short_data_fragment));
cl_assert_equal_b(success, true);
ppogatt_send_next(transport);
prv_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn,
s_sho... | (s_characteristics[0][PPoGATTCharacteristicData]) | ;
fake_gatt_client_op_assert_no_write();
// In the past we had a bug here where the pending ACK would get sent out.
// See https://pebbletechnology.atlassian.net/browse/PBL-24651
}
void test_ppogatt__ignore_invalid_packet_type(void) {
test_ppogatt__open_session_when_found_pebble_app();
PPoGATTPacket packet ... |
/*
* 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... | (ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1,
(int32_t *)&health_data->hr_last_updated) | |
/*
* 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... | (STUCK_BUTTON_REGISTER) | ;
uint8_t* button_counter = (uint8_t*) (&button_counter_register);
bool result = false;
for (int button_id = 0; button_id < NUM_BUTTONS; button_id++) {
if (!button_is_pressed(button_id)) {
button_counter[button_id] = 0;
continue;
}
if (button_counter[button_id] >= STUCK_BUTTON_THRESHOLD)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (int i = 0; i < (int)length; ++i) {
const gap_device_t *const gap_device = &devices[i];
BTDeviceInternal device;
dialog_utils_bd_address_to_bt_device(&gap_device->address, &device);
for (int j = 0; j < (int)num_permitted_devices; ++j) {
if (bt_device_internal_equal(&device, &permitted_devices[... | |
.h"
#include "services/common/system_task.h"
#include "system/passert.h"
#include "util/attributes.h"
#include "util/crc32.h"
#include "util/math.h"
#include "util/size.h"
// Defines how many PULSE file descriptors may be open concurrently
// This is shared across all supported domains
#define MAX_PULSE_FDS 3
#define... | pulse_reliable_send(resp, response_len) | ;
}
static void prv_respond_internal_error(Command *cmd, size_t length,
status_t status_code) {
InternalErrorResponse *resp = pulse_reliable_send_begin(
PULSE2_BULKIO_PROTOCOL);
resp->opcode = BULKIO_RESP_INTERNAL_ERROR;
resp->status_code = status_code;
size_t r... |
ic const PrefsTableEntry *prv_prefs_entry(const uint8_t *key, size_t key_len) {
uint32_t num_entries = ARRAY_LENGTH(s_prefs_table);
const PrefsTableEntry *entry = s_prefs_table;
for (uint32_t i = 0; i < num_entries; i++, entry++) {
if (!strncmp((const char *)key, entry->key, key_len)) {
return entry;
... | {
SettingsFile file = {{0}};
if (settings_file_open(&file, SHELL_PREFS_FILE_NAME, SHELL_PREFS_FILE_LEN) == S_SUCCESS) {
// Keys in the backing store include the null terminator, so we add 1 to key_len
success = (settings_file_get(&file, entry->key, key_len + 1, value, value_len)
... |
mutex_unlock(s_mutex);
return success;
}
// ------------------------------------------------------------------------------------
// Called from KernelMain when we get a blob DB event. We take this opportunity to update the state
// of the given pref
void prefs_private_handle_blob_db_event(PebbleBlobDBEvent *even... |
IMUCoordinateAxis axis = AXIS_X;
bool invert = false;
if (int2_status & BMA255_INT_STATUS_2_SLOPE_FIRST_X) {
axis = AXIS_X;
invert = cfg->axes_inverts[AXIS_X];
} else if (int2_status & BMA255_INT_STATUS_2_SLOPE_FIRST_Y) {
axis = AXIS_Y;
invert = cfg->axes_inverts[AXIS_Y];
} el... | PBL_ASSERTN(mode == BMA255PowerMode_Normal ||
mode == BMA255PowerMode_LowPower1 ||
mode == BMA255PowerMode_Standby) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | text_resources_init_font(SYSTEM_APP,
resource, 0, &s_system_fonts_info_table[i]) | ) {
// Can't initialize the font for some reason
return NULL;
}
}
return &s_system_fonts_info_table[i];
}
}
// Didn't find the given font, invalid key.
return (GFont)NULL;
}
void sys_font_reload_font(FontInfo *fontinfo) {
text_resources_init_font(fontinfo->base.app_... |
/*
* 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_cache_buffer, 0, sizeof(s_cache_buffer)) | ;
memset(s_cache_keys, 0, sizeof(s_cache_keys));
keyed_circular_cache_init(&s_test_cache, s_cache_keys, s_cache_buffer, sizeof(TestCacheItem),
TEST_BUFFER_SIZE);
}
void test_keyed_circular_cache__cleanup(void) {
}
// tests
static void prv_push(int index) {
keyed_circular_cache_push(&... |
/*
* 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... | ABS(delta) | ;
// Move everything above the selection rectangle (if there is anything) and stretch the selection
// color up
const int16_t area_above_selection_rect_height = selection_rect->origin.y;
if (area_above_selection_rect_height > 0) {
const GRect area_above_selection_rect = GRect(-selection_rect->origin.x, 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... | (BUTTON_ID_UP, prv_calibrate_confirm_cb) | ;
window_single_click_subscribe(BUTTON_ID_DOWN, prv_calibrate_confirm_pop);
window_single_click_subscribe(BUTTON_ID_BACK, prv_calibrate_confirm_pop);
}
static TimerID s_timer = TIMER_INVALID_ID;
static void prv_push_calibration_dialog(void *data) {
shell_prefs_set_should_prompt_display_calibration(false);
Co... |
.flags = 0,
.layout = LayoutIdTest,
}
},
{
.header = {
.id = {0xcc},
.timestamp = 14000,
.duration = 30,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
}
},
{
.header = {
.id = {0xdd},
.timestamp = 16000,
.durat... | cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1421178000), 0) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[0].header.id));
// check second
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
/... |
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
}
// // These tests only make sense if the insights are enabled
// // Now we shouldn't see another notification for the next 6 days
// for (int i = 0; i < 6; ++i) {
/... | prv_set_step_history_avg() | ;
activity_insights_init(rtc_get_time());
// Make sure we don't trigger in the default state (not above median, not active)
s_data.steps_per_minute = 0;
s_data.metric_history[ActivityMetricStepCount][0] = AVERAGE_STEPS;
prv_minute_update(ACTIVE_MINUTES);
cl_assert_equal_i(fake_kernel_services_notifications... |
) { \
char error_msg[256] = {0}; \
snprintf(error_msg, sizeof(error_msg), \
"HealthServiceInternalTimeRange equal\n" \
" a: {last_day_idx:%d, num_days:%d, seconds_first_day:%d, seconds_last_day:%d, " \
"seconds_total_last_day: %d}\n" \
" b: {last_day_idx... | (now - 10, now + 11, &range) | ;
cl_assert_equal_b(result, true);
cl_assert_equal_range(range, ((HealthServiceTimeRange){
.last_day_idx = 0,
.num_days = 1,
.seconds_first_day = 10,
.seconds_last_day = 10,
.seconds_total_last_day = 33142,
}));
// clamps value that goes into the future
const time_t first_valid_time =
... |
ed);
}
}
// Report back up to which byte we've consumed the data.
sys_app_inbox_service_consume(&info);
}
bool app_inbox_service_register(uint8_t *storage, size_t storage_size,
AppInboxMessageHandler message_handler,
AppInboxDroppedHandler drop... | prv_lock() | ;
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(tag);
if (!inbox) {
goto unlock;
}
if (prv_is_inbox_being_written(inbox)) {
++inbox->num_failed;
PBL_LOG(LOG_LEVEL_ERROR, "Dropping data, already written by <%p>", inbox->writer);
// Don't send event here, whe... |
l_unfocused) {
// This event resulted in our last focusable modal window being popped, let's transition away.
prv_handle_modal_to_app_transition_focus();
}
const bool is_app_hidden_and_unfocused =
(!(update.properties & ModalProperty_Transparent) && !is_modal_unfocused);
const bool was_app_hidden_a... | {
UpdateContext *ctx = data;
Window *window = iter->current_top_window;
// Handle window state changes
const bool is_visible = (iter->current_idx >= iter->first_opaque_idx);
if (!window->on_screen && is_visible) {
// We've been exposed by a higher priority modal window stack emptying out, become on scree... |
ctx->properties &= ~ModalProperty_Transparent;
}
if (window->is_render_scheduled) {
// There is a visible window that will render, add the render requested property
ctx->properties |= ModalProperty_RenderRequested;
}
}
if (is_focused) {
// There is a modal with focus, remove the ... |
window.window.window_handlers.unload = prv_time_picker_window_unload;
data->time_picker_window.window.window_handlers.appear = prv_time_picker_window_appear;
if (data->creating_alarm) {
time_selection_window_set_to_current_time(&data->time_picker_window);
} else {
int hour, minute;
alarm_get_hours_mi... | if (data->alarm_kind == ALARM_KIND_CUSTOM) {
alarm_get_custom_days(alarm_id, data->scheduled_days);
} |
prv_setup_day_picker_window(data);
app_window_stack_push(&data->day_picker_window, true);
}
|
*system_transport2 = (Transport *) TransportID2;
CommSession *system_session2 = comm_session_open(system_transport2, &s_transport_imp,
TransportDestinationSystem);
cl_assert(system_session2);
cl_assert_equal_p(s_last_closed_transport, system_transport);
cl_as... | (s_send_next_count, 1) | ;
comm_session_send_next(session);
cl_assert_equal_i(fake_system_task_count_callbacks(), 1);
comm_session_send_next(session);
cl_assert_equal_i(fake_system_task_count_callbacks(), 1);
cl_assert_equal_i(s_send_next_count, 1);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(s_send_next_coun... |
date_is_sharing(GAPLEConnection *connection, bool prev_is_sharing) {
const bool is_sharing = prv_is_sharing(connection);
if (is_sharing == prev_is_sharing) {
return;
}
if (is_sharing) {
if (s_ble_hrm_subscription_count == 0) {
prv_reschedule_popup_timer();
prv_execute_on_kernel_main(prv_sta... | bt_unlock() | ;
prv_execute_on_kernel_main(prv_stop_hrm_kernel_main);
} else {
bt_unlock();
}
}
void ble_hrm_handle_sharing_request_response(bool is_granted,
BLEHRMSharingRequest *sharing_request) {
PBL_LOG(LOG_LEVEL_INFO, "BLE HRM sharing permission is_granted=%u", is_gra... |
/*
* 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... | {
cached_resource = kernel_malloc_check(sizeof(CachedResource));
*cached_resource = (CachedResource){};
cached_resource->id = resource_id;
s_resource_list = (CachedResource *)list_prepend((ListNode *)s_resource_list,
(ListNode *)cached_resource);
} | |
t_controller->stop();
}
workout_push_summary_window();
workout_dialog_pop(&active_window->end_workout_dialog);
app_window_stack_remove(&active_window->window, false);
}
static void prv_end_workout_down_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutActiveWindow *active_window = contex... | (BUTTON_ID_DOWN, prv_down_click_handler) | ;
}
static void prv_window_unload_handler(Window *window) {
WorkoutActiveWindow *active_window = window_get_user_data(window);
if (active_window) {
app_timer_cancel(active_window->update_timer);
app_timer_cancel(active_window->hr_measuring_timer);
gbitmap_destroy(active_window->action_bar_start);
g... |
w or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This app only makes sense... | (msg_text_layer, GColorBlack) | |
uffer[12];
itoa(error_code, error_code_buffer, sizeof(error_code_buffer));
dbgserial_putstr(error_code_buffer);
display_error_code(error_code);
static uint8_t prev_button_state = 0;
prev_button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
while (1) {
// See if we should restart
uint8_t b... | sad_watch(ERROR_CANT_LOAD_FW) | ;
}
bool force_boot_recovery_mode = check_force_boot_recovery();
if (force_boot_recovery_mode) {
dbgserial_putstr("Force-booting recovery mode...");
}
if (force_boot_recovery_mode || check_for_fw_start_failure()) {
if (!switch_to_recovery_fw()) {
// We've failed to load recovery mode too many ... |
truct PACKED {
PPoGATTPacketType type:3;
uint8_t sn:PPOGATT_SN_BITS;
PPoGATTResetCompleteClientIDPayloadV1 payload;
} expected_response = {
.sn = 0,
.type = PPoGATTPacketTypeResetComplete
};
if (s_ppogatt_version > 0) {
expected_response.payload = (const PPoGATTResetCompleteClientIDPayloa... | ppogatt_handle_read_or_notification(s_characteristics[1][PPoGATTCharacteristicMeta],
(const uint8_t *) &s_meta_v0_app, sizeof(s_meta_v0_app),
BLEGATTErrorSuccess) | ;
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_app.app_uuid), true);
}
void test_ppogatt__handles_unknown_read_response(void) {
uint8_t data;
ppogatt_handle_read_or_notification(s_unknown_characteristics,
&data, sizeof(data), BLEGATTErrorSuccess);
// No crashes... |
// doing legacy2 aplite-compatibility work. Note we don't have to worry
// about 3.x aplite here because we don't support running 3.x aplite apps on
// 3.x basalt platforms.
s_app_state_ptr->legacy2_framebuffer = memory_segment_split(
app_state_ram, NULL, sizeof(GBitmap));
if (!s_app_state_p... | {
return &s_app_state_ptr->app_message_ctx;
} |
#if !defined(PLATFORM_TINTIN)
BLEAppState* app_state_get_ble_app_state(void) {
return &s_app_state_ptr->ble_app_state;
}
#endif
ClickManager* app_state_get_click_manager() {
return &s_app_state_ptr->click_manager;
}
WindowStack* app_state_get_window_stack() {
return &s_app_state_ptr->window_stack;
}
FrameBuf... |
->config.will_close(action_menu,
data->performed_item,
data->config.context);
}
}
static void prv_invoke_did_close(ActionMenu *action_menu) {
ActionMenuData *data = window_get_user_data(&action_menu->window);
if (data->config.did_close) {
data->config.d... | (crumbs_anim, IN_OUT_ANIMATION_DURATION) | ;
// combine the two
Animation *spawn_anim = animation_spawn_create(content_in, crumbs_anim, NULL);
return spawn_anim;
#else
return content_in;
#endif
}
static Animation* prv_create_content_out_animation(ActionMenuData *data,
const ActionMenuLevel *level) {
// animate the ease out of the current level
... |
text) {
HealthCardView *health_card_view = context;
for (int i = 0; i < CardCount; i++) {
if (i != health_card_view->current_card_index) {
layer_set_hidden(health_card_view->card_layers[i], true);
}
}
if (!finished) {
prv_set_window_background_color(health_card_view);
} else {
prv_refr... | {
window_set_click_context(BUTTON_ID_UP, context);
window_set_click_context(BUTTON_ID_SELECT, context);
window_set_click_context(BUTTON_ID_DOWN, context);
window_single_click_subscribe(BUTTON_ID_UP, prv_up_down_click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler);
window... |
///////////////////////////////////////////////////////////////////////////////////////////////////
// API Functions
//
HealthCardView *health_card_view_create(HealthData *health_data) {
HealthCardView *health_card_view = app_malloc_check(sizeof(HealthCardView));
*health_card_view = (HealthCardView) {
.heal... |
_FILE_C_NAME = "c";
static const size_t TEST_FILE_C_SIZE = 9001; // it's over 9000!
static char s_test_file_c[TEST_FILE_C_SIZE];
static uint32_t num_pages(void) {
return pfs_get_size() / PFS_SECTOR_SIZE;
}
void test_pfs__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /*... | cl_assert(fd == E_DOES_NOT_EXIST) | ;
fd = pfs_open("dne", OP_FLAG_OVERWRITE, FILE_TYPE_STATIC, 0);
cl_assert(fd == E_DOES_NOT_EXIST);
char name[] = {'a'};
int fds[100]; // arbitrarily large # of FDs
int i;
for (i = 0; i < (sizeof(fds) - 1); i++) {
fds[i] = pfs_open(name, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
name[0]++;
if (fds[... |
23 || config.minute > 59) {
PBL_LOG(LOG_LEVEL_DEBUG, "Invalid config for id %u! Blowing it out! "
"Hours %u Minutes %u Kind %u", id, config.hour, config.minute,
config.kind);
settings_file_delete(file, &key, sizeof(key));
return false;
}
*config_out = (AlarmConfig)... | (AnalyticsEvent_AlarmCreated, info) | ;
return id;
}
// ----------------------------------------------------------------------------------------------
typedef bool (*AlarmOperationCallback)(AlarmId id, AlarmConfig *config, void *context);
static void prv_alarm_operation(AlarmId id, AlarmOperationCallback callback, void *context) {
SettingsFile file;... |
icense 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 "jerry-api.h"
#include "rocky_api_graphics.h"
#include "rocky_api_graphics_path2d.... | {
Window *const top_window = app_window_stack_get_top_window();
if (!top_window) {
return jerry_create_undefined();
}
layer_mark_dirty(&top_window->layer);
return jerry_create_undefined();
} | |
ode_update(const AMSEntityUpdateNotification *update,
const uint16_t value_length) {
const AMSShuffleMode shuffle_mode = prv_parse_queue_value(update->value_str, value_length);
PBL_LOG(LOG_LEVEL_DEBUG, "Queue shuffle mode update: %d", shuffle_mode);
// TODO: Do som... | prv_handle_track_title_update(update, value_length) | ;
// FIXME: This is a workaround. See PBL-21818
music_update_track_position(0);
return;
case AMSTrackAttributeIDDuration:
prv_handle_track_duration_update(update, value_length);
return;
default:
break;
}
break;
default:
... |
cl_assert_equal_i(delay, 15);
}
void test_alarm__set_snooze_alarm() {
alarm_set_snooze_alarm();
cl_assert_equal_i(s_snooze_timer_timeout_ms, 10 * 1000);
cl_assert_equal_i(s_num_alarm_events_put, 0);
s_current_minute = 10;
cl_assert_equal_i(s_num_alarm_events_put, 1);
}
void test_alarm__get_string_for_kind(... | prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule) | ;
cl_assert_equal_i(s_num_timeline_adds , 3);
s_current_hour = 10;
s_current_minute = 30;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
}
void test_alarm__recurring_daily_alarm_timeout_behind(void) {
AlarmId id;
s_current_hour = 11;
s_current_minute = 30;
id = alarm_create(&(Alarm... |
ion(void) {
// Force in an old data version.
typedef struct {
uint32_t data_version;
uint32_t color;
uint32_t rtc_freq;
} MfgDataV1;
MfgDataV1 old_data = {
.data_version = 1,
.color = 3,
.rtc_freq = 4
};
flash_write_bytes((const uint8_t*) &old_data, FLASH_REGION_MFG_INFO_B... | cl_assert(memcmp(fpga_buffer + HEADER_SIZE, s_boot_fpga, sizeof(s_boot_fpga)) == 0) | ;
mfg_info_set_disp_offsets((GPoint) { 2, 3 });
char model[MFG_INFO_MODEL_STRING_LENGTH] = "123456789012345";
mfg_info_set_model(model);
// Now let's write in an fpga image
mfg_info_update_constant_data();
// Let's make sure the mfg data is still persisted
cl_assert_equal_i(mfg_info_get_rtc_freq(), 1)... |
_equal_i(regular_timer_seconds_count(), 0);
cl_assert_equal_i(regular_timer_minutes_count(), 0);
regular_timer_deinit();
}
// Janky black box smoke-test to exercise the ANCS message re-assembly state
// machine
void test_ancs__should_handle_small_and_large_messages(void) {
// Get 4 complete notifications
prv_s... | fake_notification_storage_get_store_count() | |
tem_task_watchdog_feed();
psleep(1);
}
return (attempt < max_attempts);
}
// NOTE: the caller must hold the device's state lock
static void prv_disable(HRMDevice *dev) {
mutex_assert_held_by_curr_task(dev->state->lock, true);
// Turn off our watchdog timer
prv_disable_watchdog(dev);
// Make sure inte... | (&s_as7000_watchdog_timer) | ;
}
static void prv_disable_watchdog(HRMDevice *dev) {
mutex_assert_held_by_curr_task(dev->state->lock, true);
regular_timer_remove_callback(&s_as7000_watchdog_timer);
s_missing_interrupt_count = 0;
}
static bool prv_start_loader(HRMDevice *dev) {
// check if the loader is already running
if (!prv_is_app_ru... |
seTimeMin);
cl_assert_equal_i(secs_to_wait, 100);
cl_assert_equal_i(fake_gap_le_connect_params_get_last_requested(), ResponseTimeMin);
// another consumer at lower rate should not have any effect
fake_gap_le_connect_params_reset_last_requested();
conn_mgr_set_ble_conn_response_time(
&s_hdl, BtConsumerU... | (&s_hdl, BtConsumerLeServiceDiscovery, ResponseTimeMin, 1,
prv_granted_handler) | |
DDR(device->address),
.Encryption_Change_Status = status,
.Encryption_Mode = encrypted ? emEnabled : emDisabled,
};
GAP_LE_Event_Data_t event = (GAP_LE_Event_Data_t) {
.Event_Data_Type = etLE_Encryption_Change,
.Event_Data_Size = sizeof(GAP_LE_Encryption_Change_Event_Data_t),
.Event_Data.GAP_LE... | {
return 0;
} |
static const Encryption_Key_t s_fake_irk = {
0xaa,
0xaa,
};
static const BD_ADDR_t s_resolving_bd_addr = {
0xaa, 0xff, 0xff, 0xff, 0xff,
0x7f /* 6th byte: bit 6 set, bit 7 unset indicates "resolvable private address" */
};
static const BD_ADDR_t s_not_resolving_bd_addr = {
0xff,
};
const Encryption_Key_t... |
ER_INVALID_ID);
cl_assert(!stub_new_timer_is_scheduled(timer_id));
cl_assert(timeline_add(&item1));
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(!prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_n... | stub_new_timer_timeout(timer_id) | / 1000);
rtc_set_time(20 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_count(), 3);
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(15*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(35 * 60);
cl... |
ware of our running rate.
actual_interval = BMA255SampleInterval_125HZ;
prv_enable_operating_mode(AccelOperatingMode_Data, actual_interval);
return accel_get_sampling_interval();
}
static void prv_configure_operating_mode(void) {
BMA255SampleInterval interval_us = accel_get_sampling_interval();
const uint8... | (BMA255PowerMode_Standby) | ;
if (num_samples > BMA255_FIFO_MAX_FRAMES) {
num_samples = BMA255_FIFO_MAX_FRAMES;
}
BMA255_DBG("Setting num samples to: %"PRIu32, num_samples);
// Note that with the bma255, we do not want to use Bypass mode when
// collecting a single sample as this will result in uneven sampling.
// The accelerome... |
_timezone(&tz_info);
struct tm time_tm = s_init_time_tm;
time_t utc_sec = mktime(&time_tm);
fake_rtc_init(100 /*initial_ticks*/, utc_sec);
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(false);
prv_activity_algorithm_erase_minute_data();
prv_activity_init_and_set_enabled(true);
// S... | ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricSleepRestfulSeconds,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){1 * SECONDS_PER_MINUTE, 0, 0, 0, 0, 0, 0})) | ;
// Check that we have the expected # of activities
ASSERT_NUM_ACTIVITY_SESSIONS(3); // 2 sleep sessions + 1 activity sessions
ASSERT_STEP_ACTIVITY_SESSION_PRESENT(&walk_activity);
// The expected resting calories
int minutes_today = 17 * MINUTES_PER_HOUR + 3 + wait_min;
const int exp_resting_kcalories_... |
serts.h"
#include <stdio.h>
// stubs
#include "stubs_process_manager.h"
#include "stubs_passert.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
/////////////////////////////
void test_gtypes__gpoint_scale_by_gsize(void) {
GSize from = GSize(10, 20);
GSize to = GSize(20, 40);
GPoint point = GPoint(10, ... | (2, PBL_IF_RECT_ELSE(1,2)) | ;
#else
#error "unknown platform"
#endif
}
void test_gtypes__pbl_if_round_else(void) {
#if defined(PLATFORM_TINTIN)
cl_assert_equal_i(2, PBL_IF_ROUND_ELSE(1,2));
#elif defined(PLATFORM_SNOWY)
cl_assert_equal_i(2, PBL_IF_ROUND_ELSE(1,2));
#elif defined(PLATFORM_SPALDING)
cl_assert_equal_i(1, PBL_IF_ROUND_ELSE(1,2... |
if (false == prv_is_multi_click_enabled(recognizer)) {
return 0;
} |
if (recognizer->config.multi_click.max == 0) {
return prv_multi_click_get_min(recognizer);
}
return recognizer->config.multi_click.max;
}
static uint32_t prv_multi_click_get_timeout(ClickRecognizer *recognizer) {
if (false == prv_is_multi_click_enabled(recognizer)) {
return 0;
}
if (recognizer->co... | |
X, CLIP_RECT_DRAW_BOX, false, 1);
prv_draw_hline_test_pattern(&ctx, prv_hline_pattern_assign_horizontal_line_raw);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_core_assign_horizontal_line_raw")));
};
void prv_blend_horizontal_line_raw(GBitmap *framebuffer, int16_t... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_core_assign_vertical_line_raw"))) | ;
};
void prv_blend_vertical_line_raw(GBitmap *framebuffer, int16_t x, int16_t y1, int16_t y2,
GColor color);
static void prv_vline_pattern_blend_vertical_line_raw(GContext *ctx, int16_t x, int16_t y1,
int16_t y2, GColor color) {
... |
/*
* 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... | (sizeof(Uuid)) | ;
if (!removed_id) {
return;
}
*removed_id = *reminder_id;
PebbleEvent event = {
.type = PEBBLE_REMINDER_EVENT,
.reminder = {
.type = type,
.reminder_id = removed_id,
}
};
event_put(&event);
}
void reminders_handle_reminder_updated(const Uuid *reminder_id) {
prv_put_reminder_... |
}
}
// we need to run this before reserving a new GC region so that we don't
// think a region is free when in reality we just rebooted in the middle of it
// being re-written
int fd;
if ((fd = pfs_open_gc_file(0, false)) >= S_SUCCESS) {
// we rebooted while we were in the middle of a garbage collecti... | {
uint16_t avail_kilobytes = (uint16_t)(get_available_pfs_space() / 1024);
analytics_set(ANALYTICS_DEVICE_METRIC_PFS_SPACE_FREE_KB,
avail_kilobytes, AnalyticsClient_System);
} |
/*
* Debug Utilities
*/
// TODO: Remove once we figure out PBL-20973
void pfs_collect_diagnostic_data(int fd, void *diagnostic_buf, size_t diagnostic_buf_len) {
mutex_lock_recursive(s_pfs_mutex);
memcpy(diagnostic_buf, &PFS_FD(fd), MIN(diagnostic_buf_len, sizeof(FileDesc)));
mutex_unlock_recursive(s_pfs_mut... |
/*
* 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_glance_reload(prv_basic_reload_cb, s_test_state.context) | |
break;
}
if (s_current_brightness != new_brightness) {
prv_change_brightness(new_brightness);
}
}
static bool prv_light_allowed(void) {
if (!s_backlight_allowed) {
return false;
}
if (backlight_is_enabled()) {
if (backlight_is_ambient_sensor_enabled()) {
// If the light is off and it... | backlight_set_ambient_sensor_enabled(!backlight_is_ambient_sensor_enabled()) | ;
if (prv_light_allowed() && !ambient_light_is_light()) {
prv_change_state(LIGHT_STATE_ON_TIMED);
} else {
prv_change_state(LIGHT_STATE_OFF);
// FIXME: PBL-24793 There is an edge case of when the backlight has timed off
// or you're toggling it from no ambient (always light on buttons) to ambient,
... |
{ 1376, 320, -56},
{ 1224, 504, 136},
{ 912, 472, -16},
{ 1104, 304, -24},
{ 1096, 440, -104},
{ 1096, 360, -32},
{ 1280, 328, 64},
{ 1440, 272, 40},
{ 1232, 176, 80},
{ 1248, 0, 184},
{ 1288, -80, 72},
{ 1192, -48, -8},
{ 1032, 24, -8},
{ 952, -16, 64},
{ 117... | // 73 seconds
{ 1408, 296, 16},
{ 1512, 240, 72},
{ 1328, 128, 48},
{ 1144, 24, 72},
{ 1136, -56, 48},
{ 1088, -32, -24},
{ 944, 16, -48},
{ 736, 16, -40},
{ 848, -56, -8},
{ 888, -40, -48},
{ 800, 8, -128},
{ 1072, -16, -96},
{ 1224, -32, 0},
{ 1320, 88, -136... |
{ 1704, 184, -184},
{ 1744, 112, -192},
{ 1360, 144, -208},
{ 864, 136, -192},
{ 688, 208, -40},
{ 736, 248, -48},
{ 928, 240, -48},
// 76 seconds
{ 992, 256, -56},
{ 1136, 240, 40},
{ 1392, 320, 136},
{ 944, 448, 200},
{ 1408, 544, 40},
{ 1136, 536, -72},
{ ... |
te;
bool result;
uint16_t nack_count;
}I2cTransfer;
typedef struct I2cBus{
I2C_TypeDef *i2c;
uint8_t user_count;
I2cTransfer transfer;
volatile bool busy;
}I2cBus;
static I2cBus i2c_buses[BOARD_I2C_BUS_COUNT];
static uint32_t s_guard_events[] = {
I2C_EVENT_MASTER_MODE_... | (BOARD_CONFIG.i2c_bus_configs[bus_idx].i2c_sda, false) | ;
}
//! Power up I2C bus power supply
//! Always lock bus and peripheral config access before use
static void bus_rail_power_up(uint8_t bus_idx) {
if (BOARD_CONFIG.i2c_bus_configs[bus_idx].rail_ctl_fn == NULL) {
return;
}
// check that at least enough time has elapsed since the last turn-off
// TODO: is t... |
dbgserial_putstr("exit standby");
system_hard_reset();
}
periph_config_disable(RCC_APB1PeriphClockCmd, RCC_APB1Periph_PWR);
}
void boot_main(void) {
gpio_enable_all();
check_and_handle_resuming_from_standby();
dbgserial_init();
dbgserial_putstr("");
dbgserial_putstr(" ___ _ _ _ ");
dbgseri... | {
if (i == 4) {
dbgserial_putstr("Remove charger to shutdown");
i = 0;
}
delay_ms(500);
++i;
} |
dbgserial_putstr("Shutting down.");
pmic_full_power_off();
}
watchdog_init();
#ifndef NO_WATCHDOG
watchdog_start();
#endif
gpio_disable_all();
jump_to_fw();
}
|
ftware
* 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 "util/heap.h"
#include "util/assert.h"
#include ... | {
heap->corruption_handler(heap->corrupt_block);
heap->corrupt_block = NULL;
} |
}
static void prv_handle_corruption(Heap * const heap, void *ptr) {
if (heap->corruption_handler) {
heap->corrupt_block = ptr;
return;
}
UTIL_ASSERT(0); // Error: Heap corrupt around <ptr>
}
static HeapInfo_t *find_segment(Heap* const heap, unsigned long n_units);
static HeapInfo_t *allocate_block(Heap... |
/*
* 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... | ("Hello\0w\0rld", 11, 12) | ;
assert_out_equal("\x06Hello\x02w\x04rld", 12);
}
void test_cobs_encode__max_block_1(void) {
// vector[] = { 0x01, 0x02, ..., 0xfe };
uint8_t vector[254];
for (size_t i = 0; i < sizeof(vector); ++i) {
vector[i] = i + 1;
}
// expected[] = { 0xff, 0x01, 0x02, ..., 0xfe };
uint8_t expected[255];
expe... |
_item_added->header.timestamp, rtc_get_time());
// Second alarm goes off. First one should be up again
s_current_hour = 11;
s_current_minute = 30;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 2);
cl_assert_equal_i(s_num_alarm_events_put, 2);
cl_assert_equal_i(s_num_timeline_adds, 9);
cl... | (s_num_alarm_events_put, 4) | ;
cl_assert_equal_i(s_num_timeline_adds, 17);
cl_assert_equal_i(s_num_timeline_removes, 11);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm__just_once_alarm_timeout_ahead(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind =... |
ot use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR ... | {
// If we have to truncate, truncate at the beginning as opposed to the end.
filename = filename + (filename_length - 15);
} |
strncpy(msg->filename, filename, sizeof(msg->filename));
// Copy the log message into the struct and set the message_length param.
const int max_message_length = buffer_len - sizeof(LogBinaryMessage);
// Use vnsiprintf only if we don't have sufficient stack space
if (!prv_use_default_log_msg(msg, max_messa... |
IT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY , ORIGIN_RECT_CLIP_NXNY , true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY , 2, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r2_aa_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx,... | MIN(RECT_WIDTH, RECT_HEIGHT) | ) / 2) - 1, GCornerBottomRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_bottomright.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__origin_aa_corners(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// TODO: Remove these #ifdefs in PBL-15916 when ... |
{
if (op != BtPersistBondingOpWillDelete) {
return;
}
// Clean up the bonding_id field for the bonding that just got removed:
bt_lock();
GAPLEConnection *connection = gap_le_connection_find(prv_find_connection_with_bonding_id,
(void *)(uintptr_t)bondi... |
void gap_le_connection_copy_device_name(
const GAPLEConnection *connection, char *name_out, size_t name_out_len) {
bt_lock();
{
if (!gap_le_connection_is_valid(connection)) {
goto unlock;
}
if (connection->device_name != NULL) {
strncpy(name_out, connection->device_name, name_out_len);... | |
on the line.
delay_us(200);
return result;
}
bool pmic_enable_battery_measure(void) {
prv_mon_config_lock();
return prv_set_mon_config(&MON_CONFIG[PMIC_MON_CONFIG_VBAT_INDEX]);
// Don't prv_unlock, we don't want anyone else mucking with the mon config until
// pmic_disable_battery_measure is called.
}
... | {
prv_log_status_registers("PMIC charge/connection status changed");
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info) | ;
cl_assert(horiz_advance != 0);
cl_assert_equal_i(horiz_advance,
text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info));
cl_assert_equal_i(horiz_advance,
text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info));
}
void test_text_resources__horiz_advance_multiple(v... |
uint32_t first_used_region = UINT32_MAX;
for (uint32_t offset = 0; offset < LOG_REGION_SIZE; offset += LOG_PAGE_SIZE) {
uint32_t flash_addr = FLASH_REGION_DEBUG_DB_BEGIN + offset;
FlashLoggingHeader hdr;
flash_read_bytes((uint8_t *)&hdr, flash_addr, sizeof(hdr));
if (!prv_flash_log_valid(&hdr)) { /... | (prev_log_id, hdr.log_file_id,
LOG_ID_BITWIDTH) | ;
if ((dist == 0) || (dist == 1)) {
prev_log_id = hdr.log_file_id;
multiple_gens_found |= (dist != 0 && offset != 0);
continue; // keep looking
}
// we have found a page to use, but we need to erase the contents first
prv_erase_unit(prv_get_unit_base_address(flash_addr)... |
UPDATED_EVENT,
.bluetooth = {
.le = {
.hrm_sharing_state = {
.subscription_count = subscription_count,
},
},
},
};
event_put(&e);
}
static void prv_reschedule_popup_timer(void);
static void prv_push_reminder_popup_kernel_main_cb(void *unused) {
bt_lock();
if (s_bl... | PBL_LOG(LOG_LEVEL_INFO, "BLE HRM sharing: all revoked") | ;
}
static void prv_update_subscription(GAPLEConnection *connection, bool is_subscribed) {
bt_lock_assert_held(true);
if (connection->hrm_service_is_subscribed == is_subscribed) {
return;
}
PBL_LOG(LOG_LEVEL_INFO, "BLE HRM sharing: conn <%p> is_subscribed=%u", connection, is_subscribed);
const bool prev... |
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_ui_window.h"
#include "stubs_process_manager.h"
#include "stubs_unobstructed_area.h"
// Fakes
////////////////////////
//#include "fake_gbitmap_png.c"
GDrawState graphics_context_get_... | menu_layer_get_selected_index(&l) | .row);
cl_assert_equal_i(0, l.selection.y);
const int16_t basic_cell_height = menu_cell_basic_cell_height();
const int row0_vertically_centered = (height - basic_cell_height)/2;
cl_assert_equal_i(row0_vertically_centered, scroll_layer_get_content_offset(&l.scroll_layer).y);
menu_layer_set_selected_index(&l, ... |
Y);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw5_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 5);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw5_c... | (&ctx.dest_bitmap, "draw_rect_origin_sw4_clip_xy.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 4);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// SW = 5
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ... |
/*
* 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_free_list) {
prv_check_free_list();
// remove the head of the free list to be returned
m = s_free_list;
s_free_list = mbuf_get_next(s_free_list);
mbuf_clear_next(m);
} else {
// check that there is space left in this pool
PBL_ASSERTN(s_mbuf_pool_space[pool] > 0);
s_mbuf_pool_spac... |
mutex_unlock(s_free_list_lock);
mbuf_set_flag(m, MBUF_FLAG_IS_FREE, false);
mbuf_set_data(m, data, length);
return m;
}
void mbuf_free(MBuf *m) {
if (!m) {
return;
}
PBL_ASSERTN(mbuf_is_flag_set(m, MBUF_FLAG_IS_MANAGED));
PBL_ASSERTN(!mbuf_is_flag_set(m, MBUF_FLAG_IS_FREE)); // double free
// ... |
-600, 680, 320},
{ -616, 672, 328},
{ -624, 664, 336},
{ -616, 680, 320},
{ -616, 672, 328},
{ -608, 704, 320},
{ -608, 672, 320},
{ -600, 672, 336},
{ -616, 688, 328},
{ -608, 696, 360},
{ -608, 696, 328},
{ -608, 680, 344},
{ -592, 704, 344},
{ -608, 696, 328},
... | { -696, 688, 120},
{ -672, 704, 128},
{ -680, 680, 120},
{ -696, 704, 136},
{ -688, 696, 160},
// 94 seconds
{ -688, 664, 176},
{ -704, 648, 200},
{ -688, 664, 184},
{ -680, 688, 184},
{ -680, 680, 160},
{ -672, 688, 136},
{ -688, 680, 200},
{ -696, 704, 200},
... |
{ -680, 696, 40},
{ -680, 712, 48},
{ -688, 704, 40},
{ -688, 688, 56},
{ -680, 688, 40},
{ -696, 696, 56},
{ -688, 696, 56},
{ -696, 696, 48},
{ -688, 696, 40},
{ -688, 696, 48},
{ -688, 680, 40},
{ -704, 712, 40},
// 97 seconds
{ -696, 712, 80},
{ -696, 704... |
RECT_ELSE(18, DISP_ROWS - (ACTION_BAR_WIDTH + RIGHTSIDE_PADDING) - ICON_WIDTH)
#if PBL_ROUND
#define ICON_POSITION_CENTERED_X (DISP_ROWS / 2 - ICON_WIDTH / 2)
#endif
static const int16_t DOT_SIZE = 8;
static const uint32_t UNFOLD_DURATION = 300;
static const int16_t UNFOLD_EXPAND = 8;
static const uint32_t ANIMATION... | modal_window_push(&s_phone_ui_data->window, ModalPriorityNotification, false /* don't animate */) | ;
}
//! Icon setters.
// This one will make sure the *previously* set icon resource is destroyed.
// The final icon set must still be destroyed alongside the reel.
static void prv_set_icon_resource(TimelineResourceId timeline_res_id) {
TimelineResourceInfo timeline_res = {
.res_id = timeline_res_id,
};
AppRe... |
cl_assert(word_iter_state.current.width_px == HORIZ_ADVANCE_PX * 5) | ;
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_codepoint == '-');
cl_assert(*line.start == 's');
// le
cl_assert(*word_... | |
/*
* 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... | (new_state == RecognizerState_Possible) | ;
break;
default:
WTF;
}
recognizer->state = new_state;
}
static bool prv_should_handle_touches(Recognizer *recognizer, const TouchEvent *touch_event) {
if (recognizer_get_state(recognizer->fail_after) != RecognizerState_Failed) {
return false;
}
if (!recognizer->subscriber.filter) {
... |
= {
.id = {0x29, 0xac, 0xd8, 0xb5, 0x9, 0xc7, 0x4c, 0x31, 0xbf,
0x6f, 0x3, 0x64, 0xd0, 0x5b, 0x9b, 0xc2},
.parent_id = {0},
.timestamp = 1425254400, // midnight March 2 2015 UTC
.duration = 4 * MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.layout = LayoutIdTe... | cl_assert_equal_i(pin_db_flush(), 0) | ;
cl_assert(timeline_add(&item));
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
cl_assert_equal_i(timeline_init(&head), S_SUCCESS);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1430200800 - 60 * 60), S_SUCCESS);
co... |
ms = state->timestamp_ms;
}
unlock:
mutex_unlock_recursive(s_mutex);
return result;
}
// ---------------------------------------------------------------------------------------------
DEFINE_SYSCALL(bool, sys_accel_manager_consume_samples, AccelSessionRef session, uint32_t samples) {
bool success = true;
mut... | {
mutex_lock_recursive(s_mutex);
{
PBL_ASSERTN(s_tap_subscribers_count > 0);
if (--s_tap_subscribers_count == 0 && !s_data_subscribers) {
PBL_LOG(LOG_LEVEL_DEBUG, "Stopping accel service");
if (accel_running()) {
accel_stop();
}
}
}
mutex_unlock_recursive(s_mutex);
} |
// -------------------------------------------------------------------------------------------
DEFINE_SYSCALL(void, sys_accel_manager_data_unsubscribe, AccelSessionRef session) {
mutex_lock_recursive(s_mutex);
{
AccelSubscriberState* state = prv_subscriber_state(session);
if (state != NULL) {
// Re... |
cl_assert_equal_b(shared_prf_storage_get_root_key(key_type, &keys_out[key_type]), true) | ;
// It's a byte array inside, so memcmp should be OK to use:
cl_assert_equal_i(memcmp(&keys[key_type], &keys_out[key_type], sizeof(keys[0])), 0);
}
}
void test_shared_prf_storage_v2__local_device_name(void) {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_local_device_name(NULL... | |
tc_time() {
return rtc_get_time();
}
static bool deleted_and_expired(SettingsRecordHeader *hdr) {
return (hdr->val_len == 0)
&& (hdr->last_modified <= (utc_time() - DELETED_LIFETIME));
}
static void compute_stats(SettingsFile *file) {
file->dead_space = 0;
file->used_space = 0;
file->last_modified = 0... | {
return false;
} |
uint8_t hdr_key[hdr->key_len];
settings_raw_iter_read_key(iter, hdr_key);
if (memcmp(key, hdr_key, hdr->key_len) == 0) {
return true;
}
return false;
}
static bool prv_is_desired_hdr(SettingsRawIter *iter, const uint8_t *key, int key_len) {
if (overwritten(&iter->hdr) || partially_written(&iter->hdr))... |
/*
* 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... | {
size_t cropped_length = MIN(MUSIC_BUFFER_LENGTH - 1, src_length);
if (src) {
memcpy(dest, src, cropped_length);
}
dest[cropped_length] = 0;
} |
static void prv_put_now_playing_changed_event(void) {
PebbleEvent e = {
.type = PEBBLE_MEDIA_EVENT,
.media.type = PebbleMediaEventTypeNowPlayingChanged
};
event_put(&e);
}
bool music_set_connected_server(const MusicServerImplementation *implementation, bool connected) {
enum {
Disconnected = -1,
... |
#include "util/size.h"
#include "util/trig.h"
#include "vendor/jerryscript/jerry-libm/include/math.h" // easiest way to get M_PI
#include <stdlib.h>
#include <string.h>
#define ROCKY_SINGLETON "_rocky"
// [MT] including <math.h> causes the jerry-libm header to get included again :(
extern double round(double d);
ui... | (parent, name, result) | |
uffer, sizeof(buffer),
"%s {%u args}", cmd->cmd_str, cmd->num_params);
} else {
prompt_send_response(cmd->cmd_str);
}
}
}
typedef struct CommandArgs {
unsigned int num_args;
const char* args[NUM_SUPPORTED_PARAM_COUNT];
} CommandArgs;
static CommandArgs prv_parse_argu... | if (UNLIKELY(prompt_command_is_executing())) {
return;
} | |
/*
* 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... | mktime(&francois_birthday) | , 612528240);
struct tm rons_birthday = {
.tm_sec = 17,
.tm_min = 1,
.tm_hour = 9,
.tm_mday = 10,
.tm_mon = 4,
.tm_year = 63,
};
cl_assert_equal_i(mktime(&rons_birthday), -1);
struct tm alex_marianetti_birthday = {
.tm_sec = 29,
.tm_min = 4,
.tm_hour = 17,
.tm_mday = 2,... |
-32},
{ 936, 80, -8},
{ 944, 56, 16},
{ 968, 48, 8},
{ 984, 32, -32},
{ 1000, 8, -64},
{ 1064, -8, -8},
{ 1144, 8, -16},
// 40 seconds
{ 1328, 56, 0},
{ 1648, 112, -112},
{ 1264, 184, -96},
{ 952, 184, -56},
{ 880, 40, 112},
{ 1256, 0, 248},
{ 1392, -40, 280},... | { 904, -96, -120},
{ 872, -96, -136},
{ 880, -72, -136},
{ 912, -80, -168},
{ 936, -104, -184},
{ 952, -96, -216},
{ 968, -72, -288},
{ 1032, -56, -296},
{ 1088, -104, -264},
{ 1144, -64, -264},
{ 1128, -72, -272},
{ 1424, -112, -224},
{ 1512, 0, -320},
{ 1248, -7... |
{ 1328, -32, 16},
{ 1160, 8, 72},
{ 960, 72, 24},
{ 856, 136, 8},
{ 896, 176, -104},
{ 840, 160, -72},
{ 968, 80, -120},
{ 944, 24, -128},
{ 1032, 56, -232},
{ 1120, 16, -264},
{ 1248, 16, -352},
{ 1456, 40, -440},
{ 1432, -24, -408},
{ 1120, 0, -280},
{ 864,... |
/*
* 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(db_id == s_blobdb_id);
return test_db_read(key, key_len, val_out, val_len);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.