prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
orkout->last_paused_utc;
total_paused_time_s += duration_current_pause;
}
s_workout_data.current_workout->duration_s =
now_utc - s_workout_data.current_workout->start_utc - total_paused_time_s;
}
static void prv_reset_hr_data(void) {
const time_t now_ts = time_get_uptime_seconds();
s_workout_data.cu... | {
return;
} |
prv_lock();
{
// Update the duration
prv_update_duration();
// Check to make sure our HR sample is still valid
const time_t now_ts = time_get_uptime_seconds();
const time_t age_hr_s = now_ts - s_workout_data.current_workout->current_bpm_timestamp_ts;
if (s_workout_data.current_workout->cu... |
tdlib.h>
#include <stdio.h>
typedef struct {
Window menu_window;
Window test_window;
Window results_window;
MenuLayer test_menu;
TextLayer results_text;
char results_str[100];
GfxTest *current_test;
} AppData;
#define RAND_SEED (775762732) // Randomly selected
#define US_PER_MS (1000)
#define ... | PBL_LOG(LOG_LEVEL_DEBUG, "results: %s", app_data->results_str) | ;
text_layer_set_text(&app_data->results_text, app_data->results_str);
}
static void prv_results_window_unload(Window *window) {
AppData *app_data = window_get_user_data(window);
menu_layer_deinit(&app_data->test_menu);
}
static void prv_results_window_click_config_provider(void *context) {
window_single_clic... |
set_play_count(item_animation->animation, PLAY_COUNT_INFINITE);
animation_set_delay(item_animation->animation, DELAY_PER_LINE /* ms */);
animation_schedule(item_animation->animation);
}
*draw_top_shading = (item_animation->current_offset_y != item_animation->bottom_offset_y);
*draw_bottom_shadin... | GEdgeInsets(0, horizontal_inset) | );
// Use a smaller font for the unfocused cells to achieve a fish-eye effect
const GFont font = selected ? aml->layout_cache.font : prv_get_unfocused_item_font();
const GTextOverflowMode overflow_mode = selected ? GTextOverflowModeWordWrap :
GTextOverflowMode... |
/*
* 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_data.window = window_create();
window_set_click_config_provider(s_data.window, click_config_provider);
window_set_window_handlers(s_data.window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(s_data.window, animated);
} |
static void deinit(void) {
window_destroy(s_data.window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
b/graphics/gpath.h"
#include "applib/graphics/graphics.h"
#include "applib/preferred_content_size.h"
#include "applib/ui/kino/kino_layer.h"
#include "applib/ui/kino/kino_reel/scale_segmented.h"
#include "applib/ui/property_animation.h"
#include "applib/ui/window.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/ker... | prv_get_style() | ->fat_pin_height;
}
uint16_t timeline_layer_get_ideal_sidebar_width(void) {
return prv_get_style()->sidebar_width;
}
///////////////////////////////////////////////////////////
// Drawing functions
///////////////////////////////////////////////////////////
static int prv_get_scroll_delta(TimelineLayer *timeline_l... |
/*
* 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 (text_layer == NULL) {
return;
} | |
pp_install_id_from_app_db(sys_process_manager_get_current_process_id())) {
return;
} else {
Window *window = window_manager_get_top_window();
window_set_overrides_back_button(window, true);
}
}
ClickManager *mgr = prv_get_current_click_manager();
ClickConfig *cfg = &mgr->recognizers[butt... | window_call_handler(window, WindowHandlerOffsetDisappear) | ;
}
}
}
void window_set_background_color(Window *window, GColor background_color) {
const GColor window_bg_color = window->background_color;
if (gcolor_equal(background_color, window_bg_color)) {
return;
}
window->background_color = background_color;
layer_mark_dirty(&window->layer);
}
void window... |
/*
* 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... | xSemaphoreGiveFromISR(s_dma_in_progress, &should_context_switch) | ;
return should_context_switch != pdFALSE;
}
void compositor_dma_run(void *to, const void *from, uint32_t size) {
stop_mode_disable(InhibitorCompositor);
dma_request_start_direct(COMPOSITOR_DMA, to, from, size, prv_dma_complete_handler, NULL);
if (xSemaphoreTake(s_dma_in_progress, 10) != pdTRUE) {
PBL_LOG... |
e_all_pairings(void) {
prv_lock();
{
SettingsFile fd;
status_t rv = settings_file_open(&fd, BT_PERSISTENT_STORAGE_FILE_NAME,
BT_PERSISTENT_STORAGE_FILE_SIZE);
if (rv) {
return;
}
settings_file_rewrite(&fd, prv_delete_all_pairings_itr, NULL);
settin... | PBL_ASSERTN(info->val_len == sizeof(BTBondingID)) | ;
BTBondingID id;
memcpy(&id, val, sizeof(BTBondingID));
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "%s : %d",
ACTIVE_GATEWAY_KEY, (int)id);
} else if (memcmp(key, IS_UNFAITHFUL_KEY, info->key_len) == 0) {
PBL_ASSERTN(info->val_len == sizeof(bool));
bool is_un... |
uid *id,
bool is_first_notification) {
// reload everything, doesn't matter since it will be covered by the peek layer
notification_window_focus_notification(id, false);
// if the peek animation is already in progress, we've done all we need
// data->peek_layer is onl... | prv_pop_notification_window(data) | ;
return;
}
prv_reload_swap_layer(data);
}
static void prv_layout_removed_handler(SwapLayer *swap_layer, LayoutLayer *layout, void *context) {
TimelineItem *item = layout_get_context(layout);
timeline_item_destroy(item);
layout_destroy(layout);
}
T_STATIC LayoutLayer *prv_get_layout_handler(SwapLayer *... |
/*
* 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... | CCSIDR_SETS(ccsidr) | ;
do {
ways = CCSIDR_WAYS(ccsidr);
do {
*reg = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) |
((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk));
#if defined(__CC_ARM)
__schedule_barrier();
#endif
} while (ways--);
} while (sets--);
__DSB();
__ISB();
}
#endif
MOCKAB... |
e nicer printing.
// when getting at this point, it will always trip:
cl_assert_equal_i(length, max_length);
}
cl_assert_equal_p(s_sent_data, NULL);
s_sent_data = kernel_malloc(length);
cl_assert(s_sent_data);
memcpy(s_sent_data, data, length);
s_sent_data_length = length;
s_sent_endpoint_id = en... | app_message_is_closed_outbound() | , true);
fake_app_timer_deinit();
kernel_free(s_sent_data);
s_sent_data = NULL;
}
// Test OUTBOUND (watch->phone):
////////////////////////////////////
static void prv_send_test_data_expecting_result(AppMessageResult result) {
DictionaryIterator *iter;
cl_assert_equal_i(app_message_outbox_begin(&iter), APP_... |
uint8_t stroke_width, GCornerMask quadrant) {
prv_stroke_circle_quadrant_full_override_aa(ctx, p, radius, stroke_width, quadrant, true);
}
#endif // PBL_COLOR
//! Draws aliased stroked quadrant of a circle
//! @internal
T_STATIC void graphics_circle_quadrant_draw_stroked_non_aa(GContext* ctx, GPoint p, uint16_t ... | graphics_circle_draw_1px_aa(ctx, p, radius) | ;
return;
}
}
#endif
if (ctx->draw_state.stroke_width > 1) {
// Non-Antialiased and Stroke Width > 1
graphics_circle_draw_stroked_non_aa(ctx, p, radius, ctx->draw_state.stroke_width);
} else {
// Non-Antialiased and Stroke Width == 1
graphics_circle_draw_1px_non_aa(ctx, p, radius);
}
}... |
layer_remove_from_parent(&data->device_name_text_layer.layer);
}
if (prv_has_confirmation_token(data)) {
layer_remove_from_parent(&data->code_text_layer.layer);
}
// Disable all buttons in this screen:
action_bar_layer_remove_from_window(&data->action_bar_layer);
action_bar_layer_set_click_config_provi... | action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_DOWN, data->decline_bitmap) | ;
action_bar_layer_set_context(action_bar_layer, data);
prv_add_prf_layers(pair_text_area, data);
const int16_t y_offset = PBL_IF_RECT_ELSE(0, 2);
// Device name:
if (prv_has_device_name(data)) {
TextLayer *device_name_layer = &data->device_name_text_layer;
text_layer_init_with_parameters(device_nam... |
for (int i = 0; i < max_put_ops; i++) {
prv_receive_put(s_last_response_cookie, chunk, sizeof(chunk));
} |
prv_receive_commit(s_last_response_cookie, EXPECTED_CRC);
assert_ack_count(max_put_ops); // For the Put(s)
assert_nack_count(1); // For the Commit
}
void test_put_bytes__commit_message_cookie_mismatch(void) {
prv_receive_init_and_put_fw_object();
prv_receive_commit(~s_last_response_cookie, EXPECTED_CRC);... | |
e_id = event.service_id;
const bool is_available = (event.result == SmartstrapResultOk);
state->handlers.availability_did_change(service_id, is_available);
}
} else {
// All events other than SmartstrapConnectionEvent contain the attribute pointer
SmartstrapAttribute *attr = event.attribute;
... | {
prv_state_deinit();
} |
sys_smartstrap_attribute_unregister(attr);
#endif
}
bool app_smartstrap_service_is_available(SmartstrapServiceId service_id) {
#if USE_SMARTSTRAP
return sys_smartstrap_is_service_connected(service_id);
#else
return false;
#endif
}
SmartstrapServiceId app_smartstrap_attribute_get_service_id(SmartstrapAttribute ... |
average);
//! Activity sessions
health_data->num_activity_sessions = ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT;
if (!activity_get_sessions(&health_data->num_activity_sessions,
health_data->activity_sessions)) {
PBL_LOG(LOG_LEVEL_ERROR, "Fetching activity sessions failed");
} else {... | if (health_data->step_average_last_updated_time !=
((today_min / k_minutes_per_step_avg) * k_minutes_per_step_avg)) {
// current_step_average is stale
health_data->current_step_average =
prv_health_data_get_n_average_chunks(health_data, today_min / k_minutes_per_step_avg);
health_data->step_a... |
return health_data->current_step_average;
}
int32_t health_data_steps_get_cur_wday_average(HealthData *health_data) {
return prv_health_data_get_n_average_chunks(health_data, ACTIVITY_NUM_METRIC_AVERAGES);
}
int32_t health_data_steps_get_monthly_average(HealthData *health_data) {
return health_data->monthly_st... |
"drivers/rtc.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "os/mutex.h"
#include "process_management/app_install_manager.h"
#include "services/normal/app_cache.h"
#include "services/normal/blob_db/app_glance_db.h"
#include "syscall/syscall_internal.h"
#include "system/passert.h"
#include "system... | if (!glance) {
return;
} |
*glance = (AppGlance) {};
}
void app_glance_service_init(void) {
static EventServiceInfo s_blob_db_event_info = {
.type = PEBBLE_BLOBDB_EVENT,
.handler = prv_blob_db_event_handler,
};
event_service_client_subscribe(&s_blob_db_event_info);
static EventServiceInfo s_app_cache_event_info = {
.typ... |
g_state(GContext* ctx, GDrawState draw_state) {
}
AnimationPrivate *animation_private_animation_find(Animation *handle) {
return NULL;
}
static int s_count_display_update = 0;
void compositor_display_update(void (*handle_update_complete_cb)(void)) {
++s_count_display_update;
}
static bool s_display_update_in_pro... | cl_assert_equal_i(s_count_compositor_init_func_b, 2) | ;
}
void test_compositor__app_render_busy(void) {
// Set the display as busy and then render the app. Nothing should update.
s_display_update_in_progress = true;
compositor_app_render_ready();
cl_assert_equal_i(s_count_display_update, 0);
// Now fake the display update completeing. The app should know draw.... |
,
{"coral", GColorARGB8FromHEX(0xff7f50)},
{"cornflowerblue", GColorARGB8FromHEX(0x6495ed)},
{"cornsilk", GColorARGB8FromHEX(0xfff8dc)},
{"crimson", GColorARGB8FromHEX(0xdc143c)},
{"darkblue", GColorARGB8FromHEX(0x00008b)},
{"darkcyan", GColorARGB8FromHEX(0x008b8b)},
{"darkgoldenrod", GColorARGB8FromHEX(0... | GColorARGB8FromHEX(0x6b8e23) | |
-----------
// Calculates and stores the most recent minutes median heart rate value.
// Used for the health_service and the minute level data.
static void prv_update_median_hr_bpm(ActivityState *state) {
const ActivityHRSupport *hr = &state->hr;
const uint16_t num_hr_samples = hr->num_samples;
if (num_hr_sample... | activity_private_state() | ;
mutex_lock_recursive(state->mutex);
{
// Update the median HR / HR weight for the minute
prv_update_median_hr_bpm(state);
// Update our current HR zone (based on the median which is calculated above)
prv_update_current_hr_zone(state);
}
mutex_unlock_recursive(state->mutex);
}
// ------------... |
tic void prv_write_metric_history(ActivitySettingsKey key,
const ActivitySettingsValueHistory *history) {
SettingsFile *file = activity_private_settings_open();
if (file) {
settings_file_set(file, &key, sizeof(key), history, sizeof(*history));
activity_private_settings_c... | prv_wait_system_task(prv_fill_minute_file_system_cb, &context, &context.success,
&context.completed, 300 /*timeout_sec*/) | |
/*
* 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 (id == 0) {
prompt_send_response("invalid app number");
return;
} |
AppInstallEntry entry;
bool success = app_install_get_entry_for_install_id(id, &entry);
if (success && app_install_entry_has_worker(&entry)) {
app_manager_put_launch_app_event(&(AppLaunchEventConfig) { .id = id });
prompt_send_response("OK");
} else {
prompt_send_response("No worker with id");
... |
tubs_system_theme.h"
#include "stubs_syscalls.h"
#include "stubs_task_watchdog.h"
#include "stubs_tick.h"
#include "stubs_time.h"
#include "stubs_watchface.h"
#include "stubs_weather_service.h"
#include "stubs_weather_types.h"
#include "stubs_window_manager.h"
#include "stubs_window_stack.h"
#include "stubs_workout_ser... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_launcher_menu_layer__no_icon_app_with_glance(void) {
// Insert a glance with a slice for the app that doesn't have a default icon
const AppGlance glance = (AppGlance) {
.num_slices = 1,
.slices = {
{
.expiration_time = 1464734484, // (Tue, 31 May 2016 22:41:24 GMT)
... |
c = 0xff,
} BLEAdType;
// -----------------------------------------------------------------------------
//! AD DATA element header
typedef struct __attribute__((__packed__)) {
uint8_t length;
BLEAdType type:8;
} BLEAdElementHeader;
typedef struct __attribute__((__packed__)) {
BLEAdElementHeader header;
u... | {
const uint8_t uuid_type = elem->header.type / 2;
// Most common is probably 128-bit UUID, then 16-bit, then 32-bit:
const size_t uuid_width = (uuid_type == 3) ? 16 : ((uuid_type == 1) ? 2 : 4);
const size_t num_uuids = (elem->header.length - 1 /* Type byte */)
... | |
/*
* 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... | (is_complete == false) | ;
cl_assert(should_store == false);
cl_assert(is_invalid == false);
data = HDLC_FLAG;
is_complete = hdlc_streaming_decode(&ctx, &data, &should_store, &is_invalid);
cl_assert(is_complete == true);
cl_assert(should_store == false);
cl_assert(is_invalid == true);
}
void test_hdlc__decode_escaped_special(voi... |
cmd_no_addr(dev, dev->state->part->instructions.block_unlock_all);
qspi_release(dev->qspi);
return S_SUCCESS;
}
#if !RELEASE
#include "console/prompt.h"
#include "drivers/flash.h"
#include "kernel/pbl_malloc.h"
#include "system/profiler.h"
#include "util/size.h"
static bool prv_flash_read_verify(QSPIFlash *dev, i... | qspi_release(QSPI) | ;
bool was_busy = false;
// write a few bytes to the sector we're going to erase so it's not empty
uint8_t dummy_data = 0x55;
flash_write_bytes(&dummy_data, FLASH_REGION_FIRMWARE_SCRATCH_BEGIN, sizeof(dummy_data));
profiler_start();
status_t result = flash_impl_erase_sector_begin(FLASH_REGION_FIRMWARE_SCR... |
ude "clar.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
#include "stubs_passert.h"
#include "stubs_process_manager.h"
void test_graphics_colors__black(void) {
cl_assert(GColorBlack.r == 0b00);
cl_assert(GColorBlack.g == 0b00);
cl_assert(GColorBlack.b == 0b00);
cl_assert(GColorBlack.a == 0b11);
}
voi... | gcolor_get_grayscale(GColorBlack) | |
const char *new_device_name = "New iPhone";
bt_persistent_storage_update_ble_device_name(id, new_device_name);
bt_persistent_storage_get_ble_pairing_by_id(id, NULL, NULL, device_name_out);
cl_assert_equal_i(strcmp(new_device_name, device_name_out), 0);
}
//////////////////////////////////////////////////////... | bt_persistent_storage_get_bt_classic_pairing_by_id(id_2, &addr_out, &link_key_out,
name_out, &platform_bits_out) | ;
cl_assert(ret);
cl_assert_equal_m(&addr_2, &addr_out, sizeof(addr_out));
cl_assert_equal_m(&link_key_2, &link_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_2, name_out);
cl_assert_equal_i(platform_bits_2, platform_bits_out);
// Add a thrid pairing
BTDeviceAddress addr_3 = {{0x31, 0x32, 0x33, 0... |
tor));
cl_assert(iter_prev(&iterator));
cl_assert(!iter_prev(&iterator));
}
void test_timeline__all_day_middle_past(void) {
prv_insert_all_day_items();
// 1421183640 is 13:14 on Jan 13, 2015
// after first timed event of the day but not all of them
Iterator iterator = {0};
TimelineIterState state = {0}... | iter_next(&iterator) | );
}
// 11 am, all events passed
void test_timeline__extra_case_backwards(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPas... |
_STEP_AVG 500
#define DAILY_STEP_AVG 1000
#define HEART_RATE_THRESHOLD 80
// Persist keys
typedef enum {
AppPersistKeyLapSteps = 0,
} AppPersistKey;
// -------------------------------------------------------------------------------
// Structures
typedef struct {
TextLayer *text_layer;
char text[256];
} Resul... | (data->debug_card.dialog_text, title) | ;
// Get History
time_t day_start = time_start_of_today();
for (int i = 0; i < 30; i++) {
HealthValue value = health_service_sum(metric, day_start, day_start + SECONDS_PER_DAY);
char elapsed[8];
prv_convert_seconds_to_time(value, elapsed, sizeof(elapsed));
APP_LOG(APP_LOG_LEVEL_DEBUG, "%d: %s", i... |
ime_buf);
// June 9th 2015, 14:00:00 (T-02:00:00)
rtc_set_time(event_time - (2 * SECONDS_PER_HOUR));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("In 2 hours", time_buf);
// June 9th 2015, 15:59:00 (T-00:01:00)
rtc_set_time(event_time - (1 * SECONDS_PER... | (time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("Yesterday, 16:00", time_buf);
// June 9th 2015, 02:00:00 (T-14:00:00)
rtc_set_time(event_time - (14 * SECONDS_PER_HOUR));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("16:00", time_buf);
// June 8th 2015, 16:00:00 (T-48:00:00)
rtc... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (0, buffer_remove(b, 0, 0)) | ;
buffer_add(b, &b1, sizeof(uint8_t));
buffer_add(b, &b2, sizeof(uint8_t));
buffer_add(b, &b3, sizeof(uint8_t));
buffer_add(b, &b4, sizeof(uint8_t));
// handles out of bounds cases
cl_assert_passert(buffer_remove(b, 0, 5));
cl_assert_passert(buffer_remove(b, 1, 4));
cl_assert_equal_i(4, b->bytes_writ... |
tions_draw_timeline_speed_lines(ctx, offset);
}
const int16_t sidebar_width = timeline_layer->sidebar_width;
const GRect sidebar_rect = GRect(bounds->size.w - sidebar_width, 0, sidebar_width,
bounds->size.h);
graphics_context_set_fill_color(ctx, timeline_layer->sidebar_color)... | {
if (layer->layouts[s_nonvisible_items[0]]) {
prv_destroy_layout(layer, s_nonvisible_items[0]);
}
for (int i = 0; i < TIMELINE_NUM_ITEMS_IN_TIMELINE_LAYER - 1; i++) {
layer->layouts[i] = layer->layouts[i + 1];
layer->layouts_info[i] = layer->layouts_info[i + 1];
}
layer->layouts[T... | else if (delta == -1) {
if (layer->layouts[s_nonvisible_items[1]]) {
prv_destroy_layout(layer, s_nonvisible_items[1]);
}
for (int i = TIMELINE_NUM_ITEMS_IN_TIMELINE_LAYER - 1; i > 0; i--) {
layer->layouts[i] = layer->layouts[i - 1];
layer->layouts_info[i] = layer->layouts_info[i - 1];
... |
_util_get_midnight_of(info->timestamp) != current_day &&
time_util_get_midnight_of(info->end_time) == current_day)
? info->end_time : info->timestamp;
}
void timeline_layout_get_icon_frame(const GRect *bounds, TimelineScrollDirection scroll_direction,
GRect... | timeline_layout_init_view((TimelineLayout *)layout, final_mode) | ;
}
void prv_init_colors(TimelineLayout *timeline_layout) {
LayoutLayer *layout = &timeline_layout->layout_layer;
const LayoutColors *default_colors = &timeline_layout->impl->default_colors;
LayoutColors *colors = &timeline_layout->colors;
colors->bg_color =
(GColor) attribute_get_uint8(layout->attribute... |
syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "system/passert.h"
#include "util/net.h"
#include "util/pack.h"
#include "util/uuid.h"
#define RESOURCE_MAX_SIZE (700)
//! Autogenerated table created by generate_resource_code.py as part of resource generation. The
//! format is:
//! tiny resource id ... | prv_is_app_published_resource_valid(&res_info) | ) {
if (res_info_out) {
*res_info_out = res_info;
}
return true;
}
}
}
return false;
}
void timeline_resources_get_id(const TimelineResourceInfo *timeline_res, TimelineResourceSize size,
AppResourceInfo *res_info_out) {
PBL_ASSERTN(timel... |
ert_equal_s(buffer, "test_model");
}
void test_spalding_mfg_info__1_to_3_conversion(void) {
// Force in an old data version.
typedef struct {
uint32_t data_version;
uint32_t color;
uint32_t rtc_freq;
} MfgDataV1;
MfgDataV1 old_data = {
.data_version = 1,
.color = 3,
.rtc_freq =... | flash_read_bytes(fpga_buffer, BOOT_FPGA_FLASH_ADDR, sizeof(fpga_buffer)) | ;
cl_assert(memcmp(fpga_buffer + HEADER_SIZE, s_boot_fpga, sizeof(s_boot_fpga)) == 0);
mfg_info_set_disp_offsets((GPoint) { 2, 3 });
char model[MFG_INFO_MODEL_STRING_LENGTH] = "123456789012345";
mfg_info_set_model(model);
// Now let's write in an fpga image
mfg_info_update_constant_data();
// Let's ma... |
>legacy2_framebuffer = (GBitmap) {
.addr = fb_data,
.row_size_bytes = row_size,
.info.is_bitmap_heap_allocated = false,
.info.format = GBitmapFormat1Bit,
.info.version = GBITMAP_VERSION_0,
.bounds = { { 0, 0 }, { LEGACY_2X_DISP_COLS, LEGACY_2X_DISP_ROWS } }
};
}
return true;
... | {
s_app_state_ptr->user_data = data;
} |
void* app_state_get_user_data(void) {
return s_app_state_ptr->user_data;
}
AccelServiceState* app_state_get_accel_state(void) {
return &s_app_state_ptr->accel_state;
}
CompassServiceConfig **app_state_get_compass_config(void) {
return &s_app_state_ptr->compass_config;
}
PluginServiceState *app_state_get_plug... |
owStack *window_stacks[NumModalPriorities];
for (ModalPriority idx = ModalPriorityMin; idx < NumModalPriorities; idx++) {
window_stacks[idx] = modal_manager_get_window_stack(idx);
windows[idx] = window_create();
window_stack_push(window_stacks[idx], windows[idx], true);
// Modals are visible as we pu... | (prv_get_appear_disappear_count(), 1) | ;
window_stack_pop_all(stack, true);
cl_assert_equal_i(window_stack_count(stack), 2);
cl_assert_equal_i(prv_get_load_unload_count(), 2);
cl_assert_equal_i(prv_get_appear_disappear_count(), 2);
cl_assert_equal_i(s_disappear_count, 2);
cl_assert_equal_i(s_appear_count, 4);
window_stack_pop_all(stack, tru... |
////////////////////////////
// Declarations of permitted handlers:
extern void app_message_receiver_message_handler(const uint8_t *data, size_t length,
AppInboxConsumerInfo *consumer_info);
extern void app_message_receiver_dropped_handler(uint32_t num_dropped_messages)... | {
// Using one "global" lock for all app inboxes.
// If needed, we could easily give each app inbox its own mutex, but it seems overkill right now.
mutex_lock_recursive(s_app_inbox_mutex);
} |
static void prv_unlock(void) {
mutex_unlock_recursive(s_app_inbox_mutex);
}
static bool prv_list_filter_by_storage(ListNode *found_node, void *data) {
return ((AppInboxNode *)found_node)->buffer.storage == (uint8_t *)data;
}
static AppInboxNode *prv_find_inbox_by_storage(uint8_t *storage) {
return (AppInboxNo... |
F ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "spi_definitions.h"
#include "drivers/spi.h"
#include "drivers/spi_dma.h"
#include "drivers/dma.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#... | {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI4;
bus->state->spi_clock_periph_speed = clocks.PCLK2_Frequency;
bus->state->spi_apb = SpiAPB_2;
#endif
#ifdef SPI5
} | else if (bus->spi == SPI5) {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI5;
bus->state->spi_clock_periph_speed = clocks.PCLK2_Frequency;
bus->state->spi_apb = SpiAPB_2;
#endif
#ifdef SPI6
} else if (bus->spi == SPI6) {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI6;
bus->state->spi_clock... |
;
// serialize the attributes / actions
size_t bytes_serialized = timeline_item_serialize_payload(item, write_ptr, payload_size);
status_t rv;
if (bytes_serialized != payload_size) {
rv = E_INVALID_ARGUMENT;
goto cleanup;
}
// Only pins from the reminders app should be dirty and synced to the phon... | (&s_pin_db_storage, key, key_len, val_out, val_len) | ;
}
status_t pin_db_delete(const uint8_t *key, int key_len) {
status_t rv = timeline_item_storage_delete(&s_pin_db_storage, key, key_len);
if (rv == S_SUCCESS) {
//! remove reminders that are children of this pin
reminder_db_delete_with_parent((TimelineItemId *)key);
}
return rv;
}
status_t pin_db_fl... |
/*
* 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 (window) {
// Do not call 'disappear' handler on window displaced by modal window
window_set_on_screen(window, false, false);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (!endpoint) {
return MetaResponseCodeUnhandled;
}
if (!prv_is_endpoint_allowed_with_session(endpoint, session)) {
return MetaResponseCodeDisallowed;
}
return MetaResponseCodeNoError;
} |
static void prv_cleanup_router(ReceiveRouter *rtr) {
memset(rtr, 0, sizeof(*rtr));
}
static bool prv_copy_header(ReceiveRouter *rtr, size_t *data_size_p, const uint8_t **data_p) {
// New message or still gathering the header of the message
const uint16_t header_bytes_missing = sizeof(PebbleProtocolHeader) - rt... |
mer_add_seconds_callback(&vcom_timer);
}
}
static void init_drivers(void) {
board_init();
// The dbgserial input support requires timer support, so it is initialized here, much later
// than the core dbgserial_init().
dbgserial_input_init();
serial_console_init();
voltage_monitor_init();
battery_in... | resource_init() | |
yer_set_background_color(data->steps_card.cur_step_layer, GColorClear);
text_layer_set_text_color(data->steps_card.cur_step_layer, GColorWhite);
layer_add_child(window_layer, text_layer_get_layer(data->steps_card.cur_step_layer));
// Time
data->steps_card.time_layer = text_layer_create(TIME_RECT);
text_layer... | (text_layer_get_layer(data->steps_card.time_layer), false) | ;
layer_set_hidden(text_layer_get_layer(data->steps_card.delta_step_layer), false);
}
// -------------------------------------------------------------------------------
static void prv_results_back_click_handler(ClickRecognizerRef recognizer, void *context) {
window_stack_pop(true);
}
// ------------------------... |
) {
return (get_curr_state(start_page, DELETE_STATE_OFFSET, DELETE_STATE_DONE));
}
static bool is_tmp_file(uint16_t start_page) {
return (!get_curr_state(start_page, TMP_STATE_OFFSET, TMP_STATE_DONE));
}
static uint32_t compute_pg_header_crc(PageHeader *hdr) {
PageHeader crc_hdr = *hdr;
// don't factor fields... | memcmp(name, file_name, namelen) | == 0) && (!is_tmp_file(pg))) {
if (read_header(pg, &pg_hdr, &file_hdr) == HdrCrcCorrupt) {
PBL_LOG(LOG_LEVEL_WARNING, "%d: CRC corrupt", pg);
continue;
}
*page = pg;
return (S_SUCCESS);
}
}
}
return (E_DOES_NOT_EXIST);
}
// Populates 'hdr' with what... |
e beginning of the firmware off flash to see if it's new world or old world
const unsigned world_length = FW_IDENTIFIER_OFFSET + sizeof(uint32_t); // NeWo read as uint32_t
uint8_t buffer[world_length];
flash_read_bytes(buffer, flash_new_fw_addr, world_length);
return firmware_is_new_world(buffer);
}
static b... | dbgserial_putstr("\nInvalid firmware description!") | |
-----------------------------------------------------------------------------
static void prv_debug_cmd_set_sleep_history(int index, void *context) {
ActivityDemoAppData *data = context;
activity_test_set_sleep_history();
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_text),
"Sl... | {
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_text),
"Not enough memory");
return;
} |
// Get sessions
bool success = activity_get_sessions(&num_sessions, sessions);
if (!success) {
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_text),
"Error getting sleep sessions");
goto exit;
}
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_t... |
m_attributes = 1,
.attributes = &title_attr,
},
};
static TimelineItem item3 = {
.header = {
.id = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 25*60,
.duration = 5,
.type = TimelineItemTypePin,
.all_day = false,
... | (timer_id) | / 1000);
}
void test_calendar_handle__ongoing_event_added_and_removed(void) {
rtc_set_time(15 * 60);
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1);
cl_assert(!prv_get_calendar_ongoing());
TimerID timer_id = stub_new_timer_get_next();
cl_assert_equal_i(timer_id, TIMER_INVALID_ID);
c... |
ng.h"
#include "util/time/time.h"
typedef void (*DialogUpdateFn)(Dialog *, void *);
static Dialog *s_dialog = NULL;
typedef struct {
uint32_t percent;
GColor background_color;
ResourceId warning_icon;
} BatteryWarningDisplayData;
// UI Callbacks
///////////////////////
static const GColor s_warning_color[] =... | {
// 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(ModalPriorityGeneric);
prv_display_modal(stack, prv_update_ui_charging, NULL);
} |
void battery_ui_display_fully_charged(void) {
// If we're plugged in (charged), 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(ModalPriorityGeneric);
prv_display_moda... |
{
return;
} |
// look for clipbox
if (!WITHIN(y, clip_box->origin.y, grect_get_max_y(clip_box) - 1)) {
return;
}
const int16_t min_valid_x = clip_box->origin.x;
if (x1.integer < min_valid_x) {
x1 = (Fixed_S16_3){.integer = min_valid_x, .fraction = 0};
}
const int16_t max_valid_x = grect_get_max_x(clip_box) ... | |
noInvalidParameter;
}
bt_lock();
// Find the intent for the device:
GAPLEConnectionIntent *intent = prv_get_intent_by_device(device);
BTErrno ret_value;
if (!intent) {
// No intent for given device
ret_value = BTErrnoInvalidParameter;
} else {
ret_value = prv_unregister_intent(intent, client, ... | {
s_has_pending_create_connection = false;
// Going into air-plane mode, send virtual disconnection events:
GAPLEConnectionIntent *intent = s_intents;
while (intent) {
GAPLEConnectionIntent *next = (GAPLEConnectionIntent *) intent->node.next;
prv_update_clients(intent, GAPLEConnectHCIReason... |
bt_unlock();
}
// -------------------------------------------------------------------------------------------------
// For unit testing
bool gap_le_connect_has_pending_create_connection(void) {
bt_lock();
const bool ret_value = s_has_pending_create_connection;
bt_unlock();
return ret_value;
}
bool gap_le_... |
in (Set this pin low to turn off the display)
GPIO_WriteBit(DISP_GPIO, DISP_PIN_LCD, Bit_SET);
prv_setup_pulse_vcom();
// Don't need the GPIO peripheral clocks to be enabled anymore
gpio_release(PWR_CTL_GPIO);
gpio_release(DISP_GPIO);
}
// Clear-all mode is entered by sending 0x04 to the panel
void display... | {
const unsigned y_offset = 116; // beneath sad face, above url
unsigned x_offset = 28; // Aligned with sad face
// Extract and print digits
for (int i = 7; i >= 0; i--) {
// Mask off 4 bits at a time
uint32_t mask = (0xf << (i * 4));
unsigned digit = ((code & mask) >> (i * 4));
prv_render_char... | |
/*
* 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... | (notif_db_flush(), 0) | ;
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(notif_db_get_len((uint8_t *)&hdr1, UUID_SIZE), 0);
cl_assert_equal_i(notif_db_get_len((uint8_t *)&hdr2, UUID_SIZE), 0);
cl_assert_equal_i(notif_db_get_len((uint8_t *)&hdr3, UUID_SIZE), 0);
}
|
{
node->name = ((PFSFileChangedCallbackNode *)find_str)->name;
} |
s_head_callback_node_list = list_prepend(s_head_callback_node_list, &node->list_node);
mutex_unlock_recursive(s_pfs_mutex);
return node;
}
void pfs_unwatch_file(PFSCallbackHandle cb_handle) {
mutex_lock_recursive(s_pfs_mutex);
PFSFileChangedCallbackNode *callback_node = (PFSFileChangedCallbackNode *)cb_h... | |
h,
s_r1.origin.y + s_r1.size.h);
GRect result = GRect(min_x, min_y, max_x - min_x, max_y - min_y);
return result;
}
GPoint grect_center_point(const GRect *rect) {
return GPoint(rect->origin.x + (rect->size.w / 2), rect->origin.y + (rect->size.h / 2));
}
bool grect_contains_point(cons... | {
return gpoint_sub(point, ctx->draw_state.drawing_box.origin);
} |
GRect grect_to_global_coordinates(const GRect rect, GContext *ctx) {
GRect translated_rect = {
.origin.x = ctx->draw_state.drawing_box.origin.x + rect.origin.x,
.origin.y = ctx->draw_state.drawing_box.origin.y + rect.origin.y,
.size = rect.size,
};
return translated_rect;
}
GRect grect_to_local_coo... |
/*
* 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 NULL;
} |
void gap_le_device_name_request(uintptr_t stack_id, GAPLEConnection *connection) {
}
void gatt_service_changed_server_cleanup_by_connection(GAPLEConnection *connection) {
}
void bt_driver_handle_le_conn_params_update_event(
const BleConnectionUpdateCompleteEvent *event) {
}
typedef struct PairingUserConfirmati... |
C_HISTORY(ActivityMetricSleepRestfulSeconds,
((const uint32_t [ACTIVITY_HISTORY_DAYS])
{3 * SECONDS_PER_MINUTE, 2 * SECONDS_PER_MINUTE,
1 * SECONDS_PER_MINUTE, 0, 0, 0, 0}));
}
// ---------------------------------------... | (stat(in_path, &st) == 0) | ;
FILE *file = fopen(in_path, "r");
cl_assert(file);
uint8_t buf[st.st_size];
// copy file to fake flash storage
cl_assert(fread(buf, 1, st.st_size, file) > 0);
pfs_remove(pfs_name);
int fd = pfs_open(pfs_name, OP_FLAG_WRITE, FILE_TYPE_STATIC, st.st_size);
cl_assert(fd >= 0);
int bytes_written = pf... |
-192, 248},
// 343 seconds
{ -872, -224, 248},
{ -864, -224, 216},
{ -872, -216, 184},
{ -872, -240, 208},
{ -880, -216, 232},
{ -888, -224, 256},
{ -888, -256, 264},
{ -880, -232, 216},
{ -880, -232, 152},
{ -864, -200, 88},
{ -856, -136, 80},
{ -856, -80, 160},
... | { -904, 200, 280},
{ -904, 192, 272},
{ -904, 176, 288},
{ -904, 192, 304},
{ -904, 184, 280},
{ -888, 192, 208},
{ -896, 192, 216},
{ -904, 224, 248},
{ -904, 192, 256},
{ -904, 208, 232},
{ -912, 192, 248},
{ -912, 224, 240},
// 349 seconds
{ -896, 240, 240},
... |
{ -968, 184, -184},
{ -928, 144, -248},
{ -880, 32, -256},
{ -896, 72, -232},
{ -880, 104, -184},
{ -912, 120, -200},
{ -928, 120, -232},
{ -944, 120, -272},
{ -1008, 232, -312},
{ -1024, 112, -240},
{ -1000, 80, -184},
{ -968, 96, -136},
{ -928, 80, -104},
{ -88... |
indicator = "**";
}
if (expected->value != -1) {
int delta = actual->value - expected->value;
printf(" (%3d,%3d) %s%3d (%+4d) ", expected->min, expected->max, indicator, actual->value,
delta);
} else {
printf(" (NA, NA ) %s%3d ", indicator, actual->va... | if (!found_activity) {
result.activity_type.value = (int)session->activity;
result.len.value = (int)session->len_minutes;
result.start_at.value = start_idx;
found_activity = true;
} | |
ate->part->instructions.read_status,
dev->state->part->status_bit_masks.busy, true /* set */,
busy_timeout_us);
qspi_release(QSPI);
return result ? S_SUCCESS : E_ERROR;
}
status_t qspi_flash_erase_suspend(QSPIFlash *dev, uint32_t addr) {
qs... | {
const uint32_t offset_in_page = addr % PAGE_SIZE_BYTES;
const uint32_t bytes_in_page = MIN(PAGE_SIZE_BYTES - offset_in_page, length);
qspi_use(dev->qspi);
prv_write_enable(dev);
qspi_indirect_write(dev->qspi, dev->state->part->instructions.page_program, addr, buffer,
bytes_in_page);
... |
status_t qspi_flash_get_write_status(QSPIFlash *dev) {
qspi_use(dev->qspi);
uint8_t status_reg;
prv_read_register(dev, dev->state->part->instructions.read_status, &status_reg, 1);
qspi_release(dev->qspi);
return (status_reg & dev->state->part->status_bit_masks.busy) ? E_BUSY : S_SUCCESS;
}
void qspi_flash_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_get_resource(app_num, resource_id, &resource) | ;
if (resource.id < 1) {
mutex_unlock_recursive(s_resource_mutex);
return 0;
}
if (offset + num_bytes > resource.length) {
if (offset >= resource.length) {
// Can't recover from trying to read from beyond the resource. Read nothing.
mutex_unlock_recursive(s_resource_mutex);
return 0... |
e_slide_animation(health_card_view, next_card_index, slide_up);
}
}
// Select click handler
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
HealthCardView *health_card_view = context;
Layer *layer = health_card_view->card_layers[health_card_view->current_card_index];
s_card... | layer_mark_dirty(health_card_view->card_layers[health_card_view->current_card_index]) | |
adding them here might relveal bugs.
// .a is the important part
GColor8 test_blend_colors[] = {
(GColor8){.a = 0, .r = 3, .g = 2, .b = 1},
(GColor8){.a = 1, .r = 0, .g = 3, .b = 2},
(GColor8){.a = 2, .r = 1, .g = 0, .b = 3},
(GColor8){.a = 3, .r = 2, .g = 1, .b = 0}
};
// Test image with four... | memset(dest_data, GColorBlue.argb, sizeof(dest_data)) | |
nd enter deep sleep mode.
uint8_t unused;
prv_read_register(HRM, ADDR_SYNC, &unused);
PPG_DBG("Handshake handle done");
HRM->state->handshake_count++;
PROFILER_NODE_STOP(hrm_handling);
mutex_unlock(HRM->state->lock);
// PPG_DBG log out each PPG data sample that we recorded
for (int i = 0; i < data... | {
break;
} |
system_task_watchdog_feed();
psleep(1);
}
return (attempt < max_attempts);
}
// Wait for the INT line to go high. Return true if it went high before timing out
static bool prv_wait_int_high(HRMDevice *dev) {
const int max_attempts = 300;
int attempt;
for (attempt = 0; attempt < max_attempts; attempt... |
(fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
}
// Teardown
void test_graphics_draw_stroke_precise_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
#define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168)
#define ORIGIN_RECT_CLIP_XY GRect(0, 0, 30, 40)
#define ORIGIN_RECT_CLIP_NXNY GRect(0, 0, 30, 40)
... | |
PacketTypeResetComplete,
};
static PPoGATTPacket s_server_reset_request = (const PPoGATTPacket) {
.sn = 0,
.type = PPoGATTPacketTypeResetRequest,
};
static PPoGATTPacket * s_client_reset_request;
static uint16_t s_client_reset_request_size;
static PPoGATTPacket * s_client_reset_complete;
static uint16_t s_client... | if (s_ppogatt_version > 0) {
expected_response.payload = (const PPoGATTResetCompleteClientIDPayloadV1) {
.ppogatt_max_rx_window = PPOGATT_V1_DESIRED_RX_WINDOW_SIZE,
.ppogatt_max_tx_window = PPOGATT_V0_WINDOW_SIZE,
};
} | |
gatt_id(ListNode *found_node, void *data) {
const unsigned int connection_id = (uintptr_t) data;
const GAPLEConnection *connection = (const GAPLEConnection *) found_node;
return (connection->gatt_connection_id == connection_id);
}
static GAPLEConnection * prv_find_connection_by_gatt_id(uintptr_t connection_id) {... | gap_le_connect_params_cleanup_by_connection(connection) | ;
gatt_client_discovery_cleanup_by_connection(connection, BTErrnoServiceDiscoveryDisconnected);
gatt_client_subscriptions_cleanup_by_connection(connection, false /* should_unsubscribe */);
gatt_client_cleanup_discovery_jobs(connection);
list_remove(&connection->node, (ListNode **) &s_connections, NULL);
bt_c... |
(token + strlen(token) + 1, "%d", &state->test_entry.version);
} else if (strcmp(token, "TEST_TOTAL") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.total.value);
} else if (strcmp(token, "TEST_TOTAL_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entr... | 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, &plugged_in);
} else {
cl_assert(false);
}
fflush(stdout);
PBL_ASSERTN(state->test_entry.num_samples < SLEEP_SAMPLES_... |
F) && (read_buffer != 0xAA)) || (test_addr == base_addr)) {
if (display_logs) {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Erasing Addr 0x%"PRIx32, test_addr);
}
flash_erase_sector_blocking(test_addr);
// Verify data was erased
status = prv_read_verify_byte(test_addr, 0x... | for (bit_offset = 1, bitpos = 0; bit_offset & addr_mask; bit_offset <<= 1, bitpos++) {
if (bit_offset > base_addr) {
test_addr = bit_offset;
} else if (bit_offset == base_addr) {
base_addr_pos = bitpos;
// Skip base address check - that is done later
PBL_LOG(LOG_LEVEL_DEBUG, "Skip base a... |
// Special case - test bit for base address
// - Use an address between FLASH_TEST_ADDR_START and base_addr
PBL_LOG(LOG_LEVEL_DEBUG, ">> Testing special case for base address bit %d", base_addr_pos);
// Read initial value
test_addr = FLASH_REGION_FILESYSTEM_BEGIN;
uint32_t special_case_addr = test_addr... |
{ 1240, 400, -368},
{ 1368, 520, -336},
{ 1376, 576, -392},
{ 1240, 616, -448},
{ 1040, 784, -560},
{ 936, 920, -632},
{ 928, 872, -584},
{ 1176, 1056, -544},
{ 1032, 704, -408},
{ 1184, 656, -344},
{ 1424, 608, -264},
{ 1488, 424, -56},
{ 1240, 216, -176},
{ 113... | { 1248, 528, -288},
{ 1512, 408, -240},
{ 1272, 240, -168},
{ 1104, 184, -144},
{ 1120, 192, -184},
{ 1248, 160, -128},
{ 1192, 128, -128},
{ 1200, 136, -208},
{ 1048, -136, -120},
{ 512, -456, -136},
{ 848, -304, -288},
{ 728, -176, -336},
{ 1160, 0, -320},
// 47... |
{ 1432, 0, -536},
{ 1184, 32, -472},
{ 1104, 232, -456},
{ 1160, 328, -400},
{ 1304, 528, -456},
{ 1304, 640, -520},
{ 952, 800, -656},
{ 784, 952, -648},
{ 760, 904, -472},
{ 1128, 912, -408},
{ 1160, 760, -312},
{ 1408, 680, -312},
{ 1424, 552, -376},
{ 1160, 4... |
tus_pos_y = PBL_IF_RECT_ELSE(142, 144),
.status_height = 20,
};
static const PhoneStyle s_phone_style_large = {
.icon_size = PBL_IF_RECT_ELSE(TimelineResourceSizeSmall, TimelineResourceSizeLarge),
.icon_pos = { ICON_POSITION_X, PBL_IF_RECT_ELSE(11, 22) },
.caller_id_pos_y = PBL_IF_RECT_ELSE(80, 88),
.caller_... | (kino_reel, icon_to) | ;
kino_reel_transform_set_transform_duration(kino_reel, UNFOLD_DURATION);
kino_reel_scale_segmented_set_deflate_effect(kino_reel, UNFOLD_EXPAND);
kino_layer_set_reel(&s_phone_ui_data->icon_layer, kino_reel, true);
kino_layer_play(&s_phone_ui_data->icon_layer);
s_phone_ui_data->current_icon = image;
s_phone_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&ctx, fb) | |
ager->mutex);
// Find this timer
TaskTimer* timer = prv_find_timer(manager, timer_id);
PBL_ASSERTN(!timer->defer_delete);
// If this timer is currently executing it's callback, return false if
// TIMER_START_FLAG_FAIL_IF_EXECUTING is on
if (timer->executing && (flags & TIMER_START_FLAG_FAIL_IF_EXECUTING))... | PBL_ASSERTN(list_contains(manager->running_timers, &timer->list_node)) | ;
list_remove(&timer->list_node, &manager->running_timers /* &head */, NULL /* &tail */);
manager->idle_timers = list_insert_before(manager->idle_timers, &timer->list_node);
}
timer->repeating = false; // In case it's currently executing, make sure we don't reschedule it
// If it's currently executing, d... |
_args, ArgsForMock *last_args) {
memcpy(actual_args, last_args, sizeof(ArgsForMock));
}
// Zero out the arguments from the last run
static void reset_last_args_for_mock() {
memset(&s_last_args_for_mock, 0x00, sizeof(s_last_args_for_mock));
}
// Validate the arguments based on the shape that is drawn
static bool v... | cl_assert(gcolor_equal(context.draw_state.stroke_color, GColorBlack)) | ;
// Fill Color
graphics_context_set_fill_color(&context, GColorClear);
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb);
color = GColorOrange;
graphics_context_set_fill_color(&context, color);
#if PBL_COLOR
cl_assert_equal_i(context.draw_state.fill_color.argb, GColorOrange.argb);
#... |
func_obj_val,
const jerry_value_t this_val,
const jerry_value_t args_p[],
jerry_size_t args_count) {
if (!jerry_value_is_function(func_obj_val)) {
return TYPE_ERROR_ARG;
}
return (jerry_value_t)EM_ASM_INT({... | __jerryRefs.setNativeHandle($0, $1, $2) | ;
}, obj_val, handle_p, freecb_p);
}
void emscripten_call_jerry_object_free_callback(jerry_object_free_callback_t freecb_p,
uintptr_t handle_p) {
if (freecb_p) {
freecb_p(handle_p);
}
}
//////////////////////////////////////////////////////////////////////////... |
ESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */);
resource_init();
}
void test_simple_dialog__cleanup(void) {
free(fb);
gbitmap_destroy(s_dest_bitmap);
s_dest_bitmap = NULL;
}
// Helpers
//////////////////////
void prv_push_and_render_simple_dialog(Dialog *dialog) {
gbitmap_dest... | gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE) | );
}
void test_simple_dialog__calendar_unmute(void) {
SimpleDialog *simple_dialog = simple_dialog_create("Calendar Unmute");
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
dialog_set_text(dialog, "Calendar Unmuted");
dialog_set_icon(dialog, RESOURCE_ID_RESULT_MUTE_LARGE);
dialog_set_timeout(dialog... |
1112, 320, -80},
{ -1056, 448, -64},
// 44 seconds
{ -1136, 480, -112},
{ -1168, 544, -88},
{ -800, 552, -120},
{ -480, 512, -152},
{ -384, 496, -144},
{ -408, 480, -104},
{ -520, 488, -64},
{ -752, 504, -104},
{ -896, 816, -56},
{ -968, 712, -168},
{ -1096, 800, -32}... | { -352, 880, -632},
{ -544, 976, -512},
{ -592, 1024, -368},
{ -520, 632, -168},
{ -616, 752, -320},
{ -656, 696, -280},
{ -712, 584, -64},
{ -688, 416, 256},
{ -608, 272, 328},
{ -664, 728, 40},
{ -616, 624, 88},
{ -680, 480, 224},
{ -680, 616, 120},
{ -920, 720,... |
{ -576, 400, -72},
{ -776, 480, -32},
{ -968, 576, -64},
{ -1112, 608, -40},
{ -1648, 704, -112},
{ -1176, 632, -88},
{ -952, 496, -88},
{ -1040, 608, -144},
{ -864, 408, 8},
{ -576, 304, 24},
{ -400, 368, -24},
{ -360, 336, -40},
{ -360, 288, -8},
{ -472, 264, 2... |
/*
* 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 (connection_is_valid(connection)) {
list_remove((ListNode *)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;
}
... |
prv_unlock();
}
bool connection_is_valid(Connection *connection) {
bool rv;
prv_lock();
{
rv = list_contains((ListNode *)s_connections, (const ListNode *)connection);
}
prv_unlock();
return rv;
}
static bool prv_connection_by_idx_list_filter_cb(ListNode *found_node, void *data) {
uint16_t conn_id... |
----------------------------------------------------------------------
//! Convenience function to apply a function to each intent matching or resolving to a device
//! bt_lock is assumed to be taken before calling this function.
static void prv_apply_fuction_to_intents_matching_connection(const GAPLEConnection *connec... | (LOG_LEVEL_WARNING, "Watch driven BLE connection cancel unimplemented") | |
, 3666, true,
"1 hour, 1 minute, and 6 seconds",
1,
},
{ "'%aT')", 3666, true,
"1 hr 1 min 6 sec",
1,
},
{ "'%auT')", 3666, true,
"1 hour, 1 minute, and 6 seconds",
1,
},
{ "'%0uT')", 3666, true,
"01 hour, 01 minute, and 06 seconds",
1,
},
{ "'%fT')", 129666, true,
"3... | cl_assert_equal_s(s_output, test->expect_str) | ;
cl_assert_equal_i(s_cond.eval_time, test->expect_eval_time);
#if DEBUG_PRINTING
printf("\n");
#endif
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Test pipeline parser
static const struct {
const char *instr;
time_t intime;
const char *e... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | while (current_offset + sizeof(marker) < max_size) {
if (sizeof(marker) != sys_resource_load_range(app_num, resource_id, current_offset,
(uint8_t*)&marker, sizeof(marker))) {
return -1;
}
// Need to byte swap it
marker.length = ntohl(marker.length);
marker.chunk_ty... |
return -1; // Error
}
GBitmap* gbitmap_create_from_png_data(const uint8_t *png_data, size_t png_data_size) {
GBitmap *bitmap = applib_type_malloc(GBitmap);
if (bitmap) {
memset(bitmap, 0, sizeof(GBitmap));
gbitmap_init_with_png_data(bitmap, png_data, png_data_size);
}
return bitmap;
}
bool gbitmap_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(b->data[0], b1) | |
clude "graphics_private.h"
#include "gtypes.h"
#include "system/passert.h"
#include "util/bitset.h"
#include "util/math.h"
// ## Point setting/blending functions
#if PBL_COLOR
T_STATIC inline void set_pixel_raw_8bit(GContext* ctx, GPoint point) {
if (!grect_contains_point(&ctx->dest_bitmap.bounds, &point)) {
re... | {
// Couldn't capture framebuffer
return;
} | |
*
* 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 Lice... | smartstrap_connection_got_valid_data() | |
s/common/analytics/analytics.h"
#include <string.h>
//! Make a resolution of 100. Working in integer duty cycles on the following ranges:
//!
//! For a 2-direction, rotating vibe (PWM actuates an H-Bridge):
//! [0, 49] : Full-strength reverse rotation to zero-strength reverse rotation.
//! 50 : No rotation stren... | analytics_inc(ANALYTICS_DEVICE_METRIC_VIBRATOR_ON_COUNT, AnalyticsClient_System) | ;
analytics_stopwatch_start(ANALYTICS_APP_METRIC_VIBRATOR_ON_TIME, AnalyticsClient_App);
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_VIBRATOR_ON_TIME, AnalyticsClient_System);
} else if (!on && s_on) {
analytics_stopwatch_stop(ANALYTICS_APP_METRIC_VIBRATOR_ON_TIME);
analytics_stopwatch_stop(ANAL... |
_utc = timestamp,
.pin_open_create_update.parent_id = *parent_id,
};
#if LOG_DOMAIN_ANALYTICS
char uuid_string[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(&event_blob.pin_open_create_update.parent_id, uuid_string);
ANALYTICS_LOG_DEBUG("pin %s event: timestamp: %"PRIu32", uuid:%s", verb,
... | ANALYTICS_LOG_DEBUG("canned response failed event: response_size_bytes:%d",
event_blob.canned_response.response_size_bytes) | ;
}
analytics_logging_log_event(&event_blob);
}
// ------------------------------------------------------------------------------------------
// Log a voice response event
void analytics_event_voice_response(AnalyticsEvent event_type, uint16_t response_size_bytes,
uint16_t resp... |
list_find(&s_seconds_callbacks, prv_callback_registered_filter, &cb->list_node) | ||
list_find(&s_minutes_callbacks, prv_callback_registered_filter, &cb->list_node));
}
// ------------------------------------------------------------------------------------------
bool regular_timer_is_scheduled(RegularTimerInfo *cb) {
PBL_ASSERTN(s_callback_list_semaphore);
mutex_lock(s_callback_list... | |
// |
// '->grand_child_a
//
cl_assert(parent.first_child == NULL);
layer_add_child(&parent, &child_a);
cl_assert(parent.first_child == &child_a);
layer_add_child(&parent, &child_b);
cl_assert(parent.first_child == &child_a);
cl_assert(child_a.next_sibling == &child_b);
cl_assert... | cl_assert(parent.first_child == &child_b) | ;
cl_assert(child_b.next_sibling == &child_c);
cl_assert(child_c.parent == &parent);
cl_assert(child_c.next_sibling == &child_a);
cl_assert(child_a.next_sibling == NULL);
}
void test_layer__traverse(void) {
Layer *stack[5];
uint8_t current_stack = 0;
Layer *a = layer_create(GRectZero);
Layer *aa = lay... |
vent) {
process_manager_send_event_to_process(CONSUMER_TASK, &event);
}
}
static void prv_do_deferred_delete_cb(void *context) {
s_deferred_delete_queued = false;
mutex_lock(s_attr_list_lock);
SmartstrapAttributeInternal *attr = s_attr_head;
while (attr) {
SmartstrapAttributeInternal *next = NEXT_ATT... | if (service_id) {
syscall_assert_userspace_buffer(service_id, sizeof(uint16_t));
} |
if (attribute_id) {
syscall_assert_userspace_buffer(attribute_id, sizeof(uint16_t));
}
if (length) {
syscall_assert_userspace_buffer(length, sizeof(size_t));
}
}
if (service_id) {
*service_id = attr->service_id;
}
if (attribute_id) {
*attribute_id = attr->attribute_id;
}
... |
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 License.
*... | cl_assert(fread(buf, 1, st.st_size, file) > 0) | ;
int fd = pfs_open(pfs_name, OP_FLAG_WRITE, FILE_TYPE_STATIC, st.st_size);
cl_assert(fd >= 0);
cl_assert(st.st_size == pfs_write(fd, buf, st.st_size));
pfs_close(fd);
}
/* Start of test */
static const AppInstallId CRAZY_ID = 171717;
bool app_install_get_entry_for_uuid(const Uuid *uuid, AppInstallEntry *e... |
_args__cleanup(void) {
jerry_cleanup();
rocky_runtime_context_deinit();
fake_pbl_malloc_check_net_allocs(); // Make sure no memory was leaked
}
void test_rocky_api_util_args__missing_args(void) {
JERRY_ARGS_MAKE(/* argc == 0 */);
uint8_t v;
ROCKY_ARGS_ASSIGN(ROCKY_ARG(v));
ASSERT_JS_ERROR(error_value, ... | jerry_create_number(c->u8) | ,
jerry_create_number(c->u16),
jerry_create_number(c->u32),
jerry_create_number(c->u64),
jerry_create_number(c->s8),
jerry_create_number(c->s16),
jerry_create_number(c->s32),
jerry_create_number(c->s64),
jerry_create_number(c->d),
);
ROCKY_ARGS_ASS... |
/*
* 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... | {
int num_attributes;
int header_size;
if (type == AttributeGroupType_Action) {
header_size = sizeof(SerializedActionHeader);
num_attributes = ((SerializedActionHeader *)data)->num_attributes;
} else {
header_size = sizeof(SerializedAddressHeader);
num_attributes = ((SerializedAd... | |
Normally,
StationaryAnalyticsEnterFromPeek,
StationaryAnalyticsExitNormally,
StationaryAnalyticsExitToPeek,
StationaryAnalyticsEnterCharging,
StationaryAnalyticsExitCharging,
StationaryAnalyticsEnableStationaryMode,
StationaryAnalyticsDisableStationaryMode
} StationaryAnalytics;
//! The possible states t... | {
prv_watch_is_in_motion();
} |
}
//! Called every minute to determine whether any motion has occured since the last time
//! the call was made. The current position is updated at this time
static void prv_stationary_check_timer_cb(void *unused_data) {
//! All stationary events need to be handled by kernel main
launcher_task_add_callback(prv_st... |
Y,
.mday = CRON_MDAY_ANY,
.month = CRON_MONTH_ANY,
.may_be_instant = true,
.clock_change_tolerance = 0,
};
CronJob *job = &test_cron;
time_t base = s_2015_nov12_123456_gmt;
prv_set_rtc(base, &s_timezone_gmt);
// 2015 Nov 12, 12:35:00
int32_t target = 1447331700;
cron_clear_all_jobs();
... | {
CronJob *job = &test_cron[4 - i - 1];
cron_job_schedule(job);
cl_assert_equal_i((uintptr_t)job->cb_data, 0);
cl_assert_equal_i(job->cached_execute_time, timestamps[4 - i - 1]);
cl_assert_equal_i(cron_service_get_job_count(), i+1);
} |
time_t left = s_2015_nov12_123456_gmt;
for (int i = 0; i < 4; i++) {
fake_rtc_increment_time(timestamps[i] - left);
left = timestamps[i];
cron_service_wakeup();
cl_assert_equal_i(cron_service_get_job_count(), 4 - i - 1);
for (int l = 0; l < 4; l++) {
cl_assert_equal_i((uintptr_t)test_cro... |
ocusable window 1
window_set_focusable(windows[2][1], false);
window_stack_push(window_stacks[2], windows[2][1], false);
// An unfocusable window is now the top window
// Test: Opaque windows that are not the top window have no affect on unfocusable
// Test: One unfocusable top window results in Unfocused
... | {
for (int i = 0; i < num_windows_per_stack; i++) {
window_stack_remove(windows[idx][i], false);
window_destroy(windows[idx][i]);
}
} |
}
void test_window_stack__modal_properties_enable_disable(void) {
// Enable all modals
modal_manager_set_min_priority(ModalPriorityMin);
Window *window1 = window_create();
modal_window_push(window1, ModalPriorityGeneric, false);
modal_manager_event_loop_upkeep();
cl_assert_equal_i(modal_manager_get_prop... |
outside of packable range!
top_byte = ((top_byte & 0b00111000) >> 1) | (top_byte & 0b11);
bits = (top_byte << 24) | (bits & 0xffffff);
bits >>= 1;
return bits;
}
// Unpack a function pointer previously packed by prv_custom_curve_ptr_pack
static AnimationCurveFunction prv_custom_curve_ptr_unpack(uintptr_t bits)... | (animation) | ;
}
const uint32_t now = animation_legacy2_get_ms_since_system_start();
animation->abs_start_time_ms = now + animation->delay_ms;
if (animation->implementation->setup != NULL) {
animation->implementation->setup(animation);
}
const bool old_head_is_animating = animation_legacy2_scheduler->head
... |
oday - (1 * SECONDS_PER_MINUTE), // 11:59pm
.length_min = (2 * MINUTES_PER_HOUR) + 39,
.type = ActivitySessionType_Sleep,
},
};
uint16_t session_entries = ARRAY_LENGTH(sessions);
activity_algorithm_post_process_sleep_sessions(session_entries, sessions);
cl_assert_equal_i(sessions... | prv_create_test_data(num_minutes, minute_data) | ;
// Zero out the first hour of data. The sleep algorithm takes an hour to figure out that
// you are sleeping, so it has no chance of zeroing out all the steps in that first hour.
for (int i = 0; i < 60; i++) {
minute_data[i].base.steps = 0;
}
time_t start_utc = rtc_get_time();
// Set to sleeping fo... |
/*
* 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... | (mem_write, sizeof(mem_write)) | ;
struct __attribute__((packed)) {
uint32_t copy_address;
uint32_t length;
} send_data_cmd_payload = {
.copy_address = address,
.length = data_len
};
dialog_spi_transmit_data((uint8_t *)&send_data_cmd_payload, sizeof(send_data_cmd_payload));
dialog_spi_wait_for_int();
dialog_spi_start_cmd... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.