prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (STUCK_BUTTON_REGISTER, button_counter_register) | ;
return result;
}
bool boot_test_is_flash_broken(void) {
return !flash_sanity_check();
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | new_timer_create() | |
int32_t angle_start, int32_t angle_end) {}
void layer_mark_dirty(Layer *layer) {}
jerry_value_t prv_create_canvas_context_2d_for_layer(Layer *layer);
static void prv_create_global_ctx(void) {
// make this easily testable by putting it int JS context as global
Layer l = {.bounds = GRect(0, 0, 144, 168)}... | (s_graphics_api) | ;
prv_create_global_ctx();
EXECUTE_SCRIPT(
"ctx.moveTo(1, 2);\n"
"ctx.lineTo(3, 4);\n"
"ctx.fill();\n"
);
// only 2 points
cl_assert_equal_i(0, s_gpath_draw_filled.call_count);
EXECUTE_SCRIPT(
"ctx.lineTo(5, 6);\n"
"ctx.fill();\n"
);
cl_assert_equal_i(1, s_gpath_draw_filled.call_c... |
ormal/filesystem/pfs.h"
#include "services/normal/legacy/persist_map.h"
#include "services/normal/settings/settings_file.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/list.h"
#include "util/units.h"
#define PERSIST_STORAGE_MAX_SPACE KiBYTES(6)
typedef struct PersistStore {
ListNode list... | settings_file_open(&store->file, filename, PERSIST_STORAGE_MAX_SPACE) | ));
store->file_open = true;
}
return &store->file;
}
void persist_service_unlock_store(SettingsFile *store) {
prv_unlock();
}
// Create a store for a client of the given UUID it doesn't already exist. If it
// exists already (another client with the same UUID is running), then just
// increment its usage c... |
changes to the ABI:
const uint8_t raw_bytes_v1[] = {
0x04, 0x00, 0x00, 0x00, ':', '1', '2', '3',
};
cl_assert_equal_i(sizeof(raw_bytes_v1), expected_size);
cl_assert_equal_m(raw_bytes_v1, buffer, expected_size);
prv_rcv_app_message_ack(APP_MSG_OK);
json_bytes_remaining -= json_bytes_size... | (true, jerry_value_is_object(event_valid)) | ;
// Make sure that there is a "data" property
JS_VAR data_prop = jerry_get_object_field(event_valid, "data");
cl_assert_equal_b(true, jerry_value_is_object(data_prop));
// Make sure the re-serialized object matches:
ASSERT_JS_GLOBAL_EQUALS_S("json_str", "{\"x\":123}");
EXECUTE_SCRIPT("json_s... |
See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "simple_menu_layer.h"
#include "applib/legacy2/ui/menu_layer_legacy2.h"
#include "applib/applib_malloc.auto.h"
#include "process_management/process_manager.h"
static int16_t get_header_height(struct Men... | MenuIndex(simple_menu->menu.selection.index.section, index) | |
t_old_value = true;
break;
case RecordResultNew:
have_hit_new_value = true;
break;
case RecordResultEnd:
have_hit_end = true;
break;
}
}
cl_assert(have_hit_old_value);
cl_assert(have_hit_new_value);
cl_assert(have_hit_end);
}
void test_settings_file__zero... | (STOPPING_NUM, cur_val) | ;
}
void test_settings_file__in_place(void) {
printf("Testing that we can update a setting file in place\n");
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_in_place", 4096));
uint8_t key[4];
int key_len = sizeof(key) - 1;
memcpy(key, "key", sizeof(key));
uint8_t val[4] = {0x11, 0... |
ctivity_state.bg_wait_semaphore);
}
bool activity_test_minute_file_info(bool compact_first, uint32_t *num_records, uint32_t *data_bytes,
uint32_t *minutes) {
// Fill in the context
ActivitySleepFileInfoContext context = (ActivitySleepFileInfoContext) {
.compact_first = compa... | health_db_set_typical_values(ActivityMetricStepCount,
day_of_week,
step_avg_array,
ACTIVITY_STEP_AVERAGES_PER_KEY) | ;
}
mutex_unlock_recursive(s_activity_state.mutex);
}
// ------------------------------------------------------------------------------------------------
void activity_test_set_steps_history() {
ActivitySettingsValueHistory step_history = {
.utc_sec = rtc_get_time(),
.values = {
0, // This ends up... |
{
s_graphics_draw_line.call_count++;
s_graphics_draw_line.last_call =
(MockCallRecording){.ctx = ctx, .p0 = p0, .p1 = p1};
}
static MockCallRecordings s_graphics_fill_rect;
void graphics_fill_rect(GContext *ctx, const GRect *rect) {
s_graphics_fill_rect.call_count++;
s_graphics_fill_rect.last_call = (MockC... | EXECUTE_SCRIPT(script) | ;
ASSERT_JS_GLOBAL_EQUALS_I("c", 3.0);
}
void test_js__eval_error(void) {
prv_deinit(); // engine will be re-initialized in rocky_event_loop~
char script[] = "function f({;";
s_log_internal__expected = (const char *[]){
"Not a snapshot, interpreting buffer as JS source code",
"Exception while Evaluati... |
oke_points = NULL;
}
if (s_fill_points) {
free(s_fill_points);
s_fill_points = NULL;
}
if (s_precise_lines) {
free(s_precise_lines);
s_precise_lines = NULL;
}
}
// tests
void test_gdraw_command__draw_command_stroke(void) {
GDrawCommand *command = malloc(sizeof(GDrawCommand) + (sizeof(GPoint... | gdraw_command_set_point(command, 0, points2[0]) | ;
gdraw_command_set_point(command, 1, points2[1]);
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorPurpleARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorGreenARGB8);
cl_assert_equal_i(s_stroke_width, 2);
cl_assert_equal_i(s_path_num_points, 2);
cl_assert_equal_b(s_path_o... |
/*
* 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... | crc_update(crc, (uint8_t*)&last_word, 4) | ;
}
return crc & 0xffffffff;
}
/*
* Data Logging Test App
*/
struct DataLoggingInfo {
TextLayer text_layer;
char text[32];
int counter;
uint32_t crc;
DataLoggingSessionRef logging_session;
uint8_t item_size;
};
static struct {
Window window;
struct DataLoggingInfo info[3];
TextLayer log_lay... |
// https://pebbletechnology.atlassian.net/browse/PBL-42467
// TODO: check reason and act upon it
const OutboxMsgType sent_msg_type = s_state.out.msg_type;
s_state.out.msg_type = OutboxMsgTypeNone;
const bool is_sent_successfully = (reason == APP_MSG_OK);
// Process the (N)ACK:
switch (sent_msg_type) {
... | rocky_global_call_event_handlers(event) | |
if (slave->bus->state->user_count == 0) {
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->bus-... | |
gbitmap_get_data_row.c
s_fake_data_row_handling = true;
}
// Teardown
void test_graphics_draw_core__cleanup(void) {
free(fb);
}
// Helpers
////////////////////////////////////
// HORIZONTAL LINE HELPERS
typedef void (*HLinePatternDrawFunction)(GContext *ctx, int16_t y, int16_t x1, int16_t x2,
... | (right_rects_x, right_rects_y_offset) | ,
.size = right_rects_size
};
prv_draw_vlines_in_rect(ctx, draw_func, &top_left_rect, top_right_rect_color);
GColor bottom_right_rect_color = GColorYellow;
bottom_right_rect_color.a = 2;
const GRect top_right_rect = (GRect) {
.origin = GPoint(right_rects_x, (bitmap_bounds_size->h / 2) + right_rects_y_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (length - 1) | ;
}
static void prv_wait_for_qspi_transfer_complete(QSPIFlag actions) {
while (QSPI_GetFlagStatus(QSPI_FLAG_TC) == RESET) { }
if (actions == QSPIFlag_ClearTC) {
QSPI_ClearFlag(QSPI_FLAG_TC);
}
}
static void prv_wait_for_qspi_not_busy(void) {
while (QSPI_GetFlagStatus(QSPI_FLAG_BUSY) != RESET) { }
}
stat... |
/*
* 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 (connection == NULL) {
PBL_LOG(LOG_LEVEL_WARNING, "Discovery service_changed_handle but no device connected?");
return;
} |
bt_driver_cb_gatt_client_discovery_handle_service_changed(connection, payload->handle);
}
void hc_endpoint_discovery_handler(const HcProtocolMessage *msg) {
bt_lock();
{
switch (msg->command_id) {
case HcMessageID_Discovery_Service_Found:
prv_handle_new_service_found((HcProtocolDiscoveryServi... |
lor_get_grayscale(GColorBlue).argb);
cl_assert_equal_i(GColorLightGrayARGB8, gcolor_get_grayscale(GColorTiffanyBlue).argb);
cl_assert_equal_i(GColorDarkGrayARGB8, gcolor_get_grayscale(GColorOrange).argb);
}
void test_graphics_colors__bw_colors(void) {
cl_assert_equal_i(GColorClearARGB8, gcolor_get_bw(GColorClear... | (GColorRed,
NULL) | );
// A src_color of yellow should have a luminance that picks white from lookup_table
// initialized with a tint_color of black
prv_test_tint_using_luminance_and_perform_lookup_using_color_luminance(GColorYellow,
GColorBlack,
... |
ert_userspace_buffer(out_cb, sizeof(*out_cb));
syscall_assert_userspace_buffer(out_cb_data, sizeof(*out_cb_data));
}
mutex_lock(s_mutex);
EventedTimer *timer = prv_find_timer(timer_id);
// It's possible that the client made a call to delete the timer just
// after the timer executed (from the timer ta... | (timer_id, timeout_ms) | ) {
return timer_id;
}
return evented_timer_register(timeout_ms, false, callback, data);
}
EventedTimerID evented_timer_register(uint32_t timeout_ms,
bool repeating,
EventedTimerCallback callback,
... |
(LOG_LEVEL_DEBUG, "Invalid baud rate (%"PRIu8")", requested_baud) | ;
smartstrap_link_control_disconnect();
success = false;
} else {
accessory_set_baudrate(BAUDS[requested_baud]);
prv_do_send(LinkControlTypeStatus);
}
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Invalid response type (%d)", header->type);
smartstrap_link_control_disconnect();
succes... | |
th 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 CONDITIONS OF ANY KIND, either express o... | for (int i = 0; i < NUM_RX_BUFFERS; ++i) {
prv_reset_buffer(&s_buffers[i]);
} |
accessory_manager_set_state(AccessoryInputStateImaging);
accessory_use_dma(true);
s_timeout_timer = new_timer_create();
new_timer_start(s_timeout_timer, TIMEOUT_MS, prv_timeout_timer_cb, NULL, 0 /* flags */);
PBL_LOG(LOG_LEVEL_DEBUG, "Starting accessory imaging");
}
static void prv_stop(void *context) {
i... |
_history_values.stage = 0;
s_sys_activity_get_minute_history_values.out[0].asserts = false;
HealthMinuteData data[5] = {};
// pass time that's not exactly on a boundary
time_t time_start;
time_t time_end;
////////////
// start time on boundary
const time_t time_on_boundary = (rtc_get_time() / 60 * 60... | if (i == 0) {
continue;
} | |
nt_hour = 11;
s_current_minute = 30;
s_current_day = s_saturday;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKENDS });
prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_WEEKENDS, s_weekend_schedule);
// Only 1 pin should be added (for Sunday)
cl_assert_equal_i(s_num_... | (s_num_alarms_fired, 1) | ;
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 8);
cl_assert_equal_i(s_num_timeline_removes, 4);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm goes off. First one should be up again
s_current_hour = 11;
s_current_m... |
he LogState buffer obtained by prv_get_log_state()
static void prv_release_log_state(LogState *state) {
PebbleTask task = pebble_task_get_current();
if (task == PebbleTask_App || task == PebbleTask_Worker) {
state->in_progress = false;
} else {
kernel_applib_release_log_state(state);
}
}
static void p... | memset(expanded_fmt_buffer, 0, sizeof(expanded_fmt_buffer)) | ;
for (unsigned index = 0; index < num_fmt_conversions; ++index) {
if (((str_index_1 != 0) && ((index + 1) == str_index_1)) ||
((str_index_2 != 0) && ((index + 1) == str_index_2))) {
strcat(expanded_fmt_buffer, " `%s`");
} else {
strcat(expanded_fmt_buffer, " %x"); ... |
ASE_TYPE uxItemSize, unsigned char ucQueueType ) {
static intptr_t counter = 0;
// Return unique IDs for all the created queues
return (void*) ++counter;
}
signed portBASE_TYPE xQueueGenericSend( QueueHandle_t xQueue,
const void * const pvItemToQueue, TickType_t xTicksToWait, portBASE_TYPE xCopyPosition ) {
... | (app_manager_get_current_app_md() == (PebbleProcessMd*) &s_launch_app) | ;
}
void test_app_manager__start_third_party_and_force_close_back_to_first(void) {
test_app_manager__start_third_party();
s_last_to_app_event = (PebbleEvent) {0};
// Make the app get stuck in a syscall. This will indicate that the app is running
// privileged.
stub_control_reg(0x0);
// Try to close the... |
ncoded_mset_payload(s_saved_encoded_msg);
cl_assert_equal_m(msg->msrmt.values, &values[num_samples_encoded * num_values_per_sample],
msg->msrmt.num_values * sizeof(uint32_t));
}
}
// Delete the session now
protobuf_log_session_delete(session_ref);
}
// -------------------------... | (session_ref != NULL) | ;
bool success;
for (int i = 0; i < ARRAY_LENGTH(events); i++) {
success = protobuf_log_session_add_event(session_ref, &events[i]);
cl_assert(success);
}
prv_test_decode_payload(&input, false /*use_data_logging*/, session_ref);
}
|
.active_calories = session->active_calories / len,
.resting_calories = session->resting_calories / len,
.distance_mm = session->distance_mm / len,
};
}
}
// -----------------------------------------------------------------------------------
// Feed activity minute data into the kalg_activitie... | rtc_get_time() | ;
int len = 5;
KAlgTestActivitySession exp_session = {
.activity = KAlgActivityType_Walk,
.start_utc = now + 10 * SECONDS_PER_MINUTE,
.steps = len * 80, // 80 steps/min
.len_minutes = len,
.resting_calories = len * 100,
.active_calories = len * 200,
.distance_mm = len ... |
sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Fri, 12:00 PM", time_buf);
// June 11th 2015, 23:59:29 (T-12:00:31)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) - 31);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Fri, ... | rtc_set_time(event_time) | ;
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("NOW", time_buf);
// June 9th 2015, 12:00:59 (T+00:00:59)
rtc_set_time(event_time + (1 * SECONDS_PER_MINUTE) - 1);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELAT... |
= (RegularTimerInfo) {
.cb = prv_workout_timer_cb,
};
// Initialize all of our initial values for keeping track of metrics
activity_get_metric(ActivityMetricStepCount, 1,
&s_workout_data.current_workout->last_event_step_count);
s_workout_data.current_workout->last_movemen... | prv_unlock() | ;
return rv;
}
// ---------------------------------------------------------------------------------------
bool workout_service_is_workout_ongoing(void) {
prv_lock();
bool rv = (s_workout_data.current_workout != NULL);
prv_unlock();
return rv;
}
// ------------------------------------------------------------... |
;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 2);
cl_assert_equal_i(s_num_alarm_events_put, 2);
cl_assert_equal_i(s_num_timeline_adds, 9);
cl_assert_equal_i(s_num_timeline_removes, 5);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// First alarm goes of... | cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time()) | ;
}
void test_alarm__just_once_alarm_timeout_ahead(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_JUST_ONCE });
// It's currently Thursday @ 00:00
bool just_once_schedule_thursday[7] = {false, false, false, false, true, false, false};
prv_assert_alarm_config... |
r_tag(AppInboxServiceTagUnitTest));
}
void test_app_inbox__app_inbox_service_begin_already_being_written(void) {
prv_create_test_inbox();
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer));
cl_assert_equal_b(true, ... | (AppInboxServiceTagUnitTest) | );
prv_process_callback_events();
assert_message(0, s_test_data, BUFFER_SIZE);
assert_num_message_callbacks(1);
assert_num_dropped_callbacks(0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// app_inbox_service_cancel
void test_app_inbox__app_inbox_se... |
{ -1112, 176, 136},
{ -1112, 144, 160},
{ -1104, 104, 184},
{ -1016, 112, 176},
{ -1024, 96, 216},
{ -1216, 8, 280},
{ -1136, -112, 240},
{ -1320, 0, 56},
{ -1016, 128, -216},
{ -1104, 176, -288},
{ -1216, 136, -184},
{ -1168, -104, -152},
{ -1056, -136, -120},
{ -... | { -984, 312, -88},
{ -976, 488, -24},
{ -1128, 216, 112},
{ -1184, 408, -128},
{ -992, 464, -176},
{ -1112, 456, -296},
{ -1280, 480, -112},
{ -1096, 408, -56},
{ -888, 392, 16},
{ -880, 384, 48},
{ -944, 432, 96},
{ -1000, 424, 72},
{ -864, 456, -8},
// 44 second... | |
tion interp = prv_default_interpolate;
int y = prv_int_scale_and_translate_to(255, 10, 10, 10, 0, 255, ANIMATION_NORMALIZED_MAX,
interp);
cl_assert_equal_i(y, 255 + 255);
}
void test_gdraw_command_transforms__int_scale_to_translate_overflow_neg(void) {
InterpolateInt64Fun... | (img, from, to, t, interp, index_lookup, f, false) | |
SmartstrapConnectionEvent contain the attribute pointer
SmartstrapAttribute *attr = event.attribute;
PBL_ASSERTN(attr);
if ((event.type == SmartstrapDataSentEvent) && state->handlers.did_write) {
state->handlers.did_write(attr, event.result);
} else if ((event.type == SmartstrapDataReceivedEvent) ... | (service_id) | ;
#else
return false;
#endif
}
SmartstrapServiceId app_smartstrap_attribute_get_service_id(SmartstrapAttribute *attr) {
#if USE_SMARTSTRAP
SmartstrapServiceId service_id;
sys_smartstrap_attribute_get_info(attr, &service_id, NULL, NULL);
return service_id;
#else
return 0;
#endif
}
SmartstrapAttributeId app_s... |
= TimelineAppStateDaySeparator) {
prv_cleanup_timer(&data->day_separator_timer_id);
prv_hide_day_sep(data);
return true;
}
return false;
}
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
TimelineAppData *data = context;
prv_attempt_hide_day_sep(data);
if (!p... | if (data->timeline_model.direction == TimelineIterDirectionPast) {
analytics_inc(ANALYTICS_DEVICE_METRIC_TIMELINE_PAST_NAVIGATION_COUNT, AnalyticsClient_System);
} else {
analytics_inc(ANALYTICS_DEVICE_METRIC_TIMELINE_FUTURE_NAVIGATION_COUNT, AnalyticsClient_System);
} |
}
static void prv_click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_BACK, prv_back_click_handler);
window_single_click_subscribe(BUTTON_ID_UP, prv_up_down_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_up_down_click_handler);
window_single_click_subscribe(BUTTON... |
__missing_inbound_packet(void) {
test_ppogatt__open_session_when_found_pebble_app();
// Receive data:
prv_receive_short_data_fragment(s_characteristics[0][PPoGATTCharacteristicData],
1 /* sn (expecting sn=0) */);
// Expect nothing to be sent, rely on other end to hit time-out ... | (transport) | ;
prv_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn,
s_short_data_fragment, sizeof(s_short_data_fragment));
}
}
void test_ppogatt__handle_client_disappearing_for_send_callback(void) {
// ppogatt_send_next() is called from the KernelBG task sometimes.
// It's po... |
true /* standalone_reply */);
break;
case TimelineItemActionTypeAncsResponse:
// Mark this window so we know to pop it when we get a response
s_phone_ui_data->waiting_for_action_result = true;
// Kick off the reply action automatically - we will pop the phone ui... | animation_set_duration(ui_movement, 3 * ANIMATION_FRAME_MS) | ;
Animation *ui_bounceback = property_animation_get_animation(
property_animation_create_bounds_origin(
&s_phone_ui_data->core_ui_container, &overshoot,
&GPoint(PBL_IF_RECT_ELSE(ACTION_BAR_WIDTH / 2, 0), 0)));
animation_set_curve(ui_bounceback, AnimationCurveEaseOut);
animation_set_duration(... |
subscribe(handlers, s_data.context);
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS... | layer_get_unobstructed_bounds(&layer, &unobstructed_bounds) | ;
cl_assert_equal_grect(unobstructed_bounds, GRect(110, 130, 140, 150));
}
void test_unobstructed_area_service__nested_layer_clip_nx_ny(void) {
app_state_get_unobstructed_area_state()->area = GRect(0, 0, 400, 400);
Layer root_layer = {
.bounds = GRect(-150, -120, 10, 10), // The size of the parent layer has ... |
elapsed_sec, params->seconds);
float err = act_distance[i] - exp_distance_m;
float pct_err = err * 100.0 / exp_distance_m;
printf("\n%4d %5d %4d %7.2f %7d %7d %13d %13d %+.2f",
i, params->height_in, params->steps, params->seconds, steps_per_minute,
params->exp_distance_m, ... | cl_assert_equal_i(s_hrm_manager_update_interval, 1) | ;
}
// ---------------------------------------------------------------------------------------
// Test that average heart rate is reported correctly
void test_activity__hrm_median(void) {
int32_t median, total_weight;
// Start activity tracking. This method assumes it can be called from any task, so we must
//... |
\n"
" add r0, r0, #4 \n"
: [regs] "+r" (regs)
:
: "r0", "r1"
);
} else if (g_stacked_regs != NULL) {
// Copy the stacked registers from the stacked register set
s_thread_info.ti.registers[portCANONICAL_REG_INDEX_R0] = g_stacked_regs[Stacked_Register_R0];
s... | (".text CRC32 does not match!\n") | ;
}
// Reset the DMA controller
for (HW_DMA_CHANNEL channel = HW_DMA_CHANNEL_0; channel < HW_DMA_CHANNEL_INVALID; channel++) {
hw_dma_channel_enable(channel, HW_DMA_STATE_DISABLED);
}
// Configure the SPI module.
hw_spi_reset(s_spi->bus_id);
hw_spi_init(s_spi->bus_id, &s_spi->hw_init);
// Configu... |
, 1128, -272},
// 52 seconds
{ -56, 1120, -472},
{ 344, 784, -520},
{ 656, 504, -576},
{ 536, 208, 168},
{ 632, -80, -400},
{ 360, -160, -464},
{ 296, -296, -256},
{ 288, -400, -240},
{ 320, -320, -344},
{ 400, -400, -280},
{ 472, -584, -392},
{ 560, -648, -456},
... | { -64, 824, 16},
{ 120, 1064, 0},
{ 368, 1280, -144},
{ 208, 1352, -160},
{ 88, 1296, -152},
{ 8, 928, -32},
{ 88, 752, -120},
{ 248, 536, 48},
{ 112, 640, -224},
{ 328, 568, 112},
{ 424, 512, 24},
{ 456, 480, -72},
{ 560, 576, -112},
{ 544, 736, -104},
{ 712,... |
// elapsed: 1 minutes
{ 0, -432, -912},
{ 0, -432, -888},
{ 0, -424, -872},
{ -8, -416, -864},
{ -16, -464, -856},
{ -48, -400, -920},
{ -40, -432, -960},
{ -48, -384, -976},
{ -24, -408, -992},
{ -16, -352, -968},
{ -32, -376, -968},
{ -56, -384, -944},
{ -48, -... |
nance lookup table if necessary
GColor8 tint_luminance_lookup_table[GCOLOR8_COMPONENT_NUM_VALUES] = {};
if (compositing_mode == GCompOpTintLuminance) {
gcolor_tint_luminance_lookup_table_init(tint_color, tint_luminance_lookup_table);
}
for (int16_t dest_y = dest_begin_y; dest_y < dest_e... | (grect_get_max_x(&dest_rect), dest_row_info.max_x + 1) | |
text_layer_set_text(text_layer, g_text);
} else if (type == 1) {
snprintf(g_text, sizeof(g_text), "BAT: %d, %d, %d", (int)data->data0, (int)data->data1, (int)data->data2);
text_layer_set_text(text_layer, g_text);
}
}
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
AppWork... | (HealthMetricSleepRestfulSeconds) | ;
APP_LOG(APP_LOG_LEVEL_INFO, "app: New sleep event: total: %"PRIu32", restful: %"PRIu32" ",
total_sleep / SECONDS_PER_MINUTE, restful_sleep / SECONDS_PER_MINUTE);
}
}
void handle_deinit(void) {
tick_timer_service_unsubscribe();
health_service_events_unsubscribe();
}
void handle_init(void) {
... |
NT32_MIN;
int32_t sum = 0;
int32_t count = 0;
uint8_t value = 50;
for (unsigned i = 0; i < num_minutes_per_call; i++) {
min_value = MIN(min_value, value);
max_value = MAX(max_value, value);
sum += value;
count++;
s_sys_activity_get_minute_history_values.out[0].records[i].heart_rate_bpm = val... | cl_assert_equal_i(s_metric_alert_count, 0);
} |
// --------------------------------------------------------------------------------------
// Test the health metric alert registration
void test_health__metric_alert_registration(void) {
health_service_events_subscribe(prv_test_event_handler, NULL);
time_t now = rtc_get_time();
HealthServiceAccessibilityMask a... |
#include "mfg/mfg_serials.h"
#include "resource/resource_ids.auto.h"
#include "services/common/i18n/i18n.h"
#include "services/common/new_timer/new_timer.h"
#include "shell/prefs.h"
#include "util/size.h"
// The calibration screen will be changing the screen offsets, so it's best that it remains on top
// of most othe... | {
s_timer = new_timer_create();
const uint32_t prompt_delay_time_ms = MS_PER_SECOND * SECONDS_PER_MINUTE;
new_timer_start(s_timer, prompt_delay_time_ms, prv_timer_callback, NULL, 0 /* flags */);
} |
}
#endif
|
assert_equal_i(sys_wakeup_query(late_wakeup_id), late_event);
// Make sure that the next scheduled timer is now the late wakeup id.
cl_assert_equal_i(late_wakeup_id, wakeup_get_next_scheduled());
// Set time 10 minutes into the future, late_event should fire
rtc_set_time(late_event);
// Force wakeup to che... | wakeup_get_current() | ;
// Jump 30 seconds in the future
uint32_t initial_timeout = stub_new_timer_timeout(first_timer);
uint32_t time_jump_seconds = 30;
rtc_set_time(sys_get_time() + time_jump_seconds);
// Notify clock change and record change in new timer
wakeup_handle_clock_change();
uint32_t final_timeout = stub_new_ti... |
{ 1360, 360, 120},
{ 1392, 232, 88},
{ 1248, 200, 64},
{ 1224, 184, 32},
{ 1208, 248, -24},
{ 1104, 272, -16},
{ 936, 224, -32},
{ 792, 200, -104},
{ 864, 192, -104},
{ 1080, 224, -168},
{ 1184, 176, -96},
{ 1392, 184, -40},
{ 1280, 184, -96},
{ 1176, 224, -80},
... | { 1344, 584, 232},
{ 1608, 328, 320},
{ 1432, 224, 240},
{ 1336, 144, 136},
{ 1248, 40, 64},
// 81 seconds
{ 1104, 56, 40},
{ 928, 184, -104},
{ 872, 248, -120},
{ 1128, 264, -104},
{ 1048, 272, -224},
{ 904, 184, -144},
{ 1304, 160, -88},
{ 840, 208, -8},
{ 1... |
{ 888, 128, -40},
{ 976, 192, -32},
{ 1104, 256, -232},
{ 1360, 288, -216},
{ 1264, 272, -96},
{ 1008, 192, -40},
{ 1008, 248, -120},
{ 1152, 296, -40},
{ 1280, 360, -64},
{ 1128, 392, -88},
{ 1120, 408, -104},
{ 1448, 520, -80},
// 84 seconds
{ 1312, 616, 0},
... |
_app_prefs_db.settings_file, pref_key,
strlen(pref_key), prefs, len);
if (rv != S_SUCCESS) {
task_free(prefs);
prefs = NULL;
}
}
prv_close_file_and_unlock_mutex();
return prefs;
}
SerializedSendTextPrefs *watch_app_prefs_get_send_text(void) {
return (SerializedSe... | {
rv = settings_file_set(&s_watch_app_prefs_db.settings_file, key, key_len, val, val_len);
// Cache the data we just set if it was for the Reminders app
const int expected_reminder_app_prefs_size = sizeof(SerializedReminderAppPrefs);
if ((rv == S_SUCCESS) &&
is_valid_reminder_key &&
(va... |
return rv;
}
int watch_app_prefs_db_get_len(const uint8_t *key, int key_len) {
int len = 0;
if (prv_lock_mutex_and_open_file() == S_SUCCESS) {
len = settings_file_get_len(&s_watch_app_prefs_db.settings_file, key, key_len);
prv_close_file_and_unlock_mutex();
}
return len;
}
status_t watch_app_pref... |
/*
* 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 E_INVALID_OPERATION;
} |
static status_t framebuffer_domain_open(uint8_t *packet_data, size_t length, void **resp) {
animation_private_pause();
return S_SUCCESS;
}
static void framebuffer_domain_close_cb(void *foo) {
FrameBuffer *fb = compositor_get_framebuffer();
framebuffer_dirty_all(fb);
compositor_display_update(NULL);
}
stat... |
/*
* 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 (result != GET_APP_INFO_SUCCESS) {
// Failed to load the app out of flash, this function will have already printed an error.
return false;
} |
// We load the full binary (.text + .data) into ram as well as the relocation entries. These
// relocation entries will overlap with the .bss section of the loaded app, but we'll fix that
// up later.
const size_t load_size = app_storage_get_process_load_size(&info);
if (load_size > memory_segment_get_size... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | resource_init() | ;
}
void test_expandable_dialog__cleanup(void) {
free(fb);
}
// Helpers
//////////////////////
void prv_manual_scroll(ScrollLayer *scroll_layer, int8_t dir);
void prv_push_and_render_expandable_dialog(ExpandableDialog *expandable_dialog,
uint32_t num_times_to_scroll_down... |
, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_checkerboard_no_clip")));
// Clipping on even boundaries - no offset
... | (&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_checkerboard_no_clip")) | );
// Clipping on even boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_EVEN, OFFSET_RECT_EVEN, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_... |
sions and
* limitations under the License.
*/
#include "applib/pbl_std/pbl_std.h"
#include "applib/pbl_std/locale.h"
#include "services/common/i18n/i18n.h"
#include "util/size.h"
#include "clar.h"
// Stubs
//////////////////////////////////////////////////////////
#include "stubs_heap.h"
#include "stubs_hexdump.h"... | cl_assert_equal_s(tmbuf, "20 Jan") | ;
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%D %e", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "01/02/15 2");
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%n %r", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "\n 01:00:00 PM");
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%R ... |
----------------------------------------------------------
BTErrno gap_le_connect_cancel_by_bonding(BTBondingID bonding_id, GAPLEClient client) {
if (bonding_id == BT_BONDING_ID_INVALID || client >= GAPLEClientNum) {
return BTErrnoInvalidParameter;
}
bt_lock();
// Find the intent for the device:
GAPLECon... | {
if (!intent->client[c].is_used) {
// Not all specified clients own the intent
ret_value = false;
}
} | else {
// Intent not found
ret_value = false;
}
bt_unlock();
return ret_value;
}
uint32_t gap_le_connect_connection_intents_count(void) {
bt_lock();
const uint32_t count = prv_intents_count();
bt_unlock();
return 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... | (ps1->str_value, ps2->str_value, ps1->str_length) | |
sert_equal_i(last_update_utc, 0);
// Simulate some HRM callbacks with no heart rate, should get 0 median
prv_advance_time_hr(10 /*sec*/, 0 /*hr*/, HRMQuality_Good, true /*force_continuous*/);
activity_metrics_prv_get_median_hr_bpm(&median, &total_weight);
cl_assert_equal_i(median, 0);
cl_assert_equal_i(total... | prv_advance_time_hr(1 /*sec*/, 120 /*hr*/, HRMQuality_Excellent, true /*force_continuous*/) | ;
cl_assert_equal_i(s_num_hr_events, 4);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 120);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.quality, HRMQuality_Excellent);
// Should not fire off an event. Bad HR reading
prv_advance_time_hr(1 /*sec*/, 20 /*hr*/, HRMQuality_Ex... |
e we are oversampling super aggressively with the
// bma255, I'm concerned about changing the timing of how fast we drain things. Thus, just use a
// static buffer for now. This should be safe because only one thread should be draining the data.
static AccelDriverSample data[BMA255_FIFO_MAX_FRAMES];
const uint6... | {
s_accel_outstanding_data_work = true;
accel_offload_work_from_isr(prv_handle_data, should_context_switch);
} |
}
static void prv_update_accel_interrupts(bool enable, AccelOperatingMode mode) {
s_operating_states[mode].using_interrupts = enable;
bool enable_interrupts = false;
for (uint32_t i = 0; i < ARRAY_LENGTH(s_operating_states); i++) {
if (s_operating_states[i].using_interrupts) {
enable_interrupts = tru... |
{
BatteryCriticalAppData* data = app_malloc_check(sizeof(BatteryCriticalAppData));
gbitmap_init_with_resource(&data->bitmap, RESOURCE_ID_BATTERY_ICON_CHARGE);
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Battery Critical"));
window_set_overrides_back_bu... |
static void handle_deinit(void) {
BatteryCriticalAppData* app_data = app_state_get_user_data();
gbitmap_deinit(&app_data->bitmap);
app_free(app_data);
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* battery_critical_get_app_info() {
static cons... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | i18n_get("Open Workout", ¬if_attr_list) | );
const int num_actions = 3;
TimelineItemActionGroup action_group = {
.num_actions = num_actions,
.actions = (TimelineItemAction[]) {
{
.id = 0,
.type = TimelineItemActionTypeDismiss,
.attr_list = dismiss_attr_list,
},
{
.id = 1,
.type = TimelineIt... |
ts) - 1);
const GRect *bounds = &layer->layer.bounds;
frame->origin = GPoint(style->left_margin, s_height_offsets[index]);
prv_get_size_for(prv_get_mode(index), bounds, &frame->size);
}
void timeline_layer_get_layout_frame(TimelineLayer *layer, int index, GRect *frame_out) {
prv_get_frame(layer, index, frame_o... | ((LayoutLayer *)timeline_layout) | ;
layer->layouts[index] = NULL;
app_free(layer->layouts_info[index]);
layer->layouts_info[index] = NULL;
}
static void prv_destroy_nonvisible_items(TimelineLayer *layer) {
for (int i = 0; i < (int)ARRAY_LENGTH(s_nonvisible_items); i++) {
TimelineLayout *timeline_layout = layer->layouts[s_nonvisible_items[... |
/*
* 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... | (void, sys_data_logging_finish, DataLoggingSessionRef session_ref) | {
// TODO: It would be nice to verify the session itself, because they could be
// passing us any memory address (not necesarilly a valid DataLoggingSession).
// An evil developer could potentially use this to confuse the data_logging
// logic, and do evil things with kernel rights. However, it's pretty unlike... |
pi_clock();
handle_sleep_when_idle_begin();
flash_wait_for_write();
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD_READ);
flash_send_24b_address(start_addr);
// There is delay associated with setting up the stm32 dma, using FreeRTOS
// sempahores, handling ISRs, etc. Thus for short reads, th... | prv_check_protection_flag() | ;
disable_flash_spi_clock();
power_tracking_stop(PowerSystemFlashErase);
flash_unlock();
}
// It is dangerous to leave this built in by default.
#if 0
void flash_erase_bulk(void) {
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
flash_prf_set_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... | accel_manager_init() | ;
s_sampling_interval_us = 1000000 / ACCEL_SAMPLING_25HZ;
s_num_samples = 0;
s_force_sampling_interval = false;
}
void test_accel_manager__cleanup(void) {
test_accel_manager_reset();
}
static void prv_noop_sample_handler(void *context) {
}
static void prv_validate_sample_rates(int *arr, int num_samples) {... |
iphResetCmd(ahb3_periphs, DISABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, ENABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, DISABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, ENABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, DISABLE);
}
static void __attribute__((noreturn)) prv_jump_to_fw(void) {
void *initial_stack_poin... | boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE) | |
104},
{ 840, 64, 96},
{ 960, 88, 24},
{ 1400, 40, 112},
{ 1464, 280, -216},
// 60 seconds
// elapsed: 1 minutes
{ 1328, 232, -312},
{ 1656, 384, -392},
{ 1592, 584, -312},
{ 1168, 416, -160},
{ 888, 352, -128},
{ 752, 336, -112},
{ 688, 352, -56},
{ 760, 440, -64}... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25666_6
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ 224, -16, -1000},
{ 2... |
{ 544, 376, 152},
{ 704, 400, 80},
{ 864, 408, 96},
{ 968, 424, 40},
{ 1384, 488, -72},
{ 1952, 744, -176},
{ 2008, 672, -208},
{ 1592, 472, -272},
{ 1584, 208, -144},
{ 1616, 136, -56},
{ 1440, 88, -24},
{ 1136, 64, 24},
{ 888, 64, 48},
{ 760, 64, 64},
{ 624... |
ackEventCallback callback, void *data) {
// Use fake_system_task as mock:
system_task_add_callback(callback, data);
}
void ppogatt_create(void) {
}
void ppogatt_destroy(void) {
}
void ppogatt_handle_buffer_empty(void) {
}
void bt_driver_reconnect_try_now(bool ignore_paused) {
}
void gatt_client_op_cleanup(GAPL... | kernel_le_client_deinit() | ;
fake_system_task_callbacks_cleanup();
}
void test_kernel_le_client__read_response_consumed_even_if_client_is_gone(void) {
// Simulate the client goes away:
s_can_handle_characteristic = false;
PebbleEvent e = (PebbleEvent) {
.type = PEBBLE_BLE_GATT_CLIENT_EVENT,
.bluetooth.le.gatt_client = {
.... |
/*
* 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_signature) | == expected_signature))) {
return false;
}
// Data is the second entry after the resource signature
if (data_size) {
size_t output_data_size = sys_resource_size(app_num, resource_id) - VIBE_DATA_OFFSET;
*data_size = output_data_size;
}
return true;
}
bool vibe_score_validate(VibeScore *score, u... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// Should be a basic log for timed out expect in hc_protocol layer
return false;
} | |
.x, px); \
cl_assert_fixedS16_3(p.y, py); \
} while(0)
void test_graphics_circle__grect_polar_calc_values_handles_null(void) {
GPointPrecise center = {};
Fixed_S16_3 radius = {};
const GRect r = GRect(0, 0, 3, 5);
const GOvalScaleMode mode = GOvalScaleModeFitCircle;
grect_polar_calc_values(&r, mode, ... | (s_radius, 4.5) | ;
}
void test_graphics_circle__fill_oval(void) {
cl_assert_gpoint_precise(s_center, 0, 0);
cl_assert_fixedS16_3(s_radius_inner, 0);
cl_assert_fixedS16_3(s_radius_outer, 0);
cl_assert_equal_i(s_angle_start, 0);
cl_assert_equal_i(s_angle_end, 0);
graphics_fill_oval(NULL, GRect(0, 0, 10, 12), GOvalScaleModeF... |
/*
* 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... | (&dest_bitmap, "test_bitblt__8bit_assign-expect.8bit.pbi") | );
memset(dest_data, GColorGreen.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpOr, GColorWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_assign-expect.8bit.pbi"));
memset(dest_data, GColorGreen.argb, sizeof(dest_data));
bitblt_bitmap_into_... |
by prv_custom_curve_ptr_pack
static AnimationCurveFunction prv_custom_curve_ptr_unpack(uintptr_t bits) {
bits = (bits << 1) | 1; // Set the Thumb bit on the function pointer
uint8_t top_byte = bits >> 24;
top_byte = ((top_byte & 0b11100) << 1) | (top_byte & 0b11);
bits = (top_byte << 24) | (bits & 0xffffff);
... | {
animation->implementation->setup(animation);
} |
const bool old_head_is_animating = animation_legacy2_scheduler->head
? (((AnimationLegacy2 *)animation_legacy2_scheduler->head)->abs_start_time_ms <= now)
: false;
const bool ascending = true;
animation_legacy2_scheduler->head = list_sorted_add(animation_legacy2_scheduler->head,
&anima... |
(!token) {
continue;
}
// If this is a pre-processor directive, skip it
if (token[0] == '#') {
continue;
}
// If this is a comment skip it
if (strcmp(token, "//") == 0) {
continue;
}
// If this is an AccelRawData line, get the name
if (strcmp(token, "AccelRawDat... | (token + strlen(token) + 1, "%d", &state->test_entry.version) | ;
} else if (strcmp(token, "TEST_TOTAL") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.total.value);
} else if (strcmp(token, "TEST_TOTAL_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.total.min);
} else if (strcmp(token, "TEST_TOTAL_MAX"... |
_separator_height(it->menu_layer, &it->cursor.index);
if (it->cursor.h > 0) {
// Bottom of previous cell is y of the next cell
const int16_t total_height = it->cursor.h + it->cursor.sep;
if (total_height > it->cursor.y) {
// If the total height is greater than the cursor y, don'... | (&render_iter->it) | ;
render_iter->it.cursor = menu_layer->cache.cursor;
prv_menu_layer_walk_upward_from_iterator(&render_iter->it);
} else {
// Walk upward from cache.cursor, then downward
prv_menu_layer_walk_upward_from_iterator(&render_iter->it);
render_iter->it.cursor = menu_layer->cache.cursor;
prv_menu_laye... |
uadrant);
} else {
prv_plot8(framebuffer, &ctx->draw_state.clip_box, p, GPoint(edge.integer, progress),
MAX_PLOT_OPACITY, stroke_color, quadrant);
}
}
// Behold for magic number 3!!!
// Note: magic numbers explained in main comment for this function
int special_case_pixels = 3;
... | {
graphics_internal_circle_quadrant_fill_aa(ctx, p, outer_radius, quadrant);
} | else {
graphics_circle_quadrant_fill_non_aa(ctx, p, outer_radius, quadrant);
}
#else
graphics_circle_quadrant_fill_non_aa(ctx, p, outer_radius, quadrant);
#endif
// Restore original status
ctx->draw_state.fill_color = temp_color;
return;
}
// Since fill_oval will use fill color, we have... |
bool prv_read_minute_file_record(SettingsFile *file, SettingsRecordInfo *info,
uint32_t key_range_start, uint32_t key_range_end,
AlgMinuteFileRecord *chunk) {
// Get the key for this record and see if we want it
uint32_t key;
info->g... | if (file) {
prv_minute_data_file_close(file);
} |
prv_unlock();
return success;
}
// ----------------------------------------------------------------------------------------------
// Settings file rewrite callback used by prv_validate_and_trim_minute_file() when trimming off
// old keys
typedef struct {
uint32_t oldest_valid_key;
uint32_t newest_valid_key;
... |
/*
* 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... | {
// Make sure we aren't overflowing / backing up the queue too much
if (system_task_get_available_space() > 10) {
system_task_add_callback(prv_poll_phone_for_status, context);
}
} | |
log_file_id = hdr.log_file_id;
}
}
return (first_used_region);
}
//! @param log_file_id - the id of the log file to find
//! @param[out] start_page_addr - the address of the page the log starts on
//! @return the number of pages in the log file requested or 0 if no
//! file is found
static int prv_get_start_... | (prev_log_id,
&s_curr_state.page_start_addr) | == 0)) {
s_curr_state.page_start_addr = FLASH_REGION_DEBUG_DB_BEGIN;
}
s_curr_state.page_start_addr = prv_get_unit_base_address(s_curr_state.page_start_addr);
prv_erase_unit(s_curr_state.page_start_addr);
s_curr_state.log_file_id = prv_get_next_log_file_id(prev_log_id);
}
done: // we have al... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (flash_locked) | ;
}
void test_system_flash__erase_one_byte(void) {
cl_assert(system_flash_erase(FLASH_BASE, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sector(void) {
cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, N... |
/*
* 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... | (set_value, get_value) | ;
// If we get the pref setting now, it should still be the old value because we haven't
// issued the blob_db update event yet
uint32_t get_pref = backlight_get_timeout_ms();
cl_assert_equal_i(get_pref, set_value + 1);
// Issue the blob_db update event
PebbleBlobDBEvent event = (PebbleBlobDBEvent) {
... |
/*
* 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_ALWAYS, "Delaying reset by 3s so the UI can update...") | ;
TimerID timer = new_timer_create(); // Don't bother cleaning up this timer, we're going to reset
PBL_ASSERTN(timer != TIMER_INVALID_ID);
new_timer_start(timer, timeout, prv_ui_update_reset_delay_timer_callback, NULL, 0);
}
//! Note: For now we just call into storage directly for the status of FW installs. Som... |
int(0, SCREEN_HEIGHT / 2));
ctx.draw_state.drawing_box = GRect(SCREEN_WIDTH / 2, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
ctx.draw_state.clip_box = GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled.${BIT_DEPTH_NAME}.pbi"));
printf("-... | {
// NOTE: Those tests are being performed only in 8bits due to differences caused by AA,
// performing them in both 1bit and 8bit would create differences on the edges
// and fail unit tests as a result
GContext ctx;
Layer layer;
// Bolt path - test antialiased edges
prv_reset();
test_graphics_con... |
gpath_move_to(s_infinite_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_infinite_aa.8bit.pbi"));
// An angle of infinite path... |
const ActionMenuItem *action_menu_item,
void *context) {
prv_mute_notification(action_menu_item, MuteBitfield_Weekends);
}
static bool prv_has_mute_action(TimelineItem *item) {
PebbleProtocolCapabilities capabilities;
bt_persistent_stor... | i18n_noop("Mute %s") | ;
static char mute_label_buf[32];
snprintf(mute_label_buf, sizeof(mute_label_buf),
i18n_get(mute_label, root_level), display_name);
const uint8_t mute_option = ancs_filtering_get_mute_type(notif_prefs);
const bool is_mute_weekdays = mute_option == MuteBitfield_Weekdays;
const bool is_mu... |
/*
* 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... | ARRAY_LENGTH(g_task_handles) | ; ++i) {
if (g_task_handles[i] == task_handle) {
return i;
}
}
return PebbleTask_Unknown;
}
TaskHandle_t pebble_task_get_handle_for_task(PebbleTask task) {
return g_task_handles[task];
}
static uint16_t prv_task_get_stack_free(PebbleTask task) {
// If task doesn't exist, return a dummy with max ... |
/////////////////////////////////////
#define SPRF_REGION_SIZE (FLASH_REGION_SHARED_PRF_STORAGE_END - \
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_NUM_PAGES (SPRF_REGION_SIZE / sizeof(SharedPRFData))
#define SPRF_PAGE_FLASH_OFFSET(idx) (FLASH_REGION_SHARED_PRF_STORAGE_BEGIN + \
... | (page_idx[i]) | , sizeof(data));
data.magic = SprfMagic_ValidEntry;
flash_write_bytes((uint8_t *) &data, SPRF_PAGE_FLASH_OFFSET(page_idx[i]), sizeof(data));
// Call init and see if it found the valid page
shared_prf_storage_init();
uint32_t desired_page_idx = page_idx[i];
if (page_idx[i] > SPRF_MAX_NUM_PAGES_M... |
lude "flash_region/flash_region.h"
#include "process_management/app_install_manager.h"
#include "services/normal/process_management/app_storage.h"
#include "process_management/pebble_process_info.h"
#include "process_management/pebble_process_md.h"
#include "resource/resource.h"
#include "resource/resource_storage.h"
#... | {
AppInstallId id = app_install_get_id_for_uuid(uuid);
return app_install_get_entry_for_install_id(id, entry);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (scroll_layer) | ->bounds;
GPoint offset = { .y = bounds->size.h - new_height };
#if PBL_ROUND
// do paging on round display
offset.y = ROUND_TO_MOD_CEIL(offset.y, scroll_layer->layer.frame.size.h);
#endif
scroll_layer_set_content_size(scroll_layer,
(GSize) { scroll_layer->layer.frame.s... |
/*
* 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... | TEST_NAMED_PBI_FILE("draw_line_across_x_origin_layer") | ));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_nx_origin_layer")));
test_graphics_context_reset(&ctx, fb);
layer_set_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_LOG(LOG_LEVEL_DEBUG, "Call Cookie: 0x%"PRIx32, i->cookie);
// PBL_LOG(LOG_LEVEL_DEBUG, "Caller Number: %s", i->caller_number);
// PBL_LOG(LOG_LEVEL_DEBUG, "Caller Name: %s", i->caller_name);
} |
static void prv_put_call_disconnect_event(void) {
PebbleEvent e = {
.type = PEBBLE_PHONE_EVENT,
.phone = {
.type = PhoneEventType_Disconnect,
.source = PhoneCallSource_PP,
.call_identifier = 0, // Cookie is not yet implemented / used
}
};
event_put(&e);
}
static void prv_put_call_... |
ay_10_30 = 1426933800;
// Sunday, March 22, 2015, 9:30 UTC
static const int s_sunday_9_30 = 1427016600;
// Sunday, March 22, 2015, 10:00 UTC
static const int s_sunday_10_00 = 1427018400;
// Sunday, March 22, 2015, 23:30 UTC
static const int s_sunday_23_30 = 1427067000;
// Monday, March 23, 2015, 10:30 UTC
static const ... | cl_assert(do_not_disturb_is_manually_enabled() == false) | |
buted 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 "console/control_protocol.h"
#include "console/control_protocol_i... | (LCP_HEADER_LEN) | ,
};
pulse_link_send(packet, LCP_HEADER_LEN);
}
static void prv_send_terminate_ack(PPPControlProtocol *this, int identifier) {
if (identifier < 0) { // Not in response to a Terminate-Request
// Pick an arbitrary identifier to send in ack
identifier = this->state->next_terminate_id++;
} else {
// U... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
default:
case 0: return 2;
case 1: return 3;
case 2: return 4;
case 3: return 5;
} |
}
static int16_t get_cell_height_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index, AppData *data) {
(void)data;
(void)menu_layer;
(void)cell_index;
// Variable row heights demo:
switch (cell_index->row % 3) {
default:
case 0:
return 44;
case 1:
return 64;
case 2:
... |
TRIBUTE_X:
if (data->intersection.x < bounds.size.w - 1) {
++data->intersection.x;
}
break;
case ATTRIBUTE_Y:
if (data->intersection.y < bounds.size.h - 1) {
++data->intersection.y;
}
break;
default:
break;
}
layer_mark_dirty(data->canvas_layer);
}
... | GPoint(0, data->intersection.y) | ,
GPoint(bounds.size.w, data->intersection.y));
graphics_draw_line(ctx, GPoint(data->intersection.x, 0),
GPoint(data->intersection.x, bounds.size.h));
}
static void main_window_load(Window *window) {
AppData *data = window_get_user_data(s_window);
Layer *window_layer = w... |
/*
* 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... | ("\nTesting setting and retreiving a key several times...\n") | ;
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_set_get_one_many_times", 4096));
uint8_t key[4];
int key_len = sizeof(key) - 1;
memcpy(key, "key", sizeof(key));
uint8_t val[7];
int val_len = 6;
printf("Setting key 10 times and verifying we get the same value back...\n");
for (in... |
dv_state = AdvertState_Off;
static struct {
bool needs_updating;
BLEAdData ad_data;
uint8_t data_buffer[2 * GAP_LE_AD_REPORT_DATA_MAX_LENGTH];
} s_desired_ad_data;
static PebbleRecursiveMutex *s_adv_mutex;
static void prv_lock(void) {
mutex_lock_recursive(s_adv_mutex);
}
static void prv_unlock(void) {
mute... | {
ble_error_t rv = BLE_STATUS_OK;
prv_lock();
{
// The only valid desired host states are Off & Running
switch (s_desired_host_adv_state) {
case AdvertState_Running:
case AdvertState_Off:
break;
default:
WTF;
}
// Are we already in the state we desire
if (s_d... |
AdvertState advert_enable(void) {
AdvertState rv;
prv_lock();
{
s_desired_host_adv_state = AdvertState_Running;
prv_try_to_enter_host_desired_state();
rv = s_adv_state;
}
prv_unlock();
return rv;
}
void advert_disable(void) {
prv_lock();
{
s_desired_host_adv_state = AdvertState_Off;
... |
data_bytes, glyph->data, glyph_size_bytes);
glyph = text_resources_get_glyph(&s_font_cache, 0x4E50 /* 乐 */, &s_font_info);
// the chinese pbpack contains the letter 你, it should succeed
cl_assert(glyph != NULL);
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(chinese_glyph_data_bytes, glyph... | (FONT_VERSION(font_info_compressed.base.md.version), 3) | |
{
PBL_ASSERTN(highest_rate == ACCEL_SAMPLING_25HZ
&& state->sampling_rate == ACCEL_SAMPLING_10HZ);
new_num = 2;
new_den = 5;
}
if (state->subsample_numerator != new_num || state->subsample_denominator != new_den) {
state->subsample_numerator = new_num;
state->subs... | {
uint64_t old_timestamp_ms = accel_get_latest_timestamp();
// Else, change the FIFO to 1 deep and wait for a reading
ACCEL_LOG_DEBUG("setting FIFO to 1 deep for peek");
accel_set_num_samples(1);
s_accel_samples_per_update = 1;
// Set a timer to restore settings after a while
... |
}
mutex_unlock_recursive(s_mutex);
return result;
}
static bool prv_call_data_callback(AccelSubscriberState *state) {
switch (state->task) {
case PebbleTask_App:
case PebbleTask_Worker:
case PebbleTask_KernelMain: {
PebbleEvent event = {
.type = PEBBLE_CALLBACK_EVENT,
.callba... |
/*
* 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_string_for_cmd(clock_cmd))
PERIPH_CONFIG_LOG("Enabling clock %s", prv_string_for_cmd(clock_cmd)); |
#endif
clock_cmd(rcc_bit, ENABLE);
}
void periph_config_disable(void *periph, uint32_t rcc_bit) {
ClockCmd clock_cmd = prv_get_clock_cmd((uintptr_t)periph);
#if PERIPH_CONFIG_DEBUG
if (prv_string_for_cmd(clock_cmd))
PERIPH_CONFIG_LOG("Disabling clock %s", prv_string_for_cmd(clock_cmd));
#endif
clock_cmd(r... |
1328, -96, 8},
{ 1096, -32, -144},
{ 784, -24, -344},
{ 752, -56, -320},
{ 1104, -104, -200},
{ 1192, -184, -120},
{ 1024, -192, -136},
// 164 seconds
{ 952, -112, -184},
{ 968, -48, -176},
{ 976, -8, -168},
{ 968, -8, -136},
{ 920, -56, -96},
{ 992, -64, -80},
{... | { 1376, 128, 0},
{ 1192, 96, 24},
{ 1112, 80, -24},
{ 1088, 160, -64},
{ 1080, 152, -64},
{ 1016, 96, -80},
{ 944, 64, -176},
{ 872, 80, -272},
{ 768, 40, -384},
{ 720, 24, -408},
{ 688, -16, -528},
{ 728, -32, -544},
{ 752, -72, -560},
{ 864, -56, -472},
{ 11... |
{ 1168, -24, -544},
{ 1192, -24, -560},
{ 1200, -8, -496},
{ 1024, 0, -472},
{ 1016, -40, -360},
{ 1064, -64, -344},
{ 976, -48, -272},
{ 928, 40, -272},
{ 984, 136, -344},
{ 952, 136, -280},
{ 944, 184, -304},
{ 880, 224, -360},
{ 816, 256, -400},
{ 760, 256, -4... |
ndle shall be the last Attribute Handle of the service
// definition containing the change" (Core Spec 2.5.2 Attribute Caching)
// Send an event to notify us that service was removed/added
gatt_client_discovery_handle_service_range_change(connection, range);
// Let's spawn a new discovery
gatt_client_discov... | bt_unlock() | ;
}
void bt_driver_cb_gatt_client_discovery_handle_service_changed(GAPLEConnection *connection,
uint16_t handle) {
bt_lock();
{
connection->gatt_service_changed_att_handle = handle;
}
bt_unlock();
}
//////////////////////////////////
// Prompt... |
urrent_y,
.final_y = final_y,
.progress = progress,
},
};
event_put(&event);
}
static void prv_clip_area(GRect *area_out) {
PBL_ASSERTN(area_out);
const GRect display_frame = { .size = framebuffer_get_size(app_state_get_framebuffer()) };
grect_clip(area_out, &display_frame);
}
//! Currently,... | {
if (state && area_out) {
*area_out = state->area;
}
} |
void app_unobstructed_area_service_subscribe(UnobstructedAreaHandlers handlers, void *context) {
unobstructed_area_service_subscribe(app_state_get_unobstructed_area_state(), &handlers, context);
}
void app_unobstructed_area_service_unsubscribe(void) {
unobstructed_area_service_unsubscribe(app_state_get_unobstruc... |
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 for ... | {
int remaining = dst_space - strlen(dst);
if (dst_space > 0) {
strncat(dst, src, remaining);
}
dst[dst_space-1] = 0;
} |
// -----------------------------------------------------------------------------------------
static void prv_display_scalar_history_alert(HealthAPITestAppData *data, const char *title,
HealthMetric metric) {
strcpy(data->debug_card.dialog_text, title);
// Get History... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.