prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
, EN_DASH, buffer_size);
return;
}
snprintf(buffer, buffer_size, "%"PRId32, current_calories);
}
static void prv_set_distance(char *buffer, size_t buffer_size, int32_t current_distance_meters) {
if (current_distance_meters == 0) {
strncpy(buffer, EN_DASH, buffer_size);
return;
}
const int conve... | {
HealthDetailCard *card = (HealthDetailCard *)window;
HealthActivityDetailCardData *card_data = card->data;
for (int i = 0; i < card_data->num_headings; i++) {
app_free(card_data->headings[i].primary_value);
app_free(card_data->headings[i].secondary_value);
}
for (int i = 0; i < card_data->num_subtit... | |
fset;
// Have we gone through first use before? If not, show first use UI. Otherwise show recovery UI.
const bool first_use_is_complete = shared_prf_storage_get_getting_started_complete();
// Pick the right layout for the screen
if (first_use_is_complete || data->has_pebble_mobile_app_connected) {
// If f... | if (first_use_is_complete || data->has_pebble_mobile_app_connected || data->is_showing_version) {
name_font_key = FONT_KEY_GOTHIC_14;
} else {
name_font_key = FONT_KEY_GOTHIC_24;
} |
text_layer_set_font(&data->name_text_layer, fonts_get_system_font(name_font_key));
#endif
// Update the size of the name text layer based on the new content.
// First set the text layer to be the width of the entire window and only a single line of text
// high.
layer_set_frame(&data->name_text_layer.layer... |
sizeof(AppMessagePush));
cl_assert_equal_p(r, NULL);
cl_assert_equal_b(false, s_kernel_receiver_is_receiving);
fake_kernel_malloc_mark_assert_equal();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Normal flow: writing m... | app_message_receiver_open(sizeof(AppMessagePush)) | |
/*
* 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... | animation_get_duration(s_animation, true, true) | ;
animation_set_elapsed(s_animation, duration - 300);
APP_LOG(APP_LOG_LEVEL_INFO, "Advancing to 300ms from the end of %d ms", (int)duration);
return;
}
Layer *layer = text_layer_get_layer(s_text_layer_a);
GRect from_rect_a = GRect(0, 0, 60, 60);
GRect to_rect_a = GRect(84, 92, 60, 60);
GRect fr... |
/*
* 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_antialiased(ctx, false) | ;
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(10, 2, 18, 4), 4, GCornersAll);
}
void across_nx_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rec... |
s_prv_activity_cb__call_count;
static uint32_t s_prv_activity_cb__false_at_call_no = UINT32_MAX;
bool prv_activity_cb(HealthActivity activity,
time_t time_start, time_t time_end,
void *context) {
s_prv_activity_cb__args[s_prv_activity_cb__call_count] = (HealthActivityCBData... | cl_assert_equal_i(s_sys_activity_get_metric_values.in.metric, ActivityMetricStepCount) | |
nvoked if we close with read access
s_watch_file_callback_called_count = 0;
fd = pfs_open(file_name, OP_FLAG_READ, 0, 0);
cl_assert(fd >= 0);
pfs_close(fd);
cl_assert(s_watch_file_callback_called_count == 0);
// Callback should get invoked if we remove the file
s_watch_file_callback_called_count = 0;
p... | cl_assert(fd >= 0) | ;
fd = pfs_open("b_test_1", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
// Get a directory listing with no filtering
PFSFileListEntry *dir_list;
dir_list = pfs_create_file_list(NULL);
// Should have 4 entries in it
cl_assert_equal_i(list_count(&dir_list->list_node), 4);
cl_assert(list_fi... |
/ --------------------------------------------------------------------------------------
static void prv_gcolor8_setter(GColor8 *p, GColor8 value) {
*p = value;
}
static GColor8 prv_gcolor8_getter(GColor8 *p) {
return *p;
}
// --------------------------------------------------------------------------------------... | (max_loops > 0) | ;
max_loops--;
}
// Make sure the frame reached the "to" state
cl_assert_equal_point(layer.frame.origin, to_r.origin);
// Make sure our started and stopped handlers got called
cl_assert_equal_i(s_started_handler_calls.num_calls, 1);;
cl_assert(s_started_handler_calls.entries[0].fired_time_ms - start_m... |
put_msg,
sizeof(incomplete_put_msg));
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__commit_message_sent_while_previous_put_was_not_acked_yet(void) {
uint8_t max_put_ops = prv_put_bytes_get_max_batched_pb_ops();
prv_receive_init(VALID_OBJECT_SIZE * max_put_o... | {
prv_receive_init_put_and_commit_fw_object();
prv_receive_install(~s_last_response_cookie);
assert_ack_count(0);
assert_nack_count(1);
} | |
viceRemoveSubscriberCallback remove_subscriber_callback;
} EventServiceEntry;
typedef struct {
ListNode list_node;
void *ptr;
// There is an intent bit for each task + a special "claimed" bit
uint16_t intents_pending;
} EventServiceBuffer;
static const uint16_t CLAIMED_BIT = (1 << NumPebbleTask);
static Even... | (sizeof(EventServiceEntry)) | ;
memset(s_event_services[type], 0, sizeof(*s_event_services[type]));
s_event_services[type]->add_subscriber_callback = add_subscriber_callback;
s_event_services[type]->remove_subscriber_callback = remove_subscriber_callback;
}
bool event_service_is_running(PebbleEventType event_type) {
if (s_event_services[ev... |
/*
* 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... | (LOG_LEVEL_ERROR, "Error %d while logging data", (int)result) | ;
}
}
unlock:
mutex_unlock(s_plog_state.mutex);
return success;
}
// -----------------------------------------------------------------------------------------
// Encode a struct `msg` with the field number and fields passed.
static bool prv_encode_struct(pb_ostream_t *stream, uint32_t field_number,
... |
&nap_count);
PBL_LOG(LOG_LEVEL_DEBUG, "Found %d sleep sessions and %d nap sessions", sleep_count, nap_count);
if (nap_count > 0 || sleep_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "FAILED: expected only sleep but got %d naps and %d sleep", nap_count,
sleep_count);
prv_test_end(context, false);
r... | (rtc_get_time()) | + 1 * SECONDS_PER_DAY);
ActivityInsightSettings original_settings;
activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD, &original_settings);
ActivityInsightSettings disabled_settings = original_settings;
disabled_settings.enabled = false;
activity_insights_settings_write(ACTIVITY_INS... |
ime
prv_feed_cannned_accel_data(k_elapsed_sec, steps_per_minute, ActivitySleepStateAwake);
activity_get_metric(ActivityMetricStepCount, 1, &value);
cl_assert_near(value, ROUND(steps_per_minute * k_elapsed_sec, SECONDS_PER_MINUTE), 5);
activity_get_metric(ActivityMetricDistanceMeters, 1, &value);
a... | {
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
s_test_alg_state.orientation = 0x11; // Not flat
prv_advance_ti... |
cl_assert(s_hrm_manager_update_interval > SECONDS_PER_HOUR);
// Advance to our next sampling period, but the watch is flat so we shouldn't start sampling
s_test_alg_state.orientation = 0x00; // Flat
prv_advance_time_hr(ACTIVITY_DEFAULT_HR_PERIOD_SEC, 100 /*bpm*/, HRMQuality_Good, false /*force_continuous*/);
... |
ORECF | USART_ICR_PECF | USART_ICR_NCF | USART_ICR_FECF);
}
static void prv_init(UARTDevice *dev, bool is_open_drain, UARTCR1Flags cr1_extra_flags) {
// Enable peripheral clock
periph_config_enable(dev->periph, dev->rcc_apb_periph);
// configure GPIO
const GPIOOType_TypeDef otype = is_open_drain ? GPIO_OType_... | {
return dev->periph->ISR & USART_ISR_RXNE;
} |
bool uart_has_rx_overrun(UARTDevice *dev) {
return dev->periph->ISR & USART_ISR_ORE;
}
bool uart_has_rx_framing_error(UARTDevice *dev) {
return dev->periph->ISR & USART_ISR_FE;
}
bool uart_is_tx_ready(UARTDevice *dev) {
return dev->periph->ISR & USART_ISR_TXE;
}
bool uart_is_tx_complete(UARTDevice *dev) {
... |
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 (result < 0) {
P... | {
// Skip over deleted notification
pfs_seek(*fd, iter_state.header.payload_length, FSeekCur);
continue;
} |
TimelineItem notification;
if (!prv_get_notification(¬ification, &iter_state.header, *fd)) {
// Error occurred
goto cleanup;
}
int result = prv_write_notification(¬ification, &iter_state.header, new_fd);
if (result < 0) {
// Error occurred
kernel_free(notification.all... |
/*
* 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... | ("blah %p", glob_ptr) | ;
}
mutex_unlock(global_lock);
}
void timeout() {
mutex_lock_with_timeout(global_lock);
mutex_unlock(global_lock);
}
void good_timeout() {
if (mutex_lock_with_timeout(global_lock)) {
mutex_unlock(global_lock);
}
}
void stupid_timeout() {
if (!mutex_lock_with_timeout(global_lock)) {
mutex_unlo... |
(buf, buf_size, "%m", &good_data);
if (r == 0 || strncmp(buf, "05", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"m\": %s", buf);
}
r = strftime(buf, buf_size, "%M", &good_data);
if (r == 0 || strncmp(buf, "04", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"M\": %s", buf);... | strftime(buf, buf_size, "%p", &bad_data) | ;
strftime(buf, buf_size, "%r", &bad_data);
strftime(buf, buf_size, "%R", &bad_data);
strftime(buf, buf_size, "%S", &bad_data);
strftime(buf, buf_size, "%T", &bad_data);
strftime(buf, buf_size, "%u", &bad_data);
strftime(buf, buf_size, "%U", &bad_data);
strftime(buf, buf_size, "%V", &bad_data);
... |
gs[bus_idx].i2c_scl, false);
bus_pin_cfg_output(BOARD_CONFIG.i2c_bus_configs[bus_idx].i2c_sda, false);
}
//! Power up I2C bus power supply
//! Always lock bus and peripheral config access before use
static void bus_rail_power_up(uint8_t bus_idx) {
if (BOARD_CONFIG.i2c_bus_configs[bus_idx].rail_ctl_fn == NULL) {
... | BOARD_CONFIG.i2c_bus_configs[i].rail_cfg_fn() | |
/*
* 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... | (&payload->address) | ;
if (connection == NULL) {
PBL_LOG(LOG_LEVEL_WARNING, "Discovery complete but no device connected?");
return;
}
BTErrno e = (payload->status == HciStatusCode_Success) ? BTErrnoOK :
(BTErrnoInternalErrorBegin + payload->status);
bt_driver_cb_gatt_client_discovery_complete(connection, e);
}
stat... |
g, 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.
*/
#include "get_bytes_storage_file.h"
#include "get_byt... | kernel_free(storage->impl_data) | |
d_data[2], uuid_bytes, sizeof(Uuid));
// One should fit though:
cl_assert_equal_b(ble_ad_set_service_uuids(ad, uuid, 1), true);
cl_assert_equal_i(memcmp(expected_ad_data, ad->data,
sizeof(expected_ad_data)), 0);
cl_assert_equal_i(ad->ad_data_length, sizeof(expected_ad_data));
cl_a... | cl_assert_equal_b(ble_ad_set_manufacturer_specific_data(ad,
0x1234,
(uint8_t *) "hello world",
11), true) | |
9, 0x6f, 0x75, 0x20, 0x6c,
0x61, 0x74, 0x65, 0x72, 0x00, 0x54, 0x68, 0x61, 0x6e, 0x6b, 0x20, 0x79, 0x6f, 0x75, 0x00, 0x53,
0x65, 0x65, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x73, 0x6f, 0x6f, 0x6e, 0x00, 0x52, 0x75, 0x6e, 0x6e,
0x69, 0x6e, 0x67, 0x20, 0x6c, 0x61, 0x74, 0x65, 0x00, 0x4f, 0x6e, 0x20, 0x6d, 0x79, 0x20, 0x77,... | (&attr_list) | ;
ios_notif_pref_db_free_prefs(notif_prefs);
}
void test_ios_notif_pref_db__store_empty_prefs(void) {
// Store empty prefs
char *key = "key1";
int key_len = strlen(key);
ios_notif_pref_db_store_prefs((uint8_t *)key, key_len, NULL, NULL);
// Read them back
iOSNotifPrefs *notif_prefs = ios_notif_pref_db_g... |
window_set_click_config_provider(window, NULL);
}
static void confirm_click_handler(ClickRecognizerRef recognizer, Window *window) {
ConfirmUIData *data = window_get_user_data(window);
// Need to lock-out inputs after starting the factory reset.
prv_lockout_back_button(window);
PeekLayer *peek_layer = &data-... | (forget_text_layer, &forget_text_frame,
i18n_get(BT_FORGET_PAIRING_STR, data),
fonts_get_system_font(FONT_KEY_GOTHIC_18), text_color,
GColorClear, alignment, overflow_mode) | ;
layer_add_child(&window->layer, &forget_text_layer->layer);
#if PBL_ROUND
text_layer_enable_screen_text_flow_and_paging(forget_text_layer, text_flow_inset);
#endif
// Action bar:
ActionBarLayer *action_bar = &data->action_bar;
action_bar_layer_init(action_bar);
action_bar_layer_set_context(action_bar, wi... |
ST_ONCE, just_once_schedule_thursday);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 4);
cl_assert_equal_i(s_num_timeline_removes, 2);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm goes off. No alarms should be up
s_c... | cl_assert_equal_i(s_num_timeline_adds, 1) | ;
id2 = alarm_create(&(AlarmInfo) { .hour = 11, .minute = 30, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_1 });
prv_assert_alarm_config(id2, 11, 30, false, ALARM_KIND_CUSTOM, schedule_1);
cl_assert_equal_i(s_num_timeline_adds, 2);
// First alarm goes off. Second one should be up
s_current_hour = ... |
_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
bool custom_schedule1[7] = {true, false, true, false, false, true, true};
alarm_set_custom(id, custom_schedule1);
prv_assert_alarm_config(id, 3, 1... | (s_num_timeline_removes, 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... | graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App) | ;
s_app_state_get_graphics_context = &s_ctx;
}
|
CATION_PRIORITY, true /* animated */);
} else if (in_view) {
// Only focus the new notification if it becomes the new front of the list.
// In DND mode notifications can get inserted into the middle of the list and we don't
// want to change focus in this use case
if (notifications_presented... | if (should_focus) {
const bool animated = true;
notification_window_focus_notification(id, animated);
} | |
pp_prefs_db__insert_send_text(void) {
const int data_len = sizeof(s_send_text_prefs);
cl_assert_equal_i(
watch_app_prefs_db_insert(SEND_TEXT_KEY, SEND_TEXT_KEY_LEN, s_send_text_prefs, data_len),
S_SUCCESS);
cl_assert_equal_i(watch_app_prefs_db_get_len(SEND_TEXT_KEY, SEND_TEXT_KEY_LEN), data_len);
... | watch_app_prefs_get_send_text() | ;
cl_assert_equal_m(s_send_text_prefs, send_text_prefs_out, data_len);
task_free(send_text_prefs_out);
}
void test_watch_app_prefs_db__get_weather(void) {
const int data_len = sizeof(s_weather_prefs);
cl_assert_equal_i(watch_app_prefs_db_insert(WEATHER_KEY, WEATHER_KEY_LEN,
... |
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "drivers/qemu/qemu_serial.h"
#include "drivers/qemu/qemu_serial_private.h"
#include "util/net.h"
#include "clar.h"
exte... | qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol) | );
// -----------------------------------------------------------------------------
// Check after just part of the data
prv_send_hdr(QemuProtocol_SPP, 2*sizeof(msg_data));
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
prv_send_bytes(msg_data, sizeof(msg_data));
cl... |
(data->background_layer, &s_fps_background_bitmap) | ;
layer_add_child(root_layer, (Layer *)data->background_layer);
data->topleft_layer = bitmap_layer_create(GRect(0, 0, navbar_width, navbar_width));
bitmap_layer_set_background_color(data->topleft_layer, GColorWhite);
bitmap_layer_set_bitmap(data->topleft_layer, &s_fps_topleft_bitmap);
layer_add_child(root_l... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (sizeof(*watchfaces_glance)) | ;
// Copy the name of the Watchfaces app as the title
const size_t title_size = sizeof(watchfaces_glance->title);
strncpy(watchfaces_glance->title, node->name, title_size);
watchfaces_glance->title[title_size - 1] = '\0';
// Create the icon for the Watchfaces app
watchfaces_glance->icon = kino_reel_create... |
_send_event(VoiceEventTypeSessionResult, VoiceStatusTimeout, NULL);
mutex_unlock(s_lock);
}
static void prv_session_setup_timeout(void * data) {
mutex_lock(s_lock);
PBL_ASSERTN(s_state == SessionState_StartSession ||
s_state == SessionState_VoiceEndpointSetupReceived ||
s_state == Se... | {
goto unlock;
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
settings_menu_push(cell_index->row);
} |
static int16_t prv_get_cell_height_callback(MenuLayer *menu_layer,
MenuIndex *cell_index, void *context) {
PBL_ASSERTN(cell_index->row < SettingsMenuItem_Count);
#if PBL_RECT
const int16_t category_title_height = 37;
return category_title_height;
#else
const int16_... |
/*
* 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... | {
// TODO: What if Pebble App is connected via iSPP *and* PPoGATT ?
return comm_session_get_by_type(CommSessionTypeSystem);
} |
CommSession* comm_session_get_current_app_session(void) {
// TODO: What if App is connected via iSPP *and* PPoGATT ?
return comm_session_get_by_type(CommSessionTypeApp);
}
void comm_session_close(CommSession *session, CommSessionCloseReason reason) {
cl_assert(list_contains((const ListNode *) s_session_head, &... |
(e, BTErrnoOK) | ;
// Verify (only) the app task got a (virtual) connection event:
prv_assert_client_event(&device, true /* connected */, (1 << PebbleTask_App),
HCI_ERROR_CODE_SUCCESS);
}
void __disabled_test_gap_le_connect__disconnection_event_upon_airplane_mode(void) {
BTDeviceInternal device = prv_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... | {
return false;
} |
if (battery_is_usb_connected()) {
return false;
}
if (prv_get_ms_since_last_notification_vibe() < NOTIFICATION_VIBE_HOLDOFF_MS) {
return false;
}
return alerts_preferences_get_vibrate();
}
bool alerts_get_vibrate(void) {
return alerts_preferences_get_vibrate();
}
AlertMask alerts_get_mask(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... | (response) | |
edef enum {
RuninStateStart = 0,
RuninStatePlugCharger,
RuninStateRunning,
RuninStatePass,
RuninStateFail,
} RuninTestState;
static const char* status_text[] = {
[RuninStateStart] = "Start",
[RuninStatePlugCharger] = "Plug Charger",
[RuninStateRunning] = "Running...",
[RuninStatePass] = ... | app_window_stack_pop(true) | ;
}
}
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *data) {
AppData *app_data = app_state_get_user_data();
if (app_data->test_state == RuninStateFail || app_data->test_state == RuninStatePass) {
// we've finished the runin test - long-press to close the app
app_window_stack_p... |
cs_context_init(&ctx, fb);
// TODO: Remove these #ifdefs in PBL-15916 when support for non-antialiased rounded rect
#if SCREEN_COLOR_DEPTH_BITS == 8
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT... | prv_clamp_corner_radius(GSize(8, 10), GCornersAll, 4) | |
/*
* 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... | {
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
#ifdef MICRO_FAMILY_STM32F7
DWT->LAR = 0xC5ACCE55;
#endif
DWT->CYCCNT = 0;
DWT->CTRL |= 0x01;
g_profiler.start = DWT->CYCCNT;
} | |
1336, 16, 16},
{ 896, 24, -56},
{ 912, -96, -88},
{ 1088, -160, 16},
{ 1104, 40, -192},
{ 1128, 56, -224},
{ 1064, -48, -160},
{ 960, 0, -232},
{ 872, 64, -288},
{ 832, 112, -136},
{ 968, 144, -48},
{ 1072, 216, -48},
{ 1016, 248, -112},
{ 1080, 208, -96},
{ 1448... | { 1704, 184, -184},
{ 1744, 112, -192},
{ 1360, 144, -208},
{ 864, 136, -192},
{ 688, 208, -40},
{ 736, 248, -48},
{ 928, 240, -48},
// 76 seconds
{ 992, 256, -56},
{ 1136, 240, 40},
{ 1392, 320, 136},
{ 944, 448, 200},
{ 1408, 544, 40},
{ 1136, 536, -72},
{ 1... | |
/*
* 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_weather_db.settings_file,
prv_weather_db_for_each_cb,
&data) | ;
prv_close_file_and_unlock_mutex();
return S_SUCCESS;
}
/////////////////////////
// Blob DB API
/////////////////////////
void weather_db_init(void) {
memset(&s_weather_db, 0, sizeof(s_weather_db));
s_weather_db.mutex = mutex_create();
}
status_t weather_db_flush(void) {
if (!weather_service_supported_... |
i(layout.box.size.w, box.size.w);
cl_assert_equal_i(layout.max_used_size.h, 0);
cl_assert_equal_i(layout.max_used_size.w, 0);
graphics_text_layout_get_max_used_size(&gcontext, doubleton, font, box,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, (void*)&layout);
cl_assert_equal_i(layout.box.size.... | (&gcontext, "JR Whopper", font, box, GTextOverflowModeWordWrap, GTextAlignmentLeft, (void*)&layout) | ;
cl_assert(layout.box.size.w == box.size.w);
cl_assert_equal_i(layout.max_used_size.w, 4 * HORIZ_ADVANCE_PX);
// 3 lines - one line extra being layed out so that it will clip ("Jr\nWho-\npper")
cl_assert_equal_i(layout.max_used_size.h, 3 * (FONT_HEIGHT + FONT_LINE_DELTA));
graphics_text_layout_get_max_used_... |
ed);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Failed);
// A touchdown occurs where no layers are touched while a window recognizer is active
e.type = TouchEvent_Touchdown;
s_active_layer = NULL;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {... | (NULL, 0, &s_recognizers_reset) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersActive);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[... |
tric)alert;
if (prv_is_heart_rate_metric(metric) && !sys_activity_prefs_heart_rate_is_enabled()) {
return false;
}
switch (metric) {
case HealthMetricHeartRateBPM:
state->cache->alert_threshold_heart_rate = (HealthServiceMetricAlertInfo) {};
return true;
default:
return false;
}
#... | (ActivitySessionType_Walk) | ) {
result |= HealthActivityWalk;
}
if (sys_activity_sessions_is_session_type_ongoing(ActivitySessionType_Run)) {
result |= HealthActivityRun;
}
if (sys_activity_sessions_is_session_type_ongoing(ActivitySessionType_Open)) {
result |= HealthActivityOpenWorkout;
}
return result;
#endif
}
// --... |
0,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
},
.attr_list = {
.num_attributes = 0,
.attributes = NULL,
},
.action_group = {
.num_actions = 0,
.actions = NULL,
},
.allocated_buffer = NULL,
}, {
.header = { // [2... | (new_idx, 2) | ;
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[0]].header.id,
&timeline_model_get_iter_state(-1)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[1]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_eq... |
ce we have no action menu
data->standalone_action = true;
} else if (complete_cb) {
// If data is NULL, something went wrong (or local action), so call callback in case caller
// relies on it for cleanup
complete_cb(false /* success */, cb_data);
}
}
static void prv_push_dismiss_first_use_dialog(Ac... | for (size_t i = 0; i < canned_responses_count; i++) {
const char *label = string_list_get_at(responses_list, i);
action_menu_level_add_action(template_level, label, prv_action_menu_cb, action);
} |
} else {
// hard-wired default responses in case the phone app doesn't provide any
static char *strings[] = {
i18n_noop("Ok"),
i18n_noop("Yes"),
i18n_noop("No"),
i18n_noop("Call me"),
i18n_noop("Call you later"),
};
template_level = prv_create_level(ARRAY_LENGTH(strings)... |
if (prv_parse_hex_comps(color_value + 1, 1, &r, &g, &b, &a)) {
*parsed_color = GColorFromRGBA(r * (255/15), g * (255/15), b * (255/15), a * (255/15));
if (parsed_color->a == 0) {
*parsed_color = GColorClear;
}
return true;
} |
}
case 7: { // #RRGGBB
if (prv_parse_hex_comps(color_value + 1, 2, &r, &g, &b, NULL)) {
*parsed_color = GColorFromRGB(r, g, b);
return true;
}
}
case 9: { // #RRGGBBAA
if (prv_parse_hex_comps(color_value + 1, 2, &r, &g, &b, &a)) {
*parsed_color = GColorFromRGBA... | |
/*
* 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;
} | |
tributes * sizeof(SerializedAttributeHeader));
for (int i = 0; i < attr_list->num_attributes; i++) {
switch (prv_attribute_type(attr_list->attributes[i].id)) {
case AttributeTypeString:
size += strlen(attr_list->attributes[i].cstring);
break;
case AttributeTypeResourceId:
... | (dest->cstring, src->cstring, attribute_length) | ;
break;
}
case AttributeTypeStringList: {
dest->string_list = (StringList *)*buffer;
dest->string_list->serialized_byte_length = src->string_list->serialized_byte_length;
memcpy(dest->string_list->data, src->string_list->data,
src->string_list->serialized_byte_length);
... |
rv_create_layout(layer, iter_state, s_nonvisible_items[0]);
if (iter_state->current_day != layer->current_day) {
// we moved back to an item from the previous day, display the day separator
// by first hiding the pin of the "last" day that is about to come in and placing it there
if (layer->layouts[0]) {... | (
&s_implementation, timeline_layer, &timeline_layer->sidebar_width, &to_sidebar_width) | |
/*
* 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... | (g_profiler.nodes, (ListNode *)node) | |
tributeId id, const char *cstring) {
if (prv_attribute_type(id) != AttributeTypeString) {
PBL_LOG(LOG_LEVEL_WARNING, "Adding attribute with type cstring for non-cstring attribute");
}
prv_add_attribute(list, id)->cstring = (char*) cstring;
}
void attribute_list_add_uint32(AttributeList *list, AttributeId id,... | attribute_find(attr_list, id) | ;
return attribute ? attribute->cstring : default_value;
}
StringList *attribute_get_string_list(
const AttributeList *attr_list, AttributeId id) {
PBL_ASSERTN(attr_list != NULL);
Attribute *attribute = attribute_find(attr_list, id);
return attribute ? attribute->string_list : NULL;
}
uint8_t attribute_g... |
ble_pairings_count, AnalyticsClient_System);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Local Device Info
void bt_persistent_storage_set_active_gateway(BTBondingID bonding) {
BTBondingID old_active_gateway;
int read_size = prv_file_get(&... | {
*capabilities_out = (PebbleProtocolCapabilities) {};
} |
}
void bt_persistent_storage_get_cached_system_capabilities(
PebbleProtocolCapabilities *capabilities_out) {
if (!capabilities_out) {
return;
}
prv_lock();
{
*capabilities_out = s_cached_system_capabilities;
}
prv_unlock();
}
void bt_persistent_storage_set_cached_system_capabilities(
con... |
/*
* 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 (dev->state->use_count++ == 0) {
periph_config_enable(QUADSPI, dev->clock_ctrl);
} |
}
void qspi_release(QSPIPort *dev) {
PBL_ASSERTN(dev->state->use_count > 0);
if (--dev->state->use_count == 0) {
periph_config_disable(QUADSPI, dev->clock_ctrl);
}
}
static void prv_set_num_data_bytes(uint32_t length) {
// From the docs: QSPI_DataLength: Number of data to be retrieved, value+1.
// so 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... | (".rocky_bss") | |
/*
* 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 (s_subscribe_head) {
list_append((ListNode *)s_subscribe_head, &subscribe->node);
} else {
s_subscribe_head = subscribe;
} | |
/*
* 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... | uuid_is_invalid(&invalid) | );
cl_assert(!uuid_is_invalid(&system));
cl_assert(!uuid_is_invalid(&test_uuid_1));
}
void test_uuid__string(void) {
char buffer[UUID_STRING_BUFFER_LENGTH];
const Uuid test_uuid_1 = (Uuid) {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5
};
uuid_to_string(&test_uuid_1, buffer);
cl_assert_equal_s(bu... |
eof(Uuid)) == 0);
// confirm the others are still here
cl_assert(reminder_db_get_len((uint8_t*)&item3.header.id, sizeof(Uuid)) > 0);
cl_assert(reminder_db_get_len((uint8_t*)&item4.header.id, sizeof(Uuid)) > 0);
}
void test_reminder_db__bad_item(void) {
cl_assert(S_SUCCESS != reminder_db_insert((uint8_t *)&bad_... | cl_assert(!dirty_list) | |
t positive_attr_list = {0};
attribute_list_add_cstring(&positive_attr_list, AttributeIdTitle,
i18n_get(notif_config->text_positive_action, ¬if_attr_list));
attribute_list_add_cstring(&positive_attr_list, AttributeIdBody,
i18n_get(notif_config->text_positi... | ("Open App", i18n_owner) | );
// Set the launch args to open the correct health app card
HealthLaunchArgs launch_args = {
.card_type = card_type,
};
attribute_list_add_uint32(action_attr_list, AttributeIdLaunchCode, launch_args.args);
}
// ----------------------------------------------------------------------------------------------... |
{ 1632, 472, -120},
{ 1592, 552, -80},
{ 1552, 624, -48},
{ 1280, 768, 56},
{ 1112, 752, 152},
{ 968, 1072, 168},
{ 776, 832, 40},
{ 848, 768, 16},
{ 952, 680, -40},
{ 1080, 552, -104},
{ 1152, 464, -128},
{ 1384, 352, -176},
{ 1800, 136, -104},
{ 1712, 88, -56},
... | { 1728, 216, 32},
{ 1408, 224, -88},
{ 1384, 200, -160},
{ 1000, -504, 72},
// 66 seconds
{ 488, -360, 80},
{ 896, -160, -368},
{ 1080, -232, 8},
{ 1312, 192, -224},
{ 1280, 48, -208},
{ 1296, 208, -224},
{ 1472, 328, -192},
{ 1640, 456, -296},
{ 1656, 656, -344},... |
{ 1416, 672, -352},
{ 1120, 816, -336},
{ 936, 880, -280},
{ 1040, 912, -216},
{ 1040, 752, -256},
{ 1096, 672, -208},
{ 1288, 536, -192},
{ 1240, 328, -160},
{ 1232, 272, -104},
{ 1328, 296, -104},
{ 1400, 248, -64},
{ 1392, 224, -32},
{ 1432, 168, -16},
{ 1232,... |
/*
* 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... | {
snprintf(buffer + pos, buffer_size - pos, " %"PRId32, daily_avg);
} | else {
snprintf(buffer + pos, buffer_size - pos, " "EN_DASH);
}
}
Window *health_activity_detail_card_create(HealthData *health_data) {
HealthActivityDetailCardData *card_data = app_zalloc_check(sizeof(HealthActivityDetailCardData));
card_data->daily_avg = health_data_steps_get_monthly_average(health_data)... |
75,
PmicRegisters_INT_STATUS_1 = 0x77,
PmicRegisters_INT_STATUS_2 = 0x78,
PmicRegisters_CHARGE_CNTL = 0x80,
PmicRegisters_CHARGE_VOLTAGE_CNTL = 0x81,
PmicRegisters_CHARGE_CURRENT_CNTL = 0x82,
PmicRegisters_CHARGE_CONFIG_1 = 0x83,
PmicRegisters_CHARGE_CONFIG_2 = 0x84,
PmicRegisters_CHARGE_SUPERVISION = 0... | (PmicRegisters_INT_STATUS_2, &throwaway_read_result) | ;
}
// Set up 120Hz clock which is used for VCOM.
// Slowest possible setting, with divisor of 16 and high/low duration of 256us.
void prv_start_120hz_clock(void) {
const uint8_t pwm_high_low_time_us = (256 - 1);
prv_write_register(PmicRegisters_PWM_CNTL_H, pwm_high_low_time_us);
prv_write_register(PmicRegisters... |
tentIndicatorDirectionDown]);
menu_layer_set_selected_index(&l, MenuIndex(0, 1), MenuRowAlignNone, false);
cl_assert_equal_i(1 * NORMAL, l.selection.y);
cl_assert_equal_i(2 * NORMAL - FOCUSED, scroll_layer_get_content_offset(&l.scroll_layer).y);
cl_assert_equal_i(FOCUSED, l.selection.h);
cl_assert_equal_b(fa... | (0 * basic_cell_height, l.selection.y) | |
ight.h"
#include "kernel/low_power.h"
#include "services/common/analytics/analytics.h"
#include "services/common/battery/battery_monitor.h"
#include "services/common/new_timer/new_timer.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#include "os/mutex.h"
#include "system/passert.h"
#include "Free... | (ANALYTICS_DEVICE_METRIC_BACKLIGHT_ON_COUNT, AnalyticsClient_System) | ;
}
if (new_brightness <= HALF_BRIGHTNESS && s_current_brightness > HALF_BRIGHTNESS) {
// getting dimmer and have now transitioned past half brightness
analytics_stopwatch_stop(ANALYTICS_APP_METRIC_BACKLIGHT_ON_TIME);
analytics_stopwatch_stop(ANALYTICS_DEVICE_METRIC_BACKLIGHT_ON_TIME);
}
backlight... |
GAPLEClientKernel);
cl_assert_equal_i(e, BTErrnoOK);
fake_event_clear_last();
fake_kernel_malloc_mark();
// Subscribe again:
e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
GAPLEClientKernel);
cl_ass... | (s_last_cccd_value, BLESubscriptionIndications) | ;
prv_confirm_cccd_write(BLEGATTErrorSuccess);
prv_assert_subscription_event(characteristic, BLESubscriptionIndications, BLEGATTErrorSuccess,
true /* kernel */, false /* app */);
}
void test_gatt_client_subscriptions__subscribe_not_first_subscriber(void) {
BLECharacteristic characteristic = p... |
esAdded,
.device = connection->device,
.status = status
};
info->services_added_data.num_services_added =
gatt_client_copy_service_refs_by_discovery_generation(
&connection->device, &info->services_added_data.services[0],
BLE_GATT_MAX_SERVICES_CHANGED, connection->gatt_service_dis... | {
// we are rediscovering all services so flush everything
prv_free_service_nodes(connection);
prv_send_services_invalidate_all_event(
connection, BTErrnoServiceDiscoveryDatabaseChanged);
} | else { // we are rediscovering one service
gatt_client_discovery_handle_service_range_change(connection, &new_job->hdl);
}
}
void gatt_client_cleanup_discovery_jobs(GAPLEConnection *connection) {
bt_lock();
{
while (connection->discovery_jobs != NULL) {
prv_remove_current_discovery_job(connection)... |
64 * 1024);
cl_assert_equal_i(s_command_list_index, 2);
cl_assert_equal_i(s_command_list[0].addr, 60 * 1024);
cl_assert_equal_i(s_command_list[0].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[1].addr, 64 * 1024);
cl_assert_equal_i(s_command_list[1].type, SectorEraseCommand);
s_command_li... | cl_assert_equal_i(s_command_list[8].type, SectorEraseCommand) | ;
s_command_list_index = 0;
}
void test_flash_region__erase_optimal_range_watch_and_learn(void) {
// Test cases stolen from Alvin's watch and learn app that originally hit this bug
flash_region_erase_optimal_range(0x320000, 0x320000, 0x33177c, 0x338000);
cl_assert_equal_i(s_command_list_index, 3);
cl_as... |
l) {
return 'L';
}
char pebble_task_get_char(PebbleTask task) {
return 'T';
}
PebbleTask pebble_task_get_current(void) {
return PebbleTask_Unknown;
}
void *pulse_best_effort_send_begin(uint16_t protocol) {
static char buffer[1024];
return buffer;
// todo
}
static int s_num_packets_sent = 0;
static int s... | s_last_event.callback.callback(NULL) | ;
cl_assert_equal_i(s_num_packets_sent, 1);
cl_assert_equal_i(s_num_bytes_sent, LOG_METADATA_LENGTH + 128);
cl_assert_equal_s(s_log_message_buffer, "TestTestTestTestTestTestTestTestTestTest"
"TestTestTestTestTestTestTestTestTestTest"
... |
parent and the right half is completely opaque
// - Dest is 100x100, white.
// Result:
// - The top right half will be alternating between dithered gray and black lines
// The bottom right half consists of a diagonal white line on a black background
// The left half will be completely white
void test_bitbl... | (&color, GColorRed) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, &GRect(2, 2, 28, 20), 4, GCornersAll) | ;
}
void corners_clipped_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(-19, 0, 20, 20), 4, GCornersAll);
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__origin_layer(void) {
GC... |
total_seconds, total_seconds, &uuid);
uuid = UUID_INVALID;
prv_push_sleep_summary_pin(now_utc, exit_utc, enter_seconds, exit_seconds,
total_seconds - deviate_seconds, total_seconds, &uuid);
uuid = UUID_INVALID;
prv_push_sleep_summary_pin(now_utc, exit_utc, enter_seconds,... | rtc_get_time() | |
oader_size) {
const size_t bytes_left = bootloader_size - curr_offset;
uint8_t data_buf[256] = { 0 };
const size_t read_len = MIN(bytes_left, sizeof(data_buf));
if (!resource_load_byte_range_system(SYSTEM_APP, RESOURCE_ID_BT_BOOT_IMAGE, curr_offset,
data_buf, r... | prv_deinit_dialog_bootrom_interface() | ;
#if ACCESSORY_UART_IS_SHARED_WITH_BT
// We are sharing a UART with the accessory port, so we need to block it from being used while we
// are using it and then unblock at the end.
accessory_unblock();
#endif
if (success) {
PBL_LOG(LOG_LEVEL_DEBUG, "Succesfully loaded second stage BLE bootloader!");
}
... |
= {{ 3, 97 }, {5, 5} };
memcpy(command->points, points, sizeof(points));
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorRedARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorBlueARGB8);
cl_assert_equal_i(s_stroke_width, 1);
cl_assert_equal_i(s_path_num_points, 2);
cl_ass... | prv_compare_points(points2, s_fill_points, s_path_num_points) | );
prv_reset();
// set path to be open
gdraw_command_set_path_open(command, true);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorPurpleARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorGreenARGB8);
cl_assert_equal_i(s_stroke_width, 2);
cl_assert_equal_i(s_path_num_poi... |
roduce a pin
prv_add_sleep_session(0, 7);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 1);
Uuid orig_id = s_last_timeline_id;
// Next session, < 1h after should move the pin
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR);
prv_add_sleep_session(0.5, 1.5);... | fake_kernel_services_notifications_ancs_notifications_count() | |
prv_reload_swap_layer(data) | ;
}
static void prv_layout_removed_handler(SwapLayer *swap_layer, LayoutLayer *layout, void *context) {
TimelineItem *item = layout_get_context(layout);
timeline_item_destroy(item);
layout_destroy(layout);
}
T_STATIC LayoutLayer *prv_get_layout_handler(SwapLayer *swap_layer, int8_t rel_position,
... | |
if (page_type_bits_set(page_flags, DELETED_START_PAGE_MASK) &&
!is_delete_complete(curr_pg)) {
PBL_LOG(LOG_LEVEL_WARNING, "Delete of %d did not complete", curr_pg);
unlink_flash_file(curr_pg);
} |
}
update_last_written_page();
}
static void prv_handle_sector_erase(uint16_t start_page, bool update_erase_count) {
if (!update_erase_count) {
prv_flash_erase_sector(start_page);
return;
}
uint16_t max_erase = 0;
uint16_t last_written_pg = INVALID_PAGE;
PageHeader hdr;
for (int i = 0; i < PF... | |
= 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 16:00:00
// Now - one day
const int event_time = jun10th_noon_2015 - SECONDS_PER_DAY + (4 * SECONDS_PER_HOUR);
// if the event is within 24 hours, then show the actual time instead of "X hours ago"
... | ("2 hours ago", time_buf) | ;
// June 9th 2015, 16:01:00 (T+00:01:00)
rtc_set_time(event_time + (1 * SECONDS_PER_MINUTE));
clock_get_until_time(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 minute ago", time_buf);
// June 9th 2015, 16:02:00 (T+00:02:00)
rtc_set_time(event_time + (2 * SECONDS_PER_MIN... |
ppData *data, TimelineAppState prev_state,
uint32_t duration) {
PeekLayer *peek_layer = &data->peek_layer;
if (prev_state == TimelineAppStateNoEvents ||
prev_state == TimelineAppStatePeek ||
prev_state == TimelineAppStateHidePeek) {
prv_cleanup_timer(&data... | prv_set_state(data, TimelineAppStateCard) | ;
TimelineIterState *state = timeline_model_get_current_state();
Uuid app_uuid;
timeline_get_originator_id(&state->pin, &app_uuid);
analytics_event_pin_open(state->pin.header.timestamp, &app_uuid);
}
static Animation *prv_animate_to_pin_window(TimelineAppData *data) {
Layer *layer = &data->timeline_layer.la... |
/*
* 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_put_byte(datum ^ HDLC_ESCAPE_MASK) | ;
} else {
prv_put_byte(datum);
}
}
static void prv_prompt_output_cb(int16_t *samples, size_t sample_count, void *context) {
const int OUTPUT_SAMPLE_RATE = (s_is_8khz) ? 8000 : 16000;
int to_process = MIN((int)sample_count, s_timeout);
s_timeout -= to_process;
if (to_process > 0) {
// Groups of s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (CompositorTransitionDirectionLeft) | ;
goto done;
}
// If we get here, we don't use a compositor animation for the transition
done:
kernel_free(app_entry);
return res;
}
const CompositorTransition *shell_get_open_compositor_animation(AppInstallId current_app_id,
AppInstallId ne... |
k to avoid centering the title / subtitle labels in the entire cell:
((Layer *)cell_layer)->bounds.size.h -= SHARING_HEART_RATE_EXTRA_HEIGHT_PX;
}
menu_cell_basic_draw(ctx, cell_layer, remote_name, connected_string, NULL);
if (is_sharing_heart_rate_string) {
// Restore original height:
((Layer *)cel... | {
#if PBL_RECT
# if CAPABILITY_HAS_BUILTIN_HRM
int heart_rate_sharing_text_height = 0;
if (row > 0) {
SettingsBluetoothData *data = (SettingsBluetoothData *) context;
const uint16_t device_index = row - 1;
StoredRemote* remote = (StoredRemote*) list_get_at(data->remote_list_head, device_index);
if ... |
static void prv_draw_row_cb(SettingsCallbacks *context, GContext *ctx,
const Layer *cell_layer, uint16_t row, bool selected) {
SettingsBluetoothData *data = (SettingsBluetoothData *) context;
if (row == 0) {
char device_name_buffer[BT_DEVICE_NAME_BUFFER_SIZE];
const char *s... |
layer_get_data(base_layer);
const int units_offset_y =
fonts_get_font_height(data->bpm_font) - fonts_get_font_height(data->units_font);
GTextNodeHorizontal *horiz_container = graphics_text_node_create_horizontal(MAX_TEXT_NODES);
GTextNodeContainer *container = &horiz_container->container;
horiz_containe... | (health_data) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (window, true) | ;
window_set_background_color(window, GColorBlack);
window_set_click_config_provider(window, prv_panic_click_config_provider);
#if CAPABILITY_HAS_HARDWARE_PANIC_SCREEN
display_show_panic_screen(launcher_panic_get_current_error());
#else
layer_init(&data->layer, &window_get_root_layer(&data->window)->frame);
... |
IN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Message type 0x%x not recognized", message[0]);
}
}
bool dls_endpoint_open_session(DataLoggingSession *session) {
CommSession *comm_session = comm_session_get_system_session();
if (!session) {
return false;
}
DataLoggingOpenSessionMessage msg = {
.command = DataLog... | mutex_lock(s_endpoint_data.mutex) | |
T_STATIC jerry_value_t prv_json_stringify(jerry_value_t object) {
return prv_call_json_function(GLOBAL_JSON_STRINGIFY, &object, 1);
}
T_STATIC jerry_value_t prv_json_parse(const char *object) {
JS_VAR string_obj = jerry_create_string_utf8((const jerry_char_t *)object);
return prv_call_json_function(GLOBAL_JSON_P... | {
return jerry_acquire_value(json_string);
} |
if (jerry_value_is_undefined(json_string)) {
// ECMA v5.1, 15.12.3, Note 5: Values that do not have a JSON representation (such as undefined
// and functions) do not produce a String. Instead they produce the undefined value.
return rocky_error_unexpected_type(0, "JSON.stringify()-able object");
}
c... |
{
if (*ref_count) {
(*ref_count)++;
return true;
} else {
// Set the register byte to XXXXX01X to enable the rail, mask and set
register_value = (register_value & ~0x06) | 0x02;
success = prv_write_register(rail_control_reg, register_value);
if (success) {
// We en... | if (BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio) {
gpio_output_init(&BOARD_CONFIG_POWER.rail_6V6_ctrl, GPIO_OType_OD, GPIO_Speed_50MHz);
} |
gpio_output_init(&BOARD_CONFIG_ACCESSORY.power_en, GPIO_OType_OD, GPIO_Speed_50MHz);
periph_config_release_lock();
}
void set_4V5_power_state(bool enabled) {
gpio_output_set(&BOARD_CONFIG_POWER.rail_4V5_ctrl, enabled);
}
void set_6V6_power_state(bool enabled) {
if (BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio) {
... |
prv_push_error_dialog(data, i18n_noop("No internet connection"),
RESOURCE_ID_CHECK_INTERNET_CONNECTION_LARGE, dialog_bg_color) | ;
data->error_exit_status = DictationSessionStatusFailureConnectivityError;
} else {
prv_exit_and_send_result_event(data, DictationSessionStatusFailureConnectivityError);
}
}
static void prv_handle_bt_conn_result(bool connected, void *context) {
VoiceUiData *data = context;
if (connected) {
if (dat... | |
/*
* 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... | {
dbgserial_putstr("Button is pushed at boot");
char buffer[32];
itoa(button_counter_register, buffer, sizeof(buffer));
dbgserial_putstr(buffer);
} |
RTC_WriteBackupRegister(STUCK_BUTTON_REGISTER, button_counter_register);
return result;
}
bool is_flash_broken(void) {
return !flash_sanity_check();
}
|
/*
* 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->kino_layer, res_id) | ;
layer_mark_dirty(&data->kino_layer.layer);
reschedule:
data->saved_state = current_state;
data->timer = app_timer_register(LOW_POWER_APP_STATE_UPDATE_TIME_MS, prv_refresh_state, data);
}
////////////////////////////////////////////////////////////
// Window loading, unloading, initializing
static 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... | (app_data->result, size, "You said:\n%s", transcription) | |
PBL-24823
TimezoneInfo tz_info = {
.tm_zone = "EST",
.tm_gmtoff = -5 * SECONDS_PER_HOUR,
};
time_util_update_timezone(&tz_info);
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_trac... | {
// Let's start out in PST time when tracking starts. All of our tests start at 5pm UTC, which is
// 9am PST.
TimezoneInfo tz_info = {
.tm_zone = "PST",
.tm_gmtoff = -8 * SECONDS_PER_HOUR,
};
time_util_update_timezone(&tz_info);
// Start activity tracking. This method assumes it can be called from... |
// If we ask for the sum from latter half of yesterday till now, we should get 2500
steps = health_service_sum(
HealthMetricStepCount, time_start_of_today() - (12 * SECONDS_PER_HOUR), rtc_get_time());
cl_assert_equal_i(steps, 2500);
// If we ask for the sum from latter half of yesterday till half of tod... |
PBL_LOG(LOG_LEVEL_DEBUG, ">> Erasing Addr 0x%"PRIx32, *erase_addr) | ;
}
flash_erase_sector_blocking(*erase_addr);
} else {
// Erase the addresses within test range that we will touch. These are addresses with
// power-of-two offsets
for (bit_offset = 0; (bit_offset == 0) || (bit_offset & addr_mask); bit_offset <<= 1) {
if (bit_offset > base_addr) {
... | |
_hdr, 0xff, sizeof(PageHeader));
pg_hdr.version = PFS_CUR_VERSION;
SET_PAGE_FLAGS(pg_hdr.page_flags,
PAGE_FLAG_CONT_PAGE | PAGE_FLAG_ERASED_PAGE);
} else {
write_pg_header(&pg_hdr, curr_page);
break; // we are done
}
}
// we have succesfully allocated space for the file, s... | {
// First search to see if the fd has already been located
for (int fd = FD_INDEX_OFFSET; fd < FD_INDEX_OFFSET+MAX_FD_HANDLES; fd++) {
File *f = &PFS_FD(fd).file;
if ((f->is_tmp == is_tmp) && (f->name != NULL)) {
if (strcmp(f->name, name) == 0) {
PBL_ASSERTN(PFS_FD(fd).fd_status != FD_STATUS_... |
/*
* Exported PFS APIs
*/
size_t pfs_get_file_size(int fd) {
mutex_lock_recursive(s_pfs_mutex);
size_t res = 0;
if (FD_VALID(fd)) {
res = PFS_FD(fd).file.file_size;
}
mutex_unlock_recursive(s_pfs_mutex);
return (res);
}
int pfs_read(int fd, void *buf_ptr, size_t size) {
uint8_t *buf = buf_ptr;... |
ber = s_receive_variable,
.protocol = hton16(app_protocol),
.length = hton16(packet_size),
};
memcpy(&packet->i.information[0], information, info_length);
pulse_link_send(packet, packet_size);
}
static void prv_process_ack(uint8_t ack_number) {
if ((ack_number - 1) % MODULUS == s_send_variable) {
p... | if (!packet->is_supervisory) {
PBL_LOG(LOG_LEVEL_DEBUG, "Received Information packet response; this is "
"not permitted by the protocol (Information packets can only be "
"commands). Discarding.");
return;
} |
prv_process_ack(packet->s.ack_number);
if (packet->s.kind != SupervisoryKind_ReceiveReady &&
packet->s.kind != SupervisoryKind_Reject) {
PBL_LOG(LOG_LEVEL_DEBUG, "Received a command packet of type %" PRIu8
" which is not supported by this implementation.",
(uint8_t)packet->s.kin... |
;
}
cobs_streaming_decode(&frame_decode_ctx, c);
}
}
// Finally handle the timer.
if (timeout == 0) {
pulse2_reliable_retransmit_timer_expired_handler(timer_sequence_number);
}
prv_pulse_task_feed_watchdog();
}
}
static void prv_forge_terminate_ack(void) {
// Send ... | (FRAME_MAX_SEND_SIZE) | ], &fcs, sizeof(fcs));
length += sizeof(fcs);
length = cobs_encode(frame, frame + COBS_OVERHEAD(FRAME_MAX_SEND_SIZE), length);
// TODO: DMA
dbgserial_putchar_lazy(FRAME_DELIMITER);
for (size_t i = 0; i < length; ++i) {
if (frame[i] == FRAME_DELIMITER) {
dbgserial_putchar_lazy('\0');
} else {
... |
t the INT line
// faster than the DMA transfer complete interrupt happens. Probably very unlikely, but
// in case we're worried about this:
// FIXME: Maybe the solution is to disable the EXTI while DMA is on-going and re-enable
// when it's finished? OTOH, this might be tricky when we're also us... | {
return (s_spi_transport.task == xTaskGetCurrentTaskHandle());
} |
bool host_transport_init(void) {
s_spi_transport.tx_storage = s_spi_tx_storage_buffer;
s_spi_transport.tx_footer = &s_spi_tx_footer;
s_spi_transport.status_local = &s_spi_status_local;
s_spi_transport.semph = xSemaphoreCreateBinary();
PBL_ASSERTN(s_spi_transport.semph);
prv_watchdog_init();
hc_protoco... |
ata->bg_text_buffer, true);
} else {
set_text_element(data->bg_text, data->bg_text_buffer, false);
}
// Set FG Color Text
uint8_t fg_color = data->fg_color.argb;
snprintf(data->fg_color_text_buffer, sizeof(data->fg_color_text_buffer), "FG = 0x%02x", fg_color);
if (data->property == PROPERTY_FG_COLOR) {... | GPoint(8, 114) | ;
GColor compare_color = GColorClear;
uint8_t color_index_match = 0;
uint16_t height_offset = 0;
bool compare = true;
if (data->property == PROPERTY_FG_COLOR) {
compare_color = data->fg_color;
} else if (data->property == PROPERTY_BG_COLOR) {
compare_color = data->bg_color;
} else {
compare =... |
BIT_DEPTH_NAME}.pbi"));
#endif
}
extern uint16_t prv_clamp_corner_radius(GSize size, GCornerMask corner_mask,
uint16_t radius);
void test_graphics_fill_rect__corner_radius(void) {
// Test 0 radius cases
cl_assert_equal_i(prv_clamp_corner_radius(GSize(0, 0), GCornerNone, 0),... | (&ctx, 0, 0, 0) | ;
prv_fill_rects(&ctx, CLIP_OFFSET, 1, 0);
prv_fill_rects(&ctx, 2 * CLIP_OFFSET, 0, 4);
prv_fill_rects(&ctx, 3 * CLIP_OFFSET, 1, 4);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_clip_rect_aa.${BIT_DEPTH_NAME}.pbi"));
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | while (s_scheduled_jobs != NULL) {
CronJob* job = (CronJob*)s_scheduled_jobs;
s_scheduled_jobs = list_pop_head(s_scheduled_jobs);
// Re-calculate the execute time.
// See the notes in the API header on how this works.
if (must_recalc || change_diff >= job->clock_change_tolerance) {
job->cached... |
// Then move it back to the static
s_scheduled_jobs = newlist;
mutex_unlock(s_list_mutex);
// We want to run any tasks we've skipped over.
prv_timer_callback(NULL);
}
// --------------------------------------------------------------------------------------------
void cron_service_init(void) {
PBL_ASSERT... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.