Improve remote connection logging.
This CL improves traceability of calls initiated via a remote connection service. For regular incoming/outgoing calls, when initiating a request to create a remote connection in RemoteConnectionService, we set EXTRA_REQUESTING_PACKAGE_NAME in the parcelled request to the package name of the connection manager. In ConnectionService this serves as an indicator that the incoming request is via a connection manager and is used to trigger setting of EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE with the phone account handle the remote connection service uses to place the call. For conferences and existing connections, the initial request is from the remote connection service to the connection manager so we can just set the EXTRA_REMOTE_PHONE_ACCOUNT handle there directly. Also cleaned up logging in the telecom session logging to remove the assumption that the ownerInfo is an incall service. Test: Manual testing with connection manager to verify logging. Fixes: 154353494 Change-Id: Iee1b5cfd3334a5de08d7b04022b7c6d5af6a4b04
This commit is contained in:
@@ -733,6 +733,31 @@ public abstract class Connection extends Conferenceable {
|
||||
public static final String EXTRA_ORIGINAL_CONNECTION_ID =
|
||||
"android.telecom.extra.ORIGINAL_CONNECTION_ID";
|
||||
|
||||
/**
|
||||
* Extra key set on a {@link Connection} when it was created via a remote connection service.
|
||||
* For example, if a connection manager requests a remote connection service to create a call
|
||||
* using one of the remote connection service's phone account handle, this extra will be set so
|
||||
* that Telecom knows that the wrapped remote connection originated in a remote connection
|
||||
* service. We stash this in the extras since connection managers will typically copy the
|
||||
* extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
|
||||
* other way to relate a {@link RemoteConnection} to a {@link Connection}.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
|
||||
"android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
|
||||
|
||||
/**
|
||||
* Extra key set from a {@link ConnectionService} when using the remote connection APIs
|
||||
* (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
|
||||
* ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
|
||||
* {@link ConnectionService} with a means to know the package name of the requesting
|
||||
* {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
|
||||
* better visibility in Telecom of where a connection ultimately originated.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
|
||||
"android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
|
||||
|
||||
/**
|
||||
* Boolean connection extra key set on the extras passed to
|
||||
* {@link Connection#sendConnectionEvent} which indicates that audio is present
|
||||
|
||||
@@ -1859,9 +1859,25 @@ public abstract class ConnectionService extends Service {
|
||||
new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONFERENCE"),
|
||||
request.getAccountHandle());
|
||||
}
|
||||
if (conference.getExtras() != null) {
|
||||
conference.getExtras().putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId);
|
||||
|
||||
Bundle extras = request.getExtras();
|
||||
Bundle newExtras = new Bundle();
|
||||
newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId);
|
||||
if (extras != null) {
|
||||
// If the request originated from a remote connection service, we will add some
|
||||
// tracking information that Telecom can use to keep informed of which package
|
||||
// made the remote request, and which remote connection service was used.
|
||||
if (extras.containsKey(Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME)) {
|
||||
newExtras.putString(
|
||||
Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME,
|
||||
extras.getString(
|
||||
Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME));
|
||||
newExtras.putParcelable(Connection.EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE,
|
||||
request.getAccountHandle());
|
||||
}
|
||||
}
|
||||
conference.putExtras(newExtras);
|
||||
|
||||
mConferenceById.put(callId, conference);
|
||||
mIdByConference.put(conference, callId);
|
||||
conference.addListener(mConferenceListener);
|
||||
@@ -1936,6 +1952,30 @@ public abstract class ConnectionService extends Service {
|
||||
Log.i(this, "createConnection, implementation returned null connection.");
|
||||
connection = Connection.createFailedConnection(
|
||||
new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONNECTION"));
|
||||
} else {
|
||||
try {
|
||||
Bundle extras = request.getExtras();
|
||||
if (extras != null) {
|
||||
// If the request originated from a remote connection service, we will add some
|
||||
// tracking information that Telecom can use to keep informed of which package
|
||||
// made the remote request, and which remote connection service was used.
|
||||
if (extras.containsKey(
|
||||
Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME)) {
|
||||
Bundle newExtras = new Bundle();
|
||||
newExtras.putString(
|
||||
Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME,
|
||||
extras.getString(
|
||||
Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME
|
||||
));
|
||||
newExtras.putParcelable(Connection.EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE,
|
||||
request.getAccountHandle());
|
||||
connection.putExtras(newExtras);
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedOperationException ose) {
|
||||
// Do nothing; if the ConnectionService reported a failure it will be an instance
|
||||
// of an immutable Connection which we cannot edit, so we're out of luck.
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSelfManaged =
|
||||
|
||||
@@ -427,7 +427,7 @@ public class Session {
|
||||
StringBuilder methodName = new StringBuilder();
|
||||
methodName.append(getFullMethodPath(false /*truncatePath*/));
|
||||
if (mOwnerInfo != null && !mOwnerInfo.isEmpty()) {
|
||||
methodName.append("(InCall package: ");
|
||||
methodName.append("(");
|
||||
methodName.append(mOwnerInfo);
|
||||
methodName.append(")");
|
||||
}
|
||||
|
||||
@@ -258,6 +258,9 @@ final class RemoteConnectionService {
|
||||
// See comments on Connection.EXTRA_ORIGINAL_CONNECTION_ID for more information.
|
||||
Bundle newExtras = new Bundle();
|
||||
newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId);
|
||||
// Track the fact this request was relayed through the remote connection service.
|
||||
newExtras.putParcelable(Connection.EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE,
|
||||
parcel.getPhoneAccount());
|
||||
conference.putExtras(newExtras);
|
||||
|
||||
conference.registerCallback(new RemoteConference.Callback() {
|
||||
@@ -383,6 +386,11 @@ final class RemoteConnectionService {
|
||||
RemoteConnection remoteConnection = new RemoteConnection(callId,
|
||||
mOutgoingConnectionServiceRpc, connection, callingPackage,
|
||||
callingTargetSdkVersion);
|
||||
// Track that it is via a remote connection.
|
||||
Bundle newExtras = new Bundle();
|
||||
newExtras.putParcelable(Connection.EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE,
|
||||
connection.getPhoneAccount());
|
||||
remoteConnection.putExtras(newExtras);
|
||||
mConnectionById.put(callId, remoteConnection);
|
||||
remoteConnection.registerCallback(new RemoteConnection.Callback() {
|
||||
@Override
|
||||
@@ -535,10 +543,20 @@ final class RemoteConnectionService {
|
||||
ConnectionRequest request,
|
||||
boolean isIncoming) {
|
||||
final String id = UUID.randomUUID().toString();
|
||||
Bundle extras = new Bundle();
|
||||
if (request.getExtras() != null) {
|
||||
extras.putAll(request.getExtras());
|
||||
}
|
||||
// We will set the package name for the originator of the remote request; this lets the
|
||||
// receiving ConnectionService know that the request originated from a remote connection
|
||||
// service so that it can provide tracking information for Telecom.
|
||||
extras.putString(Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME,
|
||||
mOurConnectionServiceImpl.getApplicationContext().getOpPackageName());
|
||||
|
||||
final ConnectionRequest newRequest = new ConnectionRequest.Builder()
|
||||
.setAccountHandle(request.getAccountHandle())
|
||||
.setAddress(request.getAddress())
|
||||
.setExtras(request.getExtras())
|
||||
.setExtras(extras)
|
||||
.setVideoState(request.getVideoState())
|
||||
.setRttPipeFromInCall(request.getRttPipeFromInCall())
|
||||
.setRttPipeToInCall(request.getRttPipeToInCall())
|
||||
|
||||
Reference in New Issue
Block a user