prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
data(&attr->mbuf)
},
};
process_manager_send_event_to_process(CONSUMER_TASK, &event);
return true;
}
void smartstrap_attribute_send_event(SmartstrapEventType type, SmartstrapProfile profile,
SmartstrapResult result, uint16_t service_id,
... | {
// stop the in-progress request
smartstrap_cancel_send();
} | |
r this
JS_VAR splice = jerry_get_object_field(event_listeners, "splice");
const jerry_value_t args[] = {jerry_create_number(idx), jerry_create_number(1)};
JS_VAR remove_result = jerry_call_function(splice, event_listeners,
args, ARRAY_LENGTH(args));
if (jer... | {
if (argc < 1) {
return rocky_error_arguments_missing();
}
if (!jerry_value_is_string(argv[0])) {
return rocky_error_unexpected_type(0, "String");
}
jerry_set_object_field(this_val, ROCKY_EVENT_TYPE, argv[0]);
return jerry_create_undefined();
} |
static void prv_copy_property(const jerry_value_t rocky,
const char *name_from, const char *name_to) {
JS_VAR on = jerry_get_object_field(rocky, name_from);
jerry_set_object_field(rocky, name_to, on);
}
void rocky_global_init(const RockyGlobalAPI *const *global_apis) {
PBL_ASSERTN... |
/*
* 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... | property_animation_update_grect((PropertyAnimation *)a, progress) | ;
}
}
static void prv_window_frame_setter(void *subject, GRect rect) {
WindowTransitioningContext *ctx = subject;
Window *const window = ctx->window_to;
if (!window) {
// The window has been unloaded already, but the animation wasn't able to be unscheduled.
return;
}
Layer *const root_layer = windo... |
/*
* 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... | {
continue;
} |
uint32_t vref = ADC_GetConversionValue(VREF_ADC);
ADC_SoftwareStartConv(device->adc);
if (!prv_wait_for_conversion(device->adc)) {
continue;
}
uint32_t vmon = ADC_GetConversionValue(device->adc);
// Only save values and increment counter if both reads were successful
reading_out->vr... |
nt_timer(0, true);
}
}
void bluetooth_analytics_handle_encryption_change(void) {
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BLE_CONNECT_ENCRYPTED_TIME,
AnalyticsClient_System);
}
void bluetooth_analytics_handle_no_intent_for_connection(void) {
analytics_inc(ANALYTICS_DEVICE_ME... | prv_calc_other_errors(&new_stats) | |
rue, false),
delay_spawn + MAX(total_duration_a, total_duration_b));
cl_assert_equal_i(animation_get_duration(spawn, true, true), duration_total);
animation_destroy(spawn);
#endif
}
// --------------------------------------------------------------------------------------
// Test unschedule a... | (animation_get_delay(h) == delay) | |
e, "FIXME: Implement round drawing code to show heart rate sharing status!");
# endif // CAPABILITY_HAS_BUILTIN_HRM
menu_cell_basic_draw(ctx, cell_layer, remote_name, connected_string, NULL);
}
#endif // PBL_ROUND
static void draw_stored_remote_item(GContext *ctx, const Layer *cell_layer,
... | if (data->toggle_state == ToggleStateIdle) {
if (bt_ctl_is_airplane_mode_on()) {
subtitle = i18n_get("Airplane Mode", data);
icon = &data->icon_heap_bitmap[AirplaneIconIdx];
} else {
if (selected) {
bt_local_id_copy_device_name(device_name_buffer, false);
... |
menu_cell_basic_draw(ctx, cell_layer, title, subtitle, icon);
// TODO PBL-23111: Decide how we should show these strings on round displays
#if PBL_RECT
// Hack: the pairing instruction is drawn in the cell callback, but outside of the cell...
if (!data->remote_list_head) {
const GDrawSt... |
p_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_hr_z1(void) {
s_sports_data = (SportsData) {
.current_bpm = 135,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMe... | (active_window, 1) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_custom_hanging_label(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
.custom_label_string = "Hanging... |
urn;
}
#endif
gpath_draw_filled_with_cb(ctx, path, prv_gpath_draw_filled_cb, NULL);
}
void gpath_draw_outline(GContext* ctx, GPath* path) {
gpath_draw_stroke(ctx, path, false);
}
void gpath_draw_outline_open(GContext* ctx, GPath* path) {
gpath_draw_stroke(ctx, path, true);
}
void gpath_draw_stroke(GContext*... | GPointPreciseFromGPoint(
rotate_offset_point(&path->points[i], path->rotation, &path->offset)) | ;
if (min_x > rot_points[i].x.integer) { min_x = rot_points[i].x.integer; }
if (max_x < rot_points[i].x.integer) { max_x = rot_points[i].x.integer; }
if (min_y > rot_points[i].y.integer) { min_y = rot_points[i].y.integer; }
if (max_y < rot_points[i].y.integer) { max_y = rot_points[i].y.integer; }
i... |
ics_context_mask_record(ctx, mask));
draw_func(ctx);
cl_assert(graphics_context_mask_record(ctx, NULL));
cl_assert_equal_p(ctx->draw_state.draw_implementation, &g_default_draw_implementation);
cl_assert(graphics_context_mask_use(ctx, mask));
cl_assert_equal_p(ctx->draw_state.draw_mask, mask);
graphics_c... | (ctx, ANIMATION_NORMALIZED_MAX,
CompositorTransitionDirectionLeft,
GColorWhite) | |
{ -1272, 408, 336},
{ -1224, 328, 344},
{ -1072, 80, 360},
{ -776, -40, 328},
{ -840, 16, 248},
{ -936, -392, 240},
{ -1032, -552, 8},
{ -1256, -256, -48},
{ -1632, 216, 56},
{ -2048, 768, 0},
{ -2080, 536, 64},
{ -1768, 232, 304},
{ -1192, 728, 160},
{ -944, 560,... | { -960, 120, 312},
{ -1072, 152, 272},
{ -1240, -264, 248},
{ -1192, -224, 288},
{ -1360, 216, 56},
{ -1344, 656, 72},
{ -1376, 464, 224},
{ -1368, 576, 216},
{ -1272, 552, 312},
{ -1080, 512, 400},
// 39 seconds
{ -904, 304, 408},
{ -888, 360, 376},
{ -920, 344, ... |
{ -896, 408, 136},
{ -1024, 368, 176},
{ -1008, 336, 272},
{ -1048, 432, 328},
{ -1016, 576, 568},
{ -1248, 408, 392},
{ -1096, 480, 280},
{ -1008, 496, 176},
{ -1224, 552, 152},
{ -1520, 384, 120},
{ -1528, 560, -136},
{ -1240, 256, 32},
{ -1176, 480, 136},
{ -1... |
g, disable the mic and and stop the audio transfer session. We
// expect voice_handle_dictation_result to be called next with a dictation response
void voice_stop_dictation(VoiceSessionId session_id) {
mutex_lock(s_lock);
if ((s_state == SessionState_Idle) ||
(session_id != s_session_id) ||
(session_id ... | (sentence) | != 0) {
strcat(sentence, " ");
}
strncat(sentence, (char *) word->data, word->length);
}
return true;
}
static bool prv_handle_dictation_nlp_result_common(VoiceEndpointResult result,
AudioEndpointSessionId session_id,
... |
{
rot_bitmap_layer_init(layer, bitmap);
} |
return layer;
}
void rot_bitmap_layer_deinit(RotBitmapLayer *rot_bitmap_layer) {
layer_deinit(&rot_bitmap_layer->layer);
}
void rot_bitmap_layer_destroy(RotBitmapLayer *rot_bitmap_layer) {
if (rot_bitmap_layer == NULL) {
return;
}
rot_bitmap_layer_deinit(rot_bitmap_layer);
applib_free(rot_bitmap_laye... | |
*)&app_id,
sizeof(AppInstallId));
prv_close_file_and_unlock_mutex();
return exists;
}
typedef struct {
AppDBEnumerateCb cb;
void *data;
AppDBEntry *entry_buf;
} EnumerateData;
static bool prv_enumerate_entries(SettingsFile *file, SettingsRecordInfo *info, void *context)... | (key_len == 16) | ;
AppInstallId app_id = prv_find_install_id_for_uuid(&s_app_db.settings_file, (Uuid *)key);
if (app_id == INSTALL_ID_INVALID) {
rv = E_DOES_NOT_EXIST;
} else {
rv = settings_file_get(&s_app_db.settings_file, (uint8_t *)&app_id,
sizeof(AppInstallId), val_out, val_len);
}
pr... |
_set_stroke_width(ctx, data->stroke_width);
graphics_draw_line(ctx, GPoint(70, 100), GPoint(70, 101));
*/
return;
}
if (data->operation == OP_TEST4 || data->operation == OP_TEST5) {
/*
GRect bounds = layer->bounds;
GPoint center = GPoint(bounds.size.w/2, bounds.size.h/2);
int radiu... | layer_create(window_bounds) | ;
layer_set_update_proc(data->debug_layer, debug_layer_update_proc);
layer_add_child(window_layer, data->debug_layer);
data->canvas_layer = layer_create(GRect(10, 10, window_bounds.size.w - 20,
window_bounds.size.h - 20));
layer_set_update_proc(data->canvas_layer, canv... |
/*
* 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_GPIO, &gpio_cfg) | ;
// Configure the SCLK pin to have a weak pull-down to put it in a known state
// when SCS is toggled
gpio_cfg.GPIO_PuPd = GPIO_PuPd_DOWN;
gpio_cfg.GPIO_Pin = FLASH_PIN_SCLK;
GPIO_Init(FLASH_GPIO, &gpio_cfg);
// Configure SCS to be controlled in software; pull up to high when inactive
gpio_cfg.GPIO_Mod... |
req) {
extern void hci_initiate_length_change(uint16_t conn_idx);
hci_initiate_length_change(conn_idx);
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "PLE call a no-op");
}
return ATT_ERROR_OK;
#endif
}
extern void power_inhibit_sleep(void);
static att_error_t prv_handle_conn_params_write(const ble_evt_gatts_w... | {
uint8_t *reverse_uuid = (uint8_t *)&UuidMakeFromLEBytes(buf);
ble_uuid_from_buf(reverse_uuid, uuid);
} |
static void prv_register(PebblePairingServiceCtx *ctx, uint16_t start_hdl) {
*ctx = (PebblePairingServiceCtx) {
.svc = {
.read_req = prv_pps_handle_read_request,
.write_req = prv_pps_handle_write_request,
},
};
const uint16_t num_included_services = 0;
const uint16_t num_characteristics =... |
/*
* 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, false) | ;
graphics_draw_circle(ctx, GPoint(14, 14), 12);
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, false);
graphics_draw_circle(ctx, GPoint(14, 14), 12);
}
void clear_layer_update_callback(Layer* me, GConte... |
/*
* 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... | layer_get_bounds(window_layer) | ;
uint32_t text_width = bounds.size.w;
uint32_t text_height = 28;
text_layer = text_layer_create(GRect(0, bounds.size.h/2 - text_height/2,
text_width, text_height));
// Set the text, font, and text alignment
text_layer_set_text(text_layer, "No Accelerometer");
text_layer_set_text_alignment(text_lay... |
istNode* node = list_find(manager->running_timers, prv_id_list_filter, (void*)timer_id);
if (!node) {
node = list_find(manager->idle_timers, prv_id_list_filter, (void*)timer_id);
}
PBL_ASSERTN(node);
return (TaskTimer *)node;
}
// ===========================================================================... | (manager->mutex) | ;
return retval;
}
// --------------------------------------------------------------------------------
// Stop a timer. If the timer callback is currently executing, return false, else return true.
bool task_timer_stop(TaskTimerManager *manager, TaskTimerID timer_id) {
mutex_lock(manager->mutex);
// Find this ... |
->test_entry.in_sleep.value);
} else if (strcmp(token, "TEST_IN_SLEEP_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.min);
} else if (strcmp(token, "TEST_IN_SLEEP_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.max);
... | ("\nParsing function samples: %s", state->test_entry.name) | |
drawing_box = bitmap->bounds,
#if PBL_COLOR
.antialiased = !process_manager_compiled_with_legacy2_sdk(),
#endif
.stroke_width = 1,
.draw_implementation = &g_default_draw_implementation,
.avoid_text_orphans = (init_mode == GContextInitializationMode_System),
};
}
GDrawState graphics_context_get_drawin... | {
PBL_ASSERTN(ctx);
if (ctx->lock) {
APP_LOG(APP_LOG_LEVEL_WARNING,
"Frame buffer has already been captured; it cannot be captured again until "
"graphics_release_frame_buffer has been called.");
return NULL;
}
ctx->lock = true;
GBitmap *native = graphics_context_get_bitmap(c... | |
/*
* 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 (*attempt > 31) {
return max_value;
}
uint32_t backoff_multiplier = 0x1 << (*attempt)++;
uint32_t next_value = initial_value * backoff_multiplier;
return MIN(next_value, max_value);
} |
uint32_t gcd(uint32_t a, uint32_t b) {
// Infinite loops are bad
if (a == 0 || b == 0) {
return 0;
}
// Euclidean algorithm, yay!
while (a != b) {
if (a > b) {
a -= b;
} else {
b -= a;
}
}
return a;
}
|
app_cache_remove_entry(app1.id) | );
cl_assert_equal_i(S_SUCCESS, app_cache_remove_entry(app2.id));
cl_assert_equal_i(S_SUCCESS, app_cache_remove_entry(app3.id));
cl_assert_equal_i(fake_event_get_count(), 3);
// ensure the one that is evicted is INVALID_ID
cl_assert_equal_i(INSTALL_ID_INVALID, app_cache_get_next_eviction());
}
/***********... | |
ectors(void) {
// write 0's to the entire flash
static uint8_t buf[2048] = { 0 };
char status[80];
__disable_irq();
for (int i = 0; i < 2; i++) {
for (uint32_t addr = 0; addr < BOARD_NOR_FLASH_SIZE; addr += sizeof(buf)) {
if (addr >= FLASH_REGION_SAFE_FIRMWARE_BEGIN &&
addr < FLASH_REGI... | (name, OP_FLAG_WRITE, FILE_TYPE_STATIC, 300) | ;
if (i % 5 == 0) {
pfs_close_and_remove(fd);
} else {
pfs_close(fd);
}
}
}
#endif
#endif
static GAPLEConnection *prv_get_le_connection_and_print_info(void) {
GAPLEConnection *conn = gap_le_connection_any();
if (!conn) {
prompt_send_response("No device connected");
} else {
char... |
on.h"
// FW Includes
///////////////
#include "services/normal/blob_db/api.h"
#include "services/normal/blob_db/util.h"
#include "services/normal/blob_db/sync.h"
#include "util/size.h"
// Writebacks counter
////////////////////////
static int s_num_writebacks;
static int s_num_until_timeout;
void blob_db_endpoint_... | cl_assert_equal_i(list_count(&dirty_list->node), ARRAY_LENGTH(keys)) | ;
for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
cl_assert(list_find(&dirty_list->node, prv_list_key_comparator, keys[i]) != NULL);
}
blob_db_util_free_dirty_list(dirty_list);
// mark one as synced and re-check
for (int synced_idx = 1; synced_idx < ARRAY_LENGTH(keys); ++synced_idx) {
blob_db_mark_s... |
ain 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 CONDITIONS OF ANY KIND, either express or implied.
* See the License ... | ADC_GetConversionValue(ADC1) | ;
// Only save values and increment counter if both reads were successful
reading_out->vref_total += vref;
reading_out->vmon_total += vmon;
++i;
}
ADC_Cmd(ADC1, DISABLE);
ADC_TempSensorVrefintCmd(DISABLE);
periph_config_disable(ADC1, RCC_APB2Periph_ADC1);
mutex_unlock(s_adc_mutex);
}
|
ckLaunchPreference *pref) {
s_quick_launch_select = *pref;
return true;
}
static bool prv_set_s_quick_launch_back(QuickLaunchPreference *pref) {
s_quick_launch_back = *pref;
return true;
}
static bool prv_set_s_quick_launch_setup_opened(uint8_t *version) {
s_quick_launch_setup_opened = *version;
return tr... | {
s_timeline_peek_before_time_m = *before_time_m;
timeline_peek_set_show_before_time(*before_time_m * SECONDS_PER_MINUTE);
return true;
} |
#endif
// ------------------------------------------------------------------------------------
// Table of all prefs
typedef bool (*PrefSetHandler)(const void *value, size_t val_len);
typedef struct {
const char *key;
void *value;
uint16_t value_len;
PrefSetHandler handler;
} PrefsTableEntry;
// The PREFS_DE... |
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
... | (buffer, sizeof(buffer), "Device: %s", name) | ;
}
}
#endif // RECOVERY_FW
|
address_str, const char* length_str, const char* value_str) {
int32_t address = str_to_address(address_str);
if (address == -1) {
prompt_send_response("Invalid address");
return;
}
int length = atoi(length_str);
if (length <= 0) {
prompt_send_response("Invalid length");
return;
}
int va... | {
uint8_t memmap_buffer[130]; // > 128 bytes, triggers a memmap read for QSPI
memset(memmap_buffer, 0x00, sizeof(memmap_buffer));
const uint32_t pre_addr = TEST_ADDR + offset - MIN(offset, 1);
uint8_t pre_byte;
flash_read_bytes(&pre_byte, pre_addr, sizeof(pre_byte));
const uint32_t addr = TEST... |
// clean up
flash_erase_sector_blocking(TEST_ADDR);
if (!flash_sector_is_erased(TEST_ADDR)) {
prompt_send_response("FAIL: sector not erased");
return;
}
prompt_send_response("OK");
}
//! Some flash chips have an accelerated method of checking for erased sectors. This is a sanity
//! check against... |
scall/syscall_internal.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include <stddef.h>
//! How long to wait after failing to acquire the accessory in ms before trying again
static const uint32_t ACCESSORY_ACQUIRE_INTERVAL = 5000;
//! The backoff before trying to detect a smartstr... | {
// We should attempt to send control messages first, followed by pending attributes.
bool did_send = false;
if (smartstrap_profiles_send_control()) {
did_send = true;
} else if (smartstrap_attribute_send_pending()) {
did_send = true;
}
if (did_send && smartstrap_fsm_state_get() == ... |
if (s_monitor_interval) {
// run the monitor again after the set interval
new_timer_start(s_monitor_timer, s_monitor_interval, prv_monitor_timer_cb, NULL, 0);
} else {
// custom fast-path for 0ms timeout
prv_monitor_timer_cb(NULL);
}
}
static void prv_monitor_timer_cb(void *context) {
// we n... |
et the active gateway
bt_persistent_storage_set_active_gateway(id_1);
ret = bt_persistent_storage_get_active_gateway(&id_out, &type_out);
cl_assert(ret);
cl_assert_equal_i(id_out, id_1);
cl_assert_equal_i(type_out, BtPersistBondingTypeBTClassic);
ret = bt_persistent_storage_has_active_bt_classic_gateway_bo... | cl_assert(!ret) | ;
// Another "sync" happened. We should still be faithful
bt_persistent_storage_set_unfaithful(false);
ret = bt_persistent_storage_is_unfaithful();
cl_assert(!ret);
}
void test_bluetooth_persistent_storage__test_root_keys(void) {
SM128BitKey keys[2] = {
{{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, ... |
},
{ -280, 832, -424},
{ -288, 872, -392},
{ -264, 952, -392},
{ -232, 944, -400},
{ -208, 872, -360},
{ -192, 840, -360},
{ -184, 840, -368},
{ -176, 832, -360},
{ -176, 800, -336},
{ -200, 840, -336},
{ -184, 856, -328},
{ -160, 936, -344},
{ -128, 888, -360},
{... | { -344, 608, -696},
{ -320, 432, -656},
{ -320, 688, -440},
{ -112, 800, 0},
{ 464, 1016, -256},
{ 424, 712, 40},
{ -128, 80, 424},
{ -304, -32, 336},
{ -400, 56, -136},
{ -648, -48, -576},
{ -848, 312, -1008},
{ -616, 1304, -1600},
{ -568, 1448, -1992},
// 63 sec... | |
sizeof(data));
cl_assert_equal_i(data.getting_started.crc, new_crc);
// Should be corrupt, so it should return false
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), false);
// Should have moved to the next page
cl_assert_equal_b(shared_prf_storage_get_valid_page_number(), 1);
// Le... | cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 2) | ;
char device_name_out[BT_DEVICE_NAME_BUFFER_SIZE];
SMPairingInfo pairing_info_out;
const bool rv = shared_prf_storage_get_ble_pairing_data(&pairing_info_out, device_name_out, NULL,
NULL);
cl_assert_equal_b(rv, false);
shared_prf_storage_store_ble_pa... |
---------------------------------
void test_data_logging__log_consume(void) {
DataLoggingSessionRef logging_sessions[10];
const int item_size = 1;
// Create sessions
for (int i = 0; i < 10; i++) {
logging_sessions[i] = data_logging_create(i, DATA_LOGGING_UINT, item_size, false);
cl_assert(logging_sessi... | (LOG_LEVEL_INFO, "total bytes: %d", total_bytes) | ;
cl_assert(total_bytes < DLS_TOTAL_STORAGE_BYTES);
// We should still be able to create more sessions up to the max
for (int i = num_sessions; i < DLS_MAX_NUM_SESSIONS; i++) {
logging_sessions[i] = data_logging_create(i, DATA_LOGGING_UINT, item_size, false);
cl_assert(logging_sessions[i]);
fake_syst... |
t_handler_map[tag].message_handler == message_handler &&
s_event_handler_map[tag].dropped_handler == dropped_handler) {
return tag;
}
}
return AppInboxServiceTagInvalid;
}
DEFINE_SYSCALL(bool, sys_app_inbox_service_register, uint8_t *storage, size_t storage_size,
AppInboxMessageHan... | if (!inbox) {
goto unlock;
} |
uint8_t *const consumed_up_to_ptr = consumer_info->it;
uint8_t * const completed_messages_end = (inbox->buffer.storage + inbox->buffer.write_index);
if (consumed_up_to_ptr < inbox->buffer.storage ||
consumed_up_to_ptr > completed_messages_end) {
PBL_LOG(LOG_LEVEL_ERROR, "Out of bounds");
... |
/*
* 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... | {
attribute_group_init(GROUP_TYPE,
attr_list,
addr_list,
buffer,
num_attributes,
num_addresses,
attributes_per_address);
} | |
// B should start high
distance = prv_last_update_distance(b);
cl_assert(distance > TEST_ANIMATION_NORMALIZED_HIGH);
// Execute to the end of B
prv_advance_to_ms_with_timers(start_ms + duration_total + 1 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), ... | (&s_stopped_handler_calls, NULL) | |
f (logging_session->comm.state != DataLoggingSessionCommStateIdle) {
mutex_unlock(s_endpoint_data.mutex);
// logging_session is waiting for an ack, we'll send next time around
// don't return a failure, this is pretty innocuous.
return true;
}
const uint32_t total_length = sizeof(DataLoggingSendDat... | {
case DataLoggingSessionCommStateIdle:
case DataLoggingSessionCommStateOpening:
//Currently, these messages never get NACK'd
PBL_LOG(LOG_LEVEL_ERROR, "Unexpected NACK");
break;
case DataLoggingSessionCommStateSending:
//Maybe queue a resend
logging_session->comm.num_bytes_pend... |
update_session_state(logging_session, DataLoggingSessionCommStateIdle, true /*reschedule*/);
mutex_unlock(s_endpoint_data.mutex);
// reopen the session that was NACK'ed
dls_endpoint_open_session(logging_session);
}
//! System task callback executed which reopens the next session in the list built up by rep... |
e addresses. If we don't erase this
// area and just load in the old world firmware at FIRMWARE_OLDWORLD_BASE, the
// bootloader will still see the start of the old new world firmware in this
// section and will attempt to boot that.
dbgserial_putstr("Old World firmware base");
erase_length += FW_WO... | (
"Our internal flash contents are bad (checksum failed)! "
"This is really bad!") | ;
return UPDATE_FW_ERROR_MICRO_FLASH_MANGLED;
}
return UPDATE_FW_SUCCESS;
}
void check_update_fw(void) {
if (!boot_bit_test(BOOT_BIT_NEW_FW_AVAILABLE)) {
return;
}
if (boot_bit_test(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS)) {
dbgserial_putstr("Our previous firmware update failed, aborting update.");... |
typedef enum PeekBeforeTimingMenuIndex {
PeekBeforeTimingMenuIndex_StartTime,
PeekBeforeTimingMenuIndex_5Min,
PeekBeforeTimingMenuIndex_10Min,
PeekBeforeTimingMenuIndex_15Min,
PeekBeforeTimingMenuIndex_30Min,
PeekBeforeTimingMenuIndexCount,
PeekBeforeTimingMenuIndexDefault = PeekBeforeTimingMenuIndex_10M... | menu_cell_basic_draw(ctx, cell_layer, i18n_get(title, data), i18n_get(subtitle, data), NULL) | ;
}
static void prv_select_click_cb(SettingsCallbacks *context, uint16_t row) {
SettingsTimelinePeekData *data = (SettingsTimelinePeekData *)context;
switch ((TimelinePeekMenuIndex)row) {
case TimelinePeekMenuIndex_Toggle:
timeline_peek_prefs_set_enabled(!timeline_peek_prefs_get_enabled());
goto do... |
// Should save a reference to the scroll layer
cl_assert_equal_p(content_indicator->scroll_layer, &scroll_layer);
// Should retrieve the same content indicator with the same scroll layer
ContentIndicator *content_indicator2 = content_indicator_get_or_create_for_scroll_layer(
&scroll_layer);
cl_assert(conte... | content_indicator_set_content_available(&content_indicator, direction, true) | ;
cl_assert_equal_p(dummy_config.layer->update_proc, s_content_indicator_dummy_layer_update_proc);
}
void test_content_indicator__re_configure_direction(void) {
ContentIndicator content_indicator;
content_indicator_init(&content_indicator);
const ContentIndicatorConfig dummy_config = helper_get_dummy_config()... |
{ 872, 656, -480},
// 40 seconds
{ 968, 664, -416},
{ 944, 648, -296},
{ 1280, 600, -192},
{ 1280, 616, -216},
{ 1368, 680, -264},
{ 1568, 576, -80},
{ 1560, 456, -8},
{ 1312, 384, -88},
{ 1096, 328, -96},
{ 944, 304, -136},
{ 920, 232, -128},
{ 872, 88, -64},
... | { 1648, 480, -112},
{ 1488, 392, -136},
{ 1152, 304, -56},
{ 1000, 232, -56},
{ 816, 128, -40},
{ 792, 104, -24},
{ 656, 56, 16},
{ 672, 56, -8},
{ 728, 96, 16},
{ 912, 192, -16},
{ 1192, 224, 16},
// 46 seconds
{ 1632, 312, -56},
{ 1688, 336, -168},
{ 1552, 3... |
{ 1384, 120, -344},
{ 1080, 560, -456},
{ 760, 600, -680},
{ 792, 504, -664},
{ 864, 504, -672},
{ 776, 352, -688},
{ 736, 568, -816},
{ 800, 584, -808},
{ 960, 640, -888},
{ 1528, 736, -880},
{ 1960, 664, -560},
{ 2136, 432, -352},
{ 1936, 456, -200},
{ 1528, 32... |
// Do some deep sleep
prv_feed_deep_sleep_min(GOOD_SLEEP);
// Walk long enough to be registered as "awake" for over 2 hours
prv_feed_steps_min((2.5 * MINUTES_PER_HOUR) + ACTIVITY_SESSION_UPDATE_MIN);
// Fast forward time
rtc_set_time(time_util_get_midnight_of(rtc_get_time()) + 4 * SECONDS_PER_DAY)... | localtime_r(&now, &time_tm) | ;
time_tm.tm_hour = 20;
time_tm.tm_min = 25;
rtc_set_time(mktime(&time_tm));
// Set the step history
activity_test_set_steps_history();
prv_feed_steps_min(4);
// Trigger insights
activity_insights_recalculate_stats();
prv_feed_steps_min(1);
prv_test_end(context, passed);
}
// -------------------... |
sert_known_settings(void) {
struct tm time_tm = s_init_time_tm;
time_t utc_sec = mktime(&time_tm);
rtc_set_time(utc_sec);
prv_activity_init_and_set_enabled(true);
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricStepCount,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){300, 200, 100, 0, 0, ... | (buf, size, 1, file) | |
InputConfig miso = { .gpio = bus->spi_miso.gpio, .gpio_pin = bus->spi_miso.gpio_pin };
gpio_analog_init(&miso);
}
bus->state->initialized = false;
}
void prv_spi_bus_init(const SPIBus *bus, bool is_bidirectional) {
if (bus->state->initialized) {
return;
}
// copy the speed over to the transient s... | dma_request_init(slave->rx_dma) | ;
}
if (slave->tx_dma) {
dma_request_init(slave->tx_dma);
}
}
static void prv_spi_acquire_helper(const SPISlavePort *slave) {
spi_ll_slave_acquire(slave);
spi_ll_slave_scs_assert(slave);
}
static void prv_spi_release_helper(const SPISlavePort *slave) {
spi_ll_slave_scs_deassert(slave);
spi_ll_slave_... |
.icon_id = TIMELINE_RESOURCE_NOTIFICATION_REMINDER,
.title = "Implementation Design Review",
.location = "High (Room 12)\nPebble PA Office",
.body = "with Liron Damir and 10 other people",
.time_offset = MINUTES(10),
}
};
#define NUM_NOTIFS ((int)ARRAY_LENGTH(notifications))
typedef struct SwapLa... | swap_layer_set_click_config_onto_window(swap_layer, window) | ;
}
static void handle_init(void) {
SwapLayerDemoData *data = app_malloc_check(sizeof(SwapLayerDemoData));
memset(data, 0, sizeof(SwapLayerDemoData));
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Swap Layer"));
window_set_user_data(window, data);
windo... |
t)(++state->aux->next_handle),
.duration_ms = ANIMATION_DEFAULT_DURATION_MS,
.play_count = 1,
.curve = AnimationCurveDefault,
.auto_destroy = true
};
PBL_ASSERTN(animation->handle);
state->unscheduled_head = list_insert_before(state->unscheduled_head, &animation->list_node);
ANIMATION_LOG_DEBUG... | prv_is_mutable(state, animation) | ) {
return false;
}
animation->auto_destroy = auto_destroy;
return true;
}
// -------------------------------------------------------------------------------------------
bool animation_schedule(Animation *animation_h) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (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... | (activity_type) | ;
const GBitmap *icon = &selection_window->workout_icons[cell_index->row];
const int icon_top_padding = 11;
const int title_top_padding = PBL_IF_RECT_ELSE(11, cell_layer->is_highlighted ? 40 : 2);
const int max_icon_w = PBL_IF_RECT_ELSE(55, cell_layer->bounds.size.w);
const int title_origin_x = PBL_IF_RECT_E... |
GAPLEClientApp, &has_more);
cl_assert_equal_i(handle_out, BLE_CHARACTERISTIC_INVALID);
cl_assert_equal_i(value_length, 0);
// Notification will be eaten, regardless of whether it was copied:
cl_assert_equal_b(has_more, false);
cl_assert_equal_i(next_length, 0);
}
void test_gatt_clie... | (gatt_client_get_event_pending_state(GAPLEClientApp), true) | ;
fake_event_clear_last();
}
static void prv_assert_no_pending_events_to_kernel_and_app(void) {
cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientKernel), false);
cl_assert_equal_b(gatt_client_get_event_pending_state(GAPLEClientApp), false);
}
void test_gatt_client_subscriptions__cleanup_by_conne... |
KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "drivers/i2c_hal.h"
#include "drivers/i2c_definitions.h"
#include "drivers/stm32f2/i2c_hal_definitions.h"
#include "system/passert.h"
#include "drivers/periph_config.h... | {
bus->hal->i2c->CR2 &= ~(I2C_CR2_ITEVTEN | I2C_CR2_ITERREN | I2C_CR2_ITBUFEN);
} |
void i2c_hal_abort_transfer(I2CBus *bus) {
// Disable all interrupts on the bus
prv_disable_all_interrupts(bus);
// Generate a stop condition
bus->hal->i2c->CR1 |= I2C_CR1_STOP;
}
void i2c_hal_init_transfer(I2CBus *bus) {
// Enable Acks
bus->hal->i2c->CR1 |= I2C_CR1_ACK;
bus->state->transfer.state = I2... |
ound_rect_offset_r4_aa_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// AA = true, SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 5);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw3_no_clip.${BIT_DEPTH_NAME}.pbi") | |
bs_syscalls.h"
#include "stubs_compiled_with_legacy2_sdk.h"
///////////////////////////////////////////////////////////
// Fakes
static GContext s_ctx;
static FrameBuffer s_fb;
size_t framebuffer_get_size_bytes(FrameBuffer *f) {
return FRAMEBUFFER_SIZE_BYTES;
}
////////////////////////////////////////////////////... | (&word_iter) | );
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == 'o');
cl_assert(iter_next(&word_iter));
cl_assert(*word_iter_state.current.start == 'o');
cl_assert(*word_iter_state.current.end == '\0');
cl_assert(!iter_next(&word_iter));
}
void test_word_iterator__test_str... |
e 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 "stats.h"
#include "kernel/pbl_malloc.h"
#include <util/math.h>
#include <uti... | {
basic_out[out_index++] = consecutive_first;
} |
if (op & StatsBasicOp_Median) {
basic_out[out_index++] = prv_calculate_median(data, num_data, min, max, num_values, filter,
context);
}
}
typedef struct WeightedValue {
int32_t value;
int32_t weight_x100;
} WeightedValue;
static int prv_cmp_weighted_value... |
++i) {
action_bar->animation[i] = ActionBarLayerIconPressAnimationMoveLeft;
}
}
ActionBarLayer* action_bar_layer_create(void) {
ActionBarLayer* layer = applib_type_malloc(ActionBarLayer);
if (layer) {
action_bar_layer_init(layer);
}
return layer;
}
void action_bar_layer_deinit(ActionBarLayer *actio... | action_bar_layer_set_icon(action_bar, button_id, NULL) | |
///////////////////////////////////////////////////////////////////////////////////////////////
//! Smart Alarm first use dialog
typedef struct FirstUseDialog {
ExpandableDialog dialog;
AlarmsAppData *data;
} FirstUseDialog;
static void prv_alarms_app_opened_click_handler(ClickRecognizerRef recognizer, void *cont... | menu_layer_set_selected_index(&data->menu_layer, MenuIndex(0, 1),
PBL_IF_RECT_ELSE(MenuRowAlignNone, MenuRowAlignCenter), false) | |
eTask task,
const char *src_filename, uint16_t src_line_number) {
contents->message_type = 1; // Text
// Log the log level and the current task+privilege level
contents->log_level_char = pbl_log_get_level_char(log_level);
contents->task_char = pebble_task_get_char(task);
... | portEXIT_CRITICAL() | ;
return;
}
const size_t message_length = MIN(strlen(message), 128);
const uint32_t required_space = sizeof(uint32_t) + sizeof(BufferedLogInfo) + message_length;
if (circular_buffer_get_write_space_remaining(&s_isr_log_buffer) < required_space) {
// Not enough space for the full message, just write an... |
_enabled();
}
// ------------------------------------------------------------------------------------------------
typedef struct {
HealthMinuteData *minute_data;
uint32_t *num_records;
time_t *utc_start;
bool success;
bool completed;
} ActivityGetMinuteHistoryContext;
static void prv_get_minute_history_sys... | rtc_get_time() | ;
s_activity_state.sample_collection_num_samples = 0;
s_activity_state.sample_collection_enabled = true;
}
if (disable && s_activity_state.sample_collection_enabled) {
// Finish up the current record
s_activity_state.sample_collection_enabled = false;
prv_collect_raw_samples(NULL, ... |
de "stubs_passert.h"
#include "stubs_app_state.h"
#include "stubs_fonts.h"
#include "stubs_graphics_context.h"
#include "stubs_gbitmap.h"
#include "stubs_heap.h"
#include "stubs_text_resources.h"
#include "stubs_text_render.h"
#include "stubs_pbl_malloc.h"
#include "stubs_reboot_reason.h"
#include "stubs_resources.h"
... | char_iter_init(&char_iter, &char_iter_state, &text_box_params, utf8_bounds.start) | ;
cl_assert(utf8_iter_state->codepoint == 0x02);
cl_assert(iter_next(&char_iter));
cl_assert(utf8_iter_state->codepoint == 'A'); // 0x41
cl_assert(iter_next(&char_iter));
cl_assert(utf8_iter_state->codepoint == '\n');
cl_assert(iter_next(&char_iter));
cl_assert(utf8_iter_state->codepoint == 'B');
cl_as... |
-120},
{ 1312, 168, -80},
{ 1136, 192, -144},
{ 848, 216, -184},
{ 608, 184, -184},
// 67 seconds
{ 496, 168, -160},
{ 520, 152, -136},
{ 648, 208, -136},
{ 848, 256, -192},
{ 1104, 280, -216},
{ 1160, 304, -288},
{ 1104, 320, -248},
{ 1200, 320, -200},
{ 1168, 3... | { 1056, 88, 8},
{ 1040, 64, -8},
{ 1136, 72, -80},
{ 1232, 88, -8},
{ 1112, 112, -16},
{ 1184, 152, -88},
{ 1336, 224, -120},
{ 1200, 240, -176},
{ 848, 240, -200},
{ 560, 184, -184},
{ 456, 176, -168},
{ 464, 168, -120},
{ 600, 200, -144},
{ 856, 240, -200},
... | |
_button_layer, &window_layer->bounds);
layer_set_clips(&pin_window->action_button_layer, false);
pin_window->action_button_layer.update_proc = action_button_update_proc;
layer_add_child(&pin_window->layer, &pin_window->action_button_layer);
StatusBarLayer *status_layer = &pin_window->status_layer;
status_bar... | {
if (uuid_equal(id, &pin_window->item_detail_layer.item->header.id)) {
window_stack_remove((Window *)pin_window, true /* animated */);
}
} |
}
void timeline_pin_window_push_modal(TimelineItem *item) {
TimelinePinWindow *pin_window = kernel_zalloc_check(sizeof(TimelinePinWindow));
timeline_pin_window_init(pin_window, item, time_util_get_midnight_of(rtc_get_time()));
window_set_window_handlers((Window *)pin_window, &(WindowHandlers) {
.load = prv_... |
-------------------------------------------------------------
static void sleep_click_config_provider(void *context) {
const int k_long_press_timeout_ms = 1000;
window_single_click_subscribe(BUTTON_ID_SELECT, sleep_select_click_handler);
window_single_click_subscribe(BUTTON_ID_UP, sleep_up_click_handler);
windo... | {
HealthAPITestAppData *data = (HealthAPITestAppData *)context;
window_stack_pop(true);
window_stack_push(data->hr_window, true /* Animated */);
} |
// -------------------------------------------------------------------------------
static void steps_down_long_click_handler(ClickRecognizerRef recognizer, void *context) {
HealthAPITestAppData *data = (HealthAPITestAppData *)context;
window_stack_push(data->debug_window, true /* Animated */);
}
// -----------... |
0x4, 0x2, 0x48, 0xf4, \
0xbe, 0x14, 0x81, 0x17, 0xf1, 0xa, 0xa9, 0xc4))
// Fakes
////////////////////////////////////////////////////////////////
#include "fake_rtc.h"
#include "fake_settings_file.h"
void sys_get_app_uuid(Uuid *uuid) {
if (uuid) {
*uuid = APP_GLANCE_TEST_UUID;
}
}
typedef str... | (&bogus_session, slice) | & APP_GLANCE_RESULT_INVALID_SESSION);
// Check that adding a slice with APP_GLANCE_SLICE_DEFAULT_ICON as the icon succeeds
slice = (AppGlanceSlice) {
.expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION,
.layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
.layout.subtitle_template_string = "Test subtitle {time... |
ifo drain callback could have already been scheduled so don't check the
// interrupt status
if (s_fifo_in_use) {
prv_drain_fifo();
return;
}
// the int_status for drdy is not latched so we check the status register
// instead to confirm new data accel data is available
uint8_t status = bmi160_read... | psleep(50) | ;
struct {
char axis_name;
uint8_t register_address;
int pass_threshold;
int16_t negative_value;
int16_t positive_value;
} accel_test_axis[] = {
{
.axis_name = 'X',
.register_address = BMI160_REG_ACC_X_LSB,
.pass_threshold = 3277
}, {
.axis_name = 'Y',
.r... |
(initial_values) | , sync_tuple_changed_callback, sync_error_callback,
data);
}
static void push_window(AppData *data) {
data->window = window_create();
Window *window = data->window;
window_set_user_data(window, data);
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = ... | |
/*
* 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... | (&buffer, (uint8_t*) "abc", 3, false) | );
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 0);
cl_assert(!shared_circular_buffer_write(&buffer, (uint8_t*) "d", 1, false)); // too full
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 0);
// Try a wrapped read
cl_assert(shared_circular_buffer_... |
const PostMessageResetCompletePayload *rc =
(const PostMessageResetCompletePayload *) tuple->value[0].data;
// Check overlap in supported versions
if (!prv_is_version_supported(rc)) {
prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorUnsupportedVersion);
return;... | jerry_call_function(func, JSON, args, args_count) | ;
}
T_STATIC jerry_value_t prv_json_stringify(jerry_value_t object) {
return prv_call_json_function(GLOBAL_JSON_STRINGIFY, &object, 1);
}
T_STATIC jerry_value_t prv_json_parse(const char *object) {
JS_VAR string_obj = jerry_create_string_utf8((const jerry_char_t *)object);
return prv_call_json_function(GLOBAL_J... |
ion 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS... | (gpio_pin) | ;
uint16_t pin_cfg_mask = 0;
char buf[80];
for (int pin = 0; pin < 16; pin++) {
if ((mode & GPIO_MODER_MODER0) != GPIO_Mode_AN) {
pin_cfg_mask |= (0x1 << pin);
}
mode >>= 2;
}
dbgserial_putstr_fmt(buf, sizeof(buf), "Non Analog P%s cfg: 0x%"PRIx16,
name, (int)pin_cfg... |
/*
* 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_address + sizeof(FirmwareDescription), &firmware_description) | ) {
dbgserial_putstr("Invalid firmware CRC in SPI flash!");
return UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED;
}
erase_old_firmware(firmware_description.firmware_length);
write_new_firmware(
flash_address + sizeof(FirmwareDescription),
firmware_description.firmware_length);
if (!check_firmware... |
to_find > 0) && (free_page != INVALID_PAGE)) {
mutex_lock_recursive(s_pfs_mutex);
find_free_page(&free_page, false, false);
mutex_unlock_recursive(s_pfs_mutex);
// TODO: might be nice to only sleep here if we had to perform GC as part
// of finding a free page
if ((pages_to_find % 4) == 0) {
... | SET_PAGE_FLAGS(pg_hdr.page_flags,
PAGE_FLAG_CONT_PAGE | PAGE_FLAG_ERASED_PAGE) | ;
} else {
write_pg_header(&pg_hdr, curr_page);
break; // we are done
}
}
// we have succesfully allocated space for the file, so add file specific info
f->start_page = f->curr_page = start_page;
FileHeader file_hdr;
memset(&file_hdr, 0xff, sizeof(file_hdr));
file_hdr.file_namelen = st... |
= stack->transition_context.window_to_displacement;
gpoint_add_eq(&draw_state->drawing_box.origin, displacement);
gpoint_add_eq(&draw_state->clip_box.origin, displacement);
}
// clip_box must respect screen boundaries
grect_clip(&draw_state->clip_box, &saved_state->clip_box);
}
static void prv_restore_d... | {
if (window == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "Tried to init a NULL window");
return;
}
*window = (Window){};
#ifndef RELEASE
window->debug_name = debug_name;
#else
(void)debug_name;
#endif
bool fullscreen = !process_manager_compiled_with_legacy2_sdk();
const GRect frame = window_calc_frame(fu... | |
// mobile apps and it uses it to validate that the firmware image it has
// pulled from cohorts is correct. Thus, for now, we still use the legacy
// checksum in put_bytes() after pieces are transferred, but when we store
// the CRC for the bootloader to check, we use the real CRC32
// implementati... | PBL_LOG(LOG_LEVEL_WARNING, "Can't update Object Type %u from PRF!", type) | ;
return false;
}
#else
return true;
#endif
}
static bool prv_is_init_object_type_invalid(PutBytesObjectType type) {
if (type == 0 || type >= NumObjects) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid object type, got 0x%x", type);
return true;
}
if (!prv_is_object_allowed(type)) {
return true;
}
... |
handle(unsigned int stack_id,
const GAP_LE_Current_Connection_Parameters_t *params) {
}
void gap_le_connect_handle_bonding_change(BTBondingID bonding_id, BtPersistBondingOp op) {
}
void gap_le_connection_handle_bonding_change(BTBondingID bonding, BtPersistBondingOp op) {
}... | bt_persistent_storage_set_ble_pinned_address(NULL) | , true);
cl_assert_equal_b(bt_persistent_storage_get_ble_pinned_address(NULL), false);
}
void test_bluetooth_persistent_storage__ble_store_and_get(void) {
bool ret;
// Output variables
SMIdentityResolvingKey irk_out;
BTDeviceInternal device_out;
// Store a new pairing
SMPairingInfo pairing_1;
memset(... |
tchdog, this isn't iOS 8: %d",
s_call_source);
}
}
static void prv_cancel_call_watchdog(void) {
new_timer_stop(s_call_watchdog);
pp_get_phone_state_set_enabled(false);
}
static bool prv_can_answer(void) {
// We can't answer calls with Android
return prv_call_is_ancs();
}
static bool prv_should_... | (ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient_System) | ;
}
if (s_call_in_progress) {
prv_call_end_common();
phone_ui_handle_call_end(false /*call accepted*/, disconnected);
} else if (!disconnected) {
PBL_LOG(LOG_LEVEL_INFO, "Ignoring end call. A call is not in progress");
}
}
static void prv_handle_caller_id(PebblePhoneEvent *event) {
if (s_call_in... |
ent = (GAP_LE_Event_Data_t) {
.Event_Data_Type = etLE_Connection_Complete,
.Event_Data_Size = sizeof(GAP_LE_Connection_Complete_Event_Data_t),
.Event_Data.GAP_LE_Connection_Complete_Event_Data = &event_data,
};
if (is_master) {
prv_fake_gap_le_create_connection_event_put(&event);
} else {
prv... | COMPARE_BD_ADDR(s_encrypted_device, BD_ADDR) | |
xtended layout = (TextLayoutExtended) { };
GContext gcontext = (GContext) { };
layout.hash = 0;
layout.box = (GRect) { (GPoint) { 0, 0 }, (GSize) { 7 * HORIZ_ADVANCE_PX + 1, FONT_HEIGHT - 1} };
layout.font = (GFont) { 0 };
layout.overflow_mode = GTextOverflowModeWordWrap;
layout.alignment = GTextAlignmentL... | cl_assert_equal_p(data2->perimeter.impl, NULL) | ;
cl_assert_equal_i(data2->paging.page_on_screen.size_h, 0);
}
#include "applib/legacy2/ui/text_layer_legacy2.h"
void test_text_layout__delta(void) {
GContext gcontext = (GContext) { };
GFont font = (GFont) { 0 };
GRect box = (GRect) { (GPoint) { 0, 0 }, (GSize) { 4 * HORIZ_ADVANCE_PX + 1, 2 * (FONT_HEIGHT + F... |
ext-terminate-id so that the next ack sent not in response to
// a Terminate-Request does not look like a retransmission.
this->state->next_terminate_id = identifier + 1;
}
struct LCPPacket *packet = pulse_link_send_begin(this->protocol_number);
*packet = (struct LCPPacket) {
.code = ControlCode_Termi... | (LOG_LEVEL_WARNING,
"Configure-Ack received with options list which differs from "
"the sent Configure-Request. Discarding.") | ;
return;
}
switch (this->state->link_state) {
case LinkState_Closed:
case LinkState_Stopped:
prv_send_terminate_ack(this, -1);
break;
case LinkState_Closing:
case LinkState_Stopping:
// Do nothing
break;
case LinkState_RequestSent:
this->state->restart_count =... |
/*
* 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... | memset(dest, 0, 5) | ;
size_t copied = utf8_copy_character(dest, (utf8_t *)"hello", 5);
cl_assert_equal_i(copied, 1);
cl_assert_equal_s((char *)dest, "h");
}
void test_utf8__copy_multibyte_char(void) {
utf8_t dest[5];
memset(dest, 0, 5);
size_t copied = utf8_copy_character(dest, (utf8_t *)NIHAO, 5);
cl_assert_equal_i(copi... |
rv_send_subscription_event(BLECharacteristic characteristic_ref,
PebbleTaskBitset task_mask, BLESubscription type,
BLEGATTError gatt_error) {
PebbleEvent e = {
.type = PEBBLE_BLE_GATT_CLIENT_EVENT,
.task_mask = task_mask,
.blu... | (LOG_LEVEL_ERROR, "No subscription found for ATT handle %u", att_handle) | ;
}
goto unlock;
}
// Mask to mask out all tasks
const PebbleTaskBitset task_mask_none = ~0;
PebbleTaskBitset task_mask = task_mask_none;
for (GAPLEClient c = 0; c < GAPLEClientNum; ++c) {
if (UNLIKELY(subscription->subscriptions[c] == BLESubscriptionNone)) {
// Not subscribed, continue
... |
ction_bar_state(MusicAppData *data, enum ActionBarState state);
static void prv_trigger_cassette_icon_switch(GBitmap *bitmap, bool animated);
static void prv_update_cassette_icon(MusicAppData *data, bool animated);
static void prv_do_haptic_feedback_vibe(MusicAppData *data) {
#if CAPABILITY_HAS_VIBE_SCORES
vibe_sco... | {
MusicAppData *data = context;
data->pause_track_pos_updates = false;
prv_update_track_progress(data);
music_get_now_playing(data->title_buffer, data->artist_buffer, NULL);
// Restore the layers to their original bounds for the next part of the animation.
data->title_text_layer.layer.bounds.origin.y = -TIT... |
static inline bool prv_should_animate_casssette(void) {
return music_get_playback_state() != MusicPlayStatePaused;
}
static Animation *prv_create_cassette_animation(MusicAppData *data) {
const MusicAppSizeConfig *config = prv_config();
const GRect cassette_rect = prv_cassette_rect();
GPoint left_target = GPo... |
;
if (!notification_storage_get(id, ¬ification)) {
return;
}
prv_add_notification(s_data, id);
// NOTE: To avoid having two flash reads, we only read and validate the notification once.
// We do it here, instead of in the function call below. If the above
// notification_storage validat... | window_set_user_data(window, data) | ;
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
.appear = prv_window_appear,
.disappear = prv_window_disappear,
});
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void prv_handle_init(void) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | backlight_set_timeout_ms(set_value + 1) | ;
// Insert and check the length
cl_assert_equal_i(prefs_db_insert((uint8_t *)key, key_len, (uint8_t *)&set_value,
sizeof(set_value)), 0);
cl_assert_equal_i(prefs_db_get_len((uint8_t *)key, key_len), sizeof(set_value));
// Read it back
uint32_t get_value;
cl_assert_eq... |
/*
* 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... | (PebbleTask_BTCallback) | ;
}
static void prv_dispatcher_main(void *unused) {
HcProtocolMessageHandlerEvent e;
do {
portBASE_TYPE result = xQueueReceive(s_dispatcher.job_queue, &e, portMAX_DELAY);
PBL_ASSERTN(result);
e.cb(e.msg);
kernel_free(e.msg);
} while (e.cb != prv_terminate_dispatcher_cb);
vTaskDelete(NULL);
}
... |
08, 40, 48},
{ 936, 8, 48},
{ 1072, 16, -48},
{ 1080, 48, -152},
{ 1480, -128, -56},
{ 1424, 16, 72},
{ 1072, 264, -56},
{ 1096, 280, -176},
{ 888, 376, 16},
{ 664, 168, 112},
{ 760, 240, 112},
{ 808, 264, 160},
{ 784, 328, 112},
{ 760, 368, 56},
{ 896, 528, -104}... | { 824, 336, -88},
{ 1024, 520, -224},
{ 1136, 256, -8},
{ 1248, 64, 16},
{ 1840, 408, 64},
{ 1280, 408, 8},
{ 728, 312, 8},
{ 944, 256, 64},
{ 1024, 152, 168},
{ 880, 112, 136},
{ 760, 72, 96},
{ 752, 64, 72},
{ 768, 64, 40},
{ 680, -40, 96},
{ 984, -56, 24},
... |
{ 1512, 32, 112},
{ 1144, 248, -40},
{ 1120, 400, -136},
{ 888, 336, 80},
{ 680, 168, 96},
{ 768, 184, 112},
{ 840, 224, 96},
{ 776, 304, 56},
{ 680, 360, -16},
{ 784, 360, -56},
{ 1040, 376, -96},
{ 1264, 256, -8},
{ 1328, 248, 16},
{ 1856, 408, -32},
{ 1088... |
nclude "drivers/task_watchdog.h"
#include "drivers/temperature.h"
#include "drivers/touch/touch_sensor.h"
#include "drivers/vibe.h"
#include "drivers/voltage_monitor.h"
#include "drivers/watchdog.h"
#include "resource/resource.h"
#include "resource/system_resource.h"
#include "kernel/util/stop.h"
#include "kernel/uti... | kernel_heap_init() | ;
mbuf_init();
delay_init();
periph_config_init();
dbgserial_init();
pulse_early_init();
print_splash_screen();
rtc_init();
#if BOOTLOADER_TEST_STAGE2
#define BLTEST_LOG(x...) pbl_log(LOG_LEVEL_ALWAYS, __FILE__, __LINE__, x)
BLTEST_LOG("BOOTLOADER TEST STAGE 2");
boot_bit_set(BOOT_BIT_FW_STABLE);
... |
ge until ExtraLarge is designed
[PreferredContentSizeExtraLarge] = menu_cell_basic_cell_height(),
})[runtime_platform_content_size];
}
static void prv_draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index,
void *data) {
NotificationsData *notification... | {
return;
} |
prv_add_notification(s_data, id);
// NOTE: To avoid having two flash reads, we only read and validate the notification once.
// We do it here, instead of in the function call below. If the above
// notification_storage validation above is removed, then we should at least validate
// it in... |
/*
* 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... | window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler) select_click_handler) | ;
window_long_click_subscribe(BUTTON_ID_SELECT, 0, (ClickHandler) select_click_handler, NULL);
(void)data;
}
static void prv_window_load(Window *window) {
struct AppState* data = window_get_user_data(window);
ScrollLayer* scroll_layer = &data->scroll_layer;
scroll_layer_init(scroll_layer, &window->layer.bou... |
.icon_and_subtitle = {
.icon_resource_id = TIMELINE_RESOURCE_SCHEDULED_FLIGHT,
.template_string = "Glances baby!",
},
},
},
};
cl_assert_equal_i(app_glance_db_insert_glance(
&s_fake_app_nodes[LauncherMenuLayerTestApp_NoIcon].node.uuid, &glance), S_SUCCE... | (&s_ctx.dest_bitmap, TEST_PBI_FILE) | |
ance(&s_font_cache, 'a', &s_font_info);
cl_assert(horiz_advance != 0);
cl_assert_equal_i(horiz_advance,
text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info));
horiz_advance = text_resources_get_glyph_horiz_advance(&s_font_cache, 'b', &s_font_info);
cl_assert(horiz_advance != 0);
cl_... | (glyph->header.height_px, 15) | |
/*
* 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 (caption && caption->length > 0) {
pstring_pstring16_to_string(&caption->pstr, caption_buf);
// Inserting a caption to an image can easily cause accidental leading whitespace
stripped_caption = string_strip_leading_whitespace(caption_buf);
} |
const size_t max_msg_length =
sender->length + (stripped_caption ? strlen(stripped_caption) : 0) +
MULTIMEDIA_INDICATOR_LENGTH + strlen(s_utf8_ellipsis) + 1;
// Sender and action message
int pos = snprintf((char *)buffer, max_msg_length, "%.*s %s",
sender->length, (char *)sende... |
/*
* 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... | emx_app_deinit() | ;
return 0;
}
|
->accel_data.num_samples);
HRM_LOG("LED %"PRIu16"uA, TIA: %"PRIu16, data->led_current_ua, data->tia);
time_t utc_now = rtc_get_time();
RtcTicks cur_ticks = rtc_get_ticks();
HRMFeature kernel_bg_features_sent = 0;
HRMSubscriberState *state = (HRMSubscriberState *)s_manager_state.subscribers;
while (state) ... | {
return HRM_INVALID_SESSION_REF;
} |
const PebbleTask current_task = pebble_task_get_current();
bool is_app_subscription = false;
if (current_task == PebbleTask_KernelBackground) {
// KernelBG must provide a callback
PBL_ASSERTN(callback != NULL);
} else if (current_task == PebbleTask_KernelMain) {
// KernelMain clients can either se... |
d_attributes = {
.num_attributes = 5,
.attributes = (Attribute[]) {
{ .id = AttributeIdTitle, .cstring = "Title" },
{ .id = AttributeIdBody, .cstring = "Body" },
{ .id = AttributeIdMuteDayOfWeek, .uint8 = MuteBitfield_Always },
{ .id = AttributeIdAppName, .cstring = "Awesome" },
{ ... | cl_assert(ancs_filtering_is_muted(&mute_always)) | ;
cl_assert(ancs_filtering_is_muted(&mute_weekends));
cl_assert(!ancs_filtering_is_muted(&mute_weekdays));
s_now += SECONDS_PER_DAY; // Sunday Jan 3, 2016
cl_assert(ancs_filtering_is_muted(&mute_always));
cl_assert(ancs_filtering_is_muted(&mute_weekends));
cl_assert(!ancs_filtering_is_muted(&mute_weekdays)... |
cl_assert_equal_i(u32, (uint32_t)c->u32) | ;
cl_assert_equal_i(u64, (uint64_t)c->u64);
cl_assert_equal_i(s8, (int8_t)c->s8);
cl_assert_equal_i(s16, (int16_t)c->s16);
cl_assert_equal_i(s32, (int32_t)c->s32);
cl_assert_equal_i(s64, (int64_t)c->s64);
cl_assert_equal_d(d, (double)c->d);
}
JERRY_ARGS_RELEASE();
}
}
void... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (SECONDS_PER_DAY) | ;
// We start time out at 5pm on Jan 1, 2015 for all of these tests
struct tm time_tm = {
// Thursday, Jan 1, 2015, 5pm
.tm_hour = 17,
.tm_mday = 1,
.tm_year = 115
};
const time_t utc_sec = mktime(&time_tm);
fake_rtc_init(0 /* initial_ticks */, utc_sec);
// Setup graphics context
frameb... |
time(event_time + (1 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("1 MIN AGO", time_buf);
// June 9th 2015, 16:02:00 (T+00:02:00)
rtc_set_time(event_time + (2 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time... | (event_time - (2 * SECONDS_PER_HOUR)) | ;
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 2 H", time_buf);
// June 9th 2015, 15:59:00 (T-00:01:00)
rtc_set_time(event_time - (1 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATI... |
alytics_event(data, (result == DictationSessionStatusSuccess));
}
sys_light_reset_to_timed_mode();
prv_teardown(data);
}
static void prv_handle_error_retries(VoiceUiData *data) {
if (data->error_count < MAX_ERROR_COUNT) {
VOICE_LOG("Restarting dictation after error");
prv_start_dictation(data);
} e... | prv_start_dictation(data) | ;
} else {
prv_voice_window_push(data);
}
} else {
VOICE_LOG("Bluetooth not restored! Exiting...");
prv_exit_and_send_result_event(data, DictationSessionStatusFailureConnectivityError);
}
}
static void prv_push_bt_dialog(VoiceUiData *data) {
BtConnDialog *bt_dialog = &data->bt_dialog;
bt_... |
_equal_i(out_length, 4);
cl_assert(memcmp(out_buffer, "1234", 4) == 0);
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(shared_circular_buffer_consume(&buffer, &client, 4));
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 6);
// Now the... | cl_assert(shared_circular_buffer_consume(&buffer, &client1, 2)) | ;
cl_assert_equal_i(shared_circular_buffer_get_write_space_remaining(&buffer), 0);
// Should fail, not enough room because client 2 is full
cl_assert(!shared_circular_buffer_write(&buffer, (uint8_t*) "gh", 2, false));
// This should pass and reset client 2's read index
cl_assert(shared_circular_buffer_wri... |
;
if (prv_is_init_object_type_invalid(request->type)) {
goto exit;
}
uint32_t index;
if (!prv_parse_init_index(request, &index)) {
goto exit;
}
uint32_t append_offset = 0;
if (s_pb_state.receiver.length > offsetof(InitRequest, extra_info)) {
// We compute the offset this way because filenam... | (LOG_LEVEL_DEBUG, "PutBytes pushed %d bytes/sec", bytes_per_sec) | ;
}
bluetooth_analytics_handle_put_bytes_stats(
commit_succeeded, s_pb_state.type,
s_pb_state.total_size, elapsed_time_ms, &s_pb_state.conn_event_stats);
if (commit_succeeded) {
s_pb_state.is_success = true;
PBL_LOG(LOG_LEVEL_DEBUG, "PutBytes commit CB. CRC matches! Calculated CRC is 0x%"PRI... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (!app_state_get_unobstructed_area_state()->handlers.change) | ;
cl_assert(!app_state_get_unobstructed_area_state()->handlers.did_change);
// Unsubscribing again should not crash
app_unobstructed_area_service_unsubscribe();
cl_assert(!app_state_get_unobstructed_area_state()->handlers.will_change);
cl_assert(!app_state_get_unobstructed_area_state()->handlers.change);
c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.