prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
target_time - state->vars->current_time;
state->time_was_until = true;
}
static void prv_filter_time_since(TemplateStringState *state) {
prv_filter_time_until(state);
if (state->error->status != TemplateStringErrorStatus_Success) {
return;
}
state->filter_state = -state->filter_state;
state->time_was_... | prv_append_char(&state, *state.position) | ;
state.position++;
} else { // Template
state.position++;
prv_template_eval(&state);
if (state.error->status != TemplateStringErrorStatus_Success) {
break;
}
state.time_was_until = false;
state.filter_state = 0;
state.filters_complete = false;
}
}
if... |
d_data[k_raw_samples];
prv_uncompress_captured_data(captured_data, k_raw_samples);
cl_assert_equal_m(raw_data, captured_data, k_raw_samples * sizeof(AccelRawData));
}
}
// ---------------------------------------------------------------------------------------
// Test getting the sleep sessions
void test_act... | (num_records, ALG_MINUTES_PER_FILE_RECORD - i) | ;
cl_assert_equal_i(start_time, oldest_to_fetch + (i * SECONDS_PER_MINUTE));
printf("\nReceived %d minute records", (int)num_records);
for (int j = 0; j < num_records; j++) {
printf("\nRecord:%d, steps: %d", j, (int)received_records[j].steps);
}
// Verify the contents of the records
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... | (page.size, GSize(30, TEXT_LAYER_FLOW_DEFAULT_PAGING_HEIGHT)) | ;
scroll_layer_is_instance_value = &container;
cl_assert(true == text_layer_calc_text_flow_paging_values(&text_layer, &origin, &page));
cl_assert_equal_gpoint(origin, GPoint(40, 60));
// containers's absolute coordinate
cl_assert_equal_gpoint(page.origin, GPoint(30, 40));
cl_assert_equal_gsize(page.size, ... |
.uint32);
((PropertyAnimationImplementation*)
property_animation->animation.implementation)
->accessors.setter.uint32(property_animation->subject, result);
}
// -----------------------------------------------------------------------------------------
void property_animation_update_gpoint(PropertyAnimation... | (
distance_normalized,
property_animation->values.from.gtransform.c,
property_animation->values.to.gtransform.c) | ;
result.d = interpolate_fixed32(
distance_normalized,
property_animation->values.from.gtransform.d,
property_animation->values.to.gtransform.d);
result.tx = interpolate_fixed32(
distance_normalized,
property_animation->values.from.gtransform.tx,
property_animation->values.to.gtr... |
,
void *context) {
if (!animation) {
return false;
}
((AnimationPrivate*)animation)->context = context;
return true;
}
void *WEAK animation_get_context(Animation *animation) {
if (!animation) {
return false;
}
return ((AnimationPrivate*)animation)->context;
}
boo... | property_animation_get_animation(PropertyAnimation *property_animation) | |
(&context, GPoint(5, 5), GPoint(45, 10)));
#else
ASSERT_CALLED(graphics_line_draw_1px_non_aa(&context, GPoint(5, 5), GPoint(45, 10)));
#endif
setup_test(&context, true, 1, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20... | (&context, GPoint(5, 5), GPoint(45, 10)) | ;
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_ODD));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
setu... |
EBUG, "At least I started");
analytics_init();
hc_endpoint_analytics_send_reboot_info();
debug_reboot_reason_print();
s_ble_perip_wdog_id = sys_watchdog_register(false);
// FIXME:
// srand(time(NULL));
PBL_LOG(LOG_LEVEL_DEBUG, "hope for the best");
connection_module_init();
prv_configure_irk(init... | prv_handle_get_peer_version_complete((const ble_evt_gap_get_peer_version_t *)hdr) | ;
break;
// GATT Client Events:
case BLE_EVT_GATTC_MTU_CHANGED:
prv_handle_gatt_mtu_changed((const ble_evt_gattc_mtu_changed_t *)hdr);
break;
case BLE_EVT_GATTC_BROWSE_SVC:
gatt_client_discovery_process_service((const ble_evt_gattc_browse_svc_t *)hdr);... |
[64];
snprintf(snooze_buf, sizeof(snooze_buf), i18n_get(snooze_text, dialog), alarm_get_snooze_delay());
i18n_free(snooze_text, dialog);
dialog_set_text(dialog, snooze_buf);
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_CONFIRMATION_LARGE);
dialog_set_background_color(dialog, GColorJaegerGreen);
dialog_set_ti... | i18n_free_all(data) | ;
task_free((void *)root_level->items[DetailMenuItemIndexSnooze].next_level);
task_free((void *)root_level);
task_free(data);
data = NULL;
}
void alarm_detail_window_push(AlarmId alarm_id, AlarmInfo *alarm_info,
AlarmEditorCompleteCallback alarm_editor_callback,
... |
) {
struct InstallableObject* o = NULL;
for (int i = 0; i < NumObjects; ++i) {
if (s_ready_to_install[i].token == token) {
o = &s_ready_to_install[i];
break;
}
}
if (token == 0 || o == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "Token does not exist; got 0x%" PRIx32, token);
prv_cleanup_and_s... | {
if (s_pb_state.timer_id != TIMER_INVALID_ID) {
new_timer_stop(s_pb_state.timer_id);
} else {
s_pb_state.timer_id = new_timer_create();
}
} |
static bool prv_setup_storage_for_init_request(const InitRequest *request, uint32_t index) {
PutBytesStorageInfo *storage_info = NULL;
switch (request->type) {
#ifndef RECOVERY_FW
case ObjectFile: {
storage_info = kernel_malloc_check(sizeof(PutBytesStorageInfo) +
... |
tingResult,
BTPairingUIStateSuccess,
BTPairingUIStateFailed,
} BTPairingUIState;
typedef struct BTPairingUIData {
Window window;
KinoLayer kino_layer;
KinoReel *reel;
GBitmap *approve_bitmap;
GBitmap *decline_bitmap;
ActionBarLayer action_bar_layer;
Layer info_text_mask_layer;
PropertyAnimation *in... | {
prv_update_text_layer_with_translation(&data->info_text_layer2, &english_translation);
} | else {
prv_update_text_layer_with_translation(&data->info_text_layer2,
&translations[data->translated_str_idx]);
}
data->num_strings_shown++;
}
static void prv_animate_info_text(BTPairingUIData *data) {
prv_update_prf_info_text_layers_text(data);
animation_sche... |
d(data, length);
}
static void prv_endpoint_handler_c(
CommSession *session, const uint8_t *data, size_t length) {
s_handler_call_count[HandlerC]++;
prv_assert_data_matches_expected(data, length);
}
static const PebbleProtocolEndpoint s_endpoints[NumHandlers] = {
[0] = {
.handler = prv_endpoint_handler_... | (&expected_data, 1) | ;
fake_system_task_callbacks_invoke(1);
cl_assert_equal_i(s_handler_call_count[HandlerA], i + 1);
expected_data += 1;
}
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
}
//! Make sure that if cleanup runs and we are partially through updating a
//! buffer the callback does not get called
void ... |
display/resources/dead_face.xbm"
#include "drivers/display/resources/empty_bar.xbm"
#include "drivers/display/resources/error_url.xbm"
#include "drivers/display/resources/pebble_logo.xbm"
#define DISP_LINE_BYTES (DISP_COLS / 8)
#define DISP_LINE_WORDS (((DISP_COLS - 1) / 32) + 1)
// GPIO constants
#define DISP_SPI (S... | SPI_Init(DISP_SPI, &s_disp_spi_init) | ;
SPI_Cmd(DISP_SPI, ENABLE);
// Hold LCD on
GPIO_WriteBit(DISP_LCD_GPIO, DISP_PIN_LCD, Bit_SET);
}
// Clear-all mode is entered by sending 0x04 to the panel
void display_clear(void) {
prv_enable_display_access();
prv_display_write_byte(DISP_MODE_CLEAR);
prv_display_write_byte(0x00);
prv_disable_disp... |
);
break;
case WATCH_INFO_COLOR_RED:
model_name = TINTIN_MODEL("pebble_red");
break;
case WATCH_INFO_COLOR_ORANGE:
model_name = TINTIN_MODEL("pebble_orange");
break;
case WATCH_INFO_COLOR_GRAY:
model_name = TINTIN_MODEL("pebble_gray");
break;
... | ((const jerry_char_t *)app_get_system_locale()) | ;
}
static jerry_value_t prv_get_fw_version(void) {
WatchInfoVersion fw_version = watch_info_get_firmware_version();
JS_VAR version_major = jerry_create_number(fw_version.major);
JS_VAR version_minor = jerry_create_number(fw_version.minor);
JS_VAR version_patch = jerry_create_number(fw_version.patch);
// Pa... |
Y KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This app only makes sense on Snowy, as it uses addresses and sector sizes that only make sense
// on our parallel flash hardware
#if CAPABILITY_USE_PARALLEL_FLASH
#includ... | (FONT_KEY_GOTHIC_14_BOLD) | );
layer_add_child(&window->layer, &msg_text_layer->layer);
msg_text_layer = &data->msg_text_layer[1];
text_layer_init(msg_text_layer, &GRect(0, 32, window->layer.bounds.size.w, 18));
if (data->test_case >= FLASH_TEST_CASE_RUN_SWITCH_MODE_ASYNC) {
text_layer_set_text(msg_text_layer, "Select To Confirm Swit... |
f (logging_session->comm.state != DataLoggingSessionCommStateIdle) {
mutex_unlock(s_endpoint_data.mutex);
// logging_session is waiting for an ack, we'll send next time around
// don't return a failure, this is pretty innocuous.
return true;
}
const uint32_t total_length = sizeof(DataLoggingSendDat... | {
case DataLoggingSessionCommStateIdle:
case DataLoggingSessionCommStateOpening:
//Currently, these messages never get NACK'd
PBL_LOG(LOG_LEVEL_ERROR, "Unexpected NACK");
break;
case DataLoggingSessionCommStateSending:
//Maybe queue a resend
logging_session->comm.num_bytes_pend... | |
/////////////
#include "services/normal/blob_db/api.h"
#include "services/normal/blob_db/util.h"
#include "services/normal/blob_db/sync.h"
#include "util/size.h"
// Writebacks counter
////////////////////////
static int s_num_writebacks;
static int s_num_until_timeout;
void blob_db_endpoint_send_sync_done(BlobDBId ... | ARRAY_LENGTH(keys) | );
for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
cl_assert(list_find(&dirty_list->node, prv_list_key_comparator, keys[i]) != NULL);
}
blob_db_util_free_dirty_list(dirty_list);
// mark one as synced and re-check
for (int synced_idx = 1; synced_idx < ARRAY_LENGTH(keys); ++synced_idx) {
blob_db_mark_... |
/*
* 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... | {
strncpy(dest, "QEMU", dest_size);
} |
bool bt_driver_id_generate_private_resolvable_address(BTDeviceAddress *address_out) {
*address_out = (BTDeviceAddress) {};
return true;
}
|
_data = (WorkoutData) {
.steps = 567,
.duration_s = 84,
.distance_m = 1234,
.avg_pace = health_util_get_pace(84, 1234),
.bpm = 71,
.hr_zone = 0,
};
WorkoutActiveWindow *active_window = workout_active_create_for_activity_type(
ActivitySessionType_Run, &s_workout_data, &s_workout_contro... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
// Workout Tests
//////////////////////
void test_workout_active__sports_pace(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMetr... |
rce/resource_ids.auto.h"
#include "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "system/logging.h"
#include "util/size.h"
#include "util/string.h"
typedef struct HealthHrSummaryCardData {
HealthData *health_data;
HealthProgressBar progress_bar;
GDrawCommandSequence *pulsing_heart;
u... | (base_layer) | ;
if (data->last_updated <= 0 || data->now_bpm == 0) {
return;
}
const size_t buffer_size = 32;
char buffer[buffer_size];
clock_get_until_time_without_fulltime(buffer, buffer_size, data->last_updated, HOURS_PER_DAY);
const int y = PBL_IF_RECT_ELSE(130, 136);
GRect rect = GRect(0, y, base_layer->bo... |
update_interval(HRMSessionRef session, uint32_t update_interval_s,
uint16_t expire_s) {
cl_assert(session < s_hrm_next_session_ref);
s_hrm_manager_update_interval = update_interval_s;
s_hrm_manager_expire_s = expire_s;
s_hrm_manager_num_update_interval_changes++;
retur... | cl_assert_equal_i(item_size, sizeof(ActivityRawSamplesRecord)) | ;
return (DataLoggingSession *)DataLoggingSession_AccelSamples;
} else if (tag == DlsSystemTagActivitySession) {
s_dls_activity_sessions_created = true;
cl_assert_equal_i(item_size, sizeof(ActivitySessionDataLoggingRecord));
return (DataLoggingSession *) DataLoggingSession_ActivitySessions;
} else... |
cl_assert_equal_i(windows[3][0]->is_click_configured, true);
cl_assert_equal_i(windows[2][1]->on_screen, false);
cl_assert_equal_i(windows[2][1]->is_click_configured, false);
cl_assert_equal_p(s_last_click_configured_window, windows[3][0]);
// Add priority 3 unfocusable window 1
window_set_focusable(windows... | modal_window_push(window1, base_priority, false) | ;
cl_assert_equal_i(window1->on_screen, true);
modal_window_push(window2, base_priority - 1, false);
cl_assert_equal_i(window1->on_screen, true);
cl_assert_equal_i(window2->on_screen, false);
modal_window_push(window1, base_priority - 2, false);
modal_manager_event_loop_upkeep();
cl_assert_equal_i(w... |
oop("Way to keep it active!"),
i18n_noop("You got the moves!"),
i18n_noop("Gettin' your step on?"),
},
};
return prv_get_variant(&s_walking_intros, VARIANT_RANDOM);
}
case ActivitySessionType_Run: {
static const InsightCopyVariants s_running_intros = {
.num... | (distance_str, distance_buf_size,
session->step_data.distance_meters) | ;
snprintf(distance_str + offset, distance_buf_size - offset,
" %s", prv_get_distance_unit(headings));
string_list_add_string(headings, headings_buf_size,
i18n_get("Distance", headings), headings_buf_size);
string_list_add_string(values, values_buf_size, distance_str, values_... |
/*
* 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... | ("var y = new _rocky.test(); y.method();") | ;
cl_assert_equal_i(1, s_method_func_imp_call_count);
}
void test_rocky_api_util__error_print(void) {
s_log_internal__expected = (const char *[]){
"Unhandled Error",
" "ERROR_STRING,
NULL
};
jerry_value_t error_val =
jerry_create_error(JERRY_ERROR_COMMON, (const jerry_char_t *)ERROR_STRING)... |
rtc_calibration_init_timer();
RTC_CoarseCalibConfig(config.sign, config.units);
RTC_CoarseCalibCmd(ENABLE);
}
//! Our RTC tick counter actually overflows once every 86 seconds. If we don't call rtc_get_ticks() every 86 seconds,
//! the counter may roll over multiple times, causing our clock to appear to have g... | ticks_to_time(s_coarse_ticks) | );
//save_rtc_time_state(0);
}
void rtc_init(void) {
periph_config_acquire_lock();
rtc_enable_backup_regs();
periph_config_release_lock();
restore_rtc_time_state();
initialize_fast_mode_state();
#ifdef PBL_LOG_ENABLED
char buffer[TIME_STRING_BUFFER_SIZE];
PBL_LOG(LOG_LEVEL_DEBUG, "Current time is <%s... |
pbl_malloc.h"
#include "process_management/app_install_manager.h"
#include "resource/resource_ids.auto.h"
#include "services/common/clock.h"
#include "services/normal/alarms/alarm.h"
#include "services/normal/timeline/attribute.h"
#include "system/passert.h"
#include "util/attributes.h"
#include "util/string.h"
#includ... | time_util_get_midnight_of(current_time) | ;
const time_t alarm_midnight = time_util_get_midnight_of(alarm_time_epoch);
const bool is_alarm_for_today = (alarm_midnight == today_midnight);
const size_t alarm_subtitle_size = sizeof(alarms_glance->subtitle);
// Only show the day of the week if the alarm is not for today
if (!is_alarm_for_toda... |
b_zalloc(sizeof(ActionResultData));
if (!data) {
return;
}
data->chaining_data.action_chaining_window = chaining_window;
data->chaining_data.notif = timeline_item_copy(cb_data->item);
data->standalone_action = cb_data->standalone_action;
const bool ignore_failures = false;
prv_subscribe_to_action_re... | (&action_result->id, uuid_string) | ;
PBL_LOG(LOG_LEVEL_INFO, "Received action result: Item ID - %s; type - %"
PRIu8, uuid_string, (uint8_t)action_result->type);
// Each action result can only service one response event
event_service_client_unsubscribe(&data->event_service_info);
switch (action_result->type) {
case ActionResultTyp... |
captured_data[k_raw_samples];
prv_uncompress_captured_data(captured_data, k_raw_samples);
cl_assert_equal_m(raw_data, captured_data, k_raw_samples * sizeof(AccelRawData));
}
}
// ---------------------------------------------------------------------------------------
// Test getting the sleep sessions
void ... | cl_assert_equal_i(num_records, ALG_MINUTES_PER_FILE_RECORD - i) | ;
cl_assert_equal_i(start_time, oldest_to_fetch + (i * SECONDS_PER_MINUTE));
printf("\nReceived %d minute records", (int)num_records);
for (int j = 0; j < num_records; j++) {
printf("\nRecord:%d, steps: %d", j, (int)received_records[j].steps);
}
// Verify the contents of the records
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... | (&ctx, (GColor8){.a= 1, .r = 3}) | ;
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.stroke_color.argb);
graphics_context_set_stroke_color(&ctx, (GColor8){.a= 0, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.stroke_color.argb);
}
void test_graphics_blending__ctx_fill_color_discards_alpha(void) {
GContext ctx = {};
graphics_c... |
(0, 0)));
cl_assert_equal_grect(GRect(5, 5, 1, 2), grect_centered_internal(&p3, GSize(-1, -2)));
// handles fixed point
cl_assert_equal_grect(GRect(5, 5, 2, 2), grect_centered_internal(&p3, GSize(2, 2)));
p3.x.raw_value += FIXED_S16_3_HALF.raw_value;
cl_assert_equal_grect(GRect(5, 5, 2, 2), grect_centered_in... | (2, 2, 8, 8) | ;
grect_polar_calc_values(&r, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 5.5, 5.5);
cl_assert_fixedS16_3(radius, 3.5);
}
void test_graphics_circle__grect_polar_calc_values_mode(void) {
GPointPrecise center = {};
Fixed_S16_3 radius = {};
GRect r = GRect(0, 0, 144, 168);
grect_polar_calc_va... |
ivity_prefs_tracking_is_enabled()) {
activity_start_tracking(false /*test_mode*/);
}
workout_service_init();
#endif
bool factory_reset_or_first_use = !shared_prf_storage_get_getting_started_complete();
// We are almost done booting, welcome the user if applicable. This _must_ occur before setting
// the ... | {
case PebbleWorkoutEvent_Started:
case PebbleWorkoutEvent_Paused:
can_expire = false;
break;
case PebbleWorkoutEvent_Stopped:
can_expire = true;
break;
case PebbleWorkoutEvent_FrontendOpened:
case PebbleWorkoutEvent_FrontendClosed:
... |
app_install_mark_prioritized(APP_ID_WORKOUT, can_expire);
workout_service_workout_event_handler(workout_e);
return;
}
default:
break; // don't care
}
}
|
er_state_from_ref(session_ref) == NULL);
cl_assert(sys_hrm_manager_get_app_subscription(app_id) == HRM_INVALID_SESSION_REF);
}
// Test that system subscriptions expire correctly
void test_hrm_manager__kernel_expiration(void) {
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
const uint16_t expire_s =... | cl_assert_equal_i(s_event_count, 0) | |
},
{ 0, 0x33, 122, 0x0},
{ 0, 0x33, 74, 0x0},
{ 0, 0x33, 60, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 53, 0x0},
{ 0, 0x33, 22, 0x0},
{ 0, 0x33, 10, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 0, 0x0},
{ 0, 0x33, 0, 0x0},
// 630: Local time: 01:12:00 AM
{ 0, 0x33, 0, 0x0},
{ 0, 0... | { 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
{ 0, 0x1b, 0, 0x0},
// 7... |
{ 0, 0x60, 0, 0x0},
{ 0, 0x60, 0, 0x0},
{ 0, 0x60, 28, 0x0},
{ 0, 0x60, 0, 0x0},
{ 0, 0x60, 0, 0x0},
{ 0, 0x6f, 113, 0x0},
{ 0, 0x6a, 1398, 0x0},
{ 0, 0x4a, 0, 0x0},
{ 0, 0x4a, 710, 0x0},
{ 0, 0x73, 518, 0x0},
{ 0, 0x73, 0, 0x0},
{ 0, 0x73, 0, 0x0},
{ 0, 0x73, 0, 0x0... |
e: 0x%"PRIx32, i->cookie);
// PBL_LOG(LOG_LEVEL_DEBUG, "Caller Number: %s", i->caller_number);
// PBL_LOG(LOG_LEVEL_DEBUG, "Caller Name: %s", i->caller_name);
}
static void prv_put_call_disconnect_event(void) {
PebbleEvent e = {
.type = PEBBLE_PHONE_EVENT,
.phone = {
.type = PhoneEventType_Disconne... | PBL_HEXDUMP(LOG_LEVEL_INFO, iter, length) | |
ime > state->start_recv_packet_time + QEMU_RECV_PACKET_TIMEOUT_SEC) {
state->recv_state = QemuRecvState_WaitingHdrSignatureMSB;
PBL_LOG(LOG_LEVEL_WARNING, "Resetting receive state - max packet time expired");
}
state->callback_pending = false;
uint16_t bytes_avail = shared_circular_buffer_get_read_space... | sizeof(footer), (uint8_t *)&footer, &bytes_read);
bytes_avail -= bytes_read;
footer.signature = ntohs(footer.signature);
if (footer.signature != QEMU_FOOTER_SIGNATURE) {
PBL_LOG(LOG_LEVEL_WARNING, "Invalid footer signature");
}
state->recv_st... | // switch()
} // while (!exit && bytes_avail)
// Return pointer if we got a complete message
if (got_msg) {
*msg_bytes= state->msg_buffer_bytes;
*protocol = state->hdr.protocol;
return state->msg_buffer;
} else {
return NULL;
}
}
// --------------------------------------------------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (flash_locked) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | RTC_WriteBackupRegister(REBOOT_REASON_DROPPED_EVENT, 0) | ;
}
uint32_t reboot_get_slot_of_last_launched_app(void) {
return RTC_ReadBackupRegister(SLOT_OF_LAST_LAUNCHED_APP);
}
void reboot_set_slot_of_last_launched_app(uint32_t app_slot) {
RTC_WriteBackupRegister(SLOT_OF_LAST_LAUNCHED_APP, app_slot);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | pra_generate(&payload.address) | ;
hc_protocol_enqueue_response(msg, (const uint8_t *)&payload, sizeof(payload));
break;
}
default:
PBL_LOG(LOG_LEVEL_ERROR, "HcGap: unhandled message id: %d", msg->command_id);
}
}
void hc_endpoint_gap_service_mtu_changed(const Connection *connection, uint16_t mtu) {
HcProtocol_GapService... |
ut_us = 500 * 1000;
InputConfig creset_input = {
.gpio = ICE40LP->creset.gpio,
.gpio_pin = ICE40LP->creset.gpio_pin,
};
while (timeout_us > 0) {
if (gpio_input_read(&creset_input) == level) return true;
delay_us(100);
timeout_us -= 100;
}
return false;
}
static bool prv_wait_programmed(vo... | if (ICE40LP->use_6v6_rail) {
PBL_LOG(LOG_LEVEL_DEBUG, "Enabling 6v6 (Display VDDC)");
set_6V6_power_state(true);
psleep(2);
} |
PBL_LOG(LOG_LEVEL_DEBUG, "Enabling 4v5 (Display VDDP)");
set_4V5_power_state(true);
}
void display_power_disable(void) {
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling 4v5 (Display VDDP)");
set_4V5_power_state(false);
psleep(2);
if (ICE40LP->use_6v6_rail) {
PBL_LOG(LOG_LEVEL_DEBUG, "Disabling 6v6 (Display VDD... |
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1421188000), 2);
}
void test_timeline__all_backwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNod... | (iter_prev(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[1].header.id));
#if !CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[2].header.id));
#endif
cl_assert(!iter_prev(&iterator));
}
void test_timeline__long_middle_future(void) {
... |
/*
* 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_p(strstr(testbuf, "l"), NULL) | ;
cl_assert_equal_p(strstr(testbuf, "He"), testbuf);
}
|
e"
static Uuid s_default_watchface = UUID_INVALID_INIT;
#define PREF_KEY_CONTENT_SIZE "contentSize"
static uint8_t s_content_size;
#if !UNITTEST
_Static_assert(sizeof(PreferredContentSize) == sizeof(s_content_size),
"sizeof(PreferredContentSize) grew, pref needs to be migrated!");
#endif
void shell_pre... | (&s_default_watchface) | ;
}
return app_id;
}
#else
AppInstallId watchface_get_default_install_id(void) {
return APP_ID_SDK;
}
void watchface_set_default_install_id(AppInstallId id) {
}
#endif
void system_theme_set_content_size(PreferredContentSize content_size) {
mutex_lock(s_mutex);
const uint8_t content_size_uint = content_size;... |
(install_id, &db_entry->uuid, app_upgrade, delete_cache) | ;
}
void app_install_clear_app_db(void) {
app_db_enumerate_entries(prv_enumerate_app_db_delete, NULL);
app_cache_flush();
}
| |
/*
* 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 (strcmp(node->func, func) == 0) {
break;
} | |
de "services/common/event_service.h"
#include "syscall/syscall_internal.h"
#include "syscall/syscall.h"
#include "system/logging.h"
#include "system/passert.h"
#include "FreeRTOS.h"
#include "queue.h"
#include <string.h>
typedef struct {
int num_subscribers;
QueueHandle_t subscribers[NumPebbleTask];
EventServi... | mutex_create() | ;
}
void event_service_init(PebbleEventType type, EventServiceAddSubscriberCallback add_subscriber_callback,
EventServiceRemoveSubscriberCallback remove_subscriber_callback) {
if(s_event_services[type] != NULL) {
// an event service was already inited, free it
kernel_free(s_event_services[type]);
}
... |
nds_utc(time_t now_utc, time_t *enter_utc,
time_t *exit_utc) {
// Get useful UTC times
time_t start_of_today_utc = time_util_get_midnight_of(now_utc);
int minute_of_day = time_util_get_minute_of_day(now_utc);
int last_sleep_second_of_day = ACTIVITY_LAST_SLEEP_MINU... | {
if (state->sleep_data.cur_state != ActivitySleepStateAwake) {
continue;
}
} | |
/*
* 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... | BITS_BETWEEN(0, 0) | , erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_16KB_sectors(void) {
cl_assert(system_flash_erase(FLASH_BASE, 48 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 2), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_sectors_1_thru_10(void) {
cl_assert(sy... |
ror_status) {
uint64_t elapsed = prv_get_time_ms() - data->start_ms;
const bool speech_detected = (data->speech_detected) || (elapsed < MIN_ELAPSED_DURATION);
data->error_count++;
if (data->show_error_dialog) {
if (error_status == VoiceStatusRecognizerResponseError) {
prv_show_error_dialog(data, i18... | {
VOICE_LOG("Silence detected");
prv_stop_dictation(data);
} |
if (event->type == VoiceEventTypeSpeechDetected) {
VOICE_LOG("Speech detected");
data->speech_detected = true;
}
if (event->type == VoiceEventTypeSessionResult) {
// Recording stopped by voice service, capture time recording
prv_update_analytics_metrics(data);
... |
ROR, "Stack overflow [task: %s]", name);
RebootReason reason = {
.code = RebootReasonCode_StackOverflow,
.data8[0] = task
};
reboot_reason_set(&reason);
reset_due_to_software_failure();
}
}
bool xApplicationIsAllowedToRaisePrivilege(uint32_t caller_pc) {
// This function is called by p... | mcu_cycles_to_milliseconds(s_analytics_device_sleep_cpu_cycles) | ;
analytics_set(ANALYTICS_DEVICE_METRIC_CPU_STOP_TIME, stop_ms, AnalyticsClient_System);
analytics_set(ANALYTICS_DEVICE_METRIC_CPU_SLEEP_TIME, sleep_ms, AnalyticsClient_System);
uint32_t now_ticks = rtc_get_ticks();
uint32_t ms_running =
ticks_to_milliseconds(now_ticks - s_last_ticks) - stop_ms - sleep_... |
cl_assert_equal_i(s_data.pins_added, 2) | ;
}
// ---------------------------------------------------------------------------------------
// This makes sure the sleep summary properly handles the midnight rollover for non-UTC timezones
// since when there's no sleep, the enter/exit times will be set to midnight UTC and the metrics
// will return that time in l... | |
/*
* 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... | (&data->window) | ;
PeekLayer *peek_layer = &data->peek_layer;
peek_layer_play(peek_layer);
layer_add_child(root_layer, (Layer *)peek_layer);
const int standing_ms = 1 * MS_PER_SECOND;
data->peek_layer_timer = evented_timer_register(PEEK_LAYER_UNFOLD_DURATION + standing_ms,
... |
req_state <= granted_state) {
prv_schedule_granted_handler(curr_request->granted_handler);
curr_request->granted_handler = NULL;
}
curr_request = (ConnectionStateRequest *)list_get_next(&curr_request->list_node);
}
}
static void prv_handle_response_latency_for_le_conn(GAPLEConnection *hdl) {
ui... | conn_mgr_set_ble_conn_response_time_ext(hdl, consumer, state, max_period_secs, NULL) | ;
}
void conn_mgr_set_ble_conn_response_time_ext(
GAPLEConnection *hdl, BtConsumer consumer, ResponseTimeState state,
uint16_t max_period_secs, ResponsivenessGrantedHandler granted_handler) {
ConnectionMgrInfo *conn_mgr_info;
if (!hdl || !((conn_mgr_info = hdl->conn_mgr_info))) {
PBL_LOG(LOG_LEVEL_ERRO... |
tracting the mantissa component
uint32_t fraction = div_temp - mantissa * DIV_PRECISION;
// convert the fractional component to be in terms of the number of samples (with rounding)
fraction = (fraction * samples + (DIV_PRECISION / 2)) / DIV_PRECISION;
if (over8) {
// 3 bits of fraction
dev->periph->BRR... | dma_request_get_current_data_counter(dev->rx_dma) | ;
// make sure we didn't underflow the index
PBL_ASSERTN(next_idx < dma_length);
while (dev->state->rx_dma_index != next_idx) {
const uint8_t data = dev->state->rx_dma_buffer[dev->state->rx_dma_index];
if (dev->state->rx_irq_handler(dev, data, &err_flags)) {
should_context_sw... |
);
}
left_margin = box.origin.x;
prv_draw_icon(ctx, config->icon, &box, is_legacy2);
}
box = *bounds;
if (icon_align == GAlignRight) {
left_margin = horizontal_margin;
box.size.w -= config->icon->bounds.size.w;
} else {
left_margin = !config->icon ? horizontal_margin :
config->... | prv_should_render_subtitle_round(config, is_selected) | ;
if (render_subtitle) {
subtitle_text_frame_height = fonts_get_font_height(subtitle_font);
}
const int subtitle_text_cap_offset =
(config->subtitle) ? fonts_get_font_cap_offset(subtitle_font) : 0;
const GAlign icon_align = (GAlign)config->icon_align;
const bool render_icon = ((config->icon != NULL... |
er->text) > 0) {
graphics_context_set_text_color(ctx, get_native_color(text_layer->text_color));
graphics_draw_text(ctx, text_layer->text, text_layer->font, text_layer->layer.bounds,
text_layer->overflow_mode, text_layer->text_alignment,
prv_text_layer_legacy2_get_c... | layer_mark_dirty(&(text_layer->layer)) | ;
}
void text_layer_legacy2_set_font(TextLayerLegacy2 *text_layer, GFont font) {
if (text_layer == NULL || font == text_layer->font) {
return;
}
text_layer->font = font;
layer_mark_dirty(&(text_layer->layer));
}
void text_layer_legacy2_set_should_cache_layout(TextLayerLegacy2 *text_layer,
... |
/*
* 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... | (1500 /* milliseconds */, handle_timer, (void *) &s_data.info[1]) | |
ectly
void test_animation__auto_destroy(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation *prop_h;
Layer layer;
GRect from_r;
GRect to_r;
const int duration = 100;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
memset(&layer, 0, sizeof(... | {
prv_add_handler_entry(&s_stopped_handler_calls, animation, finished, context);
animation_destroy(animation);
} |
// --------------------------------------------------------------------------------------
// Test that animation_destroy can be called from the stopped handler
static void prv_test_destroy_from_stopped_handler(bool auto_destroy) {
Animation *h;
const int duration = 100;
const AnimationHandlers handlers = {
... |
stmessageconnected_postmessagedisconnected_init(true /* start_connected */);
ASSERT_JS_GLOBAL_EQUALS_I("c", 0);
ASSERT_JS_GLOBAL_EQUALS_I("d", 1);
prv_postmessageconnected_postmessagedisconnected_negotiate_to_open_session();
ASSERT_JS_GLOBAL_EQUALS_I("c", 1);
ASSERT_JS_GLOBAL_EQUALS_I("d", 1);
}
// TODO: t... | prv_rcv_app_message_ack(APP_MSG_OK) | ;
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
ASSERT_JS_GLOBAL_EQUALS_B("hasError", false);
}
void test_rocky_api_app_message__post_message_single_chunk(void) {
prv_init_and_goto_session_open();
EXECUTE_SCRIPT("var x = " SIMPLE_TEST_OBJECT "; _rocky.postMessage(x);");
prv_assert_simple_test_object_pending();
p... |
952, -40, -248},
{ 888, -64, -272},
{ 848, -88, -296},
{ 856, -88, -320},
{ 920, -96, -360},
{ 984, -136, -416},
{ 1080, -152, -440},
{ 1040, -168, -488},
{ 992, -208, -488},
{ 944, -216, -464},
{ 952, -200, -408},
{ 928, -152, -360},
{ 928, -88, -360},
{ 888, -32, -3... | { 984, -16, -192},
{ 944, -56, -192},
{ 1200, -48, -136},
{ 1224, -24, -120},
{ 1120, -48, -88},
{ 1072, -40, -112},
{ 1048, -40, -128},
{ 1032, -32, -128},
{ 1032, -56, -192},
{ 984, -104, -216},
{ 952, -120, -248},
// 72 seconds
{ 920, -144, -248},
{ 920, -144, ... | |
-------------------------------
bool shared_circular_buffer_consume(SharedCircularBuffer* buffer, SharedCircularBufferClient *client, uint16_t length) {
PBL_ASSERTN(list_contains(buffer->clients, &client->list_node));
uint32_t data_length = prv_get_data_length(buffer, client);
if (data_length < length) {
retu... | if (client->numerator == client->denominator) {
num_items = MIN(num_items, bytes_available / item_size);
uint16_t bytes_out;
shared_circular_buffer_read_consume(
buffer, &client->buffer_client, num_items * item_size,
(uint8_t *)data, &bytes_out);
PBL_ASSERTN(bytes_out == num_items * item... | |
/*
* 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_will_return(process_manager_compiled_with_legacy2_sdk, true) | ;
layer_render_tree((Layer *)&layer, &ctx);
expected_rect = BITMAP_LAYER_BOUNDS;
cl_assert(grect_equal(&s_graphics_draw_bitmap_in_rect__rect, &expected_rect));
}
|
, RecognizerState_Started));
recognizer_transition_state(r, RecognizerState_Updated);
cl_assert_equal_i(r->state, RecognizerState_Updated);
cl_assert_equal_i(event_type, RecognizerEvent_Updated);
cl_assert(!s_manager_state_change);
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Failed));
... | cl_assert_equal_b(impl_destroyed, true) | |
t_event_handler(PebbleWorkoutEvent *event) {
if (!workout_service_is_workout_ongoing()) {
return;
}
// Handling this with an event because the timer needs to be called from KernelMain
if (event->type == PebbleWorkoutEvent_FrontendOpened) {
evented_timer_cancel(s_workout_data.current_workout->workout_ab... | activity_get_sessions(&num_sessions, sessions) | |
/*
* 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... | otp_is_locked(index) | |
prev_index, menu_layer->callback_context);
}
void prv_center_focus_animation_update_impl(Animation *animation,
bool second_half,
AnimationProgress adjusted_progress) {
CenterFocusSelectionAnimationState state = prv_center_foc... | prv_menu_layer_update_selection_highlight(menu_layer, up, selection_animated,
true /* change_ongoing_animation */) | ;
prv_menu_layer_update_selection_scroll_position(menu_layer, MenuRowAlignNone, selection_animated);
static const PropertyAnimationImplementation s_center_focus_selection_animation_in_out_impl = {
.base = {
.setup = prv_center_focus_animation_setup,
.update = prv_center_focus_animation_update_in_an... |
tatic void watchdog_timer_callback(void* data) {
task_watchdog_bit_set(PebbleTask_NewTimers);
}
static void vcom_timer_callback(void* data) {
display_pulse_vcom();
}
static void register_system_timers(void) {
static RegularTimerInfo watchdog_timer = { .list_node = { 0, 0 }, .cb = watchdog_timer_callback };
re... | init_drivers() | ;
#if defined(IS_BIGBOARD)
// Program a random S/N into the Bigboard in case it's not been done yet:
mfg_write_bigboard_serial_number();
#endif
#if defined(MANUFACTURING_FW)
mfg_info_update_constant_data();
#endif
debug_init(s_mcu_reboot_reason);
services_early_init();
debug_print_last_launched_app();
... |
this at duration past the previous start time
uint32_t new_start_time = animation->abs_start_time_ms + animation->duration_ms;
prv_unschedule_animation(state, animation, true /*finished */, false /*allow_destroy*/,
false /*force_destroy*/, false /*teardown*/);
prv_sched... | (state, animation, now, do_update) | ;
}
// Next one
animation = (AnimationPrivate *)state->aux->iter_next;
}
// If no blocked parents, we can exit right away
if (!have_blocked_parents) {
break;
}
}
// We are done iterating
state->aux->iter_next = NULL;
}
// -----------------------------------------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("-2147483648", NULL, 10) | , -2147483648); // last valid value
cl_assert_equal_i(strtol("3294967287", NULL, 10), INT_MAX); // signed integer overflow
cl_assert_equal_i(strtol("2147483648", NULL, 10), INT_MAX);
cl_assert_equal_i(strtol("-2147483649", NULL, 10), INT_MIN);
}
static const struct {
intmax_t value;
int base;
const char *s... |
pe != KinoReelTypePDCI)) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Invalid published icon type");
is_valid = false;
} else {
const size_t resource_size = kino_reel_get_data_size(reel);
if (resource_size == 0) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Cannot determine size for published icon");
is_valid = fal... | (timeline_res->app_id) | ;
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(install_id, &entry)) {
goto fail;
}
// Only try to load icon if app was built with an SDK that supports it
const Version first_pbw_icon_version = (Version) {
.major = TIMELINE_RESOURCE_PBW_SUPPORT_FIRST_SDK_VERSION_MAJOR... |
-136},
{ 968, 176, -168},
{ 832, 216, -232},
{ 928, 280, -192},
{ 1056, 264, -176},
{ 1200, 304, -200},
{ 1584, 392, -208},
{ 1624, 592, -168},
{ 1088, 536, -312},
{ 1512, 608, -376},
{ 1024, 616, -328},
{ 1136, 440, -224},
{ 1328, 400, -144},
{ 1272, 288, -72},
... | { 1712, 520, -184},
{ 1368, 624, -192},
{ 1016, 456, -264},
{ 1288, 768, -192},
{ 960, 752, -240},
{ 1072, 504, -248},
{ 1232, 552, -176},
{ 1400, 512, -80},
{ 1200, 264, 80},
{ 1152, 160, 0},
{ 1224, 200, -16},
{ 1312, 280, -24},
// 37 seconds
{ 1176, 200, -40},
... |
{ 1328, 160, -80},
{ 1272, 208, -64},
{ 968, 192, -144},
{ 1208, 200, -232},
{ 904, 144, -232},
{ 896, 136, -320},
{ 1080, 144, -336},
{ 1224, 160, -336},
{ 1024, 208, -296},
{ 864, 216, -280},
{ 928, 256, -248},
{ 1032, 288, -232},
{ 1120, 320, -232},
{ 1104, 34... |
/*
* 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... | layer_set_frame(&l, &GRect(10, 20, 100, 700)) | ;
cl_assert_equal_grect(l.bounds, GRect(0, 0, 150, 700));
}
|
ayer.layer,
.times_out = true,
.colors.foreground = dialog->text_color,
.colors.background = dialog->window.background_color,
});
layer_init(&expandable_dialog->content_down_arrow_layer, &GRect(
0, frame.size.h - CONTENT_DOWN_ARROW_HEIGHT,
... | (background_color) | );
dialog_set_callbacks(dialog, callbacks, dialog);
}
return expandable_dialog;
}
void expandable_dialog_show_action_bar(ExpandableDialog *expandable_dialog,
bool show_action_bar) {
expandable_dialog->show_action_bar = show_action_bar;
}
void expandable_dialog_set_acti... |
/*
* 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... | (global_lock) | ;
}
static inline void __attribute__((always_inline)) lock_wrap() {
locker();
if (decision()) {
unlocker();
}
}
static inline void __attribute__((always_inline)) unlock_wrap() {
unlocker();
}
void lockme() {
lock_wrap();
unlock_wrap();
}
|
_value_boundaries(values, ARRAY_LENGTH(values), &range);
cl_assert_equal_i(values[0], 4 * 1000 / 5);
cl_assert_equal_i(values[1], 1000);
cl_assert_equal_i(values[2], 1000 / 10);
// ensure we don't calculate a single day multiple times
values[0] = 1000;
values[2] = 1000;
range.num_days = 1;
prv_adjust_v... | health_service_metric_accessible(HealthMetricStepCount, now - 10, now + 20) | ;
cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskAvailable);
// if all values are -1, data is not available
s_sys_activity_get_metric_values.out.history[0] = -1;
s_sys_activity_get_metric_values.out.history[1] = -1;
accessible = health_service_metric_accessible(HealthMetricStepCount,
... |
imation *animation_h,
const AnimationImplementation *implementation) {
AnimationPrivate *animation = (AnimationPrivate *)animation_h;
if (!animation) {
return false;
}
animation->implementation = implementation;
return true;
}
bool animation_is_scheduled(Animation *anima... | {
ListNode *iter = s_animations;
while (iter) {
ListNode *current = iter;
iter = iter->next;
free(current);
}
s_animations = NULL;
} |
void fake_animation_complete(Animation *animation) {
animation_schedule(animation);
const uint32_t duration =
animation_get_duration(animation, false /* delay */, true /* play_count */);
animation_set_elapsed(animation, duration);
animation_unschedule(animation);
}
|
ata->stroke_width);
graphics_draw_line(ctx, p0, p1);
graphics_draw_line(ctx, p2, p3);
return;
}
if (data->operation == OP_TEST3) {
int x1 = 50,
x2 = 100,
y1 = 40,
y2 = 120;
GPoint p0 = GPoint(x1, y1);
GPoint p1 = GPoint(x1, y2);
GPoint p2 = GPoint(x2, y2);
GPoint p3 = ... | graphics_line_draw_precise_stroked_non_aa(ctx, p0, p1, data->stroke_width);
} else {
graphics_draw_line(ctx, GPoint(p0.x.integer, p0.y.integer),
GPoint(p1.x.integer, p1.y.integer));
}
return;
}
int x1, y1, x2, y2;
if (data->operation == OP_ROTATE) {
int line... |
static void main_window_load(Window *window) {
AppData *data = window_get_user_data(s_window);
Layer *window_layer = window_get_root_layer(window);
window_set_background_color(window, GColorBlack);
GRect window_bounds = window_layer->bounds;
data->debug_layer = layer_create(window_bounds);
layer_set_upda... |
g_page; pg++) {
PageHeader hdr;
// read version first, check magic, then check version and make sure it makes sense
prv_flash_read((uint8_t *)&hdr.version, sizeof(hdr.version),
prv_page_to_flash_offset(pg) + offsetof(PageHeader, version));
if ((hdr.version >> 8) != PFS_MAGIC) {
continue... | mutex_lock_recursive(s_pfs_mutex) | ;
PFSFileChangedCallbackNode *node = kernel_malloc_check(sizeof(PFSFileChangedCallbackNode));
*node = (PFSFileChangedCallbackNode) {
.callback = callback,
.event_flags = event_flags,
.data = data
};
// find out if we already have a string for this particular filename
ListNode *find_str = list_fi... |
t_switch = event_put_isr(&e);
}
//! Move the mag into standby mode, which is a low power mode where we're not actively sampling
//! the sensor or firing interrupts.
static bool prv_enter_standby_mode(void) {
// Ask to enter standby mode
if (!mag3110_write(CTRL_REG1, 0x00)) {
return false;
}
// Wait for th... | align_coord_system(2, &raw_data[1]) | ;
done:
mutex_unlock(s_mag_mutex);
return (rv);
}
bool mag_change_sample_rate(MagSampleRate rate) {
mutex_lock(s_mag_mutex);
if (s_use_refcount == 0) {
mutex_unlock(s_mag_mutex);
return (true);
}
bool success = false;
// Enter standby state since we can only change sample rate in this mode.
... |
w_horizontal_line_dotted(&ctx, GPoint(0, 21), MAX_NUM_COLS - 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 23), MAX_NUM_COLS + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_odd_offset_odd_rows_no_clip")));
// Test to make sure drawing on all rows cre... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_odd_cols_no_clip"))) | ;
// Test to make sure drawing on all cols creates checkerboard pattern
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx... |
&session->node));
if (session->temp_write_buffer) {
kernel_free(session->temp_write_buffer);
}
list_remove(&session->node, (ListNode **) &s_session_head, NULL);
kernel_free(session);
++s_session_close_call_count;
}
void comm_session_receive_router_write(CommSession *session,
... | {
max_length = session->send_buffer.buffer_size - sizeof(PebbleProtocolHeader);
} | |
/*
* 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... | {
entry->store_data = &g_builtin_resources[i];
return true;
} |
}
return false;
}
static bool resource_storage_builtin_get_resource(ResourceStoreEntry *entry) {
const BuiltInResourceData *builtin = entry->store_data;
if (!builtin) {
return false;
}
entry->offset = 0;
entry->length = builtin->num_bytes;
return true;
}
bool resource_storage_builtin_check(ResApp... |
/*
* 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... | (clock_cmd) | );
#endif
portENTER_CRITICAL();
clock_cmd(rcc_bit, ENABLE);
portEXIT_CRITICAL();
}
void periph_config_disable(void *periph, uint32_t rcc_bit) {
ClockCmd clock_cmd = prv_get_clock_cmd((uintptr_t)periph);
#if PERIPH_CONFIG_DEBUG
if (prv_string_for_cmd(clock_cmd))
PERIPH_CONFIG_LOG("Disabling clock %s", prv... |
it as simple as possible. In
//! addition we want the flexibility to be able to reset the flash driver to
//! get it into a working state
static void prv_flash_start_cmd(void) {
GPIO_ResetBits(FLASH_GPIO, FLASH_PIN_SCS);
}
static void prv_flash_end_cmd(void) {
GPIO_SetBits(FLASH_GPIO, FLASH_PIN_SCS);
// 50ns ... | (start_addr) | ;
while (buffer_size--) {
*buffer = prv_flash_read_next_byte();
buffer++;
}
prv_flash_end_cmd();
}
uint32_t cd_flash_write_bytes(const void* buffer_ptr, uint32_t start_addr, uint32_t buffer_size) {
CD_ASSERTN((start_addr + buffer_size <= CORE_DUMP_FLASH_END) &&
(int)start_addr >= CORE_DUMP_FLASH... |
onnection = {
.bt_device_bits = device->opaque.opaque_64,
.hci_reason = hci_reason,
.connected = connected,
.bonding_id = bonding_id,
},
},
},
};
event_put(&pebble_event);
}
// --------------------------------------------------------------------------------... | prv_is_intent_used(intent) | |
(s_count_animation_destroy, 1) | ;
// Throughout pushing this modal the app never reported it was ready, so we still shouldn't have
// rendered from the app frame buffer.
cl_assert_equal_i(s_app_window_render_count, 0);
// Now the app has rendered something and we should actually update the display.
compositor_app_render_ready();
cl_asse... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gbitmap_create_blank(s10, GBitmapFormat8Bit) | ;
cl_assert(NULL != bmp);
cl_assert(NULL == bmp->data_row_infos);
bmp = gbitmap_create_blank(s10, GBitmapFormat1BitPalette);
cl_assert(NULL != bmp);
cl_assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette
bmp = gbitmap_create_blank(s10, GBitmapFormat2BitPalette);
cl_a... |
omm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
max_payload_length /* required_free_length */,
TIMEOUT_MS);
uint8_t fake_data_payload[max_payload_length];
for (int i = 0; i < max_... | (write_sb) | ;
}
|
system(res_info->res_app_num, res_info->res_id);
}
static void prv_init_icon(TimelineLayout *timeline_layout, const GRect *icon_frame,
TimelineResourceSize icon_res_size, TimelineResourceId resource,
TimelineResourceId fallback_resource, const Uuid *app_id) {
KinoR... | prv_create_pin_view_node(layout) | ;
break;
case LayoutLayerModeNone:
case NumLayoutLayerModes:
break;
}
layout->view_node = view_node;
timeline_layout_get_size(layout, graphics_context_get_current_context(), &layout->view_size);
}
void timeline_layout_deinit_view(TimelineLayout *layout) {
if (layout->layout_layer.mode == La... |
ash_addr() + offset, field_size);
cleanup:
prv_dealloc_struct(data);
}
static void prv_erase_field(size_t offset, size_t field_size) {
SharedPRFData *data = prv_alloc_and_fetch_struct();
uint8_t *field_ptr = ((uint8_t *)data) + offset;
memset(field_ptr, 0xFF, field_size);
prv_persist_field(field_ptr, offset... | {
bool rv;
prv_lock();
{
SprfRootKeys data;
rv = SPRF_FETCH_FIELD(data, root_keys);
if (!rv) {
goto unlock;
}
SM128BitKey nil_key = {};
if (0 == memcmp(&nil_key, &data.keys[key_type], sizeof(nil_key))) {
rv = false;
goto unlock;
}
if (key_out) {
memcpy(key_... | |
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 146},
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 146},
// 495: Local time: 02:50:00 AM
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 150},... | { 0, 0x69, 2111, 145},
{ 0, 0x5a, 20, 148},
{ 0, 0x5a, 206, 152},
{ 0, 0x5a, 5, 152},
{ 0, 0x5a, 0, 152},
{ 0, 0x49, 481, 146},
// 615: Local time: 04:51:00 AM
{ 0, 0x49, 0, 150},
{ 0, 0x49, 0, 150},
{ 0, 0x49, 0, 150},
{ 0, 0x49, 0, 151},
{ 0, 0x49, 0, 152},
{ 0, 0x4... | |
C
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distrib... | integer_sqrt(delta_x * delta_x + delta_y * delta_y) | ;
if (!magnitude) {
return bounce_offset;
}
bounce_offset.x = bounce * delta_x / magnitude;
bounce_offset.y = bounce * delta_y / magnitude;
return bounce_offset;
}
static const TransformImpl SCALE_SEGMENTED_TRANSFORM_IMPL = {
.destructor = prv_destructor,
.apply = prv_apply_transform,
};
KinoReel *... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&rcc_clocks) | |
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 2);
... | prv_last_update_distance(b) | ;
cl_assert_equal_i(distance, ANIMATION_NORMALIZED_MIN);
#endif
}
// --------------------------------------------------------------------------------------
// Test cloning complex animation
void test_animation__complex_clone(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b =... |
8_t *serialized_glance = kernel_zalloc((size_t)serialized_glance_size);
if (!serialized_glance) {
return E_OUT_OF_MEMORY;
}
status_t rv = app_glance_db_read(key, key_size, serialized_glance, serialized_glance_size);
if (rv != S_SUCCESS) {
goto cleanup;
}
rv = prv_deserialize_glance((SerializedAppG... | {
PBL_LOG(LOG_LEVEL_WARNING,
"Tried to insert AppGlanceDB entry but failed to iterate over the serialized slices");
return E_INVALID_ARGUMENT;
} | else if (validation_context.is_at_least_one_slice_invalid) {
PBL_LOG(LOG_LEVEL_WARNING,
"Tried to insert AppGlanceDB entry with at least one invalid slice");
return E_INVALID_ARGUMENT;
}
// Trim the serialized glance of excess slices by shrinking `val_len` to `validated_size`
// We do this i... |
ASSERT_CALLED(graphics_line_draw_stroked_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN));
#else
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN));
#endif
setup_test(&context, true, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRec... | graphics_fill_circle(&context, GPoint(50, 50), 10) | ;
#if PBL_COLOR
ASSERT_CALLED(graphics_internal_circle_quadrant_fill_aa(&context, GPoint(50, 50), 10, GCornersAll));
#else
ASSERT_CALLED(graphics_circle_fill_non_aa(&context, GPoint(50, 50), 10));
#endif
setup_test(&context, true, 5, GColorBlack, GColorBlack, false);
graphics_fill_round_rect(&context, &GRect(2... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
buf[buf_idx++] = d[i];
prv_put_byte_hdlc(d[i]);
buf[buf_idx++] = d[i + 1];
prv_put_byte_hdlc(d[i + 1]);
} |
}
uint32_t crc = legacy_defective_checksum_memory(buf, num_bytes);
prv_put_byte_hdlc((uint8_t) crc);
prv_put_byte_hdlc((uint8_t) (crc >> 8));
prv_put_byte_hdlc((uint8_t) (crc >> 16));
prv_put_byte_hdlc((uint8_t) (crc >> 24));
prv_put_hdlc_frame_delimiter();
}
if (s_timeout == 0) {
... |
;
// Only 1 pin should be added (for Friday)
cl_assert_equal_i(s_num_timeline_adds, 1);
}
void test_alarm__recurring_weekday_alarm(void) {
AlarmId id1, id2;
id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKDAYS });
prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_WEEKD... | cron_service_wakeup() | ;
cl_assert_equal_i(s_num_alarms_fired, 1);
prv_assert_alarm_config(id1, 10, 30, true, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 4);
cl_assert_equal_i(s_num_timeline_removes, 2);
cl_assert_equal_i(s_last_timeline_... |
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r6_aa_no_clip.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix left corners PBL-15915
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 7, GCornersAll);
cl_check(gbitmap_pbi_... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax2_aa_clip_xy.${BIT_DEPTH_NAME}.pbi")) | ;
#endif
// AA = true, SW has no effect, Clip NXNY, all corners
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY , ORIGIN_RECT_CLIP_NXNY , true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY , 0, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r0_aa_clip_nxny.${BIT_DE... |
/*
* 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_ASSERTN((region->cache_policy != MpuCachePolicy_Invalid) &&
(region->cache_policy < MpuCachePolicyNum)) | ;
// MPU Region Base Address Register
// | Addr (27 bits) | Region Valid Bit | Region Num (4 bits) |
// The address is unshifted, we take the top bits of the address and assume everything below
// is zero, since the address must be power of 2 size aligned.
*base_address_reg = region->base_address |
... |
us_inner = radius_inner,
.fill_radial_precise.radius_outer = radius_outer,
.fill_radial_precise.angle_start = angle_start,
.fill_radial_precise.angle_end = angle_end,
};
}
void graphics_fill_round_rect_by_value(GContext *ctx, GRect rect, uint16_t corner_radius,
GCo... | cl_assert_equal_i(0, s_graphics_text_attributes_destroy.call_count) | ;
rocky_global_init(s_graphics_api);
cl_assert_equal_i(1, s_fonts_get_system_font.call_count);
cl_assert_equal_i(0, s_graphics_text_attributes_destroy.call_count);
rocky_global_deinit();
cl_assert_equal_i(1, s_fonts_get_system_font.call_count);
cl_assert_equal_i(0, s_graphics_text_attributes_destroy.call_co... |
ck_push(window2, true);
cl_assert_equal_i(app_window_stack_count(), 2);
cl_assert_equal_i(window1->on_screen, false);
cl_assert_equal_i(window2->on_screen, true);
app_window_stack_pop(true);
cl_assert_equal_i(window1->on_screen, true);
cl_assert_equal_i(window2->on_screen, false);
app_window_stack_pop... | window_set_window_handlers(window, &(WindowHandlers){
.load = prv_push_window_load,
.unload = prv_window_unload,
.appear = prv_window_appear,
.disappear = prv_window_disappear
}) | ;
WindowStack *stack = app_state_get_window_stack();
// Switch to the app state to push a window
stub_pebble_tasks_set_current(PebbleTask_App);
cl_check(stack);
cl_assert_equal_i(window_stack_count(stack), 0);
window_stack_push(stack, window, true);
cl_assert_equal_i(window_stack_count(stack), 2);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.