prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 5);
cl_assert(circular_buffer_write(&buffer, (uint8_t*) "456", 3));
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(!circular_buffer_write(&buffer, (uint8_t*) "789", 3)); // too big
cl_assert_equal_i(circular_buf... | circular_buffer_copy_offset(&buffer, 3 /* start_offset */,
data_out, data_out_size) | , 1);
cl_assert(memcmp("3", data_out, 1) == 0);
// Offset as long as the available data:
cl_assert_equal_i(circular_buffer_copy_offset(&buffer, 4 /* start_offset */,
data_out, data_out_size), 0);
// Free up 2 bytes at the beginning:
circular_buffer_consume(&bu... |
/*
* 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 int32_t right_cropped_columns_count = MAX(0, rect.size.w - clipped_rect.size.w -
left_cropped_columns_count);
if (top_cropped_rows_count) {
// Skip over rows for each one that's cropped off the top.
corner_insets_left >>= 4 * MIN(top_cropped_rows_coun... | |
rning permissions and
* limitations under the License.
*/
#include "kino_layer.h"
#include "applib/applib_malloc.auto.h"
#include "applib/graphics/graphics.h"
static void prv_update_proc(Layer *layer, GContext *ctx) {
KinoLayer *kino_layer = (KinoLayer *)layer;
// Fill background
if (kino_layer->background_... | kino_player_create_play_section_animation(&kino_layer->player, from_position,
to_position) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | memcpy(ps1->str_value, ps1_str, strlen(ps1_str)) | ;
const char *ps2_str = "Four";
uint8_t ps2_buf[128];
PascalString16 *ps2 = (PascalString16 *)&ps2_buf;
ps2->str_length = strlen(ps2_str);
memcpy(ps2->str_value, ps2_str, strlen(ps2_str));
const char *ps3_str = "PhilG";
uint8_t ps3_buf[128];
PascalString16 *ps3 = (PascalString16 *)&ps3_buf;
ps3->str... |
cking_ui.h"
#include "resource/resource_ids.auto.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/activity/activity.h"
#include "services/normal/alarms/alarm.h"
#include "system/logging.h"
#include "system/passert.h"
#include <string.h>
#define ALARM_DAY_LIST_CELL_HEIGHT PBL_IF_RECT_ELSE(menu_cell_... | (&data->day_picker_menu_layer) | ;
prv_remove_windows(data);
i18n_free_all(&data->day_picker_window);
task_free(data);
data = NULL;
}
static void prv_handle_selection(int index, void *callback_context) {
AlarmEditorData *data = (AlarmEditorData *)callback_context;
data->day_picker_was_completed = true;
data->alarm_kind = prv_index_to_... |
/*
* 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_attr_list.attributes[i] = existing_notif_prefs->attr_list.attributes[i];
} |
}
char msg_buffer[message->length + 1];
memcpy(msg_buffer, message->value, message->length);
msg_buffer[message->length] = '\0';
attribute_list_add_cstring(&new_attr_list, AttributeIdAuthCode, msg_buffer);
// This will trigger a sync sending the auth code to the phone
ios_notif_pref_db_store_prefs(app_... |
(LOG_LEVEL_DEBUG, "Name: %s", remote->name) | ;
settings_bluetooth_update_remotes(remote_data->bt_data);
prv_show_dialog(context);
}
#if CAPABILITY_HAS_BUILTIN_HRM
static GAPLEConnection *prv_le_connection_for_stored_remote(const StoredRemote *const remote) {
switch (remote->type) {
case StoredRemoteTypeBLE: return remote->ble.connection;
case Store... | |
(bonding, op) | ;
bt_pairability_update_due_to_bonding_change();
}
static BTBondingID prv_bt_persistent_storage_store_ble_pairing(
const SMPairingInfo *new_pairing_info, bool is_gateway, bool requires_address_pinning,
uint8_t flags, const char *device_name, BtPersistBondingOp op) {
if (new_pairing_info && is_gateway) {
... | |
ic void (*s_process_manager_callback)(void *data);
static void *s_process_manager_callback_data;
void sys_current_process_schedule_callback(CallbackEventCallback async_cb, void *ctx) {
// Expecting the stub to be called only once durning a test:
cl_assert_equal_p(s_process_manager_callback, NULL);
cl_assert_equal... | cl_assert_equal_b(app_message_is_accepting_outbound(), false) | ;
prv_call_outbox_sent(AppOutboxStatusSuccess);
// After the ACK has been received, we should have been called
cl_assert_equal_b(s_ack_sent_is_called, true);
// Since that callback schedules another callback, we have to invoke
// system tasks again to get th actual callback to trigger.
cl_assert_equal_i(s... |
orizontal_line_dotted(&ctx, GPoint(0, 16), 21);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 18), 22);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 20), 143);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 22), 145);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("d... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 14), 20) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 16), 21);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 18), 22);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 20), MAX_NUM_COLS - 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 22), MAX_NUM_COLS + 1);
cl_check(gbitmap_pbi_eq(&ct... |
o->dst_id == DSTID_LORDHOWE) {
uxtime -= time_tm.tm_isdst ? SECONDS_PER_HOUR / 2 : 0;
} else {
uxtime -= time_tm.tm_isdst ? SECONDS_PER_HOUR : 0;
}
uxtime -= time_tm.tm_gmtoff;
return uxtime;
}
#endif // RECOVERY_FW
T_STATIC void prv_update_dstrule_timestamps_by_dstzone_id(TimezoneInfo *tz_info, time_t... | clock_get_timezone_region_id() | != UNKNOWN_TIMEZONE_ID) {
// If we have a timezone _actually_ set, update our own.
int region_id = clock_get_timezone_region_id();
prv_clock_get_timezone_info_from_region_id(region_id, tz_adjust_time, &tz_adjust_info);
tz_info = &tz_adjust_info; // We need to set timezone info so point to the n... |
s(start_ms + 1);
cl_assert_equal_gtransform(value, start_value);
// Halfway through
prv_advance_to_ms_with_timers(start_ms + duration/2);
cl_assert_close_gtransform(value, mid_value);
// End
prv_advance_to_ms_with_timers(start_ms + duration + MIN_FRAME_INTERVAL_MS*2);
cl_assert_equal_gtransform(value, e... | animation_set_duration(h, duration) | ;
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(h);
// Test the accessor functions
uint32_t test_value;
property_animation_get_from_uint32(prop_h, &test_value);
cl_assert_equal_i(test_value, start_value);
property_animation_get_to_uint32(prop_h, &test_value);
... |
struct LCPPacket *packet) {
if (this->state->link_state == LinkState_Opened) {
struct LCPPacket *reply = pulse_link_send_begin(this->protocol_number);
memcpy(reply, packet, ntoh16(packet->length));
reply->code = ControlCode_EchoReply;
pulse_link_send(reply, ntoh16(packet->length));
}
}
static ... | {
mutex_lock(s_reliable_timer_state_lock);
RtcTicks timeout_ticks = timeout_ms * RTC_TICKS_HZ / 1000;
s_reliable_timer_expiry_time_tick = rtc_get_ticks() + timeout_ticks;
s_reliable_timer_sequence_number = sequence_number;
// Wake up the PULSE task to get it to notice the newly-started timer.
xSemaphoreGive... |
void pulse2_reliable_retransmit_timer_cancel(void) {
mutex_lock(s_reliable_timer_state_lock);
s_reliable_timer_expiry_time_tick = 0;
// No need to wake up the PULSE task. It will notice that the timer was
// cancelled when it wakes up to service the timer.
mutex_unlock(s_reliable_timer_state_lock);
}
// Ch... |
p ? y_min + 1 : y_min); y <= y_max; y++) {
if (y > lm_p1.y.integer) {
// We're crossing far_left point, time to swap...
lm_p0 = far_left;
lm_p1 = far_bottom;
}
if (y > rm_p1.y.integer) {
// We're crossing far_right point, time to swap...
rm_p0 = far_right;
... | ((MIN(p0.x.raw_value, p1.x.raw_value) - radius.raw_value)
>> FIXED_S16_3_PRECISION, clip_min_x, clip_max_x) | ;
const int16_t x_max = CLIP((MAX(p0.x.raw_value, p1.x.raw_value) + radius.raw_value)
>> FIXED_S16_3_PRECISION, clip_min_x, clip_max_x);
// Blending of first line
if (fraction_for_left != 0) {
int16_t x = x_min;
if (x > tm_p1.x.integer) {
// We're crossi... |
app_install_get_entry_for_install_id(music_id, &id_entry) | );
cl_assert_equal_b(true, app_install_get_entry_for_uuid(&music_uuid, &uuid_entry));
cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry));
cl_assert_equal_b(true, app_install_get_entry_for_install_id(sports_id, &id_entry));
cl_assert_equal_b(true, app_install_get_entry_for_uuid(&sports_u... | |
tc_get_time_ms(&s, &ms);
return ((uint64_t)s) * 1000 + ms;
}
// ---------------------------------------------------------------------------------------------
// Update the driver configuration based on requested params from each subscriber
static void prv_update_driver_config(void) {
if (!s_enabled) {
//do no... | DEFINE_SYSCALL(int, sys_accel_manager_peek, AccelData *accel_data) | {
int result;
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) {
... |
a->mic_window.mic_dot_anim)) {
animation_unschedule(data->mic_window.mic_dot_anim);
}
const GRect *root_frame = &window_get_root_layer(&data->mic_window.window)->frame;
GRect dot_frame = data->mic_window.mic_dot_layer.frame;
grect_align(&dot_frame, root_frame, GAlignCenter, false);
layer_set_frame(&data-... | {
return;
} |
progress_layer_set_progress((ProgressLayer *)&data->mic_window.progress_bar, 0);
animation_unschedule((Animation *)data->mic_window.progress_anim);
data->mic_window.progress_anim = prv_create_int16_prop_anim(0, MAX_PROGRESS_FUDGE_AMOUNT,
PROGRESS_FUDGE_DURATION, &s_progress_bar_impl, data);
if (data->m... |
turn *(BTDeviceInternal *)(&device);
}
static BTDeviceInternal prv_connected_dummy_device(uint8_t octet) {
BTDeviceInternal device = prv_dummy_device(octet);
gap_le_connection_add(&device, NULL, true /* local_is_master */);
s_connection = gap_le_connection_by_device(&device);
s_connection->gatt_connection_id =... | {
prv_assert_notification_event_ext(characteristic, value, assert_value_length, kernel, app,
true /* should_consume */);
} |
static void prv_simulate_and_assert_discovery_of_one_service(const BTDeviceInternal *device) {
// Simulate discovery of Blood Pressure service:
fake_gatt_put_discovery_indication_blood_pressure_service(TEST_GATT_CONNECTION_ID);
// Simulate discovery of random 128-bit service:
fake_gatt_put_discovery_indicatio... |
/*
* 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... | MAX(0, ctx_size->w - 2 * inset) | };
}
const GPerimeter * const g_perimeter_for_display = &(const GPerimeter) {
.callback = PBL_IF_RECT_ELSE(perimeter_for_display_rect, perimeter_for_display_round),
};
|
} else {
packet_len = sizeof(GetBytesRspObjectInfo);
}
SendBuffer *sb;
if (packet_len == 0 ||
!(sb = comm_session_send_buffer_begin_write(state->session, GET_BYTES_ENDPOINT_ID, packet_len,
COMM_SESSION_DEFAULT_TIMEOUT))) {
// If timeout, try agai... | (hdr->len) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "Fetching %d bytes starting at %d", (int)info.flash_len,
(int)info.flash_start_addr);
bool rv = gb_storage_setup(&state->storage, state->object_type, &info);
return rv;
}
#endif
default:
// NYI
return false;
}
}
void get_bytes_protocol_ms... |
oid test_animation__spawn_with_0_play_count(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_spawn = 0;
// Create 2 animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = prv_create_test... | cl_assert_equal_i(animation_get_duration(seq, false, false), total_duration_a + total_duration_b) | ;
cl_assert_equal_i(animation_get_duration(seq, false, true),
play_count_seq * (total_duration_a + total_duration_b));
cl_assert_equal_i(animation_get_duration(seq, true, false),
delay_seq + total_duration_a + total_duration_b);
cl_assert_equal_i(animation_get_duration(seq,... |
/*
* 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... | UNLIKELY(c == 0x3) | ) { // CTRL-C
// FIXME: Clean this up so this logic doesn't need to be duplicated here
s_prompt_context.write_index = 0;
prv_display_prompt();
}
return should_context_switch;
#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... | (scroll_layer, offset, true /* animated */) | |
t
clar_test(int argc, char **argv)
{
clar_print_init(
(int)_clar_callback_count,
(int)_clar_suite_count,
""
);
if (clar_sandbox() < 0) {
clar_print_onabort("Failed to sandbox the test runner.\n");
exit(-1);
}
clar_mock_reset();
clar_on_init();
if (argc > 1)
clar_parse_args(argc... | clar__assert(0, file, line, err, buf, should_abort) | ;
}
}
// Shamelessly stolen from
// http://stackoverflow.com/questions/7775991/how-to-get-hexdump-of-a-structure-data
void hex_dump(char *desc, void *addr, int len) {
int i;
unsigned char buff[17];
unsigned char *pc = (unsigned char*)addr;
// Output description if given.
if (desc != NULL) {
printf("%... |
/*
* 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... | (flash_locked) | ;
}
void callback_is_called_cb(uint32_t num, uint32_t den, void *context) {
callback_called = true;
cl_assert_equal_i(8675309, (uintptr_t)context);
}
void test_system_flash__callback_is_called(void) {
cl_assert(system_flash_erase(FLASH_BASE, 16 KiB, callback_is_called_cb,
(void *)8675309));
cl_ass... |
_assert_equal_i(e, BTErrnoOK);
cl_assert_equal_i(s_last_cccd_value, BLESubscriptionIndications);
// Simulate getting confirmation from remote:
prv_confirm_cccd_write(BLEGATTErrorSuccess);
fake_event_clear_last();
// Subscribe app:
e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndi... | prv_get_indicatable_characteristic() | ;
fake_kernel_malloc_mark();
// Subscribe kernel:
BTErrno e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
GAPLEClientKernel);
cl_assert_equal_i(e, BTErrnoOK);
cl_assert_equal_i(s_last_cccd_value, BLESubscriptionIndications... |
/*
* 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... | {
analytics_inc(ANALYTICS_DEVICE_METRIC_BLE_CONN_PARAM_UPDATE_FAILED_COUNT,
AnalyticsClient_System);
} |
//! only called when we are connected as a slave
void bluetooth_analytics_handle_connection_params_update(const BleConnectionParams *params) {
// When connected as a slave device, the 'Slave Latency' connection parameter allows
// the controller to skip the connection sync for that number of connection events.
... |
ess_manager_address_to_offset(PebbleTask task, void *system_address) {
ProcessContext *context = prv_get_context_for_task(task);
if (system_address >= context->load_start &&
system_address < context->load_end) {
return (void*)((uintptr_t) system_address - (uintptr_t)context->load_start);
}
// Not in a... | (bool, process_manager_compiled_with_legacy2_sdk, void) | {
PebbleTask task = pebble_task_get_current();
if (task != PebbleTask_App && task != PebbleTask_Worker) {
return false;
}
const ProcessAppSDKType sdk_type =
process_metadata_get_app_sdk_type(sys_process_manager_get_current_process_md());
return sdk_type == ProcessAppSDKType_Legacy2x;
}
// ------... |
layout__enable_text_flow(void) {
TextLayoutExtended l = {};
graphics_text_attributes_enable_screen_text_flow((GTextLayoutCacheRef) &l, 123);
cl_assert_equal_p(l.flow_data.perimeter.impl, g_perimeter_for_display);
cl_assert_equal_i(l.flow_data.perimeter.inset, 123);
}
void test_text_layout__create_destroy(void)... | (layout.max_used_size.h, 3 * (FONT_HEIGHT + (FONT_LINE_DELTA - 1))) | ;
} else {
cl_assert_equal_i(layout.max_used_size.h, 3 * FONT_HEIGHT);
}
if (!process_manager_compiled_with_legacy2_sdk()) {
// Test negative spacing
graphics_text_layout_set_line_spacing_delta((void*)&layout, (-FONT_HEIGHT));
graphics_text_layout_get_max_used_size(&gcontext, "JR Whopper 123", fo... |
ubtitle_font(config);
const bool render_subtitle = prv_should_render_subtitle_round(config, is_selected);
if (render_subtitle) {
subtitle_text_frame_height = fonts_get_font_height(subtitle_font);
}
const int subtitle_text_cap_offset =
(config->subtitle) ? fonts_get_font_cap_offset(subtitle_font) : 0;
... | {
// Let the icon extend the container height if it's taller than the title/subtitle combo
container_height = MAX(icon_frame_size.h, container_height);
} |
GRect container_rect = (GRect) { .size = GSize(cell_layer_bounds_size.w, container_height) };
// Align the container rect in the cell
grect_align(&container_rect, cell_layer_bounds, container_alignment, true /* clip */);
// Here we reuse rect as the icon frame
rect.size = icon_frame_size;
// Align the ic... |
r the specific language governing permissions and
* limitations under the License.
*/
#include "comm/ble/gap_le_advert.h"
#include "comm/ble/gap_le_connection.h"
#include "services/common/regular_timer.h"
#include "util/size.h"
#include "clar.h"
// Fakes
///////////////////////////////////////////////////////////
... | {
strncpy((char *) ad->data + ad_data_length,
scan_resp_data, scan_resp_data_length);
} | |
, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "fw_copy.h"
#include "drivers/crc.h"
#include "drivers/dbgserial.h"
#include "drivers/display.h"
#include "drivers/flash.h"
#include "drivers/system_flash.h"
#include "fir... | ((const uint8_t*)system_flash_base,
firmware_description->firmware_length) | ;
dbgserial_print("Checksum - wanted ");
dbgserial_print_hex(firmware_description->checksum);
dbgserial_print(" got ");
dbgserial_print_hex(calculated_crc);
dbgserial_newline();
return calculated_crc == firmware_description->checksum;
}
typedef enum UpdateFirmwareResult {
UPDATE_FW_SUCCESS = 0,
UPDAT... |
_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_text.last_call.draw_text.box);
EXECUTE_SCRIPT("ctx.fillText('some text', -0.2, 1.2, 10.5);");
cl_assert_eq... | (1, s_fonts_get_system_font.call_count) | |
e_pa_set(char *command) {
char buffer[64];
int index;
for (index = 0; index < BtlePaConfigCount; ++index) {
if (strcmp(command, s_btle_pa_config_strings[index]) == 0) {
break;
}
}
if (index >= BtlePaConfigCount) {
prompt_send_response_fmt(buffer, sizeof(buffer), "BTLE PA options are: %s, %... | command_perftest_line("noaa", "5") | ;
command_perftest_line("noaa", "4");
command_perftest_line("noaa", "3");
command_perftest_line("noaa", "2");
command_perftest_line("noaa", "1");
command_perftest_line("aa", "8");
command_perftest_line("aa", "6");
command_perftest_line("aa", "5");
command_perftest_line("aa", "4");
command_perftest_lin... |
/*
* 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 NUM_MENU_SECTIONS;
} |
static uint16_t menu_get_num_rows_callback(MenuLayer *menu_layer, uint16_t section_index,
void *data) {
return NUM_MENU_ITEMS;
}
static int16_t menu_get_header_height_callback(MenuLayer *menu_layer, uint16_t section_index,
vo... |
/*
* 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... | hc_endpoint_hrm_enable(enable) | ;
}
void bt_driver_hrm_service_handle_measurement(const BleHrmServiceMeasurement *measurement,
const BTDeviceInternal *permitted_devices,
size_t num_permitted_devices) {
hc_endpoint_hrm_send_measurement(measurement, permitted... |
/*
* 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... | (bitmap, GET_PBI_NAME(1)) | );
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_s... |
w object as `this`
var bindArgs = [null].concat(args);
var boundConstructor = func_obj.bind.apply(func_obj, bindArgs);
var rv = new boundConstructor();
return __jerryRefs.ref(rv);
}, func_obj_val, args_p, args_count);
}
jerry_size_t jerry_string_to_char_buffer(const jerry_value_t va... | if (jerry_value_has_error_flag(value)) {
return false;
} | |
/*
* 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_line(ctx, GPoint(5, -30), GPoint(45, 30)) | ;
}
void across_screen_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_stroke_width(ctx, 10);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(25, 25), GPoint(119, 143));
}
void same_start_stop_layer_update... |
/*
* 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 &inverter_layer->layer;
} | |
ctx.dest_bitmap, "draw_round_rect_origin_r4_sw3_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 3);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_s... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r3_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi")) | ;
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Should not dr... |
rent(
TimelineItemStorage *storage,
const Uuid *parent_id,
TimelineItemStorageChildDeleteCallback child_delete_cb) {
mutex_lock(storage->mutex);
FindChildrenInfo info = {
.parent_id = *parent_id,
.num_children = 0,
.find_all = true,
};
status_t rv = settings_file_each(&storage->file, pr... | mutex_unlock(storage->mutex) | ;
return rv;
}
status_t timeline_item_storage_get_from_settings_record(SettingsFile *file,
SettingsRecordInfo *info,
TimelineItem *item) {
uint8_t *read_buf = kernel_zalloc_check(info->val_len);
info->... |
ntal_line(ctx, y,
(Fixed_S16_3){.raw_value = left},
(Fixed_S16_3){.raw_value = ending_edge -
FIXED_S16_3_ONE.raw_value});
}
if (starting_edge <= right) {
graphics_private_... | (starting_quadrant_normalized,
ending_quadrant_normalized) | ;
}
} else {
// Angles in different quadrants
config.start_quadrant.angle = angle_start_normalized;
config.start_quadrant.quadrant = radius_quadrants[starting_quadrant_normalized];
config.end_quadrant.angle = angle_end_normalized;
config.end_quadrant.quadrant = radius_quadrants[ending_quadrant... |
d test_ble_hrm__init_deinit_no_subscriptions(void) {
// let cleanup & initialize do the work :)
}
static void prv_assert_permissions_ui_and_respond(bool is_granted) {
cl_assert(s_last_sharing_request);
ble_hrm_handle_sharing_request_response(is_granted, s_last_sharing_request);
s_last_sharing_request = NULL;
}... | ble_hrm_is_sharing() | );
prv_assert_event_service_subscribed(true);
// Revoke:
ble_hrm_revoke_sharing_permission_for_connection(&s_conn_a);
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a));
cl_assert_equal_b(false, ble_hrm_is_sharing());
prv_assert_event_service_subscribed(false);
prv_assert_last_disconn... |
---------------------------------------------------------------------
//! Prototypes
static void prv_perform_next_job(bool force_refresh);
// -----------------------------------------------------------------------------
static const char * prv_string_for_debug_tag(GAPLEAdvertisingJobTag tag) {
switch (tag) {
c... | (job->terms) | ;
kernel_free(job);
*job_ptr = NULL;
}
}
}
static void prv_increment_time_elapsed_for_all_silent_terms_except_current(void) {
if (!s_jobs) {
return;
}
GAPLEAdvertisingJob *job = s_jobs;
do {
GAPLEAdvertisingJob *next = (GAPLEAdvertisingJob *) job->node.next;
if (job != s_current &... |
ialog->dialog.dialog;
dialog_set_destroy_on_pop(dialog, false /* free_on_pop */);
bt_conn_dialog_push(bt_dialog, prv_handle_bt_conn_result, data);
}
static uint64_t prv_get_time_ms(void) {
time_t now_s;
uint16_t now_ms;
sys_get_time_ms(&now_s, &now_ms);
uint64_t ms = (now_s * 1000) + now_ms;
return ms;
... | VOICE_LOG("No speech detected! Exiting...") | ;
prv_exit_and_send_result_event(data, DictationSessionStatusFailureNoSpeechDetected);
} else {
prv_exit_and_send_result_event(data, DictationSessionStatusFailureRecognizerError);
}
}
}
static void prv_handle_dictation_result(VoiceUiData *data, PebbleVoiceServiceEvent *event) {
VOICE_LOG("Handl... |
e HciStatusCode_Success: {
// Disconnection! Update our records:
GAPLEConnection *connection = gap_le_connection_by_device(&event->peer_address);
#if CAPABILITY_HAS_BUILTIN_HRM
ble_hrm_handle_disconnection(connection);
#endif
const bool local_is_master = connection->local_is_master;
PBL_L... | (&event->dev_address) | ;
if (connection->is_encrypted) {
PBL_LOG(LOG_LEVEL_INFO, "Encryption refreshed!");
goto unlock;
}
const bool local_is_master = connection->local_is_master;
connection->is_encrypted = true;
if (!local_is_master) {
PBL_LOG(LOG_LEVEL_INFO, "Hurray! LE Security established.");
bluetooth_analyti... |
// The information for this task is going to be incorrect: the values of
// R4-R11 will be completely bogus. The only way to recover them is to
// properly unwind the full exception stack in a debugger with unwind
// information available. Unfortunately mainline GDB is unable to unwind
// a... | if (regions[i].word_reads_only) {
// Copy the memory into a temporary buffer before writing it to flash so
// that we can be sure that the memory is only being accessed by word.
uint32_t temp;
for (uint32_t offset = 0;
offset < regions[i].length;
offset += sizeof(temp)) {
... |
}
}
// Write the Core Dump Image Header
// Returns number of bytes written @ flash_addr
static uint32_t prv_write_image_header(uint32_t flash_addr, uint8_t core_number,
const ElfExternalNote *build_id, uint32_t timestamp) {
CoreDumpImageHeader hdr = {
.magic = CORE_DUMP_... |
ayer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_nx_offset_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_y_off... | GPoint(p.x + 6, p.y + 2) | );
graphics_draw_pixel(ctx, GPoint(p.x + 7, p.y + 2));
graphics_draw_pixel(ctx, GPoint(p.x + 0, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 1, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 2, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 3, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 4, p.y... |
/*
* 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->status_text, STATUS_TEXT_SIZE, "Unknown Status") | ;
PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Unknown Test Case Selected");
break;
}
text_layer_set_text(&data->status_text_layer, data->status_text);
}
static void test_window_load(Window *window) {
struct FlashTestData *data = app_state_get_user_data();
window_set_background_color(window, GColorBlack);
... |
now - 2 * SECONDS_PER_HOUR, now);
cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskAvailable);
}
void test_health__metric_hr_averaged_accessible(void) {
const time_t now = rtc_get_time();
typedef struct {
const char *desc;
struct {
HealthMe... | {
const time_t now = rtc_get_time();
typedef struct {
const char *desc;
struct {
HealthMetric metric;
time_t time_start;
time_t time_end;
HealthAggregation aggregation;
HealthServiceTimeScope scope;
bool hr_disabled;
} in;
struct {
HealthServiceAccessibilit... |
.in = { HealthMetricHeartRateBPM, now - 10, now, HealthAggregationMax,
HealthServiceTimeScopeDaily },
.out = { HealthServiceAccessibilityMaskNotSupported }
},
{
.desc = "Invalid time range with ScopeOnce and Max. NotSupported",
.in = { HealthMetricHeartRateBPM, now - 3 ... |
cation_iterator_cb(void *data, SerializedTimelineItemHeader *header_id) {
Uuid *last_notification_received_id = data;
// The iterator proceeds from the first notification received to the last notification received,
// so copy the ID of the current notification and then return true so we iterate until the end.
... | (notifications_glance) | ;
// Subscribe to notification events for updating the glance
notifications_glance->notification_event_info = (EventServiceInfo) {
.type = PEBBLE_SYS_NOTIFICATION_EVENT,
.handler = prv_notification_event_handler,
.context = structured_glance,
};
event_service_client_subscribe(¬ifications_glance-... |
/*
* 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... | ALIAS("Default_Handler") | void PendSV_Handler(void);
ALIAS("Default_Handler") void SysTick_Handler(void);
// External Interrupts
#define IRQ_DEF(idx, irq) ALIAS("Default_Handler") void irq##_IRQHandler(void);
#include "irq_stm32.def"
#undef IRQ_DEF
#if PROFILE_INTERRUPTS
#include "system/profiler.h"
#define IRQ_DEF(idx, irq) static inline v... |
->hdr) || partially_written(&iter->hdr)) {
return false;
}
return key_matches(iter, key, key_len);
}
static bool search_forward(SettingsRawIter *iter, const uint8_t *key, int key_len) {
const int resumed_pos = settings_raw_iter_get_resumed_record_pos(iter);
// Resume searching at the current record
for... | (&file->iter, key, key_len) | ||
file->iter.hdr.val_len == 0) {
return E_DOES_NOT_EXIST;
}
PBL_ASSERTN(offset < file->iter.hdr.val_len);
settings_raw_iter_write_byte(&file->iter, offset, byte);
return S_SUCCESS;
}
// Note that this operation is designed to be atomic from the perspective of
// an outside observer. That is, eith... |
/*
* 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... | ("Edit", list) | |
/*
* 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... | (res->tm_zone, "UTC", TZ_LEN) | |
er = NULL;
new_timer_delete(s_keepalive_timer);
s_keepalive_timer = TIMER_INVALID_ID;
mutex_destroy(s_tx_buffer_mutex);
dbgserial_restore_baud_rate();
serial_console_set_state(SERIAL_CONSOLE_STATE_LOGGING);
}
void pulse_prepare_to_crash(void) {
}
static void prv_process_received_frame(void *frame_ptr) {
... | COBS_OVERHEAD(PULSE_MAX_SEND_SIZE) | , length);
memcpy(&frame[length + COBS_OVERHEAD(PULSE_MAX_SEND_SIZE)], &fcs, sizeof(fcs));
length += sizeof(fcs);
length = cobs_encode(frame, frame + COBS_OVERHEAD(PULSE_MAX_SEND_SIZE), length);
// TODO: DMA
dbgserial_putchar_lazy(FRAME_DELIMITER);
for (size_t i = 0; i < length; ++i) {
dbgserial_putch... |
/*
* 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_spi_flash_init(0, 0x1000000) | ;
pfs_init(false);
pfs_format(false /* write erase headers */);
PBL_LOG(LOG_LEVEL_INFO, "\nFile system size: %d, avail: %d", (int)pfs_get_size(),
(int)get_available_pfs_space());
}
// ----------------------------------------------------------------------------------------
// fill a buffer, return it's... |
egions in flash to avoid premature burnout of any particular region.
// @param[in] new If true, then return a pointer to a region where a new image can be stored.
// If false, then return the region containing the most recent stored image or
// CORE_DUMP_FLASH_INVALID_ADDR if no image ha... | while (true) ; |
}
if (s_test_force_assert) {
PBL_ASSERTN(false);
}
// Create the packed chunk header
strncpy ((char *)packed_info.name, task_info->pcName, CORE_DUMP_THREAD_NAME_SIZE);
packed_info.id = (uint32_t)task_info->taskHandle;
packed_info.running = (current_task_id == task_info->taskHandle);
for (int i = 0... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
printf(list == &s_recognizers_handled ? "Handle touch: " : "");
printf(list == &s_recognizers_reset ? "Reset: " : "");
printf("{ ");
for (uint32_t i = 0; i < count; i++) {
printf("%d, ", indices[i]);
}
printf("}");
ListNode *node = *list;
int list_num = list_count(node);
bool failed = list_num ... |
static void prv_sub_event_handler(const Recognizer *recognizer, RecognizerEvent event) {
}
// setup and teardown
void test_recognizer_manager__initialize(void) {
s_test_impl_data = (TestImplData){};
s_app_list = NULL;
s_active_layer = NULL;
s_manager = NULL;
s_dummy_impl = (RecognizerImpl) {
.handle_t... |
0, -920},
{ 48, 112, -928},
{ 56, 144, -920},
{ 16, 112, -984},
{ 8, 0, -896},
{ 64, 80, -936},
{ 24, 64, -952},
{ 48, 80, -936},
{ 48, 80, -944},
{ 32, 40, -912},
{ -24, 8, -952},
{ 64, 144, -920},
// 300 seconds
// elapsed: 5 minutes
{ 16, 8, -928},
{ 40, 13... | { 40, 104, -928},
{ 32, 104, -920},
{ 48, 136, -912},
{ 32, 80, -920},
{ 32, 104, -928},
{ 0, 88, -968},
{ 32, 64, -920},
{ 8, 64, -896},
{ 40, 144, -952},
{ -16, -64, -920},
{ 24, 96, -944},
{ 40, 40, -936},
};
*len = ARRAY_LENGTH(samples);
return samples;
} | |
nt > max_erase) {
max_erase = hdr.erase_count;
}
if (hdr.last_written == LAST_WRITTEN_TAG) {
last_written_pg = i + start_page;
}
}
prv_flash_erase_sector(start_page);
prv_write_erased_header_on_page_range(start_page,
start_page + PFS_PAGES_PER_ERASE_SECTOR, max_erase);
if (last_... | if (f->is_tmp) {
// TODO: For safety, could disallow this op if user has orig file hdl open
pfs_remove(f->name);
// Note: if we reboot before updating the tmp state flag to done, the tmp &
// original file will be deleted. This is an extremely small window, but
// could be resolved by checking on re... |
// Note: We don't free f->name here because we keep the file metadata
// (including the name, so we can detect hits) in the cache until we
// have to evict it to make room for a new file.
PFS_FD(fd).fd_status = FD_STATUS_UNREFERENCED;
PFS_FD(fd).time_closed = time_closed_counter++;
// If this file was m... |
/*
* 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_read_timer = new_timer_create();
s_header_mbuf = MBUF_EMPTY;
mbuf_set_data(&s_header_mbuf, s_header_data, sizeof(s_header_data));
} |
// Helper functions for static variables
////////////////////////////////////////////////////////////////////////////////
static void prv_reset_read_info(void) {
s_read_info = (ReadInfo) { };
hdlc_streaming_decode_reset(&s_read_info.hdlc_ctx);
}
static void prv_reset_read_consumer(void) {
s_read_consumer = (... |
/*
* 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 the framebuffer hasn't been cleared but it is dirty, issue a
// display command to blank the screen.
if (f->is_cleared) {
display_clear();
f->is_cleared = false;
}
if (!f->is_dirty) {
return;
}
s_current_framebuffer = f;
s_current_flush_line = 0;
display_update(&flush_get_next_li... |
static void flush_complete(void) {
s_current_flush_line = 0;
framebuffer_reset_dirty_lines(s_current_framebuffer);
}
static bool flush_get_next_line(DisplayRow* row) {
while (s_current_flush_line < DISP_ROWS) {
if (bitset8_get(s_current_framebuffer->dirty_lines, s_current_flush_line)) {
row->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... | {
// If we can't allocate enough RAM to read the whole file, we should
// at least try to read part of it.
read_size /= 2;
contents = kernel_calloc(1, read_size);
} | |
/*
* 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 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... | cl_assert(!error) | |
/*
* 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... | (chip_id_out, response->payload, sizeof(*chip_id_out)) | ;
kernel_free(response);
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... | (text, s_system_font) | ;
text_layer_set_text(text, ALL_CODEPOINTS);
// Trim text layer and scroll content to fit text box
GSize max_size = text_layer_get_content_size(app_state_get_graphics_context(), text);
text_layer_set_size(text, max_size);
static const int vert_scroll_padding = 4;
scroll_layer_set_content_size(scroll_layer,... |
nclude "comm/bluetooth_analytics.h"
#include "drivers/flash.h"
#include "drivers/rtc.h"
#include "flash_region/flash_region.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/get_bytes/get_bytes_storage.h"
#include "servic... | comm_session_send_buffer_get_max_payload_length(state->session) | ;
if (max_buf_len == 0) {
// Session disconnected in the mean time
packet_len = 0;
} else {
data_len = MIN(remaining_bytes, max_buf_len - sizeof(GetBytesRspObjectData));
packet_len = data_len + sizeof(GetBytesRspObjectData);
}
} else {
packet_len = sizeof(GetBytesRspObjectInfo)... |
prv_find_source, (void *)consumer);
bool is_already_granted = (gap_le_connect_params_get_actual_state(hdl) >= state);
if (consumer_request == NULL) {
if (state == ResponseTimeMax) {
// No changes: there was no previous node and the new state is the default "low power" one.
goto handl... | bt_unlock() | ;
}
void command_le_mode_chaos_monkey(char *enabled_str) {
bool new_enabled = atoi(enabled_str);
bool is_enabled = (s_chaos_monkey_timer != TIMER_INVALID_ID);
if (new_enabled == is_enabled) {
return;
}
bt_lock();
if (new_enabled) {
GAPLEConnection *conn_hdl = gap_le_connection_any();
if (conn... |
lerts_set_mask(AlertMaskAllOn);
}
void test_alerts__cleanup(void) {
}
// Tests
/////////////////////////////////
void test_alerts__enabled(void) {
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
// Should allow all notifications to go through
cl_assert(alerts_should_notify_f... | alerts_should_vibrate_for_type(AlertPhoneCall) | );
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(alerts_should_enable_backlight_for_type(AlertPhoneCall));
cl_assert(alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_vibrate_for_type(AlertMobile));
alerts_set_... |
services/common/bluetooth/bluetooth_ctl.h"
#include "system/logging.h"
#include "util/attributes.h"
#include "util/build_id.h"
#include "util/crc32.h"
#include "util/math.h"
#include <os/tick.h>
#if PLATFORM_ROBERT
#define CORE_DUMP_RX_BUFFER_SIZE (16 * 1024)
// Place in DTCM on Robert
static unsigned char DMA_BSS DM... | (&cmd, s_rx_buffer, sizeof(text_crc_matches)) | ) {
PBL_LOG(LOG_LEVEL_ERROR, "Unable to get Text CRC");
goto spi_failed;
}
memcpy(&text_crc_matches, s_rx_buffer, sizeof(text_crc_matches));
// Get the Build ID
cmd = (CoreDumpSPICmd) { .cmd = CoreDumpCmd_GetBuildID };
if (!prv_spi_transaction(&cmd, s_rx_buffer, sizeof(build_id))) {
PBL_LOG(LOG_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... | animation_set_duration(animation, duration) | ;
animation_set_curve(animation, AnimationCurveEaseOut);
loading_layer->animation = animation;
animation_schedule(animation);
}
|
/*
* 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... | {
pfs_close(fd);
notification_storage_unlock();
} |
static int prv_write_notification(TimelineItem *notification,
SerializedTimelineItemHeader *header, int fd) {
int bytes_written = 0;
// Invert flags & status to store on flash
header->common.flags = ~header->common.flags;
header->common.status = ~header->common.status;
int result = pfs_write(fd, (uint... |
184, 360},
{ -512, 432, 240},
{ -480, 880, 360},
{ -456, 1144, 488},
{ -264, 1536, 296},
{ -88, 1216, 224},
{ -40, 1136, 160},
{ -32, 936, 248},
{ 16, 928, 240},
{ 24, 840, 232},
{ 64, 696, 264},
// 31 seconds
{ 96, 744, 184},
{ 144, 672, 176},
{ 176, 584, 176},
... | { -800, 400, -592},
{ -1056, 24, -720},
{ -1096, 64, -808},
{ -864, -88, -712},
{ -808, -32, -440},
{ -1376, 360, 1304},
{ -992, 280, 128},
{ -1016, -32, -112},
{ -992, -128, 24},
{ -1208, 48, -24},
{ -1488, 120, 16},
{ -1200, 720, 64},
{ -1200, 632, 56},
{ -1040,... |
{ -128, 704, 488},
{ -168, 528, 520},
{ -32, 536, 352},
{ -8, 488, 344},
{ 40, 512, 344},
// 39 seconds
{ 80, 456, 352},
{ 88, 512, 408},
{ 8, 752, 560},
{ 16, 1104, 688},
{ 88, 1192, 984},
{ 136, 1464, 808},
{ 88, 1064, 584},
{ 56, 808, 512},
{ -80, 744, 536... |
_t to_free;
uint32_t before_size;
uint32_t after_size;
// lets save ids 17, 25, 42, and 47 because they are my favorite numbers
uint32_t after_free = t_data[16].size + t_data[24].size + t_data[41].size + t_data[46].size;
s_test_id_ql_up = 17;
s_test_id_ql_down = 25;
s_test_id_watchface = 42;
s_test_id... | (filename, sizeof(filename), id) | ;
prv_check_file_exists(filename);
prv_res_filename(filename, sizeof(filename), id);
prv_check_file_exists(filename);
}
// finally, make sure the 'standard' files are all there
for (uint32_t i = 0; i < ARRAY_LENGTH(descriptions); ++i) {
prv_check_file_exists(descriptions[i].name);
}
}
void test... |
ll from interrupt functions
static portBASE_TYPE end_transfer_irq(I2cBus *bus, bool result) {
bus->i2c->CR2 &= ~(I2C_CR2_ITEVTEN | I2C_CR2_ITERREN | I2C_CR2_ITBUFEN);
bus->i2c->CR1 |= I2C_CR1_STOP;
bus->transfer.result = result;
bus->transfer.state = TRANSFER_STATE_INVALID;
bus->busy = false;
return pdFALS... | (bus, false) | ;
break;
}
return should_context_switch;
}
//! Handle error interrupt on the specified \a bus
static portBASE_TYPE irq_error_handler(I2cBus *bus) {
if (bus->transfer.state == TRANSFER_STATE_INVALID) {
// Disable interrupts if spurious interrupt received
bus->i2c->CR2 &= ~I2C_CR2_ITERREN;
retu... |
raph_card->stats.weekend.avg, bounds->size.w - weekend_width,
weekend_width);
}
static int32_t prv_get_info_data_point(HealthGraphCard *graph_card) {
// Show today's data point if the selection is a day of the week, otherwise show the weekday
// average if the current day is a weekday or weeken... | strftime(buffer, buffer_size, i18n_get("%a: ", graph_card), &local_tm) | ;
}
}
static void prv_draw_info_with_text(HealthGraphCard *graph_card, GContext *ctx, char *text) {
const GRect *bounds = &graph_card->layer.bounds;
// Calculate the custom info text size
GSize custom_text_size;
const TextLayoutExtended text_layout = {};
graphics_text_layout_get_max_used_size(ctx, text, gr... |
DBToken prv_new_token(void) {
static BlobDBToken next_token = 1; // 0 token should be avoided
return next_token++;
}
static const uint8_t *prv_read_token_and_response(const uint8_t *iter, BlobDBToken *out_token,
BlobDBResponse *out_response) {
*out_token = *(Blob... | prv_handle_wb_write_response(data, length) | ;
}
static void prv_handle_sync_done_response(CommSession *session,
const uint8_t *data,
uint32_t length) {
if (length < SYNC_DONE_RESPONSE_LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a sync done response with an invalid length: %"PR... |
tx_power_level_out));
}
void test_ble_ad_parse__128_bit_uuid(void) {
// AD Element, Length: 2, AD Type: Flags
// AD Element, Length: 17, AD Type: More 128-bit UUIDs available,
// Value: 0x68753a444d6f12269c600050e4c00067
uint8_t data[GAP_LE_AD_REPORT_DATA_MAX_LENGTH] =
"\x02\x01\x1a\x11\x06\x67\x00\xc0\xe... | (ad, uuid, 8) | , false);
ble_ad_destroy(ad);
}
void test_ble_ad_parse__set_service_uuids_16_bit(void) {
BLEAdData *ad;
Uuid uuid[15];
for (int i = 0; i < 15; ++i) {
uuid[i] = bt_uuid_expand_16bit(0x1800 + i);
}
// Hand-construct expected raw advertisement data:
uint8_t expected_ad_data[] = {
(2 * sizeof(uint1... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, GColorBlack) | ;
graphics_draw_pixel(ctx, GPoint(15, 5));
}
void outside_nx_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_pixel(ctx, GPoint(-5, 5));
}
void outside_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx,... |
/*
* 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... | {
RamStorageEntry *entry = prv_get_entry(storage->entries, key, key_len);
if (entry) {
memcpy(val_out, entry->val, val_len);
return S_SUCCESS;
}
return E_DOES_NOT_EXIST;
} |
status_t ram_storage_delete(RamStorage *storage, const uint8_t *key, int key_len) {
RamStorageEntry *entry = prv_get_entry(storage->entries, key, key_len);
if (entry) {
prv_delete(&storage->entries, entry);
return S_SUCCESS;
}
return E_DOES_NOT_EXIST;
}
status_t ram_storage_flush(RamStorage *storage... |
ers(start_ms + 100);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
// -------------------------------------------------------------------------------------
// Build up a sequence out of the leftover a... | (a, b, NULL) | ;
animation_set_delay(seq, delay_seq);
animation_set_handlers(seq, handlers, seq);
animation_schedule(seq);
// The duration of seq should include all of b
uint32_t duration = animation_get_duration(seq, true, true);
cl_assert_equal_i(duration, duration_b + delay_b + delay_seq);
// The position of seq sh... |
by checking if the
// payload size for next_data_sn is not 0. This means the packet has been enqueued to get sent
if (prv_is_packet_with_sn_awaiting_ack(client, client->out.next_data_sn)) {
client->out.next_data_sn = next_sn;
}
// Clear up the payload size(s) for Ack'd packets.
// See comment... | PBL_LOG(LOG_LEVEL_DEBUG, "Ignoring all packets in state %u", client->state) | ;
}
}
// -------------------------------------------------------------------------------------------------
static void prv_handle_meta_read(PPoGATTClient *client, const uint8_t *value,
size_t value_length, BLEGATTError error) {
PBL_ASSERTN(client->state == StateDisconnectedReading... |
// 570: Local time: 05:01:00 PM
{ 0, 0x48, 25, 181},
{ 0, 0x38, 168, 187},
{ 0, 0x37, 376, 182},
{ 0, 0x37, 154, 184},
{ 0, 0x48, 820, 178},
{ 0, 0x48, 108, 187},
{ 0, 0x48, 0, 184},
{ 0, 0x47, 1564, 184},
{ 0, 0x48, 218, 192},
{ 0, 0x48, 0, 190},
{ 0, 0x48, 0, 178},
{ 0... | { 0, 0x49, 1233, 161},
{ 0, 0x49, 536, 164},
{ 0, 0x59, 1364, 149},
{ 15, 0x59, 1856, 144},
// 690: Local time: 07:01:00 PM
{ 32, 0x69, 1622, 158},
{ 0, 0x48, 1786, 155},
{ 0, 0x57, 5033, 147},
{ 56, 0x42, 5692, 146},
{ 119, 0x40, 6225, 142},
{ 74, 0x41, 4778, 144},
{ 26,... |
{ 0, 0x47, 2047, 184},
{ 0, 0x47, 1233, 182},
{ 0, 0x37, 1417, 184},
{ 0, 0x47, 1970, 182},
{ 0, 0x37, 1517, 182},
{ 0, 0x47, 930, 176},
{ 0, 0x47, 425, 178},
{ 0, 0x36, 2639, 184},
{ 0, 0x36, 4320, 186},
{ 0, 0x47, 2254, 186},
{ 0, 0x58, 610, 178},
// 750: Local time: 0... |
_menus_animated, root_level, selected_index,
ActionMenuLayerLongLabelScrollingAnimationStateCount,
0 /* additional_crumbs */);
}
// Tests
//////////////////////
void test_action_menu_window__wide_display_mode_with_just_titles(void) {
ActionMenuLevel *root_level = action_menu_level_create(3);
action_me... | prv_prepare_canvas_and_render_action_menus_static(root_level, selected_index, 0) | ;
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_action_menu_window__wide_display_mode_with_chevron(void) {
ActionMenuLevel *root_level = action_menu_level_create(3);
ActionMenuLevel *voice_level = action_menu_level_create(1);
action_menu_level_add_action(voice_level,
... |
/////////
void test_blob_db_sync__initialize(void) {
fake_blob_db_set_id(BlobDBIdTest);
blob_db_init_dbs();
s_num_until_timeout = 0;
s_num_writebacks = 0;
}
void test_blob_db_sync__cleanup(void) {
blob_db_flush(BlobDBIdTest);
fake_system_task_callbacks_cleanup();
}
void test_blob_db_sync__no_dirty(void) ... | (blob_db_sync_db(BlobDBIdTest) == S_SUCCESS) | ;
// We have built the dirty list, add more entries.
// This mimics us performing writes while the sync is ongoing or not having enough memory to
// build the initial list
char *extra_keys[] = { "keyA", "keyB" };
char *extra_values[] = { "valA", "valB" };
for (int i = 0; i < ARRAY_LENGTH(extra_keys); ++i) ... |
x->user_context);
}
}
}
static void prv_handle_nack_or_ack_timeout(AppMessageCtxOutbox *outbox,
AppMessageResult result) {
outbox->result = result;
if (outbox->phase == OUT_AWAITING_REPLY) {
prv_transition_to_accepting(outbox);
} else if (outbox->phase == OUT_... | {
return (phase == OUT_AWAITING_REPLY_AND_OUTBOX_CALLBACK ||
phase == OUT_AWAITING_REPLY);
} |
AppMessageResult app_message_outbox_begin(DictionaryIterator **iterator) {
AppMessageCtxOutbox *outbox = &app_state_get_app_message_ctx()->outbox;
if (iterator == NULL) {
return APP_MSG_INVALID_ARGS;
}
AppMessagePhaseOut phase = outbox->phase;
*iterator = NULL;
if (prv_is_message_pending(phase)) {
... |
_get_step_averages_values_weekday = (sys_activity_get_step_averages_values){
.out.result = true,
};
s_sys_activity_get_step_averages_values_weekend = (sys_activity_get_step_averages_values){
.out.result = true,
};
for (int i = 0;
i < ARRAY_LENGTH(s_sys_activity_get_step_averages_values_weekday.o... | (HealthMetricStepCount, start_of_today,
start_of_today + (9 * SECONDS_PER_HOUR),
HealthServiceTimeScopeDaily) | ;
cl_assert_equal_i(value, exp_value);
}
void test_health__get_measurement_system_for_display(void) {
MeasurementSystem actual =
health_service_get_measurement_system_for_display(HealthMetricSleepSeconds);
cl_assert_equal_i(actual, MeasurementSystemUnknown);
s_units_distance_result = UnitsDistance_Miles;
... |
(config->title, graph_card) | ;
}
if (config->info_avg) {
graph_card->info_avg = i18n_get(config->info_avg, graph_card);
}
if (config->graph_data) {
graph_card->stats = config->graph_data->stats;
memcpy(graph_card->day_data, config->graph_data->day_data, sizeof(graph_card->day_data));
graph_card->data_timestamp = config->gra... | |
/*
* 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... | EXECUTE_SCRIPT_EXPECT_ERROR("var poo\xed\xa0\xbd\xed\xb2\xa9poo = 'pileOfPoo';",
"SyntaxError: Invalid (unexpected) character. [line: 1, column: 8]") | ;
}
void test_rocky_text_encoding__string_length(void) {
EXECUTE_SCRIPT("var pileOfPooUTF8 = '\xF0\x9F\x92\xA9';");
// String.length is expected to count the surrogate code points that make up a non-BMP codepoint:
EXECUTE_SCRIPT_AND_ASSERT_RV_EQUALS_S("pileOfPooUTF8.length.toString()", "2");
}
void test_rocky_t... |
(connected) {
if (data->state == StateError) {
// We got here after a dictation result timeout, so restart the dictation
prv_start_dictation(data);
} else {
prv_voice_window_push(data);
}
} else {
VOICE_LOG("Bluetooth not restored! Exiting...");
prv_exit_and_send_result_event(dat... | ("New sentence: %s", data->message) | ;
return true;
}
static void prv_handle_dictation_error(VoiceUiData *data, VoiceStatus error_status) {
uint64_t elapsed = prv_get_time_ms() - data->start_ms;
const bool speech_detected = (data->speech_detected) || (elapsed < MIN_ELAPSED_DURATION);
data->error_count++;
if (data->show_error_dialog) {
if ... |
// Now use the info functions to read the data and make sure it's sane. A conversion will have
// happened behind the scenes to the latest version.
cl_assert_equal_i(mfg_info_get_watch_color(), 3);
cl_assert_equal_i(mfg_info_get_rtc_freq(), 4);
char buffer[MFG_INFO_MODEL_STRING_LENGTH] = { 0 };
mfg_info... | (mfg_info_get_rtc_freq(), 1) | ;
cl_assert_equal_i(mfg_info_get_disp_offsets().x, 2);
cl_assert_equal_i(mfg_info_get_disp_offsets().y, 3);
char result_model[MFG_INFO_MODEL_STRING_LENGTH];
mfg_info_get_model(result_model);
cl_assert_equal_s(model, result_model);
// Make sure the boot fpga is still correct
flash_read_bytes(fpga_buffer,... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
case AnalyticsEvent_AppOOMNative:
case AnalyticsEvent_AppOOMRocky:
return true;
default:
// Don't allow any other event types:
return false;
} | |
ader) + CHECKSUM_LENGTH)
// flags
#define FLAG_IS_SERVER (1 << 0)
#define FLAG_VERSION (VERSION << 1)
// opcodes
#define OPCODE_PING (0x01)
#define OPCODE_DISCONNECT (0x02)
#define OPCODE_RESET (0x03)
#define OPCODE_FLASH_GEOMETRY (0x11)
#define OPCODE_FLASH_ERASE (0x12)
#define OPCODE_FLASH_WRITE (0x13)
#define OPCO... | accessory_send_byte(HDLC_FLAG) | ;
// send the header
const ImagingHeader header = {
.flags = FLAG_IS_SERVER | FLAG_VERSION,
.opcode = opcode
};
prv_encode_and_send_data(&header, sizeof(header));
// send the pyaload
prv_encode_and_send_data(payload, length);
// send the checksum
uint32_t checksum = CRC32_INIT;
checksum = c... |
ude "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "services/common/new_timer/new_timer.h"
#include "services/normal/alarms/alarm.h"
#include "util/time/time.h"
#include <stdio.h>
#include <string.h>
#if !PLATFORM_TINTIN
#include "services/normal/vibes/vib... | {
s_alarm_popup_data->vibe_count++;
#if CAPABILITY_HAS_VIBE_SCORES
vibe_score_do_vibe(s_alarm_popup_data->vibe_score);
#else
if (low_power_is_active()) {
// Only vibe 10 seconds every minute in low_power_mode
_Static_assert(TINTIN_VIBE_REPEAT_INTERVAL_MS == MS_PER_SECOND,
... |
else {
prv_stop_vibes();
launcher_task_add_callback(prv_stop_animation_kernel_main_cb, NULL);
}
}
}
static void prv_vibe(void *unused) {
launcher_task_add_callback(prv_vibe_kernel_main_cb, NULL);
}
static void prv_start_vibes(void) {
s_alarm_popup_data->vibe_count = 0;
unsigned int vibe_r... |
andler_entries(&s_started_handler_calls, a0), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a0), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a1), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a1), 1);
cl_assert_equal_i(prv_cou... | (b, delay_b) | ;
// Create a sequence
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
animation_set_delay(seq, delay_seq);
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
// Test the elapsed
int32_t elapsed_ms;
animation_get_elapsed(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... | for (int i = 0; i < NumConnectionsToDebounce; i++) {
s_debounce_timers[i].cb = prv_handle_disconnection_debounced;
s_debounce_timers[i].cb_data = (void *)(uintptr_t)i;
} | |
llback_context) {
return ARRAY_LENGTH(prv_row_texts);
}
static void prv_draw_row(GContext* ctx, const Layer *cell_layer, char const *title,
int16_t offset) {
// mostly copied from menu_cell_basic_draw_with_value
// (that unfortunately doesn't respect bounds.origin.x)
const int16_t title_height = 24;
GRec... | (&data->action_list1) | );
menu_layer_init(&data->action_list2, &menu_layer_rect);
menu_layer_set_callbacks(&data->action_list2, NULL, &(MenuLayerCallbacks){
.get_num_rows = prv_get_num_rows,
.draw_row = prv_draw_row_2,
.get_separator_height = prv_get_separator_height,
});
scroll_layer_set_shadow_hidden(&data->actio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.