summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/bluetooth/BluetoothHeadset.java36
-rw-r--r--core/java/android/bluetooth/IBluetoothHeadset.aidl1
-rw-r--r--media/java/android/media/AudioService.java4
3 files changed, 37 insertions, 4 deletions
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java
index c72be6b..c03b444 100644
--- a/core/java/android/bluetooth/BluetoothHeadset.java
+++ b/core/java/android/bluetooth/BluetoothHeadset.java
@@ -183,7 +183,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
public static final String VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY =
"android.bluetooth.headset.intent.category.companyid";
- /*
+ /**
* Headset state when SCO audio is connected
* This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
@@ -192,13 +192,21 @@ public final class BluetoothHeadset implements BluetoothProfile {
public static final int STATE_AUDIO_CONNECTED = 10;
/**
- * Headset state when SCO audio is NOT connected
+ * Headset state when SCO audio is connecting
* This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
* {@link #ACTION_AUDIO_STATE_CHANGED} intent.
+ * @hide
*/
- public static final int STATE_AUDIO_DISCONNECTED = 11;
+ public static final int STATE_AUDIO_CONNECTING = 12;
+ /**
+ * Headset state when SCO audio is not connected
+ * This state can be one of
+ * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
+ * {@link #ACTION_AUDIO_STATE_CHANGED} intent.
+ */
+ public static final int STATE_AUDIO_DISCONNECTED = 11;
private Context mContext;
private ServiceListener mServiceListener;
@@ -370,7 +378,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p> Users can listen to {@link #ACTION_AUDIO_STATE_CHANGED}.
* {@link #EXTRA_STATE} will be set to {@link #STATE_AUDIO_CONNECTED}
- * when the audio connection is established.
+ * when the audio connection is established,
+ * and to {@link #STATE_AUDIO_DISCONNECTED} in case of failure.
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*
@@ -593,6 +602,25 @@ public final class BluetoothHeadset implements BluetoothProfile {
return false;
}
+ /**
+ * Get the current audio state of the Headset.
+ * Note: This is an internal function and shouldn't be exposed
+ *
+ * @hide
+ */
+ public int getAudioState(BluetoothDevice device) {
+ if (DBG) log("getAudioState");
+ if (mService != null && isEnabled()) {
+ try {
+ return mService.getAudioState(device);
+ } catch (RemoteException e) {Log.e(TAG, e.toString());}
+ } else {
+ Log.w(TAG, "Proxy not attached to service");
+ if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
+ }
+ return BluetoothHeadset.STATE_AUDIO_DISCONNECTED;
+ }
+
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
if (DBG) Log.d(TAG, "Proxy object connected");
diff --git a/core/java/android/bluetooth/IBluetoothHeadset.aidl b/core/java/android/bluetooth/IBluetoothHeadset.aidl
index 3e4c7b4..ab07931 100644
--- a/core/java/android/bluetooth/IBluetoothHeadset.aidl
+++ b/core/java/android/bluetooth/IBluetoothHeadset.aidl
@@ -46,4 +46,5 @@ interface IBluetoothHeadset {
boolean connectHeadsetInternal(in BluetoothDevice device);
boolean disconnectHeadsetInternal(in BluetoothDevice device);
boolean setAudioState(in BluetoothDevice device, int state);
+ int getAudioState(in BluetoothDevice device);
}
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index a49bb37..a64158f 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1973,6 +1973,10 @@ public class AudioService extends IAudioService.Stub {
case BluetoothHeadset.STATE_AUDIO_DISCONNECTED:
state = AudioManager.SCO_AUDIO_STATE_DISCONNECTED;
break;
+ case BluetoothHeadset.STATE_AUDIO_CONNECTING:
+ // Todo(): Handle this, ignore for now as a public
+ // API will break.
+ break;
default:
state = AudioManager.SCO_AUDIO_STATE_ERROR;
break;