prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
st
ListNode* node = list_find(manager->running_timers, prv_id_list_filter, (void*)timer_id);
if (!node) {
node = list_find(manager->idle_timers, prv_id_list_filter, (void*)timer_id);
}
PBL_ASSERTN(node);
return (TaskTimer *)node;
}
// =====================================================================... | mutex_unlock(manager->mutex) | ;
return retval;
}
// --------------------------------------------------------------------------------
// Stop a timer. If the timer callback is currently executing, return false, else return true.
bool task_timer_stop(TaskTimerManager *manager, TaskTimerID timer_id) {
mutex_lock(manager->mutex);
// Find this ... |
been past the tolerable startup time, we have a valid reading - even though it
// may indicate off-wrist.
s_manager_state.sensor_stable = true;
s_manager_state.off_wrist_when_stable = (quality == HRMQuality_OffWrist);
}
}
return s_manager_state.sensor_stable;
}
T_STATIC bool prv_can_turn_sen... | // to get a good reading for the next subscriber that needs one
if (remaining_ms < INT32_MAX) {
new_timer_start(s_manager_state.update_enable_timer_id, remaining_ms,
prv_update_enable_timer_cb, NULL /*context*/, 0 /*flags*/);
} else {
new_timer_stop(s_manager_st... |
// Timer callback that we use to re-enable the HR sensor in case we turned it off for a while
static void prv_update_enable_timer_cb(void *context) {
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
}
//! The system task needs its own handler for HRM data since we can't queue up generic events.
sta... |
/*
* 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... | (&file, SHELL_PREFS_FILE_NAME, SHELL_PREFS_FILE_LEN) | ) != S_SUCCESS) {
goto cleanup;
}
rv = settings_file_set(&file, key, strnlen(key, SETTINGS_KEY_MAX_LEN) + 1, val, val_len);
settings_file_close(&file);
cleanup:
return (rv == S_SUCCESS);
}
bool shell_prefs_get_clock_24h_style(void) {
return s_is_24h_style;
}
void shell_prefs_set_clock_24h_style(bool is_... |
= *expandable_dialog->header ? true : false;
const GFont header_font = expandable_dialog->header_font;
int32_t header_content_height = has_header ? DISP_ROWS : 0;
uint16_t status_layer_offset = dialog->show_status_layer * STATUS_BAR_LAYER_HEIGHT;
uint16_t action_bar_offset = show_action_bar * ACTION_BAR_WIDTH... | (w, text_content_height) | );
uint16_t scroll_height = icon_offset + icon_size.h +
header_content_height + text_content_height + (icon ? BOTTOM_MARGIN_PX : 0);
scroll_layer_set_content_size(scroll_layer, GSize(frame.size.w, scroll_height));
scroll_layer_set_shadow_hidden(scroll_layer, true);
scroll_layer_set_callbacks(scroll_laye... |
-------------------------------------------------------------------------------------------------
// Helpers
static uint32_t prv_remaining_ms(uint32_t timeout_ms_in, RtcTicks start_ticks) {
const RtcTicks now = rtc_get_ticks();
const uint32_t elapsed_ms = (((now - start_ticks) * 1000) / RTC_TICKS_HZ);
if (timeou... | {
if (comm_session_is_valid(session)) {
max_length = DEFAULT_KERNEL_SENDER_MAX_PAYLOAD_SIZE;
}
} |
bt_unlock();
return max_length;
}
SendBuffer * comm_session_send_buffer_begin_write(CommSession *session, uint16_t endpoint_id,
size_t required_payload_length,
uint32_t timeout_ms) {
if (!session) {
return NU... |
b/app.h"
#include "applib/graphics/gdraw_command_image.h"
#include "applib/graphics/text.h"
#include "applib/tick_timer_service.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui/kino/kino_layer.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#inclu... | clock_get_time_tm(¤t_time) | ;
prv_minute_tick(¤t_time, HOUR_UNIT);
tick_timer_service_subscribe(MINUTE_UNIT, prv_minute_tick);
}
static void low_power_main(void) {
init();
app_event_loop();
deinit();
}
const PebbleProcessMd* low_power_face_get_app_info() {
static const PebbleProcessMdSystem s_app_md = {
.common = {
... |
ger, prv_handle_dummy_touch_event, NULL));
prv_compare_recognizers_processed((int[]) {6, 5, 4, 2, 3}, 5, &s_recognizers_handled);
prv_destroy_recognizers(recognizers, k_rec_count);
}
bool prv_dispatch_touch_event(Recognizer *recognizer, void *context);
void test_recognizer_manager__dispatch_touch_event(void) {
... | layer_init(&layer_b, &GRectZero) | ;
layer_init(&layer_c, &GRectZero);
layer_add_child(root, &layer_a);
layer_add_child(root, &layer_b);
layer_add_child(&layer_a, &layer_c);
recognizer_add_to_list(recognizers[0], window_get_recognizer_list(&window));
recognizer_add_to_list(recognizers[1], &layer_a.recognizer_list);
recognizer_add_to_list(... |
ght 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 in writing, s... | gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_y_origin_layer")) | );
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_ny_origin_layer")));
}
void test_graphics_draw_line__offset_layer(void) {
GConte... |
/app_message/app_message_internal.h"
#include "applib/event_service_client.h"
#include "applib/graphics/framebuffer.h"
#include "applib/graphics/graphics.h"
#include "applib/pbl_std/locale.h"
#include "applib/ui/animation_private.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui/layer.h"
#include "applib/u... | gbitmap_format_get_row_size_bytes(
LEGACY_2X_DISP_COLS, GBitmapFormat1Bit) | ;
void *fb_data = memory_segment_split(app_state_ram, NULL,
row_size * LEGACY_2X_DISP_ROWS);
if (!fb_data) {
return false;
}
*s_app_state_ptr->legacy2_framebuffer = (GBitmap) {
.addr = fb_data,
.row_size_bytes = row_size,
.info.is_bitmap_... |
/*
* 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... | {
HcGattWriteData *w_data = (HcGattWriteData *)hdr;
gatt_wrapper_write_no_resp(conn_idx, w_data->att_handle, w_data->value_length, w_data->value);
return; // Don't respond
} |
}
rv = BTErrnoOK;
respond:
hc_protocol_enqueue_response(msg, (uint8_t *)&rv, sizeof(rv));
}
void hc_endpoint_gatt_send_read_complete(const BTDeviceInternal *addr, uint16_t handle,
BLEGATTError status, uint16_t value_length, const uint8_t *value, uintptr_t context_ref) {
const uint32_t alloc_size = size... |
ead_and_emit_error_event_and_own_json_buffer(void) {
DBG("postmessageerror event");
OutgoingObject *old_head = s_state.out.object_queue;
char *const json_data_buffer = old_head->data_buffer;
// Don't free the JSON data buffer, ownership is about to be passed to the error event.
prv_object_queue_pop_head(fals... | prv_start_session_closed_object_queue_timer() | ;
}
}
return jerry_create_undefined();
}
////////////////////////////////////////////////////////////////////////////////
// Rocky boilerplate
////////////////////////////////////////////////////////////////////////////////
static void prv_init_apis(void) {
memset(&s_state, 0, sizeof(s_state));
// Pebbl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
text_layer_set_text_color(&data->word_wrap_layer, GColorWhite);
text_layer_set_background_color(&data->word_wrap_layer, GColorBlack);
} |
if (data->up_down_direction) {
text_layer_set_text(&data->direction_layer, "Direction: Up/Down");
} else {
text_layer_set_text(&data->direction_layer, "Direction: Left/Right");
}
if (data->word_wrap) {
frame.size.w = 72;
frame.size.h = 60;
} else {
frame.size.w = 72;
frame.size.h = ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GRect(0, 0, 10, -20) | ));
cl_assert_equal_i(10, grect_shortest_side(GRect(0, 0, -20, 10)));
}
void test_gtypes__grect_inset(void) {
GRect rect = GRect(10, 20, 30, 40);
cl_assert_equal_grect(GRect(12, 23, 26, 34), grect_inset_internal(rect, 2, 3));
cl_assert_equal_grect(GRect(7, 18, 36, 44), grect_inset_internal(rect, -3, -2));
}
... |
* 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 in w... | text_layer_set_text(&data->direction_layer, "Direction: Up/Down") | ;
} else {
text_layer_set_text(&data->direction_layer, "Direction: Left/Right");
}
if (data->word_wrap) {
frame.size.w = 72;
frame.size.h = 60;
} else {
frame.size.w = 72;
frame.size.h = 32;
}
init_text_layer(data, frame);
if (data->word_wrap) {
text_layer_set_text(&data->word_w... |
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... | rtc_get_time() | , StationaryAnalyticsEnterCharging);
} else {
analytics_event_stationary_state_change(rtc_get_time(), StationaryAnalyticsExitCharging);
}
prv_update_stationary_enabled(NULL);
}
//! A movement of the watch will make the watch wake up. In this state, the watch
//! will have a low tap threshold, so it will be s... |
Local prototypes
static WakeupEntry prv_wakeup_settings_get_entry(WakeupId wakeup_id);
static void prv_wakeup_settings_delete_entry(WakeupId wakeup_id);
static StatusCode prv_wakeup_settings_add_entry(WakeupId wakeup_id, WakeupEntry entry);
static void prv_wakeup_timer_next_pending(void);
static bool s_wakeup_enabled ... | PBL_LOG(LOG_LEVEL_ERROR, "Error: could not open APP_WAKEUP settings") | ;
}
}
mutex_unlock(s_mutex);
// Create a timer for the found wakeup id, given it's valid
if (s_wakeup_state.current_wakeup_id >= 0) {
int32_t timestamp = s_wakeup_state.timestamp;
time_t current_time = rtc_get_time();
int32_t time_difference = timestamp - current_time;
// If time_differenc... |
L);
// Make sure this is an animation in the scheduled list
PBL_ASSERTN(list_contains(state->scheduled_head, &animation->list_node));
#endif
const int32_t rel_ms_running = serial_distance32(animation->abs_start_time_ms, now);
if (rel_ms_running < 0) {
// Animations are ordered by abs_... | prv_find_animation_by_handle(state, animation_array[i],
false /*quiet*/) | |
st int16_t text_x_offset = (window_width - content_size.w) / 2;
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
const int16_t text_y_offset = 33;
#else
const int16_t text_y_offset = 22;
#endif
const GRect frame = { { text_x_offset, text_y_offset }, content_size };
layer_set_frame(&data->name_text_layer.layer, &frame);... | (s_fu_app_data) | ;
} else {
prv_hide_spinner(s_fu_app_data);
}
}
////////////////////
// App boilerplate
static void handle_init(void) {
launcher_block_popups(true);
RecoveryFUAppData *data = app_malloc_check(sizeof(RecoveryFUAppData));
s_fu_app_data = data;
*data = (RecoveryFUAppData){};
app_state_set_user_data(d... |
_end_utc Only include sleep sessions that end BEFORE this time
// @param[in] last_processed_utc When activity sessions were computed, this is the UTC of the
// most recent minute we had access to when activities were computed.
// @param[out] stats this structure is filled in with the sleep stats
// @return True ... | time_util_get_minute_of_day(stats.enter_utc) | ;
uint16_t exit_minute = time_util_get_minute_of_day(stats.today_exit_utc);
sleep_data->enter_at_minute = enter_minute;
sleep_data->exit_at_minute = exit_minute;
// Fill in the rest of the sleep data metrics: the current state, and how long we have been
// in the current state
uint32_t delta_mi... |
/*
* 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... | graphics_context_set_fill_color(ctx, data->spinner_color) | ;
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_fill_circle(ctx, circle1_location, radius_of_spinner_circles);
graphics_draw_circle(ctx, circle1_location, radius_of_spinner_circles);
graphics_fill_circle(ctx, circle2_location, radius_of_spinner_circles);
graphics_draw_circle(ctx, circle2_locat... |
ess(PebbleTask task, PebbleEvent *event) {
if (event->type == PEBBLE_RENDER_FINISHED_EVENT) {
s_render_pending = false;
}
s_last_event = *event;
return true;
}
static const AnimationImplementation *s_animation_implementation;
bool animation_set_implementation(Animation *animation,
... | cl_assert_equal_i(s_count_display_update, 2) | ;
// test animation updates
s_display_update_in_progress = true;
// start a transition
compositor_transition(&s_transition_a);
cl_assert_equal_i(s_count_display_update, 2);
// app render will be handled before transition
compositor_app_render_ready();
cl_assert_equal_i(s_count_display_update, 2);
cl... |
"
#include "syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include "util/shared_circular_buffer.h"
#include "FreeRTOS.h"
#include "queue.h"
#include <inttypes.h>
// We use this as an argument to indicate a lookup of the current... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Starting accel double tap service");
accel_enable_double_tap_detection(true);
prv_setup_subsampling(accel_get_sampling_interval());
} |
mutex_unlock_recursive(s_accel_manager_mutex);
}
static void prv_double_tap_remove_subscriber_cb(PebbleTask task) {
mutex_lock_recursive(s_accel_manager_mutex);
PBL_ASSERTN(s_double_tap_subscribers_count > 0);
if (--s_double_tap_subscribers_count == 0) {
PBL_LOG(LOG_LEVEL_DEBUG, "Stopping accel double t... |
d prv_do_data_handle(void *context) {
AccelServiceState *state = (AccelServiceState *)context;
if (state->manager_state == NULL) {
if (state->deferred_free) {
PBL_LOG(LOG_LEVEL_DEBUG, "Deferred free");
kernel_free(state);
}
// event queue is handled kernel-side, so an event may fire after w... | accel_service_private_get_session(PebbleTask_Unknown) | |
roperty_animation_clone(a);
animation_set_handlers((Animation*) a_rev, (AnimationHandlers) {
.started = (AnimationStartedHandler) animation_started,
.stopped = (AnimationStoppedHandler) animation_stopped,
}, NULL /* callback data */);
animation_set_delay((Animation*)a_rev, 400);
animation_set_duration((... | {
animation_destroy(s_animation);
window_stack_remove(window, false);
window_destroy(window);
text_layer_destroy(s_text_layer_a);
} |
int main(void) {
init();
app_event_loop();
deinit();
}
|
{
new_state = WordStateJoining;
} else {
new_state = WordStateGrowing;
}
break;
case WordStateEnd:
new_state = WordStateEnd;
break;
}
return new_state;
}
//! @return true if init to new word, false otherwise (ie end of text)
//! @note assumes 'start' is not NULL, ... | if (!iter_next(char_iter)) {
break;
} |
}
return true;
}
static bool prv_line_iter_is_vertical_overflow(const LineIterState* const line_iter_state,
const TextBoxParams* const text_box_params) {
int16_t next_line_y_extent;
// Normally, we lay out the text one line below the regular cutoff so that it ma... |
l/size.h"
#include <stdio.h>
// helpers from accel manager
extern void test_accel_manager_get_subsample_info(
AccelManagerState *state, uint16_t *num, uint16_t *den, uint16_t *samps_per_update);
extern void test_accel_manager_reset(void);
// stub
void event_service_init(PebbleEventType type,
... | (den, fastest_rate / gcd_of_rates) | ;
cl_assert_equal_i(samps_per_update, 1);
}
}
cl_assert_equal_i(1000000 / s_sampling_interval_us, fastest_rate);
cl_assert_equal_i(s_num_samples, 1);
for (int i = 0; i < num_items; i++) {
sys_accel_manager_data_unsubscribe(sessions[i]);
stub_pebble_tasks_set_current(tasks[i]);
}
}
// enum... |
/*
* 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... | {
char model_buffer[MFG_INFO_MODEL_STRING_LENGTH];
mfg_info_get_model(model_buffer);
// Just send it straight out, as it's already null-terminated
prompt_send_response(model_buffer);
} |
void command_model_write(const char* model) {
// mfg_info_set_model will truncate if the string is too long, so no need to check
mfg_info_set_model(model);
char written_model[MFG_INFO_MODEL_STRING_LENGTH];
mfg_info_get_model(written_model);
if (!strncmp(model, written_model, MFG_INFO_MODEL_STRING_LENGTH)) {... |
id *)(uintptr_t) ancs_uid, fd)) {
found = true;
*uuid_out = header.common.id;
// Seek to the end of this item's payload (start of the next item)
if (pfs_seek(fd, header.payload_length, FSeekCur) < 0) {
break;
}
}
prv_file_close(fd);
return found;
}
static bool prv_compare_ancs_notifi... | {
return;
} |
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return;
}
Iterator iter;
NotificationIterState iter_state = {
.fd = fd
};
iter_init(&iter, (IteratorCallback)prv_iter_next, NULL, &iter_state);
while (iter_next(&iter)) {
uint8_t status = iter_state.header.common.status;
if (!(stat... |
d_response(uintptr_t object_ref,
uint8_t value_out[],
uint16_t value_length,
GAPLEClient client) {
}
typedef struct {
ListNode node;
BLECharacteristic characteristic;
GAPLEClient client;
uint8_t... | {
Write *next = (Write *) write->node.next;
free(write->value);
free(write);
write = next;
} |
s_write_head = NULL;
}
void fake_gatt_client_op_assert_no_write(void) {
cl_assert_equal_p(s_write_head, NULL);
}
static void fake_gatt_client_op_assert_write_failed(void) {
cl_assert_(false, "No gatt_client_op_write() or "
"gatt_client_op_write_without_response() has happened at all");
}
void fak... |
tx);
cl_check(framebuffer_is_empty("outside_nx_ny_offset_layer", ctx.parent_framebuffer, GColorWhite));
}
void test_graphics_draw_pixel_${BIT_DEPTH_NAME}__clear(void) {
GContext ctx;
Layer layer;
test_graphics_context_init(&ctx, fb);
layer_init(&layer, &GRect(0, 0, 10, 10));
layer_set_update_proc(&layer, &... | graphics_fill_rect(&ctx, &ORIGIN_RECT_NO_CLIP) | ;
// No transparency
prv_draw_boxes(&ctx, 3);
// 33% transparency
prv_draw_boxes(&ctx, 2);
// 66% transparency - should draw nothing according to current implementation
prv_draw_boxes(&ctx, 1);
// 100% transparency - should draw nothing according to current implementation
prv_draw_boxes(&ctx, 0);
... |
eResponse {
uint8_t opcode;
uint8_t fd;
uint32_t address;
uint32_t length;
} WriteResponse;
typedef struct PACKED CRCResponse {
uint8_t opcode;
uint8_t fd;
uint32_t address;
uint32_t length;
uint32_t crc;
} CRCResponse;
typedef struct PACKED StatResponse {
uint8_t opcode;
uint8_t fd;
uint8_t d... | (pulse_fd->transfer_state.bytes_left, max_read_len) | |
s_logging.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
GBitmap* graphics_capture_frame_buffer(GContext* ctx) {
return NULL;
}
bool graphics_release_frame_buffer(GContext* ctx, GBitmap* buffer) {
return true;
}
void graphics_draw_pixel(){}
void graphics_fill_rect(GContext* ctx, const GRect *rect) {}
voi... | {
GOvalScaleMode mode = GOvalScaleModeFillCircle;
// Basic container rect with GPointZero origin
const GRect container_rect1 = GRect(0, 0, 10, 10);
const GRect resulting_rect1 = grect_centered_from_polar(container_rect1, mode, 0, GSize(3, 5));
cl_assert_equal_grect(resulting_rect1, GRect(3, -2, 3, 5));
//... | |
;
}
/* Public Functions */
bool pmic_init(void) {
prv_set_pin_config();
if (!prv_is_alive()) {
return false;
}
// Power up 3.2V rail
prv_update_rail_state(PmicRail_LDO2, true);
return true;
}
static bool prv_update_rail_state(PmicRail rail, bool enable) {
static int8_t s_ldo2_ref_count = 0;
sta... | {
return false;
} |
bool usb_connected = (val >> 3) & 1;
return usb_connected;
}
void pmic_read_chip_info(uint8_t *chip_id, uint8_t *chip_revision) {
prv_read_register(PmicRegisters_CHIP_ID, chip_id);
prv_read_register(PmicRegisters_CHIP_REV, chip_revision);
}
/* Private Function Implementations */
static bool prv_is_alive(v... |
/*
* 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... | i18n_get("%d:%d", i18n_owner) | , minutes, seconds);
}
GTextNodeText *health_util_create_text_node(int buffer_size, GFont font, GColor color,
GTextNodeContainer *container) {
GTextNodeText *text_node = graphics_text_node_create_text(buffer_size);
if (container) {
graphics_text_node_container_add_ch... |
otection
static bool s_flash_protection_supported = false;
bool flash_check_whoami(void) {
return qspi_flash_check_whoami(QSPI_FLASH);
}
FlashAddress flash_impl_get_sector_base_address(FlashAddress addr) {
return (addr & SECTOR_ADDR_MASK);
}
FlashAddress flash_impl_get_subsector_base_address(FlashAddress addr) {... | qspi_flash_blank_check(QSPI_FLASH, addr, true /* is_subsector */) | ;
}
uint32_t flash_impl_get_typical_sector_erase_duration_ms(void) {
return 400;
}
uint32_t flash_impl_get_typical_subsector_erase_duration_ms(void) {
return 40;
}
|
system_flash.h"
#include "flash_region/flash_region.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "services/common/system_task.h"
#include "services/runlevel.h"
#include "system/bootbits.h"
#include "system/firmware_storage.h"
#include "system/logging.h"
#include "system/pass... | window_set_overrides_back_button(window, true) | ;
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
window_set_fullscreen(window, true);
const bool animated = false;
app_window_stack_push(window, animated);
}
////////////////////
// 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... | {
return NULL;
} |
return builtin->address;
}
static bool resource_storage_builtin_find_resource(ResourceStoreEntry *entry, ResAppNum app_num,
uint32_t resource_id) {
if (app_num != SYSTEM_APP) {
return false;
}
// Story time! This is closely related to PBL-14367
// resou... |
cohorts to reduce our stack
// requirements
static void prv_debug_str(const char* msg) {
kernel_pbl_log_from_fault_handler(__FILE_NAME__, 0, msg);
}
// -------------------------------------------------------------------------------------------------
// NOTE: We are explicitly avoiding use of vsniprintf and cohorts ... | core_dump_get_slot_address(i) | ;
prv_flash_read_bytes(®ion_hdr, base_address, sizeof(region_hdr));
// Skip if not written correctly or not most recently used
if (region_hdr.magic == CORE_DUMP_FLASH_HDR_MAGIC && region_hdr.last_used > max_last_used) {
max_last_used = region_hdr.last_used;
last_used_idx = i;
}
}
//... |
GTextNodeText *divider_text_node = health_util_create_text_node_with_text(
"/", units_font, TEXT_COLOR, container);
divider_text_node->node.offset.y = units_offset_y;
/// MI/KM units string
const char *units_string =
active_window->workout_controller->get_distance_... | prv_update_ui(active_window) | ;
active_window->update_timer = app_timer_register(1000, prv_update_timer_callback, active_window);
const int bpm = active_window->workout_controller->get_metric_value(
WorkoutMetricType_Hr, active_window->workout_data);
if (bpm == 0 && !active_window->hr_measuring_timer) {
active_window->cur_hr_measur... |
, 0, 149},
{ 0, 0xc, 0, 150},
{ 0, 0xc, 0, 149},
{ 0, 0xc, 0, 149},
{ 0, 0xc, 0, 150},
{ 0, 0xc, 0, 149},
{ 0, 0xc, 0, 146},
{ 0, 0xc, 0, 150},
{ 0, 0xc, 0, 149},
{ 0, 0xc, 0, 150},
{ 0, 0xc, 0, 150},
{ 0, 0xc, 0, 146},
// 555: Local time: 03:51:00 AM
{ 0, 0xc, 0, 150... | { 0, 0x7f, 0, 151},
{ 0, 0x7f, 0, 147},
{ 0, 0x7f, 0, 151},
{ 0, 0x7f, 0, 151},
{ 0, 0x7f, 0, 151},
{ 0, 0x7f, 0, 151},
{ 0, 0x7f, 0, 147},
// 675: Local time: 05:52:00 AM
{ 0, 0x7f, 20, 151},
{ 0, 0x7f, 0, 151},
{ 0, 0x7f, 166, 142},
{ 0, 0x7f, 5, 142},
{ 0, 0x7f, 51... |
{ 0, 0x69, 0, 152},
{ 0, 0x69, 0, 152},
{ 0, 0x69, 0, 148},
{ 0, 0x69, 146, 153},
{ 0, 0x69, 0, 152},
{ 0, 0x69, 0, 152},
{ 0, 0x69, 0, 152},
{ 0, 0x7b, 3563, 144},
// 735: Local time: 06:52:00 AM
{ 0, 0x84, 0, 148},
{ 0, 0x5e, 1228, 148},
{ 0, 0x1d, 3, 148},
{ 0, 0x... |
/*
* 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... | hton16(PULSE_PROTOCOL_LOGGING) | ;
transport->length = hton16(sizeof(PushPacket) + sizeof(s_message_header) +
s_message_length);
unsigned char *app = transport->information;
memcpy(app, s_message_header, sizeof(s_message_header));
memcpy(&app[sizeof(s_message_header)], s_message_buffer,
s_message_length);... |
/*
* 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_equal_i(id, 7) | ;
}
void test_debug_db__weird(void) {
int index;
uint8_t id;
debug_db_determine_current_index((uint8_t []) { 0, 9, 6, 7 }, &index, &id);
cl_assert_equal_i(index, 1);
cl_assert_equal_i(id, 1);
}
|
l_assert((resp_ptr - s_data) == s_sending_data_length);
}
/*************************************
* Checking for valid DELETE command *
*************************************/
static const uint8_t s_delete_cmd_success[] = {
// Message Header
0x04, // Pebble protocol message ID: DELETE
0x17, ... | cl_assert((resp_ptr - s_data) == s_sending_data_length) | ;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// BLOBDB SYNC TESTS
///////////////////////////////////////////////////////////////////////////////////////////////////
static const uint8_t *s_expected_data;
extern void prv_send_v2_response(CommSession *session... |
s_manager_state.lock);
PebbleHRMEvent event;
prv_read_event_from_buffer_and_consume(&s_manager_state.system_task_event_buffer, &event);
// Send event to all KernelBG subscribers that asked for this feature
HRMSubscriberState *state = (HRMSubscriberState *)s_manager_state.subscribers;
for (; state != NULL; s... | {
s_manager_state.enabled_charging_state = !evt->new_state.is_plugged;
} |
mutex_unlock_recursive(s_manager_state.lock);
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
}
// Accept new data from the HR device driver.
void hrm_manager_new_data_cb(const HRMData *data) {
mutex_lock_recursive(s_manager_state.lock);
if (!prv_can_turn_sensor_on() || s_manager_state.subsc... |
);
if (kernel) {
GATTBufferedNotificationHeader header = {};
gatt_client_subscriptions_get_notification_header(GAPLEClientKernel, &header);
cl_assert_equal_i(header.value_length, assert_value_length);
cl_assert_equal_i(header.characteristic, characteristic);
if (should_consume) {
uint16_t v... | gatt_client_subscriptions_cleanup_by_client(c) | ;
}
gap_le_connection_deinit();
gatt_client_subscription_cleanup();
fake_pbl_malloc_check_net_allocs();
fake_pbl_malloc_clear_tracking();
}
// -------------------------------------------------------------------------------------------------
// gatt_client_subscriptions_subscribe
void test_gatt_client_subsc... |
ppogatt_send_next((struct Transport *) &fake_client);
// No crashes, no writes, etc.
fake_gatt_client_op_assert_no_write();
}
void test_ppogatt__handle_bluetooth_stack_queue_full_and_empty_events(void) {
test_ppogatt__open_session_when_found_pebble_app();
fake_gatt_client_op_set_write_return_value(BTErrnoNot... | regular_timer_fire_seconds(PPOGATT_TIMEOUT_TICK_INTERVAL_SECS) | ;
}
fake_comm_session_process_send_next();
for (sn = 0; sn < s_tx_window_size; ++sn) {
prv_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn /* sn */,
s_short_data_fragment, sizeof(s_short_data_fragment) - sn);
}
}
void test_ppogatt__retransmit_timed_out_data_p... |
h_buffer("<Untitled>", remote->name, sizeof(remote->name));
} else {
strncpy(remote->name, name, sizeof(remote->name));
}
}
static void prv_add_bt_classic_remote(BTDeviceAddress *addr, SM128BitKey *link_key,
const char *name, uint8_t *platform_bits, void *context) {
Sett... | while (data->remote_list_head) {
StoredRemote* remote = (StoredRemote*) data->remote_list_head;
data->remote_list_head = list_pop_head(&remote->list_node);
task_free(remote);
} |
}
static void prv_reload_remote_list(SettingsBluetoothData* data) {
prv_clear_remote_list(data);
prv_add_bt_classic_remotes(data);
prv_add_and_merge_ble_remotes(data);
}
static void settings_bluetooth_update_remotes_private(SettingsBluetoothData* data) {
prv_reload_remote_list(data);
if (!data->remote_lis... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | sys_get_time() | ;
if (tloc) {
*tloc = t;
}
return (t);
}
// Manually construct double to avoid requiring soft-fp
static double prv_time_to_double(time_t time) {
// time_t is 32bit signed int, convert it manually
#ifndef UNITTEST
_Static_assert(sizeof(time_t) == 4, "Conversion depends on 32bit time_t");
#endif
if (tim... |
prv_get_value(uint16_t conn_idx, uint16_t value_handle,
uint8_t response[READ_RESPONSE_BUFFER_SIZE],
size_t *response_length_out) {
if (value_handle == s_pps_ctx.att_hdl.conn_status) {
*response_length_out = prv_handle_connection_state_read(conn_idx, response);
... | (connection, is_subscribed) | ;
value_handle = s_pps_ctx.att_hdl.conn_params;
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Unknown CCCD handle %u!", evt->handle);
return ATT_ERROR_INVALID_HANDLE;
}
if (is_subscribed) {
prv_send_notification(evt->conn_idx, value_handle);
}
return ATT_ERROR_OK;
}
static att_error_t prv_handle_mtu_v... |
_layer_slide_day_sep(&data->timeline_layer);
#endif
prv_set_day_sep_timer(data);
} else {
#if CAPABILITY_HAS_TIMELINE_PEEK
GPoint direction = GPoint(0, -1);
#else
GPoint direction = GPoint(1, 0);
#endif
Animation *layer_bounce = timeline_layer_create_bounce_back_animation(&data->timeline_layer,
... | peek_layer_clear_fields(peek_layer) | ;
animation_unschedule(data->current_animation);
const uint32_t duration = was_mini_peek ? interpolate_moook_in_duration() :
TIMELINE_SLIDE_ANIMATION_MS;
Animation *intro = prv_create_intro_animation(data, duration, was_mini_peek);
animation_set_handlers(intro, (Ani... |
s_current_location = is_current_location,
.current_temp = 68,
.today_high = 68,
.today_low = 58,
.current_weather_type = WeatherType_PartlyCloudy,
.current_weather_phrase = "Cloudy with 90% chance of meatballs",
.tomorrow_high = 62,
.tomorrow_low = 52,
.tomorrow_weather_t... | (&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_weather_app_layout__render_all_unknown_values(void) {
const WeatherLocationForecast forecast = {
.location_name = "PALO ALTO",
.current_temp = WEATHER_SERVICE_LOCATION_FORECAST_UNKNOWN_TEMP,
.today_high = WEATHER_SERVICE_LOCATION_FORECAST_UNKNOWN_TEMP,
.today_low = WEATHER_SERVICE_LOCA... |
oke_precise_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 30, 40)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 30, 40)
#define START_ON_ORIGIN_RECT GPointPre... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_offset_layer_aa.${BIT_DEPTH_NAME}.pbi") | |
16_t dest_delta_begin_x = MAX(dest_row_info.min_x - dest_rect.origin.x, 0);
const int16_t dest_begin_x = dest_delta_begin_x ? dest_row_info.min_x : dest_rect.origin.x;
const int16_t dest_end_x = MIN(grect_get_max_x(&dest_rect), dest_row_info.max_x + 1);
if (dest_end_x < dest_begin_x) {
... | MIN(32, src_bitmap->bounds.size.w + src_line_start_idx - (src_origin_offset.x % 32)) | ;
const uint8_t src_line_wrap_end_idx = MIN(32, src_bitmap->bounds.size.w + src_line_wrap_idx);
uint8_t row_bits_left = dest_rect.size.w;
uint32_t * const src_block_begin =
(uint32_t *)src_block_x_begin + (src_y * src_row_length_words);
uint32_t *src_block = src_block_begin;
uint32_t src = ... |
er_callback(void *unused) {
PBL_LOG(LOG_LEVEL_WARNING, "SSP timeout fired!");
launcher_task_add_callback(prv_show_failure_kernel_main_cb, NULL);
}
static void prv_pop_window(void) {
if (s_data_ptr) {
window_stack_remove(&s_data_ptr->window, true /* animated */);
}
}
static void prv_pop_window_kernel_main_... | vibes_short_pulse() | ;
light_enable_interaction();
}
void bluetooth_pairing_ui_handle_event(PebbleBluetoothPairEvent *event) {
PBL_ASSERT_TASK(PebbleTask_KernelMain);
switch (event->type) {
case PebbleBluetoothPairEventTypePairingUserConfirmation:
prv_handle_confirmation_request(event->ctx, event->confirmation_info);
... |
rry_value_t result_hours = jerry_call_function(getHours, now, NULL, 0);
jerry_value_t result_date = jerry_call_function(getDate, now, NULL, 0);
cl_assert(jerry_get_number_value(result_seconds) == 51.0);
cl_assert(jerry_get_number_value(result_minutes) == 40.0);
cl_assert(jerry_get_number_value(result_hours) ==... | jerry_release_value(getMinutes) | ;
jerry_release_value(getSeconds);
jerry_release_value(now);
}
|
t duration_c = 200;
const int duration_d = 400;
const int total_duration = duration_c + duration_d;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
// Create the inner sequence with a play count of 0
Animation *a = prv_create_test_animation();... | (spawn, true, true) | |
map__origin_layer_across_nx(void) {
prv_origin_layer_test(GPoint(-25, 0));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__origin_layer_across_y(void) {
prv_origin_layer_test(GPoint(0, 40));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test... | prv_composite_test(__func__, GCompOpTintLuminance) | ;
}
void test_graphics_draw_bitmap__composite_tint_luminance_black_semitransparent(void) {
GColor tint_color = GColorBlack;
tint_color.a = 2;
// We have to set the tint color directly in the GContext because
// graphics_context_set_tint_color() calls gcolor_closest_opaque() on the color you give it
s_ctx.dra... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "Not implemented") | |
iptors
0x00,
//// GATTCharacteristic
0x10, 0x00, 0x00, 0x01, 0x32, 0x8e, 0x0f, 0xbb, 0xc6, 0x42, 0x1a, 0xa6, 0x69, 0x9b, 0xda, 0xda,
//// Offset
EMULATED_DATA_CHAR_OFFSET,
//// Properties
0x14,
//// Num Descriptors
0x01,
////// Data descriptor
0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, ... | {
return; // Gotta wait for remote to subscribe.
} |
if (!state->pending_response_data) {
return; // Gotta wait for FW to subscribe / write the emulated CCCD.
}
PBL_LOG(LOG_LEVEL_ALWAYS, "Phone & Watch have hit CCCD, initiate PPoGatt WA!");
hc_protocol_enqueue_with_payload(HcEndpointID_Gatt, HcMessageID_Gatt_WriteCompleted,
... |
ather_app_warning_dialog.h"
#include "applib/app.h"
#include "applib/event_service_client.h"
#include "applib/ui/click.h"
#include "applib/ui/content_indicator.h"
#include "applib/ui/ui.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "process_management/pebble_process_md.h"
#include "process_stat... | (&window->layer, &data->layout.root_layer) | ;
}
static void prv_main_window_disappear(Window *window) {
WeatherAppData *data = app_state_get_user_data();
event_service_client_unsubscribe(&data->weather_event_info);
}
static void prv_up_down_click_handler(ClickRecognizerRef recognizer, void *context) {
WeatherAppData *data = app_state_get_user_data();
c... |
temp_buffer = *(__IO uint16_t *)(flash_data_addr-1);
buffer[bytes_read++] = (uint8_t)((temp_buffer >> 8) & 0xFF);
}
// At this point, flash_data_addr is now halfword aligned
buff_ptr = (uint16_t *)&buffer[bytes_read];
bool odd_buff_addr = ((((uint32_t)buff_ptr) % 2) == 1);
if (buffer_size - bytes_read >=... | {
// Handle a buffer with an unaligned start. Write 0xff for the first byte
// since flash can only flip ones to zeros, and no data will be lost.
const uint16_t first_short_value = 0xFF | ((*buffer) << 8);
*flash_write_dest = first_short_value;
// Now for the rest of the function let's pretend this... |
// Handle body words
for (; bytes_remaining >= 2; bytes_remaining -= 2, buffer += 2) {
uint16_t buffer_word;
memcpy(&buffer_word, buffer, sizeof buffer_word);
*flash_write_dest++ = buffer_word;
}
// Handle trailing byte if present. This will be present if we started out
// aligned and we wrote ... |
/*
* 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_init() | ;
display_firmware_update_progress(0, 1);
boot_bit_set(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
FirmwareDescription firmware_description =
firmware_storage_read_firmware_description(flash_address);
if (!firmware_storage_check_valid_firmware_description(&firmware_description)) {
dbgserial_putstr("Invali... |
LIZED_HIGH);
// B should start high
distance = prv_last_update_distance(b);
cl_assert(distance > TEST_ANIMATION_NORMALIZED_HIGH);
// Execute to the end of B
prv_advance_to_ms_with_timers(start_ms + duration_total + 1 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler... | prv_count_handler_entries(&s_stopped_handler_calls, NULL) | , 6);
// Unschedule the top-level
animation_unschedule(clone);
// Keep going, nothing new should happen except stop handlers for each component
prv_advance_to_ms_with_timers(start_ms + 5 * (duration_total + 3 * MIN_FRAME_INTERVAL_MS));
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, N... |
/*
* 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... | bt_uuid_expand_16bit(0x2a1c) | ,
.properties = 0x02,
.handle = 0x13,
.num_descriptors = 1,
.descriptors = {
[0] = {
.uuid = bt_uuid_expand_16bit(0x2902),
.handle = 0x15,
},
},
},
}
};
return &s_health_thermometer_service;
}
void fake_gatt_put_discovery... |
stance_column_x_offset = 0;
const int16_t distance_column_width = PBL_IF_ROUND_ELSE(63, background_width);
const int16_t back_value_y_offset = STATUS_BAR_LAYER_HEIGHT + PBL_IF_ROUND_ELSE(24, 0);
const int16_t mid_value_y_offset = back_value_y_offset + PBL_IF_ROUND_ELSE(30, 26);
const int16_t front_value_y_offse... | (window_layer, text_layer_get_layer(data->disconnected_text)) | ;
layer_set_hidden(text_layer_get_layer(data->disconnected_text), true);
// Sync setup:
Tuplet initial_values[] = {
TupletCString(GOLF_PAR_KEY, "0"),
TupletCString(GOLF_HOLE_KEY, "0"),
TupletCString(GOLF_BACK_KEY, "000"),
TupletCString(GOLF_MID_KEY, "000"),
TupletCString(GOLF_FRONT_KEY, "000"... |
-------------------------------------------------------------------------------------------
bool animation_set_handlers(Animation *animation_h, AnimationHandlers handlers,
void *context) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_using_l... | animation_private_using_legacy_2(state) | |
hange(&data->time_data, index, -1);
prv_update_range_text_layer(data);
}
// Public Functions
void time_selection_window_set_to_current_time(TimeSelectionWindowData *time_selection_window) {
struct tm current_time;
clock_get_time_tm(¤t_time);
time_selection_window->time_data.hour = current_time.tm_hour;
... | (&time_selection_window->status_layer) | ;
status_bar_layer_set_colors(&time_selection_window->status_layer,
PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack),
PBL_IF_COLOR_ELSE(GColorBlack, GColorWhite));
status_bar_layer_set_separator_mode(&time_selection_window->status_layer,
... |
st int16_t delta_x = to.origin.x - from.origin.x;
const int16_t delta_y = to.origin.y - from.origin.y;
if (!delta_x && !delta_y) {
return bounce_offset;
}
const int16_t magnitude = integer_sqrt(delta_x * delta_x + delta_y * delta_y);
if (!magnitude) {
return bounce_offset;
}
bounce_offset.x = b... | prv_calc_bounce_offset(from, to, bounce) | |
his so we can release the framebuffer we're
// using even though its format doesn't match GBITMAP_NATIVE_FORMAT (see comment for mocked
// graphics_capture_frame_buffer() above)
bool graphics_release_frame_buffer(GContext *ctx, GBitmap *buffer) {
PBL_ASSERTN(ctx);
ctx->lock = false;
framebuffer_dirty_all(ctx->par... | time_selection_window_init(&selection_window, &s_time_config) | |
}
if (secs_to_wait) {
uint32_t curr_ticks = rtc_get_ticks();
if (curr_ticks < timeout) {
uint16_t wait_time = (timeout - curr_ticks) / RTC_TICKS_HZ;
*secs_to_wait = MAX(1, wait_time);
} else {
*secs_to_wait = 0;
}
}
return state;
}
/*
* LE connection manager handling for a g... | if (conn_mgr_info->curr_requested_state == curr_request->req_state) {
if (curr_ticks >= curr_request->timeout) {
list_remove(&curr_request->list_node, (ListNode **)&conn_mgr_info->requests, NULL);
kernel_free(curr_request);
}
} |
curr_request = next;
}
// Note: As an optimization, we could track how long we have been in a lower
// latency state and subtract that from higher latency requests, but most of
// the time we should be in the maximum latency (low power) state anyway
// get & set the new state
prv_handle_response_late... |
d cell index.
MenuIndex selected_index = menu_layer_get_selected_index(menu_layer);
MenuPrimeCacheIterator it = {
.it = {
.menu_layer = menu_layer,
.row_callback_after_geometry = prv_menu_layer_iterator_prime_cache_callback,
.section_callback = prv_menu_layer_iterator_noop_callback,
.sho... | if (menu_layer->animation.animation) {
from = menu_layer->animation.target;
prv_cancel_selection_animation(menu_layer);
} else {
from = menu_layer->inverter.layer.frame;
} | |
ent draws will cause the voltage supplied by the battery to
// droop. We try to only sample the battery when there is minimal
// activity. We look to see if stop mode is allowed because this is a good
// indicator that no peripherals are in use (i.e vibe, backlight, etc)
if ((s_last_battery_state.skip_count < M... | {
s_periodic_timer_id = new_timer_create();
s_last_battery_state = (BatteryState) { .connection = ConnectionStateDischargingUnplugged };
battery_state_reset_filter();
battery_state_force_update();
s_analytics_previous_mv = s_last_battery_state.voltage;
} |
void battery_state_handle_connection_event(bool is_connected) {
static const uint32_t RECONNECTION_DELAY_MS = 1000;
PBL_LOG_VERBOSE("USB Connected:%d", is_connected);
// Trigger a reset update to the state machine. Delay the update to allow the battery voltage to
// settle and to debounce reconnection event... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
Window *window = prv_window_create();
app_window_stack_push(window, true);
} | |
handle_clock_change();
cron_service_handle_clock_change(set_time_info);
}
// TODO: evaluate if these need to change on every time update
do_not_disturb_handle_clock_change();
reminders_update_timer();
#endif
return;
}
case PEBBLE_BLE_SCAN_EVENT:
case PEBBLE_BLE_CONNECT... | (&e, 1000) | ) {
const PebbleTaskBitset kernel_main_task_bit = (1 << PebbleTask_KernelMain);
const bool is_not_masked_out_from_kernel_main = !(e.task_mask & kernel_main_task_bit);
if (is_not_masked_out_from_kernel_main) {
prv_handle_event(&e);
}
event_service_handle_event(&e);
event_cle... |
>p1.x++;
break;
case OP_MOVE_P1_Y:
data->p1.y++;
break;
case OP_MOVE_P2_X:
data->p2.x++;
break;
case OP_MOVE_P2_Y:
data->p2.y++;
break;
default:
PBL_LOG(LOG_LEVEL_ERROR, "Invalid operation type: %d", data->operation);
break;
}
layer_mark_dirty(d... | (ctx, data->stroke_width) | |
_metric_history_stats(ActivityMetric metric,
ActivityInsightMetricHistoryStats *stats);
// =========================================================================================
// Activity stubs / fakes
typedef struct StaticData {
ActivityScalarStore steps_per_minut... | cl_assert(start_utc <= rtc_get_time()) | |
/*
* 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_factory_reset_non_pfs_data() | ;
// TODO: wipe the registry on tintin?
filesystem_regions_erase_all();
#if !defined(RECOVERY_FW)
// "First use" is part of the PRF image for Snowy
boot_bit_set(BOOT_BIT_FORCE_PRF);
#endif
prv_factory_reset_post(should_shutdown);
}
#if !RECOVERY_FW
void close_db_files() {
// Deinit the databases and any... |
ashGeometryRequest)) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")", length);
return;
}
const FlashGeometryRequest *request = payload;
FlashGeometryResponse response = {
.region = request->region
};
if (request->region == REGION_PRF) {
// assume we're about to write to this region, ... | {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")", length);
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... | {
conn_idx = dev->conn_idx;
device_remove_pairing(dev);
} | |
0, 0, 28, 28));
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callb... | (&ctx.dest_bitmap, "draw_circle_origin_aa_r1_clip_nxny.${BIT_DEPTH_NAME}.pbi") | );
// Testing of the special cases for radius:
// Radius of 3 - starting point for calculated edges
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT_NXNY, RADIUS_MIN_CALCULATED);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_ci... |
ur board to get out!!");
__disable_irq();
RTC_ITConfig(RTC_IT_WUT, DISABLE);
RTC_WakeUpCmd(DISABLE);
// disable all IRQn_Type >= 0 interrupts
for (size_t i = 0; i < ARRAY_LENGTH(NVIC->ISER); i++) {
NVIC->ICER[i] = NVIC->ISER[i];
}
// disable SysTick
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
en... | if (bt_test_chip_in_test_mode()) {
prompt_send_response("You must run \"bt test stop\" to conduct sleep test!");
return;
} | |
mmand) {
.type = GDrawCommandTypeCircle,
.hidden = false,
.stroke_color = GColorGreen,
.stroke_width = 1,
.fill_color = GColorOrange,
.radius = 300,
.num_points = 1,
};
command->points[0] = (GPoint) { 1, 2 };
command = gdraw_command_list_get_command(&frame->command_list, 2);
GPoint ... | gdraw_command_sequence_get_frame_by_elapsed(sequence, 45 * 5) | ;
cl_assert_equal_p(frame, gdraw_command_sequence_get_frame_by_index(sequence, 0));
frame = gdraw_command_sequence_get_frame_by_elapsed(sequence, (45 + 15) * 5);
cl_assert_equal_p(frame, gdraw_command_sequence_get_frame_by_index(sequence, 1));
// test that the sequence returns the last frame if the play count ... |
480, -280},
{ 728, 520, -344},
{ 760, 624, -488},
{ 872, 816, -528},
{ 808, 784, -400},
{ 1104, 760, -272},
{ 1136, 832, -240},
{ 1312, 776, -152},
{ 1592, 688, -8},
{ 1504, 560, 32},
{ 1160, 440, -24},
{ 888, 392, -72},
{ 776, 304, -104},
{ 744, 240, -96},
{ 720... | { 1240, 216, -208},
{ 1064, 400, -392},
{ 824, 400, -344},
{ 688, 472, -280},
{ 712, 456, -304},
{ 768, 504, -376},
{ 808, 488, -432},
{ 840, 528, -496},
// 100 seconds
{ 896, 544, -552},
{ 968, 552, -416},
{ 1352, 608, -264},
{ 1296, 648, -264},
{ 1328, 616, -232... |
{ 992, 784, -240},
{ 1248, 712, -224},
{ 1216, 728, -280},
{ 1088, 720, -352},
{ 1456, 672, -288},
{ 1720, 408, -24},
{ 1360, 336, -104},
{ 1016, 360, -160},
{ 832, 328, -80},
{ 752, 256, -32},
{ 752, 200, -8},
{ 736, 184, -32},
{ 736, 160, 8},
{ 904, 216, -112},... |
s, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_outside_y);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.de... | (text_resources_init_font(0, gothic_18_handle, 0, &s_font_info)) | ;
test_graphics_context_init(&ctx, fb);
// Test when clipping/drawing and text bounds are all at (0, 0)
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_TEXT_0_0,
GT... |
ue /* send_event */));
cl_assert(reminder_db_get_len((uint8_t *)&item2.header.id, sizeof(Uuid)) == 0);
// check item 3 or 4
memset(&temp, 0, sizeof(TimelineItem));
cl_assert(S_SUCCESS == reminder_db_next_item_header(&temp));
if (uuid_equal(&item3.header.id, &temp.header.id)) {
temp.attr_list.attributes =... | (&title_item1) | );
TimelineItem reminder;
// Test non-matching title and timestamp
cl_assert_equal_b(reminder_db_find_by_timestamp_title(0, "nonexistent title", NULL, &reminder),
false);
// Test matching timstamp, but not title
cl_assert_equal_b(reminder_db_find_by_timestamp_title(title_item1.header.ti... |
* ACTIVITY_CALORIES_PER_KCAL;
int minute_of_day = time_util_get_minute_of_day(utc_now);
s_activity_state.resting_calories = activity_private_compute_resting_calories(minute_of_day);
key = ActivitySettingsKeyLastSleepActivityUTC;
settings_file_get(file, &key, sizeof(key),
... | syscall_assert_userspace_buffer(sessions, sizeof(*sessions) * (*session_entries)) | ;
}
}
return activity_get_sessions(session_entries, sessions);
}
// ------------------------------------------------------------------------------------------------
DEFINE_SYSCALL(bool, sys_activity_prefs_heart_rate_is_enabled, void) {
return activity_prefs_heart_rate_is_enabled();
}
// -----------------... |
pdate_scroll_offset(TimelineItemLayer *item_layer, int16_t new_offset,
bool is_first_scroll) {
static const PropertyAnimationImplementation implementation = {
.base = {
.update = (AnimationUpdateImplementation) property_animation_update_int16,
},
.accessors = {
... | (
&config, window_manager_get_window_stack(ModalPriorityNotification)) | ;
}
static void prv_handle_up_click(ClickRecognizerRef recognizer, void *context) {
TimelineItemLayer *item_layer = (TimelineItemLayer *)context;
const int16_t min_scroll = prv_get_min_scroll_offset(item_layer);
const int16_t first_scroll = prv_get_first_scroll_offset(item_layer);
int16_t current_scroll = item... |
var f1 = function(){throw new Error('test')};\n"
"var f2 = function(){throw new 'test';};\n"
"var f2 = function(){throw new 123;};\n"
"try {f1();} catch(e) {e1 = e;}\n"
"try {f2();} catch(e) {e2 = e;}\n"
"try {f3();} catch(e) {e3 = e;}\n";
EXECUTE_SCRIPT(script);
jerry_value_t e1 = prv_js_globa... | (jerry_value_is_constructor(date_builtin)) | ;
jerry_release_value(date_builtin);
jerry_value_t json_builtin = jerry_get_global_builtin((const jerry_char_t *)"JSON");
cl_assert(jerry_value_is_object(json_builtin));
jerry_release_value(json_builtin);
jerry_value_t not_builtin = jerry_get_global_builtin((const jerry_char_t *)"_not_builtin_");
cl_asser... |
cted_ack_sn;
sn != sn_end_excl; sn = prv_next_sn(sn)) {
num_bytes += prv_get_payload_size_for_sn(client, sn);
}
return num_bytes;
}
static uint16_t prv_total_num_bytes_awaiting_ack(const PPoGATTClient *client) {
return prv_total_num_bytes_awaiting_ack_up_to(client, client->out.next_data_sn);
}
static... | while (client) {
prv_increment_timeout_counter_if_necessary(client);
prv_check_timeouts(client);
client = (PPoGATTClient *) client->node.next;
} |
}
bt_unlock();
}
// -------------------------------------------------------------------------------------------------
static PPoGATTClient *prv_create_client(void) {
PPoGATTClient *client = kernel_malloc(sizeof(PPoGATTClient));
if (!client) {
return NULL;
}
*client = (PPoGATTClient){};
client->app_... |
) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
cl_assert(state.node->all_day);
// check that the item we see is timestamped at local midnight rather than utc midnight
// 1421136000 is midnight Jan 13, PST
cl_assert_equal_i(state.pin.header.timestamp, 1421136000);
// second all day... | cl_assert(state.node->all_day) | ;
cl_assert(!iter_next(&iterator));
cl_assert(iter_prev(&iterator));
cl_assert(!iter_prev(&iterator));
}
void test_timeline__all_day_middle_past(void) {
prv_insert_all_day_items();
// 1421183640 is 13:14 on Jan 13, 2015
// after first timed event of the day but not all of them
Iterator iterator = {0};
... |
"kernel/events.h"
#include "popups/ble_hrm/ble_hrm_reminder_popup.h"
#include "popups/ble_hrm/ble_hrm_sharing_popup.h"
#include "process_management/app_manager.h"
#include "services/common/analytics/analytics.h"
#include "services/common/analytics/analytics_event.h"
#include "services/common/hrm/hrm_manager_private.h"
... | {
return false;
} |
return prv_is_sharing(connection);
}
bool ble_hrm_is_sharing(void) {
return (s_ble_hrm_subscription_count > 0);
}
typedef struct {
BTDeviceInternal *next_permitted_device;
size_t slots_left;
} CopySharingDevicesCtx;
static void prv_copy_sharing_devices_for_each_connection_cb(GAPLEConnection *connection,
... |
icense at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific la... | (&s_ctx, &line, &word_iter_state.current, &text_box_params) | |
f will be alternating between dithered gray and black lines
// The bottom half consists of a diagonal white line on a black background
void test_bitblt_palette_1bit__2bit_palette_to_1bit_assign(void) {
GBitmap *src_bitmap =
get_gbitmap_from_pbi("test_bitblt_palette_1bit__2bit_palette_to_1bit.pbi");
bitblt... | {
cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorWhite, 0), 0xFFFFFFFF);
cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorWhite, 1), 0xFFFFFFFF);
cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorLightGray, 0), 0x55555555);
cl_assert_equal_i(graphics_pri... | |
,
[PowerSystemMcuCoreRun] = { "McuCoreRun", 0, 0, false},
[PowerSystemMcuGpioA] = { "McuGpioA", 0, 0, false},
[PowerSystemMcuGpioB] = { "McuGpioB", 0, 0, false},
[PowerSystemMcuGpioC] = { "McuGpioC", 0, 0, false},
[PowerSystemMcuGpioD] = { "McuGpioD", 0, 0, false},
[Pow... | {
if (!s_initialized) {
return;
}
PBL_ASSERTN(system < num_power_systems);
DiscreteSystemProfile *current_profile = &s_discrete_consumer_profiles[system];
if (current_profile->start_ticks != 0) {
PBL_LOG(LOG_LEVEL_WARNING, "repeat call to start ticks without stopping from %s", current_profile->name)... |
void power_tracking_stop(PowerSystem system) {
if (!s_initialized) {
return;
}
PBL_ASSERTN(system < num_power_systems);
DiscreteSystemProfile *current_profile = &s_discrete_consumer_profiles[system];
if (current_profile->start_ticks == 0) {
PBL_LOG(LOG_LEVEL_WARNING, "Stop ticks before start calle... |
strncpy(s_last_args_for_mock.func, __func__, sizeof(s_last_args_for_mock.func));
}
void prv_draw_round_rect_stroked(GContext* ctx, const GRect *rect, uint16_t radius, uint8_t stroke_width) {
s_last_args_for_mock = (ArgsForMock){
.ctx = *ctx,
.r0 = *rect,
.radius = radius,
.corner_mask = GCornersAl... | graphics_context_set_stroke_color(&context, color) | ;
#if PBL_COLOR
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorBlue.argb);
#else
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorBlack.argb);
#endif
color.a = 1;
graphics_context_set_stroke_color(&context, color);
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorClea... |
! (Should only ever be one!) If we are > 75% through the shared PRF region,
//! erase the sector and re-write the info at offset 0. We want to make the chance
//! of blocking on an erase ~0, by doing this prep on init.
void shared_prf_storage_init(void) {
s_sprf_mutex = mutex_create();
prv_lock();
{
s_valid_... | {
SprfBlePairingData data;
rv = SPRF_FETCH_FIELD(data, ble_pairing_data);
if (!rv) {
goto unlock;
}
if (!data.fields) {
// The pairing stored is empty
rv = false;
goto unlock;
}
if (pairing_info_out) {
*pairing_info_out = (SMPairingInfo) {
.local_encry... | |
/*
* 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... | (db_id == s_blobdb_id) | |
't get or send again if waiting on the ACK
cl_assert_equal_i(app_message_outbox_begin(&iter), APP_MSG_BUSY);
cl_assert_equal_i(app_message_outbox_send(), APP_MSG_BUSY);
}
void test_app_message__send_disconnected(void) {
prv_set_remote_receive_handler(prv_nack_sent_callback);
// Disconnect the comm session
s... | {
// FIXME:
// https://pebbletechnology.atlassian.net/browse/PBL-22925
return;
prv_set_remote_receive_handler(prv_receive_ack_nack_callback);
prv_receive_test_data(TEST_TRANSACTION_ID_2, true);
// Message should be dropped due to buffer overflow
cl_assert_equal_b(s_in_dropped_is_called, true);
cl_asse... |
void test_app_message__receive_app_not_running(void) {
// FIXME:
// https://pebbletechnology.atlassian.net/browse/PBL-22925
return;
prv_set_remote_receive_handler(prv_receive_ack_nack_callback);
prv_receive_test_data(TEST_TRANSACTION_ID_2, false);
cl_assert_equal_b(s_in_received_is_called, false);
cl_... |
IP_NXNY, true, 1);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw1_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// AA = true, SW = 2
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 2);
graphics_draw_rect(&ctx, &ORIGIN... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw11_clip_nxny.${BIT_DEPTH_NAME}.pbi")) | ;
#endif
}
void test_graphics_draw_rect_${BIT_DEPTH_NAME}__origin_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// SW = 1
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.des... |
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 "process_manager.h"
#include "app_install_manager.h"
#include "app_manager.h"
#include "worker_manager.h"
#include "applib/app_logging.... | {
PebbleTask task = pebble_task_get_current();
ProcessContext *context = prv_get_context_for_task(task);
if (context->closing_state == ProcessRunState_ForceClosing) {
PBL_LOG(LOG_LEVEL_DEBUG, "Hit syscall exit trap!");
context->safe_to_kill = true;
process_manager_put_kill_process_event(task, false);... |
// ---------------------------------------------------------------------------------------------
void process_manager_init(void) {
s_deinit_timer_id = new_timer_create();
}
// -----------------------------------------------------------------------------------------------------------
void process_manager_put_kill... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.