prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
jerry_create_error(jerry_error_t error_type, const jerry_char_t *message_p) {
return jerry_create_error_sz(error_type, message_p, strlen((const char *)message_p));
}
#define JERRY_ERROR(type, msg, sz) (jerry_value_t)(EM_ASM_INT({ \
return __jerryRefs.ref(new (type)(Module.Pointer_stringify($0, $1))) \
}, (... | obj.hasOwnProperty(name) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&data->text_layer, GTextAlignmentCenter) | ;
text_layer_set_overflow_mode(&data->text_layer, GTextOverflowModeTrailingEllipsis);
}
static void click_handler(ClickRecognizerRef recognizer, Window *window) {
AppState *data = window_get_user_data(window);
ButtonId button = click_recognizer_get_button_id(recognizer);
GRect frame = data->text_layer.layer.fr... |
/*
* 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... | MAX(s_current_flush_line, fb->dirty_rect.origin.y) | ;
const uint8_t y_end = fb->dirty_rect.origin.y + fb->dirty_rect.size.h;
if (s_current_flush_line < y_end) {
row->address = s_current_flush_line;
void *fb_line = framebuffer_get_line(fb, s_current_flush_line);
#if PLATFORM_SILK
// Draw rounded corners onto the screen without modifying the
// system ... |
;
}
void pbl_log_hashed_async(const uint32_t packed_loghash, ...) {
va_list fmt_args;
va_start(fmt_args, packed_loghash);
pbl_log_hashed_vargs(true, CORE_ID_MAIN_MCU, packed_loghash, fmt_args);
va_end(fmt_args);
}
// Core Number must be shifted to the correct position.
void pbl_log_hashed_core(const uint32... | prv_log_internal(async, log_level, src_filename, src_line_number, fmt, args) | ;
va_end(args);
}
void pbl_log_sync(uint8_t log_level, const char* src_filename,
int src_line_number, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
const bool async = false;
prv_log_internal(async, log_level, src_filename, src_line_number, fmt, args);
va_end(args);
}
|
sets = GEdgeInsets(top_bottom_inset, 0);
menu_layer_frame = grect_inset(menu_layer_frame, menu_layer_frame_insets);
#endif
MenuLayer *menu_layer = &launcher_menu_layer->menu_layer;
menu_layer_init(menu_layer, &menu_layer_frame);
menu_layer_set_highlight_colors(menu_layer,
LAUN... | (&launcher_menu_layer->menu_layer) | ;
}
void launcher_menu_layer_set_selection_state(LauncherMenuLayer *launcher_menu_layer,
const LauncherMenuLayerSelectionState *new_state) {
if (!launcher_menu_layer || !launcher_menu_layer->data_source || !new_state) {
return;
}
const bool animated = false;
p... |
/*
* 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(system_flash_erase(FLASH_BASE, 16 KiB, NULL, NULL)) | ;
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_16KB_sectors(void) {
cl_assert(system_flash_erase(FLASH_BASE, 48 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 2), erased_sector);
cl_assert(flash_locked);
}
void callback_is_called_cb(uin... |
gress) {
prv_draw_slider_slide(selection_layer, ctx);
}
if (selection_layer->slide_settle_anim_progress) {
prv_draw_slider_settle(selection_layer, ctx);
}
// Finally the text is drawn over everything
prv_draw_text(selection_layer, ctx);
}
/////////////////////////////////////////////////////////////... | animation_set_implementation(animation, &selection_layer->bump_settle_anim_impl) | ;
return animation;
}
static void prv_run_value_change_animation(SelectionLayer *selection_layer) {
#if !PLATFORM_TINTIN
Animation *bump_text = prv_create_bump_text_animation(selection_layer);
Animation *bump_settle = prv_create_bump_settle_animation(selection_layer);
selection_layer->value_change_animation =... |
EEN_HEIGHT);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled.${BIT_DEPTH_NAME}.pbi"));
printf("-- right\n");
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_house_path;
gpath_move_to(s_house_path, GPoint(SCREEN_WIDTH, SCREEN_HEIGHT / 2));
... | (NULL, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_duplicates_aa.8bit.pbi"));
// Crossing path - makes sure algorithm works for path that crosses itself
prv_reset();
s_current_path = s_crossing_path;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ct... |
_count_out = 0;
WeatherDataListNode *forecasts_list_head =
weather_service_locations_list_create(&forecasts_count_out);
WeatherAppData *data = app_state_get_user_data();
weather_service_locations_list_destroy(data->forecasts_list_head);
WeatherAppLayout *layout = &data->layout;
if (forecasts_count_out ... | {
WeatherAppData *data = app_zalloc_check(sizeof(WeatherAppData));
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Weather"));
const WindowHandlers window_handlers = {
.appear = prv_main_window_appear,
.load = prv_main_window_load,
.disappear = prv_... |
weather_app_splash_screen_push(splash_screen_timeout_ms);
} else {
/// Shown when there is no connection to the phone and the data that we have is not recent
const char *warning_text = i18n_get("Unable to connect. Your weather data may be out of date; "\
"try check... |
ntry
// in the DB or the mute attribute (neither of which should happen)
PBL_LOG(LOG_LEVEL_WARNING, "Could not mute notification. No prefs or mute attribute");
}
ios_notif_pref_db_free_prefs(notif_prefs);
}
static void prv_mute_notification_always(ActionMenu *action_menu,
... | action_menu_level_add_action(root_level,
i18n_get("Snooze", root_level),
prv_snooze_reminder_cb,
window_data) | |
o writes
}
uint8_t map_mask =
BMI160_INT_MAP_1_INT2_DATA_READY | BMI160_INT_MAP_1_INT2_FIFO_WATERMARK;
uint8_t int_en_mask =
BMI160_INT_EN_1_DRDY_EN | BMI160_INT_EN_1_FWM_EN;
uint8_t map_val;
uint8_t int_en_val;
if (!enable_int) {
map_val = int_en_val = 0;
} else if (!use_fifo) {
map... | prv_enable_operating_mode(AccelOperatingModeShakeDetection, BMI160SampleRate_25_HZ) | ;
BMI160_DBG("ACC_CONF = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_ACC_CONF));
}
static void prv_disable_shake_detection(void) {
// don't worry about the configuration registers but disable interrupts
// generated for taps from the accel
uint8_t dis_mask = BMI160_INT_MAP_ANYMOTION_EN_MASK;
prv_read_modify_writ... |
nsumer_profiles[num_power_systems] = {
[PowerSystem2v5Reg] = { "2v5Reg", 0, 0, false},
[PowerSystem5vReg] = { "5vReg", 0, 0, false},
[PowerSystemMcuCoreSleep] = { "McuCoreSleep", 0, 0, false},
[PowerSystemMcuCoreRun] = { "McuCoreRun", 0, 0, false},
[PowerSystemMcuGpioA] = ... | (system < num_power_systems) | ;
DiscreteSystemProfile *current_profile = &s_discrete_consumer_profiles[system];
if (current_profile->start_ticks != 0) {
PBL_LOG(LOG_LEVEL_WARNING, "repeat call to start ticks without stopping from %s", current_profile->name);
// Someone was careless: two cases:
// 1) someone forgot to call stop
... |
, service, e); // FIXME arguments?
}
PebbleTask cur_task = pebble_task_get_current();
for (unsigned i = 0; i < NumPebbleTask; i++) {
if (!prv_task_is_masked_out(e, i) && service->subscribers[i]) {
if (i == cur_task) {
// We will handle this inline, but that has to happen after we copy it into t... | {
result = ((EventPluginUUIDEntry *)found)->service_index;
goto unlock;
} |
EventPluginUUIDEntry *entry = kernel_zalloc_check(sizeof(EventPluginUUIDEntry));
entry->service_index = ++s_next_service_index;
entry->uuid = *uuid;
list_append(list, &entry->list_node);
result = entry->service_index;
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(uuid, uuid_buffer);
PBL... |
_and_check(uint8_t data) {
// NOTE: THIS IS RUN WITHIN AN ISR
accessory_send_byte(data);
const bool bus_contention = accessory_bus_contention_detected();
if (bus_contention) {
PBL_LOG(LOG_LEVEL_DEBUG, "Bus contention was detected!");
}
return !bus_contention;
}
static bool prv_send_byte(uint8_t data) {... | (&start_flag_mbuf, &header_mbuf) | ;
// Payload
mbuf_append(&start_flag_mbuf, write_mbuf);
// Checksum
uint8_t checksum = 0;
for (MBuf *m = &header_mbuf; m; m = mbuf_get_next(m)) {
if (!mbuf_is_flag_set(m, MBUF_FLAG_IS_FRAMING)) {
crc8_calculate_bytes_streaming(m->data, m->length, &checksum, false /* !big_endian */);
}
}
MB... |
_cache.item_heights[idx];
total_h += MIN(max_visible_height, item_height);
}
const int16_t header_padding = 6 * aml->num_items;
const int16_t header_height = ((bounds->size.h - total_h) / 2) - padding;
return MAX(header_height - header_padding, 0);
}
static void prv_draw_header_cb(GContext *ctx, const Lay... | menu_layer_reload_data(&aml->menu_layer) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
window_single_click_subscribe(BUTTON_ID_UP, prv_detected_workout_up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_detected_workout_down_click_handler);
} |
static void prv_show_workout_detected_dialog(WorkoutAppData *data) {
WorkoutDialog *workout_dialog = &data->detected_workout_dialog;
workout_dialog_init(workout_dialog, "Workout Detected");
Dialog *dialog = workout_dialog_get_dialog(workout_dialog);
dialog_show_status_bar_layer(dialog, true);
dialog_set_f... |
{
app_menu_data_source_draw_row(&data->data_source, ctx, cell_layer, cell_index);
}
///////////////////
// Window callbacks
static void prv_window_load(Window *window) {
LauncherMenuData *data = window_get_user_data(window);
GRect bounds = window->layer.bounds;
status_bar_layer_init(&data->status_bar);
st... | WINDOW_NAME("Launcher Menu") | );
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
});
const bool animated = false;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void s_main(void) {
const ... |
SystemMenuItemStationaryToggle] = i18n_noop("Stand-By Mode"),
[SystemMenuItemShutDown] = i18n_noop("Shut Down"),
[SystemMenuItemFactoryReset] = i18n_noop("Factory Reset"),
};
// Common status bar component is used across all windows that need them.
// This will init it and set the correct style to be used wi... | (true /* force_overwrite */) | ;
}
static void prv_confirm_pop(ClickRecognizerRef recognizer, void *context) {
confirmation_dialog_pop((ConfirmationDialog *)context);
}
static void prv_coredump_click_config(void *context) {
window_single_click_subscribe(BUTTON_ID_UP, prv_coredump_confirm_cb);
window_single_click_subscribe(BUTTON_ID_DOWN, prv... |
x) == 0);
const GRect *cell_layer_bounds = &cell_layer->bounds;
GRect remaining_rect = *cell_layer_bounds;
if (option_menu->icons_enabled) {
const bool is_chosen = (cell_index->row == option_menu->choice);
const int32_t left_inset_x = PBL_IF_RECT_ELSE(0, 14);
const int32_t right_inset_x = prv_draw_s... | (&option_menu->menu_layer,
option_menu->highlight_colors.background,
option_menu->highlight_colors.foreground) | ;
}
void option_menu_set_callbacks(OptionMenu *option_menu, const OptionMenuCallbacks *callbacks,
void *context) {
option_menu->callbacks = *callbacks;
option_menu->context = context;
}
void option_menu_set_title(OptionMenu *option_menu, const char *title) {
option_menu->title = t... |
0 || sleep_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "FAILED: expected only sleep but got %d naps and %d sleep", nap_count,
sleep_count);
prv_test_end(context, false);
return;
}
// Walk long enough for a sleep computation to run
prv_feed_steps_min(3 * ACTIVITY_SESSION_UPDATE_MIN);
// We ... | activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD, &original_settings) | ;
ActivityInsightSettings disabled_settings = original_settings;
disabled_settings.enabled = false;
activity_insights_settings_write(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD, &disabled_settings);
prv_feed_steps_min(k_num_minutes);
activity_insights_settings_write(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWAR... |
s a non-repeating integer that we also use as our key for finding
//! EventedTimers by id.
TimerID sys_timer_id;
EventedTimerCallback callback;
void* callback_data;
PebbleTask target_task;
bool expired; // This gets set when the timer's callback runs
bool repeating;
} EventedTimer;
// Fakes
//////... | cl_assert(!s_times_callback_executed) | ;
}
void test_evented_timer__cancel_during_app_event(void) {
EventedTimerID timer = evented_timer_register(100, false, stub_evented_timer_callback, 0);
// We've started the timer, but it hasn't fired yet.
TimerID sys_timer_id = timer;
cl_assert(stub_new_timer_is_scheduled(sys_timer_id));
cl_assert_equal_i(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... | qemu_accel_init() | ;
#if CAPABILITY_HAS_MAGNETOMETER
mag3110_init();
#endif
}
void imu_power_up(void) {
}
void imu_power_down(void) {
}
bool gyro_run_selftest(void) {
return true;
}
|
rted_handler,
.stopped = prv_stopped_handler
};
// Create the inner sequence with a play count of 0
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
Animation *inner_seq = animation_... | (start_ms + 1) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (connection) | ) {
goto unlock;
}
bonding_id = connection->bonding_id;
if (device_name) {
strncpy(device_name, connection->device_name, BT_DEVICE_NAME_BUFFER_SIZE);
device_name[BT_DEVICE_NAME_BUFFER_SIZE - 1] = '\0';
}
unlock:
bt_unlock();
return bonding_id;
}
void bt_driver_store_device_name_kernelbg_cb(v... |
global_box = grect_to_global_coordinates(box, ctx);
GRect temp_box = global_box;
grect_clip(&temp_box, &ctx->draw_state.clip_box);
if (temp_box.size.h <= 0) {
// the text is not ever going to make it on screen. Bail early.
return;
}
if (layout) {
layout->box.origin = global_box.origin;
}
... | {
TextLayoutExtended *extended = prv_get_writable_extended_layout(layout);
if (!extended) {
return;
}
extended->flow_data.paging.page_on_screen.size_h = 0;
} |
void graphics_text_attributes_enable_paging(
GTextLayoutCacheRef layout, GPoint content_origin_on_screen, GRect paging_on_screen) {
TextLayoutExtended *extended = prv_get_writable_extended_layout(layout);
if (extended) {
extended->flow_data.paging = (TextLayoutFlowDataPaging) {
.origin_on_screen = con... |
_t current_bpm);
// Fakes
/////////////////////
#include "fake_pbl_std.h"
#include "fake_spi_flash.h"
#include "fixtures/load_test_resources.h"
static bool s_clock_is_24h_style = false;
bool clock_is_24h_style(void) {
return s_clock_is_24h_style;
}
// Stubs
/////////////////////
#include "stubs_analytics.h"
#inc... | (&s_data.window, true, true) | ;
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
#endif
}
void test_kickstart__render_hr_bpm_obstructed(void) {
#if (PLATFORM_SILK || PLATFORM_ROBERT)
prv_set_data(&s_data, 10323, 7500, 13000, 82);
prv_set_unobstructed_area_height(TIMELINE_PEEK_HEIGHT);
w... |
/*
* 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_use(BOARD_CONFIG_POWER.chg_fast.gpio) | ;
GPIO_WriteBit(BOARD_CONFIG_POWER.chg_fast.gpio, BOARD_CONFIG_POWER.chg_fast.gpio_pin, fast_charge_enabled?Bit_RESET:Bit_SET);
gpio_release(BOARD_CONFIG_POWER.chg_fast.gpio);
PBL_LOG(LOG_LEVEL_DEBUG, "Fastcharge %s", fast_charge_enabled?"enabled":"disabled");
}
}
void battery_init(void) {
s_debounce... |
, 1);;
cl_assert(s_stopped_handler_calls.entries[0].fired_time_ms - start_ms < duration);
cl_assert(ABSOLUTE_VALUE(s_stopped_handler_calls.entries[0].fired_time_ms - unschedule_time) < 1);
cl_assert(!s_stopped_handler_calls.entries[0].finished);
// Destroy it
animation_destroy(h);
#endif
}
// -------------... | DPRINTF("rescheduled count: %d\n", s_stopped_handler_calls.num_calls) | ;
DPRINTF("%"PRIu64": frame at: %d, %d, %d %d\n", time_ms - start_ms,
layer.frame.origin.x, layer.frame.origin.y,
layer.frame.size.w, layer.frame.size.h);
if (layer.frame.origin.x == to_r.origin.x && layer.frame.origin.y == to_r.origin.y) {
reached_end_elapsed = true;
}
if... |
/*
* 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... | task_zalloc_check(sizeof(AmbientLightAppData)) | ;
data->window = window_create();
Layer *window_layer = window_get_root_layer(data->window);
GRect bounds = window_layer->bounds;
bounds.origin.y += 40;
data->title_text_layer = text_layer_create(bounds);
text_layer_set_font(data->title_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_... |
/*
* 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... | {
case BtTestStateStarting: {
PBL_ASSERTN(!bt_ctl_is_bluetooth_active());
if (bt_test_bt_sig_rf_test_mode()) {
app_data->test_state = BtTestStateStarted;
} else {
app_data->test_state = BtTestStateFailed;
}
break;
}
case BtTestStateStopping: {
PBL_ASSERTN(... |
process_manager_send_callback_event_to_process(PebbleTask_App, update_text_layers_callback, (void*)data);
}
static void select_single_click_handler(ClickRecognizerRef recognizer, Window *window) {
AppData *data = app_state_get_user_data();
BtTestState new_state = data->test_state;
PBL_ASSERTN(data->test_sta... |
{ 632, 96, -736},
{ 800, 360, -792},
{ 896, 576, -856},
{ 1008, 704, -1120},
{ 784, 720, -984},
{ 520, 680, -896},
{ 240, 472, -768},
{ 144, 336, -632},
{ 80, 288, -752},
{ 120, 360, -896},
{ 96, 528, -952},
{ 56, 568, -984},
{ 80, 496, -928},
{ 160, 464, -872},
... | { 832, 88, -112},
{ 856, 56, -96},
{ 976, 104, -176},
{ 1136, 144, -112},
{ 1336, 272, -160},
{ 1480, 288, -352},
{ 1496, 240, -368},
{ 1240, 176, -240},
{ 816, 280, -304},
// 61 seconds
{ 640, 472, -360},
{ 544, 488, -288},
{ 704, 416, -256},
{ 840, 456, -360},
... |
{ 688, 512, -408},
{ 832, 552, -456},
{ 896, 592, -488},
{ 1032, 688, -448},
{ 1016, 752, -360},
{ 1208, 824, -312},
{ 1120, 808, -312},
{ 1392, 688, -288},
{ 1728, 664, -216},
{ 1464, 528, -160},
{ 1008, 384, -200},
{ 856, 296, -200},
{ 776, 224, -240},
{ 696, 1... |
TICKS; ++i) {
regular_timer_fire_seconds(PPOGATT_TIMEOUT_TICK_INTERVAL_SECS);
}
// Simulate receiving an ack for the last, after the roll-back, but before the packets are
// retransmitted (the last part shouldn't matter much, but simplifies the test a bit)
prv_receive_ack(s_characteristics[0][PPoGATTCharac... | (fake_comm_session_send_buffer_write_raw_by_transport(transport,
s_short_data_fragment,
sizeof(s_short_data_fragment) - sn), true) | ;
fake_malloc_set_largest_free_block(1000);
s_mtu_size = 0;
ppogatt_send_next(transport);
// No crash
}
//! When client ID info got added to the Reset Packet (PBL-14099), a potential buffer overrun
//! situation got introduced accidentally. This test is a white-box test to catch this issue.
//! For the Reset P... |
ndlers.will_change, prv_will_change);
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
fake_event_service_handle_last();
unobstructed_area_service_will_change(from_area.size.h, to_... | (0, 0, DISP_COLS, 200) | ;
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
UnobstructedAreaHandlers handlers = {
.will_change = prv_will_change,
.did_change = prv_did_change,
};
app_unobstructed_area_service_subscribe(handlers, s_data.context);
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTE... |
config.h"
#include "drivers/timer.h"
#include "kernel/pbl_malloc.h"
#include "kernel/pebble_tasks.h"
#include "kernel/util/sleep.h"
#include "kernel/util/stop.h"
#include "services/common/analytics/analytics.h"
#include "services/common/analytics/analytics_logging.h"
#include "services/common/bluetooth/bluetooth_ctl.h"... | (BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update, ENABLE) | ;
}
static void prv_watchdog_deinit(void) {
TIM_Cmd(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, DISABLE);
TIM_ITConfig(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update, DISABLE);
periph_config_disable(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, RCC_APB1Periph_TIM6);
s_spi_transport.watchdog_timer_active = f... |
Title text
#define NUMBER_OFFSET_Y (TEXT_OFFSET_Y + 2)
static void prv_update_proc(Layer *layer, GContext *ctx) {
PeekLayer *peek_layer = (PeekLayer *)layer;
const GRect layer_bounds = { .size = layer->bounds.size };
if (peek_layer->bg_color.a != 0) {
graphics_context_set_fill_color(ctx, peek_layer->bg_colo... | kino_layer_set_alignment(&peek_layer->kino_layer, GAlignCenter) | ;
layer_set_clips((Layer *)&peek_layer->kino_layer, false);
layer_add_child((Layer *)peek_layer, (Layer *)&peek_layer->kino_layer);
const GTextAlignment text_alignment = GTextAlignmentCenter;
GRect text_rect = GRect(0, NUMBER_OFFSET_Y, frame->size.w, 40);
// number layer
text_layer_init_with_parameters(&pe... |
/*
* 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... | (shared_prf_storage_get_getting_started_complete()) | );
}
|
able other applib modules like sroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
property_animation_legacy2_update_gpoint((PropertyAnimationLegacy2 *)property_animation_h,
distance_normalized);
return;
}
... | interpolate_fixed32(
distance_normalized,
property_animation->values.from.gtransform.ty,
property_animation->values.to.gtransform.ty) | ;
// NOTE: We are not exposing the GTransform in the public SDK, so the setter and getter
// must be typecast
GTransformSetter setter = (GTransformSetter)((PropertyAnimationImplementation*)
property_animation->animation.implementation)
->accessors.set... |
le name info
}
prv_flash_read((uint8_t *)&file_hdr.file_namelen, sizeof(file_hdr.file_namelen),
prv_page_to_flash_offset(pg) + file_namelen_offset);
if (file_hdr.file_namelen == namelen) {
char file_name[namelen];
prv_flash_read((uint8_t *)file_name, namelen, prv_page_to_flash_offset(... | page_is_unallocated(page_flags) | ) {
sectors_active |= (0x1 << (pg % PFS_PAGES_PER_ERASE_SECTOR));
}
}
return (sectors_active);
}
//! Scans through the filesystem and finds a sector with no pages that
//! are active
//!
//! @param skip_gc_region - will skip checking the region that is
//! used for garbage collection
//! @return the... |
nimation *animation,
bool finished, void *context) {
cl_assert(history->num_calls < MAX_HANDLER_CALLS);
history->entries[history->num_calls++] = (AnimTestHandlerEntry) {
.fired_time_ms = prv_now_ms(),
.fire_order = s_fire_order_index++,
.finished = finished,
.contex... | {
prv_add_handler_entry(&s_setup_handler_calls, animation, false, NULL);
DPRINTF("%"PRIu64" ms: Executing setup handler for %d\n", prv_now_ms(), (int)animation);
} | |
(void *)layout_ref);
if (custom_node) {
custom_node->node.offset.y = 11;
custom_node->node.margin.h = 12;
return &custom_node->node;
} else {
return NULL;
}
}
static GTextNode *prv_card_view_constructor(TimelineLayout *timeline_lay... | &s_time_vertical_container_config.container.extent.node,
};
static const LayoutNodeHorizontalConfig s_horizontal_config = {
.container.extent.node.type = LayoutNodeType_Horizontal,
.container.num_nodes = ARRAY_LENGTH(s_horizontal_config_nodes),
.container.nodes = (LayoutNodeConfig **)&s_horizontal_c... | |
/*
* 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 0;
} |
void test_ancs_notifications__initialize(void) {
s_now = 1;
fake_notification_storage_reset();
fake_event_init();
}
void test_ancs_notifications__cleanup(void) {
}
void test_ancs_notifications__handle_phone_call_message(void) {
const uint8_t app_id[] = {
0x00,
21, 0x00,
'c', 'o', 'm', '.'... |
INFO, "Requesting BLE HRM sharing permission");
BLEHRMSharingRequest *const sharing_request = kernel_zalloc_check(sizeof(*sharing_request));
sharing_request->connection = connection;
launcher_task_add_callback(prv_push_sharing_request_window_kernel_main_cb, sharing_request);
}
static void prv_put_sharing_state_u... | (connection) | ;
}
bt_unlock();
analytics_event_ble_hrm(BleHrmEventSubtype_SharingRevoked);
}
static void prv_revoke_gap_le_connection_for_each_cb(GAPLEConnection *connection, void *unused) {
prv_update_permission(connection, HrmSharingPermission_Declined);
prv_disconnect_to_kill_subscription(connection);
}
void ble_hrm_... |
ftime(buf, buf_size, "%j", &good_data);
if (r == 0 || strncmp(buf, "125", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"j\": %s", buf);
}
r = strftime(buf, buf_size, "%m", &good_data);
if (r == 0 || strncmp(buf, "05", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"m\": %s",... | (buf, buf_size, "%I", &bad_data) | |
nse_msg->response == ResponseAck) {
++s_acks_received;
} else if (response_msg->response == ResponseNack) {
++s_nacks_received;
}
}
void test_put_bytes__initialize(void) {
fake_pb_storage_mem_reset();
fake_pb_storage_mem_set_crc(EXPECTED_CRC);
fake_comm_session_init();
fake_event_reset_count();
... | cl_assert_equal_i(event.put_bytes.progress_percent, 0) | |
14),
GColorBlack, GColorClear, GTextAlignmentCenter,
GTextOverflowModeTrailingEllipsis);
layer_add_child(&window->layer, &code_text_layer->layer);
}
prv_adjust_background_frame_for_state(data);
prv_initialize_info_text(data);
}
static ... | prv_push_pairing_window() | ;
}
static void prv_handle_pairing_complete(bool success) {
if (!s_data_ptr) {
PBL_LOG(LOG_LEVEL_WARNING, "Dialog was not present, but got complete (%u) event", success);
return;
}
BTPairingUIData *data = s_data_ptr;
if (data->ui_state == BTPairingUIStateAwaitingUserConfirmation) {
prv_exit_awaiti... |
ntZero, 3686380, 0,
&GPoint(15, 100), 20, 0, true);
// touchdown event should reset the touch event queue regardless of what is in it
touch_handle_update(0, TouchState_FingerDown, &GPoint(31, 1), 6, 3686500);
touch_event = touch_event_queue_get_event(0, 0);
prv_test_touch_event(touch_eve... | cl_assert_equal_p(touch_event, NULL) | ;
}
// test that the first dispatch after a cancel event is pended does not return any touches, even
// if new touches have arrived - this is to ensure that the valid new touches are not cancelled
// by the cancellation event if it is pended before previous touches
void test_touch__cancel_touches_handle_first_dispatch... |
/*
* 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_override_index(app_id) | - prv_override_index(new_id));
}
static int prv_comparator_ascending_zero_last(unsigned int a, unsigned int b) {
return ((a != 0) && (b != 0)) ? (b - a) : // Sort in ascending order
(a - b); // 0 should be sorted last so invert the sort
}
T_STATIC int prv_app_node_comparator(void... |
nsed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under t... | prv_send_response(session, (uint8_t *)&response, sizeof(response)) | ;
}
static void prv_handle_wb_write_response(const uint8_t *data,
uint32_t length) {
// read token and response code
BlobDBToken token;
BlobDBResponse response_code;
prv_read_token_and_response(data, &token, &response_code);
BlobDBSyncSession *sync_session = blob_db_... |
{ .argb = (data->bg_color.argb | ALPHA_100) };
uint8_t alpha = data->alpha;
if (alpha == ALPHA_100) {
graphics_context_set_stroke_color(ctx, fg_color);
graphics_draw_pixel(ctx, point);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y));
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1));
... | {
const GRect box = GRect(origin.x + 4*color_index_match - 1, origin.y - 1 + height_offset,
COLOR_BAR_WIDTH + 2, COLOR_BAR_HEIGHT + 2);
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_draw_rect(ctx, &box);
} |
}
static void up_handler(ClickRecognizerRef recognizer, void *context) {
AppData *data = window_get_user_data(s_window);
if (data->property == PROPERTY_FG_COLOR) {
data->fg_color_index = (data->fg_color_index + 1) & 0x3F;
data->fg_color.argb = (s_color_table[data->fg_color_index] | ALPHA_100);
} else if... |
ti_clockwise(void) {
rocky_global_init(s_graphics_api);
prv_create_global_ctx();
EXECUTE_SCRIPT(
"ctx.beginPath();\n"
"ctx.moveTo(80, 40);\n"
"ctx.arc(60, 80, 20, 0, Math.PI, true);\n"
"ctx.stroke();\n"
);
cl_assert_equal_i(1, s_graphics_line_draw_precise_stroked.call_count);
cl_assert_e... | cl_assert(actual_size >= min_size + 1) | ;
}
void test_rocky_api_graphics_path2d__array_realloc_oom(void) {
fake_malloc_set_largest_free_block(0);
const jerry_value_t rv = rocky_api_graphics_path2d_try_allocate_steps(1);
ASSERT_JS_ERROR(rv, "RangeError: Out of memory: can't create more path steps");
jerry_release_value(rv);
}
|
ration_ms;
music_get_pos(&track_pos_ms, &track_duration_ms);
cl_assert_equal_i(track_pos_ms, 0);
cl_assert_equal_i(track_duration_ms, 0);
cl_assert_equal_i(music_get_playback_rate_percent(), 0);
}
void test_ams__receive_non_numeric_player_playback_info_update(void) {
prv_connect_ams();
// Receive: 'A', '... | music_needs_user_to_start_playback_on_phone() | , true);
for (MusicCommand cmd = 0; cmd < NumMusicCommand; ++cmd) {
cl_assert_equal_b(music_is_command_supported(cmd), true);
}
cl_assert_equal_b(music_is_command_supported(NumMusicCommand), false);
}
// Tests: Create & Destroy
///////////////////////////////////////////////////////////
void test_ams__crea... |
ert_equal_p(aa, stack[1]);
// go to child if possible
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaa, actual);
cl_assert_equal_i(2, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1]);
cl_assert_equal... | {
Layer parent, child_a, child_b, child_c, child_d, child_e, child_f;
Layer *layers[] = {&parent, &child_a, &child_b, &child_c, &child_d, &child_e, &child_f};
for (int i = 0; i < ARRAY_LENGTH(layers); ++i) {
layer_init(layers[i], &GRectZero);
}
layer_set_frame(&parent, &GRect(0, 0, 20, 20));
layer_set_f... |
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(15, 15)), &parent);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(-5, -5)), NULL);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(21, 21)), NULL);
layer_remove_from_parent(&child_f);
layer_add_c... |
GRect line2;
line2.size.w = REL_BAR_LINE_CHECK_LENGTH + REL_BAR_LINE_WIDTH;
line2.size.h = REL_BAR_LINE_WIDTH;
line2.origin.x = line.origin.x - REL_BAR_LINE_NOTCH_HORIZ_OFFSET + 1;
line2.origin.y = grect_get_max_y(&line) - line2.size.h;
graphics_fill_rect(ctx, &line2);
// Bar 2
// Filled rect used to ... | (ctx, &line) | ;
// Top Notch for Bar 2
// Filled rect used to draw line of REL_BAR_LINE_WIDTH stroke width
notch.origin.x = line.origin.x - REL_BAR_LINE_NOTCH_HORIZ_OFFSET + 1;
notch.origin.y = line.origin.y;
notch.size.w = REL_BAR_LINE_CHECK_LENGTH + REL_BAR_LINE_WIDTH;
notch.size.h = REL_BAR_LINE_WIDTH;
graphics_fil... |
/*
* 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... | kernel_free(s_cache->cache) | ;
kernel_free(s_cache);
s_cache = NULL;
}
}
void ancs_app_name_storage_store(const ANCSAttribute *app_id, const ANCSAttribute *app_name) {
if (!app_id || !app_name) {
return;
}
// copy app id
ANCSAttribute *app_id_copy = kernel_zalloc_check(sizeof(ANCSAttribute) + app_id->length);;
memcpy(app_... |
ble_ad_create(void) {
const size_t max_ad_data_size = sizeof(BLEAdData) +
(GAP_LE_AD_REPORT_DATA_MAX_LENGTH * 2);
BLEAdData *ad_data = applib_malloc(max_ad_data_size);
if (ad_data) {
memset(ad_data, 0, sizeof(BLEAdData));
}
return ad_data;
}
// ---------------------... | {
case 16: element->header.type = BLEAdTypeService128BitUUIDComplete; break;
case 4: element->header.type = BLEAdTypeService32BitUUIDComplete; break;
case 2: element->header.type = BLEAdTypeService16BitUUIDComplete; break;
default:
WTF;
} |
element->header.length = buffer_size - 1 /* -1 Length byte */;
// Copy UUIDs:
for (unsigned int i = 0; i < num_uuids; ++i) {
switch (max_width_bytes) {
case 16: element->uuid_128[i] = uuids[i]; break;
case 4: element->uuid_32[i] = prv_convert_to_32bit_uuid(&uuids[i]); break;
case 2: eleme... |
/*
* 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(utf8_iter_state.current == utf8_bounds.end) | ;
cl_assert(*utf8_iter_state.current == '\0');
cl_assert(utf8_iter_state.codepoint == 0);
}
void test_utf8_iterator__decode_valid_string_backwards(void) {
// Mutable types
Iterator utf8_iter;
Utf8IterState utf8_iter_state;
// Immutable types
bool success = false;
const Utf8Bounds utf8_bounds = utf8_ge... |
0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17};
cl_assert_equal_i(INSTALL_ID_INVALID, app_install_get_id_for_uuid(&made_up));
cl_assert_equal_i(INSTALL_ID_INVALID, app_install_get_id_for_uuid(&UUID_INVALID));
cl_assert_equal_i(INSTALL_ID_INVALID, app_install_get_id_for_uuid(&(const Uuid)UU... | {
cl_assert_equal_b(false, app_install_is_hidden(tictoc_id));
cl_assert_equal_b(false, app_install_is_hidden(music_id));
cl_assert_equal_b(true, app_install_is_hidden(sports_id));
cl_assert_equal_b(false, app_install_is_hidden(bg_counter_id));
cl_assert_equal_b(false, app_install_is_hidden(menu_layer_id));
... |
void test_app_install_manager__is_from_system(void) {
cl_assert_equal_b(true, app_install_id_from_system(-1000000));
cl_assert_equal_b(true, app_install_id_from_system(-1));
cl_assert_equal_b(false, app_install_id_from_system(0));
cl_assert_equal_b(false, app_install_id_from_system(1));
cl_assert_equal_b(fa... |
e.antialiased) {
// apply draw box and clipping
y1.integer += ctx->draw_state.drawing_box.origin.y;
y2.integer += ctx->draw_state.drawing_box.origin.y;
x += ctx->draw_state.drawing_box.origin.x;
GBitmap *framebuffer = graphics_capture_frame_buffer(ctx);
if (!framebuffer) {
// Couldn't cap... | (ctx, x, y_min, y_max, color) | ;
}
void graphics_private_plot_horizontal_line(GContext *ctx, int16_t y, Fixed_S16_3 x1, Fixed_S16_3 x2,
uint16_t opacity) {
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
// apply draw box and clipping
x1.integer += ctx->draw_state.drawing_box.origin.x;
x2.in... |
is_scheduled(state, animation);
}
// -------------------------------------------------------------------------------------------
bool animation_set_handlers(Animation *animation_h, AnimationHandlers handlers,
void *context) {
AnimationState *state = prv_animation_state_get(PebbleTask_Cur... | (PebbleTask_Current) | ;
if (animation_private_using_legacy_2(state)) {
// We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
animation_legacy2_set_delay((AnimationLegacy2 *)animation_h, delay_ms);
return true;
}
Animation... |
10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, true);
ASSERT_NO_CHANGE(graphics_draw_line(&context, GPoint(5, 5), GPoint(45, ... | cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0) | ;
// Stroke Width
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_stroke_width(&context, 11);
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
}
void test_graphics_context_${BIT_DEPTH_NAME}__lock_framebuffer(void) {
FrameBuffer fb = {};
framebuf... |
((void(*)(void))data)() | ;
}
////////////////////
// UI Code
typedef struct {
Window window;
TextLayer text;
} AppData;
static void set_text(Window *window, char *message) {
AppData *data = window_get_user_data(window);
TextLayer *text = &data->text;
text_layer_set_text(text, message);
PBL_LOG(LOG_LEVEL_DEBUG, "%s", message);
}
... | |
ice_activities_iterate(HealthActivityMaskAll, now - (100 * SECONDS_PER_MINUTE), now,
HealthIterationDirectionPast, prv_activity_cb, NULL);
cl_assert_equal_i(0, s_prv_activity_cb__call_count);
s_sys_activity_get_sessions_values.out.result = true;
// result from mocked sys_activ... | cl_assert_equal_i(activities, HealthActivitySleep | HealthActivityRestfulSleep) | ;
s_sys_activity_get_metric_values.out.history[0] = ActivitySleepStateAwake;
s_activity_sessions_ongoing[ActivitySessionType_Run] = true;
s_activity_sessions_ongoing[ActivitySessionType_Walk] = true;
s_activity_sessions_ongoing[ActivitySessionType_Open] = true;
activities = health_service_peek_current_activi... |
m_is_equal(&t, &t_c));
// Test Rotation Matrix
int32_t angle = DEG_TO_TRIGANGLE(45);
t = GTransformRotation(angle);
int32_t cosine = cos_lookup(angle);
int32_t sine = sin_lookup(angle);
t_c = GTransform(GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO),
GTransformNumberFromNum... | cl_assert(gtransform_is_equal(&t_new, &t_c)) | ;
cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has not changed
gtransform_translate_number(&t_new, &t1, 10, 200);
cl_assert(gtransform_is_equal(&t_new, &t_c));
cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has not changed
// Test pointer re-use
gtransform_translate(&t1, &t1, GTransformN... |
option_menu->status_colors.foreground);
}
void option_menu_set_normal_colors(OptionMenu *option_menu, GColor background, GColor foreground) {
option_menu->normal_colors.background = background;
option_menu->normal_colors.foreground = foreground;
menu_layer_set_normal_colors(&option_menu->menu_layer,
... | {
menu_layer_deinit(&option_menu->menu_layer);
status_bar_layer_deinit(&option_menu->status_layer);
window_deinit(&option_menu->window);
gbitmap_deinit(&option_menu->chosen_image);
gbitmap_deinit(&option_menu->not_chosen_image);
} |
OptionMenu *option_menu_create(void) {
OptionMenu *option_menu = applib_type_malloc(OptionMenu);
if (!option_menu) {
return NULL;
}
option_menu_init(option_menu);
return option_menu;
}
void option_menu_destroy(OptionMenu *option_menu) {
option_menu_deinit(option_menu);
applib_free(option_menu);
}
... |
item select callback
static void menu_select_callback(int index, void *ctx) {
PBL_LOG(LOG_LEVEL_DEBUG, "Selected menu item %d", index);
// Here we just change the subtitle to a literal string
s_app_data->menu_items[index].subtitle = "You've hit select here!";
// Mark the layer to be updated
layer_mark_... | system_task_add_callback(stuck_system_task_callback, NULL) | ;
} else if (index == 12) {
PBL_LOG(LOG_LEVEL_INFO, "Generate hard-fault");
// Modify behavior of the ARM so that bus faults generate a hard fault
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
// Write to protected memory
extern uint32_t __isr_stack_start__[];
__isr_stack_start__[0] = 0x55;
}... |
al_collect_app_cpu_stats(void);
extern void analytics_external_collect_app_flash_read_stats(void);
static void prv_handle_app_stop_analytics(const ProcessContext *const context,
PebbleTask task, bool gracefully) {
if (!gracefully) {
if (task == PebbleTask_App) {
if ... | new_timer_start(s_deinit_timer_id, 3 * 1000, prv_graceful_close_timer_callback, (void*)task,
0 /*flags*/) | |
"23257157360,23257157360");
}
void test_sprintf__percent_x(void) {
char dstbuf[256];
// Simple %x
snprintf(dstbuf, 256, "There are %x lights, %x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, fffffffc");
// Alternate form (adds 0x prefix)
snprintf(dstbuf, 256, "There are %#x lights, %#x", 16,... | (dstbuf, 256, "There are %.3X lights, %.3X", 16, -4) | |
#include "compositor.h"
#include "applib/graphics/framebuffer.h"
#include "kernel/event_loop.h"
#include "kernel/pbl_malloc.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/system_task.h"
#include "system/logging.h"
#include "util/attributes.h"
#include "util/net.h"
static co... | memcpy(output_buffer_with_offset, framebuffer_row_data + framebuffer_current_column,
remaining_framebuffer_row_bytes);
#endif
if (framebuffer_row_is_larger_than_chunk) {
state->col = remaining_chunk_bytes * cols_per_byte;
} else {
state->col = 0;
state->row++;
}
remaini... |
void screenshot_send_next_chunk(void* raw_state) {
ScreenshotState* state = (ScreenshotState*)raw_state;
CommSession *session = state->session;
uint32_t max_buf_len = comm_session_send_buffer_get_max_payload_length(session);
uint32_t session_len = 0;
if (!state->sent_header) {
max_buf_len -= sizeof(Scr... |
/*
* 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... | interval_timer_get(&timer, &average_ms) | |
goto exit;
}
}
if (timeout <= 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for logging_session to write");
}
dls_unlock_session(logging_session, true /*inactivate*/);
exit:
dls_send_all_sessions();
}
// -------------------------------------------------------------------------------------... | {
return (logging_session->comm.session_id);
} | |
og if appropriate.
if (!gracefully) {
prv_app_show_crash_ui(old_install_id);
}
// Clear for next time.
s_next_app = (NextApp) {};
return true;
}
// ---------------------------------------------------------------------------------------------
void app_manager_start_first_app(void) {
const PebbleProce... | PBL_LOG(LOG_LEVEL_INFO,
"Next app overridden with watchface because action was performed successfully") | ;
return watchface_get_default_install_id();
// Handling this case specifically instead of providing a default case ensures that the addition
// of future exit reason values will cause compilation to fail until the new case is handled
case NUM_EXIT_REASONS:
break;
}
WTF;
}
// --------------... |
m *item) {
}
const PebbleProcessMd *timeline_get_app_info(void) {
return NULL;
}
PebblePhoneCaller* phone_call_util_create_caller(const char *number, const char *name) {
return NULL;
}
void ancs_perform_action(uint32_t notification_uid, uint8_t action_id) {
}
void notifications_handle_notification_action_result... | fake_spi_flash_init(0, 0x1000000) | ;
fake_rtc_init(0, 0);
pfs_init(false);
// Note: creating a settings file is going to result in one malloc for the FD name
pin_db_init();
time_util_update_timezone(&tz);
fake_pbl_malloc_clear_tracking();
for (unsigned int i = 0; i < ARRAY_LENGTH(s_items); ++i) {
cl_assert_equal_i(pin_db_insert_item(&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... | ((impl->curr_pos + length) <= impl->total_payload_size) | |
/*
* 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... | (op, data, num_data, prv_filter, &s_context, &result) | |
int32_t sleep_total_seconds,
ActivityScalarStore sleep_average_seconds, Uuid *uuid) {
prv_generate_sleep_pin_strings(sleep_enter_seconds, sleep_exit_seconds, sleep_total_seconds);
// Insert or update the pin
return prv_push_summary_pin(pin_time_utc, now_utc, uui... | kernel_free(start_time) | ;
kernel_free(short_subtitle);
kernel_free(elapsed);
i18n_free_all(&pin_attr_list);
attribute_list_destroy_list(&pin_attr_list);
return item;
}
// ------------------------------------------------------------------------------------------------
// Creates a notification to notify the user of the nap session
... |
/*
* 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_WriteBit(GPIOD, GPIO_Pin_2, Bit_SET) | |
E_8 = 0xa8,
PmicRegisters_FUSE_9 = 0xa9,
PmicRegisters_FUSE_10 = 0xaa,
PmicRegisters_FUSE_11 = 0xab,
PmicRegisters_FUSE_12 = 0xac,
PmicRegisters_FUSE_13 = 0xad,
PmicRegisters_FUSE_14 = 0xae,
PmicRegisters_FUSE_15 = 0xaf,
} PmicRegisters;
static const PmicRegisters s_registers[] = {
0x01, 0x02, 0x03, 0x... | (prv_pmic_state_change_cb, NULL, should_context_switch) | |
/*
* 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... | while (*str) {
prv_putchar(*str);
++str;
} |
}
void dbgserial_newline(void) {
prv_putchar('\r');
prv_putchar('\n');
}
void dbgserial_putstr(const char* str) {
dbgserial_print(str);
dbgserial_newline();
}
void dbgserial_print_hex(uint32_t value) {
char buf[12];
itoa(value, buf, sizeof(buf));
dbgserial_print(buf);
}
|
get the length of the data buffer(s) which is the max length of data we could have received
const uint32_t data_length = mbuf_get_chain_length(mbuf_get_next(s_read_header_mbuf));
mbuf_free(s_read_header_mbuf);
s_read_header_mbuf = NULL;
SmartstrapResult result = SmartstrapResultOk;
if (!success) {
result... | {
// make sure we're not spamming the smartstrap with service discovery messages
static time_t s_last_service_discovery_time = 0;
const time_t current_time = rtc_get_time();
if (!s_has_done_service_discovery &&
(current_time > s_last_service_discovery_time + MIN_SERVICE_DISCOVERY_INTERVAL) &&
smarts... | |
load_range(font_res->app_num, font_res->resource_id,
data->resource_offset, (uint8_t *)&g->header,
sizeof(GlyphHeaderData));
SYS_PROFILER_NODE_STOP(text_render_flash);
}
if (!num_bytes_loaded) {
PBL_LOG(LOG_LEVEL_... | if (header.features & FEATURE_RLE4) {
font_res->md.version |= VERSION_FIELD_FEATURE_RLE4;
} |
break;
default:
PBL_LOG(LOG_LEVEL_ERROR, "Unknown font resource version %"PRIu8, header.version);
return false;
}
return true;
}
static const FontResource *prv_font_res_for_codepoint(Codepoint codepoint,
const FontInfo *font_info) {
if... |
BOARD_CONFIG_DISPLAY.spi_clk);
uint32_t dma_clock_status = (RCC->AHB1ENR & DISPLAY_DMA_CLOCK);
uint32_t pri_mask = __get_PRIMASK();
PBL_CROAK("display DMA failed: 0x%" PRIx32 " %d 0x%lx 0x%lx", pri_mask,
dma_status, spi_clock_status, dma_clock_status);
}
power_tracking_stop(PowerSystemMcuDma1)... | (167 - r.address + 1) | << 8;
#endif
prv_setup_dma_transfer(((uint8_t*) s_dma_line_buffer) + 1, DISP_DMA_BUFFER_SIZE_BYTES - 1);
break;
}
default:
WTF;
}
return false;
}
static void prv_setup_dma_transfer(uint8_t *framebuffer_addr, int framebuffer_size) {
void *dst = (void *)&(BOARD_CONFIG_DISPLAY.spi->DR);
dma_reque... |
NEW_PRF_AVAILABLE), BOOT_BIT_NEW_PRF_AVAILABLE);
}
void test_put_bytes__install_message_fw_and_sys_resources_boot_bits_set(void) {
// Firmware object:
prv_receive_init_put_commit_and_install(ObjectFirmware);
assert_ack_count(1);
assert_nack_count(0);
// Expect boot bit not to be set yet:
cl_assert_equal_i... | prv_receive_init_fw_object() | ;
PebbleCommSessionEvent app_event = {
.is_open = false,
.is_system = true
};
// Close the BT session, have put_bytes react
put_bytes_handle_comm_session_event(&app_event);
fake_system_task_callbacks_invoke_pending();
assert_cleanup_event(ObjectFirmware, VALID_OBJECT_SIZE);
}
void test_put_byte... |
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 in writing, software
... | (&file, "notifpref", 1024) | );
cl_must_pass(settings_file_get(&file, key, key_len, buffer, value_len));
settings_file_close(&file);
cl_assert_equal_m(expected_value, buffer, value_len);
}
static void prv_assert_manually_dnd_setting_val(bool expected_value) {
const char *key = "dndManuallyEnabled";
prv_assert_settings_value((void*)key, ... |
icense 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/alerts_preferences.h"
#include "... | 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_notification_removed(uid, ANCSProperty_IncomingCall);
cl_assert_equal_i(fake_event_get_count(), 0);
// Make sure that we trigger 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... | printf("gack() = %d\n", gack()) | ;
return 0;
}
#endif
|
T 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 "applib/ui/content_indicator.h"
#include "applib/ui/content_indicator_private.h"
#include "util/buffer.h"
// Fakes... | {
content_indicator_deinit(&content_indicator);
bytes_written -= sizeof(ContentIndicator *);
cl_assert_equal_i(buffer->bytes_written, bytes_written);
} | |
_color = menu_layer->normal_colors[MenuLayerColorBackground];
graphics_fill_rect(ctx, bounds);
}
graphics_context_set_drawing_state(ctx, prev_state);
}
void menu_layer_update_proc(Layer *scroll_content_layer, GContext* ctx) {
MenuLayer *menu_layer = (MenuLayer*)(((uint8_t*)scroll_content_layer) -
offs... | (inverter, &GRectZero) | ;
scroll_layer_add_child(scroll_layer, &inverter->layer);
// Hide inverter layer by default for 3.0 apps
layer_set_hidden(inverter_layer_get_layer(&menu_layer->inverter), true);
#if PBL_ROUND
prv_set_center_focused(menu_layer, true);
#endif
}
MenuLayer* menu_layer_create(GRect frame) {
MenuLayer *layer = a... |
ssert_equal_b(false, app_install_id_from_app_db(0));
cl_assert_equal_b(true, app_install_id_from_app_db(1));
cl_assert_equal_b(true, app_install_id_from_app_db(1000000));
}
void test_app_install_manager__get_md(void) {
const PebbleProcessMd *tictoc_md = app_install_get_md(tictoc_id, false);
cl_assert(tictoc_md... | (music_id) | );
// Update most recent time.
app_install_mark_prioritized(music_id, true /* can_expire */);
cl_assert_equal_b(true, app_install_is_prioritized(music_id));
// Clear recent time.
app_install_unmark_prioritized(music_id);
cl_assert_equal_b(false, app_install_is_prioritized(music_id));
// Update most rec... |
08, 0x0},
{ 0, 0x43, 7062, 0x0},
{ 0, 0x64, 4083, 0x0},
{ 11, 0x43, 5342, 0x0},
{ 0, 0x54, 1212, 0x0},
{ 20, 0x44, 2807, 0x0},
{ 0, 0x52, 3184, 0x0},
// 30: Local time: 01:05:00 PM
{ 6, 0x52, 1515, 0x0},
{ 12, 0x52, 3288, 0x0},
{ 0, 0x51, 1882, 0x0},
{ 0, 0x76, 90, 0x0},
... | { 66, 0x19, 3883, 0x0},
{ 85, 0x47, 6812, 0x0},
{ 18, 0x47, 7706, 0x0},
{ 79, 0x47, 5745, 0x0},
{ 94, 0x48, 7846, 0x0},
{ 102, 0x47, 8450, 0x0},
{ 82, 0x37, 9260, 0x0},
{ 101, 0x43, 7259, 0x0},
{ 113, 0x43, 8199, 0x0},
{ 115, 0x43, 8125, 0x0},
{ 75, 0x34, 10402, 0x0},
{ 1... |
{ 9, 0x64, 1090, 0x0},
{ 0, 0x63, 11, 0x0},
{ 0, 0x63, 17, 0x0},
// 195: Local time: 03:51:00 PM
{ 0, 0x63, 51, 0x0},
{ 0, 0x63, 81, 0x0},
{ 0, 0x62, 432, 0x0},
{ 0, 0x63, 1303, 0x0},
{ 0, 0x62, 210, 0x0},
{ 0, 0x51, 2442, 0x0},
{ 0, 0x63, 565, 0x0},
{ 0, 0x63, 3293, 0x0... |
cl_assert_equal_i((intptr_t) xQueue, (intptr_t) FAKE_APP_QUEUE);
if (s_event_count < ARRAY_LENGTH(s_events_received)) {
s_events_received[s_event_count] = *((PebbleEvent *)pvItemToQueue);
}
++s_event_count;
return pdTRUE;
}
QueueHandle_t pebble_task_get_to_queue(PebbleTask task) {
switch (task) {
... | cl_assert(ret_update_interval_s == update_interval_s) | ;
cl_assert(ret_expire_s == expire_s);
cl_assert(ret_features == features);
sys_hrm_manager_unsubscribe(session_ref);
fake_system_task_callbacks_invoke_pending();
cl_assert(prv_get_subscriber_state_from_ref(session_ref) == NULL);
cl_assert_equal_b(hrm_is_enabled(HRM), false);
}
// When we cleanup after an... |
new_ms = (new_ticks * 1000 + RTC_TICKS_HZ / 2) / RTC_TICKS_HZ;
if (new_ms == target_ms - 1) {
new_ticks++;
} else if (new_ms == target_ms + 1) {
new_ticks--;
}
new_ms = (new_ticks * 1000 + RTC_TICKS_HZ / 2) / RTC_TICKS_HZ;
cl_assert(new_ms == target_ms);
fake_rtc_set_ticks(new_ticks);
}
// -------... | {
cl_assert(history->num_calls < MAX_HANDLER_CALLS);
history->entries[history->num_calls++] = (AnimTestHandlerEntry) {
.fired_time_ms = prv_now_ms(),
.fire_order = s_fire_order_index++,
.finished = finished,
.context = context,
.animation = animation
};
} |
// -------------------------------------------------------------------------
// Count how many entries were entered for the given animation
static uint32_t prv_count_handler_entries(AnimTestHandlerHistory *history, Animation *animation) {
uint32_t count = 0;
for (int i = 0; i < history->num_calls; i++) {
if... |
_t steps, duration_s, distance_m, bpm;
HRZone hr_zone;
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 0);
cl_assert_equal_i(duration_s, 0);
cl_assert_equal_i(distance_m, 0);
... | (activity_private_compute_active_calories(distance_delta_m * MM_PER_METER, 600 * MS_PER_SECOND),
ACTIVITY_CALORIES_PER_KCAL) | |
_layer, &GRect(x, y, w, h),
dialog->buffer, dialog_text_font,
dialog->text_color, GColorClear, text_alignment,
GTextOverflowModeWordWrap);
#if PBL_ROUND
text_layer_enable_screen_text_flow_and_paging(text_layer, TEXT_... | {
workout_dialog_init(workout_dialog, dialog_name);
} |
return workout_dialog;
}
Dialog *workout_dialog_get_dialog(WorkoutDialog *workout_dialog) {
return &workout_dialog->dialog;
}
ActionBarLayer *workout_dialog_get_action_bar(WorkoutDialog *workout_dialog) {
return &workout_dialog->action_bar;
}
void workout_dialog_set_click_config_provider(WorkoutDialog *workou... |
/*
* 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... | (color, tint_color) | ;
}
color = gcolor_get_grayscale(color);
for (unsigned int row_number = 0; row_number < ARRAY_LENGTH(*look_up); row_number++) {
(*look_up)[row_number].palette_pattern[palette_index] =
graphics_private_get_1bit_grayscale_pattern(color, row_number);
(*look_up)[row_number].transparent_mask[... |
S);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, NULL), 3);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, NULL), 3);
// If we keep going, we should repeat the whole sequence another time
prv_advance_to_ms_with_timers(start_ms + 2 * (duration_total + 4 * MIN_FRAM... | (&s_stopped_handler_calls, b1) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b2), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b3), 1);
// Make sure the all the spawn a stopped handlers got called before any of the spawn b
// started handlers
uint32_t last_fire_a = 0;
last_fire... |
battery_curve_lookup_voltage_by_percent(50, false);
int high_mv = battery_curve_lookup_voltage_by_percent(100, false);
int lower_mv = battery_curve_lookup_voltage_by_percent(20, false);
fake_battery_init(low_mv, false, false);
fake_rtc_auto_increment_ticks(50000);
battery_monitor_init();
periodic_timer_t... | (result.charge_percent >= last_charge_percent) | ;
cl_assert(result.is_charging == charging);
cl_assert(result.is_plugged);
last_charge_percent = result.charge_percent;
//
// test as if the battery is unplugged and discharging
//
fake_battery_init(discharge_mv, false, false);
battery_monitor_init();
periodic_timer_trigger(1);
r... |
GPoint p1 = GPoint(x1, y2);
GPoint p2 = GPoint(x2, y2);
GPoint p3 = GPoint(x2, y1);
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, data->stroke_width);
graphics_draw_line(ctx, p0, p1);
graphics_draw_line(ctx, p1, p2);
graphics_draw_line(ctx, p2, p3);
... | (rotation) | |
/*
* 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... | debug_print_str(str) | ;
debug_print_hex(value);
debug_print_str("\n");
}
|
/*
* 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_INFO, "Received %d bytes of data from watch", data_length) | ;
if (data_length >= sizeof(s_prev_send_data_hdr)) {
memcpy(&s_prev_send_data_hdr, data, sizeof(s_prev_send_data_hdr));
data_length -= sizeof(s_prev_send_data_hdr);
data += sizeof(s_prev_send_data_hdr);
if (data_length > 0) {
s_prev_send_data_bytes = data_length;
memcpy(s_prev_send_data, d... |
#if CAPABILITY_HAS_MICROPHONE
voice_window_destroy(data->voice_window);
#endif
applib_free(data);
}
static void prv_cancel_response_timer(ActionResultData *data) {
if (evented_timer_exists(data->response.timer)) {
evented_timer_cancel(data->response.timer);
}
}
static void prv_cleanup_action_result(Actio... | if (!data->dialog.message) {
return false;
} |
strncpy(data->dialog.message, message, message_buffer_size);
data->dialog.icon = timeline_res_id;
data->dialog.success = success;
return true;
}
static bool prv_show_result_window_with_progress(ActionResultData *data,
TimelineResourceId timeline_res_id,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.