am 6edbc6ed: am 1a0365fd: Merge "Wiring video state through from Connection" into lmp-dev

* commit '6edbc6edbfbec463efa2a364c1c8db32033b0765':
  Wiring video state through from Connection
This commit is contained in:
Tyler Gunn
2014-07-18 03:09:55 +00:00
committed by Android Git Automerger
9 changed files with 166 additions and 5 deletions

View File

@@ -28224,6 +28224,7 @@ package android.telecomm {
method public final android.telecomm.Connection getParentConnection();
method public final int getState();
method public final android.telecomm.StatusHints getStatusHints();
method public final int getVideoState();
method public final boolean isConferenceConnection();
method public final boolean isRequestingRingback();
method protected void onAbort();
@@ -28257,6 +28258,7 @@ package android.telecomm {
method public final void setRinging();
method public final void setSignal(android.os.Bundle);
method public final void setStatusHints(android.telecomm.StatusHints);
method public final void setVideoState(int);
method public static java.lang.String stateToString(int);
}
@@ -28391,12 +28393,13 @@ package android.telecomm {
}
public class PhoneAccountMetadata implements android.os.Parcelable {
ctor public PhoneAccountMetadata(android.telecomm.PhoneAccount, int, java.lang.String, java.lang.String);
ctor public PhoneAccountMetadata(android.telecomm.PhoneAccount, int, java.lang.String, java.lang.String, boolean);
method public int describeContents();
method public android.telecomm.PhoneAccount getAccount();
method public android.graphics.drawable.Drawable getIcon(android.content.Context);
method public java.lang.String getLabel();
method public java.lang.String getShortDescription();
method public boolean isVideoCallingSupported();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
}
@@ -28440,6 +28443,7 @@ package android.telecomm {
method public int getHandlePresentation();
method public int getState();
method public android.telecomm.StatusHints getStatusHints();
method public int getVideoState();
method public void hold();
method public void playDtmf(char);
method public void postDialContinue(boolean);
@@ -28462,6 +28466,7 @@ package android.telecomm {
method public abstract void onRequestingRingback(android.telecomm.RemoteConnection, boolean);
method public abstract void onStateChanged(android.telecomm.RemoteConnection, int);
method public abstract void onStatusHintsChanged(android.telecomm.RemoteConnection, android.telecomm.StatusHints);
method public abstract void onVideoStateChanged(android.telecomm.RemoteConnection, int);
}
public abstract interface Response {

View File

@@ -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.
@@ -117,6 +119,19 @@ public abstract class Connection {
return mState;
}
/**
* 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
@@ -284,6 +299,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).

View File

@@ -323,6 +323,13 @@ public abstract class ConnectionService extends Service {
mAdapter.setDisconnected(id, cause, message);
}
@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);

View File

@@ -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) {
}
}
}
}

View File

@@ -22,9 +22,6 @@ import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.MissingResourceException;
/**
@@ -35,16 +32,19 @@ public class PhoneAccountMetadata implements Parcelable {
private int mIconResId;
private String mLabel;
private String mShortDescription;
private boolean mVideoCallingSupported;
public PhoneAccountMetadata(
PhoneAccount account,
int iconResId,
String label,
String shortDescription) {
String shortDescription,
boolean supportsVideoCalling) {
mAccount = account;
mIconResId = iconResId;
mLabel = label;
mShortDescription = shortDescription;
mVideoCallingSupported = supportsVideoCalling;
}
/**
@@ -101,6 +101,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
//
@@ -116,6 +125,7 @@ public class PhoneAccountMetadata implements Parcelable {
out.writeInt(mIconResId);
out.writeString(mLabel);
out.writeString(mShortDescription);
out.writeInt(mVideoCallingSupported ? 1: 0);
}
public static final Creator<PhoneAccountMetadata> CREATOR
@@ -136,5 +146,6 @@ public class PhoneAccountMetadata implements Parcelable {
mIconResId = in.readInt();
mLabel = in.readString();
mShortDescription = in.readString();
mVideoCallingSupported = in.readInt() == 1;
}
}

View File

@@ -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;

View File

@@ -166,6 +166,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)) {

View File

@@ -64,6 +64,8 @@ oneway interface IConnectionServiceAdapter {
void setCallVideoProvider(String callId, ICallVideoProvider callVideoProvider);
void setVideoState(String callId, int videoState);
void setAudioModeIsVoip(String callId, boolean isVoip);
void setStatusHints(String callId, in StatusHints statusHints);

View File

@@ -19,6 +19,7 @@ package com.android.ims;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.telecomm.VideoCallProfile;
/**
* Parcelable object to handle IMS call profile.
@@ -286,4 +287,63 @@ public class ImsCallProfile implements Parcelable {
return new ImsCallProfile[size];
}
};
/**
* Converts from the call types defined in {@link com.android.ims.ImsCallProfile} to the
* video state values defined in {@link android.telecomm.VideoCallProfile}.
*
* @param callType The call type.
* @return The video state.
*/
public static int getVideoStateFromCallType(int callType) {
switch (callType) {
case CALL_TYPE_VT_NODIR:
return VideoCallProfile.VIDEO_STATE_PAUSED |
VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL;
case CALL_TYPE_VT_TX:
return VideoCallProfile.VIDEO_STATE_TX_ENABLED;
case CALL_TYPE_VT_RX:
return VideoCallProfile.VIDEO_STATE_RX_ENABLED;
case CALL_TYPE_VT:
return VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL;
case CALL_TYPE_VOICE:
return VideoCallProfile.VIDEO_STATE_AUDIO_ONLY;
default:
return VideoCallProfile.VIDEO_STATE_AUDIO_ONLY;
}
}
/**
* Converts from the video state values defined in {@link android.telecomm.VideoCallProfile}
* to the call types defined in {@link ImsCallProfile}.
*
* @param videoState The video state.
* @return The call type.
*/
public static int getCallTypeFromVideoState(int videoState) {
boolean videoTx = isVideoStateSet(videoState, VideoCallProfile.VIDEO_STATE_TX_ENABLED);
boolean videoRx = isVideoStateSet(videoState, VideoCallProfile.VIDEO_STATE_RX_ENABLED);
boolean isPaused = isVideoStateSet(videoState, VideoCallProfile.VIDEO_STATE_PAUSED);
if (isPaused) {
return ImsCallProfile.CALL_TYPE_VT_NODIR;
} else if (videoTx && !videoRx) {
return ImsCallProfile.CALL_TYPE_VT_TX;
} else if (!videoTx && videoRx) {
return ImsCallProfile.CALL_TYPE_VT_RX;
} else if (videoTx && videoRx) {
return ImsCallProfile.CALL_TYPE_VT;
}
return ImsCallProfile.CALL_TYPE_VOICE;
}
/**
* Determines if a video state is set in a video state bit-mask.
*
* @param videoState The video state bit mask.
* @param videoStateToCheck The particular video state to check.
* @return True if the video state is set in the bit-mask.
*/
private static boolean isVideoStateSet(int videoState, int videoStateToCheck) {
return (videoState & videoStateToCheck) == videoStateToCheck;
}
}