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... | RTC_WriteBackupRegister(REBOOT_REASON_STUCK_TASK_CALLBACK, 0) | ;
RTC_WriteBackupRegister(REBOOT_REASON_DROPPED_EVENT, 0);
}
uint32_t reboot_get_slot_of_last_launched_app(void) {
return RTC_ReadBackupRegister(SLOT_OF_LAST_LAUNCHED_APP);
}
void reboot_set_slot_of_last_launched_app(uint32_t app_slot) {
RTC_WriteBackupRegister(SLOT_OF_LAST_LAUNCHED_APP, app_slot);
}
|
/*
* 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_lock(s_adc_mutex) | ;
periph_config_enable(ADC1, RCC_APB2Periph_ADC1);
ADC_TempSensorVrefintCmd(ENABLE);
ADC_CommonInitTypeDef ADC_CommonInitStruct;
// Single ADC mode
ADC_CommonStructInit(&ADC_CommonInitStruct);
ADC_CommonInitStruct.ADC_Mode = ADC_Mode_Independent;
// ADCCLK = PCLK2/2
ADC_CommonInitStruct.ADC_Prescaler ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kernel_free(msg) | ;
return true;
}
static void prv_analytics_bt_chip_boot_cb(void *context) {
HcAnalyticsRebootInfo *info = context;
analytics_event_bt_chip_boot(info->build_id, info->last_crash_lr, info->reboot_reason_code);
kernel_free(info);
}
void hc_endpoint_analytics_host_handler(const HcProtocolMessage *msg) {
switch ... |
indow_create();
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_pop_window_load,
.unload = prv_window_unload
});
WindowStack *stack = app_state_get_window_stack();
// Switch to the app state to push a window
stub_pebble_tasks_set_current(PebbleTask_App);
cl_check(stack);
cl_as... | window_stack_remove(window, true) | ;
cl_assert_equal_i(window_stack_count(stack), 0);
cl_assert_equal_i(prv_get_load_unload_count(), 0);
cl_assert_equal_i(prv_get_appear_disappear_count(), 0);
// FIXME: PBL-25460
// cl_assert_equal_b(animation_is_scheduled(fake_animation_get_first_animation()), false);
}
// Push two windows back to back, be... |
alues are 1 indexed instead of zero indexed and the first three
// are the only raw ones, so we can get away with just subtracting 1.
if (object_type == ObjectSysResources) {
resource_layout = (MemoryLayout) {
resource_storage_flash_get_unused_bank()->begin,
resource_storage_flash_get_unused_ban... | prv_get_layout_for_type(object_type) | ;
return layout->end_address - layout->start_address;
}
void pb_storage_raw_write(PutBytesStorage *storage, uint32_t offset, const uint8_t *buffer,
uint32_t length) {
const MemoryLayout *layout = storage->impl_data;
const uint32_t flash_address = layout->start_address + offset;
flash... |
compositor_app_render_ready();
}
prv_send_did_focus_event(properties & ModalProperty_Unfocused);
}
static void prv_animation_teardown(Animation *animation) {
if (s_animation_state.impl->teardown) {
s_animation_state.impl->teardown(animation);
}
s_animation_state = (CompositorTransitionState) { 0 };
... | (s_animation_state.animation) | |
ne_wordwrap_clip_outside_nx.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_outside_x);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_outside_x.${BIT_DEPTH_NAME... | ("draw_text_null_w", fb, GColorWhite) | );
setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NULL_H,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_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... | (&framebuffer, &(GSize) { DISP_COLS, DISP_ROWS }) | |
/*
* 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, value, context) | |
essStorageBuiltin, tictoc_md->process_storage);
app_install_release_md(tictoc_md);
const PebbleProcessMd *music_md = app_install_get_md(music_id, false);
cl_assert(music_md != NULL);
cl_assert_equal_b(false, music_md->has_worker);
cl_assert_equal_i(ProcessTypeApp, music_md->process_type);
cl_assert_equal_i... | (music_id) | );
// Wait 10 minutes. Should return false
fake_rtc_increment_time(10 * SECONDS_PER_MINUTE);
cl_assert_equal_b(false, app_install_is_prioritized(music_id));
// Update with most recent time but don't let it expire
app_install_mark_prioritized(music_id, false /* can_expire */);
fake_rtc_increment_time(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... | gpio_output_set(&ICE40LP->creset, true) | ; // CRESET -> HIGH
#if !defined(TARGET_QEMU)
PBL_ASSERT(!gpio_input_read(&ICE40LP->cdone), "CDONE not low after reset");
// Wait until CRESET goes high again. It's open-drain (and someone with
// tweezers might be grounding it) so it may take some time.
PBL_ASSERT(prv_spin_until_creset_is(true), "CRESET not ... |
/*
* 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 (i == data_len - 2) {
// if 2 leftover bytes
*out++ = prv_encode_char(data[i] >> 2);
*out++ = prv_encode_char(((data[i] & 0x03) << 4) | (data[i + 1] >> 4));
*out++ = prv_encode_char((data[i + 1] & 0x0F) << 2);
*out++ = '=';
} else if (i == data_len - 1) {
// if 1 leftover byte... |
}
if (result < out_len) {
*out++ = 0;
}
return result;
}
|
pe == ActivitySessionType_Walk) {
type = ActivityInsightType_ActivitySessionWalk;
icon = TIMELINE_RESOURCE_ACTIVITY;
prv_add_metric_duration_info(headings, headings_buf_size, values, values_buf_size, session);
prv_add_avg_pace_metric_info(headings, headings_buf_size, values, values_buf_size, session);
... | {
uint32_t num_sessions = ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT;
ActivitySession *sessions = task_zalloc_check(num_sessions * sizeof(ActivitySession));
if (activity_get_sessions(&num_sessions, sessions)) {
for (unsigned int i = 0; i < num_sessions; i++) {
if (sessions[i].ongoing) {
// Don't proc... |
// ------------------------------------------------------------------------------------------------
void NOINLINE activity_insights_process_minute_data(time_t now_utc) {
// Update our active stats - needs to happen each iteration to ensure it's current
// If we're above the 'active' threshold, increment the numbe... |
6, 24},
{ 1680, 320, -16},
{ 1616, 360, 0},
{ 1704, 368, 24},
{ 1624, 288, 64},
{ 1384, 216, 56},
{ 1184, 88, 24},
{ 536, -1072, 64},
// 377 seconds
{ 616, -240, -304},
{ 632, -512, 32},
{ 1120, 120, -232},
{ 1352, 216, -128},
{ 1600, 280, 40},
{ 1784, 352, 0},
... | { 1000, 0, -560},
{ 1272, 0, -224},
{ 1528, 128, -8},
{ 1632, 328, -48},
{ 1888, 664, -296},
{ 2024, 992, -440},
{ 1608, 928, -424},
{ 1224, 768, -208},
{ 832, 1736, -168},
{ 656, 1488, 144},
{ 848, 1400, 272},
{ 920, 1136, 56},
{ 1320, 896, 40},
{ 1704, 904, -40}... |
{ 1576, 408, -16},
{ 1512, 368, 64},
{ 1264, 280, 8},
{ 1176, 264, -72},
// 385 seconds
{ 944, -120, 192},
{ 832, -520, 280},
{ 472, -360, -88},
{ 864, -104, -336},
{ 1200, 96, -256},
{ 1480, 200, 48},
{ 1600, 304, 72},
{ 1792, 512, -112},
{ 1936, 864, -208},
... |
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 CONDITIONS OF AN... | strcmp(title, reminder_info->title) | != 0) {
timeline_item_free_allocated_buffer(reminder);
return true; // continue iteration
}
if (reminder_info->filter_cb && !reminder_info->filter_cb(&header, context)) {
timeline_item_free_allocated_buffer(reminder);
return true; // continue iteration
}
reminder_info->match = true;
return ... |
sult);
}
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
AppWorkerMessage m;
app_worker_send_message('x', &m);
APP_LOG(APP_LOG_LEVEL_INFO, "crashing worker");
}
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
AppWorkerResult result = app_worker_k... | (window, click_config_provider) | ;
window_stack_push(window, true /* Animated */);
window_set_background_color(window, GColorBlack);
Layer *window_layer = window_get_root_layer(window);
text_layer = text_layer_create(GRect(7, 40, 144-7, 168-40));
text_layer_set_text_color(text_layer, GColorWhite);
text_layer_set_background_color(text_la... |
b/graphics/gtypes.h"
#include "applib/ui/property_animation.h"
#include "applib/ui/status_bar_layer.h"
#include "applib/ui/shadows.h"
#include "applib/ui/window.h"
#include "resource/resource_ids.auto.h"
#include "services/normal/timeline/layout_layer.h"
#include "services/normal/timeline/notification_layout.h"
#includ... | (swap_layer->layer.frame.size.h, size.h) | ,
});
return layout;
}
return NULL;
}
static void prv_announce_layout_will_appear(SwapLayer *swap_layer, LayoutLayer *layout) {
swap_layer->swap_in_progress = true;
if (swap_layer->callbacks.layout_will_appear_handler) {
return swap_layer->callbacks.layout_will_appear_handler(swap_layer, layout,
... |
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language go... | PBL_ASSERTN(m) | ;
return m->length;
}
uint32_t mbuf_get_chain_length(MBuf *m) {
uint32_t total = 0;
while (m) {
total += m->length;
m = m->next;
}
return total;
}
// MBuf chain management
////////////////////////////////////////////////////////////////////////////////
void mbuf_append(MBuf *m, MBuf *new_mbuf) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (menu_layer, &window->layer.bounds) | ;
menu_layer_set_callbacks(menu_layer, data, &(MenuLayerCallbacks) {
.get_num_sections = (MenuLayerGetNumberOfSectionsCallback) menu_get_num_sections_callback,
.get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback) menu_get_num_rows_callback,
.get_cell_height = (MenuLayerGetCellHeightCallback) menu_... |
x = 1;
const int16_t steps_y = 1;
prv_prepare_fb_steps_xy(fb_size, steps_x, steps_y);
ctx.draw_state.avoid_text_orphans = true;
const GSize size_with_orphan_avoidance = graphics_text_layout_get_max_used_size(&ctx,
text, font, bo... | (GSize(180, 360), 1, 1) | |
g_for_kind(ALARM_KIND_JUST_ONCE, all_caps), "ONCE");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_CUSTOM, all_caps), "CUSTOM");
}
void test_alarm__handle_clock_change(void) {
AlarmId id1, id2;
id1 = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_WEEKENDS });
id2 = alarm_creat... | cl_assert_equal_i(s_num_timeline_adds, 3) | ;
alarm_get_next_enabled_alarm(&next_alarm_time);
cl_assert_equal_i(next_alarm_time,
s_current_day + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
id2 = alarm_create(&(AlarmInfo) { .hour = 11, .minute = 30, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id2, 11, 30, false, ALA... |
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 the License is distributed on an "AS IS" BASIS,
* WITHOUT WARR... | if ((data->to_reel == NULL) || (from_duration != PLAY_DURATION_INFINITE)) {
duration = MAX(duration, from_duration);
} | |
.y.integer, left, inner_left,
starting_edge, ending_edge, ignore_close_angles);
prv_draw_scanline_collision_points(ctx, center.y.integer, inner_right, right,
starting_edge, ending_edge, ignore_close_angles);
} else {
prv_d... | if (draw_bottom) {
prv_draw_scanline_collision_points(ctx, center.y.integer + i + special_line_offset_bottom,
left, right, bottom_starting_edge, bottom_ending_edge,
ignore_close_angles);
} | |
olorBlack, false);
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10));
#if PBL_COLOR
ASSERT_CALLED(graphics_line_draw_stroked_aa(&context, GPoint(5, 5), GPoint(45, 10), 2));
#else
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), 2));
#endif
setup_test(&context, tru... | GRect(20, 80, 40, 10) | , 4, SW_ODD));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__fill(void) {
// Fill shape, non-antialiased (Stroke width/color N/A)
setup_test(&context, false, 5, GColorBlack, GColorBlack, false);
graphics_fill_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GRect(1... |
P_XY, ORIGIN_RECT_CLIP_XY, true, 3);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw3_clip_xy.${BIT_DEPTH_NAME}.pbi"... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw1_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// SW = 2
setup_test_aa_sw(&ctx, fb... |
heading_style_font = TextStyleFont_Header,
.paragraph_style_font = TextStyleFont_Body,
};
const LayoutNodeConfig *reminder_timestamp_node_config = NULL;
const LayoutNodeConfig *notification_timestamp_node_config = NULL;
const LayoutNodeConfig *header_node_config = NULL;
if (is_reminder) {
reminder_ti... | analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_JUMBOJI_COUNT, AnalyticsClient_System) | ;
}
}
#endif
}
static void prv_hide_or_show_banner_icon(KinoLayer *icon_layer,
const GRect *notification_layout_frame) {
const int32_t frame_too_high_for_icon_threshold = -2;
const int32_t top_banner_not_visible_threshold = 18;
const bool icon_hidden =
(notifi... |
s_activity_reward_settings.reward.activity.trigger_active_minutes) {
INSIGHTS_LOG_DEBUG("Not showing activity reward - have only been currently active for "
"%"PRIu16" minutes out of %"PRIu8, s_activity_reward_state.active_minutes,
s_activity_reward_settings.reward.a... | {
actions[num_actions++] = (TimelineItemAction) {
.id = action_id++,
.type = TimelineItemActionTypeOpenWatchApp,
.attr_list = open_app_action_attr_list,
};
} |
if (config->response.enabled) {
actions[num_actions++] = (TimelineItemAction) {
.id = config->response.type,
.type = TimelineItemActionTypeInsightResponse,
.attr_list = response_action_attr_list,
};
}
TimelineItemActionGroup action_group = {
.num_actions = num_actions,
.actions ... |
/*
* 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... | {
push_window();
} |
static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
}
static void push_window(void) {
Window *window = window_create();
window_set_fullscreen(window, s_next_window_fullscreen);
window_set_window_handlers(window, (WindowHandlers) {
.unl... |
/*
* 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_size) | );
// Init QSPI peripheral
QSPI_InitTypeDef qspi_config;
QSPI_StructInit(&qspi_config);
qspi_config.QSPI_SShift = QSPI_SShift_HalfCycleShift;
// QSPI clock = AHB / (1 + QSPI_Prescaler)
qspi_config.QSPI_Prescaler = prescaler - 1;
qspi_config.QSPI_CKMode = QSPI_CKMode_Mode0;
qspi_config.QSPI_CSHTime = QS... |
/*
* 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... | (watchfaces_glance, title, NULL) | ;
}
static void prv_watchfaces_glance_subtitle_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *node, UNUSED const GRect *box,
UNUSED const GTextNodeDrawConfig *config, UNUSED bool render, char *buffer, size_t buffer_size,
void *user_data) {
LauncherAppGlanceStructured *structured_glance... |
/*
* 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... | {
SettingsVibePatternsData *data = (SettingsVibePatternsData *)context;
i18n_free_all(data);
prv_log_analytic_if_toggled(VibePatternFeature_Notifications, VibeClient_Notifications, data);
prv_log_analytic_if_toggled(VibePatternFeature_PhoneCalls, VibeClient_PhoneCalls, data);
prv_log_analytic_if_toggled(VibeP... |
static void prv_draw_row_cb(SettingsCallbacks *context, GContext *ctx,
const Layer *cell_layer, uint16_t row, bool selected) {
SettingsVibePatternsData *data = (SettingsVibePatternsData *)context;
const char *title = NULL;
const char *subtitle = NULL;
VibeClient client = VibeClie... |
/*
* 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_mock_type(void) | ;
memcpy(s_stored_keys, keys_in, sizeof(SM128BitKey) * SMRootKeyTypeNum);
}
static uint32_t s_rng_output;
#define RNG_ROUNDS (sizeof(SM128BitKey) / sizeof(uint32_t))
#define RNG_MAX_RETRIES (20)
bool rng_rand(uint32_t *rand_out) {
bool rv = cl_mock_type(bool);
if (rv) {
*rand_out = s_rng_output;
++s_rng... |
pb_state.append_offset = append_offset;
s_pb_state.remaining_bytes = size;
s_pb_state.type = request->type;
s_pb_state.has_cookie = request->has_cookie;
s_pb_state.index = index;
s_pb_state.current_command = PutBytesInit;
s_pb_state.is_success = false;
// Generate a token
const uint32_t r = rand();
s... | {
case PutBytesIdle:
return (command == PutBytesInit || command == PutBytesInstall);
case PutBytesInit:
return (command == PutBytesPut || command == PutBytesAbort);
case PutBytesPut:
return (command == PutBytesPut || command == PutBytesCommit || command == PutBytesAbort);
case PutBytesCommit:
case... |
}
static bool prv_is_invalid_command_for_current_state(PutBytesCommand command) {
if (!prv_is_valid_command_for_current_state(command)) {
PBL_LOG(LOG_LEVEL_ERROR, "PutBytes command 0x%x not permitted in current state 0x%x",
command, s_pb_state.current_command);
return true;
}
return false;
}... |
/*
* 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... | {
animation_private_update(NULL, animation_private_animation_find(animation), 0);
} |
}
static void prv_transition_teardown_destroy_animation(Animation *a) {
// needed for compatibility with 2.x apps: manually free animation + clear pointer
WindowTransitioningContext *ctx = animation_get_context(a);
ctx->animation = NULL;
animation_destroy(a);
}
static Animation *prv_window_transition_move(Wi... |
{
PBL_LOG(LOG_LEVEL_ERROR, "ble_gatts_read_cfm: %u", e);
} |
}
static bool prv_handle_emulated_meta_read(const HcProtocolMessage *msg) {
PBL_ASSERTN(msg->command_id == HcMessageID_Gatt_Read);
HcGattHdr *hdr = (HcGattHdr *)&msg->payload[0];
PBL_LOG(LOG_LEVEL_DEBUG, "MR");
// First ack the read request itself
BTErrno rv = BTErrnoOK;
hc_protocol_enqueue_response(msg... | |
-------------------------
// Fetch sleep sessions using the health_service API
static uint32_t s_health_sessions_count;
static uint32_t s_health_sessions_max;
static ActivitySession *s_health_sessions;
static time_t s_health_sessions_sleep_time;
static time_t s_health_sessions_awake_time;
static bool prv_activity_iter... | 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);
// Set default user settings
activity_prefs_set_height_mm(ACTIVITY_DEFAULT_HEIGHT_MM);
activity_prefs_set_weight_dag(ACTIVITY_DEFAULT_WEIGHT_DAG... |
/*
* 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 rv;
} |
rv = prv_read_item_header(next_item_out, &id);
return rv;
}
static bool prv_timestamp_title_compare_func(SettingsFile *file, SettingsRecordInfo *info,
void *context) {
// Check entry is valid
if (info->key_len != UUID_SIZE || info->val_len == 0) {
return true; ... |
midnight_march_2_pst);
// day 2
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &multiday_item.header.id));
cl_assert(uuid_equal(&state.node->id, &multiday_item.header.id));
cl_assert(state.node->all_day);
cl_assert_equal_i(state.node->timestamp, 1425369600);
cl_assert_equal_i... | (state.node->duration, 0) | |
andlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
static const PropertyAnimationImplementation implementation = {
.base = {
.setup = prv_setup_handler,
.update = (AnimationUpdateImplementation) property_animation_update_int16,
.teardown = prv_teard... | (h, handlers, context) | ;
animation_set_duration(h, duration);
animation_set_delay(h, delay);
animation_set_auto_destroy(h, false);
prv_clear_handler_histories();
animation_schedule(h);
int max_loops = 20;
int num_loops = 0;
uint64_t start_ms = prv_now_ms();
uint64_t time_ms;
while (s_stopped_handler_calls.num_calls =... |
/*
* 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 RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER);
} | |
domain data");
} else {
prv_respond_internal_error(cmd, length, ret);
}
return;
}
OpenResponse *resp = pulse_reliable_send_begin(PULSE2_BULKIO_PROTOCOL);
resp->opcode = BULKIO_RESP_DOMAIN_OPEN;
resp->fd = fd;
pulse_reliable_send(resp, sizeof(*resp));
}
static void prv_handle_close(Comman... | (cmd->erase.domain) | ;
if (domain_handler) {
size_t payload_length = length - sizeof(cmd->opcode) - sizeof(cmd->erase);
status_t ret = domain_handler->erase_proc(cmd->erase.data, payload_length, cmd->erase.cookie);
if (ret == E_INVALID_ARGUMENT) {
prv_respond_malformed_command(cmd, length, "Invalid domain data");
... |
model_iter_next(&new_idx, &has_next));
}
void test_timeline_model__and_back(void) {
TimelineModel model = {0};
model.direction = TimelineIterDirectionFuture;
time_t first_time = 1421178000;
// Note: 1421178000 = Tue Jan 13 11:40:00 PST 2015
timeline_model_init(first_time, &model);
cl_assert(timeline_model... | cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(0)) | ;
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(1));
cl_assert(timeline_model_get_iter_state(2) == timeline_model_get_iter_state_with_timeline_idx(2));
cl_assert(!timeline_model_iter_prev(&new_idx, NULL));
}
void test_timeline_model__graceful_delete_middle(void) {... |
ze_t i = 0; i < ARRAY_LENGTH(thin_values); i++) {
action_menu_level_add_action(root_level, thin_values[i], prv_noop_action_callback, NULL);
}
const unsigned int selected_index = 1;
prv_prepare_canvas_and_render_action_menus_static(root_level, selected_index, 0);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_... | action_menu_level_add_child(root_level, voice_level, "Dismiss") | ;
ActionMenuLevel *template_level = action_menu_level_create(1);
action_menu_level_add_action(template_level,
"This won't be seen",
prv_noop_action_callback,
NULL);
action_menu_level_add_child(root_level, template_level,... |
_session);
#endif
#if CAPABILITY_HAS_MICROPHONE
prv_stop_mic_and_cleanup(data);
#endif
if (failed) {
snprintf(data->status_string, STATUS_STRING_LENGTH, "Test Failed");
app_window_stack_push(&data->status_window, true);
}
}
static bool prv_test_is_running(AppData *data) {
return (data->current_test_st... | {
// Init window
window_init(&data->status_window, "");
Layer *window_layer = window_get_root_layer(&data->status_window);
GRect bounds = window_layer->bounds;
bounds.origin.y += 40;
// Init text layer
text_layer_init(&data->status_text, &bounds);
text_layer_set_text(&data->status_text, data->status_st... |
//--------------------------------------------------------------------------------
// TX/RX Menus & Windows
//--------------------------------------------------------------------------------
// The same menu layer is reused for TX / RX, we just handle it differentely
// based on whether we are currently executing a 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... | profiler_cycles_to_us(node->total) | ;
}
uint32_t profiler_node_get_count(ProfilerNode *node) {
return node->count;
}
uint32_t profiler_get_total_duration(bool in_us) {
uint32_t total;
if (g_profiler.end > g_profiler.start) {
total = g_profiler.end - g_profiler.start;
} else {
total = (UINT32_MAX - g_profiler.start) + g_profiler.end;
}... |
r->periph->LISR & DMA_LISR_HTIF3;
break;
case (uintptr_t)DMA1_Stream4:
case (uintptr_t)DMA2_Stream4:
*has_tc = this->stream->controller->periph->HISR & DMA_HISR_TCIF4;
*has_ht = this->stream->controller->periph->HISR & DMA_HISR_HTIF4;
break;
case (uintptr_t)DMA1_Stream5:
case (ui... | {
return;
} |
// we only support 1 transfer per stream so assert that the stream isn't already initialized
PBL_ASSERTN(!this->stream->state->initialized);
// sanity check that the stream and controller are valid
switch ((uintptr_t)this->stream->periph) {
case (uintptr_t)DMA1_Stream0:
case (uintptr_t)DMA1_Stream1:
... |
ueue_operation();
}
// -----------------------------------------------------------------------------
// Reset & Error Handling
static void prv_reset_and_idle(void) {
prv_set_state(ANCSClientStateIdle);
prv_reset_reassembly_context();
}
static void prv_reset_and_retry(void *unused) {
if (s_ancs_client == NULL) ... | if (s_ancs_client->state == ANCSClientStateIdle) {
prv_check_ancs_alive();
} else {
s_ancs_client->alive_check_pending = true;
} | |
efine ALPHA_100 0xC0
static const int TARGET_FPS = 30;
static Window *s_window;
static Layer *s_canvas_layer;
static uint8_t *s_color_table = NULL;
// Sorted by Hue, Value, Saturation
static uint8_t color_table_hvs[] = {
0x00,
0x15,
0x10,
0x2a,
0x25,
0x20,
0x3f,
0x3a,
0x35,
0x30,
0x34,
0x24,
... | {
set_text_element(data->fg_color_text, data->fg_color_text_buffer, true);
} | else {
set_text_element(data->fg_color_text, data->fg_color_text_buffer, false);
}
// Set BG Color Text
uint8_t bg_color = data->bg_color.argb;
snprintf(data->bg_color_text_buffer, sizeof(data->bg_color_text_buffer), "BG = 0x%02x", bg_color);
if (data->property == PROPERTY_BG_COLOR) {
set_text_eleme... |
nnection_status_notifications(connection)) {
return;
}
prv_send_notification(conn_idx, s_pps_ctx.att_hdl.conn_status);
}
void pebble_pairing_service_handle_gatt_mtu_change(Connection *connection, uint16_t conn_idx) {
if (!connection_is_subscribed_to_gatt_mtu_notifications(connection)) {
return;
}
prv... | ble_gatts_add_characteristic(&uuid, GATT_PROP_READ | GATT_PROP_NOTIFY |
GATT_PROP_WRITE,
ATT_PERM_RW, max_len, enable_read_cb_flag, NULL,
&ctx->att_hdl.conn_params) | == BLE_STATUS_OK);
ble_uuid_create16(UUID_GATT_CLIENT_CHAR_CONFIGURATION, &uuid);
PBL_ASSERTN(ble_gatts_add_descriptor(&uuid, ATT_PERM_RW, sizeof(uint16_t), enable_read_cb_flag,
&ctx->att_hdl.conn_params_cccd) == BLE_STATUS_OK);
// Register service with the stack and upda... |
bytes won't satisfy space_needed
goto exit;
}
uint32_t consume_bytes = MAX(session->storage.num_bytes/2, min_delta_size);
if (dls_storage_consume(session, consume_bytes) < 0) {
// We failed to lop off the used bytes
goto exit;
}
// Reallocate which removes the consumed bytes from the beginning of ... | kernel_malloc(max_chunk_size) | ;
if (tmp_buf) {
break;
}
if (max_chunk_size < 256) {
PBL_LOG(LOG_LEVEL_ERROR, "Not enough memory for reallocation");
goto exit;
}
max_chunk_size /= 2;
}
int32_t bytes_to_copy = session->storage.num_bytes;
while (bytes_to_copy) {
uint32_t new_read_offset;
int32_t byt... |
/*
* 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 (service == NULL) {
// No event service for this event type, create one
event_service_init(subscription->event_type, NULL, NULL);
service = s_event_services[subscription->event_type];
} |
if (service->subscribers[subscription->task]) {
// already subscribed ?
PBL_LOG(LOG_LEVEL_DEBUG, "already subscribed");
return;
}
if (service->add_subscriber_callback != NULL) {
service->add_subscriber_callback(subscription->task);
}
service->subscribers[subscription->task] = subscription-... |
RAME * 4);
if (data->rectr.origin.y < 0 ||
data->rectr.origin.y + data->rectr.size.h > data->window.layer.bounds.size.h) {
data->rectr_velocity_y = data->rectr_velocity_y * -1;
}
} else if (shape == CIRCLE) {
// Move the line X per Y
data->circle_origin.x += (data->circle_v... | graphics_context_set_stroke_color(ctx, data->circle_color) | |
, void *context) {
// We only care if send text support changed right now
if (!event->capabilities.flags_diff.send_text_support) {
return;
}
const PebbleProcessMd *md = app_install_get_md(APP_ID_SEND_TEXT, false /* worker */);
const InstallEventType event_type = (md ? APP_AVAILABLE : APP_REMOVED);
app_... | (LOG_LEVEL_WARNING, "Stored app with resource id %d not found in resources",
reg_entry->bin_resource_id) | ;
goto done;
}
*entry = (AppInstallEntry) {
.install_id = reg_entry->id,
.type = AppInstallStorageResources,
.visibility = process_metadata_flags_visibility(app_header->flags),
// PebbleTask_App because the flag parsing function needs it, and we can assume all
// applications registered with... |
{
prv_execute_on_kernel_main(prv_push_reminder_popup_kernel_main_cb);
}
static void prv_stop_popup_timer(void) {
if (regular_timer_is_scheduled(&s_ble_hrm_timer)) {
regular_timer_remove_callback(&s_ble_hrm_timer);
}
}
static void prv_reschedule_popup_timer(void) {
prv_stop_popup_timer();
s_ble_hrm_timer... | prv_request_sharing_permission(connection) | ;
break;
case HrmSharingPermission_Granted:
// Stop advertising the with the HR service in the adv payload.
// Note: we're assuming this is the only device we were advertising for.
gap_le_slave_reconnect_hrm_stop();
break;
default:
break;
}
}
}
static v... |
sis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
setup_test_aa_sw(&ctx, fb, RECT_NEG, RECT_NEG, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NULL,
GTextOverflowModeTr... | graphics_draw_text(&ctx, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR"
"STUVWXYZabcdefghijklmnopqrstuvwxyz", &s_font_info, RECT_TEXT_0_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_data_row_offsets.8bit.pbi"));
}
|
akes 2.6ms for the LDO rails to ramp.
delay_ms(3);
return true;
}
return false;
}
} else {
if (*ref_count <= 1) {
// Set the register byte to XXXXX00X to disable the rail, just mask
register_value = (register_value & ~0x06);
success = prv_write_register(rail_con... | gpio_release(GPIOB) | |
tinent_index));
PBL_ASSERTN(continent_index < ARRAY_LENGTH(CONTINENT_NAMES));
// Copy the continent name into our buffer, followed by a slash.
const int continent_name_length = strlen(CONTINENT_NAMES[continent_index]);
memcpy(region_name, CONTINENT_NAMES[continent_index], continent_name_length);
region_name[... | (region_name, region_name_length) | ;
}
return region_id;
}
|
/ The following block of code was lifted from sys_power_mgr.c:apply_wfi().
//
// TODO: It's not entirely clear what's going on, but it does reduce current draw to ~0 uA. At
// some point, it's probably worth figuring out how to cleanly hibernate (PBL-42430)
hw_cpm_enable_clockless();
hw_cpm_disable_xtal... | NVIC_ClearPendingIRQ(DMA_IRQn) | ;
DMA_Handler();
}
}
// NOTE: It looks like SPI/DMA complete interrupts will fire when the data fills the FIFO, not
// when the FIFO is actually empty. Let's spin until the FIFO is drained, if we're transmitting.
// If we're receiving, this function will spin forever. See ad_spi.c:322.
if (is_tx_on... |
);
// IMPORTANT: prv_invoke_watch_file_callbacks assumes that we already have s_pfs_mutex
prv_invoke_watch_file_callbacks(file_name, FILE_CHANGED_EVENT_REMOVED);
}
mutex_unlock_recursive(s_pfs_mutex);
}
#define MAX_PAGE_CACHE_ENTRIES 10 // 6 bytes per entry
static void update_page_cache(FilePageCache *f... | if ((res = read_header(file->start_page, &pg_hdr, &file_hdr)) !=
PageAndFileHdrValid) {
mark_fd_free(fd); // file has been corrupted so clear fd
goto cleanup;
} | |
ue,
.utc_start = now - 10 * SECONDS_PER_MINUTE,
.records = {
{.is_invalid = false, .steps = 1},
{.is_invalid = true, .steps = 2},
{.is_invalid = false, .steps = 3},
},
},
};
// pass time that's not exactly on a boundary
time_t time_start = now - 10 * SECONDS_PER_MINU... | health_service_private_get_yesterdays_sleep_activity(&start_sec, &end_sec) | ;
cl_assert(success);
cl_assert_equal_i(123, start_sec);
cl_assert_equal_i(123, end_sec);
cl_assert_equal_i(1, s_sys_activity_get_metric_values.in.history_len);
cl_assert_equal_i(ActivityMetricSleepExitAtSeconds, s_sys_activity_get_metric_values.in.metric);
}
// Test that health_service_sum_averaged() return... |
36, 128, -48},
{ 1072, 200, -96},
{ 1120, 192, -128},
{ 1296, 224, -112},
{ 1288, 296, -120},
{ 1128, 304, -152},
{ 880, 264, -160},
{ 712, 248, -120},
{ 680, 240, -96},
{ 752, 280, -112},
{ 880, 296, -128},
{ 976, 328, -216},
{ 1016, 360, -256},
// 62 seconds
{ 1... | { 432, 192, -856},
{ 464, 280, -880},
{ 600, 312, -784},
{ 672, 296, -600},
{ 824, 464, -488},
{ 960, 768, -480},
{ 1000, 768, -320},
{ 1016, 760, -200},
{ 976, 760, -112},
{ 944, 632, -48},
{ 1016, 688, -8},
{ 1032, 600, -80},
{ 1064, 584, -120},
{ 1056, 560, -13... |
{ 1064, 120, -88},
{ 1232, 208, -112},
{ 1104, 248, -112},
{ 832, 248, -112},
{ 576, 224, -128},
{ 488, 224, -152},
// 5 seconds
{ 496, 264, -112},
{ 584, 240, -80},
{ 728, 248, -144},
{ 1072, 312, -232},
{ 1208, 352, -328},
{ 1104, 328, -328},
{ 1296, 336, -272}... |
/*
* 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... | { -456, 480, -800},
{ -440, 448, -720},
{ -480, 584, -464},
{ -504, 768, -448},
{ -536, 816, -296},
{ -568, 960, -216},
{ -528, 816, -88},
{ -480, 880, 184},
{ -528, 888, 288},
{ -496, 752, 224},
{ -480, 784, 240},
{ -488, 792, 280},
{ -488, 744, 272},
{ -520, 736... |
{ 1488, 184, -96},
{ 1256, 176, -136},
{ 1224, 224, -192},
{ 624, -328, -32},
{ 880, -48, -176},
{ 904, -184, -192},
{ 1088, 112, -304},
// 5 seconds
{ 1216, 272, -304},
{ 1064, 232, -296},
{ 920, 304, -280},
{ 992, 344, -208},
{ 1272, 496, -192},
{ 1376, 624, -1... |
ile, "\n");
} else {
file = fopen(filename, "a");
cl_assert(file);
}
// Write out the column values for each row
StatsRow *row = s_stat_rows;
int row_idx = 0;
for (; row != NULL; row = (StatsRow *)row->node.next, row_idx++) {
fprintf(file, "\"%s\"", test_name);
StatsEpochType epoch_type;
... | {
extern int ref_accel_data_handler(AccelData *data, uint32_t num_samples );
extern void ref_init(void);
extern int ref_finish_epoch(void);
extern void ref_minute_stats(uint8_t *orientation, uint8_t *vmc);
int steps = 0;
uint8_t orientation, vmc;
ref_init();
AccelData accel_buf[KALG_SAMPLE_HZ];
int... |
// ----------------------------------------------------------------------------------
// The file discovery state definitions
typedef enum {
SampleFileType_AccelSamples,
SampleFileType_MinuteSamples,
} SampleFileType;
typedef struct {
char *res_path; // path to directory containing sample file... |
TEST_INCLUDE_BASIC
const int duration_a = 300;
Animation *a = prv_create_test_animation();
animation_set_play_count(a, 0);
animation_set_duration(a, duration_a);
prv_clear_handler_histories();
animation_schedule(a);
uint64_t start_ms = prv_now_ms();
prv_advance_to_ms_with_timers(start_ms + duration_... | (prv_count_handler_entries(&s_started_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq)... |
Increment totals for each day of the week
day_totals[day_in_week] += s_sys_activity_get_metric_values.out.history[i];
day_counts[day_in_week] += 1;
}
// ----------------------------------------
// Compute expected values
int exp_weekly = day_totals[local_tm.tm_wday] / day_counts[local_tm.tm_wday];
... | localtime_r(&now, &local_tm) | ;
DayInWeek day_in_week = local_tm.tm_wday;
// Our _initialize should set us to Monday, 9am UTC
cl_assert_equal_i(day_in_week, Monday);
// ----------------------------------
// Let's fill in known data for the 15-minute step averages
s_sys_activity_get_step_averages_values_weekday = (sys_activity_get_step... |
{ -64, 880, -336},
{ -72, 888, -336},
{ -64, 872, -328},
{ -56, 896, -320},
{ -56, 888, -328},
{ -64, 912, -328},
{ -64, 928, -288},
{ -56, 856, -304},
{ -56, 896, -304},
{ -72, 912, -264},
{ -88, 944, -232},
// 144 seconds
{ -96, 904, -136},
{ -112, 928, -120},
... | { -160, 912, 160},
{ -160, 912, 152},
{ -160, 904, 160},
{ -160, 912, 152},
{ -160, 912, 160},
{ -152, 912, 152},
{ -160, 904, 160},
{ -160, 912, 152},
{ -160, 912, 160},
{ -160, 912, 152},
{ -160, 912, 152},
{ -160, 912, 152},
{ -168, 912, 152},
{ -160, 912, 160}... |
{ -160, 920, 144},
{ -160, 912, 152},
{ -152, 920, 144},
{ -160, 920, 144},
// 152 seconds
{ -160, 912, 144},
{ -152, 912, 144},
{ -152, 912, 144},
{ -160, 912, 152},
{ -160, 912, 152},
{ -160, 912, 152},
{ -160, 912, 152},
{ -160, 912, 144},
{ -160, 912, 144},
... |
format_time);
cl_assert_equal_s("June 10", time_buf);
// June 7th 2015, 12:00:00 (-07:00:00)
format_time = event_time - SECONDS_PER_DAY - (24 * SECONDS_PER_HOUR);
clock_get_month_named_date(time_buf, sizeof(time_buf), format_time);
cl_assert_equal_s("June 7", time_buf);
// June 16th 2015, 13:00:00 (-07:0... | cl_assert_equal_s(tonight, daypart_string) | ;
// (8am tomorrow) time between 9pm and tomorrow 9am is tonight
daypart_string = clock_get_relative_daypart_string(timestamp, 28 /* hours_in_the_future */);
cl_assert_equal_s(tonight, daypart_string);
// (9am tomorrow) time tomorrow between 9am and 12pm is tomorrow morning
daypart_string = clock_get_relati... |
{
cl_assert(gap_le_is_advertising_enabled());
regular_timer_fire_seconds(1);
--seconds_left;
} |
cl_assert(!gap_le_is_advertising_enabled());
cl_assert_equal_i(regular_timer_seconds_count(), 0);
// The job should been have been unscheduled:
cl_assert_equal_i(s_unscheduled_cb_count, 1);
cl_assert_equal_p(s_unscheduled_job, job);
cl_assert_equal_b(s_unscheduled_completed, true);
free(ad);
}
void t... | |
t_contains((const ListNode *) s_session_head, &session->node));
return circular_buffer_copy_offset(&session->send_buffer, start_off, data_out, length);
}
void comm_session_send_queue_consume(CommSession *session, size_t length) {
circular_buffer_consume(&session->send_buffer, length);
}
static void prv_send_next_... | comm_session_set_responsiveness_ext(session, consumer, state, max_period_secs, NULL) | ;
}
void comm_session_set_responsiveness_ext(CommSession *session, BtConsumer consumer,
ResponseTimeState state, uint16_t max_period_secs,
ResponsivenessGrantedHandler granted_handler) {
s_responsiveness_max_period_s = max_period_secs... |
e_touch_event,
.cancel = prv_cancel,
.reset = prv_reset,
};
}
void test_recognizer_manager__cleanup(void) {
prv_clear_recognizers_processed(&s_recognizers_handled);
prv_clear_recognizers_processed(&s_recognizers_reset);
}
static void prv_store_recognizer_idx(Recognizer *recognizer, ListNode **list) {
... | (prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL)) | ;
prv_compare_recognizers_processed((int[]) {4, 2, 3}, 3, &s_recognizers_handled);
// Recognizers attached to window processed before layer recognizers
recognizer_add_to_list(recognizers[5], window_get_recognizer_list(&window));
cl_assert(prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, 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... | pfs_seek(fd, offset, FSeekSet) | >= 0) {
bytes_read = pfs_read(fd, data, num_bytes);
// prevent invalid resource API return values
if (bytes_read < 0) {
bytes_read = 0;
}
}
pfs_close(fd);
return bytes_read;
}
///////////////////////////////////////////////////////////////////////////////
// ResourceStoreTypeFile impleme... |
iance 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 CONDITIONS OF ANY KIND, either e... | s_sent_callback(&s_outbox_iterator, context) | ;
} else {
s_failed_callback(&s_outbox_iterator, result, context);
}
}
static void prv_app_message_setup(void) {
s_inbox_size = 0;
s_outbox_size = 0;
s_outbox_buffer = NULL;
s_app_message_outbox_send_call_count = 0;
s_is_outbox_message_pending = false;
app_message_deregister_callbacks();
}
static ... |
clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r1_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, O... | (&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 11) | |
pointP_b->x.raw_value) &&
(pointP_a->y.raw_value == pointP_b->y.raw_value));
}
GPointPrecise gpointprecise_midpoint(const GPointPrecise a,
const GPointPrecise b) {
return GPointPrecise(
(int16_t)(((int32_t)a.x.raw_value + (int32_t)b.x.raw_value) / 2),
(int16_t)(... | GPoint(rect->origin.x + (rect->size.w / 2), rect->origin.y + (rect->size.h / 2)) | ;
}
bool grect_contains_point(const GRect *rect, const GPoint *point) {
int16_t min_x = rect->origin.x;
int16_t max_x = rect->origin.x + rect->size.w;
if (min_x > max_x) {
// edge case for non-standardized rects:
int16_t temp = max_x;
max_x = min_x;
min_x = temp;
}
int16_t min_y = rect->origi... |
utes, 0);
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes);
cl_assert_equal_i(zone3_minutes, 0);
// Add some "very elevated" heart rates.
// The zone should wait 1 minute, move up 1 zone per minute, stop at the top
prv_set_median_hr_for_minutes(185 /* BPM */, 5 /* minutes */);
cl... | (&walk_activity) | ;
cl_assert_equal_i(activity_private_state()->activity_sessions_count, 1);
cl_assert_equal_m(&activity_private_state()->activity_sessions[0], &walk_activity,
sizeof(ActivitySession));
activity_sessions_prv_delete_activity_session(&walk_activity);
cl_assert_equal_i(activity_private_state()->... |
(event at index 1): it should update to reflect the difference between this
// and the first event
touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(18, 5), 60, 1, true);
}
void test_touch__hand... | ARRAY_LENGTH(ctx->touch_events) | );
ctx->touch_events[ctx->idx++] = *event;
}
void test_touch__dispatch_touch_events_single_finger(void) {
TouchEventContext ctx = {
.idx = 0
};
touch_dispatch_touch_events(0, prv_touch_event_dispatch_cb, &ctx);
cl_assert_equal_i(ctx.idx, 0);
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13... |
verify(&file, key, key_len, val, val_len);
}
static bool prv_each_check_all_values(SettingsFile *file, SettingsRecordInfo *info, void *context) {
uint32_t desired_value = *(uint32_t *)context;
uint32_t key;
uint32_t value;
info->get_key(file, (uint8_t *)&key, sizeof(uint32_t));
info->get_val(file, (uint8_... | ("Iteration %d key %s val %s\n", i, key, val) | |
// The length must be reasonable
if (session->length_min > ACTIVITY_SESSION_MAX_LENGTH_MIN) {
PBL_LOG(LOG_LEVEL_WARNING, "Invalid duration: %"PRIu16" ", session->length_min);
return false;
}
// The flags must be valid
if (session->reserved != 0) {
PBL_LOG(LOG_LEVEL_WARNING, "Invalid flags: %d", (... | PBL_ASSERTN(num_to_move >= 0) | ;
if (num_to_move == 0) {
memset(&state->activity_sessions[found_session_idx], 0, sizeof(ActivitySession));
} else {
memmove(&state->activity_sessions[found_session_idx],
&state->activity_sessions[found_session_idx + 1],
num_to_move * sizeof(ActivitySession));
}
s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_workout_selection__render_walk_selected(void) {
prv_create_window_and_render(1);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_selection__render_workout_selected(void) {
prv_create_window_and_render(2);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)... |
]
// PRIMASK = 0x0
// FAULTMASK = 0x0
// BASEPRI = 0x0
// CONTROL = 0x0
//
// Attempt to put the processor into as close to the reset state as possible
// before passing control to the firmware.
//
// No attempt is made to set CONTROL to zero as it should already be set to
// the reset... | prv_prf_button_combination_is_pressed() | ) {
dbgserial_putstr("Hold down UP + BACK + SELECT for 5 secs. to force-boot PRF");
for (int i = 0; i < 5000; ++i) {
if (!prv_prf_button_combination_is_pressed()) {
// stop waiting if not held down any longer
return false;
}
delay_ms(1);
}
return true;
}
void *res... |
/*
* 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... | EM_ASM_INT({ \
return __jerryRefs.ref(Function('return this;')()[Module.Pointer_stringify($0)]); \
}, builtin_name) | );
}
////////////////////////////////////////////////////////////////////////////////
// Jerry Value Type Checking
////////////////////////////////////////////////////////////////////////////////
#define JERRY_VALUE_HAS_TYPE(ref, typename) \
((bool)EM_ASM_INT({ \
return typeof __jerryRefs.get($0) ===... |
o get into this state before we reboot,
// that way we should be able to avoid getting into a reboot loop.
pfs_close_and_remove(iter->fd);
PBL_LOG(LOG_LEVEL_INFO, "Data at address %p. Rebooting...", contents);
PBL_CROAK("Internal logic error.");
}
static int sfs_seek(SettingsRawIter *iter, int amount, int when... | (iter, val_out, val_len) | ;
}
void settings_raw_iter_write_header(SettingsRawIter *iter, SettingsRecordHeader *hdr) {
PBL_ASSERTN(hdr->key_len <= SETTINGS_KEY_MAX_LEN);
PBL_ASSERTN(hdr->val_len <= SETTINGS_VAL_MAX_LEN);
sfs_seek(iter, iter->hdr_pos, FSeekSet);
sfs_write(iter, (uint8_t*)hdr, sizeof(*hdr));
iter->hdr = *hdr;
}
void set... |
-408},
{ 752, -128, -320},
{ 1000, -128, -248},
{ 1152, -168, -192},
{ 1048, -112, -160},
{ 968, -112, -200},
{ 928, -72, -232},
{ 952, -96, -264},
{ 1008, -168, -256},
{ 1064, -192, -224},
{ 1048, -176, -232},
{ 1072, -192, -216},
{ 1112, -184, -248},
{ 1112, -112, -... | { 928, 32, -352},
{ 1104, -16, -168},
{ 1168, -120, -104},
{ 1056, -104, -104},
{ 952, -40, -144},
{ 904, -32, -160},
{ 928, -24, -144},
{ 1024, -32, -152},
{ 1088, -64, -160},
{ 1048, -80, -168},
{ 1000, -56, -184},
{ 1056, -48, -192},
{ 1120, -64, -168},
{ 1144,... |
{ 1048, -64, -80},
{ 1072, -48, -104},
{ 1128, -16, -128},
{ 1104, -40, -96},
{ 1184, -96, -80},
{ 1544, -72, -96},
{ 1080, -88, -104},
// 21 seconds
{ 1224, -64, -160},
{ 968, -32, -240},
{ 720, -48, -248},
{ 848, -120, -192},
{ 1184, -136, -160},
{ 1168, -136, ... |
vent_buffer,
(const uint8_t *)event, sizeof(PebbleHRMEvent));
}
static void prv_populate_hrm_event(PebbleHRMEvent *event, HRMFeature feature, const HRMData *data) {
switch (feature) {
case HRMFeature_BPM:
*event = (PebbleHRMEvent) {
.event_type = HRMEvent_BPM,
.bpm =... | while (state) {
HRMSubscriberState *expired_state = NULL;
// Update the time stamp for when this subscriber last received an update if the sensor
// is currently stable
if (stable_sensor) {
state->last_valid_ticks = cur_ticks;
}
PebbleHRMEvent hrm_event;
for (uint8_t i = 0; i < HRMFe... |
PBL_ASSERTN(prv_event_put(state, &hrm_event));
state->sent_expiration_event = true;
}
if (state->expire_utc && (utc_now >= state->expire_utc)) {
// This subscription has expired
expired_state = state;
}
state = (HRMSubscriberState *)state->list_node.next;
// If the prior s... |
exCommon *mutex = os_malloc_check(sizeof(PebbleMutex));
*mutex = (PebbleMutexCommon) {
.freertos_mutex = freertos_mutex,
.lr = 0
};
return mutex;
}
PebbleMutex * mutex_create(void) {
LightMutexHandle_t freertos_mutex = xLightMutexCreate();
OS_ASSERT(freertos_mutex != NULL);
PebbleMutex *mutex = (P... | mcu_state_is_isr() | );
LightMutexHandle_t mutex = handle->common.freertos_mutex;
LOG_UNLOCKED(handle->common.lr, uxLightMutexGetRecursiveCallCount(mutex));
xLightMutexUnlockRecursive(mutex);
}
|
/*
* 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... | (RCC_AHB1PeriphClockCmd, RCC_AHB1Periph_CRC) | |
ALID_ID);
}
void test_do_not_disturb__manually_enable(void) {
cl_assert(do_not_disturb_is_active() == false);
bool enabled = do_not_disturb_is_manually_enabled();
cl_assert(enabled == false);
do_not_disturb_set_manually_enabled(true);
enabled = do_not_disturb_is_manually_enabled();
cl_assert(enabled == tr... | do_not_disturb_is_active() | |
this should look like.
//
// The new UI allows the phone to give us more info up front about how much data will be
// transmitted and also cleanly drive a re-start of the UI to a non-0 percentage if the FW update
// is being resumed. Newer implementations should this! (See PBL-42130)
static SemaphoreHandle_t s_firmwar... | {
return FirmwareUpdateCancelled; // Disable firmware updates on low power
} |
if (xSemaphoreTake(s_firmware_update_semaphore, 0) == pdFALSE) {
return FirmwareUpdateStopped;
}
FirmwareUpdateStatus result = s_update_status;
if (result != FirmwareUpdateRunning) {
prv_initialize_completion_status(event);
services_set_runlevel(RunLevel_FirmwareUpdate);
modal_manager_pop_al... |
1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), ... | (a, special_handlers, NULL) | |
;
GPoint p3 = GPoint(x2, y1);
// graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, data->stroke_width);
graphics_draw_line(ctx, p1, p2);
graphics_draw_line(ctx, p3, p0);
/*
graphics_context_set_strok... | (ctx, true) | |
/*
* 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... | (top_rects_x_offset, 0) | ,
.size = top_rects_size
};
prv_draw_hlines_in_rect(ctx, draw_func, &top_left_rect, top_rects_color);
const GRect top_right_rect = (GRect) {
.origin = GPoint((bitmap_bounds_size->w / 2) + top_rects_x_offset, 0),
.size = top_rects_size
};
prv_draw_hlines_in_rect(ctx, draw_func, &top_right_rect, top... |
PPoGATTWorkAroundState *state) {
if (state->pending_response_data) {
PBL_LOG(LOG_LEVEL_DEBUG, "WOAH");
kernel_free(state->pending_response_data);
}
const uint32_t alloc_size = sizeof(HcGattWriteRespData);
state->pending_data_size = alloc_size;
HcGattWriteRe... | kernel_zalloc_check(alloc_size) | |
2, -264},
{ 1728, 320, -112},
{ 1384, 368, -256},
{ 1016, 512, -296},
{ 848, 464, -160},
{ 728, 536, -128},
{ 768, 624, -192},
{ 784, 624, -216},
{ 824, 584, -184},
{ 856, 672, -264},
{ 848, 648, -264},
{ 928, 624, -224},
{ 1352, 648, -192},
{ 1256, 696, -304},
{ ... | { 1152, 304, -432},
{ 1008, 160, -152},
{ 944, 88, -208},
{ 824, 88, -256},
{ 704, 104, -208},
{ 616, 88, -200},
{ 704, 112, -176},
{ 840, 48, -96},
// 64 seconds
{ 1064, -8, -176},
{ 1424, 64, -216},
{ 1568, 248, -384},
{ 1616, 200, -232},
{ 1568, 72, -16},
{... | |
(s_text_layer_a) | ;
GRect from_rect_a = GRect(0, 0, 60, 60);
GRect to_rect_a = GRect(84, 92, 60, 60);
GRect from_rect_b = GRect(84, 0, 60, 60);
GRect to_rect_b = GRect(0, 92, 60, 60);
GRect tmp;
if (toggle) {
tmp = to_rect_b;
to_rect_b = from_rect_b;
from_rect_b = tmp;
}
toggle = !toggle;
animation_dest... | |
prv_prepare_canvas_and_render_action_menus_animated(root_level, selected_index) | ;
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_action_menu_window__thin_display_mode_with_emoji(void) {
// Copied from prv_create_emoji_level_from_action() in timeline_actions.c; it wouldn't work that
// well to just make the array T_STATIC in that function because we need to know its leng... | |
/*
* 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... | (crc, "abcdefg", 1) | |
list_valid = prv_is_slice_attribute_list_valid(serialized_slice->type,
&attr_list);
if (!is_attr_list_valid) {
PBL_LOG(LOG_LEVEL_WARNING, "Serialized slice AttributeList is invalid");
}
attribute_list_destroy_list(&attr_list);
kernel_free(... | mutex_unlock(s_app_glance_db.mutex) | |
2, -64},
{ 840, 184, -48},
{ 880, 184, -8},
{ 952, 144, -32},
{ 1008, 120, -24},
{ 984, 96, -32},
{ 1144, 128, -112},
{ 1192, 168, -64},
{ 1128, 176, -72},
{ 1136, 192, -128},
{ 1208, 272, -136},
{ 1120, 296, -136},
{ 856, 272, -192},
{ 640, 240, -168},
{ 560, 192... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 15:43:59 local
AccelRawData *activity_sample_walk_100_pbl_25660_2(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25660_2
//> TEST... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_convert_duration_to_hours_and_minutes(duration_s, &hours, &minutes) | ;
const int units_offset_y = fonts_get_font_height(number_font) - fonts_get_font_height(units_font);
const int hours_and_minutes_buffer_size = sizeof("00");
if (hours != INT_MIN) {
GTextNodeText *hours_text_node = health_util_create_text_node(hours_and_minutes_buffer_size,
... |
map, "fill_rect_origin_r7_aa_no_clip.${BIT_DEPTH_NAME}.pbi"));
#endif
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 8, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r8_aa_no_clip.${BIT_DEPTH_NAM... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r0_aa_clip_nxny.${BIT_DEPTH_NAME}.pbi")) | ;
// TODO: Remove these #ifdefs in PBL-15916 when support for non-antialiased rounded rect
#if SCREEN_COLOR_DEPTH_BITS == 8
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 , 1, GCornersAll);
cl_check(gbitmap_pbi_eq(&c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.