summaryrefslogtreecommitdiffstats
path: root/telecomm/java
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2014-07-25 15:14:01 -0700
committerIhab Awad <ihab@google.com>2014-07-29 15:14:33 -0700
commitf8b69887b438683adee56ad1038d1414cc501ff9 (patch)
tree03137a3833829b98d6bf70c1bcf987d491bd0e05 /telecomm/java
parent5ad92c52781bf69f7e06c38c834421eecd943a23 (diff)
downloadframeworks_base-f8b69887b438683adee56ad1038d1414cc501ff9.zip
frameworks_base-f8b69887b438683adee56ad1038d1414cc501ff9.tar.gz
frameworks_base-f8b69887b438683adee56ad1038d1414cc501ff9.tar.bz2
Connection creation and service wiring for WiFi call managers (1/3)
Bug: 16469413 Change-Id: I019922f76f54d2fa376513a6284d6322959a8235
Diffstat (limited to 'telecomm/java')
-rw-r--r--telecomm/java/android/telecomm/ConnectionService.java123
-rw-r--r--telecomm/java/android/telecomm/PhoneAccount.java37
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionManager.java4
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionService.java12
-rw-r--r--telecomm/java/com/android/internal/telecomm/IConnectionService.aidl6
5 files changed, 128 insertions, 54 deletions
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index fb719a3..1484021 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -121,9 +121,15 @@ public abstract class ConnectionService extends Service {
}
@Override
- public void createConnection(ConnectionRequest request, boolean isIncoming) {
- mHandler.obtainMessage(
- MSG_CREATE_CONNECTION, isIncoming ? 1 : 0, 0, request).sendToTarget();
+ public void createConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
+ ConnectionRequest request,
+ boolean isIncoming) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = connectionManagerPhoneAccount;
+ args.arg2 = request;
+ args.argi1 = isIncoming ? 1 : 0;
+ mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget();
}
@Override
@@ -217,9 +223,19 @@ public abstract class ConnectionService extends Service {
mAdapter.addAdapter((IConnectionServiceAdapter) msg.obj);
onAdapterAttached();
break;
- case MSG_CREATE_CONNECTION:
- createConnection((ConnectionRequest) msg.obj, msg.arg1 == 1);
+ case MSG_CREATE_CONNECTION: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ PhoneAccountHandle connectionManagerPhoneAccount =
+ (PhoneAccountHandle) args.arg1;
+ ConnectionRequest request = (ConnectionRequest) args.arg2;
+ boolean isIncoming = args.argi1 == 1;
+ createConnection(connectionManagerPhoneAccount, request, isIncoming);
+ } finally {
+ args.recycle();
+ }
break;
+ }
case MSG_ABORT:
abort((String) msg.obj);
break;
@@ -428,14 +444,17 @@ public abstract class ConnectionService extends Service {
* incoming call. In either case, telecomm will cycle through a set of services and call
* createConnection util a connection service cancels the process or completes it successfully.
*/
- private void createConnection(final ConnectionRequest request, boolean isIncoming) {
+ private void createConnection(
+ final PhoneAccountHandle callManagerAccount,
+ final ConnectionRequest request,
+ boolean isIncoming) {
Log.d(this, "call %s", request);
final Connection createdConnection;
if (isIncoming) {
- createdConnection = onCreateIncomingConnection(request);
+ createdConnection = onCreateIncomingConnection(callManagerAccount, request);
} else {
- createdConnection = onCreateOutgoingConnection(request);
+ createdConnection = onCreateOutgoingConnection(callManagerAccount, request);
}
if (createdConnection != null) {
@@ -641,40 +660,94 @@ public abstract class ConnectionService extends Service {
});
}
- public final RemoteConnection createRemoteIncomingConnection(ConnectionRequest request) {
- return mRemoteConnectionManager.createRemoteConnection(request, true);
+ /**
+ * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
+ * incoming request. This is used to attach to existing incoming calls.
+ *
+ * @param connectionManagerPhoneAccount See description at
+ * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
+ * @param request Details about the incoming call.
+ * @return The {@code Connection} object to satisfy this call, or {@code null} to
+ * not handle the call.
+ */
+ public final RemoteConnection createRemoteIncomingConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
+ ConnectionRequest request) {
+ return mRemoteConnectionManager.createRemoteConnection(
+ connectionManagerPhoneAccount, request, true);
}
- public final RemoteConnection createRemoteOutgoingConnection(ConnectionRequest request) {
- return mRemoteConnectionManager.createRemoteConnection(request, false);
+ /**
+ * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
+ * outgoing request. This is used to initiate new outgoing calls.
+ *
+ * @param connectionManagerPhoneAccount See description at
+ * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
+ * @param request Details about the incoming call.
+ * @return The {@code Connection} object to satisfy this call, or {@code null} to
+ * not handle the call.
+ */
+ public final RemoteConnection createRemoteOutgoingConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
+ ConnectionRequest request) {
+ return mRemoteConnectionManager.createRemoteConnection(
+ connectionManagerPhoneAccount, request, false);
}
/**
- * Returns all connections currently associated with this connection service.
+ * Returns all the active {@code Connection}s for which this {@code ConnectionService}
+ * has taken responsibility.
+ *
+ * @return A collection of {@code Connection}s created by this {@code ConnectionService}.
*/
public final Collection<Connection> getAllConnections() {
return mConnectionById.values();
}
/**
- * Create a Connection given an incoming request. This is used to attach to existing incoming
- * calls.
- * @param request Details about the incoming call.
+ * Create a {@code Connection} given an incoming request. This is used to attach to existing
+ * incoming calls.
*
- * @return The {@link Connection} object to satisfy this call, or {@code null} to not handle
- * the call.
+ * @param connectionManagerPhoneAccount See description at
+ * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
+ * @param request Details about the incoming call.
+ * @return The {@code Connection} object to satisfy this call, or {@code null} to
+ * not handle the call.
*/
- public Connection onCreateIncomingConnection(ConnectionRequest request) { return null; }
+ public Connection onCreateIncomingConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
+ ConnectionRequest request) {
+ return null;
+ }
/**
- * Create a Connection given an outgoing request. This is used to initiate new outgoing calls.
- * @param request Details about the outgoing call.
- *
- * @return The {@link Connection} object to satisfy this request,
- * or null to not handle the call.
+ * Create a {@code Connection} given an outgoing request. This is used to initiate new
+ * outgoing calls.
*
+ * @param connectionManagerPhoneAccount The connection manager account to use for managing
+ * this call.
+ * <p>
+ * If this parameter is not {@code null}, it means that this {@code ConnectionService}
+ * has registered one or more {@code PhoneAccount}s having
+ * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain
+ * one of these {@code PhoneAccount}s, while the {@code request} will contain another
+ * (usually but not always distinct) {@code PhoneAccount} to be used for actually
+ * making the connection.
+ * <p>
+ * If this parameter is {@code null}, it means that this {@code ConnectionService} is
+ * being asked to make a direct connection. The
+ * {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be
+ * a {@code PhoneAccount} registered by this {@code ConnectionService} to use for
+ * making the connection.
+ * @param request Details about the outgoing call.
+ * @return The {@code Connection} object to satisfy this call, or the result of an invocation
+ * of {@link Connection#getFailedConnection(int, String)} to not handle the call.
*/
- public Connection onCreateOutgoingConnection(ConnectionRequest request) { return null; }
+ public Connection onCreateOutgoingConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
+ ConnectionRequest request) {
+ return null;
+ }
/**
* Returns a new or existing conference connection when the the user elects to convert the
diff --git a/telecomm/java/android/telecomm/PhoneAccount.java b/telecomm/java/android/telecomm/PhoneAccount.java
index 1f9071e..0fea7ba 100644
--- a/telecomm/java/android/telecomm/PhoneAccount.java
+++ b/telecomm/java/android/telecomm/PhoneAccount.java
@@ -32,24 +32,24 @@ import java.util.MissingResourceException;
public class PhoneAccount implements Parcelable {
/**
- * Flag indicating that this {@code PhoneAccount} can act as a call manager for
- * traditional SIM-based telephony calls. The {@link ConnectionService} associated with this
- * phone-account will be allowed to manage SIM-based phone calls including using its own
- * proprietary phone-call implementation (like VoIP calling) to make calls instead of the
- * telephony stack.
+ * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
+ * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
+ * will be allowed to manage phone calls including using its own proprietary phone-call
+ * implementation (like VoIP calling) to make calls instead of the telephony stack.
+ * <p>
* When a user opts to place a call using the SIM-based telephony stack, the connection-service
* associated with this phone-account will be attempted first if the user has explicitly
- * selected it to be used as the default call-manager.
+ * selected it to be used as the default connection manager.
* <p>
* See {@link #getCapabilities}
*/
- public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1;
+ public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
/**
* Flag indicating that this {@code PhoneAccount} can make phone calls in place of
* traditional SIM-based telephony calls. This account will be treated as a distinct method
* for placing calls alongside the traditional SIM-based telephony stack. This flag is
- * distinct from {@link #CAPABILITY_SIM_CALL_MANAGER} in that it is not allowed to manage
+ * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
* calls from or use the built-in telephony stack to place its calls.
* <p>
* See {@link #getCapabilities}
@@ -66,6 +66,11 @@ public class PhoneAccount implements Parcelable {
*/
public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
+ /**
+ * Flag indicating that this {@code PhoneAccount} is capable of video calling.
+ */
+ public static final int CAPABILITY_VIDEO_CALLING = 0x8;
+
private final PhoneAccountHandle mAccountHandle;
private final Uri mHandle;
private final String mSubscriptionNumber;
@@ -73,7 +78,6 @@ public class PhoneAccount implements Parcelable {
private final int mIconResId;
private final CharSequence mLabel;
private final CharSequence mShortDescription;
- private boolean mVideoCallingSupported;
public PhoneAccount(
PhoneAccountHandle account,
@@ -82,8 +86,7 @@ public class PhoneAccount implements Parcelable {
int capabilities,
int iconResId,
CharSequence label,
- CharSequence shortDescription,
- boolean supportsVideoCalling) {
+ CharSequence shortDescription) {
mAccountHandle = account;
mHandle = handle;
mSubscriptionNumber = subscriptionNumber;
@@ -91,7 +94,6 @@ public class PhoneAccount implements Parcelable {
mIconResId = iconResId;
mLabel = label;
mShortDescription = shortDescription;
- mVideoCallingSupported = supportsVideoCalling;
}
/**
@@ -189,15 +191,6 @@ public class PhoneAccount 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
//
@@ -216,7 +209,6 @@ public class PhoneAccount implements Parcelable {
out.writeInt(mIconResId);
out.writeCharSequence(mLabel);
out.writeCharSequence(mShortDescription);
- out.writeInt(mVideoCallingSupported ? 1 : 0);
}
public static final Creator<PhoneAccount> CREATOR
@@ -240,6 +232,5 @@ public class PhoneAccount implements Parcelable {
mIconResId = in.readInt();
mLabel = in.readCharSequence();
mShortDescription = in.readCharSequence();
- mVideoCallingSupported = in.readInt() == 1;
}
}
diff --git a/telecomm/java/android/telecomm/RemoteConnectionManager.java b/telecomm/java/android/telecomm/RemoteConnectionManager.java
index 3ca68a2..ce8bfbd 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionManager.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionManager.java
@@ -50,6 +50,7 @@ public class RemoteConnectionManager {
}
public RemoteConnection createRemoteConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request,
boolean isIncoming) {
PhoneAccountHandle accountHandle = request.getAccountHandle();
@@ -65,7 +66,8 @@ public class RemoteConnectionManager {
RemoteConnectionService remoteService = mRemoteConnectionServices.get(componentName);
if (remoteService != null) {
- return remoteService.createRemoteConnection(request, isIncoming);
+ return remoteService.createRemoteConnection(
+ connectionManagerPhoneAccount, request, isIncoming);
}
return null;
}
diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java
index e6f47d2..501e843 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionService.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionService.java
@@ -32,8 +32,6 @@ import com.android.internal.telecomm.IConnectionServiceAdapter;
import com.android.internal.telecomm.IVideoCallProvider;
import com.android.internal.telecomm.RemoteServiceCallback;
-import java.util.LinkedList;
-import java.util.List;
import java.util.UUID;
/**
@@ -421,7 +419,10 @@ final class RemoteConnectionService implements DeathRecipient {
release();
}
- final RemoteConnection createRemoteConnection(ConnectionRequest request, boolean isIncoming) {
+ final RemoteConnection createRemoteConnection(
+ PhoneAccountHandle connectionManagerPhoneAccount,
+ ConnectionRequest request,
+ boolean isIncoming) {
if (mConnectionId == null) {
String id = UUID.randomUUID().toString();
ConnectionRequest newRequest = new ConnectionRequest(
@@ -433,7 +434,10 @@ final class RemoteConnectionService implements DeathRecipient {
request.getVideoState());
mConnection = new RemoteConnection(mConnectionService, request, isIncoming);
try {
- mConnectionService.createConnection(newRequest, isIncoming);
+ mConnectionService.createConnection(
+ connectionManagerPhoneAccount,
+ newRequest,
+ isIncoming);
mConnectionId = id;
} catch (RemoteException e) {
mConnection = RemoteConnection.failure(DisconnectCause.ERROR_UNSPECIFIED,
diff --git a/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl b/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
index 05375c9..4b05fb9 100644
--- a/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
@@ -19,6 +19,7 @@ package com.android.internal.telecomm;
import android.os.Bundle;
import android.telecomm.CallAudioState;
import android.telecomm.ConnectionRequest;
+import android.telecomm.PhoneAccountHandle;
import com.android.internal.telecomm.IConnectionServiceAdapter;
@@ -32,7 +33,10 @@ import com.android.internal.telecomm.IConnectionServiceAdapter;
oneway interface IConnectionService {
void addConnectionServiceAdapter(in IConnectionServiceAdapter adapter);
- void createConnection(in ConnectionRequest request, boolean isIncoming);
+ void createConnection(
+ in PhoneAccountHandle connectionManagerPhoneAccount,
+ in ConnectionRequest request,
+ boolean isIncoming);
void abort(String callId);