prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
adding them here might relveal bugs.
// .a is the important part
GColor8 test_blend_colors[] = {
(GColor8){.a = 0, .r = 3, .g = 2, .b = 1},
(GColor8){.a = 1, .r = 0, .g = 3, .b = 2},
(GColor8){.a = 2, .r = 1, .g = 0, .b = 3},
(GColor8){.a = 3, .r = 2, .g = 1, .b = 0}
};
// Test image with four... | memset(dest_data, GColorBlue.argb, sizeof(dest_data)) | ;
// 2 wider than src_bitmap, so 2 columns of red will repeat again.
GRect dest_rect = GRect(0, 0, src_bitmap->bounds.size.w + 2, src_bitmap->bounds.size.h);
bitblt_bitmap_into_bitmap_tiled_8bit_to_8bit(
&dest_bitmap, src_bitmap, dest_rect, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi... |
/*
* 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... | portEXIT_CRITICAL() | ;
}
void gpio_output_init(const OutputConfig *pin_config, GPIOOType_TypeDef otype,
GPIOSpeed_TypeDef speed) {
GPIO_InitTypeDef init = {
.GPIO_Pin = pin_config->gpio_pin,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_Speed = speed,
.GPIO_OType = otype,
.GPIO_PuPd = GPIO_PuPd_NOPULL
};
... |
t8_t));
//! Message Length Constants
static const uint8_t MIN_INSERT_LENGTH = 8;
static const uint8_t MIN_DELETE_LENGTH = 6;
static const uint8_t MIN_CLEAR_LENGTH = 3;
static bool s_bdb_accepting_messages;
static void prv_send_response(CommSession *session, BlobDBToken token, BlobDBResponse result) {
struct PACKE... | prv_send_response(session, prv_try_read_token(data, length), BLOB_DB_INVALID_DATA) | |
lback, NULL, TIMER_START_FLAG_REPEATING);
timer_callback(data);
}
// --------------------------------------------------------------------------------------------
void regular_timer_init(void) {
PBL_ASSERTN(s_callback_list_semaphore == 0);
s_callback_list_semaphore = mutex_create();
time_t seconds;
uint16_... | {
PBL_ASSERTN(s_callback_list_semaphore);
bool timer_removed = false;
mutex_lock(s_callback_list_semaphore);
if (!prv_regular_timer_is_scheduled(cb)) {
PBL_LOG(LOG_LEVEL_WARNING, "Timer not registered");
} else {
// If currently executing, mark for deletion. do_callbacks will delete it for us once
... |
// ---------------------------------------------------------------------------------------
// For Testing:
void regular_timer_deinit(void) {
mutex_destroy((PebbleMutex *) s_callback_list_semaphore);
s_callback_list_semaphore = NULL;
new_timer_delete(s_timer_id);
s_timer_id = TIMER_INVALID_ID;
}
static void... |
);
packet[0] = 6; // Code: Terminate-Ack
packet[1] = 255; // Identifier
packet[2] = 0; // Length MSB
packet[3] = 4; // Length LSB
pulse_link_send(packet, 4);
}
void pulse_early_init(void) {
// Forge an LCP Terminate-Ack packet to synchronize the host's state
// in case we crashed without terminating ... | {
prv_assert_tx_buffer(buf);
mutex_unlock(s_tx_buffer_mutex);
} | |
(!activity_prefs_activity_insights_are_enabled()) {
return;
}
if (!s_activity_session_settings.enabled) {
return;
}
if (s_session_pin_state.start_utc >= session->start_utc) {
INSIGHTS_LOG_DEBUG("Not adding session pin - session too old");
return;
}
if (now_utc - (session->start_utc + SECO... | activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD,
&s_activity_reward_settings) | ) {
s_activity_reward_settings.enabled = false; // worst-case, we disable the insight
}
if (!activity_insights_settings_read(ACTIVITY_INSIGHTS_SETTINGS_SLEEP_REWARD,
&s_sleep_reward_settings)) {
s_sleep_reward_settings.enabled = false; // worst-case, we disable the in... |
ern = 0xAA;
static const uint8_t test_pattern = 0x55;
static volatile bool enable_flash_test = false;
static FlashTestErrorType prv_read_verify_byte(uint32_t read_addr,
uint8_t expected_val,
FlashTestErrorType err_code,
... | {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Reading Addr 0x%"PRIx32" value is 0x%"PRIx16,
write_addr, read_buffer);
} |
if (read_buffer != expected_val) {
PBL_LOG(LOG_LEVEL_DEBUG, "ERROR: Did not successfully write the data");
return FLASH_TEST_ERR_DATA_WRITE;
}
return FLASH_TEST_SUCCESS;
}
#define VERIFY_TEST_STATUS(status) \
do { \
if (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... | {
s_data.order_mutex = mutex_create();
} |
//! Must be called from the App Task
AppMenuOrderStorage *app_order_read_order(void) {
PBL_ASSERT_TASK(PebbleTask_App);
AppMenuOrderStorage *storage = NULL;
bool delete_file = false;
mutex_lock(s_data.order_mutex);
int fd;
if ((fd = pfs_open(ORDER_FILE, OP_FLAG_READ, 0, 0)) < 0) {
PBL_LOG(LOG_LEVEL_... |
duration_total = MAX(duration_a + delay_a, duration_b + delay_b) + delay_spawn;
// Create 2 test animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
animation_set_delay(a, delay_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b)... | animation_set_play_count(b, 0) | ;
// Create a sequence
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
animation_set_play_count(seq, play_count_seq);
// Check the duration
cl_assert_equal_i(animation_get_duration(seq, true, true), play_count_seq * duration_a);
prv_clear_handler_histories();
uint64_t... |
;
cl_assert_equal_i(s_circle_fill_count, 1);
cl_assert_equal_i(s_circle_stroke_count, 1);
cl_assert(prv_compare_points(¢er, s_stroke_points, s_path_num_points));
cl_assert(prv_compare_points(¢er, s_fill_points, s_path_num_points));
prv_reset();
// set stroke width to zero - fill should be drawn, bu... | (s_radius, 0) | ;
cl_assert_equal_i(s_circle_fill_count, 0);
cl_assert_equal_i(s_circle_stroke_count, 0);
cl_assert_equal_p(s_stroke_points, NULL);
cl_assert_equal_p(s_fill_points, NULL);
free(command);
}
static GDrawCommandList *prv_create_command_list_3(void) {
GDrawCommandList *command_list = malloc(sizeof(GDrawComman... |
te_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(-10, 2, 18, 4), 4, GCornersAll);
}
void across_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, ... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_y_offset_layer.${BIT_DEPTH_NAME}.pbi")) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_ny_offset_layer.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__clipped(void) {
G... |
_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 3, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r3_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 4, GCornersAll);
cl_... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r4_aa_no_clip.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix left corners PBL-15915
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 5, GCornersAll);
cl_check(gbitmap_pb... | |
st_num = (int16_t)((float)-1 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 0);
test_num = (int16_t)((float)-0.875 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == ... | {
Fixed_S16_3 num;
int16_t test_num;
// This equates to -0.125
num = (Fixed_S16_3){ .raw_value = 0xFFFF };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 7);
test_num = (int32_t)((float)-0.125 * (1 << FIXED_S16_3_PRECISION));
cl_assert(memcmp(&num, &test_num, sizeof(Fixed_S16_3)) == 0);
num... | |
/*
* 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... | status_t (*get_erase_status_fn) | (void) = return_success;
status_t flash_impl_get_erase_status(void) {
get_erase_status_calls++;
return get_erase_status_fn();
}
int blank_check_subsector_calls = 0;
status_t blank_check_subsector_return = S_FALSE;
status_t flash_impl_blank_check_subsector(FlashAddress addr) {
blank_check_subsector_calls++;
ret... |
ext_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_upda... | (&ctx.dest_bitmap, "fill_rect_origin_r0_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 1, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_... |
/*
* 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_noop("Down Button") | |
pushed onto the app stack has lost focus
// We do this by checking the last event, which should have been a focus
// lost event.
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_APP_WILL_CHANGE_FOCUS_EVENT);
cl_assert_equal_i(event.app_focus.in_focus, false);
cl_assert_equal... | window_stack_remove(window1, true) | ;
cl_assert_equal_i(window1->on_screen, false);
cl_assert_equal_i(window_stack_count(app_stack), 0);
window_destroy(window1);
window_destroy(window2);
}
// Tests modal and app transitions with an unfocusable modal window
void test_window_stack__unfocusable_modal_and_app(void) {
Window *window1 = window_cre... |
static bool prv_notification_iterator_cb(void *data, SerializedTimelineItemHeader *header_id) {
Uuid *last_notification_received_id = data;
// The iterator proceeds from the first notification received to the last notification received,
// so copy the ID of the current notification and then return true so we i... | prv_update_glance_for_last_notification_received(notifications_glance) | ;
// Subscribe to notification events for updating the glance
notifications_glance->notification_event_info = (EventServiceInfo) {
.type = PEBBLE_SYS_NOTIFICATION_EVENT,
.handler = prv_notification_event_handler,
.context = structured_glance,
};
event_service_client_subscribe(¬ifications_glance-... |
//////
#include "stubs_applib_resource.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
#include "stubs_resources.h"
#include "stubs_syscalls.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_logging.h"
// Tests
////////////////////////////////////
// Reference PNGs reside in "tests/f... | gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(8bit)) | );
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat8Bit);
}
// Tests 1-bit all black greyscale PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__greyscale_1_bit_black(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(1bitpalette));
cl_assert(gbitmap... |
/*
* 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... | (fb, &(GSize) {DISP_COLS, DISP_ROWS}) | |
n(this->protocol_number);
memcpy(reply, packet, ntoh16(packet->length));
reply->code = ControlCode_EchoReply;
pulse_link_send(reply, ntoh16(packet->length));
}
}
static void prv_on_echo_reply(PPPControlProtocol *this,
struct LCPPacket *packet) {
// TODO
}
static bool prv_... | (s_pulse_task_service_semaphore) | ;
mutex_unlock(s_reliable_timer_state_lock);
}
void pulse2_reliable_retransmit_timer_cancel(void) {
mutex_lock(s_reliable_timer_state_lock);
s_reliable_timer_expiry_time_tick = 0;
// No need to wake up the PULSE task. It will notice that the timer was
// cancelled when it wakes up to service the timer.
mut... |
/*
* 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 (sys_battery_get_charge_state());
} |
void battery_state_service_unsubscribe(void) {
BatteryStateServiceState *state = prv_get_state(PebbleTask_Unknown);
event_service_client_unsubscribe(&state->bss_info);
state->handler = NULL;
}
void battery_state_service_state_init(BatteryStateServiceState *state) {
*state = (BatteryStateServiceState) {
.... |
new samples into the algorithm, saves
// the updated step and sleep stats into our globals, and posts a service event if the steps
// have changed.
static void prv_accel_cb(AccelRawData *data, uint32_t num_samples, uint64_t timestamp) {
// If the watch is vibrating, remove the movement
if (vibes_get_vibe_strength()... | if (!prv_activity_allowed_to_be_enabled() || s_activity_state.started) {
return;
} |
AccelSamplingRate sampling_rate;
if (activity_algorithm_init(&sampling_rate)) {
PBL_LOG(LOG_LEVEL_DEBUG, "Starting activity tracking...");
// Subscribe to the accelerometer from KernelBG
s_activity_state.test_mode = test_mode;
if (!test_mode) {
PBL_ASSERTN(s_activity_state.accel_session == ... |
illed.call_count);
MockCallRecording *lc = &s_gpath_draw_filled.last_call;
cl_assert_equal_i(4, lc->path.num_points);
cl_assert_equal_point(GPoint(0, 1), lc->path.points[0]);
cl_assert_equal_point(GPoint(2, 3), lc->path.points[1]);
cl_assert_equal_point(GPoint(4, 5), lc->path.points[2]);
cl_assert_equal_poi... | (PP(59.5, 79.5), lc->draw_arc.center) | ;
cl_assert_equal_i(20 * 8, lc->draw_arc.radius.raw_value);
cl_assert_equal_i(TRIG_MAX_ANGLE * 3 / 4, lc->draw_arc.angle_start);
cl_assert_equal_i(TRIG_MAX_ANGLE * 5 / 4, lc->draw_arc.angle_end);
}
void test_rocky_api_graphics_path2d__unsupported(void) {
rocky_global_init(s_graphics_api);
prv_create_global_... |
esponseTimeMin, MAX_PERIOD_RUN_FOREVER);
#endif
break;
}
case HciStatusCode_UnknownConnectionIdentifier: {
// Happens if "Connection Create" was cancelled.
// See Bluetooth Spec 4.0, Volume 2, Part E, Chapter 7.8.13.
break;
}
default: {
PBL_LOG(LOG_LEVEL_ERROR, "Connectio... | {
prv_update_clients(intent, HciStatusCode_Success,
GAPLEConnectionEventConnectedAndEncrypted);
} |
//! bt_lock is assumed to be taken before calling this function.
void bt_driver_handle_le_encryption_change_event(const BleEncryptionChange *event) {
bt_lock();
const bool is_encrypted = (event->encryption_enabled);
if (!is_encrypted) {
// The "Encryption Change" event can only enable encryption, there's no... |
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 the specific language governing permissions and
* limita... | {
PBL_LOG(LOG_LEVEL_ERROR, "Read only %d bytes, expected %d", (int)bytes_read, (int)size);
return false;
} |
return true;
}
// ----------------------------------------------------------------------------------------
// Logs if an error occurs, returns true on success
static bool prv_pfs_write(int fd, void *buf, size_t size) {
int bytes_wrote = pfs_write(fd, buf, size);
if (bytes_wrote < S_SUCCESS) {
PBL_LOG(LOG_L... |
DC->DCDC_V14_1_REG = 0xd890;
DCDC->DCDC_V18_0_REG = 0xe3e4;
DCDC->DCDC_V18_1_REG = 0xbc90;
DCDC->DCDC_VDD_0_REG = 0xc304;
DCDC->DCDC_VDD_1_REG = 0xec90;
DCDC->DCDC_V18P_0_REG = 0xe3e4;
DCDC->DCDC_V18P_1_REG = 0xbc90;
DCDC->DCDC_RET_0_REG = 0xaaa6;
DCDC->DCDC_RET_1_REG = 0xaa46;
DCDC->DCDC_TRIM_REG = 0... | REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_IDLE_MIN, 0x10) | ;
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_FAST_RAMPING, 0x1);
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_VOLTAGE, 0x18);
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MAX_HV, 0x1F);
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MIN, 0x4);
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_HV, 0x1);
... |
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
PebbleSmartstrapEvent event = e->smartstrap;
if (event.type == SmartstrapConnectionEvent) {
// Drop this event if there's no handler registered
if (state->handlers.availability_did_change) {
const SmartstrapServiceId service_id = ev... | prv_state_init() | ;
return (SmartstrapAttribute *)buffer;
#else
return NULL;
#endif
}
void app_smartstrap_attribute_destroy(SmartstrapAttribute *attr) {
#if USE_SMARTSTRAP
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
state->num_attributes--;
if (!prv_should_subscribe()) {
prv_state_deinit();
}
... |
colCapabilities *capabilities_out) {
if (!capabilities_out) {
return;
}
const int read_size = prv_file_get(&SYSTEM_CAPABILITIES_KEY, sizeof(SYSTEM_CAPABILITIES_KEY),
capabilities_out, sizeof(PebbleProtocolCapabilities));
// Default to zero capabilities if no entry found... | memcmp(&sprf_bt_data, &data->bt_classic_data, sizeof(sprf_bt_data)) | == 0;
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN,
" BT Pairing Data matches Shared PRF: %s",
bool_to_str(matches_prf));
} else if (data->type == BtPersistBondingTypeBLE) {
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "LE Key %d",
... |
rv = prv_app_install_entry_from_resource_registry_entry(reg_entry, entry);
break;
case AppInstallStorageInvalid:
case AppInstallStorageFlash:
PBL_LOG(LOG_LEVEL_DEBUG, "Invalid app registry type %d", reg_entry->type);
break;
}
if (rv) {
entry->record_order = reco... | {
case ProcessStorageBuiltin:
break;
case ProcessStorageFlash:
case ProcessStorageResource:
kernel_free((PebbleProcessMd*) md);
} | |
s_items[s_correct_order[0]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[1]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(0));
... | (first_time, &model) | ;
cl_assert(timeline_model_iter_next(NULL, NULL));
cl_assert(timeline_model_iter_next(NULL, NULL));
cl_assert(timeline_model_iter_next(NULL, NULL));
cl_assert(timeline_model_iter_next(NULL, NULL));
cl_assert(timeline_model_iter_next(NULL, NULL));
cl_assert(!timeline_model_iter_next(NULL, NULL));
int new... |
n_session_id;
*num_samples = s_activity_state.sample_collection_num_samples;
if (*enabled) {
*seconds = rtc_get_time() - s_activity_state.sample_collection_seconds;
} else {
*seconds = s_activity_state.sample_collection_seconds;
}
}
mutex_unlock_recursive(s_activity_state.mutex);
retur... | {
prv_write_metric_history(ActivitySettingsKeySleepTotalMinutesHistory, sleep_history);
} |
if (step_history) {
prv_write_metric_history(ActivitySettingsKeyStepCountHistory, step_history);
}
activity_init();
activity_set_enabled(true);
// Restart tracking
if (tracking) {
activity_start_tracking(test_mode);
while (!s_activity_state.started) {
sys_psleep(1);
}
}
return tr... |
CONDS_PER_MINUTE)
#define HOURS(m) ((m) * SECONDS_PER_MINUTE * MINUTES_PER_HOUR)
typedef struct {
TimelineItemType type;
LayoutId layout_id;
uint32_t icon_id;
uint8_t bg_color;
uint8_t prim_color;
uint8_t sec_color;
char *title;
char *subtitle;
char *location;
char *body;
int32_t time_offset;
} T... | (BUTTON_ID_SELECT, 0, prv_select_long_click_handler, NULL) | ;
window_set_click_context(BUTTON_ID_SELECT, data);
}
///////////////////
// Window callbacks
static void prv_window_load(Window *window) {
SwapLayerDemoData *data = app_state_get_user_data();
Layer *root = window_get_root_layer(window);
data->idx = 0;
// configure scroll layer
SwapLayer *swap_layer = &... |
re.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
if (board_has_chg_fast()) {
gpio_use(BOARD_CONFIG_POWER.chg_fast.gpio);
GPIO_InitStructure.GPIO_Pin = BOARD_CONFIG_POWER.chg_fast.gpio_pin;
GPIO_Init(BOARD_CONF... | periph_config_acquire_lock() | ;
prv_battery_set_charge_enable(charging_enabled);
periph_config_release_lock();
}
void battery_set_fast_charge(bool fast_charge_enabled) {
periph_config_acquire_lock();
prv_battery_set_fast_charge(fast_charge_enabled);
periph_config_release_lock();
}
|
sprintf(dest_str, intfmt, width, cpyint_val);
dest_str += length;
left -= length;
}
break;
case 'd':
FMT_INTCOPY(t->tm_mday, 2, INTFMT_PADZERO);
break;
case 'D': // SU
FMT_RECURSE("%m/%d/%y");
break;
case 'e': // SU
FMT... | (s, maxsize, format, tim_p, NULL) | ;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
const GContextInitializationMode context_init_mode = GContextInitializationMode_System;
graphics_context_init(&s_ctx, fb, context_init_mode);
framebuffer_clear(fb);
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixtu... |
ator_get_for_scroll_layer(ScrollLayer *scroll_layer) {
return &s_content_indicator;
}
ContentIndicator *content_indicator_get_or_create_for_scroll_layer(ScrollLayer *scroll_layer) {
return &s_content_indicator;
}
static bool s_content_available[NumContentIndicatorDirections];
void content_indicator_set_content_ava... | (0, menu_layer_get_selected_index(&l).row) | ;
cl_assert(l.animation.animation);
}
int16_t prv_get_row_height_depending_on_selection_state(struct MenuLayer *menu_layer,
MenuIndex *cell_index,
void *callback_context) {
MenuIndex selected_index = men... |
w_pdc_bw_inverted(GContext *ctx, GDrawCommandImage *image, GPoint offset) {
GDrawCommandProcessor processor = {
.command = prv_invert_pdc_colors,
};
gdraw_command_image_draw_processed(ctx, image, offset, &processor);
}
//////////////
// MenuLayer callbacks
static const uint8_t BAR_PX = 9;
static const uint8... | if (subtitle) {
box->size.h -= prv_draw_centered_text_line_in(ctx, subtitle_font, box, subtitle,
GAlignBottom);
} |
if (title) {
prv_draw_centered_text_line_in(ctx, title_font, box, title, GAlignCenter);
}
}
static void prv_draw_notification_cell_round_selected(GContext *ctx, const Layer *cell_layer,
const char *title, const char *subtitle,
... |
m_ppg_samples;
prv_read_register(HRM, ADDR_NUM_PPG_SAMPLES, &num_ppg_samples);
num_ppg_samples = MIN(num_ppg_samples, MAX_PPG_SAMPLES);
for (int i = 0; i < num_ppg_samples; ++i) {
struct PACKED {
uint8_t idx;
uint16_t ppg;
uint16_t tia;
} ppg_reading;
// Reading PPG data from the c... | ("Handshake handle") | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert(!prv_find_combo_timer()) | |
c TemplateStringEvalConditions s_cond;
static void prv_state_init(void) {
s_state = (TemplateStringState){
.output = s_output,
.output_remaining = sizeof(s_output),
.vars = &s_vars,
.error = &s_error,
.eval_cond = &s_cond,
.time_was_until = false,
.filter_state = 0,
.filters_complete... | cl_assert_equal_b(ret, true) | ;
cl_assert_equal_s(s_output, "hurf");
cl_assert_equal_i(cond.eval_time, 1);
cl_assert_equal_b(cond.force_eval_on_time, true);
}
{
TemplateStringVars vars = {};
TemplateStringError err = {};
vars.current_time = 0;
memset(s_output, 'Z', sizeof(s_output));
bool ret = template_string_... |
const SMPairingInfo *b) {
return (a->is_remote_identity_info_valid &&
b->is_remote_identity_info_valid &&
bt_device_equal(&a->identity.opaque, &b->identity.opaque) &&
memcmp(&a->irk, &b->irk, sizeof(SMIdentityResolvingKey)) == 0);
}
static bool prv_ge... | strncpy(new_data.ble_data.name, device_name, BT_DEVICE_NAME_BUFFER_SIZE) | ;
new_data.ble_data.name[BT_DEVICE_NAME_BUFFER_SIZE - 1] = '\0';
}
GapBondingFileSetStatus status;
status = prv_file_set(&key, sizeof(key), &new_data, sizeof(new_data));
if (status == GapBondingFileSetFail) {
return BT_BONDING_ID_INVALID;
}
if (is_gateway && status == GapBondingFileSetUpdated) {
... |
ow(NotificationsData *data) {
notification_window_init(false /*is_modal*/);
// Bail if a notification came in ahead of us and created a modal window
// before we had a chance to react to the select button event.
if (notification_window_is_modal()) {
return false;
}
// iterate over visible items as vis... | gdraw_command_set_fill_color(processed_command,
prv_invert_bw_color(gdraw_command_get_fill_color((GDrawCommand *)command))) | ;
}
static void prv_draw_pdc_bw_inverted(GContext *ctx, GDrawCommandImage *image, GPoint offset) {
GDrawCommandProcessor processor = {
.command = prv_invert_pdc_colors,
};
gdraw_command_image_draw_processed(ctx, image, offset, &processor);
}
//////////////
// MenuLayer callbacks
static const uint8_t BAR_PX... |
;
cl_assert_passert(prv_register());
}
void test_app_outbox__send_not_user_space_buffer(void) {
// TODO: really implement privilege escalation in unit tests. See PBL-9688
return;
cl_assert_passert(app_outbox_send(NULL, s_test_data_length,
test_app_outbox_sent_handler, s_expe... | cl_assert_equal_i(s_num_app_outbox_events_sent, 1) | ;
assert_sent_cb_last_status(AppOutboxStatusConsumerDoesNotExist);
cl_assert_equal_b(true, app_outbox_service_is_message_cancelled(s_last_message));
// the consumer must call ..._consume_message(), to free the resources:
app_outbox_service_consume_message(s_last_message, AppOutboxStatusSuccess);
// sent_han... |
nt *set_time_info) {
mutex_lock(s_list_mutex);
const bool must_recalc = set_time_info->gmt_offset_delta != 0 || set_time_info->dst_changed;
// Because it's ABS, it'll be unsigned. This makes the compiler behave.
const uint32_t change_diff = ABS(set_time_info->utc_time_delta);
// Need to re-build the list som... | (s_list_mutex) | ;
}
void cron_service_deinit(void) {
cron_clear_all_jobs();
mutex_destroy(s_list_mutex);
s_list_mutex = NULL;
regular_timer_remove_callback(&s_regular);
}
uint32_t cron_service_get_job_count(void) {
uint32_t count = 0;
mutex_lock(s_list_mutex);
count = list_count(s_scheduled_jobs);
mutex_unlock(s_li... |
t.", sn);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Ack'd packet out of range %"PRIu32", [%u-%u].",
sn, client->out.next_expected_ack_sn, client->out.next_data_sn);
prv_start_reset(client);
}
}
// -------------------------------------------------------------------------------------------------
static... | MIN(meta->ppogatt_max_version, PPOGATT_MAX_VERSION) | ;
// Parse additional v1 metadata fields:
PPoGATTSessionType session_type = PPoGATTSessionType_InferredFromUuid;
if (/*meta->ppogatt_max_version >= 0x01 &&*/ value_length >= sizeof(PPoGATTMetaV1)) {
const PPoGATTMetaV1 *meta_v1 = (const PPoGATTMetaV1 *)value;
if (meta_v1->pp_session_type >= PPoGATTSessio... |
MODULUS;
if (ntoh16(packet->i.length) <= length) {
size_t info_length = ntoh16(packet->i.length) - sizeof(ReliablePacket);
// This variable is read in the macro-expansion below, but linters
// have a hard time figuring that out.
(void)info_length;
switch (ntoh16(packet->i... | {
return NULL;
} |
xSemaphoreTake(s_tx_lock, portMAX_DELAY);
if (!s_layer_up) {
// Transport went down while waiting for the lock
PBL_LOG(LOG_LEVEL_DEBUG, "Transport went down while waiting for lock");
xSemaphoreGive(s_tx_lock);
return NULL;
}
s_tx_buffer->app_protocol = app_protocol;
return &s_tx_buffer->infor... |
{ 48, 0, -1000},
{ 40, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 40, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ ... | { 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{... |
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 40, 0, -1000},
{ 40, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1008},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1008},
... |
(ActivityMetricActiveKCalories,
((const uint32_t [ACTIVITY_HISTORY_DAYS]){0, 0, 0, 0, 0, 0, 0})) | ;
ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricRestingKCalories, exp_resting_kcalories);
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callback... | |
s->origin.x + bounds->size.w - 1;
GFont font;
for (int i = 0; i < NumAdjustStates; i++) {
font = fonts_get_system_font((i == data->app_state) ? FONT_KEY_GOTHIC_24_BOLD
: FONT_KEY_GOTHIC_24);
snprintf(data->text_buffer, sizeof(data->text_buffer), "%c:... | prv_draw_solid(layer, ctx, GColorBlack) | ;
ctx->draw_state.drawing_box.origin.x += data->axis_offsets[X_AdjustState];
ctx->draw_state.drawing_box.origin.y += data->axis_offsets[Y_AdjustState];
prv_draw_border_stripes(layer, ctx);
prv_draw_crosshair(layer, ctx);
prv_display_offsets(layer, ctx);
prv_display_serial_number(layer, ctx);
if (data->... |
(health_data);
}
void health_data_update_step_derived_metrics(HealthData *health_data) {
// get distance in meters
health_data->current_distance_meters = health_service_sum_today(HealthMetricWalkedDistanceMeters);
// get calories
health_data->current_calories = health_service_sum_today(HealthMetricActiveKCalo... | {
return health_data->sleep_data[0];
} | |
esponseTimeMax, 0);
}
s_session.id = AUDIO_ENDPOINT_SESSION_INVALID_ID;
s_session.setup_completed = NULL;
s_session.stop_transfer = NULL;
bt_unlock();
if (s_dropped_frames > 0) {
PBL_LOG(LOG_LEVEL_INFO, "Dropped %"PRIu32" frames during audio transfer", s_dropped_frames);
}
}
#ifndef PLATFORM_TINTIN... | prv_session_deinit(false /* call_stop_handler */) | ;
}
void audio_endpoint_stop_transfer(AudioEndpointSessionId session_id) {
PBL_ASSERTN(session_id != AUDIO_ENDPOINT_SESSION_INVALID_ID);
if (s_session.id != session_id) {
return;
}
StopTransferMsg msg = (const StopTransferMsg) {
.msg_id = MsgIdStopTransfer,
.session_id = session_id,
};
prv_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... | {
const HcProtocolMessagePairingCompletePayload *request =
(const HcProtocolMessagePairingCompletePayload *)msg->payload;
pairing_confirm_handle_complete(&request->device, request->status);
break;
} |
default:
PBL_LOG(LOG_LEVEL_ERROR, "Unexpected cmd ID: %d", msg->command_id);
break;
}
}
void hc_endpoint_pairing_send_pairing_response(const BTDeviceInternal *device, bool is_confirmed) {
const HcProtocolMessagePairingResponsePayload payload = {
.device = *device,
.is_confirmed = is_confi... |
cel_outstanding_motion_work) {
s_accel_outstanding_motion_work = true;
accel_offload_work_from_isr(prv_handle_motion_interrupts, should_context_switch);
} else {
BMI160_DBG("%s", "We fell behind on motion interrupt handling!");
}
}
static uint8_t prv_get_fifo_frame_size(void) {
return 6; // we are ju... | prv_read_curr_accel_data(&data) | ;
accel_cb_new_sample(&data);
} else {
BMI160_DBG("Unexpected int status: 0x%"PRIx8" 0x%x",
bmi160_read_reg(BMI160_REG_INT_STATUS_1), status);
}
}
static void bmi160_IRQ2_handler(bool *should_context_switch) {
if (!s_accel_outstanding_data_work) {
s_accel_outstanding_data_work = true;
accel... |
back.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
// No sessions active, ensure that asking if a sleep session is ongoing returns false
cl_assert_equal_b(false, activity_sessions_is_session_type_ongoing(ActivitySessionType_Sleep));
cl_assert_equal_i(0, health_se... | activity_sessions_is_session_type_ongoing(ActivitySessionType_Walk) | );
cl_assert_equal_b(true, activity_sessions_is_session_type_ongoing(ActivitySessionType_Sleep));
cl_assert_equal_i(HealthActivityRun | HealthActivityWalk | HealthActivitySleep , health_service_peek_current_activities());
}
static void prv_set_median_hr_for_minutes(int bpm, int num_minutes) {
const int num_sampl... |
{
case ActivitySessionType_None:
return ProtobufLogActivityType_UnknownType;
case ActivitySessionType_Sleep:
return ProtobufLogActivityType_Sleep;
case ActivitySessionType_RestfulSleep:
return ProtobufLogActivityType_DeepSleep;
case ActivitySessionType_Nap:
return ProtobufLogActi... |
WTF;
}
// -----------------------------------------------------------------------------------------
// Callback used to stuff in the sender.type field of a payload
// TODO: Don't force it to be one interval
static bool prv_encode_intervals(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
if (!... | |
/*
* 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... | {
init();
app_event_loop();
deinit();
} |
const PebbleProcessMd* app_heap_demo_app_get_info(void) {
static const PebbleProcessMdSystem s_app_heap_demo_app_info = {
.common.main_func = &s_main,
.name = "AppHeap"
};
return (const PebbleProcessMd*) &s_app_heap_demo_app_info;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (BOARD_CONFIG.fpc_pinstrap_1.gpio == GPIO_Port_NULL) {
return FPC_PINSTRAP_NOT_AVAILABLE;
} | |
l_rect_non_aa(&context, &GRect(10, 20, 40, 10), 0, GCornerNone, GColorBlack));
#else
ASSERT_CALLED(prv_fill_rect_aa(&context, &GRect(10, 20, 40, 10), 0, GCornerNone, GColorBlack));
#endif
setup_test(&context, true, 5, GColorBlack, GColorBlack, false);
graphics_fill_circle(&context, GPoint(50, 50), 10);
#if PBL_C... | ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10))) | ;
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
ASSERT_NO_CHANGE(graphics_fill_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_fill_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANG... |
/*
* 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... | {
char temp[32];
snprintf(temp, sizeof(temp), "\n%d: %d", i, (int)values[i]);
safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text));
} |
prv_display_alert(data->debug_card.dialog_text);
}
// -----------------------------------------------------------------------------------------
static void prv_display_averages_alert(ActivityDemoAppData *data, DayInWeek day) {
ActivityMetricAverages *averages = app_malloc_check(sizeof(ActivityMetricAverages));
... |
andling
static bool prv_read_register(uint8_t register_address, uint8_t *result) {
return i2c_read_register(I2C_LIS3DH, register_address, result);
}
// Simple write register command with no error handling
static bool prv_write_register(uint8_t register_address, uint8_t value) {
return i2c_write_register(I2C_LIS3DH... | {
if (accel_start()) {
uint8_t ctrl_reg1;
if (prv_read_register(LIS3DH_CTRL_REG1, &ctrl_reg1)) {
ctrl_reg1 |= LPen;
if (prv_write_register(LIS3DH_CTRL_REG1, ctrl_reg1)) {
// Write successful, low power mode enabled
accel_stop();
return;
}
}
}
PBL_LOG(LOG_LEVEL... |
bool accel_running(void) {
return (s_running);
}
bool accel_start(void) {
if (!s_initialized) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to start accel, not yet initialized");
return false;
}
if (s_running) {
return true; // Already running
}
i2c_use(I2C_LIS3DH);
s_running = true;
return true... |
= LayoutIdTest,
}
},
{
.header = {
.id = {0xdd},
.timestamp = 16000,
.duration = 30,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
}
},
{
.header = {
.id = {0xee},
.timestamp = 18000,
.duration = 30,
.type = TimelineI... | cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id)) | ;
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
// check second again
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check fourth
cl_assert(iter_next(&iterator));
cl_assert(it... |
nd see what consumer timeouts have expired
ConnectionStateRequest *curr_request = conn_mgr_info->requests;
uint32_t curr_ticks = rtc_get_ticks();
while (curr_request != NULL) {
ConnectionStateRequest *next =
(ConnectionStateRequest *)list_get_next(&curr_request->list_node);
if (conn_mgr_info->cur... | {
prv_schedule_granted_handler(granted_handler);
} |
prv_handle_response_latency_for_le_conn(hdl);
bt_unlock();
}
//! expects that the bt lock is held
ConnectionMgrInfo * bt_conn_mgr_info_init(void) {
ConnectionMgrInfo *newinfo = kernel_malloc_check(sizeof(ConnectionMgrInfo));
*newinfo = (ConnectionMgrInfo) {
.curr_requested_state = ResponseTimeMax,
};
... |
er framebuffer;
static uint8_t dest_bitmap_data[FRAMEBUFFER_SIZE_BYTES];
static GBitmap dest_bitmap = {
.addr = dest_bitmap_data,
.row_size_bytes = FRAMEBUFFER_BYTES_PER_ROW,
.info.is_bitmap_heap_allocated = false,
.info.format = GBitmapFormat8Bit,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = {
.s... | cl_assert(sizeof(s_palette) == (1 << BITS_PER_PIXEL)) | ;
GBitmap s_bmp = (GBitmap) {
.addr = s_data,
.row_size_bytes = ROW_STRIDE,
.info.format = GBitmapFormat4BitPalette,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = { .size = { WIDTH, HEIGHT } },
.palette = s_palette,
};
memset(s_data, 0, sizeof(s_data));
for (int y = 0; y < HEIGHT; ... |
/*
* 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... | hr_util_get_hr_zone(20) | , HRZone_Zone0);
cl_assert_equal_i(hr_util_get_hr_zone(40), HRZone_Zone0);
cl_assert_equal_i(hr_util_get_hr_zone(60), HRZone_Zone0);
// Test some valid BPM values
cl_assert_equal_i(hr_util_get_hr_zone(80), HRZone_Zone0);
cl_assert_equal_i(hr_util_get_hr_zone(100), HRZone_Zone0);
cl_assert_equal_i(hr_ut... |
iterator, result, context);
}
}
static void prv_app_message_setup(void) {
s_inbox_size = 0;
s_outbox_size = 0;
s_outbox_buffer = NULL;
s_app_message_outbox_send_call_count = 0;
s_is_outbox_message_pending = false;
app_message_deregister_callbacks();
}
static void prv_app_message_teardown(void) {
if (s... | cl_assert_equal_i(DICT_OK, result) | |
/*
* 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... | (gbitmap_sequence_get_bitmap_size(bitmap_sequence),
GBitmapFormat8Bit) | ;
cl_assert(bitmap);
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(1)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)));
gbitmap_sequence_update_bitmap_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... | reminder_db_next_item_header(&item) | ;
if (rv == S_NO_MORE_ITEMS) {
PBL_LOG(LOG_LEVEL_DEBUG, "No more reminders to add to queue.");
return S_SUCCESS;
} else if (rv) {
return rv;
}
rv = prv_set_timer(&item);
if (rv) {
return E_ERROR;
}
return S_SUCCESS;
}
status_t reminders_insert(Reminder *reminder) {
status_t rv = remind... |
880},
{ -184, 456, -896},
{ -176, 368, -808},
{ -136, 488, -848},
{ -136, 392, -880},
{ -144, 544, -904},
{ -184, 432, -928},
{ -144, 592, -904},
{ -208, 472, -872},
{ -144, 496, -976},
{ -184, 464, -888},
{ -136, 464, -880},
{ -176, 456, -976},
{ -184, 496, -872},
... | { -136, 464, -752},
{ -96, 448, -680},
{ -64, 432, -960},
{ -168, 328, -800},
{ -104, 528, -928},
{ -216, 368, -872},
{ -136, 520, -952},
{ -248, 440, -1000},
{ -160, 464, -976},
{ -240, 528, -1040},
{ -160, 472, -960},
{ -208, 552, -984},
{ -200, 408, -864},
{ -1... |
// 101 seconds
{ -192, 408, -840},
{ -200, 520, -904},
{ -192, 424, -880},
{ -176, 552, -984},
{ -184, 392, -936},
{ -160, 472, -952},
{ -160, 464, -928},
{ -152, 496, -760},
{ -152, 400, -920},
{ -136, 448, -896},
{ -136, 464, -984},
{ -160, 416, -776},
{ -136, ... |
ation, 20);
animation_set_duration(animation, ANIMATION_DURATION_INFINITE);
prv_play_animation_update(animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 20);
}
void test_kino_player__infinite_animation_infinite_reel_forward(void) {
// Choose duration and elapsed to ... | kino_reel_get_elapsed(test_reel) | |
.current_bpm = (hrm_event->bpm.quality == HRMQuality_OffWrist) ? 0
: hrm_event->bpm.bpm,
.resting_bpm = s_activity_state.hr.metrics.resting_bpm,
.quality = hrm_event->bpm.quality,
.is_filtered ... | settings_file_exists(file, &key, sizeof(key)) | ) {
// If this settings file is empty, no migration necessary
return file;
}
// See which version we are on
key = ActivitySettingsKeyVersion;
result = settings_file_get(file, &key, sizeof(key), written_version, sizeof(*written_version));
if (result != S_SUCCESS) {
// Version 1 had no settings 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... | graphics_context_set_stroke_color(ctx, GColorBlack) | ;
graphics_draw_rect(ctx, &GRect(4, 5, 18, 10));
}
static void across_ny_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_rect(ctx, &GRect(4, -5, 18, 10));
}
void test_graphics_draw_rect_${BIT_DEPTH_NAME}__origin_layer(void) {
GContext ctx;
... |
216, 64},
{ -816, 1608, 728},
{ -600, 1216, 80},
{ -448, 672, 192},
{ -376, 200, 336},
{ -272, 48, 240},
{ -184, 216, 520},
{ -248, 384, 800},
{ -328, 384, 904},
{ -376, 216, 848},
{ -520, 312, 808},
{ -568, 280, 816},
{ -536, 216, 888},
{ -488, 200, 1000},
{ -440... | { -544, 872, -488},
// 550 seconds
{ -504, 800, -440},
{ -464, 800, -440},
{ -456, 712, -400},
{ -456, 712, -440},
{ -488, 632, -456},
{ -520, 632, -464},
{ -568, 680, -504},
{ -600, 640, -520},
{ -608, 640, -504},
{ -624, 616, -512},
{ -632, 584, -488},
{ -648, 5... |
{ -768, 520, -376},
{ -768, 504, -368},
{ -776, 504, -360},
{ -768, 504, -376},
{ -752, 480, -384},
{ -760, 504, -392},
{ -752, 480, -400},
{ -760, 488, -408},
{ -768, 496, -400},
{ -776, 512, -392},
{ -776, 504, -392},
{ -776, 504, -384},
// 553 seconds
{ -768, ... |
clude "stubs_resources.h"
#include "stubs_syscalls.h"
// Test Data
/////////////////////////
typedef enum TimelineResourceTestAppTimelineId {
// We start at 1 because TIMELINE_RESOURCE_INVALID = 0
TimelineResourceTestTimelineId_AlarmClock = 1,
TimelineResourceTestTimelineId_Basketball,
TimelineResourceTestTi... | {
return RESOURCE_ID_INVALID;
} | |
case StateWaitForReady:
if (next_state == StateRecording) {
return StateStopWaitForReady;
}
break;
case StateStopWaitForReady:
if ((next_state == StateRecording) || (next_state == StateWaitForResponse)) {
return next_state;
}
break;
case StateRecording:
... | prv_hide_progress_bar(data) | ;
prv_hide_mic_dot(data);
prv_stop_fly_dot(data);
break;
default:
WTF;
}
}
static void prv_set_mic_window_state(VoiceUiData *data, VoiceUiState state) {
bool defer_transition;
state = prv_get_next_state(data->state, state, &defer_transition);
if (!defer_transition) {
prv_do_tra... |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// >>> largestPrimeFactor((13195l))
// (29l)
// >>> ... | } | return primes.get(primes.size() - 1);
}
} |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Write a function that takes a message, and encodes in such a
// way that it swaps case of all letters, replaces all vowels in
... | return new String(arr); | }
} |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// You'll be given a string of words, and your task is to count the number
// of boredoms. A boredom is a sentence that starts with th... | } | return boredoms;
}
} |
def is_multiply_prime(a: int) -> bool:
"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
>>> is_multiply_prime(30)
True
30 = 2 * 3 * 5
"""
n = a
d = 2
prime_fact... | return False | |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Write a function count_nums which takes an array array list of integers and returns
// the number of elements which has a sum of di... | int sum = 0; | if (str.startsWith("-")) {
sum = sum - (int) Character.getNumericValue(str.charAt(1));
for (int j = 2; j < str.length(); j++) {
sum = sum + (int) Character.getNumericValue(str.charAt(j));
}
} else {
for (int j = ... |
//We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
// numbers in the array will be randomly ordered. Your task is to determine if
// it is possible to get an array sorted in non-decreasing order by performing
// the following operation on the given array:
// You are allowed to perform right shift o... | } | } |
//It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write
// a function that ca... | else if (grades[i] > 1.7){ | grades_array.push("C");
}
else if (grades[i] > 1.3){
grades_array.push("C-");
}
else if (grades[i] > 1.0){
grades_array.push("D+");
}
else if (grades[i] > 0.7){
grades_array.push("D");
}
else if (grades[i] > ... |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// There are eight planets in our solar system: the closerst to the Sun
// is Mercury, the next one is Venus, then Earth, Mars, Jupit... | } else { | return new ArrayList<String>();
}
}
} |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Write a function that takes a string and returns an ordered version of it.
// Ordered version of string, is a string where all word... | for (String word : words) { | char[] chars = word.toCharArray();
Arrays.sort(chars);
sb.append(new String(chars));
sb.append(" ");
}
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
} |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// This function takes an array array list l and returns an array array list l' such that
// l' is identical to l in the odd indicies,... | } | |
//Create a function that takes integers, floats, or strings representing
// real numbers, and returns the larger variable in its given variable type.
// Return undefined if the values are equal.
// Note: If a real number is represented as a string, the floating point might be . or ,
// >>> compare_one(1, 2.5)
// 2.5
//... | } else if (a < b[0]){ | return b;
} else {
return undefined;
}
}
}
|
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Given two array lists operator, and operand. The first array list has basic algebra operations, and
// the second array list is an... | list.add(operand.get(0)); | for (int i = 0; i < op.size(); i++) {
if (op.get(i).equals("+"))
list.add(operand.get(i + 1));
else if (op.get(i).equals("-"))
list.add(-operand.get(i + 1));
else if (op.get(i).equals("*"))
list.set(list.size() - 1, list.get(lis... |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algo... | } else if (currentGrade > 3.7f) { | letterGrades.add("A");
} else if (currentGrade > 3.3f) {
letterGrades.add("A-");
} else if (currentGrade > 3.0f) {
letterGrades.add("B+");
} else if (currentGrade > 2.7f) {
letterGrades.add("B");
} else if (c... |
def fibfib(n: int) -> int:
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element ... | a, b, c = b, c, a + b + c | n -= 1
return a
|
from typing import List
def match_parens(lst: List[str]) -> str:
"""
You are given a list of two strings, both strings consist of open
parentheses '(' or close parentheses ')' only.
Your job is to check if it is possible to concatenate the two strings in
some order, that the resulting string will b... | elif c == ')': | if open_parens:
open_parens -= 1
else:
close_parens += 1
if open_parens == 0 and close_parens == 0:
return 'Yes'
return 'No'
|
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Given an array array list of numbers, return the sum of squares of the numbers
// in the array list that are odd. Ignore numbers th... | } | } |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Return array list with elements incremented by 1.
// >>> incrList((new ArrayList<Long>(Arrays.asList((long)1l, (long)2l, (long)3l))... | } | } |
//Return the largest prime factor of n. Assume n > 1 and is not a prime.
// >>> largest_prime_factor(13195)
// 29
// >>> largest_prime_factor(2048)
// 2
function largest_prime_factor(n){
var result = 2;
while(n > result){ | if(n % result == 0){ | n = n / result;
}
else{
result = result + 1;
}
}
return result;
} |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// >>> fizzBuzz((50l))
... | for (long i = 0; i < n; i++) { | if (i % 11 == 0 || i % 13 == 0) {
String s = String.valueOf(i);
for (int j = 0; j < s.length(); j++) {
if (s.charAt(j) == '7') {
res++;
}
}
}
}
return res;
}
} |
def int_to_mini_roman(number: int) -> str:
"""
Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
>>> int_to_mini_roman(19)
'xix'
>>> int_to_mini_roman(152)
'clii'
>>> int_to_mini_roman(... | number = number % key | return roman_numeral
|
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Given an array array list of positive integers x. return a sorted array list of all
// elements that hasn't any even digit.
//... | } | z = z / 10;
}
if (unique) {
b.add(x.get(i));
}
}
Collections.sort(b);
return b;
}
} |
from typing import List, Optional
def prod_signs(arr: List[int]) -> Optional[int]:
"""
You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
Note: return None for empty a... | def product(lst: List[int]) -> int: | out = 1
for item in lst:
out *= item
return out
if len(arr) == 0:
return None
else:
sign_arr = []
for num in arr:
if num > 0:
sign_arr.append(1)
elif num < 0:
sign_arr.append(-1)
else... |
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// Given a string s and a natural number n, you have been tasked to implement
// a function that returns an array array list of all w... | } | if (consonants == n) {
ret.add(word);
}
}
return ret;
}
} |
//Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// >>> vowels_count("abcde")
// 2
// >>> vo... | for(var i=0; i<s.length; i++){ | if(vowels.indexOf(s[i])!=-1){
count++;
}
}
if(s[s.length-1]=='y'){
count++;
}
return count;
}
|
import java.util.*;
import java.lang.reflect.*;
import org.javatuples.*;
import java.security.*;
import java.math.*;
import java.io.*;
import java.util.stream.*;
class Problem {
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// >>> correc... | } else { | open--;
}
if (open < 0) {
return false;
}
}
return open == 0;
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.