Skip to content

Android LE Audio device types decode as unknown #185

Description

@akshatgoel07

Problem

On Android, AudioDeviceInfo.getType() is forwarded unchanged by the Kotlin plugin, but Dart decodes it with decodeEnum(AndroidAudioDeviceType.values, rawType, ...). AndroidAudioDeviceType stops at value 25, so Android device types 26 and above silently become AndroidAudioDeviceType.unknown.

The device itself remains present; only its type is lost.

Missing values

The current Android type space includes:

  • 26: TYPE_BLE_HEADSET
  • 27: TYPE_BLE_SPEAKER
  • 28: TYPE_ECHO_REFERENCE (@hide, but still occupies the integer)
  • 29: TYPE_HDMI_EARC
  • 30: TYPE_BLE_BROADCAST
  • 31: TYPE_DOCK_ANALOG
  • 32: TYPE_MULTICHANNEL_GROUP

The live Android API reference also documents API 37 preview values 33-35: TYPE_BLE_HEARING_AID, TYPE_BLE_CENTRAL, and TYPE_BLE_CENTRAL_BROADCAST.

Omitting hidden value 28 from a positional enum would shift every later value and produce plausible but incorrect device types.

Proposed fix

  • Give AndroidAudioDeviceType explicit raw integer values.
  • Decode through a value map instead of enum position.
  • Update getStreamVolumeDb to send the explicit raw value instead of .index.
  • Add regression coverage for existing values, missing values, invalid/future values, and outbound serialization.
  • Map the new Android values conservatively into the existing cross-platform AudioDeviceType values.

Scope

This requires no Kotlin change, new Android permission, or manifest change. Active-route detection (getDevices() reports connected devices) and Darwin port support are separate concerns.

References:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions