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... | (S_SUCCESS, app_cache_add_entry(app2.id, app2.size)) | ;
cl_assert_equal_i(S_SUCCESS, app_cache_add_entry(app3.id, app3.size));
// remove 2
cl_assert_equal_i(S_SUCCESS, app_cache_remove_entry(app1.id));
PebbleEvent e = fake_event_get_last();
cl_assert_equal_i(e.type, PEBBLE_APP_CACHE_EVENT);
cl_assert_equal_i(e.app_cache_event.cache_event_type, PebbleAppCacheE... |
iteration
}
void app_db_enumerate_entries(AppDBEnumerateCb cb, void *data) {
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
return;
}
AppDBEntry *db_entry = kernel_malloc_check(sizeof(AppDBEntry));
EnumerateData cb_data = {
.cb = cb,
.data = data,
.entry_buf = db_entry... | {
rv = E_DOES_NOT_EXIST;
} | else if (app_fetch_in_progress()) {
PBL_LOG(LOG_LEVEL_WARNING, "Tried to delete an app that is currently being fetched, %"PRId32,
app_id);
rv = prv_cancel_app_fetch(app_id);
}
if (rv == S_SUCCESS) {
rv = settings_file_delete(&s_app_db.settings_file, (uint8_t *)&app_id, sizeof(AppInstallId)... |
stop_mode_disable(InhibitorFlash); // FIXME: PBL-18028
s_analytics_write_bytes_count += buffer_size;
s_system_analytics_write_bytes_count += buffer_size;
prv_erase_pause();
new_timer_start(s_erase_suspend_timer, 50, prv_erase_suspend_timer_cb, NULL, 0);
while (buffer_size) {
int written = flash_impl_writ... | (s_flash_lock) | ;
xSemaphoreGive(s_erase_semphr);
// Only run the callback with no locks held so that the callback won't
// deadlock if it kicks off another sector erase.
on_complete_cb(context, status);
return 0;
}
}
// Returns non-zero expected remaining time if the erase has not finished. If the erase
// has ... |
llback_data.install_type == APP_DB_CLEARED) &&
(app_install_id_from_app_db(cur_app_id)))) {
PBL_LOG(LOG_LEVEL_DEBUG, "close and delay callbacks for app closing");
s_install_callback_data.callback_paused_for_app = true;
s_pending_app_deletion = cur_app_id;
app_manager_close_... | worker_manager_get_task_context() | |
or_count_since_last_log = 0;
static uint32_t s_subsequent_mic_errors = 0;
#define MAX_SUBSEQUENT_MIC_ERRORS (16)
bool should_log_about_mic_error(uint32_t *max_subsequent_failures) {
if (s_should_log_about_mic_error) {
*max_subsequent_failures = s_max_subsequent_error_count_since_last_log;
s_should_log_about_... | (uint32_t) | prv_llm_util_get_supp_features,
#if !SUPPORTS_PACKET_LENGTH_EXTENSION
(uint32_t) prv_llc_length_rsp_pdu_send,
#endif
#endif
(uint32_t) prv_lld_data_rx_check,
};
_Static_assert(ARRAY_LENGTH(s_orig_functions) == ARRAY_LENGTH(s_patched_functions), "");
void __wrap_patch_rom_functions(void) {
// Disable all patche... |
{
PBL_ASSERTN(node);
LauncherAppGlanceSettings *settings_glance = app_zalloc_check(sizeof(*settings_glance));
// Copy the name of the Settings app as the title
const size_t title_size = sizeof(settings_glance->title);
strncpy(settings_glance->title, node->name, title_size);
settings_glance->title[title_si... |
// Refresh the glance now that we have set the first state of the glance
prv_refresh_glance_content(settings_glance);
// Subscribe to the various events we care about
prv_subscribe_to_event(&settings_glance->battery_state_event_info,
PEBBLE_BATTERY_STATE_CHANGE_EVENT, structured_glanc... | |
/*
* 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... | {
SettingsActivityTrackerData *data = context;
const uint16_t count = prv_num_rows(data);
const bool use_icons = (count != 0);
option_menu_set_icons_enabled(&data->option_menu, use_icons /* icons_enabled */);
option_menu_set_choice(&data->option_menu, prv_get_chosen_row_index(data));
option_menu_reload_dat... |
// Settings Menu callbacks
///////////////////////////
static void prv_select_cb(OptionMenu *option_menu, int row, void *context) {
SettingsActivityTrackerData *data = context;
if (app_menu_data_source_get_count(data->data_source) == 0) {
return;
}
if (row == 0) {
// Killing current worker
proces... |
allback_events(0);
// Expect 2 message callbacks and 1 drop callback:
assert_num_message_callbacks(2);
assert_message(0, s_test_data, 1);
assert_message(1, s_test_data, 1);
// Should be able to write (BUFFER_SIZE) again,
// because the message 1 and 2 are consumed now:
cl_assert_equal_b(true, app_inbox_... | (AppInboxServiceTagUnitTest) | );
}
void test_app_inbox__app_inbox_service_unregister_by_storage_unknown_storage(void) {
uint8_t storage[BUFFER_SIZE];
cl_assert_equal_i(app_inbox_service_unregister_by_storage(storage), 0);
}
|
void test_timeline__delete_on_iterator(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1421178000), 0);
// s_items[0] is the earliest pin, followed by... | uuid_equal(&state.node->id, &multiday_item.header.id) | );
cl_assert(!state.node->all_day);
cl_assert_equal_i(state.node->timestamp, 1425312000);
cl_assert_equal_i(state.node->duration, 16 * 60);
cl_assert_equal_i(state.current_day, midnight_march_2_pst);
// day 2
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &multiday_item.heade... |
e, TimelineResourceId resource,
TimelineResourceId fallback_resource, const Uuid *app_id) {
KinoReel *icon_reel = prv_create_kino_reel_with_timeline_resource(
timeline_layout, icon_res_size, resource, fallback_resource, app_id);
if (!icon_reel) {
return;
}
GSize icon_size = ... | graphics_context_get_current_context() | , &layout->view_size);
}
void timeline_layout_deinit_view(TimelineLayout *layout) {
if (layout->layout_layer.mode == LayoutLayerModeCard && layout->impl->card_view_deinitializer) {
layout->impl->card_view_deinitializer(layout);
}
graphics_text_node_destroy(layout->view_node);
layout->view_node = NULL;
}
s... |
nt8_t*) "456", 3, false));
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(!shared_circular_buffer_write(&buffer, (uint8_t*) "789", 3, false)); // too big
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(shared_circular_buffer... | (&buffer, &client1, 3, &out_buffer, &out_length) | |
/*
* 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_LOG_LEVEL_ERROR, "Crash Demo Looping Log Spam! WarbleGarbleWarbleGarbleWarble") | ;
}
}
static void accel_data_handler(AccelData *data, uint32_t num_samples) {
}
static void trigger_to_app_event_flood(int index, void *context) {
// Generate a crazy number of events and then busy wait.
accel_data_service_subscribe(1, accel_data_handler);
accel_service_set_sampling_rate(ACCEL_SAMPLING_100H... |
, GColorGreenARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorOrangeARGB8);
cl_assert_equal_i(s_stroke_width, 1);
cl_assert_equal_i(s_path_num_points, 1);
cl_assert_equal_b(s_radius, 300);
cl_assert_equal_i(s_circle_fill_count, 1);
cl_assert_equal_i(s_circle_stroke_count, 1);
cl_assert(prv_compare_point... | cl_assert_equal_i(s_stroke_color.argb, GColorClearARGB8) | ;
cl_assert_equal_i(s_fill_color.argb, GColorClearARGB8);
cl_assert_equal_i(s_stroke_width, 0);
cl_assert_equal_i(s_path_num_points, 0);
cl_assert_equal_b(s_radius, 0);
cl_assert_equal_i(s_circle_fill_count, 0);
cl_assert_equal_i(s_circle_stroke_count, 0);
cl_assert_equal_p(s_stroke_points, NULL);
cl_as... |
index, DAYS_PER_WEEK)));
}
bool health_service_private_weekend_filter(int index, int32_t value, void *tm_weekday_ref) {
const int tm_weekday = (int)(uintptr_t)tm_weekday_ref;
return (health_service_private_non_zero_filter(index, value, NULL) &&
IS_WEEKEND(positive_modulo(tm_weekday - index, DAYS_PER_WEEK)));
}... | (metric, today_midnight, tomorrow_midnight) | ;
#endif
}
// ----------------------------------------------------------------------------------------------
HealthValue health_service_sum(HealthMetric metric, time_t time_start, time_t time_end) {
return health_service_aggregate_averaged(metric, time_start, time_end, HealthAggregationSum,
... |
under the License.
*/
#include "gdrawmask_demo.h"
#include "applib/app.h"
#include "applib/app_light.h"
#include "process_state/app_state/app_state.h"
#include "applib/fonts/fonts.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "syscall/syscall.h"
#includ... | graphics_fill_rect(ctx, &layer_bounds) | ;
graphics_context_mask_destroy(ctx, mask);
}
static void prv_refresh_timer_callback(void *context) {
GDrawMaskDemoData *data = context;
layer_mark_dirty(window_get_root_layer(&data->window));
app_timer_register(ANIMATION_TARGET_FRAME_INTERVAL_MS, prv_refresh_timer_callback, data);
}
static void prv_window_l... |
-------------------------------------------------------------------------------------
static bool prv_animation_set_custom_function(Animation *animation_h, AnimationCurve curve,
void *function) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (a... | (!animation_private_using_legacy_2(state)) | ;
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!animation) {
return false;
}
return animation->immutable;
}
// -------------------------------------------------------------------------------------------
bool animation_set_reverse(Animation *animation... |
/*
* 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... | (sizeof(PebbleEvent) <= 12,
"You made the PebbleEvent bigger! It should be no more than 12") | ;
s_system_event_queue_set = xQueueCreateSet(MAX_KERNEL_EVENTS + MAX_FROM_APP_EVENTS);
s_kernel_event_queue = xQueueCreate(MAX_KERNEL_EVENTS, sizeof(PebbleEvent));
PBL_ASSERTN(s_kernel_event_queue != NULL);
s_from_app_event_queue = xQueueCreate(MAX_FROM_APP_EVENTS , sizeof(PebbleEvent));
PBL_ASSERTN(s_fro... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_context_set_antialiased(ctx, false) | ;
graphics_draw_round_rect(ctx, &GRect(2, 2, 28, 20), 4);
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(2, 2, 28, 20), 4);
}
void clear_layer_update_callback... |
// Call the minute handler, which computes the minute stats and saves them to data logging
// as well as the sleep PFS file.
for (int i = 0; i < num_minutes; i++) {
fake_rtc_increment_time(SECONDS_PER_MINUTE);
s_alg_next_steps = minute_data[i].base.steps;
AccelRawData samples[100] = { };
uint64_t ... | cl_assert_equal_i(actual->light, ambient_light_level_to_enum(
expected->base.light * ALG_RAW_LIGHT_SENSOR_DIVIDE_BY)) | ;
cl_assert_equal_i(actual->heart_rate_bpm, expected->heart_rate_bpm);
}
// ---------------------------------------------------------------------------------------
// Test to make sure that when we re-boot we correctly get the saved minute data
void test_activity_algorithm_kraepelin__minute_data_after_boot(void) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (" 500") | |
s utf8_bounds = utf8_get_bounds(&success, "Foo b\n\n\nar \nanimalstyle");
cl_assert(success);
const TextBoxParams text_box_params = (TextBoxParams) {
.utf8_bounds = &utf8_bounds,
.box = (GRect) { GPointZero, (GSize) { 4 * HORIZ_ADVANCE_PX, 90 } }
};
line.max_width_px = text_box_params.box.size.w;
lin... | line_add_words(&line, &word_iter, NULL) | |
return s_quick_launch_select.enabled;
case BUTTON_ID_BACK:
return s_quick_launch_back.enabled;
case NUM_BUTTONS:
break;
}
return false;
}
AppInstallId quick_launch_get_app(ButtonId button) {
Uuid *uuid = NULL;
switch (button) {
case BUTTON_ID_UP:
uuid = &s_quick_launch_up.uui... | (PREF_KEY_TEXT_STYLE, &content_size_uint, sizeof(content_size_uint)) | ;
}
PreferredContentSize system_theme_get_content_size(void) {
return system_theme_convert_host_content_size_to_runtime_platform(
(PreferredContentSize)s_text_style);
}
bool shell_prefs_get_language_english(void) {
return s_language_english;
}
void shell_prefs_set_language_english(bool english) {
prv_pre... |
ibuted 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 "util/circular_buffer.h"
#include "clar.h"
#include <string.h>... | ("234567", data_out, 6) | == 0);
}
void test_circular_buffer__copy_offset(void) {
CircularBuffer buffer;
uint8_t storage[8];
circular_buffer_init(&buffer, storage, sizeof(storage));
const uint16_t data_out_size = 8;
uint8_t data_out[data_out_size];
// Assert zero bytes copied, empty buffer:
cl_assert_equal_i(circular_buffer_co... |
handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
// Create a property animation and play it to the end
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
animation_sch... | animation_set_delay(d, delay_d) | ;
// -------------------------------------------------------------------------------------
// Run A to completion
animation_schedule(a);
prv_advance_to_ms_with_timers(start_ms + 20);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
prv_advance_to_ms_with_timers(start_ms + 310)... |
w_get_root_layer(&data->status_window);
GRect bounds = window_layer->bounds;
bounds.origin.y += 40;
// Init text layer
text_layer_init(&data->status_text, &bounds);
text_layer_set_text(&data->status_text, data->status_string);
text_layer_set_text_alignment(&data->status_text, GTextAlignmentCenter);
text_l... | {
case RXMenuIdx_Channel:
title = "Channel";
itoa_int(data->channel, subtitle_buffer, 10);
subtitle = subtitle_buffer;
break;
#if CAPABILITY_HAS_BUILTIN_HRM
case RXMenuIdx_HRM:
title = "HRM";
subtitle = data->is_hrm_enabled ? "Enabled" : "Disabled";
br... |
} else {
WTF;
}
menu_cell_basic_draw(ctx, cell, title, subtitle, NULL);
}
static void prv_menu_select_click(MenuLayer *menu_layer, MenuIndex *index, void *context) {
AppData *data = context;
if (data->current_test == BTLETestType_TX) {
const uint16_t row = prv_compensated_tx_menu_row_idx(index, dat... |
pache 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 the License is di... | (data->status_string, sizeof(data->status_string),
"RUNIN\n%s", status_text[data->test_state]) | ;
text_layer_set_text(&data->status, data->status_string);
int mins_remaining = data->seconds_remaining / 60;
int secs_remaining = data->seconds_remaining % 60;
sniprintf(data->details_string, sizeof(data->details_string),
"Time:%02u:%02u\r\n%umV (%"PRIu8"%%)\r\nUSB: %s",
mins_remaining... |
_m, AlgMinuteFileRecord *file_record,
AlgMinuteDLSRecord *dls_record, bool force_send) {
// Get the circular buffer client we are working with
SharedCircularBufferClient *cbuf_client = file_record ? &s_alg_state->file_minute_data_client
... | PBL_LOG(LOG_LEVEL_INFO, "Logging %"PRIu8" MLD Records, First UTC: %"PRIu32,
dls_record->hdr.num_samples, dls_record->hdr.time_utc) | ;
if (result != DATA_LOGGING_SUCCESS) {
PBL_LOG(LOG_LEVEL_WARNING, "Error %"PRIi32" while logging activity data", (int32_t) result);
return;
}
}
}
}
// -------------------------------------------------------------------------------------------
// Handle storage and logging of the min... |
anager.h"
#include "process_management/app_manager.h"
#include "process_management/worker_manager.h"
#include "resource/resource_ids.auto.h"
#include "services/common/i18n/i18n.h"
#include <stdio.h>
typedef struct {
ActionableDialog *actionable_dialog;
ActionBarLayer action_bar;
GBitmap check_icon;
GBitmap x_... | action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, x_icon) | ;
action_bar_layer_set_click_config_provider(action_bar, prv_worker_crash_click_config_provider);
action_bar_layer_set_context(action_bar, data);
// crash_reason buffer is allocated on the heap and freed below
char *crash_reason = prv_create_worker_crash_reason_string(app_install_id);
// Create and configur... |
/*
* 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... | (response) | );
accessory_send_data((const uint8_t*) "\r\n", sizeof(char) * 2);
}
static void prv_display_prompt(void) {
accessory_send_data((const uint8_t*) ">", sizeof(char));
}
static PromptContext s_prompt_context = {
.response_callback = prv_command_response_callback,
.command_complete_callback = prv_display_prompt,
... |
ss;
#endif
bg_color = layout_get_colors(swap_layer->current)->bg_color;
}
prv_update_colors(swap_layer, bg_color, color_status_bar);
}
/////////////////////////
// ARROW LAYER FUNCTIONS
/////////////////////////
//! Hides or shows the arrow (or two arrows, on S4) depending on where the layouts sit within the... | (result, duration) | ;
#if PBL_ROUND
if (curve) {
switch (curve->swap_curve_kind) {
case ScrollAnimationCurveKind_Curve:
animation_set_curve(result, curve->curve);
break;
case ScrollAnimationCurveKind_Interpolator:
animation_set_custom_interpolation(result, curve->interpolator);
break;
... |
/*
* 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, 0x1000000) | ;
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
content_ind... |
erRequested);
cl_assert_equal_i(windows[3][0]->on_screen, true);
cl_assert_equal_i(windows[3][0]->is_click_configured, true);
cl_assert_equal_i(windows[2][1]->on_screen, false);
cl_assert_equal_i(windows[2][1]->is_click_configured, false);
cl_assert_equal_p(s_last_click_configured_window, windows[3][0]);
/... | cl_assert_equal_i(modal_manager_get_properties(),
ModalProperty_Exists | ModalProperty_CompositorTransitions |
ModalProperty_RenderRequested | ModalProperty_Unfocused) | |
// well). However, the greater the the threshold, the more orientations one
// must put their watch through in order to get solution sets
//
// For now, select a distance metric that should work out of the box for a
// majority of the middle of the world. However, if no solution sets are found
// after 45s, fall back ... | {
x_delta = ABS(saved_solution[0] - solution[0]);
y_delta = ABS(saved_solution[1] - solution[1]);
z_delta = ABS(saved_solution[2] - solution[2]);
if ((x_delta < max_delta_thresh) && (y_delta < max_delta_thresh) &&
(z_delta < max_delta_thresh)) {
saved_sample_match++;
if (saved_sample... | |
rapProfileGetInfoFunc s_profile_info_functions[] = {
#define REGISTER_SMARTSTRAP_PROFILE(f) f,
#include "services/normal/accessory/smartstrap_profile_registry.def"
#undef REGISTER_SMARTSTRAP_PROFILE
};
// every profile except for SmartstrapProfileInvalid should be registered
_Static_assert(NUM_PROFILES() == (NumSmartst... | (LOG_LEVEL_WARNING, "Dropped notification due to not being connected.") | ;
return;
}
// dispatch the notification based on the profile
const SmartstrapProfileInfo *info = prv_get_info_by_profile(profile);
if (info && info->notify) {
smartstrap_state_lock();
info->notify();
smartstrap_state_unlock();
} else {
PBL_LOG(LOG_LEVEL_WARNING, "Dropped notification for... |
e at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific languag... | if (app_notif_prefs) {
new_action_group = &app_notif_prefs->action_group;
} |
ios_notif_pref_db_store_prefs(app_id->value, app_id->length,
&new_attr_list, new_action_group);
// Update our copy of the prefs with the new data
const size_t buf_size = attributes_actions_get_buffer_size(&new_attr_list, new_action_group);
*notif_prefs = kernel_zallo... |
ge, see JIRA
const Fixed_S16_3 x1_fixed = (Fixed_S16_3) { .integer = x1 };
Fixed_S16_3 x2_fixed = (Fixed_S16_3) { .integer = x2 };
const uint8_t gradient_width = (uint8_t)((x2 - x1) / 2);
x2_fixed.integer -= gradient_width;
const int16_t clip_box_min_x = ctx->draw_state.clip_box.origin.x;
const int16_t cli... | prv_verify_mask_pixel_values(ctx, transparent_mask, 0) | ;
graphics_context_mask_destroy(ctx, transparent_mask);
GDrawMask *opaque_mask = graphics_context_mask_create(ctx, false /* transparent */);
cl_assert(opaque_mask);
// Verify all mask pixels are initialized to be opaque (3)
prv_verify_mask_pixel_values(ctx, opaque_mask, 3);
graphics_context_mask_destroy(ct... |
ITTED_MSG_HANDLER ((AppInboxMessageHandler)~0)
#define NOT_PERMITTED_DROP_HANDLER ((AppInboxDroppedHandler)~0)
#define TEST_TARGET_TASK (PebbleTask_App)
typedef struct {
ListNode node;
PebbleEvent event;
} EventNode;
static EventNode *s_event_head;
static bool s_can_send_event;
bool process_manager_send_event_to... | fake_kernel_malloc_deinit() | ;
prv_cleanup_callback_events();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// app_inbox_create_and_register
void test_app_inbox__app_inbox_create_and_register_zero_buffer_size(void) {
void *result = app_inbox_create_and_register(0, 1, test_message_handl... |
assert.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_regular_timer.h"
extern bool prv_contains_service_changed_characteristic(
GAPLEConnection *connection,
const GATT_Service_Discovery_Indication_Data_t *event);
void core_dump_reset(bool is_forced) {
}
static GAPLEConnection s_conn... | {
fake_gatt_put_discovery_indication_gatt_profile_service(TEST_GATT_CONNECTION_ID,
true /* has_service_changed_characteristic */);
cl_assert_equal_i(s_last_handle_discovery_result, Handled);
// Verify the CCCD of the Service Changed characteristic has been wri... | |
otification_uid;
const uint32_t mms_no_caption_dict_uid = ((GetNotificationAttributesMsg*)s_mms_no_caption_dict)->notification_uid;
const uint32_t mms_with_caption_dict_uid = ((GetNotificationAttributesMsg*)s_mms_with_caption_dict)->notification_uid;
const CPDSMessage *cmd_header = (const CPDSMessage *)buffer;
... | ARRAY_LENGTH(s_unknown_app_unique_title_dict) | , (uint8_t *)s_unknown_app_unique_title_dict);
s_num_ds_notifications_received++;
} else if (uid == mms_no_caption_dict_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_mms_no_caption_dict), (uint8_t *)s_mms_no_caption_dict);
s_num_ds_notifications_received++;
} else if (uid == mms_with_caption_... |
s(&s_started_handler_calls, a), 1);
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, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entrie... | (&s_started_handler_calls, b) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
// Complete A and start B
prv_advance_to_ms_with_timers(start_ms + delay_spawn + duration_a + delay_a
+ 2 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_hand... |
Heap *task_heap_get_for_current_task(void) {
if (pebble_task_get_current() == PebbleTask_App) {
return app_state_get_heap();
} else if (pebble_task_get_current() == PebbleTask_Worker) {
return worker_state_get_heap();
}
return kernel_heap_get();
}
static char* prv_strdup(Heap *heap, const char* s, ui... | app_state_get_heap() | ;
void *mem = heap_zalloc(heap, bytes, saved_lr);
if (!mem && bytes != 0) {
PBL_CROAK_OOM(bytes, saved_lr, heap);
}
return mem;
}
void *app_calloc(size_t count, size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return (heap_calloc(app_state_get_heap(), count, size, saved_lr... |
ither express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "workout.h"
#include "workout_active.h"
#include "workout_controller.h"
#include "workout_data.h"
#include "workout_dialog.h"
#include "workout_summary.h"
#include "workout_ut... | (dialog, PBL_IF_COLOR_ELSE(GColorYellow, GColorWhite)) | ;
dialog_set_text_color(dialog, GColorBlack);
dialog_set_icon(dialog, RESOURCE_ID_WORKOUT_APP_DETECTED);
dialog_set_icon_animate_direction(dialog, DialogIconAnimateNone);
dialog_set_destroy_on_pop(dialog, false);
const char *dialog_text =
workout_utils_get_detection_text_for_activity(data->ongoing_sess... |
/*
* 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... | (list_count_to_head_from(&b) == 2) | ;
cl_assert(list_count_to_head_from(&a) == 1);
}
typedef struct IntNode {
ListNode list_node;
int value;
} IntNode;
int sorting_comparator(IntNode* a, IntNode* b) {
return b->value - a->value;
}
void test_list__sort_ascending(void) {
IntNode bar1 = { .value = 1 };
IntNode bar2 = { .value = 2 };
IntNode... |
info->get_val(file, (uint8_t *)&value, sizeof(uint32_t));
cl_assert(value == desired_value);
return true;
}
static void prv_test_settings_file_compaction(const bool manual) {
// If manual is enabled, then the test will force a compaction every so often
// If manual is disabled, then the test will only compa... | (settings_file_set(&file, key, key_len, val, val_len), E_OUT_OF_STORAGE) | ;
int val_len_out = settings_file_get_len(&file, key, key_len);
cl_must_pass(val_len_out);
uint8_t *val_out = malloc(val_len_out);
cl_assert_equal_i(settings_file_get(&file, key, key_len, val_out, val_len_out), E_DOES_NOT_EXIST);
free(val_out);
printf("Making sure we can delete when at max storage...\n");
... |
COMPOSITE_TEST_OFFSET_Y));
prv_composite_test_draw_bitmap(&s_ctx, bitmap, offset_point, compositing_mode);
// Check the result
char unit_test_result_image_file_base_name[PATH_STRING_LENGTH] = {0};
snprintf(unit_test_result_image_file_base_name, PATH_STRING_LENGTH,
... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | |
/*
* 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(out_length, 2) | ;
cl_assert(memcmp(out_buffer, (uint8_t*) "9a", 2) == 0);
cl_assert(circular_buffer_consume(&buffer, 2));
// Consume one without reading it
cl_assert(circular_buffer_consume(&buffer, 1));
// Read the last little bit
cl_assert(circular_buffer_read(&buffer, 1, &out_buffer, &out_length));
cl_assert_equal_i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | layer_set_update_proc(&layer, &inside_layer_update_callback) | ;
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_pixel_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outs... |
(s_read_2_called == 1) | ;
ASSERT(s_size_2_called == 1);
// 3rd res
uint32_t id_3 = emx_resources_register_custom(custom_res_read_3, custom_res_size_3);
ASSERT(emx_resources_get_size(1, id_3) == 4);
buf = 0;
ASSERT(emx_resources_read(1, id_3, 0, (uint8_t *)&buf, 1) == 4);
ASSERT(buf == 3);
ASSERT(s_read_3_called == 1);
ASSER... | |
MenuLevel *cur_level = vm->cur_level;
GRect frame = grect_inset(data->action_menu.window.layer.frame, vm->menu_insets);
layer_set_frame(&data->action_menu_layer.layer, &frame);
if (cur_level->display_mode == ActionMenuLevelDisplayModeThin) {
action_menu_layer_set_items(&data->action_menu_layer, NULL, 0, 0, 0)... | animation_is_scheduled(data->level_change_anim) | ) {
// We are already animating.
return;
}
Animation *content_out = prv_create_content_out_animation(data, level);
Animation *content_in = prv_create_content_in_animation(data, level);
data->level_change_anim = animation_sequence_create(content_out, content_in, NULL);
animation_schedule(data->level_... |
imation_c, args);
va_end(args);
return animation;
}
Animation *WEAK animation_spawn_create_from_array(Animation **animation_array,
uint32_t array_len) {
return prv_create_from_array(animation_array, array_len);
}
typedef void (*AnimationEachCallback)(AnimationPr... | {
if (animation->handlers.stopped) {
animation->handlers.stopped((Animation *)animation, finished, animation->context);
}
if (animation->implementation && animation->implementation->teardown) {
animation->implementation->teardown((Animation *)animation);
}
} | |
int delay_a = 100;
const int duration_b = 500;
const int delay_b = 200;
const int delay_spawn = 150;
int duration_total = MAX(duration_a + delay_a, duration_b + delay_b) + delay_spawn;
// Create 2 test animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
anima... | (a, duration_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... | s_do_before_write() | ;
s_do_before_write = NULL;
}
memcpy(s_storage_data.buffer + offset, buffer, length);
}
static uint32_t fake_pb_storage_mem_calculate_crc(PutBytesStorage *storage, PutBytesCrcType crc_type) {
PBL_ASSERTN(storage->impl_data == &s_storage_data);
return s_storage_data.crc;
}
static void prv_cleanup(void) {
... |
_layer_set_layouts_hidden(TimelineLayer *layer, bool hidden) {
for (int i = 0; i < TIMELINE_NUM_ITEMS_IN_TIMELINE_LAYER; i++) {
TimelineLayout *layout = layer->layouts[i];
if (layout) {
prv_set_layout_hidden(layout, hidden);
}
}
layer_set_hidden((Layer *)&layer->end_of_timeline, hidden);
}
voi... | (&layer->end_of_timeline) | |
/*
* 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_get_user_data(layer_get_window(layer)) | ;
prv_render_activity_type(ctx, layer, summary_window->icon, summary_window->name);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Handlers
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutSummaryWindow *summary_wi... |
s_graphics_draw_text.last_call.draw_text.box);
EXECUTE_SCRIPT(
"ctx.textAlign = 'right';\n"
"ctx.fillText('some text', 100, 100);\n"
);
cl_assert_equal_i(3, s_graphics_draw_text.call_count);
cl_assert_equal_rect((GRect(-9900, 100, large_int, large_int)),
s_graphics_d... | prv_font_definition_from_value(name_js, &cmp_def) | ;
cl_assert_equal_b(true, actual);
cl_assert_equal_s(cmp_def->res_key, def->res_key);
jerry_release_value(name_js);
def++;
}
}
void test_rocky_api_graphics__measure_text(void) {
prv_global_init_and_set_ctx();
// fill text_state with unique values we can test against
s_rocky_text_state = (Rocky... |
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
setup_test_aa_sw(&ctx, fb, RECT_NULL_W, RECT_NULL_W, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
GTextOverflowModeTrailingEllipsis, GText... | (10, 100, 100, 30) | ,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_color_set.8bit.pbi"));
}
void test_graphics_draw_text_8bit__data_row_offsets(void) {
GContext ctx;
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (firmware_description->description_length != sizeof(FirmwareDescription)) {
// Corrupted description
return false;
} |
// Log around this operation, as it can take some time (hundreds of ms)
PBL_LOG(LOG_LEVEL_DEBUG, "CRCing recovery...");
start_address += sizeof(FirmwareDescription);
#if CAPABILITY_HAS_DEFECTIVE_FW_CRC
const uint32_t calculated_crc = flash_calculate_legacy_defective_checksum(
start_address, firmware_de... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (print_backward) {
byte_stream += (byte_stream_len - 1); // addr of the last element
} | |
animation_create() | ;
}
Animation *WEAK animation_spawn_create_from_array(Animation **animation_array,
uint32_t array_len) {
return animation_create();
}
bool WEAK animation_set_auto_destroy(Animation *animation, bool auto_destroy) {
return false;
}
PropertyAnimation *WEAK property_... | |
eepRestfulSeconds,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){0, 0, 0, 0, 0, 0, 0}));
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricActiveKCalories,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){0, 0, 0, 0, 0, 0, 0}));
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricRest... | (ActivityMetricSleepRestfulSeconds,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){1 * SECONDS_PER_MINUTE, 0, 0, 0, 0, 0, 0})) | ;
// The actual resting calories must be in the range from min_resting_kcalories to
// exp_resting_kcalories_now because we don't know at exactly which time settings were saved to
// storage
int32_t actual_resting_kcalories[ACTIVITY_HISTORY_DAYS];
activity_get_metric(ActivityMetricRestingKCalories, ACTIVITY_... |
ve_state->acquired);
const uint8_t *cptr = out;
while (len--) {
prv_spi_send_data(slave->spi_bus, *(cptr++));
prv_spi_transmit_flush_blocking(slave->spi_bus);
}
}
void spi_ll_slave_burst_read_write(const SPISlavePort *slave,
const void *out,
... | {
return;
} | |
/*
* 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... | event_put(&e) | ;
}
static RegularTimerInfo s_tick_timer_info = {
.cb = &timer_tick_event_publisher
};
void tick_timer_add_subscriber(PebbleTask task) {
++s_num_subscribers;
if (s_num_subscribers == 1) {
PBL_LOG(LOG_LEVEL_DEBUG, "starting tick timer");
regular_timer_add_seconds_callback(&s_tick_timer_info);
}
}
void... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (!BOARD_CONFIG_BUTTON.button_com.gpio) {
// This board doesn't use a button common pin.
return;
} |
// Configure BUTTON_COM to drive low. When the button
// is pressed this pin will be connected to the pin for the
// button.
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = BOARD_CONFIG_BUTTON.button_com.gpio_pin;
GPIO_InitStructure.GPIO_Mode = G... |
////////////////////////////////////////////////////////////////
#include "fake_spi_flash.h"
#include "fake_system_task.h"
#include "fake_kernel_services_notifications.h"
// Stubs
////////////////////////////////////////////////////////////////
#include "stubs_analytics.h"
#include "stubs_hexdump.h"
#include "stubs_la... | contacts_db_get_len((uint8_t *)&contact, UUID_SIZE) | |
stack[1]);
cl_assert_equal_p(aaa, stack[2]);
// go to child if possible
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaaa, actual);
cl_assert_equal_i(3, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1... | layer_find_layer_containing_point(&parent, &GPoint(9, 9)) | , &child_a);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(10, 10)), &parent);
layer_add_child(&child_a, &child_f);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(9, 9)), &child_f);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(1, 1)), &child_... |
f recognizer, void *context) {
WorkoutActiveWindow *active_window = context;
if (active_window->workout_controller) {
active_window->workout_controller->stop();
}
workout_push_summary_window();
workout_dialog_pop(&active_window->end_workout_dialog);
app_window_stack_remove(&active_window->window, fal... | (BUTTON_ID_UP, prv_up_click_handler) | |
tion_s % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE) ?: INT_MIN;
if (*minutes == INT_MIN && *hours == INT_MIN) {
*hours = 0;
}
}
int health_util_format_hours_and_minutes(char *buffer, size_t buffer_size, int duration_s,
void *i18n_owner) {
int hours;
int minutes;
prv_... | health_util_create_text_node(hours_and_minutes_buffer_size,
number_font, color, container) | |
CD_ASSERTN(s_flash_addr + chunk_hdr.size - flash_base < CORE_DUMP_MAX_SIZE);
s_flash_addr += prv_flash_write_bytes(&chunk_hdr, s_flash_addr,
sizeof(chunk_hdr));
s_flash_addr += prv_flash_write_bytes(&s_saved_registers.extra_reg,
s_fla... | if (flash_addr_base == CORE_DUMP_FLASH_INVALID_ADDR) {
status = false;
goto cleanup;
} | |
/*
* 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 LLC_INMSG_LINK_ESTABLISHMENT_REQUEST:
pulse_llc_send_link_opened_msg();
return;
case LLC_INMSG_LINK_CLOSE_REQUEST:
pulse_end();
return;
case LLC_INMSG_ECHO_REQUEST:
*(uint8_t*)packet = LLC_OUTMSG_ECHO_REPLY;
uint8_t *message = pulse_best_effort_send_begin(PULSE_PR... |
}
void pulse_llc_link_state_handler(PulseLinkState link_state) {
}
void pulse_llc_send_link_opened_msg(void) {
typedef struct PACKED Response {
uint8_t type;
uint8_t pulse_version;
uint16_t mtu;
uint16_t mru;
uint8_t timeout;
} Response;
Response *response = pulse_best_effort_send_begin(PU... |
/*
* 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_timer_register(dialog->timeout, prv_app_timer_callback, dialog) | ;
}
// Calls the user-given load callback, if it exists. If the user gave a non-null context,
// the function will use that, otherwise it will default to use the default context of the
// containing dialog.
if (dialog->callbacks.load) {
if (dialog->callback_context) {
dialog->callbacks.load(dialog... |
reate(&test_uuid);
int64_t time_interval = 0x10111213;
analytics_heartbeat_set(heartbeat, ANALYTICS_APP_METRIC_TIME_INTERVAL, time_interval);
int64_t sdk_major_version = 0x14;
analytics_heartbeat_set(heartbeat, ANALYTICS_APP_METRIC_SDK_MAJOR_VERSION, sdk_major_version);
// Verify that things were set as expe... | analytics_metric_num_elements(metric) | ; j++) {
verify_metric(heartbeat, metric, i, j);
i++;
}
} else {
verify_metric(heartbeat, metric, i, -1);
i++;
}
}
kernel_free(heartbeat);
}
|
EXECUTE_SCRIPT("var pileOfPooUTF8 = '\xF0\x9F\x92\xA9';") | ;
// String.length is expected to count the surrogate code points that make up a non-BMP codepoint:
EXECUTE_SCRIPT_AND_ASSERT_RV_EQUALS_S("pileOfPooUTF8.length.toString()", "2");
}
void test_rocky_text_encoding__jerry_cesu8_to_utf8_conversion(void) {
struct {
const char *const script;
size_t expected_utf... | |
272},
{ 1440, 808, -40},
{ 1640, 584, -104},
{ 1968, 632, -64},
{ 2232, 720, -232},
{ 2160, 472, -56},
{ 1792, 16, -208},
{ 1440, -152, -280},
{ 1016, -216, -240},
{ 920, -120, -272},
{ 776, -64, -312},
{ 744, -64, -264},
{ 632, -168, -232},
{ 432, -200, -288},
{... | { 736, 680, -352},
{ 552, 456, -488},
{ 336, 208, -648},
{ 80, 56, -768},
{ -16, 40, -912},
{ -304, -128, -976},
{ -168, -88, -1072},
{ -104, -232, -1016},
{ -216, -264, -936},
{ -256, -256, -896},
{ -328, -272, -840},
{ -328, -320, -792},
{ -320, -344, -728},
{ -... |
// ----------------------------------------------------------------
// Sample captured: 2015-10-01 09:37:05 local
AccelRawData *activity_sample_walk_100_pbl_25471_9(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25471_9
//> TEST_EXPECTED 100
//> T... |
);
}
// Not in a header because it's really only used from within the gatt_service_changed module
extern void gatt_client_discovery_discover_range(
GAPLEConnection *connection, ATTHandleRange *hdl_range);
void command_bt_disc_start(char *start_handle, char *end_handle) {
bt_lock();
{
ATTHandleRange range = ... | atoi(level) | ;
if (log_level < 0) {
log_level = 0;
} else if (log_level > 255) {
log_level = 255;
}
hc_endpoint_logging_set_level(log_level);
prompt_send_response_fmt(buffer, 32, "Ble Log level set to: %i", log_level);
}
extern bool hc_endpoint_logging_get_level(uint8_t *level);
void command_ble_logging_get_level... |
eof(Attribute));
write_ptr += sizeof(Attribute);
}
for (int i = 0; i < in->num_attributes; i++) {
bool r = prv_deep_copy_attribute(&out->attributes[i], &in->attributes[i],
&write_ptr, buffer_end);
if (!r) {
return false;
}
}
return true;
}
size_t att... | PBL_ASSERTN(buffer != NULL) | ;
attribute->cstring = buffer;
attribute->id = attribute_id;
}
Attribute *attribute_find(const AttributeList *attr_list, AttributeId id) {
if (!attr_list) {
return NULL;
}
if (id == AttributeIdUnused) {
return NULL;
}
for (int i = 0; i < attr_list->num_attributes; i++) {
if (attr_list->attr... |
ext {
ListNode node;
PebbleBLEGATTClientEventType subtype;
GAPLEClient client;
uintptr_t obj_ref;
} GattClientEventContext;
static ReadResponseData *s_read_responses[GAPLEClientNum];
//! Keeps track of the current outstanding GattClientOperations (reads/writes). Useful for freeing
//! the outstanding op's mem... | PBL_ASSERTN(data->subtype == PebbleBLEGATTClientEventTypeCharacteristicRead ||
data->subtype == PebbleBLEGATTClientEventTypeDescriptorRead) | ;
gatt_err_code = prv_handle_response(resp, data, &gatt_value_length);
break;
}
case GattClientOpResponseWrite: {
PBL_ASSERTN(data->subtype == PebbleBLEGATTClientEventTypeCharacteristicWrite ||
data->subtype == PebbleBLEGATTClientEventTypeDescriptorW... |
--------------------------------------
// Test a sequence animation with a play count of 0
void test_animation__sequence_with_0_play_count(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_seq = 0;
// Create 2 animations
Animation *a = prv_create... | prv_count_handler_entries(&s_started_handler_calls, b) | , 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, inner_seq), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handle... |
-864, -88, 144},
{ -872, 0, 144},
{ -728, 16, 200},
{ -720, 208, 488},
{ -840, 520, 1680},
{ -672, 480, 1528},
{ -576, 264, 952},
{ -568, 264, 256},
{ -824, 544, -40},
{ -872, 624, 168},
{ -736, 160, 544},
{ -832, -472, 448},
{ -840, -720, 272},
{ -832, -504, 88},
... | { -784, -392, -64},
{ -936, 80, -120},
{ -824, -104, 16},
{ -840, -64, 352},
{ -936, 184, 1056},
{ -688, 392, 616},
// 18 seconds
{ -880, 336, 936},
{ -992, 688, 440},
{ -888, -160, 496},
{ -936, -8, 184},
{ -912, 152, -88},
{ -952, 432, -120},
{ -832, 136, -32},
... |
{ -928, 1408, 288},
{ -1056, 1008, 208},
{ -624, 648, 336},
{ -912, 392, 320},
{ -896, 184, 200},
{ -936, 40, 144},
{ -856, -48, 56},
{ -888, 88, -8},
{ -920, 88, -64},
{ -936, 16, -104},
{ -888, -40, -248},
{ -928, -192, -256},
{ -944, -272, -176},
{ -904, -304,... |
-176, 488, 472},
{ -136, 352, 408},
{ -128, 296, 336},
{ -144, 288, 344},
{ -344, 536, 544},
{ -440, 712, 648},
{ -256, 1008, 464},
{ -104, 1016, 568},
{ 88, 1368, 848},
{ 216, 1600, 568},
{ 48, 1664, 192},
{ 88, 1296, 128},
{ 40, 856, 400},
{ 0, 672, 360},
{ -48,... | { -280, 208, 152},
{ -456, 176, 160},
{ -888, 272, 136},
// 112 seconds
{ -1776, 320, 336},
{ -2728, 72, -16},
{ -2464, 256, -504},
{ -1672, 616, -112},
{ -792, -328, -472},
{ -1576, 288, 72},
{ -1136, 280, 48},
{ -728, 352, -24},
{ -592, 280, -56},
{ -688, 248, 8... | |
/*
* 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... | pfs_close(fd) | ;
}
}
|
to
// become the top banner in the notifications window
#if PBL_ROUND
// Use a radius equal to that of the notification banner to make the transition seamless
const int32_t peek_circle_diameter = BANNER_CIRCLE_RADIUS * 2;
GRect peek_circle_frame = (GRect) {
.size = GSize(peek_circle_diameter, pee... | (&peek_layer->number.text_layer,
&text_rect,
NULL, fonts_get_system_font(FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM),
GColorBlack, GColorClear, text_alignment,
GTextOverflowModeTrailingEllips... | |
/*
* 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_prepare_fb_steps_xy(size, NUM_STEPS, NUM_STEPS);
} | |
/*
* 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 (periph_addr < AHB1PERIPH_BASE) {
return RCC_APB2PeriphClockCmd;
} else if (periph_addr < AHB2PERIPH_BASE) {
return RCC_AHB1PeriphClockCmd;
} else if (periph_addr < AHB3_BASE) {
return RCC_AHB2PeriphClockCmd;
} else {
return RCC_AHB3PeriphClockCmd;
} |
}
void periph_config_init(void) {
s_periph_config_mutex = mutex_create();
}
void periph_config_acquire_lock(void) {
mutex_lock(s_periph_config_mutex);
}
void periph_config_release_lock(void) {
mutex_unlock(s_periph_config_mutex);
}
void periph_config_enable(void *periph, uint32_t rcc_bit) {
ClockCmd clock_... |
EATURE_RLE4)) {
// Load the glyph data at the end of the buffer
target = &((uint8_t *)g->data)[CACHE_GLYPH_SIZE - glyph_size_bytes];
} else {
target = (uint8_t *)g->data;
}
SYS_PROFILER_NODE_START(text_render_flash);
size_t num_bytes_loaded = sys_resource_load_range(font_res->app_num, ... | (font_res->app_num, font_res->resource_id,
data->resource_offset, (uint8_t *)&header,
sizeof(header)) | |
*selection_layer = (SelectionLayer*) animation_get_context(animation);
selection_layer->slide_amin_progress = 0;
selection_layer->selected_cell_idx++;
}
static void prv_slide_settle_impl(struct Animation *animation,
const AnimationProgress distance_normalized) {
SelectionLayer ... | if (selection_layer->is_active) {
animation_unschedule(selection_layer->next_cell_animation);
if (selection_layer->selected_cell_idx == selection_layer->num_cells - 1) {
selection_layer->selected_cell_idx = 0;
selection_layer->callbacks.complete(selection_layer->callback_context);
} else {
... |
}
static void prv_click_config_provider(SelectionLayer *selection_layer) {
// Config UP / DOWN button behavior:
window_set_click_context(BUTTON_ID_UP, selection_layer);
window_set_click_context(BUTTON_ID_DOWN, selection_layer);
window_set_click_context(BUTTON_ID_SELECT, selection_layer);
window_single_repe... |
al, sizeof(val), "v%03d", i);
printf("Iteration %d key %s val %s\n", i, key, val);
set_and_verify(&file, key, key_len, val, val_len);
// delete the first 50
if (i < 50) {
settings_file_delete(&file, key, key_len);
}
}
prv_print_stats(&file);
settings_file_compact(&file);
const Settings... | snprintf((char *)key, sizeof(key), "k%03d", 128) | ;
for (int i = 0; i < 128; i++) {
snprintf((char *)val, sizeof(val), "v%03d", i);
printf("Iteration %d val %s\n", i, val);
set_and_verify(&file, key, key_len, val, val_len);
}
// Finally, try to set a key to a large value. This should succeed with
// plenty of room to spare if our space tracking is... |
int term = 0; term < ARRAY_LENGTH(advert_terms); ++term) {
for (int second_tick = 0; second_tick < 4; ++second_tick) {
cl_assert_equal_i(s_unscheduled_cb_count, 0);
assert_ad_data("ad data");
gap_le_assert_advertising_interval(advert_terms[term].min_interval_slots,
... | (s_unscheduled_cb_count, 0) | ;
// This is the last round for "C":
regular_timer_fire_seconds(1);
assert_ad_data("A");
regular_timer_fire_seconds(1);
assert_ad_data("B");
regular_timer_fire_seconds(1);
assert_ad_data("C");
regular_timer_fire_seconds(1);
assert_ad_data("D");
// One job ("C") should been have been unscheduled:
... |
if (PRIVILEGE_WAS_ELEVATED) {
if (info_out) {
syscall_assert_userspace_buffer(info_out, sizeof(*info_out));
}
}
return prv_get_consumer_info(tag, info_out);
}
static void prv_consume(AppInboxConsumerInfo *consumer_info);
DEFINE_SYSCALL(void, sys_app_inbox_service_consume, AppInboxConsumerInfo *consu... | {
if (!info_out) {
return false;
}
bool success = false;
prv_lock();
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(tag);
if (!inbox) {
goto unlock;
}
*info_out = (const AppInboxConsumerInfo) {
.tag = tag,
.message_handler = inbox->message_handler,
... |
//! @note Executes on app task, therefore we need to go through syscalls to access AppInbox!
static void prv_callback_event_handler(void *ctx) {
AppInboxServiceTag tag = (AppInboxServiceTag)(uintptr_t)ctx;
AppInboxConsumerInfo info = {};
size_t num_message_consumed = 0;
if (!sys_app_inbox_service_get_consumer... |
he active recognizers on non-touched layers in the tree are cancelled
s_active_layer = &layer_b;
e.type = TouchEvent_Touchdown;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0, 2}, 3, &s_recognizers_handled);
prv_compare_recognizers_processed((int[]) {4, 0,... | (manager.triggered, NULL) | ;
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible);
// A touchdown occurs where no layers are touched
s_active_layer = NULL;
e.type = TouchEvent_Touchdow... |
ake_time_timeshift_js.h"
#else
#include "fake_time.h"
#endif
// Stubs
#include "stubs_app_manager.h"
#include "stubs_app_state.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_serial.h"
#include "stubs_sys_exit.h"
#define FUNC_NAME "f"
#define ERROR_STRING "Oops!"
T_STATIC void prv_log_uncau... | {
s_log_internal__expected = (const char *[]){
"Unhandled exception",
" 1",
NULL
};
const char *script = "var "FUNC_NAME" = function() { throw 1; };";
prv_do_call_user_function(script);
cl_assert(*s_log_internal__expected == NULL);
} |
void test_rocky_api_util__call_throw_error(void) {
s_log_internal__expected = (const char *[]){
"Unhandled Error",
" "ERROR_STRING,
NULL
};
const char *script = "var "FUNC_NAME" = function() { throw new Error('"ERROR_STRING"'); };";
prv_do_call_user_function(script);
cl_assert(*s_log_internal__... |
CESSORY.power_en, GPIO_OType_PP, GPIO_Speed_2MHz);
gpio_output_set(&BOARD_CONFIG_ACCESSORY.power_en, false); // Turn power off
accessory_set_baudrate(DEFAULT_BAUD);
periph_config_release_lock();
prv_initialize_exti();
}
static void prv_set_baudrate(uint32_t baudrate, bool force_update) {
if ((baudrate !=... | prv_lock() | ;
if (s_stream_cb) {
// wait for any in-progress write to finish
PBL_ASSERTN(xSemaphoreTake(s_send_semaphore, portMAX_DELAY) == pdPASS);
xSemaphoreGive(s_send_semaphore);
}
uart_set_tx_interrupt_enabled(ACCESSORY_UART, false);
s_stream_cb = NULL;
s_stream_context = NULL;
prv_unlock();
}
void ac... |
280, -96},
{ 856, 320, -192},
{ 1104, 408, -216},
// 99 seconds
{ 1128, 400, -280},
{ 1144, 400, -208},
{ 1288, 488, -184},
{ 1072, 496, -152},
{ 1120, 416, -120},
{ 1192, 376, -80},
{ 1200, 336, -24},
{ 984, 272, 16},
{ 792, 224, -8},
{ 704, 176, 16},
{ 712, 176,... | { 1096, 208, -224},
{ 752, 232, -232},
{ 560, 216, -232},
{ 520, 200, -272},
{ 592, 168, -168},
{ 720, 224, -200},
{ 904, 288, -208},
{ 1104, 352, -280},
{ 1032, 360, -288},
{ 1064, 312, -200},
{ 1280, 384, -216},
{ 1120, 368, -176},
// 105 seconds
{ 1136, 344, -1... |
{ 1088, 464, -224},
{ 1408, 472, -208},
{ 1352, 472, -184},
{ 1208, 360, -112},
{ 1256, 272, -120},
{ 1184, 272, -56},
{ 1008, 280, -80},
{ 808, 240, -32},
{ 616, 184, -40},
{ 560, 152, -8},
{ 616, 152, -8},
{ 720, 152, -8},
{ 896, 144, -24},
{ 1048, 128, -32},
... |
* 1000 + ms;
}
mutex_unlock(s_vibe_history_mutex);
}
typedef struct {
ListNode list_node;
uint32_t duration_ms;
int32_t strength;
} VibePatternStep;
static const uint32_t MAX_VIBE_DURATION_MS = 10000;
static int s_pattern_timer = TIMER_INVALID_ID;
static bool s_pattern_in_progress = false;
// s_vibe_stren... | if (s_vibe_queue_head == NULL) {
s_vibe_queue_head = step;
} else {
list_append((ListNode*)s_vibe_queue_head, (ListNode*)step);
} |
mutex_unlock(s_vibe_pattern_mutex);
return true;
}
DEFINE_SYSCALL(bool, sys_vibe_pattern_enqueue_step_raw, uint32_t duration_ms, int32_t strength) {
return prv_vibe_pattern_enqueue_step_raw(duration_ms, strength);
}
DEFINE_SYSCALL(bool, sys_vibe_pattern_enqueue_step, uint32_t duration_ms, bool on) {
return... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_HEXDUMP(LOG_LEVEL_DEBUG, buffer, s.bytes_written) | ;
app_state_set_user_data(buffer);
}
static void prv_deinit(void) {
SimpleMessage msg = {0};
uint8_t *buffer = app_state_get_user_data();
pb_istream_t s = pb_istream_from_buffer(buffer, 30);
pb_decode(&s, SimpleMessage_fields, &msg);
PBL_LOG(LOG_LEVEL_DEBUG, "The lucky number is %"PRId32, msg.lucky_number)... |
// Verify the app task got NO (virtual) connection event, the link is not encrypted yet:
// TODO: legacy PEBBLE_BT_CONNECTION_EVENT is still emitted, see gap_le_connect.c
// prv_put_legacy_connection_event.
//
// prv_assert_no_event();
fake_event_clear_last();
fake_GAPAPI_set_encrypted_for_device(&devic... | fake_HCIAPI_whitelist_contains(&device) | , false);
}
void __disabled_test_gap_le_connect__whitelist_add_when_connected(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register connection intent for app:
gap_le_connect_connect(&device,
false /* no auto_reconnect */,
false /* is_pairing_require... |
/*
* 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... | {
// Configure the pin itself
gpio_use(config->gpio);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = config->pull;
GPIO_InitStructure.GPIO_Pin = con... |
bool button_is_pressed(ButtonId id) {
const ButtonConfig* button_config = &BOARD_CONFIG_BUTTON.buttons[id];
gpio_use(button_config->gpio);
uint8_t bit = GPIO_ReadInputDataBit(button_config->gpio, button_config->gpio_pin);
gpio_release(button_config->gpio);
return (BOARD_CONFIG_BUTTON.active_high) ? bit : !b... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&RCC_ClocksStatus) | ;
uint64_t scaled_apbclock = DIV_PRECISION;
if ((dev->periph == USART1) || (dev->periph == USART6)) {
scaled_apbclock *= RCC_ClocksStatus.PCLK2_Frequency;
} else {
scaled_apbclock *= RCC_ClocksStatus.PCLK1_Frequency;
}
if (dev->periph->CR1 & USART_CR1_OVER8) {
scaled_apbclock <<= 1;
}
// cal... |
/*
* 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... | ("Katharine Berry", dest, NAME_LENGTH) | ;
cl_assert_equal_s(dest, "Katharine B.");
}
void test_phone_formatting__name_trailing_space(void) {
char dest[NAME_LENGTH];
phone_format_caller_name("Katharine Berry ", dest, NAME_LENGTH);
cl_assert_equal_s(dest, "Katharine B.");
memset(dest, 0, NAME_LENGTH);
phone_format_caller_name("Katharine Berry ... |
s = bt_driver_stop_le_scan();
kernel_free(s_reports_buffer);
s_reports_buffer = NULL;
s_is_scanning = false;
if (s_dropped_reports) {
PBL_LOG(LOG_LEVEL_INFO, "LE Scan -- Dropped reports: %" PRIu32, s_dropped_reports);
}
}
}
bt_unlock();
return success;
}
// ------------... | gap_le_stop_scan() | ;
s_is_scanning = false;
}
bt_unlock();
}
// For UNIT Tests
uint32_t gap_le_scan_get_dropped_reports_count(void) {
return s_dropped_reports;
}
|
"app_install_manager_private.h"
#include "app_custom_icon.h"
#include "app_manager.h"
#include "worker_manager.h"
#include "applib/event_service_client.h"
#include "apps/system_app_registry.h"
#include "console/prompt.h"
#include "drivers/task_watchdog.h"
#include "kernel/event_loop.h"
#include "kernel/pbl_malloc.h"... | {
// The recent app should never expire and we haven't been manually expired yet.
rv = true;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.