我正在尝试了解dumpsys bluetooth_manager
的结果。更具体地说,我想通过查看dumpsys输出来了解蓝牙适配器的不同状态。例如,如果蓝牙已启用/禁用,可连接/可发现,正在扫描,或者已配对或绑定,则为
通过查看dumpsys输出,我可以说state: 12
下的Bluetooth 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
答案 0 :(得分:0)
对于开放源代码项目,查看source code通常比阅读文档甚至更好:
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;