prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
176, -40},
{ 664, 120, -16},
{ 720, 120, 16},
{ 840, 88, 32},
{ 984, 88, 0},
{ 1128, 104, -64},
{ 1128, 64, -48},
{ 1400, 96, -8},
{ 1256, 96, 8},
{ 1072, 80, -80},
{ 1200, 136, -72},
{ 1232, 136, -56},
{ 1048, 216, -112},
{ 736, 176, -152},
// 81 seconds
{ 53... | { 1328, 272, -232},
{ 1032, 272, -160},
{ 1032, 256, -136},
{ 1160, 280, -136},
{ 1176, 280, -64},
{ 1032, 176, -16},
{ 848, 160, -16},
{ 736, 160, -24},
{ 768, 200, -40},
{ 816, 136, -8},
{ 840, 64, 16},
{ 952, 48, -16},
{ 1048, 56, -104},
{ 1040, -8, -104},
... |
{ 744, 128, 0},
{ 800, 112, -16},
{ 848, 64, -24},
{ 920, 48, -40},
// 89 seconds
{ 992, 72, -104},
{ 1040, 56, -120},
{ 1208, 88, -128},
{ 1240, 112, -136},
{ 1064, 136, -144},
{ 1072, 120, -144},
{ 1232, 152, -152},
{ 1160, 224, -144},
{ 912, 240, -144},
{ ... |
/*
* 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 (!prv_has_device_name()) {
if (!bt_persistent_storage_get_local_device_name(s_local_device_name,
sizeof(s_local_device_name))) {
prv_set_default_device_name();
}
} |
prv_configure_device_name();
}
void bt_local_id_set_device_name(const char *device_name) {
strncpy(s_local_device_name, device_name, sizeof(s_local_device_name));
s_local_device_name[sizeof(s_local_device_name) - 1] = '\0';
prv_configure_device_name();
}
void bt_local_id_copy_device_name(char name_out[BT_DE... |
cl_assert_equal_i(e, BTErrnoInvalidParameter);
}
void test_gap_le_connect__unregister_non_existing_bonding(void) {
BTErrno e = gap_le_connect_cancel_by_bonding(~0, GAPLEClientApp);
cl_assert_equal_i(e, BTErrnoInvalidParameter);
}
void test_gap_le_connect__register_is_already_registered_for_same_client(void) {
... | (&device, GAPLEClientApp) | ;
cl_assert_equal_i(e, BTErrnoInvalidParameter);
}
void test_gap_le_connect__unregister_unowned_intent(void) {
BTDeviceInternal device = prv_dummy_device(1);
BTErrno e;
// Register connection intent owned by kernel:
e = gap_le_connect_connect(&device,
true /* auto_reconnect */,
... |
lc->fill_radial_precise.center);
cl_assert_equal_i(0, lc->fill_radial_precise.radius_inner.raw_value);
cl_assert_equal_i(20 * 8, lc->fill_radial_precise.radius_outer.raw_value);
// outer radius capped to >= 0
EXECUTE_SCRIPT(
"ctx.rockyFillRadial(30, 40, -10, -20, 0, Math.PI);\n"
);
cl_assert_equal_i(3... | (10, 10, large_int, large_int) | ),
s_graphics_draw_text.last_call.draw_text.box);
rocky_api_graphics_get_gcontext()->draw_state.fill_color = GColorBlue;
EXECUTE_SCRIPT(
"ctx.fillText('more text', -10.5, 5000, 60);\n"
);
cl_assert_equal_i(2, s_graphics_draw_text.call_count);
cl_assert_equal_s("more text", s_graph... |
/*
* 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 (prv_hw_and_sw_supports_hrm() &&
activity_prefs_heart_rate_is_enabled());
} |
static void prv_reset_subscriptions(void);
static bool prv_free_permission_for_each_cb(ListNode *node, void *unused) {
kernel_free(node);
return true; // continue iteration
}
static void prv_free_all_permissions(void) {
list_foreach((ListNode *)s_permissions_head, prv_free_permission_for_each_cb, NULL);
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... | buffer_create(4) | |
, LayoutLayer *layout,
int8_t rel_change, void *context) {
SwapLayerDemoData *data = context;
data->idx += rel_change;
}
static void prv_update_colors_handler(SwapLayer *swap_layer, GColor bg_color,
bool status_bar_filled, void *context... | {
attribute_list_add_cstring(&attr_list, AttributeIdSubtitle, notif.subtitle);
} |
if (notif.body) {
attribute_list_add_cstring(&attr_list, AttributeIdBody, notif.body);
}
if (notif.location) {
attribute_list_add_cstring(&attr_list, AttributeIdLocationName, notif.location);
}
uint32_t timestamp = (rtc_get_time() + notif.time_offset);
TimelineItem *notification... |
er 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 <stdint.h>
#include <inttypes.h>
#include "board/board.h"
#include "boot_... | RCC_AHB3PeriphResetCmd(ahb3_periphs, DISABLE) | ;
RCC_APB1PeriphResetCmd(apb1_periphs, ENABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, DISABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, ENABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, DISABLE);
// The Cortex-M user guide states that the reset values for the core registers
// are as follows:
// R0-R12 = Unkno... |
em r;
cl_assert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_buffer);
cl_assert_equal_b(notification_storage_get(&i2, &r), false);
notification_storage_store(&e3);
cl_assert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_bu... | cl_assert(notification_storage_get(&uuids[i], &r)) | ;
compare_notifications(&e, &r);
free(r.allocated_buffer);
//Ensure that compression does not remove old notifications
e.header.id = uuids[j];
e.header.timestamp = timestamp + j;
cl_assert(notification_storage_get(&uuids[j], &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
//Add anothe... |
.size.h + current_frame->origin.y;
prv_layout_set_frame(swap_layer->previous, &prev_frame);
layer_add_child(&swap_layer->layer, (Layer *)swap_layer->previous);
layer_insert_below_sibling((Layer *)swap_layer->previous, &swap_layer->arrow_layer.layer);
return true;
}
static void prv_swap_down_start(Animation *a... | (swap_layer, -current_frame->size.h - current_frame->origin.y + layer_frame->size.h,
AnimationCurveEaseOut) | ;
}
}
//! Attempt to swap up or down. 'full_swap' is for swapping up, and it is used when wanting to go
//! to the top of the previous notification.
static bool prv_attempt_swap(SwapLayer *swap_layer, ScrollDirection direction, bool full_swap) {
prv_finish_animation(swap_layer);
Animation *animation;
if (dire... |
zed, with_fulltime);
} else if (difference >= SECONDS_PER_HOUR) {
const int num_hrs =
prv_round(difference, SECONDS_PER_HOUR, RoundTypeHalfUp) / SECONDS_PER_HOUR;
const char *str_fmt;
if (capitalized) {
str_fmt = i18n_noop("%lu H AGO");
} else if (num_hrs == 1) {
str_fmt = i18n_n... | (buffer, buf_size, timestamp, false, max_relative_hrs, true) | ;
}
void clock_get_until_time_capitalized(char *buffer, int buf_size, time_t timestamp,
int max_relative_hrs) {
prv_clock_get_relative_time_string(buffer, buf_size, timestamp, true, max_relative_hrs, true);
}
void clock_get_until_time_without_fulltime(char *buffer, int buf_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... | {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test loading GBitmap Kino Reel
uint32_t resource_id = sys_resource_load_file_as_resource(
TEST_IMAGES_PATH, "test_kino_reel__resource_gbitmap.pbi");
cl_assert(resource_id != UINT32_MAX);
KinoReel *kino_reel = kino_reel_create_with_resource(res... |
void test_kino_reel__resource_gbitmap_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test loading GBitmap Sequence Kino Reel
uint32_t resource_id = sys_resource_load_file_as_resource(
TEST_IMAGES_PATH, "test_kino_reel__resource_gbitmap_sequence.apng");
cl_assert(resource_id !... |
pfs_write(fd, &buf[0], sizeof(buf)) | , sizeof(buf));
if (i == 0) {
start_page = test_get_file_start_page(fd);
}
if ((i % 2) != 0) {
pfs_close_and_remove(fd);
} else {
pfs_close(fd);
}
}
// force garbage collection
test_force_garbage_collection(start_page);
// now make sure the files are still there!
for ... | |
tes that there are transparent modals that allow the app framebuffer to show through
compositor_render_app();
prv_compositor_flush();
}
// Draw the modal if in the Modal state
if (s_state == CompositorState_Modal) {
compositor_render_modal();
prv_compositor_flush();
}
prv_release_app_framebu... | if (s_animation_state.impl->teardown) {
s_animation_state.impl->teardown(animation);
} | |
ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_s... | (prv_count_handler_entries(&s_started_handler_calls, a), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);... |
= prv_fill_native_ancs_action(buffer, action, ActionIDPositive,
positive_action, app_id, properties);
action++;
}
if (negative_action) {
*buffer = prv_fill_native_ancs_action(buffer, action, ActionIDNegative,
negative_action... | for (int i = 0; i < notif_prefs->action_group.num_actions; i++) {
TimelineItemAction *action = ¬if_prefs->action_group.actions[i];
if (prv_should_hide_reply_because_group_sms(action, app_id, subtitle)) {
continue;
}
required_space_for_strings += attribute_list_get_buffer_size(&action-... | |
valuate the subtitle as a template string
const char *subtitle_template_string =
structured_glance->glance.current_slice.icon_and_subtitle.template_string;
TemplateStringEvalConditions template_string_reeval_conditions = {0};
const TemplateStringVars template_string_vars = (TemplateStringVars) {
.curren... | LauncherAppGlanceStructured *structured_glance =
launcher_app_glance_structured_create(&node->uuid, &s_generic_structured_glance_impl,
should_consider_slices, generic_glance);
if (structured_glance) {
if (generic_glance->use_legacy_28x28_icon_size_limit) {
... | |
include "test_rocky_common.h"
#include "applib/graphics/gpath.h"
#include "applib/graphics/gtypes.h"
#include "applib/rockyjs/api/rocky_api_global.h"
#include "applib/rockyjs/api/rocky_api_graphics.h"
#include "applib/rockyjs/api/rocky_api_graphics_color.h"
#include "applib/rockyjs/pbl_jerry_port.h"
#include "util/tri... | (jerry_get_global_object(), "ctx", ctx) | ;
}
void test_rocky_api_graphics_path2d__initialize(void) {
fake_malloc_set_largest_free_block(~0);
s_log_internal__expected = NULL;
rocky_runtime_context_init();
fake_app_timer_init();
jerry_init(JERRY_INIT_EMPTY);
s_app_window_stack_get_top_window = (Window){};
s_context = (GContext){};
s_app_state... |
t int pixel_min = bounds->origin.x;
const int pixel_max = bounds->origin.x + bounds->size.w - 1;
for (int j = 0; j < 2; j++) {
graphics_context_set_stroke_color(ctx, j ? GColorGreen : GColorRed);
for (int i = 0 + j; i < 5; i += 2) {
graphics_draw_line(ctx, (GPoint) {.x = i, .y = pixel_min},
... | app_state_get_user_data() | ;
app_timer_cancel(data->exit_timer);
app_free(data);
}
static void s_main(void) {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
}
const PebbleProcessMd* mfg_display_calibration_app_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &s_main,
// UUI... |
{ 928, 256, 40},
{ 1032, 136, 120},
{ 984, 48, 232},
{ 904, 48, 184},
{ 800, 40, 128},
{ 736, 16, 88},
{ 720, -16, 96},
{ 752, -32, 88},
{ 864, -56, 80},
{ 1008, -96, 40},
// 39 seconds
{ 1056, -72, -16},
{ 1656, -304, 152},
{ 1400, -32, 152},
{ 1080, 240, -88... |
{ 840, 256, 120},
{ 880, 288, 120},
{ 856, 328, 8},
{ 928, 368, -120},
{ 1032, 368, -208},
{ 1184, 336, -192},
{ 1648, 160, 16},
{ 1784, 320, 8},
{ 960, 344, 0},
{ 1080, 200, 48},
{ 1200, 120, 160},
{ 976, 56, 208},
{ 808, 104, 144},
{ 744, 88, 104},
{ 688, 2... | |
(s_num_samples, 22) | ;
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
sys_accel_manager_set_sample_buffer(main_session, fake_buf, 3);
cl_assert_equal_i(s_num_samples, 7); /* 300ms / (1000ms / 25 samps) */
}
| |
{
EmxCustomResource *custom_resources;
uint32_t last_id;
int array_size;
int next_index;
} CustomResList;
static CustomResList s_custom_res_list = {0};
static int prv_custom_resource_get_index(uint32_t resource_id) {
int index;
for (index = 0; index < s_custom_res_list.next_index; ++index) {
if (s_cu... | {
if (offset > INT_MAX || num_bytes > INT_MAX) {
return 0;
}
EmxCustomResource *custom_res = NULL;
if (app_num != SYSTEM_APP && (custom_res = prv_custom_resource_get(resource_id))) {
return custom_res->read(offset, buf, num_bytes);
}
Resource resource = {};
if (!prv_get_resource(resource_id, &re... |
size_t emx_resources_get_size(ResAppNum app_num, uint32_t resource_id) {
EmxCustomResource *custom_res = NULL;
if (app_num != SYSTEM_APP && (custom_res = prv_custom_resource_get(resource_id))) {
return custom_res->get_size();
}
Resource resource = {};
if (!prv_get_resource(resource_id, &resource)) {
... |
TX/RX max values.
// This means that TX max on one end is bound by RX max on the other, and vice versa.
s_state.tx_chunk_size_bytes = MIN(rc->max_rx_chunk_size, POSTMESSAGE_PROTOCOL_MAX_TX_CHUNK_SIZE);
s_state.rx_chunk_size_bytes = MIN(rc->max_tx_chunk_size, POSTMESSAGE_PROTOCOL_MAX_RX_CHUNK_SIZE);
s_st... | {
return true;
} |
PBL_LOG(LOG_LEVEL_ERROR, "ResetComplete too small! %"PRIu16, reset_complete->length);
return false;
}
static void prv_awaiting_reset_complete_remote_initiated__inbox_received(DictionaryIterator *it,
void *context) {
Tuple *tuple = dict_fin... |
start(PowerSystemFlashWrite);
enable_flash_spi_clock();
handle_sleep_when_idle_begin();
uint32_t first_page_available_bytes = FLASH_PAGE_SIZE - (start_addr % FLASH_PAGE_SIZE);
uint32_t bytes_to_write = MIN(buffer_size, first_page_available_bytes);
if (first_page_available_bytes < FLASH_PAGE_SIZE) {
PBL... | {
flash_unlock();
return;
} |
enable_flash_spi_clock();
handle_sleep_when_idle_begin();
uint8_t status_register = prv_flash_get_register(FLASH_CMD_READ_STATUS_REG);
uint8_t lock_register = prv_flash_get_register(FLASH_CMD_READ_LOCK_REGISTER);
uint8_t flag_status_register = prv_flash_get_register(FLASH_CMD_READ_FLAG_STATUS_REG);
uint8... |
/*
* 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... | {
switch (msg->command_id) {
case HcMessageID_Discovery_Service_Found:
prv_handle_new_service_found((HcProtocolDiscoveryServiceFoundPayload *)msg->payload);
break;
case HcMessageID_Discovery_Complete:
prv_handle_discovery_complete((HcProtocolDiscoveryCompletePayload *)msg->payloa... |
bt_unlock();
}
|
ow_private.h"
#include "applib/ui/layer.h"
#include "util/graphics.h"
#include "util/trig.h"
#include "clar.h"
#include "util.h"
#include <stdio.h>
// Helper Includes
////////////////////////////////////
#include "test_graphics.h"
#include "test_graphics_mask.h"
#include "8bit/test_framebuffer.h"
// Stubs
/////////... | test_graphics_context_mask_debug(ctx, mask) | ;
graphics_context_mask_destroy(ctx, mask);
}
///////////////////////////////////////
// RECORDING VERTICAL LINE HELPERS //
///////////////////////////////////////
static void prv_prepare_canvas_for_vline_recording_test(GContext *ctx) {
const GSize bitmap_size = GSize(num_src_colors, num_mask_values * num_pixe... |
(void) {
return s_activity_next_resting_calories;
}
// --------------------------------------------------------------------------------------------
uint32_t activity_metrics_prv_get_active_calories(void) {
return s_activity_next_active_calories;
}
HRZone activity_metrics_prv_get_hr_zone(void) {
return s_activi... | if (next_vmc == 65533) {
// Make sure combinations of vmc/orient are mostly unique, so don't wrap at the same
// module 256 boundary.
next_vmc = 0;
} |
minute_data[i].base.orientation = next_orient++;
minute_data[i].base.light = next_light++;
minute_data[i].base.plugged_in = next_plugged_in;
next_plugged_in = !next_plugged_in;
minute_data[i].active_calories = next_active_calories++;
minute_data[i].resting_calories = next_resting_calories++;
... |
nstall_manager.h"
#include "services/normal/filesystem/app_file.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/legacy/persist_map.h"
#include "services/normal/settings/settings_file.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/list.h"
#include "util/units.h"
#defi... | (prv_get_file_name(filename, sizeof(filename), uuid)) | );
PBL_ASSERTN(PASSED(settings_file_open(&store->file, filename, PERSIST_STORAGE_MAX_SPACE)));
store->file_open = true;
}
return &store->file;
}
void persist_service_unlock_store(SettingsFile *store) {
prv_unlock();
}
// Create a store for a client of the given UUID it doesn't already exist. If it
// ex... |
_tuplets__deprecated(const uint8_t tuplets_count, const Tuplet * const tuplets) {
return dict_calc_buffer_size_from_tuplets(tuplets, tuplets_count);
}
static DictionaryResult dict_write_tuple(DictionaryIterator* iter, Tuple* tuple) {
return dict_write_data_internal(iter, tuple->key, (uint8_t*)tuple->value,
... | {
size_t size = dict_size(iter);
uint8_t* buf = task_malloc(size);
if (buf == NULL) return NULL;
memcpy(buf, iter->dictionary, size);
return buf;
} | |
order[5]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(!timeline_model_iter_next(&new_idx, &has_next));
}
void test_timeline_model__and_back(void) {
TimelineModel model = {0};
model.direction = TimelineIterDirectionFuture;
time_t first_time = 1421178000;
// Note: 1421178000... | (&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(2)->pin.header.id) | |
512, -992},
{ -184, 592, -840},
// 10 seconds
{ -72, 472, -704},
{ 0, 296, -584},
{ -80, 296, -504},
{ -152, 344, -624},
{ -128, 376, -824},
{ -64, 472, -984},
{ -136, 520, -1160},
{ -16, 568, -1264},
{ -48, 480, -1184},
{ 32, 720, -1152},
{ 248, 584, -1152},
{ 22... | { 16, 416, -1136},
{ -24, 456, -1168},
{ 64, 552, -1120},
{ 136, 576, -1048},
{ 64, 552, -1016},
{ 80, 488, -912},
{ 56, 320, -696},
{ -80, 272, -640},
{ -160, 208, -664},
{ -208, 192, -768},
{ -232, 296, -920},
{ -352, 368, -1096},
{ -240, 512, -1296},
{ -240, 52... | |
/*
* 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... | (info->sys_locale) | ;
return info->sys_locale;
}
void app_i18n_get(const char *locale, const char *string, char *buffer, size_t length) {
const char *system_locale = app_get_system_locale();
if (strncmp(locale, system_locale, ISO_LOCALE_LENGTH) != 0) {
strncpy(buffer, string, length);
buffer[length - 1] = '\0';
} else {
... |
>action_bar_stop =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_STOP);
active_window->action_bar_more =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_MORE);
active_window->action_bar_next =
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_TOGGLE);
prv_set_pause_bu... | (WorkoutMetricType_Hr,
ARRAY_LENGTH(scrollable_metrics),
scrollable_metrics,
workout_data,
workout_controller) | ;
} else {
return workout_active_create_single_layout(WorkoutMetricType_Duration,
workout_data,
workout_controller);
}
}
case ActivitySessionType_Walk:
{
if (hrm_is_available) {
... |
/*
* 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_fill_points = prv_copy_points(path->points, path->num_points, s_offset);
s_path_fill_count++;
} | |
x) {
if (outbox->not_ready_throttle_ms == 0) {
outbox->not_ready_throttle_ms = 1;
} else {
outbox->not_ready_throttle_ms = MIN(outbox->not_ready_throttle_ms * 2, 100 /*ms*/);
}
sys_psleep(outbox->not_ready_throttle_ms);
}
static bool prv_is_message_pending(AppMessagePhaseOut phase) {
return (phase ==... | {
return APP_MSG_BUFFER_OVERFLOW;
} |
uint8_t transaction_id = prv_get_next_transaction_id(outbox);
AppMessageAppOutboxData *app_outbox_message = outbox->app_outbox_message;
AppMessagePush *transmission = (AppMessagePush *)app_outbox_message->payload;
transmission->header.command = CMD_PUSH;
transmission->header.transaction_id = transaction_id;... |
int32_t crc = legacy_defective_checksum_memory(
&frame->data, frame->length - sizeof(fcs));
if (fcs == crc) {
prv_reset_keepalive_timer();
uint8_t protocol = (uint8_t)frame->data[0];
bool protocol_found = false;
for (unsigned int i = 0; i < ARRAY_LENGTH(s_supported_protocols); ++i) {
if (... | {
prv_assert_tx_buffer(buf);
mutex_unlock(s_tx_buffer_mutex);
} |
void pulse_change_baud_rate(uint32_t new_baud) {
dbgserial_change_baud_rate(new_baud);
}
#endif
|
/*
* 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... | (last_word) | ;
} else {
crc_value = CRC_GetCRC();
}
return crc_value;
}
static void prv_calculate_incremental_stop(void) {
prv_disable_crc_clock();
}
uint32_t crc_calculate_bytes(const uint8_t* data, unsigned int data_length) {
prv_calculate_incremental_start();
// First calculate the CRC of the whole words, sin... |
ing)
static bool s_input_enabled;
//! We'll store up to the last 3 bytes which were sent for detecting bus contention
typedef struct {
uint8_t data;
bool has_data;
} SendHistory;
static volatile SendHistory s_send_history;
//! Flag which states whether or not we've detected bus contention since last disabling input... | (s_stop_mode_monitor.timer, ACCESSORY_STOP_INTERVAL_PERIOD_MS,
prv_timer_interval_expired_cb, NULL, TIMER_START_FLAG_REPEATING) | ;
}
//! Callback run whenever the EXTI fires
static void prv_exti_cb(bool *should_context_switch) {
if (!s_stop_mode_monitor.active) {
// First time seeing data, let's go active
s_stop_mode_monitor.active = true;
s_stop_mode_monitor.intervals_without_data = 0;
s_stop_mode_monitor.max_intervals_witho... |
CONFIG.spi_gpio, FLASH_CONFIG.miso_pin, altfunc);
GPIO_PinAFConfig(FLASH_CONFIG.spi_gpio, FLASH_CONFIG.mosi_pin, altfunc);
// Setup MISO/MOSI
GPIO_InitTypeDef gpio_cfg;
gpio_cfg.GPIO_OType = GPIO_OType_PP;
gpio_cfg.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio_cfg.GPIO_Mode = GPIO_Mode_AF;
gpio_cfg.GPIO_Speed = GPI... | prv_flash_wait_for_write_bounded(64000000) | ;
prv_flash_start_cmd();
prv_flash_send_and_receive_byte(FLASH_CMD_READ_ID);
uint32_t manufacturer = prv_flash_read_next_byte();
uint32_t type = prv_flash_read_next_byte();
uint32_t capacity = prv_flash_read_next_byte();
prv_flash_end_cmd();
prv_disable_flash_spi_clock();
return ((manufacturer << 16)... |
ct(ctx, &GRect(16, 2, 28, 20), 4);
}
void across_nx_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(-14, 2, 28, 20), 4);
}
void across_y_layer_update_callback(Layer* me, GCon... | ("white_over_black", ctx.parent_framebuffer, GColorWhite) | |
GE)) {
continue; // only start pages contain file 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((ui... | {
*first_free_page = pg;
} |
} else if (!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
//!... |
y >= 0)
#define BITS_BETWEEN(x, y) (BITS(y) & ~BITS(x-1))
// Yo dawg, I heard you like tests so I put tests in your tests so you can test
// your tests while you test!
void test_system_flash__bit_range_macros(void) {
cl_assert_equal_i(0b1, BITS(0));
cl_assert_equal_i(0b00011111, BITS(4));
cl_assert_equal_i(0b00... | {
cl_assert(flash_written_flag[start + i] == false);
} |
}
void test_system_flash__write_simple(void) {
const char testdata[] = "The quick brown fox jumps over the lazy dog.";
malloc_flash_data(100);
flash_data_start = FLASH_BASE;
cl_assert(system_flash_write(
FLASH_BASE + 10, testdata, sizeof(testdata), callback_is_called_cb,
(void *)8675309));
c... |
ct(),
.expected_output = "[object Object]",
},
};
for (int i = 0; i < ARRAY_LENGTH(cases); ++i) {
jerry_value_t input = cases[i].input;
JERRY_ARGS_MAKE(input);
// Exercise ROCKY_ARG (automatic binding creation, defaults to malloc'd string for char *):
{
char *output = NULL;
R... | for (int i = 0; i < ARRAY_LENGTH(cases); ++i) {
jerry_value_t *argv = cases[i].argv;
jerry_length_t argc = cases[i].argc;
GRectPrecise output;
memset(&output, 0x55, sizeof(output));
ROCKY_ARGS_ASSIGN(ROCKY_ARG(output));
ASSERT_JS_ERROR(error_value, cases[i].error_msg);
if (!cases[i].error_... |
}
void test_rocky_api_util_args__gcolor(void) {
const char *type_error_msg =
"TypeError: Argument at index 0 is not a String ('color name' or '#hex') or Number";
const char *invalid_value_msg =
"TypeError: Argument at index 0 is invalid: " \
"Expecting String ('color name' or '#hex') or Number";... |
/*
* 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... | for (int i = 0; i < 4; i++) {
char c = str[i];
bool should_store, is_invalid;
bool is_complete = hdlc_streaming_decode(&ctx, (uint8_t *)&c, &should_store, &is_invalid);
cl_assert(is_complete == true);
cl_assert(should_store == false);
cl_assert(is_invalid == false);
} |
}
void test_hdlc__decode_invalid(void) {
// invalid sequences
uint8_t data;
bool should_store, is_invalid, is_complete;
HdlcStreamingContext ctx;
// two consecutive escape characters
hdlc_streaming_decode_reset(&ctx);
data = HDLC_ESCAPE;
is_complete = hdlc_streaming_decode(&ctx, &data, &should_store,... |
;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw5_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 5);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw5_clip_xy.$... | (&ctx.dest_bitmap, "draw_rect_offset_sw4_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 4);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw4_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, fal... |
es_removed->num_services_removed; s++) {
bool removed = false;
for (int c = 0; c < KernelLEClientNum; c++) {
const KernelLEClient * const client = &s_clients[c];
if (uuid_equal(&service_remove_info->uuid, client->service_uuid)) {
removed = true;
client->handle_service_removed(
... | {
// For removals, we log info in the handler routine
PBL_LOG(LOG_LEVEL_INFO, "Service changed Indication: type: %d status: %d",
event_info->type, event_info->status);
} |
switch (event_info->type) {
case PebbleServicesRemoved:
prv_handle_services_removed(&event_info->services_removed_data);
break;
case PebbleServicesInvalidateAll:
prv_handle_all_services_invalidated();
break;
case PebbleServicesAdded:
prv_handle_services_added(&event_info->s... |
{ 32, 112, -920},
// 194 seconds
{ 40, 136, -920},
{ 32, 128, -920},
{ 32, 120, -920},
{ 32, 128, -920},
{ 40, 136, -920},
{ 32, 144, -920},
{ 32, 144, -928},
{ 24, 144, -944},
{ 48, 104, -920},
{ 48, 96, -896},
{ 56, 96, -888},
{ 24, 112, -944},
{ 24, 160, -... | { 32, 144, -920},
{ 24, 120, -912},
{ 40, 136, -920},
{ 32, 128, -912},
{ 32, 136, -920},
// 200 seconds
{ 32, 144, -920},
{ 24, 120, -920},
{ 32, 160, -928},
{ 32, 128, -920},
{ 32, 136, -920},
{ 40, 136, -912},
{ 32, 128, -928},
{ 32, 128, -928},
{ 32, 128, ... | |
*company_id = ctx.company_id;
}
return ctx.copied_size;
}
// -----------------------------------------------------------------------------
// Creating BLEAdData:
// -----------------------------------------------------------------------------
//! Magic high bit used as scan_resp_data_length to indicate that t... | {
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;
} |
// -----------------------------------------------------------------------------
void ble_ad_destroy(BLEAdData *ad) {
applib_free(ad);
}
// -----------------------------------------------------------------------------
//! The smallest UUID width, by reducing the width when a UUID is based on the
//! Bluetooth base... |
data->is_mic_enabled = !data->is_mic_enabled;
menu_layer_reload_data(menu_layer);
break;
#endif
case TXMenuIdx_RunStop: // Run / Stop
if (data->current_test_step == BTLETestStep_None) {
prv_run_test(data);
} else {
prv_stop_test(data);
}
b... | (menu_items) | ,
.items = data->main_menu_items,
};
Layer *window_layer = window_get_root_layer(&data->main_menu_window);
const GRect bounds = window_layer->bounds;
data->main_menu_layer =
simple_menu_layer_create(bounds, &data->main_menu_window, &data->main_menu_section, 1, data);
layer_add_child(window_layer, s... |
i/ui.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
#include "system/passert.h"
#include <stdio.h>
#define BUFFER_SIZE 25
static const uint8_t s_music_launcher_icon_pixels[] = {
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x01, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xf... | (detail_window, data) | ;
window_set_window_handlers(detail_window, &(WindowHandlers) {
.load = detail_window_load,
});
const bool animated = true;
app_window_stack_push(detail_window, animated);
}
static void select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, AppData *data) {
push_detail_window(data, cell_index, fal... |
/*
* 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(-10000, interpolate_int16(0, -10000, 10000));
cl_assert_equal_i(10000, interpolate_int16(ANIMATION_NORMALIZED_MAX, -10000, 10000));
} | |
layer_deinit(&pair->black_layer.layer) | ;
layer_deinit(&pair->layer);
}
void rotbmp_pair_layer_set_angle(RotBmpPairLayer *pair, int32_t angle) {
rot_bitmap_layer_set_angle(&pair->white_layer, angle);
rot_bitmap_layer_set_angle(&pair->black_layer, angle);
}
void rotbmp_pair_layer_increment_angle(RotBmpPairLayer *pair, int32_t angle_change) {
rot_b... | |
(LOG_LEVEL_INFO, "Received a tap event for KernelMain, axis: %d, "
"direction: %" PRId32, axis, direction);
}
#endif
// Compute and return the device's delta position to help determine movement as idle.
static uint32_t prv_compute_delta_pos(AccelData *cur_pos, AccelData *last_pos) {
return (abs(last_pos->x - c... | list_insert_before(s_data_subscribers, &state->list_node) | ;
if (no_subscribers_before) {
sys_vibe_history_start_collecting();
}
// Add as a consumer to the accel buffer
shared_circular_buffer_add_subsampled_client(
&s_buffer, &state->buffer_client, 1, 1);
// Update the sampling rate and num samples of the driver considering the new
// s... |
gbitmap_destroy(s_dest_bitmap);
s_dest_bitmap = NULL;
}
// Helpers
//////////////////////
static char s_emoji_string[] =
"😄😃😀😊☺😉😍😘😚😗😙😜😝😛😳😁😔😌😒😞😣😢😂😭😥😪😰😅😓😩😫😨😱"
"😠😡😤😖😆😋😷😎😴😵😲😟😧😈👿😮😬😐😕😯😶😇😏😑😺😸😻😽😼🙀😿😹😾💩"
"👍👎👌👊✊✌👋✋👐👆👇👉👈🙌🙏☝👏💛💙💜💚❤💔💗💓... | (RESOURCE_ID_GOTHIC_28_EMOJI) | ;
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
|
ue;
}
return false;
}
// ----------------------------------------------------------------------------------------------
static void prv_alarm_set_config(SettingsFile *file, AlarmId id, const AlarmConfig* config) {
PBL_ASSERTN(id >= 0 && id < MAX_CONFIGURED_ALARMS);
Alarm alarm = { .id = id, .config = *config... | prv_enable_alarm_config(&config, true /* enabled */) | |
tructions upon wake from STOP
// in certain sitations. See the STM32F20x and STM32F21x Errata sheet
// section 2.1.3 "Debugging Stop mode with WFE entry", or the erratum
// of the same name in section 2.1.2 of the STM32F42x and STM32F43x
// Errata sheet, for (misleading) details.
// http://www.st.com/web/en/r... | ticks_to_milliseconds(ticks) | , AnalyticsClient_System);
}
void analytics_external_collect_stop_inhibitor_stats(RtcTicks now_ticks) {
prv_collect(ANALYTICS_DEVICE_METRIC_CPU_NOSTOP_MAIN_TIME, InhibitorMain, now_ticks);
// We don't care about the serial console nostop time, it should always
// be zero on watches in the field anyway. (Inhibito... |
rintf(dstbuf, 256, "What is the %%d");
cl_assert_equal_s(dstbuf, "What is the %d");
snprintf(dstbuf, 256, "What is the %%d");
cl_assert_equal_s(dstbuf, "What is the %d");
}
void test_sprintf__truncate(void) {
char dstbuf[256];
memset(dstbuf, 0xFF, 256);
cl_assert_equal_i(snprintf(dstbuf, 17, "Hello!\nI a... | (dstbuf, 256, "There are %#i lights, %#i", 4, -4) | ;
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %02i lights, %02i", 4, -4);
cl_assert_equal_s(dstbuf, "There are 04 lights, -4");
// Space padded minimum character output
snprintf(dstbuf, 256, "There are %2i lights, %2i", 4, -... |
sys_hrm_manager_set_features(session_ref, HRMFeature_LEDCurrent | HRMFeature_BPM);
cl_assert_equal_i(state->features, HRMFeature_LEDCurrent | HRMFeature_BPM);
}
void test_hrm_manager__set_update_internal(void) {
AppInstallId app_id = 1;
const uint16_t expire_a_s = SECONDS_PER_MINUTE;
uint32_t update_interval_... | rtc_get_time() | + ms / MS_PER_SECOND);
}
// Test that we handle different update intervals correctly
void test_hrm_manager__update_interval(void) {
AppInstallId app_id = 1;
uint32_t update_interval_s = 600;
const uint16_t expire_s = 30 * SECONDS_PER_MINUTE;
HRMFeature features = HRMFeature_BPM;
HRMSessionRef session_ref = ... |
next part of the animation.
data->title_text_layer.layer.bounds.origin.y = -TITLE_BOUNDS_OFFSET;
data->artist_text_layer.layer.bounds.origin.y = -ARTIST_BOUNDS_OFFSET;
data->position_text_layer.layer.bounds.origin.y = -TIME_BOUNDS_OFFSET;
data->length_text_layer.layer.bounds.origin.y = -TIME_BOUNDS_OFFSET;
}
... | (disappear_animation, 3 * ANIMATION_FRAME_MS) | ;
animation_set_curve(disappear_animation, AnimationCurveEaseIn);
GRect origin = cassette_rect;
origin.origin.y -= BOUNCEBACK_OFFSET;
Animation *bounceback_animation = property_animation_get_animation(
property_animation_create(&s_frame_layer_implementation, &data->cassette_layer.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... | (s_framebuffer) | ;
if (s_pixels) {
gbitmap_destroy(s_pixels);
}
s_pixels = gbitmap_create_blank(size, GBITMAP_NATIVE_FORMAT);
memset(s_pixels->addr, 0xff, size.h * s_pixels->row_size_bytes);
s_context.dest_bitmap = *s_pixels;
s_context.draw_state.clip_box = (GRect){.size = size};
s_context.draw_state.drawing_box = s_c... |
PebbleMediaEventTypeServerDisconnected,
},
};
event_put(&event);
}
mutex_unlock_recursive(s_music_ctx.mutex);
return (change_type != None);
}
const char * music_get_connected_server_debug_name(void) {
const char *debug_name = NULL;
mutex_lock_recursive... | (time_elapsed_ticks) | ;
mutex_unlock_recursive(s_music_ctx.mutex);
return time_elapsed_ms;
}
void music_get_pos(uint32_t *track_pos_ms, uint32_t *track_length_ms) {
mutex_lock_recursive(s_music_ctx.mutex);
const int32_t time_elapsed_ms = music_get_ms_since_pos_last_updated();
const int32_t track_time_elapsed =
(time_elapse... |
/*
* 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... | {
uint16_t company_id = 0;
AdDataManufacturerSpecificAppleiBeacon raw_ibeacon;
const size_t size_copied =
ble_ad_copy_manufacturer_specific_data(ad, &company_id,
(uint8_t *) &raw_ibeacon,
sizeof(raw_ibeacon));
if (si... |
// -----------------------------------------------------------------------------
//! iBeacon Advertisement Data composer
bool ble_ibeacon_compose(const BLEiBeacon *ibeacon_in, BLEAdData *ad_out) {
AdDataManufacturerSpecificAppleiBeacon raw_ibeacon = {
.type = APPLE_TYPE_IBEACON,
.length = APPLE_IBEACON_LENG... |
/*
* 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... | mfg_info_get_model(buffer) | ;
cl_assert_equal_s(buffer, "test_model");
}
|
state.mutex);
{
activity_insights_process_sleep_data(utc_sec);
activity_insights_process_minute_data(utc_sec);
}
mutex_unlock_recursive(s_activity_state.mutex);
}
// ------------------------------------------------------------------------------------------------
// Runs on the timer task. Simply registe... | {
data->record.flags |= ACTIVITY_RAW_SAMPLE_FLAG_LAST_RECORD;
} |
DataLoggingResult result = dls_log(data->dls_session, &data->record, 1);
if (result != DATA_LOGGING_SUCCESS) {
PBL_LOG(LOG_LEVEL_WARNING, "Error %"PRIi32" while logging raw sample data",
(int32_t)result);
}
// Generate a log message as well. This is temporary until we h... |
/*
* 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... | (timer_data->callback) | ;
for (unsigned i = 0; i < timer_data->argc; i++) {
jerry_release_value(timer_data->argv[i]);
}
task_free(timer_data);
}
static void prv_timer_callback(void *data) {
RockyTimerCbData *timer_data = data;
if (jerry_value_is_function(timer_data->callback)) {
rocky_util_call_user_function_and_log_uncaug... |
/*
* 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 (*cur_ptr == NULL) {
break;
} |
cur_ptr = &cur_entry->more_recent;
}
// cur_ptr should point to the last pointer in the list
PBL_ASSERTN(*cur_ptr == NULL);
if (new == NULL) {
// cache full, evict LRU
new = c->least_recent;
c->least_recent = new->more_recent;
}
new->more_recent = NULL;
new->key = key;
memcpy(new->da... |
tance_m, bpm, active_kcalories;
HRZone hr_zone;
// We have a session that started at utc=10 and length_min of 10. Increment the time
// so that makes sense
prv_inc_time(610);
// Start a new session
ActivitySession session = {
.start_utc = 10,
.length_min = 10,
.type = ActivitySessionType_Run,
... | prv_put_bpm_event(190, HRMQuality_Good) | ;
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 10);
cl_assert_equal_i(duration_s, 10);
cl_assert_equal_i(bpm, 190);
// Resume the workout and get more data (it updates this ... |
) {
if (node == NULL) {
return NULL;
}
ListNode *head = list_get_head(node);
ListNode *new_head = head->next;
list_remove(head, NULL, NULL);
return new_head;
}
ListNode* list_pop_tail(ListNode *node) {
if (node == NULL) {
return NULL;
}
ListNode* tail = list_get_tail(node);
ListNode* new_ta... | filter_callback(cursor, data) | ) {
return cursor;
}
// We're back at where we started and even <node> itself doesn't match the filter
if (cursor == node) {
return NULL;
}
cursor = cursor->next;
}
UTIL_ASSERT(0);
return NULL;
}
ListNode* list_find_prev(ListNode *node, ListFilterCallback filter_callback, bool wra... |
er_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(50, 40), GPoint(70, 35));
}
void across_nx_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GC... | (&layer, &white_layer_update_callback) | |
dx);
node = list_get_next(node);
}
printf("}");
}
printf("\n");
cl_assert(!failed);
prv_clear_recognizers_processed(list);
}
static void prv_sub_event_handler(const Recognizer *recognizer, RecognizerEvent event) {
}
// setup and teardown
void test_recognizer_manager__initialize(void) {
s_tes... | ((int[]) {0, 1}, 2, &s_recognizers_handled) | ;
// Recognizers attached to children of active layer will not be evaluated
manager.active_layer = &layer_a;
cl_assert(prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL));
prv_compare_recognizers_processed((int[]) {2, 3}, 2, &s_recognizers_handled);
// Recognizers attached to active l... |
BatteryShutdownCharging
}},
[BatteryFullyCharged] = { .enter = prv_display_fully_charged, .exit = prv_dismiss_fully_charged,
.next_state = {
BatteryGood, BatteryWarning, BatteryLowPower, BatteryCritical, BatteryShutdownCharging
}},
// TODO PBL-39883: Replace w/ QUIRK_RESET_ON_SHUTDOWN_WHILE_CHARGING onc... | {
if (s_state != next_state) {
// All self-transitions are internal.
// A state's entry function is a its only valid action.
// The exit function is only called on actual state changes.
if (ui_states[s_state].exit) {
ui_states[s_state].exit();
}
s_state = next_state;
}
if (ui_states[... |
static bool prv_is_valid_transition(BatteryUIStateID next_state) {
const uint8_t count = ARRAY_LENGTH(ui_states[s_state].next_state);
for (int i = 0; i < count; i++) {
if (ui_states[s_state].next_state[i] == next_state) {
return true;
}
}
return false;
}
static BatteryUIStateID prv_get_state(P... |
2,
const char *file,
int line,
const char *err,
int should_abort)
{
int match = (s1 == NULL || s2 == NULL) ? (s1 == s2) : (strcmp(s1, s2) == 0);
if (!match) {
char buf[4096];
snprint_eq(buf, 4096, "'%s' != '%s'", s1, s2);
clar__assert(0, file, line, err, buf, should_abort);
}
}
void clar__as... | ("m2:", m2, n) | ;
fflush(stdout);
clar__assert(0, file, line, err, buf, should_abort);
}
}
void cl_set_cleanup(void (*cleanup)(void *), void *opaque)
{
_clar.local_cleanup = cleanup;
_clar.local_cleanup_payload = opaque;
}
${clar_modules}
int _MAIN_CC main(int argc, char *argv[])
{
return clar_test(argc, argv);
}
|
/*
* 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... | ("PMIC didn't shut us down!") | ;
}
NORETURN enter_standby(RebootReasonCode reason) {
PBL_LOG(LOG_LEVEL_ALWAYS, "Preparing to enter standby mode.");
RebootReason reboot_reason = { reason, 0 };
reboot_reason_set(&reboot_reason);
// Wipe display
display_clear();
/* skip BT teardown if BT isn't working */
system_reset_prepare(reason ==... |
(PebbleProcessMd*) &s_root_app;
}
void system_app_state_machine_register_app_launch(const PebbleProcessMd* app) {
}
void sys_vibe_history_stop_collecting(void) {
}
Heap *worker_state_get_heap(void) {
return NULL;
}
QueueHandle_t xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxIt... | test_app_manager__start_first() | ;
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = &s_borked_app.common,
});
app_manager_get_task_context()->safe_to_kill = true;
app_manager_close_current_app(true /* gracefully */);
// The first app should still be running
cl_assert(app_manager_get_current_app_md() == (PebbleProcessMd*) &s_laun... |
ered
chunk_size = item_size;
} else {
chunk_size = MIN(num_bytes, DLS_SESSION_MAX_BUFFERED_ITEM_SIZE);
chunk_size -= (chunk_size % item_size);
}
PBL_ASSERTN(chunk_size <= num_bytes);
data_logging_log(logging_session, buf, chunk_size / item_size);
fake_system_task_callbacks_invoke_p... | (i, DATA_LOGGING_BYTE_ARRAY, item_size,
false /*buffered*/, false /*resume*/, &system_uuid) | |
mes;
} AppData;
static int64_t prv_time_64(void) {
time_t s;
uint16_t ms;
rtc_get_time_ms(&s, &ms);
return (int64_t)s * 1000 + ms;
}
static void prv_redraw_timer_cb(void *cb_data) {
AppData *data = app_state_get_user_data();
layer_mark_dirty(&data->window.layer);
app_timer_register(0, prv_redraw_timer_... | prv_draw_row(ctx, cell_layer, title, -cell_layer->frame.origin.y/4 + cell_layer->bounds.size.w) | ;
}
static int16_t prv_get_separator_height(struct MenuLayer *menu_layer, MenuIndex *cell_index,
void *callback_context) {
return 0;
}
static void prv_window_update_proc(struct Layer *layer, GContext *ctx) {
AppData *data = app_state_get_user_data();
if (data->rendered_frames == 0) {
data->time_started ... |
/*
* 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... | (ctx, GColorBlack) | ;
graphics_context_set_antialiased(ctx, false);
graphics_draw_circle(ctx, GPoint(14, 14), 12);
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, false);
graphics_draw_circle(ctx, GPoint(14, 14), 12);
}
vo... |
/*
* 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_rtc_auto_increment = auto_increment;
} | |
/*
* 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 (launcher_panic_get_current_error() != 0) {
return panic_app_get_app_info();
}
#if CAPABILITY_HAS_SDK_SHELL4
const AppInstallId watchface_app_id = watchface_get_default_install_id();
if (watchface_app_id != INSTALL_ID_INVALID) {
return app_install_get_md(watchface_app_id, false /* worker */);
}
... |
#if CAPABILITY_HAS_SDK_SHELL4
//! @return True if the currently running app is an installed watchface
static bool prv_current_app_is_watchface(void) {
return app_install_is_watchface(app_manager_get_current_app_id());
}
AppInstallId system_app_state_machine_get_last_registered_app(void) {
// If we're rooted in t... |
stubs_sleep.h"
#include "stubs_task_watchdog.h"
#define CONTACT_1_UUID 0x0a, 0x04, 0x98, 0x00, 0x39, 0x18, 0x47, 0xaa, 0x9c, 0x16, 0x8e, 0xa0, 0xa8, 0x2a, 0x2e, 0xb8
#define ADDRESS_1_UUID 0xd3, 0x72, 0x2d, 0x75, 0x6b, 0x21, 0x49, 0x2a, 0x9c, 0xc7, 0x5f, 0xf8, 0x4d, 0xd2, 0x5a, 0x9c
#define ADDRESS_2_UUID 0x43, 0x03... | contacts_db_get_serialized_contact((Uuid *)&contact, &serialized_contact) | ;
cl_assert_equal_i(serialized_contact->flags, 0);
cl_assert_equal_i(serialized_contact->num_attributes, 1);
cl_assert_equal_i(serialized_contact->num_addresses, 2);
contacts_db_free_serialized_contact(serialized_contact);
}
|
/*
* 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_ASSERT_TASK(PebbleTask_KernelBackground) | ;
if (!bt_ctl_is_bluetooth_running()) {
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Pairabilty state: LE=%u, Classic=%u",
s_allow_ble_pairing_refcount, s_allow_bt_pairing_refcount);
bool is_ble_pairable_and_discoverable = (s_allow_ble_pairing_refcount > 0);
bt_driver_le_pairability_set_enabled(is_bl... |
_SMARTSTRAP
// Event handler
////////////////////////////////////////////////////////////////////////////////
static void prv_app_smartstrap_event(PebbleEvent *e, void *context) {
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
PebbleSmartstrapEvent event = e->smartstrap;
if (event.type == S... | (service_id, attribute_id, buffer, buffer_length) | ) {
applib_free(buffer);
return NULL;
}
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
state->num_attributes++;
prv_state_init();
return (SmartstrapAttribute *)buffer;
#else
return NULL;
#endif
}
void app_smartstrap_attribute_destroy(SmartstrapAttribute *attr) {
#if USE_SMARTS... |
if (is_active_mode == s_comm_is_running) {
prv_send_state_change_event();
} |
} else if (!s_comm_is_running && s_first_run) {
PBL_LOG(LOG_LEVEL_DEBUG, "Shutting down the BT stack on boot");
bt_driver_power_down_controller_on_boot();
}
s_first_run = false;
mutex_unlock(s_comm_state_change_mutex);
}
void bt_ctl_set_enabled(bool enabled) {
if (!s_comm_initialized) {
PBL_LOG... | |
/*
* 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... | {
const PebbleProcessMd *md = worker_manager_get_current_worker_md();
if (md == NULL) {
return false;
}
return (uuid_equal(&md->uuid, &app_manager_get_current_app_md()->uuid));
} |
// ---------------------------------------------------------------------------------------------------------------
// Display the confirmation dialog for switching into the worker
static void prv_switch_worker(void *data) {
AppInstallId install_id = (AppInstallId)data;
WindowStack *window_stack = modal_manager_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (bt_dialog, 0, sizeof(BtConnDialog)) | |
/*
* 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... | (e->app_outbox_sent.sent_handler) | |
/*
* 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_fb, &DISP_FRAME.size) | ;
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers *... |
, ALARM_KIND_WEEKDAYS, s_weekday_schedule);
bool custom_schedule1[7] = {true, false, true, false, false, true, true};
id = alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &custom_schedule1 });
prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_CUSTOM, custom_sc... | (schedule_8, alarm_day_text_8) | ;
cl_assert_equal_s(alarm_day_text_8, "Saturdays");
bool schedule_9[7] = {true, false, false, false, false, false, false};
char alarm_day_text_9[32] = {0};
alarm_get_string_for_custom(schedule_9, alarm_day_text_9);
cl_assert_equal_s(alarm_day_text_9, "Sundays");
}
void test_alarm__alarm_set_get_enabled(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... | (&icon_layer->layer, false) | ;
GRect from = icon_rect;
// Animate from off screen. We need to be at least -80, since that is our largest icon size.
const int16_t DISP_OFFSET = 80;
if (dialog->icon_anim_direction == DialogIconAnimationFromLeft) {
from.origin.x = -DISP_OFFSET;
} else if (dialog->icon_anim_direction == DialogIconAnimat... |
);
}
void test_alerts__phone_calls_only(void) {
cl_assert(alerts_get_mask() == AlertMaskAllOn);
alerts_set_mask(AlertMaskPhoneCalls);
// Should allow a phone call notification
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
// Should not allow any other notifications through
cl_assert(!alerts_... | (!alerts_should_notify_for_type(AlertReminder)) | ;
cl_assert(!alerts_should_vibrate_for_type(AlertReminder));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertReminder));
cl_assert(!alerts_should_notify_for_type(AlertOther));
cl_assert(... |
attempt fails because not in SessionOpen
ASSERT_JS_GLOBAL_EQUALS_B("hasError", false);
prv_simulate_transport_connection_event(true /* is_connected */);
prv_postmessageconnected_postmessagedisconnected_negotiate_to_open_session();
prv_assert_simple_test_object_pending();
prv_rcv_app_message_ack(APP_MSG_OK)... | memcpy(chunk->chunk_data, expected_json + payload_offset, TINY_CHUNK_SIZE) | ;
EXPECT_OUTBOX_MESSAGE_PENDING(TupletBytes(PostMessageKeyChunk,
(const uint8_t *) chunk, expected_size));
// Compare with hard-coded byte array, to catch accidental changes to the ABI:
const uint8_t raw_bytes_v1[] = {
0x08, 0x00, 0x00, 0x00, '}', '\0',
... |
erning permissions and
* limitations under the License.
*/
#include "pebble.h"
#include <inttypes.h>
// -------------------------------------------------------------------------------
// Defines
// Rect: left, top, width, height
#define STEPS_HEIGHT 45
#define STEPS_TOP ((DISP_ROWS - 3 * STEPS_HEIGHT)/2)
#if PBL_... | strcpy(data->debug_card.dialog_text, title) | ;
// Get History
time_t day_start = time_start_of_today();
for (int i = 0; i < 30; i++) {
HealthValue value = health_service_sum(metric, day_start, day_start + SECONDS_PER_DAY);
APP_LOG(APP_LOG_LEVEL_DEBUG, "%d: %d", i, (int)value);
char temp[32];
snprintf(temp, sizeof(temp), "\n%d: %d", i, (int)... |
e 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 distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or imp... | prv_call_ble_bonding_change_handlers(BLE_BONDING_ID, BtPersistBondingOpWillDelete) | |
eate(&config);
}
static void prv_property_animation_grect_update(Animation *animation,
const AnimationProgress progress) {
PropertyAnimationPrivate *property_animation = (PropertyAnimationPrivate *)animation;
if (property_animation) {
layer_set_frame(property_ani... | (&s_notification_window_data.action_button_layer, false) | ;
// Render the window
window_render(window, fake_graphics_context_get_context());
}
//! @note This must be a multiple of 8 so that we are word-aligned when using a 1-bit bitmap.
#define GRID_CELL_PADDING 8
static void prv_prepare_canvas_and_render_notification_windows(unsigned int num_down_scrolls) {
// Initi... |
n.y += (data->square_velocity_y * PIXEL_SPEED_PER_FRAME);
if (data->square.origin.y < 0 ||
data->square.origin.y + data->square.size.h > data->window.layer.bounds.size.h) {
data->square_velocity_y = data->square_velocity_y * -1;
}
} else if (shape == RECTANGLE) {
// Move the rect... | (ctx, data->line_p0, data->line_p1) | |
qual_i(pfs_close(fd), S_SUCCESS);
}
// the file system is full, lets delete a file
snprintf(file_name, sizeof(file_name), "file%d", num / 2);
fd = pfs_open(file_name, OP_FLAG_READ, 0, 0);
cl_assert(fd >= 0);
uint16_t target_start_page = test_get_file_start_page(fd);
pfs_close_and_remove(fd);
// lets f... | (fd, NULL, sizeof(buf)) | ;
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_write(fd, buf, sizeof(buf) / 2);
int off = sizeof(buf) / 2;
rv = pfs_write(fd, &buf[off], sizeof(buf) - off);
cl_assert(rv == (sizeof(buf) - off));
rv = pfs_seek(fd, 0, FSeekSet);
cl_assert(rv == 0);
memset(buf, 0x00, sizeof(buf));
uint8_t bigbuf[11];
... |
/*
* 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_LOG(LOG_LEVEL_INFO, "Not a snapshot, interpreting buffer as JS source code");
rv = jerry_eval((jerry_char_t *) buffer, buffer_size, false);
} |
bool error_occurred = jerry_value_has_error_flag(rv);
if (error_occurred) {
jerry_value_clear_error_flag(&rv);
rocky_log_exception("Evaluating JS", rv);
}
jerry_release_value(rv);
return !(error_occurred);
}
static void prv_rocky_deinit(void) {
app_heap_analytics_log_stats_to_app_heartbeat(true ... |
cl_assert(list_count(&a) == 3);
cl_assert(list_count(&b) == 3);
cl_assert(list_count(&c) == 3);
cl_assert(list_count_to_tail_from(&a) == 3);
cl_assert(list_count_to_tail_from(&b) == 2);
cl_assert(list_count_to_tail_from(&c) == 1);
cl_assert(list_count_to_head_from(&c) == 3);
cl_assert(list_count_to_head... | (list_find_prev(NULL, filter_odd, false, NULL) == NULL) | ;
}
void test_list__concatenate(void) {
ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL, c = LIST_NODE_NULL;
ListNode d = LIST_NODE_NULL, e = LIST_NODE_NULL, f = LIST_NODE_NULL;
cl_assert_equal_p(list_concatenate(&a, &b), &a);
cl_assert_equal_p(a.next, &b);
cl_assert_equal_p(b.prev, &a);
cl_assert_equal_... |
E_ID_ACTION_BAR_ICON_CHECK,
prv_alarms_app_opened_click_handler);
expandable_dialog_set_action_bar_background_color(expandable_dialog, ALARMS_APP_HIGHLIGHT_COLOR);
expandable_dialog_set_header(expandable_dialog, header);
#if defined(PBL_ROUND)
expandable_dialog_set_header_font(expandable_dialog,
... | prv_handle_deinit() | ;
}
const PebbleProcessMd* alarms_app_get_info() {
static const PebbleProcessMdSystem s_alarms_app_info = {
.common = {
.main_func = s_main,
.uuid = UUID_ALARMS_DATA_SOURCE,
},
.name = i18n_noop("Alarms"),
#if CAPABILITY_HAS_APP_GLANCES
.icon_resource_id = RESOURCE_ID_ALARM_CLOCK_TINY,
#e... |
, subscriber A at
//! 200ms, and subscriber B at 250ms, new samples will become available every
//! 200ms, so subscriber B's data buffer would not fill until 400ms, resulting
//! in a 150ms latency. This is how the legacy implementation worked as well
//! but is potentionally something we could improve in the future if... | system_task_add_callback(state->data_cb_handler, state->data_cb_context) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.