Add @TestApi annotations to CS-side RTT APIs for CTS

CTS tests need both the in-call and connection service sides of the APIs
to test Telecom functionality properly, so annotating the hidden-for-now
connection service APIs with TestApi.

Test: part of CTS
Change-Id: I3711729d7e8c8aff2735f4da9fbd04bcca6b4942
This commit is contained in:
Hall Liu
2017-03-02 16:11:00 -08:00
parent 4a8953094f
commit ffa4a812f8
7 changed files with 92 additions and 22 deletions

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;
//**********************************************************************************************
@@ -779,6 +782,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;
@@ -824,15 +828,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;
}
}
@@ -2491,7 +2504,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));
}
@@ -2504,7 +2519,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));
}
@@ -2513,6 +2530,7 @@ public abstract class Connection extends Conferenceable {
* side of the coll.
* @hide
*/
@TestApi
public final void sendRttSessionRemotelyTerminated() {
mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
}
@@ -2522,6 +2540,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));
}
@@ -2740,6 +2759,7 @@ public abstract class Connection extends Conferenceable {
* the in-call app.
* @hide
*/
@TestApi
public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
/**
@@ -2747,6 +2767,7 @@ public abstract class Connection extends Conferenceable {
* channel. No response to Telecom is needed for this method.
* @hide
*/
@TestApi
public void onStopRtt() {}
/**
@@ -2758,8 +2779,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) {