prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
governing permissions and
* limitations under the License.
*/
#include "drivers/accessory.h"
#include "drivers/rtc.h"
#include "kernel/pebble_tasks.h"
#include "services/normal/accessory/smartstrap_comms.h"
#include "services/normal/accessory/smartstrap_link_control.h"
#include "services/normal/accessory/smartstrap... | PBL_LOG(LOG_LEVEL_WARNING, "Invalid link control response (type=%d).", s_type) | ;
if (s_type == LinkControlTypeStatus) {
prv_fatal_error_strike();
} else if (!s_profiles) {
smartstrap_link_control_disconnect();
}
return false;
}
s_strikes = 0;
if (header->type == LinkControlTypeStatus) {
// status message
const LinkControlStatus status = header->data[0];
... |
and CPHA bits
tmpreg &= CR1_CLEAR_MASK;
// get the baudrate prescaler
uint32_t prescaler = prv_spi_find_prescaler(bus);
// Master mode, 8 bit Data Size and Soft Slave select are hardcoded
// Direction, CPOL, CPHA, baudrate prescaler and first-bit come from the device config
tmpreg |= (uint16_t)((uint32_t)sl... | (slave, out, len) | ;
prv_spi_release_helper(slave);
}
void spi_slave_burst_read_write(const SPISlavePort *slave, const void *out, void *in, size_t len) {
prv_spi_acquire_helper(slave);
spi_ll_slave_burst_read_write(slave, out, in, len);
prv_spi_release_helper(slave);
}
void spi_slave_burst_read_write_scatter(const SPISlavePort ... |
clean up their act(ivity sessions) and save off
// any new data they have (only to RAM...persisted to flash a few lines later).
activity_algorithm_early_deinit();
// Update storage before we close down
s_activity_state.update_settings_counter = -1;
prv_update_storage(rtc_get_time());
PBL_LOG(LOG_LEVEL_DE... | {
const bool enable = prv_activity_allowed_to_be_enabled();
if (enable == s_activity_state.started) {
// No change in enabled state, we're done.
goto cleanup;
}
if (enable) {
// We just got enabled, re-start activity tracking if it should be in the started state
if (s_activity_... |
cleanup:
mutex_unlock_recursive(s_activity_state.mutex);
}
static void prv_handle_activity_enabled_change(void) {
if (activity_tracking_on() && !prv_activity_allowed_to_be_enabled()) {
prv_stop_tracking_early();
}
system_task_add_callback(prv_set_enable_cb, NULL);
}
static void prv_charger_event_cb(Pebb... |
e service_refs[num_services];
const Service *bp_service = fake_gatt_get_blood_pressure_service();
uint8_t num_found_services = gatt_client_copy_service_refs_matching_uuid(&device, service_refs,
num_services,
... | (2, refs_out) | ;
const Uuid uuid1 = gatt_client_service_get_uuid(service_refs_out[0]);
const Uuid uuid2 = gatt_client_service_get_uuid(service_refs_out[0]);
cl_assert(uuid_equal(&uuid1, &thermo_service->uuid) ||
uuid_equal(&uuid1, &random_128bit_service->uuid));
cl_assert(uuid_equal(&uuid2, &thermo_service->uuid) ... |
e:
status = VoiceStatusRecognizerResponseError;
break;
case VoiceEndpointResultFailTimeout:
case VoiceEndpointResultFailRecognizerError:
case VoiceEndpointResultFailInvalidMessage:
default:
status = VoiceStatusErrorGeneric;
break;
}
return status;
}
void voice_init(void) {
... | {
goto unlock;
} | |
GlanceSettingsState {
BatteryChargeState battery_charge_state;
bool is_pebble_app_connected;
bool is_airplane_mode_enabled;
bool is_quiet_time_enabled;
#if CAPABILITY_HAS_BUILTIN_HRM
bool is_sharing_hrm;
#endif
} LauncherAppGlanceSettingsState;
typedef struct LauncherAppGlanceSettings {
char title[APP_NAME... | (ctx, battery_silhouette_color) | ;
// Draw the battery silhouette
const GRect battery_silhouette_frame = (GRect) {
.origin = rect->origin,
.size = battery_silhouette_icon_size,
};
gpath_draw_filled(ctx, &battery_silhouette_path);
// Inset the filled area
GRect battery_fill_rect = grect_inset_internal(battery_silho... |
for (sn = s_tx_window_size; sn < 2 * s_tx_window_size; ++sn) {
cl_assert_equal_b(fake_comm_session_send_buffer_write_raw_by_transport(transport,
s_short_data_fragment,
sizeof(s_short_data_fragm... | fake_comm_session_send_buffer_write_raw_by_transport(transport,
s_short_data_fragment,
sizeof(s_short_data_fragment) - sn) | , true);
ppogatt_send_next(transport);
prv_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn,
s_short_data_fragment, sizeof(s_short_data_fragment) - sn);
if (sn == 0 || sn == 1) {
// Make the first and second packet time out each, one second earlier
//... |
GColorGreenARGB8);
cl_assert_equal_i(s_stroke_width, 2);
cl_assert_equal_i(s_path_num_points, 2);
cl_assert_equal_b(s_path_open, false);
cl_assert_equal_i(s_path_fill_count, 1);
cl_assert_equal_i(s_path_stroke_count, 1);
cl_assert(prv_compare_points(points2, s_stroke_points, s_path_num_points));
cl_assert... | cl_assert_equal_i(s_path_num_points, 1) | |
nclude "system/passert.h"
#include "util/math.h"
#include "util/ratio.h"
#ifdef DEBUG_BATTERY_STATE
#define BATTERY_SAMPLE_RATE_MS 1000
#else
#define BATTERY_SAMPLE_RATE_MS (60 * 1000)
#endif
typedef void (*EntryFunc)(void);
typedef enum {
ConnectionStateInvalid,
ConnectionStateChargingPlugged,
ConnectionState... | {
if (charging) {
return ConnectionStateChargingPlugged;
} else {
return ConnectionStateDischargingPlugged;
}
} | else {
if (charging) {
// Since we can't be charging and disconnected,
// just log a warning and pretend we aren't charging.
PBL_LOG(LOG_LEVEL_WARNING, "PMIC reported charging while unplugged - ignoring");
}
return ConnectionStateDischargingUnplugged;
}
}
static void prv_update_state(v... |
///////////////
#include "stubs_app_state.h"
#include "stubs_applib_resource.h"
#include "stubs_compiled_with_legacy2_sdk.h"
#include "stubs_heap.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_print.h"
#include "stubs_resources.h"
#... | (&t, &t_c) | );
cl_assert(gtransform_is_only_scale(&t));
cl_assert(gtransform_is_only_scale(&t_c));
t_c = GTransformScaleFromNumber(2, 5);
cl_assert(gtransform_is_equal(&t, &t_c));
// Test Translation Matrix
t = GTransformTranslation(GTransformNumberFromNumber(2), GTransformNumberFromNumber(5));
t_c = GTransformFrom... |
day_start = time_util_get_midnight_of(rtc_get_time());
ActivitySession walk_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,
.distanc... | (&walk_activity) | ;
// Pretend that 24 hours has elapsed since we saved prefs. This should put both the step and
// sleep history 1 day behind
struct tm time_tm = s_init_time_tm;
time_tm.tm_mday += 1;
time_t utc_sec = mktime(&time_tm);
rtc_set_time(utc_sec);
prv_activity_init_and_set_enabled(true);
ASSERT_EQUAL_METRIC_... |
bled_charging_state;
}
// ------------------------------------------------------------------------------------------------
// If necessary, change the sampling period of our heart rate subscription
// @param[in] now_ts number of seconds the system has been running (from time_get_uptime_seconds())
static void prv_hear... | {
ACTIVITY_LOG_DEBUG("HR bpm: %"PRIu8", qual: %"PRId8" ", hrm_event->bpm.bpm,
(int8_t) hrm_event->bpm.quality);
// Perform a basic validity check so we only proceed with reasonable data
// TODO: Use quality to filter out some readings,
// TODO PBL-40784: Use HRMQuality_OffWrist a... |
.resting_bpm = s_activity_state.hr.metrics.resting_bpm,
.quality = hrm_event->bpm.quality,
.is_filtered = false,
},
},
};
event_put(&event);
}
mutex_unlock_recursive(s_activity_state.mutex);
}
// Modify our sampling pe... |
{
HRM_LOG("Unsubscribing");
bool success = false;
mutex_lock_recursive(s_manager_state.lock);
HRMSubscriberState *state = prv_get_subscriber_state_from_ref(session);
if (state) {
prv_remove_and_free_subscription(state);
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
success = t... | prompt_command_continues_after_returning() | ;
}
HRMAccelData * hrm_manager_get_accel_data(void) {
mutex_lock(s_manager_state.accel_data_lock);
return &s_manager_state.accel_data;
}
void hrm_manager_release_accel_data(void) {
s_manager_state.accel_data.num_samples = 0; // Reset buffer
mutex_unlock(s_manager_state.accel_data_lock);
}
void hrm_manager_pr... |
/*
* 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 (zone_time_s == 0) {
strncpy(buffer, EN_DASH, buffer_size);
return;
} |
health_util_format_hours_and_minutes(buffer, buffer_size, zone_time_s, i18n_owner);
}
Window *health_hr_detail_card_create(HealthData *health_data) {
HealthHrDetailCardData *card_data = app_zalloc_check(sizeof(HealthHrDetailCardData));
const int32_t zone1_minutes = health_data_hr_get_zone1_minutes(health_data... |
P_FIXTURE_NAME, filename_buf);
app_storage_get_file_name(filename_buf, sizeof(filename_buf), 1,
PebbleTask_Worker);
load_fixture_on_pfs(APP1_WORKER_FIXTURE_NAME, filename_buf);
resource_storage_get_file_name(filename_buf, sizeof(filename_buf), 1);
load_fixture_on_pfs(APP1_RESOURCES_F... | cl_assert_equal_b(false, app_install_get_uuid_for_install_id(INSTALL_ID_INVALID, &uuid)) | ;
cl_assert_equal_uuid(uuid, UUID_INVALID);
cl_assert_equal_b(true, app_install_get_uuid_for_install_id(tictoc_id, &uuid));
cl_assert_equal_uuid(uuid, tictoc_uuid);
cl_assert_equal_b(true, app_install_get_uuid_for_install_id(music_id, &uuid));
cl_assert_equal_uuid(uuid, music_uuid);
cl_assert_equal_b(true... |
/*
* 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... | SPI_StructInit(&spi_cfg) | ;
spi_cfg.SPI_Direction = SPI_Direction_1Line_Tx; // Write-only SPI
spi_cfg.SPI_Mode = SPI_Mode_Master;
spi_cfg.SPI_DataSize = SPI_DataSize_8b;
spi_cfg.SPI_CPOL = SPI_CPOL_Low;
spi_cfg.SPI_CPHA = SPI_CPHA_1Edge;
spi_cfg.SPI_NSS = SPI_NSS_Soft;
spi_cfg.SPI_BaudRatePrescaler =
spi_find_prescaler(s_spi... |
E,
.info.format = GBitmapFormat2BitPalette,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = { .size = { WIDTH, HEIGHT } },
.palette = s_palette,
};
memset(s_data, 0, sizeof(s_data));
for (int y = 0; y < HEIGHT; ++y) {
for (int x = 0; x < WIDTH; ++x) {
packed_pixel_set(s_data, x /* c... | {
prv_4bit_simple(GCompOpSet, GColorWhite, false /* opaque */);
} |
void test_bitblt_palette__4Bit_set_transparent(void) {
prv_4bit_simple(GCompOpSet, GColorWhite, true /* transparent */);
}
void test_bitblt_palette__4Bit_comptint_opaque(void) {
prv_4bit_simple(GCompOpTint, GColorBlack, false /* opaque */);
prv_4bit_simple(GCompOpTint, GColorBlue, false /* opaque */);
}
void ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | DEFINE_SYSCALL(DataLoggingSessionRef, sys_data_logging_create, uint32_t tag,
DataLoggingItemType item_type, uint16_t item_size,
void *buffer, bool resume) | {
return dls_create_current_process(tag, item_type, item_size, buffer, resume);
}
DEFINE_SYSCALL(void, sys_data_logging_finish, DataLoggingSessionRef session_ref) {
// TODO: It would be nice to verify the session itself, because they could be
// passing us any memory address (not necesarilly a valid DataLogging... |
mpty.
if ((s_valid_page_idx >= SPRF_NUM_PAGES) ||
(prv_get_magic_for_page(s_valid_page_idx) != SprfMagic_UnpopulatedEntry)) {
PBL_LOG(LOG_LEVEL_WARNING, "Ran out of pages or found corrupted next page, erasing region");
// NOTE: This should not happen often. On boot, we delete and rewrite the region if >... | FIELD_CRC_FROM_FIELD(field_out) | ;
if (written_crc == SPRF_UNWRITTEN_CRC) {
// If empty field, return that we have invalid data too
return false;
}
return true;
}
#define SPRF_PERSIST_FIELD(data, name) \
prv_persist_field((uint8_t *)&data, offsetof(SharedPRFData, name), sizeof(data), true)
#define SPRF_ERASE_FIELD(name) \
prv_e... |
// Write data that will be wrapped:
cl_assert_equal_b(circular_buffer_write(&buffer, (uint8_t *)"456789", 6), true);
cl_assert_equal_i(circular_buffer_copy_offset(&buffer, 2 /* start_offset */,
data_out, data_out_size), 6);
cl_assert(memcmp("456789", data_out, 6... | cl_assert_equal_b(true, caller_should_free) | ;
cl_assert_equal_m(data_out, "12345678", sizeof(storage));
free(data_out);
// Test OOM scenario:
cl_assert_equal_b(false, circular_buffer_read_or_copy(&buffer, &data_out, sizeof(storage),
prv_oom_malloc, &caller_should_free));
cl_assert_equal_p(data_ou... |
ETRICS 3
typedef enum MovementDataFields {
MD_Version,
MD_Timestamp,
MD_Steps,
MD_ActiveKCalories,
MD_RestingKCalories,
MD_Distance,
MD_ActiveTime
} MovementDataFields;
static uint32_t s_movement_data[] = {
1, // Version
NOW, // Timestamp
1234, // Steps
1111, ... | (ActivityMetricSleepTotalSeconds, Monday, &val_out) | );
// insert something with an older version (this will succeed)
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
(uint8_t *)s_invalid_sleep_data, sizeof(s_sleep_data)),
S_SUCCESS);
// check
cl_assert(!health_db_get_typical_value(ActivityM... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
}) | ;
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void handle_init(void) {
FSResourceAppData *data = (FSResourceAppData*) app_malloc_check(sizeof(FSResourceAppData));
if (data == NULL) {
PBL_CROAK("Out of memory");
}
app_state_set_us... |
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.
*/
#inc... | {
if (compositor_transition_app_to_app_should_be_skipped()) {
return NULL;
}
if (flip_to_the_right) {
static const CompositorTransition s_impl = {
.init = prv_transition_to_launcher_animation_init,
.update = prv_transition_animation_update,
};
return &s_impl;
} else {
static con... | |
return (next_state == TimelineAppStateUpDown ||
next_state == TimelineAppStateShowDaySeparator ||
next_state == TimelineAppStateStationary);
case TimelineAppStateShowDaySeparator:
return (next_state == TimelineAppStateDaySeparator);
case TimelineAppStateDaySeparator:
... | timeline_layer_get_current_layout(&data->timeline_layer) | ;
if (first_timeline_layout && use_pin) {
GRect frame;
timeline_layer_get_layout_frame(&data->timeline_layer, TIMELINE_LAYER_FIRST_VISIBLE_LAYOUT,
&frame);
timeline_layout_get_icon_frame(&frame, data->timeline_layer.scroll_direction, &icon_frame);
} else {
// Sinc... |
/*
* 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_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_across_x_origin_layer.${BIT_DEPTH_NAME}.pbi")) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_across_nx_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&lay... |
us to store on flash
header->common.flags = ~header->common.flags;
header->common.status = ~header->common.status;
int result = pfs_write(fd, (uint8_t *) header, sizeof(*header));
// Restore flags & status
header->common.flags = ~header->common.flags;
header->common.status = ~header->common.status;
if ... | if (status & TimelineItemStatusDeleted) {
// Skip over deleted notification
pfs_seek(*fd, iter_state.header.payload_length, FSeekCur);
continue;
} | |
/*
* 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... | {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) { DISP_COLS, DISP_ROWS });
} |
// Teardown
void test_framebuffer_duma__cleanup(void) {
free(fb);
}
// Intentionally unchecked framebuffer drawing function
static void draw_fb_raw(uint8_t *buffer, int offset, GColor8 color) {
buffer[offset] = color.argb;
}
// Tests
////////////////////////////////////
void test_framebuffer_duma__draw_within_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_window_stack_get_top_window() | ;
if (e->app_focus.in_focus) {
if (window) {
// Do not call 'appear' handler on window displacing modal window
window_set_on_screen(window, true, false);
window_render(window, app_state_get_graphics_context());
}
click_manager_reset(app_state_get_click_manager());
} else if (window) {
... |
s) {
prv_write_erased_header_on_page_range(0, s_pfs_page_count, 1);
}
mutex_unlock_recursive(s_pfs_mutex);
PBL_LOG(LOG_LEVEL_INFO, "FS-Format Done");
}
int pfs_sector_optimal_size(int min_size, int namelen) {
min_size += sizeof(FileHeader);
min_size += sizeof(FileMetaData);
min_size += namelen;
in... | if (read_header(pg, &pg_hdr, &file_hdr) != PageAndFileHdrValid) {
snprintf(display_buf, sizeof(display_buf), "%3d: Corrupt Sector", pg);
prompt_send_response(display_buf);
} |
char file_name[file_hdr.file_namelen + 1];
file_name[file_hdr.file_namelen] = '\0';
prv_flash_read((uint8_t *)file_name, file_hdr.file_namelen,
prv_page_to_flash_offset(pg) + FILE_NAME_OFFSET);
snprintf(display_buf, sizeof(display_buf), "%3d:\t%8s%s\t%5d\t\t0x%x\t%15d",
pg, file_name... |
(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("Fri, 12:00 PM", time_buf);
// June 11th 2015, 12:00:00 (T-24:00:00)
rtc_set_time(event_time - SECONDS_PER_DAY);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Fri, 12:00 PM", time_buf);
// June 11th 2015, 12:00:01 (T-23:5... | |
health_data);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_sleep_summary_card__render_sleep_late_start_early_end2(void) {
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
HealthData health_data = {
// Used for text
.sleep_data[0] = (8 * SECONDS_PER_H... | (s_now_utc) | |
sizeof(data_signature)) == sizeof(data_signature) &&
(ntohl(data_signature) == expected_signature))) {
return NULL;
}
// Data is the second entry after the resource signature
if (data_size) {
uint32_t output_data_size;
_Static_assert(PDCI_SIZE_OFFSET == PDCS_SIZE_OFFSET,
... | if (!command) {
return (GColor) {0};
} else {
return command->fill_color;
} |
}
void gdraw_command_set_stroke_color(GDrawCommand *command, GColor stroke_color) {
if (!command) {
return;
} else {
command->stroke_color = stroke_color;
}
}
GColor gdraw_command_get_stroke_color(GDrawCommand *command) {
if (!command) {
return (GColor) {0};
} else {
return command->stroke... |
(new_node);
new_node = NULL;
} else {
new_node->tag = tag;
new_node->message_handler = message_handler;
new_node->dropped_handler = dropped_handler;
new_node->event_handler_task = pebble_task_get_current();
new_node->buffer.storage = storage;
new_node->buffer.size = storage... | prv_lock() | ;
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(tag);
if (!inbox) {
goto unlock;
}
prv_mark_failed_if_no_writer(inbox);
if (inbox->write_failed) {
goto unlock;
}
if (!prv_check_space_remaining(inbox, length)) {
inbox->write_failed = true;
goto u... |
/*
* 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_modal_manager_render_count;
} |
ModalProperty modal_manager_get_properties(void) {
return s_modal_window_present ? ModalProperty_Exists : ModalPropertyDefault;
}
GContext* kernel_ui_get_graphics_context(void) {
static GContext s_context;
return &s_context;
}
void framebuffer_clear(FrameBuffer* f) {
}
void framebuffer_dirty_all(FrameBuffer ... |
/*
* 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 (!context) {
// Default context is the window.
context = 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... | prv_render_app() | ;
}
}
static void prv_app_will_focus_handler(PebbleEvent *e, void *context) {
Window *window = app_window_stack_get_top_window();
if (e->app_focus.in_focus) {
if (window) {
// Do not call 'appear' handler on window displacing modal window
window_set_on_screen(window, true, false);
window_re... |
/*
* 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... | memcpy(s_ad_data->data, data, length) | ;
s_ad_data->ad_data_length = length;
}
void test_ble_ad_parse__initialize(void) {
memset(s_ad_data, 0, sizeof(s_buffer_size));
}
// -----------------------------------------------------------------------------
// Consuming BLEAdData:
// ----------------------------------------------------------------------------... |
llback function is used to iterate over all keys and find the largest
//! AppInstallId currently being using.
static bool prv_each_inspect_ids(SettingsFile *file, SettingsRecordInfo *info, void *context) {
// check entry is valid
if ((info->val_len == 0) || (info->key_len != sizeof(AppInstallId))) {
return true... | (id, cb_data->entry_buf, cb_data->data) | ;
return true; // continue iteration
}
void app_db_enumerate_entries(AppDBEnumerateCb cb, void *data) {
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
return;
}
AppDBEntry *db_entry = kernel_malloc_check(sizeof(AppDBEntry));
EnumerateData cb_data = {
.cb = cb,
.data = d... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, STROKE_BIG) | ;
graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT_NXNY, RADIUS_BIG);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_origin_aa_r16_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// Medium circles
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, STROKE_SMALL);
graphics_draw_circle(&ct... |
te) {
const int from_index = to_index + prv_get_index_delta(layer);
GRect from_frame, to_frame;
prv_get_end_of_timeline_frame(layer, from_index, &from_frame);
prv_get_end_of_timeline_frame(layer, to_index, &to_frame);
PropertyAnimation *prop_animation = property_animation_create_layer_frame(
(Layer *)&l... | prv_show_day_sep(timeline_layer, slide) | ;
}
static void prv_day_sep_anim_stopped(Animation *anim, bool finished, void *context) {
TimelineLayer *timeline_layer = context;
if (finished) {
timeline_layer_unfold_day_sep(timeline_layer);
}
}
// TODO: PBL-21717 Day separator on Spalding
Animation *timeline_layer_create_day_sep_show(TimelineLayer *time... |
is just being used for padding, so we don't actually need to draw anything.
return;
}
static void prv_selection_changed_cb(struct MenuLayer *menu_layer, MenuIndex new_index,
MenuIndex old_index, void *callback_context) {
ActionMenuLayer *aml = callback_context;
if (new_index.... | window_set_click_context(BUTTON_ID_DOWN, aml) | ;
window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_handler);
window_set_click_context(BUTTON_ID_SELECT, aml);
}
void action_menu_layer_set_callback(ActionMenuLayer *aml,
ActionMenuLayerCallback cb,
void *context) {
aml->cb = cb;
... |
w = (Window *)health_detail_card_create(config);
window_set_on_screen(window, true, true);
window_render(window, &s_ctx);
return window;
}
// Tests
//////////////////////
void test_health_detail_card__render_no_data(void) {
prv_create_card_and_render(&(HealthDetailCardConfig) {});
cl_check(gbitmap_pbi_eq(&s... | {
HealthDetailCardConfig config = {
.num_headings = 1,
.headings = &(HealthDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.fill_color = GColorWhite,
#if PBL_BW
.outline_color = GColorBlack,
#endif
},
.num_subtitles = 1,
.subtitles = &(HealthDetailSub... |
void test_health_detail_card__render_crown(void) {
HealthDetailZone zones[] = DEFAULT_ZONES;
zones[1].show_crown = true;
HealthDetailCardConfig config = {
.num_headings = 1,
.headings = &(HealthDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.fill_color = GColor... |
/*
* 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_teardown_session() | |
d(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Jun 9, 4:00 PM", time_buf);
}
void test_clock__time_24h_style(void) {
char time_buf[64];
const int jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015,... | (time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | |
6"PRIu16" tia %-6"PRIu16,
data.ppg_data.indexes[i], data.ppg_data.ppg[i], data.ppg_data.tia[i]);
}
hrm_manager_new_data_cb(&data);
if (num_samples == 0 && should_expect_samples) {
analytics_inc(ANALYTICS_DEVICE_METRIC_HRM_ACCEL_DATA_MISSING, AnalyticsClient_System);
PBL_LOG(LOG_LEVEL... | {
if (gpio_input_read(&dev->int_gpio)) {
break;
}
system_task_watchdog_feed();
psleep(1);
} |
return (attempt < max_attempts);
}
// NOTE: the caller must hold the device's state lock
static void prv_disable(HRMDevice *dev) {
mutex_assert_held_by_curr_task(dev->state->lock, true);
// Turn off our watchdog timer
prv_disable_watchdog(dev);
// Make sure interrupts are fully disabled before changing st... |
e "system/passert.h"
// Dialog SDK:
#include "ble_common.h"
#include "ble_gap.h"
#include "ble_irb_helper.h"
#include "ble_mgr.h"
#include "osal.h"
#include <bluetooth/bluetooth_types.h>
#include <stdbool.h>
#include <string.h>
#include <inttypes.h>
extern bool advert_execute_cb_if_adverts_are_paused(void (*cb)(voi... | (LOG_LEVEL_DEBUG, "Local address policy in sync!") | ;
s_local_addr_state = LocalAddressState_InSync;
}
// @note: Everything below executes on ble_task to avoid locking.
static void prv_assert_is_executing_on_ble_task(void) {
ble_task_assert_is_executing_on_ble_task();
}
void local_addr_set(bool allow_cycling, const BTDeviceAddress *pinned_address) {
prv_assert_i... |
", "valB" };
for (int i = 0; i < ARRAY_LENGTH(extra_keys); ++i) {
blob_db_insert(BlobDBIdTest, (uint8_t *)extra_keys[i], key_len,
(uint8_t *)extra_values[i], value_len);
}
prv_generate_responses_from_phone();
cl_assert_equal_i(s_num_writebacks, 7);
}
void test_blob_db_sync__sync_some(v... | (pins_session == blob_db_sync_get_session_for_token(2)) | ;
cl_assert(reminders_session == blob_db_sync_get_session_for_token(3));
// Cancel the sync sessions so they get cleaned up
blob_db_sync_cancel(test_session);
blob_db_sync_cancel(pins_session);
blob_db_sync_cancel(reminders_session);
// reset fake blob db so cleanup doesn't assert
fake_blob_db_set_id(Bl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
Window window;
window_init(&window, WINDOW_NAME("Health"));
Layer *window_layer = window_get_root_layer(&window);
Layer *card_layer = health_sleep_summary_card_create(health_data);
layer_set_frame(card_layer, &window_layer->bounds);
layer_add_child(window_layer, card_layer);
window_set_background_color(... |
// Tests
//////////////////////
void test_health_sleep_summary_card__render_no_data(void) {
prv_create_card_and_render(&(HealthData) {});
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_sleep_summary_card__render_no_typical(void) {
HealthData health_data = {
.monthly_sleep_... |
/*
* 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, GColorClear) | ;
graphics_context_set_stroke_width(ctx, 10);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_stroke_width(ctx, 10)... |
/*
* 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 ram_storage_is_dirty(&s_test_db.ram_storage, is_dirty_out);
} |
bool prv_dirty_items_each_cb(RamStorageEntry *entry, void *context) {
BlobDBDirtyItem **dirty_items = context;
if (entry->flags & RamStorageFlagDirty) {
BlobDBDirtyItem *new_item = kernel_zalloc_check(sizeof(BlobDBDirtyItem) + entry->key_len);
memcpy(new_item->key, entry->key, entry->key_len);
new_ite... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | dialog_create_icon(dialog) | ;
const GSize icon_size = icon ? kino_reel_get_size(icon) : GSizeZero;
const bool show_action_bar = !workout_dialog->hide_action_bar;
const GRect *bounds = &window_root_layer->bounds;
const uint16_t icon_single_line_text_offset_px = 9;
const uint16_t small_icon_offset = (icon_size.h < 60) ? 7 : 0;
const u... |
re.NVIC_IRQChannelPreemptionPriority = (configMAX_SYSCALL_INTERRUPT_PRIORITY >> 4) - 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_EnableIRQ(OTG_FS_WKUP_IRQn);
// Trigger it. This transfers control to our I... | PBL_ASSERTN(i == NUM_MENU_ITEMS) | |
icense at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific la... | cl_assert(g_gbitmap_spalding_data_row_infos == bmp->data_row_infos) | |
{
goto error;
}
const ButtonId button_id = (ButtonId)button;
uint32_t num_presses = 1;
// If presses is NULL, default to 1; otherwise convert the char string to an integer
if (presses) {
char *end;
num_presses = MAX(0, strtol(presses, &end, 10));
// Validate the num_presses value
if (*en... | {
prompt_command_finish();
factory_reset(false /* should_shutdown */);
} | |
} else if (rtc_is_timezone_set()) {
// Otherwise, if the timezone has been set, then we assume this is a user on 3.10 and lower
// that has not touched their vibe intensity preferences.
// rtc_is_timezone_set() was chosen because it is a setting that gets written when the user
// connects their... | (AlertMaskAllOn) | ;
}
return s_mask;
}
void alerts_preferences_set_alert_mask(AlertMask mask) {
s_mask = mask;
SET_PREF(PREF_KEY_MASK, s_mask);
}
uint32_t alerts_preferences_get_notification_window_timeout_ms(void) {
return s_notif_window_timeout_ms;
}
void alerts_preferences_set_notification_window_timeout_ms(uint32_t time... |
ITY_SUMMARY_PIN_CONFIG);
return prv_push_summary_pin(pin_time_utc, now_utc, uuid, steps, total_steps_avg,
&ACTIVITY_SUMMARY_PIN_CONFIG);
}
// ------------------------------------------------------------------------------------------------
// Checks to see if we should add/update an act... | {
case ActivitySessionType_Walk: {
static const InsightCopyVariants s_walking_intros = {
.num_variants = 4,
.variants = {
i18n_noop("Didn’t that walk feel good?"),
i18n_noop("Way to keep it active!"),
i18n_noop("You got the moves!"),
i18n_noop("Gettin' y... |
return "";
}
// ------------------------------------------------------------------------------------------------
static const char *prv_get_distance_unit(void *i18n_owner) {
return health_util_get_distance_string(i18n_get("MI", i18n_owner), i18n_get("KM", i18n_owner));
}
static void prv_add_metric_duration_info... |
/*
* 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... | (dist, 1) | ;
}
{
int32_t dist = serial_distance32(0x1, 0x0);
cl_assert_equal_i(dist, -1);
}
{
int32_t dist = serial_distance32(0x0, 0xffffffff);
cl_assert_equal_i(dist, -1);
}
{
int32_t dist = serial_distance32(0xffffffff, 0x0);
cl_assert_equal_i(dist, 1);
}
{
int32_t dist = serial_d... |
ATE_WRITE_REG_ADDRESS,
TRANSFER_STATE_REPEAT_START,
TRANSFER_STATE_WRITE_ADDRESS_RX,
TRANSFER_STATE_WAIT_FOR_DATA,
TRANSFER_STATE_READ_DATA,
TRANSFER_STATE_WRITE_DATA,
TRANSFER_STATE_END_WRITE,
TRANSFER_STATE_INVALID,
} state;
bool result;
uint16_t nack_count;
}I2cTransfer;
typedef s... | if (BOARD_CONFIG.i2c_bus_configs[bus_idx].rail_ctl_fn == NULL) {
return;
} | |
GAPLEClientApp, &has_more);
cl_assert_equal_i(handle_out, BLE_CHARACTERISTIC_INVALID);
cl_assert_equal_i(value_length, 0);
// Notification will be eaten, regardless of whether it was copied:
cl_assert_equal_b(has_more, false);
cl_assert_equal_i(next_length, 0);
}
void test_... | cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientApp), true) | ;
fake_event_clear_last();
}
static void prv_assert_no_pending_events_to_kernel_and_app(void) {
cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientKernel), false);
cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientApp), false);
}
void test_gatt_client_subscriptions__cleanup_by_conne... |
c uint32_t s_movement_data[] = {
1, // Version
NOW, // Timestamp
1234, // Steps
1111, // Active K Calories
2222, // Resting K Calories
3333, // Distance
4444, // Active Time
};
static uint32_t s_old_movement_data[] = {
1, // Version... | ((uint8_t *)key, strlen(key),
(uint8_t *)s_invalid_sleep_data, sizeof(s_sleep_data)) | ,
S_SUCCESS);
// check
cl_assert(!health_db_get_typical_value(ActivityMetricSleepTotalSeconds, Monday, &val_out));
}
void test_health_db__movement_data(void) {
const char *key = "monday_movementData";
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
} |
static void prv_disable_flash_spi_clock(void) {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, DISABLE);
}
static void prv_flash_start(void) {
gpio_use(FLASH_CONFIG.spi_gpio);
// Enable the GPIOA clock
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
uint8_t altfunc = GPIO_AF_SPI1;
// Connect pins t... |
next_app_args;
EventServiceInfo fetch_event_info;
EventServiceInfo connect_event_info;
bool failed;
} AppFetchUIData;
static void prv_set_progress(AppFetchUIData *data, int16_t progress) {
progress_window_set_progress(&data->window, progress);
}
// Launch the desired app
static void prv_app_fetch_launch_app(... | event_service_client_unsubscribe(&data->fetch_event_info) | ;
event_service_client_unsubscribe(&data->connect_event_info);
}
//! Used when the app fetch process has failed
static void prv_app_fetch_failure(AppFetchUIData *data, uint8_t error_code) {
PBL_LOG(LOG_LEVEL_WARNING, "App Fetch: prv_app_fetch_failure: %d", error_code);
if (error_code == AppFetchResultUserCancel... |
alerts_get_mask() == AlertMaskAllOn);
alerts_set_mask(AlertMaskPhoneCalls);
// Should allow a phone call notification
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
// Should not allow any other notifications through
cl_assert(!alerts_should_notify_for_type(AlertInvalid));
cl_assert(!alerts_sh... | alerts_should_vibrate_for_type(AlertReminder) | );
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertReminder));
cl_assert(!alerts_should_notify_for_type(AlertOther));
cl_assert(!alerts_should_vibrate_for_type(AlertOther));
alerts_set_n... |
((const jerry_char_t *)"red") | ,
.expected_output = {
.r = 0b11,
.g = 0,
.b = 0,
.a = 0b11,
}
},
{
.input = jerry_create_string((const jerry_char_t *)"unknown-color"),
.error_msg = invalid_value_msg,
},
{
.input = jerry_create_null(),
.error_msg = type_error_msg,
... | |
GRect screen_frame) {
ScaleSegmentedData *data = applib_malloc(sizeof(ScaleSegmentedData));
if (!data) {
return NULL;
}
*data = (ScaleSegmentedData) {
.point_duration = SCALE_SEGMENTED_DEFAULT_POINT_DURATION,
.effect_duration = SCALE_SEGMENTED_DEFAULT_EFFECT_DU... | if (data) {
data->stroke_width.to = to;
data->stroke_width.to_op = to_op;
} |
}
void kino_reel_scale_segmented_set_stroke_width_curve(KinoReel *reel,
AnimationCurveFunction curve) {
ScaleSegmentedData *data = kino_reel_transform_get_context(reel);
if (data) {
data->stroke_width.curve = curve;
}
}
static AnimationProgress prv_ease... |
// Attribute Length
// Attribute text: "Test Notification"
0x54, 0x65, 0x73, 0x74, 0x20, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e,
// Attribute 2
0x02, // Attribute ID - Subtitle
0x08, 0x00, // Attribute Length
// At... | attribute_get_string(&list2, AttributeIdBody, "") | !=
attribute_get_string(&list, AttributeIdBody, ""));
attribute_list_destroy_list(&list);
kernel_free(buffer);
}
static void prv_check_app_glance_subtitle_in_attribute_list_deserializes(
const uint8_t *serialized_attribute_list_to_deserialize,
size_t serialized_attribute_list_to_deserialize_size, uint... |
eak;
}
} else if (timestamp_midnight == yesterday_midnight) {
switch (style) {
case FullStyleLower12h:
case FullStyleCapital12h:
if (with_fulltime) {
time_fmt = i18n_noop("Yesterday, %l:%M %p");
} else {
time_fmt = i18n_noop("Yesterday");
}
break... | (-difference, SECONDS_PER_HOUR, RoundTypeHalfDown) | / SECONDS_PER_HOUR;
const char *str_fmt;
if (capitalized) {
str_fmt = i18n_noop("IN %lu H");
} else if (num_hrs == 1) {
str_fmt = i18n_noop("In %lu hour");
} else {
str_fmt = i18n_noop("In %lu hours");
}
snprintf(buffer, buf_size, i18n_get(str_fmt, buffer), num_hrs);
} els... |
if (app_install_entry_is_SDK_compatible(&entry)) {
return true;
}
PBL_LOG(LOG_LEVEL_WARNING, "App requires support for SDK version (%"PRIu8".%"PRIu8"), "
"we only support version (%"PRIu8".%"PRIu8").",
entry.sdk_version.major, entry.sdk_version.minor,
(uint8_... | {
// Check if the app ram size is valid in order to determine if its SDK version is supported.
if (!app_manager_is_app_supported(md)) {
PBL_LOG(LOG_LEVEL_WARNING, "Tried to launch an app with an unsupported SDK version.");
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(id, &e... |
#endif
if (is_worker) {
worker_manager_launch_new_worker_with_args(md, NULL);
} else {
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = md,
.common = config->common,
.forcefully = config->forcefully,
});
}
}
// -----------------------------------------------------------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_timer_register(WORKER_CRASH_DELAY_MS, worker_timer_callback, NULL) | ;
}
int main(void) {
worker_init();
worker_event_loop();
}
|
atol("500") | , 500);
cl_assert_equal_i(atol("765"), 765);
cl_assert_equal_i(atol("573888"), 573888);
cl_assert_equal_i(atol("713713"), 713713);
}
void test_atol__whitespace_pfx(void) {
cl_assert_equal_i(atol(" 500"), 500);
cl_assert_equal_i(atol(" 765"), 765);
cl_assert_equal_i(atol(" 573888"), 5738... | |
624, -360},
{ 904, 648, -464},
{ 856, 440, -312},
{ 872, 384, -184},
{ 1024, 424, -232},
// 61 seconds
{ 1176, 600, -488},
{ 1344, 488, -336},
{ 1536, 280, -160},
{ 1528, 232, -296},
{ 1296, 288, -512},
{ 968, 240, -392},
{ 800, 168, -272},
{ 744, 368, -408},
{ 7... | { 1288, 32, -152},
{ 1736, 448, -320},
{ 1760, 488, -656},
{ 1768, 88, 216},
{ 1480, 128, 56},
{ 1248, 576, -336},
{ 944, 448, -232},
{ 800, 448, 24},
{ 856, 736, -64},
{ 792, 848, -48},
{ 808, 896, -144},
{ 880, 880, -216},
{ 872, 856, -304},
{ 752, 768, -304},
... |
{ 856, 528, -392},
{ 872, 552, -512},
{ 824, 544, -480},
{ 960, 576, -432},
{ 936, 624, -352},
{ 1088, 608, -200},
{ 1296, 688, -200},
{ 1096, 736, -144},
{ 1416, 776, -80},
{ 1696, 672, 64},
{ 1640, 456, 112},
{ 1392, 344, 72},
{ 1200, 304, 72},
{ 1064, 296, 72}... |
/ temporarily mark the file as in use so no one tries to use the fd once we
// release the lock
if (fd != GC_FD_HANDLE_ID) {
FileDesc *file_desc = &PFS_FD(fd);
uint8_t curr_status = file_desc->fd_status;
file_desc->fd_status = FD_STATUS_IN_USE;
mutex_unlock_recursive(s_pfs_mutex);
pfs_prepare_fo... | {
prv_flash_erase_sector(s_gc_block.gc_start_page);
} | |
/*
* 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... | {
p1 = segment->points[0];
p2 = segment->points[1];
p3 = segment->points[2];
p4 = segment->points[3];
} | |
1
success = prv_write_register(PmicRegisters_CHARGE_CURRENT_CNTL, cntl);
}
}
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not set pmic charge current.");
}
// Set EOC current to 5% of ConstantCurrent
prv_set_register_bit(PmicRegisters_CHARGE_CONFIG_2, 5, false);
if (BOARD_CONFIG_POWER.cha... | while (1) {} | |
&value, &value_length,
GAPLEClientKernel, &has_more);
// Expect untouched:
cl_assert_equal_i(characteristic_out, ~0);
cl_assert_equal_i(value, 0xff);
cl_assert_equal_b(has_more, false);
}
// ----------------------------------------------------------------------... | prv_assert_no_event() | ;
// there should be no more subscriptions
cl_assert(s_connection->gatt_subscriptions == NULL);
prv_assert_no_pending_events_to_kernel_and_app();
fake_kernel_malloc_mark_assert_equal();
}
// -------------------------------------------------------------------------------------------------
// TODO: Write tests... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
buffer[0] = '\0';
return 0;
} | |
/*
* 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... | mag3110_read(SYSMOD_REG, 1, &sysmod) | ) {
return false;
}
if (sysmod == 0) {
// We're done and we're now in standby!
return true;
}
// Wait at least 1ms before asking again
psleep(2);
}
return false;
}
// Ask the compass for a 8-bit value that's programmed into the IC at the
// factory. Useful as a sanity check... |
cfg.GPIO_Pin = (1 << FLASH_CONFIG.scs_pin);
gpio_cfg.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(FLASH_CONFIG.spi_gpio, &gpio_cfg);
// Set up a SPI bus on SPI1
SPI_InitTypeDef spi_cfg;
SPI_I2S_DeInit(FLASH_CONFIG.spi);
spi_cfg.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
spi_cfg.SPI_Mode = SPI_Mode_Master;
... | prv_flash_deep_sleep_exit() | ;
prv_disable_flash_spi_clock();
prv_flash_whoami();
}
bool flash_sanity_check(void) {
return prv_is_whoami_correct();
}
void flash_read_bytes(uint8_t* buffer, uint32_t start_addr, uint32_t buffer_size) {
if (!buffer_size) {
return;
}
prv_enable_flash_spi_clock();
prv_flash_wait_for_write();
p... |
vity_activation_delay_insight,
sizeof(s_activity_activation_delay_insight));
}
uint8_t activity_prefs_get_health_app_opened_version(void) {
return s_activity_prefs_health_app_opened;
}
void activity_prefs_set_health_app_opened_version(uint8_t version) {
if (s_activity_prefs_health_app_opened != ver... | (s_display_user_offset, mfg_info_get_disp_offsets()) | |
/*
* 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... | {
struct tm time;
localtime_r(×tamp, &time);
return clock_format_time(buffer, size, time.tm_hour, time.tm_min, true);
} |
void clock_copy_time_string(char *buffer, uint8_t size) {
time_t t = 0;
clock_copy_time_string_timestamp(buffer, size, t);
}
size_t clock_get_date(char *buffer, int buf_size, time_t timestamp) {
return prv_format_time(buffer, buf_size, i18n_noop("%m/%d"), timestamp);
}
size_t clock_get_day_date(char *buffer, ... |
ected_index, unsigned int additional_crumbs);
static void prv_prepare_canvas_and_render_for_each_size(RenderCallback callback,
const ActionMenuLevel *root_level,
unsigned int selected_index,
... | (root_level,
"I will text back",
prv_noop_action_callback,
NULL) | ;
action_menu_level_add_action(root_level,
"Sorry, I can't talk right now, call me back at a later time",
prv_noop_action_callback,
NULL);
action_menu_level_add_action(root_level,
"I will call... |
etting to zero is ignored
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_stroke_width(&context, 0);
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
// Check draw state
memset(&draw_state, 0x5A, sizeof(GDrawState));
graphics_context_set_drawing_... | prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_EVEN) | );
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle_draw_stroked_non_aa(&context, GPoint(50, 50), 10, SW_EVEN));
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_round_... |
tic int16_t prv_get_cell_height_callback(MenuLayer *menu_layer, MenuIndex *cell_index,
void *context) {
#if PBL_RECT
return 56;
#else
return menu_layer_is_index_selected(menu_layer, cell_index) ? 84 : 38;
#endif
}
static void prv_draw_row_callback(GContext *ctx, const La... | {
gbitmap_init_with_resource(&selection_window->workout_icons[i], prv_get_icon_resource_id(i));
} |
MenuLayer *menu_layer = &selection_window->menu_layer;
menu_layer_init(menu_layer, &window->layer.bounds);
menu_layer_pad_bottom_enable(menu_layer, false);
menu_layer_set_callbacks(menu_layer, selection_window, &(MenuLayerCallbacks){
.get_num_rows = prv_get_num_rows_callback,
.get_cell_height = prv_ge... |
oint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_odd_clip")));
}
void test_graphics_draw_line__dotted_cross(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test horizontal and vertical lines cross appropriat... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(36, 16), 10) | |
/*
* 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... | (RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */) | ;
resource_init();
// Setup content indicator
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
content_indicator_init_buffer(buffer);
}
void test_health_activity_detail_card__cleanup(void) {
}
// Helpers
//////////////////////
static Window* prv_create_card_and_render(HealthData *he... |
3);
}
void test_ams_util__float_string_parse_multiple_minusses(void) {
// "--.1" * 30
assert_float_parse("--.1", 30, false, 0);
}
void test_ams_util__float_string_parse_null(void) {
// NULL * 3
assert_float_parse(NULL, 3, false, 0);
}
void test_ams_util__float_string_parse_not_zero_terminated(void) {
uint8... | (count, 1) | ;
cl_assert_equal_s(one_value, s_results[0]);
}
void test_ams_util__csv_multiple_values(void) {
const char multi_values[] = "A,B,C";
const uint8_t count = ams_util_csv_parse(multi_values, sizeof(multi_values), NULL,
prv_result_callback);
cl_assert_equal_i(s_results_co... |
instr = "foo",
.output = "",
},
{ .size = 3, .intime = 1000,
.instr = "foo",
.output = "fo",
},
{ .size = 3, .intime = 1000,
.instr = "{format('foo')}",
.output = "fo",
},
{ .size = 1, .intime = 1000,
.instr = "{time_until(1004)|format('%S')}",
.output = "",
},
{ .size = 2, .... | cl_assert_equal_i(err.status, TemplateStringErrorStatus_MissingArgument) | ;
cl_assert_equal_i(err.index_in_string, 40);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Test `time_since` and `time_until` filters
static const struct {
time_t current_time;
const char *params;
intmax_t done_state;
} s_time_since_tests[] = ... |
ACTIVITY_CALORIES_PER_KCAL),
.step_data.resting_kcalories = ROUND(activity_private_compute_resting_calories(len_min),
ACTIVITY_CALORIES_PER_KCAL),
};
activity_sessions_prv_add_activity_session(&session);
activity_insights_push_... | {
*current_hr_zone_out = s_workout_data.current_workout->current_hr_zone;
} |
}
}
prv_unlock();
return rv;
}
#if UNITTEST
bool workout_service_get_avg_hr(int32_t *avg_hr_out) {
if (!avg_hr_out || !workout_service_is_workout_ongoing()) {
return false;
}
*avg_hr_out = prv_get_avg_hr();
return true;
}
bool workout_service_get_current_workout_hr_zone_time(int32_t *hr_zone_t... |
dot_ring_outer_radius_from,
dot_ring_outer_radius_to);
const int16_t dot_ring_inner_radius = interpolated_dot_ring_outer_radius - dot_radius;
// Draw the dot ring
graphics_context_set_fill_color(ctx, T... | {
return PBL_IF_RECT_ELSE(prv_modal_transition_get_rect,
prv_modal_transition_get_round)(modal_is_destination);
} | |
on/system_task.h"
#include "services/normal/stationary.h"
#include "shell/normal/battery_ui.h"
#include "shell/prefs.h"
#include "system/bootbits.h"
#include "system/passert.h"
#include "util/math.h"
#include "util/size.h"
#include "util/time/time.h"
#include "system/version.h"
#include "services/normal/activity/activ... | {
layer_remove_from_parent(status_bar_layer_get_layer(status_layer));
status_bar_layer_deinit(status_layer);
} |
// Dialog callbacks for confirmation.
////////////////////////////////////////////////////
static ConfirmationDialog *prv_settings_confirm(const char *title, const char *text,
uint32_t resource_id) {
ConfirmationDialog *confirmation_dialog = confirmation_dialog_create... |
ts = 2;
command = gdraw_command_list_get_command(command_list, 2);
command->num_points = 4;
cl_assert(!gdraw_command_list_validate(command_list, size));
command->num_points = 3;
command->type = GDrawCommandTypeCircle;
cl_assert(!gdraw_command_list_validate(command_list, size));
command->type = GDrawComman... | memcpy(command_list->commands[0].points, points, sizeof(points)) | ;
GContext *ctx = (GContext *)123; // just a fake internal guard != NULL
gdraw_command_frame_draw(ctx, NULL, frame, GPoint(0, 0));
cl_assert_equal_i(s_path_num_points, 2);
cl_assert(prv_compare_points(points, s_stroke_points, s_path_num_points));
cl_assert(prv_compare_points(points, s_fill_points, s_path_nu... |
ino_layer_play(&s_phone_ui_data->icon_layer);
s_phone_ui_data->current_icon = new_image;
s_phone_ui_data->current_icon_id = resource;
#else
kino_layer_set_reel(&s_phone_ui_data->icon_layer, new_image, true);
s_phone_ui_data->current_icon = new_image;
s_phone_ui_data->current_icon_id = resource;
#endif
}
// T... | (color_animation, COLOUR_ANIMATION_FRAMES * ANIMATION_FRAME_MS) | ;
animation_set_curve(color_animation, AnimationCurveEaseIn);
animation_schedule(color_animation);
#else
layer_mark_dirty(&s_phone_ui_data->window.layer);
#endif
}
// Names can sometimes actually be phone numbers. We're assuming that phone numbers will always
// match /^[() +0-9-]+$/
static bool prv_is_string_a_... |
if (settings_glance->glance_state.battery_charge_state.is_plugged) {
GTextNodeCustom *charging_icon_node =
graphics_text_node_create_custom(prv_charging_icon_node_draw_cb, structured_glance);
// Push the charging icon down to center it properly
charging_icon_node->node.offset.y += subtitle_icon_offs... |
return &horizontal_container_node->container.node;
}
static void prv_destructor(LauncherAppGlanceStructured *structured_glance) {
LauncherAppGlanceSettings *settings_glance =
launcher_app_glance_structured_get_data(structured_glance);
if (settings_glance) {
event_service_client_unsubscribe(&settings_... | |
148, 0},
// 285: Local time: 10:56:00 PM
{ 0, 0x71, 0, 150, 0},
{ 0, 0x71, 0, 150, 0},
{ 0, 0x71, 0, 150, 0},
{ 0, 0x71, 13, 150, 0},
{ 0, 0x71, 0, 151, 0},
{ 0, 0x71, 0, 150, 0},
{ 0, 0x70, 1157, 166, 0},
{ 27, 0x33, 2564, 191, 0},
{ 16, 0x26, 5309, 149, 0},
{ 0, 0x45, 63, 1... | { 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 149, 0},
{ 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 151, 0},
{ 0, 0x36, 0, 150, 0},
// 405: Local time: 12:56:00 AM
{ 0, 0x36, 15, 151, 0},
{ 0, 0x36... |
// 450: Local time: 01:41:00 AM
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 148, 0},
{ 8, 0x5a, 1508, 149, 0},
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 148, 0},
{ 0, 0x6a, 0, 146, 0},
{ 0, 0... |
NUTES_PER_DAY,
ACTIVITY_CALORIES_PER_KCAL));
// Feed in 125 steps/minute over 60 minutes
prv_feed_cannned_accel_data(60 * SECONDS_PER_MINUTE, 125, ActivitySleepStateAwake);
const int k_exp_steps_2 = 125 * MINUTES_PER_HOUR;
// Test the derived metrics
activity_get_metric(Acti... | activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value) | ;
cl_assert_equal_i(value, 2 * SECONDS_PER_HOUR + 20 * SECONDS_PER_MINUTE
/* 2:20am in minutes */);
}
// ---------------------------------------------------------------------------------------
// Test that sleep sessions get registered in the correct day
void test_activity__sleep_history(void) {... |
ox_data_size = sizeof(AppMessageAppOutboxData) + payload_length;
AppMessageAppOutboxData *outbox_data = app_malloc(outbox_data_size);
cl_assert(outbox_data);
outbox_data->session = session;
outbox_data->endpoint_id = endpoint_id;
memcpy(outbox_data->payload, payload, payload_length);
prv_send_outbox_raw_dat... | prv_create_and_send_outbox_message(NULL /* auto-select */, ALLOWED_ENDPOINT_ID,
TEST_PAYLOAD, sizeof(TEST_PAYLOAD)) | ;
assert_consumed(AppMessageSenderErrorDisconnected, 1);
app_free(outbox_data);
}
void test_app_message_sender__auto_select_not_js_app(void) {
AppMessageAppOutboxData *outbox_data =
prv_create_and_send_outbox_message(NULL /* auto-select */, ALLOWED_ENDPOINT_ID,
TEST... |
bool finish) {
ActivitySampleCollectionData *data = s_activity_state.sample_collection_data;
// Create the data logging session now, if needed
if (data->dls_session == NULL) {
Uuid system_uuid = UUID_SYSTEM;
data->dls_session = dls_create(
DlsSystemTagActivityAccelSamples, DATA_... | (LOG_LEVEL_INFO, __FILE_NAME__, __LINE__, "RAW: %s", data->base64_buf) | ;
num_chars = base64_encode(data->base64_buf, sizeof(data->base64_buf),
binary_data + chunk_size, sizeof(data->record) - chunk_size);
PBL_ASSERTN(num_chars + 1 < (int)sizeof(data->base64_buf));
pbl_log(LOG_LEVEL_INFO, __FILE_NAME__, __LINE__, "RAW: %s", data->base64_buf... |
/*
* 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_private_move_pixels_horizontally(&ctx->dest_bitmap, delta_x,
false /* patch_garbage */) | ;
context->window_to_last_x = new_x;
// render window_from
window_render(window_to, ctx);
// cover whole movement with a ring that distracts from the simple movement
uint16_t gap_to_cover = prv_window_distance_from_screen_bounds(window_to);
compositor_port_hole_transition_draw_outer_ring(ctx, ... |
_page_begin failed: %d", written);
status_t status;
while ((status = flash_impl_get_write_status()) == E_BUSY) {
psleep(0);
}
#ifdef TEST_FLASH_LOCK_PROTECTION
if (s_assert_write_error) {
PBL_ASSERT(FAILED(status), "flash write unexpectedly succeeded: %" PRId32,
status);
... | mutex_lock(s_flash_lock) | |
4},
{ 848, 816, -504},
{ 1048, 696, -488},
{ 1056, 720, -456},
{ 1560, 712, -440},
{ 2080, 440, -360},
// 10 seconds
{ 1640, 296, -392},
{ 1320, 184, -256},
{ 1112, 136, -216},
{ 808, 128, -136},
{ 592, 104, -168},
{ 512, 64, -136},
{ 560, 192, -152},
{ 592, 136, ... | { 672, -336, -56},
{ 840, -160, -296},
{ 720, -160, -280},
{ 944, -136, -288},
{ 1296, 192, -440},
{ 1328, 88, -360},
{ 1272, 216, -352},
{ 1248, 424, -352},
{ 1280, 392, -384},
{ 1408, 552, -424},
{ 1288, 648, -504},
{ 928, 784, -640},
{ 968, 880, -584},
{ 1184, ... |
{ 1096, 736, -200},
{ 1416, 632, -160},
{ 1400, 368, -152},
{ 1256, 144, -24},
// 18 seconds
{ 1312, 280, -96},
{ 1400, 200, -104},
{ 1288, 272, -56},
{ 1328, 160, -32},
{ 1288, 176, 0},
{ 1056, 160, -112},
{ 1224, 24, -112},
{ 512, -440, 0},
{ 816, 16, -376},
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.