prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
, 0xf9},
.constructor = launcher_app_glance_alarms_create,
},
{ // Watchfaces
.uuid = {0x18, 0xe4, 0x43, 0xce, 0x38, 0xfd, 0x47, 0xc8,
0x84, 0xd5, 0x6d, 0x0c, 0x77, 0x5f, 0xbe, 0x55},
.constructor = launcher_app_glance_watchfaces_create,
},
{
// Workout
.uuid... | if (glance_in_cache) {
launcher_app_glance_update_current_slice(glance_in_cache);
// If necessary, update the slice expiration timer with the updated current slice
prv_update_slice_expiration_timer_if_necessary(service,
glance_in_cache->current_slice.expir... | |
ST_UUID, UUID_SIZE,
(uint8_t *)&app_glance, sizeof(app_glance)),
E_INVALID_ARGUMENT);
}
void test_app_glance_db__lower_version_blob_not_inserted(void) {
for (uint8_t version = 0; version < APP_GLANCE_DB_CURRENT_VERSION; version++) {
prv_check_invalid_v... | (app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&app_glance_with_slice_missing_expiration_time,
app_glance_with_slice_missing_expiration_time_size),
S_SUCCESS) | |
-----------------------
// Sample captured: 2015-10-05 15:46:25 local
AccelRawData *activity_sample_walk_100_pbl_25660_3(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25660_3
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
... | { 384, 232, -152},
{ 608, 288, -264},
{ 984, 320, -280},
// 5 seconds
{ 1160, 376, -368},
{ 1104, 392, -312},
{ 1112, 408, -280},
{ 1184, 400, -248},
{ 1248, 424, -240},
{ 1208, 408, -216},
{ 1248, 352, -192},
{ 1080, 296, -128},
{ 808, 200, -120},
{ 664, 168, -72... | |
));
cl_assert_equal_b(true, app_install_has_worker(bg_counter_id));
cl_assert_equal_b(false, app_install_has_worker(menu_layer_id));
cl_assert_equal_b(false, app_install_has_worker(CRAZY_ID));
}
void test_app_install_manager__is_hidden(void) {
cl_assert_equal_b(false, app_install_is_hidden(tictoc_id));
cl_... | (0, INIT_TIME) | ;
AppInstallEntry entry;
cl_assert(true == app_install_get_entry_for_install_id(sports_id, &entry));
// hidden before communication
cl_assert(true == app_install_entry_is_hidden(&entry));
// simulates multiple messages from app
for (int i = 0; i < 10; i++) {
// visible after communication
app_ins... |
/*
* 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_b(true, scroll_layer->paging.paging_disabled) | ;
cl_assert_equal_b(false, scroll_layer->paging.shadow_hidden);
scroll_layer->shadow_sublayer.clips = false;
cl_assert_equal_b(false, scroll_layer->paging.paging_disabled);
cl_assert_equal_b(false, scroll_layer->paging.shadow_hidden);
// Validate that shadow_hidden is same position as layer hidden in shadow... |
int32_t in_min,
int32_t in_max, int32_t progress) {
return out_min + (out_max - out_min) * (progress - in_min) / (in_max - in_min);
}
static void prv_draw_banner_round(NotificationLayout *notification_layout, GContext *ctx,
const GRe... | PBL_IF_ROUND_ELSE(true, false) | |
nclude "util.h"
#include "clar.h"
#include <stdio.h>
// Helper Functions
////////////////////////////////////
#include "test_graphics.h"
#include "${BIT_DEPTH_NAME}/test_framebuffer.h"
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
static FrameBu... | (&ctx, fb) | ;
layer_set_update_proc(&layer, &across_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);... |
/*
* 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... | quick_launch_is_enabled(button) | ) {
return;
}
AppInstallId app_id = quick_launch_get_app(button);
if (app_id == INSTALL_ID_INVALID) {
app_id = app_install_get_id_for_uuid(&quick_launch_setup_get_app_info()->uuid);
}
prv_launch_app_via_button(&(AppLaunchEventConfig) {
.id = app_id,
.common.reason = APP_LAUNCH_QUICK_LAUNCH,
... |
/*
* 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(window) | |
ER_MINUTE, RoundTypeAlwaysDown) / SECONDS_PER_MINUTE;
const char *str_fmt;
if (capitalized) {
str_fmt = i18n_noop("%lu MIN AGO");
} else if (num_minutes == 1) {
str_fmt = i18n_noop("%lu minute ago");
} else {
str_fmt = i18n_noop("%lu minutes ago");
}
snprintf(buffer, buf_size,... | (void, sys_clock_get_timezone, char *timezone, const size_t buffer_size) | {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(timezone, TIMEZONE_NAME_LENGTH);
}
clock_get_timezone_region(timezone, buffer_size);
}
typedef struct daypart_message {
const uint32_t hour_offset; // hours from 12am of current day
const char* const message; // text containing daypart
} ... |
/*
* 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... | floor( 0.0001) | == 0.0);
cl_assert(floor(-0.0001) == -1.0);
cl_assert(isnan(floor(NAN)));
cl_assert(isinf(floor(INFINITY)));
}
|
/*
* 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... | kino_reel_create_with_resource_system(res_info->res_app_num, res_info->res_id) | ;
const KinoReelType reel_type = kino_reel_get_type(reel);
if ((reel_type != KinoReelTypeGBitmap) && (reel_type != KinoReelTypePDCI)) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Invalid published icon type");
is_valid = false;
} else {
const size_t resource_size = kino_reel_get_data_size(reel);
if (resource_... |
ay_count_spawn * duration_a);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(spawn);
// Start A
prv_advance_to_ms_with_timers(start_ms + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s... | (prv_count_handler_entries(&s_teardown_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_setup_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 0)... |
clude "console/prompt.h"
#include "drivers/rtc.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "services/common/comm_session/session.h"
#include "services/common/i18n/i18n.h"
#include "services/common/regular_timer.h"
#include "services/normal/alarms/alarm.h"
#include "services/normal/timezone_dat... | if (rule->hour >= HOURS_PER_DAY) {
time_tm.tm_mday += rule->hour / HOURS_PER_DAY;
uxtime = mktime(&time_tm);
gmtime_r(&uxtime, &time_tm);
} |
if (rule->flag & TIMEZONE_FLAG_STANDARD_TIME) { // Standard time (not wall time)
time_tm.tm_gmtoff = tz_info->tm_gmtoff;
time_tm.tm_isdst = 0;
} else if (rule->flag & TIMEZONE_FLAG_UTC_TIME) { // UTC
time_tm.tm_gmtoff = 0;
time_tm.tm_isdst = 0;
} else { // Wall time
time_tm.tm_gmtoff = tz_in... |
ata->pin_window, &state->pin, state->current_day);
// match the card background color
const LayoutColors *colors = layout_get_colors((LayoutLayer *)timeline_layout);
window_set_background_color(&data->timeline_window, colors->bg_color);
// animate the card from the right
#if !PLATFORM_TINTIN
TimelineLayout ... | prv_hide_day_sep(data) | ;
return true;
}
return false;
}
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
TimelineAppData *data = context;
prv_attempt_hide_day_sep(data);
if (!prv_set_state(data, TimelineAppStatePushCard)) {
return;
}
TimelineIterState *state = timeline_model_get_c... |
equired by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#incl... | (s_accel_manager_mutex) | ;
}
static void prv_shake_remove_subscriber_cb(PebbleTask task) {
mutex_lock_recursive(s_accel_manager_mutex);
{
PBL_ASSERTN(s_shake_subscribers_count > 0);
if (--s_shake_subscribers_count == 0) {
PBL_LOG(LOG_LEVEL_DEBUG, "Stopping accel shake service");
accel_enable_shake_detection(false);
... |
har *buffer, int buf_size, time_t timestamp) {
if (buffer) {
strncpy(buffer, "Today", buf_size);
buffer[buf_size - 1] = '\0';
}
}
void clock_get_since_time(char *buffer, int buf_size, time_t timestamp) {
if (buffer) {
strncpy(buffer, "15 minutes ago", buf_size);
buffer[buf_size - 1] = '\0';
}
}... | attribute_list_add_cstring(&attr_list, AttributeIdTitle, config->title) | ;
}
if (config->subtitle) {
attribute_list_add_cstring(&attr_list, AttributeIdSubtitle, config->subtitle);
}
if (config->location_name) {
attribute_list_add_cstring(&attr_list, AttributeIdLocationName, config->location_name);
}
if (config->body) {
attribute_list_add_cstring(&attr_list, Attribute... |
ay) || (!next)) {
// No relationship bar shown
return RelationshipBarTypeNone;
}
const time_t current_end = current->end_time;
if ((next->timestamp > current_end) && (current->current_day == next->current_day)) {
// Next pin starts after the end of the current pin
return RelationshipBarTypeFreeTi... | animation_set_delay(prev_rel_bar_anim, 0) | ;
animation_set_duration(prev_rel_bar_anim, duration / 3);
}
return prev_rel_bar_anim;
}
#define REL_BAR_CURR_OVERLAP_START_OFFSET 10
#define REL_BAR_CURR_ANIM_DELAY(delay) ((2 * delay) / 3)
#define REL_BAR_CURR_ANIM_DURATION(duration) ((2 * duration) / 3)
// Create current rel bar animation
static Animation ... |
&action_group);
i18n_free_all(¬if_attr_list);
attribute_list_destroy_list(¬if_attr_list);
attribute_list_destroy_list(&dismiss_action_attr_list);
attribute_list_destroy_list(&open_app_action_attr_list);
return item;
}
// ------------------------------------------... | activity_get_metric(ActivityMetricSleepState, 1, &sleep_state) | ;
return sleep_state;
}
// ------------------------------------------------------------------------------------------------
// Checks the common parameters for a given insight to see if it should be triggered
static bool prv_reward_check_common(const ActivityInsightSettings *insight_settings,
... |
ppId_AppWithInvalidSDKVersion,
TimelineResourceTestAppId_ValidApp,
TimelineResourceTestAppIdInvalid,
TimelineResourceTestAppIdCount = TimelineResourceTestAppIdInvalid - 1
} TimelineResourceTestAppId;
static const TimelineResourceTestAppData s_test_apps[TimelineResourceTestAppIdCount] = {
{
.install_entry ... | {
PBL_ASSERTN(entry);
if (uuid_equal(&entry->uuid, &(Uuid)UUID_SYSTEM)) {
return SYSTEM_APP;
} else {
return entry->install_id;
}
} |
// Setup
/////////////////////////
void test_timeline_resources__initialize(void) {
s_is_app_published_resource_invalid = false;
}
// Tests
/////////////////////////
void test_timeline_resources__get_id_system(void) {
AppResourceInfo res_info;
// Calling the function with an invalid TimelineResourceId shoul... |
/*
* 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... | evented_timer_exists((EventedTimerID)timer) | ) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Timer %u does not exist", (unsigned)timer);
return;
}
if (!evented_timer_is_current_task((EventedTimerID)timer)) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Invalid timer %u used in app_timer_reschedule", (unsigned)timer);
syscall_failed();
}
}
evented_timer... |
LOG(LOG_LEVEL_WARNING, "prv_check_initialized called when hc_protocol is not initialized, "
"state: %d", state);
}
return is_initialized;
}
static TickType_t prv_remaining_ticks(TickType_t timeout_ticks, TickType_t start_ticks) {
const TickType_t now = xTaskGetTickCount();
const TickType_t elapsed ... | {
if (!prv_check_initialized()) {
return false;
}
HcProtocolMessage *message = prv_create_message(endpoint_id, command_id, request_payload,
request_payload_length);
const bool rv = hc_protocol_enqueue(message);
kernel_free(message);
return rv;
} |
#if !BT_CONTROLLER_BUILD
static HcExpectation *prv_set_expectation_for_request(const HcProtocolMessage *request_message) {
SemaphoreHandle_t semaphore = xSemaphoreCreateBinary();
PBL_ASSERTN(semaphore);
HcExpectation *expectation = kernel_malloc_check(sizeof(HcExpectation));
*expectation = (HcExpectation) {
... |
ct_field(now, "getSeconds");
jerry_value_t getMinutes = jerry_get_object_field(now, "getMinutes");
jerry_value_t getHours = jerry_get_object_field(now, "getHours");
jerry_value_t getDate = jerry_get_object_field(now, "getDate");
jerry_value_t result_seconds = jerry_call_function(getSeconds, now, NULL, 0);
je... | jerry_get_number_value(result_year) | , 116.0);
jerry_release_value(result_year);
jerry_release_value(result_month);
jerry_release_value(result_date);
jerry_release_value(result_hours);
jerry_release_value(result_minutes);
jerry_release_value(result_seconds);
jerry_release_value(getYear);
jerry_release_value(getMonth);
jerry_release_valu... |
1421020800, // midnight jan 12, 2015 UTC
.duration = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.all_day = 1,
.layout = LayoutIdTest,
},
.attr_list = {
.num_attributes = 0,
.attributes = NULL,
},
.action_group = {
.num_actions = 0,
.act... | (&state.pin.header.id, &s_items[1].header.id) | );
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
// check rollover behaviour
cl_assert(!iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
cl_assert(state.node);
cl_assert(iter_prev(&iterator)... |
rAppGlanceStructured *structured_glance) {
LauncherAppGlanceSettings *settings_glance =
launcher_app_glance_structured_get_data(structured_glance);
return NULL_SAFE_FIELD_ACCESS(settings_glance, title, NULL);
}
static void prv_charging_icon_node_draw_cb(GContext *ctx, const GRect *rect,
... | if (size_out) {
*size_out = GSize(battery_silhouette_icon_size.w, settings_glance->subtitle_font_height);
} |
}
static void prv_battery_percent_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *node, UNUSED const GRect *box,
UNUSED const GTextNodeDrawConfig *config, UNUSED bool render, char *buffer, size_t buffer_size,
void *user_data) {
LauncherAppGlanceStructured *structured_glance = user_data... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_list_mutex) | ;
// We want to run any tasks we've skipped over.
prv_timer_callback(NULL);
}
// --------------------------------------------------------------------------------------------
void cron_service_init(void) {
PBL_ASSERTN(s_list_mutex == NULL);
s_list_mutex = mutex_create();
s_scheduled_jobs = NULL;
regular_... |
/*
* 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 (recognizer_get_state(recognizer->fail_after) != RecognizerState_Failed) {
return false;
}
if (!recognizer->subscriber.filter) {
return true;
}
return recognizer->subscriber.filter(recognizer, touch_event);
} |
static void prv_send_subscriber_event(Recognizer *recognizer) {
RecognizerEvent event;
switch (recognizer->state) {
case RecognizerState_Started:
event = RecognizerEvent_Started;
break;
case RecognizerState_Updated:
event = RecognizerEvent_Updated;
break;
case RecognizerState... |
/*
* 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_cache_buffer[0], &s_test_item[0], sizeof(TestCacheItem)) | ;
cl_assert_equal_m(&s_cache_buffer[1], &s_test_item[2], sizeof(TestCacheItem));
cl_assert_equal_m(&s_cache_buffer[2], &s_test_item[1], sizeof(TestCacheItem));
circular_cache_push(&s_test_cache, &s_test_item[1]);
cl_assert_equal_m(&s_cache_buffer[0], &s_test_item[1], sizeof(TestCacheItem));
cl_assert_equal_m... |
_equal_b(false, app_install_is_watchface(bg_counter_id));
cl_assert_equal_b(false, app_install_is_watchface(menu_layer_id));
cl_assert_equal_b(false, app_install_is_watchface(CRAZY_ID));
}
void test_app_install_manager__is_watchface_via_entry(void) {
cl_assert_equal_b(true, prv_app_install_is_watchface(tictoc_... | app_install_get_md(bg_counter_id, false) | ;
cl_assert(bg_counter_md != NULL);
cl_assert_equal_b(true, bg_counter_md->has_worker);
cl_assert_equal_i(ProcessTypeApp, bg_counter_md->process_type);
cl_assert_equal_i(ProcessStorageFlash, bg_counter_md->process_storage);
app_install_release_md(bg_counter_md);
const PebbleProcessMd *bg_counter_md_worker ... |
/*
* 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_m(&s_cache_buffer[0], &s_test_item[0], sizeof(TestCacheItem)) | ;
cl_assert_equal_m(&s_cache_buffer[1], &ZERO_ITEM, sizeof(TestCacheItem));
cl_assert_equal_m(&s_cache_buffer[2], &ZERO_ITEM, sizeof(TestCacheItem));
circular_cache_push(&s_test_cache, &s_test_item[2]);
cl_assert_equal_m(&s_cache_buffer[0], &s_test_item[0], sizeof(TestCacheItem));
cl_assert_equal_m(&s_cache_... |
ve layer becomes non-null
e.type = TouchEvent_Touchdown;
s_next_state = RecognizerState_Completed;
s_idx_to_change = 0;
s_active_layer = &layer_a;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) { 0 }, 1, &s_recognizers_handled);
prv_compare_recognizers_proce... | (&layer_a, &GRectZero) | ;
layer_add_child(root, &layer_a);
manager.window = &window;
manager.active_layer = &layer_a;
recognizer_add_to_list(r1, &layer_a.recognizer_list);
recognizer_add_to_list(r2, &layer_a.recognizer_list);
RecognizerManager manager2;
recognizer_set_manager(r1, &manager2);
recognizer_manager_deregister_r... |
inside_rect->origin.x;
rect->origin.y = ((inside_rect->size.h - rect->size.h) / 2) + inside_rect->origin.y;
return;
}
case GAlignTopLeft: {
rect->origin.x = inside_rect->origin.x;
rect->origin.y = + inside_rect->origin.y;
return;
}
case GAlignTopRight: {
rect->origin.... | {
if (rect->size.w.raw_value < 0) {
rect->origin.x.raw_value += rect->size.w.raw_value;
rect->size.w.raw_value = -rect->size.w.raw_value;
}
if (rect->size.h.raw_value < 0) {
rect->origin.y.raw_value += rect->size.h.raw_value;
rect->size.h.raw_value = -rect->size.h.raw_value;
}
} |
bool gcolor_is_transparent(GColor8 color) {
// Mimic a "closest color" behaviour, since we do not have blending.
return (color.a <= 1);
}
GColor8 gcolor_closest_opaque(GColor8 color) {
if (gcolor_is_transparent(color)) {
return GColorClear;
}
color.a = 3;
return color;
}
static int32_t prv_get_lumin... |
/*
* 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... | atoi("2147483647") | , 2147483647); // last valid value
cl_assert_equal_i(atoi("4294967287"), (int)4294967287); // signed integer overflow
// ((2147483648 * 10) + 1) & 0xFFFFFFFF
cl_assert_equal_i(atoi("21474836481"), 1);
// ((2147483647 * 10) + 1) & 0xFFFFFFFF
cl_assert_equal_i(atoi("21474836471"), (int)4294967287);
// -1 * ((... |
obile) {
if (!notification_storage_get(id, item)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to read notification");
goto cleanup;
}
} else if (type == NotificationReminder) {
// validate reminder
int rv = reminder_db_read_item(item, id);
if (rv != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_ERROR, "... | timeline_item_free_allocated_buffer(&reminder) | |
r that the watch must poll the phone for its status if not iOS 9+ (using PP messages).
//! - On iOS 9, ANCS tells us when the phone stops ringing
//! - The watch can pickup / decline a call using ANCS actions
//! - We don't show the ongoing call UI because we must continue to poll so that we know when the
//! call en... | prv_schedule_call_watchdog(600) | ;
phone_ui_handle_incoming_call(event->caller, prv_can_answer(), prv_should_show_ongoing_call_ui(),
s_call_source);
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_INCOMING_COUNT, AnalyticsClient_System);
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_PHONE_CALL_TIME, Analytic... |
y_value_t prop_name_val) {
if (!jerry_value_is_object(obj_val) || !jerry_value_is_string(prop_name_val)) {
return false;
}
return (bool)EM_ASM_INT({
var obj = __jerryRefs.get($0);
var name = __jerryRefs.get($1);
return obj.hasOwnProperty(name);
}, obj_val, prop_name_val);
}
bool jerry_d... | {
desc.set = __jerryRefs.get($11);
} |
if ($3 /* is_writable_defined */) {
desc.writable = Boolean($4 /* is_writable */);
}
if ($5 /* is_enumerable_defined */) {
desc.enumerable = Boolean($6 /* is_enumerable */);
}
if ($7 /* is_configurable */) {
desc.configurable = Boolean($8 /* is_configurable */);
... |
*context;
int num_will_change_calls;
int num_change_calls;
int num_did_change_calls;
GRect last_will_change_final_area;
AnimationProgress last_change_progress;
} UnobstructedAreaTestData;
UnobstructedAreaTestData s_data;
static void prv_will_change(GRect final_area, void *context) {
s_data.last_will_chang... | fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT) | |
activity_insights_init(rtc_get_time()) | ;
// Make sure we don't trigger as soon as we're awake
s_data.metric_history[ActivityMetricSleepState][0] = ActivitySleepStateAwake;
s_data.metric_history[ActivityMetricSleepExitAtSeconds][0] = 7 * SECONDS_PER_HOUR;
s_data.metric_history[ActivityMetricSleepStateSeconds][0] = 30 * SECONDS_PER_MINUTE;
activity... | |
e 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 <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "clar.... | cl_assert(!system_flash_erase(FLASH_BASE, 512 KiB, error_in_middle_cb,
&countdown)) | ;
cl_assert(flash_locked);
cl_assert_(countdown <= 0, "Callback not called enough times");
}
void malloc_flash_data(uint32_t size) {
flash_data_length = size;
flash_written_data = malloc(size * sizeof(uint8_t));
cl_assert(flash_written_data);
flash_written_flag = malloc(size * sizeof(bool));
cl_assert(f... |
found = true;
*uuid_out = header.common.id;
// Seek to the end of this item's payload (start of the next item)
if (pfs_seek(fd, header.payload_length, FSeekCur) < 0) {
break;
}
}
prv_file_close(fd);
return found;
}
static bool prv_compare_ancs_notifications(TimelineItem *notification,... | prv_file_open(OP_FLAG_READ) | ;
if (fd < 0) {
return;
}
Iterator iter;
NotificationIterState iter_state = {
.fd = fd
};
iter_init(&iter, (IteratorCallback)prv_iter_next, NULL, &iter_state);
while (iter_next(&iter)) {
uint8_t status = iter_state.header.common.status;
if (!(status & TimelineItemStatusDeleted)) {
... |
nt = 0,
}, false /* animated */);
TimelinePeek *peek = timeline_peek_get_peek();
const Layer *layer = &peek->layout_layer;
// Normally it is animated, but for this unit test, we don't request `animated`
cl_assert(layer->frame.origin.y < DISP_ROWS);
// Transition away from the watchface
s_is_watchface_run... | cl_assert(layer->frame.origin.y >= DISP_ROWS) | |
E-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the... | window_single_click_subscribe(BUTTON_ID_UP, (ClickHandler)click_handler) | ;
window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler)click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, (ClickHandler)click_handler);
(void)window;
}
static void handle_init(void) {
AnimatedDemoData *data = (AnimatedDemoData*) app_malloc_check(sizeof(AnimatedDemoData));
data->toggle = f... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
dialog->icon_anim_direction = direction;
} |
void dialog_set_vibe(Dialog *dialog, bool vibe_on_show) {
dialog->vibe_on_show = vibe_on_show;
}
void dialog_set_timeout(Dialog *dialog, uint32_t timeout) {
dialog->timeout = timeout;
}
void dialog_set_callbacks(Dialog *dialog, const DialogCallbacks *callbacks,
void *callback_context) ... |
{
send_golf_cmd(CMD_PREV);
}
static void down_click_handler(ClickRecognizerRef recognizer, AppData *data) {
send_golf_cmd(CMD_NEXT);
}
static void select_click_handler(ClickRecognizerRef recognizer, AppData *data) {
send_golf_cmd(CMD_SELECT);
}
static void config_provider(AppData *data) {
window_single_click... | (data->action_bar, BUTTON_ID_SELECT, data->click_bitmap) | ;
action_bar_layer_set_icon(data->action_bar, BUTTON_ID_DOWN, data->down_bitmap);
action_bar_layer_set_click_config_provider(data->action_bar,
(ClickConfigProvider) config_provider);
action_bar_layer_set_icon_press_animation(data->action_bar,
... |
applib/ui/ui.h"
#include "drivers/battery.h"
#include "kernel/pbl_malloc.h"
#include "popups/notifications/notification_window.h"
#include "process_state/app_state/app_state.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "shell/prefs.h"
#include "system/logging.h"
#include "system... | {
return backlight_is_enabled();
} | |
se.
*/
#include "clar.h"
#include "services/common/comm_session/session.h"
#include "services/common/bluetooth/bluetooth_persistent_storage.h"
#include "services/normal/blob_db/api.h"
#include "services/normal/blob_db/endpoint.h"
#include "services/normal/blob_db/sync.h"
#include <stdio.h>
// Fakes
///////////////... | {
s_expected_msg = s_dirty_dbs_response;
blob_db2_protocol_msg_callback(NULL, s_dirty_dbs_request, sizeof(s_dirty_dbs_request));
} |
static const uint8_t s_start_sync_request[] = {
BLOB_DB_COMMAND_START_SYNC, // cmd
0x12, 0x34, // token
BlobDBIdiOSNotifPref, // db id
};
static const uint8_t s_start_sync_response[] = {
BLOB_DB_COMMAND_START_SYNC_RESPONSE, // cmd
0x12, 0x34, // token
... |
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Common Setup
static void prv_create_window_common(WorkoutActiveWindow *active_window,
void *workout_data,
WorkoutController *workout_control... | status_bar_layer_init(status_layer) | |
t_did_appear(swap_layer, swap_layer->current, +1);
// refresh the layer down below in case we have jumped around in our data model
prv_refresh_next_layer(swap_layer);
}
static Animation *prv_create_swap_down_animation(SwapLayer *swap_layer) {
// Compute the animation distance
const GRect *prev_frame = &swap_l... | (swap_layer, full_swap) | ;
}
animation_set_handlers(animation, (AnimationHandlers) {
.started = (direction == ScrollDirectionDown) ? prv_swap_down_start : prv_swap_up_start,
.stopped = (direction == ScrollDirectionDown) ? prv_swap_down_complete : prv_swap_up_complete,
}, swap_layer);
swap_layer->animation = animation;
ani... |
ExecutingCommand;
static bool s_command_continues_after_return = false;
static ExecutingCommand s_executing_command = ExecutingCommandNone;
//! Currently used prompt context. This is set so that we know which response
//! and completion callbacks to use.
static PromptContext *s_current_context = NULL;
static void ... | {
cmd[cmd_len] = '\0';
char buffer[64];
prompt_send_response_fmt(buffer, sizeof(buffer), "Invalid command <%s>! Try 'help'", cmd);
prompt_command_finish();
} |
}
void prompt_context_execute(PromptContext *context) {
s_executing_command = ExecutingCommandContext;
prv_find_and_execute_command(context->buffer, context->write_index, context);
context->write_index = 0;
}
static void prv_execute_command_from_dbgserial(void *data) {
dbgserial_putstr("");
char* buffer ... |
/*
* 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... | settings_file_close(&settings_file) | ;
done:
return ((new_capabilities & capability) != 0);
}
static void prv_rewrite_cb(SettingsFile *old_file,
SettingsFile *new_file,
SettingsRecordInfo *info,
void *context) {
if (!info->val_len) {
return; // Cache for this app ha... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (max_num_items) | ),
.max_num_items = max_num_items,
.max_item_string_size = max_item_string_size,
};
return metric;
}
void metric_group_destroy(MetricGroup *metric_group) {
if (!metric_group) {
return;
}
task_free(metric_group->names);
task_free(metric_group->values);
task_free(metric_group->icons);
task_fr... |
e == WorkoutMetricType_Custom) {
// I seriously have no idea why the height is hardcoded to 40 and overflow is set to word
// wrap when there's a note that says the height is being set to 40 to avoid wrapping. Also,
// with a font size of 18, I don't know how it wouldn't wrap. This fixes the inconsistent
... | window_get_user_data(layer_get_window(layer)) | ;
WorkoutMetricType metric_type = WorkoutMetricType_None;
if (layer == &active_window->top_metric_layer) {
metric_type = active_window->top_metric;
} else if (layer == &active_window->middle_metric_layer) {
metric_type = active_window->middle_metric;
}
GColor bg_color = prv_get_bg_color_for_metric(m... |
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 distributed on a... | (GColorFromHEX(0x550055)) | .argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0000)).argb);
// contradiction with previous case - oh dear...
// cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xff5500)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa5500)).argb);
}
void test_graphics_colors__grays... |
////////////////////
enum SettingsDisplayItem {
SettingsDisplayLanguage,
SettingsDisplayBacklightMode,
SettingsDisplayMotionSensor,
SettingsDisplayAmbientSensor,
SettingsDisplayBacklightIntensity,
SettingsDisplayBacklightTimeout,
#if PLATFORM_SPALDING
SettingsDisplayAdjustAlignment,
#endif
NumSettingsD... | (sizeof(*data)) | ;
*data = (SettingsDisplayData){};
data->callbacks = (SettingsCallbacks) {
.deinit = prv_deinit_cb,
.draw_row = prv_draw_row_cb,
.select_click = prv_select_click_cb,
.num_rows = prv_num_rows_cb,
};
return settings_window_create(SettingsMenuItemDisplay, &data->callbacks);
}
const SettingsModul... |
R canvas = jerry_get_object_field(context_2d, ROCKY_CONTEXT2D_CANVAS);
{
JS_VAR client_width = jerry_create_number(layer->bounds.size.w);
JS_VAR client_height = jerry_create_number(layer->bounds.size.h);
jerry_set_object_field(canvas, ROCKY_CANVAS_CLIENTWIDTH, client_width);
jerry_set_object_field(can... | (
ROCKY_ARG(width),
) | ;
graphics_context_set_stroke_width(rocky_api_graphics_get_gcontext(), width);
return jerry_create_undefined();
}
JERRY_FUNCTION(prv_get_stroke_width) {
return jerry_create_number((double)rocky_api_graphics_get_gcontext()->draw_state.stroke_width);
}
static jerry_value_t prv_graphics_set_color(const jerry_lengt... |
s, value);
} else {
prv_update_stats(&weekday_stats, value);
}
prv_update_stats(&daily_stats, value);
}
// ----------------------------------------
// Compute each combination of agg/stat and compare to expected
for (HealthAggregation agg = HealthAggregationSum; agg <= HealthAggregationMax; ... | (min_value, value) | ;
max_value = MAX(max_value, value);
sum += value;
count++;
s_sys_activity_get_minute_history_values.out[0].records[i].heart_rate_bpm = value;
value++;
if (value > 200) {
value = 50;
}
}
for (unsigned i = 0; i < num_minutes_per_call; i++) {
min_value = MIN(min_value, value);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | layer_remove_from_parent(&s_canvas) | ;
}
|
/*
* 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... | text_layer_get_layer(&data->text_layer_2) | );
text_layer_enable_screen_text_flow_and_paging(&data->text_layer_2, inset);
const GSize max_size_2 =
text_layer_get_content_size(app_state_get_graphics_context(), &data->text_layer_2);
text_layer_set_size(&data->text_layer_1, GSize(scroll_bounds.size.w, max_size_2.h + padding));
// Setup paging before ... |
ate(&s_color_slide_animation_impl, NULL, &zero, &width));
s_phone_ui_data->bg_color.boundary = 0;
} else {
s_phone_ui_data->bg_color.right = color;
color_animation = property_animation_get_animation(
property_animation_create(&s_color_slide_animation_impl, NULL, &width, &zero));
s_phone_ui_dat... | (ctx, &GRect(s_phone_ui_data->bg_color.boundary, 0, layer->bounds.size.w,
layer->bounds.size.h)) | ;
#else
graphics_context_set_fill_color(ctx, DEFAULT_COLOR);
graphics_fill_rect(ctx, &layer->bounds);
#endif
}
//! Ring functionality
static void prv_ring(void *unused) {
PBL_LOG(LOG_LEVEL_DEBUG, "RING");
if (alerts_should_vibrate_for_type(AlertPhoneCall)) {
#if CAPABILITY_HAS_VIBE_SCORES
if (!s_phone_ui_d... |
/*
* 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... | date_util_is_leap_year(year) | ;
// date_util_get_max_days_in_month expects Jan == 1, but this function expects Jan == 0
int max_days = date_util_get_max_days_in_month(month + 1, is_leap_year);
return MIN(day, max_days);
}
int date_time_selection_step_year(int year, int delta) {
year += delta;
return CLIP(year, MIN_SELECTABLE_YEAR - STDT... |
cl_assert_equal_m(wildcard_bytes, glyph->data, glyph_size_bytes) | ;
}
void test_text_resources__test_gothic_wildcard(void) {
uint8_t wildcard_bytes[] = {0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x83, 0xc1, 0x60, 0x30, 0x18, 0x0c, 0xfe, 0x01};
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
int8_t hori... | |
/*
* 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_protocol) | ;
return &packet->information;
}
void pulse_push_send(void *buf, size_t length) {
PBL_ASSERT(length <= pulse_link_max_send_size() - sizeof(PushPacket),
"Packet to big to send");
// We're blindly assuming that buf is the same pointer returned by
// pulse_push_send_begin. If it isn't, we'll either c... |
r to move data out of, it would
// have been written directly to flash during dls_log. But, we can end up here because of a
// call to prv_write_all_sessions_to_flash() which iterates through ALL active sessions.
if (!session->data->buffer_storage) {
goto exit;
}
session->data->write_request_pending = fa... | last_whole_items_read_bytes = read_bytes;
*new_read_offset = read_offset;
}
} |
exit:
if (got_session_file) {
prv_release_session_file(logging_session);
}
if (last_whole_items_read_bytes < 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Nuking storage for session %d", logging_session->comm.session_id);
dls_storage_delete_logging_storage(logging_session);
}
return last_whole_items_read_byt... |
left_aa_offset, right_aa_offset,
min_valid_x, max_valid_x,
color);
}
void graphics_private_draw_horizontal_line_delta_aa(GContext *ctx,... | grect_get_max_x(&bitmap->bounds) | - 1);
const int16_t num_pix_data_row = max_x - min_x + 1;
const int16_t pixels_to_move = num_pix_data_row - abs_delta;
switch (bpp) {
case 1: {
// Note: this doesn't care about the bounding, because we don't have any round 1bpp
// devices to support, and it simplifies the code.
#if PB... |
ber(number_buffer, number_buffer_size, timestamp);
clock_get_time_word(word_buffer, word_buffer_size, timestamp);
}
static void prv_get_relative_all_day_string(char *buffer, int buffer_size, time_t timestamp) {
time_t today = time_util_get_midnight_of(rtc_get_time());
if (time_util_get_midnight_of(timestamp) == ... | {
// Always return a future timestamp, so if day was today, and
// minutes and hours already occurred, just make it tomorrow
cal.tm_mday++; // normalized by mktime
} |
cal.tm_hour = hour;
cal.tm_min = minute;
return mktime(&cal);
}
void command_timezone_clear(void) {
rtc_timezone_clear();
}
void command_get_time(void) {
char buffer[80];
char time_buffer[26];
prompt_send_response_fmt(buffer, 80, "Time is now <%s>", rtc_get_time_string(time_buffer));
}
void command_... |
me, uint16_t src_line_number) {
contents->message_type = 1; // Text
// Log the log level and the current task+privilege level
contents->log_level_char = pbl_log_get_level_char(log_level);
contents->task_char = pebble_task_get_char(task);
if (mcu_state_is_privileged()) {
contents->task_char = toupper(cont... | MIN(strlen(message), 128) | ;
const uint32_t required_space = sizeof(uint32_t) + sizeof(BufferedLogInfo) + message_length;
if (circular_buffer_get_write_space_remaining(&s_isr_log_buffer) < required_space) {
// Not enough space for the full message, just write an empty message with only the length
// word to indicate we're dropping t... |
Reset HR reading. It has expired
prv_reset_hr_data();
}
}
prv_unlock();
}
// ---------------------------------------------------------------------------------------
void workout_service_health_event_handler(PebbleHealthEvent *event) {
if (!workout_service_is_workout_ongoing()) {
return;
}
prv... | app_get_app_id() | , 1, hr_time_left, HRMFeature_BPM);
} else {
// No time left. Kill the subscription
sys_hrm_manager_unsubscribe(s_workout_data.hrm_session);
}
#endif // CAPABILITY_HAS_BUILTIN_HRM
prv_put_event(PebbleWorkoutEvent_FrontendClosed);
}
prv_unlock();
}
// --------------------------------------... |
= mutex_create_recursive();
}
static void copy_and_truncate(char *dest, const char *src, size_t src_length) {
size_t cropped_length = MIN(MUSIC_BUFFER_LENGTH - 1, src_length);
if (src) {
memcpy(dest, src, cropped_length);
}
dest[cropped_length] = 0;
}
static void prv_put_now_playing_changed_event(void) {... | (title, title_length, o) | ;
}
void music_update_track_artist(const char *artist, size_t artist_length) {
off_t o = offsetof(__typeof__(s_music_ctx), artist);
prv_update_string_and_put_event(artist, artist_length, o);
}
void music_update_track_album(const char *album, size_t album_length) {
off_t o = offsetof(__typeof__(s_music_ctx), alb... |
rants = GCornersAll,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerNone}
}));
// Tests for overflowing angles
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(20), TO_TRIG(1000)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerNone},
.full_qu... | (prv_calc_draw_config_ellipsis(TO_TRIG(180), TO_TRIG(360 + 90)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(180),GCornerBottomLeft},
.full_quadrants = (GCornersTop | GCornerBottomLeft),
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight}
})) | ;
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(270), TO_TRIG(360 + 180)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerTopLeft},
.full_quadrants = (GCornersTop | GCornerBottomRight),
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(180),GCornerBottomL... |
ata->alarm_hour = time_picker_window->time_data.hour;
data->alarm_minute = time_picker_window->time_data.minute;
if (data->creating_alarm) {
app_window_stack_push(&data->day_picker_window, true);
} else {
alarm_set_time(data->alarm_id, data->alarm_hour, data->alarm_minute);
app_window_stack_remove(&t... | (sizeof(AlarmEditorData)) | |
*layout) {
if (!layout) {
return;
}
layer_remove_from_parent((Layer *)layout);
if (layout && swap_layer->callbacks.layout_removed_handler) {
swap_layer->callbacks.layout_removed_handler(swap_layer, layout, swap_layer->context);
}
}
//! Calls the fetch layout callback and gets the layout that is at ... | (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
//! primary layer.
static void prv_update_arrow(SwapLayer *swap_layer) {
bool hide_it = true;
// If there is a current layout, then we... |
fd_free(fd);
} else {
PFS_FD(fd).fd_status = FD_STATUS_IN_USE;
}
return (res);
}
int pfs_open(const char *name, uint8_t op_flags, uint8_t file_type,
size_t start_size) {
size_t namelen = (name == NULL) ? 0 : strlen(name);
if ((namelen < 1) || (namelen > FILE_MAX_NAME_LEN)) {
return (E_INVALID_AR... | pfs_close_and_remove(fd) | ;
}
static int prv_copy_sector_to_gc_file(uint16_t *free_page,
uint16_t sector_start_page, uint32_t sectors_active) {
size_t num_entries = __builtin_popcount(sectors_active);
// We need space to store all the data for active pages, the
// page header for all pages, and the GCData struct
size_t space_neede... |
_current(PebbleTask_KernelMain);
}
void test_window_stack__cleanup(void) {
stub_pebble_tasks_set_current(PebbleTask_App);
app_window_stack_pop_all(false);
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
modal_manager_pop_all();
fake_animation_cleanup();
cl_assert_equal_i(fake_pbl_malloc_num_net_... | (windows[1]->on_screen, false) | ;
cl_assert_equal_i(windows[2]->on_screen, true);
window_stack_pop_all(stack, true);
cl_assert_equal_i(window_stack_count(stack), 0);
cl_assert_equal_i(windows[0]->on_screen, false);
cl_assert_equal_i(windows[1]->on_screen, false);
cl_assert_equal_i(windows[2]->on_screen, false);
for (uint8_t idx = 0; ... |
lude "util/math.h"
extern void comm_session_send_queue_cleanup(CommSession *session);
// Fakes & Stubs
////////////////////////////////////////////////////////////////////////////////////////////////////
#include "fake_kernel_malloc.h"
#include "stubs_bt_lock.h"
#include "stubs_logging.h"
#include "stubs_passert.h"... | comm_session_send_queue_get_length(s_valid_session) | );
}
}
static void prv_add_jobs(int num_jobs) {
for (int i = 0; i < num_jobs; ++i) {
SessionSendQueueJob *job = prv_create_test_job(TEST_DATA, sizeof(TEST_DATA));
comm_session_send_queue_add_job(s_valid_session, &job);
cl_assert(job);
}
}
void test_session_send_queue__copy_empty_queue(void) {
uint... |
}
const size_t max_msg_length =
sender->length + (stripped_caption ? strlen(stripped_caption) : 0) +
MULTIMEDIA_INDICATOR_LENGTH + strlen(s_utf8_ellipsis) + 1;
// Sender and action message
int pos = snprintf((char *)buffer, max_msg_length, "%.*s %s",
sender->length, (char *)send... | {
attribute_copy(cur_attribute, &pbl_action->attr_list.attributes[i], buffer, buf_end);
cur_attribute++;
} |
return *buffer;
}
static void prv_populate_attributes(TimelineItem *item,
uint8_t **buffer,
const ANCSAttribute *title,
const ANCSAttribute *display_name,
const ANCSAttrib... |
tical_line_dotted(&ctx, GPoint(17, 0), 21);
graphics_draw_vertical_line_dotted(&ctx, GPoint(19, 0), 22);
graphics_draw_vertical_line_dotted(&ctx, GPoint(21, 0), MAX_NUM_ROWS - 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 0), MAX_NUM_ROWS + 1 );
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_N... | graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 0), MAX_NUM_ROWS + 1 ) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_odd_cols_no_clip")));
// Test to make sure drawing on all cols creates checkerboard pattern
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
for (int16_t col = 0; col < MAX_NUM_CO... |
ATA_CHAR_OFFSET:
return prv_handle_emulated_write(conn_idx, msg);
case EMULATED_DATA_CCCD_OFFSET: {
PPoGATTWorkAroundState *state = prv_get_state(conn);
return prv_handle_emulated_cccd_write(msg, state);
}
default:
goto unhandled;
}
unhandled:
return false;
}
void ppogatt_injec... | ble_gatts_add_characteristic(&uuid, GATT_PROP_WRITE_NO_RESP, ATT_PERM_WRITE,
data_wr_size,
enable_read_cb_flag, NULL,
&ctx->att_hdl.data_wr) | |
memory_segment_get_size(&worker_ram) - stack_guard_size);
MemorySegment worker_segment;
PBL_ASSERTN(memory_segment_split(&worker_ram, &worker_segment,
worker_segment_size));
PBL_ASSERTN(memory_segment_split(&worker_segment, NULL, stack_guard_size));
// No (accessible)... | {
// Is there another worker set to switch to?
if (s_next_worker.md != NULL) {
worker_manager_launch_new_worker_with_args(s_next_worker.md, s_next_worker.args);
} else {
// Do we have a default worker we should switch to that is different from the previous worker?
AppInstallId default_id = worker_mana... |
// ------------------------------------------------------------------------------------------------
void worker_manager_handle_remove_current_worker(void) {
s_worker_crash_relaunches_disabled = true;
worker_manager_close_current_worker(true);
}
// ------------------------------------------------------------------... |
ht_icon_spacing;
int16_t text_inset_single;
int16_t text_inset_multi;
int16_t right_text_inset_with_icon;
} OptionMenuStyle;
static const OptionMenuStyle s_style_medium = {
#if PBL_RECT
.cell_heights[OptionMenuContentType_DoubleLine] = 56,
#endif
.right_icon_spacing = PBL_IF_RECT_ELSE(7, 35),
};
static cons... | prv_draw_selection_icon(option_menu, ctx, &remaining_rect,
is_chosen) | |
TTPacket * s_client_reset_complete;
static uint16_t s_client_reset_complete_size;
static int s_ppogatt_version;
static int s_tx_window_size;
static int s_rx_window_size;
static void prv_create_expected_reset_request(void) {
s_client_reset_request_size = sizeof(PPoGATTPacket) + sizeof(PPoGATTResetRequestClientIDPayl... | (characteristic,
(const uint8_t *) &expected_response, s_client_reset_complete_size,
GAPLEClientKernel, false /* is_response_required */) | |
s the frequency that our timer
// prescalar has to calculate. The duty cycle is defined by the TIM_Pulse parameter, which
// controls after which counter value the output waveform will become active. For example, a
// TIM_Pulse value of TIMER_PERIOD_RESOLUTION / 4 will result in an output waveform that will go
// activ... | PWR_TRACK_BACKLIGHT("ON", PWM_OUTPUT_FREQUENCY_HZ,
(desired_duty_cycle * 100) / TIMER_PERIOD_RESOLUTION) | ;
}
}
if (BOARD_CONFIG_BACKLIGHT.options & ActuatorOptions_IssiI2C) {
led_controller_backlight_set_brightness(brightness >> 8);
}
}
void command_backlight_ctl(const char *arg) {
const int bright_percent = atoi(arg);
if (bright_percent < 0 || bright_percent > 100) {
prompt_send_response("Invalid ... |
king store include the null terminator, so we add 1 to key_len
size_t key_len = strlen(entry->key) + 1;
if (settings_file_get_len(&file, entry->key, key_len) == entry->value_len) {
settings_file_get(&file, entry->key, key_len, entry->value, entry->value_len);
}
}
settings_file_close(&file);
}
/... | {
return false;
} |
if (value_len != entry->value_len) {
PBL_LOG(LOG_LEVEL_WARNING, "Attempt to read %s using invalid value_len of %"PRIu32"",
entry->key, (uint32_t)value_len);
return false;
}
bool success = false;
mutex_lock(s_mutex);
{
SettingsFile file = {{0}};
if (settings_file_open(&file, SHEL... |
in 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 implied.
* See the License f... | {
// We only care about app glance changes
return;
} |
prv_glance_event_put((Uuid *)blob_db_event->key);
}
static void prv_handle_app_cache_event(PebbleEvent *e, void *context) {
if (e->app_cache_event.cache_event_type == PebbleAppCacheEvent_Removed) {
Uuid app_uuid;
app_install_get_uuid_for_install_id(e->app_cache_event.install_id, &app_uuid);
app_glanc... |
_layer_set_icon_with_size(peek_layer, &first_timeline_layout->icon_info,
TimelineResourceSizeTiny, icon_from);
} else {
const bool use_pin = false;
prv_setup_peek_animation(data, &first_timeline_layout->icon_info, use_pin);
}
}
static void NOINLINE prv_setup_peek(TimelineA... | (timeline_layer, true) | ; // hide until the peek is over
layer_set_hidden((Layer *)&timeline_layer->day_separator, true);
layer_add_child(&window->layer, (Layer *)timeline_layer);
// peek layer
prv_init_peek_layer(s_app_data);
prv_setup_peek(s_app_data);
}
static void prv_timeline_window_appear(Window *window) {
TimelineAppData ... |
ude "process_management/app_manager.h"
#include "resource/resource_ids.auto.h"
#include "services/common/battery/battery_curve.h"
#include "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "system/logging.h"
#include "util/time/time.h"
typedef void (*DialogUpd... | if (old_dialog) {
dialog_pop(old_dialog);
} |
}
// Public API
////////////////////
void battery_ui_display_plugged(void) {
// If we're plugged in for charging, we want to alert the user of this,
// but we don't want to overlay ourselves over anything they may have
// on the screen at the moment.
WindowStack *stack = modal_manager_get_window_stack(ModalP... |
/*
* 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 (comm_session_is_valid(session)) {
rv = (session->protocol_capabilities & capability) != 0;
} |
bt_unlock();
return rv;
}
CommSessionCapability comm_session_get_capabilities(CommSession *session) {
CommSessionCapability capabilities = 0;
bt_lock();
if (comm_session_is_valid(session)) {
capabilities = session->protocol_capabilities;
}
bt_unlock();
return capabilities;
}
void comm_session_se... |
FUNCTIONS
//////////////////////////
static void prv_update_status_bar_color(SwapLayer *swap_layer) {
// Set initial values to assume failure
bool color_status_bar = false;
GColor bg_color = GColorClear;
// If there is a current layout, then fetch the color and whether or not the status bar
// should be co... | {
if (!finished) {
GRect end;
PropertyAnimation *property_animation = (PropertyAnimation *)animation;
Layer *layer = context;
property_animation_get_to_grect(property_animation, &end);
layer_set_frame(layer, &end);
}
} |
//! Creates an animation that moves a layer from its original frame to another frame that is offset
//! dy (change in origin.y).
static Animation *prv_create_anim_frame_scroll(Layer *layer, uint32_t duration, int16_t dy,
ScrollAnimationCurve *curve) {
if (!layer) {
... |
ogle LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* ... | pin_db_insert((uint8_t *)&item1.header.id, sizeof(TimelineItemId),
(uint8_t *)&item1, sizeof(TimelineItem)) | ;
pin_db_insert((uint8_t *)&item2.header.id, sizeof(TimelineItemId),
(uint8_t *)&item2, sizeof(TimelineItem));
pin_db_insert((uint8_t *)&item3.header.id, sizeof(TimelineItemId),
(uint8_t *)&item3, sizeof(TimelineItem));
pin_db_insert((uint8_t *)&item4.header.id, sizeof(TimelineItem... |
udged with the order and the fallback/default
PBL_ASSERTN(s_window_timeouts_ms[DEFAULT_IDX] == NOTIF_WINDOW_TIMEOUT_DEFAULT);
const uint32_t timeout_ms = alerts_preferences_get_notification_window_timeout_ms();
for (size_t i = 0; i < ARRAY_LENGTH(s_window_timeouts_ms); i++) {
if (s_window_timeouts_ms[i] == t... | (SettingsMenuItemNotifications) | ;
}
static void prv_settings_notifications_event_handler(PebbleEvent *event, void *context) {
switch (event->type) {
case PEBBLE_BATTERY_CONNECTION_EVENT:
// Redraw the menu so that the Vibration status will be re-rendered.
settings_menu_mark_dirty(SettingsMenuItemNotifications);
break;
def... |
const int pace_buf_size = 16;
char pace_str[pace_buf_size];
const int pace_s = health_util_get_pace(session->length_min * SECONDS_PER_MINUTE,
session->step_data.distance_meters);
int offset = health_util_format_hours_minutes_seconds(pace_str, pace_buf_size, pace_s,
... | i18n_get("Endurance", headings) | |
ady have one
dls_session = prv_get_dls_minute_session();
if (!dls_session) {
return;
}
}
// While we have whole minute records available for sending, send them.
while (prv_prepare_minute_data(uncertain_m,
sleep_start_utc,
sleep_l... | {
return 0;
} | |
(full_day_strings[latest_day_scheduled],
full_day_strings) | ;
strcpy(alarm_day_text, full_day_string);
i18n_free(full_day_strings[latest_day_scheduled], full_day_strings); // copied in above.
} else if (num_days_scheduled > 1) {
// Write the shortened day strings, remove last ','
alarm_day_text[strnlen(alarm_day_text, 28) - 1] = 0;
}
}
// ------------------... | |
32},
{ -48, 568, 832},
{ -48, 584, 800},
{ -24, 592, 808},
{ -48, 616, 792},
{ -40, 624, 832},
{ 32, 592, 912},
{ 216, 512, 1064},
{ 152, 456, 936},
{ -24, 424, 552},
{ -128, 504, 824},
// 135 seconds
{ -176, 544, 912},
{ -176, 600, 968},
{ -88, 576, 1000},
{ ... | { 400, 1312, -440},
{ 296, 792, -320},
{ 408, 920, -248},
{ 384, 904, -168},
{ 376, 968, -120},
{ 320, 1000, -72},
{ 264, 1056, -40},
{ 224, 1104, -24},
{ 208, 1048, -32},
{ 192, 1024, -48},
{ 224, 1056, -32},
{ 256, 1032, -32},
{ 272, 992, -40},
{ 264, 992, -80},... |
{ 264, 1000, -96},
// 143 seconds
{ 272, 1040, -72},
{ 248, 1056, -88},
{ 288, 968, -80},
{ 360, 1000, -32},
{ 376, 944, -48},
{ 336, 1008, -80},
{ 280, 984, -72},
{ 264, 1056, -72},
{ 280, 1024, -72},
{ 312, 1024, -96},
{ 304, 1016, -120},
{ 312, 952, -128},
... |
/*
* 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_s(written_hw_version2, hw_version) | ;
// Write third time
const char* written_hw_version3 = "OPQRSTU";
command_hwver_write(written_hw_version3);
hw_version = mfg_get_hw_version();
cl_assert_equal_s(written_hw_version3, hw_version);
// Write fourth time
const char* written_hw_version4 = "VWXYZ12";
command_hwver_write(written_hw_version4)... |
/*
* 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, &across_nx_layer_update_callback) | ;
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_nx_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.des... |
T_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax2_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
// AA = true, SW = 11
setup_test_aa_sw(&ctx, fb, ORIGIN... | (&ctx.dest_bitmap, "draw_round_rect_origin_r3_sw1_no_clip.${BIT_DEPTH_NAME}.pbi") | );
#endif
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Should ... |
t
if (!data->current_slice) {
data->current_slice = slice;
}
// Continue iterating through the slices
return true;
}
const int time_until_slice_expires = slice->expiration_time - data->current_time;
// Continue iterating through the slices if this slice expires in the past
if (time_until... | syscall_assert_userspace_buffer(uuid, sizeof(*uuid)) | ;
syscall_assert_userspace_buffer(glance, sizeof(*glance));
}
const bool success = (app_glance_db_insert_glance(uuid, glance) == S_SUCCESS);
if (success) {
prv_glance_event_put(uuid);
}
return success;
}
|
/*
* 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_KernelMain) | ;
prv_event_service_subscribe(subscription);
}
static bool prv_event_service_send_event(QueueHandle_t queue, PebbleEvent *e) {
PBL_ASSERTN(queue != NULL);
bool success = (xQueueSendToBack(queue, e, 0) == pdTRUE);
return success;
}
void event_service_handle_subscription(PebbleSubscriptionEvent *subscription) {... |
{ 1712, 568, -144},
{ 1936, 752, -64},
{ 2088, 840, -64},
{ 2360, 392, 216},
{ 2016, 64, -96},
{ 1600, -112, -104},
{ 1200, -48, -256},
{ 968, -104, -216},
{ 712, -248, -96},
{ 536, -200, -80},
{ 336, -160, -208},
{ 680, -32, -112},
{ 936, 40, -184},
{ 1344, 184, -3... | { 2064, 480, -56},
{ 1888, 192, -176},
{ 1520, 24, -128},
{ 1288, -32, -280},
{ 1048, -88, -256},
{ 744, -192, -208},
{ 632, -240, -192},
{ 520, -240, -216},
{ 376, -216, -272},
{ 760, -24, -136},
// 37 seconds
{ 1048, 88, -192},
{ 1664, 312, -376},
{ 2072, 432, -... | |
/*
* 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 we can't alloc 2kB put bytes is likely going to fail anyway so just fallback to default
// impl
return success;
} |
uint32_t curr_read_address = layout->end_address;
uint32_t stop_read_address = layout->start_address + layout->start_offset;
// Walk through the bank backwards. We rely on the NOR flash property that an "erased" byte will
// read 0xff. When we encounter a byte which is not 0xff, we have found data which has ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.