prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
int32_t aux_info) {
analytics_event_ams(event, aux_info);
}
static void prv_perform_on_kernel_main_task(void (*callback)(void *), void *data) {
const bool is_kernel_main = (pebble_task_get_current() == PebbleTask_KernelMain);
if (is_kernel_main) {
callback(data);
} else {
launcher_task_add_callback(ca... | prv_analytics_log_event_with_info(AMSAnalyticsEventErrorRegisterEntityWrite, e) | ;
}
}
static bool prv_set_connected(bool connected) {
if (s_ams_client->connected == connected) {
return true;
}
s_ams_client->connected = connected;
const bool has_error = !music_set_connected_server(&s_ams_music_implementation, connected);
if (has_error) {
s_ams_client->connected = false;
PBL... |
ceId:
attribute->length = sizeof(uint32_t);
memcpy(buffer, &attr_list->attributes[i].uint32, attribute->length);
break;
case AttributeTypeUint8:
attribute->length = sizeof(uint8_t);
memcpy(buffer, &attr_list->attributes[i].uint8, attribute->length);
br... | for (int i = 0; i < in->num_attributes; i++) {
bool r = prv_deep_copy_attribute(&out->attributes[i], &in->attributes[i],
&write_ptr, buffer_end);
if (!r) {
return false;
}
} |
return true;
}
size_t attribute_list_get_buffer_size(const AttributeList *list) {
return (sizeof(Attribute) * list->num_attributes) + attribute_list_get_string_buffer_size(list);
}
size_t attribute_list_get_string_buffer_size(const AttributeList *list) {
size_t size = 0;
for (int i = 0; i < list->num_attrib... |
/*
* 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... | system_theme_get_default_content_size_for_runtime_platform() | |
/*
* 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... | {
each_cb(item, context);
} |
}
applib_free((void *)level);
}
void action_menu_hierarchy_destroy(const ActionMenuLevel *root,
ActionMenuEachItemCb each_cb,
void *context) {
if (root) {
prv_cleanup_helper(root, each_cb, context);
}
}
|
/*
* 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... | {
TimerID timer_id = battery_state_get_periodic_timer_id();
cl_assert(timer_id != TIMER_INVALID_ID);
cl_assert(stub_new_timer_is_scheduled(timer_id));
for (int i=0; i<count; ++i) {
stub_new_timer_fire(timer_id);
fake_system_task_callbacks_invoke_pending();
}
} | |
cognizer, void *context) {
AppData *data = window_get_user_data(s_window);
switch (data->operation) {
case OP_ROTATE:
data->rotation_angle = (data->rotation_angle + STEP_ROTATION_ANGLE) % TRIG_MAX_ANGLE;
break;
case OP_CHANGE_WIDTH:
case OP_TEST:
case OP_TEST2:
case OP_TEST3:
ca... | (ctx, true) | |
Sample captured: 2015-10-19 11:02:53 local
AccelRawData *activity_sample_walk_200_pbl_27927_10(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_27927_10
//> TEST_EXPECTED 200
//> TEST_EXPECTED_MIN 180
//> TEST_EXPECTED_MAX 220
//> TEST_WEIGHT 1.0
... | { 16, 1024, 24},
// 5 seconds
{ 64, 816, -64},
{ 32, 920, -48},
{ 32, 992, 8},
{ 88, 952, 24},
{ 128, 880, 64},
{ 152, 896, 240},
{ 96, 952, 440},
{ 56, 1000, 504},
{ -48, 856, 568},
{ -120, 1048, 464},
{ -120, 1048, 416},
{ -40, 896, 440},
{ 64, 1024, 256},
... |
{ 440, 440, -456},
{ 440, 520, -544},
{ 432, 552, -616},
{ 376, 608, -520},
{ 392, 696, -640},
{ 400, 880, -568},
// 8 seconds
{ 488, 1000, -552},
{ 552, 1056, -488},
{ 752, 912, -488},
{ 744, 832, -344},
{ 568, 1072, -376},
{ 352, 1064, -224},
{ 144, 984, -136},... |
/*
* 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... | (name, device_name, BT_DEVICE_NAME_BUFFER_SIZE) | |
NSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under t... | graphics_context_set_fill_color(&ctx, (GColor8){.a= 3, .r = 3}) | ;
cl_assert_equal_i(GColorRedARGB8, ctx.draw_state.fill_color.argb);
graphics_context_set_fill_color(&ctx, (GColor8){.a= 2, .r = 3});
cl_assert_equal_i(GColorRedARGB8, ctx.draw_state.fill_color.argb);
graphics_context_set_fill_color(&ctx, (GColor8){.a= 1, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | for (unsigned int i=0; i<CORE_DUMP_MAX_IMAGES; i++) {
if (flash_hdr.unformatted & (1 << i)) {
continue;
}
base_address = core_dump_get_slot_address(i);
flash_read_bytes((uint8_t *)®ion_hdr, base_address, sizeof(region_hdr));
if (unread_only && !region_hdr.unread) {
continue;
}
... |
if (!max_last_used) {
return CORE_DUMP_FLASH_INVALID_ADDR;
}
return core_dump_get_slot_address(last_used_idx);
}
bool gb_storage_coredump_setup(GetBytesStorage *storage, GetBytesObjectType object_type,
GetBytesStorageInfo *info) {
storage->impl_data = kernel_zalloc_check(size... |
);
pin_db_insert_item_without_event(item);
timeline_item_destroy(item);
attribute_list_destroy_list(&list);
}
static void prv_add_activity_session_pin(int32_t delta_time_s, int32_t duration_m) {
const time_t now = rtc_get_time();
AttributeList list = {};
attribute_list_add_uint32(&list, AttributeIdIconPi... | prv_add_calendar_pin(6 * 60 * 60, 60, !is_all_day, recurring, 0, 0) | ;
prv_add_generic_pin(7 * 60 * 60, has_subtitle);
prv_add_generic_pin(8 * 60 * 60, !has_subtitle);
prv_add_weather_pin(1 * 24 * 60 * 60);
prv_add_weather_pin(2 * 24 * 60 * 60);
prv_add_weather_pin(3 * 24 * 60 * 60);
// Fallthrough
}
case TimelinePinsDemo_OneDayAway:
prv... |
/*
* 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... | {
state->connection = next_state;
s_transitions[state->connection].enter();
} |
static void prv_update_plugged_change(void) {
// If the connection state changed or we finished charging, reset the filter since we're
// probably switching to a new curve.
battery_state_reset_filter();
bool is_charging = battery_charge_controller_thinks_we_are_charging();
if (is_charging) {
analytics... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | setup_png_test(TEST_PNG_FILE) | ;
GBitmap *native_framebuffer = graphics_context_get_bitmap(ctx);
cl_assert(native_framebuffer->info.format == GBitmapFormat8BitCircular);
cl_assert(DISPLAY_FRAMEBUFFER_BYTES == 25944);
bitblt_bitmap_into_bitmap(native_framebuffer, bitmap, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi_eq(nati... |
f the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the spec... | kernel_zalloc(sizeof(AppMessageReceiver)) | ;
if (!rcv) {
return NULL;
}
rcv->session = session;
const size_t header_bytes_remaining = MIN(MAX_HEADER_SIZE, total_payload_size);
rcv->header_bytes_remaining = header_bytes_remaining;
// Always forward the header to default system receiver as well, we'll cancel it later on if the
// message was w... |
)));
cl_assert_equal_i(S_SUCCESS, app_db_insert((uint8_t*)&app3.uuid,
sizeof(Uuid), (uint8_t*)&app3, sizeof(AppDBEntry)));
}
void test_app_db__cleanup(void) {
//nada
}
// Tests
////////////////////////////////////////////////////////////////
void test_app_db__basic_test(void) {
// confirm all three are ... | (S_SUCCESS, app_db_insert((uint8_t*)&app1.uuid, sizeof(Uuid), (uint8_t*)&app1,
sizeof(AppDBEntry))) | ;
cl_assert_equal_i(S_SUCCESS, app_db_insert((uint8_t*)&app1.uuid, sizeof(Uuid), (uint8_t*)&app1,
sizeof(AppDBEntry)));
cl_assert_equal_i(S_SUCCESS, app_db_insert((uint8_t*)&app1.uuid, sizeof(Uuid), (uint8_t*)&app1,
sizeof(AppDBEntry)));
cl_assert(app_db_check_next_unique_id() == 4);
// add two mor... |
yout);
}
static void prv_pin_to_card_first_half_stopped(KinoLayer *layer, bool finished,
void *context) {
TimelineLayout *timeline_layout = context;
// reset the first half of the animation
kino_reel_set_elapsed(kino_layer_get_reel(&timeline_layout->icon_layer), 0)... | layer_set_hidden((Layer *)&pin_timeline_layout->icon_layer, true) | ;
}
static void prv_up_down_stopped(Animation *animation, bool finished, void *context) {
TimelineLayout *layout = context;
timeline_animation_layer_stopped_cut_to_end(animation, finished, context);
// move the icon layer to where it transformed to
KinoReel *prev_reel = kino_layer_get_reel(&layout->icon_layer... |
lib/ui/window_private.h"
#include "apps/system_app_ids.h"
#include "apps/system_apps/launcher/launcher_app.h"
#include "apps/system_apps/timeline/timeline.h"
#include "kernel/pbl_malloc.h"
#include "process_management/app_install_manager.h"
#include "process_management/app_manager.h"
#include "process_state/app_state/a... | (sizeof(SdkAppData)) | ;
Window *window = &data->window;
window_init(window, WINDOW_NAME("SDK Home"));
window_set_click_config_provider(window, prv_config_provider);
window_set_overrides_back_button(window, true);
window_set_fullscreen(window, true);
layer_set_update_proc(&window->layer, prv_sdk_home_update_proc);
GRect frame... |
XIE |
I2C_CR1_RXIE |
I2C_CR1_TCIE |
I2C_CR1_NACKIE |
I2C_CR1_ERRIE);
}
void i2c_hal_abort_transfer(I2CBus *bus) {
// Disable all interrupts on the bus
prv_disable_all_interrupts(bus);
// Generate a stop condit... | {
i2c->ICR |= I2C_ICR_NACKCF;
return i2c_handle_transfer_event(bus, I2CTransferEvent_NackReceived);
} |
break;
case I2CTransferState_ReadData:
if ((i2c->ISR & I2C_ISR_RXNE) != 0) {
transfer->data[transfer->idx++] = i2c->RXDR;
}
if ((i2c->ISR & I2C_ISR_TCR) != 0) {
prv_resume_transfer(bus, false /* !generate_start */);
}
if ((i2c->ISR & I2C_ISR_TC) != 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... | {
psleep(10);
dialog_spi_transmit_data_no_wait((uint8_t *)core_dump_connect_ping,
sizeof(core_dump_connect_ping));
psleep(10);
dialog_spi_receive_data_no_wait(buffer, sizeof(buffer));
if (memcmp(buffer, core_dump_connect_response, sizeof(core_dump_connect_respo... |
PBL_LOG(LOG_LEVEL_ERROR, "Failed to connect with BLE chip to collect coredump");
return false;
}
static void prv_int_exti_cb(bool *should_context_switch) {
xSemaphoreGiveFromISR(s_spi_int_semph, NULL);
}
static void prv_dma_cb(bool *should_context_switch) {
portBASE_TYPE was_higher_task_woken = false;
xSem... |
ult worker
#define DO_NOT_EVICT_LIST_SIZE (NUM_BUTTONS + 2)
static PebbleRecursiveMutex *s_app_cache_mutex = NULL;
//! Actual data structure stored in flash about an app cache entry
typedef struct PACKED {
time_t install_date;
time_t last_launch;
uint32_t total_size;
uint16_t launch_count;
} AppCacheE... | {
priority = MAX_PRIORITY;
} |
*node = (EvictListNode) {
.id = id,
.size = entry.total_size,
.priority = MAX(priority, prv_calculate_priority(&entry)),
};
data->list = (EvictListNode *)list_sorted_add((ListNode *)data->list, (ListNode *)node,
evict_node_comparator, false);
data->bytes_in_list += node->size;
if (data->... |
uint8_t *)&write, i, sizeof(write));
}
flash_read_bytes((uint8_t *)&read, i, sizeof(read));
if (read != write) {
PBL_LOG_SYNC(LOG_LEVEL_INFO, ">>>> Address 0x%lx failed to write: 0x%lx 0x%lx",
i, read, write);
success = false;
}
}
return success;
}
// Writes 0's to the first ... | (GRect(4, 44, width, 60)) | ;
TextLayer *text_layer = stress_data.text_layer;
text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
text_layer_set_background_color(text_layer, GColorClear);
layer_add_child(layer, text_layer_get_layer(text_layer));
text_layer_set_text(stress_data.text_layer, "Starting Stress T... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (list->data[i] == '\0') {
result++;
} |
}
return result;
}
char *string_list_get_at(StringList *list, size_t index) {
if (!list) {
return NULL;
}
char *ptr = list->data;
const char *max_ptr = ptr + list->serialized_byte_length;
while (index > 0 && ptr < max_ptr) {
ptr += strlen(ptr) + 1;
index--;
}
if (index > 0) {
retur... |
tings_raw_iter_set_current_record_pos(&file->iter,
partially_overwritten_record_pos);
set_flag(&file->iter.hdr, SETTINGS_FLAG_OVERWRITE_COMPLETE);
settings_raw_iter_write_header(&file->iter, &file->iter.hdr);
}
return S_SUCCESS;
}
static status_t bootup_check(Setting... | settings_raw_iter_write_header(&file->iter, &new_hdr) | |
data->steps_updated_value = steps_today;
}
}
// -------------------------------------------------------------------------------
// Tests
typedef struct {
const char *title;
AppTimerCallback callback;
} TestEntry;
static TestEntry s_test_entries[] = {
{
.title = "steps",
.callback = prv_test_steps,
... | window_set_user_data(data->window, data) | ;
window_set_click_config_provider_with_context(data->window, click_config_provider, data);
window_set_window_handlers(data->window, &(WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
});
app_window_stack_push(data->window, true /* Animated */);
}
// ---------------------------... |
_id, we know what parser to call later on:
reassembly_ctx->command_id = cmd_header->command_id;
// Append the partial response to the reassembly buffer:
const int bytes_written = buffer_add(&reassembly_ctx->buffer, data, length);
// If this gets hit, NOTIFICATION_ATTRIBUTES_MAX_BUFFER_LENGTH is too sma... | {
length--;
if (*data++ == 0) {
break;
}
} |
ANCSAttribute *app_attrs[NUM_FETCHED_APP_ATTRIBUTES] = {0};
if (length == 0) {
goto fail;
}
bool error = false;
const bool complete = ancs_util_get_attr_ptrs(data,
length,
s_fetched_app_attributes,
... |
v_phone_ui_deinit();
}
//! Window destroy functions
//! Currently only 1 call window can exist at a time
static void prv_window_pop(void) {
if (s_phone_ui_data == NULL) {
// Check to make sure we didn't get popped already.
// There could possibly be 2 of these callback in the queue at time if this is called ... | PBL_IF_COLOR_ELSE(GColorClear, GColorWhite) | ,
PBL_IF_RECT_ELSE(GTextAlignmentCenter, GTextAlignmentRight),
GTextOverflowModeTrailingEllipsis);
layer_add_child(&s_phone_ui_data->core_ui_container,
&s_phone_ui_data->caller_id_text_layer.layer);
// Shrink the bounds but not th... |
;
// How often we want the interrupt to fire
#define TIMER_INTERRUPT_HZ 2
// The frequency to run the peripheral at
#define TIMER_CLOCK_HZ 32000
// The number of timer ticks that should elapse before the timer interrupt fires
#define TIME_PERIOD (TIMER_CLOCK_HZ / TIMER_INTERRUPT_HZ)
// How many ticks have elapsed s... | vTaskPrioritySet(pebble_task_get_handle_for_task(PebbleTask_App),
APP_TASK_PRIORITY | portPRIVILEGE_BIT) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "Ending App Throttling");
}
static void prv_app_task_throttle_start(void) {
static char last_throttled_task[configMAX_TASK_NAME_LEN];
const char *curr_task = pebble_task_get_name(PebbleTask_App);
// if an app results in system throttling, log it at the INFO level at least
// once ... |
i/app_window_stack.h"
#include "applib/ui/text_layer.h"
#include "applib/ui/window.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
static Window *s_window;
typedef enum PixelBit {
PIXEL_BIT_BO... | GRect(30, 80, 20, 20) | , "R", data->hue == HUE_RED,
data->selection == ATTRIBUTE_HUE);
draw_ui_element(ctx, GRect(50, 80, 20, 20), "G", data->hue == HUE_GREEN,
data->selection == ATTRIBUTE_HUE);
draw_ui_element(ctx, GRect(70, 80, 20, 20), "B", data->hue == HUE_BLUE,
data->selection ==... |
kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_1 });
prv_assert_alarm_config(id1, 1, 30, false, ALARM_KIND_CUSTOM, schedule_1);
// It's currently Thursday @ 00:00, 2 days + 1:30 till next alarm
/* cl_assert_equal_i(s_alarm_timer_timeout_ms, */
/* (SECONDS_PER_DAY * 2 + prv_hours_and_min... | alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKDAYS }) | ;
at_least_one_alarm_enabled = alarm_get_next_enabled_alarm(&next_alarm);
cl_assert_equal_b(at_least_one_alarm_enabled, true);
alarm_is_scheduled = alarm_get_time_until(id1, &time_until_alarm);
cl_assert_equal_b(alarm_is_scheduled, true);
cl_assert_equal_i(next_alarm, rtc_get_time() + time_until_alarm);
//... |
_size__ ) / sizeof(portSTACK_TYPE);
TaskParameters_t task_params = {
.pvTaskCode = main_task,
.pcName = "KernelMain",
.usStackDepth = kernel_main_stack_words,
.uxPriority = (tskIDLE_PRIORITY + 3) | portPRIVILEGE_BIT,
.puxStackBuffer = (void*)(uintptr_t)((uint32_t)__kernel_main_stack_start__
... | prv_sjlj_main(r) | ;
PBL_ASSERT(s_sjlj_num == 3, "SJLJ TRACK INCORRECT @ END");
PBL_LOG(LOG_LEVEL_ALWAYS, "sjlj works \\o/");
}
#endif
static NOINLINE void prv_main_task_init(void) {
// The Snowy bootloader does not clear the watchdog flag itself. Clear the
// flag ourselves so that a future safe reset does not look like a watch... |
configure as analog inputs to save some power
// SCLK
InputConfig sclk = { .gpio = bus->spi_sclk.gpio, .gpio_pin = bus->spi_sclk.gpio_pin };
gpio_analog_init(&sclk);
// MOSI
InputConfig mosi = { .gpio = bus->spi_mosi.gpio, .gpio_pin = bus->spi_mosi.gpio_pin };
gpio_analog_init(&mosi);
// MISO
if (is_... | prv_spi_bus_init(slave->spi_bus, prv_is_bidrectional(slave)) | ;
// SCS
gpio_output_init(&slave->spi_scs, GPIO_OType_PP, slave->spi_bus->spi_sclk_speed);
gpio_output_set(&slave->spi_scs, false); // SCS not asserted (high)
// Set up an SPI
prv_spi_slave_deinit(slave);
prv_spi_slave_init(slave);
// Set up DMA
if (slave->rx_dma) {
dma_request_init(slave->rx_d... |
--------------------
// Sample captured: 2015-09-28 17:10:23 local
AccelRawData *activity_sample_100_steps_heather_18(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_heather_18
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 30
//> TEST_EXPECTED_MAX 105
//>... | { 1264, 264, -384},
{ 1208, 152, -136},
{ 1704, 128, -144},
// 5 seconds
{ 1584, 280, -256},
{ 1360, 344, -192},
{ 1112, 416, -96},
{ 1064, 432, -144},
{ 1176, 248, -64},
{ 1200, 328, 48},
{ 1576, 624, 136},
{ 1104, 920, 304},
{ 1192, 1088, -120},
{ 1024, 624, -18... |
{ 1520, 600, 72},
{ 1376, 368, 56},
{ 1240, 96, 48},
{ 1176, -8, 48},
{ 1216, 112, -16},
{ 1160, 184, -40},
{ 1064, 192, -24},
{ 1320, 192, -120},
{ 1120, 104, -184},
{ 1000, -48, -16},
{ 1184, -88, 56},
// 8 seconds
{ 1216, 152, -272},
{ 1280, 168, -272},
{ ... |
/*
* 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... | (BITS_BETWEEN(0, 2), erased_sector) | |
lytics_event.h"
#include "services/common/system_task.h"
#include "syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#include "syscall/syscall.h"
#include <util/heap.h>
#define CMSIS_COMPATIBLE
#include <mcu.h>
#include "FreeRTOS.h"
#include "portmacro.h"
#include "task.h"
#includ... | convert_to_process_offset(s_current_app_crash_info.pc_known, &s_current_app_crash_info.pc, task) | ;
convert_to_process_offset(s_current_app_crash_info.lr_known, &s_current_app_crash_info.lr, task);
}
static NORETURN kernel_fault(RebootReasonCode reason_code, uint32_t lr) {
RebootReason reason = { .code = reason_code, .extra = lr };
reboot_reason_set(&reason);
reset_due_to_software_failure();
}
// TODO: Ca... |
,
{ 968, 608, -408},
{ 752, 832, -528},
{ 880, 1016, -440},
{ 992, 768, -360},
{ 1464, 888, -360},
{ 1072, 472, -208},
{ 1112, 496, -264},
{ 1336, 392, -192},
{ 1248, 344, -248},
{ 1048, 40, -56},
{ 1016, 104, -120},
{ 1040, 216, -112},
{ 1024, 176, -144},
{ 976, ... | { 1576, 272, -184},
{ 1272, 128, -56},
{ 1160, 288, -168},
{ 1152, 168, -152},
{ 1168, 224, -160},
{ 1080, 168, -144},
{ 1064, 184, -216},
{ 1056, 160, -272},
{ 768, -40, -296},
// 54 seconds
{ 808, -32, -240},
{ 544, -40, -328},
{ 704, 32, -480},
{ 1040, 112, -48... | |
phone_call_service_init() | ;
prv_call_end();
s_last_phone_ui_event = PhoneEventType_Invalid;
// s_transport = fake_transport_create(TransportDestinationSystem, NULL, NULL);
// s_session = fake_transport_set_connected(s_transport, true /* connected */);
// pp_get_phone_state_set_enabled(false);
}
// --------------------------------------... | |
trlen(overwrite_string));
cl_assert_equal_i(pfs_close(tmp_fd), S_SUCCESS);
uint8_t new_buf[strlen(overwrite_string)];
fd = pfs_open(file, OP_FLAG_READ, 0, 0);
cl_assert(fd >= 0);
rv = pfs_read(fd, &new_buf[0], strlen(overwrite_string));
cl_assert_equal_i(rv, strlen(overwrite_string));
cl_assert(memcmp(ov... | cl_assert(pfs_write(fd, (uint8_t *)buf, len) == len) | ;
cl_assert(pfs_close(fd) == S_SUCCESS);
if ((i % 2) == 0) {
cl_assert(pfs_remove(file_small) == S_SUCCESS);
}
}
// now write two large files that are interleaved between sectors
// was negative
int bytes_available = (num_pages() / 2) * 4000;
int large_file_size = bytes_available / 2;
pr... |
progress_source) {
case PROGRESS_UI_SOURCE_COREDUMP: {
break;
}
case PROGRESS_UI_SOURCE_LOGS: {
break;
}
case PROGRESS_UI_SOURCE_FW_UPDATE: {
if (firmware_update_current_status() == FirmwareUpdateFailed) {
prv_handle_finished(data, false /* success */);
return;
... | PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite) | );
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_window_load_handler,
.unload = prv_window_unload_handler,
});
app_window_stack_push(window, false);
}
static void prv_main(void) {
if (!app_manager_get_task_context()->args) {
PBL_LOG(LOG_LEVEL_WARNING, "Progress UI App must be la... |
ing, reset the filter since we're
// probably switching to a new curve.
battery_state_reset_filter();
bool is_charging = battery_charge_controller_thinks_we_are_charging();
if (is_charging) {
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BATTERY_CHARGE_TIME, AnalyticsClient_System);
} else {
ana... | (&s_last_battery_state, next_state) | ;
state_changed = true;
}
}
s_last_battery_state.voltage = prv_filter_voltage(s_last_battery_state.voltage,
battery_get_millivolts());
bool charging = (s_last_battery_state.connection == ConnectionStateChargingPlugged);
// Update Percent & Filterin... |
InvalidTimeUnit,
3,
},
{ "'%T',)", 1, true,
"1",
1,
TemplateStringErrorStatus_MissingArgument,
5,
},
{ "'%T'fj)", 1, true,
"1",
1,
TemplateStringErrorStatus_InvalidArgumentSeparator,
4,
},
// Basic %T tests
{ "'%T')", 1, true,
"1",
1,
},
{ "'%T')", 60, true... | {
for(size_t i = 0; i < ARRAY_LENGTH(s_format_tests); i++) {
const FormatTestData *test = &s_format_tests[i];
prv_state_init();
s_state.filter_state = test->filter_state;
s_state.time_was_until = test->time_was_until;
prv_template_evaluate_filter(&s_state, "format", test->params);
// The fil... |
cl_assert_equal_i(s_cond.eval_time, test->expect_eval_time);
#if DEBUG_PRINTING
printf("\n");
#endif
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Test pipeline parser
static const struct {
const char *instr;
time_t intime;
const char *ex... |
her_icon_resource_id_for_type(WeatherType type) {
AppResourceInfo res_info;
const bool lookup_success =
timeline_resources_get_id_system(weather_type_get_timeline_resource_id(type),
TimelineResourceSizeTiny, SYSTEM_APP, &res_info);
return lookup_success ? res_info.res_... | app_zalloc_check(sizeof(*weather_glance)) | |
ons = 0,
};
// Store them in the DB
char *key = "key1";
int key_len = strlen(key);
ios_notif_pref_db_store_prefs((uint8_t *)key, key_len, &attr_list, &action_group);
// Make sure we can get the data back
iOSNotifPrefs *notif_prefs = ios_notif_pref_db_get_prefs((uint8_t *)key, key_len);
cl_assert(notif... | ios_notif_pref_db_get_dirty_list() | |
vices/normal/music_internal.h"
#include "services/common/comm_session/session.h"
#include "services/common/comm_session/session_remote_os.h"
#include "kernel/events.h"
#include "util/size.h"
// Stubs & Fakes
///////////////////////////////////////////////////////////
#include "fake_events.h"
#include "fake_rtc.h"
... | cl_assert_equal_i(e.media.type, PebbleMediaEventTypeNowPlayingChanged) | ;
char player_name[MUSIC_BUFFER_LENGTH];
music_get_player_name(player_name);
cl_assert_equal_s(player_name, "Spotify");
} else {
cl_assert_equal_i(e.type, PEBBLE_NULL_EVENT);
}
}
static void prv_receive_and_assert_all(bool expect_is_handled) {
prv_receive_and_assert_now_playing(expect_is_handle... |
ack, 1px white.
// - Dest is Blue, 100x100
// - Dest rect is 50 x 25, at (0, 0)
// Result:
// - 50x20 of alternating stripes, rest is blue.
void test_bitblt__1bit_to_8bit_wrap_x(void) {
GBitmap *src_bitmap = get_gbitmap_from_pbi("test_bitblt__1bit_to_8bit_wrap_x.1bit.pbi");
uint8_t dest_data[100*100];
GBit... | GRect(10, 25, src_bitmap->bounds.size.w*2, src_bitmap->bounds.size.h*2) | ;
GPoint src_origin_offset = { .x = 4, .y = 2 }; // Offset past the black
bitblt_bitmap_into_bitmap_tiled(&dest_bitmap, src_bitmap, dest_rect, src_origin_offset,
GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap,
"test_bitblt__1bit_to... |
new_timer_delete(TimerID timer_id) {
s_snooze_timer_timeout_ms = 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Setup
void test_alarm__initialize(void) {
s_num_timer_register_calls = 0;
s_num_timeline_adds = 0;
s_num_timeline_removes = 0;
s_num... | prv_assert_alarm_config(id, 5, 14, false, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday) | ;
id = alarm_create(&(AlarmInfo) { .hour = 6, .minute = 14, .kind = ALARM_KIND_JUST_ONCE });
prv_assert_alarm_config(id, 6, 14, false, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday);
}
void test_alarm__alarm_create_recurring_custom(void) {
AlarmId id;
bool custom_schedule1[7] = {true, false, true, false, f... |
= start + (item->header.duration * SECONDS_PER_MINUTE);
if (now >= end) {
return 0;
}
const uint32_t timeout_s = ((start > now) ? start : end) - now;
return MIN(timeout_s, UINT32_MAX / MS_PER_SECOND) * MS_PER_SECOND;
}
static void prv_set_timer(unsigned int timeout_ms) {
if (!timeout_ms) {
PBL_LOG(L... | mutex_lock(s_mutex) | |
tion_bar_start);
if (can_stop) {
action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, active_window->action_bar_stop);
}
} else {
action_bar_layer_clear_icon(action_bar, BUTTON_ID_SELECT);
action_bar_layer_set_icon(action_bar, active_window->pause_button,
active_... | graphics_fill_rect(ctx, bounds) | ;
}
static void prv_render_metric_label(GContext *ctx, GRect *box, WorkoutMetricType metric_type,
WorkoutActiveWindow *active_window, void *i18n_owner) {
GRect label_box = *box;
GTextOverflowMode overflow_mode = GTextOverflowModeWordWrap;
if (metric_type == WorkoutMetricType_C... |
text_layer_set_text(&data->thumbsup_layer, "") | ;
}
static void prv_show_thumbsup(AppData *data) {
app_timer_cancel(data->thumbsup_timer);
text_layer_set_text(&data->thumbsup_layer, "👍");
data->thumbsup_timer = app_timer_register(1000, prv_hide_thumbsup, data);
}
static void prv_set_tap_text(AppData *data, uint32_t count, AccelAxisType axis) {
char axes[]... | |
= &state->sleep_data.restful_minutes;
info->settings_key = ActivitySettingsKeySleepDeepMinutesHistory;
info->has_history = true;
info->converter = prv_convert_minutes_to_seconds;
break;
case ActivityMetricSleepEnterAtSeconds:
info->value_p = &state->sleep_data.enter_at_minute;
i... | {
*m_info.value_u32p = value;
current_value_updated = true;
} |
} else if (m_info.has_history) {
// This update is for a day in the past. Modify the copy stored in the settings file
SettingsFile *file = activity_private_settings_open();
if (!file) {
goto unlock;
}
ActivitySettingsValueHistory history;
settings_file_get(file, &m_info.settings_key, si... |
/*
* 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... | {
system_task_add_callback(prv_reset_kernel_bg_cb, NULL);
} |
static void prv_handle_firmware_complete_msg(void) {
uint32_t timeout = 3000;
// Wait 3 seconds before rebooting so there is time to show the update complete screen
PBL_LOG(LOG_LEVEL_ALWAYS, "Delaying reset by 3s so the UI can update...");
TimerID timer = new_timer_create(); // Don't bother cleaning up this... |
/! @note This only supports odd numbers for stroke_width - even numbers will be rounded up.
//! Minimal supported stroke_width is 3
T_STATIC void graphics_circle_draw_stroked_non_aa(GContext* ctx, GPoint p, uint16_t radius,
uint8_t stroke_width) {
graphics_circle_quad... | {
int f = 1 - radius;
int ddF_x = 1;
int ddF_y = -2 * radius;
int x = 0;
uint16_t y = radius;
while (x < y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
// bottom
if (section & GCornersBottom) {
prv_fill_horizontal_line(ct... |
MOCKABLE void graphics_circle_fill_non_aa(GContext* ctx, GPoint p, uint16_t radius) {
prv_fill_horizontal_line(ctx, GPoint(p.x - radius, p.y), 2 * radius + 1);
graphics_fill_half_circle(ctx, p.x, p.y, radius, GCornersAll);
}
#if PBL_COLOR
MOCKABLE void graphics_internal_circle_quadrant_fill_aa(GContext* ctx, GPo... |
/*
* 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(bitmap, GET_PBI_NAME(2))) | ;
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(4)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_... |
/*
* 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... | (i * 0x11111111) | ;
delay_ms(200);
}
for (uint32_t i = 0; i < 8; ++i) {
for (uint32_t j = 1; j <= 0xf; ++j) {
display_error_code(j << (i * 4));
delay_ms(200);
}
}
display_error_code(0x01234567);
delay_ms(200);
display_error_code(0x89abcdef);
delay_ms(200);
display_error_c... |
AlertMaskAllOn);
}
void test_alerts__cleanup(void) {
}
// Tests
/////////////////////////////////
void test_alerts__enabled(void) {
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
// Should allow all notifications to go through
cl_assert(alerts_should_notify_for_type(AlertMo... | (AlertPhoneCall) | );
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(alerts_should_enable_backlight_for_type(AlertPhoneCall));
cl_assert(alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_vibrate_for_type(AlertMobile));
alerts_set_... |
),
.type = object_type,
.cookie = htonl(1),
};
prv_receive_data(s_session, (const uint8_t *) &init_msg, sizeof(init_msg));
}
static void prv_receive_init_cookie(uint32_t total_size, PutBytesObjectType object_type,
uint32_t cookie) {
InitRequest init_msg = (InitRequest)... | (s_last_response_cookie, chunk, sizeof(chunk)) | ;
prv_process_and_reset_test_counters();
prv_receive_commit(s_last_response_cookie, EXPECTED_CRC);
prv_process_and_reset_test_counters();
prv_receive_install(s_last_response_cookie);
}
// Tests
///////////////////////////////////////////////////////////
static void prv_system_msg_sent_callback(uint16_t endp... |
/*
* 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_print("failed to write address ") | ;
dbgserial_print_hex(address);
dbgserial_putstr("");
FLASH_Lock();
return false;
}
if (progress_callback && i % 128 == 0) {
progress_callback(i/128, length/128, progress_context);
}
}
FLASH_Lock();
return true;
}
uint32_t system_flash_read(uint32_t address) {
uint32_t... |
(void*)&expected_value, sizeof(bool));
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Tests
void test_do_not_disturb__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(false);
rtc_set_time(s_thursday_00_00);
alerts_... | (do_not_disturb_is_active() == true) | ;
cl_assert(do_not_disturb_is_manually_enabled() == false);
cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == true);
cl_assert(do_not_disturb_is_smart_dnd_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == true);
// Enabling Smart DND
do_not_disturb_set_manually_... |
G, "All day? %s", node->all_day ? "True": "False");
PBL_LOG(LOG_LEVEL_DEBUG, "Address %p", node);
node = (TimelineNode *)node->node.next;
}
}
#endif
// dummy iterator that always returns false
// Useful for when there aren't any items in pindb
// but we don't want an invalid iterator.
static bool prv_iter_du... | (LOG_LEVEL_DEBUG, "Starting to build list.") | ;
status_t rv = pin_db_each(prv_each, timeline);
prv_prune_ordered_timeline_list(timeline);
prv_set_indices(*timeline);
PBL_LOG(LOG_LEVEL_DEBUG, "Finished building list.");
#ifdef TIMELINE_SERVICE_DEBUG
prv_debug_print_pins(*timeline);
#endif
return rv;
}
bool timeline_add(TimelineItem *item) {
return (S... |
E(45), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_color_set_center_45_transparent.Xbit.pbi"));
}
void test_graphics_draw_rotated_bitmap__offset_color(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_... | (&ctx->dest_bitmap, "draw_rotated_bitmap_stamp_0deg.Xbit.pbi") | );
// Top-left corner rotation point, Angle 45
setup_test_rotate_bitmap(ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(ctx, test_image,
GPoint(71, 71), DEG_TO_TRIGANGLE(45), center);
cl_check(gbitmap_pbi_eq(&ctx->dest_bitmap, "dra... |
ime_info->utc_time_delta);
// Need to re-build the list somewhere else
ListNode *newlist = NULL;
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... | (s_list_mutex) | ;
count = list_count(s_scheduled_jobs);
mutex_unlock(s_list_mutex);
return count;
}
void cron_service_wakeup(void) {
prv_timer_callback(NULL);
}
// ---------------------------------------------------------------------------------------
// The brains.
typedef enum {
CronAssignMode_LocalEpoch, // 'any' uses l... |
was not expected");
} else {
PBL_LOG(LOG_LEVEL_WARNING, "Received session setup result for non-app session when an app "
"session result was expected");
}
prv_send_event(VoiceEventTypeSessionSetup, VoiceStatusErrorGeneric, NULL);
goto done;
}
has_error = false;
done:
if (has_... | (result, session_id, app_initiated, app_uuid) | ) {
goto unlock;
}
// Calculate size of string
size_t sentence_size = 0;
transcription_iterate_words(transcription->sentences[0].words,
transcription->sentences[0].word_count, prv_get_string_size_cb, &sentence_size);
const size_t event_size = sizeof(PebbleVoiceServiceEventData) + sentence_size;
... |
"", "555-555-5555");
}
void test_phone_pp__incoming_no_number(void) {
uint8_t pp_msg[] = {0x04, 0x1a, 0xd4, 0x77, 0x08,
0x00,
0x06, 0x42, 0x6F, 0x62, 0x62, 0x79, 0x00}; // "Bobby"
phone_protocol_msg_callback(s_session, pp_msg, sizeof(pp_msg));
fake_system_task_ca... | phone_protocol_msg_callback(s_session, pp_msg, sizeof(pp_msg)) | ;
fake_system_task_callbacks_invoke_pending();
prv_assert_last_event(PhoneEventType_Start, true /* check_cookie */, false /* check_name_number */,
NULL, NULL);
}
void test_phone_pp__get_phone_call_state_response_two_started_calls(void) {
pp_get_phone_state_set_enabled(true);
uint8_t pp_... |
/*
* 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... | (GColorLightGray, GColorWhite) | );
peek_layer_play(peek_layer);
layer_add_child(&window->layer, &peek_layer->layer);
// give it a chance to animate
const uint32_t factory_reset_start_delay = 100;
app_timer_register(PEEK_LAYER_UNFOLD_DURATION + factory_reset_start_delay,
start_factory_reset, NULL);
}
//! Wipe registry ... |
/*
* 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... | {
// Drop this event if there's no handler registered
if (state->handlers.availability_did_change) {
const SmartstrapServiceId service_id = event.service_id;
const bool is_available = (event.result == SmartstrapResultOk);
state->handlers.availability_did_change(service_id, is_available);
}... | else {
// All events other than SmartstrapConnectionEvent contain the attribute pointer
SmartstrapAttribute *attr = event.attribute;
PBL_ASSERTN(attr);
if ((event.type == SmartstrapDataSentEvent) && state->handlers.did_write) {
state->handlers.did_write(attr, event.result);
} else if ((event.... |
eader = {
.id = i3,
.type = TimelineItemTypeNotification,
.status = 0,
.ancs_uid = 0,
.layout = LayoutIdGeneric,
.timestamp = 0x53f0dda7,
},
.attr_list = {
.num_attributes = 1,
.attributes = &attributes[2],
},
.action_group = {
.num_actions = 2,
... | (r.allocated_buffer) | |
/*
* 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... | delay_us(7) | ;
}
static void prv_disable_chip_select(void) {
// delay while last byte is emitted by the SPI peripheral
delay_us(7);
GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_RESET);
// hold time > 1us
// produce a delay 4ms
delay_us(4);
}
//! These functions needed to be called around any commands that
//! are sent ... |
0,
container_bounds.size.w, container_bounds.size.h);
layer_set_hidden(&s_phone_ui_data->action_bar.layer, true /* hide */);
layer_set_bounds(&s_phone_ui_data->core_ui_container, &onscreen);
#endif
}
//! Action bar setup functions
static void prv_set_action_bar_icon(ButtonId button,... | {
s_phone_ui_data->up_action = prv_sms_reply_click_handler;
up_icon = RESOURCE_ID_ACTION_BAR_ICON_SMS;
} | else {
s_phone_ui_data->select_action = prv_sms_reply_click_handler;
select_icon = RESOURCE_ID_ACTION_BAR_ICON_SMS;
}
}
if (actions & PhoneCallActions_Decline) {
s_phone_ui_data->down_action = prv_decline_click_handler;
down_icon = RESOURCE_ID_ACTION_BAR_ICON_X;
}
pr... |
.w, layer.frame.size.h);
cl_assert(max_loops > 0);
max_loops--;
}
// This should return a NULL context now if the animation got destroyed
cl_assert(animation_get_context(h) == NULL);
// Make sure no animations exist
cl_assert_equal_i(prv_count_animations(), 0);
#endif
}
// -----------------------... | (&s_stopped_handler_calls, h) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, h), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, h), 1);
// Make sure the frame reached the "to" state
cl_assert_equal_i(prv_last_update_distance(h), ANIMATION_NORMALIZED_MAX);
// This should return NULL ... |
BLECharacteristic *characteristics, uint8_t num_characteristics) {
ams_invalidate_all_references();
}
void ams_handle_service_discovered(BLECharacteristic *characteristics) {
if (!s_ams_client) {
return;
}
BLE_LOG_DEBUG("In AMS service discovery CB");
PBL_ASSERTN(characteristics);
if (s_ams_client->c... | prv_set_connected(false) | ;
kernel_free(s_ams_client);
s_ams_client = NULL;
}
static void prv_send_command_kernel_main_task_cb(void *data) {
if (!s_ams_client) {
return;
}
const AMSRemoteCommandID command_id = (uintptr_t)data;
BLECharacteristic characteristic = s_ams_client->characteristics[AMSCharacteristicRemoteCommand];
B... |
sActive) {
// Already inactive
return true;
}
PebbleTask task = (PebbleTask)(uintptr_t)data;
// System data logging sessions are responsible for killing themselves
Uuid system_uuid = UUID_SYSTEM;
if (!uuid_equal(&session->app_uuid, &system_uuid)) {
if (task == session->task) {
PBL_LOG_D(LO... | kernel_malloc_check(buf_size) | ;
logging_session->data->buffer_in_kernel_heap = true;
}
logging_session->data->buffer_storage = buffer;
shared_circular_buffer_init(&logging_session->data->buffer,
logging_session->data->buffer_storage, buf_size);
shared_circular_buffer_add_client(&logg... |
g <= 0) {
prv_attempt_swap(swap_layer, direction, false /* to_top */);
swap_layer->swap_delay_remaining = MESSAGE_SWAP_DELAY;
} else {
swap_layer->swap_delay_remaining--;
}
}
T_STATIC void prv_attempt_scroll(SwapLayer *swap_layer, ScrollDirection direction,
bool is_repe... | prv_scroll_to_top(swap_layer) | |
e->process_type == two->process_type);
bool uuid = !memcmp(&one->uuid, &two->uuid, sizeof(Uuid));
bool name = !strcmp(one->name,two->name);
bool icon = (one->icon_resource_id == two->icon_resource_id);
return (id && type && visibility && process_type && uuid && name && icon);
}
// background counter
static co... | resource_storage_get_file_name(filename_buf, sizeof(filename_buf), 2) | ;
load_fixture_on_pfs(APP2_RESOURCES_FIXTURE_NAME, filename_buf);
}
void test_app_install_manager__cleanup(void) {
}
/*************************************
*************************************/
void test_app_install_manager__get_id_invalid_uuid(void) {
const Uuid made_up = {0x17, 0x17, 0x17, 0x17, 0x17, 0x1... |
CompositorTransitionDirection direction,
uint32_t duration,
bool collapse_starting_animation) {
// Flip the direction and dot colors if we aren't starting with a coll... | {
static const CompositorTransition s_impl = {
.init = prv_dot_transition_from_timeline_past_animation_init,
.update = prv_static_dot_transition_animation_update,
};
return &s_impl;
} | else {
static const CompositorTransition s_impl = {
.init = prv_dot_transition_to_timeline_past_animation_init,
.update = prv_static_dot_transition_animation_update,
};
return &s_impl;
}
}
}
const CompositorTransition* compositor_dot_transition_app_fetch_get(void) {
if (compo... |
uffer->bytes_written, bytes_written);
}
}
void test_content_indicator__configuring_should_configure(void) {
ContentIndicator content_indicator;
content_indicator_init(&content_indicator);
ContentIndicatorDirectionData *direction_data = content_indicator.direction_data;
// Test setting a dummy configuration ... | (content_indicator2->scroll_layer, &scroll_layer) | ;
cl_assert_equal_p(content_indicator2, content_indicator);
// Should retrieve a different content indicator for a different scroll layer
ScrollLayer scroll_layer2;
ContentIndicator *content_indicator3 = content_indicator_get_or_create_for_scroll_layer(
&scroll_layer2);
cl_assert(content_indicator3);
/... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | pbl_log(LOG_LEVEL_ERROR, __FILE_NAME__, __LINE__,
"System resources are missing or corrupt, time to sad watch") | |
0, 150, 0},
{ 0, 0x69, 1591, 150, 0},
{ 8, 0x79, 2427, 173, 0},
// 555: Local time: 03:26:00 AM
{ 31, 0x78, 3960, 150, 0},
{ 0, 0x68, 1169, 150, 0},
{ 0, 0x68, 0, 150, 0},
{ 0, 0x67, 7, 149, 0},
{ 0, 0x67, 0, 149, 0},
{ 0, 0x68, 1531, 149, 0},
{ 0, 0x68, 11, 149, 0},
{ 0, 0x6... | { 0, 0x17, 0, 151, 0},
{ 0, 0x17, 0, 151, 0},
{ 0, 0x17, 0, 151, 0},
{ 0, 0x17, 0, 151, 0},
{ 0, 0x17, 0, 151, 0},
{ 0, 0x17, 30, 151, 0},
{ 0, 0x18, 0, 151, 0},
{ 0, 0x18, 0, 151, 0},
{ 0, 0x18, 0, 151, 0},
{ 0, 0x18, 0, 151, 0},
{ 0, 0x18, 0, 151, 0},
{ 0, 0x18, 0, 151,... |
{ 0, 0x7f, 362, 151, 0},
{ 0, 0x40, 0, 151, 0},
{ 0, 0x40, 0, 151, 0},
{ 0, 0x40, 11, 151, 0},
{ 0, 0x40, 0, 151, 0},
// 720: Local time: 06:11:00 AM
{ 0, 0x40, 0, 151, 0},
{ 0, 0x40, 0, 151, 0},
{ 0, 0x40, 0, 151, 0},
{ 0, 0x40, 0, 151, 0},
{ 0, 0x40, 0, 151, 0},
{ 0, 0... |
on 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 in writing, software
* distributed under the License is distributed on an "AS ... | cl_assert(s_manager_state_change) | ;
cl_assert_equal_i(event_type, -1);
r->state = RecognizerState_Possible;
s_manager_state_change = false;
recognizer_transition_state(r, RecognizerState_Completed);
cl_assert_equal_i(r->state, RecognizerState_Completed);
cl_assert(s_manager_state_change);
cl_assert_equal_i(event_type, RecognizerEvent_Com... |
int prv_get_start_of_log_file(uint8_t log_file_id,
uint32_t *start_page_addr) {
uint8_t num_log_pages = 0;
uint8_t prev_chunk_id = 0;
uint32_t log_start_addr = FLASH_LOG_INVALID_ADDR;
for (uint32_t offset = 0; offset < LOG_REGION_SIZE; offset += LOG_PAGE_SIZE) {
uint32_t flash_addr = FLASH_REGION_DEBUG... | prv_get_next_log_file_id(prev_log_id) | ;
}
done: // we have allocated a region to be used
prv_allocate_page_for_use();
flash_logging_set_enabled(true);
}
//! Writes the log record header to flash and advances the
//! s_curr_state.offset_in_log_page field
//!
//! @param msg_length - the length of the message to be written
static void prv_write_flash_... |
one);
prv_send_notification((uint8_t *)&s_chunked_dict_part_one);
prv_send_notification((uint8_t *)&s_chunked_dict_part_one);
prv_send_notification((uint8_t *)&s_chunked_dict_part_one);
cl_assert_equal_i(s_num_requested_notif_attributes, 4 + 4);
cl_assert_equal_i(s_num_ds_notifications_received, 4 + 2*4);
c... | (s_num_requested_notif_attributes, 1) | ;
cl_assert_equal_i(s_num_ds_notifications_received, 2);
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 1);
}
void test_ancs__attribute_at_end(void) {
prv_send_notification((uint8_t *)&memory_with_attribute_id_at_end.attribute_data);
cl_assert_equal_i(s_num_requested_notif_at... |
BLECharacteristic characteristic,
BLESubscription subscription_type,
BLEGATTError error, bool kernel, bool app) {
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_BLE_GATT_CLIENT_EVENT);
cl_assert_eq... | (GATT_SERVICE_DISCOVERY_STATUS_SUCCESS,
TEST_GATT_CONNECTION_ID) | ;
}
static BLECharacteristic prv_get_indicatable_characteristic(void) {
// The Blood Pressure Service UUID:
Uuid service_uuid = bt_uuid_expand_16bit(0x1810);
BLEService service;
uint8_t num_copied = gatt_client_copy_service_refs_matching_uuid(&s_device, &service, 1,
... |
urrent_bpm = (hrm_event->bpm.quality == HRMQuality_OffWrist) ? 0
: hrm_event->bpm.bpm,
.resting_bpm = s_activity_state.hr.metrics.resting_bpm,
.quality = hrm_event->bpm.quality,
.is_filtered = false,
... | (file, &key, sizeof(key)) | |
(deep_sleep) {
snprintf(temp, sizeof(temp), " %dm\n", (int)(session->length_min));
} else {
time_t end_time = session->start_utc + (session->length_min * SECONDS_PER_MINUTE);
localtime_r(&end_time, &local_tm);
strftime(temp, sizeof(temp), "-%H:%M\n", &local_tm);
}
safe_strcat(data->... | activity_prefs_get_gender() | |
);
// It's possible the connection is gone in the mean time; this runs on KernelMain.
if (connection) {
bonding_id = connection->bonding_id;
}
bt_unlock();
// don't hold bt_lock while calling bt_persistent_storage_... because it accesses flash
if (bonding_id != BT_BONDING_ID_INVALID) {
bt_persisten... | client->handle_service_discovered(characteristics) | |
= radius;
top_rect_size_w -= radius;
}
if (corner_mask & GCornerBottomLeft) {
circle_func(ctx, GPoint(rect->origin.x + radius, rect->origin.y + rect->size.h - radius - 1),
radius, GCornerBottomLeft);
bottom_rect_origin_x += radius;
bottom_rect_size_w -= radius;
}
... | GPoint(rect->origin.x, rect->origin.y + rect->size.h - 1) | ;
const GPoint br = GPoint(rect->origin.x + rect->size.w - 1, rect->origin.y + rect->size.h - 1);
graphics_line_draw_stroked_aa(ctx, tl, tr, stroke_width);
graphics_line_draw_stroked_aa(ctx, tl, bl, stroke_width);
graphics_line_draw_stroked_aa(ctx, tr, br, stroke_width);
graphics_line_draw_stroked_aa(ctx, bl... |
b(result, false);
// start after end
result = prv_calculate_time_range(now - 100, now - 200, NULL);
cl_assert_equal_b(result, false);
}
void test_health__range_to_day_id_clamps_values(void) {
const time_t now = rtc_get_time();
bool result;
HealthServiceTimeRange range;
// clamps value that goes into t... | cl_assert_equal_i(values[1], 1000) | |
// Stubs / fakes
void event_service_client_subscribe(EventServiceInfo *info) {
cl_assert(info->type == PEBBLE_SMARTSTRAP_EVENT);
s_event_handler = info->handler;
}
void event_service_client_unsubscribe(EventServiceInfo *info) {
cl_assert(info->type == PEBBLE_SMARTSTRAP_EVENT);
s_event_handler = NULL;
}
bool... | assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, false)) | ;
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, true));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 100, false));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 100, true));
// smartstrap_attribute_read()
assert_result_invalid(app_smartstrap_attribute_re... |
_version_add_all_regions(bool revert) {
static unsigned int original_idx;
if (!revert) {
original_idx = s_next_region_idx;
s_next_region_idx = TOTAL_NUM_FLASH_REGIONS;
} else {
s_next_region_idx = original_idx;
}
s_ftl_size = 0;
for (unsigned int i = 0; i < s_next_region_idx; i++) {
s_ftl... | for (unsigned int idx = 0; (idx < s_next_region_idx) && (size != 0); idx++) {
curr_virt_offset_end += prv_region_size(idx);
if (offset < curr_virt_offset_end) {
uint32_t bytes = MIN(curr_virt_offset_end - offset, size);
if (operation == FTLRead) {
flash_read_bytes(
buffer, s_reg... |
}
void ftl_read(void *buffer, size_t size, uint32_t offset) {
prv_ftl_operation(buffer, size, offset, FTLRead);
}
void ftl_write(const void *buffer, size_t size, uint32_t offset) {
prv_ftl_operation((void *)buffer, size, offset, FTLWrite);
}
void ftl_erase_sector(uint32_t size, uint32_t offset) {
prv_ftl_oper... |
/*
* 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;
} |
return pb_encode_string(stream, encoder_arg->buffer, encoder_arg->len);
}
|
itle,
.icon_and_subtitle = {
.icon_resource_id = TIMELINE_RESOURCE_SCHEDULED_FLIGHT,
.template_string = "Glances baby!",
},
},
},
};
cl_assert_equal_i(app_glance_db_insert_glance(
&s_fake_app_nodes[LauncherMenuLayerTestApp_NoIcon].node.uuid, &glance), ... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
|
util.h>
#include <os/mutex.h>
#define SPRF_REGION_SIZE (FLASH_REGION_SHARED_PRF_STORAGE_END - \
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_NUM_PAGES (SPRF_REGION_SIZE / sizeof(SharedPRFData))
#define SPRF_PAGE_FLASH_ADDR(idx) (FLASH_REGION_SHARED_PRF_STORAGE_BEGIN + \
... | {
if (write_metadata) {
data->magic = SprfMagic_ValidEntry;
data->version = SPRF_CUR_VERSION;
}
flash_write_bytes((uint8_t *)data, prv_current_page_flash_addr(), sizeof(*data));
} |
}
static void prv_erase_region_and_save(SharedPRFData *data) {
flash_region_erase_optimal_range_no_watchdog(FLASH_REGION_SHARED_PRF_STORAGE_BEGIN,
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN,
FLASH_REGION_SHARED_PRF_STORAGE_END,... |
/*
* 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;
} |
void graphics_context_set_drawing_state(GContext *ctx, GDrawState draw_state) {
}
void window_schedule_render(struct Window *window) {
}
TimerID animation_service_test_get_timer_id(void);
// --------------------------------------------------------------------------------------
static void cl_assert_equal_point(co... |
lif ROBERT_SCREEN_RES
const GTextAlignment alignment = GTextAlignmentRight;
#elif SNOWY_SCREEN_RES
const GTextAlignment alignment = screen_is_obstructed ? GTextAlignmentRight: GTextAlignmentCenter;
bounds.origin.y += screen_is_obstructed ? 65 : 108; // steps text top offset
#elif SPALDING_SCREEN_RES
const GText... | GEdgeInsets(15) | ).size.h) / 2;
#endif
#if PBL_COLOR
const bool has_passed_goal = (data->current_steps > data->typical_steps);
const GColor fill_color = has_passed_goal ? GColorJaegerGreen : GColorVividCerulean;
const GColor text_color = has_passed_goal ? GColorJaegerGreen : GColorVividCerulean;
#if SNOWY_SCREEN_RES
GBitmap *s... |
void) {
const uint8_t chip_id = bma255_read_register(BMA255Register_BGW_CHIP_ID);
PBL_LOG(LOG_LEVEL_DEBUG, "Read BMA255 whoami byte 0x%"PRIx8", expecting 0x%"PRIx8,
chip_id, BMA255_CHIP_ID);
return (chip_id == BMA255_CHIP_ID);
}
static uint64_t prv_get_curr_system_time_ms(void) {
time_t time_s;
uin... | ("%2d: %"PRId16" %"PRId16" %"PRId16" %"PRIu32,
i, data[i].x, data[i].y, data[i].z, (uint32_t)data[i].timestamp_us) | ;
accel_cb_new_sample(&data[i]);
}
// clear of fifo overrun flag must happen after draining samples, also the samples available will
// get drained too!
if ((fifo_status & 0x80) && !s_fifo_overrun_detected) {
s_fifo_overrun_detected = true;
// We don't clear the interrupt here because you are only ... |
ute
if (state->steps_per_minute >= ACTIVITY_ACTIVE_MINUTE_MIN_STEPS) {
state->step_data.step_minutes++;
ACTIVITY_LOG_DEBUG("new step minutes: %"PRIu16"", state->step_data.step_minutes);
// The prior minute was the most recent active one
state->last_active_minute = time_util_minute_of_day_ad... | hr_util_get_hr_zone(hr_median) | ;
if (new_hr_zone != HRZone_Zone0 && state->hr.num_samples < ACTIVITY_MIN_NUM_SAMPLES_FOR_HR_ZONE) {
// There wasn't enough data in the past minute to give us confidence that
// the new HR zone will represents that minute, default to Zone0
new_hr_zone = HRZone_Zone0;
}
bool new_hr_elevated = hr_util... |
ActivitySession *sessions) {
}
void activity_algorithm_minute_handler(time_t utc_sec, AlgMinuteRecord *record_out) {
s_test_alg_state.last_sleep_utc = utc_sec;
record_out->data.base.orientation = s_test_alg_state.orientation;
}
bool activity_algorithm_dump_minute_data_to_log(void) ... | {
num_steps--;
} |
}
}
fake_accel_service_invoke_callbacks(accel_data, ALGORITHM_SAMPLING_RATE);
// Advance time
fake_rtc_increment_time(1);
fake_rtc_increment_ticks(configTICK_RATE_HZ);
// Is it time to call the minute callback?
utc_secs += 1;
if ((utc_secs % 60) == 0) {
fake_cron_job_fire... |
/*
* 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_sector_addresses) | -1;
}
bool system_flash_erase(uint32_t address, size_t length, SystemFlashProgressCb progress_callback,
void *progress_context) {
if (length == 0) {
// Nothing to do
return true;
}
int first_sector = prv_get_sector_num_for_address(address);
int last_sector = prv_get_sector_num_... |
etPriority(bus->hal->ev_irq_channel, I2C_IRQ_PRIORITY);
NVIC_SetPriority(bus->hal->er_irq_channel, I2C_IRQ_PRIORITY);
NVIC_EnableIRQ(bus->hal->ev_irq_channel);
NVIC_EnableIRQ(bus->hal->er_irq_channel);
prv_i2c_deinit(bus);
}
static void prv_i2c_init(I2C_TypeDef *i2c, TIMINGR timingr) {
// Soft reset of the s... | {
transfer->state = I2CTransferState_WriteData;
} |
}
}
static void prv_enable_interrupts(I2CBus *bus) {
bus->hal->i2c->CR1 |= I2C_CR1_ERRIE | // Enable error interrupt
I2C_CR1_NACKIE | // Enable NACK interrupt
I2C_CR1_TCIE | // Enable transfer complete interrupt
I2C_CR1_TXIE; // Enable trans... |
riting, 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 "util/misc.h"
#include "drivers/i2c.h"
... | (pin_config.gpio, pin_config.gpio_pin_source, pin_config.gpio_af) | ;
gpio_release(pin_config.gpio);
}
//! Configure bus pin as input
//! Lock bus and peripheral config access before use
static void bus_pin_cfg_input(AfConfig pin_config) {
gpio_use(pin_config.gpio);
// Configure pin as high impedance input
GPIO_InitTypeDef gpio_init_struct;
gpio_init_struct.GPIO_Pin = pin_... |
window.h"
#include "stubs_unobstructed_area.h"
///////////////////////////////////////////////////////////
// Fakes
#include "fake_gbitmap_get_data_row.h"
static FrameBuffer *fb = NULL;
// Setup
void test_graphics_draw_text_${BIT_DEPTH_NAME}__initialize(void) {
s_fake_data_row_handling = false;
fb = malloc(sizeo... | graphics_context_set_text_color(ctx, GColorBlack) | ;
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, -18, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_across_ny_second_line(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_... |
peed_metric) {
data->pace_speed_metric = metric_type;
prv_update_scrollable_metrics(data);
}
break;
}
case SPORTS_UNITS_KEY:
break;
case SPORTS_HRM_KEY:
{
// This returns if the SPORTS_HRM_KEY value has not changed from the default 0 value
if (new_tuple->val... | {
SportsAppData *data = app_state_get_user_data();
const Tuple *metric_tuple = app_sync_get(&data->sync, SPORTS_UNITS_KEY);
uint8_t is_metric = 1;
if (metric_tuple != NULL) {
is_metric = MIN(metric_tuple->value->uint8, 1);
}
if (is_metric) {
return km_string;
} else {
return miles_string;
... |
static char *prv_get_custom_metric_label_string(void) {
SportsAppData *data = app_state_get_user_data();
return data->custom_label_string;
}
static void prv_init(void) {
SportsAppData *data = app_zalloc_check(sizeof(SportsAppData));
app_state_set_user_data(data);
app_message_open(114, 16);
// Sync setu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.