Merge "Add @TestApi annotations to CS-side RTT APIs for CTS" am: f6f3c16dfb

am: 6689b57b66

Change-Id: I35ec391a2edcc4d64bc7330415505f700b90a568
This commit is contained in:
Hall Liu
2017-04-04 23:45:39 +00:00
committed by android-build-merger
7 changed files with 92 additions and 22 deletions

View File

@ -36887,7 +36887,8 @@ package android.telecom {
public static final class Call.RttCall {
method public int getRttAudioMode();
method public java.lang.String read();
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException;
field public static final int RTT_MODE_FULL = 1; // 0x1

View File

@ -39865,7 +39865,8 @@ package android.telecom {
public static final class Call.RttCall {
method public int getRttAudioMode();
method public java.lang.String read();
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException;
field public static final int RTT_MODE_FULL = 1; // 0x1

View File

@ -36970,7 +36970,8 @@ package android.telecom {
public static final class Call.RttCall {
method public int getRttAudioMode();
method public java.lang.String read();
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException;
field public static final int RTT_MODE_FULL = 1; // 0x1
@ -37090,6 +37091,7 @@ package android.telecom {
method public final int getState();
method public final android.telecom.StatusHints getStatusHints();
method public final android.telecom.Connection.VideoProvider getVideoProvider();
method public void handleRttUpgradeResponse(android.telecom.Connection.RttTextStream);
method public final boolean isRingbackRequested();
method public void onAbort();
method public void onAnswer(int);
@ -37106,14 +37108,20 @@ package android.telecom {
method public void onReject(java.lang.String);
method public void onSeparate();
method public void onShowIncomingCallUi();
method public void onStartRtt(android.telecom.Connection.RttTextStream);
method public void onStateChanged(int);
method public void onStopDtmfTone();
method public void onStopRtt();
method public void onUnhold();
method public static java.lang.String propertiesToString(int);
method public final void putExtras(android.os.Bundle);
method public final void removeExtras(java.util.List<java.lang.String>);
method public final void removeExtras(java.lang.String...);
method public void sendConnectionEvent(java.lang.String, android.os.Bundle);
method public final void sendRemoteRttRequest();
method public final void sendRttInitiationFailure(int);
method public final void sendRttInitiationSuccess();
method public final void sendRttSessionRemotelyTerminated();
method public final void setActive();
method public final void setAddress(android.net.Uri, int);
method public final void setAudioModeIsVoip(boolean);
@ -37167,6 +37175,7 @@ package android.telecom {
field public static final java.lang.String EXTRA_LAST_FORWARDED_NUMBER = "android.telecom.extra.LAST_FORWARDED_NUMBER";
field public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 32; // 0x20
field public static final int PROPERTY_IS_EXTERNAL_CALL = 16; // 0x10
field public static final int PROPERTY_IS_RTT = 256; // 0x100
field public static final int PROPERTY_SELF_MANAGED = 128; // 0x80
field public static final int STATE_ACTIVE = 4; // 0x4
field public static final int STATE_DIALING = 3; // 0x3
@ -37187,6 +37196,12 @@ package android.telecom {
field public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4; // 0x4
}
public static final class Connection.RttTextStream {
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String readImmediately() throws java.io.IOException;
method public void write(java.lang.String) throws java.io.IOException;
}
public static abstract class Connection.VideoProvider {
ctor public Connection.VideoProvider();
method public void changeCameraCapabilities(android.telecom.VideoProfile.CameraCapabilities);
@ -37227,7 +37242,9 @@ package android.telecom {
method public android.telecom.PhoneAccountHandle getAccountHandle();
method public android.net.Uri getAddress();
method public android.os.Bundle getExtras();
method public android.telecom.Connection.RttTextStream getRttTextStream();
method public int getVideoState();
method public boolean isRequestingRtt();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telecom.ConnectionRequest> CREATOR;
}

View File

@ -1001,15 +1001,24 @@ public final class Call {
* @return A string containing text sent by the remote user, or {@code null} if the
* conversation has been terminated or if there was an error while reading.
*/
public String read() {
try {
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
return null;
}
return new String(mReadBuffer, 0, numRead);
} catch (IOException e) {
Log.w(this, "Exception encountered when reading from InputStreamReader: %s", e);
public String read() throws IOException {
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
return null;
}
return new String(mReadBuffer, 0, numRead);
}
/**
* Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
* be read.
* @return A string containing text entered by the user, or {@code null} if the user has
* not entered any new text yet.
*/
public String readImmediately() throws IOException {
if (mReceiveStream.ready()) {
return read();
} else {
return null;
}
}

View File

@ -24,6 +24,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.Notification;
import android.content.Intent;
import android.hardware.camera2.CameraManager;
@ -395,9 +396,11 @@ public abstract class Connection extends Conferenceable {
public static final int PROPERTY_SELF_MANAGED = 1<<7;
/**
* When set, indicates that a connection has an active RTT session associated with it.
* Set by the framework to indicate that a connection has an active RTT session associated with
* it.
* @hide
*/
@TestApi
public static final int PROPERTY_IS_RTT = 1 << 8;
//**********************************************************************************************
@ -791,6 +794,7 @@ public abstract class Connection extends Conferenceable {
* Provides methods to read and write RTT data to/from the in-call app.
* @hide
*/
@TestApi
public static final class RttTextStream {
private static final int READ_BUFFER_SIZE = 1000;
private final InputStreamReader mPipeFromInCall;
@ -836,15 +840,24 @@ public abstract class Connection extends Conferenceable {
* @return A string containing text entered by the user, or {@code null} if the
* conversation has been terminated or if there was an error while reading.
*/
public String read() {
try {
int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
return null;
}
return new String(mReadBuffer, 0, numRead);
} catch (IOException e) {
Log.w(this, "Exception encountered when reading from InputStreamReader: %s", e);
public String read() throws IOException {
int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
return null;
}
return new String(mReadBuffer, 0, numRead);
}
/**
* Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
* be read.
* @return A string containing text entered by the user, or {@code null} if the user has
* not entered any new text yet.
*/
public String readImmediately() throws IOException {
if (mPipeFromInCall.ready()) {
return read();
} else {
return null;
}
}
@ -2503,7 +2516,9 @@ public abstract class Connection extends Conferenceable {
* {@link #onStartRtt(ParcelFileDescriptor, ParcelFileDescriptor)} has succeeded.
* @hide
*/
@TestApi
public final void sendRttInitiationSuccess() {
setRttProperty();
mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
}
@ -2516,7 +2531,9 @@ public abstract class Connection extends Conferenceable {
* exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
* @hide
*/
@TestApi
public final void sendRttInitiationFailure(int reason) {
unsetRttProperty();
mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
}
@ -2525,6 +2542,7 @@ public abstract class Connection extends Conferenceable {
* side of the coll.
* @hide
*/
@TestApi
public final void sendRttSessionRemotelyTerminated() {
mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
}
@ -2534,6 +2552,7 @@ public abstract class Connection extends Conferenceable {
* RTT session in the call.
* @hide
*/
@TestApi
public final void sendRemoteRttRequest() {
mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
}
@ -2752,6 +2771,7 @@ public abstract class Connection extends Conferenceable {
* the in-call app.
* @hide
*/
@TestApi
public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
/**
@ -2759,6 +2779,7 @@ public abstract class Connection extends Conferenceable {
* channel. No response to Telecom is needed for this method.
* @hide
*/
@TestApi
public void onStopRtt() {}
/**
@ -2770,8 +2791,25 @@ public abstract class Connection extends Conferenceable {
* @param rttTextStream The object that should be used to send text to or receive text from
* the in-call app.
*/
@TestApi
public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
/**
* Internal method to set {@link #PROPERTY_IS_RTT}.
* @hide
*/
void setRttProperty() {
setConnectionProperties(getConnectionProperties() | PROPERTY_IS_RTT);
}
/**
* Internal method to un-set {@link #PROPERTY_IS_RTT}.
* @hide
*/
void unsetRttProperty() {
setConnectionProperties(getConnectionProperties() & (~PROPERTY_IS_RTT));
}
static String toLogSafePhoneNumber(String number) {
// For unknown number, log empty string.
if (number == null) {

View File

@ -16,6 +16,7 @@
package android.telecom;
import android.annotation.TestApi;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
@ -311,6 +312,7 @@ public final class ConnectionRequest implements Parcelable {
* if this connection request is not requesting an RTT session upon connection establishment.
* @hide
*/
@TestApi
public Connection.RttTextStream getRttTextStream() {
if (isRequestingRtt()) {
return new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall);
@ -324,6 +326,7 @@ public final class ConnectionRequest implements Parcelable {
* @return {@code true} if RTT is requested, {@code false} otherwise.
* @hide
*/
@TestApi
public boolean isRequestingRtt() {
return mRttPipeFromInCall != null && mRttPipeToInCall != null;
}

View File

@ -1603,6 +1603,7 @@ public abstract class ConnectionService extends Service {
Log.d(this, "stopRtt(%s)", callId);
if (mConnectionById.containsKey(callId)) {
findConnectionForAction(callId, "stopRtt").onStopRtt();
findConnectionForAction(callId, "stopRtt").unsetRttProperty();
} else if (mConferenceById.containsKey(callId)) {
Log.w(this, "stopRtt called on a conference.");
}