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 (__builtin_floor(d) == d) {
return d;
} |
double half;
if (d < 0.0) {
if (d > -0.5) {
return -0.0;
} else {
half = -0.5;
}
} else {
half = 0.5;
}
return __builtin_floor(d + half);
}
|
0x21, 0x22, 0x13, 0x14, 0x15, 0x26
},
},
.is_classic = false,
.is_random_address = false,
},
.is_remote_identity_info_valid = true,
};
prv_reset_change_op_tracking();
BTBondingID id_2 = bt_persistent_storage_store_ble_pairing(&pairing_2, tr... | cl_assert_equal_m(&irk_out, &pairing.irk, sizeof(irk_out)) | |
{ 952, -40, 80},
{ 1336, -136, 120},
{ 1488, 112, -128},
{ 1320, 256, -272},
{ 1424, 488, -344},
{ 1424, 592, -88},
{ 1240, 224, -64},
{ 952, 232, -152},
{ 776, 264, -88},
{ 744, 288, -96},
{ 792, 336, -80},
{ 920, 408, -88},
{ 960, 392, -88},
{ 1104, 400, -120},
... | { 872, 264, 112},
{ 864, 256, 128},
{ 872, 224, 152},
{ 840, 184, 160},
{ 832, 216, 112},
{ 880, 168, 128},
{ 1048, 168, 88},
{ 1112, 176, 32},
{ 1360, -8, 96},
{ 1544, 232, -96},
{ 1088, 360, -344},
{ 1056, 344, -312},
{ 1360, 456, -320},
{ 1320, 424, -144},
... |
{ 1344, 392, -352},
// 38 seconds
{ 1440, 584, -288},
{ 1208, 352, -72},
{ 952, 296, -72},
{ 784, 288, -16},
{ 680, 336, -16},
{ 696, 384, -32},
{ 824, 376, 0},
{ 968, 384, -32},
{ 1080, 376, -32},
{ 1312, 408, -120},
{ 1360, 344, -40},
{ 1664, 352, -56},
{ 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... | reminder_db_insert_item(reminder) | ;
return rv;
}
status_t reminders_init(void) {
if (s_reminder_timer) {
new_timer_delete(s_reminder_timer);
}
s_reminder_timer = new_timer_create();
if (s_reminder_timer == TIMER_INVALID_ID) {
return E_ERROR;
} else {
return reminders_update_timer();
}
}
status_t reminders_delete(ReminderId *... |
/*
* 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... | {
swap16(&p0.x, &p1.x);
swap16(&p0.y, &p1.y);
} |
int dx = p1.x - p0.x;
int dy = abs(p1.y - p0.y);
int16_t err = dx / 2;
int16_t ystep;
if (p0.y < p1.y) {
ystep = 1;
} else {
ystep = -1;
}
for (; p0.x <= p1.x; p0.x++) {
if (steep) {
graphics_private_set_pixel(ctx, GPoint(p0.y, p0.x));
} else {
graphics_private_set_pixel... |
onEvent) {
.is_system = true,
.is_open = app_connected,
}
};
prv_handle_mobile_app_event(&comm_session_event, NULL);
}
static void prv_put_phone_event(PhoneEventType type, PhoneCallSource source,
uint32_t call_identifier) {
PebbleEvent phone_event = {
.type = P... | (PhoneEventType_End) | ;
}
// ---------------------------------------------------------------------------------------
// Basic test for incoming calls on iOS 9 and up
void test_phone_call__ancs_incoming(void) {
// We should allow incoming calls with or without a mobile app on iOS 9
prv_put_incoming_call_event(PhoneCallSource_ANCS, fals... |
ndle_battery_state_change_event(PreciseBatteryChargeState new_state) {
if (new_state.is_plugged) {
s_charger_plugged = true;
s_current_cal_status = CompassStatusDataInvalid;
memset(s_active_corr, 0x00, sizeof(s_active_corr));
prv_reset_saved_sample();
} else if (s_charger_plugged) {
// we have u... | if (s_high_freq_calib_active) {
prv_calibration_time_expired_cb(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... | {
bus->busy = true;
volatile uint32_t timeout_attempts = I2C_TIMEOUT_ATTEMPTS_MAX;
while ((timeout_attempts-- > 0) && (bus->busy)) {};
bus->busy = false;
return (timeout_attempts != 0);
} |
static void prv_semaphore_give(I2CBusState *bus) {
bus->busy = false;
}
static void prv_semaphore_give_from_isr(I2CBusState *bus) {
bus->busy = false;
return;
}
/*-------------------BUS/PIN CONFIG FUNCTIONS--------------------------*/
static void prv_rail_ctl(I2CBus *bus, bool enable) {
bus->rail_ctl_fn(bu... |
rnersTop);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_offset_r8_quads_top.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_circle_quadrant_draw_1px_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, GCornersBottom);
cl_check(gbitmap_... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_clear.8bit.pbi")) | ;
#else
cl_check(framebuffer_is_empty("clear_over_black", ctx.parent_framebuffer, GColorWhite));
#endif
}
// Draws circles in a grid pattern while increasing the stroke width for each circle
static void prv_draw_circles(GContext *ctx) {
GPoint pt = CENTER_OF_ORIGIN_RECT;
for (int sw = 0; sw <= 10; sw++) {
ct... |
TouchEventContext ctx = {
.idx = 0
};
touch_dispatch_touch_events(0, prv_touch_event_dispatch_cb, &ctx);
cl_assert_equal_i(ctx.idx, 0);
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_handle_update(0, TouchState_FingerDown, &GPoint(15, 15), 6, 3686440);
touch_handle_up... | touch_handle_driver_event(TouchDriverEvent_PalmDetect) | ;
// Cancelled event, followed by a palm detection event
cl_assert_equal_i(s_expected_palm_events[0].type, PEBBLE_TOUCH_EVENT);
cl_assert_equal_i(s_expected_palm_events[0].touch.type, PebbleTouchEvent_TouchesCancelled);
cl_assert_equal_i(s_expected_palm_events[1].type, PEBBLE_TOUCH_EVENT);
cl_assert_equal_i(... |
-968},
{ -176, 480, -872},
{ -200, 360, -896},
{ -168, 496, -944},
{ -192, 336, -952},
{ -200, 480, -896},
{ -160, 320, -992},
// 147 seconds
{ -184, 416, -896},
{ -176, 368, -992},
{ -168, 440, -872},
{ -160, 344, -976},
{ -144, 464, -896},
{ -184, 344, -944},
{ ... | { -152, 344, -888},
{ -152, 288, -872},
{ -136, 296, -936},
{ -112, 368, -944},
{ -136, 384, -984},
{ -112, 488, -1048},
{ -160, 312, -848},
{ -88, 408, -1064},
{ -176, 296, -920},
{ -136, 400, -1096},
{ -208, 392, -992},
{ -208, 440, -928},
{ -104, 376, -960},
{ ... |
{ -104, 416, -976},
{ -168, 360, -944},
{ -184, 432, -944},
{ -152, 440, -1072},
{ -192, 352, -952},
{ -168, 440, -1064},
{ -128, 368, -992},
{ -192, 304, -1016},
{ -200, 464, -1048},
{ -208, 392, -864},
{ -168, 408, -992},
// 155 seconds
{ -192, 376, -864},
{ -1... |
, message_p, message_size);
break;
case JERRY_ERROR_REFERENCE:
error_ref = JERRY_ERROR(ReferenceError, message_p, message_size);
break;
case JERRY_ERROR_SYNTAX:
error_ref = JERRY_ERROR(SyntaxError, message_p, message_size);
break;
case JERRY_ERROR_TYPE:
error_ref = JERRY_... | {
if (!jerry_value_is_object(obj_val) || !jerry_value_is_string(prop_name_val)) {
return TYPE_ERROR_ARG;
}
return (jerry_value_t)EM_ASM_INT({
var obj = __jerryRefs.get($0);
var name = __jerryRefs.get($1);
return __jerryRefs.ref(obj[name]);
}, obj_val, prop_name_val);
} | |
ine_dotted(&ctx, GPoint(0, 0), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 2), MAX_NUM_COLS + 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 4), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 6), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 8), 2);
graph... | (&ctx, GPoint(4, 0), 0) | ;
graphics_draw_vertical_line_dotted(&ctx, GPoint(6, 0), 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(8, 0), 2);
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 0), 3);
graphics_draw_vertical_line_dotted(&ctx, GPoint(12, 0), 4);
graphics_draw_vertical_line_dotted(&ctx, GPoint(14, 0), 20);
graphic... |
notification_storage_set_status(const Uuid *id, uint8_t status) {
}
void notifications_handle_notification_acted_upon(Uuid *notification_id) {
return;
}
// Data
/////////////////////////
static TimelineItem s_items[] = {
{
.header = { // [0]
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
... | cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0) | ;
}
void test_timeline_model__cleanup(void) {
}
// Tests
///////////////////////////
static int s_correct_order[] = {0, 4, 5, 2, 1, 3};
void test_timeline_model__future(void) {
TimelineModel model = {0};
model.direction = TimelineIterDirectionFuture;
time_t first_time = 1421178000;
// Note: 1421178000 = Tue... |
unk->offset_bytes) {
PBL_LOG(LOG_LEVEL_ERROR,
"Chunk reassembly out of sync! received_size_bytes=%"PRIu32", offset_bytes=%"PRIu32,
(uint32_t) s_state.in.received_size_bytes, (uint32_t) chunk->offset_bytes);
return false;
}
if (s_state.in.received_size_bytes + payload_size... | {
prv_control_message_queue_send_head();
} | else if ((s_state.state == PostMessageStateSessionOpen) &&
s_state.out.object_queue) {
prv_object_queue_send_current_chunk();
}
}
static void prv_outbox_try_send_next_timer_cb(void *unused) {
s_state.out.app_msg_retry_timer = EVENTED_TIMER_INVALID_ID;
prv_outbox_try_send_next();
}
static void ... |
FY_TIMEOUT, prv_notify_timeout, NULL, 0));
}
}
bool smartstrap_handle_break_from_isr(void) {
// NOTE: THIS IS RUN WITHIN AN ISR
bool should_context_switch = false;
// we should only accept notifications if we're in the ReadReady state
if (smartstrap_fsm_state_test_and_set(SmartstrapStateReadReady,
... | prv_reset_read_info() | |
// we only care about pins
return;
}
BlobDBEventType type = blobdb_event->type;
Uuid *id = (Uuid *)blobdb_event->key;
if (type == BlobDBEventTypeDelete) {
if (uuid_equal(id, &s_activity_pin_state.uuid)) {
s_activity_pin_state.removed = true;
} else if (uuid_equal(id, &s_sleep_pin_state.uui... | {
time_t now_utc = rtc_get_time();
int minute_of_day = (20 * MINUTES_PER_HOUR) + 30; // Activity pins only trigger after 8:30
Uuid uuid_way_below = UUID_INVALID;
Uuid uuid_below = UUID_INVALID;
Uuid uuid = UUID_INVALID;
Uuid uuid_above = UUID_INVALID;
prv_push_activity_summary_pin(now_utc, now_utc, minu... |
prv_push_sleep_summary_pin(now_utc, exit_utc, enter_seconds, exit_seconds,
total_seconds + deviate_seconds, total_seconds, &uuid);
uuid = UUID_INVALID;
prv_push_sleep_summary_pin(now_utc, exit_utc, enter_seconds, exit_seconds,
total_seconds, total_seconds... |
ne_draw_precise_stroked_non_aa(&ctx, START_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_origin_layer_non_aa.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 10);
graphics_line_draw_precise_strok... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_same_point_offset_layer_non_aa.${BIT_DEPTH_NAME}.pbi")) | ;
}
#define COLOR_START_POINT GPointPrecise(5, 35)
#define COLOR_END_POINT GPointPrecise(45, 40)
void test_graphics_draw_stroke_${BIT_DEPTH_NAME}__color(void) {
// TODO: Fix blending and reenable this - PBL-16509
/*
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, OFFSET_R... |
/*
* 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... | {
ADCVoltageMonitorReading reading = {
.vref_total = prv_convert_millivolts_to_12bit_reading(VREF_VOLTAGE),
.vmon_total = prv_convert_millivolts_to_12bit_reading(1800)
};
uint32_t result = battery_convert_reading_to_millivolts(reading, 1, 1);
cl_assert_equal_i(result, 1800);
reading.vmon_total = prv... |
void test_battery__reading_conversion_40_samples(void) {
ADCVoltageMonitorReading reading = {
.vref_total = prv_convert_millivolts_to_12bit_reading(VREF_VOLTAGE) * 40,
.vmon_total = prv_convert_millivolts_to_12bit_reading(1800) * 40
};
uint32_t result = battery_convert_reading_to_millivolts(reading, 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... | cl_assert(get_pref == get_value) | ;
// Set new value using the set call and read it back using prefs_db
uint32_t new_set_value = 4242;
backlight_set_timeout_ms(new_set_value);
cl_assert_equal_i(prefs_db_read((uint8_t *)key, key_len, (uint8_t *)&get_value,
sizeof(get_value)), 0);
cl_assert_equal_i(new_set_va... |
eof("00:00:00");
GTextNodeText *number_text_node = health_util_create_text_node(buffer_size, number_font,
TEXT_COLOR, container);
active_window->workout_controller->metric_to_string(metric_type,
(char *)number_text_node->text, bu... | {
if (render) {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
graphics_draw_bitmap_in_rect(ctx, icon, rect);
}
if (size_out) {
*size_out = rect->size;
}
} |
static void prv_draw_heart_node_callback(GContext *ctx, const GRect *box,
const GTextNodeDrawConfig *config, bool render,
GSize *size_out, void *user_data) {
WorkoutActiveWindow *active_window = user_data;
GRect bounds = gbitmap_get... |
/*
* 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... | CREATE_DMA_STREAM(1, 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... | jerry_get_object_field(rocky, "_listeners") | ;
JS_VAR event_listeners = jerry_get_object_field(all_listeners, event_name);
// printf("event_listeners.refcount: %d", jerry_port_)
const uint32_t len = jerry_get_array_length(event_listeners);
for (uint32_t idx = 0; idx < len; idx++) {
JS_VAR listener = jerry_get_property_by_index(event_listeners, idx);
... |
action);
return postpone_level;
}
void timeline_actions_add_action_to_root_level(TimelineItemAction *action,
ActionMenuLevel *root_level) {
const char *label = attribute_get_string(&action->attr_list, AttributeIdTitle, "[Action]");
if (action-... | if (!data) {
return;
} |
data->action_menu = action_menu;
analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_DISMISS_ALL_COUNT, AnalyticsClient_System);
data->action_complete.callback = dismiss_all_complete_callback;
data->action_complete.callback_data = dismiss_all_cb_data;
// When performing a bulk request (dismiss all) errors ... |
/*
* 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... | IWDG_SetPrescaler(IWDG_Prescaler_64) | |
{
syscall_internal_elevate_privilege();
char * new = buf;
do_stuff(new, size);
} |
void malloc_syscall() {
syscall_internal_elevate_privilege();
void *buf = app_malloc(5);
syscall_assert_userspace_buffer(buf, 5);
do_stuff(buf, 5);
}
| |
(&event_blob) | ;
#endif
}
static void prv_int_exti_cb(bool *should_context_switch) {
// The controller responded -- stop the watchdog.
prv_watchdog_stop();
switch (s_spi_transport.state) {
case SPITransportState_Idle:
// If the RX buffer is full, defer ack'ing the Dialog INT until we have
// some room to actua... | |
0 AM
{ 0, 0x9, 0, 148, 1},
{ 0, 0x1b, 218, 148, 1},
{ 0, 0x1c, 168, 138, 1},
{ 0, 0x1c, 0, 139, 1},
{ 0, 0x1c, 39, 150, 1},
{ 0, 0x1c, 3, 149, 1},
{ 0, 0x1c, 0, 149, 1},
{ 0, 0x1c, 0, 149, 1},
{ 0, 0x1c, 0, 149, 1},
{ 0, 0x1c, 0, 147, 1},
{ 0, 0x1c, 0, 149, 1},
{ 0, 0x1c,... | { 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 147, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 150, 1},
{ 0, 0x62, 0, 147, 1},
// 450: Local time: 02:05:00 AM
{ 0, 0x6f, 1170, 150, 1},
{ 0, 0x... |
// 495: Local time: 02:50:00 AM
{ 0, 0x1e, 0, 150, 1},
{ 0, 0x1e, 0, 150, 1},
{ 0, 0x1e, 0, 150, 1},
{ 0, 0x1e, 0, 149, 1},
{ 0, 0x1e, 0, 147, 1},
{ 0, 0x1e, 37, 140, 1},
{ 0, 0x1e, 0, 140, 1},
{ 0, 0x1e, 0, 150, 1},
{ 0, 0x1e, 0, 149, 1},
{ 0, 0x1e, 0, 146, 1},
{ 0, 0x2... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_DEBUG, "Task %s stack has %d bytes free", pcTaskGetTaskName(task),
((int)uxTaskGetStackHighWaterMark(task) * sizeof(StackType_t))) | ;
}
}
}
DialogTask task_get_dialogtask(void) {
if (mcu_state_is_isr()) {
return DialogTask_ISR;
}
return task_to_dialogtask(xTaskGetCurrentTaskHandle());
}
void task_unregister_task(OS_TASK task) {
DialogTask index = task_to_dialogtask(task);
if (index >= DialogTask_Last) {
return;
}
Dialo... |
t op_flags) {
notification_storage_lock();
int fd = pfs_open(FILENAME, op_flags, FILE_TYPE_STATIC, NOTIFICATION_STORAGE_FILE_SIZE);
if (fd < 0) {
// If a write operation or a read operation fails with anything other than "does not exist",
// log error
bool read_only =
((op_flags & (OP_FLAG_WRI... | pfs_open(FILENAME, OP_FLAG_OVERWRITE, FILE_TYPE_STATIC,
NOTIFICATION_STORAGE_FILE_SIZE) | ;
if (new_fd < 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Error opening new file for compression %d", new_fd);
return false;
}
// Delete old notifications if there is no space left in storage
size_t size_available;
if (prv_is_storage_full(size_needed, &size_available, *fd)) {
pfs_seek(*fd, 0, FSeekSet);
... |
, false, false, 0x5 },
{ true, false, true, false, 0x6 },
{ true, false, true, false, 0x7 } // Both 0x6 and 0x7 map to the same permissions.
};
static const uint32_t s_cache_settings[MpuCachePolicyNum] = {
[MpuCachePolicy_NotCacheable] = (0x1 << MPU_RASR_TEX_Pos) | (MPU_RASR_S_Msk),
[MpuCachePolicy_WriteTh... | for (unsigned int i = 0; i < ARRAY_LENGTH(s_permission_mappings); ++i) {
if (s_permission_mappings[i].value == access_permissions) {
region.priv_read = s_permission_mappings[i].priv_read;
region.priv_write = s_permission_mappings[i].priv_write;
region.user_read = s_permission_mappings[i].u... |
}
return region;
}
// Fill in the task parameters for a new task with the configurable memory regions we want.
void mpu_set_task_configurable_regions(MemoryRegion_t *memory_regions,
const MpuRegion **region_ptrs) {
unsigned int region_num, region_idx;
uint32_t base_reg... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers *... |
e "applib/ui/window_private.h"
#include "drivers/flash.h"
#include "drivers/system_flash.h"
#include "flash_region/flash_region.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "services/common/system_task.h"
#include "services/runlevel.h"
#include "system/bootbits.h"
#include "... | ("Grenade Launcher") | );
window_set_user_data(window, data);
window_set_overrides_back_button(window, true);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
window_set_fullscreen(window, true);
const bool an... |
{ .argb = (uint8_t)(row_index | 0b11000000) };
graphics_draw_pixel(ctx, GPoint(x, y));
}
}
}
}
static GDrawMask *prv_create_mask_for_vline_applying_test(GContext *ctx) {
// The initial transparency doesn't really matter since we're about to overwrite it
const bool transparent = false;
GDrawM... | (prv_mask_recording_blend_horizontal_line_raw) | ;
CHECK_EXPECTED_TEST_IMAGE(s_ctx);
};
void prv_mask_recording_assign_horizontal_line_delta_raw(GContext *ctx, int16_t y,
Fixed_S16_3 x1, Fixed_S16_3 x2,
uint8_t left_aa_offset,
... |
private(&frame->command_list, NULL, NULL);
}
GDrawCommandSequence *gdraw_command_sequence_create_with_resource(uint32_t resource_id) {
ResAppNum app_num = sys_get_current_resource_num();
return gdraw_command_sequence_create_with_resource_system(app_num, resource_id);
}
GDrawCommandSequence *gdraw_command_sequence... | {
return 0;
} |
size_t size = sizeof(GDrawCommandSequence);
GDrawCommandFrame *frame = sequence->frames;
for (uint32_t i = 0; i < sequence->num_frames; i++) {
size += gdraw_command_frame_get_data_size(frame);
frame = prv_next_frame(frame);
}
return size;
}
GSize gdraw_command_sequence_get_bounds_size(GDrawCommand... |
/*
* 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... | (dict_result, app_message_result, s->callback.context) | ;
}
}
static void update_key_callback(const uint32_t key, const Tuple *new_tuple,
const Tuple *old_tuple, void *context) {
AppSync *s = context;
if (s->callback.value_changed) {
s->callback.value_changed(key, new_tuple, old_tuple, s->callback.context);
}
}
static void pass_... |
(&data->device_name_text_layer) | ;
text_layer_deinit(&data->code_text_layer);
gbitmap_destroy(data->approve_bitmap);
gbitmap_destroy(data->decline_bitmap);
action_bar_layer_deinit(&data->action_bar_layer);
new_timer_delete(data->timer);
if (data->ui_state == BTPairingUIStateAwaitingUserConfirmation) {
prv_send_response(fa... | |
break;
}
}
// If we haven't loaded a glance yet, try loading a generic glance for the node
if (!glance) {
glance = launcher_app_glance_generic_create(node, service->generic_glance_icon,
service->generic_glance_icon_resource_id);
}
// If we successfu... | launcher_app_glance_draw(ctx, frame, glance, is_highlighted) | ;
// If we didn't use the glance cache, destroy the glance now
if (!use_glance_cache) {
launcher_app_glance_destroy(glance);
}
}
void launcher_app_glance_service_rewind_current_glance(LauncherAppGlanceService *service) {
if (!service) {
return;
}
kino_player_rewind(&service->glance_reel_player);
}... |
ent_wakeup_id = wakeup_id;
}
return true; // continue iterating
}
// Checks for the next pending wakeup event and sets up a timer for the event
static void prv_wakeup_timer_next_pending(void) {
if (!s_wakeup_enabled) {
return;
}
// If there is already a wakeup timer scheduled, cancel it. There will be... | (old_file, (uint8_t*)&entry, info->val_len) | ;
if (struct_migration) {
entry.timestamp = wakeup_id; // WakeupId (key) is a timestamp
entry.utc = false; // If we're migrating, this has not been utc
}
int32_t timestamp = entry.timestamp;
time_t current_time = rtc_get_time();
int32_t time_difference = timestamp - current_time;
if (timestamp >= ... |
id < NumANCSCharacteristic; ++id, ++characteristic) {
if (*characteristic == characteristic_to_find) {
return id;
}
}
return ANCSCharacteristicInvalid;
}
static void prv_put_ancs_disconnected_event(void) {
PebbleEvent event = {
.type = PEBBLE_ANCS_DISCONNECTED_EVENT,
};
event_put(&event)... | analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_NS_COUNT, AnalyticsClient_System) | ;
analytics_add(ANALYTICS_DEVICE_METRIC_NOTIFICATION_BYTE_IN_COUNT, length, AnalyticsClient_System);
if (length != sizeof(NSNotification)) {
PBL_LOG(LOG_LEVEL_ERROR, "Received invalid ANCS NS Notification length=<%"PRIu32">", length);
return;
}
NSNotification* nsnotification = (NSNotification*) notifi... |
// 38 seconds
{ 1160, 464, -40},
{ 1392, 384, -64},
{ 1584, 216, 104},
{ 1576, 328, 40},
{ 1280, 480, 32},
{ 1264, 336, 112},
{ 1336, 256, 144},
{ 1312, 376, 104},
{ 928, 88, 176},
{ 840, 328, 96},
{ 824, 224, 104},
{ 872, 152, 112},
{ 840, 128, 144},
{ 816, 14... | { 776, 416, -24},
{ 896, 496, -16},
{ 1088, 504, -24},
{ 1352, 544, -64},
{ 1368, 456, 0},
{ 1752, 368, 8},
// 44 seconds
{ 1528, 488, -56},
{ 1056, 424, 16},
{ 1336, 296, 16},
{ 1464, 224, 48},
{ 1248, 168, 128},
{ 976, 160, 128},
{ 848, 232, 88},
{ 864, 192,... | |
/*
* 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... | {
free(flash_written_data);
free(flash_written_flag);
} |
void test_system_flash__erase_zero_bytes(void) {
cl_assert(system_flash_erase(FLASH_BASE, 0, NULL, NULL));
cl_assert_equal_i(0, erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte(void) {
cl_assert(system_flash_erase(FLASH_BASE, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(... |
", GColorARGB8FromHEX(0x800000)},
{"red", GColorARGB8FromHEX(0xff0000)},
// {"purple", GColorARGBFromHEX(0x800080)}, inconsistent with Pebble color
{"fuchsia", GColorARGB8FromHEX(0xff00ff)},
// {"green", GColorARGBFromHEX(0x008000)}, inconsistent with Pebble color
{"lime", GColorARGB8FromHEX(0x00ff00)},
{"oli... | GColorARGB8FromHEX(0x87cefa) | |
f(buf)), sizeof(buf));
if (i == 0) {
start_page = test_get_file_start_page(fd);
}
if ((i % 2) != 0) {
pfs_close_and_remove(fd);
} else {
pfs_close(fd);
}
}
// force garbage collection
test_force_garbage_collection(start_page);
// now make sure the files are still there!... | pfs_open("page_lookup", OP_FLAG_WRITE, FILE_TYPE_STATIC, PFS_SECTOR_SIZE * num_regions) | ;
cl_assert(fd >= 0);
char buf[PFS_SECTOR_SIZE];
for (int i = 0; i < num_regions; i++) {
memset(buf, 0xff - i, sizeof(buf));
cl_assert_equal_i(pfs_write(fd, (uint8_t *)&buf[0], sizeof(buf)), sizeof(buf));
}
pfs_close(fd);
fd = pfs_open("page_lookup", OP_FLAG_READ | OP_FLAG_USE_PAGE_CACHE, FILE_TYPE... |
nter
TimelineItem *item = timeline_item_create_with_attributes(notif_time, 0,
TimelineItemTypeNotification,
LayoutIdNotification, ¬if_attr_list,
... | (&s_activity_stats, &s_activity_reward_settings) | |
}
static bool prv_are_alarms_scheduled(AlarmsAppData *data) {
return (list_count((ListNode*) data->alarm_list_head) > 0);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! General helper functions
static void prv_show_deleted_dialog(void) {
SimpleDialog *s... | {
return menu_cell_basic_cell_height();
} |
static void prv_alarm_list_draw_row_callback(GContext *ctx, const Layer *cell_layer,
MenuIndex *cell_index, void *callback_context) {
AlarmsAppData *data = (AlarmsAppData *)callback_context;
if (prv_is_add_alarm_cell(cell_index)) {
GRect box;
uint32_t new_bit... |
ster_callbacks();
}
static void prv_app_message_teardown(void) {
if (s_outbox_buffer) {
free(s_outbox_buffer);
}
}
// Statics and Utilities
static void prv_init_and_goto_session_open(void);
static void prv_simulate_transport_connection_event(bool is_connected) {
// FIXME: use events here instead of poking... | cl_assert(found_t) | ; \
cl_assert_equal_i(found_t->type, expected_t->type); \
cl_assert_equal_i(found_t->length, expected_t->length); \
if (expected_t->length) { \
cl_assert_equal_i(0, memcmp(found_t->value[0].data, expected_t->value[0].data, \
expected_t->length)); \
} \... |
);
}
void draw_text_single_line_ellipsis_clip_outside_x(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(80, 4, 72, 32),
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
// Word Wrap Test... | layer_render_tree(&canvas, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_nx_zero_y_offset.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_ny_descender);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap... |
, offset);
return;
}
}
static void prv_render_bpm(GContext *ctx, Layer *base_layer) {
HealthHrSummaryCardData *data = layer_get_data(base_layer);
const int units_offset_y =
fonts_get_font_height(data->bpm_font) - fonts_get_font_height(data->units_font);
GTextNodeHorizontal *horiz_container = graphi... | (s_hr_summary_progress_segments) | ,
.segments = s_hr_summary_progress_segments,
},
.now_bpm = health_data_hr_get_current_bpm(health_data),
.resting_bpm = health_data_hr_get_resting_bpm(health_data),
.last_updated = health_data_hr_get_last_updated_timestamp(health_data),
.bpm_font = fonts_get_system_font(FONT_KEY_LECO_26_BOLD_N... |
-----------
// Log a health insight created event.
void analytics_event_health_insight_created(time_t timestamp,
ActivityInsightType insight_type,
PercentTier pct_tier) {
// Format the event specifc info in the blob. The analytics... | {
return;
} |
AnalyticsEventBlob event_blob = {
.event = AnalyticsEvent_PutByteTime,
.pb_time = {
.ppogatt = is_ppogatt,
.conn_intvl_1_25ms = MIN(conn_interval, UINT8_MAX),
.crc_good = crc_good,
.type = type,
.bytes_transferred = bytes_transferred,
.elapsed_time_ms = elapsed_time_ms,
... |
{ .integer = x2 };
const uint8_t gradient_width = (x2 - x1) / 6;
x2_fixed.integer -= gradient_width;
prv_assign_horizontal_line_delta_raw(&ctx->dest_bitmap, y, x1_fixed, x2_fixed, gradient_width,
gradient_width, ctx->draw_state.clip_box.origin.x,
... | GPoint(x, y) | ;
set_pixel_raw_8bit(&ctx, point);
}
}
// Replicate the last column of the colored gradient for the remaining columns of the bitmap
prv_replicate_column_row_raw(&ctx.dest_bitmap,
(bitmap_bounds.size.w / 2) - 1,
(bitmap_bounds.size.w / 2),
... |
sumer_info) {
cl_assert(s_message_idx < TEST_ARRAY_SIZE);
s_messages[s_message_idx].length = length;
memcpy(s_messages[s_message_idx].data, data, length);
++s_message_idx;
if (s_num_messages_to_consume_from_handler--) {
app_inbox_consume(consumer_info);
}
}
#define assert_message(idx, dd, ll) \
{ \
c... | cl_assert(result != NULL) | ;
cl_assert_equal_b(true, app_inbox_service_has_inbox_for_tag(AppInboxServiceTagUnitTest));
}
void test_app_inbox__app_inbox_create_and_register_kernel_oom(void) {
fake_kernel_malloc_set_largest_free_block(0);
void *result = app_inbox_create_and_register(BUFFER_SIZE, 1,
... |
quadrant, int8_t ending_quadrant) {
GCornerMask quadrants_solid = GCornerNone;
if (starting_quadrant >= ending_quadrant) {
ending_quadrant += QUADRANTS_NUM;
}
for (int i = starting_quadrant + 1; i < ending_quadrant; i++) {
quadrants_solid = quadrants_solid | radius_quadrants[i % QUADRANTS_NUM];
}
... | prv_calc_draw_config_ellipsis(angle_start, angle_end) | |
ord_buffer_size, time_t timestamp, time_t end_time) {
time_t now = rtc_get_time();
// average without overflows since time_t might be signed and now ~1.4 billion, so 2*now > INT_MAX
time_t midtime = timestamp / 2 + end_time / 2;
if (midtime > now) { // future
time_t difference = timestamp - now;
if (tim... | (&t, NULL) | ;
char buffer[80];
char time_buffer[26];
prompt_send_response_fmt(buffer, 80, "Time is now <%s>", rtc_get_time_string(time_buffer));
}
void clock_get_timezone_region(char* region_name, const size_t buffer_size) {
if (!region_name) {
return;
}
if (clock_is_timezone_set()) {
int region_id = clock_g... |
rt_equal_i(cron_service_get_job_count(), 0);
cron_clear_all_jobs();
}
static void prv_basic_test(const TimezoneInfo *tz_info, CronJob *job, time_t base,
time_t offset, time_t increment, int dst_type) {
TimezoneInfo new_tz_info = *tz_info;
switch (dst_type) {
case 0:
break;
... | prv_basic_test(&s_timezone_gmt, &test_cron, s_2015_nov12_123456_gmt, 0, SECONDS_PER_MINUTE, 0) | ;
}
struct {
int month, mday, hour, minute;
int8_t wday;
time_t dest_time;
} s_cron_test_info[] = {
//////// 'future' time finding
// minute
// 2015 Nov 12, 12:45:00
{ -1,-1,-1,45, WDAY_ANY, 1447332300},
// hour
// 2015 Nov 12, 13:00:00
{ -1,-1,13,-1, WDAY_ANY, 1447333200},
// hour+minute
// 20... |
layer(status_layer));
status_bar_layer_deinit(status_layer);
}
// Dialog callbacks for confirmation.
////////////////////////////////////////////////////
static ConfirmationDialog *prv_settings_confirm(const char *title, const char *text,
uint32_t resource_id) {
Conf... | (s_dialog) | ;
confirmation_dialog_pop((ConfirmationDialog *)context);
}
static void prv_coredump_reset_decline_cb(ClickRecognizerRef recognizer, void *context) {
ConfirmationDialog *confirmation_dialog = prv_settings_confirm("Core Dump",
i18n_noop("Core dump and reboot?"), RESOURCE_ID_GENERIC_QUESTION_LARGE);
confirma... |
{
fake_transport_set_sent_cb(s_transport, prv_assert_get_phone_call_state_sent_cb);
pp_get_phone_state();
fake_comm_session_process_send_next();
} |
void test_phone_pp__get_phone_call_state_response_no_calls(void) {
pp_get_phone_state_set_enabled(true);
uint8_t pp_msg[] = {0x83};
phone_protocol_msg_callback(s_session, pp_msg, sizeof(pp_msg));
fake_system_task_callbacks_invoke_pending();
prv_assert_last_event(PhoneEventType_End, false /* check_cookie */,... | |
cessing the callback to retry:
cl_assert(s_launcher_task_callback != NULL);
s_launcher_task_callback(s_launcher_task_callback_data);
// Expect to have written the command to register for the Player entity:
fake_gatt_client_op_assert_write(entity_update, s_register_player_entity,
... | prv_connect_ams() | ;
// Simulate Music app calling music_command_send():
stub_pebble_tasks_set_current(PebbleTask_App);
music_command_send(MusicCommandPlay);
// Process the KernelMain callback:
cl_assert(s_launcher_task_callback != NULL);
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
s_launcher_task_callback(s_lau... |
(const void *payload, uint32_t length) {
if (length < sizeof(FlashReadRequest)) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")", length);
return;
}
const FlashReadRequest *request = payload;
if (request->length > MAX_DATA_LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid request length (%"PRIu32"... | (payload, payload_length) | ;
} else if (header->opcode == OPCODE_FLASH_READ) {
prv_handle_flash_read_request(payload, payload_length);
} else if (header->opcode == OPCODE_FLASH_CRC) {
prv_handle_flash_crc_request(payload, payload_length);
} else if (header->opcode == OPCODE_FLASH_FINALIZE) {
prv_handle_flash_finalize_request(pa... |
/*
* 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_malloc_check(sizeof(KinoLayerDemoData)) | ;
memset(data, 0, sizeof(KinoLayerDemoData));
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Kino Layer"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
.appear = prv_window_appe... |
GAPLEClientApp, NULL);
cl_assert_equal_i(memcmp(buffer, value, value_length), 0);
cl_assert_equal_i(characteristic_out, characteristic);
}
}
free(buffer);
}
static void prv_assert_notification_event(BLECharacteristic characteristic,
const ... | (num_copied, 1) | |
// Start, we should start at the start values
prv_advance_to_ms_with_timers(start_ms + 1);
cl_assert(gcolor_equal(value, start_value));
// Halfway through
prv_advance_to_ms_with_timers(start_ms + duration/2);
cl_assert(gcolor_equal(value, mid_value));
// End
prv_advance_to_ms_with_timers(start_ms + ... | DPRINTF("%"PRIu64": frame at: %d, %d, %d %d\n", time_ms - start_ms,
layer.frame.origin.x, layer.frame.origin.y,
layer.frame.size.w, layer.frame.size.h) | ;
cl_assert(max_loops > 0);
max_loops--;
}
// Make sure the frame reached the "to" state
cl_assert_equal_point(layer.frame.origin, to_r.origin);
// -------------------------------------------------------------------------------
// Now, reschedule it
prv_advance_by_ms_no_timers(10);
prv_clear_ha... |
x(error_code);
dbgserial_newline();
display_error_code(error_code);
static uint8_t prev_button_state = 0;
prev_button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
while (1) {
// See if we should restart
uint8_t button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
if (button_st... | (0xbeefcace) | ;
delay_us(200000);
display_error_code(0x0defaced);
delay_us(200000);
display_error_code(0xd15ea5e5);
delay_us(200000);
display_error_code(0xdeadbeef);
delay_us(200000);
}
#endif
flash_init();
if (is_button_stuck()) {
prv_sad_watch(ERROR_STUCK_BUTTON);
}
if (is_flash_broken(... |
rm_set_kind(data->alarm_id, data->alarm_kind);
data->complete_callback(EDITED, data->alarm_id, data->callback_context);
app_window_stack_pop(true);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Custom Day Picker
static void prv_custom_day_picker_... | {
data->alarm_kind = ALARM_KIND_JUST_ONCE;
} |
menu_layer_set_selected_index(&data->day_picker_menu_layer,
(MenuIndex) { 0, prv_alarm_kind_to_index(data->alarm_kind) },
MenuRowAlignCenter, false);
}
static uint16_t prv_custom_day_picker_get_num_sections(struct MenuLayer *menu_layer,
... |
orm * const t2) {
if ((!t1) || (!t2)) {
return false;
}
return memcmp(t1, t2, sizeof(GTransform)) == 0;
}
//////////////////////////////////////
/// Modifying Transforms
//////////////////////////////////////
// Note that t_new can be set to either of t1 or t2 safely to do in place muliplication
// Note thi... | (vectorP.dx, t->a) | ;
Fixed_S16_3 y_c = Fixed_S16_3_S32_16_mul(vectorP.dy, t->c);
Fixed_S16_3 one_tx = Fixed_S16_3_S32_16_mul(FIXED_S16_3_ONE, t->tx);
Fixed_S16_3 x_b = Fixed_S16_3_S32_16_mul(vectorP.dx, t->b);
Fixed_S16_3 y_d = Fixed_S16_3_S32_16_mul(vectorP.dy, t->d);
Fixed_S16_3 one_ty = Fixed_S16_3_S32_16_mul(FIXED_S16_3_ON... |
lance_1);
cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&app_glance_1, glance_1_size),
S_SUCCESS);
cl_assert_equal_i(app_glance_db_get_len((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE),
g... | cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&s_app_glance_with_invalid_slice_total_sizes,
sizeof(s_app_glance_with_invalid_slice_total_sizes)),
E_INVALID_ARGUMENT) | ;
}
status_t app_glance_db_insert_stale(const uint8_t *key, int key_len, const uint8_t *val,
int val_len);
void test_app_glance_db__read_stale_glance_blob(void) {
// Force the insertion of a stale glance blob (outdated version)
const SerializedAppGlanceHeader app_glance = (Seri... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | i18n_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_timeout(dialog, DIALOG_TIMEOUT_DEFAULT);
return simple_dialog;
}
static void prv_edit_snooze_delay(ActionMenu *action_menu,
... |
cl_assert_equal_i(data->test, TEST_PATTERN) | ;
if (data->reset) {
cl_assert_equal_b(*data->reset, false);
*data->reset = true;
}
}
static void prv_on_destroy(Recognizer *recognizer) {
TestImplData *data = recognizer_get_impl_data(recognizer, &s_test_impl);
cl_assert_equal_i(data->test, TEST_PATTERN);
if (data->destroyed) {
cl_assert_equal_b... | |
////////////////////
void test_app_message__initialize(void) {
prv_set_app_uuid(simplicity_uuid);
prv_set_remote_app_uuid(simplicity_uuid);
fake_app_timer_init();
s_app_receiver_oom = false;
s_sys_psleep_last_millis = 0;
s_app_inbox_consume_call_count = 0;
app_message_init();
app_message_set_context... | prv_send_test_data() | ;
prv_call_outbox_sent(AppOutboxStatusSuccess);
prv_process_sent_data();
// After the ACK has been received, we should have been called
cl_assert_equal_b(s_ack_sent_is_called, true);
// Check that we were called
cl_assert_equal_i(s_out_sent_call_count, 1);
// Timer should be invalid
cl_assert_equal_b... |
{ 1128, -192, -392},
{ 1232, 72, -168},
{ 1232, 272, -360},
{ 1224, 216, -400},
{ 1280, 352, -336},
{ 1424, 432, -336},
{ 1488, 648, -456},
{ 1360, 848, -568},
{ 944, 1064, -928},
{ 768, 1208, -888},
{ 1104, 1056, -696},
{ 1400, 832, -392},
{ 1456, 632, -312},
{ 1584,... | { 1096, 736, -200},
{ 1416, 632, -160},
{ 1400, 368, -152},
{ 1256, 144, -24},
// 18 seconds
{ 1312, 280, -96},
{ 1400, 200, -104},
{ 1288, 272, -56},
{ 1328, 160, -32},
{ 1288, 176, 0},
{ 1056, 160, -112},
{ 1224, 24, -112},
{ 512, -440, 0},
{ 816, 16, -376},
... |
{ 1184, 224, -384},
{ 1184, 432, -376},
{ 1280, 352, -232},
{ 1472, 592, -232},
{ 1256, 728, -232},
{ 1064, 816, -288},
{ 1008, 928, -192},
{ 1264, 1024, -200},
{ 1080, 512, -184},
{ 864, 584, -192},
{ 848, 624, -120},
{ 1136, 584, -120},
{ 1128, 400, -120},
// 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... | graphics_context_set_antialiased(ctx, false) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&data->word_wrap_layer, GColorWhite) | ;
text_layer_set_background_color(&data->word_wrap_layer, GColorBlack);
}
if (data->up_down_direction) {
text_layer_set_text(&data->direction_layer, "Direction: Up/Down");
} else {
text_layer_set_text(&data->direction_layer, "Direction: Left/Right");
}
if (data->word_wrap) {
frame.size.w = 7... |
alarm_create(&info) | ;
data->complete_callback(CREATED, data->alarm_id, data->callback_context);
} else {
alarm_set_custom(data->alarm_id, data->scheduled_days);
data->complete_callback(EDITED, data->alarm_id, data->callback_context);
}
app_window_stack_pop(true);
}
} else { // selecting a da... | |
writes past the end of destination buffer");
}
}
void test_persist__string_does_not_exist(void) {
char string_buffer[PERSIST_STRING_MAX_LENGTH];
memset(string_buffer, '~', sizeof(string_buffer));
cl_assert_equal_i(
persist_read_string(0, string_buffer, sizeof(string_buffer)),
E_DOES_NOT_EXIST);
... | ("n = %d", n) | ;
for (int i = 0; i < n; ++i) {
PBL_LOG(LOG_LEVEL_DEBUG, "i = %d", i);
cl_assert_equal_i(persist_write_data(i, &buffer, sizeof(buffer)), sizeof(buffer));
}
// Don't be too strict about preventing apps from using more persist than they
// had available under the old implementation.
// cl_assert_equal_... |
s the current airplane mode state
static const char AIRPLANE_MODE_KEY[] = "AIRPLANE_MODE";
//! This key is used to access a uint64_t which stores the most recent system session capabilities
static const char SYSTEM_CAPABILITIES_KEY[] = "SYSTEM_CAPABILITIES";
//! This key is used to access the BLE address that can be us... | {
goto cleanup;
} |
// Only store data if data_in is a valid pointer, otherwise, clear the entry
if (data_in) {
if (settings_file_get_len(&fd, key, key_len) == (int)data_len) {
uint8_t curr_val[data_len];
settings_file_get(&fd, key, key_len, &curr_val[0], data_len);
// Don't bother rewriting the e... |
/ not sending anything
return true;
}
CommSession *session = comm_session_get_system_session();
if (!session) {
return false;
}
mutex_lock(s_endpoint_data.mutex);
if (logging_session->comm.state != DataLoggingSessionCommStateIdle) {
mutex_unlock(s_endpoint_data.mutex);
// logging_session i... | PBL_LOG(LOG_LEVEL_ERROR, "Unexpected NACK") | ;
break;
case DataLoggingSessionCommStateSending:
//Maybe queue a resend
logging_session->comm.num_bytes_pending = 0;
if (++logging_session->comm.nack_count > MAX_NACK_COUNT) {
PBL_LOG(LOG_LEVEL_ERROR, "Too many nacks. Flushing...");
dls_storage_consume(logging_session, loggi... |
128-bit UUID to 32-bits. Note: this function does not
//! check whether the original UUID is based on the Bluetooth base.
static uint32_t prv_convert_to_32bit_uuid(const Uuid *uuid) {
uint32_t uuid_32bits = 0;
// Use bytes 0-3 of the Uuid:
for (int i = 0; i < 4; ++i) {
uuid_32bits <<= 8;
uuid_32bits += (... | prv_write_element_to_ad_data(ad, (const BLEAdElement *) element) | ;
}
// -----------------------------------------------------------------------------
bool ble_ad_set_flags(BLEAdData *ad, uint8_t flags) {
struct __attribute__((__packed__)) BLEAdElementManufacturerSpecific {
BLEAdElementHeader header;
uint8_t flags;
} element = {
.header = {
.length = sizeof(str... |
cense.
*/
#include "compositor_modal_slide_transitions.h"
#include "services/common/compositor/compositor_private.h"
#include "applib/graphics/bitblt.h"
#include "applib/graphics/framebuffer.h"
#include "applib/graphics/graphics.h"
#include "applib/ui/animation_interpolate.h"
#include "kernel/ui/kernel_ui.h"
#inclu... | {
if (s_data.modal_is_destination) {
prv_modal_transition_push_update(ctx, distance_normalized);
} else {
prv_modal_transition_pop_update(ctx, distance_normalized);
}
} |
#define NUM_MOOOK_FRAMES_MID 1
static int64_t prv_interpolate_moook_soft(int32_t normalized, int64_t from, int64_t to) {
return interpolate_moook_soft(normalized, from, to, NUM_MOOOK_FRAMES_MID);
}
static void prv_transition_animation_init(Animation *animation) {
// Tweaked from observations by the design team
... |
d_len];
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
pfs_close(fd);
fd = pfs_open("newfile", OP_FLAG_READ, 0, 0);
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == rd_len);
rv = pfs_read(fd, buf, 1);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, 0, FSeekSet);
cl_assert(rv == 0);... | int fd = pfs_open(file_large, OP_FLAG_READ, 0, 0);
cl_assert(fd >= 0);
size_t sz = pfs_get_file_size(fd);
cl_assert(sz == large_file_size);
uint8_t *b = calloc(sz, 1);
cl_assert(pfs_read(fd, b, sz) == sz);
for (int j = 0; j < large_file_size / 4; j++) {
uint32_t *val = ((uint32_t *)(... |
void test_pfs__file_span_regions(void) {
pfs_format(false /* write erase headers */); // start with an empty flash
pfs_init(false);
char name[128];
snprintf(name, sizeof(name), "bigfile");
//Fill up entire memory section, subtract 32768 for header space.
int fd = pfs_open(name, OP_FLAG_WRITE, FILE_TYPE_... |
/*
* 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... | { // This will catch '\0'
break;
} |
if (ch >= base) {
break;
}
value *= base;
value += ch;
if (do_errors) {
if ((sign > 0) && (value > max)) {
value = max;
} else if ((sign < 0) && (-value < min)) {
value = -min;
}
}
nptr++;
}
if (endptr) {
*endptr = (char*)nptr;
}
return va... |
/*
* 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_region_list[i].start, s_region_list[i].start,
s_region_list[i].end, s_region_list[i].end) | ;
}
}
|
* ctx) {
if (action_bar->layer.window && action_bar->layer.window->on_screen == false) {
// clear first, fixes issue of returning from other page while highlighted
for (int i = 0; i < NUM_ACTION_BAR_LEGACY2_ITEMS; i++) {
action_bar_legacy2_set_highlighted(action_bar, i, false);
}
}
}
static void ... | {
layer_mark_dirty(&action_bar->layer);
} | |
t_to_square(GDrawCommandList *list, GSize size, int32_t normalized) {
ToSquareCBContext ctx = {
.integer_size = size,
.precise_size = gsize_scalar_lshift(size, GPOINT_PRECISE_PRECISION),
.normalized = normalized,
};
gdraw_command_list_iterate(list, prv_gdraw_command_attract_to_square, &ctx);
}
void g... | (list, prv_distance_comparator, &target, false) | ;
}
void gpoint_index_lookup_add_at(GPointIndexLookup *lookup, int delay_index, int delay_amount) {
if (delay_index < 0 || delay_index >= lookup->max_index) {
return;
}
// We are adding additional delay, the max delay index increases
lookup->max_index += delay_amount;
for (int i = 0; i < lookup->num_poin... |
/common/light.h"
#include "util/size.h"
typedef enum {
TestPattern_Black,
TestPattern_Gray,
TestPattern_White,
TestPattern_Crosshair,
#if PBL_COLOR
TestPattern_Red,
TestPattern_Green,
TestPattern_Blue,
#endif
#if PBL_ROUND
TestPattern_Border1,
TestPattern_Border2,
TestPattern_Border3,
#endif
#if PB... | graphics_draw_bitmap_in_rect(ctx, bitmap, &layer->bounds) | ;
gbitmap_destroy(bitmap);
}
static void prv_update_proc(struct Layer *layer, GContext* ctx) {
AppData *app_data = app_state_get_user_data();
switch (app_data->test_pattern) {
case TestPattern_Black:
prv_draw_solid(layer, ctx, GColorBlack);
break;
case TestPattern_Gray:
prv_draw_solid(layer, ctx... |
y(data, ARRAY_LENGTH(data), NULL, &time_end);
cl_assert_equal_i(0, written);
// empty end before start
time_t early_end = time_start - 20 * SECONDS_PER_MINUTE;
written = health_service_get_minute_history(data, ARRAY_LENGTH(data), &time_start, &early_end);
cl_assert_equal_i(0, written);
// empty end works ... | time_start = time_almost_next_minute;
time_end = time_start + (5 * SECONDS_PER_MINUTE / 2);
health_service_get_minute_history(data, ARRAY_LENGTH(data), &time_start, &time_end);
cl_assert_equal_i(4, s_sys_activity_get_minute_history_values.in[0].num_records);
// respects time_end, 1 minute => 1 records
s_sy... |
void test_health__get_yesterdays_sleep_activity(void) {
HealthValue start_sec;
HealthValue end_sec;
// our mock setup doesn't provide configurations for multiple calls
// as health_service_private_get_yesterdays_sleep_activity() calls the function twice, both
// values will have the same value
s_sys_acti... |
, play_count_a * duration_a);
cl_assert_equal_i(animation_get_duration(a, true, false), delay_a + duration_a);
cl_assert_equal_i(animation_get_duration(a, true, true), total_duration_a);
cl_assert_equal_i(animation_get_duration(b, false, false), duration_b);
cl_assert_equal_i(animation_get_duration(b, false, t... | (c, d, NULL) | ;
cl_assert(spawn != NULL);
// Create a primitive one
Animation *e = prv_create_test_animation();
// Schedule them all
animation_schedule(seq);
animation_schedule(spawn);
animation_schedule(e);
// Verify count
cl_assert_equal_i(prv_count_scheduled_animations(), 7);
// Unschedule all
animation_... |
case WATCH_INFO_COLOR_GREEN:
model_name = TINTIN_MODEL("pebble_green");
break;
case WATCH_INFO_COLOR_PINK:
model_name = TINTIN_MODEL("pebble_pink");
break;
case WATCH_INFO_COLOR_TIME_WHITE:
model_name = SNOWY_MODEL("pebble_time_white");
break;
case WATC... | jerry_create_string((const jerry_char_t *)suffix_str) | ;
JS_VAR version_object = jerry_create_object();
jerry_set_object_field(version_object, ROCKY_WATCHINFO_FW_MAJOR, version_major);
jerry_set_object_field(version_object, ROCKY_WATCHINFO_FW_MINOR, version_minor);
jerry_set_object_field(version_object, ROCKY_WATCHINFO_FW_PATCH, version_patch);
jerry_set_object_... |
1080, -480},
{ -128, 928, -320},
{ -56, 1128, -288},
{ -168, 856, -208},
{ -80, 1016, -464},
{ -112, 832, -528},
{ -128, 824, -528},
// 57 seconds
{ -88, 1016, -624},
{ -144, 896, -496},
{ -88, 976, -536},
{ -88, 1008, -544},
{ -72, 776, -448},
{ -16, 928, -520},
... | { -120, 440, -936},
{ -112, 544, -848},
{ -128, 760, -712},
{ -112, 408, -824},
{ -8, 464, -1040},
{ -96, 624, -704},
{ -40, 624, -784},
{ 16, 800, -776},
{ -136, 512, -672},
{ -80, 824, -1184},
{ -272, 496, -736},
{ -216, 832, -968},
{ -160, 528, -792},
{ -96, 69... |
{ -120, 776, -968},
{ -120, 680, -768},
{ -96, 648, -848},
{ -80, 656, -832},
{ -32, 640, -856},
// 65 seconds
{ -40, 568, -712},
{ 16, 808, -888},
{ -64, 488, -568},
{ -24, 832, -856},
{ -216, 608, -768},
{ -256, 768, -904},
{ -344, 680, -800},
{ -184, 544, -656... |
ap.bounds, &point)) {
return;
}
bool black = (gcolor_equal(ctx->draw_state.stroke_color, GColorBlack));
uint8_t *line = ((uint8_t *)ctx->dest_bitmap.addr) + (ctx->dest_bitmap.row_size_bytes * point.y);
bitset8_update(line, point.x, !black);
}
#endif
void graphics_private_set_pixel(GContext* ctx, GPoint po... | {
x2 = (Fixed_S16_3){.integer = max_valid_x};
} |
// last pixel with blending (don't render the pixel if it overflows the framebuffer/clip box)
if (x2.integer >= max_valid_x) {
x2.fraction = 0;
}
ctx->draw_state.draw_implementation->assign_horizontal_line(ctx, y, x1, x2, color);
}
void graphics_private_draw_horizontal_line_integral(GContext *ctx, GBitm... |
xSemaphoreGive(s_pb_semaphore);
}
void put_bytes_expect_init(uint32_t timeout_ms) {
xSemaphoreTake(s_pb_semaphore, portMAX_DELAY);
if (s_pb_state.current_command != PutBytesIdle) {
PBL_LOG(LOG_LEVEL_ERROR, "Called put_bytes_expect while put_bytes is not idle");
xSemaphoreGive(s_pb_semaphore);
return... | prv_pre_ack_if_space_in_put_job_queue() | ;
}
}
}
void prv_receiver_write(Receiver *receiver, const uint8_t *data, size_t length) {
if (!prv_take_lock_with_short_timeout()) {
s_pb_state.receiver.should_nack = true;
return;
}
if (!prv_is_message_pending_processing()) {
// Could happen if put_bytes_cancel() was called after "prepare"
... |
(center.x - (outer_size / 2), center.y - (outer_size / 2),
outer_size, outer_size) | ;
inset = outer_size - inner_size;
scale_mode = GOvalScaleModeFitCircle;
}
static void prv_setup_even_angles_inner(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = window_layer->bounds;
// Parameters
outer_size = 50;
inner_size = 35;
angle_start = (TRIG_MAX_ANGLE /... | |
skTimerManager s_task_timer_manager;
// =======================================================================================
// Client-side Implementation
// ---------------------------------------------------------------------------------------
// Create a new timer
TimerID new_timer_create(void) {
return task_... | {
TickType_t TICKS_TO_WAIT = 50;
NewTimerWorkItem work = { cb, data };
if (xQueueSend(s_work_queue, &work, TICKS_TO_WAIT)) {
// Wake up the thread to process the work item we just added.
xSemaphoreGive(s_wake_srv_loop);
return true;
}
return false;
} | |
inset;
frame.size.h -= top_inset;
// Using TextStyleFont_Header here is a little bit of a hack to achieve Gothic 18 Bold on
// Spalding's default content size (medium) while still being a little robust for any future round
// watches that have a default content size larger than medium
const GFont font = syste... | i18n_get("Clear All", data) | , font, box,
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
#endif
return;
}
// shift index since the first one is hard coded to Clear
const int16_t notif_idx = cell_index->row - 1;
NotificationNode *node = (NotificationNode*) list_get_at(
(ListNode*) notifica... |
/*
* 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... | {
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetPrescaler(IWDG_Prescaler_64); // ~8 seconds
IWDG_SetReload(0xfff);
IWDG_WriteAccessCmd(IWDG_WriteAccess_Disable);
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP, ENABLE);
} |
void watchdog_start(void) {
IWDG_Enable();
IWDG_ReloadCounter();
}
bool watchdog_check_reset_flag(void) {
return RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET;
}
|
/*
* 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... | (result, 40) | |
fs_db_get_len,
.read = prefs_db_read,
.del = prefs_db_delete,
.flush = prefs_db_flush,
},
[BlobDBIdContacts] = {
#if !PLATFORM_TINTIN
.init = contacts_db_init,
.insert = contacts_db_insert,
.get_len = contacts_db_get_len,
.read = contacts_db_read,
.del = contacts_db_delete,
.flus... | if (db->flush) {
status_t rv = db->flush();
if (rv == S_SUCCESS) {
PBL_LOG(LOG_LEVEL_INFO, "Flushing BlobDB with Id %d", db_id);
blob_db_event_put(BlobDBEventTypeFlush, db_id, NULL, 0);
}
return rv;
} |
return E_INVALID_OPERATION;
}
BlobDBDirtyItem *blob_db_get_dirty_list(BlobDBId db_id) {
if (!prv_db_valid(db_id)) {
return NULL;
}
const BlobDB *db = &s_blob_dbs[db_id];
if (db->get_dirty_list) {
return db->get_dirty_list();
}
return NULL;
}
status_t blob_db_mark_synced(BlobDBId db_id, uint8... |
utes[j].steps);
cl_assert_equal_i(minute_data[j].orientation, exp_minutes[j].orientation);
cl_assert_equal_i(minute_data[j].vmc, exp_minutes[j].vmc);
}
}
// ---------------------------------------------------------------------------------------
void test_kraepelin_algorithm__sleep_tests(void) {
bool succ... | printf(" exp_%-8s act_%-7s", metrics[i], metrics[i]) | ;
}
printf(" %-10s %-10s", "weight_err", "status");
printf("\n------------------------");
for (int i = 0; i < ARRAY_LENGTH(metrics); i++) {
printf("| ---------------------- ");
}
float weighted_sum = 0.0;
int pass_count = 0;
int fail_count = 0;
SleepFileTestEntry *entry = &test_entry[0];
Sleep... |
itmap, "draw_round_rect_offset_r4_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, false, 1);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw1_clip_nx... | setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 11) | ;
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw11_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, false, 11);
graphics_draw_round_rect(&ctx, &OFFSET_DR... |
t
to_r = GRect(1000, 2000, 100, 200); // x, y, width, height
prop_h = property_animation_create_layer_frame(&layer, &from_r, &to_r);
Animation *h = property_animation_get_animation(prop_h);
void *context = &layer;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
prv_clea... | animation_schedule(h) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.