Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

Replaces deprecated runtime type checking (device is Capability) with the new capability system API introduced in open_earable_flutter v2.3.0.

Changes

  • Replace all device is Capability checks with device.hasCapability<Capability>()
  • Replace all (device as Capability) casts with device.requireCapability<Capability>()
  • Add explicit RgbLed capability check alongside StatusLed (original code implicitly assumed coexistence)

Pattern

Before:

if (device is BatteryLevelStatus) {
  final level = await (device as BatteryLevelStatus)
      .batteryPercentageStream.first;
}

After:

if (device.hasCapability<BatteryLevelStatus>()) {
  final level = await device.requireCapability<BatteryLevelStatus>()
      .batteryPercentageStream.first;
}

Scope

Migrated 17 capability types across 11 files:

  • Battery: BatteryLevelStatus, BatteryLevelStatusService, BatteryEnergyStatusService, BatteryHealthStatusService
  • Sensors: SensorManager, SensorConfigurationManager, EdgeRecorderManager
  • Device Info: DeviceIdentifier, DeviceFirmwareVersion, DeviceHardwareVersion, SystemDevice
  • Stereo: StereoDevice
  • Audio: MicrophoneManager, AudioModeManager
  • LED: StatusLed, RgbLed
  • Time: TimeSynchronizable
Original prompt

This section details on the original issue you should resolve

<issue_title>Adopt new capability system from open_earable_flutter version 2.3.0</issue_title>
<issue_description>Adopt the new capability system of open_earable_flutter version 2.3.0. Instead of checking for the implementation of capabilities with device is Capability use device.hasCapability<Capability>(), device.getCapability<Capability>() and device.requireCapability<Capability>.</issue_description>

<agent_instructions>Use hasCapability<T>() to check support and getCapability<T>() or requireCapability<T>() to fetch an instance:

if (wearable.hasCapability<SensorManager>()) {
  final sensorManager = wearable.requireCapability<SensorManager>();
  final sensors = sensorManager.sensors;
}

The difference between getCapability<T>() and requireCapability<T>() is that the latter throws an exception if the capability is not supported, while the former returns null.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant
Copy link

CLAassistant commented Jan 9, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ DennisMoschina
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Visit the preview URL for this PR (updated for commit 07ca820):

https://open-earable-web--pr199-copilot-adopt-new-ca-s91t606q.web.app

(expires Fri, 06 Feb 2026 14:43:41 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c7397c11177c71d8d81172cea9365829823fb41c

Copilot AI changed the title [WIP] Adopt new capability system from open_earable_flutter 2.3.0 Migrate to open_earable_flutter v2.3.0 capability system API Jan 9, 2026
Copilot AI requested a review from DennisMoschina January 9, 2026 14:29
…device_row.dart: Refactor _buildNewTabContent to use Wearable device instead of SensorConfigurationManager
Copy link
Collaborator

@DennisMoschina DennisMoschina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks fine and everything works as expected

@DennisMoschina DennisMoschina marked this pull request as ready for review January 9, 2026 14:45
@DennisMoschina DennisMoschina merged commit 032d223 into oe_lib_upgrade Jan 9, 2026
3 of 4 checks passed
@DennisMoschina DennisMoschina deleted the copilot/adopt-new-capability-system branch January 9, 2026 14:46
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.

3 participants