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 (x < 0) {
return 0;
}
int64_t last_res = 0x3fff;
uint16_t iterations = 0;
while ((last_res > 0) && (iterations < 15)) {
last_res = ((x / last_res) + last_res)/2;
iterations++;
}
return (last_res);
} | |
cl_check(!stack->list_head);
// Switch to the app state to push the window
stub_pebble_tasks_set_current(PebbleTask_App);
window_stack_push(stack, window, true);
cl_assert_equal_i(window->on_screen, 1);
cl_assert_equal_i(window_stack_count(stack), 1);
// Ensure the load handler was called
cl_assert_... | (window, &(WindowHandlers){
.load = prv_window_load,
.unload = prv_push_window_unload
}) | ;
WindowStack *stack = app_state_get_window_stack();
// Switch to the app state to push a window
stub_pebble_tasks_set_current(PebbleTask_App);
cl_check(stack);
cl_assert_equal_i(window_stack_count(stack), 0);
window_stack_push(stack, window, true);
cl_assert_equal_i(window_stack_count(stack), 1);
... |
_events(0);
// The buffer should be completely available again:
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer));
}
void test_app_inbox__app_inbox_service_cancel_non_existing_inbox(void) {
app_inbox_service_canc... | (AppInboxServiceTagUnitTest) | );
// One callback event scheduled:
assert_num_callback_events(1);
prv_process_callback_events();
assert_num_callback_events(0);
}
void test_app_inbox__consume_inbox_closed_in_mean_time(void) {
prv_create_test_inbox_and_begin_write();
cl_assert_equal_b(true, app_inbox_service_write(AppInboxServiceTagUnit... |
c_x + 1;
dst_x2 = DISP_COLS - 1;
} else if (*prev_x < new_x) {
src_x = new_x;
dst_x1 = 0;
dst_x2 = src_x - 1;
}
*prev_x = new_x;
if (dst_x1 > dst_x2) {
return;
}
GBitmap *fb = graphics_capture_frame_buffer(ctx);
if (!fb) {
return;
}
prv_replicate_column_row_raw(fb, src_x, d... | {
// on this row, the delta is wider than the available pixels
if (patch_garbage) {
const uint8_t fill_byte = delta_neg ? left_pixel[num_pix_data_row - 1] :
left_pixel[0];
memset(left_pixel, fill_byte, num_pix_data_row);
... | |
IS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/pbl_std/pbl_std.h"
#include "applib/pbl_std/locale.h"
#include "services/common/i18n/i18n.h"
#include "util/size.... | (tmbuf, "Fri Jan 2 13:00:00 2015") | |
ete sequence
prv_advance_to_ms_with_timers(start_ms + duration_a + duration_b + 5 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(... | prv_create_test_animation() | |
-64},
{ 1296, 248, -184},
{ 888, 296, -152},
{ 744, 248, -24},
{ 872, 248, 40},
{ 1160, 216, 40},
{ 1240, 264, 56},
{ 1080, 336, 72},
{ 1360, 496, 160},
{ 1080, 872, 120},
{ 1032, 384, 120},
{ 1144, 384, 16},
{ 1040, 432, -24},
// 113 seconds
{ 1088, 584, 88},
... | { -200, 968, 160},
{ -184, 848, 224},
{ -232, 808, 176},
{ -248, 808, 328},
{ -224, 792, 424},
{ -240, 936, 336},
{ -288, 1144, 336},
{ -208, 1056, 312},
{ -16, 776, 464},
{ -80, 1136, 344},
{ -112, 992, 240},
{ -216, 960, 192},
{ -216, 840, 160},
{ -240, 800, 192... |
{ 1272, 480, -280},
{ 1248, 536, -200},
{ 1384, 696, 192},
// 5 seconds
{ 1024, 880, 208},
{ 880, 440, 264},
{ 968, 736, 352},
{ 880, 672, 296},
{ 1008, 536, 248},
{ 1272, 432, 176},
{ 1592, 368, 112},
{ 1624, 288, 144},
{ 1824, 96, 168},
{ 1792, -8, 88},
{ 1... |
t_set_stroke_color(&ctx, GColorBlack);
prv_draw_circles(&ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_r0_swX_black.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_draw_circle_${BIT_DEPTH_NAME}__zero_aa_swX_black(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Draw black circles... | (&ctx.dest_bitmap, "draw_arc_origin_aa_letter_c.${BIT_DEPTH_NAME}.pbi") | );
// Incorrect angles (angle_start > angle_end) - should result in empty image
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, RADIUS_BIG * 2);
graphics_draw_arc_internal(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG, angle_end, angle_start);
cl_check(framebuffer_is_empty(NULL, ctx.parent... |
data
int32_t peek_steps = health_service_sum_today(HealthMetricStepCount);
data->cur_steps = peek_steps + data->steps_offset;
data->lap_steps = persist_read_int(AppPersistKeyLapSteps);
if (data->lap_steps > data->cur_steps) {
// Probably left over since a midnight rollover, reset the persistent storage
... | text_layer_destroy(data->results_card.text_layer) | ;
}
// -------------------------------------------------------------------------------
static void prv_hr_select_click_handler(ClickRecognizerRef recognizer, void *context) {
}
// -------------------------------------------------------------------------------
static void prv_hr_up_click_handler(ClickRecognizerRef ... |
/*
* 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 (!s_fake_data_row_handling_disable_vertical_flip) {
y = bitmap->bounds.size.h - y - 1;
} | |
tributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "services/normal/notifications/ancs/nexmo.h... | (valid_message) | );
// Existing prefs
iOSNotifPrefs existing_prefs = {
.attr_list = {
.num_attributes = 3,
.attributes = (Attribute[]) {
{ .id = AttributeIdTitle, .cstring = "Title" },
{ .id = AttributeIdBody, .cstring = "Body" },
{ .id = AttributeIdAppName, .cstring = "Awesome" },
},
... |
id_font = s_phone_ui_data->name_font;
}
text_layer_set_font(&s_phone_ui_data->caller_id_text_layer, caller_id_font);
if (lines == 1) {
s_phone_ui_data->caller_id_text_layer.layer.bounds.origin.y = SINGLE_LINE_BOUND_OFFSET;
} else {
s_phone_ui_data->caller_id_text_layer.layer.bounds.origin.y = DOUBLE_LI... | animation_set_duration(bounceback, BOUNCEBACK_ANIMATION_FRAMES * ANIMATION_FRAME_MS) | ;
Animation *animation = animation_sequence_create(upward, bounceback, NULL);
s_phone_ui_data->call_status_animation = animation;
animation_schedule(animation);
#else
s_phone_ui_data->call_status_text_layer.layer.bounds.origin = GPointZero;
#endif
}
static void prv_update_call_time(void *unused) {
if (s_pho... |
Private *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!animation) {
return false;
}
if (animation->play_count == ANIMATION_PLAY_COUNT_INFINITE_STORED) {
return ANIMATION_PLAY_COUNT_INFINITE;
} else {
return animation->play_count;
}
}
// --------------------... | (!animation_private_using_legacy_2(NULL)) | |
st(BOOT_BIT_BOOTLOADER_TEST_A) && !boot_bit_test(BOOT_BIT_BOOTLOADER_TEST_B)) {
BLTEST_LOG("ALL BOOTLOADER TESTS PASSED");
} else {
BLTEST_LOG("STAGE 2 -- Boot bits incorrect!");
BLTEST_LOG("BOOTLOADER TEST FAILED");
}
boot_bit_clear(BOOT_BIT_BOOTLOADER_TEST_A | BOOT_BIT_BOOTLOADER_TEST_B);
psleep(1... | disable_mcu_debugging() | |
er_entries(&s_started_handler_calls, NULL), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, NULL), 0);
// Execute to the start of B and C
prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_ca... | (prv_count_handler_entries(&s_stopped_handler_calls, b0), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b1), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b2), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b3), 0);
// Let it finish completely
prv_advance_to_ms_with_timers(start_ms + ... |
/*
* 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_start & (~SUBSECTOR_ADDR_MASK)) == 0) &&
((max_end & (~SUBSECTOR_ADDR_MASK)) == 0) &&
(min_start <= max_start) &&
(max_start <= min_end) &&
(min_end <= max_end)) | ;
// We want to erase the sector that starts immediately below max_start but
// after min_start. If no sector boundary exists between the two, we need to
// start erasing sectors after min_start and backfill with subsector erases.
int32_t sector_start = (max_start & SECTOR_ADDR_MASK);
int32_t subsector_start... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(result, 1800) | ;
reading.vmon_total = prv_convert_millivolts_to_12bit_reading(1200) * 40;
result = battery_convert_reading_to_millivolts(reading, 1, 1);
cl_assert_equal_i(result, 1200);
reading.vmon_total = prv_convert_millivolts_to_12bit_reading(0);
result = battery_convert_reading_to_millivolts(reading, 1, 1);
cl_as... |
/*
* 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_ERROR, "HcAdvert: unhandled message id: %d", msg->command_id) | ;
}
}
|
et();
}
bool activity_prefs_sleep_insights_are_enabled(void) {
return s_activity_preferences.sleep_insights_enabled;
}
void activity_prefs_sleep_insights_set_enabled(bool enable) {
s_activity_preferences.sleep_insights_enabled = enable;
prv_activity_pref_set();
}
bool activity_prefs_tracking_is_enabled(void) {... | {
return s_timeline_peek_before_time_m;
} | |
32(&list, AttributeIdLastUpdated, now);
uint8_t buffer[Uint32ListSize(ActivitySessionMetricCount)];
Uint32List *icons = (Uint32List *)buffer;
icons->num_values = ActivitySessionMetricCount,
icons->values[0] = TIMELINE_RESOURCE_PACE;
icons->values[1] = TIMELINE_RESOURCE_DURATION;
icons->values[2] = TIMELINE... | prv_add_generic_pin(-24 * 60 * 60, has_subtitle) | ;
prv_add_weather_pin(-60 * 60);
prv_add_weather_pin(60 * 60);
prv_add_generic_pin(24 * 60 * 60, has_subtitle);
goto timeline;
case TimelinePinsDemo_Notifications:
prv_add_notification(-60 * 60 * 24);
prv_add_notification(-60 * 60);
prv_add_notification(-60 * 30);
prv... |
/*
* 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... | gpio_output_init(&BOARD_CONFIG_BT_COMMON.reset, GPIO_OType_PP, GPIO_Speed_25MHz) | ;
periph_config_release_lock();
}
static void prv_enter_reset(void) {
gpio_output_set(&BOARD_CONFIG_BT_COMMON.reset, true);
delay_us(100);
}
static void prv_exit_reset(void) {
gpio_output_set(&BOARD_CONFIG_BT_COMMON.reset, false);
}
static void prv_send_char(uint8_t c) {
uart_write_byte(BT_TX_BOOTROM_UART... |
void test_workout_active__sports_hr_z1(void) {
s_sports_data = (SportsData) {
.current_bpm = 135,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMetricType middle_metric = WorkoutMetricType_Dist... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_workout_active__sports_custom_hanging_label(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
.custom_label_string = "Hanging Field",
.custom_value_string = "000000",
};
Workou... |
2) - 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Should not draw anything
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HE... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r1_sw1_no_clip.${BIT_DEPTH_NAME}.pbi")) | ;
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 2);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r2_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&dialog->window) | ) {
kino_layer_set_reel_with_resource(&dialog->icon_layer, icon_id);
}
}
void dialog_set_icon_animate_direction(Dialog *dialog, DialogIconAnimationDirection direction) {
dialog->icon_anim_direction = direction;
}
void dialog_set_vibe(Dialog *dialog, bool vibe_on_show) {
dialog->vibe_on_show = vibe_on_show;
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prompt_send_response(line_buffer) | ;
}
void hexdump_using_pbllog(int level, const char *src_filename, int src_line_number,
const char *line_buffer) {
pbl_log_sync(level, src_filename, src_line_number, "%s", line_buffer);
}
void hexdump_log_src(const char *src_filename, int src_line_number, int level,
co... |
enabled = true;
s_last_num_permitted_devices = 0;
memset(s_last_permitted_devices, 0, sizeof(s_last_permitted_devices));
s_bt_driver_hrm_service_enable_call_count = 0;
s_hrm_manager_subscribe_with_callback_call_count = 0;
s_sys_hrm_manager_unsubscribe_call_count = 0;
s_bt_driver_hrm_service_handle_measureme... | prv_assert_event_service_subscribed(false) | ;
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count, 1);
// Device B unsubscribes again, should be no-op
bt_driver_cb_hrm_service_update_subscription(s_device_b, false);
prv_assert_event_service_subscribed(false);
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count, 1);
}
void test_ble_hrm__... |
/*
* 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... | (0, 0, 200, 500) | );
// act as 2.x once bounds.origin is different from (0, 0)
layer_set_bounds(&l, &GRect(1, 1, 200, 500));
layer_set_frame(&l, &GRect(10, 20, 100, 600));
cl_assert_equal_grect(l.bounds, GRect(1, 1, 200, 599));
// act as 2.x once bounds.size isn't same as frame.size
layer_set_bounds(&l, &GRect(0, 0, 150, 6... |
Node * prv_find_subscription_and_connection_for_cccd(
BLEDescriptor cccd_ref,
GAPLEConnection **connection_out) {
BLECharacteristic characteristic_ref =
gatt_client_des... | prv_lock() | ;
if (!prv_check_buffer(client)) {
goto unlock;
}
has_notification = prv_get_next_notification_header(client, header_out);
const uint16_t read_space = circular_buffer_get_read_space_remaining(s_circular_buffer[client]);
if (has_notification && header_out) {
// When tackling https://pebbletechnology.at... |
_ptr);
/* Check to see if the previous segment can be combined. */
if(!previous_block->is_allocated) {
/* Add the segment to be freed to the new beginer. */
previous_block->Size += heap_info_ptr->Size;
/* Set the pointer to the beginning of the previous */
/* free seg... | (heap, heap_info_ptr) | ;
/* Check to see if the current entry is free and is large*/
/* enough to hold the data being requested. */
if (heap_info_ptr->is_allocated || (heap_info_ptr->Size < n_units)) {
/* If the requested size is larger than the limit then*/
/* search backwards for an available buffer, e... |
/*
* 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_ProgramByte(address + i, data_array[i]) | != FLASH_COMPLETE) {
dbgserial_print("failed to write address ");
dbgserial_print_hex(address);
dbgserial_newline();
FLASH_Lock();
return false;
}
if (progress_callback && i % 128 == 0) {
progress_callback(i/128, length/128, progress_context);
}
}
FLASH_Lock();
ret... |
orkout_active_create_for_activity_type(
ActivitySessionType_Run, &s_workout_data, &s_workout_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__workout_render_hr_zone_3(void) {
s_workout_data = (WorkoutData) ... | {
s_hrm_is_present = false;
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMetricType middle_metric = WorkoutMetricType_Distance;
WorkoutMetr... |
void test_workout_active__sports_hr_z0(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMetricType middle_metric = WorkoutMetricType_Dista... |
/*
* 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... | i2c_release(I2C_LED) | |
AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "pbl_malloc.h"
#include "kernel_heap.h"
#include "pebble_tasks.h"
#include "process_management/app_manager.h"... | (app_state_get_heap(), ptr, saved_lr) | ;
}
void *app_realloc(void *ptr, size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_realloc(app_state_get_heap(), ptr, bytes, saved_lr);
}
void *app_zalloc(size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_zalloc(app_state_get_hea... |
dex->row == 0)) {
// Clear All button selected
prv_settings_clear_history_window_push(notifications_data);
return;
}
// shift index since the first one is hard coded to Clear
int16_t notif_idx = cell_index->row - 1;
NotificationNode *node = (NotificationNode*) list_get_at(
(ListNode*) notif... | attribute_get_string(¬ification->attr_list, AttributeIdTitle, "") | |
/*
* 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... | (buffer, sizeof(buffer), fmt, fmt_args) | |
/*
* 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... | (capability) | ;
}
DEFINE_SYSCALL(void, sys_app_pp_app_message_analytics_count_drop, void) {
analytics_inc(ANALYTICS_APP_METRIC_MSG_DROP_COUNT, AnalyticsClient_App);
}
|
PBL_LOG(LOG_LEVEL_DEBUG, "Sending Data to PP endpoint %u (0x%x):",
pp_header.endpoint_id, pp_header.endpoint_id);
PBL_HEXDUMP(LOG_LEVEL_DEBUG, buffer, pp_header.length);
DataNode *data_node = kernel_malloc(sizeof(DataNode) + pp_header.length);
list_init(&data_node->node);
data_no... | cl_assert_equal_b(list_contains((const ListNode *)s_fake_transport_head,
(const ListNode *)fake_transport), true) | ;
if (fake_transport->session) {
// Causes clean up of CommSession:
fake_transport_set_connected((Transport *)fake_transport, false /* connected */);
}
list_remove((ListNode *) fake_transport, (ListNode **) &s_fake_transport_head, NULL);
DataNode *data_node = fake_transport->sent_data;
while (data_nod... |
ALARM_SNOOZE_DELAY_S / SECONDS_PER_MINUTE)
void test_alarm_smart__trigger_30_min_early_awake(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY, .is_smart = true });
prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
cl... | (s_num_timeline_adds, 6) | ;
cl_assert_equal_i(s_num_timeline_removes, 3);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm_smart__trigger_at_timeout(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY, .is_smart = true });
prv_ass... |
/*
* 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_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 */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
... |
, 0x47, 0xca, 0xad, 0xfe},
.constructor = launcher_app_glance_settings_create,
},
{ // Music
.uuid = {0x1f, 0x03, 0x29, 0x3d, 0x47, 0xaf, 0x4f, 0x28,
0xb9, 0x60, 0xf2, 0xb0, 0x2a, 0x6d, 0xd7, 0x57},
.constructor = launcher_app_glance_music_create,
},
{ // Weather
.... | (service, glance->current_slice.expiration_time) | |
ion from remote:
prv_confirm_cccd_write(BLEGATTErrorSuccess);
fake_event_clear_last();
gatt_client_subscriptions_handle_server_notification(s_connection, s_handle, NULL, 0);
prv_assert_notification_event(characteristic, NULL, 0, false /* kernel */, true /* app */);
// Nothing to be read after "consuming" i... | gatt_client_subscriptions_handle_server_notification(s_connection, s_handle,
value, too_big) | ;
prv_assert_no_event();
// Receive a GATT notification that is supposed to fill up the buffer entirely:
const size_t fill_entirely_size = (GATT_CLIENT_SUBSCRIPTIONS_BUFFER_SIZE -
sizeof(GATTBufferedNotificationHeader));
gatt_client_subscriptions_handle_server_notification(... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
c = 'a' + (digit - 0xa);
} | else {
c = ' ';
}
*buffer++ = c;
}
*buffer = '\0';
}
void string_reverse(char *str) {
uint8_t i = 0;
int8_t j = strlen(str) - 1;
for (i = 0; i < j; i++, j--) {
char c = str[i];
str[i] = str[j];
str[j] = c;
}
}
/* itoa: convert n to characters in s */
void itoa_int(int n, char ... |
perating modes are enabled and what the requirements are thereof.
typedef enum {
AccelOperatingModeData,
AccelOperatingModeShakeDetection,
AccelOperatingModeDoubleTapDetection,
AccelOperatingMode_Num,
} AccelOperatingMode;
typedef enum {
AccelPowerModeLowPower,
AccelPowerModeNormal,
AccelPowerMode_Num... | (&time_s, &time_ms) | ;
return (((uint64_t)time_s) * 1000 + time_ms);
}
static uint32_t prv_sensortime_to_timestamp(uint8_t sensor_time[3]) {
return (sensor_time[0] | (sensor_time[1] << 8) | (sensor_time[2] << 16));
}
static uint32_t prv_get_min_sampling_interval_us(void) {
BMI160SampleRate sample_rate_max = BMI160SampleRate_12p5_HZ... |
meout(get_reminder_timer_id()) == 1037 * 1000);
now += 1037;
stub_pebble_tasks_set_current(PebbleTask_NewTimers);
cl_assert(stub_new_timer_fire(get_reminder_timer_id()));
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
fake_system_task_callbacks_invoke(1);
cl_assert_equal_i(num_events_put, 5);
... | cl_assert_equal_i(600, reminders_calculate_snooze_time(&item2)) | ;
now = 100 + 48 * 60 * 60;
cl_assert_equal_i(600, reminders_calculate_snooze_time(&item2));
// Test no snooze
now = 100 + 48 * 60 * 60 + 1;
cl_assert_equal_i(0, reminders_calculate_snooze_time(&item2));
}
|
_i(out_length, 2);
cl_assert(memcmp(out_buffer, "bc", 2) == 0);
cl_assert(shared_circular_buffer_consume(&buffer, &client1, 2));
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 0);
// Should fail, not enough room because client 2 is full
cl_assert(!shared_circular_buffer_write(... | shared_circular_buffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 2) | ;
cl_assert_equal_i(items_read, 1);
cl_assert_equal_m(out_buffer, "5q", 2);
}
void test_shared_circular_buffer__subsampling_1of3(void) {
SharedCircularBuffer buffer;
uint16_t item_size = 2;
uint8_t storage[12*item_size];
uint8_t out_buffer[12*item_size];
uint16_t items_read;
// Init
shared_circular... |
/*
* 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(!success) | ;
utf8_t* malformed_test_string_utf8 = (utf8_t*)s_malformed_test_string;
for (int i = 0; i < (UTF8_TEST_MALFORMED_CODEPOINT_INDEX - 1); i++) {
uint32_t decoded_codepoint = utf8_peek_codepoint(malformed_test_string_utf8, NULL);
uint32_t actual_codepoint = s_valid_test_codepoints[i];
cl_assert_equal_i(d... |
/ Swap animation speed
// Adding ANIMATION_TARGET_FRAME_INTERVAL_MS doesn't actually add a frame, because plain moook
// has a fixed number of frames. Adding it in just adds more time between the frames
#define SWAP_MS PBL_IF_RECT_ELSE(200, 150)
// Pixel peek amount for next layout
#define PEEK_PX PBL_IF_RECT_ELSE(LAY... | (swap_layer, bg_color, status_bar_filled,
swap_layer->context) | ;
}
}
static void prv_announce_interaction(SwapLayer *swap_layer) {
if (swap_layer->callbacks.interaction_handler) {
swap_layer->callbacks.interaction_handler(swap_layer, swap_layer->context);
}
}
static void prv_refresh_next_layer(SwapLayer *swap_layer) {
prv_remove_old_layout(swap_layer, swap_layer->nex... |
ure that we don't try to fail a recognizer twice (causing an assert)
cl_assert(prv_fail_recognizer(r1, &ctx));
cl_assert_equal_i(r1->state, RecognizerState_Failed);
r1->state = RecognizerState_Possible;
recognizer_set_simultaneous_with(r1, prv_simultaneous_with_cb);
cl_assert(prv_fail_recognizer(r1, &ctx));
... | recognizer_transition_state(recognizer, s_next_state) | ;
s_idx_to_change = -1;
s_next_state = RecognizerStateCount;
}
}
static void prv_reset_test(Recognizer *recognizer) {
prv_store_recognizer_idx(recognizer, &s_recognizers_reset);
}
void test_recognizer_manager__handle_touch_event(void) {
const int k_rec_count = 5;
s_dummy_impl.handle_touch_event = prv_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
CronJob* job = (CronJob*)s_scheduled_jobs;
s_scheduled_jobs = list_pop_head(s_scheduled_jobs);
// Re-calculate the execute time.
// See the notes in the API header on how this works.
if (must_recalc || change_diff >= job->clock_change_tolerance) {
job->cached_execute_time = cron_job_get_exec... | |
ar_over_black", ctx.parent_framebuffer, GColorWhite));
}
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 20, 20)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 144, 168)
#define ORIGIN_DRAW_RECT_NO_CLIP GRect(6, 6, 30, 40)
#define ORIGIN_DRAW_RECT_CLIP_XY GRe... | (&ctx.dest_bitmap, "draw_rect_origin_aa_sw5_clip_xy.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 5);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if... |
GColorBlue);
graphics_fill_rect(&ctx, &GRect(0, 0, 20, 10));
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPoint(30, 30), DEG_TO_TRIGANGLE(45), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_color_set_center_45... | graphics_draw_rotated_bitmap(ctx, test_image, GPoint(
test_image->bounds.size.w / 2 - 1,
test_image->bounds.size.h / 2 - 1),
DEG_TO_TRIGANGLE(0), center) | ;
cl_check(gbitmap_pbi_eq(&ctx->dest_bitmap, "draw_rotated_bitmap_stamp_0deg.Xbit.pbi"));
// Top-left corner rotation point, Angle 45
setup_test_rotate_bitmap(ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(ctx, test_image,
GPoint(... |
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
* limitations under the Lic... | test_graphics_context_init(&s_ctx, fb) | |
tive) {
PBL_LOG_VERBOSE("True");
} else {
PBL_LOG_VERBOSE("False");
}
PBL_LOG_VERBOSE("\n");
PBL_LOG_VERBOSE("Key is:\n\t");
for (int i = 0; i < r->key_length; i++) {
PBL_LOG_VERBOSE("'%c'", r->key[i]);
}
PBL_LOG_VERBOSE("\n");
PBL_LOG_VERBOSE("UUID is:\n\t");
for (int i = 0; i < UUID_SI... | flash_region_erase_optimal_range(next_start_address, next_start_address,
next_end_address, next_end_address) | ;
// Write the next header + content
registry_set_header(next_start_address, true);
const uint32_t data_start_address = next_start_address + REGISTRY_HEADER_SIZE_BYTES;
flash_write_bytes((uint8_t*)registry->records, data_start_address,
registry->registry_size_bytes);
registry->cursor->a... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (destination, info->load_size) | |
hen disable it.
if (rv && config->kind == ALARM_KIND_JUST_ONCE) {
config->is_disabled = true;
prv_alarm_set_config(file, id, config); // This will reload the alarms
} else {
prv_reload_alarms(file);
}
cleanup:
prv_file_close_and_unlock(file);
kernel_free(file);
PBL_LOG(LOG_LEVEL_INFO, "Alarm ... | {
// The time is before or equal to the current time. Sechedule the alarm for tomorrow
return (local_time.tm_wday + 1) % DAYS_PER_WEEK;
} | |
/*
* 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... | (strspn(testbuf, "B"), 0) | |
-----------------------------------------------------
// Test calling unschedule on the sequence from the stopped handler of one of its children
void test_animation__sequence_unschedule_from_child(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_b = ... | (prv_count_handler_entries(&s_started_handler_calls, a), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);... |
luetoothStackID, ...) {
return (0);
}
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
callback(data);
}
static uint32_t s_unscheduled_cb_count;
static void * s_unscheduled_cb_data = "Callback Data";
static GAPLEAdvertisingJobRef s_unscheduled_job;
static bool s_unscheduled_completed;
... | regular_timer_seconds_count() | , 1);
// Unschedule callback should not have been called:
cl_assert_equal_i(s_unscheduled_cb_count, 0);
// Unschedule and expect not to be advertising any more:
gap_le_advert_unschedule(job);
cl_assert(!gap_le_is_advertising_enabled());
// Unschedule callback should have been called once:
cl_assert_equa... |
_I2C4 | RCC_APB1Periph_CAN1
| RCC_APB1Periph_CAN2 | RCC_APB1Periph_CEC | RCC_APB1Periph_PWR | RCC_APB1Periph_DAC
| RCC_APB1Periph_UART7 | RCC_APB1Periph_UART8;
const uint32_t apb2_periphs =
RCC_APB2Periph_TIM1 | RCC_APB2Periph_TIM8 | RCC_APB2Periph_USART1
| RCC_APB2Periph_USART6 | RCC_APB2Periph_SDMMC... | PBL_LOG_VERBOSE("We're good, we're just starting normally.") | ;
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
return false;
}
// We failed to start our firmware successfully!
if (watchdog_check_reset_flag()) {
dbgserial_putstr("Watchdog caused a reset");
}
if (boot_bit_test(BOOT_BIT_SOFTWARE_FAILU... |
s_phone_ui_data->vibe_score);
s_phone_ui_data->vibe_score = NULL;
}
#endif
vibes_cancel();
}
//! Call duration related functions
static void prv_show_call_status(void) {
layer_set_hidden(&s_phone_ui_data->call_status_text_layer.layer, false);
#if !PLATFORM_TINTIN
s_phone_ui_data->call_status_text_layer.la... | timeline_item_destroy(context) | |
xpress or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "spinner_ui_window.h"
#include "applib/graphics/gpath_builder.h"
#include "applib/graphics/graphics.h"
#include "util/trig.h"
#include "applib/ui/animation.h"
#include "applib/ui/la... | animation_get_context(animation) | ;
if (!data->should_cancel_animation) {
data->cur_distance_normalized = 0;
animation_schedule(property_animation_get_animation(data->spinner_animation));
}
}
////////////////////////////////////////////////////////////
// Window loading, unloading, initializing
static void prv_window_unload_handler(Window... |
ion == 4);
test_num = (int32_t)((float)-0.375 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 5);
test_num = (int32_t)((float)-0.250 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_as... | Fixed_S16_3_rounded_int(Fixed_S16_3(8)) | );
cl_assert_equal_i(2, Fixed_S16_3_rounded_int(Fixed_S16_3(12)));
cl_assert_equal_i(0, Fixed_S16_3_rounded_int(Fixed_S16_3(-3)));
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-4)));
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-5)));
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fix... |
MIN(str1_len, MAX_MSG_STR_LEN_HALF) | ;
str2_len = MIN(str2_len, MAX_MSG_STR_LEN_HALF);
}
if (str1_len) {
// length + strlen(string) + padding (round up to nearest uint32_t).
msg_size += 1 + str1_len + (3 - (1 + str1_len + 3) % 4);
}
if (str2_len) {
// length + strlen(string) + padding (round up to nearest uint32_t)... | |
*history = 0;
return true;
}
int s_metric_updated_count = 0;
void activity_metrics_prv_set_metric(ActivityMetric metric, DayInWeek day, int32_t value) {
printf("s_metric_updated_count: %d\n", s_metric_updated_count);
s_metric_updated_count++;
}
// Setup
///////////////////////////////////////////////////////... | health_db_delete((uint8_t *)key, strlen(key)) | ,
S_SUCCESS);
// check
cl_assert(!health_db_get_typical_value(ActivityMetricSleepTotalSeconds, Monday, &val_out));
// insert again
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
(uint8_t *)s_sleep_data, sizeof(s_sleep_data)),
... |
/*
* 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... | (handlers, s_data.context) | ;
cl_assert(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_unobstruc... |
prv_destructor(data);
}
return reel;
}
void kino_reel_scale_segmented_set_delay_lookup_creator(
KinoReel *reel, GPointIndexLookupCreator creator, void *userdata, bool take_ownership) {
ScaleSegmentedData *data = kino_reel_transform_get_context(reel);
if (!data) {
return;
}
if (data->lookup.owns_us... | kino_reel_scale_segmented_set_to_stroke_width(reel, to, GStrokeWidthOpSet) | ;
kino_reel_scale_segmented_set_stroke_width_curve(reel, prv_ease_in_out_last_half);
}
|
title, NULL /* value_font */,
NULL /* value */, subtitle_font, subtitle, NULL /* icon */,
false /* icon_on_right */, GTextOverflowModeTrailingEllipsis);
// Restore the cell layer's bounds
mutable_cell_layer->bounds = cell_layer_bounds;
}
//! outer_box i... | (TextStyleFont_Header) | |
(LOG_LEVEL_INFO, "Added <%s> to the notif pref db", buffer) | ;
blob_db_sync_record(BlobDBIdiOSNotifPref, app_id, length, rtc_get_time());
}
return rv;
}
void ios_notif_pref_db_init(void) {
s_mutex = mutex_create();
PBL_ASSERTN(s_mutex != NULL);
}
status_t ios_notif_pref_db_insert(const uint8_t *key, int key_len,
const uint8_t *va... | |
iter_init(&char_iter, &char_iter_state, text_box_params, word->start);
Utf8IterState* utf8_iter_state = &char_iter_state.utf8_iter_state;
if (utf8_iter_state->codepoint != codepoint) {
return false;
}
bool is_advanced = iter_next(&char_iter);
if (!is_advanced) {
PBL_ASSERTN(*word->end == NULL_CODE... | (&char_iter, &char_iter_state, text_box_params, line->start) | ;
Utf8IterState* utf8_iter_state = (Utf8IterState*) &char_iter_state.utf8_iter_state;
bool is_newline_as_space = text_box_params->overflow_mode == GTextOverflowModeFill;
Codepoint current_codepoint = utf8_iter_state->codepoint;
if (current_codepoint == NEWLINE_CODEPOINT) {
if (is_newline_as_space) {
... |
ired by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include... | (num.integer == 0) | ;
cl_assert(num.fraction == 0);
test_num = (int32_t)((float)0 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == 0);
cl_assert(num.fraction == 0);
test_num = (int32_t)((float)0.125 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return s_process_manager_compiled_with_legacy2_sdk;
} | |
// Used for unit testing
// List of memory regions to include in the core dump
typedef struct {
void* start;
uint32_t length;
bool word_reads_only; // Some peripherals can only be read 32 bits at a
// time, or you BusFault (maybe). Set this to true
... | pulse_logging_log_sync_begin(LOG_LEVEL_ALWAYS, __FILE_NAME__, 0) | ;
pulse_logging_log_sync_append(ctx, msg);
pulse_logging_log_sync_append(ctx, buffer);
pulse_logging_log_sync_send(ctx);
#else
int max_length = 256;
while (*msg && max_length--) {
dbgserial_putchar(*msg);
++msg;
}
dbgserial_putstr(buffer);
#endif
}
static NORETURN prv_reset(void) {
dbgserial_fl... |
request. Triggered by a call to
//! app_fetch_binaries().
static void prv_app_fetch_binaries_system_task_cb(void *data) {
AppFetchInstallRequest *request = (AppFetchInstallRequest *)data;
// check if Bluetooth is active. If so, this will send.
bool successful = comm_session_send_data(comm_session_get_system_sess... | PBL_ASSERT_TASK(PebbleTask_KernelBackground) | |
Valid) {
mark_fd_free(fd); // file has been corrupted so clear fd
goto cleanup;
}
}
PFS_FD(fd).fd_status = FD_STATUS_IN_USE;
file_found = true;
}
cleanup:
*fd_used = (res >= 0) ? fd : res;
return (file_found);
}
// handles the creation of a file which was not previously on the... | if ((op_flags & OP_FLAG_USE_PAGE_CACHE) != 0) {
allocate_page_cache(res);
} |
// check to see if we should update the gc block
prv_update_gc_reserved_region();
}
mutex_unlock_recursive(s_pfs_mutex);
return (res);
}
static int pfs_open_gc_file(uint32_t space_needed, bool create) {
int fd = GC_FD_HANDLE_ID; // the gc fd follows the avail fd
File *file = &PFS_FD(fd).file;
//... |
l_free(state->pending_response_data);
}
kernel_free(state);
}
static bool prv_is_emulated_server_wa_requested(uint16_t conn_idx) {
bool enabled = false;
storage_acquire();
device_t *dev = find_device_by_conn_idx(conn_idx);
if (dev) {
// Only enable the work-around if the bit is present in the bonding l... | if (evt->offset == 0) {
uint16_t value;
memcpy(&value, evt->value, sizeof(value));
bool subscribed = (GATT_CCC_NOTIFICATIONS == value);
prv_handle_cccd_write(conn, subscribed);
PBL_LOG(LOG_LEVEL_DEBUG, "Wrote reversed PPoGATT CCCD: %"PRIu16, subscribed);
} else {
PBL_LOG(LOG_LEVE... |
}
}
static void prv_ppogatt_handle_read_request(ble_service_t *svc,
const ble_evt_gatts_read_req_t *evt) {
PBL_LOG(LOG_LEVEL_DEBUG, "Unexpected PPoGATT Service Read: 0x%"PRIx16, evt->handle);
// In the future, we might actually return something useful. For now, just ... |
/*
* 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 attribute_group_get_required_buffer_size(GROUP_TYPE,
num_attributes,
num_addresses,
attributes_per_address,
... |
void attributes_address_init(AttributeList *attr_list,
AddressList *addr_list,
uint8_t **buffer,
uint8_t num_attributes,
uint8_t num_addresses,
const uint8_t *attributes_per... |
_service(ad_data, &hrm_uuid);
} else {
result->has_services = false;
result->has_heart_rate_service = false;
}
// Insert into the list:
list_link_sorted_by_rssi(result);
// Tell the menu to update:
menu_layer_reload_data(s_menu_layer);
}
void toggle_scan(void) {
if (s_is_scanning) {
ble_sca... | (cell_index->row) | ;
BTErrno e = ble_central_cancel_connect(result->device);
if (e) {
APP_LOG(APP_LOG_LEVEL_INFO, "ble_central_cancel_connect: %d", e);
}
}
//------------------------------------------------------------------------------
// Window callbacks:
static void window_load(Window *window) {
Layer *window_layer = w... |
andler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
// Start B
prv_advance_to_ms_with_timers(start_ms + delay_spawn + MAX(delay_a, delay_b)
+ 2 * MIN_FRA... | prv_count_handler_entries(&s_stopped_handler_calls, b) | , 0);
// Complete sequence
prv_advance_to_ms_with_timers(start_ms + duration_total + 5 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 2);
cl_assert_equal_i(prv_count_handler_... |
PERSISTENT_STORAGE_FILE_SIZE);
if (rv != S_SUCCESS) {
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(&... | {
shared_prf_storage_set_ble_pinned_address(&pinned_address);
} |
}
static void prv_load_local_data_from_prf(void) {
char name[BT_DEVICE_NAME_BUFFER_SIZE];
if (shared_prf_storage_get_local_device_name(name, BT_DEVICE_NAME_BUFFER_SIZE)) {
bt_persistent_storage_set_local_device_name(name, BT_DEVICE_NAME_BUFFER_SIZE);
}
SM128BitKey keys[SMRootKeyTypeNum];
if (shared_prf... |
ENGTHS[attribute->id - 1], attribute->length);
} else if (attribute->id == AttributeIdSubtitleTemplateString) {
attr_length = MIN((uint16_t)ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN, attribute->length);
} else {
attr_length = attribute->length;
}
*buffer += attr_length + 1;
PBL... | {
return 0;
} |
size_t size = 0;
size += (attr_list->num_attributes * sizeof(SerializedAttributeHeader));
for (int i = 0; i < attr_list->num_attributes; i++) {
switch (prv_attribute_type(attr_list->attributes[i].id)) {
case AttributeTypeString:
size += strlen(attr_list->attributes[i].cstring);
b... |
art == 2);
cl_assert(success);
// Init mutable types
utf8_iter_init(&utf8_iter, &utf8_iter_state, &utf8_bounds, utf8_bounds.start);
// Tests
cl_assert(!iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
cl_assert(!iter_next(&utf8_iter));
}
void test_utf8_iterator__decode_valid_string(void) {
... | (s_each_count, 0) | ;
}
|
[2].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[0].header.id));
}
void test_timeline__n... | uuid_equal(&state.pin.header.id, &s_long_items[3].header.id) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("Dismiss", ¬if_attr_list) | );
int action_id = 0;
TimelineItemAction actions[] = {
{
.id = action_id++,
.type = TimelineItemActionTypeDismiss,
.attr_list = dismiss_action_attr_list,
},
};
TimelineItemActionGroup action_group = {
.num_actions = ARRAY_LENGTH(actions),
.actions = actions,
};
const time... |
nt rv = pfs_read(-1, NULL, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_read(0, NULL, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = pfs_open("newfile", OP_FLAG_WRITE, FILE_TYPE_STATIC, rd_len);
cl_assert(fd >= 0);
uint8_t buf[rd_len];
rv = pfs_read(fd, buf, rd_len);
cl_assert(rv == ... | (file_large, sizeof(file_large), "large%d", i) | ;
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 *... |
cl_assert_equal_i(s_num_timeline_removes, 8);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm__custom_alarm_no_alarm(void) {
AlarmId id1;
bool schedule_1[7] = {false, false, false, false, false, false, false};
id1 = alarm_create(&(AlarmInfo) { .hour = 10, .mi... | cron_service_wakeup() | |
n_get("End Workout?", workout_dialog));
dialog_set_background_color(dialog, BACKGROUND_COLOR);
dialog_set_text_color(dialog, TEXT_COLOR);
dialog_set_icon(dialog, RESOURCE_ID_WORKOUT_APP_END);
dialog_set_icon_animate_direction(dialog, DialogIconAnimateNone);
dialog_set_destroy_on_pop(dialog, false);
i18n_fr... | app_free(active_window) | ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Common Setup
static void prv_create_window_common(WorkoutActiveWindow *active_window,
void *workout_data,
WorkoutController *workout... |
DIV_X(frame.size.w * (1000 - MULT_X((cur - limit_c), (limit_d - limit_c)))),
frame.origin.y + frame.size.h);
} else if (cur <= limit_e) {
// zone d - e
return GPoint(frame.origin.x,
frame.origin.y +
DIV_X(frame.size.h * (1000 - MULT_X((cur -... | (fill_thickness) | );
graphics_draw_rect(ctx, &inner_bounds);
inner_bounds = grect_inset(inner_bounds, GEdgeInsets(-1));
graphics_draw_rect(ctx, &inner_bounds);
#endif
app_free(path.points);
#elif PBL_ROUND
const int32_t degree = total ? (360 * current / total) : 0;
const int32_t to_angle = DEG_TO_TRIGANGLE(degree);
graph... |
"
#define ROCKY_CANVAS_CONSTRUCTOR "CanvasElement"
#define ROCKY_CANVAS_CLIENTWIDTH "clientWidth"
#define ROCKY_CANVAS_CLIENTHEIGHT "clientHeight"
#define ROCKY_CANVAS_UNOBSTRUCTEDLEFT "unobstructedLeft"
#define ROCKY_CANVAS_UNOBSTRUCTEDTOP "unobstructedTop"
#define ROCKY_CANVAS_UNOBSTRUCTEDWIDTH "unobstructedWidth"
#d... | {
return prv_rect_call(argc, argv, graphics_fill_rect);
} |
static void prv_draw_rect_impl(GContext *ctx, const GRectPrecise *rect) {
GRectPrecise adjusted_rect = *rect;
adjusted_rect.origin.x.raw_value -= FIXED_S16_3_HALF.raw_value;
adjusted_rect.origin.y.raw_value -= FIXED_S16_3_HALF.raw_value;
graphics_draw_rect_precise(ctx, &adjusted_rect);
}
JERRY_FUNCTION(prv_s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (framebuffer_bitmap, (uint16_t)y) | ;
const int row_width = row_info.max_x - row_info.min_x + 1;
num_pixels += row_width;
}
// Round up after dividing by the mask bits per pixel
const size_t num_bytes_needed_for_pixel_mask_data = DIVIDE_CEIL(num_pixels,
GDRAWMASK_BITS_PER_PIX... |
&GPointZero, 0, 0, false);
touch_handle_update(0, TouchState_FingerUp, NULL, 0, 3686410);
touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event, 0, TouchEvent_Liftoff, &GPoint(1, 13), 3686400, 5, &GPointZero,
10, -5, true);
}
void test_to... | GPoint(18, 5) | ,
60, 0, true);
}
void test_touch__handle_update_merge_liftoff_null_pos(void) {
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 3686380, 0);
touch_handle_update(0, TouchState_FingerDown, &GPoint(10, 10), 5, 3686400);
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
... |
>update_proc = s_content_indicator_dummy_layer_update_proc;
cl_assert(content_indicator_configure_direction(&content_indicator,
ContentIndicatorDirectionUp,
&dummy_config));
// Using the same dummy configuration (wh... | {
ContentIndicatorsBuffer *content_indicators_buffer = content_indicator_get_current_buffer();
Buffer *buffer = &content_indicators_buffer->buffer;
// At the start of the test, the buffer should be empty
cl_assert(buffer_is_empty(buffer));
ScrollLayer scroll_layer;
// Trying to access the ContentIndicator ... |
void test_content_indicator__pass_null_config_to_reset_direction_data(void) {
ContentIndicator content_indicator;
content_indicator_init(&content_indicator);
ContentIndicatorDirectionData *direction_data = content_indicator.direction_data;
const ContentIndicatorConfig dummy_config = helper_get_dummy_config()... |
TN(e->type == PEBBLE_HRM_EVENT);
const PebbleHRMEvent *const hrm_event = &e->hrm;
if (hrm_event->event_type != HRMEvent_BPM) {
return;
}
const BleHrmServiceMeasurement measurement = {
.bpm = hrm_event->bpm.bpm,
.is_on_wrist = (hrm_event->bpm.quality > HRMQuality_NoSignal),
};
BTDeviceInternal s... | if (s_ble_hrm_subscription_count == 0) {
prv_reschedule_popup_timer();
prv_execute_on_kernel_main(prv_start_hrm_kernel_main);
} |
++s_ble_hrm_subscription_count;
} else {
--s_ble_hrm_subscription_count;
if (s_ble_hrm_subscription_count == 0) {
prv_stop_popup_timer();
prv_execute_on_kernel_main(prv_stop_hrm_kernel_main);
}
}
// Emit for every subscription, so Settings/Bluetooth menu can update accordingly.
prv... |
_db_insert,
.get_len = ios_notif_pref_db_get_len,
.read = ios_notif_pref_db_read,
.del = ios_notif_pref_db_delete,
.flush = ios_notif_pref_db_flush,
.is_dirty = ios_notif_pref_db_is_dirty,
.get_dirty_list = ios_notif_pref_db_get_dirty_list,
.mark_synced = ios_notif_pref_db_mark_synced,
},
... | (key, key_len) | |
/*
* 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... | bt_uuid_expand_16bit(0x2902) | ,
.handle = 0x15,
},
},
},
}
};
return &s_health_thermometer_service;
}
void fake_gatt_put_discovery_indication_blood_pressure_service(
unsigned int connection_id) {
GATT_Characteristic_Descriptor_Information_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... | gbitmap_init_with_png_data(bitmap, png_data, png_data_size) | |
mitations under the License.
*/
#include "ad_ble.h"
#include "ble_common.h"
#include "ble_mgr.h"
#include "ble_mgr_irb_common.h"
#include "co_bt.h"
#include "hc_protocol/hc_endpoint_hci.h"
#include "hci_rom_passthrough.h"
#include "system/hexdump.h"
#include "system/logging.h"
#include "llc.h"
#include "llm.h"
#incl... | (0x8, 0x1f, NULL, 0) | |
g_color = GColorBlack;
const GColor fg_color = PBL_IF_COLOR_ELSE(GColorDarkGray, GColorWhite);
GRect arrow_rect = (GRect) { .size = GSize(aml_bounds->size.w, arrow_layer_height) };
if (row >= SHORT_ITEM_MAX_ROWS_SPALDING - 1) {
grect_align(&arrow_rect, aml_bounds, GAlignTop, true /* clip */);
c... | (&aml->menu_layer) | );
layer_set_hidden((Layer *)&aml->menu_layer.inverter, true);
aml->menu_layer.selection_animation_disabled = true;
}
void action_menu_layer_deinit(ActionMenuLayer *aml) {
if (aml->layout_cache.item_heights) {
applib_free(aml->layout_cache.item_heights);
}
prv_unschedule_item_animation(aml);
#ifndef RE... |
bit/test_framebuffer.h"
#endif
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
///////////////////////////////////////////////////////////
// Fakes
#include "fake_gbitmap_get_data_row.h"
// Setup
////////////////////////////////////
static GBitmap *... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_bw_assign_center_45.Xbit.pbi")) | ;
}
void test_graphics_draw_rotated_bitmap__origin_bw_set(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_bw,
... |
/*
* 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_menu_data_source_init(&data->data_source, &(AppMenuDataSourceCallbacks) {
.changed = prv_menu_reload_data,
.filter = prv_app_filter_callback,
}, option_menu) | ;
const AppInstallId install_id = quick_launch_get_app(button);
const int app_index = app_menu_data_source_get_index_of_app_with_install_id(&data->data_source,
install_id);
const OptionMenuConfig config = {
.title = i18n_get(i18n_... |
l(context);
app_free(context);
}
static uint16_t prv_num_rows_cb(SettingsCallbacks *context) {
return timeline_peek_prefs_get_enabled() ? TimelinePeekMenuIndexEnabledCount :
TimelinePeekMenuIndexDisabledCount;
}
static void prv_draw_row_cb(SettingsCallbacks *context, G... | (TimelineSettingsVersionCurrent) | ;
if (version == TimelineSettingsVersion_InitialVersion) {
return prv_create_first_use_dialog();
} else {
return prv_create_settings_window();
}
}
const SettingsModuleMetadata *settings_timeline_get_info(void) {
static const SettingsModuleMetadata s_module_info = {
.name = i18n_noop("Timeline"),
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.