Add Bluetooth headset API to allow disabling audio route.

This functionality is required by devices which have multiple profiles
using the SCO channel. For example, a device that is both a HFP AG and HF.
In this case, we must explicitly notify the profiles when they can acquire
the channel as they are not aware of each other. A similar change was
previously added to the Bluetooth Headset Client profile.

Bug: 25485578
Change-Id: Ia60cfdd33c2c3c3f185464b24056f8ccb976056d
This commit is contained in:
Bryce Lee
2015-11-16 08:55:52 -08:00
parent e6538dcc06
commit 0db53d90a0
2 changed files with 44 additions and 0 deletions

View File

@@ -684,6 +684,48 @@ public final class BluetoothHeadset implements BluetoothProfile {
return BluetoothHeadset.STATE_AUDIO_DISCONNECTED;
}
/**
* Sets whether audio routing is allowed. When set to {@code false}, the AG will not route any
* audio to the HF unless explicitly told to.
* This method should be used in cases where the SCO channel is shared between multiple profiles
* and must be delegated by a source knowledgeable
* Note: This is an internal function and shouldn't be exposed
*
* @param allowed {@code true} if the profile can reroute audio, {@code false} otherwise.
*
* @hide
*/
public void setAudioRouteAllowed(boolean allowed) {
if (VDBG) log("setAudioRouteAllowed");
if (mService != null && isEnabled()) {
try {
mService.setAudioRouteAllowed(allowed);
} 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()));
}
}
/**
* Returns whether audio routing is allowed. see {@link #setAudioRouteAllowed(boolean)}.
* Note: This is an internal function and shouldn't be exposed
*
* @hide
*/
public boolean getAudioRouteAllowed() {
if (VDBG) log("getAudioRouteAllowed");
if (mService != null && isEnabled()) {
try {
return mService.getAudioRouteAllowed();
} 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 false;
}
/**
* Check if Bluetooth SCO audio is connected.
*

View File

@@ -50,6 +50,8 @@ interface IBluetoothHeadset {
boolean isAudioOn();
boolean connectAudio();
boolean disconnectAudio();
void setAudioRouteAllowed(boolean allowed);
boolean getAudioRouteAllowed();
boolean startScoUsingVirtualVoiceCall(in BluetoothDevice device);
boolean stopScoUsingVirtualVoiceCall(in BluetoothDevice device);
void phoneStateChanged(int numActive, int numHeld, int callState, String number, int type);