diff options
Diffstat (limited to 'telecomm/java/android')
8 files changed, 218 insertions, 87 deletions
diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java index 130364f..c050f30 100644 --- a/telecomm/java/android/telecomm/Connection.java +++ b/telecomm/java/android/telecomm/Connection.java @@ -37,6 +37,7 @@ public abstract class Connection { public void onHandleChanged(Connection c, Uri newHandle, int presentation) {} public void onCallerDisplayNameChanged( Connection c, String callerDisplayName, int presentation) {} + public void onVideoStateChanged(Connection c, int videoState) {} public void onSignalChanged(Connection c, Bundle details) {} public void onDisconnected(Connection c, int cause, String message) {} public void onPostDialWait(Connection c, String remaining) {} @@ -75,6 +76,7 @@ public abstract class Connection { private CallVideoProvider mCallVideoProvider; private boolean mAudioModeIsVoip; private StatusHints mStatusHints; + private int mVideoState; /** * Create a new Connection. @@ -118,6 +120,19 @@ public abstract class Connection { } /** + * Returns the video state of the call. + * Valid values: {@link android.telecomm.VideoCallProfile#VIDEO_STATE_AUDIO_ONLY}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_BIDIRECTIONAL}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_TX_ENABLED}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_RX_ENABLED}. + * + * @return The video state of the call. + */ + public final int getVideoState() { + return mVideoState; + } + + /** * @return The audio state of the call, describing how its audio is currently * being routed by the system. This is {@code null} if this Connection * does not directly know about its audio state. @@ -285,6 +300,23 @@ public abstract class Connection { } /** + * Set the video state for the connection. + * Valid values: {@link android.telecomm.VideoCallProfile#VIDEO_STATE_AUDIO_ONLY}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_BIDIRECTIONAL}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_TX_ENABLED}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_RX_ENABLED}. + * + * @param videoState The new video state. + */ + public final void setVideoState(int videoState) { + Log.d(this, "setVideoState %d", videoState); + mVideoState = videoState; + for (Listener l : mListeners) { + l.onVideoStateChanged(this, mVideoState); + } + } + + /** * Sets state to active (e.g., an ongoing call where two or more parties can actively * communicate). */ diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java index 5855470..9e04c6e 100644 --- a/telecomm/java/android/telecomm/ConnectionService.java +++ b/telecomm/java/android/telecomm/ConnectionService.java @@ -324,6 +324,13 @@ public abstract class ConnectionService extends Service { } @Override + public void onVideoStateChanged(Connection c, int videoState) { + String id = mIdByConnection.get(c); + Log.d(this, "Adapter set video state %d", videoState); + mAdapter.setVideoState(id, videoState); + } + + @Override public void onHandleChanged(Connection c, Uri handle, int presentation) { String id = mIdByConnection.get(c); mAdapter.setHandle(id, handle, presentation); diff --git a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java index a812fa4..63546d3 100644 --- a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java +++ b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java @@ -323,4 +323,25 @@ final class ConnectionServiceAdapter implements DeathRecipient { } } } + + /** + * Sets the video state associated with a call. + * + * Valid values: {@link android.telecomm.VideoCallProfile#VIDEO_STATE_AUDIO_ONLY}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_BIDIRECTIONAL}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_TX_ENABLED}, + * {@link android.telecomm.VideoCallProfile#VIDEO_STATE_RX_ENABLED}. + * + * @param callId The unique ID of the call to set the video state for. + * @param videoState The video state. + */ + void setVideoState(String callId, int videoState) { + Log.v(this, "setVideoState: %d", videoState); + for (IConnectionServiceAdapter adapter : mAdapters) { + try { + adapter.setVideoState(callId, videoState); + } catch (RemoteException ignored) { + } + } + } } diff --git a/telecomm/java/android/telecomm/PhoneAccount.java b/telecomm/java/android/telecomm/PhoneAccount.java index b246d92..bb335c3 100644 --- a/telecomm/java/android/telecomm/PhoneAccount.java +++ b/telecomm/java/android/telecomm/PhoneAccount.java @@ -16,8 +16,10 @@ package android.telecomm; +import org.json.JSONException; +import org.json.JSONObject; + import android.content.ComponentName; -import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -26,55 +28,27 @@ import java.util.Objects; /** * Represents a distinct account, line of service or call placement method that * the system can use to place phone calls. + * + * TODO: Per feedback from API Council, rename to "PhoneAccountHandle". See also comment on class + * PhoneAccountMetadata. */ public class PhoneAccount implements Parcelable { - - /** - * Flag indicating that this {@code PhoneAccount} can act as a call manager for traditional - * SIM-based telephony calls. The {@link ConnectionService} associated with this phone-account - * will be allowed to manage SIM-based phone calls including using its own proprietary - * phone-call implementation (like VoIP calling) to make calls instead of the telephony stack. - * When a user opts to place a call using the SIM-based telephony stack, the connection-service - * associated with this phone-account will be attempted first if the user has explicitly - * selected it to be used as the default call-manager. - * <p> - * See {@link #getCapabilities} - */ - public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1; - - /** - * Flag indicating that this {@code PhoneAccount} can make phone calls in place of traditional - * SIM-based telephony calls. This account will be treated as a distinct method for placing - * calls alongside the traditional SIM-based telephony stack. This flag is distinct from - * {@link #CAPABILITY_SIM_CALL_MANAGER} in that it is not allowed to manage calls from or use - * the built-in telephony stack to place its calls. - * <p> - * See {@link #getCapabilities} - */ - public static final int CAPABILITY_CALL_PROVIDER = 0x2; - /** - * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM subscription. + * Flag indicating that this {@code PhoneAccount} represents built-in PSTN SIM subscription. * <p> - * Only the android framework can set this capability on a phone-account. + * Only the android framework can set this capability on a phone account. */ public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4; private ComponentName mComponentName; private String mId; - private Uri mHandle; - private int mCapabilities; public PhoneAccount( ComponentName componentName, - String id, - Uri handle, - int capabilities) { + String id) { mComponentName = componentName; mId = id; - mHandle = handle; - mCapabilities = capabilities; } /** @@ -97,31 +71,9 @@ public class PhoneAccount implements Parcelable { return mId; } - /** - * The handle (e.g., a phone number) associated with this {@code PhoneAccount}. This represents - * the destination from which outgoing calls using this {@code PhoneAccount} will appear to - * come, if applicable, and the destination to which incoming calls using this - * {@code PhoneAccount} may be addressed. - * - * @return A handle expressed as a {@code Uri}, for example, a phone number. - */ - public Uri getHandle() { - return mHandle; - } - - /** - * The capabilities of this {@code PhoneAccount}. - * - * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities. - */ - public int getCapabilities() { - return mCapabilities; - } - @Override public int hashCode() { - return Objects.hashCode(mComponentName) + Objects.hashCode(mId) + - Objects.hashCode(mHandle) + mCapabilities; + return Objects.hashCode(mComponentName) + Objects.hashCode(mId); } @Override @@ -130,20 +82,16 @@ public class PhoneAccount implements Parcelable { .append(", ") .append(mId) .append(", ") - .append(Log.pii(mHandle)) .append(", ") - .append(String.valueOf(mCapabilities)) .toString(); } - /** - * TODO: Change this to just be equals() and use Set<> in Telecomm code instead of Lists. - * @hide - */ - public boolean equalsComponentAndId(PhoneAccount other) { + @Override + public boolean equals(Object other) { return other != null && - Objects.equals(other.getComponentName(), getComponentName()) && - Objects.equals(other.getId(), getId()); + other instanceof PhoneAccount && + Objects.equals(((PhoneAccount) other).getComponentName(), getComponentName()) && + Objects.equals(((PhoneAccount) other).getId(), getId()); } // @@ -159,8 +107,6 @@ public class PhoneAccount implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeParcelable(mComponentName, flags); out.writeString(mId); - out.writeString(mHandle != null ? mHandle.toString() : ""); - out.writeInt(mCapabilities); } public static final Creator<PhoneAccount> CREATOR = new Creator<PhoneAccount>() { @@ -178,8 +124,5 @@ public class PhoneAccount implements Parcelable { private PhoneAccount(Parcel in) { mComponentName = in.readParcelable(getClass().getClassLoader()); mId = in.readString(); - String uriString = in.readString(); - mHandle = uriString.length() > 0 ? Uri.parse(uriString) : null; - mCapabilities = in.readInt(); } } diff --git a/telecomm/java/android/telecomm/PhoneAccountMetadata.java b/telecomm/java/android/telecomm/PhoneAccountMetadata.java index 20a4d47..e5e41ff 100644 --- a/telecomm/java/android/telecomm/PhoneAccountMetadata.java +++ b/telecomm/java/android/telecomm/PhoneAccountMetadata.java @@ -19,32 +19,67 @@ package android.telecomm; import android.content.Context; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; -import java.io.IOException; -import java.io.ObjectStreamException; -import java.io.Serializable; import java.util.MissingResourceException; /** * Provides user interface description information for a {@code PhoneAccount}. + * + * TODO: Per feedback from API Council, rename to "PhoneAccount". See also comment on class + * PhoneAccount. */ public class PhoneAccountMetadata implements Parcelable { - private PhoneAccount mAccount; - private int mIconResId; - private String mLabel; - private String mShortDescription; + + /** + * Flag indicating that this {@code PhoneAccount} can act as a call manager for traditional + * SIM-based telephony calls. The {@link ConnectionService} associated with this phone-account + * will be allowed to manage SIM-based phone calls including using its own proprietary + * phone-call implementation (like VoIP calling) to make calls instead of the telephony stack. + * When a user opts to place a call using the SIM-based telephony stack, the connection-service + * associated with this phone-account will be attempted first if the user has explicitly + * selected it to be used as the default call-manager. + * <p> + * See {@link #getCapabilities} + */ + public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1; + + /** + * Flag indicating that this {@code PhoneAccount} can make phone calls in place of traditional + * SIM-based telephony calls. This account will be treated as a distinct method for placing + * calls alongside the traditional SIM-based telephony stack. This flag is distinct from + * {@link #CAPABILITY_SIM_CALL_MANAGER} in that it is not allowed to manage calls from or use + * the built-in telephony stack to place its calls. + * <p> + * See {@link #getCapabilities} + */ + public static final int CAPABILITY_CALL_PROVIDER = 0x2; + + private final PhoneAccount mAccount; + private final Uri mHandle; + private final int mCapabilities; + private final int mIconResId; + private final String mLabel; + private final String mShortDescription; + private boolean mVideoCallingSupported; public PhoneAccountMetadata( PhoneAccount account, + Uri handle, + int capabilities, int iconResId, String label, - String shortDescription) { + String shortDescription, + boolean supportsVideoCalling) { mAccount = account; + mHandle = handle; + mCapabilities = capabilities; mIconResId = iconResId; mLabel = label; mShortDescription = shortDescription; + mVideoCallingSupported = supportsVideoCalling; } /** @@ -57,6 +92,27 @@ public class PhoneAccountMetadata implements Parcelable { } /** + * The handle (e.g., a phone number) associated with this {@code PhoneAccount}. This represents + * the destination from which outgoing calls using this {@code PhoneAccount} will appear to + * come, if applicable, and the destination to which incoming calls using this + * {@code PhoneAccount} may be addressed. + * + * @return A handle expressed as a {@code Uri}, for example, a phone number. + */ + public Uri getHandle() { + return mHandle; + } + + /** + * The capabilities of this {@code PhoneAccount}. + * + * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities. + */ + public int getCapabilities() { + return mCapabilities; + } + + /** * A short string label describing a {@code PhoneAccount}. * * @return A label for this {@code PhoneAccount}. @@ -75,6 +131,15 @@ public class PhoneAccountMetadata implements Parcelable { } /** + * The icon resource ID for the icon of this {@code PhoneAccount}. + * + * @return A resource ID. + */ + public int getIconResId() { + return mIconResId; + } + + /** * An icon to represent this {@code PhoneAccount} in a user interface. * * @return An icon for this {@code PhoneAccount}. @@ -101,6 +166,15 @@ public class PhoneAccountMetadata implements Parcelable { } } + /** + * Determines whether this {@code PhoneAccount} supports video calling. + * + * @return {@code true} if this {@code PhoneAccount} supports video calling. + */ + public boolean isVideoCallingSupported() { + return mVideoCallingSupported; + } + // // Parcelable implementation // @@ -113,9 +187,12 @@ public class PhoneAccountMetadata implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeParcelable(mAccount, 0); + out.writeParcelable(mHandle, 0); + out.writeInt(mCapabilities); out.writeInt(mIconResId); out.writeString(mLabel); out.writeString(mShortDescription); + out.writeInt(mVideoCallingSupported ? 1 : 0); } public static final Creator<PhoneAccountMetadata> CREATOR @@ -133,8 +210,11 @@ public class PhoneAccountMetadata implements Parcelable { private PhoneAccountMetadata(Parcel in) { mAccount = in.readParcelable(getClass().getClassLoader()); + mHandle = in.readParcelable(getClass().getClassLoader()); + mCapabilities = in.readInt(); mIconResId = in.readInt(); mLabel = in.readString(); mShortDescription = in.readString(); + mVideoCallingSupported = in.readInt() == 1; } } diff --git a/telecomm/java/android/telecomm/RemoteConnection.java b/telecomm/java/android/telecomm/RemoteConnection.java index 5d8579e..d17e62a 100644 --- a/telecomm/java/android/telecomm/RemoteConnection.java +++ b/telecomm/java/android/telecomm/RemoteConnection.java @@ -42,6 +42,7 @@ public final class RemoteConnection { void onHandleChanged(RemoteConnection connection, Uri handle, int presentation); void onCallerDisplayNameChanged( RemoteConnection connection, String callerDisplayName, int presentation); + void onVideoStateChanged(RemoteConnection connection, int videoState); void onDestroyed(RemoteConnection connection); } @@ -55,6 +56,7 @@ public final class RemoteConnection { private boolean mRequestingRingback; private boolean mConnected; private int mCallCapabilities; + private int mVideoState; private boolean mAudioModeIsVoip; private StatusHints mStatusHints; private Uri mHandle; @@ -120,6 +122,10 @@ public final class RemoteConnection { return mCallerDisplayNamePresentation; } + public int getVideoState() { + return mVideoState; + } + public void abort() { try { if (mConnected) { @@ -297,6 +303,16 @@ public final class RemoteConnection { } } + /** + * @hide + */ + void setVideoState(int videoState) { + mVideoState = videoState; + for (Listener l : mListeners) { + l.onVideoStateChanged(this, videoState); + } + } + /** @hide */ void setAudioModeIsVoip(boolean isVoip) { mAudioModeIsVoip = isVoip; diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java index 7fd8f93..c2b574c 100644 --- a/telecomm/java/android/telecomm/RemoteConnectionService.java +++ b/telecomm/java/android/telecomm/RemoteConnectionService.java @@ -167,6 +167,13 @@ final class RemoteConnectionService implements DeathRecipient { } @Override + public void setVideoState(String connectionId, int videoState) { + if (isCurrentConnection(connectionId)) { + mConnection.setVideoState(videoState); + } + } + + @Override public final void setAudioModeIsVoip(String connectionId, boolean isVoip) { if (isCurrentConnection(connectionId)) { mConnection.setAudioModeIsVoip(isVoip); @@ -253,9 +260,7 @@ final class RemoteConnectionService implements DeathRecipient { List<PhoneAccount> accounts = new LinkedList<>(); accounts.add(new PhoneAccount( mComponentName, - null /* id */, - null /* handle */, - 0 /* capabilities */)); + null /* id */)); return accounts; } diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java index 8bf80bb..89fcdb5 100644 --- a/telecomm/java/android/telecomm/TelecommManager.java +++ b/telecomm/java/android/telecomm/TelecommManager.java @@ -56,6 +56,34 @@ public class TelecommManager { } /** + * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing + * phone calls. This {@code PhoneAccount} will always be a member of the list which is + * returned from calling {@link #getEnabledPhoneAccounts()}. + * <p> + * Apps must be prepared for this method to return {@code null}, indicating that there + * currently exists no user-chosen default {@code PhoneAccount}. In this case, apps wishing to + * initiate a phone call must either create their {@link android.content.Intent#ACTION_CALL} or + * {@link android.content.Intent#ACTION_DIAL} {@code Intent} with no + * {@link TelecommConstants#EXTRA_PHONE_ACCOUNT}, or present the user with an affordance + * to select one of the elements of {@link #getEnabledPhoneAccounts()}. + * <p> + * An {@link android.content.Intent#ACTION_CALL} or {@link android.content.Intent#ACTION_DIAL} + * {@code Intent} with no {@link TelecommConstants#EXTRA_PHONE_ACCOUNT} is valid, and subsequent + * steps in the phone call flow are responsible for presenting the user with an affordance, if + * necessary, to choose a {@code PhoneAccount}. + */ + public PhoneAccount getDefaultOutgoingPhoneAccount() { + try { + if (isServiceConnected()) { + return getTelecommService().getDefaultOutgoingPhoneAccount(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#getDefaultOutgoingPhoneAccount", e); + } + return null; + } + + /** * Return a list of {@link PhoneAccount}s which can be used to make and receive phone calls. * * @see #EXTRA_PHONE_ACCOUNT @@ -94,13 +122,12 @@ public class TelecommManager { /** * Register a {@link PhoneAccount} for use by the system. * - * @param account The {@link PhoneAccount}. - * @param metadata The metadata for the account. + * @param metadata The complete {@link PhoneAccountMetadata}. */ - public void registerPhoneAccount(PhoneAccount account, PhoneAccountMetadata metadata) { + public void registerPhoneAccount(PhoneAccountMetadata metadata) { try { if (isServiceConnected()) { - getTelecommService().registerPhoneAccount(account, metadata); + getTelecommService().registerPhoneAccount(metadata); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecommService#registerPhoneAccount", e); |