diff options
author | Grace Jia <xiaotonj@google.com> | 2020-08-04 12:52:09 -0700 |
---|---|---|
committer | Grace Jia <xiaotonj@google.com> | 2020-08-11 19:26:33 +0000 |
commit | 9a09c670759c50ce8f84b40f62ceef9b5dc00132 (patch) | |
tree | e518672aeaf9ec9afe0ed0af19557bc6244164ce | |
parent | bad5c4ec49a6dfc6c0c73dedba6cd5c0a9b27f9b (diff) |
Add adhoc conference APIs to RemoteConnection and
RemoteConnectionService.
Plumb through the adhoc conference APIs via these new APIs.
Bug: 159944852
Test: atest CtsTelecomTestCases:RemoteConnectionTest
Change-Id: Icfa27e0616dd35ba350f7a491e5c95337a286b9d
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | non-updatable-api/current.txt | 3 | ||||
-rwxr-xr-x | telecomm/java/android/telecom/ConnectionService.java | 36 | ||||
-rw-r--r-- | telecomm/java/android/telecom/RemoteConference.java | 24 | ||||
-rw-r--r-- | telecomm/java/android/telecom/RemoteConnection.java | 25 | ||||
-rw-r--r-- | telecomm/java/android/telecom/RemoteConnectionManager.java | 31 | ||||
-rw-r--r-- | telecomm/java/android/telecom/RemoteConnectionService.java | 34 |
7 files changed, 149 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt index ed9fba774e2a..f41a555d39c8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -44071,7 +44071,9 @@ package android.telecom { method public final void addExistingConnection(android.telecom.PhoneAccountHandle, android.telecom.Connection); method public final void conferenceRemoteConnections(android.telecom.RemoteConnection, android.telecom.RemoteConnection); method public final void connectionServiceFocusReleased(); + method @Nullable public final android.telecom.RemoteConference createRemoteIncomingConference(@Nullable android.telecom.PhoneAccountHandle, @Nullable android.telecom.ConnectionRequest); method public final android.telecom.RemoteConnection createRemoteIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); + method @Nullable public final android.telecom.RemoteConference createRemoteOutgoingConference(@Nullable android.telecom.PhoneAccountHandle, @Nullable android.telecom.ConnectionRequest); method public final android.telecom.RemoteConnection createRemoteOutgoingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public final java.util.Collection<android.telecom.Conference> getAllConferences(); method public final java.util.Collection<android.telecom.Connection> getAllConnections(); @@ -44302,6 +44304,7 @@ package android.telecom { public final class RemoteConnection { method public void abort(); + method public void addConferenceParticipants(@NonNull java.util.List<android.net.Uri>); method public void answer(); method public void disconnect(); method public android.net.Uri getAddress(); diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt index 05cf625abf48..49ea2ae99860 100644 --- a/non-updatable-api/current.txt +++ b/non-updatable-api/current.txt @@ -43927,7 +43927,9 @@ package android.telecom { method public final void addExistingConnection(android.telecom.PhoneAccountHandle, android.telecom.Connection); method public final void conferenceRemoteConnections(android.telecom.RemoteConnection, android.telecom.RemoteConnection); method public final void connectionServiceFocusReleased(); + method @Nullable public final android.telecom.RemoteConference createRemoteIncomingConference(@Nullable android.telecom.PhoneAccountHandle, @Nullable android.telecom.ConnectionRequest); method public final android.telecom.RemoteConnection createRemoteIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); + method @Nullable public final android.telecom.RemoteConference createRemoteOutgoingConference(@Nullable android.telecom.PhoneAccountHandle, @Nullable android.telecom.ConnectionRequest); method public final android.telecom.RemoteConnection createRemoteOutgoingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public final java.util.Collection<android.telecom.Conference> getAllConferences(); method public final java.util.Collection<android.telecom.Connection> getAllConnections(); @@ -44158,6 +44160,7 @@ package android.telecom { public final class RemoteConnection { method public void abort(); + method public void addConferenceParticipants(@NonNull java.util.List<android.net.Uri>); method public void answer(); method public void disconnect(); method public android.net.Uri getAddress(); diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index 8bc80adf80a8..bf0b3ae3ac0c 100755 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -2448,6 +2448,42 @@ public abstract class ConnectionService extends Service { } /** + * Ask some other {@code ConnectionService} to create a {@code RemoteConference} given an + * incoming request. This is used by {@code ConnectionService}s that are registered with + * {@link PhoneAccount#CAPABILITY_ADHOC_CONFERENCE_CALLING}. + * + * @param connectionManagerPhoneAccount See description at + * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. + * @param request Details about the incoming conference call. + * @return The {@code RemoteConference} object to satisfy this call, or {@code null} to not + * handle the call. + */ + public final @Nullable RemoteConference createRemoteIncomingConference( + @Nullable PhoneAccountHandle connectionManagerPhoneAccount, + @Nullable ConnectionRequest request) { + return mRemoteConnectionManager.createRemoteConference(connectionManagerPhoneAccount, + request, true); + } + + /** + * Ask some other {@code ConnectionService} to create a {@code RemoteConference} given an + * outgoing request. This is used by {@code ConnectionService}s that are registered with + * {@link PhoneAccount#CAPABILITY_ADHOC_CONFERENCE_CALLING}. + * + * @param connectionManagerPhoneAccount See description at + * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. + * @param request Details about the outgoing conference call. + * @return The {@code RemoteConference} object to satisfy this call, or {@code null} to not + * handle the call. + */ + public final @Nullable RemoteConference createRemoteOutgoingConference( + @Nullable PhoneAccountHandle connectionManagerPhoneAccount, + @Nullable ConnectionRequest request) { + return mRemoteConnectionManager.createRemoteConference(connectionManagerPhoneAccount, + request, false); + } + + /** * Indicates to the relevant {@code RemoteConnectionService} that the specified * {@link RemoteConnection}s should be merged into a conference call. * <p> diff --git a/telecomm/java/android/telecom/RemoteConference.java b/telecomm/java/android/telecom/RemoteConference.java index 502b7c01b0c0..e024e6186519 100644 --- a/telecomm/java/android/telecom/RemoteConference.java +++ b/telecomm/java/android/telecom/RemoteConference.java @@ -16,14 +16,14 @@ package android.telecom; -import com.android.internal.telecom.IConnectionService; - import android.annotation.Nullable; import android.annotation.SystemApi; import android.os.Bundle; import android.os.Handler; import android.os.RemoteException; +import com.android.internal.telecom.IConnectionService; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -155,6 +155,14 @@ public final class RemoteConference { } /** @hide */ + RemoteConference(DisconnectCause disconnectCause) { + mId = "NULL"; + mConnectionService = null; + mState = Connection.STATE_DISCONNECTED; + mDisconnectCause = disconnectCause; + } + + /** @hide */ String getId() { return mId; } @@ -583,4 +591,16 @@ public final class RemoteConference { } } } + + /** + * Create a {@link RemoteConference} represents a failure, and which will + * be in {@link Connection#STATE_DISCONNECTED}. + * + * @param disconnectCause The disconnect cause. + * @return a failed {@link RemoteConference} + * @hide + */ + public static RemoteConference failure(DisconnectCause disconnectCause) { + return new RemoteConference(disconnectCause); + } } diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java index 05480dc38a0d..78b4f3bfb90b 100644 --- a/telecomm/java/android/telecom/RemoteConnection.java +++ b/telecomm/java/android/telecom/RemoteConnection.java @@ -16,10 +16,6 @@ package android.telecom; -import com.android.internal.telecom.IConnectionService; -import com.android.internal.telecom.IVideoCallback; -import com.android.internal.telecom.IVideoProvider; - import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; @@ -32,6 +28,10 @@ import android.os.IBinder; import android.os.RemoteException; import android.view.Surface; +import com.android.internal.telecom.IConnectionService; +import com.android.internal.telecom.IVideoCallback; +import com.android.internal.telecom.IVideoProvider; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -1061,6 +1061,23 @@ public final class RemoteConnection { } /** + * Instructs this {@link RemoteConnection} to initiate a conference with a list of + * participants. + * <p> + * + * @param participants with which conference call will be formed. + */ + public void addConferenceParticipants(@NonNull List<Uri> participants) { + try { + if (mConnected) { + mConnectionService.addConferenceParticipants(mConnectionId, participants, + null /*Session.Info*/); + } + } catch (RemoteException ignored) { + } + } + + /** * Set the audio state of this {@code RemoteConnection}. * * @param state The audio state of this {@code RemoteConnection}. diff --git a/telecomm/java/android/telecom/RemoteConnectionManager.java b/telecomm/java/android/telecom/RemoteConnectionManager.java index 0322218d75dc..f3c7bd83ed4b 100644 --- a/telecomm/java/android/telecom/RemoteConnectionManager.java +++ b/telecomm/java/android/telecom/RemoteConnectionManager.java @@ -73,6 +73,37 @@ public class RemoteConnectionManager { return null; } + /** + * Ask a {@code RemoteConnectionService} to create a {@code RemoteConference}. + * @param connectionManagerPhoneAccount See description at + * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. + * @param request Details about the incoming conference call. + * @param isIncoming {@code true} if it's an incoming conference. + * @return + */ + public RemoteConference createRemoteConference( + PhoneAccountHandle connectionManagerPhoneAccount, + ConnectionRequest request, + boolean isIncoming) { + PhoneAccountHandle accountHandle = request.getAccountHandle(); + if (accountHandle == null) { + throw new IllegalArgumentException("accountHandle must be specified."); + } + + ComponentName componentName = request.getAccountHandle().getComponentName(); + if (!mRemoteConnectionServices.containsKey(componentName)) { + throw new UnsupportedOperationException("accountHandle not supported: " + + componentName); + } + + RemoteConnectionService remoteService = mRemoteConnectionServices.get(componentName); + if (remoteService != null) { + return remoteService.createRemoteConference( + connectionManagerPhoneAccount, request, isIncoming); + } + return null; + } + public void conferenceRemoteConnections(RemoteConnection a, RemoteConnection b) { if (a.getConnectionService() == b.getConnectionService()) { try { diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java index cad5b707a146..0a02e79e0fa4 100644 --- a/telecomm/java/android/telecom/RemoteConnectionService.java +++ b/telecomm/java/android/telecom/RemoteConnectionService.java @@ -31,9 +31,9 @@ import com.android.internal.telecom.RemoteServiceCallback; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; -import java.util.List; import java.util.UUID; /** @@ -573,6 +573,38 @@ final class RemoteConnectionService { } } + RemoteConference createRemoteConference( + PhoneAccountHandle connectionManagerPhoneAccount, + ConnectionRequest request, + boolean isIncoming) { + final String id = UUID.randomUUID().toString(); + try { + if (mConferenceById.isEmpty()) { + mOutgoingConnectionServiceRpc.addConnectionServiceAdapter(mServant.getStub(), + null /*Session.Info*/); + } + RemoteConference conference = new RemoteConference(id, mOutgoingConnectionServiceRpc); + mOutgoingConnectionServiceRpc.createConference(connectionManagerPhoneAccount, + id, + request, + isIncoming, + false /* isUnknownCall */, + null /*Session.info*/); + conference.registerCallback(new RemoteConference.Callback() { + @Override + public void onDestroyed(RemoteConference conference) { + mConferenceById.remove(id); + maybeDisconnectAdapter(); + } + }); + conference.putExtras(request.getExtras()); + return conference; + } catch (RemoteException e) { + return RemoteConference.failure( + new DisconnectCause(DisconnectCause.ERROR, e.toString())); + } + } + private boolean hasConnection(String callId) { return mConnectionById.containsKey(callId); } |