prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
arm_service_enable_alarms(bool enable) {
s_alarms_enabled = enable;
}
// ----------------------------------------------------------------------------------------------
const char *alarm_get_string_for_kind(AlarmKind kind, bool all_caps) {
const char *alarm_day_text = NULL;
switch (kind) {
case ALARM_KIND_EV... | if (scheduled_days[i % 7] == true) {
num_days_scheduled++;
latest_day_scheduled = i % 7;
const char *day_string = i18n_get(day_strings[i % 7], day_strings);
strcat(alarm_day_text, day_string);
strcat(alarm_day_text, ",");
i18n_free(day_strings[i % 7], day_strings); // copied in by st... | |
->bg_color.argb = (s_color_table[data->bg_color_index] | ALPHA_100);
} else if (data->property == PROPERTY_ALPHA) {
data->alpha = (data->alpha + 0x40) & ALPHA_100;
set_text_layers(data);
} else if (data->property == PROPERTY_COLOR_TABLE) {
if (s_color_table == color_table_hsv) {
s_color_table = co... | text_layer_create(GRect(2, 24, 64, 20)) | ;
layer_add_child(window_get_root_layer(window), text_layer_get_layer(data->fg_color_text));
data->fg_color_index = 8;
data->bg_text = text_layer_create(GRect(2, 48, 28, 20));
layer_add_child(window_get_root_layer(window), text_layer_get_layer(data->bg_text));
data->bg_color_text = text_layer_create(GRect(... |
} else if (state->test_entry.version == 2) {
sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d", &steps, &orientation, &vmc, &light);
} else if (state->test_entry.version == 3) {
sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d, %d", &steps, &orientation, &vmc,
&light, &plugg... | {
if (!prv_sample_discovery_next_file(&state->common)) {
return false;
}
} |
// Parse next set of samples in the current file
bool success = prv_parse_sleep_samples_file(state);
if (success) {
*entry = state->test_entry;
return true;
} else {
// No more in this file
fclose(state->common.file);
state->common.file = NULL;
}
}
}
// ----------... |
GPoint(x, y));
}
}
return mask;
}
typedef void (*HorizontalClippingMaskRecordFunc)(GContext *ctx, int16_t y, int16_t x1, int16_t x2,
GColor color);
static void prv_mask_record_hline_test_pattern(HorizontalClippingMaskR... | {
for (int16_t column_index = 0; column_index < num_dest_colors; column_index++) {
const int16_t starting_x = column_index * hline_applying_test_column_width;
for (int16_t x = starting_x; x < starting_x + hline_applying_test_column_width; x++) {
ctx->draw_state.stroke_color = (GColor) { .argb = ... |
}
static GDrawMask *prv_create_mask_for_hline_applying_test(GContext *ctx) {
// The initial transparency doesn't really matter since we're about to overwrite it
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparent);
cl_assert(mask);
const GSize mask_size = ctx->de... |
RT_JS_GLOBAL_EQUALS_S("s", "05");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {minute: 'numeric'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "4");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, {minute: '2-digit'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "04");
s_clock_is_24h_style = false;
EXECUTE_SCRIPT... | EXECUTE_SCRIPT("var d = new Date();") | ;
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {hour: 'numeric'});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "07/25/05, 8 PM");
}
void test_rocky_api_datetime__locale_string_options(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT("var d = new Date();");
s_clock_is_24h_style = false;
EXECUTE_SCRIPT("s = d... |
d* data) {
uint8_t *location = prv_heartbeat_get_array_location(heartbeat, metric, 0);
uint32_t size = analytics_metric_size(metric);
memcpy(location, data, size);
}
/////////
// Get
int64_t analytics_heartbeat_get(AnalyticsHeartbeat *heartbeat, AnalyticsMetric metric) {
uint8_t *location = prv_heartbeat_get_l... | {
if (written > BUF_LENGTH) {
PBL_LOG(LOG_LEVEL_DEBUG, "print buffer overflow by %lu bytes",
BUF_LENGTH - written);
continue;
}
int64_t val = analytics_heartbeat_get_array(heartbeat, metric, i);
const char *sep = (i == 0 ? "" : ", ");
if (val >= 0) {
wri... |
PBL_LOG(LOG_LEVEL_DEBUG, "%3" PRIu32 ": %s: %s", analytics_metric_offset(metric), name, buf);
}
}
void analytics_heartbeat_print(AnalyticsHeartbeat *heartbeat) {
switch (heartbeat->kind) {
case ANALYTICS_HEARTBEAT_KIND_DEVICE:
PBL_LOG(LOG_LEVEL_DEBUG, "Device heartbeat:");
prv_print_heartbeat(heartb... |
"After compaction: size: %d, num_bytes: %d, write_offset:%d",
(int)new_size, (int)session->storage.num_bytes, (int)session->storage.write_offset);
success = true;
exit:
kernel_free(tmp_buf);
if (new_storage.fd != DLS_INVALID_FILE) {
pfs_close_and_remove(new_storage.fd);
}
if (!success) {
... | (&session->storage, read_ptr, bytes_read) | ;
if (!success) {
goto exit;
}
shared_circular_buffer_consume(&session->data->buffer, &session->data->buffer_client,
bytes_read);
bytes_remaining -= bytes_read;
}
exit:
if (got_session_file) {
prv_release_session_file(session);
}
if (!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... | {
// If we are not currently sampling, turn on after ACTIVITY_DEFAULT_HR_PERIOD_SEC
const uint32_t turn_on_at = last_toggled_ts + ACTIVITY_DEFAULT_HR_PERIOD_SEC;
if (turn_on_at <= now_ts) {
should_toggle = true;
}
} |
if (should_toggle) {
// Check to see if the watch is face up or face down. If it is assume the watch is off wrist
// The z-axis is encoded in the 4 most significant bits of the orientation
const uint8_t z_axis = s_activity_state.last_orientation >> 4;
const bool watch_is_flat = z_axis == 0 || z_axis... |
const int duration_d = 220; // This one won't be scheduled yet
const int delay_d = 230;
const int delay_spawn = 170;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
// ... | prv_create_test_animation() | ;
animation_set_duration(a, duration_a);
animation_set_delay(a, delay_a);
animation_set_auto_destroy(a, auto_destroy);
animation_schedule(a);
Animation *b = prv_create_test_animation();
animation_set_implementation(b, &implementation);
animation_set_duration(b, duration_a);
animation_set_delay(b, delay... |
num_consec_request_failures++;
PBL_LOG(LOG_LEVEL_ERROR, "HC request timed out (endpoint:%d, command:%"PRIu8")",
end_id, cmd_id);
if (prv_check_initialized() && (s_num_consec_request_failures >= NUM_CONSEC_FAILURES)) {
core_dump_and_reset_or_reboot();
}
}
return response;
}
HcProtocol... | prv_unlock() | ;
return false;
}
// Make a heap copy if needed, or transfer ownership if the message is already heap-allocated:
HcProtocolMessage *response_heap_copy;
if (*should_free) {
*should_free = false;
response_heap_copy = message;
} else {
response_heap_copy = (HcProtocolMessage *) kernel_malloc_che... |
/*
* 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 (size_remaining <= 0) {
return 0;
} |
const bool has_last_terminator = (list->serialized_byte_length > 0);
char *cursor = &list->data[list->serialized_byte_length + (has_last_terminator ? 1 : 0)];
const size_t bytes_written = MIN(str_length, (size_t)size_remaining - 1);
strncpy(cursor, buffer, bytes_written);
cursor[bytes_written] = '\0';
list... |
/*
* 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... | ascii_hex_to_int(lsb) | ;
}
uintptr_t str_to_address(const char *address_str) {
unsigned int address_str_length = strlen(address_str);
if (address_str_length < 3) return -1; // Invalid address, must be at least 0x[0-9a-f]+
if (address_str[0] != '0' || address_str[1] != 'x') return -1; // Incorrect address prefix.
address_str += 2;
... |
AppData;
static void prv_handle_second_tick(struct tm *tick_time, TimeUnits units_changed) {
AppData *data = app_state_get_user_data();
if (data->test_complete) {
if (--data->seconds_remaining == 0) {
app_window_stack_pop(true);
}
return;
}
const bool test_passed = (data->buttons_pressed ==... | app_window_stack_push(window, true /* Animated */) | |
2, -72, -176},
{ 1192, -120, -296},
{ 1296, -104, -352},
{ 1176, -96, -376},
{ 1488, -96, -400},
{ 1296, -40, -400},
{ 1048, -56, -232},
{ 1144, 0, -240},
{ 1024, 0, -176},
{ 1040, -16, -152},
{ 1152, -8, -104},
{ 1176, 16, -48},
{ 1176, 16, -32},
{ 1200, 0, 0},
{... | { 936, -40, -184},
// 126 seconds
{ 912, 0, -208},
{ 936, -24, -216},
{ 984, -104, -192},
{ 1040, -136, -216},
{ 1072, -128, -208},
{ 1080, -112, -208},
{ 1096, -120, -200},
{ 1104, -120, -200},
{ 1040, -136, -160},
{ 1248, -152, -128},
{ 1488, -64, -232},
{ 1296,... | |
/*
* 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... | {
FSResourceAppData *data = window_get_user_data(window);
Layer *root_layer = window_get_root_layer(window);
gbitmap_init_with_resource(&data->bitmap, RESOURCE_ID_PUG);
bitmap_layer_init(&data->bitmap_layer, &root_layer->bounds);
bitmap_layer_set_bitmap(&data->bitmap_layer, &data->bitmap);
layer_add_child(r... |
static void push_window(FSResourceAppData *data) {
Window *window = &data->window;
window_init(window, WINDOW_NAME("FS Resource Demo"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
const bool animated = true;
app_window_stac... |
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 L... | {
PBL_ASSERT_TASK(PebbleTask_KernelMain);
bt_lock();
if (s_ams_client) {
const BLECharacteristic characteristic = s_ams_client->characteristics[0];
const BTDeviceInternal device = gatt_client_characteristic_get_device(characteristic);
if (!bt_device_is_invalid(&device.opaque)) {
GAPLEConnection ... |
static void prv_request_reduced_latency_cb(void *data) {
const bool reduced_latency = (uintptr_t)data;
const ResponseTimeState state = reduced_latency ? ResponseTimeMiddle : ResponseTimeMax;
prv_request_response_time(BtConsumerMusicServiceIndefinite, state, MAX_PERIOD_RUN_FOREVER);
}
static void prv_request_lo... |
"health.h"
#include "health_card_view.h"
#include "health_data.h"
#include "applib/app.h"
#include "applib/ui/dialogs/expandable_dialog.h"
#include "kernel/event_loop.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/modals/modal_manager.h"
#include "popups/health_tracking_ui.h"
#include "process_state/app_state/a... | health_card_view_push(health_app_data->health_card_view) | ;
// Finish up initializing the app a bit later. This helps reduce lag when opening the app
app_focus_service_subscribe_handlers((AppFocusHandlers){
.did_focus = prv_finish_initilization_cb,
});
}
//! Terminate application
static void prv_terminate(void) {
HealthAppData *health_app_data = app_state_get_us... |
};
text_node->user_data = context;
// graphics_text_node_create_text_dynamic() sets text_node->text.text to text_node->buffer,
// but since we are using the start of that buffer for our TextDynamicContext we must override
// text_node->text.text to the actual location of the text buffer here, if any... | (headings) | ;
if (num_headings == 0) {
return NULL;
}
const LayoutNodeTextConfig s_heading_config = {
.extent.node.type = LayoutNodeType_Text,
.font_key = prv_get_font_key_for_size(config->heading_style_font, config->size),
};
const LayoutNodeTextConfig s_paragraph_config = {
.extent.node.type = LayoutNo... |
nt_put_failure(queue_type, saved_lr, event);
#ifdef NO_WATCHDOG
enable_mcu_debugging();
while (1);
#endif
reset_due_to_software_failure();
}
return should_context_switch;
}
static bool prv_try_event_put(QueueHandle_t queue, PebbleEvent *event) {
PBL_ASSERTN(queue);
return (xQueueSendToBack(queue... | {
result = xQueueReceive(s_from_app_event_queue, event, 0);
} |
if (!result) {
result = xQueueReceive(s_from_worker_event_queue, event, 0);
}
// If there was nothing in the queue, return false. We are misusing the queue set by pulling events out
// from the s_kernel_event_queue queue before it's activated so likely, the activated queue was
// s_kernel_... |
/*
* 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... | (db_id == s_blobdb_id) | ;
return test_db_mark_synced(key, key_len);
}
|
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 <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "drivers/qe... | (qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)) | ;
prv_send_footer();
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
// -----------------------------------------------------------------------------
// Check after just part of the data
prv_send_hdr(QemuProtocol_SPP, 2*sizeof(msg_data));
cl_assert(!qemu_serial_priva... |
/*
* 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_init(status,
&GRect(5, 40, window->layer.bounds.size.w - 5, window->layer.bounds.size.h - 40)) | ;
text_layer_set_font(status, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(status, GTextAlignmentCenter);
text_layer_set_text(status, data->status_string);
layer_add_child(&window->layer, &status->layer);
if (has_hrm) {
data->hrm_event_info = (EventServiceInfo){
.... |
item_create(3, 2, (uint8_t[]) {1, 2}, buf_size, (uint8_t **)&buffer);
timeline_item_deserialize_payload(item, buffer, buf_size, s_payload_complete, sizeof(s_payload_complete));
cl_assert_equal_i(item->attr_list.num_attributes, 3);
cl_assert_equal_i(item->attr_list.attributes[0].id, AttributeIdTitle);
cl_assert_... | {
StringList *list = malloc(20);
memset(list, 0, 20);
// no data
list->serialized_byte_length = 0;
cl_assert_equal_i(0, string_list_count(list));
list->serialized_byte_length = 3;
// 4 empty strings
cl_assert_equal_i(4, string_list_count(list));
cl_assert_equal_s("", string_list_get_at(list, 0));
c... |
list->data[4] = '\0';
cl_assert_equal_i(2, string_list_count(list));
cl_assert_equal_s("ab", string_list_get_at(list, 0));
cl_assert_equal_s("c", string_list_get_at(list, 1));
// 3 strings (last two are is empty)
list->serialized_byte_length = 4;
list->data[0] = 'a';
list->data[1] = 'b';
list->data[... |
clock.
static ClockText prv_configure_clock_text(ClockTextType type, ClockTextLocation location,
GColor color, struct tm *tick_time) {
ClockText text = (ClockText) {
.location = location,
.color = color,
};
if (type == CLOCK_TEXT_TYPE_DATE) {
strftime(text.bu... | {
ClockModel model = prv_clock_model_default(tick_time);
watch_model_handle_change(&model);
} |
void watch_model_cleanup() {
tick_timer_service_unsubscribe();
}
static void prv_intro_animation_finished(Animation *animation) {
const time_t t = rtc_get_time();
prv_handle_time_update(pbl_override_localtime(&t), (TimeUnits)0xff);
tick_timer_service_subscribe(MINUTE_UNIT, prv_handle_time_update);
}
void w... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | accel_service_peek(&accel_data) | ) != 0) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Accelerometer error %i", error);
return;
}
static char accel_text[20];
#if !ACCEL_RAW_DATA
int32_t delta = prv_compute_delta_pos(&accel_data, &s_last_accel_data);
s_last_accel_data = accel_data;
snprintf(accel_text, sizeof(accel_text), "Accel delta: %"PRIu32, ... |
define DATALOGGING_DO_FLUSH_CHECK_INTERVAL_MINUTES 5
static bool prv_sends_enabled(void) {
return (s_sends_enabled_run_level && s_sends_enabled_pp);
}
// ----------------------------------------------------------------------------------------
//! Wrapper for data_logging_send_session that makes it usable in dls_li... | {
prv_remove_logging_session(logging_session);
return true;
} | else if (!empty && !inactive && (total_bytes < 8000)) {
return true; // nothing to flush yet
}
bool success = false;
uint8_t *buffer = kernel_malloc_check(DLS_ENDPOINT_MAX_PAYLOAD);
unsigned int num_bytes = DLS_ENDPOINT_MAX_PAYLOAD;
PBL_ASSERTN(logging_session->item_size <= num_bytes);
num_bytes -= (n... |
_value, so we need to subract one minute from the end to see if the start of this
// test minute is entirely within the sleep range.
bool was_sleeping = WITHIN(cbuf_record->utc_sec, sleep_start_utc,
sleep_end_utc - SECONDS_PER_MINUTE);
// Handle writing the record out to PF... | (s_alg_state->k_state, &sleep_stats) | ;
// If there are any uncertain minutes, they will always be at the end
int16_t uncertain_m = 0;
if (sleep_stats.uncertain_start_utc != 0) {
uncertain_m = (utc_now - sleep_stats.uncertain_start_utc) / SECONDS_PER_MINUTE;
}
if (uncertain_m > KALG_MAX_UNCERTAIN_SLEEP_M) {
PBL_LOG(LOG_LEVEL_ERROR, "Unex... |
d, e->app_fetch_request.id, has_worker);
}
static NOINLINE void prv_extended_event_handler(PebbleEvent* e) {
switch (e->type) {
case PEBBLE_APP_OUTBOX_MSG_EVENT:
e->app_outbox_msg.callback(e->app_outbox_msg.data);
return;
case PEBBLE_APP_FETCH_REQUEST_EVENT:
prv_handle_app_fetch_request_ev... | launcher_panic_get_current_error() | ? RunLevel_BareMinimum
: RunLevel_Normal;
services_set_runlevel(run_level);
// emulate a button press-and-release to turn on/off the backlight
light_button_pressed();
light_button_released();
#ifndef RECOVERY_FW
i18n_set_resource(RESOURCE_ID_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... | {
gdraw_command_list_scale(&image->command_list, image->size, to);
image->size = to;
} |
////////////////////
// attract to square
static int16_t prv_int_attract_to(int16_t value, int16_t bounds, int32_t normalized) {
const int16_t delta_0 = (int16_t) ((0 + 1) - value);
const int16_t delta_b = (int16_t) ((bounds - 1) - value);
const int16_t delta = ABS(delta_0) < ABS(delta_b) ? delta_0 : delta_b;... |
, NULL);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_text_flow__avoid_repeat_text_to_avoid_orphans(void) {
TextLayoutExtended layout = {
.flow_data = {
.perimeter.impl = &(GPerimeter){.callback=perimeter_for_display_round},
.perimeter.inset = 8,
.paging.p... | perimeter_for_circle(vertical_range, center, radius) | |
lable",
.in = { HealthMetricHeartRateBPM, now - 10, now, HealthAggregationMax,
HealthServiceTimeScopeOnce },
.out = { HealthServiceAccessibilityMaskAvailable }
},
{
.desc = "Valid time range with ScopeDaily and Max. NotSupported",
.in = { HealthMetricHeartRateBPM, now - ... | cl_assert_equal_b(true, fun(&session, HealthActivityMaskAll, now - (1 * SECONDS_PER_MINUTE),
now + (10 * SECONDS_PER_MINUTE))) | ;
}
void test_health__any_activity_accessible(void) {
const time_t now = rtc_get_time();
HealthServiceAccessibilityMask accessible;
// empty mask => not available
accessible = health_service_any_activity_accessible(HealthActivityNone,
now - (10 * SECONDS_P... |
ognizerState_Failed);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Failed);
// A touchdown occurs where no layers are touched while a window recognizer is active
e.type = TouchEvent_Touchdown;
s_active_layer = NULL;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_pr... | prv_compare_recognizers_processed(NULL, 0, &s_recognizers_reset) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersActive);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[... |
phics_fill_rect(ctx, &box);
}
}
// Draw border
if (compare) {
const GRect box = GRect(origin.x + 4*color_index_match - 1, origin.y - 1 + height_offset,
COLOR_BAR_WIDTH + 2, COLOR_BAR_HEIGHT + 2);
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_draw_rect(c... | GRect(124, 40 - 16, 20, 16) | |
_delete_activity_session(&session);
} else {
activity_sessions_prv_add_activity_session(&session);
}
}
// ------------------------------------------------------------------------------------------
// Used from settings_file_each() callback to read in a chunk based on the SettingsRecordInfo
// given to the cal... | prv_minute_file_get_settings_key(k_newest_valid_utc) | + 1,
.oldest_valid_utc = k_oldest_valid_utc,
.newest_valid_utc = k_newest_valid_utc,
};
// Feed in the saved data, reading chunks out of the saved minute data and compressing
// it into algorithm sleep minute structures.
status_t status = settings_file_each(file, prv_log_minute_file_minutes_cb, &conte... |
/*
* 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_WARNING, "incompatible JS snapshot version %"PRIu8" (expected: %"PRIu8")",
actual_version, expected_version) | ;
return false;
}
return jerry_is_snapshot(buffer + header_length, buffer_size - header_length);
#else
return false;
#endif
}
static bool prv_rocky_eval_buffer(const uint8_t *buffer, size_t buffer_size) {
jerry_value_t rv;
if (rocky_is_snapshot(buffer, buffer_size)) {
buffer += sizeof(ROCKY_EXPECTED... |
_config[PercentTierCount] = {
[PercentTier_AboveAverage] = {
.num_variants = 5,
.variants = {
i18n_noop("Killer job! You've walked %d steps today which is %d%% above your typical. "
"Do it again tomorrow and you'll be on top of the world!"),
i18n_noop("Nice moves! You'v... | kernel_free(body) | ;
}
// ------------------------------------------------------------------------------------------------
// Creates a notification to notify the user of the sleep summary
static void prv_push_sleep_summary_notification(time_t notif_time, int32_t sleep_total_seconds,
int3... |
/*
* 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... | ("Smart Alarm", list) | |
cl_assert_equal_i(actual_resting_kcalories[i], exp_resting_kcalories[i]);
}
}
}
// ---------------------------------------------------------------------------------------
// Test that we correctly initialize the setting upon startup based on the stored settings file
void test_activity__settings(void) {
// Sho... | rtc_get_time() | );
ActivitySession old_activity = {
.start_utc = day_start + 12 * SECONDS_PER_HOUR,
.length_min = 120,
.type = ActivitySessionType_Walk,
.step_data = {
.steps = 100,
.active_kcalories = 200,
.resting_kcalories = 300,
.distance_meters = 400,
},
};
ActivitySession new_act... |
/*
* 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... | {
AncsAppNameStorageEntry entry = {
.app_id = (ANCSAttribute *)app_id,
};
AncsAppNameStorageEntry *found = circular_cache_get(s_cache, &entry);
if (found) {
return found->app_name;
} else {
return NULL;
}
} | |
/*
* 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... | battery_get_charge_state() | ;
uint32_t res_id;
GRect kino_area;
if (current_state.is_charging && !data->saved_state.is_charging) {
kino_area = data->charging_kino_area;
res_id = RESOURCE_ID_RECOVERY_LOW_POWER_CHARGING;
} else if (!current_state.is_charging && data->saved_state.is_charging) {
kino_area = data->discharging_kino... |
/*
* 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_preferences_api) | ;
EXECUTE_SCRIPT("var size = _rocky.userPreferences.contentSize");
ASSERT_JS_GLOBAL_EQUALS_S("size", "medium");
}
void test_rocky_api_preferences__always_valid(void) {
s_preferred_content_size = NumPreferredContentSizes;
rocky_global_init(s_preferences_api);
EXECUTE_SCRIPT("var size = _rocky.userPreference... |
ctionsTestProcessor *processor_with_data =
(PreAndPostFunctionsTestProcessor *)processor;
// Record the existing compositing mode and tint color and check that they are what we expect
cl_assert(ctx->draw_state.compositing_mode ==
EXPECTED_COMPOSITING_MODE_BEFORE_AND_AFTER_PRE_FUNCTION);
process... | (s_ctx.draw_state.tint_color,
EXPECTED_TINT_COLOR_BEFORE_AND_AFTER_PRE_FUNCTION) | );
// Note that additional checks are performed in the .pre and .post functions
}
typedef struct PostFunctionCalledEvenIfPreFunctionCausesNothingToBeDrawnTestProcessor {
GBitmapProcessor processor;
const GBitmap *expected_bitmap_in_post;
bool post_func_called;
} PostFunctionCalledEvenIfPreFunctionCausesNothin... |
single_line_ellipsis_clip_outside_nx(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-80, 4, 72, 32),
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_ellipsis_... | (&canvas, &canvas_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... | if (!prv_update_enqueue_count(true)) {
return false;
} |
bool success = true;
// Retry for 500ms
TickType_t start_ticks = xTaskGetTickCount();
while (1) {
HostTransportEnqueueStatus status =
host_transport_tx_enqueue((const uint8_t *)message, message->message_length);
if (status != HostTransportEnqueueStatus_RetryLater) {
success = (status... |
pported published
// resources as proved by the following asserts)
_Static_assert((APP_GLANCE_MIN_SUPPORTED_SDK_VERSION_MAJOR >
TIMELINE_RESOURCE_PBW_SUPPORT_FIRST_SDK_VERSION_MAJOR) ||
((APP_GLANCE_MIN_SUPPORTED_SDK_VERSION_MAJOR ==
TIMELINE_R... | app_free(generic_glance) | ;
}
static const LauncherAppGlanceStructuredImpl s_generic_structured_glance_impl = {
.base_handlers.current_slice_updated = prv_current_slice_updated,
.get_icon = prv_get_icon,
.get_title = prv_get_title,
.create_subtitle_node = prv_create_subtitle_node,
.destructor = prv_destructor,
};
LauncherAppGlance *... |
PIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_High_Speed;
// I2S CK
GPIO_InitStructure.GPIO_Pin = BOARD_CONFIG.mic_config.i2s_ck.gpio_pin;
GPIO_Init(BOARD_CONFIG.mic_config.i2s_ck.gpio, &GPIO_InitStructure);
GPIO_PinAFConfig(BOARD_CONFIG.mic_config.i2s_ck.gpio,
BOARD_CONFIG.mic_config.i2s_ck.gp... | (MIC_I2S_RX_DMA, s_in_buffer, periph_addr, sizeof(s_in_buffer),
prv_dma_handler, NULL) | ;
s_running = true;
success = true;
unlock:
mutex_unlock_recursive(s_mic_mutex);
return success;
}
void mic_stop(MicDevice *this) {
mutex_lock_recursive(s_mic_mutex);
if (!s_running) {
goto unlock;
}
// Disable DMA and I2S
dma_request_stop(MIC_I2S_RX_DMA);
I2S_Cmd(BOARD_CONFIG.mic_config.s... |
status_t status_code) {
InternalErrorResponse *resp = pulse_reliable_send_begin(
PULSE2_BULKIO_PROTOCOL);
resp->opcode = BULKIO_RESP_INTERNAL_ERROR;
resp->status_code = status_code;
size_t response_len = sizeof(*resp);
size_t command_len = MIN(length, PULSE_MAX_SEND_SIZE - respo... | if (FAILED(status)) {
prv_respond_internal_error(cmd, length, status);
return;
} |
CloseResponse *resp = pulse_reliable_send_begin(PULSE2_BULKIO_PROTOCOL);
resp->opcode = BULKIO_RESP_DOMAIN_CLOSE;
resp->fd = cmd->close.fd;
pulse_reliable_send(resp, sizeof(*resp));
prv_free_fd(cmd->close.fd);
}
static void prv_handle_read(Command *cmd, size_t length) {
if (cmd->read.length == 0) {
... |
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(b, actual);
cl_assert_equal_i(0, current_stack);
cl_assert_equal_p(b, stack[0]);
// no more siblings on root level
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(st... | GPoint(21, 21) | ), NULL);
layer_remove_from_parent(&child_f);
layer_add_child(&parent, &child_b);
layer_add_child(&parent, &child_c);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(9, 9)), &child_a);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(6, 6)), &child_b);
cl_assert_equ... |
andler handler) {
s_remote_receive_handler = handler;
}
void test_app_message__send_happy_case_outbox_sent_then_ack(void) {
prv_set_remote_receive_handler(prv_ack_sent_callback);
prv_send_test_data();
prv_call_outbox_sent(AppOutboxStatusSuccess);
prv_process_sent_data();
// After the ACK has been received... | app_message_is_accepting_outbound() | , true);
}
void test_app_message__busy(void) {
DictionaryIterator *iter;
prv_set_remote_receive_handler(prv_no_reply_callback);
prv_send_test_data();
prv_process_sent_data();
// Can't get or send again if still sending
cl_assert_equal_i(app_message_outbox_begin(&iter), APP_MSG_BUSY);
cl_assert_equal_i(a... |
er = {
.id = {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 100*60,
.duration = 10,
.type = TimelineItemTypePin,
.all_day = false,
.layout = LayoutIdCalendar,
},
.attr_list = {
.num_attributes = 1,
.attributes... | cl_assert_equal_i(fake_event_get_count(), 2) | ;
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(5*60, stub_new_timer_timeout(timer_id) / 1000);
cl_assert(timeline_remove(&item1.header.id));
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 3);
cl_assert(!prv_get... |
et_value_for_coordinate(ctx, mask,
GPoint(x, y)),
expected_value);
}
}
}
void test_graphics_context_mask__basic_create(void) {
GContext *ctx = s_ctx;
// Should be safe to call create with NULL values
cl_ass... | graphics_context_mask_destroy(ctx, mask2) | ;
}
void test_graphics_context_mask__basic_destroy(void) {
// Should be safe to call destroy on NULL values
graphics_context_mask_destroy(NULL, NULL);
}
|
_stop.origin.y = slide_up ? window_bounds.size.h : -window_bounds.size.h;
GRect next_start = window_bounds;
next_start.origin.y = slide_up ? -window_bounds.size.h : window_bounds.size.h;
Animation *curr_out = prv_create_slide_animation(current_card_layer, &window_bounds, &curr_stop);
Animation *next_in = prv_c... | layer_init(&health_card_view->select_indicator_layer, &window_root->frame) | ;
layer_add_child(window_root, &health_card_view->select_indicator_layer);
layer_set_update_proc(&health_card_view->select_indicator_layer,
prv_select_indicator_layer_update_proc);
// setup content indicators
const int content_indicator_height = PBL_IF_ROUND_ELSE(18, 11);
const GRect ... |
/*
* 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_mutex, (uint32_t)__builtin_return_address(0)) | ;
}
static inline void prv_unlock(void) {
mutex_unlock(s_mutex);
}
#define PERSIST_FILE_NAME_MAX_LENGTH sizeof("ps000001")
static status_t prv_get_file_name(char *name, size_t buf_len, const Uuid *uuid) {
// Firmware 2.x persist files are named "p%06d", the added "s" in the file
// name prefix indicates that i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | pbl_log_get_level_char(log_level) | , ' ', task_char, ' ', 0 };
serial_console_write_log_message(buffer);
}
// Start out with the timestamp
prv_log_timestamp();
// Write out the filename
src_filename = GET_FILE_NAME(src_filename);
serial_console_write_log_message(src_filename);
// Write out the line number
{
char line_number_bu... |
animation_set_handlers(seq, handlers, seq) | ;
animation_schedule(seq);
// The duration of seq should include all of a and b
uint32_t duration = animation_get_duration(seq, true, true);
cl_assert_equal_i(duration, duration_a + delay_a + duration_b + delay_b);
// The position of seq should be the amount we already played of a, including the 'a' delay
... | |
NTIN_MODEL("pebble_black");
break;
case WATCH_INFO_COLOR_WHITE:
model_name = TINTIN_MODEL("pebble_white");
break;
case WATCH_INFO_COLOR_RED:
model_name = TINTIN_MODEL("pebble_red");
break;
case WATCH_INFO_COLOR_ORANGE:
model_name = TINTIN_MODEL("pebble_o... | ((const jerry_char_t *)combined_string) | ;
}
}
static jerry_value_t prv_get_language(void) {
return jerry_create_string((const jerry_char_t *)app_get_system_locale());
}
static jerry_value_t prv_get_fw_version(void) {
WatchInfoVersion fw_version = watch_info_get_firmware_version();
JS_VAR version_major = jerry_create_number(fw_version.major);
JS_V... |
%x%x...", node->id.byte0, node->id.byte1);
PBL_LOG(LOG_LEVEL_DEBUG, "Index %d", node->index);
PBL_LOG(LOG_LEVEL_DEBUG, "Timestamp %ld", node->timestamp);
PBL_LOG(LOG_LEVEL_DEBUG, "Duration %hu", node->duration);
PBL_LOG(LOG_LEVEL_DEBUG, "All day? %s", node->all_day ? "True": "False");
PBL_LOG(LOG_L... | (caller_id, NULL) | ,
}
};
event_put(&event);
}
///////////////////////////////////////////////////
// Public functions
//////////////////////////////////////////////////
status_t timeline_init(TimelineNode **timeline) {
PBL_LOG(LOG_LEVEL_DEBUG, "Starting to build list.");
status_t rv = pin_db_each(prv_each, timeline);
pr... |
GPoint displacement = stack->transition_context.window_to_displacement;
gpoint_add_eq(&draw_state->drawing_box.origin, displacement);
gpoint_add_eq(&draw_state->clip_box.origin, displacement);
}
// clip_box must respect screen boundaries
grect_clip(&draw_state->clip_box, &saved_state->clip_box);
}
stat... | window_calc_frame(fullscreen) | ;
layer_init(&window->layer, &frame);
window->is_fullscreen = fullscreen;
window->layer.window = window;
window->layer.update_proc = window_do_layer_update_proc;
window->background_color = GColorWhite;
window->in_click_config_provider = false;
window->is_waiting_for_click_config = false;
window->parent_... |
/*
* 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;
} |
if (row == 0) {
// Killing current worker
process_manager_put_kill_process_event(PebbleTask_Worker, true /* graceful */);
worker_manager_set_default_install_id(INSTALL_ID_INVALID);
} else {
const uint16_t app_index = row - 1; // offset because of the "None" selection
const AppMenuNode *app_node... |
/*
* 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... | compositor_transition_pdcs_animation_update(
ctx, s_data.animation_sequence, distance_normalized, replace_color, stroke_color,
s_data.outer_color /* overdraw color */, inner, NULL) | |
istNode *)connection, (ListNode **)&s_connections, NULL);
ListNode *tmp = (ListNode *) connection->gatt_op_list;
while (tmp) {
ListNode *next = list_get_next((ListNode *)tmp);
kernel_free(tmp);
tmp = next;
}
if (connection->ppogatt_wa_state) {
ppogatt_destroy_st... | connection_get_address(connection, addr_out) | ;
}
prv_unlock();
}
uint8_t connection_get_last_pairing_result(uint16_t conn_idx) {
uint8_t rv = 0;
prv_lock();
{
Connection *connection = connection_by_idx(conn_idx);
if (connection) {
rv = connection->last_pairing_result;
}
}
prv_unlock();
return rv;
}
PPoGATTWorkAroundState *conne... |
(raw, s_accel_scale);
return (converted);
}
// Simple read register command with no error handling
static bool prv_read_register(uint8_t register_address, uint8_t *result) {
return i2c_read_register(I2C_LIS3DH, register_address, result);
}
// Simple write register command with no error handling
static bool prv_wr... | (LIS3DH_CTRL_REG1, &ctrl_reg1) | ) {
ctrl_reg1 |= LPen;
if (prv_write_register(LIS3DH_CTRL_REG1, ctrl_reg1)) {
// Write successful, low power mode enabled
accel_stop();
return;
}
}
}
PBL_LOG(LOG_LEVEL_ERROR, "Failed to enter low power mode");
}
bool accel_running(void) {
return (s_running);
}
bool ... |
// Enable SPIx reset state
RCC_APB2PeriphResetCmd(bus->state->spi_clock_periph, ENABLE);
// Release SPIx from reset state
RCC_APB2PeriphResetCmd(bus->state->spi_clock_periph, DISABLE);
}
spi_ll_slave_release(slave);
}
//
//! High level slave port interface
//! This part of the API can be used for fair... | PBL_ASSERTN(slave->slave_state->acquired == false) | ;
prv_spi_enable_peripheral_clock(slave->spi_bus);
prv_spi_clear_flags(slave->spi_bus);
slave->slave_state->acquired = true;
spi_ll_slave_spi_enable(slave);
}
void spi_ll_slave_release(const SPISlavePort *slave) {
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
sp... |
PBL_LOG(LOG_LEVEL_INFO, "Orphaned resource file removed: %s", iter->name);
pfs_remove(iter->name);
iter = (PFSFileListEntry *)iter->list_node.next;
}
}
// The bug addressed in PBL-34010 caused resource files to remain in the filesystem even
// after the associated application had been deleted. This funct... | {
pfs_remove(APP_CACHE_FILE_NAME);
prv_delete_cached_files();
} |
mutex_unlock_recursive(s_app_cache_mutex);
}
////////////////////////////////
// Testing only
////////////////////////////////
static bool prv_each_get_size(SettingsFile *file, SettingsRecordInfo *info, void *context) {
if ((info->key_len != sizeof(AppInstallId)) || (info->val_len != sizeof(AppCacheEntry))) {
... |
/*
* 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... | raw_click_handler(recognizer, window, true) | ;
}
static void raw_down_click_handler(ClickRecognizerRef recognizer, Window *window) {
raw_click_handler(recognizer, window, false);
}
static void select_multi_click_handler(ClickRecognizerRef recognizer, Window *window) {
ClickAppData *data = window_get_user_data(window);
const uint16_t count = click_number_o... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kernel_free(session) | ;
++s_session_close_call_count;
}
void comm_session_receive_router_write(CommSession *session,
const uint8_t *received_data,
size_t num_bytes_to_copy) {
PBL_LOG(LOG_LEVEL_DEBUG, "Received Data:");
PBL_HEXDUMP(LOG_LEVEL_DEBUG, received_... |
ch.c#L2687
extern ble_error_t __real_patch_rom_functions(void);
static bool s_should_log_about_mic_error = false;
static uint32_t s_max_subsequent_error_count_since_last_log = 0;
static uint32_t s_subsequent_mic_errors = 0;
#define MAX_SUBSEQUENT_MIC_ERRORS (16)
bool should_log_about_mic_error(uint32_t *max_subsequen... | (uint32_t) | llc_length_rsp_pdu_send,
#endif
#endif
(uint32_t) lld_data_rx_check,
};
static const uint32_t s_patched_functions[] = {
#if IS_AE_CHIP
(uint32_t) prv_llm_util_get_supp_features,
#if !SUPPORTS_PACKET_LENGTH_EXTENSION
(uint32_t) prv_llc_length_rsp_pdu_send,
#endif
#endif
(uint32_t) prv_lld_data_rx_check,
};
_S... |
ECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// AA = true, SW = 11
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi")) | ;
#endif
// SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 5);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw5_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RE... |
d the actual_args would be set to the arguments
// that are set in prv_draw_line... so when compared to directly calling prv_draw_line..., the two
// should match.
#define ASSERT_CALLED(code_block) \
do {\
ArgsForMock actual_args; \
copy_last_args_for_mock(&actual_args, &s_last_args_for_mock); \
reset_las... | graphics_context_set_fill_color(&context, color) | ;
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb);
color.a = 0;
graphics_context_set_fill_color(&context, color);
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb);
// Fill Color - 2-bit
graphics_context_set_fill_color_2bit(&context, GColor2White);
cl_assert... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(2, 12, 28, 20), 4);
} | |
f first line
if (fraction_for_left != 0) {
int16_t x = x_min;
if (x > tm_p1.x.integer) {
// We're crossing far_top point, time to swap...
tm_p0 = far_top;
tm_p1 = far_right;
}
if (x > bm_p1.x.integer) {
// We're crossing far_bottom point, time to swap...
... | {
graphics_private_plot_vertical_line(ctx, x, top_margin, bottom_margin,
(fraction_for_right >> 1));
} |
}
}
}
static void prv_adjust_stroked_line_width(uint8_t *width) {
PBL_ASSERTN(*width >= MINIMUM_PRECISE_STROKE_WIDTH);
if (*width % 2 == 0) {
(*width)++;
}
}
static void prv_draw_stroked_line_override_aa(GContext* ctx, GPointPrecise p0, GPointPrecise p1,
... |
ap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_or-expect.8bit.pbi"));
memset(dest_data, GColorBlue.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpAnd, GColorWhite);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_and-expect.8bit.pbi"));
me... | gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_comptint_black_cross_black_corners-expect.8bit.pbi") | );
memset(dest_data, GColorBlack.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, (GPoint){0}, GCompOpTint, GColorLightGray);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_comptint_black_cross_lightgray_corners-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
... |
const uint32_t to_duration = kino_reel_get_duration(data->to_reel);
duration = MAX(duration, to_duration);
}
return duration;
}
static bool prv_elapsed_setter(KinoReel *reel, uint32_t elapsed) {
KinoReelTransformData *data = kino_reel_custom_get_data(reel);
if (data->elapsed == elapsed) {
return fals... | (&offset, prv_get_interpolated_origin(data)) | ;
}
prv_draw_reel_or_command_list_processed(ctx, reel, list, offset, processor);
}
static void prv_draw_processed_at_rect(KinoReelTransformData *data, GContext *ctx, GPoint offset,
GRect rect, KinoReelProcessor *processor) {
if (!prv_image_size_eq_rect_size(data, rect)) {
... |
time_t utc_start = time(NULL) - 30 * SECONDS_PER_DAY;
time_t utc_end;
uint32_t num_records = 0;
int num_minutes = 0;
while (true) {
utc_end = time(NULL);
num_minutes = health_service_get_minute_history(minute_data, k_size, &utc_start, &utc_end);
char time_start_text[64];
local_tm = localtime(&u... | (data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text)) | |
GColor bar_color) {
const GColor border_color = GColorBlack;
graphics_context_set_fill_color(ctx, border_color);
graphics_fill_rect(ctx, box);
graphics_context_set_fill_color(ctx, bar_color);
graphics_fill_rect(ctx, box_inset);
}
static void prv_draw_day_bar_thin(GContext *ctx, const GRect *box, int wee... | graphics_context_set_text_color(ctx, is_active ? active_legend_color : inactive_legend_color) | ;
graphics_draw_text(ctx, char_buffer, graph_card->legend_font, box,
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
// Move the box cursor to the next bar
box.origin.x = next_x;
}
}
static void prv_draw_avg_line(HealthGraphCard *graph_card, GContext *ctx, int32_t avg,
... |
/*
* 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 (*data == HDLC_FLAG) {
if (ctx->escape) {
// extra escape character before flag
ctx->escape = false;
*hdlc_error = true;
}
// we've reached the end of the frame
is_complete = true;
} else if (*data == HDLC_ESCAPE) {
if (ctx->escape) {
// invalid sequence
ctx->escap... |
return is_complete;
}
bool hdlc_encode(uint8_t *data) {
if (*data == HDLC_FLAG || *data == HDLC_ESCAPE) {
*data ^= HDLC_ESCAPE_MASK;
return true;
}
return false;
}
|
l.h"
#include "sys_clock_mgr.h"
#include "sys_power_mgr.h"
#include "sys_watchdog.h"
/* The configCHECK_FOR_STACK_OVERFLOW setting in FreeRTOSConifg can be used to
check task stacks for overflows. It does not however check the stack used by
interrupts. This demo has a simple addition that will also check the stack u... | ("SI", /* The text name assigned to the task, for
debug only; not used by the kernel. */
system_init, /* The System Initialization task. */
( void * ) 0, /* The parame... | ; /* The task handle */
configASSERT(status == OS_TASK_CREATE_SUCCESS);
/* Start the tasks and timer running. */
vTaskStartScheduler();
/* If all is well, the scheduler will now be running, and the following
line will never be reached. If the following line does execute, then
there was insufficien... |
00 PST 2015
// all items garbage collected
rtc_set_time(1421445600);
head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
1421445600),
S_NO_MORE_ITEMS);
cl_assert_equal_i(fake... | cl_assert(iter_prev(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
}
void test_timeline__all_day_past(void) {
prv_insert_all_day_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
TimelineItem earlier_item = {
.header = {
.id = {0x04},
.parent_id... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gbitmap_get_bounds(bitmap_reel->bitmap) | ;
bounds.origin = gpoint_add(bounds.origin, offset);
// Save compositing mode
GCompOp prev_compositing_mode = ctx->draw_state.compositing_mode;
GCompOp op = (bitmap_reel->bitmap->info.format == GBitmapFormat1Bit)
? GCompOpAssign
: GCompOpSet;
graphics_context_set_compositing_mo... |
a->alarm_list_head, cell_index->row - 1);
alarm_detail_window_push(node->id, &node->info, prv_handle_alarm_editor_complete, data);
}
static void prv_alarm_list_selection_changed_callback(MenuLayer *menu_layer, MenuIndex new_index,
MenuIndex old_index, void *callb... | gbitmap_init_with_resource(&data->plus_icon, RESOURCE_ID_PLUS_ICON_BLACK) | ;
data->current_plus_icon_resource_id = RESOURCE_ID_PLUS_ICON_BLACK;
app_state_set_user_data(data);
data->alarm_event_info = (EventServiceInfo) {
.type = PEBBLE_ALARM_CLOCK_EVENT,
.handler = prv_handle_alarm_event,
.context = data,
};
event_service_client_subscribe(&data->alarm_event_info);
i... |
full_quadrants = prv_get_full_quadrants(starting_quadrant_normalized,
ending_quadrant_normalized);
}
return config;
}
static void prv_fill_oval_precise(GContext *ctx, GPointPrecise center,
Fixed_S16_3 radius_outer_x, Fixed_S16_3 ... | prv_swap_precise_points(&end_top, &end_bottom) | ;
}
// Range for scanline, since scanlines are mirred from the middle of the circle this is also
// indicated from the middle, therefore initialised with 0 (as middle) and
// radius_y (as scalines are on y axis)
int draw_min = 0;
int draw_max = radius_outer_y.integer;
// Adjust to drawing_box offset... |
S 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 "apps/system_apps/workout/workout.h"
#include "apps/system_apps/workout/workout_active.h"
#include "apps/system_... | (true /* write erase headers */) | |
// Returns the appropriate app id for the given phone number and call source
static const char *prv_get_app_id(const char *number, PhoneCallSource source) {
if (!number) {
return NULL;
}
// Select appropriate app id
switch (source) {
case PhoneCallSource_PP:
// We require the this to be a valid... | {
prv_hide_action_bar();
} | |
play_count_seq * (total_duration_a + total_duration_b));
cl_assert_equal_i(animation_get_duration(seq, true, false),
delay_seq + total_duration_a + total_duration_b);
cl_assert_equal_i(animation_get_duration(seq, true, true), duration_total);
animation_destroy(seq);
#endif
}
/... | (&s_stopped_handler_calls, a) | , 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 1);
#endif
}
// --------------------------------------------------------------------------------------
// Test that we fail if we try and put a component in more than 1 complex animation
void test_animation__reuse_components(void) {
#... |
RECEIVE(0x01) | ;
cl_assert_equal_i(s_prepare_count, 0);
// Endpoint low byte (big endian!)
RECEIVE(PRIVATE_TEST_ENDPOINT_ID >> 8);
cl_assert_equal_i(s_prepare_count, 0);
// Endpoint low byte (big endian!)
RECEIVE(PRIVATE_TEST_ENDPOINT_ID & 0xff);
cl_assert_equal_i(s_prepare_count, 1);
}
void test_session_receive_rout... | |
health_service_sum(HealthMetricStepCount,
time_util_get_midnight_of(now) - SECONDS_PER_DAY,
time_util_get_midnight_of(now));
cl_assert_equal_i(result, 2000);
// yesterday and today
result = health_service_sum(HealthMetricStepCount,
... | cl_assert_equal_p(s_health_service.cache, NULL) | |
x_send() before calling app_message_outbox_begin() again!");
return APP_MSG_INVALID_STATE;
} else if (phase == OUT_CLOSED) {
PBL_LOG(LOG_LEVEL_ERROR,
"Must call app_message_open() before calling app_message_outbox_begin()!");
return APP_MSG_INVALID_STATE;
}
// Reset the send state (dictio... | {
AppMessageCtxOutbox *outbox = &app_state_get_app_message_ctx()->outbox;
if (!prv_is_awaiting_ack(outbox->phase)) {
PBL_LOG(LOG_LEVEL_ERROR, "Received (n)ack, but was not expecting one");
return;
}
if (outbox->transaction_id != header->transaction_id) {
PBL_LOG(LOG_LEVEL_ERROR, "Tx ID mismatch: %... |
////////////////////////////////////////////////////////////////////////////////////////////////////
// Unit test interfaces
AppTimer *app_message_outbox_get_ack_nack_timer(void) {
AppMessageCtxOutbox *outbox = &app_state_get_app_message_ctx()->outbox;
return outbox ? outbox->ack_nack_timer : NULL;
}
|
teps_and_shoe(GContext *ctx, const char *steps_buffer, GFont font,
GRect bounds, GColor color, GBitmap *shoe_icon,
bool screen_is_obstructed, bool has_bpm) {
#if PBL_BW
bounds.origin.y += screen_is_obstructed ? (has_bpm ? 74 : 66) : (has_bpm ? 11... | graphics_context_set_compositing_mode(ctx, GCompOpSet) | |
tion is used to iterate over all entries and search for
//! the particular entry with the given UUID. If one is found, it will set the uuid_data->found_id
//! to a value other than INSTALL_ID_INVALID
static bool prv_db_filter_app_id(SettingsFile *file, SettingsRecordInfo *info, void *context) {
// check entry is vali... | mutex_create() | ;
// set to zero to reset unit test static variable.
s_next_unique_flash_app_id = INSTALL_ID_INVALID;
// Iterate through all entires and find the one with the highest AppInstallId. The next unique
// is then one greater than the largest found.
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCC... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("kernel_malloc") | |
ssion->comm.ack_timeout;
}
return true;
}
static void reschedule_ack_timeout(void) {
RtcTicks soonest_ack_timeout = 0;
dls_list_for_each_session(find_soonest_ack_timeout_cb, &soonest_ack_timeout);
if (soonest_ack_timeout == 0) {
// No one is waiting for ack, just stop the timer
new_timer_stop(s_endp... | if (logging_session->comm.state != DataLoggingSessionCommStateIdle) {
mutex_unlock(s_endpoint_data.mutex);
// logging_session is waiting for an ack, we'll send next time around
// don't return a failure, this is pretty innocuous.
return true;
} |
const uint32_t total_length = sizeof(DataLoggingSendDataMessage) + num_bytes;
const uint32_t timeout_ms = 500;
SendBuffer *sb = comm_session_send_buffer_begin_write(session, ENDPOINT_ID_DATA_LOGGING,
total_length, timeout_ms);
if (!sb) {
mutex_unlock... |
---------------------------------------------------------------
void ppogatt_reset_disconnect_counter(void) {
s_disconnect_counter = 0;
}
static bool prv_client_supports_enhanced_throughput_features(const PPoGATTClient *client) {
// In PPoGATT V1, two features were added to allow for enhanced throughput:
// 1)... | for (uint32_t sn = client->out.next_expected_ack_sn;
sn != sn_end_excl; sn = prv_next_sn(sn)) {
num_bytes += prv_get_payload_size_for_sn(client, sn);
} |
return num_bytes;
}
static uint16_t prv_total_num_bytes_awaiting_ack(const PPoGATTClient *client) {
return prv_total_num_bytes_awaiting_ack_up_to(client, client->out.next_data_sn);
}
static void prv_set_payload_size_for_sn(PPoGATTClient *client, uint32_t sn, uint16_t payload_size) {
client->out.payload_sizes[s... |
LEGATTClientEvent *event,
const KernelLEClient *client) {
const uint16_t value_length = event->value_length;
uint8_t *buffer = NULL;
if (value_length) {
// This is ugly and causes double-copying the data...
// TODO: https://pebbletechnology.atlassian.net/browse/PBL-1... | {
goto log_error;
} |
client->handle_subscribe(event->object_ref, event->subscription_type, event->gatt_error);
return;
case PebbleBLEGATTClientEventTypeCharacteristicRead:
if (!client->handle_read_or_notification) {
goto log_error;
}
prv_consume_read_response(event, client);
return;
de... |
// MSP = VECTOR_TABLE[0] (main stack pointer)
// PSP = Unknown (process stack pointer)
// LR = 0xFFFFFFFF
// PC = VECTOR_TABLE[1]
// PRIMASK = 0x0
// FAULTMASK = 0x0
// BASEPRI = 0x0
// CONTROL = 0x0
//
// Attempt to put the processor into as close to the reset stat... | button_is_pressed(BUTTON_ID_BACK) | )) {
// stop waiting if not held down any longer
return false;
}
delay_ms(1);
}
return true;
}
void *reset_vector, *initial_sp;
prv_get_fw_reset_vector(&reset_vector, &initial_sp);
if ((uintptr_t)reset_vector == 0xffffffff ||
(uintptr_t)initial_sp == 0xffffffff) {
... |
/*
* 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... | {
FirmwareDescription firmware_description;
flash_read_bytes((uint8_t*) &firmware_description, firmware_start_address,
sizeof(FirmwareDescription));
return firmware_description;
} |
bool firmware_storage_check_valid_firmware_description(
uint32_t start_address, const FirmwareDescription *firmware_description) {
if (firmware_description->description_length != sizeof(FirmwareDescription)) {
// Corrupted description
return false;
}
// Log around this operation, as it can take so... |
t_writeback_timer());
}
static int s_bonding_change_count;
static BtPersistBondingOp s_bonding_change_ops[2];
void kernel_le_client_handle_bonding_change(BTBondingID bonding, BtPersistBondingOp op) {
if (s_bonding_change_count <= ARRAY_LENGTH(s_bonding_change_ops)) {
s_bonding_change_ops[s_bonding_change_count] ... | prv_fire_writeback_timer() | ;
cl_assert(id_1 != BT_BONDING_ID_INVALID);
cl_assert_equal_i(s_bonding_change_count, 1);
cl_assert_equal_i(s_bonding_change_ops[0], BtPersistBondingOpDidChange);
// Store another pairing (different device):
SMPairingInfo pairing_2 = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
... |
KEY_GOTHIC_24_BOLD,
[TextStyleFont_MenuCellSubtitle] = FONT_KEY_GOTHIC_18,
#if !RECOVERY_FW
[TextStyleFont_TimeHeaderNumbers] = FONT_KEY_LECO_20_BOLD_NUMBERS,
#endif
[TextStyleFont_TimeHeaderWords] = FONT_KEY_GOTHIC_14_BOLD,
[TextStyleFont_PinSubtitle] = FONT_KEY_GOTHIC_18,
[TextStyleFont_... | (content_size) | ;
return prv_get_font_for_size(size_on_runtime_platform, font);
}
GFont system_theme_get_font(TextStyleFont font) {
return fonts_get_system_font(system_theme_get_font_key(font));
}
GFont system_theme_get_font_for_size(PreferredContentSize size, TextStyleFont font) {
return fonts_get_system_font(system_theme_get... |
leted;
Window day_picker_window;
MenuLayer day_picker_menu_layer;
bool day_picker_was_completed;
Window custom_day_picker_window;
MenuLayer custom_day_picker_menu_layer;
bool custom_day_picker_was_completed;
bool scheduled_days[DAYS_PER_WEEK];
GBitmap deselected_icon;
GBitmap selected_icon;
GBitma... | {
const AlarmInfo info = {
.hour = data->alarm_hour,
.minute = data->alarm_minute,
.kind = data->alarm_kind,
.is_smart = (data->alarm_type == AlarmType_Smart),
};
data->alarm_id = alarm_create(&info);
data->complete_callback(CREATED, data->alarm_id, data->callback_context);
a... | else {
alarm_set_kind(data->alarm_id, data->alarm_kind);
data->complete_callback(EDITED, data->alarm_id, data->callback_context);
app_window_stack_pop(true);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Custom Day Picker
static void prv_cus... |
const bool slide = false;
prv_show_day_sep(timeline_layer, slide);
}
void timeline_layer_slide_day_sep(TimelineLayer *timeline_layer) {
const bool slide = true;
prv_show_day_sep(timeline_layer, slide);
}
static void prv_day_sep_anim_stopped(Animation *anim, bool finished, void *context) {
TimelineLayer *tim... | (&timeline_layer->end_of_timeline) | ;
};
static void prv_up_down_stopped(Animation *animation, bool is_finished, void *context) {
TimelineLayer *layer = context;
prv_update_pins_mode(layer);
prv_set_layouts_to_final_position(layer);
prv_destroy_nonvisible_items(layer);
prv_place_day_separator(layer);
prv_place_end_of_timeline(layer);
}
stat... |
/*
* 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_initialized) | ;
uint32_t crc_value;
if (data_length >= 4) {
const unsigned int num_words = data_length / 4;
crc_calculate_incremental_words((uint32_t*) data, num_words);
data += num_words * 4;
data_length -= num_words * 4;
}
if (data_length) {
uint32_t last_word = 0;
for (unsigned int i = 0; i < da... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.