0

I am trying to understand dumpsys bluetooth_manager results. More specifically, I would like to figure out about different states of Bluetooth adapter by looking at the dumpsys output. For example, if bluetooth is enabled/disabled, if it is connectable/discoverable, if it is scanning, or if it is paired or bonded.

By looking at the dumpsys output, I can say that state: 12 under Bluetooth Status section should answer my questions. However, I am unable to interpret what state value means. For example, 12 means bluetooth_on or 10 means bluetooth_off.

I tried to look at the Android Bluetooth Adapter documentation to resolve this issue. However, not all the state values in dumpsys report matches constant values in Android documentation. I appreciate if someone can help me with this.

Below is an example of dumpsys result:

Bluetooth Status
  enabled: true
  state: 12
  address: 64:BC:0C:F9:3A:59
  name: Nexus 5X

Bonded devices:

Profile: BtGatt.GattService
  mAdvertisingServiceUuids:
  mMaxScanFilters: 0

GATT Client Map
  Entries: 0

GATT Server Map
  Entries: 0

GATT Handle Map
  Entries: 0
  Requests: 0

Profile: HeadsetService
  mCurrentDevice: null
  mTargetDevice: null
  mIncomingDevice: null
  mActiveScoDevice: null
  mMultiDisconnectDevice: null
  mVirtualCallStarted: false
  mVoiceRecognitionStarted: false
  mWaitingForVoiceRecognition: false
  StateMachine: HeadsetStateMachine:
 total records=4
 rec[0]: time=07-31 14:49:06.420 processed=Disconnected org=Disconnected dest=<null> what=10(0xa)
 rec[1]: time=07-31 14:49:06.420 processed=<null> org=Disconnected dest=<null> what=11(0xb)
 rec[2]: time=07-31 14:49:07.048 processed=Disconnected org=Disconnected dest=<null> what=10(0xa)
 rec[3]: time=07-31 14:49:37.126 processed=Disconnected org=Disconnected dest=<null> what=10(0xa)
curState=Disconnected

  mPhoneState: com.android.bluetooth.hfp.HeadsetPhoneState@14b5ce6
  mAudioState: 10

Profile: A2dpService
  mCurrentDevice: null
  mTargetDevice: null
  mIncomingDevice: null
  mPlayingA2dpDevice: null
  StateMachine: A2dpStateMachine:
 total records=0
curState=Disconnected

AVRCP:
  mMetadata: Metadata[artist=null trackTitle=null albumTitle=null]
  mTransportControlFlags: 0
  mCurrentPlayState: 0
  mPlayStatusChangedNT: 1
  mTrackChangedNT: 1
  mTrackNumber: -1
  mCurrentPosMs: 0
  mPlayStartTimeMs: -1
  mSongLengthMs: 0
  mPlaybackIntervalMs: 0
  mPlayPosChangedNT: 1
  mNextPosMs: 0
  mPrevPosMs: 0
  mSkipStartTime: 0
  mFeatures: 0
  mAbsoluteVolume: -1
  mLastSetVolume: -1
  mLastDirection: 0
  mVolumeStep: 8
  mAudioStreamMax: 15
  mVolCmdInProgress: false
  mAbsVolRetryTimes: 0
  mSkipAmount: 0

Profile: HidService
  mTargetDevice: null
  mInputDevices:

Profile: HealthService
  mHealthChannels:
  mApps:
  mHealthDevices:

Profile: PanService
  mMaxPanDevices: 5
  mPanIfName: bt-pan
  mTetherOn: false
  mPanDevices:
  mBluetoothIfaceAddresses:

Profile: BluetoothMapService
  mRemoteDevice: null
  sRemoteDeviceName: null
  mState: 0
  mAppObserver: com.android.bluetooth.map.BluetoothMapAppObserver@348d227
  mIsWaitingAuthorization: false
  mRemoveTimeoutMsg: false
  mPermission: 0
  mAccountChanged: false
  mBluetoothMnsObexClient: null
  mMasInstanceMap:
    null : MasId: 0 Uri:null SMS/MMS:true
  mEnabledAccounts:

Profile: SapService

Connection Events:
  None
Alex P.
  • 30,437
  • 17
  • 118
  • 169
Reyhan
  • 1
  • 1

1 Answers1

0

For open source projects looking at the source code is often even better than reading documentation:

public @interface AdapterState {}
/**
 * Indicates the local Bluetooth adapter is off.
 */
public static final int STATE_OFF = 10;
/**
 * Indicates the local Bluetooth adapter is turning on. However local
 * clients should wait for {@link #STATE_ON} before attempting to
 * use the adapter.
 */
public static final int STATE_TURNING_ON = 11;
/**
 * Indicates the local Bluetooth adapter is on, and ready for use.
 */
public static final int STATE_ON = 12;
/**
 * Indicates the local Bluetooth adapter is turning off. Local clients
 * should immediately attempt graceful disconnection of any remote links.
 */
public static final int STATE_TURNING_OFF = 13;
/**
 * Indicates the local Bluetooth adapter is turning Bluetooth LE mode on.
 *
 * @hide
 */
public static final int STATE_BLE_TURNING_ON = 14;
/**
 * Indicates the local Bluetooth adapter is in LE only mode.
 *
 * @hide
 */
public static final int STATE_BLE_ON = 15;
/**
 * Indicates the local Bluetooth adapter is turning off LE only mode.
 *
 * @hide
 */
public static final int STATE_BLE_TURNING_OFF = 16;
Alex P.
  • 30,437
  • 17
  • 118
  • 169