prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
return;
}
ctx->draw_state.draw_implementation->blend_horizontal_line(ctx, y, x1, x2,
ctx->draw_state.stroke_color);
graphics_release_frame_buffer(ctx, framebuffer);
}
void prv_assign_line_vertical_non_aa(GContext* ctx, int16_t x, int16_t y1, int16_... | (ctx, x, y1, y2, color) | ;
}
void graphics_private_draw_horizontal_line(GContext *ctx, int16_t y, Fixed_S16_3 x1,
Fixed_S16_3 x2) {
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
// apply draw box and clipping
x1.integer += ctx->draw_state.drawing_box.origin.x;
x2.integer += ctx->dra... |
C
*
* 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, software
* distrib... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_y_origin_layer.${BIT_DEPTH_NAME}.pbi") | );
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_y_origin_layer.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_draw_round_rect_${BIT_DEPTH_NAME}__offset_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... | (&capabilities) | ;
return (capabilities.send_text_support && s_has_send_text_reply_action);
}
|
#define I2C_FAST_MODE_CLOCK_SPEED_MAX (400000)
#define I2C_FAST_MODE_PLUS_CLOCK_SPEED_MAX (1000000)
#define TIMINGR_MASK_PRESC (0x0F)
#define TIMINGR_MASK_SCLH (0xFF)
#define TIMINGR_MASK_SCLL (0xFF)
#define CR1_CLEAR_MASK (0x00CFE0FF)
#define CR2_CLEAR_MASK (0x07FF7FFF)
#define CR2_NBYTES_OFFSET (16)
#d... | periph_config_disable(bus->hal->i2c, bus->hal->clock_ctrl) | ;
prv_i2c_deinit(bus);
}
bool i2c_hal_is_busy(I2CBus *bus) {
return ((bus->hal->i2c->ISR & I2C_ISR_BUSY) != 0);
}
static void prv_disable_all_interrupts(I2CBus *bus) {
bus->hal->i2c->CR1 &= ~(I2C_CR1_TXIE |
I2C_CR1_RXIE |
I2C_CR1_TCIE |
... |
yed_icon);
}
}
static KinoReel *prv_create_glance_icon(const AppResourceInfo *res_info,
bool legacy_icon_size_limit) {
if (!res_info) {
return NULL;
}
KinoReel *icon = kino_reel_create_with_resource_system(res_info->res_app_num, res_info->res_id);
if (!icon) {
... | {
return;
} | |
issues with some platforms, see PBL-37278 as an example
should_use_dma = false;
#endif
#if TARGET_QEMU
// QEMU doesn't yet support DMA or memory-mapping
should_use_dma = should_use_memmap = false;
#endif
qspi_use(dev->qspi);
uint8_t instruction;
uint8_t dummy_cycles;
bool is_ddr;
prv_get_fast_read_pa... | {
qspi_use(dev->qspi);
#if TARGET_QEMU
// QEMU doesn't support memory-mapping the FLASH
const bool result = prv_blank_check_poll(dev, addr, is_subsector);
#else
const bool result = prv_blank_check_mmap(dev, addr, is_subsector);
#endif
qspi_release(dev->qspi);
return result ? S_TRUE : S_FALSE;
} |
void qspi_flash_ll_set_register_bits(QSPIFlash *dev, uint8_t read_instruction,
uint8_t write_instruction, uint8_t value, uint8_t mask) {
// make sure we're not trying to set any bits not within the mask
PBL_ASSERTN((value & mask) == value);
qspi_use(dev->qspi);
// first ... |
malloc.h"
#include "process_management/app_install_manager.h"
#include "resource/resource_ids.auto.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/activity/health_util.h"
#include "services/normal/activity/workout_service.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/attr... | workout_service_get_current_workout_type(&workout_type) | ;
workout_service_get_current_workout_info(NULL, &workout_duration_s, NULL, NULL, NULL);
} else if (has_automatic_session) {
// Automatic workout is going on - get the type and duration
workout_type = automatic_session.type;
workout_duration_s = rtc_get_time() - automatic_session.start_utc;
} else {... |
= status;
++s_num_sent_handler_called;
}
#define assert_sent_cb_last_status(expected_status) \
cl_assert_equal_i(s_last_sent_status, expected_status)
////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
static uint8_t *s_test_data;
static size_t s_test_... | cl_assert_equal_i(s_num_app_outbox_events_sent, 0) | ;
}
void test_app_outbox__send(void) {
fake_kernel_malloc_mark();
prv_register();
uint32_t max_pending_messages =
app_outbox_service_max_pending_messages(AppOutboxServiceTagUnitTest);
AppOutboxMessage *message[max_pending_messages];
for (uint32_t i = 0; i < max_pending_messages; ++i) {
app_outbo... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_ERROR, "Invalid SYNC msg received, length: %u", len) | ;
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Received health SYNC request");
system_task_add_callback(prv_sync_health_system_task_cb, NULL);
}
#endif
void health_sync_protocol_msg_callback(CommSession *session, const uint8_t *msg, size_t len) {
#if CAPABILITY_HAS_HEALTH_TRACKING
if (len < 1) {
PBL_LOG(LOG_... |
dLastUpdated, .uint32 = s_now },
}
};
s_expected_attributes = &expected_attributes;
ancs_filtering_record_app(&existing_prefs, s_app_id_attr, s_display_name_attr, s_title_attr);
cl_assert(s_performed_store);
// Make sure the our existing prefs got updated
iOSNotifPrefs expected_prefs = {
.attr_lis... | (&mute_weekdays) | );
s_now += SECONDS_PER_DAY; // Monday Jan 4, 2016
cl_assert(ancs_filtering_is_muted(&mute_always));
cl_assert(!ancs_filtering_is_muted(&mute_weekends));
cl_assert(ancs_filtering_is_muted(&mute_weekdays));
}
void test_ancs_filtering__record_app_no_display_name(void) {
iOSNotifPrefs *existing_prefs = NULL;
... |
/*
* 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_fill_rect(ctx, &kino_layer->layer.bounds) | ;
}
// Draw Reel
KinoReel *reel = kino_player_get_reel(&kino_layer->player);
if (reel == NULL) {
return;
}
const GRect reel_bounds = kino_layer_get_reel_bounds(kino_layer);
kino_player_draw(&kino_layer->player, ctx, reel_bounds.origin);
}
//////////////////////
// Player Callbacks
/////////////////... |
Fixed_S16_3_add(num1, num2);
sum_c = (Fixed_S16_3){ .raw_value = (int16_t)((float)4.5 * (1 << FIXED_S16_3_PRECISION)) };
cl_assert(sum.raw_value == sum_c.raw_value);
// sum = 1 + 3.5 = 4.5 - test commutative property of addition
num1 = FIXED_S16_3_ONE;
num2 = (Fixed_S16_3){ .raw_value = (int16_t)((float)3.5 ... | (num1, num2) | ;
sum_c = (Fixed_S32_16){ .raw_value = (int32_t)((float)2 * (1 << FIXED_S32_16_PRECISION)) };
cl_assert(sum.raw_value == sum_c.raw_value);
// sum = 3.5 + 1 = 4.5
num1 = (Fixed_S32_16){ .raw_value = (int32_t)((float)3.5 * (1 << FIXED_S32_16_PRECISION)) };
num2 = FIXED_S32_16_ONE;
sum = Fixed_S32_16_add(num1... |
snprintf(data->steps_card.cur_step_text, sizeof(data->steps_card.cur_step_text),
"%d", (int) data->cur_steps);
text_layer_set_text(data->steps_card.cur_step_layer, data->steps_card.cur_step_text);
}
// Show time
if (data->steps_card.time_layer) {
time_t now = time(NULL);
APP_LOG(APP_LOG_... | layer_set_update_proc(window_layer, steps_base_layer_update_proc) | ;
// Total steps
data->steps_card.cur_step_layer = text_layer_create(CUR_STEP_RECT);
text_layer_set_text_alignment(data->steps_card.cur_step_layer, GTextAlignmentCenter);
text_layer_set_font(data->steps_card.cur_step_layer,
fonts_get_system_font(FONT_KEY_LECO_38_BOLD_NUMBERS));
text_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... | sdk_app_get_info() | ;
}
#endif
void system_app_state_machine_register_app_launch(AppInstallId app_id) {
if (app_install_id_from_app_db(app_id)) {
shell_sdk_set_last_installed_app(app_id);
}
#if CAPABILITY_HAS_SDK_SHELL4
if (app_id == APP_ID_LAUNCHER_MENU) {
s_rooted_in_watchface = false;
} else if (app_install_is_watchfa... |
if (allocated_block) {
return &allocated_block->Data;
} |
return NULL;
}
void heap_free(Heap* const heap, void *ptr, uintptr_t client_pc) {
UTIL_ASSERT(heap->begin);
if (!ptr) {
// free(0) is a no-op, just bail
return;
}
UTIL_ASSERT(heap_contains_address(heap, ptr)); // <ptr> not in range (heap->begin, heap->end)
heap_lock(heap);
{
/* Get a poin... | |
*connection) {
bool rv;
prv_lock();
{
rv = list_contains((ListNode *)s_connections, (const ListNode *)connection);
}
prv_unlock();
return rv;
}
static bool prv_connection_by_idx_list_filter_cb(ListNode *found_node, void *data) {
uint16_t conn_idx = (uintptr_t)data;
return (((Connection *)found_nod... | {
PPoGATTWorkAroundState *state;
prv_lock();
{
state = connection->ppogatt_wa_state;
}
prv_unlock();
return state;
} |
bool connection_is_gateway(Connection *connection) {
bool val;
prv_lock();
{
val = connection->is_gateway;
}
prv_unlock();
return val;
}
static bool prv_get_flag(const Connection *connection, ConnectionFlag flag) {
bool val;
prv_lock();
{
uint32_t bit = (1 << flag);
val = ((connection->... |
eList.num_attributes
VibeAttributeId_Notes,
8, 0, // GenericAttribute.length
15, 0, // VibeNote.vibe_duration_ms
9, // VibeNote.brake_duration_ms
100, // VibeNote.strength
100, 0, // VibeNote.vibe_duration_ms
0, // VibeNote.brake_duration_ms
0, // VibeNote.strength
... | vibe_score_destroy(score) | ;
}
void test_vibe_score__test_get_repeat_delay_ms_default_delay(void) {
uint8_t buffer[] = {
'V', 'I', 'B', 'E', // FourCC
1, 0, // version
0, 0, 0, 0, // reserved bytes
18, 0, // attr_list_size
2, // GenericAttributeList.num_attributes
VibeAttributeId_Notes,
8, 0, // Gener... |
t16_t)(y1 + num_pixels_per_mask_value - 1);
record_func(ctx, x, y1, y2, src_color);
}
}
cl_assert(graphics_context_mask_record(ctx, NULL));
test_graphics_context_mask_debug(ctx, mask);
graphics_context_mask_destroy(ctx, mask);
}
///////////////////////////////////////
// APPLYING HORIZONTAL LINE ... | for (int16_t row_index = 0; row_index < num_dest_colors; row_index++) {
const int16_t starting_y = row_index * vline_applying_test_row_height;
for (int16_t y = starting_y; y < starting_y + vline_applying_test_row_height; y++) {
ctx->draw_state.stroke_color = (GColor) { .argb = (uint8_t)(row_index | ... |
}
}
static GDrawMask *prv_create_mask_for_vline_applying_test(GContext *ctx) {
// The initial transparency doesn't really matter since we're about to overwrite it
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparent);
cl_assert(mask);
const GSize mask_size = ctx... |
racteristic_att_handle_out,
GAPLEConnection **connection_out);
extern BLECharacteristic gatt_client_descriptor_get_characteristic_and_connection(
BLEDescriptor descriptor_ref,
... | circular_buffer_get_write_space_remaining(buffer) | ;
prv_unlock();
if (LIKELY(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... |
L_WARNING, "Tried to launch an invalid app in bank %u!",
process_metadata_get_code_bank_num(app_md));
return false;
}
const ResAppNum res_bank_num = process_metadata_get_res_bank_num(app_md);
if (res_bank_num != SYSTEM_APP) {
const ResourceVersion res_version = process_metadata_get_res_version(ap... | (&app_md->uuid, RUNNING) | ;
system_app_state_machine_register_app_launch(s_app_task_context.install_id);
prv_handle_app_start_analytics(app_md, launch_reason);
#if CAPABILITY_HAS_HEALTH_TRACKING && !defined(RECOVERY_FW)
health_tracking_ui_register_app_launch(s_app_task_context.install_id);
#endif
return true;
}
// -----------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | pebble_task_get_current() | ;
}
if (task == PebbleTask_App) {
return app_state_get_battery_state_service_state();
} else if (task == PebbleTask_Worker) {
return worker_state_get_battery_state_service_state();
} else {
WTF;
}
}
static void do_handle(PebbleEvent *e, void *context) {
BatteryStateServiceState *state = prv_g... |
(root_level, NULL, NULL) | ;
}
static void prv_noop_action_callback(ActionMenu *action_menu, const ActionMenuItem *action,
void *context) {
// Do nothing
}
// From action_menu_layer.c, needed to scroll the action menu layer to the point of interest
void prv_set_selected_index(ActionMenuLayer *aml, int sel... | |
/*
* 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... | {
const PebbleCommSessionEvent app_event = (const PebbleCommSessionEvent) {
.is_open = is_open,
.is_system = true
};
music_endpoint_handle_mobile_app_event(&app_event);
} |
static void prv_receive_pp_data(const uint8_t *data, uint16_t length) {
fake_event_clear_last();
music_protocol_msg_callback(NULL, data, length);
}
static void prv_receive_and_assert_now_playing(bool expect_is_handled) {
uint8_t msg[] = { 0x10, 3, 'o', 'n', 'e', 3, 't', 'w', 'o', 5, 't', 'h', 'r', 'e', 'e', 0x... |
graphics_capture_frame_buffer(GContext* ctx) {
return NULL;
}
bool graphics_release_frame_buffer(GContext* ctx, GBitmap* buffer) {
return true;
}
void graphics_draw_pixel(){}
void graphics_fill_rect(GContext* ctx, const GRect *rect) {}
void graphics_private_draw_horizontal_line(){}
void graphics_private_draw_verti... | cl_assert_equal_grect(resulting_rect2, GRect(3, 0, 2, 4)) | ;
// Odd-length width and height for container rect, 180 degree angle
const GRect container_rect3 = GRect(2, 2, 5, 5);
const GRect resulting_rect3 = grect_centered_from_polar(container_rect3, mode,
DEG_TO_TRIGANGLE(180), GSize(2, 4));
cl_assert_equal_gr... |
-----------------------------------------
// Get the last entry for the given handle
static AnimTestHandlerEntry *prv_last_handler_entry(AnimTestHandlerHistory *history,
Animation *animation) {
int last_entry=-1;
for (int i = 0; i < history->num_calls; i++) {
if (!animation || history->entries[i].anim... | (animation) | , prv_animation_get_current());
prv_add_handler_entry(&s_update_handler_calls, animation, false,
(void *)(uintptr_t)distance /*context*/);
DPRINTF("%"PRIu64" ms: Executing update handler for %d, distance: %d\n", prv_now_ms(),
(int)animation, (int)distance);
}
// ----------------... |
.NumberOfDescriptors = 0x1,
.DescriptorList = &cccd2,
},
};
GATT_Service_Discovery_Indication_Data_t data = {
.ConnectionID = connection_id,
.ServiceInformation = {
.Service_Handle = RANDOM_S_START_ATT_HANDLE,
.End_Group_Handle = 0x9,
.UUID = {
.UUID_Type = guUUID_1... | {
return 3; // .Characteristic_Handle = 0x3,
} | |
on.Runn
//! 69 6e 67 20 6c 61 74 65 00 4f 6e 20 6d 79 20 77 ing late .On my w
//! 61 79 00 42 75 73 79 20 72 69 67 68 74 20 6e 6f ay.Busy right no
//! 77 20 2d 20 67 69 76 65 20 6d 65 20 61 20 73 65 w - give me a se
//! 63 6f 6e 64 3f 21 01 00 00 cond?!.. .
static const uint8_t s_ios... | cl_assert(notif_prefs) | ;
title = attribute_find(¬if_prefs->attr_list, AttributeIdShortTitle);
cl_assert(title);
cl_assert_equal_s(title->cstring, "Title");
mute = attribute_find(¬if_prefs->attr_list, AttributeIdMuteDayOfWeek);
cl_assert(mute);
cl_assert_equal_i(mute->uint8, 0x1F);
name = attribute_find(¬if_prefs->attr_... |
/*
* 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... | {
break;
} |
}
// Force the local part of the phone number to the second line using newline
const int region_min_len = 3;
if (local_number_length <= (phone_number_length - region_min_len)) {
int region_length = phone_number_length - local_number_length;
const char *local_number = &phone_number[region_l... |
ostMessageStateAwaitingResetCompleteRemoteInitiated);
EXPECT_OUTBOX_RESET_COMPLETE_PENDING();
ASSERT_JS_GLOBAL_EQUALS_B("isCalled", true);
// TODO: assert:
// - flushed recv chunk reassembly buffer
}
void test_rocky_api_app_message__session_open__rcv_reset_complete(void) {
prv_init_and_goto_session_open();... | {
JS_VAR obj = jerry_create_object();
JS_VAR json_str = prv_json_stringify(obj);
char *json_c_str = rocky_string_alloc_and_copy(json_str);
cl_assert_equal_s(json_c_str, "{}");
task_free(json_c_str);
} |
void test_rocky_api_app_message__json_parse(void) {
JS_VAR number = prv_json_parse("1");
cl_assert(jerry_value_is_number(number));
cl_assert_equal_d(jerry_get_number_value(number), 1.0);
JS_VAR object = prv_json_parse("{ \"x\" : 42 }");
cl_assert(jerry_value_is_object(object));
JS_VAR x = jerry_get_objec... |
t uint8_t *) &s_server_reset_request,
sizeof(s_server_reset_request), BLEGATTErrorSuccess);
}
static void prv_receive_reset_complete(BLECharacteristic characteristic) {
ppogatt_handle_read_or_notification(characteristic, (const uint8_t *)s_client_reset_complete,
... | fake_pbl_malloc_clear_tracking() | ;
fake_gatt_client_op_init();
fake_gatt_client_subscriptions_init();
regular_timer_init();
fake_comm_session_init();
ppogatt_create();
}
void test_ppogatt__cleanup(void) {
ppogatt_destroy();
cl_assert_equal_i(ppogatt_client_count(), 0);
cl_assert_equal_i(regular_timer_seconds_count(), 0);
regular_tim... |
);
// June 10th 2015, 13:30:29 (T-00:29:31)
rtc_set_time(event_time - (30 * SECONDS_PER_MINUTE) + 29);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 30 MIN", time_buf);
// June 10th 2015, 13:30:30 (T-00:29:30)
rtc_set_time(event_time - (3... | (event_time - (12 * SECONDS_PER_HOUR) - 1) | ;
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Fri, 12:00 PM", time_buf);
// June 12th 2015, 00:00:00 (T-12:00:00)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX... |
GPoint(13, 13), 6, 3686420);
touch_handle_update(0, TouchState_FingerUp, &GPoint(15, 100), 0, 3686400);
TouchEvent *touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event, 0, TouchEvent_Liftoff, &GPointZero, 3686380, 0,
&GPoint(15, 100), 20, 0, true);
// touchd... | cl_assert_equal_i(event.touch.type, PebbleTouchEvent_TouchesCancelled) | ;
// no more touches
TouchEvent *touch_event = touch_event_queue_get_event(0, 0);
cl_assert_equal_p(touch_event, NULL);
touch_event = touch_event_queue_get_event(1, 0);
cl_assert_equal_p(touch_event, NULL);
}
// test that the first dispatch after a cancel event is pended does not return any touches, even
//... |
x, GPoint(10, 70), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(5, 76), 5);
// T facing right - even vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(50, 70), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(45, 75), 5);
// T facing right - odd vert, even horiz
graphics_draw... | (&ctx, GPoint(131, 71), 10) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(132, 76), 5);
// T facing right - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 90), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(10, 96), 5);
// T facing right - even vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GP... |
/*
* 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... | mutex_unlock(mutex_2) | ;
cl_assert_equal_b(fake_mutex_all_unlocked(), false);
mutex_unlock(mutex_1);
cl_assert_equal_b(fake_mutex_all_unlocked(), true);
}
|
ist) {
return NULL;
}
size_t size = gdraw_command_list_get_data_size(list);
GDrawCommandList *result = applib_malloc(size);
if (result) {
memcpy(result, list, size);
}
return result;
}
void gdraw_command_list_destroy(GDrawCommandList *list) {
if (list) {
applib_free(list);
}
}
static GDr... | prv_get_list_max_command_size(command_list) | ;
GDrawCommandDrawProcessedCBData data = {
.ctx = ctx,
.list = command_list,
.processor = processor,
// malloc because we clear the memory within each iteration of `prv_draw_command_processed`
.processed_draw_command = applib_malloc(max_size)
};
if (data.processed_draw_comman... |
(idx <= s_dropped_idx); \
cl_assert_equal_i(num, s_dropped_messages[idx]); \
}
#define assert_num_dropped_callbacks(num_cbs) \
{ \
cl_assert_equal_i(num_cbs, s_dropped_idx); \
}
void test_alt_message_handler(const uint8_t *data, size_t length,
AppInboxConsumerInfo *consumer_info) {
... | (storage, sizeof(storage),
test_message_handler, test_dropped_handler,
AppInboxServiceTagUnitTest) | ;
cl_assert_equal_b(success, true);
cl_assert_equal_b(true, app_inbox_service_has_inbox_for_storage(storage));
cl_assert_equal_b(true, app_inbox_service_has_inbox_for_tag(AppInboxServiceTagUnitTest));
fake_kernel_malloc_mark();
success = app_inbox_service_register(storage, sizeof(storage),
... |
estroy_list(&pin_attr_list);
attribute_list_destroy_list(&completed_attr_list);
attribute_list_destroy_list(&postpone_attr_list);
attribute_list_destroy_list(&remove_attr_list);
timeline_item_destroy(item);
}
static void prv_push_success_dialog(void) {
SimpleDialog *simple_dialog = simple_dialog_create("Remi... | rtc_get_time() | + SECONDS_PER_HOUR + (15 * SECONDS_PER_MINUTE);
struct tm local_tm;
localtime_r(&utc_sec, &local_tm);
local_tm.tm_min -= (local_tm.tm_min % 15);
local_tm.tm_sec = 0;
data->timestamp = mktime(&local_tm);
}
// If the user doesn't accept the transcription, try again.
data->ui_st... |
stent_storage_set_local_device_name(name, BT_DEVICE_NAME_BUFFER_SIZE);
}
SM128BitKey keys[SMRootKeyTypeNum];
if (shared_prf_storage_get_root_key(SMRootKeyTypeEncryption, &keys[SMRootKeyTypeEncryption]) &&
shared_prf_storage_get_root_key(SMRootKeyTypeIdentity, &keys[SMRootKeyTypeIdentity])) {
#if !defined(R... | {
BtPersistBondingData data;
prv_file_get(&id, sizeof(id), &data, sizeof(data));
return data.type;
} |
bool prv_delete_pairing_with_type_by_id(BTBondingID bonding, BtPersistBondingType type,
BtPersistBondingData *data_out) {
if (!prv_file_get(&bonding, sizeof(bonding), data_out, sizeof(*data_out))) {
return false;
}
if (data_out->type != type) {
PBL_LOG(LOG_LEVEL_... |
((uintptr_t)reset_handler) | ;
dbgserial_newline();
dbgserial_newline();
prv_hw_reset();
// The Cortex-M user guide states that the reset values for the core registers
// are as follows:
// R0-R12 = Unknown
// MSP = VECTOR_TABLE[0] (main stack pointer)
// PSP = Unknown (process stack pointer)
// LR = 0xFFFFFF... | |
vel for i18n ownership
if (!root_level) {
root_level = postpone_level;
}
action_menu_level_add_action(postpone_level,
i18n_get("In 15 minutes", root_level),
prv_postpone_15_minutes,
action);
if (show_later_today)... | kernel_ui_set_current_timeline_item_action_source(source) | ;
prv_request_responsive_session();
ActionMenuConfig config = {
.context = item,
.colors.background = bg_color,
.did_close = did_close_cb,
.root_level = prv_create_responses_level(reply_action, NULL, standalone_reply),
};
return timeline_actions_push_action_menu(&config, window_stack);
}
void 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... | {
return __jerryRefs.acquire($0);
} | |
;
#endif
}
static void prv_int_exti_cb(bool *should_context_switch) {
// The controller responded -- stop the watchdog.
prv_watchdog_stop();
switch (s_spi_transport.state) {
case SPITransportState_Idle:
// If the RX buffer is full, defer ack'ing the Dialog INT until we have
// some room to actua... | PBL_LOG(LOG_LEVEL_INFO, "Skipping host transport enqueue .. waiting for reset") | ;
return HostTransportEnqueueStatus_Failure;
}
PBL_ASSERTN(length < HOST_TRANSPORT_HOST_TX_BUFFER_SIZE &&
length < HOST_TRANSPORT_CTLR_RX_BUFFER_SIZE);
prv_lock();
bool success = circular_buffer_write(&s_spi_transport.tx, data, length);
prv_unlock();
if (success) {
prv_indicate_has_... |
SessionOpen:
prv_outbox_try_send_next();
DBG("SessionOpen enter");
}
static void prv_session_open__after_exit(void) {
DBG("After SessionOpen exit");
prv_cleanup_inbound_reassembly_buffer();
if (s_state.out.object_queue) {
// Make sure we'll re-transfer the object from the start when re-opening:
Out... | {
// TODO: document this in statechart
prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorMalformedResetComplete);
return;
} |
const PostMessageResetCompletePayload *rc =
(const PostMessageResetCompletePayload *) tuple->value[0].data;
// Check overlap in supported versions
if (!prv_is_version_supported(rc)) {
// Don't send an error here! The initiating side is supposed have detected the version
// incompatibili... |
const int16_t icon_on_left_title_subtitle_vertical_spacing_offset = -3;
if (icon_align == GAlignTop) {
// Set the title text's frame origin at the bottom of the icon's frame
title_text_frame_origin_y = grect_get_max_y(&rect);
} else if (icon_on_left) {
// Move content to the right for the icon on the ... |
graphics_draw_text(ctx, config->subtitle, subtitle_font, rect, config->overflow_mode,
text_alignment, NULL);
}
// Draw the title, which we're guaranteed to have room for because otherwise we would have bailed
// out at the beginning of this function
// Reuse rect as the title text f... | |
ation and then clips a full-screen red rectangle to the resulting mask
static void prv_left_flip_half_frame_clipping(GContext *ctx) {
compositor_round_flip_transitions_flip_animation_update(ctx, ANIMATION_NORMALIZED_MAX / 2,
CompositorTransitionDirectionLeft,... | compositor_round_flip_transitions_flip_animation_update(ctx, ANIMATION_NORMALIZED_MAX / 2,
CompositorTransitionDirectionRight,
GColorWhite) | ;
}
void test_graphics_window_stack_animation__right_flip_half_frame_clipping(void) {
prv_test_clipping_mask(prv_right_flip_half_frame_clipping, "right_flip_half_frame_clipping");
};
// This test records a clipping mask of the 3/4 progress frame of the right "round flip" compositor
// transition animation and then ... |
/*
* 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_hex(address) | |
/*
* 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_fb, &(GSize) {DISP_COLS, DISP_ROWS}) | |
/*
* 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_user_data() | ;
++data->count;
snprintf(data->count_str, 10, "%d", data->count);
text_layer_set_text(&data->count_layer, data->count_str);
}
static void handle_bt_connection(bool connected) {
EventServiceAppData *data = app_state_get_user_data();
text_layer_set_text(&data->connected_layer, connected ? "connected" : "disco... |
);
}
static size_t s_consumer_data_length = 1;
static void prv_register(void) {
app_outbox_service_register(AppOutboxServiceTagUnitTest,
prv_message_handler,
PebbleTask_KernelMain,
s_consumer_data_length);
}
void test_app_out... | fake_kernel_malloc_mark_assert_equal() | ;
}
void test_app_outbox__unregister_with_pending_message(void) {
fake_kernel_malloc_mark();
prv_register();
app_outbox_send(s_test_data, s_test_data_length,
test_app_outbox_sent_handler, s_expected_cb_ctx);
cl_assert(s_last_message);
app_outbox_service_unregister(AppOutboxServiceTagUnitT... |
/*
* 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(BITS_BETWEEN(0, 0), erased_sector) | ;
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sector(void) {
cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_some_sectors_from_beginning(void) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_IF_COLOR_ELSE(2, 3) | );
}
static void handle_init(void) {
ProgressAppData *data = app_zalloc_check(sizeof(ProgressAppData));
app_state_set_user_data(data);
Window* window = &data->window;
window_init(window, WINDOW_NAME("Progress Demo"));
window_set_user_data(window, data);
window_set_click_config_provider_with_context(window... |
PACKED {
uint8_t command;
Uuid uuid;
} AppStateMessage;
struct CommSession {
};
typedef struct PACKED {
AppState state:8;
Uuid uuid;
} AppRunState;
// Globals
///////////////////////////////////////
CommSession *s_session = NULL;
static uint8_t s_launcher_deprecated_messages = 0;
static uint8_t s_app_run_s... | (s_launcher_deprecated_messages, 2) | |
ther express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "launcher_app_glance_settings.h"
#include "launcher_app_glance_structured.h"
#include "launcher_menu_layer.h"
#include "applib/battery_state_service.h"
#include "applib/graph... | GSize(BATTERY_SILHOUETTE_ICON_WIDTH,
BATTERY_SILHOUETTE_ICON_HEIGHT) | ;
if (render) {
// This points array is static to help conserve stack usage
static const GPoint s_battery_silhouette_path_points[] = {
{0, 0},
{BATTERY_SILHOUETTE_ICON_WIDTH - 1, 0},
{BATTERY_SILHOUETTE_ICON_WIDTH - 1, 1},
{BATTERY_SILHOUETTE_ICON_WIDTH + 1, 2},
{BATTERY_SILHOUE... |
// Clipping on odd boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_ODD, OFFSET_RECT_ODD, false, 1);
for (int16_t row = 0; row < MAX_NUM_ROWS; row++) {
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, row), MAX_NUM_COLS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_P... | {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
} |
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_odd_clip")));
}
void test_graphics_draw_line___even_offset_vertical_dotted(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test odd and even cols draw appropriately
setup_test_aa_sw(&ctx, fb, ... |
+= config->separator.h;
for (int i = 0; i < config->separator.h; i++) {
// First point from bottom will be +0, second +1, third +0, etc.
separator_start_point.y--;
separator_start_point.x += i & 1;
graphics_draw_horizontal_line_dotted(ctx, separator_start_point, separator_width);
separ... | if (num_rows - row >= SHORT_ITEM_MAX_ROWS_SPALDING) {
grect_align(&arrow_rect, aml_bounds, GAlignBottom, true /* clip */);
content_indicator_draw_arrow(ctx, &arrow_rect, ContentIndicatorDirectionDown, fg_color,
bg_color, GAlignBottom);
} | |
/*
* 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_ASSERTN(text_layer) | ;
*text_layer = (TextLayerLegacy2){};
text_layer->layer.frame = *frame;
text_layer->layer.bounds = (GRect){{0, 0}, frame->size};
text_layer->layer.update_proc = (LayerUpdateProc)text_layer_legacy2_update_proc;
text_layer->text_color = GColor2Black;
text_layer->background_color = GColor2White;
text_layer->... |
d(command_list, 2);
*command = (GDrawCommand) {
.type = GDrawCommandTypePath,
.hidden = false,
.stroke_color = GColorGreen,
.stroke_width = 1,
.fill_color = GColorPurple,
.path_open = false,
.num_points = 3,
};
GPoint points2[] = { { 6, 7 }, {5, 5}, { 0, 0 } };
memcpy(command->points... | (!gdraw_command_image_validate(image, size - 1)) | ;
cl_assert(!gdraw_command_image_validate(image, size + 1));
cl_assert_equal_i(size, gdraw_command_image_get_data_size(image));
image->version = 2;
cl_assert(!gdraw_command_image_validate(image, size));
free(image);
}
void test_gdraw_command__clone_image(void) {
cl_assert_equal_p(gdraw_command_image_clo... |
Functions *******************/
/***********************************************************/
static FlashTestErrorType prv_run_data_test(void) {
FlashTestErrorType status = FLASH_TEST_SUCCESS;
// Test each data bit using walking 1's method by toggling each data line
PBL_LOG(LOG_LEVEL_DEBUG, ">START - DATA TES... | for (bit_offset = 0; (bit_offset == 0) || (bit_offset & addr_mask); bit_offset <<= 1) {
if (bit_offset > base_addr) {
test_addr = bit_offset;
} else {
test_addr = base_addr + bit_offset;
}
if (test_addr >= FLASH_TEST_ADDR_END) {
break;
}
// skip erasing of ... |
}
if (display_logs) { PBL_LOG(LOG_LEVEL_DEBUG, ">>> Erasing sectors...complete"); }
// Write default data pattern to each power-of-two offset within the test region
for (bit_offset = 1; (bit_offset & addr_mask) != 0; bit_offset <<= 1) {
if (bit_offset > base_addr) {
test_addr = bit_offset;
} el... |
oop("TmplStringSing", " min"),
/// Plural suffix for minutes with abbreviated units
i18n_ctx_noop("TmplStringPlur", " min")},
/// Singular suffix for minutes with full units
{ i18n_ctx_noop("TmplStringSing", " minute"),
/// Plural suffix for minutes with full units
i18n_ctx_noop("TmplStringPlur", " minu... | if (*input == '%') { // Escaped %
prv_append_char(state, *input);
input++;
return input;
} |
FormatUnits add_units = FormatUnits_None;
bool zero_pad = false;
bool modulus = true;
bool checking_flags = true;
while (checking_flags) {
switch (*input) {
case 'a':
add_units = FormatUnits_Abbreviated;
break;
case 'u':
add_units = FormatUnits_Full;
break;
... |
x = (int)data;
PBL_ASSERTN(idx >= 0 && idx < NUM_MAX_TIMERS);
PBL_LOG(LOG_LEVEL_DEBUG, "STT long running callback %d executed", idx);
s_app_data->fired_time[idx] = rtc_get_ticks();
psleep(250);
return;
}
// =================================================================================
// Try and resched... | (index, ctx) | ;
// Repeating timer
s_app_data->timer[timer_idx_0] = new_timer_create();
bool success = new_timer_start(s_app_data->timer[timer_idx_0], 500, timer_callback, (void*)timer_idx_0,
TIMER_START_FLAG_REPEATING);
PBL_ASSERTN(success);
scheduled = new_timer_scheduled(s_app_da... |
app_inbox_service_begin(AppInboxServiceTagAppMessageReceiver, total_size, session) | ) {
rcv->is_writing_to_app_inbox = true;
// Log most recent communication timestamp
const AppInstallId app_id = app_manager_get_current_app_id();
app_install_mark_prioritized(app_id, true /* can_expire */);
// Write the header, this info is needed for the app to handle the message and reply:
c... | |
47483646LL, 17, "53g7f547", },
{ -2147483647LL, 17, "-53G7F548", },
{ -2147483647LL, 17, "-53g7f548", },
{ 2147483646LL, 18, "3928G3H0", },
{ 2147483646LL, 18, "3928g3h0", },
{ -2147483647LL, 18, "-3928G3H1", },
{ -2147483647LL, 18, "-3928g3h1", },
{ 2147483646LL, 19, "27C57H31", },
{ 2147483646LL, 19, ... | ("+-123", NULL, 10) | , 0);
}
void test_strtol__end(void) {
char *end;
char *s;
s = "";
strtol(s, &end, 10);
cl_assert_equal_p(s, end);
cl_assert_equal_i('\0', *end);
s = "123";
strtol(s, &end, 10);
cl_assert_equal_p(s+3, end);
cl_assert_equal_i('\0', *end);
s = "123a";
strtol(s, &end, 10);
cl_assert_equal_p(s+... |
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
flash_prf_set_protection(false);
power_tracking_start(PowerSystemFlashErase);
enable_flash_spi_clock();
handle_sleep_when_idle_begin();
flash_write_enable();
flash_start_cmd();
flash_send_and_... | (context, S_SUCCESS) | ;
}
|
/*
* 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... | i18n_get(text, i18n_owner) | ,
GColorWhite, GColorCobaltBlue, &callback, RESOURCE_ID_ACTION_BAR_ICON_CHECK,
expandable_dialog_close_cb);
i18n_free(text, i18n_owner);
expandable_dialog_show_action_bar(e_dialog, true);
expandable_dialog_set_header(e_dialog, i18n_get("You're all set", e_dialog));
app_expandable_dialog_push(e_dia... |
dy = abs(p1.y - p0.y);
int16_t err = dx / 2;
int16_t ystep;
if (p0.y < p1.y) {
ystep = 1;
} else {
ystep = -1;
}
for (; p0.x <= p1.x; p0.x++) {
if (steep) {
graphics_private_set_pixel(ctx, GPoint(p0.y, p0.x));
} else {
graphics_private_set_pixel(ctx, GPoint(p0.x, p0.y));
}... | if (dy > dx) {
// Y-major line; calculate 16-bit fixed-point fractional part of a
// pixel that X advances each time Y advances 1 pixel, truncating the
// result so that we won't overrun the endpoint along the X axis
error_adj = ((uint32_t)(dx) << 16) / (uint32_t) dy;
// Draw all pixels o... |
if (error_acc <= error_acc_temp) {
// The error accumulator turned over, so advance the Y coord
y1++;
}
x1 += xi;
weighting = error_acc >> intensity_shift;
graphics_private_plot_pixel(framebuffer, &ctx->draw_state.clip_box, x1, y1, weighting,
... |
timer.h"
#include "services/common/system_task.h"
#include "services/runlevel.h"
#include "shell/prefs.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/size.h"
#include <stdlib.h>
#define STATIONARY_PEEKING_TIME_MINS 5
#define STATIONARY_WAIT_BEFORE_ENGAGING_TIME_MINS 30
#define STATIONARY_EN... | analytics_inc(ANALYTICS_DEVICE_METRIC_STATIONARY_TIME_MINUTES, AnalyticsClient_System) | ;
prv_handle_action(StationaryActionGoToSleep);
}
}
//! The orientation of the accelerometer is checked every minute. If the orientation has
//! changed by a significant amount, we consider the watch as in motion, and restart the
//! stationary counter
static void prv_watch_is_in_motion(void) {
prv_handle_acti... |
rdraw color, if we are filling the inner ring
// if it's the outer ring (inner == false) this "key color" is GColorGreen,
// also we don't render the app's framebuffer in this case
// it's a bit weird but just they way how these SVGs have been designed
const GColor8 key_color = inner ? GColorIslamicGreen : GCol... | compositor_get_app_framebuffer_as_bitmap() | ;
// We assume that both source and destination are framebuffers using the native bitmap format
PBL_ASSERTN(app_framebuffer.info.format == framebuffer->info.format);
PBL_ASSERTN(app_framebuffer.data_row_infos == framebuffer->data_row_infos);
GBitmapDataRowInfo source_data_row_info = gbitmap_get_data_row_info(&... |
/*
* 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 (!weather_service_supported_by_phone()) {
return E_RANGE;
}
if (key_len != sizeof(WeatherDBKey) ||
val_len < (int) MIN_ENTRY_SIZE ||
val_len > (int) MAX_ENTRY_SIZE) {
return E_INVALID_ARGUMENT;
}
const WeatherDBEntry *entry = (WeatherDBEntry *)val;
if (entry->version != WEATHER_DB_... |
int weather_db_get_len(const uint8_t *key, int key_len) {
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
return 0;
}
PBL_ASSERTN(key_len == sizeof(WeatherDBKey));
int entry_len = settings_file_get_len(&s_weather_db.settings_file, key, key_len);
prv_close_file_and_unlock_mutex(... |
't passed on from activity service
void test_activity__hrm_ignore(void) {
int32_t median, total_weight;
s_num_hr_events = 0;
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*... | cl_assert_equal_i(metric_values[1], 22) | ;
cl_assert_equal_i(activity_metrics_prv_get_distance_mm(), 66 * MM_PER_METER);
activity_metrics_prv_set_metric(ActivityMetricActiveKCalories, Thursday, 22);
activity_metrics_prv_set_metric(ActivityMetricActiveKCalories, Wednesday, 33);
activity_get_metric(ActivityMetricActiveKCalories, 2, metric_values);
cl... |
/*
* 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... | {
scroll_layer_scroll(scroll_layer, dir, true);
} |
static void prv_offset_changed_handler(ScrollLayer *scroll_layer, void *context) {
ExpandableDialog *expandable_dialog = context;
ActionBarLayer *action_bar = &expandable_dialog->action_bar;
GPoint offset = scroll_layer_get_content_offset(scroll_layer);
if (!expandable_dialog->show_action_bar) {
// Prema... |
////////////////////////////////////////
void *app_malloc(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_malloc(app_state_get_heap(), bytes, saved_lr);
}
void *app_malloc_check(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap ... | {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap = kernel_heap_get();
void *mem = prv_strdup(heap, s, saved_lr);
if (!mem) {
PBL_CROAK_OOM(strlen(s) + 1, saved_lr, heap);
}
return mem;
} |
// Wrappers (Jay-Z, Tupac, etc)
// We want to keep these around for code bases that we don't own. For example, libc will want
// malloc to exist, and libc should use the appropriate heap based on the task.
////////////////////////////////////////////////////////////
void *__wrap_malloc(size_t bytes) {
register uint... |
.origin.x +
((src_x - src_bitmap->bounds.origin.x) % src_bitmap->bounds.size.w);
} else {
// Increment source but don't draw
continue;
}
}
// src points to the info for the row, so y and stride are 0 for raw_image_get_value
uint8_t cindex = raw_image_ge... | {
// keep correct bounds alignment for circular when tiling
src_x = src_bitmap->bounds.origin.x +
((src_x - src_bitmap->bounds.origin.x) % src_bitmap->bounds.size.w);
} | else {
// Increment source but don't draw
continue;
}
}
dest[dest_x] = src[src_x];
}
}
break;
}
case GCompOpTint:
case GCompOpTintLuminance:
case GCompOpSet:
default: {
// Initialize the tint luminance lookup tabl... |
list, size);
}
return result;
}
void gdraw_command_list_destroy(GDrawCommandList *list) {
if (list) {
applib_free(list);
}
}
static GDrawCommand *prv_next_command(GDrawCommand *command) {
return (GDrawCommand *) (command->points + command->num_points);
}
bool gdraw_command_list_validate(GDrawCommandL... | if (!processor) {
gdraw_command_list_iterate(command_list, prv_draw_command, ctx);
} else {
const size_t max_size = prv_get_list_max_command_size(command_list);
GDrawCommandDrawProcessedCBData data = {
.ctx = ctx,
.list = command_list,
.processor = processor,
// malloc because we ... |
}
static bool prv_calc_size(GDrawCommand *command, uint32_t idx, void *ctx) {
size_t *size = ctx;
*size += gdraw_command_get_data_size(command);
return true;
}
uint32_t gdraw_command_list_get_num_commands(GDrawCommandList *command_list) {
if (!command_list) {
return 0;
}
return command_list->num_co... |
normalize_angle(angle_end);
int8_t starting_quadrant_normalized = (angle_start_normalized / QUADRANT_ANGLE) % 4;
int8_t ending_quadrant_normalized = (angle_end_normalized / QUADRANT_ANGLE) % 4;
if (starting_quadrant_normalized == ending_quadrant_normalized) {
// Both indicate same quadrant...
config.sta... | (radius_inner_y.raw_value * radius_inner_y.raw_value) >> FIXED_S16_3_PRECISION;
// Intersection points of angles and radiuses
GPointPrecise start_top =
prv_get_rotated_precise_point_for_ellipsis(center,
radius_outer_x.raw_value, radius_outer_y.raw_value,... |
// Special case to make bottom edge to be on left side and keep masking algorithm happy
prv_swap_precise_points(&start_top, &start_bottom);
}
if (end_top.y.raw_value > end_bottom.y.raw_value) {
prv_swap_precise_points(&end_top, &end_bottom);
} else if (end_top.y.raw_value == end_bottom.y.raw_value &... |
/*
* 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... | (0xf5f5dc) | },
{"bisque", GColorARGB8FromHEX(0xffe4c4)},
{"blanchedalmond", GColorARGB8FromHEX(0xffebcd)},
{"blueviolet", GColorARGB8FromHEX(0x8a2be2)},
{"brown", GColorARGB8FromHEX(0xa52a2a)},
{"burlywood", GColorARGB8FromHEX(0xdeb887)},
// {"cadetblue", GColorARGBFromHEX(0x5f9ea0)}, inconsistent with Pebble color
{"... |
HOUT 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 "text.h"
#include "text_resources.h"
#include "syscall/syscall.h"
#include "applib/fonts/fonts.h"
#include "applib/fonts/fonts_pr... | (text_render_flash) | ;
offset = s_font_md_size[version] +
(sizeof(FontHashTableEntry) * font_res->md.hash_table_size) + table_entry.offset;
num_bytes = table_entry.count * prv_offset_table_entry_size(&font_res->md);
num_entries = table_entry.count;
PBL_ASSERTN(num_bytes <= sizeof(font_cache->offsets_buffer_4... |
_install_manager.h"
#include "process_management/app_manager.h"
#include "services/common/new_timer/new_timer.h"
#include "services/normal/audio_endpoint.h"
#include "services/normal/voice/transcription.h"
#include "services/normal/voice_endpoint.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#inc... | { // we error'ed out
return;
} |
if (s_state == SessionState_StartSession) {
// we are still waiting for one of the subsystems to be ready
s_state = transition_to_state;
} else {
PBL_ASSERTN((s_state == SessionState_VoiceEndpointSetupReceived ||
s_state == SessionState_AudioEndpointSetupReceived) &&
(... |
mock_cleanup();
clar_unsandbox();
return _clar.total_errors;
}
char *strdup(const char *s1);
void
clar__assert(
int condition,
const char *file,
int line,
const char *error_msg,
const char *description,
int should_abort)
{
struct clar_error *error;
if (condition)
return;
#ifndef _WIN32
#ifd... | {
// Just don't print ASCII for the zeroth line.
if (i != 0) {
printf(" %s\n", buff);
}
// Output the offset.
printf(" %04x ", i);
} |
// Now the hex code for the specific character.
printf(" %02x", pc[i]);
// And store a printable ASCII character for later.
if ((pc[i] < 0x20) || (pc[i] > 0x7e)) {
buff[i % 16] = '.';
} else {
buff[i % 16] = pc[i];
}
buff[(i % 16) + 1] = '\0';
}
// Pad out last line if no... |
ubscribe(ButtonId button_id, uint8_t min_clicks, uint8_t max_clicks, uint16_t timeout,
bool last_click_only, ClickHandler handler) {
Window *window = window_manager_get_top_window();
prv_check_is_in_click_config_provider(window, "subscribe");
ClickManager *mgr = prv_get_current_c... | (&window->layer) | ;
window->on_screen = new_on_screen;
if (window->on_screen) {
window_schedule_render(window);
// The click provider was set but not updated
if (window->is_waiting_for_click_config && !window->is_unfocusable) {
prv_call_click_provider(window);
}
} else {
window->is_render_scheduled = fal... |
layer->layouts_info[i] = layer->layouts_info[i - 1];
}
layer->layouts[0] = NULL;
layer->layouts_info[0] = NULL;
}
layer->move_delta = delta * prv_get_scroll_delta(layer);
// hide other day's pins before the animation shows them
prv_hide_non_current_day_items(layer);
}
TimelineLayout *timeline_... | (animation, (AnimationHandlers) {
.stopped = timeline_animation_layer_stopped_cut_to_end,
}, animation) | ;
return animation;
}
Animation *timeline_layer_create_bounce_back_animation(TimelineLayer *layer, GPoint direction) {
Animation *animations[TIMELINE_NUM_VISIBLE_ITEMS + 2] = {};
int num_animations = 0;
for (int i = 0; i < TIMELINE_NUM_VISIBLE_ITEMS; i++) {
TimelineLayout *layout = layer->layouts[s_visibl... |
/*
* 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 true;
} |
//! Interrupt masks for InterruptStatus1 and InterruptMask1 registers
enum PmicInt1 {
PmicInt1_Trickle = (1 << 0), //!< Trickle charge
PmicInt1_NoBat = (1 << 1), //!< Battery detached
PmicInt1_Resume = (1 << 2), //!< Resuming charge on drop after full
PmicInt1_EOC = (1 << 3), //!< End of charge
PmicI... |
(normalized, from.y, to.y) | ,
};
}
int16_t scale_int16(int16_t value, int16_t from, int16_t to) {
return (int16_t) ((int32_t) value * to / from);
}
int32_t scale_int32(int32_t value, int32_t from, int32_t to) {
return (int32_t) ((int64_t) value * to / from);
}
// -------------------------------------------------------
// these values ar... | |
et_reel(&peek_layer->kino_layer);
if (prev_reel) {
icon_from = kino_reel_get_elapsed(prev_reel) ? kino_reel_transform_get_to_frame(prev_reel)
: kino_reel_transform_get_from_frame(prev_reel);
}
kino_layer_set_reel(&peek_layer->kino_layer, NULL, false);
KinoRe... | (peek_layer) | ;
return kino_layer_create_play_section_animation(&peek_layer->kino_layer, from_elapsed_ms,
to_elapsed_ms);
}
void peek_layer_play(PeekLayer *peek_layer) {
prv_set_visible(peek_layer);
kino_layer_play(&peek_layer->kino_layer);
}
GSize peek_layer_get_size(PeekLay... |
;
TimelineItemActionSource current_timeline_item_action_source;
GBitmap *legacy2_framebuffer;
} AppState;
KERNEL_READONLY_DATA static AppState *s_app_state_ptr;
bool app_state_configure(MemorySegment *app_state_ram,
ProcessAppSDKType sdk_type,
int16_t obstructio... | (app_state_get_health_service_state()) | ;
#endif
unobstructed_area_service_deinit(app_state_get_unobstructed_area_state());
}
Heap *app_state_get_heap(void) {
return &s_app_state_ptr->heap;
}
struct tm *app_state_get_gmtime_tm(void) {
return &s_app_state_ptr->gmtime_tm;
}
struct tm *app_state_get_localtime_tm(void) {
return &s_app_state_ptr->localt... |
/*
* 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(cron_service_get_job_count(), 0) | ;
cron_job_schedule(job);
cl_assert_equal_i((uintptr_t)job->cb_data, 0);
cl_assert_equal_i(job->cached_execute_time, target);
cl_assert_equal_i(cron_service_get_job_count(), 1);
// Mutate the execute time to see if we actually effect change.
job->cached_execute_time = UINT32_MAX;
job->clock_change_toler... |
assert_equal_p(s_stroke_points, NULL);
cl_assert_equal_p(s_fill_points, NULL);
prv_reset();
// set stroke width to non-zero value. stroke should be drawn, but no fill
gdraw_command_set_stroke_width(command, 2);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorRedARGB8);
cl_... | cl_assert_equal_i(1, s_path_fill_precise_count) | ;
cl_assert(prv_compare_points((GPoint*)points, s_fill_points, s_path_num_points));
cl_assert_equal_i(1, s_path_stroke_precise_count);
cl_assert_equal_b(false, s_path_open);
cl_assert(prv_compare_points((GPoint*)points, s_stroke_points, s_path_num_points));
prv_reset();
// change to open path and ensure t... |
oOK);
// Verify (only) the app task got a (virtual) connection event:
prv_assert_client_event(&device, true /* connected */, (1 << PebbleTask_App),
HCI_ERROR_CODE_SUCCESS);
}
void test_gap_le_connect__register_for_already_connected_bonding(void) {
BTErrno e;
BTDeviceInternal device =... | gap_le_connect_connect(&device,
false /* no auto_reconnect */,
false /* is_pairing_required */,
GAPLEClientApp) | ;
prv_fake_disconnect(&device, true /* is_master */);
// Verify both app task and kernel got the (virtual) disconnection event:
prv_assert_client_event(&device, false /* connected */,
(1 << PebbleTask_App) | (1 << PebbleTask_KernelMain),
HCI_ERROR_CODE_CONNECT... |
timezone_length_ptr = data + offsetof(TimezoneCBData, region_name_len);
if (length != (sizeof(uint8_t) + header_size + *timezone_length_ptr)) {
PBL_LOG(LOG_LEVEL_WARNING, "Set timezone message invalid length");
return;
}
TimezoneCBData *timezone_data = (TimezoneCBData *)data;
pr... | {
i18n_get_with_buffer("Today", buffer, buffer_size);
} | else {
i18n_get_with_buffer("All day", buffer, buffer_size);
}
}
static void prv_copy_relative_time_string(char *number_buffer, uint8_t number_buffer_size,
char *word_buffer, uint8_t word_buffer_size, time_t timestamp, time_t end_time) {
time_t now = rtc_get_time();
// average without overflows since ti... |
/*
* 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... | {
fake_app_timer_init();
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
s_framebuffer = malloc(sizeof(FrameBuffer));
framebuffer_init(s_framebuffer, &(GSize) { DISP_COLS, DISP_ROWS });
s_app_window_stack_get_top_window = (Window){};
prv_init_gcontext((GSize) { DISP_COLS, DISP_ROWS });
s_a... | |
ET_RECT_EVEN, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_checkerboard_no_clip")));
// Clipping on even bounda... | gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_checkerboard_no_clip")) | );
// Clipping on even boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_EVEN, OFFSET_RECT_ODD, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_N... |
margin = 6,
.fat_pin_height = 131,
// PBL-42540: This property is dependent on the screen size.
.thin_pin_height = 88,
.day_sep_dot_diameter = 12,
.day_sep_offset.y = -21,
.past_day_sep_dot_offset_y = -16,
.future_day_sep_dot_offset_y = 16,
};
static const TimelineLayerStyle * const s_styles[NumPreferred... | prv_get_style() | ;
gpoint_add_eq(&frame->origin,
GPoint(style->fin_offset_x,
is_future ? style->future_fin_offset_y : style->past_fin_offset_y));
frame->size.w -= PBL_IF_RECT_ELSE(style->sidebar_width, 0);
}
static void prv_get_day_sep_frame(TimelineLayer *layer, int index, GRect *frame) {
... |
hasn't already been removed
const int minute_of_day = time_util_get_minute_of_day(now_utc);
if ((minute_of_day < s_activity_summary_settings.summary.activity.trigger_minute) ||
s_activity_pin_state.removed) {
INSIGHTS_LOG_DEBUG("Not adding activity pin - before trigger time (%d < %d) or removed (%d)",
... | (&s_open_intros, VARIANT_RANDOM) | ;
}
default: {
break;
}
}
return "";
}
// ------------------------------------------------------------------------------------------------
static const char *prv_get_distance_unit(void *i18n_owner) {
return health_util_get_distance_string(i18n_get("MI", i18n_owner), i18n_get("KM", i18n_owner)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (*data->failed, false) | ;
*data->failed = true;
}
}
static void prv_sub_event_handler(const Recognizer *recognizer, RecognizerEvent event) {
RecognizerEvent *event_type = recognizer_get_user_data(recognizer);
if (event_type) {
*event_type = event;
}
}
Recognizer *test_recognizer_create(TestImplData *test_impl_data, void *use... |
/*
* 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_CROAK_OOM(bytes, saved_lr, heap) | ;
}
return mem;
}
char *task_strdup(const char *s) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return prv_strdup(task_heap_get_for_current_task(), s, saved_lr);
}
// app_* functions that allocate on the app heap
///////////////////////////////////////////////////////////
void *app_malloc(... |
ager_set_compiled_with_legacy2_sdk(is_legacy2);
int16_t y_offset = 0;
for (unsigned int row_index = 0; row_index < num_rows; row_index++) {
const MenuLayerSystemCellTestRowData row_data =
s_menu_system_cell_test_row_data[row_index];
for (unsigned int row_height_index = 0; row_height_index < num_ro... | (s_dest_bitmap, TEST_PBI_FILE) | );
}
|
de "stubs_memory_layout.h"
#include "stubs_menu_cell_layer.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_print.h"
#include "stubs_process_manager.h"
#include "stubs_prompt.h"
#include "stubs_serial.h"
#include "stubs_shell_prefs.h"
#... | (&selection_window, SELECTION_COLOR, NULL, NULL) | ;
selection_window.from.hour = 16;
selection_window.from.minute = 20;
selection_window.to.hour = 18;
selection_window.to.minute = 9;
// Set the window on screen so its window handlers will be called
window_set_on_screen(&selection_window.window, true, true);
window_render(&selection_window.window, ctx)... |
dle_notification_added_common(Uuid *id, NotificationType type) {
if (!alerts_should_notify_for_type(prv_alert_type_for_notification_type(type))) {
return;
}
NotificationWindowData *data = &s_notification_window_data;
// will fail and return early if already init'ed.
prv_init_notification_window(true /*i... | (&s_notification_window_data) | |
tart_handler(ClickRecognizerRef recognizer, void *context) {
prv_toggle_playing();
prv_set_action_bar_state(context, ActionBarStateLongPress);
prv_do_haptic_feedback_vibe(context);
}
static void prv_play_pause_long_click_end_handler(ClickRecognizerRef recognizer, void *context) {
prv_set_action_bar_state(conte... | (&window->text_layer,
&NO_MUSIC_TEXT_RECT,
i18n_get("START PLAYBACK\nON YOUR PHONE", window),
fonts_get_system_font(config->no_music_font_key),
GColorBlack, GColorClear, GTextAlignment... | ;
layer_add_child(&window->window.layer, &window->bitmap_layer.layer);
layer_add_child(&window->window.layer, &window->text_layer.layer);
window_set_click_config_provider(&window->window, prv_no_music_window_click_config);
return window;
}
static void prv_push_no_music_window(MusicAppData *data) {
if (data->... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | va_start(fmt_args, fmt) | ;
prv_handle_passert_failed_vargs(filename, line_number, lr, expr, fmt, fmt_args);
va_end(fmt_args);
}
void passert_failed(const char* filename, int line_number, const char* message, ...) {
va_list fmt_args;
va_start(fmt_args, message);
prv_handle_passert_failed_vargs(filename, line_number,
(uintptr_t... |
Missile Command",
.icon = TIMELINE_RESOURCE_TIMELINE_CALENDAR,
.num_concurrent = 0,
}, false /* animated */);
TimelinePeek *peek = timeline_peek_get_peek();
const Layer *layer = &peek->layout_layer;
// Normally it is animated, but for this unit test, we don't request `animated`
cl_assert(layer->frame.... | (false, false /* animated */) | ;
// Peek should be hidden and off-screen.
cl_assert(layer->frame.origin.y >= DISP_ROWS);
// Transition back to the watchface
s_is_watchface_running = true;
timeline_peek_set_visible(true, false /* animated */);
// Peek should be visible again, but it should still be off-screen.
cl_assert(layer->frame.or... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.