Skip to content

Conversation

@g150446
Copy link

@g150446 g150446 commented Dec 28, 2025

Problem

When connecting to a Pebble watch running recovery firmware (PRF), the app crashes with an ArrayIndexOutOfBoundsException in ConnectivityWatcher.kt:91.

Root Cause:

  • Recovery firmware returns an empty byte array (length=0) for the BLE connectivity characteristic
  • The ConnectivityStatus constructor attempts to access characteristicValue[0] and characteristicValue[3] without checking if the array is empty
  • This causes an immediate crash during connection, preventing users from updating their watch firmware

User Impact:

  • Users cannot connect to watches in recovery mode
  • Firmware updates cannot be completed
  • App shows "Rebooting after update - Waiting" indefinitely after firmware update

Error from logs:

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
    at io.rebble.libpebblecommon.connection.bt.ble.pebble.ConnectivityStatus.<init>(ConnectivityWatcher.kt:91)

Solution

Added bounds checking in the ConnectivityStatus constructor to handle empty byte arrays from recovery firmware:

  1. Check for empty array - If characteristicValue.isEmpty(), initialize all fields with safe default values (all false, NO_ERROR)
  2. Add bounds check for pairingErrorCode - Only access characteristicValue[3] if array size > 3

Files Changed:

  • libpebble3/src/commonMain/kotlin/io/rebble/libpebblecommon/connection/bt/ble/pebble/ConnectivityWatcher.kt

Testing

  • Tested on Pixel 7a (Android 14) with Pebble Time in recovery mode (v3.0.1-prf-rc1)
  • Successfully connects to recovery firmware
  • Firmware update to v4.4.3-rbl completes successfully
  • Watch reconnects properly after firmware update

Recovery firmware returns an empty byte array for the BLE connectivity characteristic, causing ArrayIndexOutOfBoundsException when trying to parse connection status. Added bounds checking to handle empty arrays safely, allowing users to connect and update watches in recovery mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Dec 28, 2025

CLA assistant check
All committers have signed the CLA.

When firmware sideload failed with a safety check error (e.g., board
mismatch), the UI would stay on "Idle" instead of showing the error
message. Now properly displays error messages from the Idle state's
lastFailure field.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants