Add ability to set supported audio routes on phone accounts and connection

The set audio routes are used by Telecom to restrict where the audio may
be routed to. For example, an account can specify that calls may not be
routed over bluetooth headsets, which will prevent a new call from being
routed to this source.

This is a cherry-pick of abandoned ag/1521009.

Bug: 32958838
Change-Id: Idd5e4d38b157f11454f3d991385644f2f384596e
This commit is contained in:
Christine Hallstrom
2016-11-30 16:06:42 -08:00
committed by Hall Liu
parent fbeacb02c0
commit 2830ce9a09
7 changed files with 136 additions and 14 deletions

View File

@@ -697,6 +697,7 @@ public abstract class Connection extends Conferenceable {
public void onDestroyed(Connection c) {}
public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
public void onConnectionPropertiesChanged(Connection c, int properties) {}
public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
public void onVideoProviderChanged(
Connection c, VideoProvider videoProvider) {}
public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
@@ -1403,6 +1404,7 @@ public abstract class Connection extends Conferenceable {
private boolean mRingbackRequested = false;
private int mConnectionCapabilities;
private int mConnectionProperties;
private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
private VideoProvider mVideoProvider;
private boolean mAudioModeIsVoip;
private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
@@ -1682,6 +1684,15 @@ public abstract class Connection extends Conferenceable {
return mConnectionProperties;
}
/**
* Returns the connection's supported audio routes.
*
* @hide
*/
public final int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
/**
* Sets the value of the {@link #getAddress()} property.
*
@@ -1903,6 +1914,28 @@ public abstract class Connection extends Conferenceable {
}
}
/**
* Sets the supported audio routes.
*
* @param supportedAudioRoutes the supported audio routes as a bitmask.
* See {@link CallAudioState}
* @hide
*/
public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
if ((supportedAudioRoutes
& (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
throw new IllegalArgumentException(
"supported audio routes must include either speaker or earpiece");
}
if (mSupportedAudioRoutes != supportedAudioRoutes) {
mSupportedAudioRoutes = supportedAudioRoutes;
for (Listener l : mListeners) {
l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
}
}
}
/**
* Tears down the Connection object.
*/