Fields Summary |
---|
private static final String | TAG |
private static final boolean | DBG |
public static final String | SINK_STATEint extra for SINK_STATE_CHANGED_ACTION |
public static final String | SINK_PREVIOUS_STATEint extra for SINK_STATE_CHANGED_ACTION |
public static final String | SINK_STATE_CHANGED_ACTIONIndicates the state of an A2DP audio sink has changed.
This intent will always contain SINK_STATE, SINK_PREVIOUS_STATE and
BluetoothIntent.ADDRESS extras. |
public static final int | STATE_DISCONNECTED |
public static final int | STATE_CONNECTING |
public static final int | STATE_CONNECTED |
public static final int | STATE_DISCONNECTING |
public static final int | STATE_PLAYINGPlaying implies connected |
public static final int | PRIORITY_AUTODefault priority for a2dp devices that should allow incoming
connections |
public static final int | PRIORITY_OFFDefault priority for a2dp devices that should not allow incoming
connections |
private final IBluetoothA2dp | mService |
private final android.content.Context | mContext |
Methods Summary |
---|
public int | connectSink(java.lang.String address)Initiate a connection to an A2DP sink.
Listen for SINK_STATE_CHANGED_ACTION to find out when the
connection is completed.
if (DBG) log("connectSink(" + address + ")");
try {
return mService.connectSink(address);
} catch (RemoteException e) {
Log.w(TAG, "", e);
return BluetoothError.ERROR_IPC;
}
|
public int | disconnectSink(java.lang.String address)Initiate disconnect from an A2DP sink.
Listen for SINK_STATE_CHANGED_ACTION to find out when
disconnect is completed.
if (DBG) log("disconnectSink(" + address + ")");
try {
return mService.disconnectSink(address);
} catch (RemoteException e) {
Log.w(TAG, "", e);
return BluetoothError.ERROR_IPC;
}
|
public static boolean | doesClassMatchSink(int btClass)Check class bits for possible A2DP Sink support.
This is a simple heuristic that tries to guess if a device with the
given class bits might be a A2DP Sink. It is not accurate for all
devices. It tries to err on the side of false positives.
if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) {
return true;
}
// By the A2DP spec, sinks must indicate the RENDER service.
// However we found some that do not (Chordette). So lets also
// match on some other class bits.
switch (BluetoothClass.Device.getDevice(btClass)) {
case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO:
case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES:
case BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER:
case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
return true;
default:
return false;
}
|
public int | getSinkPriority(java.lang.String address)Get priority of a2dp sink.
if (DBG) log("getSinkPriority(" + address + ")");
try {
return mService.getSinkPriority(address);
} catch (RemoteException e) {
Log.w(TAG, "", e);
return BluetoothError.ERROR_IPC;
}
|
public int | getSinkState(java.lang.String address)Get the state of an A2DP sink
if (DBG) log("getSinkState(" + address + ")");
try {
return mService.getSinkState(address);
} catch (RemoteException e) {
Log.w(TAG, "", e);
return BluetoothError.ERROR_IPC;
}
|
public boolean | isSinkConnected(java.lang.String address)Check if a specified A2DP sink is connected.
if (DBG) log("isSinkConnected(" + address + ")");
int state = getSinkState(address);
return state == STATE_CONNECTED || state == STATE_PLAYING;
|
public java.util.List | listConnectedSinks()Check if any A2DP sink is connected.
if (DBG) log("listConnectedSinks()");
try {
return mService.listConnectedSinks();
} catch (RemoteException e) {
Log.w(TAG, "", e);
return null;
}
|
private static void | log(java.lang.String msg)
Log.d(TAG, msg);
|
public int | setSinkPriority(java.lang.String address, int priority)Set priority of a2dp sink.
Priority is a non-negative integer. By default paired sinks will have
a priority of PRIORITY_AUTO, and unpaired headset PRIORITY_NONE (0).
Sinks with priority greater than zero will accept incoming connections
(if no sink is currently connected).
Priority for unpaired sink must be PRIORITY_NONE.
if (DBG) log("setSinkPriority(" + address + ", " + priority + ")");
try {
return mService.setSinkPriority(address, priority);
} catch (RemoteException e) {
Log.w(TAG, "", e);
return BluetoothError.ERROR_IPC;
}
|
public static java.lang.String | stateToString(int state)Helper for converting a state to a string.
For debug use only - strings are not internationalized.
switch (state) {
case STATE_DISCONNECTED:
return "disconnected";
case STATE_CONNECTING:
return "connecting";
case STATE_CONNECTED:
return "connected";
case STATE_DISCONNECTING:
return "disconnecting";
case STATE_PLAYING:
return "playing";
default:
return "<unknown state " + state + ">";
}
|