prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ERROR: Data bit %d not returning correct data value", bitpos);
return status;
}
bitpos++;
addr_region += 4; // increment to the next address to avoid extra erases
}
PBL_LOG(LOG_LEVEL_DEBUG, ">PASS - DATA TEST 1: Data bus test");
return status;
}
/**********************************************... | {
test_addr = base_addr;
// Read initial value
read_buffer = 0;
flash_read_bytes((uint8_t*) &read_buffer, test_addr, sizeof(read_buffer));
if (display_logs) {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Reading Addr 0x%"PRIx32" value is 0x%"PRIx8,
test_addr, read_buffer);
}
// Write d... | |
/*
* 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_layer_deinit(bitmap_layer) | ;
applib_free(bitmap_layer);
}
Layer* bitmap_layer_get_layer(const BitmapLayer *bitmap_layer) {
return &((BitmapLayer *)bitmap_layer)->layer;
}
const GBitmap* bitmap_layer_get_bitmap(BitmapLayer* bitmap_layer) {
return bitmap_layer->bitmap;
}
void bitmap_layer_set_bitmap(BitmapLayer *image, const GBitmap *bitm... |
s = action2_attributes
};
AttributeList attr_list3 = {
.num_attributes = ARRAY_LENGTH(attributes),
.attributes = attributes
};
static uint8_t attr_list1_serialized[] = {
// Action Attributes
0x01, // Attribute ID - Title
0x07, 0x00, // Attribute Length
... | (size_list, (5 + 1) + (8 + 1) + (4 + 1) + 3 * sizeof(Attribute)) | ;
uint8_t *buffer = kernel_malloc_check(size_list);
uint8_t *buffer_orig = buffer;
AttributeList list2 = {0};
cl_assert(attribute_list_copy(&list2, &list, buffer, buffer + size_list));
// check that we haven't modified buffer
cl_assert(buffer == buffer_orig);
cl_assert_equal_s(attribute_get_string(&list2,... |
issions and
* limitations under the License.
*/
#include "jerry-api.h"
#include <emscripten/emscripten.h>
#include <string.h>
#define TYPE_ERROR \
jerry_create_error(JERRY_ERROR_TYPE, NULL);
#define TYPE_ERROR_ARG \
jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t *)"wrong type of argument");
#de... | EM_ASM_INT({
return (__jerryRefs.get($0) === true);
}, value) | ;
}
double jerry_get_number_value(const jerry_value_t value) {
if (!jerry_value_is_number(value)) {
return 0.0;
}
return EM_ASM_DOUBLE({
return __jerryRefs.get($0);
}, value);
}
////////////////////////////////////////////////////////////////////////////////
// Functions for UTF-8 encoded string va... |
ssert_(*malformed_test_string_utf8 == 0xcd, "Failed to invalidate an invalid UTF-8 test string");
}
void test_utf8__decode_all_gothic_codepoints(void) {
static const int NUM_GOTHIC_CODEPOINTS = sizeof(s_valid_gothic_codepoints) / sizeof(uint32_t);
bool is_valid = utf8_is_valid_string(s_valid_gothic_codepoints_str... | cl_assert_equal_i(trunc_size, 4) | ;
// test where max_length == ellipsis_length + 1
output_buffer = realloc(output_buffer, 5);
trunc_size = utf8_truncate_with_ellipsis("Hello", output_buffer, 5);
cl_assert_equal_s(output_buffer, "H\xe2\x80\xa6");
cl_assert_equal_i(trunc_size, 5);
// test that if we don't need to truncate, we don't
outpu... |
;
typedef struct PACKED {
uint32_t address;
uint32_t length;
uint8_t complete;
} FlashEraseResponse;
typedef struct PACKED {
uint32_t address;
uint8_t data[];
} FlashWriteRequest;
typedef struct PACKED {
uint32_t address;
uint32_t length;
} FlashReadRequest;
typedef struct PACKED {
uint32_t address;... | {
const uint32_t sectors_to_erase = (length + SECTOR_SIZE_BYTES - 1) / SECTOR_SIZE_BYTES;
for (uint32_t sector = 0; sector < sectors_to_erase; sector++) {
if (!flash_sector_is_erased(sector * SECTOR_SIZE_BYTES + addr)) {
return false;
}
}
return true;
} |
static void prv_handle_ping_request(const void *payload, uint32_t length) {
// echo it back
prv_send_frame(OPCODE_PING, payload, length);
}
static void prv_handle_disconnect_request(const void *payload, uint32_t length) {
if (length) {
// should be 0
PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")... |
/*
* 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_lock(s_vibe_history_mutex) | ;
VibeHistory *vibe = (VibeHistory*)list_get_tail((ListNode*)s_vibe_history);
if (vibe->time_end == END_NOT_SET) {
vibe->time_end = ((uint64_t)s) * 1000 + ms;
}
mutex_unlock(s_vibe_history_mutex);
}
typedef struct {
ListNode list_node;
uint32_t duration_ms;
int32_t strength;
} VibePatternStep;
stat... |
->view_node = view_node;
timeline_layout_get_size(layout, graphics_context_get_current_context(), &layout->view_size);
}
void timeline_layout_deinit_view(TimelineLayout *layout) {
if (layout->layout_layer.mode == LayoutLayerModeCard && layout->impl->card_view_deinitializer) {
layout->impl->card_view_deinitiali... | prv_create_all_day_text_node(layout) | ;
} else {
return prv_create_hour_text_node(layout);
}
}
static const char *prv_get_secondary_text(const TimelineLayout *layout) {
const AttributeList *attributes = layout->layout_layer.attributes;
return attribute_get_string(attributes, AttributeIdShortSubtitle, NULL) ?:
attribute_get_string(attribu... |
n writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "drivers/stm32f7/... | (MHZ_TO_HZ(20), I2CBusMode_Standard,
KHZ_TO_HZ(100), 800, 200) | ,
2, 47, 40, 11);
}
void test_i2c_timingr__invalid_speed_too_high(void) {
// We'll use a base clock speed of 1Mhz and try to get to 400KHz I2C, which won't be possible
// because the sync cycles alone will make us way slower than 400kHz.
cl_assert_equal_i(i2c_timingr_calculate(MHZ_TO_HZ(1), I2... |
sert(idx <= s_message_idx); \
cl_assert_equal_i(ll, s_messages[idx].length); \
cl_assert_equal_m(dd, s_messages[idx].data, ll); \
}
#define assert_num_message_callbacks(num_cbs) \
{ \
cl_assert_equal_i(num_cbs, s_message_idx); \
}
static int s_dropped_idx;
static uint32_t s_dropped_messages[TEST_ARRAY_SIZE];
v... | {
fake_kernel_malloc_set_largest_free_block(0);
void *result = app_inbox_create_and_register(BUFFER_SIZE, 1,
test_message_handler,
test_dropped_handler);
cl_assert_equal_p(result, NULL);
} |
////////////////////////////////////////////////////////////////////////////////////////////////////
// app_inbox_service_register
void test_app_inbox__app_inbox_create_and_register_storage_already_associated(void) {
bool success;
uint8_t storage[BUFFER_SIZE];
success = app_inbox_service_register(storage, siz... |
OG(LOG_LEVEL_DEBUG, "Overwriting SPRF field at offset %d, size %d",
(int)offset, (int)field_size);
// write the crc first so it's easier to detect a non empty field (we can just read if the CRC is
// not 0xFFFFFFFF instead of comparing all bytes.
*(uint32_t *)field = new_crc;
flash_write_bytes(field... | prv_unlock() | ;
}
//!
//! BLE Root Key APIs
//!
bool shared_prf_storage_get_root_key(SMRootKeyType key_type, SM128BitKey *key_out) {
bool rv;
prv_lock();
{
SprfRootKeys data;
rv = SPRF_FETCH_FIELD(data, root_keys);
if (!rv) {
goto unlock;
}
SM128BitKey nil_key = {};
if (0 == memcmp(&nil_key, &d... |
20);
cl_assert_equal_i(s_invalidate_addr, 0x00);
cl_assert_equal_i(s_invalidate_size, 0x20);
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Valid);
}
void test_cpu_cache__userspace_fail_from_size(void) {
cl_will_return(icache_is_enabled, true);
cl_will_return(dcache_is_enabled, true);
cl_will_return(ic... | (dcache_is_enabled, 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... | ADC_GetFlagStatus(ADC1, ADC_FLAG_OVR) | == SET) {
ADC_ClearFlag(ADC1, ADC_FLAG_OVR);
ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
return false;
}
}
return true;
}
void voltage_monitor_read(const VoltageMonitorDevice *device, VoltageReading *reading_out) {
PBL_ASSERTN(device->adc == ADC1);
mutex_lock(s_adc_mutex);
periph_config_enable... |
gacy_checksum.h"
#include <string.h>
//! This comes from the generated pebble.auto.c with all the exported functions in it.
extern const void* const g_pbl_system_tbl[];
// ----------------------------------------------------------------------------------------------
static bool prv_verify_checksum(const PebbleProces... | (fd, destination->start, load_size) | != (int)load_size) {
PBL_LOG(LOG_LEVEL_ERROR, "Process read failed for process %s, fd = %d", process_name, fd);
pfs_close(fd);
return (false);
}
pfs_close(fd);
return prv_intialize_sdk_process(task, &info, destination);
}
// --------------------------------------------------------------------------... |
in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util/iterator.h"
#include "applib/... | (!iter_next(&char_iter)) | ;
cl_assert(!iter_next(&char_iter));
}
void test_char_iterator__decode_test_string_with_initial_formatting_char(void) {
Iterator char_iter;
CharIterState char_iter_state;
Utf8IterState* utf8_iter_state = (Utf8IterState*) &char_iter_state.utf8_iter_state;
// Skip over codepoints that aren't newline and < 0x2... |
d_verify(&file, key, key_len, big_val, 511);
}
typedef enum {
RecordResultOld,
RecordResultNew,
RecordResultEnd,
} RecordResult;
static RecordResult write_and_change_record_aborting_after_bytes(int after_n_bytes) {
fake_spi_flash_init(0, 0x1000000);
// Wednesday (the 1st) at 00:00
// date -d "2014/01/01 0... | (val, "val", sizeof(val)) | |
(LOG_LEVEL_INFO, "Put bytes cleanup. Tok: %"PRIu32, s_pb_state.token) | ;
prv_deinit_put_job_queue();
s_pb_state.receiver = (__typeof__(s_pb_state.receiver)) {};
if (s_pb_state.timer_id) {
new_timer_delete(s_pb_state.timer_id);
s_pb_state.timer_id = TIMER_INVALID_ID;
}
pb_storage_deinit(&s_pb_state.storage, s_pb_state.is_success);
// Stay at ResponseTimeMin for a bi... | |
ed);
ActivityRawSamplesRecord *records = (ActivityRawSamplesRecord *)data;
for (int i = 0; i < num_items; i++) {
cl_assert(s_num_dls_accel_records < ARRAY_LENGTH(s_dls_accel_records));
s_dls_accel_records[s_num_dls_accel_records++] = records[i];
}
} else if (logging_session == (DataLoggingSe... | (false, file, line, "Missing activity record", "", true) | ;
}
#define ASSERT_ACTIVITY_DLS_RECORD_PRESENT(record) \
prv_assert_dls_activity_record_present((record), __FILE__, __LINE__)
// Assert that given number of activity sessions are present
static void prv_assert_num_activities(uint32_t num_expected, char *file, int line) {
ActivitySession sessions[ACTIVITY_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_process_manager_compiled_with_legacy2_sdk = false;
} |
void test_layer_rect__cleanup(void) {
}
// Tests
////////////////////////////////////
void test_layer_rect__2_x_extend_shrink(void) {
Layer l;
s_process_manager_compiled_with_legacy2_sdk = true;
layer_init(&l, &GRect(10, 20, 30, 40));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 30, 40));
// expands
la... |
/*
* 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... | decode_start(254) | ;
assert_decode_char_succeeds(0xff);
for (int c = 0x01; c <= 0xfe; ++c) {
assert_decode_char_succeeds(c);
}
assert_decode_completed(254);
const unsigned char *iter = out;
for (int c = 0x01; c <= 0xfe; ++c) {
cl_assert_equal_i(*iter++, c);
}
}
void test_cobs_decode__empty_data(void) {
decode_sta... |
return;
}
AppInstallId app_id = quick_launch_get_app(button);
if (app_id == INSTALL_ID_INVALID) {
app_id = app_install_get_id_for_uuid(&quick_launch_setup_get_app_info()->uuid);
}
prv_launch_app_via_button(&(AppLaunchEventConfig) {
.id = app_id,
.common.reason = APP_LAUNCH_QUICK_LAUNCH,
}, recog... | ("Invalid event type: %u", e->type) | ;
break;
}
}
static void prv_watchface_launch_low_power(void) {
PBL_LOG(LOG_LEVEL_DEBUG, "Switching default watchface to low_power_mode watchface");
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = APP_ID_LOW_POWER_FACE,
});
}
void watchface_launch_default(const CompositorTransition ... |
rendered at position (0,0);
// then this function shifts it to its correct position of (0, STATUS_BAR_HEIGHT).
// Either this function should set the window not on screen, or we should provide
// an alternate function for initializing the window that takes a frame dimension too.
void window_init(Window *window, const c... | if (button_id == BUTTON_ID_BACK) {
return;
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | bt_driver_handle_le_encryption_change_event(e) | ;
break;
}
case HcMessageID_GapLEConnect_UpdateAddressAndIRK: {
const BleAddressAndIRKChange *e = (BleAddressAndIRKChange *)msg->payload;
bt_driver_handle_le_connection_handle_update_address_and_irk(e);
break;
}
case HcMessageID_GapLEConnect_PeerVersionInfo: {
const BleRemo... |
/*
* 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_m(expectbuf, destbuf, 8) | ;
}
void test_strcpy__n_return(void) {
char testbuf[8] = "Hello!";
char destbuf[8] = "AAAAAAAA";
cl_assert_equal_p(strncpy(destbuf, testbuf, 8), destbuf);
}
|
Stubs
/////////////////////
#include "stubs_app_state.h"
#include "stubs_graphics.h"
#include "stubs_heap.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_ui_window.h"
#include "stubs_process_manager.h"
#include "stubs_unobstructed_a... | menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks){
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
}) | ;
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(0, l.selection.y);
const int16_t basic_cell_height = menu_cell_basic_cell_height();
const int row0_vertically_centered = (height - basic_cell_height)/2;
cl_assert_equal_i(row0_vertically_centered, scroll_layer_get_content_offset(... |
ome tests deinitialize the engine, avoid double de-init
if (app_state_get_rocky_runtime_context() != NULL) {
jerry_cleanup();
rocky_runtime_context_deinit();
}
gbitmap_destroy(s_pixels);
s_pixels = NULL;
free(s_framebuffer);
}
static const RockyGlobalAPI *s_graphics_api[] = {
&GRAPHIC_APIS,
NULL,... | (GSize(500, 300)) | ;
prv_global_init_and_set_ctx();
// http://fiddle.jshell.net/uopr1ez2/2/
EXECUTE_SCRIPT(
"var xx = 200;\n"
"\n"
"function f(x, y, r, a1, a2) {\n"
" ctx.beginPath();\n"
" ctx.arc(x, y, r, a1, a2, false);\n"
" ctx.stroke();\n"
"\n"
" ctx.rockyFillRadial(x + xx, y, 0, r, a1, a2);... |
h encapsulated in `prv_iter_will_draw` and `prv_iter_did_draw`.
//
// In order to visualize this algorithm, imagine these lines below overlaid on the major control
// statements below:
//
// for ___ Ascent loop caused by the "if container". With nested containers, the algorithm
// \ \ / will k... | (node, ctx, box, render) | ) {
prv_draw_text_node_tree(node, ctx, box, config, render, size_out);
} else if (size_out) {
*size_out = node->cached_size;
}
}
void graphics_text_node_get_size(GTextNode *node, GContext *ctx, const GRect *box,
const GTextNodeDrawConfig *config, GSize *size_out) {
const ... |
ho-")
cl_assert_equal_i(layout.max_used_size.h, 2 * (FONT_HEIGHT + FONT_LINE_DELTA));
graphics_text_layout_get_max_used_size(&gcontext, "JR Whopper", font, box, GTextOverflowModeWordWrap, GTextAlignmentLeft, (void*)&layout);
cl_assert(layout.box.size.w == box.size.w);
cl_assert_equal_i(layout.max_used_size.w, ... | (&gcontext,
"\xE2\x80\x8F" // Left-To-Right mark
"\xEF\xB8\x8E" // Variation Selector 1
"\xF0\x9F\x8F\xBB", // White skin tone codepoint
font, box,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, (void*)&layo... | ;
cl_assert_equal_i(layout.box.size.w, box.size.w);
cl_assert_equal_i(layout.max_used_size.w, 0 * HORIZ_ADVANCE_PX);
}
|
ast_processed_utc When activity sessions were computed, this is the UTC of the
// most recent minute we had access to when activities were computed.
// @param[out] stats this structure is filled in with the sleep stats
// @return True if there were sleep session, False if not
static bool prv_compute_sleep_stats(... | {
// We will be filling in this structure based on the sleep sessions
ActivitySleepData *sleep_data = &state->sleep_data;
// If we detect a change in the sleep metrics, we want to post a health event
ActivitySleepData prev_sleep_data = *sleep_data;
// Collect stats on sleep
ActivitySleepStats ... |
// We are still sleeping
if (stats.last_deep_exit_utc == stats.last_exit_utc) {
sleep_data->cur_state = ActivitySleepStateRestfulSleep;
} else {
sleep_data->cur_state = ActivitySleepStateLightSleep;
}
sleep_data->cur_state_elapsed_minutes = (stats.last_session_len_sec + no... |
eters_t *GAP_LE_Advertising_Parameters,
GAP_LE_Connectability_Parameters_t *GAP_LE_Connectability_Parameters,
GAP_LE_Event_Callback_t GAP_LE_Event_Callback,
unsigned long CallbackParameter) {
s_is_le_advertising_enabled = true;
... | BTDeviceAddressToBDADDR(device->address) | |
e this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDI... | if (expect_is_handled) {
cl_assert_equal_i(e.type, PEBBLE_MEDIA_EVENT);
cl_assert_equal_i(e.media.type, PebbleMediaEventTypeVolumeChanged);
cl_assert_equal_i(music_get_volume_percent(), 0x33);
} else {
cl_assert_equal_i(e.type, PEBBLE_NULL_EVENT);
} |
}
static void prv_receive_and_assert_player_info(bool expect_is_handled) {
uint8_t msg[] = { 0x13, 17, 'c', 'o', 'm', '.', 's', 'p', 'o', 't', 'i', 'f', 'y', '.', 'm',
'u', 's', 'i', 'c', 7, 'S', 'p', 'o', 't', 'i', 'f', 'y' };
prv_receive_pp_data(msg, sizeof(msg));
PebbleEvent e = fake_eve... |
e, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on... | (&s_fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
framebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers *... |
/*
* 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;
} |
bool app_install_is_app_running(AppInstallId id) {
return true;
}
void app_install_mark_prioritized(AppInstallId install_id, bool can_expire) {
}
bool system_task_add_callback(void(*cb)(void *data), void *data) {
cb(data);
return true;
}
status_t app_cache_app_launched(AppInstallId id) {
return 0;
}
void ... |
tc_sync_timer);
}
//! How frequently we save the time state to the backup registers in ticks.
#define SAVE_TIME_FREQUENCY (30 * RTC_TICKS_HZ)
static void check_and_handle_rollover(RtcIntervalTicks rtc_ticks) {
bool save_needed = false;
const RtcIntervalTicks last_ticks = s_last_ticks;
s_last_ticks = rtc_ticks;... | RTC_AlarmCmd(RTC_Alarm_A, DISABLE) | ;
RTC_ClearITPendingBit(RTC_IT_ALRA);
EXTI_ClearITPendingBit(EXTI_Line17);
}
}
|
cense, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distribute... | MIN((uint16_t)ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN, attribute->length) | |
bl_override_time(time_t *tloc) {
time_t t = sys_get_time();
if (tloc) {
*tloc = t;
}
return (t);
}
// Manually construct double to avoid requiring soft-fp
static double prv_time_to_double(time_t time) {
// time_t is 32bit signed int, convert it manually
#ifndef UNITTEST
_Static_assert(sizeof(time_t) ==... | {
syscall_assert_userspace_buffer(s, maxsize);
syscall_assert_userspace_buffer(format, strlen(format));
syscall_assert_userspace_buffer(tim_p, sizeof(struct tm));
} |
return localized_strftime(s, maxsize, format, tim_p, locale);
}
void *pbl_memcpy(void *destination, const void *source, size_t num) {
// In releases prior to FW 2.5 we used GCC 4.7 and newlib as our libc implementation. However,
// in 2.5 we switched to GCC 4.8 and nano-newlib. We actually ran into bad apps 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... | data->closed_cb(data->closed_cb_context) | ;
}
menu_layer_deinit(&data->menu_layer);
#if PBL_RECT
status_bar_layer_deinit(&data->status_layer);
#endif
kernel_free(data);
}
static void prv_chaining_window_load(Window *window) {
ChainingWindowData *data = window_get_user_data(window);
const GRect bounds = grect_inset(data->window.layer.bounds, (GEd... |
table;
}
// If we were stable before, just make sure we are still stable
if (s_manager_state.sensor_stable) {
// If we just went on-wrist or off-wrist, reset the stable state
bool off_wrist_now = (data->hrm_quality == HRMQuality_OffWrist);
if (off_wrist_now != s_manager_state.off_wrist_when_stable) {... | ticks_to_milliseconds(remaining_ticks) | ;
HRM_LOG("Need sensor on again in %"PRIu32" sec", remaining_ms / MS_PER_SECOND);
turn_sensor_on = (remaining_ms <= 0);
}
if (turn_sensor_on && !hrm_is_enabled(HRM)) {
// Turn on the sensor now
HRM_LOG("Turning on HR sensor");
s_manager_state.accel_state = sys_accel_manager_data_... |
ual_i(FOCUSED, l.selection.h);
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionUp]);
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
menu_layer_set_selected_index(&l, MenuIndex(0, 1), MenuRowAlignNone, false);
cl_assert_equal_i(1 * NORMAL, l.selection.y);
cl_... | impl->update(l.animation.animation, ANIMATION_NORMALIZED_MAX / 10) | ;
// still unchanged
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(0 * basic_cell_height, l.selection.y);
cl_assert_equal_i(initial_scroll_offset, l.scroll_layer.content_sublayer.bounds.origin.y);
// and updated
impl->update(l.animation.animation, ANIMATION_NORMALIZED_MAX *... |
ions under the License.
*/
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "applib/app.h"
#include "applib/app_timer.h"
#include "applib/battery_state_service.h"
#include "applib/ui/dialogs/simple_dialog.h"
#include "applib/ui/window.h"
#include "kernel/pbl_malloc.h"
#include "kernel/util/stand... | {
struct AppData *data = app_malloc_check(sizeof(struct AppData));
*data = (struct AppData){};
app_state_set_user_data(data);
data->dialog = simple_dialog_create(WINDOW_NAME("Shutdown Charging"));
Dialog *dialog = simple_dialog_get_dialog(data->dialog);
dialog_set_background_color(dialog, GColorBlack);
d... |
static void s_main(void) {
prv_handle_init();
app_event_loop();
}
const PebbleProcessMd* shutdown_charging_get_app_info(void) {
static const PebbleProcessMdSystem s_app_md = {
.common = {
.main_func = s_main,
.visibility = ProcessVisibilityHidden,
// UUID: 48fa66c4-4e6f-4b32-bf75-a16e12d... |
etooth.connection.device);
}
// fall-through!
case PEBBLE_BT_PAIRING_EVENT:
#if CAPABILITY_HAS_BUILTIN_HRM
case PEBBLE_BLE_HRM_SHARING_STATE_UPDATED_EVENT:
#endif
case PEBBLE_BLE_DEVICE_NAME_UPDATED_EVENT: {
settings_bluetooth_update_remotes_private(settings_data);
settings_menu_mark... | ("No LE", data) | : i18n_get("LE Only", data);
}
const char *connected_string = connected ? i18n_get("Connected", data) :
PBL_IF_RECT_ELSE("", NULL);
// Add ellipsis if the name might have been cut off by the mobile
const char ellipsis[] = UTF8_ELLIPSIS_STRING;
const size_t max_name_size = B... |
urn;
}
// This calls through to our window_unload() callback, which cancels our timer and clears s_in_use
window_stack_remove(&data->window, true /* animated */);
}
static int prv_reminders_on_top_comparator(void *a, void *b) {
NotifList *notif_a = (NotifList*) a;
NotifList *notif_b = (NotifList*) b;
Noti... | animation_set_duration(animation, interpolate_moook_soft_duration(NUM_MOOOK_SOFT_MID_FRAMES)) | ;
animation_set_custom_interpolation(animation, prv_interpolate_moook_peek_animation);
return animation;
}
/////////////////////
// Peek Layer
/////////////////////
static void prv_peek_anim_stopped(Animation *animation, bool finished, void *context) {
NotificationWindowData *data = context;
data->first_notif_... |
static PebbleMutex* s_lock = NULL;
// Handle requests from apps
static bool s_from_app;
static Uuid s_app_uuid;
static AudioEndpointSessionId s_session_id = AUDIO_ENDPOINT_SESSION_INVALID_ID;
static TimerID s_timeout = TIMER_INVALID_ID;
static void prv_send_event(VoiceEventType event_type, VoiceStatus status,
... | {
if (s_session_id != session_id) {
PBL_LOG(LOG_LEVEL_WARNING, "Received audio transfer message when no session was in progress ("
"%d)", session_id);
return;
}
mutex_lock(s_lock);
prv_handle_subsystem_started(SessionState_AudioEndpointSetupReceived);
mutex_unlock(s_lock);
} |
static void prv_session_result_timeout(void * data) {
mutex_lock(s_lock);
PBL_ASSERTN(s_state == SessionState_WaitForSessionResult);
prv_reset();
PBL_LOG(LOG_LEVEL_WARNING, "Timeout waiting for session result");
prv_send_event(VoiceEventTypeSessionResult, VoiceStatusTimeout, NULL);
mutex_unlock(s_lock... |
S == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r0_aa_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
#endif
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 11);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 1);
// TODO: Fix offset calculation and reenable... | (&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2)) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax1_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Should not draw anything
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) /... |
*bus) {
bus->busy = false;
}
static void prv_semaphore_give_from_isr(I2CBusState *bus) {
bus->busy = false;
return;
}
/*-------------------BUS/PIN CONFIG FUNCTIONS--------------------------*/
static void prv_rail_ctl(I2CBus *bus, bool enable) {
bus->rail_ctl_fn(bus, enable);
if (enable) {
// wait for ... | prv_bus_disable(slave->bus) | ;
}
}
void i2c_reset(I2CSlavePort *slave) {
PBL_ASSERTN(slave);
if (slave->bus->state->user_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted reset of disabled bus %s when still in use by "
"another bus", slave->bus->name);
return;
}
PBL_LOG(LOG_LEVEL_WARNING, "Resetting I2C bus %s", slave-... |
/*
* 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... | (&BOARD_CONFIG_DISPLAY.mosi, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL) | ;
gpio_output_init(&BOARD_CONFIG_DISPLAY.cs, GPIO_OType_PP, GPIO_Speed_50MHz);
gpio_output_init(&BOARD_CONFIG_DISPLAY.on_ctrl,
BOARD_CONFIG_DISPLAY.on_ctrl_otype,
GPIO_Speed_50MHz);
if (BOARD_CONFIG.power_5v0_options != OptionNotPresent) {
GPIOOType_TypeDef otype = (BOAR... |
ark,
.arg2 = prv_get_japan_telec_t_id()
});
}
// Create the menu
MenuLayer *menu_layer = &data->menu_layer;
GRect bounds = data->window.layer.bounds;
const GEdgeInsets menu_layer_insets = (GEdgeInsets) {
.top = STATUS_BAR_LAYER_HEIGHT,
.bottom = PBL_IF_RECT_ELSE(0, STATUS_BAR_LAYER_HEIGHT... | (&data->title_text, &title_text_frame,
title, title_text_font,
GColorBlack, GColorClear, GTextAlignmentCenter,
GTextOverflowModeTrailingEllipsis) | ;
layer_add_child(window_layer, text_layer_get_layer(&data->title_text));
GRect info_text_frame = (GRect) { .size = info_text_size };
info_text_frame.origin.y = title_text_frame.origin.y + title_text_size.h + vertical_spacing;
text_layer_init_with_parameters(&data->info_text, &info_text_frame,
... |
/*
* 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_comm_session_init() | ;
s_setup_complete_call_count = 0;
s_transport = fake_transport_create(TransportDestinationSystem, NULL, NULL);
s_session = fake_transport_set_connected(s_transport, true);
s_session_id = audio_endpoint_setup_transfer(prv_test_setup_complete_callback,
prv_test_sto... |
0x0
// CONTROL = 0x0
//
// Attempt to put the processor into as close to the reset state as possible
// before passing control to the firmware.
//
// No attempt is made to set CONTROL to zero as it should already be set to
// the reset value when this code executes.
__asm volatile (
"cpsie if... | dbgserial_putstr("Hold down UP + BACK + SELECT for 5 secs. to force-boot PRF") | ;
for (int i = 0; i < 5000; ++i) {
if (!prv_prf_button_combination_is_pressed()) {
// stop waiting if not held down any longer
return false;
}
delay_ms(1);
}
return true;
}
void *reset_vector, *initial_sp;
prv_get_fw_reset_vector(&reset_vector, &initial_sp);
if ((... |
June 9th 2015, 14:00:00 (T-24:00:00)
rtc_set_time(event_time - (24 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Wed, 2:00 PM", time_buf);
// June 9th 2015, 23:59:58 (T-14:00:02)
rtc_set_time(event_time - (14 * SECONDS_PE... | (event_time) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("Version: %"PRIu16"\n", got_version) | ;
cl_assert(got_version == ANALYTICS_DEVICE_HEARTBEAT_BLOB_VERSION);
uint32_t got_value = *((uint32_t *)(data + 28));
printf("Battery change period: %"PRIu32"\n", got_value);
cl_assert(got_value == expected_value);
dls_log_called = true;
return DATA_LOGGING_SUCCESS;
}
DataLoggingSession *dls_create(uint3... |
we report the that multiple sessions are ongoing.
void test_activity__activity_sessions_ongoing_multiple(void) {
// 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 /*test_mode*/);
f... | activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes) | ;
cl_assert_equal_i(zone3_minutes, 0);
// Add some "very elevated" heart rates.
// The zone should wait 1 minute, move up 1 zone per minute, stop at the top
prv_set_median_hr_for_minutes(185 /* BPM */, 5 /* minutes */);
cl_assert_equal_b(prv_is_hr_elevated(), true);
activity_get_metric(ActivityMetricHeartR... |
/*
* 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... | fonts_get_font_height(text_layer->font) | ;
text_layer_set_size(text_layer, (GSize) { text_layer->layer.frame.size.w, size.h + font_height });
const GSize scroll_size = scroll_layer_get_content_size(scroll_layer);
const int16_t new_height = size.h + TEXT_OFFSET_VERTICAL;
if (scroll_size.h != new_height) {
const GRect *bounds = &scroll_layer_get_l... |
ay_picker_handle_selection(MenuLayer *menu_layer, MenuIndex *cell_index,
void *callback_context) {
AlarmEditorData *data = (AlarmEditorData *)callback_context;
if (cell_index->row == 0) { // selected the "completed day selection" row
if (!prv_is_custom_day_sch... | {
#if !CAPABILITY_HAS_HEALTH_TRACKING
prv_call_complete_cancelled_if_no_alarm(data);
#endif
return;
} |
// Editing time
time_selection_window_deinit(&data->time_picker_window);
if (data->time_picker_was_completed) {
data->complete_callback(EDITED, data->alarm_id, data->callback_context);
}
i18n_free_all(data);
task_free(data);
data = NULL;
}
static void prv_time_picker_window_appear(Window *window) ... |
if (jobs_pending == put_jobs->num_allocated_pb_jobs) {
return NULL; // Remote has sent data without us ACKing the previous payload!
}
return put_jobs->job[write_idx].buffer;
}
//! Marks the PB job as written to
static void prv_finalize_pb_job(void) {
PutBytesPendingJobs *put_jobs = &s_pb_state.pb_pendi... | (LOG_LEVEL_INFO, "Put bytes cleanup. Tok: %"PRIu32, s_pb_state.token) | ;
prv_deinit_put_job_queue();
s_pb_state.receiver = (__typeof__(s_pb_state.receiver)) {};
if (s_pb_state.timer_id) {
new_timer_delete(s_pb_state.timer_id);
s_pb_state.timer_id = TIMER_INVALID_ID;
}
pb_storage_deinit(&s_pb_state.storage, s_pb_state.is_success);
// Stay at ResponseTimeMin for a bi... |
*ctx, const char *text,
GFont const font, const GRect box,
const GTextOverflowMode overflow_mode,
const GTextAlignment alignment,
GTextLayo... | (1, s_graphics_fill_rect.call_count) | ;
cl_assert_equal_i(4, s_graphics_line_draw_precise_stroked.call_count);
cl_assert_equal_i(0, s_graphics_draw_line.call_count);
cl_assert_equal_i(1, s_graphics_context_set_fill_color.call_count);
cl_assert_equal_i(4, s_graphics_context_set_stroke_color.call_count);
cl_assert_equal_i(4, s_graphics_co... |
sizeof(m_info.settings_key),
&history, sizeof(history));
}
activity_private_settings_close(file);
}
if (current_value_updated) {
if (metric == ActivityMetricStepCount) {
PebbleEvent e = {
.type = PEBBLE_HEALTH_SERVICE_EVENT,
.health_event = {
.ty... | time_util_get_minute_of_day(utc_sec) | |
/*
* 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 (!window) {
return NULL;
}
return layer_get_recognizer_list(&window->layer);
} | |
= 42 + status_layer_offset;
#else
const uint16_t icon_top_default_margin_px = 18 + status_layer_offset;
#endif
const uint16_t frame_height_claimed = icon_height + TEXT_MAX_HEIGHT_PX + status_layer_offset;
const uint16_t icon_top_adjusted_margin_px = MAX(window_height - frame_height_claimed, 0);
// Try and use ... | window_single_click_subscribe(BUTTON_ID_SELECT, prv_click_handler) | |
/*
* 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(entry->val, val, val_len) | ;
entry->key_len = key_len;
entry->val_len = val_len;
entry->flags |= RamStorageFlagDirty;
// Add to list
storage->entries = (RamStorageEntry *)list_prepend((ListNode *)storage->entries, &entry->node);
return 0;
}
int ram_storage_get_len(RamStorage *storage, const uint8_t *key, int key_len) {
RamStorage... |
urce_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
// Reset data
prv_set_data(&s_data, 0, 0, 0, 0);
prv_set_unobstructed_area_height(0);
s_clock_is_24h_style = false;
// Init window
window_init(&s_data.wind... | (&s_data.window, &s_ctx) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
|
aw_row(GContext* ctx,
const Layer *cell_layer,
MenuIndex *cell_index,
void *callback_context) {}
static uint16_t prv_get_num_rows(struct MenuLayer *menu_layer,
uint16_t section_index,
... | menu_layer_get_selected_index(&l) | .row);
cl_assert_equal_i(0, l.selection.y);
cl_assert_equal_i(0, scroll_layer_get_content_offset(&l.scroll_layer).y);
cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]);
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
const int FOCUSED = MENU_CELL_ROUND_FO... |
_bar_layer_legacy2_deinit(action_bar_layer);
task_free(action_bar_layer);
}
Layer* action_bar_layer_legacy2_get_layer(ActionBarLayerLegacy2 *action_bar_layer) {
return &action_bar_layer->layer;
}
inline static void* action_bar_legacy2_get_context(ActionBarLayerLegacy2 *action_bar) {
return action_bar->context ?... | {
const uint8_t vertical_margin = 3;
const GRect *window_bounds = &window->layer.bounds;
GRect rect = GRect(0, 0, ACTION_BAR_LEGACY2_WIDTH,
window_bounds->size.h - (vertical_margin * 2));
layer_set_bounds(&action_bar->layer, &rect);
rect.origin.x = window_bounds->size.w - ACTION_BAR_LEGAC... |
void action_bar_layer_legacy2_remove_from_window(ActionBarLayerLegacy2 *action_bar) {
if (action_bar == NULL || action_bar->window == NULL) {
return;
}
layer_remove_from_parent(&action_bar->layer);
window_set_click_config_provider_with_context(action_bar->window, NULL, NULL);
action_bar->window = NULL;
... |
return StateStopWaitForResponse;
} else if (next_state == StateWaitForResponse) {
return next_state;
}
break;
case StateWaitForResponse:
if (next_state == StateTransitionToText) {
return StateStopWaitForResponse;
}
break;
case StateStopWaitForRespons... | window_get_root_layer(window) | ;
const GRect *root_frame = &root_layer->frame;
Layer *mic_dot_layer = &data->mic_window.mic_dot_layer;
GRect dot_frame = {.size = MIC_DOT_LAYER_SIZE};
grect_align(&dot_frame, root_frame, GAlignCenter, false);
layer_init(mic_dot_layer, &dot_frame);
layer_set_clips(mic_dot_layer, false); //
layer_set_u... |
, int key_len, const uint8_t *val,
int val_len);
void test_app_glance_db__read_stale_glance_blob(void) {
// Force the insertion of a stale glance blob (outdated version)
const SerializedAppGlanceHeader app_glance = (SerializedAppGlanceHeader) {
.version = APP_GLANCE_DB_CURRE... | (app_glance_db_read_glance(NULL, &glance_out), E_INVALID_ARGUMENT) | ;
// NULL glance_out fails
cl_assert_equal_i(app_glance_db_read_glance(&APP_GLANCE_TEST_UUID, NULL), E_INVALID_ARGUMENT);
}
void test_app_glance_db__inserting_glance_with_invalid_arguments_fails(void) {
// NULL UUID fails
const AppGlance glance = {};
cl_assert_equal_i(app_glance_db_insert_glance(NULL, &glan... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | connection_by_idx(conn_idx) | ;
if (!conn) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to find connection during enqueue attempt");
return false;
}
connection_enqueue_gatt_op(conn, context_ref, resp_dest, op_type);
return true;
}
static bool prv_pop_errored_op(uint16_t conn_idx) {
Connection *conn = connection_by_idx(conn_idx);
if (!c... |
ct pair_text_area = GRect(0, -2, width, 44);
#else
GRect pair_text_area = GRect(0, -2, width, 30);
#endif
#if PLATFORM_ROBERT || PLATFORM_CALCULUS
layer_set_frame(&data->info_text_mask_layer, &GRect(x_offset, info_text_y_offset, width, 30));
#else
layer_set_frame(&data->info_text_mask_layer, &GRect(x_offset, inf... | kernel_free(data) | |
(&ctx, GPoint(66, 36), 10) | ;
// T facing down - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(101, 33), 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(97, 37), 10);
// T facing left - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 70), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(5, 76), 5... | |
/*
* 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 (prv_is_advertising_for_reconnection()) {
gap_le_advert_unschedule(s_reconnect_advert_job);
}
} |
static void prv_evaluate(ReconnectType prev_type) {
ReconnectType cur_type = prv_current_reconnect_type();
if (cur_type == prev_type) {
return;
}
if (cur_type != ReconnectType_None) {
prv_unschedule_adv_if_needed();
#if CAPABILITY_HAS_BUILTIN_HRM
const bool use_hrm_payload = (cur_type == Reconne... |
/*
* 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... | {
BlobDBCommand cmd;
BlobDBToken token;
BlobDBResponse result;
uint8_t num_ids;
BlobDBId db_ids[NumBlobDBs];
} | |
/*
* 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... | (BOARD_CONFIG_POWER.vusb_stat.gpio, &GPIO_InitStructure) | |
kino_reel_transform_set_to_frame(reel, from);
}
kino_reel_scale_segmented_set_end_as_dot(reel, data->mic_window.mic_dot_radius);
kino_layer_play_section(&data->mic_window.icon_layer, 0, UNFOLD_DURATION);
} else {
if (to.size.w < from.size.w) {
// swap frames so that we unfold from a dot
... | (&data->mic_window.mic_dot_layer, &to) | |
client->alive_check_pending = false;
prv_set_state(ANCSClientStateAliveCheck);
//! Sends an ANCS attribute fetch (to the Control Point). The notification UID is invalid, ANCS
//! will reply with 0xA2 (invalid param)
const GetNotificationAttributesMsg dummy_cmd = {
.command_id = CommandIDGetNotific... | {
case CommandIDGetNotificationAttributes:
return ancs_util_is_complete_notif_attr_response(data, length, out_error);
case CommandIDGetAppAttributes:
return ancs_util_is_complete_app_attr_dict(data, length, out_error);
default:
*out_error = false;
break;
} |
return false;
}
static void prv_reassembly_handle_complete_response(const uint8_t* data, const size_t length) {
analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_COUNT, AnalyticsClient_System);
switch (prv_current_command_id(data)) {
case CommandIDGetNotificationAttributes:
prv_handle_notifica... |
s_layer_frame);
status_bar_layer_set_colors(&data->status_layer, GColorClear, GColorBlack);
layer_add_child(&data->window.layer, &status_layer->layer);
music_get_pos(&data->track_pos, &data->track_length);
#if CAPABILITY_HAS_VIBE_SCORES
data->score = vibe_score_create_with_resource(RESOURCE_ID_VIBE_SCORE_HAPT... | {
// [INTL] The app name should come from a standard app resource, so it's localizable.
static const PebbleProcessMdSystem s_app_info = {
.common = {
.main_func = &prv_main,
// UUID: 1f03293d-47af-4f28-b960-f2b02a6dd757
.uuid = {0x1f, 0x03, 0x29, 0x3d, 0x47, 0xaf, 0x4f, 0x28,
0x... | |
lock();
}
static void prv_bt_le_gateway_response_latency_watchdog_cb(void *data) {
// offload handling onto KernelBG so we don't stall the timer thread
// trying to get the bt lock
system_task_add_callback(prv_bt_le_gateway_response_latency_watchdog_handler, data);
}
static bool prv_find_source(ListNode *found_... | kernel_free(curr_request) | ;
curr_request = temp;
}
kernel_free(*info);
*info = NULL;
}
void command_change_le_mode(char *mode) {
// assume we only have one connection for debug
GAPLEConnection *conn_hdl = gap_le_connection_any();
ResponseTimeState state = atoi(mode);
conn_mgr_set_ble_conn_response_time(
conn_hdl, BtCo... |
nsform_set_transform_duration(icon_reel,
SQUARE_ANIMATION_FRAMES * ANIMATION_FRAME_MS);
kino_layer_set_reel(&s_phone_ui_data->icon_layer, icon_reel, true);
kino_layer_play(&s_phone_ui_data->icon_layer);
s_phone_ui_data->current_icon = new_image;
s_phone_ui_data->curr... | property_animation_create(&s_color_slide_animation_impl, NULL, &width, &zero) | );
s_phone_ui_data->bg_color.boundary = width;
}
s_phone_ui_data->bg_color_animation = color_animation;
animation_set_duration(color_animation, COLOUR_ANIMATION_FRAMES * ANIMATION_FRAME_MS);
animation_set_curve(color_animation, AnimationCurveEaseIn);
animation_schedule(color_animation);
#else
layer_mark... |
ssert_equal_i(y, 255 + 255);
}
void test_gdraw_command_transforms__int_scale_to_translate_overflow_neg(void) {
InterpolateInt64Function interp = prv_default_interpolate;
int y = prv_int_scale_and_translate_to(-255, 10, 10, 10, 0, -255, ANIMATION_NORMALIZED_MAX,
interp);
c... | (&ctx.dest_bitmap, fn) | ;
t += dt;
}
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (!pb_encode_tag_for_field(stream, field)) {
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... | ("# passed all %d test(s)\n", test_count) | ;
else
printf("# failed %d among %d test(s)\n", error_count,
test_count);
printf("1..%d\n", test_count);
}
static void clar_print_error(int num, const struct clar_error *error)
{
(void)num;
printf(" ---\n");
printf(" message : %s\n", error->error_msg);
printf(" severity: fail\n");
printf(" suite : %... |
_recursive(s_manager_state.lock);
HRMSessionRef session_ref = HRM_INVALID_SESSION_REF;
// If there is already an existing subscription for this app, remove the old one before we
// add another subscription for this app.
if (is_app_subscription) {
HRMSubscriberState * state = prv_get_subscriber_state_from_a... | (s_manager_state.lock) | ;
HRMSubscriberState *state = prv_get_subscriber_state_from_ref(session);
if (state) {
state->update_interval_s = update_interval_s;
state->expire_utc = (expire_s != 0) ? (rtc_get_time() + expire_s) : 0;
state->sent_expiration_event = false;
success = true;
}
system_task_add_callback(prv_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... | PBL_IF_COLOR_ELSE(GColorCobaltBlue, GColorBlack) | , GColorWhite },
.icons_enabled = config->icons_enabled,
};
option_menu_configure(&s_data.option_menu, &option_menu_config);
const OptionMenuCallbacks callbacks = {
.draw_row = config->callbacks.draw_row ?: prv_menu_draw_row,
.get_num_rows = config->callbacks.get_num_rows ?: prv_menu_get_num_rows,
... |
prv_advance_time_hr(1, 100 /*bpm*/, HRMQuality_Good, false /*force_continuous*/) | ;
// Should be back to no sampling by now (very large sampling period)
cl_assert(s_hrm_manager_update_interval > SECONDS_PER_HOUR);
// Advance to our next sampling period, but the watch is flat so we shouldn't start sampling
s_test_alg_state.orientation = 0x00; // Flat
prv_advance_time_hr(ACTIVITY_DEFAULT_HR... | |
/*
* 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... | storage_acquire() | ;
{
device_t *dev = find_device_by_conn_idx(conn_idx);
if (!dev) {
success = false;
goto release;
}
bool is_resolved = false;
if (dev && dev->irk) {
is_resolved = true;
if (irk_out) {
memcpy(irk_out, dev->irk->key, sizeof(*irk_out));
}
} else {
PBL_L... |
// reversed in the future)
if (s_data.expanding) {
prv_modal_transition_animation_init_sequence(MODAL_CONTRACT_FROM_MODAL_ANIMATION);
s_data.expanding = false;
}
distance_normalized = animation_timing_scaled(distance_normalized,
0,
... | if (s_data.animation_sequence) {
animation_set_duration(animation, duration);
animation_set_curve(animation, AnimationCurveLinear);
} | |
struct LCPPacket *packet = pulse_link_send_begin(this->protocol_number);
packet->code = ControlCode_CodeReject;
packet->identifier = this->state->next_code_reject_id++;
size_t body_len = MIN(ntoh16(bad_packet->length),
pulse_link_max_send_size() - LCP_HEADER_LEN);
memcpy(packet->data, ba... | PBL_LOG(LOG_LEVEL_WARNING, "Unexpected duplicate Configure-Ack") | ;
prv_send_configure_request(this);
prv_transition_to(this, LinkState_RequestSent);
break;
case LinkState_AckSent:
this->state->restart_count = MAX_CONFIGURE;
prv_transition_to(this, LinkState_Opened);
break;
default:
break;
}
}
static void prv_handle_nak_or_reject(P... |
e opaque since that represents how framebuffer discards it in display.
// Also needed for unit tests since PNG tests interpret alpha
color.a = 3;
line[point.x] = color.argb;
}
}
#endif
#if PBL_BW
static inline void set_pixel_raw_2bit(GContext* ctx, GPoint point) {
if (!grect_contains_point(&ctx->dest_b... | WITHIN(y, clip_box->origin.y, grect_get_max_y(clip_box) - 1) | ) {
return;
}
const int16_t min_valid_x = clip_box->origin.x;
if (x1.integer < min_valid_x) {
x1 = (Fixed_S16_3){.integer = min_valid_x, .fraction = 0};
}
const int16_t max_valid_x = grect_get_max_x(clip_box) - 1;
if (x2.integer > max_valid_x) {
x2 = (Fixed_S16_3){.integer = max_valid_x};
}
... |
/*
* 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... | (sizeof(GBCoredumpData)) | |
(BTLEPayloadTypeCount * sizeof(SimpleMenuItem)) | ;
for (int i = 0; i < BTLEPayloadTypeCount; ++i) {
data->payload_menu_items[i] = (SimpleMenuItem) {
.title = s_payload_names[i],
.callback = prv_register_payload,
};
}
data->payload_menu_section = (SimpleMenuSection) {
.num_items = BTLEPayloadTypeCount,
.items = data->payload_menu_ite... | |
(
s_command_list_index? S_SUCCESS : S_NO_ACTION_REQUIRED);
}
// Tests
///////////////////////////////////////////////////////////
void test_flash_erase__initialize(void) {
s_command_list_index = 0;
s_callback_called_count = 0;
s_callback_status = 42;
s_simulate_work_queue_full_countdown = -1;
s_simula... | prv_test_erase_optimal_range(
32 * 1024, 32 * 1024, (32 + 71) * 1024, (32 + 96) * 1024,
(EraseCommand[]) {
{ 32 * 1024, SubsectorEraseCommand },
{ 36 * 1024, SubsectorEraseCommand },
{ 40 * 1024, SubsectorEraseCommand },
{ 44 * 1024, SubsectorEraseCommand },
... | ;
}
void test_flash_erase__watch_and_learn(void) {
// Test cases stolen from Alvin's watch and learn app that originally hit this bug
prv_test_erase_optimal_range(
0x320000, 0x320000, 0x33177c, 0x338000,
(EraseCommand[]) {
{ 0x320000, SectorEraseCommand },
{ 0x330000, SubsectorErase... |
mation, calling the b's transition init func. The animation
// should not be scheduled as we're waiting for the interrupted app to render
cl_assert_equal_i(s_count_animation_create, 2);
cl_assert_equal_i(s_count_animation_schedule, 1);
cl_assert_equal_i(s_count_compositor_init_func_a, 1);
cl_assert_equal_i(s_... | (s_count_animation_create, 0) | ;
// Push a modal window with an animation and then pop it without an animation. The app still
// shouldn't be ready.
s_modal_window_present = true;
compositor_transition(&s_transition_a);
cl_assert_equal_i(s_count_animation_create, 1);
s_modal_window_present = false;
compositor_transition(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... | {
prv_shutdown(true);
} |
}
void led_controller_rgb_set_color(uint32_t rgb_color) {
if ((BOARD_CONFIG_BACKLIGHT.options & ActuatorOptions_IssiI2C) == 0 || !s_initialized) {
return;
}
s_rgb_current_color = rgb_color;
uint8_t red = (s_rgb_current_color & 0x00FF0000) >> 16;
uint8_t green = (s_rgb_current_color & 0x0000FF00) >> 8... |
/*
* 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_ASSERT_RUNNING_FROM_EXPECTED_TASK(PebbleTask_KernelBackground);
const uint8_t cmd = data[0];
switch (cmd) {
case ResetCmdNormal:
PBL_LOG(LOG_LEVEL_WARNING, "Rebooting");
system_reset();
break;
case ResetCmdCoreDump:
PBL_LOG(LOG_LEVEL_INFO, "Core dump + Reboot triggered");
... |
void fw_prepare_for_reset(bool unsafe_reset) {
if (!unsafe_reset) {
// Tear down Bluetooth, to avoid confusing the phone:
services_set_runlevel(RunLevel_BareMinimum);
#if PULSE_EVERYWHERE
pulse_end();
#endif
} else {
pulse_prepare_to_crash();
}
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, "Exec command <%s>", buffer) | ;
prompt_context_execute(prompt_context);
}
void accessory_mfg_mode_start(void) {
#ifdef DISABLE_PROMPT
return;
#else
prv_display_prompt();
#endif
}
bool accessory_mfg_mode_handle_char(char c) {
// Note: You're in an interrupt here, be careful
#if DISABLE_PROMPT
return false;
#else
if (UNLIKELY... |
to the phone and force this to say we're not a MFG firmware. If we tell the phone app
// that we're a MFG firmware it will get mad at us and try to update us out of this mode. We
// want to stay in this mode to collect logs and core dumps at the factory.
// FIXME: Long term the phone should probably just be able... | hton16(activity_insights_settings_get_version()) | ;
#endif
comm_session_send_data(session, s_endpoint_id, (uint8_t*) &versions_msg, sizeof(versions_msg),
COMM_SESSION_DEFAULT_TIMEOUT);
}
void system_version_protocol_msg_callback(CommSession *session, const uint8_t* data, size_t length) {
switch (data[0]) {
case VERSION_REQUEST: {
p... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | MULT_X((cur - limit_c), (limit_d - limit_c)) | )),
frame.origin.y + frame.size.h);
} else if (cur <= limit_e) {
// zone d - e
return GPoint(frame.origin.x,
frame.origin.y +
DIV_X(frame.size.h * (1000 - MULT_X((cur - limit_d), (limit_e - limit_d)))));
} else {
// zone e - 0
return GPoint(f... |
ed.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "local_addr.h"
#include "comm/bt_lock.h"
#include "system/logging.h"
#include "system/passert.h"
#include <bluetooth/bluetooth_types.h>
#include <bluetooth/id.h>
#include <btutil/bt_device.h>
st... | (LOG_LEVEL_INFO, "Pausing address cycling because PRF!") | ;
bt_local_addr_pause_cycling();
#elif BT_CONTROLLER_CC2564X && !RELEASE
PBL_LOG(LOG_LEVEL_INFO, "Pausing address cycling because cc2564x and beta build!");
bt_local_addr_pause_cycling();
#else
PBL_LOG(LOG_LEVEL_INFO, "No bondings found that require address pinning!");
bt_driver_set_local_address(tr... |
NFIG = 0x0F,
PmicRegisters_LDO1_CONFIG = 0x12,
PmicRegisters_LDO2_CONFIG = 0x14,
PmicRegisters_LDO3_CONFIG = 0x16,
PmicRegisters_MON_CFG = 0x19,
PmicRegisters_HAND_SHK = 0x1D,
PmicRegisters_PWR_CFG = 0x1F
} PmicRegisters;
//! The different power rails that our PMIC controls
typedef enum PmicRail {
PmicRa... | if (success) {
// We enabled the rail!
*ref_count = 1;
// We need to wait a bit for the rail to stabilize before continuing to use the device.
// It takes 2.6ms for the LDO rails to ramp.
delay_ms(3);
return true;
} |
return false;
}
} else {
if (*ref_count <= 1) {
// Set the register byte to XXXXX00X to disable the rail, just mask
register_value = (register_value & ~0x06);
success = prv_write_register(rail_control_reg, register_value);
if (success) {
// We disabled the rail!
... |
/*
* 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... | gpio_output_init(&BOARD_CONFIG_VIBE.ctl, GPIO_OType_PP, GPIO_Speed_2MHz) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | jerry_cleanup() | ;
rocky_runtime_context_deinit();
fake_pbl_malloc_check_net_allocs(); // Make sure no memory was leaked
}
void test_rocky_api_util_args__missing_args(void) {
JERRY_ARGS_MAKE(/* argc == 0 */);
uint8_t v;
ROCKY_ARGS_ASSIGN(ROCKY_ARG(v));
ASSERT_JS_ERROR(error_value, "TypeError: Not enough arguments");
}
v... |
fine PACKET_ID_FLASH_RESPONSE (0x97)
#define PACKET_ID_FLASH_READ (0x98)
#define PACKET_ID_HELLO (0x55)
#define PACKET_ID_TOUCH_STATUS (0x5A)
#define PACKET_ID_PALM_DETECTION (0xBA)
// packet footers
#define PACKET_FOOTER (0x01)
#define RAM_FLASH_FOOTER (0xF1)
// message-related defines
#define HELLO_MESSAGE_DATA (0x... | {
// The 3 data bytes are ST PQ 01 (in hex) with ST being the address and PQ being the value.
PBL_ASSERTN(response.data[0] == address);
PBL_ASSERTN(response.data[2] == PACKET_FOOTER);
*(uint8_t *)result = response.data[1];
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.