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... | (BOOT_BIT_NEW_PRF_AVAILABLE) | |
de <bluetooth/features.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
// Caches of the local address and device name.
// Some clients (i.e. Settings app) make a lot of calls to this module. By caching this info,
// we avoid having to reach out to the BT driver every time.
static BTDeviceAddress s_loca... | (addr_out->octets) | - 1] |= 0b11000000;
// Addresses with all 0's or 1's
const BTDeviceAddress zero_addr = {.octets = {0x00, 0x00, 0x00, 0x00, 0x00, 0xC0}};
const BTDeviceAddress one_addr = {.octets = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
// NOTE: It already has the two most sig. bits set.
const BTDeviceAddress fallb... |
/*
* 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 s_in_low_power;
} |
bool firmware_update_is_in_progress(void) {
return false;
}
void battery_force_charge_enable(bool is_charging) { }
bool stop_mode_is_allowed(void) {
return s_stop_mode_allowed;
}
static void periodic_timer_trigger(int count) {
TimerID timer_id = battery_state_get_periodic_timer_id();
cl_assert(timer_id != ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (log_contains_build_id) | ;
}
return true;
}
bool s_completed = false;
bool s_completed_success = false;
static void prv_flash_log_dump_completed_cb(bool success) {
PBL_LOG(LOG_LEVEL_DEBUG, "Called prv_flash_log_dump_completed_cb(%d)", (int)success);
s_completed = true;
s_completed_success = success;
}
static void setup_and_test_ex... |
eResourceSizeTiny, &res_info));
cl_assert_passert(timeline_resources_get_id(&timeline_res_info, TimelineResourceSizeTiny, NULL));
// Set the TimelineResourceInfo to have the UUID of an app with an invalid LUT
const TimelineResourceTestAppData *app_with_invalid_lut_data =
prv_get_data_for_app_with_id(Timeli... | cl_assert(!timeline_resources_is_system(TIMELINE_RESOURCE_INVALID)) | ;
cl_assert(!timeline_resources_is_system(NUM_TIMELINE_RESOURCES));
}
|
grect = to_value ? *((GRect*)to_value)
: implementation->accessors.getter.grect(subject);
property_animation->values.from.grect = from_value ? *((GRect*)from_value)
: implementation->accessors.getter.grect(subject);
#if !PLATFO... | memset(property_animation, 0, sizeof(*property_animation)) | ;
uint8_t *dst = (uint8_t *)property_animation;
uint8_t *src = (uint8_t *)from;
uint32_t offset = sizeof(AnimationPrivate); // Skip the base class fields
uint32_t size = sizeof(PropertyAnimationPrivate) - offset;
memcpy(dst + offset, src + offset, size);
return property_animation;
}
// -------------... |
{
const ResponseTimeState state = reduced_latency ? ResponseTimeMiddle : ResponseTimeMax;
comm_session_set_responsiveness(comm_session_get_system_session(),
BtConsumerMusicServiceIndefinite, state,
MAX_PERIOD_RUN_FOREVER);
} |
static void prv_music_request_low_latency_for_period(uint32_t period_ms) {
comm_session_set_responsiveness(comm_session_get_system_session(),
BtConsumerMusicServiceMomentary,
ResponseTimeMin,
period_ms / MS_PER_SEC... | |
ontext *ctx, GBitmap *buffer) {
PBL_ASSERTN(ctx);
ctx->lock = false;
framebuffer_dirty_all(ctx->parent_framebuffer);
return true;
}
void test_simple_dialog__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
test_graphics_context_init(&s_ctx, fb);
... | (gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_simple_dialog__alarm_deleted(void) {
SimpleDialog *simple_dialog = simple_dialog_create("Alarm Deleted");
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
dialog_set_text(dialog, "Alarm Deleted");
dialog_set_icon(dialog, RESOURCE_ID_RESULT_SHREDDED_LARGE);
dialog_set_background_color(d... |
l") == 0) {
// TODO: PBL-23915
// We leak this i18n'd string because not leaking it is really hard.
// We make sure we only ever allocate it once though, so it's not the end of the world.
action->attr_list.attributes[1].cstring = (char*)i18n_get("Call Back", __FILE__);
}
return rv;
}
static uint8_... | prv_add_pstring_to_attribute(*buffer, app_id, APP_ID_MAX_LENGTH,
&item->attr_list.attributes[attr_idx],
AttributeIdiOSAppIdentifier) | ;
attr_idx++;
}
// add the icon attribute
item->attr_list.attributes[attr_idx].id = AttributeIdIconTiny;
item->attr_list.attributes[attr_idx].uint32 = app_metadata->icon_id;
attr_idx++;
#if PBL_COLOR
if (app_metadata->app_color != 0) {
item->attr_list.attributes[attr_idx].id = AttributeIdBgColor;
... |
/*
* 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... | {
CronJob* job = (CronJob*)s_scheduled_jobs;
s_scheduled_jobs = list_pop_head(s_scheduled_jobs);
// Re-calculate the execute time.
// See the notes in the API header on how this works.
if (must_recalc || change_diff >= job->clock_change_tolerance) {
job->cached_execute_time = cron_job_get_exec... |
// Then move it back to the static
s_scheduled_jobs = newlist;
mutex_unlock(s_list_mutex);
// We want to run any tasks we've skipped over.
prv_timer_callback(NULL);
}
// --------------------------------------------------------------------------------------------
void cron_service_init(void) {
PBL_ASSERT... |
aphics/graphics.h"
#include "applib/graphics/framebuffer.h"
#include "applib/graphics/gtransform.h"
#include "util/trig.h"
#include "util/math_fixed.h"
#include "clar.h"
#include <stdio.h>
#include <string.h>
// Helper Functions
////////////////////////////////////
// Stubs
////////////////////////////////////
#in... | cl_assert(gtransform_is_equal(&t, &t_c)) | ;
cl_assert(gtransform_is_identity(&t));
cl_assert(gtransform_is_identity(&t_c));
// Test Scale Matrix
t = GTransformScale(GTransformNumberFromNumber(2), GTransformNumberFromNumber(5));
t_c = GTransformFromNumbers(2, 0, 0, 5, 0, 0);
cl_assert(gtransform_is_equal(&t, &t_c));
cl_assert(gtransform_is_only_... |
//! With one event in flight, walk through the prepare, write, finish happy
//! path. Ensure that the endpoint handler CB is run from kernel BG and that
//! we don't leak memory
void test_default_kernel_receiver__prepare_write_finish_single(void) {
char *data = "helloworld";
Receiver *receiver = g_default_kern... | prv_assert_no_handler_calls() | ;
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
}
//! Test the case where a callback has been pended to kernelBG and we get a cleanup
void test_default_kernel_receiver__race_condition(void) {
char *data = "cleanup but finish ran first!";
Receiver *receiver = g_default_kernel_receiver_implementation.pr... |
->node,
&data_node->node);
}
circular_buffer_consume(&session->send_buffer, sizeof(pp_header) + pp_header.length);
}
kernel_free(buffer);
}
static void prv_fake_transport_reset(Transport *transport) {
cl_assert_(false, "Not implemented: prv_fake... | (fake_transport) | |
/*
* 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(strcspn(testbuf, "o!B"), 4) | ;
cl_assert_equal_i(strcspn(testbuf, "o"), 4);
cl_assert_equal_i(strcspn(testbuf, "!"), 5);
cl_assert_equal_i(strcspn(testbuf, "H"), 0);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | launcher_app_glance_structured_get_data(structured_glance) | ;
if (watchfaces_glance) {
kino_reel_destroy(watchfaces_glance->icon);
}
app_free(watchfaces_glance);
}
static void prv_update_active_watchface_title(LauncherAppGlanceWatchfaces *watchfaces_glance) {
const AppInstallId selected_watch_id = watchface_get_default_install_id();
AppInstallEntry entry;
if (... |
enuIndex(0, 1), MenuRowAlignTop, false);
cl_assert_equal_i(1, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(basic_cell_height, l.selection.y);
const int y_center_of_row_1 = basic_cell_height + basic_cell_height / 2;
const int row1_vertically_centered = height / 2 - y_center_of_row_1;
cl_assert_eq... | cl_assert_equal_i(2 * FOCUSED - NORMAL, l.selection.y) | ;
cl_assert_equal_i(NORMAL, l.selection.h);
cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]);
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
}
void test_menu_layer__center_focused_respects_row_height_for_selection(void) {
MenuLayer l;
const int height =... |
tion = &aml->item_animation;
if (item_animation->animation == NULL) {
const int16_t DELAY_PER_LINE = 600; /* milliseconds to delay per line */
// Top offset represents when the text has scrolled to its minimum y value so the last line of
// text is visible. Bottom offset represents when the text ... | {
indicator = INDICATOR;
} | else {
const GSize indicator_size = graphics_text_layout_get_max_used_size(
ctx, INDICATOR, font, *content_box, GTextOverflowModeWordWrap, GTextAlignmentRight, NULL);
content_box->size.w -= (indicator_size.w + (2 * horizontal_padding));
}
} else {
content_box->size.w -= horizontal_paddi... |
ile 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... | prv_touch_queue_add(ctx, touch_idx, TouchEvent_Liftoff, pos, 0, time_ms) | ;
TOUCH_DEBUG("Touch %"PRIu8": Liftoff!", touch_idx);
}
update = true;
} else if (touch_state == TouchState_FingerDown) {
PBL_ASSERTN(pos);
if (ctx->touch_queue.count > 0) {
// don't update if the position hasn't changed
TouchEvent *last = &ctx->touch_queue.events[prv_get_idx_last_it... |
_unschedule_all_handler,
.teardown = prv_teardown_handler
};
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
animation_set_delay(a, delay_a);
animation_set_auto_destroy(a, auto_destroy);
animation_schedule(a);
Animation *b = prv_create_test_animation();
animation... | animation_get_custom_curve(a) | , NULL);
cl_assert_equal_p(animation_get_custom_interpolation(a), NULL);
cl_assert_equal_i(animation_get_curve(a), AnimationCurveDefault);
animation_set_custom_curve(a, curve);
cl_assert_equal_p(animation_get_custom_curve(a), curve);
cl_assert_equal_p(animation_get_custom_interpolation(a), NULL);
cl_assert... |
get_time();
HealthValue result;
// today until now
result = health_service_sum(HealthMetricStepCount,
time_util_get_midnight_of(now),
now);
cl_assert_equal_i(result, 1000);
cl_assert_equal_i(s_sys_activity_get_metric_values.in.history_len, ACTIVITY_H... | time_util_get_midnight_of(now) | - SECONDS_PER_DAY,
time_util_get_midnight_of(now) - SECONDS_PER_DAY / 4);
cl_assert_equal_i(result, 1500);
cl_assert_equal_i(s_sys_activity_get_metric_values.in.history_len, ACTIVITY_HISTORY_DAYS);
// 1/2 of today's captured seconds so far
result = health_service_sum(HealthMetric... |
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(4));
cl_assert(timeline_model_iter_next(&new_idx, &has_next));
cl_assert(has_next);
cl_assert_equal_i(new_idx, 5);
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order... | timeline_model_get_num_items() | , 2);
cl_assert(uuid_equal(&s_items[s_correct_order[1]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[3]].header.id,
&ti... |
}
void test_window_stack__modal_properties_unfocused(void) {
const int num_windows_per_stack = 2;
Window *windows[NumModalPriorities][num_windows_per_stack];
WindowStack *window_stacks[NumModalPriorities];
for (ModalPriority idx = ModalPriorityMin; idx < NumModalPriorities; idx++) {
window_stacks[idx] = ... | window_stack_push(window_stacks[1], windows[1][0], false) | ;
// An opaque top window is now below two unfocusable top windows
// Test: An opaque top window below a unfocusable top window removes Unfocusable
// i.e. A unfocusable top window above an opaque top window does not result in Unfocusable
modal_manager_event_loop_upkeep();
cl_assert_equal_i(modal_manag... |
value_u32p && (uint32_t)value > *m_info.value_u32p) {
*m_info.value_u32p = value;
current_value_updated = true;
}
} else if (m_info.has_history) {
// This update is for a day in the past. Modify the copy stored in the settings file
SettingsFile *file = activity_private_settings_open();
if ... | ROUND(state->active_calories,
ACTIVITY_CALORIES_PER_KCAL) | ;
ACTIVITY_LOG_DEBUG("new active kcal: %"PRIu16"", state->step_data.active_kcalories);
}
mutex_unlock_recursive(state->mutex);
}
// --------------------------------------------------------------------------------------------
// Called periodically from the minute handler to update step derived metrics that do... |
calc_buffer_size(3, 10, 100, 1000);
cl_assert(size == sizeof(Dictionary) + (3 * sizeof(Tuple)) + 10 + 100 + 1000);
}
struct SerializeTestResult {
bool okay;
uint16_t expected_size;
};
static void serialize_callback(const uint8_t * const data, const uint16_t size, void *context) {
struct SerializeTestResult *r... | memcmp(tuple->value->data, SOME_DATA, sizeof(SOME_DATA)) | == 0);
data_found = true;
break;
case SOME_STRING_KEY:
cl_assert(tuple->length == strlen(SOME_STRING) + 1);
cl_assert(strncmp(tuple->value->cstring, SOME_STRING, strlen(SOME_STRING) + 1) == 0);
// Check zero termination:
cl_assert(tuple->value->cstring[strlen(SOME_... |
/*
* 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... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME pbl_37567
//> TEST_VERSION 3
//> TEST_TOTAL -1
//> TEST_TOTAL_MIN -1
//> TEST_TOTAL_MAX -1
//> TEST_DEEP -1
//> TEST_DEEP_MIN -1
//> TEST_DEEP_MAX -1
//> TEST_START_AT 190
//> TEST_START_AT_MIN 180
//> TEST_START... |
{ 0, 0x6d, 0, 121, 0},
{ 0, 0x7d, 1666, 125, 0},
{ 0, 0x7f, 0, 123, 0},
{ 0, 0x7f, 749, 126, 0},
{ 0, 0x7e, 539, 127, 0},
// 30: Local time: 2016-05-15 09:45:00 PM
{ 0, 0x7e, 0, 125, 0},
{ 0, 0x7e, 0, 127, 0},
{ 0, 0x7e, 0, 127, 0},
{ 0, 0x7e, 0, 151, 0},
{ 0, 0x7e, 0, 129, ... |
// registers has been enabled
static void prv_enable_backup_access() {
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_BackupAccessCmd(ENABLE); // Disable write-protect on RTC_BKP_x registers
}
void boot_main(void) {
prv_configure_system_flash();
prv_enable_backup_access();
dbgserial_init();
prv... | {
// We've failed to load recovery mode too many times.
prv_sad_watch(ERROR_CANT_LOAD_FW);
} | |
(StationaryActionWakeUp) | ;
}
//! If the watch is determined to be motionless for 30 minutes, it will go to sleep
static void prv_watch_is_motionless(void) {
// Check if we should enable stationary mode and disabled unneeded features
if (s_stationary_count_down > 0) {
PBL_LOG_D(DEBUG_STATIONARY, LOG_LEVEL_DEBUG,
"Countdow... | |
/*
* 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... | connection_service_subscribe(conn_handlers) | ;
}
void bluetooth_connection_service_unsubscribe(void) {
connection_service_unsubscribe();
}
bool bluetooth_connection_service_peek(void) {
return connection_service_peek_pebble_app_connection();
}
|
/*
* 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... | event_service_client_unsubscribe(&state->event_info) | |
test_app_message__send_disconnected(void) {
prv_set_remote_receive_handler(prv_nack_sent_callback);
// Disconnect the comm session
s_is_connected = false;
// The return value should be APP_MSG_OK, even though we already know it's going to fail.
// The failure should be delivered after returning from app_mes... | cl_assert_equal_b(s_nack_received_for_id_2, true) | ;
// Check that the state was reset
check_in_accepting_again();
}
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_... |
(animation) | , false);
// Create play animation unschedules previous animation
animation = (Animation *)kino_player_create_play_animation(test_player);
cl_assert_equal_i(animation_is_scheduled(animation), false);
animation_schedule(animation);
// Pause unschedules the current animation
cl_assert_equal_i(animation_is_s... | |
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
// Simulate some delay incurred on every call to rtc_get_ticks()
fake_rtc_auto_increment_ticks(3);
Animation *a0, *a1, *a2, *a3;
Animation *b0, *b1, *b2, *b3;
Animation *spawn_a, *spawn_b;
for (int i=0; i<4; i++) {
switch(create... | prv_last_handler_entry(&s_started_handler_calls, b3) | ->fire_order);
first_fire_b = MIN(first_fire_b,
prv_last_handler_entry(&s_started_handler_calls, spawn_b)->fire_order);
cl_assert(last_fire_a < first_fire_b);
cl_assert_equal_i(prv_count_animations(), 0);
}
// ---------------------------------------------------------------------------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (memcmp(&num, &test_num, sizeof(Fixed_S16_3)) == 0) | ;
num = (Fixed_S16_3){ .raw_value = (int16_t)((float)3.5 * (1 << FIXED_S16_3_PRECISION)) };
test_num = (int16_t)((float)3.5 * (1 << FIXED_S16_3_PRECISION));
cl_assert(memcmp(&num, &test_num, sizeof(Fixed_S16_3)) == 0);
num = (Fixed_S16_3){ .raw_value = (int16_t)((float)-2 * (1 << FIXED_S16_3_PRECISION)) };
... |
init_index(request, &index)) {
goto exit;
}
uint32_t append_offset = 0;
if (s_pb_state.receiver.length > offsetof(InitRequest, extra_info)) {
// We compute the offset this way because filename installs can be variable length. In the
// future, if we used this feature for files, this would allow for t... | {
uint32_t elapsed_time_ms = ticks_to_milliseconds(rtc_get_ticks() - s_pb_state.start_ticks);
const CommitRequest *request = (const CommitRequest *)s_pb_state.receiver.buffer;
uint32_t crc = ntohl(request->crc);
uint32_t calculated_crc = pb_storage_calculate_crc(&s_pb_state.storage, PutBytesCrcType_Legacy);
... |
static bool prv_is_valid_command_for_current_state(PutBytesCommand command) {
switch (s_pb_state.current_command) {
case PutBytesIdle:
return (command == PutBytesInit || command == PutBytesInstall);
case PutBytesInit:
return (command == PutBytesPut || command == PutBytesAbort);
case PutBytesPut:
r... |
s_prv_activity_cb__args[0].time_start,
s_sys_activity_get_sessions_values.out.sessions[1].start_utc);
cl_assert_equal_i(s_prv_activity_cb__args[3].time_start,
s_sys_activity_get_sessions_values.out.sessions[2].start_utc);
// order direction future
s_prv_activity_cb__call_c... | cl_assert_equal_i(0, written) | ;
// empty start
written = health_service_get_minute_history(data, ARRAY_LENGTH(data), NULL, &time_end);
cl_assert_equal_i(0, written);
// empty end before start
time_t early_end = time_start - 20 * SECONDS_PER_MINUTE;
written = health_service_get_minute_history(data, ARRAY_LENGTH(data), &time_start, &ear... |
__IO uint16_t *flash_write_dest = (__IO uint16_t*)
(FMC_BANK_1_BASE_ADDRESS + (start_addr & ~0x1));
uint32_t bytes_remaining = bytes_in_page;
// Handle leading byte
if (start_addr & 0x1) {
// Handle a buffer with an unaligned start. Write 0xff for the first byte
// since flash can only flip ones ... | FMC_NORSRAMCmd(FMC_Bank1_NORSRAM1, DISABLE) | ;
FMC_NORSRAMInit(nor_init);
FMC_NORSRAMCmd(FMC_Bank1_NORSRAM1, ENABLE);
}
static uint16_t prv_get_num_wait_cycles(uint32_t flash_clock_freq) {
// wait_cycle table based on frequency (table 7.1)
// NOTE: 27MHZ frequency skipped due to data latency being 4 smaller than the wait_cycle
uint32_t wait_cycle[] = {... |
bus->i2c->DR = bus->transfer.device_address | I2C_READ_WRITE_BIT;
if (bus->transfer.size == 1) {
// Last byte, we want to NACK this one to tell the slave to stop sending us bytes.
bus->i2c->CR1 &= ~I2C_CR1_ACK;
}
bus->transfer.state = TRANSFER_STATE_WAIT_FOR_DATA;
break;
cas... | (&i2c_buses[0]) | |
* is_connected */);
prv_simulate_transport_connection_event(false /* is_connected */);
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateDisconnected);
}
static void prv_init_and_goto_awaiting_reset_complete_remote_initiated(void) {
prv_init_api(true /* st... | prv_rcv_app_message_ack(APP_MSG_OK) | ;
// Chunk is ignored, no new reset request is sent out.
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
// TODO: timeout + retry ResetRequest if no ResetComplete follows within N secs.
}
void test_rocky_api_app_message__awaiting_reset_complete_loc_init__(void) {
prv_init_and_goto_awaiting_reset_complete_local_initiated... |
th;
break;
case BTPairingUIStateFailed:
case BTPairingUIStateSuccess:
alignment = GAlignTop;
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
x_offset = 0;
y_offset = 59;
#else
x_offset = 2;
y_offset = PBL_IF_RECT_ELSE(30, 36);
#endif
width = window_width;
break;
defa... | layer_set_clips(&data->info_text_mask_layer, true) | ;
layer_add_child(&window->layer, &data->info_text_mask_layer);
TextLayer *info_text_layer = &data->info_text_layer;
text_layer_init_with_parameters(info_text_layer,
&pair_text_area,
data->info_text_layer_buffer,
#if PLATFORM_ROBERT || PLATFORM_... |
_HOUR) + (30 * SECONDS_PER_MINUTE) + 1);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 11 H", time_buf);
// June 12th 2015, 00:59:59 (T-11:00:01)
rtc_set_time(event_time - (11 * SECONDS_PER_HOUR) - 1);
clock_get_until_time_capitalized(time_b... | clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("59 MIN AGO", time_buf);
// June 9th 2015, 12:59:59 (T+00:59:59)
rtc_set_time(event_time + (59 * SECONDS_PER_MINUTE) + 59);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("59 MIN AGO", time_buf);
// June 9th 2015, 13:00:00 ... |
r_write(&s_manager_state.system_task_event_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) {
.eve... | {
HRMFeature feature = (1 << i);
if (!(state->features & feature)) {
continue;
}
// Only send BPM and HRV events if the sensor is stable
if (!stable_sensor && (feature == HRMFeature_BPM || feature == HRMFeature_HRV)) {
continue;
}
if (state->callback_handler) {
... |
// If this is an app subscription, see if we need to send an "expiring" event. We check
// KernelBG subscribers from the system callback function (prv_system_task_hrm_handler).
if (!state->callback_handler && prv_needs_expiring_event(state, utc_now)) {
hrm_event = (PebbleHRMEvent) {
.event_t... |
tion_get_duration(b, false, false), duration_b);
cl_assert_equal_i(animation_get_duration(b, false, true), play_count_b * duration_b);
cl_assert_equal_i(animation_get_duration(b, true, false), delay_b + duration_b);
cl_assert_equal_i(animation_get_duration(b, true, true), total_duration_b);
cl_assert_equal_i(a... | (animation_set_auto_destroy(h, false) == true) | ;
// Handlers
void *context = &value;
animation_set_handlers(h, handlers, context);
AnimationHandlers c_handlers = animation_get_handlers(h);
cl_assert(memcmp(&c_handlers, &handlers, sizeof(AnimationHandlers)) == 0);
// Context
cl_assert(animation_get_context(h) == context);
// Duration
cl_assert(a... |
->num_days < 1)) {
return;
}
// as all indices inside of values[] are relative to range.last_day_idx, we adjust the pointer
// once here to simplify the following lines
values += range->last_day_idx;
// last day might not be complete, yet (as it can be today)
values[0] =
(HealthValue)(((int64_t)va... | APP_LOG(APP_LOG_LEVEL_ERROR, "Unsupported scope: %d", (int) scope) | ;
result = 0;
}
// Get the result
switch (aggregation) {
case HealthAggregationSum:
// NOTE: the caller is asking for "sum" aggregation, but we only have one value stored per
// day, so we just need to compute the average amongst all the days.
result = which_stats->avg;
break;
... |
, 1);
shared_prf_storage_set_local_device_name(DEVICE_NAME);
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 1);
}
// Test that setting and retrieving a pinned address works.
void test_shared_prf_storage_v3__pinned_address(void) {
shared_prf_storage_set_ble_pinned_address(&DEVICE_ADDR);
BTDeviceA... | shared_prf_storage_get_ble_pairing_data(&pairing_info_out, device_name_out,
&requires_address_pinning,
&flags) | ;
cl_assert_equal_b(requires_address_pinning, true);
cl_assert_equal_i(flags, 0xff);
cl_assert_equal_b(sm_is_pairing_info_equal_identity(&PAIRING_INFO, &pairing_info_out), true);
cl_assert_equal_s(device_name_out, DEVICE_NAME);
// Check local_name
cl_assert_equal_b(shared_prf_storage_get_local_device_name(... |
/*
* 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... | shared_circular_buffer_read(&s_buffer, &s_buffer_client, sizeof(uint8_t), &data_read, &read_length) | ;
PBL_ASSERTN(result);
PBL_ASSERT(read_length == sizeof(uint8_t), "read_length %u sizeof(uint8_t) %u", read_length, sizeof(uint8_t));
uint8_t msg_length = *data_read;
if (shared_circular_buffer_get_read_space_remaining(&s_buffer, &s_buffer_client) < msg_length + sizeof(uint8_t)) {
return; // Not ready yet,... |
am->controller);
// Configure and enable the IRQ if necessary (DMA interrupts enabled later)
if (this->irq_priority != IRQ_PRIORITY_INVALID) {
NVIC_SetPriority(this->stream->irq_channel, this->irq_priority);
NVIC_EnableIRQ(this->stream->irq_channel);
}
}
void dma_request_init(DMARequest *this) {
if (t... | {
case DMARequestType_MemoryToMemory:
case DMARequestType_PeripheralToMemory:
this->stream->periph->PAR = (uint32_t)src;
this->stream->periph->M0AR = (uint32_t)dst;
break;
case DMARequestType_MemoryToPeripheral:
this->stream->periph->PAR = (uint32_t)dst;
this->stream->periph->M... |
// set the mode and enable the appropriate interrupts
switch (transfer_type) {
case DMARequestTransferType_Direct:
this->stream->periph->CR &= ~DMA_SxCR_CIRC;
this->stream->periph->CR |= DMA_SxCR_TCIE;
break;
case DMARequestTransferType_Circular:
this->stream->periph->CR |= DMA_Sx... |
/*
* 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... | load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */) | ;
resource_init();
// Setup content indicator
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
content_indicator_init_buffer(buffer);
}
void test_health_activity_summary_card__cleanup(void) {
}
// Helpers
//////////////////////
static void prv_create_card_and_render(HealthData *heal... |
ibuted on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util/misc.h"
#include "drivers/i2c.h"
#include "drivers/periph_config.h"
#include "drivers/gpio.... | (pin_config.gpio) | ;
}
//! Configure bus pin as input
//! Lock bus and peripheral config access before use
static void bus_pin_cfg_input(AfConfig pin_config) {
gpio_use(pin_config.gpio);
// Configure pin as high impedance input
GPIO_InitTypeDef gpio_init_struct;
gpio_init_struct.GPIO_Pin = pin_config.gpio_pin;
gpio_init_struc... |
ree(node, NULL, layer_property_changed_tree_node);
}
void layer_set_update_proc(Layer *layer, LayerUpdateProc update_proc) {
PBL_ASSERTN(layer != NULL);
layer->update_proc = update_proc;
}
void layer_set_frame(Layer *layer, const GRect *frame) {
if (grect_equal(frame, &layer->frame)) {
return;
}
const b... | layer_remove_from_parent(child) | ;
}
PBL_ASSERTN(child->next_sibling == NULL);
child->parent = parent;
layer_set_window(child, parent->window);
if (child->window) {
window_schedule_render(child->window);
}
Layer *sibling = parent->first_child;
if (sibling == NULL) {
parent->first_child = child;
return;
}
for (;;) {
... |
phone_format_caller_name("Pankajavalli", dest, buffer_length);
cl_assert_equal_s(dest, "Pankajava");
cl_assert_equal_m(dest + buffer_length, GUARD_REFERENCE, NAME_LENGTH - buffer_length);
}
void test_phone_formatting__overflowing_first_name(void) {
const size_t buffer_length = 10;
char dest[NAME_LENGTH];
... | (test_number, dest, dest_len) | |
is initiated by pulling CRESET high while SCS is high.
GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_SET);
// CRESET needs to be low for at least 200 ns
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_RESET);
delay_ms(1);
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_SET);
return prv_wait_programmed();
}
static... | prv_end_command() | ;
prv_draw_scene(SCENE_BLACK);
ASSERT_BUSY_IS(Bit_SET);
dbgserial_print("Does the draw-scene command complete? ");
dbgserial_putstr(prv_wait_busy()? "Yes" : "No");
#endif
// Work around an issue which some boards exhibit where the FPGA ring
// oscillator can start up with higher harmonics, massively overc... |
tributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util/iterator.h"
#include "applib/graphics/framebuffer.h"
#include "applib/graphics/utf8.h"
#i... | (&s_ctx, &line, &word_iter_state.current, &text_box_params) | );
}
void test_line_layout__test_line_add_word_horizontal_overflow(void) {
// Allocate mutable types
Iterator word_iter = (Iterator) { 0 };
WordIterState word_iter_state = (WordIterState) { 0 };
Line line = (Line) { 0 };
// Allocate immutable types
bool success = false;
const char *sentence = "Foo bar"... |
/*
* 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... | (&dialog->icon_layer) | ;
if (dialog->buffer && dialog->is_buffer_owned) {
applib_free(dialog->buffer);
}
// Calls the user-given unload callback, if it exists. If the user gave a non-null context,
// the function will use that, otherwise it will default to use the default context of the
// containing dialog.
if (dialog->cal... |
/*
* 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... | {
decoder_info->offset_sec[(*decoder_info->num_samples)++] = msg.offset_sec;
} |
return true;
}
typedef struct PLogMeasurementSetDecoderArg {
Uuid *uuid;
PLogTypesDecoderArg *types_decoder_arg;
PLogMeasurementsDecoderArg *measurements_decoder_arg;
uint32_t *time_utc;
uint32_t *time_end_utc;
int32_t *utc_to_local;
} PLogMeasurementSetDecoderArg;
// ---------------------------------... |
{ 1200, -72, -64},
{ 1056, -40, -80},
{ 976, -16, -128},
{ 1000, -8, -120},
{ 1000, -32, -136},
{ 928, -8, -168},
{ 880, -16, -224},
{ 848, -8, -232},
{ 824, -8, -224},
// 113 seconds
{ 904, 8, -208},
{ 984, 56, -192},
{ 1080, 80, -144},
{ 1544, 120, -160},
{ ... | { 1080, -88, -104},
{ 1008, -56, -120},
{ 936, -32, -176},
{ 944, -40, -160},
{ 1016, -80, -128},
{ 1008, -104, -96},
{ 1016, -88, -104},
{ 1024, -56, -112},
{ 1088, -56, -128},
{ 1096, -64, -112},
{ 1152, -64, -72},
{ 1472, -48, -128},
{ 1352, -32, -96},
{ 1064, ... |
{ 1528, -16, -16},
{ 1536, 32, -144},
{ 1056, 40, -184},
{ 712, -8, -296},
{ 680, 8, -320},
{ 1048, 56, -184},
{ 1200, -16, -112},
{ 1024, -64, -112},
{ 1016, 16, -168},
{ 944, 64, -208},
{ 952, 88, -168},
{ 1016, 72, -128},
{ 1072, 80, -144},
{ 1032, 104, -136},... |
/*
* 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... | (evt, WAITING_ACK) | && !(rxdesc->rxstatus & BLE_NESN_ERR_BIT))
{
// We received the acknowledgment
LLD_EVT_FLAG_RESET(evt, WAITING_ACK);
}
#endif //(BLE_PERIPHERAL)
// Go to the next descriptor
hdl = co_buf_rx_next(hdl);
};
// Move the current RX buffer
co_buf_rx_current_set(hdl);
}
#if IS_AE_CHIP
sta... |
the world.
prv_put_notification_action_result(&item->header.id, i18n_get("Removed", &i18n_key),
TIMELINE_RESOURCE_RESULT_DELETED, ActionResultTypeSuccess);
} else {
const bool do_async = true;
prv_do_remote_action(&item->header.id, action->type,
... | prv_put_notification_action_result(&item->header.id, message, timeline_res_id,
ActionResultTypeSuccess) | ;
}
void timeline_enable_ancs_bulk_action_mode(bool enable) {
s_bulk_action_mode = enable;
}
bool timeline_is_bulk_ancs_action_mode_enabled(void) {
return s_bulk_action_mode;
}
typedef struct OpenAppContext {
EventServiceInfo event_info;
AppInstallId install_id;
} OpenAppContext;
static void prv_app_render_... |
process_state/app_state/app_state.h"
#include "syscall/syscall.h"
#include "system/passert.h"
#include <ecma/base/ecma-gc.h>
#include <jmem/jmem-allocator.h>
#include <jmem/jmem-heap.h>
#include <jmem/jmem-poolman.h>
#include <util/math.h>
#include <stdbool.h>
#include <string.h>
#define ROCKY_EVENT_MEMORYPRESSURE ... | {
if (ctx->is_calling_memory_callback && fatal_if_not_freed) {
// If this happens, the event handler wasn't able to run because there wasn't enough memory
// and triggered the OOM callback again -- basically this means our headroom was too small to
// execute the handler...
sys_analytics_inc(ANALYTICS... | |
text bounds are all at (2, 0)
setup_test_aa_sw(&ctx, fb, RECT_TEXT_2_0, RECT_TEXT_2_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "ajj", &s_font_info, RECT_TEXT_2_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(gbitmap_p... | (&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL) | |
04, -8, -448},
{ 1104, -32, -304},
{ 1288, 184, -376},
{ 1080, 40, -344},
{ 960, 240, -376},
{ 1104, 336, -312},
{ 1288, 416, -368},
{ 1344, 504, -416},
{ 1032, 640, -512},
{ 840, 792, -616},
{ 992, 776, -616},
{ 1344, 856, -560},
{ 1144, 544, -384},
{ 1144, 456, -304... | { 872, 976, -608},
{ 1184, 1120, -480},
{ 1360, 696, -328},
{ 1288, 648, -296},
{ 1352, 528, -208},
{ 1408, 392, -224},
{ 1208, 112, -120},
{ 1160, 272, -216},
{ 1176, 256, -152},
{ 1216, 360, -160},
{ 1184, 272, -168},
// 52 seconds
{ 992, 232, -128},
{ 872, 184,... |
{ 944, 744, -408},
{ 336, 592, -560},
{ 120, 968, -472},
{ 272, 1016, -272},
{ 296, 1008, -264},
{ 112, 816, -432},
{ -128, 656, -216},
{ -200, 680, -16},
{ -272, 656, 32},
{ -320, 792, 200},
{ -264, 888, 360},
{ -224, 920, 384},
{ -224, 832, 352},
{ -216, 720, 4... |
/*
* 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... | (LOG_LEVEL_DEBUG, "Sending result of %d", result) | ;
comm_session_send_data(session, APP_ORDER_ENDPOINT_ID, (uint8_t*)&result, sizeof(result),
COMM_SESSION_DEFAULT_TIMEOUT);
}
static void prv_handle_app_order_msg(CommSession *session, const uint8_t *data, uint32_t length) {
// call write order function, then fire an event for app install m... |
te(int32_t ams_playback_state) {
switch (ams_playback_state) {
case AMSPlaybackStatePaused: return MusicPlayStatePaused;
case AMSPlaybackStatePlaying: return MusicPlayStatePlaying;
case AMSPlaybackStateRewinding: return MusicPlayStateRewinding;
case AMSPlaybackStateForwarding: return MusicPlayStateFor... | {
int32_t value_out = 0;
prv_float_string_parse(value, value_length, 1, &value_out);
return value_out;
} |
static void prv_handle_queue_index_update(const AMSEntityUpdateNotification *update,
const uint16_t value_length) {
const int32_t idx = prv_parse_queue_value(update->value_str, value_length);
PBL_LOG(LOG_LEVEL_DEBUG, "Queue index update: %"PRId32, idx);
// TODO: Do some... |
e/restore/lookup wakeup events
new_timer_start(s_current_timer_id, (time_difference * 1000), prv_wakeup_dispatcher,
(void*)((intptr_t)s_wakeup_state.current_wakeup_id), 0);
}
}
static void prv_migrate_events_callback(SettingsFile *old_file, SettingsFile *new_file,
SettingsRecordInfo *info, void *utc... | if (settings_file_open(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_ERROR, "Error: could not open wakeup settings");
return;
} |
// Want to check if there are any events first to prevent us from rewriting the file on boot if
// we don't need to.
bool event_found = false;
settings_file_each(&wakeup_settings, prv_check_for_events, &event_found);
if (event_found) {
PBL_LOG(LOG_LEVEL_DEBUG, "Rewriting wakeup file");
// Update set... |
PUT_TIMEOUT_MS);
prv_cleanup_async();
}
static bool prv_has_valid_fw_update_state_for_object_type(PutBytesObjectType type) {
#ifndef RECOVERY_FW
if (!firmware_update_is_in_progress()) {
bool is_fw_update_object = (type == ObjectFirmware ||
type == ObjectRecovery ||
... | {
PBL_LOG(LOG_LEVEL_ERROR, "Token does not exist; got 0x%" PRIx32, token);
prv_cleanup_and_send_response(ResponseNack);
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... | (AppOutboxServiceTagUnitTest) | ;
s_test_data = kernel_malloc(s_test_data_length);
memset(s_test_data, 0x88, s_test_data_length);
s_num_sent_handler_called = 0;
s_num_app_outbox_events_sent = 0;
s_num_message_handler_calls = 0;
s_last_message = NULL;
stubs_syscall_init();
s_app_state_app_outbox_subscription_info = (EventServiceInfo)... |
stepping*/);
#endif
// Run through reference code
int ref_steps = prv_feed_reference_samples(entry->samples, entry->num_samples);
//int ref_steps = -1;
int error = abs(steps - entry->exp_steps);
float weighted_error = (float)error * entry->weight;
printf("\nRESULTS: exp_steps: %d, act_steps: ... | printf("\nRESULTS for %s: exp: (NA), act: %d, error: NA, weighted_error: NA",
name, (int)act->value) | ;
}
return weighted_error;
}
// =========================================================================================
// Support for capturing sleep sessions detected by the algorithm
typedef struct {
KAlgActivityType activity;
time_t start_utc;
uint16_t len_m;
} KAlgTestSleepSession;
KAlgTestSleepSes... |
, NON_EXISTENT_ENDPOINT_ID >> 8, NON_EXISTENT_ENDPOINT_ID & 0xff, 0x55);
cl_assert_equal_i(s_prepare_count, 0);
assert_meta_response_sent(MetaResponseCodeUnhandled);
// Length: 1, Endpoint ID: OTHER_NON_EXISTENT_ENDPOINT_ID, Payload: 0x55
RECEIVE(0x00, 0x01,
OTHER_NON_EXISTENT_ENDPOINT_ID >> 8, OTHER... | {
// Expect that when a partial message has been received, but then the session gets closed,
// that "cleanup" is called.
// Length: 1, Endpoint ID: PRIVATE_TEST_ENDPOINT_ID, Payload: not received yet
RECEIVE(0x00, 0x01, PRIVATE_TEST_ENDPOINT_ID >> 8, PRIVATE_TEST_ENDPOINT_ID & 0xff);
cl_assert_equal_i(s_pre... |
void test_session_receive_router__payload_in_pieces(void) {
// Expect that when a message's payload is received in pieces, the complete payload will be
// written and finish will only be called after the whole payload has been received.
const uint8_t expected_payload[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee };
//... |
n_attempts_per_sec = ((1000 * 1000 * 5) / (interval_1_25ms)) / 4;
analytics_stopwatch_start_at_rate(
ANALYTICS_DEVICE_METRIC_BLE_CONN_EVENT_COUNT,
conn_attempts_per_sec, AnalyticsClient_System);
s_analytic_conn_timer_running = true;
}... | (ANALYTICS_DEVICE_METRIC_BT_PAIRING_COUNT, AnalyticsClient_System) | ;
}
void bluetooth_analytics_handle_ble_pairing_error(uint32_t error) {
analytics_event_bt_error(AnalyticsEvent_BtLePairingError, error);
}
void bluetooth_analytics_handle_bt_classic_pairing_error(uint32_t error) {
analytics_event_bt_error(AnalyticsEvent_BtClassicPairingError, error);
}
void bluetooth_analytics_... |
p.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 3);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r3_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIG... | (&ctx, &OFFSET_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_offset_r4_aa_sw3_clip_xy.${BIT_DEPTH_NAME}.pbi"));
#endif
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, 3);
graphics_draw... |
mode.
dbgserial_putstr("Failed to start firmware, strike three.");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
return true;
} else if (boot_bit_test(BOOT_BIT_FW_START_FAIL_STRIKE_ONE)) {
dbgserial_putstr("Failed to start firmware, strike tw... | display_boot_splash() | ;
#ifdef DISPLAY_DEMO_LOOP
while (1) {
for (int i=0; i < 92; ++i) {
display_firmware_update_progress(i, 91);
delay_us(80000);
}
for (uint32_t i=0; i <= 0xf; ++i) {
display_error_code(i * 0x11111111);
delay_us(200000);
}
for (uint32_t i=0; i < 8; ++i) {
for (uint32_t... |
down
////////////////////////////////////
void test_graphics_text_node__initialize(void) {
s_data = (GTextNodeTestData) {};
}
void test_graphics_text_node__cleanup(void) {
}
// Tests
////////////////////////////////////
void test_graphics_text_node__text_draw(void) {
GContext *ctx = &s_data.gcontext;
GTextNod... | cl_assert(!text_c.node.free_on_destroy) | ;
GTextNodeCustom *custom_a = graphics_text_node_create_custom(NULL, NULL);
cl_assert(custom_a->node.free_on_destroy);
GTextNodeHorizontal *horizontal_a = graphics_text_node_create_horizontal(3);
cl_assert(horizontal_a->container.node.free_on_destroy);
cl_assert_equal_i(horizontal_a->container.max_nodes, 3)... |
/*
* 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, "STT reg_timer_2_callback deleting from callback") | ;
regular_timer_remove_callback(&s_app_data->reg_timers[0]);
}
}
// =================================================================================
// Try and delete, then re-add a regular timer from its callback
static int s_reg_timer_3_callback_count = 0;
static void reg_timer_3_callback(void* data) {
s_r... |
r,
GTextOverflowModeTrailingEllipsis);
layer_add_child(root_layer, (Layer *)text_layer);
layer_set_hidden((Layer *)text_layer, true);
static const int16_t LOADING_FRAME_OFFSET_Y = 27;
GRect loading_frame = (GRect) { .size = LOADING_LAYER_DEFAULT_SIZE };
grect_align(&loading_... | {
data->last_session_successful = false;
} |
prv_cancel_dictation(data);
}
}
static void prv_mic_window_appear(Window *window) {
VoiceUiData *data = window_get_user_data(window);
if ((data->state == StateStart) || (data->state == StateFinished)) {
sys_light_enable_respect_settings(true);
prv_start_dictation(data);
}
}
static void prv_voice_... |
gbitmap_create_blank(bitmap_size, GBITMAP_NATIVE_FORMAT);
s_ctx.dest_bitmap = *s_dest_bitmap;
s_ctx.draw_state.clip_box.size = bitmap_size;
s_ctx.draw_state.drawing_box = *drawing_box;
layer_render_tree(layer, &s_ctx);
if (use_screen) {
GBitmap *screen_bitmap = s_dest_bitmap;
screen_bitmap->bounds ... | cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_timeline_peek__peek_concurrent_2_max(void) {
prv_render_timeline_peek(&(TimelinePeekItemConfig) {
.title = ":parrot: :parrot:",
.subtitle = ":parrot: :parrot: :parrot:",
.icon = TIMELINE_RESOURCE_GENERIC_CONFIRMATION,
.num_concurrent = 3,
});
cl_check(gbitmap_pbi_eq(s_dest_bitmap, T... |
ed in the "move and expand" step.
static void prv_slide_impl(struct Animation *animation,
const AnimationProgress distance_normalized) {
SelectionLayer *selection_layer = (SelectionLayer*) animation_get_context(animation);
// Update the completion percent of the animation
selection_la... | (&selection_layer->layer) | ;
} else {
// Run the animation. The decrement callback will be run halfway through
selection_layer->bump_is_upwards = is_up;
prv_run_value_change_animation(selection_layer);
}
}
}
void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
SelectionLayer *selection_laye... |
/*
* 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;
} |
CommSession *session = comm_session_get_system_session();
if (!session) {
return;
}
// [MT]: comm_session_send_data() doesn't make the link active,
// which is what we want here. If this this changes in the future
// we need to take measures here to make sure we don't pull the link active.
const Poll... |
EXECUTE_SCRIPT("_rocky.on('daychange', function() {});");
cl_assert_equal_b(false, rocky_global_has_event_handlers("secondchange"));
cl_assert_equal_b(false, rocky_global_has_event_handlers("minutechange"));
cl_assert_equal_b(false, rocky_global_has_event_handlers("hourchange"));
cl_assert_equal_b(true, rocky_g... | ASSERT_JS_GLOBAL_EQUALS_I("h", 3) | ;
ASSERT_JS_GLOBAL_EQUALS_I("d", 3);
prv_tick_handler(NULL, HOUR_UNIT);
ASSERT_JS_GLOBAL_EQUALS_I("s", 4);
ASSERT_JS_GLOBAL_EQUALS_I("m", 4);
ASSERT_JS_GLOBAL_EQUALS_I("h", 4);
ASSERT_JS_GLOBAL_EQUALS_I("d", 3);
prv_tick_handler(NULL, MINUTE_UNIT);
ASSERT_JS_GLOBAL_EQUALS_I("s", 5);
ASSERT_JS_GLOBAL... |
fake_battery_set_millivolts(high_mv) | ;
periodic_timer_trigger(20);
cl_assert_equal_i(battery_get_charge_state().charge_percent, 50);
PBL_LOG(LOG_LEVEL_DEBUG, "▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲");
// Should still update if it goes lower
fake_battery_set_millivolts(lower_mv);
periodic_timer_trigger(20);
cl_assert_equal_i(battery_get_charge_state().cha... | |
t *serialized_glance_size_out) {
if (!glance || (glance->num_slices > APP_GLANCE_DB_MAX_SLICES_PER_GLANCE) ||
!serialized_glance_out || !serialized_glance_size_out) {
return E_INVALID_ARGUMENT;
}
// Allocate a buffer for data about each slice's attribute list, but only if we have at least
// one slic... | attribute_list_serialize(attr_list, serialized_slice_header->data, glance_buffer_end) | ;
// Note that we'll destroy the attribute list's attributes below in the cleanup section
// Advance the cursor by the serialized slice's total size
glance_buffer_cursor += serialized_slice_total_size;
}
// Check that we fully populated the serialized glance buffer
rv = (glance_buffer_cursor == gla... |
ggleState prv_get_toggled_state_index(ActionToggleContext *ctx) {
return ctx->enabled ? ActionToggleState_Disabled : ActionToggleState_Enabled;
}
static void prv_setup_state_config(ActionToggleContext *ctx, ActionToggleDialogConfig *config,
ActionToggleDialogType dialog_type) {
i... | (actionable_dialog, DialogActionBarConfirm, NULL) | ;
actionable_dialog_set_click_config_provider(actionable_dialog, prv_prompt_click_config_provider);
prv_setup_dialog(actionable_dialog_get_dialog(actionable_dialog), &config, (void *)ctx);
actionable_dialog_push(actionable_dialog, prv_get_window_stack());
}
static bool prv_should_prompt(const ActionToggleConfig ... |
/*
* 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... | {
// Fire the timer on "the timer task"
stub_new_timer_fire(sys_timer_id);
// We know have an event to run on "the app task"
cl_assert_equal_i(s_last_event.type, PEBBLE_CALLBACK_EVENT);
cl_assert(s_times_callback_executed == i);
// Run the code on "the app task"
s_last_event.callback.callb... | |
" - 0x%"PRIx32")",
subsector_addr,
subsector_addr & SUBSECTOR_ADDR_MASK,
(subsector_addr & SUBSECTOR_ADDR_MASK) + SUBSECTOR_SIZE_BYTES);
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
analytics_inc(ANALYTICS_APP_METRIC_FLASH_SUBSECTOR_ERASE_COUNT, AnalyticsCli... | (LOG_LEVEL_DEBUG, "Volatile Configuration Register: 0x%x", volatile_config_register) | ;
#endif
}
bool flash_is_initialized(void) {
return (s_flash_state.mutex != 0);
}
size_t flash_get_size(void) {
uint32_t spi_flash_id = flash_whoami();
if (!check_whoami(spi_flash_id)) {
// Zero bytes is the best size to report if the flash is corrupted
return 0;
}
// capcity_megabytes = 2^(capacit... |
if (!new_job) {
return; // nothing to do
} |
if ((new_job->hdl.start == MIN_ATT_HANDLE) && (new_job->hdl.end == MAX_ATT_HANDLE)) {
// we are rediscovering all services so flush everything
prv_free_service_nodes(connection);
prv_send_services_invalidate_all_event(
connection, BTErrnoServiceDiscoveryDatabaseChanged);
} else { // we are red... | |
wait for another "Good" or better.
//
// So, for the first 0 to HRM_SENSOR_SPIN_UP_SEC seconds after turning the sensor on or first
// contacting the wrist after being off-wrist, the readings can be unstable and this method will
// return false during that time.
//
// @param[in] data pointer to last received HRMdata or... | {
bool turn_sensor_on = false;
// How many ms until we need the sensor on again. INT32_MAX means we don't need to turn it on
// again
int32_t remaining_ms = INT32_MAX;
if (prv_can_turn_sensor_on()) {
RtcTicks cur_ticks = rtc_get_ticks();
int32_t remaining_ticks = INT32_MAX;
const ... |
remaining_ms = ticks_to_milliseconds(remaining_ticks);
HRM_LOG("Need sensor on again in %"PRIu32" sec", remaining_ms / MS_PER_SECOND);
turn_sensor_on = (remaining_ms <= 0);
}
if (turn_sensor_on && !hrm_is_enabled(HRM)) {
// Turn on the sensor now
HRM_LOG("Turning on HR sensor");
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
app_event_loop_common();
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, distance_normalized, true /* fill inner */) | ;
return;
}
// For the first half of the animation where the app is the destination, draw the "contract
// from modal" frame and fill its outer ring with the background color specified by
// s_data.outer_color
const uint32_t contract_to_dot_distance = ANIMATION_NORMALIZED_MAX / 2;
if (distance_normaliz... |
ssert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_buffer);
notification_storage_store(&e2);
notification_storage_store(&e3);
cl_assert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_buffer);
cl_assert(notification_storage_... | ARRAY_LENGTH(attributes) | |
t == &child_a);
// Remove non-first-child (child_b):
//
// +-parent
// |
// '->child_a->child_c
// |
// '->grand_child_a
//
// +-child_b
//
layer_remove_from_parent(&child_b);
cl_assert(child_b.parent == NULL);
cl_assert(child_b.next_sibling == NULL);
cl_assert(p... | layer_add_child(aaa, aaaa) | ;
layer_add_child(a, ab);
a->next_sibling = b;
stack[0] = a;
// go to child if possible
Layer *actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack,
true);
cl_assert_equal_p(aa, actual);
cl_assert_equal_i(1, current_stack);
cl_assert_equal_p(a, stack[0]);... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | worker_manager_get_current_worker_md() | |
.w == 0) {
return;
}
#if SCREEN_COLOR_DEPTH_BITS == 8
// NOTE: Since all calculations are based on 1-bit calculation - use the row size from
// the 1-bit frame buffer
const int row_size_bytes = 4 * ((dest_bitmap->bounds.size.w / 32) +
((dest_bitmap->bounds.size.w % 32) ? 1... | PBL_ASSERTN(dest_block >= (uint32_t*) base_addr) | |
button_counter_register);
}
}
__enable_irq();
}
void debounced_button_init(void) {
button_init();
#if defined(BOARD_SNOWY_BB2) || defined(BOARD_SPALDING_BB2)
// Snowy BB2s have a capacitor that results in a really slow rise time (~0.4ms). Sleep for
// at least 1 ms to prevent fake button events
pslee... | TIM_ClearITPendingBit(TIM4, TIM_IT_Update);
portEND_SWITCHING_ISR(should_context_switch);
} |
// Serial commands
///////////////////////////////////////////////////////////
void command_put_raw_button_event(const char* button_index, const char* is_button_down_event) {
PebbleEvent e;
int is_down = atoi(is_button_down_event);
int button = atoi(button_index);
if ((button < 0 || button > NUM_BUTTONS) || ... |
, &s_test_impl_data,
0, dummy, NULL));
cl_assert_equal_p(NULL, recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
sizeof(s_test_impl_data), NULL, NULL));
s_test_impl.handle_touch_event = NULL;
cl_assert... | (recognizer_transition_state(r, RecognizerState_Possible)) | |
_flash_state.sleep_when_idle = false;
// Assume that last time we shut down we were asleep. Come back out.
s_flash_state.deep_sleep = true;
flash_deep_sleep_exit();
prv_clear_flag_status_register();
disable_flash_spi_clock();
flash_unlock();
flash_whoami();
PBL_LOG_VERBOSE("Detected SPI Flash Size:... | (PowerSystemFlashErase) | |
ivity_last_processed_time(KAlgState *state, KAlgActivityType activity) {
return rtc_get_time();
}
// Set these to simulate a sleep session (that should result in zeroing out any steps taken)
static time_t s_kalg_sleep_start_utc;
static uint16_t s_kalg_sleep_m;
void kalg_get_sleep_stats(KAlgState *alg_state, KAlgOng... | (rtc_get_time() + delay) | ;
}
s_alg_next_vmc = minute_data[i].base.vmc;
s_alg_next_orientation = minute_data[i].base.orientation;
s_alg_next_light = minute_data[i].base.light;
s_alg_next_plugged_in = minute_data[i].base.plugged_in;
s_activity_next_distance_mm += minute_data[i].distance_cm * 10;
s_activity_next_restin... |
/*
* 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 (touch_state == TouchState_FingerDown) {
PBL_ASSERTN(pos);
// Reset all state when a touchdown event occurs
prv_touch_context_reset(ctx);
ctx->start_pos = *pos;
ctx->start_time_ms = time_ms;
ctx->start_pressure = pressure;
prv_touch_queue_add(ctx, touch_idx, TouchEven... | else if (touch_state == TouchState_FingerDown) {
PBL_ASSERTN(pos);
if (ctx->touch_queue.count > 0) {
// don't update if the position hasn't changed
TouchEvent *last = &ctx->touch_queue.events[prv_get_idx_last_item(ctx)];
GPoint last_pos = gpoint_add(last->start_pos, last->diff_pos);
upd... |
g to call MAX everytime is a bit silly, but the strn function expect a size_t (unsigned).
// Calling MAX ensures that a negative value isn't passed in which gets cast to something positive
buf_space_remaining = MAX(buf_space_remaining - sentence_len, 0);
strncat(data->dialog_text, "\n\n", buf_space_remaining);
... | voice_window_set_confirmation_enabled(data->voice_window, false) | ;
// Let the main window manage the voice window
app_window_stack_push(window, false);
}
static void prv_deinit(void) {
ReminderAppData *data = app_state_get_user_data();
voice_window_destroy(data->voice_window);
event_service_client_unsubscribe(&data->event_service_info);
app_free(data->dialog_text);
a... |
enuTestData;
OptionMenuTestData s_data;
void test_option_menu_window__initialize(void) {
fake_app_state_init();
load_system_resources_fixture();
s_data = (OptionMenuTestData) {};
rtc_set_time(3 * SECONDS_PER_DAY);
}
void test_option_menu_window__cleanup(void) {
}
// Helpers
//////////////////////
typedef ... | FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE() | ;
}
void prv_create_menu_and_render_short_title(bool icons_enabled, const char *title,
bool special_height) {
prv_create_menu_and_render(&(MenuConfig) {
.title = title,
.content_type = special_height ? OptionMenuContentType_SingleLine :
... |
dler || handler->protocol_id > protocol_id) {
break;
}
if (handler->protocol_id == protocol_id) {
return handler;
}
}
return NULL;
}
// -----------------------------------------------------------------------------------------
void qemu_serial_init(void) {
// Init our state variables
... | ("Sending data:") | |
center.x.fraction = 4;
center.y.fraction = 4;
radius.fraction = 4;
angle_start = TRIG_MAX_ANGLE / 8;
angle_end = angle_start + (TRIG_MAX_ANGLE / 4);
}
}
void test_graphics_draw_circle_${BIT_DEPTH_NAME}__calc_draw_config_caps(void) {
// ## Section with special cases
// Test for no angles
c... | prv_calc_draw_config_ellipsis(TO_TRIG(90), TO_TRIG(270)) | , ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight},
.full_quadrants = GCornersBottom,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerTopLeft}
}));
// Tests for triples of quadrants
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG... |
yer, &draw_text_single_line_wordwrap_clip_across_ny_second_line);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_ny_second_line.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_sing... | (&ctx.dest_bitmap, "draw_text_jja22.${BIT_DEPTH_NAME}.pbi") | );
// Test when clipping/drawing and text bounds are all at (2, 0)
setup_test_aa_sw(&ctx, fb, RECT_TEXT_2_0, RECT_TEXT_2_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "ajj", &s_font_info, RECT_TEXT_2_0,
GTextOverflowModeTrailingEllipsis, GTextAl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.