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

am: d11261dcc9

Change-Id: I002d1d32e6c0fb69c99047a19ca07f4326ec5323
This commit is contained in:
Hall Liu
2016-12-14 20:03:54 +00:00
committed by android-build-merger
7 changed files with 136 additions and 14 deletions

View File

@ -324,6 +324,7 @@ public final class Call {
private final PhoneAccountHandle mAccountHandle; private final PhoneAccountHandle mAccountHandle;
private final int mCallCapabilities; private final int mCallCapabilities;
private final int mCallProperties; private final int mCallProperties;
private final int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
private final DisconnectCause mDisconnectCause; private final DisconnectCause mDisconnectCause;
private final long mConnectTimeMillis; private final long mConnectTimeMillis;
private final GatewayInfo mGatewayInfo; private final GatewayInfo mGatewayInfo;
@ -535,6 +536,15 @@ public final class Call {
return mCallProperties; return mCallProperties;
} }
/**
* @return a bitmask of the audio routes available for the call.
*
* @hide
*/
public int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
/** /**
* @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed * @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed
* by {@link android.telecom.DisconnectCause}. * by {@link android.telecom.DisconnectCause}.

View File

@ -44,8 +44,12 @@ public final class CallAudioState implements Parcelable {
*/ */
public static final int ROUTE_WIRED_OR_EARPIECE = ROUTE_EARPIECE | ROUTE_WIRED_HEADSET; public static final int ROUTE_WIRED_OR_EARPIECE = ROUTE_EARPIECE | ROUTE_WIRED_HEADSET;
/** Bit mask of all possible audio routes. */ /**
private static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET | * Bit mask of all possible audio routes.
*
* @hide
**/
public static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET |
ROUTE_SPEAKER; ROUTE_SPEAKER;
private final boolean isMuted; private final boolean isMuted;

View File

@ -697,6 +697,7 @@ public abstract class Connection extends Conferenceable {
public void onDestroyed(Connection c) {} public void onDestroyed(Connection c) {}
public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {} public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
public void onConnectionPropertiesChanged(Connection c, int properties) {} public void onConnectionPropertiesChanged(Connection c, int properties) {}
public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
public void onVideoProviderChanged( public void onVideoProviderChanged(
Connection c, VideoProvider videoProvider) {} Connection c, VideoProvider videoProvider) {}
public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
@ -1403,6 +1404,7 @@ public abstract class Connection extends Conferenceable {
private boolean mRingbackRequested = false; private boolean mRingbackRequested = false;
private int mConnectionCapabilities; private int mConnectionCapabilities;
private int mConnectionProperties; private int mConnectionProperties;
private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
private VideoProvider mVideoProvider; private VideoProvider mVideoProvider;
private boolean mAudioModeIsVoip; private boolean mAudioModeIsVoip;
private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
@ -1682,6 +1684,15 @@ public abstract class Connection extends Conferenceable {
return mConnectionProperties; return mConnectionProperties;
} }
/**
* Returns the connection's supported audio routes.
*
* @hide
*/
public final int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
/** /**
* Sets the value of the {@link #getAddress()} property. * 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. * Tears down the Connection object.
*/ */

View File

@ -1131,6 +1131,7 @@ public abstract class ConnectionService extends Service {
connection.getState(), connection.getState(),
connection.getConnectionCapabilities(), connection.getConnectionCapabilities(),
connection.getConnectionProperties(), connection.getConnectionProperties(),
connection.getSupportedAudioRoutes(),
connection.getAddress(), connection.getAddress(),
connection.getAddressPresentation(), connection.getAddressPresentation(),
connection.getCallerDisplayName(), connection.getCallerDisplayName(),
@ -1530,6 +1531,7 @@ public abstract class ConnectionService extends Service {
connection.getState(), connection.getState(),
connection.getConnectionCapabilities(), connection.getConnectionCapabilities(),
connection.getConnectionProperties(), connection.getConnectionProperties(),
connection.getSupportedAudioRoutes(),
connection.getAddress(), connection.getAddress(),
connection.getAddressPresentation(), connection.getAddressPresentation(),
connection.getCallerDisplayName(), connection.getCallerDisplayName(),

View File

@ -39,6 +39,7 @@ public final class ParcelableCall implements Parcelable {
private final List<String> mCannedSmsResponses; private final List<String> mCannedSmsResponses;
private final int mCapabilities; private final int mCapabilities;
private final int mProperties; private final int mProperties;
private final int mSupportedAudioRoutes;
private final long mConnectTimeMillis; private final long mConnectTimeMillis;
private final Uri mHandle; private final Uri mHandle;
private final int mHandlePresentation; private final int mHandlePresentation;
@ -64,6 +65,7 @@ public final class ParcelableCall implements Parcelable {
List<String> cannedSmsResponses, List<String> cannedSmsResponses,
int capabilities, int capabilities,
int properties, int properties,
int supportedAudioRoutes,
long connectTimeMillis, long connectTimeMillis,
Uri handle, Uri handle,
int handlePresentation, int handlePresentation,
@ -86,6 +88,7 @@ public final class ParcelableCall implements Parcelable {
mCannedSmsResponses = cannedSmsResponses; mCannedSmsResponses = cannedSmsResponses;
mCapabilities = capabilities; mCapabilities = capabilities;
mProperties = properties; mProperties = properties;
mSupportedAudioRoutes = supportedAudioRoutes;
mConnectTimeMillis = connectTimeMillis; mConnectTimeMillis = connectTimeMillis;
mHandle = handle; mHandle = handle;
mHandlePresentation = handlePresentation; mHandlePresentation = handlePresentation;
@ -137,6 +140,11 @@ public final class ParcelableCall implements Parcelable {
/** Bitmask of properties of the call. */ /** Bitmask of properties of the call. */
public int getProperties() { return mProperties; } public int getProperties() { return mProperties; }
/** Bitmask of supported routes of the call */
public int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
/** The time that the call switched to the active state. */ /** The time that the call switched to the active state. */
public long getConnectTimeMillis() { public long getConnectTimeMillis() {
return mConnectTimeMillis; return mConnectTimeMillis;
@ -292,6 +300,7 @@ public final class ParcelableCall implements Parcelable {
source.readList(conferenceableCallIds, classLoader); source.readList(conferenceableCallIds, classLoader);
Bundle intentExtras = source.readBundle(classLoader); Bundle intentExtras = source.readBundle(classLoader);
Bundle extras = source.readBundle(classLoader); Bundle extras = source.readBundle(classLoader);
int supportedAudioRoutes = source.readInt();
return new ParcelableCall( return new ParcelableCall(
id, id,
state, state,
@ -299,6 +308,7 @@ public final class ParcelableCall implements Parcelable {
cannedSmsResponses, cannedSmsResponses,
capabilities, capabilities,
properties, properties,
supportedAudioRoutes,
connectTimeMillis, connectTimeMillis,
handle, handle,
handlePresentation, handlePresentation,
@ -355,6 +365,7 @@ public final class ParcelableCall implements Parcelable {
destination.writeList(mConferenceableCallIds); destination.writeList(mConferenceableCallIds);
destination.writeBundle(mIntentExtras); destination.writeBundle(mIntentExtras);
destination.writeBundle(mExtras); destination.writeBundle(mExtras);
destination.writeInt(mSupportedAudioRoutes);
} }
@Override @Override

View File

@ -37,6 +37,7 @@ public final class ParcelableConnection implements Parcelable {
private final int mState; private final int mState;
private final int mConnectionCapabilities; private final int mConnectionCapabilities;
private final int mConnectionProperties; private final int mConnectionProperties;
private final int mSupportedAudioRoutes;
private final Uri mAddress; private final Uri mAddress;
private final int mAddressPresentation; private final int mAddressPresentation;
private final String mCallerDisplayName; private final String mCallerDisplayName;
@ -57,6 +58,7 @@ public final class ParcelableConnection implements Parcelable {
int state, int state,
int capabilities, int capabilities,
int properties, int properties,
int supportedAudioRoutes,
Uri address, Uri address,
int addressPresentation, int addressPresentation,
String callerDisplayName, String callerDisplayName,
@ -74,6 +76,7 @@ public final class ParcelableConnection implements Parcelable {
mState = state; mState = state;
mConnectionCapabilities = capabilities; mConnectionCapabilities = capabilities;
mConnectionProperties = properties; mConnectionProperties = properties;
mSupportedAudioRoutes = supportedAudioRoutes;
mAddress = address; mAddress = address;
mAddressPresentation = addressPresentation; mAddressPresentation = addressPresentation;
mCallerDisplayName = callerDisplayName; mCallerDisplayName = callerDisplayName;
@ -117,6 +120,10 @@ public final class ParcelableConnection implements Parcelable {
return mConnectionProperties; return mConnectionProperties;
} }
public int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
public Uri getHandle() { public Uri getHandle() {
return mAddress; return mAddress;
} }
@ -210,12 +217,14 @@ public final class ParcelableConnection implements Parcelable {
source.readStringList(conferenceableConnectionIds); source.readStringList(conferenceableConnectionIds);
Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true); Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
int properties = source.readInt(); int properties = source.readInt();
int supportedAudioRoutes = source.readInt();
return new ParcelableConnection( return new ParcelableConnection(
phoneAccount, phoneAccount,
state, state,
capabilities, capabilities,
properties, properties,
supportedAudioRoutes,
address, address,
addressPresentation, addressPresentation,
callerDisplayName, callerDisplayName,
@ -264,5 +273,6 @@ public final class ParcelableConnection implements Parcelable {
destination.writeStringList(mConferenceableConnectionIds); destination.writeStringList(mConferenceableConnectionIds);
destination.writeBundle(mExtras); destination.writeBundle(mExtras);
destination.writeInt(mConnectionProperties); destination.writeInt(mConnectionProperties);
destination.writeInt(mSupportedAudioRoutes);
} }
} }

View File

@ -17,15 +17,6 @@
package android.telecom; package android.telecom;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources.NotFoundException;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon; import android.graphics.drawable.Icon;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -37,7 +28,6 @@ import java.lang.String;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.MissingResourceException;
/** /**
* Represents a distinct method to place or receive a phone call. Apps which can place calls and * Represents a distinct method to place or receive a phone call. Apps which can place calls and
@ -237,6 +227,7 @@ public final class PhoneAccount implements Parcelable {
private final CharSequence mLabel; private final CharSequence mLabel;
private final CharSequence mShortDescription; private final CharSequence mShortDescription;
private final List<String> mSupportedUriSchemes; private final List<String> mSupportedUriSchemes;
private final int mSupportedAudioRoutes;
private final Icon mIcon; private final Icon mIcon;
private final Bundle mExtras; private final Bundle mExtras;
private boolean mIsEnabled; private boolean mIsEnabled;
@ -246,10 +237,12 @@ public final class PhoneAccount implements Parcelable {
* Helper class for creating a {@link PhoneAccount}. * Helper class for creating a {@link PhoneAccount}.
*/ */
public static class Builder { public static class Builder {
private PhoneAccountHandle mAccountHandle; private PhoneAccountHandle mAccountHandle;
private Uri mAddress; private Uri mAddress;
private Uri mSubscriptionAddress; private Uri mSubscriptionAddress;
private int mCapabilities; private int mCapabilities;
private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
private int mHighlightColor = NO_HIGHLIGHT_COLOR; private int mHighlightColor = NO_HIGHLIGHT_COLOR;
private CharSequence mLabel; private CharSequence mLabel;
private CharSequence mShortDescription; private CharSequence mShortDescription;
@ -286,6 +279,7 @@ public final class PhoneAccount implements Parcelable {
mIsEnabled = phoneAccount.isEnabled(); mIsEnabled = phoneAccount.isEnabled();
mExtras = phoneAccount.getExtras(); mExtras = phoneAccount.getExtras();
mGroupId = phoneAccount.getGroupId(); mGroupId = phoneAccount.getGroupId();
mSupportedAudioRoutes = phoneAccount.getSupportedAudioRoutes();
} }
/** /**
@ -430,6 +424,18 @@ public final class PhoneAccount implements Parcelable {
return this; return this;
} }
/**
* Sets the audio routes supported by this {@link PhoneAccount}.
*
* @param routes bit mask of available routes.
* @return The builder.
* @hide
*/
public Builder setSupportedAudioRoutes(int routes) {
mSupportedAudioRoutes = routes;
return this;
}
/** /**
* Creates an instance of a {@link PhoneAccount} based on the current builder settings. * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
* *
@ -452,6 +458,7 @@ public final class PhoneAccount implements Parcelable {
mShortDescription, mShortDescription,
mSupportedUriSchemes, mSupportedUriSchemes,
mExtras, mExtras,
mSupportedAudioRoutes,
mIsEnabled, mIsEnabled,
mGroupId); mGroupId);
} }
@ -468,6 +475,7 @@ public final class PhoneAccount implements Parcelable {
CharSequence shortDescription, CharSequence shortDescription,
List<String> supportedUriSchemes, List<String> supportedUriSchemes,
Bundle extras, Bundle extras,
int supportedAudioRoutes,
boolean isEnabled, boolean isEnabled,
String groupId) { String groupId) {
mAccountHandle = account; mAccountHandle = account;
@ -480,6 +488,7 @@ public final class PhoneAccount implements Parcelable {
mShortDescription = shortDescription; mShortDescription = shortDescription;
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes); mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
mExtras = extras; mExtras = extras;
mSupportedAudioRoutes = supportedAudioRoutes;
mIsEnabled = isEnabled; mIsEnabled = isEnabled;
mGroupId = groupId; mGroupId = groupId;
} }
@ -552,6 +561,17 @@ public final class PhoneAccount implements Parcelable {
return (mCapabilities & capability) == capability; return (mCapabilities & capability) == capability;
} }
/**
* Determines if this {@code PhoneAccount} has routes specified by the passed in bit mask.
*
* @param route The routes to check.
* @return {@code true} if the phone account has the routes.
* @hide
*/
public boolean hasAudioRoutes(int routes) {
return (mSupportedAudioRoutes & routes) == routes;
}
/** /**
* A short label describing a {@code PhoneAccount}. * A short label describing a {@code PhoneAccount}.
* *
@ -591,6 +611,15 @@ public final class PhoneAccount implements Parcelable {
return mExtras; return mExtras;
} }
/**
* The audio routes supported by this {@code PhoneAccount}.
*
* @hide
*/
public int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
/** /**
* The icon to represent this {@code PhoneAccount}. * The icon to represent this {@code PhoneAccount}.
* *
@ -707,6 +736,7 @@ public final class PhoneAccount implements Parcelable {
out.writeByte((byte) (mIsEnabled ? 1 : 0)); out.writeByte((byte) (mIsEnabled ? 1 : 0));
out.writeBundle(mExtras); out.writeBundle(mExtras);
out.writeString(mGroupId); out.writeString(mGroupId);
out.writeInt(mSupportedAudioRoutes);
} }
public static final Creator<PhoneAccount> CREATOR public static final Creator<PhoneAccount> CREATOR
@ -751,6 +781,7 @@ public final class PhoneAccount implements Parcelable {
mIsEnabled = in.readByte() == 1; mIsEnabled = in.readByte() == 1;
mExtras = in.readBundle(); mExtras = in.readBundle();
mGroupId = in.readString(); mGroupId = in.readString();
mSupportedAudioRoutes = in.readInt();
} }
@Override @Override
@ -760,7 +791,9 @@ public final class PhoneAccount implements Parcelable {
.append("] PhoneAccount: ") .append("] PhoneAccount: ")
.append(mAccountHandle) .append(mAccountHandle)
.append(" Capabilities: ") .append(" Capabilities: ")
.append(capabilitiesToString(mCapabilities)) .append(capabilitiesToString())
.append(" Audio Routes: ")
.append(audioRoutesToString())
.append(" Schemes: "); .append(" Schemes: ");
for (String scheme : mSupportedUriSchemes) { for (String scheme : mSupportedUriSchemes) {
sb.append(scheme) sb.append(scheme)
@ -780,7 +813,7 @@ public final class PhoneAccount implements Parcelable {
* @param capabilities The capabilities bitmask. * @param capabilities The capabilities bitmask.
* @return String representation of the capabilities bitmask. * @return String representation of the capabilities bitmask.
*/ */
private String capabilitiesToString(int capabilities) { private String capabilitiesToString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) { if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) {
sb.append("SuppVideo "); sb.append("SuppVideo ");
@ -817,4 +850,23 @@ public final class PhoneAccount implements Parcelable {
} }
return sb.toString(); return sb.toString();
} }
private String audioRoutesToString() {
StringBuilder sb = new StringBuilder();
if (hasAudioRoutes(CallAudioState.ROUTE_BLUETOOTH)) {
sb.append("B");
}
if (hasAudioRoutes(CallAudioState.ROUTE_EARPIECE)) {
sb.append("E");
}
if (hasAudioRoutes(CallAudioState.ROUTE_SPEAKER)) {
sb.append("S");
}
if (hasAudioRoutes(CallAudioState.ROUTE_WIRED_HEADSET)) {
sb.append("W");
}
return sb.toString();
}
} }