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... | {
MorphSquareDemoData *data = app_state_get_user_data();
app_free(data);
} | |
(lookup_table_out[2], GColorBrass) | );
cl_assert(gcolor_equal(lookup_table_out[3], GColorYellow));
// lookup_table_out's entries should all preserve the alpha of tint_color
tint_color = GColorBlack;
tint_color.a = 1;
gcolor_tint_luminance_lookup_table_init(tint_color, lookup_table_out);
for (GColor8Component i = 0; i < GCOLOR8_COMPONENT_NUM_... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GSize(64, 64) | , GBitmapFormat8Bit);
uint32_t size_full = (DISP_COLS*DISP_ROWS);
#endif
uint8_t *s_gfx_rotated_bitmap_pixels = s_gfx_rotated_bitmap_bitmap->addr;
// Init images
for (uint32_t index = 0; index < size_full; index++) {
s_gfx_rotated_bitmap_pixels[index] = (index % 2) ? 0xf0 : 0xcc;
}
#if SCREEN_COLOR_DEPTH... |
224, -224},
{ 1152, 176, -312},
{ 1336, 128, -352},
{ 1064, 40, -328},
{ 872, -136, -328},
{ 1080, -48, -208},
{ 1048, 24, -256},
{ 1112, 160, -304},
// 39 seconds
{ 1312, 216, -392},
{ 1224, 256, -384},
{ 968, 288, -304},
{ 912, 360, -272},
{ 1056, 384, -288},
{ ... | { 1368, 160, -352},
{ 984, 192, -344},
{ 744, 216, -328},
{ 824, 272, -264},
{ 1080, 344, -320},
{ 1200, 424, -208},
{ 1224, 520, -232},
{ 1368, 816, -336},
{ 976, 680, -344},
{ 1376, 808, -200},
{ 1168, 720, -280},
{ 1240, 640, -352},
{ 1352, 464, -240},
{ 1408, ... |
{ 1176, 320, -192},
{ 1288, 296, -240},
{ 1360, 224, -264},
{ 1184, 192, -336},
{ 1144, 56, -384},
{ 1128, -120, -288},
{ 688, -248, -144},
{ 1248, -176, -200},
// 47 seconds
{ 1024, 32, -152},
{ 1264, 128, -312},
{ 1416, 248, -416},
{ 1240, 248, -424},
{ 936, 16... |
ly(void) {
printf("\nTesting if we can use each and stop early at %d iterations...\n", STOPPING_NUM);
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_each", 4096));
uint8_t key[5];
int key_len = 4;
uint8_t val[5];
int val_len = 4;
for (int i = 0; i < 255; i++) {
snprintf((char... | settings_file_get_len(&file, key, key_len) | |
do_not_disturb_set_schedule_enabled(WeekdaySchedule, false) | ;
active = do_not_disturb_is_active();
cl_assert(active == true);
// Manual && Scheduled && Smart
do_not_disturb_set_manually_enabled(true);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
active = do_not_disturb_is_active();
cl_assert(active == true);
// !Manual && !Scheduled && Smart
d... | |
// Don't fuzz 3rd party app heaps because likely many of them rely on accessing free'd memory
bool enable_heap_fuzzing = (sdk_type == ProcessAppSDKType_System);
Heap *app_heap = app_state_get_heap();
PBL_LOG(LOG_LEVEL_DEBUG, "App heap init %p %p",
app_segment.start, app_segment.end);
heap_init(app... | (SNIFF_INTERVAL_NORMAL) | |
s);
client = next;
}
}
bt_unlock();
}
void ppogatt_handle_service_discovered(BLECharacteristic *characteristics) {
bt_lock();
{
// Create new clients:
PPoGATTClient *client = prv_create_client();
BLECharacteristic meta = characteristics[PPoGATTCharacteristicMeta];
client->characterist... | {
return NULL;
} |
if (client->out.reset_packet_to_send.type == PPoGATTPacketTypeResetRequest) {
// Reset Request packet:
*packet = (const PPoGATTPacket) {
.type = PPoGATTPacketTypeResetRequest,
.sn = 0,
};
PPoGATTResetRequestClientIDPayload *client_id_payload =
(PPoGATTResetRequestClientIDPayloa... |
ventIDNotificationAdded:
// In iOS 8.2 several apps (especially mail.app) seem to be setting the pre-existing flag
// when they shouldn't. This appeared to be fixed in iOS 9 beta 1.
// By skipping the pre-existing check we will re-recieve all the notifications
// we got in the past 2 hours. To g... | ("Control point write error: %d", error) | ;
return false;
}
return true;
}
// -------------------------------------------------------------------------------------------------
// Performing ANCS Notification Actions
static void prv_perform_action(uint32_t notification_uid, ActionId action_id) {
prv_set_state(ANCSClientStatePerformingAction);
Per... |
), //!< Low Battery detected. Set when BSUP drops below ResVoltFall
};
enum PmicRail {
PmicRail_SD1, //!< 1.8V
PmicRail_LDO1, //!< 3.0V
PmicRail_LDO2, //!< 2.0V
};
#define AS3701B_CHIP_ID 0x11
#define AS3701B_WRITE_ADDR 0x80
#define AS3701B_READ_ADDR 0x81
static bool prv_read_register(uint8_t register_addre... | (PmicRegisters_RESET_CNTL, 1) | ) {
while (1) {}
__builtin_unreachable();
}
return false;
}
// On the as3701b, a power_off will cut power to all rails. We want to keep the
// RTC alive, so rather than performing a sw_power_off, enter the pmic's standby
// mode, powering down all but LDO2.
bool pmic_power_off(void) {
// Only enable int... |
_t *)repeat_delay_attribute->data;
if (*delay > VIBE_SCORE_MAX_REPEAT_DELAY_MS) {
return false;
}
}
return true;
}
VibeScore *vibe_score_create_with_resource_system(ResAppNum app_num,
uint32_t resource_id) {
uint32_t data_size;
if (!prv_vibe_score... | if (!score) {
return;
} |
applib_free(score);
}
|
/*
* 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... | {
QemuCommChannelHdr hdr = (QemuCommChannelHdr) {
.signature = htons(QEMU_HEADER_SIGNATURE),
.protocol = htons(protocol),
.len = htons(data_len)
};
prv_send_bytes(&hdr, sizeof(hdr));
} |
static void prv_send_footer(void) {
QemuCommChannelFooter footer = (QemuCommChannelFooter) {
.signature = htons(QEMU_FOOTER_SIGNATURE)
};
prv_send_bytes(&footer, sizeof(footer));
}
// ------------------------------------------------------------------------------------
// Tests
void test_qemu_serial__foo(v... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT) | ->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.will_change, prv_will_change);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.change, prv_change);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
// Unsubscribi... |
/*
* 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... | time_ms(&seconds, &milliseconds) | |
#include <stdio.h>
#define USE_FAKE_DATA 0
#define CUR_TEMP_HEIGHT 35
#define CUR_TEMP_TOP 1
#define CUR_TEMP_RECT GRect(0, CUR_TEMP_TOP, DISP_COLS, CUR_TEMP_HEIGHT)
#define TEMP_RANGE_HEIGHT 20
#define TEMP_RANGE_TOP CUR_TEMP_HEIGHT
#define TEMP_RANGE_RECT GRect(0, TEMP_RANGE_TOP, DISP_COLS, TEMP_RANGE_HEIGHT)
#de... | {
return;
} |
PBL_LOG(LOG_LEVEL_DEBUG, "min temp: %d, max temp: %d", data->min_temp, data->max_temp);
int temp_range = data->max_temp - data->min_temp;
temp_range = MAX(10, temp_range);
for (int i = first_non_zero_idx, x_pos = 0; i < (int)READ_HISTORY_ENTRIES; i++, x_pos++) {
int reading = s_temp_readings[i];
int l... |
ssert_equal_i(s_out_failed_call_count, 0);
cl_assert_equal_b(app_message_is_closed_outbound(), true);
}
void test_app_message__send_while_closing(void) {
prv_set_remote_receive_handler(prv_ack_sent_callback);
prv_send_test_data();
// Close the AppMessage context
app_message_close();
// Make fake remote s... | (app_message_outbox_begin(NULL), APP_MSG_INVALID_ARGS) | ;
}
void test_app_message__send_while_not_begun(void) {
cl_assert_equal_i(app_message_outbox_send(), APP_MSG_INVALID_STATE);
}
void test_app_message__zero_inbox(void) {
app_message_close();
cl_assert_equal_i(app_message_open(0, MAX_SIZE_OUTBOUND), APP_MSG_OK);
cl_assert_equal_b(app_message_is_closed_inbound()... |
pfs_active_in_region(known_size, known_size + prv_region_size(i))) {
// if active, increment known flash version and increase size to check next region
flash_version = i + 1;
known_size += prv_region_size(i);
} else {
// if not active, break and return known flash version
break;
}
... | {
prv_ftl_operation(NULL /* not needed for erase */, size, offset, FTLEraseSubsector);
} |
void ftl_format(void) {
}
//! Only used for tests.
void ftl_force_version(int version_idx) {
s_next_region_idx = version_idx;
s_ftl_size = 0;
for (int i = 0; i < version_idx; i++) {
s_ftl_size += prv_region_size(i);
}
pfs_set_size(s_ftl_size, false);
extern void test_force_recalc_of_gc_region(void);... |
v;
}
static bool prv_read_register(HRMDevice *dev, uint8_t register_address, uint8_t *value) {
i2c_use(dev->i2c_slave);
bool rv = i2c_read_register(dev->i2c_slave, register_address, value);
i2c_release(dev->i2c_slave);
return rv;
}
static bool prv_read_register_block(HRMDevice *dev, uint8_t register_address, ... | if (hrm_data_regs.sqi <= AS7000SQIThreshold_Excellent) {
data->hrm_quality = HRMQuality_Excellent;
} else if (hrm_data_regs.sqi <= AS7000SQIThreshold_Good) {
data->hrm_quality = HRMQuality_Good;
} else if (hrm_data_regs.sqi <= AS7000SQIThreshold_Acceptable) {
data->hrm_quality = HRMQuality_Acceptable;
... |
}
// Sequence of events for handshake pulse (when in one-second burst mode):
// - [optional] Host writes the one-second time (registers 10,11) measured for the last 20
// samples (about one second).
// - Host reads any data/HRV-result/LED-current, as needed (see registers [14...53])
// - Host reads the ... |
les);
graphics_draw_circle(ctx, circle1_location, radius_of_spinner_circles);
graphics_fill_circle(ctx, circle2_location, radius_of_spinner_circles);
graphics_draw_circle(ctx, circle2_location, radius_of_spinner_circles);
}
static void prv_anim_impl(struct Animation *animation,
const An... | (window, data) | ;
window_set_overrides_back_button(window, true);
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_window_load_handler,
.unload = prv_window_unload_handler,
});
return window;
}
|
/*
* 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_expandable_dialog_push(e_dialog) | ;
}
static void prv_forget_bt_classic_remote(BTDeviceAddress* address) {
bt_persistent_storage_delete_bt_classic_pairing_by_addr(address);
bt_driver_classic_disconnect(address);
analytics_inc(ANALYTICS_DEVICE_METRIC_BT_PAIRING_FORGET_COUNT, AnalyticsClient_System);
}
static void prv_forget_ble_remote(int id) {
... |
x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0... | {
return sbox[num];
} |
static uint8_t getSBoxInvert(uint8_t num)
{
return rsbox[num];
}
// This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states.
static void KeyExpansion(void)
{
uint32_t i, j, k;
uint8_t tempa[4]; // Used for the column/row operations
// The first round key is th... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
prv_put_event_from_process(task, &event);
} |
}
DEFINE_SYSCALL(void, sys_event_service_client_unsubscribe, EventServiceInfo *state,
EventServiceInfo *handler) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(handler, sizeof(*handler));
syscall_assert_userspace_buffer(state, sizeo... |
s = 0,
.actions = NULL,
},
.allocated_buffer = NULL,
}, {
.header = {
.id = {0x02},
.parent_id = {0},
.timestamp = 1421107200, // Tue Jan 13 midnight 2015 UTC
.duration = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.all_day = 1,
.layout = ... | (state.node) | ;
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
}
void test_timeline__forward_and_back(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
// Note: 1421178000 = Tue Jan 13 11:40:00 PST 2015
// check first
tim... |
g_regulatory_compliance_marks(cd);
if (flags->has_japan_telec_r) {
prv_append_certification_menu(cd, &(SystemCertificationMenuItem) {
.draw_cell_fn = prv_draw_rt_cell,
.arg1 = &cd->r_mark,
.arg2 = prv_get_japan_telec_r_id()
});
}
if (flags->has_japan_telec_t) {
prv_append_cert... | bitmap_layer_get_layer(&data->bmp_layer) | );
GRect title_text_frame = (GRect) { .size = title_text_size };
const int16_t title_text_internal_padding = 5;
title_text_frame.origin.y = bmp_frame.origin.y + bmp_size.h + vertical_spacing
- title_text_internal_padding;
text_layer_init_with_parameters(&data->title_text, &title... |
/*
* 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... | (base_layer) | ;
char buffer[8];
GFont font;
if (data->current_steps) {
font = fonts_get_system_font(FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM);
snprintf(buffer, sizeof(buffer), "%"PRIu32"", data->current_steps);
} else {
font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
snprintf(buffer, sizeof(buffer), EM_DAS... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_deinit(&s_data.window) | ;
}
// Tests
//////////////////////
void test_kickstart__render_no_data(void) {
window_set_on_screen(&s_data.window, true, true);
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_kickstart__render_obstructed_area(void) {
#if !PBL_ROUND
prv_set_un... |
/*
* 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 (!buffer) {
applib_free(session);
return NULL;
} |
}
VoiceWindow *voice_window = voice_window_create(buffer, buffer_size,
VoiceEndpointSessionTypeDictation);
if (!voice_window) {
applib_free(buffer);
applib_free(session);
return NULL;
}
*session = (DictationSession) {
.callback = callback,
... |
ww.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions... | if (bytes_read < (int)size) {
PBL_LOG(LOG_LEVEL_ERROR, "Read only %d bytes, expected %d", (int)bytes_read, (int)size);
return false;
} |
return true;
}
// ----------------------------------------------------------------------------------------
// Logs if an error occurs, returns true on success
static bool prv_pfs_write(int fd, void *buf, size_t size) {
int bytes_wrote = pfs_write(fd, buf, size);
if (bytes_wrote < S_SUCCESS) {
PBL_LOG(LOG_L... |
e_name)) {
// Don't include
continue;
}
// Make sure the rest of the page header contents are valid. We are doing this after the
// filename filter call because it requires more flash reads and is likely slower than the
// filter call.
if (read_header(pg, &pg_hdr, &file_hdr) != PageAndF... | get_avail_fd(name, &fd, is_tmp) | |
+= (has_snooze_action) ? 1 : 0;
num_item_specific_actions += (has_ancs_mute_action) ? 1 : 0;
// Create root level
uint8_t num_actions = num_timeline_actions + num_local_actions;
uint8_t separator_index = num_actions > num_item_specific_actions ? num_item_specific_actions : 0;
ActionMenuLevel *root_level = ti... | ("End Quiet Time", root_level) | :
i18n_get("Start Quiet Time", root_level),
prv_toggle_dnd_from_action_menu,
window_data);
}
return root_level;
}
static void prv_action_menu_did_close(ActionMenu *action_menu, const ActionMenuItem *item,
... |
ecomes the new active layer
prv_set_all_states(recognizers, k_rec_count, RecognizerState_Started);
prv_cancel_layer_tree_recognizers(&manager, &layer_b, &layer_c);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Cancelled);
cl_assert_... | cl_assert_equal_i(recognizers[3]->state, RecognizerState_Possible) | ;
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible);
// All recognizers receive events while none have started recognizing
e.type = TouchEvent_PositionUpdate;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0, 3, 1}, 4, &s_recognizers_handle... |
der[4]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[5]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(4));
cl_assert(timeline_... | (timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(1)) | ;
cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(2));
cl_assert(timeline_model_get_iter_state(2) == timeline_model_get_iter_state_with_timeline_idx(3));
cl_assert(timeline_model_iter_prev(&new_idx, NULL));
cl_assert_equal_i(new_idx, 0);
cl_assert_equal_i(timelin... |
/*
* 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... | assert_encode(vector, sizeof(vector), sizeof(expected)) | |
_a + duration_a);
const int duration_b = 500;
const int delay_b = 200;
const int play_count_b = 3;
const int total_duration_b = play_count_b * (delay_b + duration_b);
const int delay_seq = 150;
const int play_count_seq = 2;
int duration_total = play_count_seq * (total_duration_a + total_duration_b + de... | MAX(total_duration_a, total_duration_b) | );
cl_assert_equal_i(animation_get_duration(spawn, false, true),
play_count_spawn * (MAX(total_duration_a, total_duration_b)));
cl_assert_equal_i(animation_get_duration(spawn, true, false),
delay_spawn + MAX(total_duration_a, total_duration_b));
cl_assert_equal_i(animation_... |
//////////////////////////////////////////////////////////
//! Drawing
static void prv_render_activity_type(GContext *ctx, Layer *layer, KinoReel *icon,
const char *name) {
const GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
const GTextOverflowMode overflow_mode ... | {
WorkoutSummaryWindow *summary_window = app_zalloc_check(sizeof(WorkoutSummaryWindow));
summary_window->start_workout_cb = start_workout_cb;
summary_window->select_workout_cb = select_workout_cb;
Window *window = &summary_window->window;
window_init(window, WINDOW_NAME("Workout Summary"));
window_set_use... | |
DICT_OK, result); \
if (s_received_callback) { \
s_received_callback(&it, NULL); \
} \
} while(0);
#define RCV_RESET_REQUEST() \
RCV_APP_MESSAGE(TupletBytes(PostMessageKeyResetRequest, NULL, 0));
#define RCV_RESET_COMPLETE() \
RCV_APP_MESSAGE(TupletBytes(PostMessageKeyResetComplete, \
... | EXPECT_OUTBOX_RESET_REQUEST() | ;
EXPECT_OUTBOX_MESSAGE_PENDING(TupletBytes(PostMessageKeyResetRequest, NULL, 0));
// TODO: check fields
cl_assert_equal_i(rocky_api_app_message_get_state(),
PostMessageStateAwaitingResetCompleteLocalInitiated);
}
void test_rocky_api_app_message__awaiting_reset_request__disconnect(void) {
... |
t_animation();
animation_set_duration(b, duration_b);
// Create a sequence
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
animation_set_play_count(seq, play_count_seq);
// Check the duration
cl_assert_equal_i(animation_get_duration(seq, true, true), 0);
prv_clear_hand... | prv_count_handler_entries(&s_teardown_handler_calls, b) | , 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a),... |
ecific language governing permissions and
* limitations under the License.
*/
#include "resource_storage_flash.h"
#include "resource_storage_impl.h"
#include "drivers/flash.h"
#include "kernel/pbl_malloc.h"
#include "resource/resource_version.auto.h"
#include "services/normal/process_management/app_storage.h"
#incl... | {
const uint32_t addr = (BANK.begin + (i * SECTOR_SIZE_BYTES)) & SECTOR_ADDR_MASK;
uint8_t status_reg = pbl_28517_flash_impl_get_status_register(addr);
uint32_t crc = flash_calculate_legacy_defective_checksum(addr, SECTOR_SIZE_BYTES);
PBL_LOG(LOG_LEVEL_DEBUG, "PBL-28517 Sector 0x%"PRIx32" Stat... |
}
#endif
uint32_t start_offset = resource_store_get_metadata_size(entry) + entry_offset;
return flash_calculate_legacy_defective_checksum(
BANK.begin + start_offset, num_bytes);
}
static uint32_t resource_storage_system_bank_read(ResourceStoreEntry *entry, uint32_t offset,
... |
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, O... | (&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// SW = 11
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.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... | (layer->bounds, GEdgeInsets(-overdraw)) | ,
GOvalScaleModeFillCircle, crumbs_layer_width(), 0, TRIG_MAX_ANGLE);
}
void crumbs_layer_set_level(CrumbsLayer *crumbs_layer, int level) {
const int max_crumbs = prv_crumb_maximum_count();
if (level > max_crumbs) {
PBL_LOG(LOG_LEVEL_WARNING, "exceeded max number of crumbs");
level =... |
/*
* 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 (md->process_storage == ProcessStorageFlash) {
return ((const PebbleProcessMdFlash*) md)->res_bank_num;
} |
return 0;
}
ResourceVersion process_metadata_get_res_version(const PebbleProcessMd *md) {
if (md->process_storage == ProcessStorageFlash) {
return ((const PebbleProcessMdFlash*) md)->res_version;
}
return (ResourceVersion) { 0, 0 } ;
}
const uint8_t *process_metadata_get_build_id(const PebbleProcessMd *m... |
return;
}
bool layer_is_status_bar_layer(Layer *layer) {
return false;
}
void status_bar_layer_render(GContext *ctx, const GRect *bounds, void *config) {
return;
}
GDrawState graphics_context_get_drawing_state(GContext* ctx) {
GDrawState state;
memset(&state, 0, sizeof(GDrawState));
return state;
}
void ... | cl_check(window->parent_window_stack) | ;
cl_assert_equal_i(window->on_screen, true);
cl_assert_equal_i(window->is_loaded, false);
window_stack_push(window->parent_window_stack, new_window, true);
}
static void prv_pop_window_load(Window *window) {
prv_window_load(window);
cl_check(window->parent_window_stack);
cl_assert_equal_i(window->on_scr... |
}
settings_file_close(file);
// We have to close and reopen the new_file so that it's temp flag is cleared.
// Before the close succeeds, if we reboot, we will just end up reading the
// old file. After the close suceeds, we will end up reading the new
// (compacted) file.
char *name = kernel_strdup(new_f... | {
settings_raw_iter_resume(&file->iter);
if (search_forward(&file->iter, key, key_len)) {
return file->iter.hdr.val_len;
} else {
return 0;
}
} | |
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
// check rollover behaviour
cl_assert(!iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].head... | (&iterator, &state, &head, TimelineIterDirectionPast,
s_feb_5_midnight + 5 * 60 * 60) | |
,
{ 1592, 8, 288},
{ 1336, 160, 152},
{ 1192, 360, 48},
{ 976, 272, 48},
{ 656, 128, 104},
{ 688, 80, 112},
{ 728, 24, 208},
{ 736, 176, 112},
{ 776, 224, 32},
{ 776, 224, -24},
{ 832, 208, 0},
{ 864, 208, 0},
{ 1056, 176, 24},
{ 1168, 120, 112},
{ 1344, 152, ... | { 768, -16, 128},
{ 752, -16, 144},
{ 832, 96, 72},
{ 792, 176, 112},
{ 744, 232, -8},
{ 720, 208, -72},
{ 752, 144, 8},
{ 760, 160, -40},
{ 928, 136, 48},
{ 1080, 176, 168},
{ 1296, 192, 192},
{ 1632, 296, 152},
{ 1288, 464, 136},
{ 1072, 312, 16},
{ 944, 328... |
{ 976, 256, 64},
{ 1104, 240, -24},
{ 1056, 48, 304},
{ 920, 168, 8},
{ 816, 72, 112},
{ 744, 88, 64},
{ 696, 72, 96},
{ 624, 32, 72},
{ 608, 64, 72},
{ 712, 56, 120},
{ 976, 144, 112},
{ 1288, 48, 328},
{ 1920, -96, 496},
{ 1544, 640, -64},
{ 968, 768, -288}... |
// StateStopWaitForReady
StateRecording,
StateWaitForResponse, // StateStopRecording
StateWaitForResponse,
StateTransitionToText, // StateStopWaitForResponse
StateTransitionToText,
StateError,
StateFinished,
StateExiting,
};
_Static_assert(StateExiting < ARRAY_LENGTH(state_map... | graphics_fill_circle(ctx, grect_center_point(&layer->bounds), data->mic_window.mic_dot_radius) | ;
}
static void prv_set_dot_width(void *subject, int16_t radius) {
VoiceUiData *data = subject;
data->mic_window.mic_dot_radius = radius;
layer_mark_dirty(&data->mic_window.mic_dot_layer);
}
static PropertyAnimation *prv_create_int16_prop_anim(int16_t from, int16_t to,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return Date.now().getMilliseconds;
} | );
const double wait_ms = 1000 - ms_into_s;
const bool is_update_due_to_time_change = false;
emscripten_async_call(prv_do_update, (void *)(uintptr_t)is_update_due_to_time_change, wait_ms);
}
void tick_timer_service_handle_time_change(void) {
const bool is_update_due_to_time_change = true;
prv_do_update((void... |
p more than this many times, something is seriously wrong
while (--max_loops) {
RTC_TimeTypeDef rtc_time_before;
RTC_GetTime(RTC_Format_BIN, &rtc_time_before);
RTC_GetDate(RTC_Format_BIN, &rtc_date);
// See reference manual section 26.6.11 for SSR to milliseconds conversion
sub_seconds = RTC_GetS... | RTC_ITConfig(RTC_IT_WUT, ENABLE) | ;
s_alarm_set_time_milliseconds_since_epoch = prv_get_time_milliseconds_since_epoch();
}
RtcTicks rtc_alarm_get_elapsed_ticks(void) {
uint64_t now = prv_get_time_milliseconds_since_epoch();
PBL_ASSERTN(now >= s_alarm_set_time_milliseconds_since_epoch);
uint64_t milliseconds_elapsed = now - s_alarm_set_time_mi... |
sk | MPU_CTRL_PRIVDEFENA_Msk);
}
void mpu_disable(void) {
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
}
// Get the required region base address and region attribute register settings for the given region.
// These are the values which should written to the RBAR and RASR registers to configure that
// region.
void mpu_get_re... | (mpu_region, &base_reg, &attr_reg) | ;
}
memory_regions[region_idx] = (MemoryRegion_t) {
.pvBaseAddress = (void *)mpu_region->base_address,
.ulLengthInBytes = mpu_region->size,
.ulParameters = attr_reg,
};
}
}
bool mpu_memory_is_cachable(const void *addr) {
if (!dcache_is_enabled()) {
return false;
}
// TODO PB... |
ken for a long time when a PutBytes message is prepared,
// expect to receive a Nack:
// Take and hold for a long time:
xSemaphoreTake(put_bytes_get_semaphore(), portMAX_DELAY);
fake_queue_set_yield_callback(put_bytes_get_semaphore(), prv_taking_too_long_yield_cb);
prv_receive_init(4, ObjectFirmware);
//... | assert_ack_count(0) | |
oid test_hrm_manager__update_interval(void) {
AppInstallId app_id = 1;
uint32_t update_interval_s = 600;
const uint16_t expire_s = 30 * SECONDS_PER_MINUTE;
HRMFeature features = HRMFeature_BPM;
HRMSessionRef session_ref = sys_hrm_manager_app_subscribe(app_id, update_interval_s, expire_s,
... | hrm_is_enabled(HRM) | );
s_activity_prefs_heart_rate_is_enabled = true;
hrm_manager_handle_prefs_changed();
cl_assert(prv_can_turn_sensor_on());
fake_system_task_callbacks_invoke_pending();
cl_assert(hrm_is_enabled(HRM));
// Test charging state changes
prv_put_battery_state_change_event(true /* is plugged in */);
cl_assert... |
GTextAlignmentRight : GTextAlignmentCenter));
uint16_t right_aligned_box_reduction = PBL_IF_RECT_ELSE(0, show_action_bar ? 10 : 0);
if (has_header) {
const uint16_t HEADER_OFFSET = 6;
#if PBL_RECT
x = left_margin_px;
w = frame.size.w - right_margin_px - left_margin_px - action_bar_offset
... | (action_bar, BUTTON_ID_SELECT,
expandable_dialog->select_icon, expandable_dialog->show_action_icon_animated) | ;
}
action_bar_layer_set_context(action_bar, expandable_dialog);
action_bar_layer_set_click_config_provider(action_bar, prv_config_provider);
action_bar_layer_add_to_window(action_bar, window);
} else {
window_set_click_config_provider_with_context(window, prv_config_provider, expandable_dialog);
... |
W and Normal FW
// fault handling the way they are now.
static uint32_t s_fault_saved_sp;
static uint32_t s_fault_saved_lr;
static uint32_t s_fault_saved_pc;
void enable_fault_handlers(void) {
NVIC_SetPriority(MemoryManagement_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY);
NVIC_SetPriority(BusFault_IRQn, configMAX_S... | {
sys_app_fault(lr);
} |
}
NORETURN trigger_oom_fault(size_t bytes, uint32_t lr, Heap *heap_ptr) {
if (mcu_state_is_privileged()) {
RebootReason reason = {
.code = RebootReasonCode_OutOfMemory,
.heap_data = {
.heap_alloc_lr = lr,
.heap_ptr = (uint32_t)heap_ptr,
}
};
reboot_reas... |
just do it safely.
return *(volatile uint8_t*)&bus->spi->DR;
#else
return bus->spi->DR;
#endif
}
void prv_spi_enable_peripheral_clock(const SPIBus *bus) {
periph_config_enable(bus->spi, bus->state->spi_clock_periph);
}
void prv_spi_disable_peripheral_clock(const SPIBus *bus) {
periph_config_disable(bus->spi, ... | prv_spi_pick_peripheral(bus) | |
ould be since we have no data
int32_t last_median;
int32_t last_update_utc;
activity_get_metric(ActivityMetricHeartRateFilteredBPM, 1, &last_median);
activity_get_metric(ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1, &last_update_utc);
cl_assert_equal_i(last_median, 0);
cl_assert_equal_i(last_update_utc,... | cl_assert_equal_i(s_num_hr_events, 3) | ;
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 0);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.quality, HRMQuality_OffWrist);
// Should fire off an event. Good HR and Good Quality
prv_advance_time_hr(1 /*sec*/, 120 /*hr*/, HRMQuality_Excellent, true /*force_continuous*/);
... |
written + calc_size;
// If it fits, add it. If it doesn't, flush first.
if (size_if_added > session->max_data_size) {
// We would be over capacity if we added this message. Let's flush first.
PROTOBUF_LOG_DEBUG("Session: 0x%x - Would have been over limit at size %"PRIu32", flushing",
... | PBL_LOG(LOG_LEVEL_ERROR, "Failure when sending encoded message, resetting session") | |
EventedTimer* timer = (EventedTimer*) iter;
ListNode* next = list_get_next(iter);
if (timer->target_task == task) {
list_remove(iter, &s_timer_list_head, NULL);
// The delete operation will stop it for us
new_timer_delete(timer->sys_timer_id);
kernel_free(timer);
}
iter = ... | (timer_id) | ;
if (!timer) {
PBL_LOG(LOG_LEVEL_DEBUG, "Attempting to cancel an invalid timer (id=%u)", (unsigned)timer_id);
mutex_unlock(s_mutex);
return;
}
new_timer_delete(timer->sys_timer_id); // This automatically stops the timer for us first
list_remove(&timer->list_node, &s_timer_list_head, NULL);
ke... |
GRect window_bounds = window_layer->bounds;
// Calculate the bounding rect for the certification content and center it in the window
GBitmap *bmp = &data->kcc_mark;
const GSize bmp_size = bmp->bounds.size;
const GFont title_text_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
const GSize title_tex... | (a_dialog, DialogActionBarConfirm, NULL) | ;
actionable_dialog_set_click_config_provider(a_dialog, prv_shutdown_click_provider);
dialog_set_text_color(dialog, GColorWhite);
dialog_set_background_color(dialog, GColorCobaltBlue);
dialog_set_text(dialog, i18n_get("Do you want to shut down?", a_dialog));
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_QUESTI... |
false or there was no notification after the focusing one.
// Just set the current notification and reload data.
notifications_presented_list_set_current(id);
prv_reload_swap_layer(data);
}
void notification_window_service_init(void) {
s_notification_window_mutex = mutex_create();
s_notification_window_data... | (id, notifications_presented_list_current()) | |
lMenuItemIndex;
typedef struct AlarmDetailData {
ActionMenuConfig menu_config;
AlarmId alarm_id;
AlarmInfo alarm_info;
AlarmEditorCompleteCallback alarm_editor_callback;
void *callback_context;
} AlarmDetailData;
static SimpleDialog *prv_snooze_set_confirm_dialog(void) {
SimpleDialog *simple_dialog = s... | if (!level) return NULL; |
*level = (ActionMenuLevel) {
.num_items = NUM_SNOOZE_MENU_ITEMS,
.parent_level = parent_level,
.display_mode = ActionMenuLevelDisplayModeWide,
};
return level;
}
void prv_cleanup_alarm_detail_menu(ActionMenu *action_menu,
const ActionMenuItem *item,
... |
},
{ 448, 224, -840},
{ 448, 216, -840},
{ 456, 232, -840},
{ 440, 240, -848},
{ 448, 224, -832},
{ 440, 264, -840},
{ 440, 184, -840},
{ 464, 216, -840},
{ 440, 304, -824},
{ 440, 344, -792},
{ 464, 416, -816},
{ 440, 320, -800},
{ 456, 328, -816},
{ 432, 344, -8... | { 424, 512, -736},
{ 464, 440, -720},
{ 408, 528, -752},
// 177 seconds
{ 424, 376, -768},
{ 432, 488, -736},
{ 424, 480, -736},
{ 416, 472, -752},
{ 424, 488, -808},
{ 288, 496, -640},
{ 416, 480, -784},
{ 352, 384, -696},
{ 416, 472, -736},
{ 456, 544, -776},
... |
{ 432, 520, -728},
{ 440, 512, -664},
{ 456, 496, -768},
{ 448, 424, -792},
{ 432, 320, -800},
{ 424, 424, -824},
{ 424, 360, -768},
{ 424, 280, -712},
{ 424, 280, -784},
{ 448, 224, -808},
{ 472, 312, -912},
// 180 seconds
// elapsed: 3 minutes
{ 400, 336, -800}... |
e second separator in `<hour>:<minute>:<second>`
i18n_ctx_noop("TmplStringSep", ":"), },
/// The first separator in `<hour> hr <minute> min <second> sec`
{ i18n_ctx_noop("TmplStringSep", " "),
/// The second separator in `<hour> hr <minute> min <second> sec`
i18n_ctx_noop("TmplStringSep", " "), },
/// T... | ("TmplStringSing", "") | ,
/// Plural suffix for hours with no units
i18n_ctx_noop("TmplStringPlur", "")},
/// Singular suffix for hours with abbreviated units
{ i18n_ctx_noop("TmplStringSing", " hr"),
/// Plural suffix for hours with abbreviated units
i18n_ctx_noop("TmplStringPlur", " hr")},
/// Singular suffix for hours wit... |
void (*func)(GContext *, GColor)) {
GColor color;
const RockyArgBinding binding = ROCKY_ARG(color);
JS_VAR error_value = rocky_args_assign(argc, argv, &binding, 1);
// Canvas APIs do a no-op if the color string is invalid
if (!jerry_value_has_error_flag(error_value)) {
func(rocky_api_graphics_ge... | rocky_add_constructor(ROCKY_CONTEXT2D_CONSTRUCTOR,
prv_canvas_rendering_context_2d_constructor) | ;
jerry_set_object_field(ctx_prototype, ROCKY_CONTEXT2D_CANVAS, jerry_create_undefined());
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_CLEARRECT, prv_clear_rect);
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_FILLRECT, prv_fill_rect);
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_FILLRADIAL, prv_... |
while (buffer_size--) {
*buffer = flash_read_next_byte();
buffer++;
} |
} else {
enable_flash_dma_clock();
setup_dma_read(buffer, buffer_size);
do_dma_transfer();
disable_flash_dma_clock();
}
flash_end_cmd();
disable_flash_spi_clock();
power_tracking_stop(PowerSystemFlashRead);
flash_unlock();
}
void flash_write_bytes(const uint8_t* buffer, uint32_t start_a... | |
ModeWordWrap, GTextAlignmentCenter, NULL);
}
static void prv_cell_item_draw(GContext *ctx, const Layer *cell_layer,
ActionMenuLayer *aml, const ActionMenuItem *item,
bool selected) {
GRect label_text_container = cell_layer->bounds;
// bottom_inset won't... | (aml->num_short_items - base_idx, 0, SHORT_COL_COUNT) | ;
prv_cell_column_draw(ctx, cell_layer, aml, (ActionMenuItem *)&aml->short_items[base_idx],
num_items, sel_idx);
}
}
static int prv_get_menu_layer_row(ActionMenuLayer *aml, int item_index) {
if (item_index < aml->num_items) {
return item_index;
} else {
return aml->num_items ... |
k 1:
{
const size_t json_bytes_size = MIN(TINY_CHUNK_SIZE, json_bytes_remaining);
const size_t expected_size = sizeof(PostMessageChunkPayload) + json_bytes_size;
PostMessageChunkPayload *chunk = (PostMessageChunkPayload *)buffer;
*chunk = (PostMessageChunkPayload) {
.total_size_bytes = expected... | {
prv_init_api(false /* start_connected */);
fake_malloc_set_largest_free_block(0);
EXECUTE_SCRIPT_EXPECT_ERROR("_rocky.postMessage('x');",
"RangeError: Out of memory: can't postMessage() -- object too large");
} |
////////////////////////////////////////////////////////////////////////////////
// Receive Tests
////////////////////////////////////////////////////////////////////////////////
void test_rocky_api_app_message__receive_message_multi_chunk(void) {
prv_init_and_goto_session_open_with_tiny_buffers();
EXECUTE_SCRIP... |
/*
* 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... | MIN((int)sample_count, s_timeout) | ;
s_timeout -= to_process;
if (to_process > 0) {
// Groups of samples are encapsulated in HDLC-like framing in order to verify the integrity of
// samples
prv_put_hdlc_frame_delimiter();
int num_bytes = (to_process * (s_is_8_bit ? 1 : 2)) / (MIC_SAMPLE_RATE/OUTPUT_SAMPLE_RATE);
// Store frame... |
epCount,
time_util_get_midnight_of(now),
now + 12345);
cl_assert_equal_i(result, 1000);
// yesterday
result = health_service_sum(HealthMetricStepCount,
time_util_get_midnight_of(now) - SECONDS_PER_DAY,
... | (HealthMetricStepCount,
time_util_get_midnight_of(now),
(time_util_get_midnight_of(now) + now) / 2) | |
2_t start_addr, uint32_t buffer_size);
// ----------------------------------------------------------------------------------------
// Private globals
static uint32_t s_flash_addr; // next address in flash to write to
// Saved registers before we trigger our interrupt: [r0-r12, sp, lr, pc, xpsr]
stat... | pulse_logging_log_sync_begin(LOG_LEVEL_ALWAYS, __FILE_NAME__, 0) | ;
pulse_logging_log_sync_append(ctx, msg);
pulse_logging_log_sync_append(ctx, s);
pulse_logging_log_sync_send(ctx);
#else
int max_length = 256;
while (*msg && max_length--) {
dbgserial_putchar(*msg);
++msg;
}
dbgserial_putstr(s);
#endif
}
// ------------------------------------------------------... |
g at 9pm. This will leave us at 11pm. Since this
// session ends after the the cutoff, it should be registered for the next day
prv_feed_cannned_accel_data(120 * SECONDS_PER_MINUTE, 0, ActivitySleepStateLightSleep);
// Awake for 2 hours which puts us at 1am
prv_feed_cannned_accel_data(120 * SECONDS_PER_MINUTE,... | cl_assert_equal_i(seconds,
(k_raw_samples + ALGORITHM_SAMPLING_RATE - 1) / ALGORITHM_SAMPLING_RATE) | ;
// Verify the collected data
AccelRawData 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));
}
}
// ----------------------------------------------------------------------------... |
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "send all sessions: empty %s connected %s counter %u",
bool_to_str(check_counter == 0),
bool_to_str(comm_session_get_system_session() != NULL),
check_counter);
system_task_add_callback(prv_send_all_sessions_system_task_cb,
... | regular_timer_add_multiminute_callback(&prv_check_all_sessions_timer_info,
DATALOGGING_DO_FLUSH_CHECK_INTERVAL_MINUTES) | ;
}
// ----------------------------------------------------------------------------------------
void dls_init(void) {
dls_endpoint_init();
dls_list_init();
// rebuild data logging_sessions
dls_storage_rebuild();
// add callbacks to empty and check logging_sessions
dls_resume();
s_initialized = true;
}... |
rn jerry_string_to_utf8_char_buffer(value, buffer_p, buffer_size);
}
jerry_size_t jerry_object_to_string_to_utf8_char_buffer(const jerry_value_t object,
jerry_char_t *buffer_p,
jerry_size_t buffer_size) {
... | jerry_value_has_error_flag(value) | ) {
return TYPE_ERROR_FLAG;
}
return (jerry_value_t)EM_ASM_INT({
return __jerryRefs.ref(new Object(__jerryRefs.get($0)));
}, value);
}
jerry_value_t jerry_value_to_primitive(const jerry_value_t value) {
if (jerry_value_has_error_flag(value)) {
return TYPE_ERROR_FLAG;
}
return (jerry_value_t... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | GRect(0, 0, 30, 40) | );
// expands
layer_set_frame(&l, &GRect(10, 20, 300, 400));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 300, 400));
// keeps size in sync
layer_set_frame(&l, &GRect(10, 20, 200, 500));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 200, 500));
// act as 2.x once bounds.origin is different from (0, 0)
l... |
.raw_value = -sine_val };
GTransformNumber c = (GTransformNumber) { .raw_value = sine_val };
GTransformNumber d = (GTransformNumber) { .raw_value = cosine_val };
return GTransform(a, b, c, d, GTransformNumberZero, GTransformNumberZero);
} else {
return GTransformIdentity();
}
}
///////////////////... | (ty, t->c) | |
gnature
static void prv_process_receive_buffer(void *context) {
uint32_t msg_bytes;
uint16_t protocol;
// Process ISR receive buffer, see if we have a complete message
// Prevent our ISR from putting more characters in while we muck with the receive buffer by
// disabling UART interrupts while we process it... | ((uint8_t *)&footer, sizeof(footer)) | ;
mutex_unlock(s_qemu_state.qemu_comm_lock);
}
|
s_X:
return GAxis_Y;
case GAxis_Y:
return GAxis_X;
}
return GAxis_X;
}
GTextNodeText *graphics_text_node_create_text(size_t buffer_size) {
GTextNodeText *text_node = task_zalloc(sizeof(GTextNodeText) + buffer_size);
if (text_node) {
*text_node = (GTextNodeText) {
.node.type = GTextNod... | (size, max_size) | ;
}
static void prv_draw_text_node_text(GTextNodeDrawContext *ctx) {
GTextNodeText *text_node = (GTextNodeText *)ctx->node;
prv_clip_size(&ctx->box.size, &text_node->max_size);
TextLayoutExtended layout = {
.line_spacing_delta = text_node->line_spacing_delta,
};
const GTextNodeDrawConfig *config = ctx->c... |
OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 10);
graphics_line_draw_precise_stroked_aa(&ctx, END_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_same_point_offset_layer_aa.${BIT_DEPTH_NAME}.pbi"));
#endif
}
void test_graphics_draw_stroke_precise_${BIT_DEP... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_close_points_around_1px_aa.${BIT_DEPTH_NAME}.pbi")) | ;
#endif
}
void test_graphics_draw_stroke_precise_${BIT_DEPTH_NAME}__close_points_non_aa(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 10);
graphics_line_draw_precise_stroked_non_aa(&ctx, CLOSE_POINTS_LESS_THAN_1PX_STAR... |
exti_enable(BOARD_CONFIG_ACCEL.accel_ints[i]);
}
}
static void clear_accel_interrupts(void) {
for (unsigned int i = 0; i < ARRAY_LENGTH(BOARD_CONFIG_ACCEL.accel_ints); i++) {
EXTI_ClearFlag(BOARD_CONFIG_ACCEL.accel_ints[i].exti_line);
EXTI_ClearITPendingBit(BOARD_CONFIG_ACCEL.accel_ints[i].exti_line);... | get_axis_data(ACCEL_AXIS_Z, ptr) | ;
s_accel_data = *data;
data++;
}
}
void lis3dh_init(void) {
PBL_ASSERTN(!s_initialized);
lis3dh_init_mutex();
s_initialized = true;
if (!accel_start()) {
s_initialized = false;
return;
}
if (!lis3dh_config_set_defaults()) {
// accel write will call reset if it fails, so just try ... |
at doesn't exist
bt_persistent_storage_delete_bt_classic_pairing_by_id(9);
cl_assert_equal_i(fake_shared_prf_storage_get_bt_classic_delete_count(), 3);
// Make sure the pairing is actually still there
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
... | bt_persistent_storage_get_active_gateway(&id_out, &type_out) | ;
cl_assert(ret);
cl_assert_equal_i(id_out, id_1);
cl_assert_equal_i(type_out, BtPersistBondingTypeBTClassic);
ret = bt_persistent_storage_has_active_bt_classic_gateway_bonding();
cl_assert(ret);
ret = bt_persistent_storage_has_active_ble_gateway_bonding();
cl_assert(!ret);
// Store another BT Classic... |
/*
* 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... | ASSERT_JS_ERROR(error_value, NULL) | |
8},
{ 1072, -64, 32},
{ 680, -152, -16},
// 108 seconds
{ 1008, -160, -48},
{ 1320, -120, 72},
{ 1408, 128, -112},
{ 1504, 128, -48},
{ 1512, 104, -16},
{ 1224, 216, -112},
{ 952, 184, -96},
{ 1000, 224, -48},
{ 1080, 240, -8},
{ 1080, 272, -40},
{ 944, 320, -72}... | { 16, 40, -992},
{ 32, 96, -1064},
{ 16, 184, -944},
{ 56, 384, -888},
{ -112, 392, -920},
{ 0, 416, -904},
{ -40, 520, -920},
{ -104, 352, -944},
};
*len = ARRAY_LENGTH(samples);
return samples;
} |
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 16:15:30 local
AccelRawData *activity_sample_walk_200_pbl_25667_15(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_25667_15
//> TEST_EXPECTED 200
//>... |
_buffer();
if (s_state.out.object_queue) {
// Still not open and still things in the object queue, restart the timer:
prv_start_session_closed_object_queue_timer();
}
}
static void prv_start_session_closed_object_queue_timer(void) {
PBL_ASSERTN(EVENTED_TIMER_INVALID_ID == s_state.out.session_closed_obje... | task_free(node) | |
fonts_get_system_font(FONT_KEY_LECO_38_BOLD_NUMBERS));
text_layer_set_background_color(data->steps_card.cur_step_layer, GColorClear);
text_layer_set_text_color(data->steps_card.cur_step_layer, GColorWhite);
layer_add_child(window_layer, text_layer_get_layer(data->steps_card.cur_step_layer));
//... | (text_layer_get_layer(data->steps_card.cur_step_layer), false) | ;
layer_set_hidden(text_layer_get_layer(data->steps_card.time_layer), false);
layer_set_hidden(text_layer_get_layer(data->steps_card.delta_step_layer), false);
}
// -------------------------------------------------------------------------------
static void prv_results_back_click_handler(ClickRecognizerRef recogniz... |
singJobTagReconnection: return "RCN";
case GAPLEAdvertisingJobTagiOSAppLaunch: return "iOS";
default: return "?";
}
}
// -----------------------------------------------------------------------------
//! Helpers to manage the s_jobs list
//! bt_lock is expected to be taken with all of them!
static bool prv_i... | prv_increment_elapsed_time_for_job(&job, NULL) | ;
}
job = next;
} while (job != s_jobs);
}
// -----------------------------------------------------------------------------
//! Cycle timer callback.
//! It increments the air-time counter of the job's current term.
//! Updates the job's term if the term is done.
//! It removes the job if it's done.
//! It u... |
{ -56, 40, -904},
{ -40, 56, -928},
{ -184, 152, -1160},
{ -80, 136, -952},
// 182 seconds
{ -112, 48, -680},
{ -88, 56, -1064},
{ -8, -80, -1040},
{ -72, 304, -1096},
{ -80, 104, -784},
{ -40, -16, -960},
{ -104, 152, -1120},
{ -40, 40, -744},
{ -184, 200, -1056},
... | { 80, 168, -960},
{ 72, 176, -976},
{ 72, 264, -968},
{ 0, 192, -904},
{ -48, 152, -944},
{ 0, 104, -912},
{ 8, 72, -944},
{ 80, -8, -960},
{ 64, -200, -904},
{ 32, -288, -1024},
{ -40, -288, -1064},
{ -88, -384, -904},
// 188 seconds
{ 112, -168, -1024},
{ -2... |
{ -96, -72, -1008},
{ -96, -80, -992},
{ -104, -56, -1008},
{ -104, -80, -1016},
{ -104, -72, -976},
{ -96, -56, -992},
{ -112, -88, -1008},
{ -104, -72, -992},
{ -96, -56, -992},
{ -96, -64, -992},
{ -96, -80, -1000},
{ -96, -80, -984},
{ -96, -64, -984},
{ -96,... |
rrent_temp,
.today_high = entry->today_high_temp,
.today_low = entry->today_low_temp,
.current_weather_type = entry->current_weather_type,
.tomorrow_high = entry->tomorrow_high_temp,
.tomorrow_low = entry->tomorrow_low_temp,
.tomorrow_weather_type = entry->tomorrow_weather_type,
.time_update... | if (prv_fill_forecast_from_entry(entry, forecast_out)) {
s_default_forecast = forecast_out;
} else {
task_free(forecast_out);
} |
free_entry:
task_free(entry);
cleanup:
mutex_unlock(s_mutex);
}
WeatherLocationForecast *weather_service_create_default_forecast(void) {
mutex_lock(s_mutex);
WeatherLocationForecast *forecast = NULL;
if (s_default_forecast) {
forecast = task_zalloc_check(sizeof(WeatherLocationForecast));
*forecast ... |
/*
* 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_get_time() | ^ (uintptr_t) &seed;
}
srand(seed);
}
|
ion_set_custom_function(animation_h,
AnimationCurveCustomFunction,
curve_function);
}
// -------------------------------------------------------------------------------------------
bool animation_set_custom_interpolation(Animation *a... | {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
PBL_ASSERTN(!animation_private_using_legacy_2(state));
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!animation) {
return false;
}
return animation->reverse;
} |
// -------------------------------------------------------------------------------------------
bool animation_set_play_count(Animation *animation_h, uint32_t play_count) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
PBL_ASSERTN(!animation_private_using_legacy_2(state));
AnimationPrivate... |
{"darkblue", GColorARGB8FromHEX(0x00008b)},
{"darkcyan", GColorARGB8FromHEX(0x008b8b)},
{"darkgoldenrod", GColorARGB8FromHEX(0xb8860b)},
// {"darkgray", GColorARGBFromHEX(0xa9a9a9)}, inconsistent with Pebble color
// {"darkgreen", GColorARGBFromHEX(0x006400)}, inconsistent with Pebble color
// {"darkgrey", GCol... | GColorARGB8FromHEX(0x98fb98) | },
{"paleturquoise", GColorARGB8FromHEX(0xafeeee)},
{"palevioletred", GColorARGB8FromHEX(0xdb7093)},
{"papayawhip", GColorARGB8FromHEX(0xffefd5)},
{"peachpuff", GColorARGB8FromHEX(0xffdab9)},
{"peru", GColorARGB8FromHEX(0xcd853f)},
{"pink", GColorARGB8FromHEX(0xffc0cb)},
{"plum", GColorARGB8FromHEX(0xdda0... |
= 3;
box = grect_inset(box, GEdgeInsets(border_width, 0));
const GColor label_background_color = GColorWhite;
graphics_context_set_fill_color(ctx, label_background_color);
graphics_fill_rect(ctx, &box);
}
//! Get the corresponding data point for a weekday.
//! Sunday is 0, and the day data begins with today a... | fonts_get_font_height(graph_card->legend_font) | ;
const GRect *bounds = &graph_card->layer.bounds;
GRect box = { .origin.x = (bounds->size.w - total_bar_widths) / 2, .origin.y = LABEL_OFFSET_Y };
// The first day to draw is Monday, and draw a week's worth of bars
for (int i = Monday, draw_count = 0;
draw_count < DAYS_PER_WEEK;
draw_count++, i =... |
org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* li... | cl_assert_equal_i(event.type, PEBBLE_PHONE_EVENT) | ;
cl_assert_equal_i(event.phone.type, PhoneEventType_Incoming);
cl_assert_equal_i(event.phone.source, PhoneCallSource_ANCS_Legacy);
}
void test_ancs_notifications__handle_phone_call_removed(void) {
const uint32_t uid = 5;
// Make sure we don't send any events when this isn't iOS9
ancs_notifications_handle_n... |
72, -248},
{ 1232, -112, -304},
{ 944, -376, -144},
{ 728, -456, -168},
{ 504, -464, -224},
{ 344, -384, -288},
{ 704, -232, -208},
{ 728, -56, -208},
{ 1192, 16, -360},
{ 1832, 0, -344},
{ 2736, 48, -344},
{ 2912, 320, -624},
// 42 seconds
{ 2088, 384, -248},
{ 1... | { 1040, -104, -96},
{ 1120, 32, -216},
{ 1512, 104, -216},
{ 2176, 216, -440},
{ 2376, 280, -408},
{ 2088, 416, -496},
{ 1592, 448, -312},
{ 1312, 480, -448},
{ 880, 504, -184},
{ 680, 680, -48},
{ 584, 976, 144},
{ 504, 872, 168},
{ 1096, 1064, 344},
{ 1472, 840,... |
{ 2544, 640, -32},
{ 2528, 384, -40},
{ 2184, 320, 24},
{ 1800, -128, 40},
{ 1592, -264, -32},
{ 1088, -272, -128},
{ 816, -144, -136},
// 50 seconds
{ 752, -192, -152},
{ 544, -280, -64},
{ 408, -256, -40},
{ 968, -56, -104},
{ 1016, 72, -192},
{ 1712, 80, -192}... |
ting_click_subscribe(BUTTON_ID_DOWN, VOLUME_REPEAT_INTERVAL_MS,
prv_volume_click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, prv_play_pause_click_handler);
}
static void prv_update_layout(MusicAppData *data) {
// Hide track position bar if progress reporting ... | strncmp(data->artist_buffer, artist_buffer, MUSIC_BUFFER_LENGTH) | != 0;
if (title_changed || artist_changed) {
// Animating nothing looks weird, so don't do that.
if (data->artist_buffer[0] == 0 && data->title_buffer[0] == 0) {
strncpy(data->artist_buffer, artist_buffer, MUSIC_BUFFER_LENGTH);
strncpy(data->title_buffer, title_buffer, MUSIC_BUFFER_LENGTH);
... |
rotocol_system_nack_callback(CommSession *session,
const uint8_t* data, size_t length) {
if (prv_has_invalid_header_length(length)) {
return;
}
AppMessageHeader *message = (AppMessageHeader *) data;
if (message->command != CMD_PUSH) {
return;
}
app_... | app_state_get_app_message_ctx() | |
pebble_task_get_current() | ;
TimerID *timer_id;
if (task == PebbleTask_KernelMain) {
timer_id = &s_kernel_main_timer_id;
} else if (task == PebbleTask_App) {
timer_id = &s_app_timer_id;
} else {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_failed();
}
return;
}
// Need to create the timer?
bool success = false;... | |
atus != BTErrnoOK) {
// gatt_client_discovery.c already logs errors for this condition
return;
}
if (event_info->type != PebbleServicesRemoved) {
// For removals, we log info in the handler routine
PBL_LOG(LOG_LEVEL_INFO, "Service changed Indication: type: %d status: %d",
event_info->ty... | (header.characteristic, buffer, header.value_length,
BLEGATTErrorSuccess) | ;
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "No client to handle GATT notification from characteristic %p",
(void*) header.characteristic);
}
kernel_free(buffer);
header.value_length = next_value_length;
}
}
static void prv_handle_gatt_event(const PebbleBLEGATTClientEvent *event) {
if (... |
ses these variables outside of the block
// when dealing with round displays, sizes change depending on location.
const GRect probe_rect = GRect(x, y + text_single_line_text_offset_px,
w, max_text_line_height_px);
text_height = graphics_text_layout_get_max_used_size(ctx,
... | if (workout_dialog->dialog.destroy_on_pop) {
applib_free(workout_dialog);
} |
}
void workout_dialog_init(WorkoutDialog *workout_dialog, const char *dialog_name) {
PBL_ASSERTN(workout_dialog);
*workout_dialog = (WorkoutDialog){};
dialog_init(&workout_dialog->dialog, dialog_name);
Window *window = &workout_dialog->dialog.window;
window_set_window_handlers(window, &(WindowHandlers) {
... |
turn 0;
}
iter->end = iter->cursor;
return dict_size(iter);
}
//! Returns the cursor, or NULL if the tuple at cursor extends beyond the bounds of the backing storage
static Tuple * get_safe_cursor(DictionaryIterator *iter) {
// If iter->cursor is already at the end, return now so we don't try and read past the... | (iter, buffer, *size_in_out) | ) != DICT_OK) {
return result;
}
for (unsigned int i = 0; i < tuplets_count; ++i) {
if ((result = dict_write_tuplet(iter, &tuplets[i])) != DICT_OK) {
return result;
}
}
*size_in_out = dict_write_end(iter);
return DICT_OK;
}
// Legacy version to prevent previous app breakage, __deprecated pr... |
fter_size;
// lets save ids 17, 25, 42, and 47 because they are my favorite numbers
uint32_t after_free = t_data[16].size + t_data[24].size + t_data[41].size + t_data[46].size;
s_test_id_ql_up = 17;
s_test_id_ql_down = 25;
s_test_id_watchface = 42;
s_test_id_worker = 47;
// test removing all and more b... | (filename) | ;
prv_res_filename(filename, sizeof(filename), id);
prv_check_file_exists(filename);
}
// finally, make sure the 'standard' files are all there
for (uint32_t i = 0; i < ARRAY_LENGTH(descriptions); ++i) {
prv_check_file_exists(descriptions[i].name);
}
}
void test_app_cache__purge_orphaned_files_no_a... |
super-old notifications
if (prv_should_ignore_because_stale(timestamp)) {
return true;
}
return false;
}
void ancs_notifications_handle_message(uint32_t uid,
ANCSProperty properties,
ANCSAttribute **notif_attributes,
... | (notification, &existing_header) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.