0

我试图理解dumpsys bluetooth_manager结果。更具体地说,我想通过查看 dumpsys 输出来了解蓝牙适配器的不同状态。例如,如果蓝牙启用/禁用,是否可连接/可发现,是否正在扫描,或者是否已配对或绑定。

通过查看 dumpsys 输出,我可以说state: 12Bluetooth Status部分应该回答我的问题。但是,我无法解释状态值的含义。例如,12表示 bluetooth_on 或10表示 bluetooth_off。

我尝试查看 Android 蓝牙适配器文档来解决此问题。但是,并非 dumpsys 报告中的所有状态值都与 Android 文档中的常量值匹配。如果有人可以帮助我,我将不胜感激。

以下是 dumpsys 结果的示例:

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
4

1 回答 1

0

对于开源项目,查看源代码通常比阅读文档更好:

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;
于 2019-08-19T17:09:25.730 回答