prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_state_get_window_stack() | ;
} else {
// Bluetooth disconnection events are always displayed at maximum priority.
window_stack = modal_manager_get_window_stack(ModalPriorityCritical);
}
simple_dialog_push(&bt_dialog->dialog, window_stack);
}
BtConnDialog *bt_conn_dialog_create(void) {
BtConnDialog *bt_dialog = applib_malloc(size... |
) == AlertMaskAllOn);
alerts_set_mask(AlertMaskAllOnLegacy);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
}
void test_alerts__dnd_interruptions(void) {
s_dnd_active = true;
alerts_set_dnd_mask(AlertMaskAllOff);
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_should_notify_for_type(AlertMobile));
... | (!alerts_should_enable_backlight_for_type(AlertOther)) | |
// Minimum digits output
snprintf(dstbuf, 256, "There are %.2i lights, %.2i", 4, -4);
cl_assert_equal_s(dstbuf, "There are 04 lights, -04");
// Minimum digits output (zero digits)
snprintf(dstbuf, 256, "%.0izero%.0i", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified dig... | cl_assert_equal_s(dstbuf, "zero1") | |
t_for_current_task(), size, saved_lr);
}
void *task_zalloc_check(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap = task_heap_get_for_current_task();
void *mem = heap_zalloc(heap, bytes, saved_lr);
if (!mem && bytes != 0) {
PBL_CROAK_OOM(bytes, saved_lr, heap);
}... | {
PBL_CROAK_OOM(bytes, saved_lr, heap);
} |
return mem;
}
void *kernel_realloc(void *ptr, size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_realloc(kernel_heap_get(), ptr, bytes, saved_lr);
}
void *kernel_zalloc(size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_zalloc(k... |
);
prv_spi_transmit_flush_blocking(slave->spi_bus);
}
}
void spi_ll_slave_burst_read_write(const SPISlavePort *slave,
const void *out,
void *in,
size_t len) {
PBL_ASSERTN(slave->slave_state->initialized);
... | PBL_ASSERTN(slave->slave_state->acquired) | |
rame. This byte could be the last byte we receive
// (making it the checksum byte), so we always keep a 1 byte temporary buffer before storing the
// byte in the MBuf. This avoids us potentially overrunning a conservatively sized payload buffer;
if (s_read_info.length > 0) {
// copy the previous byte from the... | smartstrap_fsm_state_get() | |
ransform_list(KinoReelTransformData *data) {
KinoReel *reel = prv_get_current_reel(data);
GDrawCommandList *source_list = kino_reel_get_gdraw_command_list(reel);
GDrawCommandList *list = prv_get_or_create_list_copy(data, source_list);
if (!list) {
return;
}
if (!gdraw_command_list_copy(list, gdraw_comma... | (data, ctx, offset, processor) | |
LayoutNodeType_TextDynamic : LayoutNodeType_Text,
.update = prv_peek_time_text_update,
.buffer_size = ATTRIBUTE_SUBTITLE_MAX_LEN,
.text.style = LayoutContentSizeDefault,
.text.style_font = TextStyleFont_PinSubtitle,
.text.alignment = ToLayoutTextAlignment(TIMELINE_LAYER_TEXT_ALIGNMENT),
... | PBL_IF_ROUND_ELSE(30, 20) | ;
}
}
static void prv_get_card_view_bounds(TimelineLayout *layout, GRect *box_out) {
const GRect *frame = &((Layer *)layout)->frame;
*box_out = GRect(TIMELINE_CARD_MARGIN, 0, frame->size.w - 2 * TIMELINE_CARD_MARGIN,
TIMELINE_MAX_BOX_HEIGHT);
}
static void prv_render_view(TimelineLayout *layo... |
3 to pulse VCOM every second to avoid damage to the display
void prv_setup_pulse_vcom(void) {
periph_config_enable(RCC_APB1PeriphClockCmd, RCC_APB1Periph_TIM3);
// Standard peripheral functions are too big so toggle the registers manually:
// Scale timer to roll over once per second
TIM3->CR1 = TIM_CounterMode... | (prv_reverse_bits(168 - line_addr)) | ;
for (int i = DISP_LINE_BYTES - 1; i >= 0; --i) {
prv_display_write_byte(line[i]);
}
prv_display_write_byte(0x00);
}
static void prv_display_end_write(void) {
prv_display_write_byte(0x00);
prv_disable_display_access();
}
// Round a bit offset to a byte offset
static unsigned prv_round_to_byte(unsig... |
s_graphics_draw_text.last_call.draw_text.box);
}
void test_rocky_api_graphics__fill_text_coordinates(void) {
prv_global_init_and_set_ctx();
EXECUTE_SCRIPT("ctx.fillText('some text', 0, 1.5);");
cl_assert_equal_rect((GRect(0, 2, large_int, large_int)),
s_graphics_draw_... | ("ctx.font = 'unknown';\n") | ;
cl_assert_equal_p((GFont)-1, s_rocky_text_state.font);
cl_assert_equal_i(1, s_fonts_get_system_font.call_count);
EXECUTE_SCRIPT("ctx.font = '14px bold Gothic';\n");
cl_assert_equal_i(2, s_fonts_get_system_font.call_count);
cl_assert_equal_p(FONT_KEY_GOTHIC_14_BOLD, s_fonts_get_system_font.last_call.font_ke... |
ll-caps the subtitle in the card view on rectangular displays
bool all_caps_desired = PBL_IF_RECT_ELSE(true, false);
bool need_to_all_caps_string = false;
// First, try to extract an AlarmKind from the pin to request a string with the desired
// capitalization
Attribute *alarm_kind_attribute = attribute_find... | {
AlarmLayout *layout = task_zalloc_check(sizeof(AlarmLayout));
static const TimelineLayoutImpl s_timeline_layout_impl = {
.attributes = { AttributeIdTitle, AttributeIdSubtitle },
.default_colors = { { .argb = GColorBlackARGB8 },
{ .argb = GColorClearARGB8 },
... |
#else
LayoutLayer *alarm_layout_create(const LayoutLayerConfig *config) { return NULL; }
bool alarm_layout_verify(bool existing_attributes[]) { return false; }
#endif
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | while (SPI_I2S_GetFlagStatus(BMA255_SPI, SPI_I2S_FLAG_RXNE) == RESET) {} |
// Return the byte
return SPI_I2S_ReceiveData(BMA255_SPI);
}
void bma255_send_byte(uint8_t byte) {
// Ensure that there are no other write operations in progress
while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET) {}
// Send the byte on the SPI bus
SPI_I2S_SendData(BMA255_SPI, byte);
}
//! Set... |
a soft reset of the bus
//! Always lock the bus before reset
static void prv_bus_reset(I2CBus *bus) {
prv_bus_disable(bus);
prv_bus_enable(bus);
}
/*---------------INIT/USE/RELEASE/RESET FUNCTIONS----------------------*/
void i2c_init(I2CBus *bus) {
PBL_ASSERTN(bus);
*bus->state = (I2CBusState) {};
i2c_h... | i2c_hal_is_busy(bus) | |
/*
* 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... | (new_reel) | ;
if (duration > start) {
kino_layer_play_section(&layout->icon_layer, start, duration);
}
}
static void prv_pin_to_card_second_half_stopped(KinoLayer *layer, bool finished, void *context) {
TimelineLayout *layout = context;
KinoReel *new_reel = kino_reel_create_with_resource_system(layout->icon_res_info.r... |
ache 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 in writing, software
* distributed under the License is dis... | {
return s_display_update_in_progress;
} | |
GAPLEConnection **connection_out);
extern BLECharacteristic gatt_client_descriptor_get_characteristic_and_connection(
BLEDescriptor descriptor_ref,
GAPLEConnection **connect... | (write_space >= required_length) | ) {
if (UNLIKELY(did_stall)) {
PBL_LOG(LOG_LEVEL_DEBUG, "GATT notification stalled for %d ms...",
(int)(timeout_ms - ticks_to_milliseconds(timeout_end_ticks - rtc_get_ticks())));
analytics_inc(ANALYTICS_DEVICE_METRIC_BLE_GATT_STALLED_NOTIFICATIONS_COUNT,
Analy... |
/*
* 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... | (&l, &GRect(10, 20, 100, 600)) | ;
cl_assert_equal_grect(l.bounds, GRect(1, 1, 200, 599));
// act as 2.x once bounds.size isn't same as frame.size
layer_set_bounds(&l, &GRect(0, 0, 150, 600));
layer_set_frame(&l, &GRect(10, 20, 100, 700));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 150, 700));
}
|
__property_int16(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation *prop_h;
int16_t value = 0;
int16_t start_value = 0, end_value = 100;
const int duration = 200;
const int delay = 25;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
stat... | (100, 200) | ;
prop_h = property_animation_create(&implementation, &value, &start_value, &end_value);
Animation *h = property_animation_get_animation(prop_h);
void *context = &value;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
animation_set_delay(h, delay);
animation_set_auto_des... |
ert_equal_b(false, app_install_has_worker(menu_layer_id));
cl_assert_equal_b(false, app_install_has_worker(CRAZY_ID));
}
void test_app_install_manager__is_hidden(void) {
cl_assert_equal_b(false, app_install_is_hidden(tictoc_id));
cl_assert_equal_b(false, app_install_is_hidden(music_id));
cl_assert_equal_b(tru... | (true == app_install_get_entry_for_install_id(sports_id, &entry)) | |
layout = LayoutIdTest,
}
}
};
// all day item
static TimelineItem s_all_day_items[] = {
{
.header = {
.id = {0x01},
.parent_id = {0},
.timestamp = 1421020800, // midnight jan 12, 2015 UTC
.duration = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.all_day = 1... | cl_assert(iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[2].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.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... | (1478397600) | ;
fake_spi_flash_init(0, 0x1000000);
fake_event_init();
pfs_init(false);
app_cache_init();
app_cache_flush();
}
void test_app_cache__cleanup(void) {
fake_system_task_callbacks_cleanup();
s_test_id_ql_up = 0;
s_test_id_ql_down = 0;
s_test_id_watchface = 0;
s_test_id_worker = 0;
}
/****************... |
from token + 1 to skip the '*' at the front
strncpy(state->test_entry.name, token + 1, sizeof(state->test_entry.name));
printf("\nParsing function samples: %s", state->test_entry.name);
continue;
}
// Look for and parse the expected values
if (strcmp(token, "//>") == 0) {
token = s... | (token, "TEST_DEEP") | == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.deep.value);
} else if (strcmp(token, "TEST_DEEP_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.deep.min);
} else if (strcmp(token, "TEST_DEEP_MAX") == 0) {
sscanf(token + strlen(token... |
;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_origin_color_set_0.Xbit.pbi"));
// Top-left corner rotation point, Angle 45
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpSet);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
... | (&ctx, test_image_color,
GPoint(59, 30), DEG_TO_TRIGANGLE(2), GPoint(72, 84)) | |
ht.h"
#include "board/board.h"
#include "drivers/ambient_light.h"
#include "drivers/backlight.h"
#include "kernel/low_power.h"
#include "services/common/analytics/analytics.h"
#include "services/common/battery/battery_monitor.h"
#include "services/common/new_timer/new_timer.h"
#include "syscall/syscall_internal.h"
#in... | analytics_inc(ANALYTICS_APP_METRIC_BACKLIGHT_ON_COUNT, AnalyticsClient_App) | ;
analytics_inc(ANALYTICS_DEVICE_METRIC_BACKLIGHT_ON_COUNT, AnalyticsClient_System);
}
if (new_brightness <= HALF_BRIGHTNESS && s_current_brightness > HALF_BRIGHTNESS) {
// getting dimmer and have now transitioned past half brightness
analytics_stopwatch_stop(ANALYTICS_APP_METRIC_BACKLIGHT_ON_TIME);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (APP_GLANCE_DB_MAX_USED_SIZE <= SETTINGS_FILE_SIZE, "AppGlanceDB is too small!") | ;
static struct {
SettingsFile settings_file;
PebbleMutex *mutex;
} s_app_glance_db;
//////////////////////////////////////////
// Slice Type Implementation Definition
//////////////////////////////////////////
//! Return true if the type-specific serialized slice's attribute list is valid. You don't have to
//!... |
_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertPhoneCall));
s_dnd_active = true;
alerts_set_dnd_mask(AlertMaskPhoneCalls);
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
cl_assert(alerts_sho... | (AlertOther) | );
s_dnd_active = false;
alerts_set_mask(AlertMaskAllOn);
alerts_set_dnd_mask(AlertMaskAllOff);
cl_assert(alerts_should_notify_for_type(AlertPhoneCall));
cl_assert(alerts_should_vibrate_for_type(AlertPhoneCall));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION... |
/*
* 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... | (
(ListNode *)s_connections, prv_connection_by_idx_list_filter_cb,
(void *)(uintptr_t)conn_idx) | ;
}
prv_unlock();
return connection;
}
Connection *connection_by_idx_check(uint16_t conn_idx) {
Connection *connection;
prv_lock();
{
connection = connection_by_idx(conn_idx);
PBL_ASSERTN(connection);
}
prv_unlock();
return connection;
}
static bool prv_connection_by_address_list_filter_cb(L... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | persist_service_lock_and_get_store(
&sys_process_manager_get_current_process_md()->uuid) | |
/*
* 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... | (qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)) | |
"clar.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
///////////////////////////////////////////////////////////
// Stubs
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_app_state.h"
#include "stubs_fonts.h"
#include "stubs_graphics_context.h"
#include "stubs... | cl_assert(*word_iter_state.current.end == '\n') | ;
cl_assert(0 == word_iter_state.current.width_px);
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == '\n');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.curren... |
list, AttributeIdShortTitle);
cl_assert(title);
cl_assert_equal_s(title->cstring, "Title");
Attribute *mute = attribute_find(¬if_prefs->attr_list, AttributeIdMuteDayOfWeek);
cl_assert(mute);
cl_assert_equal_i(mute->uint8, 0x1F);
Attribute *name = attribute_find(¬if_prefs->attr_list, AttributeIdAppName... | cl_assert(!is_dirty) | ;
dirty_list = ios_notif_pref_db_get_dirty_list();
cl_assert(!dirty_list);
}
|
ib/graphics/graphics_line.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/framebuffer.h"
#include "applib/ui/animation.h"
#include "applib/ui/animation_timing.h"
#include "applib/ui/animation_interpolate.h"
#include "applib/graphics/gdraw_command_transforms.h"
#include "util.h"
#include "test_graphic... | (y, -255 + -255) | ;
}
void test_gdraw_command_transforms__int_scale_to_scale_overflow(void) {
InterpolateInt64Function interp = prv_default_interpolate;
int y = prv_int_scale_and_translate_to(181, 1, 1, 181, 0, 0, ANIMATION_NORMALIZED_MAX,
interp);
cl_assert_equal_i(y, 181 * 181);
}
void ... |
-----------------------------
static void steps_down_long_click_handler(ClickRecognizerRef recognizer, void *context) {
HealthAPITestAppData *data = (HealthAPITestAppData *)context;
window_stack_push(data->debug_window, true /* Animated */);
}
// -------------------------------------------------------------------... | (ctx, GColorJaegerGreen) | ;
graphics_fill_radial(ctx, bounds, GOvalScaleModeFitCircle, 15, 0, TRIG_MAX_ANGLE * percent / 100);
}
// -------------------------------------------------------------------------------
static void handle_battery(BatteryChargeState charge_state) {
layer_mark_dirty(window_get_root_layer(s_data->steps_window));
}
... |
int32_t cosine = cos_lookup(angle);
int32_t sine = sin_lookup(angle);
t_c = GTransform(GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO),
GTransformNumberFromNumber(-(float)sine / TRIG_MAX_RATIO),
GTransformNumberFromNumber((float)sine / TRIG_MAX_RATIO),
... | gtransform_translate_number(&t_new, &t1, 10, 200) | |
missions and
* limitations under the License.
*/
#include "applib/graphics/gtypes.h"
#include "clar.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
#include "stubs_passert.h"
#include "stubs_process_manager.h"
void test_graphics_colors__black(void) {
cl_assert(GColorBlack.r == 0b00);
cl_assert(GColorBl... | cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_grayscale(GColorWhite).argb) | ;
cl_assert_equal_i(GColorBlackARGB8, gcolor_get_grayscale(GColorBlack).argb);
cl_assert_equal_i(GColorLightGrayARGB8, gcolor_get_grayscale(GColorLightGray).argb);
cl_assert_equal_i(GColorDarkGrayARGB8, gcolor_get_grayscale(GColorDarkGray).argb);
cl_assert_equal_i(GColorWhiteARGB8, gcolor_get_grayscale(GColorYe... |
/*
* 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... | comm_session_get_by_type(CommSessionTypeApp) | ;
}
void comm_session_close(CommSession *session, CommSessionCloseReason reason) {
cl_assert(list_contains((const ListNode *) s_session_head, &session->node));
if (session->temp_write_buffer) {
kernel_free(session->temp_write_buffer);
}
list_remove(&session->node, (ListNode **) &s_session_head, NULL);
ke... |
bus)) {
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for bus %s to become non-busy", bus->name);
return false;
}
}
return true;
}
//! Set up and start a transfer to a bus, wait for it to finish and clean up after the transfer
//! has completed
static bool prv_do_transfer(I2CBus *bus, TransferDirect... | PBL_ASSERTN(result_buffer) | ;
// Do transfer locks the bus
bool result = prv_do_transfer(slave->bus, Read, slave->address, register_address_start, read_size,
result_buffer, SendRegisterAddress);
if (!result) {
PBL_LOG(LOG_LEVEL_ERROR, "Read failed on bus %s", slave->bus->name);
}
return result;
}
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... | for (int i = cl->level; i > 0; --i) {
p.x = xpos + (cl->crumbs_x_increment / i);
graphics_context_set_fill_color(ctx, cl->fg_color);
graphics_fill_circle(ctx, p, crumb_radius);
p.y += crumb_spacing;
} |
}
static void prv_crumbs_layer_update_proc_round(Layer *layer, GContext *ctx) {
CrumbsLayer *cl = (CrumbsLayer *)layer;
graphics_context_set_fill_color(ctx, cl->bg_color);
// TODO: remove stroke color again, once it's been fixed in fill_radial
graphics_context_set_stroke_color(ctx, cl->bg_color);
// com... |
} else if (*prev_x < new_x) {
src_x = new_x;
dst_x1 = 0;
dst_x2 = src_x - 1;
}
*prev_x = new_x;
if (dst_x1 > dst_x2) {
return;
}
GBitmap *fb = graphics_capture_frame_buffer(ctx);
if (!fb) {
return;
}
prv_replicate_column_row_raw(fb, src_x, dst_x1, dst_x2);
graphics_release_f... | {
const uint8_t fill_byte = delta_neg ? left_pixel[num_pix_data_row - 1] :
left_pixel[0];
memset(left_pixel, fill_byte, num_pix_data_row);
} |
break;
}
uint8_t *const from = delta_neg ? right_pixel : left_pixel;
uint8_t *const to = delta_neg ? left_pixel : right_pixel;
uint8_t *const garbage_start = delta_neg ? left_pixel + pixels_to_move : left_pixel;
const uint8_t fill_byte = delta_neg ? right_pixel[pixels... |
480, -312},
{ 904, 528, -296},
{ 1000, 640, -456},
{ 976, 632, -408},
{ 1312, 576, -328},
{ 1272, 568, -352},
{ 1176, 616, -392},
{ 1464, 528, -264},
{ 1568, 440, -112},
{ 1408, 352, -104},
{ 1096, 304, -120},
{ 904, 272, -72},
{ 880, 248, -80},
// 37 seconds
{ 9... | // 42 seconds
{ 944, 720, -264},
{ 1032, 856, -488},
{ 976, 736, -400},
{ 1184, 616, -320},
{ 1264, 608, -304},
{ 1136, 640, -328},
{ 1392, 568, -280},
{ 1600, 472, -88},
{ 1536, 320, -176},
{ 1152, 256, -72},
{ 880, 272, -128},
{ 760, 240, -120},
{ 744, 216, -96}... |
{ 960, 272, -64},
{ 864, 248, -64},
{ 856, 184, -56},
{ 840, 160, -72},
{ 808, 104, -72},
{ 984, 16, -96},
{ 952, -64, -56},
{ 1232, 72, -240},
{ 1288, 48, -176},
// 45 seconds
{ 1040, -24, -392},
{ 1352, 0, -376},
{ 1344, 120, -280},
{ 1264, 472, -528},
{ 90... |
/*
* 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 (!pb_encode_varint(stream, encoder_arg->values[i])) {
return false;
} |
}
return true;
}
bool protobuf_log_util_encode_measurement_types(pb_ostream_t *stream, const pb_field_t *field,
void * const *arg) {
PLogTypesEncoderArg *encoder_arg = *(PLogTypesEncoderArg **)arg;
for (unsigned i = 0; i < encoder_arg->num_types; i++) {
if (... |
to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util/math_fixed.h"
#include ... | (num.fraction == 0) | ;
test_num = (int32_t)((float)0 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == 0);
cl_assert(num.fraction == 0);
test_num = (int32_t)((float)0.125 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.i... |
024 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 in writing, softwa... | (layout.max_used_size.h, 2 * FONT_HEIGHT) | ; // 2 lines - all that will completely fit in the box ("Jr\nWho-")
graphics_text_layout_get_max_used_size(&gcontext, "JR Whopper", font, box, GTextOverflowModeWordWrap, GTextAlignmentLeft, (void*)&layout);
cl_assert(layout.box.size.w == box.size.w);
cl_assert_equal_i(layout.max_used_size.w, 4 * HORIZ_ADVANCE_P... |
---------------------------------------------------------------------
// Test to make sure that the minute data file gets compacted correctly. If we write more than
// ALG_MINUTE_DATA_FILE_LEN worth of data to the sleep file, it's size should be capped at
// ALG_MINUTE_DATA_FILE_LEN and we should be able to successfull... | prv_assert_minute_data(&retrieve[i], &minute_data[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... | BT_DEVICE_ADDRESS_XPLODE_PTR(&addr->address) | );
return;
}
prv_gap_le_device_name_request(connection);
}
static void prv_handle_request_all_cb(Connection *connection, void *data) {
prv_gap_le_device_name_request(connection);
}
void gap_le_device_name_handle_request_all(void) {
connection_for_each(prv_handle_request_all_cb, NULL);
}
|
f (rail == PmicRail_LDO3) {
rail_control_reg = PmicRegisters_LDO3_CONFIG;
ref_count = &s_ldo3_ref_count;
} else {
WTF;
}
uint8_t register_value;
bool success = prv_read_register(rail_control_reg, ®ister_value);
if (!success) {
// Failed to read the current register value
return false;... | PBL_LOG(LOG_LEVEL_DEBUG, "Error reading max14690 WHOAMI byte") | ;
return false;
}
}
static void prv_set_pin_config(void) {
periph_config_acquire_lock();
// Initialize the GPIOs for the 4V5 & 6V6 rails
gpio_output_init(&BOARD_CONFIG_POWER.rail_4V5_ctrl, GPIO_OType_OD, GPIO_Speed_50MHz);
if (BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio) {
gpio_output_init(&BOARD_CONFIG_P... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&kino_layer->player) | ;
}
KinoPlayer *kino_layer_get_player(KinoLayer *kino_layer) {
return &kino_layer->player;
}
void kino_layer_set_alignment(KinoLayer *kino_layer, GAlign alignment) {
kino_layer->alignment = alignment;
layer_mark_dirty(&kino_layer->layer);
}
void kino_layer_set_background_color(KinoLayer *kino_layer, GColor col... |
ssions
CommSession *session;
bt_lock();
{
session = (CommSession *) list_find((ListNode *) s_session_head,
prv_find_session_is_system_filter,
(void *) (uintptr_t) type);
}
bt_unlock();
return session;
}
CommSession* comm_se... | if (session->is_send_next_call_pending) {
return;
} |
system_task_add_callback(prv_send_next_kernel_bg_cb, session);
session->is_send_next_call_pending = true;
}
bool prv_filter_by_transport_callback(ListNode *node, void *data) {
return (((CommSession *) node)->transport == data);
}
CommSession * prv_find_session_by_transport(Transport *transport) {
return (Com... |
i < num_sessions; i++) {
if (activity_sessions[i].type != ActivitySessionType_Sleep) {
continue;
}
if (*enter_utc == 0) {
*enter_utc = activity_sessions[i].start_utc;
}
time_t session_exit_utc = activity_sessions[i].start_utc
+ activity_sessions[i].length_mi... | {
static SettingsFile file = {};
return &file;
} |
void activity_private_settings_close(SettingsFile *file) {
return;
}
bool activity_get_step_averages(DayInWeek day_of_week, ActivityMetricAverages *averages) {
return false;
}
static time_t s_activation_time = 0;
time_t activity_prefs_get_activation_time(void) {
return s_activation_time;
}
static void prv_se... |
/*
* 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 (should_shutdown) {
enter_standby(RebootReasonCode_FactoryResetShutdown);
} else {
factory_reset_set_reason_and_reset();
} |
}
void factory_reset(bool should_shutdown) {
s_in_factory_reset = true;
prv_factory_reset_non_pfs_data();
// TODO: wipe the registry on tintin?
filesystem_regions_erase_all();
#if !defined(RECOVERY_FW)
// "First use" is part of the PRF image for Snowy
boot_bit_set(BOOT_BIT_FORCE_PRF);
#endif
prv_fac... |
*value_length_in_out = 0;
}
has_more = has_notification &&
prv_get_next_notification_header(client, &next_header);
}
unlock:
if (!has_more) {
s_is_notification_event_pending[client] = false;
}
if (has_more_out) {
*has_more_out = has_more;
}
prv_unlock... | if (subscription->pending_confirmation[c]) {
return true;
} |
}
return false;
}
static BLESubscription prv_prevailing_subscription_type(GATTClientSubscriptionNode *subscription) {
const BLESubscription orred = subscription->subscriptions[GAPLEClientApp] |
subscription->subscriptions[GAPLEClientKernel];
// Notifications wins over None and ... |
ontext_init(&ctx, fb);
layer_init(&layer, &GRect(0, 0, 32, 24));
layer_set_update_proc(&layer, &corners_all_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_corners_all.${BIT_DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &white_layer_update_callback);... | graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 6, GCornersAll) | |
esult == DICT_OK);
cl_assert(context.okay == true);
cl_assert(context.expected_size == size);
}
void test_dict__write_read(void) {
// Stack allocated buffer:
const uint8_t key_count = 10;
const uint32_t size = dict_calc_buffer_size(key_count,
sizeof(SOME_DATA),
... | case SOME_UINT8_KEY:
cl_assert(tuple->length == sizeof(uint8_t));
cl_assert(tuple->value->uint8 == 8);
uint8_found = true;
break;
case SOME_UINT16_KEY:
cl_assert(tuple->length == sizeof(uint16_t));
cl_assert(tuple->value->uint16 == 16);
uint16_found = ... |
cl_assert(data_found);
cl_assert(string_found);
cl_assert(uint8_found);
cl_assert(uint16_found);
cl_assert(uint32_found);
cl_assert(int8_found);
cl_assert(int16_found);
cl_assert(int32_found);
cl_assert(null_cstring_found);
cl_assert(empty_cstring_found);
}
void test_dict__out_of_storage(void) {
... |
reak;
default:
WTF;
}
this->stream->state->initialized = true;
prv_set_constant_config(this);
this->state->initialized = true;
}
// Transfer APIs
////////////////////////////////////////////////////////////////////////////////
static void prv_validate_memory(DMARequest *this, void *dst, const void... | (this->state->initialized) | ;
PBL_ASSERTN(this->state->transfer_type == DMARequestTransferType_None);
this->state->transfer_type = DMARequestTransferType_Direct;
this->state->direct_transfer_handler = handler;
this->state->context = context;
PBL_ASSERTN(!this->stream->state->current_request);
this->stream->state->current_request = t... |
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(accel_data, sizeof(*accel_data));
} |
analytics_inc(ANALYTICS_DEVICE_METRIC_ACCEL_PEEK_COUNT, AnalyticsClient_System);
PebbleTask task = pebble_task_get_current();
if (task == PebbleTask_Worker || task == PebbleTask_App) {
analytics_inc(ANALYTICS_APP_METRIC_ACCEL_PEEK_COUNT, AnalyticsClient_CurrentTask);
}
if (!accel_running()) {
retur... | |
LL;
if (data->toggle_state == ToggleStateIdle) {
if (bt_ctl_is_airplane_mode_on()) {
subtitle = i18n_get("Airplane Mode", data);
icon = &data->icon_heap_bitmap[AirplaneIconIdx];
} else {
if (selected) {
bt_local_id_copy_device_name(device_name_buffer, fals... | event_service_client_subscribe(&data->ble_hrm_sharing_event_info) | ;
#endif
event_service_client_subscribe(&data->bt_airplane_event_info);
event_service_client_subscribe(&data->bt_connection_event_info);
event_service_client_subscribe(&data->bt_pairing_event_info);
event_service_client_subscribe(&data->ble_device_name_updated_event_info);
bt_pairability_use();
bt_driver_re... |
prv_noop_action_callback,
NULL);
action_menu_level_add_action(root_level,
"Sorry, I can't talk right now, call me back at a later time",
prv_noop_action_callback,
NU... | (voice_level,
"This won't be seen",
prv_noop_action_callback,
NULL) | ;
action_menu_level_add_child(root_level, voice_level, "Voice");
ActionMenuLevel *template_level = action_menu_level_create(1);
action_menu_level_add_action(template_level,
"This won't be seen",
prv_noop_action_callback,
... |
0, 0x54, 8088, 0x0},
{ 0, 0x42, 5604, 0x0},
{ 0, 0x42, 926, 0x0},
{ 0, 0x64, 287, 0x0},
{ 7, 0x54, 828, 0x0},
{ 0, 0x68, 674, 0x0},
{ 12, 0x55, 4129, 0x0},
// 30: Local time: 09:41:00 PM
{ 0, 0x67, 1138, 0x0},
{ 0, 0x54, 498, 0x0},
{ 0, 0x54, 389, 0x0},
{ 0, 0x65, 1262, 0x0}... | { 0, 0x62, 362, 0x0},
{ 7, 0x41, 4506, 0x0},
{ 7, 0x22, 5674, 0x0},
{ 0, 0x18, 1653, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 13, 0x0},
// 150: Local time: 11:41:00 PM
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0, 0x18, 0, 0x0},
{ 0,... | |
t *cptr = out;
while (len--) {
prv_spi_send_data(slave->spi_bus, *(cptr++));
prv_spi_transmit_flush_blocking(slave->spi_bus);
}
}
void spi_ll_slave_burst_read_write(const SPISlavePort *slave,
const void *out,
void *in,
... | (slave->tx_dma) | ;
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_ReqTx, false);
slave->slave_state->dma_complete_handler = NULL;
slave->slave_state->dma_complete_context = NULL;
}
void spi_ll_slave_read_write_dma_start(const SPISlavePort *sl... |
aken by the caller!
bool comm_session_is_valid(const CommSession *session) {
return list_contains((ListNode *) s_session_head, &session->node);
}
// -------------------------------------------------------------------------------------------------
//! Extern'd interface for protocol.c
// -----------------------------... | (existing_system_session->transport,
existing_system_session->transport_imp,
CommSessionTransportType_PULSE) |
&& !prv_is_transport_type(transport, implementation, CommSessionTransportType_PULSE)) {
if (!existing_system_session->transport_imp->close) {
// iAP sessions cannot be closed from the watch' side :(
PBL_LOG(LOG_LEVEL_ERROR, "System session already exists and cannot be closed");
... |
_term].min_interval_slots == GAPLE_ADVERTISING_SILENCE_INTERVAL_SLOTS);
}
//! Links the job into the ring of jobs. Will make the new job the start (s_jobs) of the ring only
//! if the first term isn't silent.
//! @return True if the new job was made the start of the ring, false if not.
static bool prv_link_job(GAPLEAd... | bt_driver_advert_client_has_cycled() | || !s_gap_le_advert_is_initialized) {
// Job got removed in the meantime.
goto unlock;
}
prv_increment_time_elapsed_for_all_silent_terms_except_current();
GAPLEAdvertisingJob *job = s_current;
BLE_LOG_DEBUG("Currently running job: %s (non-connectable=%u)",
prv_string_for... |
h>
T_STATIC bool prv_scroll_layer_is_paging_enabled(ScrollLayer *scroll_layer) {
PBL_ASSERTN(scroll_layer);
if (process_manager_compiled_with_legacy2_sdk() || !scroll_layer->shadow_sublayer.hidden) {
return false;
}
return !scroll_layer->paging.paging_disabled;
}
T_STATIC uint16_t prv_scroll_layer_get_pag... | property_animation_get_animation(scroll_layer->animation) | );
content_indicator_destroy_for_scroll_layer(scroll_layer);
layer_deinit(&scroll_layer->layer);
}
void scroll_layer_destroy(ScrollLayer *scroll_layer) {
if (scroll_layer == NULL) {
return;
}
scroll_layer_deinit(scroll_layer);
applib_free(scroll_layer);
}
Layer* scroll_layer_get_layer(const ScrollLaye... |
arted_complete(GETTING_STARTED_COMPLETE);
shared_prf_storage_set_local_device_name(DEVICE_NAME);
char device_name_out[BT_DEVICE_NAME_BUFFER_SIZE];
// Check pairing info
SMPairingInfo pairing_info_out;
bool requires_address_pinning = false;
uint8_t flags = 0;
shared_prf_storage_get_ble_pairing_data(&pair... | shared_prf_storage_get_getting_started_complete() | |
ap.h"
#include "stubs_text_resources.h"
#include "stubs_text_render.h"
#include "stubs_pbl_malloc.h"
#include "stubs_reboot_reason.h"
#include "stubs_resources.h"
#include "stubs_syscalls.h"
#include "stubs_compiled_with_legacy2_sdk.h"
///////////////////////////////////////////////////////////
// Fakes
static GConte... | (utf8_iter_state->codepoint == 'A') | |
((1 << bpp) - 1) << shift);
buf[idx] = buf[idx] & mask;
buf[idx] |= ((color_index & ((1 << bpp) - 1)) << shift);
}
static bool prv_check_source_stripe_blit(const uint8_t *data,
const GBitmap *src_bmp, GColor surround_color) {
for (uint8_t y = 0; y < (FRAMEBUFFER_SIZE_BYTE... | (&dest_bitmap, &s_bmp, GPointZero, GCompOpAssign, GColorWhite) | ;
cl_assert(prv_check_source_stripe_blit(dest_bitmap_data, &s_bmp, GColorWhite));
}
static void prv_opaque_2bit_simple(GCompOp compositing_mode) {
const int BITS_PER_PIXEL = 2;
const int PIXELS_PER_BYTE = (8 / BITS_PER_PIXEL);
const int WIDTH = 4;
const int HEIGHT = 4;
const int ROW_STRIDE = (WIDTH + (PIX... |
/*
* 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... | (0, string_list_count(list)) | ;
list->serialized_byte_length = 3;
// 4 empty strings
cl_assert_equal_i(4, string_list_count(list));
cl_assert_equal_s("", string_list_get_at(list, 0));
cl_assert_equal_s("", string_list_get_at(list, 1));
cl_assert_equal_s("", string_list_get_at(list, 2));
cl_assert_equal_s("", string_list_get_at(list, ... |
s_file_rewrite(&fd, prv_delete_all_pairings_itr, NULL);
settings_file_close(&fd);
}
prv_unlock();
shared_prf_storage_erase_ble_pairing_data();
if (bt_driver_supports_bt_classic()) {
shared_prf_storage_erase_bt_classic_pairing_data();
}
}
static void prv_dump_bonding_db_data(char display_buf[DISPLAY_... | (key, IS_UNFAITHFUL_KEY, info->key_len) | == 0) {
PBL_ASSERTN(info->val_len == sizeof(bool));
bool is_unfaithful;
memcpy(&is_unfaithful, val, sizeof(bool));
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "%s : %d",
IS_UNFAITHFUL_KEY, (int)is_unfaithful);
} else if (memcmp(key, ROOT_KEYS_KEY, info->key_len) ... |
eq, true, true);
cl_assert_equal_i(duration, duration_a + delay_a + duration_b + delay_b);
// The position of seq should be the amount we already played of a, including the 'a' delay
// since a is embedded within seq
int32_t position;
animation_get_elapsed(seq, &position);
cl_assert_equal_i(position, 100)... | (&s_started_handler_calls, b) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 1);
#endif
}
// ------------------------------------------------------------... |
((bitmap_format == GBitmapFormat1Bit) ||
(bitmap_format == GBitmapFormat8Bit) ||
(bitmap_format == GBitmapFormat8BitCircular))) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Invalid destination bitmap format for APNG");
goto cleanup;
}
// Update current time elapsed using the previous frames current_fra... | upng_get_format(upng) | ;
uint8_t *upng_buffer = (uint8_t*)upng_get_buffer(upng);
// Byte aligned rows for image at bpp
uint16_t row_stride_bytes = (fctl.width * bpp + 7) / 8;
if (png_format >= UPNG_INDEXED1 && png_format <= UPNG_INDEXED8) {
const GColor8 *palette = png_decoder_data->palette;
for (uint32_t y = 0; y < fctl.... |
strncpy(buffer, data->duration_string, buffer_size) | ;
break;
}
case WorkoutMetricType_Custom:
{
strncpy(buffer, data->custom_value_string, buffer_size);
break;
}
// Not supported by the sports API
case WorkoutMetricType_Steps:
case WorkoutMetricType_AvgPace:
case WorkoutMetricType_None:
case WorkoutMetricTypeCount:
... | |
/*
* 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_bitmap_in_rect(ctx, icon, icon_frame) | |
_window_timeout_get_selection_index(void) {
const int DEFAULT_IDX = 2;
// Double check no one has fudged with the order and the fallback/default
PBL_ASSERTN(s_window_timeouts_ms[DEFAULT_IDX] == NOTIF_WINDOW_TIMEOUT_DEFAULT);
const uint32_t timeout_ms = alerts_preferences_get_notification_window_timeout_ms();
... | prv_window_timeout_menu_push(data) | ;
break;
default:
WTF;
}
settings_menu_reload_data(SettingsMenuItemNotifications);
}
static void prv_settings_notifications_event_handler(PebbleEvent *event, void *context) {
switch (event->type) {
case PEBBLE_BATTERY_CONNECTION_EVENT:
// Redraw the menu so that the Vibration status wil... |
or the node we just removed
break; // we can quit now that we've found a match for this id
}
iter = next;
}
return true;
}
// Delete files from resource_list that don't correspond to entries in the app cache
static void prv_app_cache_find_and_delete_orphans(PFSFileListEntry **resource_list) {
mutex... | app_storage_app_exists(app_id) | ) {
settings_file_delete(&file, (uint8_t *)&app_id, sizeof(AppInstallId));
exists = false;
}
settings_file_close(&file);
}
unlock:
mutex_unlock_recursive(s_app_cache_mutex);
return exists;
}
//! Removes an entry with the given AppInstallId from the cache
status_t app_cache_remove_entry(AppIn... |
oid test_phone_call__cleanup(void) {
// fake_comm_session_cleanup();
}
// ---------------------------------------------------------------------------------------
// Basic test for incoming calls over PP
void test_phone_call__pp_incoming(void) {
// We should only allow incoming calls when connected to the mobile ap... | ASSERT_LAST_EVENT(PhoneEventType_Incoming) | ;
prv_call_hide(ANCS_UNUSED_UID);
ASSERT_LAST_EVENT(PhoneEventType_Invalid);
prv_call_hide(ANCS_CALL_UID);
ASSERT_LAST_EVENT(PhoneEventType_Hide);
}
|
/*
* 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... | (&seconds, &millis) | ;
return ((double)seconds * 1000.0) + millis;
} /* jerry_port_get_current_time */
DEFINE_SYSCALL(bool, jerry_port_get_time_zone, jerry_time_zone_t *tz_p) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(tz_p, sizeof(*tz_p));
}
time_t utc_now;
time_ms(&utc_now, NULL);
int32_t dstoffset =... |
/*
* 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(decoded_codepoint, actual_codepoint) | |
snprintf(min_buf, sizeof(min_buf), ".%d", min_offset_percent);
}
snprintf(region_name, buffer_size, "UTC%+d%s", hour_offset, min_buf);
}
} else {
strncpy(region_name, "---", buffer_size);
}
}
int16_t clock_get_timezone_region_id(void) {
return rtc_get_timezone_id();
}
void clock_set_timez... | {
time_fmt = i18n_noop("%b %e, %l:%M %p");
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | dialog_set_text(dialog, msg) | ;
dialog_set_icon(dialog, RESOURCE_ID_BLE_HRM_NOT_SHARED);
dialog_set_timeout(dialog, BLE_HRM_CONFIRMATION_TIMEOUT_MS);
simple_dialog_set_icon_animated(simple_dialog, false);
i18n_free(msg, dialog);
return simple_dialog;
}
|
LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a start sync with an invalid length: %"PRIu32"", length);
return;
}
struct PACKED StartSyncResponseMsg {
BlobDBCommand cmd;
BlobDBToken token;
BlobDBResponse result;
} response = {
.cmd = BLOB_DB_COMMAND_START_SYNC_RESPONSE,
};
BlobDBId db_id;
... | {
case BLOB_DB_COMMAND_DIRTY_DBS:
PBL_LOG(LOG_LEVEL_DEBUG, "Got DIRTY DBs");
prv_handle_get_dirty_databases(session, data, data_length);
break;
case BLOB_DB_COMMAND_START_SYNC:
PBL_LOG(LOG_LEVEL_DEBUG, "Got SYNC");
prv_handle_start_sync(session, data, data_length);
break;
... | |
/*
* 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... | {
notification_storage_init();
} |
void notifications_add_notification(TimelineItem *notification) {
notification_storage_store(notification);
Uuid *uuid = kernel_malloc_check(sizeof(Uuid));
*uuid = notification->header.id;
notifications_handle_notification_added(uuid);
}
|
_text_height_px + 8;
const uint16_t status_layer_offset = dialog->show_status_layer ? 6 : 0;
uint16_t text_top_margin_px = icon ? icon_size.h + 22 : 6;
uint16_t subtext_top_margin_px = text_top_margin_px + single_line_text_height_px;
uint16_t icon_top_margin_px = PBL_IF_RECT_ELSE(18, 22);
uint16_t text_heigh... | (&workout_dialog->action_bar, window) | ;
}
// Icon
// On rectangular displays we just center it horizontally b/w the left edge of the display and
// the left edge of the action bar
#if PBL_RECT
x = (grect_get_max_x(bounds) - action_bar_width - icon_size.w) / 2;
#else
// On round displays we right align it with respect to the same imaginary vert... |
irst_wakeup_id = sys_wakeup_schedule(first_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(first_wakeup_id), first_event);
TimerID first_timer = wakeup_get_current();
// Schedule another a minute away
time_t second_event = sys_get_time() + WAKEUP_EVENT_WINDOW * 2;
WakeupId second_wakeup_id = sys_wakeup... | (s_popup_occurred, true) | ;
// Make sure the wakeup event is no longer scheduled
cl_assert_equal_i(sys_wakeup_query(first_timer), E_DOES_NOT_EXIST);
}
|
c uint16_t s_volume;
static bool s_running = false;
static bool s_main_pending = false;
static bool s_bg_pending = false;
static int s_overflow_cnt;
static bool s_initialized = false;
static uint8_t s_discarded;
static CircularBuffer s_circ_buffer;
// A mutex is needed to protect against a race condition between mic... | (&BOARD_CONFIG.mic_config.mic_gpio_power, false) | |
now - (10 * SECONDS_PER_MINUTE), now);
cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskNotAvailable);
accessible = health_service_any_activity_accessible(HealthActivityMaskAll,
now - (10 * SECONDS_PER_MINUTE), now);
cl_assert_equal_i(a... | (HealthActivityRestfulSleep, now - (100 * SECONDS_PER_MINUTE),
now, HealthIterationDirectionPast, prv_activity_cb, NULL) | ;
cl_assert_equal_i(num_restfulsleep_sessions, s_prv_activity_cb__call_count);
cl_assert_equal_b(s_prv_activity_cb__args[0].activity, HealthActivityRestfulSleep);
// respect mask for Run/Walk
s_prv_activity_cb__call_count = 0;
s_sys_activity_get_sessions_values.out.num_sessions = 7;
health_service_activiti... |
ormal");
analytics_event_stationary_state_change(rtc_get_time(), StationaryAnalyticsExitNormally);
prv_reset_stationary_counter();
s_current_state = StationaryStateAwake;
}
//! The accelerometer tap threshold will be set very low, so a small motion will wake
//! the watch back up
static void prv_enter_stationary... | prv_exit_disabled_state() | ;
break;
case StationaryActionDisableStationary:
break;
default:
WTF;
}
}
typedef void (*StationaryActionHandler)(StationaryAction action);
static void prv_handle_action(StationaryAction action) {
// we need to be on kernel main so that we subscribe to event services
// for kernel main... |
e(s_valid_page_idx) != SprfMagic_UnpopulatedEntry)) {
PBL_LOG(LOG_LEVEL_WARNING, "Ran out of pages or found corrupted next page, erasing region");
// NOTE: This should not happen often. On boot, we delete and rewrite the region if >75% of
// regions are filled. In the worst case, this will happen if the use... | if (written_crc == SPRF_UNWRITTEN_CRC) {
// If empty field, return that we have invalid data too
return false;
} | |
heck(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__workout_render_hr_zone_3(void) {
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 789,
.distance_m = 234,
.avg_pace = health_util_get_pace(789, 234),
.bpm = 197,
.hr_zone = 3,
};
WorkoutActiv... | (
top_metric, middle_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics,
&s_sports_data, &s_sports_controller) | ;
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_hr_z0(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
Wo... |
mutex.h>
#include <util/attributes.h>
typedef struct PACKED RecentApp {
AppInstallId id;
time_t last_activity;
bool can_expire;
} RecentApp;
// The number of applications to store in the circular cache.
// These are used to detect which application shave recently communicated
#define NUM_RECENT_APPS 5
#define C... | {
const time_t cur_time = time_get_uptime_seconds();
RecentApp *app = circular_cache_get(&s_recent_apps.cache, &install_id);
if (app) {
app->last_activity = cur_time;
app->can_expire = can_expire;
} else {
RecentApp app = {
.id = install_id,
.last_activity = cur_time,
... |
mutex_unlock_recursive(s_recent_apps.mutex);
}
#if UNITTEST
void app_install_manager_flush_recent_communication_timestamps(void) {
circular_cache_flush(&s_recent_apps.cache);
memset(&s_recent_apps.cache_buffer, 0, sizeof(s_recent_apps.cache));
}
#endif
bool app_install_entry_is_watchface(const AppInstallEntry ... |
event_listeners.splice(idx, 1)` to remove item at idx
// wow, this is a lot of code for this
JS_VAR splice = jerry_get_object_field(event_listeners, "splice");
const jerry_value_t args[] = {jerry_create_number(idx), jerry_create_number(1)};
JS_VAR remove_result = jerry_call_function(splice, event_listen... | {
return rocky_error_arguments_missing();
} |
if (!jerry_value_is_string(argv[0])) {
return rocky_error_unexpected_type(0, "String");
}
jerry_set_object_field(this_val, ROCKY_EVENT_TYPE, argv[0]);
return jerry_create_undefined();
}
static void prv_copy_property(const jerry_value_t rocky,
const char *name_from, const char... |
icable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>... | while (SPI_I2S_GetFlagStatus(FLASH_CONFIG.spi, SPI_I2S_FLAG_TXE) == RESET) {} |
// Send the byte on the SPI bus
SPI_I2S_SendData(FLASH_CONFIG.spi, byte);
// Wait for the response byte to be received
while (SPI_I2S_GetFlagStatus(FLASH_CONFIG.spi, SPI_I2S_FLAG_RXNE) == RESET) {}
// Return the byte
return SPI_I2S_ReceiveData(FLASH_CONFIG.spi);
}
static void prv_flash_send_24b_address(u... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | dbgserial_print("address ") | ;
dbgserial_print_hex(address);
dbgserial_putstr(" is outside system flash");
return -1;
}
for (size_t i=0; i < ARRAY_LENGTH(s_sector_addresses)-1; ++i) {
if (s_sector_addresses[i] <= address
&& address < s_sector_addresses[i+1]) {
return i;
}
}
return ARRAY_LENGTH(s_sector_add... |
hrm_manager_app_subscribe,
AppInstallId app_id, uint32_t update_interval_s, uint16_t expire_sec, HRMFeature features) {
return hrm_manager_subscribe_with_callback(app_id, update_interval_s, expire_sec, features, NULL,
NULL);
}
DEFINE_SYSCALL(bool, sys_hrm_manager_uns... | (buf, 32, "LED: %"PRIu16"uA", event->led.current_ua) | ;
}
}
}
void command_hrm_read(void) {
s_tia_count = 0;
sys_hrm_manager_unsubscribe(s_console_session);
s_console_session = hrm_manager_subscribe_with_callback(
INSTALL_ID_INVALID, 1 /*update_interval_s*/, 0 /*expire_s*/, HRMFeature_LEDCurrent,
prv_console_read_callback, NULL);
prompt_command_... |
ion *shrink = NULL;
PropertyAnimation *revert = NULL;
// Do the overshoot animation first
expand = prv_create_int16_prop_anim(max, overshoot + max, stage_duration, &s_animated_dot_impl,
data);
if (!expand) {
goto cleanup;
}
animation_set_delay((Animation *) expand, delay_duration);
// If overs... | (&data->mic_window.mic_dot_layer, false) | ;
static const uint32_t ANIMATION_DURATION = 270;
static const int16_t MIN_RADIUS = 7;
static const int16_t OVERSHOOT = 4;
static const uint32_t DELAY_DURATION = 1000;
static const uint32_t START_ELAPSED = 800; // show pulse just after the start of the animation
layer_mark_dirty(&data->mic_window.mic_dot... |
/*
* 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((idx < MAX_GPIO) && s_gpio_clock_count[idx] && !(--s_gpio_clock_count[idx])) {
CLEAR_BIT(RCC->AHB1ENR, (0x1 << idx));
power_tracking_stop(s_gpio_to_power_system_map[idx]);
} |
portEXIT_CRITICAL();
}
void gpio_output_init(const OutputConfig *pin_config, GPIOOType_TypeDef otype,
GPIOSpeed_TypeDef speed) {
GPIO_InitTypeDef init = {
.GPIO_Pin = pin_config->gpio_pin,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_Speed = speed,
.GPIO_OType = otype,
.GPIO_PuPd = ... |
graphics_context_set_stroke_width(ctx, 10);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void across_x_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_stroke_width(ctx, 10);
... | setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, STROKE_WIDTH) | ;
graphics_draw_line(&ctx, START_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_inside_offset_layer.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, STROKE_WIDTH);
graphics_draw_line(&ctx, START_ON_ORIGIN_RECT_XY, ... |
PBL_IF_RECT_ELSE(ACTION_BAR_WIDTH, 0) | ,
STATUS_BAR_LAYER_HEIGHT));
status_bar_layer_set_colors(&s_phone_ui_data->status_bar,
PBL_IF_COLOR_ELSE(GColorClear, GColorWhite),
GColorBlack);
layer_add_child(&s_phone_ui_data->core_ui_container, &s_phone_ui_data->status_bar.lay... | |
/*
* 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... | (true, bt_dialog->context) | ;
}
// handler to NULL so it won't be called again during the unload
bt_dialog->connected_handler = NULL;
dialog_pop(&bt_dialog->dialog.dialog);
}
}
static void prv_bt_dialog_unload(void *context) {
BtConnDialog *bt_dialog = context;
event_service_client_unsubscribe(&bt_dialog->pebble_app_event_s... |
.h - radius - 1),
radius, GCornerBottomLeft);
bottom_rect_origin_x += radius;
bottom_rect_size_w -= radius;
}
if (corner_mask & GCornerTopRight) {
circle_func(ctx, GPoint(rect->origin.x + rect->size.w - radius - 1, rect->origin.y + radius),
radius, GCornerTo... | (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, br, stroke_width);
}
#endif // PBL_COLOR
T_STATIC void prv_draw_rect_stroked(GContext *ctx, const GRect *rect, uint8_t stroke_width) {
const GPoint tl = G... |
VAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls,... | (&s_started_handler_calls, 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... | (SDL_INIT_VIDEO) | < 0) {
printf("Error: Failed to init SDL\n");
return false;
}
if (!sdl_graphics_init()) {
printf("Error: Failed to init graphics\n");
return false;
}
return true;
}
void sdl_app_deinit(void) {
SDL_Quit();
}
void sdl_app_event_loop(void) {
SDL_Event event;
int keypress = 0;
while (!... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.