prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
sitive signed
// No signed conversion occurs, so this is a no-op
snprintf(dstbuf, 256, "There are %+u lights, the absolute value of %+u", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, the absolute value of 4294967292");
// Minimum digits output
snprintf(dstbuf, 256, "There are %.2u lights, %.2u", 4,... | cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.-3ozero%.-3o", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (non-zero digits outputting zero)
snprintf(dstbuf, 256, "%.1ozero%.1o", 0, 1);
cl_assert_equal_s(dstbuf... |
void test_sprintf__percent_x(void) {
char dstbuf[256];
// Simple %x
snprintf(dstbuf, 256, "There are %x lights, %x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, fffffffc");
// Alternate form (adds 0x prefix)
snprintf(dstbuf, 256, "There are %#x lights, %#x", 16, -4);
cl_assert_equal_s(dst... |
us)
TIM3->CCR4 = 63999;
// Enable channel 4
TIM3->CCER = TIM_CCER_CC4E;
// Hook up the VCOM pin's alternate function to TIM3
GPIO_PinAFConfig(DISP_GPIO, DISP_PINSOURCE_VCOM, GPIO_AF_TIM3);
TIM3->EGR = TIM_PSCReloadMode_Immediate; // Reload shadow registers
TIM_Cmd(TIM3, ENABLE);
}
static void prv_dis... | {
prv_display_write_line(i, buffer[i]);
} | |
d(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(-10, 2, 18, 4), 4, GCornersAll);
}
void across_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_f... | test_graphics_context_reset(&ctx, fb) | ;
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_ny_offset_layer.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__clipped(void) {
GContext ctx;
Layer layer;
test_graphic... |
/*
* 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... | ancs_app_storage_deinit() | ;
}
void test_ancs_app_storage__one_app(void) {
ANCSAppData app_data = {
.bundle_id = "com.getpebble.PebbleApp",
.display_name = "Pebble",
.flags = ANCSAppIsBlocked,
};
app_data.is_meta_changed = true;
ancs_app_storage_save(&app_data);
ANCSAppData app_data_out = { 0 };
ancs_app_storage_load(ap... |
id test_graphics_context_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb);
}
/////////////////////////////////////
/// TESTS
/////////////////////////////////////
void test_graphics_context_${BIT_DEPTH_NAME}__set(void) {
GDrawState draw_state;
GColor color;
// Stroke Color
graphics_context_set_stroke_color(&cont... | (&context) | |
ersistent_storage_has_pinned_ble_pairings, false);
cl_will_return(bt_persistent_storage_set_ble_pinned_address, true);
cl_will_return(bt_driver_set_local_address, 0);
s_last_bt_persist_pinned_addr_is_null = true;
bt_local_addr_init();
}
static void prv_assert_driver_addr_is_null(void) {
cl_assert_equal_b(s_l... | bt_local_addr_pause_cycling() | ;
cl_assert_equal_b(false, s_last_driver_allow_cycling);
prv_assert_driver_addr_is_addr1();
// Pin, expect pinned address to be sent to BT driver:
cl_will_return(bt_driver_set_local_address, 0);
cl_will_return(bt_persistent_storage_has_pinned_ble_pairings, true);
bt_local_addr_pin(&TEST_PINNED_ADDR_1);
b... |
/*
* 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_draw_circle(ctx, GPoint(14, 14), 12) | ;
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_circle(ctx, GPoint(28, 14), 12);
}
void across_nx_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_c... |
dow_long_click_subscribe(BUTTON_ID_UP, 0, prv_volume_long_click_start_handler,
prv_volume_long_click_end_handler);
window_long_click_subscribe(BUTTON_ID_DOWN, 0, prv_volume_long_click_start_handler,
prv_volume_long_click_end_handler);
window_long_click_sub... | app_window_stack_remove(&data->no_music_window->window, true) | ;
app_free(data->no_music_window);
data->no_music_window = NULL;
}
}
static void prv_update_now_playing(MusicAppData *data) {
layer_set_hidden((Layer *)&data->track_pos_bar, !music_is_progress_reporting_supported());
char artist_buffer[MUSIC_BUFFER_LENGTH];
char title_buffer[MUSIC_BUFFER_LENGTH];
mu... |
PULL);
}
static void prv_bus_pins_cfg_input(I2CBus *bus) {
InputConfig in_scl = {
.gpio = bus->scl_gpio.gpio,
.gpio_pin = bus->scl_gpio.gpio_pin,
};
gpio_input_init(&in_scl);
InputConfig in_sda = {
.gpio = bus->sda_gpio.gpio,
.gpio_pin = bus->sda_gpio.gpio_pin,
};
gpio_input_init(&in_sda);... | {
gpio_output_set(&out_scl, false);
delay_ms(TOGGLE_DELAY);
gpio_output_set(&out_scl, true);
delay_ms(TOGGLE_DELAY);
if (gpio_input_read(&in_sda)) {
recovered = true;
break;
}
} |
if (recovered) {
PBL_LOG(LOG_LEVEL_DEBUG, "I2C Bus %s recovered", slave->bus->name);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "I2C Bus %s still hung after bitbang reset", slave->bus->name);
}
prv_bus_pins_cfg_i2c(slave->bus);
prv_bus_reset(slave->bus);
return recovered;
}
/*--------------------DATA TRA... |
/*
* 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... | mbuf_append(s_free_list, m) | ;
} else {
s_free_list = m;
}
prv_check_free_list();
mutex_unlock(s_free_list_lock);
}
// Basic setters and getters
////////////////////////////////////////////////////////////////////////////////
void mbuf_set_data(MBuf *m, void *data, uint32_t length) {
PBL_ASSERTN(m);
//! We should never be trying... |
_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX);
cl_assert(iter_next(&word_iter));
cl_assert(line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 7 * HORI... | cl_assert(line.height_px == 10) | ;
cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX);
cl_assert(iter_next(&word_iter));
cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX);
// reset line
line = (Line) { 0 };
line.max_wi... |
/*
* 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... | enable_mcu_debugging() | ;
__disable_irq();
while (1) {
continue;
}
#endif
PBL_LOG_FROM_FAULT_HANDLER("Resetting!");
boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED);
system_reset();
}
|
,
.insert = pin_db_insert,
.get_len = pin_db_get_len,
.read = pin_db_read,
.del = pin_db_delete,
.flush = pin_db_flush,
.is_dirty = pin_db_is_dirty,
.get_dirty_list = pin_db_get_dirty_list,
.mark_synced = pin_db_mark_synced,
},
[BlobDBIdApps] = {
.init = app_db_init,
.insert ... | {
const BlobDB *db = s_blob_dbs;
*num_ids = 0;
for (uint8_t i = 0; i < NumBlobDBs; ++i, ++db) {
bool is_dirty = false;
if (db->is_dirty && (db->is_dirty(&is_dirty) == S_SUCCESS) && is_dirty) {
ids[*num_ids] = i;
*num_ids += 1;
}
}
} |
status_t blob_db_insert(BlobDBId db_id,
const uint8_t *key, int key_len, const uint8_t *val, int val_len) {
if (!prv_db_valid(db_id)) {
return E_RANGE;
}
const BlobDB *db = &s_blob_dbs[db_id];
if (db->insert) {
status_t rv = db->insert(key, key_len, val, val_len);
if (rv == S_SUCCESS) {
... |
, 104, -96},
{ 928, 168, 8},
{ 1040, 208, 16},
{ 1064, 272, -40},
{ 952, 296, -96},
{ 1184, 264, -16},
{ 1120, 368, 32},
{ 1056, 456, 64},
// 95 seconds
{ 1272, 400, -168},
{ 1104, 280, -56},
{ 1216, 288, 40},
{ 1456, 280, 48},
{ 1432, 240, -24},
{ 1200, 112, 72},... | { 1304, 288, -88},
{ 1080, 352, -8},
{ 1304, 480, -64},
{ 1152, 488, -200},
{ 1136, 176, -40},
{ 1168, 200, 88},
{ 1272, 216, 24},
{ 1016, 184, 0},
{ 928, 56, 56},
{ 968, 0, 8},
{ 1104, 8, -48},
{ 1120, 40, -200},
{ 928, -24, -96},
{ 1088, -152, 64},
{ 1048, -... |
{ 1000, -64, 16},
{ 1072, -48, -16},
{ 1128, -32, -88},
{ 1224, 8, -104},
{ 1296, 48, -96},
{ 1400, 104, -192},
{ 1344, 48, -120},
{ 1200, 80, -104},
{ 856, 128, -184},
{ 688, 112, -144},
{ 672, 152, -80},
{ 792, 176, -64},
{ 1024, 232, -112},
{ 1080, 256, -160},... |
{ -296, 1104, 856},
{ -424, 800, 584},
// 54 seconds
{ -472, 624, 680},
{ -240, 480, 624},
{ 8, 368, 440},
{ 64, 328, 384},
{ 104, 320, 392},
{ 144, 312, 368},
{ 152, 304, 504},
{ 144, 440, 616},
{ 168, 464, 824},
{ 96, 688, 1168},
{ 56, 992, 1472},
{ -16, 1240... | { -80, 1152, 1272},
{ -128, 1200, 1328},
{ -256, 896, 1128},
{ -200, 664, 784},
{ -240, 688, 728},
{ -136, 504, 688},
{ -16, 328, 504},
{ 64, 224, 424},
// 60 seconds
// elapsed: 1 minutes
{ 80, 248, 456},
{ 88, 184, 512},
{ 112, 248, 608},
{ 128, 336, 680},
{... |
{ 48, 528, 808},
{ 16, 504, 696},
{ 0, 552, 720},
{ 0, 664, 696},
{ -24, 768, 616},
{ 16, 680, 632},
{ 8, 840, 576},
{ 64, 696, 648},
{ 96, 832, 584},
{ 56, 712, 576},
{ 64, 832, 488},
{ 112, 832, 424},
{ 144, 776, 360},
{ 168, 864, 184},
{ 152, 864, -8},
... |
sert(shared_circular_buffer_consume(&buffer, &client1, 2));
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 0);
// Should fail, not enough room because client 2 is full
cl_assert(!shared_circular_buffer_write(&buffer, (uint8_t*) "gh", 2, false));
// This should pass and reset cl... | (items_read, 1) | ;
cl_assert_equal_m(out_buffer, "5q", 2);
}
void test_shared_circular_buffer__subsampling_1of3(void) {
SharedCircularBuffer buffer;
uint16_t item_size = 2;
uint8_t storage[12*item_size];
uint8_t out_buffer[12*item_size];
uint16_t items_read;
// Init
shared_circular_buffer_init(&buffer, storage, sizeo... |
le %s to increase its size from %d to %d.",
name, actual_size, max_space_total);
// The settings_file_rewrite_filtered call creates a new file based on file->max_used_space
// and copies the contents of the existing file into it.
status = settings_file_rewrite_filtered(file, NULL, NULL);
if ... | (LOG_LEVEL_ERROR,
"Could not open temporary file to compact settings file. Error %"PRIi32".",
status) | ;
return status;
}
settings_raw_iter_begin(&new_file.iter);
for (settings_raw_iter_begin(&file->iter); !settings_raw_iter_end(&file->iter);
settings_raw_iter_next(&file->iter)) {
SettingsRecordHeader *hdr = &file->iter.hdr;
if (partially_written(hdr)) {
// This should only happen if we r... |
VALID_HANDLE;
}
ble_error_t e = ble_gatts_read_cfm(evt->conn_idx, evt->handle, response_status,
response_length, response);
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gatts_read_cfm: %u", e);
}
}
static void prv_send_notification(uint16_t conn_idx, uint16_... | if (settings->connection_parameter_sets[i].interval_min_1_25ms < LL_CONN_INTV_MIN_SLOTS) {
return (att_error_t)PebblePairingServiceGATTError_ConnParamsMinSlotsTooSmall;
} |
if (settings->connection_parameter_sets[i].interval_min_1_25ms > LL_CONN_INTV_MAX_SLOTS) {
return (att_error_t)PebblePairingServiceGATTError_ConnParamsMinSlotsTooLarge;
}
if (settings->connection_parameter_sets[i].interval_min_1_25ms +
settings->connection_parameter_sets[i].interval... |
orst";
case HRMQuality_Poor:
return "Poor";
case HRMQuality_Acceptable:
return "Acceptable";
case HRMQuality_Good:
return "Good";
case HRMQuality_Excellent:
return "Excellent";
}
WTF;
}
static char *prv_translate_error(AppMessageResult result) {
switch (result) {
case ... | {
snprintf(app_data->bpm_string, sizeof(app_data->bpm_string), "%"PRIu8" BPM", hrm->bpm.bpm);
text_layer_set_text(&app_data->quality_text_layer, prv_get_quality_string(hrm->bpm.quality));
layer_mark_dirty(&app_data->window.layer);
bpm = hrm->bpm.bpm;
bpm_quality = hrm->bpm.quality;
} | else if (hrm->event_type == HRMEvent_LEDCurrent) {
led_current = hrm->led.current_ua;
} else if (hrm->event_type == HRMEvent_Diagnostics) {
if (!app_data->ready_to_send) {
return;
}
AppMessageResult result = app_message_outbox_begin(&app_data->out_iter);
PBL_ASSERTN(result ==... |
/*
* 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... | jerry_release_value(timer_data->argv[i]) | ;
}
task_free(timer_data);
}
static void prv_timer_callback(void *data) {
RockyTimerCbData *timer_data = data;
if (jerry_value_is_function(timer_data->callback)) {
rocky_util_call_user_function_and_log_uncaught_error(
timer_data->callback, jerry_create_undefined(), timer_data->argv, timer_data->ar... |
MenuIndex *cell_index, void *callback_context) {
ActionMenuLayer *aml = callback_context;
if (aml->separator_index && cell_index->row == aml->separator_index) {
const PreferredContentSize runtime_platform_default_size =
system_theme_get_default_content_size_for_runtime_platform();
const A... | layer_set_frame(menu_layer_get_layer(&aml->menu_layer), &menu_layer_frame) | ;
}
static void prv_update_proc(Layer *layer, GContext *ctx) {
#if PBL_ROUND
ActionMenuLayer *aml = (ActionMenuLayer *)layer;
const int num_rows = prv_get_num_rows(&aml->menu_layer, 0, aml);
if (prv_aml_is_short(aml) && (num_rows > SHORT_ITEM_MAX_ROWS_SPALDING)) {
// draw some "content indicator" arrows
... |
{ 0, 0x63, 0, 150},
{ 0, 0x63, 18, 149},
{ 0, 0x63, 803, 149},
{ 0, 0x44, 0, 149},
{ 0, 0x44, 75, 146},
{ 0, 0x44, 0, 149},
{ 0, 0x44, 0, 148},
{ 0, 0x44, 0, 149},
{ 0, 0x44, 0, 149},
{ 0, 0x44, 0, 146},
{ 0, 0x44, 0, 149},
{ 0, 0x44, 0, 149},
{ 0, 0x44, 0, 148},
... |
{ 0, 0x34, 1791, 152},
{ 0, 0x6b, 0, 152},
{ 0, 0x6b, 0, 152},
{ 0, 0x6b, 0, 152},
{ 0, 0x6b, 0, 149},
{ 0, 0x6b, 0, 152},
{ 0, 0x6b, 0, 151},
{ 0, 0x6b, 10, 151},
{ 0, 0x6b, 0, 151},
{ 0, 0x6b, 0, 148},
{ 0, 0x6b, 0, 151},
{ 0, 0x6b, 0, 151},
{ 0, 0x6b, 0, 151},
... | |
/*
* 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... | (&launch_event) | ;
}
///////////////////////////////
// Animation Related Functions
///////////////////////////////
static void prv_remote_comm_session_event_handler(PebbleEvent *event, void *context) {
AppFetchUIData *data = app_state_get_user_data();
if (event->bluetooth.comm_session_event.is_open &&
event->bluetooth.comm... |
].header.id));
cl_assert(state.node);
}
void test_timeline__none_forwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture,
1421188000), 2);
}
void... | (iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[0].header.id));
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[1].header.id));
#if !CAPABILITY_HAS_CORE_NAVIGATION4
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_long_items[... |
stNode **) &connection->gatt_subscriptions, NULL);
kernel_free(subscription);
}
// -------------------------------------------------------------------------------------------------
static BTErrno prv_subscribe(BLECharacteristic characteristic_ref,
BLESubscription subscription_type,
... | if (subscription_type == BLESubscriptionNone) {
// Decrement retain count, or free:
prv_release_buffer(client);
} else {
// Increment retain count, or create buffer:
if (!prv_retain_buffer(client)) {
// Failed to create buffer, abort!
if (did_create_new_subscription) {
prv_remove_s... |
if (ret_val == BTErrnoOK && !is_cleaning_up) {
if (subscription_type == BLESubscriptionNone || !has_pending_write) {
// When unsubscribing or when Pebble was already subscribed,
// immediately send unsubscription confirmation event to client:
prv_send_subscription_event(characteristic_ref, ~ga... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | memcpy(&new_node->scheduled_days, info->scheduled_days, sizeof(new_node->scheduled_days)) | ;
new_node->info.scheduled_days = &new_node->scheduled_days;
data->alarm_list_head = (AlarmNode *)list_sorted_add((ListNode *)data->alarm_list_head,
(ListNode *)new_node,
prv_alarm_comparator,
... |
.h"
#include "stubs_tick.h"
extern SemaphoreHandle_t put_bytes_get_semaphore(void);
extern TimerID put_bytes_get_timer_id(void);
extern uint32_t put_bytes_get_index(void);
extern uint8_t prv_put_bytes_get_max_batched_pb_ops(void);
extern const ReceiverImplementation g_put_bytes_receiver_impl;
static const PebbleProt... | (total_size) | ,
.type = ObjectFile,
};
memcpy(&init_msg->filename[0], fn, fn_len);
prv_receive_data(s_session, buffer, sizeof(buffer));
}
static void prv_receive_put(uint32_t cookie, const uint8_t *payload, uint32_t payload_size) {
uint8_t buffer[sizeof(PutRequest) + payload_size];
PutRequest *put_msg = (PutRequest *... |
w_load,
.unload = prv_window_unload
});
WindowStack *stack = app_state_get_window_stack();
// Switch to the app state to push a window
stub_pebble_tasks_set_current(PebbleTask_App);
cl_check(stack);
cl_assert_equal_i(window_stack_count(stack), 0);
window_stack_push(stack, window, true);
cl_asse... | cl_assert_equal_i(prv_get_load_unload_count(), 0) | ;
cl_assert_equal_i(prv_get_appear_disappear_count(), 0);
// FIXME: PBL-25460
// cl_assert_equal_b(animation_is_scheduled(fake_animation_get_first_animation()), false);
}
// Push two windows back to back, before the first transition completes. This should cancel the
// first transition and instead run the secon... |
s_num_alarms_fired, 1);
}
void test_alarm__delete_upcoming_alarm(void) {
AlarmId id1, id2;
id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
id2 = alarm_create(&(AlarmInfo) { .hour... | (&(AlarmInfo) { .hour = 8, .minute = 30, .kind = ALARM_KIND_WEEKDAYS }) | |
_get_step_averages_values_weekday = (sys_activity_get_step_averages_values){
.out.result = true,
};
s_sys_activity_get_step_averages_values_weekend = (sys_activity_get_step_averages_values){
.out.result = true,
};
for (int i = 0;
i < ARRAY_LENGTH(s_sys_activity_get_step_averages_values_weekday.o... | (HealthMetricStepCount, start_of_today,
start_of_today + (9 * SECONDS_PER_HOUR),
HealthServiceTimeScopeDaily) | |
oller. Simulate this event:
fake_gap_le_put_cancel_create_event(&device, true /* is_master */);
prv_assert_no_event();
// Verify there are no more intents:
cl_assert_equal_i(gap_le_connect_connection_intents_count(), 0);
cl_assert_equal_b(gap_le_connect_has_pending_create_connection(), false);
}
void __dis... | (&device, GAPLEClientKernel) | , false);
}
void test_gap_le_connect__connection_event_only_after_encrypted_if_encryption_required(void) {
BTDeviceInternal device = *fake_GAPAPI_get_device_resolving_to_fake_irk();
BTBondingID bonding_id = prv_add_bonding_for_fake_resolvable_device();
// Register connection intent for app:
gap_le_connect_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... | {
/// Shown in Quick Launch Settings when the button is disabled.
i18n_get_with_buffer("Disabled", buffer, buf_len);
return;
} | else {
AppInstallEntry entry;
if (app_install_get_entry_for_install_id(app_id, &entry)) {
strncpy(buffer, entry.name, buf_len);
buffer[buf_len - 1] = '\0';
return;
}
}
// if failed both, set as empty string
buffer[0] = '\0';
}
// Filter List Callbacks
////////////////////////
stati... |
node.h"
#include "kernel/pbl_malloc.h"
#include "resource/resource_ids.auto.h"
#include "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/activity/activity_private.h"
#include "services/normal/activity/health_util.h"
#include "services/normal/activity/hr_util.h"
#include "servic... | {
switch (metric_type) {
case WorkoutMetricType_Hr:
{
int bpm = active_window->workout_controller->get_metric_value(WorkoutMetricType_Hr,
active_window->workout_data);
return prv_get_label_for_hr_metric(bpm);
}
case Workou... |
case WorkoutMetricType_Distance:
#if PBL_RECT
/// Distance Label
return i18n_noop("DISTANCE");
#else
/// Distance Label with units
return active_window->workout_controller->get_distance_string(i18n_noop("DISTANCE (MI)"),
i1... |
phics_convert_8_bit_to_1_bit(const GBitmap *from, GBitmap *to) {
const GRect bounds = from->bounds;
uint8_t *to_buffer = (uint8_t *) to->addr;
const int y_start = bounds.origin.y;
const int y_end = y_start + bounds.size.h;
const int x_start = bounds.origin.x;
const int x_end = x_start + bounds.size.w;
f... | (ctx->draw_state.drawing_box.origin, offset) | ;
}
void graphics_context_set_stroke_color(GContext* ctx, GColor color) {
PBL_ASSERTN(ctx);
if (ctx->lock) {
return;
}
#if PBL_BW
color = gcolor_get_bw(color);
#else
color = gcolor_closest_opaque(color);
#endif
ctx->draw_state.stroke_color = color;
}
void graphics_context_set_stroke_color_2... |
RIx8", INT2: 0x%"PRIx8, int0_status, int2_status);
prv_dump_int_stats();
}
if (toggled_power_mode) {
bmi160_set_accel_power_mode(BMI160_Accel_Mode_Low);
}
}
// TODO: strictly for debug, remove when done
static void prv_dump_int_stats(void) {
for (uint8_t addr = 0x1b; addr <= 0x1f; addr++) {
BMI160... | bmi160_end_burst() | ;
BMI160_DBG("%d bytes remain", prv_get_current_fifo_length_and_timestamp(&last_frame_time));
if (was_low_power) {
bmi160_set_accel_power_mode(BMI160_Accel_Mode_Low);
}
}
static void prv_handle_data(void) {
s_accel_outstanding_data_work = false;
// if the task draining the fifo gets swapped out for a ... |
ASSERT_JS_GLOBAL_EQUALS_B("isCalled", true);
// TODO: assert:
// - flushed recv chunk reassembly buffer
}
void test_rocky_api_app_message__session_open__rcv_reset_complete(void) {
prv_init_and_goto_session_open();
EXECUTE_SCRIPT("var isCalled = false;"
"_rocky.on('postmessagedisconnected'... | (json_c_str) | ;
}
void test_rocky_api_app_message__json_parse(void) {
JS_VAR number = prv_json_parse("1");
cl_assert(jerry_value_is_number(number));
cl_assert_equal_d(jerry_get_number_value(number), 1.0);
JS_VAR object = prv_json_parse("{ \"x\" : 42 }");
cl_assert(jerry_value_is_object(object));
JS_VAR x = jerry_get_ob... |
>has_worker);
cl_assert_equal_i(ProcessTypeApp, sports_md->process_type);
cl_assert_equal_i(ProcessStorageBuiltin, sports_md->process_storage);
app_install_release_md(sports_md);
const PebbleProcessMd *bg_counter_md = app_install_get_md(bg_counter_id, false);
cl_assert(bg_counter_md != NULL);
cl_assert_equ... | app_install_is_prioritized(music_id) | );
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (task_handle) | ;
PBL_LOG_SYNC(LOG_LEVEL_WARNING, "Task <%s> stuck: LR: %p PC: %p", pebble_task_get_name(task), current_lr, current_pc);
reboot_reason->watchdog.stuck_task_pc = (uint32_t)current_pc;
reboot_reason->watchdog.stuck_task_lr = (uint32_t)current_lr;
}
static void prv_log_failed_message(RebootReason *reboot_reason) {... |
lytics (which does so on an hourly heartbeat).
return (prv_compute_delta_pos(&s_last_accel_data, &s_last_analytics_position)
< ACCEL_MAX_IDLE_DELTA);
}
// The accelerometer should issue a shake/tap event with any slight movements when stationary.
// This will allow the watch to immediately return to ... | (s_accel_manager_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... | prv_update_struct(&data) | ;
}
GPoint mfg_info_get_disp_offsets(void) {
return (GPoint) {
.x = prv_fetch_struct().disp_offset_x,
.y = prv_fetch_struct().disp_offset_y
};
}
void mfg_info_set_disp_offsets(GPoint p) {
MfgData data = prv_fetch_struct();
data.disp_offset_x = p.x;
data.disp_offset_y = p.y;
prv_update_struct(&data... |
ntroller);
// make sure the stream is disabled before trying to configure
PBL_ASSERTN((this->stream->periph->CR & DMA_SxCR_EN) == 0);
this->stream->periph->CR = cr_value;
this->stream->periph->FCR = fcr_value;
prv_release_controller(this->stream->controller);
// Configure and enable the IRQ if necessary (D... | prv_get_data_size_bytes(this) | ;
// set the addresses
switch (this->type) {
case DMARequestType_MemoryToMemory:
case DMARequestType_PeripheralToMemory:
this->stream->periph->PAR = (uint32_t)src;
this->stream->periph->M0AR = (uint32_t)dst;
break;
case DMARequestType_MemoryToPeripheral:
this->stream->periph->PA... |
ity_y;
// Bucket
GPath *bucket;
GPoint bucket_offset;
int16_t bucket_velocity_x;
int16_t bucket_velocity_y;
// Generic properties that can be changed as property_index changes
bool fill;
int16_t color_index;
int64_t time_started;
uint32_t rendered_frames;
bool moving;
AppStateIndex state_ind... | {
for (uint8_t shape = POINT; shape < MAX_SHAPES; shape++) {
if (shape == POINT) {
// Move the point 4*X per Y
data->point_p0.x += (data->point_velocity_x * PIXEL_SPEED_PER_FRAME * 4);
if (data->point_p0.x < 0 || data->point_p0.x > data->window.layer.bounds.size.w) {
data->point_velocity... | |
_attributes = 0,
.attributes = NULL,
},
.action_group = {
.num_actions = 0,
.actions = NULL,
},
.allocated_buffer = NULL,
}, {
.header = { // [2]
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb3},... | 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_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_sta... |
m_polar(GRect(0, 0, 10, 10), GOvalScaleModeFillCircle, 0);
cl_assert_equal_gpoint(result, GPoint(4, 0));
}
void test_graphics_circle__grect_centered_from_polar(void) {
GOvalScaleMode mode = GOvalScaleModeFillCircle;
// Basic container rect with GPointZero origin
const GRect container_rect1 = GRect(0, 0, 10, 1... | (&r, mode, NULL, NULL) | ;
grect_polar_calc_values(&r, mode, ¢er, NULL);
grect_polar_calc_values(&r, mode, NULL, &radius);
cl_assert_gpoint_precise(center, 1, 2);
cl_assert_fixedS16_3(radius, 1);
grect_polar_calc_values(NULL, mode, ¢er, &radius);
cl_assert_gpoint_precise(center, 1, 2);
cl_assert_fixedS16_3(radius, 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... | prompt_send_response("No Device Name") | ;
}
prompt_send_response_fmt(buf, BT_DEVICE_NAME_BUFFER_SIZE, "Started Complete: %s",
bool_to_str(shared_prf_storage_get_getting_started_complete()));
}
|
ert_equal_p(recognizer_get_manager(r1), &manager2);
recognizer_set_manager(r1, &manager);
recognizer_manager_deregister_recognizer(&manager, r1);
cl_assert(!recognizer_get_manager(r1));
cl_assert_equal_p(manager.active_layer, &layer_a);
recognizer_set_manager(r1, &manager);
r1->state = RecognizerState_St... | (&manager, r[0]) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersTriggered);
cl_assert_equal_p(manager.triggered, r[0]);
cl_assert_equal_p(manager.active_layer, &layer_a);
prv_compare_recognizers_processed(NULL, 0, &s_recognizers_reset);
r[0]->state = RecognizerState_Completed;
recognizer_manager_handl... |
est.");
const uint16_t conn_idx = evt->conn_idx;
Connection *conn = connection_by_idx(conn_idx);
if (conn == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "No connection for idx=%d", conn_idx);
return;
}
BTDeviceInternal device = {};
connection_get_address(conn, &device);
if (prv_is_auto_accept_repairing_mo... | (&own_addr, 0) | ;
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_address_set: %u", e);
}
#endif
e = ble_gap_mtu_size_set(ATT_MAX_SUPPORTED_MTU);
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_mtu_size_set: %u", e);
}
e = ble_gap_role_set(GAP_PERIPHERAL_ROLE);
if (e != BLE_STATUS_OK) {
... |
/*
* 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_test_buffer) | ;
accessory_enable_input();
#if RECOVERY_FW
const AccessoryInputState input_state = AccessoryInputStateMfg;
#else
const AccessoryInputState input_state = AccessoryInputStateIdle;
#endif
PBL_ASSERTN(accessory_manager_set_state(input_state));
}
}
static void prv_mic_start(void *data) {
const size_t ... |
cl_assert_equal_s(tomorrow_morning, daypart_string) | ;
// (12pm tomorrow) time tomorrow between 12pm and 6pm is tomorrow afternoon
daypart_string = clock_get_relative_daypart_string(timestamp, 32 /* hours_in_the_future */);
cl_assert_equal_s(tomorrow_afternoon, daypart_string);
// (6pm tomorrow) time tomorrow between 6pm and 9pm is tomorrow evening
daypart_st... | |
/*
* 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... | applib_free(data) | ;
}
static void prv_apply_transform(GDrawCommandList *list, const GSize size, const GRect *from,
const GRect *to, AnimationProgress normalized, void *context) {
MorphSquareData *data = context;
AnimationProgress curved;
if (!kino_reel_transform_get_to_reel(data->reel)) {
curv... |
/*
* 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... | (child_b.next_sibling == NULL) | ;
cl_assert(parent.first_child == &child_a);
cl_assert(child_a.next_sibling == &child_c);
cl_assert(grand_child_a.parent == &child_a);
cl_assert(child_c.parent == &parent);
// Remove first-child (child_a):
//
// +-parent
// |
// '->child_c
//
// +-child_a
// |
// '->grand_... |
_default_kernel_receiver_opt_main,
},
};
// Tests
///////////////////////////////////////////////////////////
void test_default_kernel_receiver__cleanup(void) {
memset(s_handler_call_count, 0x0, sizeof(s_handler_call_count));
s_kernel_main_schedule_count = 0;
}
//! With one event in flight, walk through the p... | cl_assert(receiver != NULL) | ;
g_default_kernel_receiver_implementation.write(receiver, (uint8_t *)data, strlen(data));
prv_assert_no_handler_calls();
g_default_kernel_receiver_implementation.cleanup(receiver);
fake_system_task_callbacks_invoke_pending();
prv_assert_no_handler_calls();
cl_assert_equal_i(fake_pbl_malloc_num_net_allo... |
opped_handler);
syscall_failed();
}
return app_inbox_service_register(storage, storage_size,
message_handler, dropped_handler, service_tag);
}
DEFINE_SYSCALL(uint32_t, sys_app_inbox_service_unregister, uint8_t *storage) {
// No check is needed on the value of `storage `, ... | memmove(inbox->buffer.storage, consumed_up_to_ptr, remaining_size) | ;
}
inbox->buffer.write_index -= bytes_consumed;
}
unlock:
prv_unlock();
}
static bool prv_get_consumer_info(AppInboxServiceTag tag, AppInboxConsumerInfo *info_out) {
if (!info_out) {
return false;
}
bool success = false;
prv_lock();
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_i... |
stack_start__ = 0;
static const uint32_t __kernel_bg_stack_start__ = 0;
#else
extern const uint32_t __privileged_functions_start__[];
extern const uint32_t __privileged_functions_size__[];
extern const uint32_t __unpriv_ro_bss_start__[];
extern const uint32_t __unpriv_ro_bss_size__[];
extern const uint32_t __isr_stack_... | mpu_set_region(&s_microflash_region) | ;
// RAM parts
// The background memory map only allows privileged access. We need to add aditional regions to
// enable access to unprivileged code.
mpu_set_region(&s_readonly_bss_region);
mpu_set_region(&s_isr_stack_guard_region);
mpu_enable();
}
const MpuRegion* memory_layout_get_app_region(void) {
... |
s = 1,
.attributes = &title_attr,
},
};
// NOT A CALENDAR PIN
static TimelineItem item5 = {
.header = {
.id = {0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
.timestamp = 10*60,
.duration = 10,
.type = TimelineItemTypePin,
.all_da... | cl_assert_equal_i(fake_event_get_count(), 3) | ;
cl_assert(!prv_get_calendar_ongoing());
cl_assert(!stub_new_timer_is_scheduled(timer_id));
}
void test_calendar__init_with_past_event(void) {
cl_assert(timeline_add(&item1));
timeline_event_handle_blobdb_event();
rtc_set_time(30 * 60);
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1... |
*animation = (AnimationPrivate *)animation_h;
if (!animation) {
return false;
}
return animation->scheduled;
}
uint32_t animation_get_duration(Animation *animation, bool include_delay, bool include_play_count) {
if (!animation) {
return 0;
}
return ((AnimationPrivate *)animation)->duration_ms;
}
s... | (animation) | ;
}
|
NT32_MIN + 100));
}
// Check that the percentage reported is somewhat protected from transient voltage changes
void test_battery_monitor__charge_fluctuate_voltage(void) {
int high_percent = 70;
int low_percent = 20;
int high_mv = battery_curve_lookup_voltage_by_percent(high_percent, true);
int low_mv = battery... | battery_monitor_init() | ;
periodic_timer_trigger(1);
cl_assert(!s_in_low_power && !battery_monitor_critical_lockout());
cl_assert_equal_i(s_power_state, PowerStateGood);
// good -> lpm
fake_battery_set_millivolts(low_mv);
periodic_timer_trigger(10);
cl_assert(s_in_low_power);
cl_assert_equal_i(s_power_state, PowerStateLowPowe... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_gpoint(result, GPoint(-5, 0)) | |
00:00 PST 2015
// No items within window
rtc_set_time(1421395200);
head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
1421395200),
S_NO_MORE_ITEMS);
fake_pbl_malloc_clear_tra... | (&iterator) | |
IT_SOFTWARE_FAILURE_OCCURRED);
// We have a "three strikes" algorithm: if the watch fails three times, return true
// to tell the parent we should load the recovery firmware. A reset for any other reason
// will reset this algorithm.
if (boot_bit_test(BOOT_BIT_FW_START_FAIL_STRIKE_TWO)) {
// Yikes, our fir... | {
// If not entering or leaving standby this is a cold boot. The firmware
// expects the clock to be running in fast mode
rtc_initialize_fast_mode();
} |
// Print out our super cool bootloader logo:
// ______ __
// /_ __/ __/ /_
// / / /_ __/
// /_/ /_/
dbgserial_putstr(" ______ __\r\n/_ __/ __/ /\r\n / / /_ __/\r\n/_/ /_/\r\n");
boot_version_write();
// Write the bootloader version to serial-out
dbgserial_print("Bootloader... |
_get_current();
if (animation && animation->curve == AnimationCurveCustomInterpolationFunction) {
return animation->custom_interpolation_function;
}
return NULL;
}
// ------------------------------------------------------------------------------------
static bool prv_handle_list_filter(ListNode* node, void* ... | serial_distance32(animation_a->abs_start_time_ms, animation_b->abs_start_time_ms) | ;
}
// -------------------------------------------------------------------------------------------
inline static uint32_t prv_get_ms_since_system_start(void) {
return ((sys_get_ticks() * 1000 + RTC_TICKS_HZ / 2) / RTC_TICKS_HZ);
}
// --------------------------------------------------------------------------------... |
ceeded);
}
if (data->action_complete.callback) {
data->action_complete.callback(succeeded, data->action_complete.callback_data);
}
if (data->action_menu) {
action_menu_close(data->action_menu, true);
data->action_menu = NULL;
} else if (data->chaining_data.action_chaining_window) {
window_st... | progress_window_set_result_success(data->progress_window) | |
(1);
#endif
reset_due_to_software_failure();
}
return should_context_switch;
}
static bool prv_try_event_put(QueueHandle_t queue, PebbleEvent *event) {
PBL_ASSERTN(queue);
return (xQueueSendToBack(queue, event, milliseconds_to_ticks(3000)) == pdTRUE);
}
static void prv_event_put(QueueHandle_t queue,
... | (s_from_worker_event_queue, event, 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... | (device1_int, device2_int) | ;
}
bool bt_device_is_invalid(const BTDevice *device) {
const BTDevice invalid_device = BT_DEVICE_INVALID;
return bt_device_equal(device, &invalid_device);
}
|
get_system_font(FONT_KEY_GOTHIC_24_BOLD);
const int16_t fcc_title_font_cap_padding = 10;
const GFont fcc_number_subtitle_font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
const uint8_t fcc_title_height = fonts_get_font_height(fcc_title_font);
const uint8_t fcc_number_subtitle_height = fonts_get_font_height(fcc_... | grect_align(®ulatory_marks_rect, cell_layer_bounds, alignment,
/* clip */ true) | ;
// Draw the regulatory marks
GPoint mark_origin = regulatory_marks_rect.origin;
mark_origin.x += MARK_PADDING;
const bool highlight = menu_cell_layer_is_highlighted(cell_layer);
for (uint32_t i = 0; i < num_marks; i++) {
GBitmap *mark = cd->regulatory_marks[start_idx + i];
// Vertically center the i... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (bits_per_pixel == 2) return GBitmapFormat2BitPalette; |
if (bits_per_pixel == 4) return GBitmapFormat4BitPalette;
return GBitmapFormat8Bit;
}
bool gbitmap_png_data_is_png(const uint8_t *data, size_t data_size) {
if (data_size >= sizeof(PNG_SIGNATURE)) {
// PNG files start with [137, 'P', 'N', 'G']
return (ntohl(*(uint32_t*)data) == PNG_SIGNATURE);
}
ret... |
s
// Unaligned start, even length - Need to pad both ends
// Unaligned start, odd length - Pad the start
// Aligned start, odd length - Pad the end
if (start_addr & 0x1 || bytes_in_page & 0x1) {
++num_shorts;
}
const FlashAddress sector_addr =
flash_impl_get_sector_base_address(start_addr);
flas... | // if they are concerned about reliability.
result = S_SUCCESS;
}
}
prv_allow_write_if_sector_is_not_protected(true, sector_addr);
flash_impl_release();
return FAILED(result) ? result : (int)bytes_in_page;
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(i >= TransportID1 && i <= TransportID3) | |
_RESOURCE_RESULT_DELETED, ActionResultTypeSuccess);
} else {
const bool do_async = true;
prv_do_remote_action(&item->header.id, action->type,
action->id, attributes, do_async);
}
}
static void prv_dismiss_local_notification_action(const TimelineItem *item) {
// TODO: PBL-23915
... | {
s_bulk_action_mode = enable;
} | |
les
//! The list of open Pebble Protocol sessions.
//! @note bt_lock() must be held when accessing this list.
static CommSession *s_session_head;
// -------------------------------------------------------------------------------------------------
// Defined in session_send_buffer.c
extern SendBuffer * comm_session_s... | {
switch (destination) {
case TransportDestinationSystem: return "S";
case TransportDestinationApp: return "A";
case TransportDestinationHybrid: return "H";
default:
WTF;
return NULL;
}
} |
static void prv_log_session_event(CommSession *session, bool is_open) {
char uuid_string[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(prv_get_uuid(session), uuid_string);
PBL_LOG(LOG_LEVEL_INFO, "Session event: is_open=%d, destination=%s, app_uuid=%s",
is_open, prv_string_for_destination(session->destin... |
/*
* 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_assert_valid_fsm_transition(s_fsm_state, next_state) | |
/*
* 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... | {
Connection *connection;
prv_lock();
{
connection = connection_by_idx(conn_idx);
PBL_ASSERTN(connection);
}
prv_unlock();
return connection;
} | |
M (Day of Second kickstarter)
const int feb24_2015 = 1424753940;
prv_clock_reset(0);
rtc_set_time(feb24_2015);
time_t timestamp = rtc_get_time();
// The following are for "Powered 'til"
// Which is read as "Powered 'til at least" ...
// (4am today) Any time before 12pm is this morning
daypart_string... | cl_assert_equal_s(tomorrow_morning, daypart_string) | ;
// Our test event is at Jan 1st 2016, 21:00:00
const int jan1_2016 = 1451682000;
prv_clock_reset(0);
rtc_set_time(jan1_2016);
timestamp = rtc_get_time();
// (9pm today) time between 9pm and tomorrow 9am is tonight
daypart_string = clock_get_relative_daypart_string(timestamp, 0 /* hours_in_the_future... |
info->remote_encryption_info.rand,
.ediv = pairing_info->remote_encryption_info.ediv,
.irk = pairing_info->irk,
.identity = pairing_info->identity,
.csrk = pairing_info->csrk,
.is_local_encryption_info_valid = pairing_info->is_local_encryption_info_valid,
.is_remote_encryption_info_valid = pa... | (&data, addr, device_name, link_key, platform_bits) | |
e;
}
// ----------------------------------------------------------------------------------------------
const char *alarm_get_string_for_kind(AlarmKind kind, bool all_caps) {
const char *alarm_day_text = NULL;
switch (kind) {
case ALARM_KIND_EVERYDAY:
alarm_day_text = all_caps ?
/// A frequency opt... | (alarm_day_text, ",") | ;
i18n_free(day_strings[i % 7], day_strings); // copied in by strcat. We can free it
}
}
if (num_days_scheduled == 1) {
// Write the full day string
const char *full_day_string = i18n_get(full_day_strings[latest_day_scheduled],
full_day_strings);
strc... |
e_rate) {
acc_odr = BMI160AccODR_200_HZ;
} else if (BMI160SampleRate_400_HZ == sample_rate) {
acc_odr = BMI160AccODR_400_HZ;
} else if (BMI160SampleRate_800_HZ == sample_rate) {
acc_odr = BMI160AccODR_800_HZ;
} else { // any interval < min supported must saturate to 1600Hz
acc_odr = BMI160AccODR_1... | ("INT_EN[1] = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_INT_EN_1)) | ;
int_enabled = enable_int;
s_fifo_in_use = use_fifo;
}
void accel_set_num_samples(uint32_t num_samples) {
uint8_t fifo_frame_size = prv_get_fifo_frame_size(); // x,y,z accel data
uint16_t max_num_samples = (BMI160_FIFO_LEN_BYTES / fifo_frame_size);
max_num_samples = (max_num_samples / BMI160_FIFO_WM_UNIT_BY... |
T_ONE);
break;
case 4:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_TWO);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_THREE);
break;
case 5:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 6:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETE... | ("exit standby") | |
/*
* 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... | (MFG_COLOR_KEY) | &&
data[0] == 0x0 &&
data[1] == strlen(MFG_COLOR_KEY) &&
memcmp(data + 2, MFG_COLOR_KEY, strlen(MFG_COLOR_KEY)) == 0) {
prv_send_color_response();
return;
}
prv_send_fail_response();
}
|
S_PER_HOUR,
.length_min = 120,
.type = ActivitySessionType_Run,
.step_data = {
.steps = 1000,
.active_kcalories = 300,
.resting_kcalories = 400,
.distance_meters = 500,
},
};
activity_sessions_prv_add_activity_session(&old_activity);
activity_sessions_prv_add_activity_sessi... | prv_feed_cannned_accel_data(SECONDS_PER_HOUR, 100, ActivitySleepStateAwake) | ;
const int k_exp_steps = 100 * MINUTES_PER_HOUR;
// Test the derived metrics
activity_get_metric(ActivityMetricStepCount, 1, &value);
cl_assert_equal_i(value, k_exp_steps);
cl_assert_equal_i(health_service_sum_today(HealthMetricStepCount), k_exp_steps);
activity_get_metric(ActivityMetricActiveSeconds, 1,... |
r();
shared_prf_storage_erase_ble_pairing_data();
prv_call_ble_bonding_change_handlers(bonding, BtPersistBondingOpWillDelete);
}
bool bt_persistent_storage_get_ble_pairing_by_id(BTBondingID bonding,
SMIdentityResolvingKey *IRK_out,
... | (BT_CLASSIC_BONDING_ID) | ;
}
bool bt_persistent_storage_get_bt_classic_pairing_by_id(BTBondingID bonding,
BTDeviceAddress *address_out,
SM128BitKey *link_key_out,
char *name_out,
... |
/*
* 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_health_thermometer_service = (const Service) {
.uuid = bt_uuid_expand_16bit(0x1809),
.handle = 0x11,
.num_characteristics = 1,
.characteristics = {
[0] = {
.uuid = bt_uuid_expand_16bit(0x2a1c),
.properties = 0x02,
.handle = 0x13,
.num_descriptors = 1,
... |
void fake_gatt_put_discovery_indication_blood_pressure_service(
unsigned int connection_id) {
GATT_Characteristic_Descriptor_Information_t cccd1 = {
.Characteristic_Descriptor_Handle = 0x05,
.Characteristic_Descriptor_UUID = {
.UUID_Type =... |
TON_ID_SELECT, select_click_handler);
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}
static uint32_t s_seconds_count;
void handle_second_tick(struct tm *tick_time, TimeUnits units_changed) {
bool running = app_worker_is_running... | (window_layer, text_layer_get_layer(text_layer)) | |
utines for pfs_open()
///
//! Returns true iff the file is found in the cache and the fd is ready to use
//! fd_used >= 0 if we were able to allocate a fd for the file (regardless of
//! whether or not its in the cache), else it reflects the error code
static NOINLINE bool file_found_in_cache(const char *name, uint8_t... | (fd, file_type, start_size) | ;
} else if ((op_flags & OP_FLAG_READ) != 0) {
res = pfs_open_handle_read_request(fd, page);
} else { // unexpected situation
res = E_INTERNAL;
}
cleanup:
if (res < S_SUCCESS) {
mark_fd_free(fd);
} else {
PFS_FD(fd).fd_status = FD_STATUS_IN_USE;
}
return (res);
}
int pfs_open(const char ... |
week] += 1;
}
// ----------------------------------------
// Compute expected values
int exp_weekly = day_totals[local_tm.tm_wday] / day_counts[local_tm.tm_wday];
int exp_daily = 0;
int count = 0;
for (int i = 0; i < DAYS_PER_WEEK; i++) {
exp_daily += day_totals[i];
count += day_counts[i];
}
... | (day_in_week, Monday) | |
ceStructured *structured_glance) {
LauncherAppGlanceAlarms *alarms_glance =
launcher_app_glance_structured_get_data(structured_glance);
return NULL_SAFE_FIELD_ACCESS(alarms_glance, title, NULL);
}
static void prv_alarms_glance_subtitle_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *nod... | (alarms_glance, new_icon_resource_id) | ;
}
static void prv_alarm_clock_event_handler(UNUSED PebbleEvent *event, void *context) {
LauncherAppGlanceStructured *structured_glance = context;
LauncherAppGlanceAlarms *alarms_glance =
launcher_app_glance_structured_get_data(structured_glance);
prv_update_glance_for_next_alarm(alarms_glance);
// Br... |
e_common.h"
#include "applib/graphics/bitblt.h"
#include "applib/graphics/framebuffer.h"
#include "applib/graphics/gtypes.h"
#include "applib/ui/animation_interpolate.h"
#include "popups/timeline/peek.h"
// TODO: PBL-31388 Factor out vertical compositor slide animations
// This does a similar transition to the legacy ... | graphics_context_set_fill_color(ctx, GColorWhite) | ;
const int content_width = DISP_COLS - TIMELINE_PEEK_ICON_BOX_WIDTH;
graphics_fill_rect(ctx, &GRect(0, fill_offset_y, content_width, fill_height));
graphics_context_set_fill_color(ctx, s_data.fill_color);
graphics_fill_rect(ctx, &GRect(content_width, fill_offset_y, TIMELINE_PEEK_ICON_BOX_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... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_inside_origin_layer.${BIT_DEPTH_NAME}.pbi")) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_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... | {
framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
} | |
st_impl, &s_test_impl_data,
sizeof(s_test_impl_data), dummy,
NULL));
s_test_impl.reset = dummy;
s_test_impl.cancel = NULL;
cl_assert_passert(recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
... | recognizer_transition_state(r, RecognizerState_Failed) | );
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Possible));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Started));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Updated));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Cancelled));
... |
.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 10);
graphics_line_draw_precise_stroked_aa(&ctx, START_ON_ORIGIN_RECT_NXNY, END_ON_ORIGIN_RECT_NXNY, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_across_nxny_origin_layer_aa.${BIT_DEPTH_NAME}.pbi"));
... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_offset_layer_non_aa.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 10);
graphics_line_draw_precise_stroked_non_aa(&ctx, START_ON_ORIGIN_RECT_XY, END_ON_ORIGIN_RECT_XY, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_across_x_offset_layer_non_aa.${BIT_DEPTH_NAME}.pbi"));
setup_t... |
{ 1216, 216, -176},
{ 984, 232, -152},
{ 680, 200, -176},
{ 536, 184, -168},
{ 488, 176, -144},
{ 560, 176, -120},
{ 720, 208, -144},
{ 856, 240, -160},
{ 1000, 248, -216},
{ 1048, 296, -272},
{ 1056, 288, -296},
{ 1320, 336, -240},
{ 1128, 368, -272},
{ 1040, 352... | { 800, 152, -32},
{ 808, 160, 40},
{ 776, 152, 24},
{ 856, 160, 32},
{ 728, 144, 32},
{ 760, 80, 56},
{ 944, 56, -40},
{ 984, 40, -176},
{ 1232, 80, -192},
{ 1256, 128, -200},
// 115 seconds
{ 1216, 168, -168},
{ 1312, 248, -272},
{ 1328, 296, -248},
{ 1104, 2... |
{ 1120, 152, -184},
{ 1200, 160, -96},
{ 1104, 176, -96},
{ 1136, 248, -168},
{ 1272, 288, -176},
{ 1168, 272, -152},
{ 904, 256, -144},
{ 680, 232, -144},
{ 600, 224, -160},
{ 624, 248, -120},
{ 720, 248, -144},
{ 816, 272, -184},
{ 944, 352, -256},
{ 1048, 376,... |
Args s_timeline_args;
const bool is_up = (click_recognizer_get_button_id(recognizer) == BUTTON_ID_UP);
if (is_up) {
PBL_LOG(LOG_LEVEL_DEBUG, "Launching timeline in past mode.");
s_timeline_args.direction = TimelineIterDirectionPast;
analytics_inc(ANALYTICS_DEVICE_METRIC_TIMELINE_PAST_LAUNCH_COUNT, Analy... | {
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = watchface_get_default_install_id(),
.common.transition = animation,
});
} |
static void kernel_callback_watchface_launch(void* data) {
watchface_launch_default(NULL);
}
void command_watch(void) {
launcher_task_add_callback(kernel_callback_watchface_launch, NULL);
}
void watchface_start_low_power(void) {
app_manager_set_minimum_run_level(ProcessAppRunLevelNormal);
prv_watchface_laun... |
nst int k_height_mm = 1630;
activity_prefs_set_height_mm(k_height_mm);
activity_prefs_set_weight_dag(6800);
activity_prefs_set_gender(ActivityGenderFemale);
activity_prefs_set_age_years(30);
// The health_service calls expect to be in the app or worker task
stub_pebble_tasks_set_current(PebbleTask_App);
... | (false /*test_mode*/) | ;
fake_system_task_callbacks_invoke_pending();
// All tests start at 5pm, which is 1020 minutes into a 1440 minute day. The BMR for
// the above user is 1859 kcalories per day, so we expect to get:
// 1859 * 1020/1440 = 1328 kcalories
activity_get_metric(ActivityMetricRestingKCalories, 1, &value);
const... |
);
temp.attr_list.attributes = NULL;
cl_assert(memcmp(&item4, &temp, sizeof(TimelineItem)) == 0);
cl_assert(S_SUCCESS == reminder_db_delete_item(&temp.header.id, true /* send_event */));
cl_assert(reminder_db_get_len((uint8_t *)&item4.header.id, sizeof(Uuid)) == 0);
} else {
temp.attr_list.attribu... | reminder_db_find_by_timestamp_title(title_item1.header.timestamp,
title_item1.attr_list.attributes[0].cstring, NULL, &reminder) | , true);
cl_assert(uuid_equal(&reminder.header.id, &title_item1.header.id));
}
void test_reminder_db__is_dirty_insert_from_phone(void) {
// Insert a bunch of reminders "from the phone"
// They should NOT be dirty (the phone is the source of truth)
reminder_db_insert((uint8_t *)&item1.header.id, sizeof(Timeline... |
t(resource_id != UINT32_MAX);
GBitmapSequence *bitmap_sequence = gbitmap_sequence_create_with_resource(resource_id);
cl_assert(bitmap_sequence);
GBitmap *bitmap = gbitmap_create_blank(gbitmap_sequence_get_bitmap_size(bitmap_sequence),
GBitmapFormat8Bit);
cl_assert(bitm... | (bitmap_sequence, bitmap, NULL) | |
ue & ~mask) | value;
// enable writing and write the register value
prv_write_cmd_no_addr(dev, dev->state->part->instructions.write_enable);
qspi_indirect_write_no_addr(dev->qspi, write_instruction, ®_value, 1);
qspi_release(dev->qspi);
}
static bool prv_protection_is_enabled(QSPIFlash *dev) {
uint8_t s... | ("FAILURE: buffer_dma != buffer_mmap") | ;
success = false;
}
const int buf_size = 64;
char buf[buf_size];
prompt_send_response_fmt(buf, buf_size, "Size: %d DMA: %"PRIu32 " POL: %"PRIu32 " MMP: %"PRIu32,
size, dma_time, pol_time, mmap_time);
kernel_free(buffer_dma_ptr);
kernel_free(buffer_pol);
kernel_free(buffe... |
PropertyAnimation *prv_create_int16_prop_anim(int16_t from, int16_t to,
uint32_t duration,
const PropertyAnimationImplementation *impl,
void *subject);
static vo... | dialog_set_icon(dialog, resource_id) | ;
dialog_set_background_color(dialog, color);
dialog_set_timeout(dialog, has_timeout ? ERROR_DIALOG_TIMEOUT : DIALOG_TIMEOUT_INFINITE);
dialog_set_destroy_on_pop(dialog, false /* free_on_pop */);
}
static void prv_push_error_dialog(VoiceUiData *data, const char *text, uint32_t resource_id,
GColor color) {
... |
/*
* 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_flush_size, 0x20) | ;
cl_assert_equal_i(s_invalidate_addr, 0x00);
cl_assert_equal_i(s_invalidate_size, 0x20);
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Valid);
}
void test_cpu_cache__userspace_fail_from_size(void) {
cl_will_return(icache_is_enabled, true);
cl_will_return(dcache_is_enabled, true);
cl_will_return(icach... |
nedFat);
UNUSED const bool is_thin = (layout->layout_layer.mode == LayoutLayerModePinnedThin);
const TimelineLayoutStyle *style = prv_get_style();
const bool thin_can_have_secondary = style->thin_can_have_secondary;
const bool has_secondary =
(((is_peek || is_fat || thin_can_have_secondary) && !IS_EMPTY_S... | (numbers_font) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(strtol("765", NULL, 10), 765) | ;
cl_assert_equal_i(strtol("573888", NULL, 10), 573888);
cl_assert_equal_i(strtol("713713", NULL, 10), 713713);
cl_assert_equal_i(strtol("2147483646", NULL, 10), 2147483646);
cl_assert_equal_i(strtol("-2147483647", NULL, 10), -2147483647);
}
void test_strtol__whitespace_pfx(void) {
cl_assert_equal_i(strtol(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.