prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
-----------------------------------------
// Interface towards the system / subsystems that need to receive and send data
// -------------------------------------------------------------------------------------------------
bool comm_session_send_data(CommSession *session, uint16_t endpoint_id,
... | ((ListNode *) s_session_head,
prv_find_session_is_system_filter, NULL) | ;
if (session) {
return session;
}
// If we don't find one, try to find a PULSE session
session = prv_find_session_by_type(CommSessionTransportType_PULSE);
if (session) {
return session;
}
// If we don't find one, try to find a QEMU session as a last resort
return prv_find_session_by_type(Comm... |
slackers if requested
SharedCircularBufferClient *slacker;
uint32_t max_data = prv_get_max_data_length(buffer, &slacker);
uint32_t avail_space = buffer->buffer_size - 1 - max_data;
while (length > avail_space) {
if (!advance_slackers) {
return false;
}
// Delete data from the biggest slacker
... | shared_circular_buffer_add_client(buffer,
&client->buffer_client) | );
subsampled_shared_circular_buffer_client_set_ratio(
client, subsample_numerator, subsample_denominator);
}
// -------------------------------------------------------------------------------------------------
void shared_circular_buffer_remove_subsampled_client(
SharedCircularBuffer *buffer,
Subsampl... |
xpanded_fmt_buffer, 0, sizeof(expanded_fmt_buffer));
// Craft a buffer that will hold HcProtocolMessage followed by BinLogMessage.
int msg_buffer_size = MAX((msg_size + sizeof(HcProtocolMessage)), 130);
uint8_t msg_buffer[msg_buffer_size];
memset(msg_buffer, 0, msg_buffer_size);
HcProtocolMessage *hc_msg = ... | ((char *)msg->body.filename, src_filename,
MEMBER_SIZE(BinLogMessage_UnhashedBody, filename)) | ;
msg->body.core_number = CORE_ID_BLE;
msg->body.task_id = task_get_dialogtask();
msg->body.level = log_level;
// Temporarily reserve space for a NULL terminator
// TODO: remove NULL termination
uint8_t max_str_len = msg_buffer_size - sizeof(BinLogMessage_Unhashed_v1) - 1;
va_list args;
va_start(args,... |
/*
* 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... | (&data->text_layer, GTextAlignmentCenter) | ;
data->line_spacing_delta = 0;
text_layer_set_line_spacing_delta(&data->text_layer, data->line_spacing_delta);
data->overflow_mode = GTextOverflowModeWordWrap;
text_layer_set_overflow_mode(&data->text_layer, data->overflow_mode);
layer_add_child(&window->layer, &data->text_layer.layer);
GSize size_used =... |
/*
* 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... | {
uint32_t version;
uint32_t last_processed_timestamp;
uint32_t sleep_duration;
uint32_t deep_sleep_duration;
uint32_t fall_asleep_time;
uint32_t wakeup_time;
uint32_t typical_sleep_duration;
uint32_t typical_deep_sleep_duration;
uint32_t typical_fall_asleep_time;
uint32_t typical_wakeup_time;
} | SleepData;
_Static_assert(offsetof(SleepData, version) == 0, "Version not at the start of SleepData");
_Static_assert(sizeof(SleepData) % sizeof(uint32_t) == 0, "SleepData size is invalid");
// The phone doesn't send us Zone0 minutes
typedef struct PACKED HeartRateZoneData {
uint32_t version;
uint32_t last_proces... |
* num_entries);
AppInstallId zero_id = 0;
pfs_write(fd, &zero_id, sizeof(zero_id));
pfs_close(fd);
}
void prv_test_new_order_with_filter_callback(const AppInstallId order[], uint8_t num_entries,
AppMenuFilterCallback filter_callback) {
prv_write_order_to_file(order... | (APP_ID_MUSIC, true /* can expire */) | |
uint32_t sn_end_excl) {
for (uint32_t sn = client->out.next_expected_ack_sn;
sn != sn_end_excl; sn = prv_next_sn(sn)) {
prv_set_payload_size_for_sn(client, sn, 0);
}
}
// ----------------------------------------------------------------------------------------------... | list_prepend((ListNode *)s_ppogatt_head, &client->node) | ;
if (!regular_timer_is_scheduled(&s_ack_timer)) {
s_ack_timer.cb = prv_timer_callback;
regular_timer_add_multisecond_callback(&s_ack_timer, PPOGATT_TIMEOUT_TICK_INTERVAL_SECS);
}
return client;
}
// -------------------------------------------------------------------------------------------------
static... |
--------------------------------------------------------------------------------------------
void prv_process_activity_sessions(time_t now_utc) {
uint32_t num_sessions = ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT;
ActivitySession *sessions = task_zalloc_check(num_sessions * sizeof(ActivitySession));
if (activity_get_s... | {
// we only care about pins
return;
} | |
(dstbuf, 256, "Hur% c", 'f');
cl_assert_equal_s(dstbuf, "Hurf");
// Plus for positive signed
// No signed conversion occurs, so this is a no-op
snprintf(dstbuf, 256, "Hur%+c", 'f');
cl_assert_equal_s(dstbuf, "Hurf");
// Variable length character output
snprintf(dstbuf, 256, "Hur%*c", 2, 'f');
cl_asser... | (hhntest[1], 0) | ;
cl_assert_equal_i(hhntest[2], 0);
cl_assert_equal_i(hhntest[3], 0);
hntest[0] = hntest[1] = 0;
snprintf(dstbuf, 512, "aaaa aaaa aaaa aaaa " // 0- 20
"aaaa aaaa aaaa aaaa " // 20- 40
"aaaa aaaa aaaa aaaa " // 40- 60
"aaaa aaaa aaaa aaaa ... |
bute_list_add_cstring(&list, AttributeIdTitle, "3.3 Mile run");
attribute_list_add_cstring(&list, AttributeIdSubtitle, "30M of activity");
attribute_list_add_uint32(&list, AttributeIdLastUpdated, now);
uint8_t buffer[Uint32ListSize(ActivitySessionMetricCount)];
Uint32List *icons = (Uint32List *)buffer;
icons... | prv_add_calendar_pin(-(3 * SECONDS_PER_DAY) / 2, 3 * MINUTES_PER_DAY, is_all_day,
!recurring, 0, 0) | ;
goto timeline;
}
case TimelinePinsDemo_TodayAndTomorrow:
prv_add_generic_pin(-24 * 60 * 60, has_subtitle);
prv_add_weather_pin(-60 * 60);
prv_add_weather_pin(60 * 60);
prv_add_generic_pin(24 * 60 * 60, has_subtitle);
goto timeline;
case TimelinePinsDemo_Notifications:
... |
"Alarms");
client = VibeClient_Alarms;
break;
}
case VibeSettingsRow_System: {
/// Refers to the class of all non-score vibes, e.g. 3rd party app vibes
title = i18n_noop("System");
const VibeIntensity current_system_default_vibe_intensity = vibe_intensity_get();
subtitle = v... | prv_selection_changed_cb(&data->callbacks, current_row, 0) | ;
settings_menu_mark_dirty(SettingsMenuItemVibrations);
}
static void prv_hide_cb(SettingsCallbacks *context) {
vibes_cancel();
}
static Window *prv_init(void) {
SettingsVibePatternsData *data = app_zalloc_check(sizeof(SettingsVibePatternsData));
data->callbacks = (SettingsCallbacks) {
.deinit = prv_dei... |
/*
* 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 "ScrollLayer";
} | else if (layer->update_proc == (LayerUpdateProc) window_do_layer_update_proc) {
return "Window";
} else if (layer->update_proc == NULL) {
return "Layer";
} else {
return "Custom Layer";
}
}
static void layer_dump_tree_node(Layer* node, uint8_t indentation_level, char *buffer, uint8_t buffer_size);
... |
id_entry));
cl_assert_equal_b(true, app_install_get_entry_for_uuid(&menu_layer.uuid, &uuid_entry));
cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry));
}
void test_app_install_manager__is_watchface_via_install_id(void) {
cl_assert_equal_b(true, app_install_is_watchface(tictoc_id));
cl_... | (ProcessStorageBuiltin, music_md->process_storage) | ;
app_install_release_md(music_md);
const PebbleProcessMd *sports_md = app_install_get_md(sports_id, false);
cl_assert(sports_md != NULL);
cl_assert_equal_b(false, sports_md->has_worker);
cl_assert_equal_i(ProcessTypeApp, sports_md->process_type);
cl_assert_equal_i(ProcessStorageBuiltin, sports_md->process... |
776, -32, 160},
{ 712, -40, 144},
{ 688, -48, 80},
{ 792, -24, -24},
{ 992, 112, -120},
{ 1392, -232, 80},
{ 1648, -168, 232},
{ 1456, 240, -8},
{ 1304, 384, -256},
{ 1232, 440, 16},
{ 1056, 336, 256},
{ 976, 360, 184},
{ 904, 288, 200},
{ 856, 432, 168},
// 33 s... | { 1704, 144, 120},
{ 1400, 296, -136},
{ 1504, 248, -208},
{ 1576, 384, 72},
{ 1344, 352, 296},
{ 1200, 528, 296},
{ 944, 360, 208},
{ 856, 248, 128},
{ 848, 264, 128},
{ 872, 392, 64},
{ 880, 384, 72},
{ 1176, 560, -8},
{ 1344, 480, 200},
{ 1824, 536, 224},
{... | |
/*
* 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... | (pin_config->gpio, pin_config->gpio_pin,
asserted? Bit_SET : Bit_RESET) | |
m_theme.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include <string.h>
//! @return True if there was an animation to cancel, false otherwise
static bool prv_cancel_selection_animation(MenuLayer *menu_layer);
//////////////////////
// Menu Layer
//
// NOTES: The MenuLayer is bui... | {
return menu_layer->callbacks.get_num_sections(menu_layer, menu_layer->callback_context);
} | |
t(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_wrap_x-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test vertical wrapping when dest_rect taller than src_bitmap.
// Setup:
// - Source is 25 x 10
// - 4 rows red, 2 rows blue, 4 rows black.
// - Dest is Green, 50 x 50
// - Dest Rect is 10 x 24 at (... | gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_and-expect.8bit.pbi") | |
tem_task_callbacks_invoke_pending();
HRMSessionRef session_ref_2 = hrm_manager_subscribe_with_callback(INSTALL_ID_INVALID, 1,
expire_s, HRMFeature_BPM,
prv_fake_hrm_2_cb, NULL);
fake_s... | (memcmp(&event[i], &out_event[i], sizeof(PebbleHRMEvent)), false) | ;
}
}
{ // Test reading back unaligned
for (int i = 0; i < NUM_TEST_EVENTS; ++i) {
circular_buffer_write(&cb, (const uint8_t *)&event[i], sizeof(PebbleHRMEvent));
}
PebbleHRMEvent out_event[NUM_TEST_EVENTS];
for (int i = 0; i < NUM_TEST_EVENTS; ++i) {
prv_read_event_from_buffer_and_c... |
equal_i(cron_service_get_job_count(), 0);
cron_job_schedule(job);
cl_assert_equal_i((uintptr_t)job->cb_data, 0);
cl_assert_equal_i(job->cached_execute_time, target);
cl_assert_equal_i(cron_service_get_job_count(), 1);
// Mutate the execute time to see if we actually effect change.
job->clock_change_tolera... | 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_cron[l].cb_data, i >= l ? 1 : 0);
}
} |
}
void test_cron__already_elapsed(void) {
CronJob test_cron = {
.cb = prv_cron_callback,
.cb_data = (void*)0,
.minute = CRON_MINUTE_ANY,
.hour = CRON_HOUR_ANY,
.mday = CRON_MDAY_ANY,
.month = CRON_MONTH_ANY,
.may_be_instant = true,
};
prv_basic_test(&s_timezone_gmt, &test_cron, s_... |
{
prev_anim_needed = false;
prv_rel_bar_reset_offsets(&layer->relbar_layer, RelationshipBarOffsetTypePrev);
curr_anim_needed = true;
} |
// Create previous rel bar animation
Animation *prev_rel_bar_anim = NULL;
if (prev_anim_needed) {
prev_rel_bar_anim = prv_create_prev_rel_bar_animation(layer, duration, interpolate);
}
Animation *curr_rel_bar_anim = NULL;
if (curr_anim_needed) {
curr_rel_bar_anim = prv_create_curr_rel_bar_anima... | |
on_ref);
cl_assert(success);
TestPLParsedMsg *(*parser)(void *);
switch (input->type) {
case ProtobufLogType_Events:
parser = prv_parse_encoded_event_payload;
break;
case ProtobufLogType_Measurements:
parser = prv_parse_encoded_mset_payload;
break;
}
// Verify the contents
... | ARRAY_LENGTH(values) | ,
.values = values,
},
};
ProtobufLogRef ref = prv_test_encode_measurements(&input, false /*use_data_logging*/);
prv_test_decode_payload(&input, false /*use_data_logging*/, ref);
}
// A message with 4 types, 3 samples
{
ProtobufLogMeasurementType types[] = {ProtobufLogMeasurementTyp... |
ULL);
// Create a sequence by putting a in front and repeat it 5 times
// We now have a -> (b | c)
Animation *seq = animation_sequence_create(a, spawn, NULL);
animation_set_play_count(seq, repeat_count);
// Now, clone it
Animation *clone = animation_clone(seq);
// Destroy the original
animation_dest... | (prv_count_handler_entries(&s_started_handler_calls, a1), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a1), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a2), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a2), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a3)... |
ui/scroll_layer.h"
#include "kernel/ui/kernel_ui.h"
#include "resource/resource_ids.auto.h"
#include "system/passert.h"
#include <stdlib.h>
#include <string.h>
#define SCROLL_ANIMATION_DURATION (300)
#define POP_WINDOW_DELAY (400)
#define CHARACTER_DELAY (20)
#define TEXT_OFFSET_VERTICAL (6)
static void prv_show_n... | property_animation_get_animation(transcription_dialog->animation) | |
sic:
return remote->classic.connected;
case StoredRemoteTypeBLE:
return (remote->ble.connection != NULL);
case StoredRemoteTypeBTDual:
return remote->dual.classic.connected || (remote->dual.ble.connection != NULL);
default:
WTF;
}
return false;
}
static int remote_comparator(Sto... | (prv_add_and_merge_ble_remote, data) | ;
StoredRemote *remote = (StoredRemote *)data->remote_list_head;
while (remote) {
StoredRemoteBLE *ble_rem = NULL;
if (remote->type == StoredRemoteTypeBLE) {
ble_rem = &remote->ble;
} else if (remote->type == StoredRemoteTypeBTDual) {
ble_rem = &remote->dual.ble;
}
if (ble_rem) {
... |
= HealthAggregationSum);
case HealthMetricHeartRateRawBPM: {
// Only support querying the current raw heart rate.
const bool query_cur_minute = prv_interval_within_last_minute(now_utc, time_start, time_end);
return ((agg == HealthAggregationAvg) && query_cur_minute);
}
case HealthMetricHea... | (op, daily_totals.totals, ARRAY_LENGTH(daily_totals.totals),
health_service_private_weekend_filter, (void *)(uintptr_t)local_tm->tm_wday,
&stats->weekend.sum) | ;
// We want to sum only the days that are this far from index 0 (which is local_tm.tm_wday)
int day_offset = local_tm->tm_wday - weekly_day;
if (day_offset < 0) {
day_offset += DAYS_PER_WEEK;
}
stats_calculate_basic(op, daily_totals.totals, ARRAY_LENGTH(daily_totals.totals),
healt... |
t *val = malloc(info->val_len + 1);
info->get_key(file, key, info->key_len);
info->get_val(file, val, info->val_len);
key[info->key_len] = '\0';
val[info->val_len] = '\0';
printf("Read key of %s %d and val of %s %d\n", key, info->key_len, val, info->val_len);
int key_i = atoi((char*)key + 1);
cl_assert(k... | {
snprintf((char *)key, sizeof(key), "k%03d", i);
snprintf((char *)val, sizeof(val), "v%03d", i);
set_and_verify(&file, key, key_len, val, val_len);
} |
const int search_for_idx = 57;
snprintf((char *)key, sizeof(key), "k%03d", search_for_idx);
// Move iter to the beginning to bring to a known state
settings_raw_iter_begin(&file.iter);
// Get the iter to the record we want
cl_assert_equal_b(true, settings_file_exists(&file, key, key_len));
// Check t... |
se is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "drivers/voltage_monitor.... | ADC_Cmd(device->adc, DISABLE) | ;
}
ADC_TempSensorVrefintCmd(DISABLE);
periph_config_disable(VREF_ADC, VREF_ADC_CLOCK);
if (!same_adc) {
periph_config_disable(device->adc, device->clock_ctrl);
}
mutex_unlock(s_adc_mutex);
}
|
/*
* 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_raw_drawing_function_counters[GDrawRawFunctionTypeBlendVerticalLine]++;
} |
static void prv_fake_raw_assign_horizontal_line_delta(GContext *ctx, int16_t y,
Fixed_S16_3 x1, Fixed_S16_3 x2,
uint8_t left_aa_offset,
uint8_t right_aa_off... |
has delay 1000 ms, frame 4 and 5 have zero delay, so at time 2000 ms == frame 5
gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 2 * 1000);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
// Since loop only equals 1, make sure that huge elapsed time leaves us at final frame
gbitmap_sequen... | gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)) | );
#endif
}
// Tests APNG file with 8-bit color, originally broke the updated upng+tinflate code
// Result:
// - gbitmaps matches platform decoded APNG
void test_gbitmap_sequence__color_8bit_yoshi(void) {
#if PLATFORM_SPALDING
bool status = false;
uint32_t resource_id = sys_resource_load_file_as_resource(TEST_IM... |
/*
* 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... | {
// >= because we will be reading more bytes after this point
if ((buf_len == 0) || ((iter + buf_len) > iter_end)) {
PBL_LOG(LOG_LEVEL_WARNING, "BlobDB: read invalid length");
return NULL;
}
// grab pointer to start of buf
*out_buf = (uint8_t*)iter;
iter += buf_len;
return iter;
} |
static const uint8_t *prv_read_key_size(const uint8_t *iter, const uint8_t *iter_end,
uint8_t *out_int) {
// copy length from iter to out_len, then save a local copy of the length
*out_int = *iter++;
return iter;
}
static const uint8_t *prv_read_value_size(const uint8_t... |
/*
* 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... | { 472, 656, -184},
{ 256, 368, -96},
{ 280, 200, -32},
{ 328, -128, 80},
{ 280, -104, 184},
{ 248, -208, 320},
{ 504, 184, 360},
{ 1640, 3792, 16},
{ 800, 1912, 280},
{ 104, 1512, -8},
{ -208, 928, -160},
{ -616, 544, -176},
{ -680, 320, -200},
{ -720, 176, -240},... |
{ 536, 1824, 624},
{ 480, 792, 272},
// 5 seconds
{ 432, 280, 24},
{ 432, -224, 48},
{ 320, -480, 248},
{ 208, -576, 376},
{ 944, 248, 312},
{ 1104, 3056, 960},
{ 624, 2496, 200},
{ -128, 1888, -80},
{ -304, 1072, -160},
{ -608, 376, -24},
{ -752, 128, -56},
... |
ClickConfigProvider click_config_provider,
void *context) {}
void window_set_click_context(ButtonId button_id, void *context) {}
void content_indicator_destroy_for_scroll_layer(ScrollLayer *scroll_layer) {}
ContentIndicator s_content_indicator;
Conte... | {
MenuLayer l;
const int height = 180;
menu_layer_init(&l, &GRect(10, 10, height, 180));
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks){
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
});
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(0, l.sel... |
int16_t prv_get_row_height_depending_on_selection_state(struct MenuLayer *menu_layer,
MenuIndex *cell_index,
void *callback_context) {
MenuIndex selected_index = menu_layer_get_selected_index(menu_layer);... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | sys_current_process_schedule_callback(pass_initial_values_app_task_callback, s) | ;
delegate_errors(s, dict_result, APP_MSG_OK);
}
void app_sync_deinit(AppSync *s) {
app_message_set_context(NULL);
app_message_register_outbox_sent(NULL);
app_message_register_outbox_failed(NULL);
app_message_register_inbox_received(NULL);
app_message_register_inbox_dropped(NULL);
s->current = NULL;
}
A... |
prv_draw_round_rect_aa_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
#else
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__fill(void) {
// Fill shape, non-antialiased (Stroke width/color N/A)
setup_test(&cont... | (&context, true, 1, GColorBlack, GColorBlack, true) | ;
ASSERT_NO_CHANGE(graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10)));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_... |
comm_session_get_by_type(CommSessionTypeSystem) | , session);
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
fake_system_task_callbacks_invoke_pending(); // get dls called
cl_assert_equal_b(s_dls_private_handle_disconnect_called, true);
cl_assert_equal_b(s_comm_session_event_put, true);
}
void test_session__get_type_app(void) {
... | |
mers(uint64_t dst_time) {
uint64_t now = prv_now_ms();
while (now < dst_time) {
TimerID sys_timer_id = animation_service_test_get_timer_id();
if (!sys_timer_id) {
DPRINTF("timer not created\n");
prv_advance_by_ms_no_timers(dst_time - now);
return;
}
if (!stub_new_timer_is_schedu... | {
return 0;
} |
}
// =============================================================================================
// Handlers
// --------------------------------------------------------------------------------------
// Started handler
static void prv_started_handler(Animation *animation, void *context) {
prv_add_handler_entry(&... |
(curr_request->granted_handler) | ;
curr_request->granted_handler = NULL;
}
curr_request = (ConnectionStateRequest *)list_get_next(&curr_request->list_node);
}
}
static void prv_handle_response_latency_for_le_conn(GAPLEConnection *hdl) {
uint16_t secs_til_max_latency;
ResponseTimeState state;
BtConsumer responsible_consumer;
#ifd... | |
/*
* 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... | attribute_list_add_cstring(&list, AttributeIdTitle, "SUNRISE") | ;
attribute_list_add_cstring(&list, AttributeIdSubtitle, "11°/6°");
attribute_list_add_cstring(&list, AttributeIdLocationName,
"SAN LOUIS OBISPO\n"
"CALIFORNIA, USA");
attribute_list_add_cstring(&list, AttributeIdBody,
"Cloudy ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ERROR, "System resources are missing or corrupt! Going to PRF") | ;
fw_reset_into_prf();
#endif
}
}
bool system_resource_is_valid(void) {
return resource_init_app(SYSTEM_APP, &SYSTEM_RESOURCE_VERSION);
}
#define NUM_SYSTEM_FONTS ARRAY_LENGTH(s_font_resource_keys)
// Total number of fonts = NUM_SYSTEM_FONTS + 1 for the fallback font
FontInfo s_system_fonts_info_table[NUM_SY... |
/*
* 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... | gap_le_connection_init() | ;
}
void test_gatt_client_discovery__cleanup(void) {
gap_le_connection_deinit();
// make sure we haven't leaked any memory!
fake_pbl_malloc_check_net_allocs();
}
// -----------------------------------------------------------------------------
// Edge cases
void test_gatt_client_discovery__not_connected(void) ... |
ttribute(Attribute *dest, const Attribute *src, uint8_t **buffer,
uint8_t *const buffer_end) {
const size_t attribute_length = prv_get_attribute_length(src);
if (*buffer + attribute_length > buffer_end) {
return false;
}
switch (prv_attribute_type(src->id)) {
case At... | (list, id) | ->string_list = string_list;
}
void attribute_list_add_uint32_list(AttributeList *list, AttributeId id, Uint32List *uint32_list) {
PBL_ASSERTN(prv_attribute_type(id) == AttributeTypeUint32List);
prv_add_attribute(list, id)->uint32_list = uint32_list;
}
void attribute_list_add_attribute(AttributeList *list, const ... |
_BYTES) == 0) {
prompt_send_response_fmt(status, sizeof(status), "Validated: 0x%lx", addr);
flash_erase_sector_blocking(addr);
flash_erase_sector_blocking(addr); // exercise already erased check
}
flash_write_bytes(&buf[0], addr, sizeof(buf));
flash_expect_program_failure(fal... | {
char buf[80];
prompt_send_response_fmt(buf, sizeof(buf), "Connected to " BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE(conn->device.address));
} |
return conn;
}
void command_bt_conn_param_set(
char *interval_min_1_25ms, char *interval_max_1_25ms, char *slave_latency_events,
char *timeout_10ms) {
BleConnectionParamsUpdateReq req = {
.interval_min_1_25ms = atoi(interval_min_1_25ms),
.interval_max_1_25ms = atoi(interval_max_1_25ms),
... |
pen.data, payload_length, &state->domain_state);
if (FAILED(ret)) {
prv_free_fd(fd);
if (ret == E_INVALID_ARGUMENT) {
prv_respond_malformed_command(cmd, length, "Invalid domain data");
} else {
prv_respond_internal_error(cmd, length, ret);
}
return;
}
OpenResponse *resp = pulse... | {
pulse_reliable_send_cancel(resp);
prv_respond_internal_error(cmd, length, ret);
} |
}
static void prv_handle_erase(Command *cmd, size_t length) {
PulseBulkIODomainHandler *domain_handler = prv_get_domain_handler(cmd->erase.domain);
if (domain_handler) {
size_t payload_length = length - sizeof(cmd->opcode) - sizeof(cmd->erase);
status_t ret = domain_handler->erase_proc(cmd->erase.data, p... |
/*
* 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 rtc_get_time();
} |
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
callback(data);
}
bool system_task_add_callback(void (*cb)(void*), void *data) {
cb(data);
return true;
}
#define APP_REGISTRY_FIXTURE_PATH "app_registry"
#define APP1_APP_FIXTURE_NAME "feature-background-counter-app"
#define APP1_WO... |
overflow our uint8_t.
const int num_regions = MIN(UINT8_MAX, (num_pages() * 5) / 10);
int fd = pfs_open("page_lookup", OP_FLAG_WRITE, FILE_TYPE_STATIC, PFS_SECTOR_SIZE * num_regions);
cl_assert(fd >= 0);
char buf[PFS_SECTOR_SIZE];
for (int i = 0; i < num_regions; i++) {
memset(buf, 0xff - i, sizeof(buf))... | (rv == E_RANGE) | ;
}
void test_pfs__read(void) {
const int rd_len = 10;
int rv = pfs_read(-1, NULL, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_read(0, NULL, rd_len);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = pfs_open("newfile", OP_FLAG_WRITE, FILE_TYPE_STATIC, rd_len);
cl_assert(fd >= 0);
uint8_t buf... |
the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specif... | if (body_length != sizeof(uint32_t)) {
// Don't send a response; the client will have already changed its receiver
// baud rate.
return;
} |
uint32_t *new_baud = body;
pulse_change_baud_rate(*new_baud);
}
|
4, 176, -160},
{ 1240, 136, -104},
{ 1424, 136, -224},
{ 1448, 112, -8},
{ 1048, 88, -80},
{ 1000, -64, -8},
// 107 seconds
{ 952, -72, 136},
{ 712, -40, -400},
{ 816, 0, -376},
{ 920, -48, -216},
{ 1000, 72, -320},
{ 1016, 120, -248},
{ 1176, 296, -184},
{ 1536, ... | { 848, 208, -304},
{ 1056, 280, -184},
{ 1464, 328, -296},
{ 1648, 512, -464},
{ 1344, 1216, -792},
{ 1184, 656, -600},
{ 1112, 936, -576},
{ 1088, 792, -576},
{ 1136, 704, -320},
{ 1288, 648, -264},
{ 1232, 408, -304},
{ 848, 232, -208},
{ 768, 248, -224},
{ 968,... |
{ 1304, 176, -136},
{ 1048, 24, -112},
{ 816, -240, 64},
{ 784, -248, -8},
// 115 seconds
{ 728, -72, -496},
{ 832, -112, -400},
{ 968, -48, -288},
{ 952, 24, -432},
{ 1032, 224, -328},
{ 1240, 344, -256},
{ 1512, 448, -376},
{ 1584, 760, -432},
{ 1344, 784, -424... |
-----------------------------------------------------
void test_activity__cleanup(void) {
activity_stop_tracking();
fake_system_task_callbacks_invoke_pending();
}
// ---------------------------------------------------------------------------------------
// Test that we correctly initialize the history upon startu... | ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricRestingKCalories, exp_resting_kcalories) | ;
// See what distance we walked
int32_t exp_distance;
activity_get_metric(ActivityMetricDistanceMeters, 1, &exp_distance);
cl_assert(exp_distance > 0);
// Read the active calories
int32_t exp_active_kcalories;
activity_get_metric(ActivityMetricActiveKCalories, 1, &exp_active_kcalories);
cl_assert(exp... |
{ 48, 24, -992},
{ 40, 24, -992},
{ 48, 24, -1000},
{ 48, 16, -992},
{ 48, 16, -1008},
{ 48, 24, -992},
{ 48, 8, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -992},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},... | { 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 8, -1008},
{ 48, 32, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 24, -1008},
{ 48, 24, -1000},
{ 40, 24, -992},
{ 48, 16, -1000},
{ 48, 24, ... |
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 24, -1008},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 16, -1000},
{ 48, 1... |
ount--;
if (slave->bus->state->user_count == 0) {
prv_bus_disable(slave->bus);
}
mutex_unlock(slave->bus->state->bus_mutex);
}
void i2c_reset(I2CSlavePort *slave) {
PBL_ASSERTN(slave);
// Take control of bus; only one task may use bus at a time
mutex_lock(slave->bus->state->bus_mutex);
if (slave->... | mutex_unlock(bus->state->bus_mutex) | ;
PBL_LOG(LOG_LEVEL_ERROR, "I2C bus did not recover after reset (%s)", bus->name);
prv_analytics_track_i2c_error();
return false;
}
}
// Take binary semaphore so that next take will block
PBL_ASSERT(prv_semaphore_take(bus->state), "Could not acquire semaphore token");
// Set up transfer
... |
/*
* 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... | RTC_WriteBackupRegister(STUCK_BUTTON_REGISTER, 0) | ;
return false;
}
button_counter[button_id] += 1;
if (button_counter[button_id] >= STUCK_BUTTON_THRESHOLD) {
dbgserial_print("Button id ");
dbgserial_print_hex(button_id);
dbgserial_putstr("is stuck!");
result = true;
}
}
if (button_counter_register != 0) {
dbgse... |
return NULL;
}
prv_init_peek_layer(data);
GRect icon_from;
layer_get_global_frame((Layer *)&first_timeline_layout->icon_layer, &icon_from);
peek_layer_set_icon_with_size(peek_layer, &first_timeline_layout->icon_info,
TimelineResourceSizeTiny, icon_from);
} ... | {
Layer *layer = &data->timeline_layer.layer;
GPoint to_origin = GPoint(-layer->bounds.size.w, 0);
Animation *animation = (Animation *)property_animation_create_bounds_origin(layer, NULL,
&to_origin);
animation_set_handlers(animation,... | |
// Adjustment because struct tm has mday 1-indexed for whatever reason
mktime(cron_tm);
cron_tm->tm_mday -= 1;
// We have 1 week to find a fitting date
for (int l = 0; l < DAYS_PER_WEEK; l++) {
if (cron->wday & (1 << cron_tm->tm_wday)) {
break;
}
// Advance the day.
cron_tm->tm_mday++;
... | if (direction < 0) {
// If the target is _behind_ the current time, we need to increase a higher order field.
// Step from next highest all the way up to a year. We adjust the least significant field
// that is more significant than the current field, and is unspec'd.
for (int l = i - 1... |
if (direction != 0) {
// The target is now ahead of the current time, the rest of the unspec'd fields
// should be 0.
assign_mode = CronAssignMode_Zero;
}
}
}
// Increase the day until we fit into the `wday` spec.
if (prv_adjust_for_wday_spec(job, &cron_tm)) {
// If t... |
compare_color = data->bg_color;
} else {
compare = false;
}
for (uint8_t row = 0; row < 2; row++) {
for (uint8_t color_index = row * ROW_LENGTH; color_index < (row + 1) * ROW_LENGTH;
color_index++) {
GColor color = (GColor){.argb = (s_color_table[color_index] | ALPHA_100)};
if (com... | (ctx, "BG", font, GRect(72, 110 - 16, 20, 16),
GTextOverflowModeFill, GTextAlignmentLeft, NULL) | ;
draw_color_rect(ctx, data, GRect(92, 0, 62, 90));
graphics_context_set_text_color(ctx, GColorWhite);
if (data->alpha < ALPHA_100) {
graphics_draw_text(ctx, "FG+BG", font, GRect(92, 90 - 16, 62, 16),
GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}
else {
graphics_draw_text... |
phics_text_attributes_enable_screen_text_flow(text_attributes, TEXT_FLOW_INSET_PX);
#endif
// Check if the text takes up more than one line. If the dialog has a single line of text,
// the icon and line of text are positioned lower so as to be more vertically centered.
GContext *ctx = graphics_context_get_current... | (&workout_dialog->dialog) | |
NTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler... | prv_create_test_animation() | ;
animation_set_duration(d, duration_d);
Animation *seq = animation_sequence_create(inner_seq, c, d, NULL);
animation_set_handlers(seq, handlers, seq);
// Play it
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
prv_advance_to_ms_with_timers(start_ms + total... |
int s_overflow_cnt;
static bool s_initialized = false;
static uint8_t s_discarded;
static CircularBuffer s_circ_buffer;
// A mutex is needed to protect against a race condition between mic_stop and the dispatch routine
// potentially resulting in the deallocation of the subscriber module's receive buffer while the
// ... | (!s_initialized) | ;
s_main_pending = false;
s_bg_pending = false;
s_running = false;
s_subscriber = (struct Subscriber){0};
s_volume = BOARD_CONFIG.mic_config.gain;
s_pdm_filter.Fs = MIC_SAMPLE_RATE;
s_pdm_filter.LP_HZ = 8000;
s_pdm_filter.HP_HZ = 10;
s_pdm_filter.Out_MicChannels = 1;
s_pdm_filter.In_MicChannels =... |
onfig = {
.attr_id = AttributeIdLocationName,
.text.style_font = TextStyleFont_Footer,
.text.extent.offset.y = style->location_offset,
.text.extent.margin.h = style->location_margin,
};
const int reminder_body_line_delta = 0;
const LayoutNodeTextAttributeConfig body_config = {
.attr_id = Attri... | kino_layer_get_layer(&layout->icon_layer) | );
}
static void NOINLINE prv_init_view(NotificationLayout *layout) {
#if PLATFORM_TINTIN
layout->view_node = prv_create_view(layout, false /* use_body_icon */);
#else
const bool use_body_icon = prv_should_enlarge_emoji(layout);
layout->view_node = prv_create_view(layout, use_body_icon);
if (use_body_icon) {
... |
_interaction(swap_layer);
const bool is_repeating = false;
prv_attempt_scroll(swap_layer, prv_direction_for_recognizer(recognizer), is_repeating);
}
}
static void prv_swap_layer_click_config_provider(void *context) {
// Use raw clicks to avoid single click delay which results from having multi-click enable... | layer_set_update_proc(layer, prv_swap_layer_update_proc) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&s_cache_buffer[0], &s_test_item[0], sizeof(TestCacheItem)) | ;
cl_assert_equal_m(&s_cache_buffer[1], &s_test_item[2], sizeof(TestCacheItem));
cl_assert_equal_m(&s_cache_buffer[2], &ZERO_ITEM, sizeof(TestCacheItem));
circular_cache_push(&s_test_cache, &s_test_item[1]);
cl_assert_equal_m(&s_cache_buffer[0], &s_test_item[0], sizeof(TestCacheItem));
cl_assert_equal_m(&s_c... |
const bool is_hidden = !s_card_view_show_select_indicator[health_card_view->current_card_index](
card_layer);
layer_set_hidden(&health_card_view->select_indicator_layer, is_hidden);
}
static void prv_content_indicator_setup_direction(HealthCardView *health_card_view,
... | {
if (i != health_card_view->current_card_index) {
layer_set_hidden(health_card_view->card_layers[i], true);
}
} | |
-------------
static void prv_init(PropertyAnimationPrivate *property_animation,
const PropertyAnimationImplementation *implementation,
void *subject, void *from_value, void *to_value) {
property_animation->animation.is_property_animation = true;
memset(&propert... | if (property_animation->animation.implementation->update
== (AnimationUpdateImplementation)property_animation_update_gcolor8) {
property_animation->values.to.gcolor8 = to_value ? *((GColor8*)to_value)
: implementation->accessors.getter.gcolor8(subject);
... |
}
}
// -----------------------------------------------------------------------------------------
PropertyAnimation *property_animation_create(
const PropertyAnimationImplementation *implementation,
void *subject, void *from_value, void *to_value) {
if (anim... |
HEIGHT + 4)),
COLOR_BAR_WIDTH, COLOR_BAR_HEIGHT);
graphics_context_set_fill_color(ctx, color);
graphics_fill_rect(ctx, &box);
}
}
// Draw border
if (compare) {
const GRect box = GRect(origin.x + 4*color_index_match - 1, origin.y - 1 + height_offset,
... | graphics_fill_rect(ctx, &GRect(124, 0, 20, 40)) | ;
graphics_context_set_text_color(ctx, GColorWhite);
graphics_draw_text(ctx, "FG", font, GRect(124, 40 - 16, 20, 16),
GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}
draw_color_wheel_box(ctx, data);
}
static void main_window_load(Window *window) {
AppData *data = window_get_us... |
REG = 0x22;
CACHE->CACHE_MRM_HITS_REG = 0x0;
CACHE->CACHE_MRM_MISSES_REG = 0x0;
CACHE->CACHE_MRM_CTRL_REG = 0x0;
CACHE->CACHE_MRM_TINT_REG = 0x0;
CACHE->CACHE_MRM_THRES_REG = 0x0;
CACHE->SWD_RESET_REG = 0x0;
#if DEFAULT_REGISTER_DEBUG
// DCDC
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_FAST_STARTUP, 0x0);
R... | REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_CURRENT, 0x0) | |
.id));
cl_assert(!iter_next(&iterator));
}
// 8:16 am, 8:00 event has passed but not 8:15 event
void test_timeline__extra_case_middle_past(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(t... | {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1421178000), 0);
cl_assert_equal_i(pin_db_delete((uint8_t *)&s_items[4].header.id, sizeof(Uuid)), 0);
//... |
void test_timeline__delete_last_items(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1421178000), 0);
// delete item 2, iterate to the end, check ... |
tor,
ContentIndicatorDirection direction,
bool available) {
s_content_available[direction] = available;
}
void graphics_context_set_compositing_mode(GContext* ctx, GCompOp mode) {}
void graphics_draw_bitmap_in_rect(GContext *ct... | menu_layer_get_selected_index(menu_layer) | ;
bool is_selected = menu_index_compare(&selected_index, cell_index) == 0;
return is_selected ? MENU_CELL_ROUND_FOCUSED_TALL_CELL_HEIGHT : menu_cell_basic_cell_height();
}
void test_menu_layer__default_ignores_row_height_for_selection(void) {
MenuLayer l;
const int height = 180;
menu_layer_init(&l, &GRect(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... | PBL_LOG(LOG_LEVEL_WARNING,
"Filesystem: Uh oh, we somehow added regions in the wrong order, %"PRIu32" %"PRIu32,
region_start, region_end) | ;
return;
}
// erase if asked to
if (erase_new_region) {
flash_region_erase_optimal_range_no_watchdog(region_start, region_start,
region_end, region_end);
}
s_ftl_size += (region_end - region_start);
// call back to PFS to make sure it realizes the... |
/*
* 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... | strncmp(testbuf, testbuf, 8) | , true);
}
void test_strcmp__n_same_content(void) {
char testbuf1[8] = "Hello!\0\0";
char testbuf2[8] = "Hello\0\0\0";
testbuf2[5] = '!';
cl_assert_equal_b(!strncmp(testbuf1, testbuf2, 8), true);
}
void test_strcmp__n_different_content(void) {
char testbuf1[8] = "Hello!\0\0";
char testbuf2[8] = "Hello\0\0... |
urn false;
}
pfs_close(fd);
return true;
}
static void prv_create_file_for_id(AppInstallId id) {
char buffer[30];
itoa_int(id, buffer, 10);
int fd = pfs_open(buffer, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
pfs_close(fd);
}
void test_app_cache__delete_binaries_for_id_with_no_entry(void) {
// confirm bin... | ("@ffffffff/res", 1024) | |
/*
* 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... | (config->gpio, &GPIO_InitStructure) | ;
gpio_release(config->gpio);
}
bool button_is_pressed(ButtonId id) {
const ButtonConfig* button_config = &BOARD_CONFIG_BUTTON.buttons[id];
gpio_use(button_config->gpio);
uint8_t bit = GPIO_ReadInputDataBit(button_config->gpio, button_config->gpio_pin);
gpio_release(button_config->gpio);
return !bit;
}
u... |
q);
animation_set_play_count(seq, play_count_seq);
// Check durations
cl_assert_equal_i(animation_get_duration(a, false, false), duration_a);
cl_assert_equal_i(animation_get_duration(a, false, true), play_count_a * duration_a);
cl_assert_equal_i(animation_get_duration(a, true, false), delay_a + duration_a);... | animation_sequence_create(a, b, NULL) | |
HealthMetricHeartRateBPM, now - 10, now, HealthAggregationSum,
HealthServiceTimeScopeDaily },
.out = { HealthServiceAccessibilityMaskNotSupported }
},
{
.desc = "Valid time range with ScopeDaily and Avg. Not available because Daily",
.in = { HealthMetricHeartRateBPM, now - 10, ... | fun(&session, HealthActivityMaskAll, now - (20 * SECONDS_PER_MINUTE),
now + (10 * SECONDS_PER_MINUTE)) | );
// range before doesn't match, even if it touches
cl_assert_equal_b(false, fun(&session, HealthActivityMaskAll, now - (20 * SECONDS_PER_MINUTE),
now - (10 * SECONDS_PER_MINUTE)));
// range after doesn't match, even if it touches
cl_assert_equal_b(false, fun(&session, HealthAc... |
}
}
// If this is a "static AlgDlsMinuteData samples[] = {" line, skip it
if (strcmp(token, "static") == 0) {
continue;
}
// Grab a sample
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
int steps = 0;
int orientation = 0;
int vmc ... | strcmp(token, "TEST_START_AT") | == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.value);
} else if (strcmp(token, "TEST_START_AT_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.min);
} else if (strcmp(token, "TEST_START_AT_MAX") == 0) {
sscanf(token + st... |
urce_storage_file_readonly_bytes_unsupported(ResourceStoreEntry *entry,
bool has_privileged_access) {
return NULL;
}
static bool resource_storage_file_find_resource(ResourceStoreEntry *entry, ResAppNum app_num,
... | (filename, op_flags, FILE_TYPE_STATIC, 0) | |
ta_pattern, data_pattern, display_logs);
VERIFY_TEST_STATUS(status);
}
}
if (!skip_base_addr) {
test_addr = base_addr;
// Read initial value
read_buffer = 0;
flash_read_bytes((uint8_t*) &read_buffer, test_addr, sizeof(read_buffer));
if (display_logs) {
PBL_LOG(LOG_LEVEL_DEBUG, ... | prv_read_verify_byte(test_addr, 0xFF, FLASH_TEST_ERR_ERASE, 0, 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... | (&req->address) | ;
HciStatusCode status = HciStatusCode_Success;
if (conn == NULL) {
status = HciStatusCode_UnknownConnectionIdentifier;
PBL_LOG(LOG_LEVEL_WARNING, "No connection to addr!");
goto failure;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Received Discovery Start for 0x%x to 0x%x",
(int)req->range.start, (int)r... |
t->closing_state == ProcessRunState_Running ||
context->closing_state == ProcessRunState_GracefullyClosing) {
// Right before a syscall drops privilege, it calls
// process_manager_force_close_syscall_exit_trap to check whether
// it is about to return control to a misbehaving app. This
... | animation_service_cleanup(task) | ;
persist_service_client_close(&context->app_md->uuid);
event_reset_from_process_queue(task);
evented_timer_clear_process_timers(task);
event_service_clear_process_subscriptions(task);
#if CAPABILITY_HAS_BUILTIN_HRM
hrm_manager_process_cleanup(task, context->install_id);
#endif
#ifndef RECOVERY_FW
#if CAPAB... |
StringFormat mask,
char *buffer, size_t buffer_len,
jerry_value_t *error) {
JS_VAR locale = argc >= 1 ? jerry_acquire_value(argv[0]) : jerry_create_undefined();
JS_VAR options = argc >= 2 ? jerry_acquire_value(argv[1]) : jerry_create_object();
... | (this_val, argc, argv,
ToStringFormatEmpty,
ToStringFormatDateMask | ToStringFormatTimeMask,
buffer, sizeof(buffer), &error) | ;
if (jerry_value_has_error_flag(error)) {
return error;
}
if (total_len != 0) {
// user picked options, so we formatted something into buffer
return jerry_create_string_utf8((jerry_char_t *) buffer);
}
// if total_len == 0, nothing was formatted and we default to "<date>, <time>"
return prv_t... |
o.h"
#include "process_state/app_state/app_state.h"
#include "process_management/pebble_process_md.h"
#include "util/bitset.h"
#include "util/size.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
// How long after test pass / fail to wait before popping the window
#define WINDOW_POP_TIME_S (3)
typedef ... | (title, "BUTTON TEST") | ;
layer_add_child(&window->layer, &title->layer);
TextLayer *status = &data->status;
text_layer_init(status,
&GRect(5, 110,
window->layer.bounds.size.w - 5, window->layer.bounds.size.h - 110));
text_layer_set_font(status, fonts_get_system_font(FONT_KEY_GOTHIC_24));
... |
(uint32_t)time;
// In order to normalize the significand, we shift off all the leading 0s
// plus the msb which is implicitly included
int shift = __builtin_clz(time) + 1;
significand <<= shift;
// top 20 bits fit into the upper 32 bits of the double
conv.representation[1] |= (significand >> 12);
// b... | (destination, source, num) | ;
}
// Formatted printing. The ROM's libc library (newlib) is compiled without
// floating point support in order to save space. Because of this, you can
// get an exception and a OS reset if an app tries to use %f or any of the
// other floating point format types in an snprintf call. This is because the
// implement... |
flash
app_db_insert((uint8_t *)&menu_layer.uuid, sizeof(Uuid), (uint8_t *)&menu_layer, sizeof(AppDBEntry));
menu_layer_id = app_db_get_install_id_for_uuid(&menu_layer.uuid);
app_cache_add_entry(menu_layer_id, menu_layer_size /* size */);
cl_assert_equal_i(2, menu_layer_id);
// load second app
app_storage_g... | cl_assert_equal_b(true, app_install_get_uuid_for_install_id(sports_id, &uuid)) | ;
cl_assert_equal_uuid(uuid, sports_uuid);
cl_assert_equal_b(false, app_install_get_uuid_for_install_id(CRAZY_ID, &uuid));
cl_assert_equal_uuid(uuid, UUID_INVALID);
}
void test_app_install_manager__has_worker(void) {
cl_assert_equal_b(false, app_install_has_worker(tictoc_id));
cl_assert_equal_b(false, app_in... |
default:
break;
}
}
//! Action bar click handlers
static void prv_answer_click_handler(ClickRecognizerRef recognizer, void *unused) {
prv_stop_ringing();
phone_call_answer();
// This must be called before prv_set_status_text, otherwise the text will not be centered
prv_action_bar_setup(PhoneCallActi... | (action_bar_animation, ui_animation, NULL) | ;
s_phone_ui_data->action_bar_animation = combined;
animation_schedule(combined);
#if PBL_ROUND
// Extend the bounds to center the call text when the action bar is removed
s_phone_ui_data->caller_id_text_layer.layer.bounds.size.w += TEXT_RIGHTSIDE_PADDING;
text_layer_set_text_alignment(&s_phone_ui_data->calle... |
/*
* 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... | __builtin_unreachable() | |
.h"
#include "services/common/light.h"
#include "services/common/new_timer/new_timer.h"
#include "services/normal/alarms/alarm.h"
#include "util/time/time.h"
#include <stdio.h>
#include <string.h>
#if !PLATFORM_TINTIN
#include "services/normal/vibes/vibe_client.h"
#include "services/normal/vibes/vibe_score.h"
#endif
... | if (low_power_is_active()) {
// Only vibe 10 seconds every minute in low_power_mode
_Static_assert(TINTIN_VIBE_REPEAT_INTERVAL_MS == MS_PER_SECOND,
"LPM Vibes timing incorrect");
if (s_alarm_popup_data->vibe_count % SECONDS_PER_MINUTE < TINTIN_LPM_VIBES_PER_MINUTE) {
... |
#endif
}
else {
prv_stop_vibes();
launcher_task_add_callback(prv_stop_animation_kernel_main_cb, NULL);
}
}
}
static void prv_vibe(void *unused) {
launcher_task_add_callback(prv_vibe_kernel_main_cb, NULL);
}
static void prv_start_vibes(void) {
s_alarm_popup_data->vibe_count = 0;
unsign... |
/*
* 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... | {
#ifndef NO_WATCH_TIMEOUT
prv_start_timer(false /* do not create a timer */);
#endif
} | |
0},
{ 1496, 896, -64},
{ 960, 736, -136},
{ 1368, 728, -168},
{ 968, 808, -184},
{ 1016, 600, -144},
{ 1184, 600, -32},
{ 1624, 528, 56},
{ 1688, 360, 80},
// 72 seconds
{ 1504, 216, 96},
{ 1488, 184, 96},
{ 1472, 248, 40},
{ 1304, 296, 0},
{ 1040, 272, -32},
... | { 1088, 488, -24},
{ 1248, 592, 88},
{ 1344, 784, 392},
{ 904, 1168, 104},
{ 1184, 624, 0},
{ 944, 600, 0},
{ 1144, 688, 8},
{ 1240, 648, 120},
{ 1448, 560, 184},
{ 1664, 376, 96},
{ 1432, 328, 24},
{ 1248, 216, 72},
{ 1288, 192, 8},
{ 1216, 224, -24},
{ 1072,... |
{ 1256, 256, -32},
{ 1176, 288, -56},
{ 1064, 264, -48},
{ 1160, 280, -88},
{ 1104, 280, -200},
{ 1088, 152, -216},
{ 1080, 48, -16},
{ 1000, 136, -104},
{ 1160, 264, -216},
{ 1400, 288, -192},
{ 1304, 344, -240},
{ 984, 264, -96},
{ 936, 328, -264},
{ 960, 288, ... |
BTErrno, sys_ble_client_read, BLECharacteristic characteristic) {
return gatt_client_op_read(characteristic, GAPLEClientApp);
}
DEFINE_SYSCALL(bool, sys_ble_client_get_notification_value_length,
BLECharacteristic *characteristic_out,
uint16_t *value_length_out) {
if (PRIVI... | {
return gatt_client_op_read_descriptor(descriptor, GAPLEClientApp);
} |
// -----------------------------------------------------------------------------
// ble_service.h
DEFINE_SYSCALL(uint8_t, sys_ble_service_get_characteristics, BLEService service_ref,
BLECharacteristic characteristics_out[],
uint8... |
// Close the session file
static void prv_release_session_file(DataLoggingSession *session) {
PBL_ASSERTN(session->storage.fd != DLS_INVALID_FILE);
status_t status = pfs_close(session->storage.fd);
if (status != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_ERROR, "Error %d closing file for session %d", (int)status,
... | {
// Lopping off the used bytes won't satisfy space_needed
goto exit;
} | |
void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Golf sync error! dict: %u, app msg: %u", dict_error,
app_message_error);
}
static void sync_tuple_changed_callback(const uint32_t key, const Tuple *new_tuple,
const Tuple *old_tuple, void *context) {
App... | gbitmap_create_from_png_data(s_golf_api_down_icon_png_data,
sizeof(s_golf_api_down_icon_png_data)) | ;
data->click_bitmap = gbitmap_create_from_png_data(s_golf_api_click_icon_png_data,
sizeof(s_golf_api_click_icon_png_data));
// Set up UI here
Layer *window_layer = window_get_root_layer(window);
TextLayer **text = &data->text_layers[0];
const GRect 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... | for (i = 0; i < j; i++, j--) {
char c = str[i];
str[i] = str[j];
str[j] = c;
} |
}
/* itoa: convert n to characters in s */
void itoa_int(int n, char *str, int base) {
bool neg;
if ((neg = (n < 0))) { /* record sign */
n = -n; /* make n positive */
}
int i = 0;
do { /* generate digits in reverse order */
str[i++] = (n %... |
the timestamp on the samples is NOW! PBL-33765
data->timestamp_us = prv_get_curr_system_time_ms() * 1000;
BMA255_DBG("%"PRId16" %"PRId16" %"PRId16, data->x, data->y, data->z);
}
typedef enum {
BMA255Axis_X = 0,
BMA255Axis_Y,
BMA255Axis_Z,
} BMA255Axis;
static void prv_drain_fifo(void) {
// TODO: I think ... | {
BMA255_DBG("Slope Int");
if (!s_accel_outstanding_motion_work) {
s_accel_outstanding_motion_work = true;
accel_offload_work_from_isr(prv_handle_motion_interrupts, should_context_switch);
}
} |
// Services data / fifo interrupts.
// NOTE: The BMA255 Errata specifically states that we should keep the fifo /
// data interrupt on INT2 to avoid "data inconsistencies" which arise when
// we have it fifo / data interrupt on INT1.
static void prv_bma255_IRQ2_handler(bool *should_context_switch) {
BMA... |
mask = PebbleProtocolAccessPrivate,
.receiver_imp = &g_put_bytes_receiver_impl,
.receiver_opt = NULL,
};
// Fakes
//////////////////////////////////////////////////////////
uint32_t s_boot_bits_orred;
void boot_bit_set(BootBitValue bit) {
s_boot_bits_orred |= bit;
}
static bool s_firmware_update_is_in_progress... | (payload_size) | ,
};
memcpy(&put_msg->payload[0], payload, payload_size);
prv_receive_data(s_session, buffer, sizeof(buffer));
}
static void prv_receive_commit(uint32_t cookie, uint32_t crc) {
CommitRequest commit_msg = (CommitRequest) {
.cmd = CmdCommit,
.cookie = htonl(cookie),
.crc = htonl(crc),
};
prv_rece... |
de_monitor.data_seen_this_interval) {
// The accessory connector didn't have any data since the last time this callback fired.
++s_stop_mode_monitor.intervals_without_data;
if (s_stop_mode_monitor.intervals_without_data >=
s_stop_mode_monitor.max_intervals_without_data) {
// Enough intervals ... | prv_initialize_hardware() | ;
accessory_set_power(false);
accessory_enable_input();
}
void accessory_block(void) {
prv_lock();
accessory_send_stream_stop();
uart_deinit(ACCESSORY_UART);
}
void accessory_unblock(void) {
// We want to restore the previous baudrate, but clear s_baudrate in order to force a complete
// re-init of the ... |
(recognizer_transition_state(r, RecognizerState_Started)) | ;
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Updated));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Cancelled));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Completed));
r->state = RecognizerState_Started;
event_type = -1;
recognizer_transitio... | |
----------------------
// We start time out at 5pm on Jan 1, 2015 for all of these tests
static const struct tm s_init_time_tm = {
// Thursday, Jan 1, 2015, 5:pm
.tm_hour = 17,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
// Logged items
#define TEST_PL_DLS_SESSION_ID 1
typedef struct {
uint8_t data[PLOG_... | memset(&s_types, 0, sizeof(s_types)) | ;
memset(&s_offsets, 0, sizeof(s_offsets));
memset(&s_values, 0, sizeof(s_values));
s_parsed_msg = (TestPLParsedMsg) {
.msrmt = {
.num_types = ARRAY_LENGTH(s_types),
.types = s_types,
.num_samples = ARRAY_LENGTH(s_offsets),
.offset_sec = s_offsets,
.num_values = ARRAY_LENGTH(s_v... |
,
{ -648, -400, 560},
// 236 seconds
{ -544, -280, 360},
{ -432, 720, -184},
{ -816, 1024, 64},
{ -976, 0, 440},
{ -952, -1184, 216},
{ -704, -720, -488},
{ -496, -200, -2072},
{ -960, 2432, -1488},
{ -872, 776, -816},
{ -672, 16, -512},
{ -544, -152, -312},
{ -63... | { 72, 664, -136},
{ 296, 952, -112},
{ 688, 832, -384},
{ 472, 656, 184},
{ -848, 1272, 736},
{ 648, 888, -1400},
{ 88, 256, -480},
{ 80, 1216, -560},
{ 272, 904, -600},
{ 208, 800, -640},
{ 200, 752, -592},
{ 176, 856, -536},
{ 168, 952, -544},
{ 176, 920, -552},... |
// 244 seconds
{ 216, 896, -536},
{ 224, 888, -536},
{ 216, 872, -520},
{ 208, 888, -536},
{ 216, 880, -528},
{ 216, 888, -544},
{ 224, 880, -544},
{ 216, 864, -552},
{ 224, 872, -560},
{ 224, 872, -552},
{ 224, 872, -552},
{ 224, 880, -552},
{ 224, 864, -552},
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (size_t i = 0; i < ARRAY_LENGTH(s_runlevel_debug_names); ++i) {
char response[80];
itoa_int(i, response, 10);
strcat(response, " - ");
strcat(response, s_runlevel_debug_names[i]);
prompt_send_response(response);
} |
}
void command_set_runlevel(char *arg) {
if (strcmp(arg, "list") == 0) {
prv_list_runlevels();
return;
}
int runlevel = atoi(arg);
if (runlevel < 0 || runlevel >= RunLevel_COUNT) {
prompt_send_response("Unknown runlevel");
return;
} else if (runlevel == 0 && arg[0] != '0') {
prompt_send... |
GContext *ctx, KinoReel *reel, GDrawCommandList *list, GPoint offset,
KinoReelProcessor *processor) {
if (list) {
prv_draw_command_list_processed(ctx, list, offset, processor);
} else {
kino_reel_draw_processed(reel, ctx, offset, processor);
}
}
static void prv_draw_processed_in_local(KinoReelTransfo... | {
return data->context;
} |
return NULL;
}
void kino_reel_transform_set_from_reel(KinoReel *reel, KinoReel *from_reel,
bool take_ownership) {
KinoReelTransformData *data = kino_reel_custom_get_data(reel);
if (!data) {
return;
}
if (data->owns_from_reel) {
kino_reel_destroy(data->from... |
_head, cell_index->row - 1);
// Format 1: 10:34 AM
// Format 2: 14:56
char alarm_time_text[9];
clock_format_time(alarm_time_text, sizeof(alarm_time_text),
node->info.hour, node->info.minute, true);
const char *enabled = node->info.enabled ? i18n_get("ON", data) : i18n_get("OFF", data);
... | (&expandable_dialog->dialog.window, false /* animated */) | ;
}
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
//! App boilerplate
static void prv_handle_init(void) {
AlarmsAppData *data = app_malloc_check(sizeof(*data));
*data = (AlarmsAppData) {{ .user_data = NULL }};
Window *window = &data->window;
window... |
-1272, -224, -48},
{ -1456, -432, -40},
{ -1448, -144, 168},
{ -1240, 232, 360},
{ -2568, 1728, -896},
{ -704, 4000, -3320},
// 20 seconds
{ 2104, 2576, -1128},
{ 752, 1056, -152},
{ 1264, 88, 88},
{ 1432, -464, 168},
{ 1440, -688, 48},
{ 1416, -272, 296},
{ 1336, 12... | // 25 seconds
{ -584, 872, -432},
{ -480, 160, -240},
{ -1048, -112, 216},
{ -1648, -184, 8},
{ -1128, 0, -24},
{ -1176, 224, 304},
{ -2040, 2544, -1472},
{ -1064, 4000, -2568},
{ 384, 3616, -1040},
{ 648, 1448, -80},
{ 1232, 856, -256},
{ 1904, -120, -408},
{ 156... |
{ -2352, 4000, -824},
{ -760, 4000, -1696},
{ 136, 2248, -304},
{ 800, 888, 80},
{ 1560, 256, -160},
{ 1200, -568, -408},
{ 1480, 88, -16},
{ 880, -272, 48},
{ 936, 616, -264},
{ 896, 2016, -1088},
{ 512, 4000, -1536},
{ 224, 3568, -1528},
// 28 seconds
{ -368, 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.