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... | {
if (IS_LPTIM(pwm->timer.peripheral)) {
LPTIM_SetCompareValue(pwm->timer.lp_peripheral, duty_cycle);
LPTIM_SelectOperatingMode(pwm->timer.lp_peripheral, LPTIM_Mode_Continuous);
} else {
TIM_OCInitTypeDef tim_oc_init;
TIM_OCStructInit(&tim_oc_init);
tim_oc_init.TIM_OCMode = TIM_OCMode_PWM1;
... |
void pwm_enable(const PwmConfig *pwm, bool enable) {
if (enable) {
gpio_af_init(&pwm->afcfg, GPIO_OType_PP, GPIO_Speed_100MHz, GPIO_PuPd_DOWN);
periph_config_enable(pwm->timer.peripheral, pwm->timer.config_clock);
} else {
periph_config_disable(pwm->timer.peripheral, pwm->timer.config_clock);
gpio... |
/*
* 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... | (pass_initial_values_app_task_callback, s) | ;
delegate_errors(s, dict_result, APP_MSG_OK);
}
void app_sync_deinit(AppSync *s) {
app_message_set_context(NULL);
app_message_register_outbox_sent(NULL);
app_message_register_outbox_failed(NULL);
app_message_register_inbox_received(NULL);
app_message_register_inbox_dropped(NULL);
s->current = NULL;
}
A... |
,
unscheduled_callback, s_unscheduled_cb_data, 0);
// It should get immediate air-time for one cycle:
cl_assert(infinite_job_d);
assert_ad_data("D");
// Round-robin 4 times:
for (int i = 0; i < 4; ++i) {
regular_timer_fire_seconds(1);
assert_ad_data("A");
... | (gap_le_is_advertising_enabled(), false) | ;
regular_timer_fire_seconds(1);
cl_assert_equal_b(gap_le_is_advertising_enabled(), true);
assert_ad_data("B");
}
void test_gap_le_advert__round_robin_two_jobs_incl_silent_terms(void) {
GAPLEAdvertisingJobTerm advert_terms_a[] =
{
{
.min_interval_slots = 160,
.max_interval_slots = 320,
... |
checking while we are at it.
const uint8_t *adv_bytes = ad_data->data;
size_t adv_bytes_len = ad_data->ad_data_length;
gap_disc_mode_t disc_mode = GAP_DISC_MODE_NON_DISCOVERABLE;
// Make sure the whole packet data is at least 3 bytes.
// Make sure that the length of the first field is at least 2 (contains th... | prv_try_to_enter_host_desired_state() | ;
}
void advert_handle_completed(const ble_evt_gap_adv_completed_t *evt) {
prv_lock();
{
PBL_LOG(LOG_LEVEL_DEBUG, "advert_handle_completed %"PRIu8, evt->status);
if (s_adv_state == AdvertState_Pausing) {
s_adv_state = AdvertState_Paused;
} else {
s_adv_state = AdvertState_Off;
}
//... |
nless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/... | app_zalloc_check(buffer_len) | |
rt(num.fraction == 1); // rounds down to 1.125
test_num = (int16_t)((float)1.249 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == 1);
cl_assert(num.fraction == 1); // rounds down to 1.125
}
void test_math_fixed__S16_3_add(void) {
Fixed_S16_3 num1, num2... | {
Fixed_S32_16 num;
int32_t test_num;
cl_assert(FIXED_S32_16_PRECISION == 16);
test_num = 1 << FIXED_S32_16_PRECISION;
num = (Fixed_S32_16){ .integer = 1, .fraction = 0 };
test_num = (int32_t)((float)1 * (1 << FIXED_S32_16_PRECISION));
cl_assert(num.raw_value == test_num);
cl_assert((FIXED_S32_16_ONE... |
void test_math_fixed__S32_16_add(void) {
Fixed_S32_16 num1, num2;
Fixed_S32_16 sum, sum_c;
// Test number addition
num1 = FIXED_S32_16_ONE;
num2 = FIXED_S32_16_ONE;
sum = Fixed_S32_16_add(num1, num2);
sum_c = (Fixed_S32_16){ .raw_value = (int32_t)((float)2 * (1 << FIXED_S32_16_PRECISION)) };
cl_asser... |
}
s_flash_state.mutex = mutex_create();
vSemaphoreCreateBinary(s_flash_state.dma_semaphore);
flash_lock();
enable_flash_spi_clock();
flash_start();
s_flash_state.enabled = true;
s_flash_state.sleep_when_idle = false;
// Assume that last time we shut down we were asleep. Come back out.
s_flash_s... | (FLASH_CMD_ERASE_SUBSECTOR) | ;
flash_send_24b_address(subsector_addr);
flash_end_cmd();
flash_wait_for_write();
prv_check_protection_flag();
disable_flash_spi_clock();
power_tracking_stop(PowerSystemFlashErase);
flash_unlock();
}
void flash_erase_sector_blocking(uint32_t sector_addr) {
assert_usable_state();
PBL_LOG(LOG_LEV... |
) {
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
weather_db_init();
weather_service_init();
weather_shared_data_init();
}
void test_weather_service__cleanup(void) {
weather_shared_data_cleanup();
}
static const WeatherLocationForecast s_forecasts[] = {
{
.location_name = TEST_WEATHER_DB_LOCAT... | cl_assert(forecast) | ;
prv_assert_forecast_equal(forecast, &s_forecasts[0]);
weather_service_destroy_default_forecast(forecast);
weather_db_flush();
PebbleEvent flush_event = (PebbleEvent) {
.type = PEBBLE_BLOBDB_EVENT,
.blob_db = {
.db_id = BlobDBIdWeather,
.type = BlobDBEventTypeFlush,
.key = NULL,
... |
e end of the buffer (*buffer + size of strings)
static uint8_t *prv_fill_native_ancs_action(uint8_t **buffer,
TimelineItemAction *action,
ActionId ancs_action_id,
const ANCSAttribute *titl... | {
// Promote the subtitle (group name) for Group MMS
title = subtitle;
subtitle = NULL;
} | |
.perimeter.inset = 8,
.paging.page_on_screen.size_h = DISP_ROWS, // setting a page height != enables positioning
.paging.origin_on_screen = {0, 0},
},
};
render_steps(&layout, RenderMoveTextBox, DELTA, DISP_ROWS, NULL);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_graph... | GPoint(s_dest_bitmap->bounds.size.w, y) | );
y += layout.flow_data.paging.page_on_screen.size_h;
}
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
GRangeHorizontal perimeter_for_circle(GRangeVertical vertical_range, GPoint center, int32_t radius);
GRangeHorizontal perimeter_for_display_rect(const GPerimeter *perimeter,
... |
list->data[2] = '\0';
list->data[3] = 'c'; // end of data
list->data[4] = '\0';
cl_assert_equal_i(2, string_list_count(list));
cl_assert_equal_s("ab", string_list_get_at(list, 0));
cl_assert_equal_s("c", string_list_get_at(list, 1));
// 3 strings (last two are is empty)
list->serialized_byte_length = ... | timeline_item_find_action_by_type(&item, 0) | , NULL);
}
void test_timeline_item__find_dismiss_action(void) {
// Make sure we're resilient to NULL items
cl_assert_equal_p(timeline_item_find_dismiss_action(NULL), NULL);
// Make sure we can handle timeline items with no actions
TimelineItem item = {};
cl_assert_equal_p(timeline_item_find_dismiss_action(&... |
veMutex *s_workout_mutex;
RegularTimerInfo second_timer;
time_t last_workout_end_ts;
time_t frontend_last_opened_ts;
HRMSessionRef hrm_session;
CurrentWorkoutData *current_workout;
} WorkoutServiceData;
static WorkoutServiceData s_workout_data;
static void prv_lock(void) {
mutex_lock_recursive(s_workout_... | if (event->quality == HRMQuality_OffWrist) {
// Reset to zero for OffWrist readings
prv_reset_hr_data();
} else if (event->quality >= HRMQuality_Worst) {
const int prev_bpm_timestamp_ts = wrkt_data->current_bpm_timestamp_ts;
wrkt_data->current_bpm = event->current_bpm;
wrkt_data->current_hr_zone ... |
return;
}
// ---------------------------------------------------------------------------------------
bool workout_service_is_workout_type_supported(ActivitySessionType type) {
return type == ActivitySessionType_Walk ||
type == ActivitySessionType_Run ||
type == ActivitySessionType_Open;
}
// --... |
data->peek_animation = NULL;
data->peek_layer = NULL;
data->peek_icon_info = (TimelineResourceInfo) {
.res_id = TIMELINE_RESOURCE_INVALID,
.app_id = NULL,
.fallback_id = TIMELINE_RESOURCE_INVALID
};
data->action_menu = NULL;
data->dnd_icon_visible = false;
Window *window = &data->window;
w... | notifications_presented_list_first() | , +1);
if (second_id) {
// On rectangular displays, get the notification below the one we want to focus,
// set it as the current notification, then swap up. This allows us
// to accomplish the animation effect, while still pleasing the SwapLayer
// when it wants to retrieve the layouts it w... |
_ddr;
prv_get_fast_read_params(dev, &instruction, &dummy_cycles, &is_ddr);
qspi_indirect_read_dma(dev->qspi, instruction, 0, dummy_cycles, buffer_dma, size, is_ddr);
profiler_stop();
uint32_t dma_time = profiler_get_total_duration(true);
profiler_start();
qspi_indirect_read(dev->qspi, instruction, 0, dummy... | prompt_send_response("FAILURE: Flash never became busy, but we should be busy for 300ms.") | ;
prompt_send_response("FAILURE: Flash probably never did an erase.");
} else if (duration < min_erase_time) {
++failures;
prompt_send_response("FAILURE: Flash erase completed way to quickly to have succeeded.");
} else {
++passes;
}
// must call blank_check_poll by hand, otherwise we'll get th... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_contacts_db.mutex) | ;
}
//////////////////////////////
// Contacts DB API
//////////////////////////////
int contacts_db_get_serialized_contact(const Uuid *uuid, SerializedContact **contact_out) {
*contact_out = NULL;
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
return 0;
}
const unsigned contact_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info) | |
{ 736, 160, 64},
{ 824, 96, 208},
{ 848, 224, 128},
{ 800, 240, 88},
{ 808, 312, 0},
{ 864, 312, 0},
{ 992, 280, 96},
{ 1184, 256, 224},
{ 1880, 168, 456},
{ 1864, 400, 352},
{ 1016, 408, 272},
{ 840, 184, 176},
// 14 seconds
{ 840, 16, 192},
{ 776, -32, 264},
... | { 872, 208, 208},
{ 832, 464, 40},
{ 696, 416, 48},
{ 832, 448, 8},
{ 944, 400, 56},
{ 1088, 384, 96},
{ 1296, 344, 128},
{ 1616, 264, 232},
{ 1816, 400, 256},
{ 1200, 408, 176},
{ 1264, 240, 208},
{ 1360, -160, 416},
{ 1336, 48, 328},
{ 1088, 40, 272},
{ 960,... |
{ 1344, 8, 352},
{ 1192, 80, 224},
{ 1008, 64, 168},
{ 808, 8, 128},
{ 656, -64, 112},
{ 552, -128, 64},
{ 504, -144, 32},
{ 576, -168, 0},
{ 880, -64, -104},
{ 1416, -8, 16},
{ 2016, 56, 560},
{ 1936, 592, 440},
{ 1552, 952, -80},
{ 1240, 440, 248},
{ 944, 2... |
dTimestamp,
.uint32 = (uint32_t)(uintptr_t)context,
};
AttributeList response_attributes = {
.num_attributes = 1,
.attributes = ×tamp_attr,
};
timeline_invoke_action(pin, action, &response_attributes);
break;
}
case TimelineItemActionTypeOpenPin:
c... | PBL_LOG(LOG_LEVEL_ERROR, "Unsupported action type %d", action->type) | ;
if (action_menu) {
action_menu_close(action_menu, true);
}
return NULL;
}
void timeline_actions_invoke_action(const TimelineItemAction *action, const TimelineItem *pin,
ActionCompleteCallback complete_cb, void *cb_data) {
ActionResultData *data = prv_invoke_action(NULL... |
d.b == 0b00);
cl_assert(GColorRed.a == 0b11);
}
void test_graphics_colors__green(void) {
cl_assert(GColorGreen.r == 0b00);
cl_assert(GColorGreen.g == 0b11);
cl_assert(GColorGreen.b == 0b00);
cl_assert(GColorGreen.a == 0b11);
}
void test_graphics_colors__blue(void) {
cl_assert(GColorBlue.r == 0b00);
cl_a... | (GColorClear) | .argb);
cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_bw(GColorWhite).argb);
cl_assert_equal_i(GColorBlackARGB8, gcolor_get_bw(GColorBlack).argb);
cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_bw(GColorLightGray).argb);
cl_assert_equal_i(GColorBlackARGB8, gcolor_get_bw(GColorDarkGray).argb);
cl_assert_equal... |
_BaudRatePrescaler = spi_find_prescaler(spi_clock_hz, DISPLAY_SPI_CLOCK_PERIPH);
spi_cfg.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_Init(DISP_SPI, &spi_cfg);
SPI_Cmd(DISP_SPI, ENABLE);
}
void display_start(void) {
// Enable the GPIOG clock; this is required before configuring the pins
gpio_use(DISP_GPIO);
GPIO... | SPI_I2S_GetFlagStatus(DISP_SPI, SPI_I2S_FLAG_RXNE) | ) continue;
return SPI_I2S_ReceiveData(DISP_SPI);
}
|
INES = 2;
static const int SHORT_ITEM_MAX_ROWS_SPALDING = 3;
static GFont prv_get_item_font(void) {
return system_theme_get_font(TextStyleFont_MenuCellTitle);
}
//! Only used on round displays to achieve a fish-eye effect
static GFont prv_get_unfocused_item_font(void) {
return system_theme_get_font(TextStyleFont_... | (0, menu_cell_basic_horizontal_inset()) | |
__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(b, actual);
cl_assert_equal_i(0, current_stack);
cl_assert_equal_p(b, stack[0]);
// no more siblings on root level
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_as... | layer_remove_from_parent(&child_f) | ;
layer_add_child(&parent, &child_b);
layer_add_child(&parent, &child_c);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(9, 9)), &child_a);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(6, 6)), &child_b);
cl_assert_equal_p(layer_find_layer_containing_point(&parent... |
Y KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "services/common/clock.h"
#include "services/normal/timezone_database.h"
#include "services/normal/filesystem/pfs.h"
#include "resource/resource_id... | for (int32_t gmtoff = min_gmtoff; gmtoff <= max_gmtoff; gmtoff += gmtoff_slide) {
prv_clock_reset(0);
tzinfo.tm_gmtoff = gmtoff;
rtc_set_timezone(&tzinfo);
clock_init();
clock_set_time(jan1st_noon_2005);
cl_assert_equal_i(rtc_get_time(), jan1st_noon_2005);
cl_assert_equal_i(time_utc_to_loca... | |
/*
* 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... | (&outbox->iterator, outbox->result, outbox->user_context) | ;
}
}
}
static void prv_handle_nack_or_ack_timeout(AppMessageCtxOutbox *outbox,
AppMessageResult result) {
outbox->result = result;
if (outbox->phase == OUT_AWAITING_REPLY) {
prv_transition_to_accepting(outbox);
} else if (outbox->phase == OUT_AWAITING_REPLY_A... |
/*
* 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... | (sign_extend(-1, 3), -1) | ;
cl_assert_equal_i(sign_extend(7, 32), 7);
cl_assert_equal_i(sign_extend(7, 3), -1);
}
void test_math__serial_distance32(void) {
{
int32_t dist = serial_distance32(0x0, 0x1);
cl_assert_equal_i(dist, 1);
}
{
int32_t dist = serial_distance32(0x1, 0x0);
cl_assert_equal_i(dist, -1);
}
{
... |
/*
* 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_25945
//> TEST_VERSION 2
//> 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 105
//> TEST_START_AT_MIN 90
//> TEST_START_... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_ctx, s_fb) | ;
framebuffer_clear(s_fb);
}
void test_graphics_context_mask__cleanup(void) {
free(s_ctx);
free(s_fb);
gbitmap_destroy(s_dest_bitmap);
s_dest_bitmap = NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////... |
/*
* 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... | alerts_preferences_get_vibe_score_for_client(client) | ;
}
VibeScore *vibe_client_get_score(VibeClient client) {
VibeScoreId id = prv_get_resource_for_client(client);
if (id == VibeScoreId_Disabled) {
return NULL;
}
VibeScore *score = vibe_score_create_with_resource(vibe_score_info_get_resource_id(id));
if (!score) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a null ... |
);
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), false);
}
static void prv_validate_ble_pairing_info(const SMPairingInfo *pairing_info, char *device_name) {
char name_out[BT_DEVICE_NAME_BUFFER_SIZE];
memset(name_out, 0, sizeof(name_out));
SMPairingInfo pairing_info_out = {};
cl_assert_... | cl_assert_equal_b(shared_prf_storage_get_bt_classic_pairing_data(NULL, NULL, NULL, NULL), false) | ;
BTDeviceAddress addr = {
.octets = {
0x11, 0x22, 0x33, 0x44, 0x55,
},
};
char device_name[BT_DEVICE_NAME_BUFFER_SIZE] = "ABCDEFGHIJKLMNOPQRS";
SM128BitKey link_key = {
.data = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11,
}... |
n theoretically add members to the end of the struct, we'll still have to add compatibilty
// flags throughout here to check which size of struct the app is going to pass us through these
// APIs.
GPath* path = applib_malloc(sizeof(GPath));
if (path) {
gpath_init(path, init);
} else {
APP_LOG(APP_LOG_... | (0, 0, 0, 0) | ;
}
int16_t max_x = INT16_MIN;
int16_t min_x = INT16_MAX;
int16_t max_y = INT16_MIN;
int16_t min_y = INT16_MAX;
for (uint32_t i = 0; i < path->num_points; ++i) {
if (path->points[i].x > max_x) {
max_x = path->points[i].x;
}
if (path->points[i].x < min_x) {
min_x = path->points[i].x;... |
1));
graphics_draw_pixel(ctx, GPoint(layer->bounds.size.w - offset - 1, mask));
// Bottom-left quadrant
graphics_draw_pixel(ctx, GPoint(layer->bounds.size.w - mask - 1, offset));
graphics_draw_pixel(ctx, GPoint(offset, layer->bounds.size.h - mask - 1));
// Bottom-right quadrant
graphics_draw_pix... | app_state_get_user_data() | ;
app_data->test_pattern = (TestPattern) data;
layer_mark_dirty(&app_data->window.layer);
}
static void prv_config_provider(void *data) {
window_single_click_subscribe(BUTTON_ID_SELECT, prv_button_click_handler);
}
static void prv_handle_init(void) {
AppData *data = app_malloc_check(sizeof(AppData));
*dat... |
\0';
local_time = utc_time;
} else {
res->tm_gmtoff = time_get_gmtoffset();
res->tm_isdst = time_get_isdst(utc_time);
time_get_timezone_abbr(res->tm_zone, utc_time);
local_time = utc_time + res->tm_gmtoff + (res->tm_isdst ? s_dst_adjust : 0);
}
int32_t days = local_time / SECONDS_PER_DAY;
i... | rtc_get_time() | ;
return (time_utc_to_local(now) - now);
}
// ---------------------------------------------------------------------------------------
DayInWeek time_util_get_day_in_week(time_t utc_sec) {
struct tm local_tm;
localtime_r(&utc_sec, &local_tm);
return local_tm.tm_wday;
}
// -------------------------------------... |
IGHTS_LOG_DEBUG("Last sleep reward state: %ld",
s_sleep_reward_state.common.last_triggered_utc);
INSIGHTS_LOG_DEBUG("Last activity reward state: %ld",
s_activity_reward_state.common.last_triggered_utc);
// Recalculate metric stats
activity_insights_recalculate_stats();
... | activity_prefs_activity_insights_are_enabled() | ) {
prv_push_reward(now_utc, &ACTIVITY_REWARD_NOTIF_CONFIG);
}
}
static void prv_test_push_day_insights(void *unused) {
time_t now_utc = rtc_get_time();
for (int i = 0; i < ActivationDelayInsightTypeCount; i++) {
prv_trigger_activation_delay_insight(now_utc, &ACTIVATION_DELAY_INSIGHTS[i]);
}
}
static ... |
/*
* 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... | health_service_sum_today(HealthMetricStepCount) | ;
APP_LOG(APP_LOG_LEVEL_INFO, "worker: movement event, steps: %"PRIu32"",
(uint32_t)steps);
} else if (event == HealthEventSleepUpdate) {
HealthValue total_sleep = health_service_sum_today(HealthMetricSleepSeconds);
HealthValue restful_sleep = health_service_sum_today(HealthMetricSleepRestful... |
/*
* 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... | (GSize(DISP_COLS, DISP_ROWS),
GBitmapFormat1Bit) | ;
s_gfx_rotated_bitmap_64_bitmap = gbitmap_create_blank(GSize(64, 64), GBitmapFormat1Bit);
uint32_t size_full = (DISP_COLS*DISP_ROWS)/8;
#else
s_gfx_rotated_bitmap_bitmap = gbitmap_create_blank(GSize(DISP_COLS, DISP_ROWS),
GBitmapFormat8Bit);
s_gfx_rotated_bi... |
/*
* 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... | (a23 - atan2_lookup((int16_t)((y2 - y1) / fixedpoint_base),
(int16_t)((x2 - x1) / fixedpoint_base))) | ;
int32_t da2 = abs(atan2_lookup((int16_t)((y4 - y3) / fixedpoint_base),
(int16_t)((x4 - x3) / fixedpoint_base)) - a23);
if (da1 >= TRIG_MAX_ANGLE) {
da1 = TRIG_MAX_ANGLE - da1;
}
if (da2 >= TRIG_MAX_ANGLE) {
da2 = TRIG_MAX_ANGLE - da2;
}
if (da1 + da2 < max_angle... |
/*
* 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... | (offsetof(AccelManagerBufferData, rawdata) == 0,
"AccelRawData must be first entry in AccelManagerBufferData struct") | ;
// Statics
//! List of all registered consumers of accel data. Points to AccelManagerState objects.
static ListNode *s_data_subscribers = NULL;
//! Mutex locking all accel_manager state
static PebbleRecursiveMutex *s_accel_manager_mutex;
//! Reference count of how many shake subscribers we have. Used to turn off th... |
scribed) {
if (prv_acquire_accessory()) {
// we will now start to attempt to connect to the smartstrap
smartstrap_fsm_state_set(SmartstrapStateReadReady);
s_monitor_interval = 0;
} else {
// try again in a little while to acquire the accessory
s_monitor_interval = ACCESSORY_ACQUIRE... | prv_release_accessory() | |
s);
layer_set_clips(&pin_window->action_button_layer, false);
pin_window->action_button_layer.update_proc = action_button_update_proc;
layer_add_child(&pin_window->layer, &pin_window->action_button_layer);
StatusBarLayer *status_layer = &pin_window->status_layer;
status_bar_layer_init(status_layer);
status... | {
window_stack_remove((Window *)pin_window, true /* animated */);
} | |
/*
* 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... | {
static CompassServiceConfig *s_compass_config;
return &s_compass_config;
} |
// --------------------------------------------------------------------------------------------
AnimationState* kernel_applib_get_animation_state(void) {
static AnimationState s_kernel_animation_state;
return &s_kernel_animation_state;
}
// Get the current task. If FreeRTOS has not been initialized yet, set to K... |
rightness = s_current_brightness - (prv_backlight_get_intensity() / LIGHT_FADE_STEPS);
if (new_brightness <= BACKLIGHT_BRIGHTNESS_OFF) {
// Done fading!
new_brightness = BACKLIGHT_BRIGHTNESS_OFF;
s_light_state = LIGHT_STATE_OFF;
// Don't need to cancel the timer, we can only get ... | {
prv_change_state(LIGHT_STATE_OFF);
} |
}
mutex_unlock(s_mutex);
}
static void prv_light_reset_to_timed_mode(void) {
mutex_lock(s_mutex);
if (s_user_controlled_state) {
s_user_controlled_state = false;
if (prv_light_allowed()) {
prv_change_state(LIGHT_STATE_ON_TIMED);
}
}
mutex_unlock(s_mutex);
}
void light_toggle_enabled(... |
settings file format with known data to the local file system so that it can
// be checked in and used for migration tests.
static void prv_save_known_settings_file(const char *filename) {
// Let's include 3 days of history by start at s_init_time_tm - 3 days
struct tm time_tm = s_init_time_tm;
time_t utc_sec = ... | (st.st_size == bytes_written) | ;
pfs_close(fd);
}
// ---------------------------------------------------------------------------------------
// Test that we correctly migrate older versions of activity settings files
void test_activity__migrate_settings(void) {
// Uncomment this call to prv_save_known_settings_file() in order to save the curr... |
/*
* 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_format_time(buffer, buffer_size, i18n_noop("%p"), timestamp) | ;
}
}
size_t clock_format_time(char *buffer, uint8_t size, int16_t hours, int16_t minutes,
bool add_space) {
if (size == 0 || buffer == NULL) {
return 0;
}
bool is24h = clock_is_24h_style();
const char *format;
// [INTL] you want to have layout resources that specify time for... |
nt);
if (animation_private_using_legacy_2(state)) {
// We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
animation_legacy2_unschedule_all();
return;
}
while (state->scheduled_head) {
AnimationPr... | if (!prv_is_mutable(state, animation)) {
return false;
} |
animation->implementation = implementation;
return true;
}
// -------------------------------------------------------------------------------------------
const AnimationImplementation* animation_get_implementation(Animation *animation_h) {
if (animation_private_using_legacy_2(NULL)) {
// We need to enable ... |
) {
*prop_desc_p = (jerry_property_descriptor_t) {
.value = jerry_create_undefined(),
.getter = jerry_create_undefined(),
.setter = jerry_create_undefined(),
};
}
jerry_value_t jerry_define_own_property(const jerry_value_t obj_val,
const jerry_value_t prop_name_v... | {
args.push(__jerryRefs.get(getValue($1 + i*4, 'i32')));
} |
// Call the constructor with new object as `this`
var bindArgs = [null].concat(args);
var boundConstructor = func_obj.bind.apply(func_obj, bindArgs);
var rv = new boundConstructor();
return __jerryRefs.ref(rv);
}, func_obj_val, args_p, args_count);
}
jerry_size_t jerry_stri... |
layer = context;
AppMenuDataSource *data_source = launcher_menu_layer->data_source;
if (!data_source) {
return;
}
Window *window = layer_get_window(launcher_menu_layer_get_layer(launcher_menu_layer));
if (!window) {
return;
}
// Disable all clicking on the window so the user can't scroll anymore
... | (data_source, row) | ;
// Instruct the launcher app glance service to play the glance for the node
launcher_app_glance_service_play_glance_for_app_node(&launcher_menu_layer->glance_service, node);
}
static void prv_menu_layer_selection_will_change(MenuLayer *UNUSED menu_layer, MenuIndex *new_index,
... |
ase_suspend_timer_cb(NULL);
}
// An erase can take a long time, especially if the erase needs to be
// retried. Appease the watchdog so that it doesn't get angry when an
// erase takes >6 seconds.
//
// After a certain amount of time passes, stop kicking the watchdog. This is to handle a case
... | flash_impl_get_subsector_base_address(flash_addr) | ;
}
void flash_power_down_for_stop_mode(void) {
flash_impl_enter_low_power_mode();
}
void flash_power_up_after_stop_mode(void) {
flash_impl_exit_low_power_mode();
}
bool flash_sector_is_erased(uint32_t sector_addr) {
return flash_impl_blank_check_sector(flash_impl_get_sector_base_address(sector_addr));
}
bool... |
ta = s_workout_data.current_workout;
const int32_t new_event_steps = event->steps;
const time_t now_ts = time_get_uptime_seconds();
if (new_event_steps < wrkt_data->last_event_step_count) {
PBL_LOG(LOG_LEVEL_WARNING, "Working out through midnight, resetting last_event_step_count");
wrkt_data->last_event_... | if (!workout_service_is_workout_ongoing()) {
return;
} |
prv_lock();
{
if (event->type == HealthEventMovementUpdate) {
prv_handle_movement_update(&event->data.movement_update);
} else if (event->type == HealthEventHeartRateUpdate) {
prv_handle_heart_rate_update(&event->data.heart_rate_update);
}
}
prv_unlock();
}
// ------------------------... |
,
{ 1080, -512, -112},
{ 640, -456, -200},
{ 544, -360, -224},
{ 536, -376, -160},
{ 552, -256, -176},
{ 704, -144, -152},
{ 1000, -8, -160},
{ 1384, 152, -352},
{ 2048, 208, -536},
{ 2648, 208, -592},
{ 2232, 232, -536},
{ 1640, 304, -544},
{ 1376, 296, -376},
{ ... | { 488, -192, -184},
{ 464, -144, -216},
{ 448, -88, -248},
{ 976, 0, -192},
{ 1576, 88, -448},
{ 2184, 64, -608},
{ 2704, 8, -816},
{ 2192, 32, -520},
{ 1576, 224, -424},
// 13 seconds
{ 1304, 504, -208},
{ 1048, 416, -344},
{ 768, 584, -184},
{ 648, 880, -56},
... | |
rial_putstr("Hold down UP + BACK for 5 secs. to force-boot PRF");
for (int i = 0; i < 5000; ++i) {
if (!(button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK))) {
// stop waiting if not held down any longer
return false;
}
delay_ms(1);
}
return true;
}
... | {
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 j=1; j <= 0xf; ++j) {
display_error_code(j << (i*4));
delay_us(200000);
}
}
display_error_code(0x01234567);
delay_u... |
tra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
s_feb_5_midnight + 11 * 60 * 60), 2);
}
void test_timeline__two_iterators(void) {
uint... | cl_assert(!iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
cl_assert(uuid_equal(&state.node->id, &s_items[3].header.id));
cl_assert(state.node);
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
timeline_iter_deinit(&iterator, &state, &head);
}
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (APP_LOG_LEVEL_DEBUG, "App Message Dropped!") | ;
}
static void out_failed_handler(DictionaryIterator *failed, AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "App Message Failed to Send!");
}
static void app_message_init(void) {
// Register message handlers
app_message_register_inbox_received(in_received_handler);
app_message_regist... |
i++) {
uint32_t size = dls_test_get_num_bytes(logging_sessions[i]);
PBL_LOG(LOG_LEVEL_INFO, "Size of session %d: %d", i, size);
total_bytes += size;
}
PBL_LOG(LOG_LEVEL_INFO, "total bytes: %d", total_bytes);
cl_assert(total_bytes < DLS_TOTAL_STORAGE_BYTES);
}
// ------------------------------------... | data_logging_log(0, data, ARRAY_LENGTH(data)) | , DATA_LOGGING_INVALID_PARAMS);
cl_assert_equal_i(data_logging_log(&data, data, ARRAY_LENGTH(data)), DATA_LOGGING_INVALID_PARAMS);
// Make sure closing invalid sessions doesn't crash. It's defined to be a no-op
data_logging_finish(0);
data_logging_finish(&data);
}
// ------------------------------------------... |
ot error trying to reissue interrupted erase: "
"%"PRIi32, status);
return status;
}
// Hopefully the task watchdog isn't enabled; this could take a while.
while (1) {
psleep(10);
status = flash_impl_get_erase_status();
if (status != E_BUSY && status != E_AGAIN) {
// Success or ... | (buffer, start_addr, buffer_size) | ;
mutex_unlock(s_flash_lock);
}
#ifdef TEST_FLASH_LOCK_PROTECTION
static bool s_assert_write_error = false;
void flash_expect_program_failure(bool expect_failure) {
s_assert_write_error = expect_failure;
}
#endif
void flash_write_bytes(const uint8_t *buffer, uint32_t start_addr,
uint32_t bu... |
()) {
dbgserial_putstr("Watchdog caused a reset");
}
if (boot_bit_test(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED)) {
dbgserial_putstr("Software failure caused a reset");
}
// Clean up after the last failure.
boot_bit_clear(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
// We have a "three strikes" algorithm: if th... | leave_standby_mode() | ;
} else {
dbgserial_putstr("returning to standby");
enter_standby_mode();
}
dbgserial_putstr("leaving standby");
} else {
// If not entering or leaving standby this is a cold boot. The firmware
// expects the clock to be running in fast mode
rtc_initialize_fast_mode();
}
// ... |
/*
* 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... | reset_due_to_software_failure() | ;
}
static __attribute__((noreturn)) void handle_passert_failed(const char* filename, int line_number,
uintptr_t lr, const char *expr, const char* fmt, ...) {
va_list fmt_args;
va_start(fmt_args, fmt);
handle_passert_failed_vargs(filename, line_number, lr, expr, fmt, fmt_args);
va_end(fmt_args);
}
void ... |
dle_notification_acted_upon(id);
break;
default:
break;
// Not implemented
}
menu_layer_reload_data(&s_data->menu_layer);
prv_update_text_layer_visibility(s_data);
}
// we don't handle reminders within the notifications app
}
///////////////////
// Window callbacks
static... | menu_layer_deinit(&data->menu_layer) | ;
event_service_client_unsubscribe(&data->notification_event_info);
prv_loaded_notification_list_deinit(data->loaded_notification_list);
prv_notification_list_deinit(data->notification_list);
i18n_free_all(data);
app_free(data);
s_data = NULL;
}
static void prv_s_main(void) {
prv_handle_init();
app_e... |
_non_aa(&ctx, COLOR_START_POINT, COLOR_END_POINT, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
*/
}
/*
* Following points come from bug reports, causing "plasma effect" where multiple
* lines in close vicinity of one spot (~1 pixel) caused arti... | for (int j=0; j<9; j++) {
graphics_line_draw_precise_stroked_non_aa(&ctx, p, p, radius);
p.x.raw_value += 1;
p.y.integer += 16;
} | |
.y = bounds->size.h - new_height };
#if PBL_ROUND
// do paging on round display
offset.y = ROUND_TO_MOD_CEIL(offset.y, scroll_layer->layer.frame.size.h);
#endif
scroll_layer_set_content_size(scroll_layer,
(GSize) { scroll_layer->layer.frame.size.w, new_height });
scrol... | {
if (transcription_dialog->callback_context) {
transcription_dialog->callback(transcription_dialog->callback_context);
} else {
transcription_dialog->callback(transcription_dialog);
}
} |
transcription_dialog->pop_timer = app_timer_register(POP_WINDOW_DELAY,
prv_transcription_dialog_select_cb, transcription_dialog);
}
void transcription_dialog_update_text(TranscriptionDialog *transcription_dialog,
char *buffer, uint16_t buffer_len) {
Dialog *dialog = ex... |
TYPE_DATA, write_address,
chunk, load_length);
if (!prv_write_register_block(dev, ADDR_LOADER_STATUS, data_record,
IHEX_RECORD_LENGTH(load_length))) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to write hex record");
return false;
}
// Wait ... | PBL_LOG(LOG_LEVEL_DEBUG, "Starting HRM app") | ;
if (!prv_set_running_apps(dev, AS7000AppId_HRM)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to start HRM app!");
goto failed;
}
// Configure the int_gpio pin only when we're going to use it, as this pin is shared with
// the jtag pins and therefore can cause issues when flashing firmwares onto bigboards.
g... |
s_sys_activity_get_step_averages_values_weekday = (sys_activity_get_step_averages_values){
.out.result = true,
};
s_sys_activity_get_step_averages_values_weekend = (sys_activity_get_step_averages_values){
.out.result = true,
};
for (int i = 0;
i < ARRAY_LENGTH(s_sys_activity_get_step_averages_va... | health_service_sum_averaged(HealthMetricStepCount, start_of_today,
start_of_today + (9 * SECONDS_PER_HOUR),
HealthServiceTimeScopeDaily) | ;
cl_assert_equal_i(value, exp_value);
}
void test_health__get_measurement_system_for_display(void) {
MeasurementSystem actual =
health_service_get_measurement_system_for_display(HealthMetricSleepSeconds);
cl_assert_equal_i(actual, MeasurementSystemUnknown);
s_units_distance_result = UnitsDistance_Miles;
... |
flash_write_bytes((uint8_t *)&new_crc,
SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_page_number())
+ offsetof(SharedPRFData, ble_pairing_data)
+ offsetof(SprfBlePairingData, crc),
sizeof(new_crc)) | ;
// Confirm new CRC was written
flash_read_bytes((uint8_t *)&data,
SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_page_number()),
sizeof(data));
cl_assert_equal_i(data.ble_pairing_data.crc, new_crc);
// Should be corrupt, so after a 'set', the page number should inc... | |
{
s_content_size = content_size;
} |
mutex_unlock(s_mutex);
}
PreferredContentSize system_theme_get_content_size(void) {
return system_theme_convert_host_content_size_to_runtime_platform(
(PreferredContentSize)s_content_size);
}
bool activity_prefs_tracking_is_enabled(void) {
#if CAPABILITY_HAS_HEALTH_TRACKING
return true;
#else
return fa... | |
pplib/bluetooth/ble_ibeacon.h"
#include <btutil/bt_device.h>
#include "clar.h"
// Stubs
///////////////////////////////////////////////////////////
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_rand_ptr.h"
#include "stubs_ble_sysca... | create_too_short_ad_data() | ;
bool is_ibeacon = ble_ibeacon_parse(too_short_to_ibeacon, 0, NULL);
cl_assert(!is_ibeacon);
free(too_short_to_ibeacon);
}
|
/*
* 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_INFO, "Pausing address cycling (pinned_addr="BT_DEVICE_ADDRESS_FMT")",
BT_DEVICE_ADDRESS_XPLODE(s_pinned_addr)) | ;
prv_allow_cycling(false);
}
++s_pra_cycling_pause_count;
}
bt_unlock();
}
void bt_local_addr_resume_cycling(void) {
bt_lock();
{
PBL_ASSERTN(s_pra_cycling_pause_count);
--s_pra_cycling_pause_count;
if (s_pra_cycling_pause_count == 0) {
PBL_LOG(LOG_LEVEL_INFO, "Resuming address... |
system_theme.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include <string.h>
//! @return True if there was an animation to cancel, false otherwise
static bool prv_cancel_selection_animation(MenuLayer *menu_layer);
//////////////////////
// Menu Layer
//
// NOTES: The MenuLayer i... | {
if (menu_layer->callbacks.get_num_sections) {
return menu_layer->callbacks.get_num_sections(menu_layer, menu_layer->callback_context);
} else {
return 1; // default
}
} |
static inline uint16_t prv_menu_layer_get_num_rows(MenuLayer *menu_layer, uint16_t section_index) {
if (section_index == MENU_INDEX_NOT_FOUND) {
return 0;
}
if (menu_layer->callbacks.get_num_rows) {
return menu_layer->callbacks.get_num_rows(menu_layer, section_index,
menu_layer->callback_contex... |
test_unprintable(void) {
// Allocate mutable types
Iterator word_iter = (Iterator) { 0 };
WordIterState word_iter_state = (WordIterState) { 0 };
// Allocate immutable types
bool success = false;
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, (char[]) { 0x10, 0x0 });
cl_assert(success);
const... | (iter_next(&word_iter)) | ;
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == 'o');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == 'o');
cl_assert(*word_iter_state.current.end == '\n');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
c = 'a' + (digit - 0xa);
} | else {
c = ' ';
}
*buffer++ = c;
}
*buffer = '\0';
}
|
s_activity_activation_delay_insight_bitmask = 0;
s_activation_time = 0;
s_activity_activation_delay_insight_bitmask = 0;
}
// =============================================================================================
// Start of unit tests
void test_activity_insights__initialize(void) {
prv_set_time(&s_init_... | activity_insights_process_sleep_data(rtc_get_time()) | ;
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
// Advance the clock some and make sure we still don't get notifications
for (int i = 0; i < 100; ++i) {
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_MINUTE);
activity_insights_process_sleep_data(rtc_get_time());
... |
if (!child) {
break;
} |
child_duration = prv_get_total_duration(state, child, true, true);
if (child_duration == PLAY_DURATION_INFINITE) {
return PLAY_DURATION_INFINITE;
}
max_child_duration = MAX(max_child_duration, child_duration);
}
duration += max_child_duration;
} else {
PBL_ASSERTN(animati... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
(void)test_count;
printf("Loaded %d suites: %s\n", (int)suite_count, suite_names);
printf("Started\n");
} | |
e "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,... | if (value_length_out) {
*value_length_out = header.value_length;
} |
}
return has_notification;
}
DEFINE_SYSCALL(void, sys_ble_client_consume_read, uintptr_t object_ref,
uint8_t value_out[],
uint16_t *value_length_in_out) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspac... |
large_int = 10000;
void test_rocky_api_graphics__fill_text(void) {
prv_global_init_and_set_ctx();
// we do this in C and not JS as color binding is not linked in this unit-test
// what we want to test though is that the text color is taken from fill color
rocky_api_graphics_get_gcontext()->draw_state.fill_co... | ASSERT_JS_GLOBAL_EQUALS_S("a", "center") | ;
// we only support LTR
EXECUTE_SCRIPT("ctx.textAlign = 'start';\nvar a = ctx.textAlign;\n");
cl_assert_equal_i(GTextAlignmentLeft, s_rocky_text_state.alignment);
ASSERT_JS_GLOBAL_EQUALS_S("a", "left");
EXECUTE_SCRIPT("ctx.textAlign = 'end';\nvar a = ctx.textAlign;\n");
cl_assert_equal_i(GTextAlignmentRi... |
ssions and
* limitations under the License.
*/
#include "health.h"
#include "health_card_view.h"
#include "health_data.h"
#include "applib/app.h"
#include "applib/ui/dialogs/expandable_dialog.h"
#include "kernel/event_loop.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/modals/modal_manager.h"
#include "popup... | health_card_view_create(health_app_data->health_data) | |
ent);
// Then, when the voltage drops, the percentage should begin to decline - but should not reach the low value yet
fake_battery_set_millivolts(low_mv);
periodic_timer_trigger(1);
int delta = high_percent - battery_get_charge_state().charge_percent;
cl_assert(delta >= 0);
cl_assert(delta < high_percent ... | battery_monitor_critical_lockout() | );
cl_assert_equal_i(s_power_state, PowerStateCritical);
// critical -> lpm (only possible if unstable)
fake_battery_set_millivolts(low_mv);
battery_state_force_update();
periodic_timer_trigger(1);
cl_assert(s_in_low_power);
cl_assert_equal_i(s_power_state, PowerStateLowPower);
// lpm -> critical
fa... |
p_state.h"
#include "stubs_logging.h"
#include "stubs_heap.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_print.h"
#include "stubs_queue.h"
#include "stubs_resources.h"
#include "stubs_serial.h"
#include "stubs_ui_window.h"
#define GET_PBI_NAME(x) prv_get_im... | cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(60))) | ;
// Since we have loop count 2 and 88 frames, see if we can go to elapsed at 2nd loop correctly
status = gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap,
88 * 100 + (49 - 1) * 100);
cl_assert_equal_b(status, true);
cl_check(gbitmap_pbi_e... |
call to action
icon = TIMELINE_RESOURCE_GENERIC_WARNING;
message = i18n_get("Incompatible JS", data);
break;
case AppFetchResultGeneralFailure:
case AppFetchResultUUIDInvalid:
case AppFetchResultPutBytesFailure:
case AppFetchResultTimeoutError:
case AppFetchResultPhoneBusy:
de... | (BUTTON_ID_SELECT, (ClickHandler) prv_click_handler) | ;
window_single_click_subscribe(BUTTON_ID_BACK, (ClickHandler) prv_click_handler);
}
static void handle_init(void) {
AppFetchUIData* data = app_zalloc_check(sizeof(AppFetchUIData));
app_state_set_user_data(data);
// get app args, copy them to app memory, and free the kernel buffer
AppFetchUIArgs *temp_fetch... |
/*
* 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... | (heartbeat, metric) | ;
if (analytics_metric_is_array(metric)) {
PBL_CROAK("Attempt to use integer value for array metric.");
}
return heartbeat->data + analytics_metric_offset(metric);
}
static uint8_t *prv_heartbeat_get_array_location(AnalyticsHeartbeat *heartbeat, AnalyticsMetric metric,
uint32_t index) {
prv_verify... |
30
#define RECT_HEIGHT 40
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 20, 20)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 144, 168)
#define ORIGIN_DRAW_RECT_NO_CLIP GRect(6, 6, RECT_WIDTH, RECT_HEIGHT)
#define ORIGIN_DRAW_RECT_CLIP_XY ... | gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r9_no_clip.${BIT_DEPTH_NAME}.pbi") | );
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__origin_radius_aa(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// AA = true, SW has no effect, all corners
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLI... |
#if EXTENSION_C99
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%123F", &jan_2_10015__13_00_00);
cl_assert_equal_s(tmbuf, "10015-01-02");
#endif
#if EXTENSION_TZ
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%7G %01g", &jan_2_10015__13_00_00);
cl_assert_equal_s(tmbuf, "0010015 15");
tmbuf[0] = '\... | cl_assert_equal_s(tmbuf, "Fri Jan 2 13:00:00 2015") | |
_LOG(LOG_LEVEL_DEBUG, "sleep state minutes: %d", (int)(value / SECONDS_PER_MINUTE));
prv_test_end(context, passed);
}
// -------------------------------------------------------------------------------
// Test that we don't crash or get a weird sleep session if the UTC time changes while
// sleeping
static void prv... | prv_feed_light_sleep_min(20) | |
h"
// Stubs
/////////////////////////////////
#include "stubs_analytics.h"
#include "stubs_events.h"
#include "stubs_firmware_update.h"
#include "stubs_hexdump.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_notification_storage.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#includ... | (AlertReminder) | );
cl_assert(!alerts_should_vibrate_for_type(AlertReminder));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertReminder));
cl_assert(alerts_should_notify_for_type(AlertOther));
cl_assert(... |
roup_type_element;
attr_list->attributes = (Attribute *)*buffer;
*buffer += attributes_per_group_type_element * sizeof(Attribute);
}
static void prv_init_group_type(AttributeGroupType type,
void *group_ptr,
uint8_t **buffer,
... | {
num_group_type_elements = ((TimelineItemActionGroup *)group_ptr)->num_actions;
} | |
prv_update_enqueue_count(true) | ) {
return false;
}
bool success = true;
// Retry for 500ms
TickType_t start_ticks = xTaskGetTickCount();
while (1) {
HostTransportEnqueueStatus status =
host_transport_tx_enqueue((const uint8_t *)message, message->message_length);
if (status != HostTransportEnqueueStatus_RetryLater) ... | |
d on the clock.
static ClockText prv_configure_clock_text(ClockTextType type, ClockTextLocation location,
GColor color, struct tm *tick_time) {
ClockText text = (ClockText) {
.location = location,
.color = color,
};
if (type == CLOCK_TEXT_TYPE_DATE) {
strftim... | prv_clock_model_default(tick_time) | ;
watch_model_handle_change(&model);
}
void watch_model_cleanup() {
tick_timer_service_unsubscribe();
}
static void prv_intro_animation_finished(Animation *animation) {
const time_t t = rtc_get_time();
prv_handle_time_update(pbl_override_localtime(&t), (TimeUnits)0xff);
tick_timer_service_subscribe(MINUTE_... |
\
.target_percent_of_median = 120, \
.notif_min_interval_seconds = 7 * SECONDS_PER_DAY, \
.sleep.trigger_after_wakeup_seconds = 2 * SECONDS_PER_HOUR \
} \
}
#define ACTIVITY_INSIGHTS_SETTINGS_SLEEP_SUMMARY_DEFAULT { \
.version = ACTIVITY_INSIGHTS_SETTINGS_CURRENT_STRUCT_VERSION, \
.enabled = true, \... | (ACTIVITY_INSIGHTS_SETTINGS_VERSION_KEY) | ,
&default_version,
sizeof(uint16_t));
}
settings_file_close(&file);
return;
}
PBL_LOG(LOG_LEVEL_ERROR, "Failed to create activity insights settings file");
}
uint16_t activity_insights_settings_get_version(void) {
uint16_t version = ACTIVITY_INSIGHTS_SETTINGS_DEFAULT_VERSION;
... |
/*
* 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... | (GPIOC, &GPIO_InitStructure) | ;
/* USART configuration */
USART_InitStructure.USART_BaudRate = SERIAL_BAUD_RATE;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_Har... |
e();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 23:00 on Friday. (14.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 52200 * MS_PER_SECOND);
rtc_set_time(s_friday_23_30); // In schedule
do_not_disturb_handle_clock_change();
active = do_... | do_not_disturb_handle_clock_change() | |
);
I2C_DeInit(bus->hal->i2c);
}
static uint32_t prv_get_apb1_frequency(void) {
RCC_ClocksTypeDef rcc_clocks;
RCC_GetClocksFreq(&rcc_clocks);
return rcc_clocks.PCLK1_Frequency;
}
static const int DUTY_CYCLE_DIVIDERS[] = {
[I2CDutyCycle_16_9] = 25,
[I2CDutyCycle_2] = 3
};
static uint32_t prv_prescalar_to_f... | i2c_handle_transfer_event(bus, event) | ;
}
//! Pause a transfer, disabling interrupts during the pause
//! Only call from interrupt functions
static portBASE_TYPE prv_pause_transfer_irq(I2CBus *bus) {
prv_disable_all_interrupts(bus);
return i2c_handle_transfer_event(bus, I2CTransferEvent_NackReceived);
}
//! Handle an IRQ event on the specified \a bus... |
/*
* 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 (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_DEBUG, "ble_gattc_discover_cancel: %u", e);
} |
}
void hc_endpoint_discovery_send_service_found(
const HcProtocolDiscoveryServiceFoundPayload *payload, uint32_t payload_size) {
// Note: kind of wasteful double copy here, a service node could get sort of
// big (several hundred bytes)
hc_protocol_enqueue_with_payload(HcEndpointID_Discovery, HcMessageID_Di... |
elay index increases
lookup->max_index += delay_amount;
for (int i = 0; i < lookup->num_points; i++) {
// The lookup maps definition index => delay index
// We want to add delay to points at or above a certain delay index
if (lookup->index_lookup[i] >= delay_index) {
lookup->index_lookup[i] += del... | {
gpoint_add_eq(&point, gvalues->offset);
} | |
/*
* 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... | (key, sizeof(key), val, sizeof(val)) | ;
SettingsFile file;
settings_file_open(&file, iOS_NOTIF_PREF_DB_FILE_NAME, iOS_NOTIF_PREF_MAX_SIZE);
const unsigned prefs_len = settings_file_get_len(&file, key, sizeof(key));
void *prefs_out = kernel_zalloc(prefs_len);
settings_file_get(&file, key, sizeof(key), prefs_out, prefs_len);
settings_file_close... |
P_COLS, 0 },
{ DISP_COLS, DISP_ROWS * 0.31 }, },
// TL: 0,0 -> 0,30 (0.18)
{ { 0, 0 },
{ 0, DISP_ROWS * 0.18 }, },
PATH_INTERP_DEF_TL_CORNER,
PATH_INTERP_DEF_TR_CORNER,
},
},
// We don't have one for Left or Down becaus... | (ctx, s_data.sampled_color) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (s1[len] == *p) {
break;
}
p++;
} |
if (!*p) {
return len;
}
len++;
}
return len;
}
|
cessoryBaud14400,
AccessoryBaud19200,
AccessoryBaud28800,
AccessoryBaud38400,
AccessoryBaud57600,
AccessoryBaud62500,
AccessoryBaud115200,
AccessoryBaud125000,
AccessoryBaud230400,
AccessoryBaud250000,
AccessoryBaud460800
};
_Static_assert(ARRAY_LENGTH(BAUDS) - 1 == AccessoryBaud460800, "BAUDS doesn... | smartstrap_link_control_disconnect() | ;
success = false;
} else {
prv_do_send(LinkControlTypeStatus);
}
} else {
// length is invalid (should be an even multiple of the size of the profile value)
PBL_LOG(LOG_LEVEL_WARNING, "Got invalid profiles length (%"PRIu32")", data_length);
smartstrap_link_control_disc... |
!host_transport_is_current_task_host_transport_task());
prv_assign_next_transaction_id(request_message);
HcExpectation *expectation = prv_set_expectation_for_request(request_message);
if (!prv_enqueue(request_message)) {
prv_cleanup_expectation(expectation);
return NULL;
}
HcProtocolMessage *respon... | {
if (!prv_check_initialized()) {
return;
}
size_t rx_length = host_transport_rx_get_length();
while (rx_length) {
if (rx_length < sizeof(HcProtocolMessage)) {
// Header not received completely yet
return;
}
bool should_free = false;
HcProtocolMessage *header = prv_get_message(... |
void hc_protocol_buffer_gained_space(void) {
PBL_ASSERTN(s_retry_semph);
xSemaphoreGive(s_retry_semph);
}
//! Should be called only once at boot.
void hc_protocol_boot(void) {
if (s_hc_lock) {
return;
}
s_hc_lock = mutex_create_recursive();
}
//! Should be called when stack is brought up.
void hc_prot... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_max_advertising_interval_slots, expected_max_slots) | ;
}
bool gap_le_is_advertising_enabled(void) {
return s_is_le_advertising_enabled;
}
static Advertising_Data_t s_ad_data;
static unsigned int s_ad_data_length;
int GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID,
unsigned int Length,
Adverti... |
const uint8_t *value,
size_t value_length,
uint16_t value_offset,
BLEGATTError error) {
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
Uuid descriptor_uuid = ble_descriptor_get_uuid(de... | bt_uuid_expand_16bit(0x2A37) | ;
if (uuid_equal(&hrm_uuid, &characteristic_uuid)) {
ble_client_subscribe(characteristics[c], BLESubscriptionNotifications);
}
// BLEDescriptor descriptors[8];
// uint8_t num_descriptors =
// ble_characteristic_get_descriptors(characteristics[c], descriptors, 8);
// for ... |
/*
* 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... | {
prompt_context_append_char(&s_prompt_context, c);
} | |
ault_reminders(void) {
// add all four explicitly out of order
cl_assert_equal_i(S_SUCCESS, reminder_db_insert_item(&item4));
cl_assert_equal_i(S_SUCCESS, reminder_db_insert_item(&item2));
cl_assert_equal_i(S_SUCCESS, reminder_db_insert_item(&item1));
cl_assert_equal_i(S_SUCCESS, reminder_db_insert_item(&i... | (S_NO_MORE_ITEMS == reminder_db_next_item_header(&temp)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.