Skip to content

Commit c4f4b0f

Browse files
Eric LaurentAndroid (Google) Code Review
authored andcommitted
Merge "AudioManager: back to old setBluetoothA2dpOn()" into jb-dev
2 parents 2075f2d + 242b338 commit c4f4b0f

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

media/java/android/media/AudioManager.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,42 +1271,25 @@ public boolean isBluetoothScoOn() {
12711271
}
12721272

12731273
/**
1274-
* Allow or disallow use of Bluetooth A2DP for media.
1275-
* <p>The default behavior of the system is to use A2DP for media playback whenever an A2DP sink
1276-
* is connected. Applications can use this method to override this behavior.
1277-
* Note that the request will not persist after a wired headset or an A2DP sink is connected or
1278-
* disconnected:
1279-
* - Connection of an A2DP sink automatically enables use of A2DP.
1280-
* - Connection of a wired headset automatically disables use of A2DP.
1281-
* - Disconnection of a wired headset automatically enables use of A2DP if an A2DP sink is
1282-
* connected.
1283-
* <p>Requires Permission:
1284-
* {@link android.Manifest.permission#MODIFY_AUDIO_SETTINGS}.
1285-
* @param on set <var>true</var> to allow use of A2DP for media (default).
1286-
* <var>false</var> to disallow use of A2DP for media.
1274+
* @param on set <var>true</var> to route A2DP audio to/from Bluetooth
1275+
* headset; <var>false</var> disable A2DP audio
12871276
* @deprecated Do not use.
12881277
*/
12891278
@Deprecated public void setBluetoothA2dpOn(boolean on){
1290-
IAudioService service = getService();
1291-
try {
1292-
service.setBluetoothA2dpOn(on);
1293-
} catch (RemoteException e) {
1294-
Log.e(TAG, "Dead object in setBluetoothA2dpOn", e);
1295-
}
12961279
}
12971280

12981281
/**
1299-
* Checks whether use of A2DP sinks is enabled for media.
1282+
* Checks whether A2DP audio routing to the Bluetooth headset is on or off.
13001283
*
1301-
* @return true if use of A2DP is enabled for media, false otherwise.
1284+
* @return true if A2DP audio is being routed to/from Bluetooth headset;
1285+
* false if otherwise
13021286
*/
13031287
public boolean isBluetoothA2dpOn() {
1304-
IAudioService service = getService();
1305-
try {
1306-
return service.isBluetoothA2dpOn();
1307-
} catch (RemoteException e) {
1308-
Log.e(TAG, "Dead object in isBluetoothA2dpOn", e);
1288+
if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_BLUETOOTH_A2DP,"")
1289+
== AudioSystem.DEVICE_STATE_UNAVAILABLE) {
13091290
return false;
1291+
} else {
1292+
return true;
13101293
}
13111294
}
13121295

0 commit comments

Comments
 (0)