Andorid Bluetooth State

1. BluetoothAdapter.java/BluetoothService.java
 
getState() local adapter state

public static final int STATE_OFF = 10;
public static final int STATE_TURNING_ON = 11;
public static final int STATE_ON = 12;
public static final int STATE_TURNING_OFF = 13;

getScanMode()
setScanMode(int mode, int duration)
/**
 * Indicates that both inquiry scan and page scan are disabled on the local
 * Bluetooth adapter. Therefore this device is neither discoverable
 * nor connectable from remote Bluetooth devices.
*/
public static final int SCAN_MODE_NONE = 20;
/**
 * Indicates that inquiry scan is disabled, but page scan is enabled on the
 * local Bluetooth adapter. Therefore this device is not discoverable from
 * remote Bluetooth devices, but is connectable from remote devices that
 * have previously discovered this device.
 */
public static final int SCAN_MODE_CONNECTABLE = 21;
/**
 * Indicates that both inquiry scan and page scan are enabled on the local
 * Bluetooth adapter. Therefore this device is both discoverable and
 * connectable from remote Bluetooth devices.
 */
public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE = 23;

getConnectionState()
getProfileConnectionState(int profile)
public static final int STATE_DISCONNECTED  = 0;
public static final int STATE_CONNECTING    = 1;
public static final int STATE_CONNECTED     = 2;
public static final int STATE_DISCONNECTING = 3

2. BluetoothDevice.java

getBondState()
public static final int BOND_NONE = 10;
public static final int BOND_BONDING = 11;
public static final int BOND_BONDED = 12;

 

3.  BluetoothProfile.java/BluetoothAdapter.java
public static final int STATE_DISCONNECTED  = 0;
public static final int STATE_CONNECTING    = 1;
public static final int STATE_CONNECTED     = 2;
public static final int STATE_DISCONNECTING = 3

4. BluetoothA2dp.java/BluetoothA2dpService.java

playStatus & play state

private final static int STATUS_STOPPED = 0X00;
private final static int STATUS_PLAYING = 0X01;
private final static int STATUS_PAUSED = 0X02;
private final static int STATUS_FWD_SEEK = 0X03;
private final static int STATUS_REV_SEEK = 0X04;
private final static int STATUS_ERROR = 0XFF;

D/BluetoothA2dpService(  556): uri is content://media/external/audio/media/65mUri is content://media/external/audio/media/65
D/BluetoothA2dpService(  556): PlaySatus is 3
D/BluetoothA2dpService(  556): sendEvent /org/bluez/745/hci0/dev_**_**_**_**_**_** data 3
D/BluetoothA2dpService(  556): Metadata received
D/BluetoothA2dpService(  556): Duration 282624
D/BluetoothA2dpService(  556): playstate is 3 

 

A2DP Playing state

public static final int STATE_PLAYING   =  10;
public static final int STATE_NOT_PLAYING   =  11
(below from  BluetoothProfile.java/BluetoothAdapter.java)
public static final int STATE_DISCONNECTED  = 0;
public static final int STATE_CONNECTING    = 1;
public static final int STATE_CONNECTED     = 2;
public static final int STATE_DISCONNECTING = 3

D/BluetoothA2dpService(  638): A2DP: onSinkPropertyChanged newState is: 2mPlayingA2dpDevice: **:**:**:**:**:**
D/BluetoothA2dpService(  638): handleSinkPlayingStateChange STATE_PLAYING->STATE_NOT_PLAYING mPlayingA2dpDevice = null
I/BluetoothService(  638): Received ACTION_PLAYING_STATE_CHANGED
D/BluetoothService(  638): setA2dpAudioActive(): false
D/BluetoothA2dpService(  638): A2DP Playing state : device: **:**:**:**:**:** State:10->11

 

5. BluetoothHeadset.java

STATE_AUDIO_DISCONNECTED = 10
STATE_AUDIO_CONNECTING = 11
STATE_AUDIO_CONNECTED = 12
D/BT HS/HF(  683): audioOn()
D/BT HS/HF(  683): setAudioState(11)STATE_AUDIO_CONNECTING
D/BT HSHFP(  696): AudioStateIntent: 30:17:C8:8D:5A:D5 State: 11 PrevState: 10
E/BT HS/HF(  683): ScoThread.start
D/AudioHardwareInterface(  159): setMode(IN_CALL)
D/SemcInCallScreen(  696):   - phone state = OFFHOOK
E/BT HS/HF(  696): ScoThread.start
I/AudioService(  351):  AudioFocus  requestAudioFocus() from AudioFocus_For_Phone_Ring_And_Calls
D/BT HS/HF(  683): Routing audio for outgoing SCO conection
D/AudioPolicyManager(  159): setForceUse() usage 0, config 3, mPhoneState 2
D/BT HS/HF(  683): setAudioState(12) STATE_AUDIO_CONNECTED
D/BT HSHFP(  696): AudioStateIntent: 30:17:C8:8D:5A:D5 State: 12 PrevState: 11

6. BluetoothAdapterStateMachine.java

/**
 * Bluetooth Adapter StateMachine
 * All the states are at the same level, ie, no hierarchy.
 *                         (BluetootOn)<----------------------<-
 *                           |    ^    -------------------->-  |
 *                           |    |                         |  |
 *                 TURN_OFF  |    | SCAN_MODE_CHANGED    m1 |  | USER_TURN_ON
 *         AIRPLANE_MODE_ON  |    |                         |  |
 *                           V    |                         |  |
 *                         (Switching)                   (PerProcessState)
 *                           |    ^                         |  |
 *     POWER_STATE_CHANGED & |    | TURN_ON(_CONTINUE)      |  |
 * ALL_DEVICES_DISCONNECTED  |    |                     m2  |  |
 *                           V    |------------------------<   | SCAN_MODE_CHANGED
 *                          (HotOff)-------------------------->- PER_PROCESS_TURN_ON
 *                           /    ^
 *                          /     |  POWER_STATE_CHANGED
 *                         |      |
 *              TURN_COLD  |   (Warmup)
 *                         |      ^
 *                         |      |  SERVICE_RECORD_LOADED
 *                         |      |
 *                         | (PreWarmUp)
 *                         \      ^
 *                          \     |  TURN_HOT/TURN_ON
 *                           |    |  AIRPLANE_MODE_OFF(when Bluetooth was on before)
 *                           V    |
 *                           (PowerOff)   <----- initial state

你可能感兴趣的:(android,BlueTooth,st)