summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk4
-rw-r--r--CleanSpec.mk1
-rw-r--r--api/current.txt34
-rw-r--r--telecomm/java/android/telecomm/CallInfo.aidl19
-rw-r--r--telecomm/java/android/telecomm/CallInfo.java213
-rw-r--r--telecomm/java/android/telecomm/CallService.java335
-rw-r--r--telecomm/java/android/telecomm/CallServiceDescriptor.java51
-rw-r--r--telecomm/java/android/telecomm/Connection.java199
-rw-r--r--telecomm/java/android/telecomm/ConnectionRequest.java6
-rw-r--r--telecomm/java/android/telecomm/ConnectionService.java423
-rw-r--r--telecomm/java/android/telecomm/ConnectionServiceAdapter.java (renamed from telecomm/java/android/telecomm/CallServiceAdapter.java)132
-rw-r--r--telecomm/java/android/telecomm/RemoteConnection.java44
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionManager.java6
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionService.java84
-rw-r--r--telecomm/java/android/telecomm/TelecommConstants.java9
-rw-r--r--telecomm/java/com/android/internal/telecomm/IConnectionService.aidl (renamed from telecomm/java/com/android/internal/telecomm/ICallService.aidl)18
-rw-r--r--telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl (renamed from telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl)17
17 files changed, 495 insertions, 1100 deletions
diff --git a/Android.mk b/Android.mk
index 0c5051c..581f2da 100644
--- a/Android.mk
+++ b/Android.mk
@@ -328,12 +328,12 @@ LOCAL_SRC_FILES += \
media/java/android/media/tv/ITvInputServiceCallback.aidl \
media/java/android/media/tv/ITvInputSession.aidl \
media/java/android/media/tv/ITvInputSessionCallback.aidl \
- telecomm/java/com/android/internal/telecomm/ICallService.aidl \
- telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl \
telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl \
telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl \
telecomm/java/com/android/internal/telecomm/ICallVideoProvider.aidl \
telecomm/java/com/android/internal/telecomm/ICallVideoClient.aidl \
+ telecomm/java/com/android/internal/telecomm/IConnectionService.aidl \
+ telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl \
telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \
telecomm/java/com/android/internal/telecomm/IInCallService.aidl \
telecomm/java/com/android/internal/telecomm/ITelecommService.aidl \
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 20e48f9..2c9ea54 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -209,6 +209,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framew
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework2_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates/src/telecomm/java/com/android/internal/telecomm)
# ******************************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST ABOVE THIS BANNER
diff --git a/api/current.txt b/api/current.txt
index 07524ee..92dce76 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -27536,21 +27536,6 @@ package android.telecomm {
field public static final int VoWIFI = 2; // 0x2
}
- public final class CallInfo implements android.os.Parcelable {
- ctor public CallInfo(java.lang.String, android.telecomm.CallState, android.net.Uri);
- method public int describeContents();
- method public android.telecomm.PhoneAccount getAccount();
- method public android.telecomm.CallServiceDescriptor getCurrentCallServiceDescriptor();
- method public android.os.Bundle getExtras();
- method public android.telecomm.GatewayInfo getGatewayInfo();
- method public android.net.Uri getHandle();
- method public java.lang.String getId();
- method public android.net.Uri getOriginalHandle();
- method public android.telecomm.CallState getState();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator CREATOR;
- }
-
public final class CallNumberPresentation extends java.lang.Enum {
method public static android.telecomm.CallNumberPresentation valueOf(java.lang.String);
method public static final android.telecomm.CallNumberPresentation[] values();
@@ -27560,15 +27545,9 @@ package android.telecomm {
enum_constant public static final android.telecomm.CallNumberPresentation UNKNOWN;
}
- public abstract class CallService extends android.app.Service {
- ctor public CallService();
- method public final android.os.IBinder getBinder();
- method public final android.os.IBinder onBind(android.content.Intent);
- }
-
public final class CallServiceDescriptor implements android.os.Parcelable {
method public int describeContents();
- method public java.lang.String getCallServiceId();
+ method public java.lang.String getConnectionServiceId();
method public int getNetworkType();
method public android.content.ComponentName getServiceComponent();
method public static android.telecomm.CallServiceDescriptor.Builder newBuilder(android.content.Context);
@@ -27581,7 +27560,7 @@ package android.telecomm {
public static class CallServiceDescriptor.Builder {
method public android.telecomm.CallServiceDescriptor build();
- method public android.telecomm.CallServiceDescriptor.Builder setCallService(java.lang.Class<? extends android.telecomm.CallService>);
+ method public android.telecomm.CallServiceDescriptor.Builder setConnectionService(java.lang.Class<? extends android.telecomm.ConnectionService>);
method public android.telecomm.CallServiceDescriptor.Builder setNetworkType(int);
}
@@ -27654,7 +27633,6 @@ package android.telecomm {
method protected void onAbort();
method protected void onAnswer();
method protected void onChildrenChanged(java.util.List<android.telecomm.Connection>);
- method protected void onConference();
method protected void onDisconnect();
method protected void onHold();
method protected void onPhoneAccountClicked();
@@ -27705,12 +27683,13 @@ package android.telecomm {
field public static final android.os.Parcelable.Creator CREATOR;
}
- public abstract class ConnectionService extends android.telecomm.CallService {
+ public abstract class ConnectionService extends android.app.Service {
ctor public ConnectionService();
method public final void createRemoteOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.ConnectionService.OutgoingCallResponse<android.telecomm.RemoteConnection>);
method public final java.util.Collection<android.telecomm.Connection> getAllConnections();
method public final void lookupRemoteAccounts(android.net.Uri, android.telecomm.SimpleResponse<android.net.Uri, java.util.List<android.telecomm.PhoneAccount>>);
method public final void maybeRespondToAccountLookup();
+ method public final android.os.IBinder onBind(android.content.Intent);
method protected void onConnectionAdded(android.telecomm.Connection);
method protected void onConnectionRemoved(android.telecomm.Connection);
method protected void onCreateConferenceConnection(java.lang.String, android.telecomm.Connection, android.telecomm.Response<java.lang.String, android.telecomm.Connection>);
@@ -27828,6 +27807,7 @@ package android.telecomm {
method public void disconnect();
method public int getDisconnectCause();
method public java.lang.String getDisconnectMessage();
+ method public int getFeatures();
method public int getState();
method public void hold();
method public void playDtmf(char);
@@ -27842,6 +27822,7 @@ package android.telecomm {
public static abstract interface RemoteConnection.Listener {
method public abstract void onDestroyed(android.telecomm.RemoteConnection);
method public abstract void onDisconnected(android.telecomm.RemoteConnection, int, java.lang.String);
+ method public abstract void onFeaturesChanged(android.telecomm.RemoteConnection, int);
method public abstract void onPostDialWait(android.telecomm.RemoteConnection, java.lang.String);
method public abstract void onRequestingRingback(android.telecomm.RemoteConnection, boolean);
method public abstract void onStateChanged(android.telecomm.RemoteConnection, int);
@@ -27859,14 +27840,15 @@ package android.telecomm {
public final class TelecommConstants {
ctor public TelecommConstants();
- field public static final java.lang.String ACTION_CALL_SERVICE;
field public static final java.lang.String ACTION_CALL_SERVICE_PROVIDER;
+ field public static final java.lang.String ACTION_CONNECTION_SERVICE;
field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL";
field public static final char DTMF_CHARACTER_PAUSE = 44; // 0x002c ','
field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';'
field public static final java.lang.String EXTRA_CALL_DISCONNECT_CAUSE = "android.telecomm.extra.CALL_DISCONNECT_CAUSE";
field public static final java.lang.String EXTRA_CALL_DISCONNECT_MESSAGE = "android.telecomm.extra.CALL_DISCONNECT_MESSAGE";
field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR";
+ field public static final java.lang.String EXTRA_CONNECTION_SERVICE = "android.telecomm.extra.CONNECTION_SERVICE";
field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS";
field public static final java.lang.String EXTRA_START_CALL_WITH_SPEAKERPHONE = "android.intent.extra.START_CALL_WITH_SPEAKERPHONE";
field public static final java.lang.String EXTRA_START_CALL_WITH_VIDEO = "android.intent.extra.START_CALL_WITH_VIDEO";
diff --git a/telecomm/java/android/telecomm/CallInfo.aidl b/telecomm/java/android/telecomm/CallInfo.aidl
deleted file mode 100644
index bc5ef96..0000000
--- a/telecomm/java/android/telecomm/CallInfo.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2013, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telecomm;
-
-parcelable CallInfo;
diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java
deleted file mode 100644
index 3810d7c..0000000
--- a/telecomm/java/android/telecomm/CallInfo.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2013, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telecomm;
-
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * A parcelable holder class of Call information data. This class is intended for transferring call
- * information from Telecomm to call services and thus is read-only.
- * TODO(santoscordon): Need final public-facing comments in this file.
- */
-public final class CallInfo implements Parcelable {
-
- /**
- * Unique identifier for the call.
- */
- private final String mId;
-
- /**
- * The state of the call.
- */
- private final CallState mState;
-
- /**
- * Endpoint to which the call is connected.
- * This could be the dialed value for outgoing calls or the caller id of incoming calls.
- */
- private final Uri mHandle;
-
- /**
- * Gateway information for the call.
- */
- private final GatewayInfo mGatewayInfo;
-
- /**
- * Account information for the call.
- */
- private final PhoneAccount mAccount;
-
- /**
- * Additional information that can be persisted.
- */
- private final Bundle mExtras;
-
- /** The descriptor for the call service currently routing this call. */
- private final CallServiceDescriptor mCurrentCallServiceDescriptor;
-
- public CallInfo(String id, CallState state, Uri handle) {
- this(id, state, handle, null, null, Bundle.EMPTY, null);
- }
-
- /**
- * Persists handle of the other party of this call.
- *
- * @param id The unique ID of the call.
- * @param state The state of the call.
- * @param handle The handle to the other party in this call.
- * @param gatewayInfo Gateway information pertaining to this call.
- * @param account Account information pertaining to this call.
- * @param extras Additional information that can be persisted.
- * @param currentCallServiceDescriptor The descriptor for the call service currently routing
- * this call.
- *
- * @hide
- */
- public CallInfo(
- String id,
- CallState state,
- Uri handle,
- GatewayInfo gatewayInfo,
- PhoneAccount account,
- Bundle extras,
- CallServiceDescriptor currentCallServiceDescriptor) {
- mId = id;
- mState = state;
- mHandle = handle;
- mGatewayInfo = gatewayInfo;
- mAccount = account;
- mExtras = extras;
- mCurrentCallServiceDescriptor = currentCallServiceDescriptor;
- }
-
- public String getId() {
- return mId;
- }
-
- public CallState getState() {
- return mState;
- }
-
- public Uri getHandle() {
- return mHandle;
- }
-
- /**
- * @return The actual handle this call is associated with. This is used by call services to
- * correctly indicate in their UI what handle the user is actually calling, and by other
- * telecomm components that require the user-dialed handle to function.
- */
- public Uri getOriginalHandle() {
- if (mGatewayInfo != null) {
- return mGatewayInfo.getOriginalHandle();
- }
- return getHandle();
- }
-
- public GatewayInfo getGatewayInfo() {
- return mGatewayInfo;
- }
-
- public PhoneAccount getAccount() {
- return mAccount;
- }
-
- public Bundle getExtras() {
- return mExtras;
- }
-
- public CallServiceDescriptor getCurrentCallServiceDescriptor() {
- return mCurrentCallServiceDescriptor;
- }
-
- /**
- * Responsible for creating CallInfo objects for deserialized Parcels.
- */
- public static final Parcelable.Creator<CallInfo> CREATOR = new Parcelable.Creator<CallInfo> () {
- @Override
- public CallInfo createFromParcel(Parcel source) {
- String id = source.readString();
- CallState state = CallState.valueOf(source.readString());
- Uri handle = Uri.CREATOR.createFromParcel(source);
-
- GatewayInfo gatewayInfo = readProviderInfoIfExists(source, GatewayInfo.CREATOR);
- PhoneAccount account = readProviderInfoIfExists(source, PhoneAccount.CREATOR);
-
- ClassLoader classLoader = CallInfo.class.getClassLoader();
- Bundle extras = source.readParcelable(classLoader);
- CallServiceDescriptor descriptor = source.readParcelable(classLoader);
- return new CallInfo(id, state, handle, gatewayInfo, account, extras, descriptor);
- }
-
- @Override
- public CallInfo[] newArray(int size) {
- return new CallInfo[size];
- }
- };
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /**
- * Writes CallInfo object into a serializeable Parcel.
- */
- @Override
- public void writeToParcel(Parcel destination, int flags) {
- destination.writeString(mId);
- destination.writeString(mState.name());
- mHandle.writeToParcel(destination, 0);
-
- writeProviderInfoIfExists(destination, mGatewayInfo);
- writeProviderInfoIfExists(destination, mAccount);
-
- destination.writeParcelable(mExtras, 0);
- destination.writeParcelable(mCurrentCallServiceDescriptor, 0);
- }
-
- /**
- * Helper function to write provider information (either GatewayInfo or Account) to
- * parcel. Will write a false byte if the information does not exist.
- */
- private void writeProviderInfoIfExists(Parcel destination, Parcelable provider) {
- if (provider != null) {
- destination.writeByte((byte) 1);
- provider.writeToParcel(destination, 0);
- } else {
- destination.writeByte((byte) 0);
- }
- }
-
- /**
- * Helper function to read provider information (either GatewayInfo or Account) from
- * parcel.
- */
- private static <T> T readProviderInfoIfExists(Parcel source,
- Parcelable.Creator<T> creator) {
- if (source.readByte() != 0) {
- return creator.createFromParcel(source);
- }
- return null;
- }
-}
diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java
deleted file mode 100644
index e77fb23..0000000
--- a/telecomm/java/android/telecomm/CallService.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telecomm;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-
-import com.android.internal.os.SomeArgs;
-import com.android.internal.telecomm.ICallService;
-import com.android.internal.telecomm.ICallServiceAdapter;
-
-/**
- * Base implementation of CallService which can be used to provide calls for the system
- * in-call UI. CallService is a one-way service from the framework's CallsManager to any app
- * that would like to provide calls managed by the default system in-call user interface.
- * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before
- * we can unhide this API.
- *
- * Most public methods of this function are backed by a one-way AIDL interface which precludes
- * synchronous responses. As a result, most responses are handled by (or have TODOs to handle)
- * response objects instead of return values.
- * TODO(santoscordon): Improve paragraph above once the final design is in place.
- */
-public abstract class CallService extends Service {
-
- private static final int MSG_SET_CALL_SERVICE_ADAPTER = 1;
- private static final int MSG_CALL = 2;
- private static final int MSG_ABORT = 3;
- private static final int MSG_SET_INCOMING_CALL_ID = 4;
- private static final int MSG_ANSWER = 5;
- private static final int MSG_REJECT = 6;
- private static final int MSG_DISCONNECT = 7;
- private static final int MSG_HOLD = 8;
- private static final int MSG_UNHOLD = 9;
- private static final int MSG_ON_AUDIO_STATE_CHANGED = 10;
- private static final int MSG_PLAY_DTMF_TONE = 11;
- private static final int MSG_STOP_DTMF_TONE = 12;
- private static final int MSG_CONFERENCE = 13;
- private static final int MSG_SPLIT_FROM_CONFERENCE = 14;
- private static final int MSG_ON_POST_DIAL_CONTINUE = 15;
- private static final int MSG_ON_PHONE_ACCOUNT_CLICKED = 16;
-
- /**
- * Default Handler used to consolidate binder method calls onto a single thread.
- */
- private final class CallServiceMessageHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_SET_CALL_SERVICE_ADAPTER:
- mAdapter.addAdapter((ICallServiceAdapter) msg.obj);
- onAdapterAttached(mAdapter);
- break;
- case MSG_CALL:
- call((CallInfo) msg.obj);
- break;
- case MSG_ABORT:
- abort((String) msg.obj);
- break;
- case MSG_SET_INCOMING_CALL_ID: {
- SomeArgs args = (SomeArgs) msg.obj;
- try {
- String callId = (String) args.arg1;
- Bundle extras = (Bundle) args.arg2;
- setIncomingCallId(callId, extras);
- } finally {
- args.recycle();
- }
- break;
- }
- case MSG_ANSWER:
- answer((String) msg.obj);
- break;
- case MSG_REJECT:
- reject((String) msg.obj);
- break;
- case MSG_DISCONNECT:
- disconnect((String) msg.obj);
- break;
- case MSG_HOLD:
- hold((String) msg.obj);
- break;
- case MSG_UNHOLD:
- unhold((String) msg.obj);
- break;
- case MSG_ON_AUDIO_STATE_CHANGED: {
- SomeArgs args = (SomeArgs) msg.obj;
- try {
- String callId = (String) args.arg1;
- CallAudioState audioState = (CallAudioState) args.arg2;
- onAudioStateChanged(callId, audioState);
- } finally {
- args.recycle();
- }
- break;
- }
- case MSG_PLAY_DTMF_TONE:
- playDtmfTone((String) msg.obj, (char) msg.arg1);
- break;
- case MSG_STOP_DTMF_TONE:
- stopDtmfTone((String) msg.obj);
- break;
- case MSG_CONFERENCE: {
- SomeArgs args = (SomeArgs) msg.obj;
- try {
- String conferenceCallId = (String) args.arg1;
- String callId = (String) args.arg2;
- conference(conferenceCallId, callId);
- } finally {
- args.recycle();
- }
- break;
- }
- case MSG_ON_POST_DIAL_CONTINUE: {
- SomeArgs args = (SomeArgs) msg.obj;
- try {
- String callId = (String) args.arg1;
- boolean proceed = (args.argi1 == 1);
- onPostDialContinue(callId, proceed);
- } finally {
- args.recycle();
- }
- break;
- }
- case MSG_SPLIT_FROM_CONFERENCE:
- splitFromConference((String) msg.obj);
- break;
- case MSG_ON_PHONE_ACCOUNT_CLICKED:
- onPhoneAccountClicked((String) msg.obj);
- break;
- default:
- break;
- }
- }
- }
-
- /**
- * Default ICallService implementation provided to CallsManager via {@link #onBind}.
- */
- private final class CallServiceBinder extends ICallService.Stub {
- @Override
- public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) {
- mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter)
- .sendToTarget();
- }
-
- @Override
- public void call(CallInfo callInfo) {
- mMessageHandler.obtainMessage(MSG_CALL, callInfo).sendToTarget();
- }
-
- @Override
- public void abort(String callId) {
- mMessageHandler.obtainMessage(MSG_ABORT, callId).sendToTarget();
- }
-
- @Override
- public void setIncomingCallId(String callId, Bundle extras) {
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = callId;
- args.arg2 = extras;
- mMessageHandler.obtainMessage(MSG_SET_INCOMING_CALL_ID, args).sendToTarget();
- }
-
- @Override
- public void answer(String callId) {
- mMessageHandler.obtainMessage(MSG_ANSWER, callId).sendToTarget();
- }
-
- @Override
- public void reject(String callId) {
- mMessageHandler.obtainMessage(MSG_REJECT, callId).sendToTarget();
- }
-
- @Override
- public void disconnect(String callId) {
- mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget();
- }
-
- @Override
- public void hold(String callId) {
- mMessageHandler.obtainMessage(MSG_HOLD, callId).sendToTarget();
- }
-
- @Override
- public void unhold(String callId) {
- mMessageHandler.obtainMessage(MSG_UNHOLD, callId).sendToTarget();
- }
-
- @Override
- public void playDtmfTone(String callId, char digit) {
- mMessageHandler.obtainMessage(MSG_PLAY_DTMF_TONE, digit, 0, callId).sendToTarget();
- }
-
- @Override
- public void stopDtmfTone(String callId) {
- mMessageHandler.obtainMessage(MSG_STOP_DTMF_TONE, callId).sendToTarget();
- }
-
- @Override
- public void onAudioStateChanged(String callId, CallAudioState audioState) {
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = callId;
- args.arg2 = audioState;
- mMessageHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, args).sendToTarget();
- }
-
- @Override
- public void conference(String conferenceCallId, String callId) {
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = conferenceCallId;
- args.arg2 = callId;
- mMessageHandler.obtainMessage(MSG_CONFERENCE, args).sendToTarget();
- }
-
- @Override
- public void splitFromConference(String callId) {
- mMessageHandler.obtainMessage(MSG_SPLIT_FROM_CONFERENCE, callId).sendToTarget();
- }
-
- @Override
- public void onPostDialContinue(String callId, boolean proceed) {
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = callId;
- args.argi1 = proceed ? 1 : 0;
- mMessageHandler.obtainMessage(MSG_ON_POST_DIAL_CONTINUE, args).sendToTarget();
- }
-
- @Override
- public void onPhoneAccountClicked(String callId) {
- mMessageHandler.obtainMessage(MSG_ON_PHONE_ACCOUNT_CLICKED, callId).sendToTarget();
- }
-
- }
-
- /**
- * Message handler for consolidating binder callbacks onto a single thread.
- * See {@link CallServiceMessageHandler}.
- */
- private final CallServiceMessageHandler mMessageHandler = new CallServiceMessageHandler();
-
- /**
- * Default binder implementation of {@link ICallService} interface.
- */
- private final CallServiceBinder mBinder = new CallServiceBinder();
-
- private CallServiceAdapter mAdapter = new CallServiceAdapter();
-
- /** {@inheritDoc} */
- @Override
- public final IBinder onBind(Intent intent) {
- return getBinder();
- }
-
- /**
- * Returns binder object which can be used across IPC methods.
- */
- public final IBinder getBinder() {
- return mBinder;
- }
-
- /** @hide */
- protected final CallServiceAdapter getAdapter() {
- return mAdapter;
- }
-
- /** @hide */
- protected abstract void onAdapterAttached(CallServiceAdapter adapter);
-
- /** @hide */
- protected abstract void call(CallInfo callInfo);
-
- /** @hide */
- protected abstract void abort(String callId);
-
- /** @hide */
- protected abstract void setIncomingCallId(String callId, Bundle extras);
-
- /** @hide */
- protected abstract void answer(String callId);
-
- /** @hide */
- protected abstract void reject(String callId);
-
- /** @hide */
- protected abstract void disconnect(String callId);
-
- /** @hide */
- protected abstract void hold(String callId);
-
- /** @hide */
- protected abstract void unhold(String callId);
-
- /** @hide */
- protected abstract void playDtmfTone(String callId, char digit);
-
- /** @hide */
- protected abstract void stopDtmfTone(String callId);
-
- /** @hide */
- protected abstract void onAudioStateChanged(String activeCallId, CallAudioState audioState);
-
- /** @hide */
- protected abstract void conference(String conferenceCallId, String callId);
-
- /** @hide */
- protected abstract void splitFromConference(String callId);
-
- /** @hide */
- protected abstract void onPostDialContinue(String callId, boolean proceed);
-
- /** @hide */
- protected abstract void onFeaturesChanged(String callId, int features);
-
- /** @hide */
- protected abstract void onPhoneAccountClicked(String callId);
-}
diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.java b/telecomm/java/android/telecomm/CallServiceDescriptor.java
index dec3791..5ae07d3 100644
--- a/telecomm/java/android/telecomm/CallServiceDescriptor.java
+++ b/telecomm/java/android/telecomm/CallServiceDescriptor.java
@@ -26,7 +26,7 @@ import java.util.Locale;
import java.util.UUID;
/**
- * An immutable object containing information about a given {@link CallService}. Instances are
+ * An immutable object containing information about a given {@link ConnectionService}. Instances are
* created using the enclosed {@link Builder}.
*/
public final class CallServiceDescriptor implements Parcelable {
@@ -40,19 +40,19 @@ public final class CallServiceDescriptor implements Parcelable {
/**
* Indicates that the device must be connected to a Wi-Fi network in order for the backing
- * {@link CallService} to be used.
+ * {@link ConnectionService} to be used.
*/
public static final int FLAG_WIFI = 0x01;
/**
* Indicates that the device must be connected to a cellular PSTN network in order for the
- * backing {@link CallService} to be used.
+ * backing {@link ConnectionService} to be used.
*/
public static final int FLAG_PSTN = 0x02;
/**
* Indicates that the device must be connected to a cellular data network in order for the
- * backing {@link CallService} to be used.
+ * backing {@link ConnectionService} to be used.
*/
public static final int FLAG_MOBILE = 0x04;
@@ -65,45 +65,46 @@ public final class CallServiceDescriptor implements Parcelable {
/**
* A unique ID used to identify a given instance.
*/
- private final String mCallServiceId;
+ private final String mConnectionServiceId;
/**
- * The {@link ComponentName} of the {@link CallService} implementation which this is describing.
+ * The {@link ComponentName} of the {@link ConnectionService} implementation which this is
+ * describing.
*/
private final ComponentName mComponentName;
/**
- * The type of connection that the {@link CallService} requires; will be one of the FLAG_*
+ * The type of connection that the {@link ConnectionService} requires; will be one of the FLAG_*
* constants defined in this class.
*/
private final int mNetworkType;
private CallServiceDescriptor(
- String callServiceId,
+ String connectionServiceId,
ComponentName componentName,
int networkType) {
- mCallServiceId = callServiceId;
+ mConnectionServiceId = connectionServiceId;
mComponentName = componentName;
mNetworkType = networkType;
}
/**
- * @return The ID used to identify this {@link CallService}.
+ * @return The ID used to identify this {@link ConnectionService}.
*/
- public String getCallServiceId() {
- return mCallServiceId;
+ public String getConnectionServiceId() {
+ return mConnectionServiceId;
}
/**
- * @return The {@link ComponentName} of the {@link CallService}.
+ * @return The {@link ComponentName} of the {@link ConnectionService}.
*/
public ComponentName getServiceComponent() {
return mComponentName;
}
/**
- * @return The network type required by the {@link CallService} to place a call.
+ * @return The network type required by the {@link ConnectionService} to place a call.
*/
public int getNetworkType() {
return mNetworkType;
@@ -119,7 +120,7 @@ public final class CallServiceDescriptor implements Parcelable {
return false;
}
CallServiceDescriptor descriptor = (CallServiceDescriptor) obj;
- return mCallServiceId.equals(descriptor.mCallServiceId) &&
+ return mConnectionServiceId.equals(descriptor.mConnectionServiceId) &&
mComponentName.equals(descriptor.mComponentName) &&
mNetworkType == descriptor.mNetworkType;
}
@@ -147,10 +148,10 @@ public final class CallServiceDescriptor implements Parcelable {
/** The {@link Context} to use to verify {@link ComponentName} ownership. */
private Context mContext;
- /** The {@link ComponentName} pointing to the backing {@link CallService}. */
+ /** The {@link ComponentName} pointing to the backing {@link ConnectionService}. */
private ComponentName mComponentName;
- /** The required network type that the {@link CallService} needs. */
+ /** The required network type that the {@link ConnectionService} needs. */
private int mNetworkType = FLAG_INVALID;
private Builder(Context context) {
@@ -158,21 +159,21 @@ public final class CallServiceDescriptor implements Parcelable {
}
/**
- * Set which {@link CallService} this {@link CallServiceDescriptor} is describing.
+ * Set which {@link ConnectionService} this {@link CallServiceDescriptor} is describing.
*
- * @param callServiceClass The {@link CallService} class
+ * @param serviceClass The {@link ConnectionService} class
* @return This {@link Builder} for method chaining.
*/
- public Builder setCallService(Class<? extends CallService> callServiceClass) {
- mComponentName = new ComponentName(mContext, callServiceClass);
+ public Builder setConnectionService(Class<? extends ConnectionService> serviceClass) {
+ mComponentName = new ComponentName(mContext, serviceClass);
return this;
}
/**
- * Which network type the backing {@link CallService} requires. This must be one of the
- * {@link CallServiceDescriptor}.TYPE_* fields.
+ * Which network type the backing {@link ConnectionService} requires. This must be one of
+ * the {@link CallServiceDescriptor}.TYPE_* fields.
*
- * @param networkType Which network type the backing {@link CallService} requires.
+ * @param networkType Which network type the backing {@link ConnectionService} requires.
* @return This {@link Builder} for method chaining.
*/
public Builder setNetworkType(int networkType) {
@@ -207,7 +208,7 @@ public final class CallServiceDescriptor implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(mCallServiceId);
+ dest.writeString(mConnectionServiceId);
dest.writeParcelable(mComponentName, 0);
dest.writeInt(mNetworkType);
}
diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java
index 32dcf6c..c55e5ab 100644
--- a/telecomm/java/android/telecomm/Connection.java
+++ b/telecomm/java/android/telecomm/Connection.java
@@ -35,7 +35,6 @@ public abstract class Connection {
public interface Listener {
void onStateChanged(Connection c, int state);
void onFeaturesChanged(Connection c, int features);
- void onAudioStateChanged(Connection c, CallAudioState state);
void onHandleChanged(Connection c, Uri newHandle);
void onSignalChanged(Connection c, Bundle details);
void onDisconnected(Connection c, int cause, String message);
@@ -56,10 +55,6 @@ public abstract class Connection {
@Override
public void onFeaturesChanged(Connection c, int features) {}
- /** {@inheritDoc} */
- @Override
- public void onAudioStateChanged(Connection c, CallAudioState state) {}
-
@Override
public void onHandleChanged(Connection c, Uri newHandle) {}
@@ -141,7 +136,9 @@ public abstract class Connection {
* @return The features of the call. These are items for which the InCall UI may wish to
* display a visual indicator.
*/
- public final int getFeatures() { return mFeatures; }
+ public final int getFeatures() {
+ return mFeatures;
+ }
/**
* @return The audio state of the call, describing how its audio is currently
@@ -153,6 +150,21 @@ public abstract class Connection {
}
/**
+ * Returns whether this connection is requesting that the system play a ringback tone
+ * on its behalf.
+ */
+ public final boolean isRequestingRingback() {
+ return mRequestingRingback;
+ }
+
+ /**
+ * Returns whether this connection is a conference connection (has child connections).
+ */
+ public final boolean isConferenceConnection() {
+ return !mChildConnections.isEmpty();
+ }
+
+ /**
* Assign a listener to be notified of state changes.
*
* @param l A listener.
@@ -179,151 +191,14 @@ public abstract class Connection {
}
/**
- * Play a DTMF tone in this Connection.
- *
- * @param c A DTMF character.
- *
- * @hide
- */
- public final void playDtmfTone(char c) {
- Log.d(this, "playDtmfTone %c", c);
- onPlayDtmfTone(c);
- }
-
- /**
- * Stop any DTMF tones which may be playing in this Connection.
- *
- * @hide
- */
- public final void stopDtmfTone() {
- Log.d(this, "stopDtmfTone");
- onStopDtmfTone();
- }
-
- /**
- * Disconnect this Connection. If and when the Connection can comply with
- * this request, it will transition to the {@link State#DISCONNECTED}
- * state and notify its listeners.
- *
- * @hide
- */
- public final void disconnect() {
- Log.d(this, "disconnect");
- onDisconnect();
- }
-
- /**
- * Separates this Connection from a parent connection.
- *
- * @hide
- */
- public final void separate() {
- Log.d(this, "separate");
- onSeparate();
- }
-
- /**
- * Abort this Connection. The Connection will immediately transition to
- * the {@link State#DISCONNECTED} state, and send no notifications of this
- * or any other future events.
- *
- * @hide
- */
- public final void abort() {
- Log.d(this, "abort");
- onAbort();
- }
-
- /**
- * Place this Connection on hold. If and when the Connection can comply with
- * this request, it will transition to the {@link State#HOLDING}
- * state and notify its listeners.
- *
- * @hide
- */
- public final void hold() {
- Log.d(this, "hold");
- onHold();
- }
-
- /**
- * Un-hold this Connection. If and when the Connection can comply with
- * this request, it will transition to the {@link State#ACTIVE}
- * state and notify its listeners.
- *
- * @hide
- */
- public final void unhold() {
- Log.d(this, "unhold");
- onUnhold();
- }
-
- /**
- * Accept a {@link State#RINGING} Connection. If and when the Connection
- * can comply with this request, it will transition to the {@link State#ACTIVE}
- * state and notify its listeners.
- *
- * @hide
- */
- public final void answer() {
- Log.d(this, "answer");
- if (mState == State.RINGING) {
- onAnswer();
- }
- }
-
- /**
- * Reject a {@link State#RINGING} Connection. If and when the Connection
- * can comply with this request, it will transition to the {@link State#ACTIVE}
- * state and notify its listeners.
- *
- * @hide
- */
- public final void reject() {
- Log.d(this, "reject");
- if (mState == State.RINGING) {
- onReject();
- }
- }
-
- /**
- * TODO(santoscordon): Needs updated documentation.
- *
- * @hide
- */
- public final void conference() {
- Log.d(this, "conference");
- onConference();
- }
-
- /**
- * Set the features applicable to the connection. These are items for which the InCall UI may
- * wish to display a visual indicator.
- * Features are defined in {@link android.telecomm.CallFeatures} and are passed in as a
- * bit-mask.
- *
- * @param features The features active.
- */
- public final void setFeatures(int features) {
- Log.d(this, "setFeatures %d", features);
- this.mFeatures = features;
- for (Listener l : mListeners) {
- l.onFeaturesChanged(this, mFeatures);
- }
- }
-
- /**
* Inform this Connection that the state of its audio output has been changed externally.
*
* @param state The new audio state.
* @hide
*/
- public final void setAudioState(CallAudioState state) {
+ final void setAudioState(CallAudioState state) {
Log.d(this, "setAudioState %s", state);
mCallAudioState = state;
- for (Listener l : mListeners) {
- l.onAudioStateChanged(this, state);
- }
onSetAudioState(state);
}
@@ -352,21 +227,6 @@ public abstract class Connection {
}
/**
- * Returns whether this connection is requesting that the system play a ringback tone
- * on its behalf.
- */
- public final boolean isRequestingRingback() {
- return mRequestingRingback;
- }
-
- /**
- * Returns whether this connection is a conference connection (has child connections).
- */
- public final boolean isConferenceConnection() {
- return !mChildConnections.isEmpty();
- }
-
- /**
* TODO(santoscordon): Needs documentation.
*/
public final void setParentConnection(Connection parentConnection) {
@@ -415,6 +275,22 @@ public abstract class Connection {
}
/**
+ * Set the features applicable to the connection. These are items for which the InCall UI may
+ * wish to display a visual indicator.
+ * Features are defined in {@link android.telecomm.CallFeatures} and are passed in as a
+ * bit-mask.
+ *
+ * @param features The features active.
+ */
+ public final void setFeatures(int features) {
+ Log.d(this, "setFeatures %d", features);
+ mFeatures = features;
+ for (Listener l : mListeners) {
+ l.onFeaturesChanged(this, mFeatures);
+ }
+ }
+
+ /**
* Sets state to active (e.g., an ongoing call where two or more parties can actively
* communicate).
*/
@@ -604,11 +480,6 @@ public abstract class Connection {
/**
* TODO(santoscordon): Needs documentation.
*/
- protected void onConference() {}
-
- /**
- * TODO(santoscordon): Needs documentation.
- */
protected void onChildrenChanged(List<Connection> children) {}
/**
diff --git a/telecomm/java/android/telecomm/ConnectionRequest.java b/telecomm/java/android/telecomm/ConnectionRequest.java
index a9aa5dd..ed61622 100644
--- a/telecomm/java/android/telecomm/ConnectionRequest.java
+++ b/telecomm/java/android/telecomm/ConnectionRequest.java
@@ -80,9 +80,6 @@ public final class ConnectionRequest implements Parcelable {
mExtras == null ? "" : mExtras);
}
- /**
- * Responsible for creating CallInfo objects for deserialized Parcels.
- */
public static final Parcelable.Creator<ConnectionRequest> CREATOR =
new Parcelable.Creator<ConnectionRequest> () {
@Override
@@ -107,9 +104,6 @@ public final class ConnectionRequest implements Parcelable {
return 0;
}
- /**
- * Writes CallInfo object into a serializeable Parcel.
- */
@Override
public void writeToParcel(Parcel destination, int flags) {
destination.writeString(mCallId);
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index d6970e2..3b763957 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -16,16 +16,19 @@
package android.telecomm;
+import android.app.Service;
+import android.content.Intent;
import android.content.ComponentName;
import android.net.Uri;
import android.os.Bundle;
-
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.telephony.DisconnectCause;
+import android.os.Message;
-import com.android.internal.telecomm.ICallService;
+import com.android.internal.os.SomeArgs;
+import com.android.internal.telecomm.IConnectionService;
+import com.android.internal.telecomm.IConnectionServiceAdapter;
import com.android.internal.telecomm.RemoteServiceCallback;
import java.util.Collection;
@@ -34,23 +37,39 @@ import java.util.List;
import java.util.Map;
/**
- * A {@link android.app.Service} that provides telephone connections to
- * processes running on an Android device.
+ * A {@link android.app.Service} that provides telephone connections to processes running on an
+ * Android device.
*/
-public abstract class ConnectionService extends CallService {
+public abstract class ConnectionService extends Service {
// Flag controlling whether PII is emitted into the logs
private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
private static final Connection NULL_CONNECTION = new Connection() {};
- // Mappings from Connections to IDs as understood by the current CallService implementation
+ private static final int MSG_ADD_CALL_SERVICE_ADAPTER = 1;
+ private static final int MSG_CALL = 2;
+ private static final int MSG_ABORT = 3;
+ private static final int MSG_CREATE_INCOMING_CALL = 4;
+ private static final int MSG_ANSWER = 5;
+ private static final int MSG_REJECT = 6;
+ private static final int MSG_DISCONNECT = 7;
+ private static final int MSG_HOLD = 8;
+ private static final int MSG_UNHOLD = 9;
+ private static final int MSG_ON_AUDIO_STATE_CHANGED = 10;
+ private static final int MSG_PLAY_DTMF_TONE = 11;
+ private static final int MSG_STOP_DTMF_TONE = 12;
+ private static final int MSG_CONFERENCE = 13;
+ private static final int MSG_SPLIT_FROM_CONFERENCE = 14;
+ private static final int MSG_ON_POST_DIAL_CONTINUE = 15;
+ private static final int MSG_ON_PHONE_ACCOUNT_CLICKED = 16;
+
private final Map<String, Connection> mConnectionById = new HashMap<>();
private final Map<Connection, String> mIdByConnection = new HashMap<>();
private final RemoteConnectionManager mRemoteConnectionManager = new RemoteConnectionManager();
- private final Handler mHandler = new Handler(Looper.getMainLooper());
private SimpleResponse<Uri, List<PhoneAccount>> mAccountLookupResponse;
private Uri mAccountLookupHandle;
private boolean mAreAccountsInitialized = false;
+ private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter();
/**
* A callback for providing the resuilt of creating a connection.
@@ -81,6 +100,180 @@ public abstract class ConnectionService extends CallService {
void onCancel(ConnectionRequest request);
}
+ private final IBinder mBinder = new IConnectionService.Stub() {
+ @Override
+ public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter) {
+ mHandler.obtainMessage(MSG_ADD_CALL_SERVICE_ADAPTER, adapter).sendToTarget();
+ }
+
+ @Override
+ public void call(ConnectionRequest request) {
+ mHandler.obtainMessage(MSG_CALL, request).sendToTarget();
+ }
+
+ @Override
+ public void abort(String callId) {
+ mHandler.obtainMessage(MSG_ABORT, callId).sendToTarget();
+ }
+
+ @Override
+ public void createIncomingCall(ConnectionRequest request) {
+ mHandler.obtainMessage(MSG_CREATE_INCOMING_CALL, request).sendToTarget();
+ }
+
+ @Override
+ public void answer(String callId) {
+ mHandler.obtainMessage(MSG_ANSWER, callId).sendToTarget();
+ }
+
+ @Override
+ public void reject(String callId) {
+ mHandler.obtainMessage(MSG_REJECT, callId).sendToTarget();
+ }
+
+ @Override
+ public void disconnect(String callId) {
+ mHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget();
+ }
+
+ @Override
+ public void hold(String callId) {
+ mHandler.obtainMessage(MSG_HOLD, callId).sendToTarget();
+ }
+
+ @Override
+ public void unhold(String callId) {
+ mHandler.obtainMessage(MSG_UNHOLD, callId).sendToTarget();
+ }
+
+ @Override
+ public void onAudioStateChanged(String callId, CallAudioState audioState) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = callId;
+ args.arg2 = audioState;
+ mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, args).sendToTarget();
+ }
+
+ @Override
+ public void playDtmfTone(String callId, char digit) {
+ mHandler.obtainMessage(MSG_PLAY_DTMF_TONE, digit, 0, callId).sendToTarget();
+ }
+
+ @Override
+ public void stopDtmfTone(String callId) {
+ mHandler.obtainMessage(MSG_STOP_DTMF_TONE, callId).sendToTarget();
+ }
+
+ @Override
+ public void conference(String conferenceCallId, String callId) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = conferenceCallId;
+ args.arg2 = callId;
+ mHandler.obtainMessage(MSG_CONFERENCE, args).sendToTarget();
+ }
+
+ @Override
+ public void splitFromConference(String callId) {
+ mHandler.obtainMessage(MSG_SPLIT_FROM_CONFERENCE, callId).sendToTarget();
+ }
+
+ @Override
+ public void onPostDialContinue(String callId, boolean proceed) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = callId;
+ args.argi1 = proceed ? 1 : 0;
+ mHandler.obtainMessage(MSG_ON_POST_DIAL_CONTINUE, args).sendToTarget();
+ }
+
+ @Override
+ public void onPhoneAccountClicked(String callId) {
+ mHandler.obtainMessage(MSG_ON_PHONE_ACCOUNT_CLICKED, callId).sendToTarget();
+ }
+ };
+
+ private final Handler mHandler = new Handler(Looper.getMainLooper()) {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_ADD_CALL_SERVICE_ADAPTER:
+ mAdapter.addAdapter((IConnectionServiceAdapter) msg.obj);
+ onAdapterAttached();
+ break;
+ case MSG_CALL:
+ call((ConnectionRequest) msg.obj);
+ break;
+ case MSG_ABORT:
+ abort((String) msg.obj);
+ break;
+ case MSG_CREATE_INCOMING_CALL:
+ createIncomingCall((ConnectionRequest) msg.obj);
+ break;
+ case MSG_ANSWER:
+ answer((String) msg.obj);
+ break;
+ case MSG_REJECT:
+ reject((String) msg.obj);
+ break;
+ case MSG_DISCONNECT:
+ disconnect((String) msg.obj);
+ break;
+ case MSG_HOLD:
+ hold((String) msg.obj);
+ break;
+ case MSG_UNHOLD:
+ unhold((String) msg.obj);
+ break;
+ case MSG_ON_AUDIO_STATE_CHANGED: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ String callId = (String) args.arg1;
+ CallAudioState audioState = (CallAudioState) args.arg2;
+ onAudioStateChanged(callId, audioState);
+ } finally {
+ args.recycle();
+ }
+ break;
+ }
+ case MSG_PLAY_DTMF_TONE:
+ playDtmfTone((String) msg.obj, (char) msg.arg1);
+ break;
+ case MSG_STOP_DTMF_TONE:
+ stopDtmfTone((String) msg.obj);
+ break;
+ case MSG_CONFERENCE: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ String conferenceCallId = (String) args.arg1;
+ String callId = (String) args.arg2;
+ conference(conferenceCallId, callId);
+ } finally {
+ args.recycle();
+ }
+ break;
+ }
+ case MSG_SPLIT_FROM_CONFERENCE:
+ splitFromConference((String) msg.obj);
+ break;
+ case MSG_ON_POST_DIAL_CONTINUE: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ String callId = (String) args.arg1;
+ boolean proceed = (args.argi1 == 1);
+ onPostDialContinue(callId, proceed);
+ } finally {
+ args.recycle();
+ }
+ break;
+ }
+ case MSG_ON_PHONE_ACCOUNT_CLICKED:
+ onPhoneAccountClicked((String) msg.obj);
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
private final Connection.Listener mConnectionListener = new Connection.Listener() {
@Override
public void onStateChanged(Connection c, int state) {
@@ -88,22 +281,22 @@ public abstract class ConnectionService extends CallService {
Log.d(this, "Adapter set state %s %s", id, Connection.stateToString(state));
switch (state) {
case Connection.State.ACTIVE:
- getAdapter().setActive(id);
+ mAdapter.setActive(id);
break;
case Connection.State.DIALING:
- getAdapter().setDialing(id);
+ mAdapter.setDialing(id);
break;
case Connection.State.DISCONNECTED:
// Handled in onDisconnected()
break;
case Connection.State.HOLDING:
- getAdapter().setOnHold(id);
+ mAdapter.setOnHold(id);
break;
case Connection.State.NEW:
// Nothing to tell Telecomm
break;
case Connection.State.RINGING:
- getAdapter().setRinging(id);
+ mAdapter.setRinging(id);
break;
}
}
@@ -113,14 +306,14 @@ public abstract class ConnectionService extends CallService {
public void onFeaturesChanged(Connection c, int features) {
String id = mIdByConnection.get(c);
Log.d(this, "Adapter set features %d", features);
- getAdapter().setFeatures(id, features);
+ mAdapter.setFeatures(id, features);
}
@Override
public void onDisconnected(Connection c, int cause, String message) {
String id = mIdByConnection.get(c);
Log.d(this, "Adapter set disconnected %d %s", cause, message);
- getAdapter().setDisconnected(id, cause, message);
+ mAdapter.setDisconnected(id, cause, message);
}
@Override
@@ -129,11 +322,6 @@ public abstract class ConnectionService extends CallService {
}
@Override
- public void onAudioStateChanged(Connection c, CallAudioState state) {
- // TODO: Unsupported yet
- }
-
- @Override
public void onSignalChanged(Connection c, Bundle details) {
// TODO: Unsupported yet
}
@@ -144,23 +332,23 @@ public abstract class ConnectionService extends CallService {
}
@Override
- public final void onPostDialWait(Connection c, String remaining) {
+ public void onPostDialWait(Connection c, String remaining) {
String id = mIdByConnection.get(c);
Log.d(this, "Adapter onPostDialWait %s, %s", c, remaining);
- getAdapter().onPostDialWait(id, remaining);
+ mAdapter.onPostDialWait(id, remaining);
}
@Override
public void onRequestingRingback(Connection c, boolean ringback) {
String id = mIdByConnection.get(c);
Log.d(this, "Adapter onRingback %b", ringback);
- getAdapter().setRequestingRingback(id, ringback);
+ mAdapter.setRequestingRingback(id, ringback);
}
@Override
public void onConferenceCapableChanged(Connection c, boolean isConferenceCapable) {
String id = mIdByConnection.get(c);
- getAdapter().setCanConference(id, isConferenceCapable);
+ mAdapter.setCanConference(id, isConferenceCapable);
}
/** ${inheritDoc} */
@@ -168,156 +356,120 @@ public abstract class ConnectionService extends CallService {
public void onParentConnectionChanged(Connection c, Connection parent) {
String id = mIdByConnection.get(c);
String parentId = parent == null ? null : mIdByConnection.get(parent);
- getAdapter().setIsConferenced(id, parentId);
+ mAdapter.setIsConferenced(id, parentId);
}
@Override
public void onSetCallVideoProvider(Connection c, CallVideoProvider callVideoProvider) {
String id = mIdByConnection.get(c);
- getAdapter().setCallVideoProvider(id, callVideoProvider);
+ mAdapter.setCallVideoProvider(id, callVideoProvider);
}
};
- /** @hide */
+ /** {@inheritDoc} */
@Override
- protected final void call(final CallInfo callInfo) {
- Log.d(this, "call %s", callInfo);
+ public final IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+
+ private void call(final ConnectionRequest originalRequest) {
+ Log.d(this, "call %s", originalRequest);
onCreateConnections(
- new ConnectionRequest(
- callInfo.getId(),
- callInfo.getHandle(),
- callInfo.getExtras()),
+ originalRequest,
new OutgoingCallResponse<Connection>() {
@Override
public void onSuccess(ConnectionRequest request, Connection connection) {
- Log.d(this, "adapter handleSuccessfulOutgoingCall %s",
- callInfo.getId());
- getAdapter().handleSuccessfulOutgoingCall(callInfo.getId());
- addConnection(callInfo.getId(), connection);
+ Log.d(this, "adapter handleSuccessfulOutgoingCall %s", request.getCallId());
+ mAdapter.handleSuccessfulOutgoingCall(request);
+ addConnection(request.getCallId(), connection);
}
@Override
public void onFailure(ConnectionRequest request, int code, String msg) {
- getAdapter().handleFailedOutgoingCall(request, code, msg);
+ mAdapter.handleFailedOutgoingCall(request, code, msg);
}
@Override
public void onCancel(ConnectionRequest request) {
- getAdapter().cancelOutgoingCall(callInfo.getId());
+ mAdapter.cancelOutgoingCall(request);
}
}
);
}
- /** @hide */
- @Override
- protected final void abort(String callId) {
+ private void abort(String callId) {
Log.d(this, "abort %s", callId);
- findConnectionForAction(callId, "abort").abort();
+ findConnectionForAction(callId, "abort").onAbort();
}
- /** @hide */
- @Override
- protected final void setIncomingCallId(final String callId, Bundle extras) {
- Log.d(this, "setIncomingCallId %s %s", callId, extras);
+ private void createIncomingCall(ConnectionRequest originalRequest) {
+ Log.d(this, "createIncomingCall %s", originalRequest);
onCreateIncomingConnection(
- new ConnectionRequest(
- callId,
- null, // TODO: Can we obtain this from "extras"?
- extras),
+ originalRequest,
new Response<ConnectionRequest, Connection>() {
@Override
public void onResult(ConnectionRequest request, Connection... result) {
if (result != null && result.length != 1) {
- Log.d(this, "adapter handleFailedOutgoingCall %s", callId);
- getAdapter().handleFailedOutgoingCall(
- request,
- DisconnectCause.ERROR_UNSPECIFIED,
- "Created " + result.length + " Connections, expected 1");
for (Connection c : result) {
- c.abort();
+ c.onAbort();
}
} else {
- addConnection(callId, result[0]);
- Log.d(this, "adapter notifyIncomingCall %s", callId);
- // TODO: Uri.EMPTY is because CallInfo crashes when Parceled with a
- // null URI ... need to fix that at its cause!
- getAdapter().notifyIncomingCall(new CallInfo(
- callId,
- connectionStateToCallState(result[0].getState()),
- request.getHandle() /* result[0].getHandle() == null
- ? Uri.EMPTY : result[0].getHandle() */));
+ addConnection(request.getCallId(), result[0]);
+ Log.d(this, "adapter notifyIncomingCall %s", request);
+ mAdapter.notifyIncomingCall(request);
}
}
@Override
public void onError(ConnectionRequest request, int code, String msg) {
- Log.d(this, "adapter failed setIncomingCallId %s %d %s",
+ Log.d(this, "adapter failed createIncomingCall %s %d %s",
request, code, msg);
}
}
);
}
- /** @hide */
- @Override
- protected final void answer(String callId) {
+ private void answer(String callId) {
Log.d(this, "answer %s", callId);
- findConnectionForAction(callId, "answer").answer();
+ findConnectionForAction(callId, "answer").onAnswer();
}
- /** @hide */
- @Override
- protected final void reject(String callId) {
+ private void reject(String callId) {
Log.d(this, "reject %s", callId);
- findConnectionForAction(callId, "reject").reject();
+ findConnectionForAction(callId, "reject").onReject();
}
- /** @hide */
- @Override
- protected final void disconnect(String callId) {
+ private void disconnect(String callId) {
Log.d(this, "disconnect %s", callId);
- findConnectionForAction(callId, "disconnect").disconnect();
+ findConnectionForAction(callId, "disconnect").onDisconnect();
}
- /** @hide */
- @Override
- protected final void hold(String callId) {
+ private void hold(String callId) {
Log.d(this, "hold %s", callId);
- findConnectionForAction(callId, "hold").hold();
+ findConnectionForAction(callId, "hold").onHold();
}
- /** @hide */
- @Override
- protected final void unhold(String callId) {
+ private void unhold(String callId) {
Log.d(this, "unhold %s", callId);
- findConnectionForAction(callId, "unhold").unhold();
+ findConnectionForAction(callId, "unhold").onUnhold();
}
- /** @hide */
- @Override
- protected final void playDtmfTone(String callId, char digit) {
- Log.d(this, "playDtmfTone %s %c", callId, digit);
- findConnectionForAction(callId, "playDtmfTone").playDtmfTone(digit);
+ private void onAudioStateChanged(String callId, CallAudioState audioState) {
+ Log.d(this, "onAudioStateChanged %s %s", callId, audioState);
+ findConnectionForAction(callId, "onAudioStateChanged").setAudioState(audioState);
}
- /** @hide */
- @Override
- protected final void stopDtmfTone(String callId) {
- Log.d(this, "stopDtmfTone %s", callId);
- findConnectionForAction(callId, "stopDtmfTone").stopDtmfTone();
+ private void playDtmfTone(String callId, char digit) {
+ Log.d(this, "playDtmfTone %s %c", callId, digit);
+ findConnectionForAction(callId, "playDtmfTone").onPlayDtmfTone(digit);
}
- /** @hide */
- @Override
- protected final void onAudioStateChanged(String callId, CallAudioState audioState) {
- Log.d(this, "onAudioStateChanged %s %s", callId, audioState);
- findConnectionForAction(callId, "onAudioStateChanged").setAudioState(audioState);
+ private void stopDtmfTone(String callId) {
+ Log.d(this, "stopDtmfTone %s", callId);
+ findConnectionForAction(callId, "stopDtmfTone").onStopDtmfTone();
}
- /** @hide */
- @Override
- protected final void conference(final String conferenceCallId, String callId) {
+ private void conference(final String conferenceCallId, String callId) {
Log.d(this, "conference %s, %s", conferenceCallId, callId);
Connection connection = findConnectionForAction(callId, "conference");
@@ -336,7 +488,7 @@ public abstract class ConnectionService extends CallService {
Connection conferenceConnection = result[0];
if (!mIdByConnection.containsKey(conferenceConnection)) {
Log.v(this, "sending new conference call %s", conferenceCallId);
- getAdapter().addConferenceCall(conferenceCallId);
+ mAdapter.addConferenceCall(conferenceCallId);
addConnection(conferenceCallId, conferenceConnection);
}
}
@@ -350,9 +502,7 @@ public abstract class ConnectionService extends CallService {
});
}
- /** @hide */
- @Override
- protected final void splitFromConference(String callId) {
+ private void splitFromConference(String callId) {
Log.d(this, "splitFromConference(%s)", callId);
Connection connection = findConnectionForAction(callId, "splitFromConference");
@@ -364,55 +514,36 @@ public abstract class ConnectionService extends CallService {
// TODO(santoscordon): Find existing conference call and invoke split(connection).
}
- /** @hide */
- @Override
- protected final void onPostDialContinue(String callId, boolean proceed) {
+ private void onPostDialContinue(String callId, boolean proceed) {
Log.d(this, "onPostDialContinue(%s)", callId);
-
- Connection connection = findConnectionForAction(callId, "onPostDialContinue");
- if (connection == NULL_CONNECTION) {
- Log.w(this, "Connection missing in post-dial request %s.", callId);
- return;
- }
- connection.onPostDialContinue(proceed);
- }
-
- /** @hide */
- @Override
- protected final void onFeaturesChanged(String callId, int features) {
- Log.d(this, "onFeaturesChanged %s %d", callId, features);
- findConnectionForAction(callId, "onFeaturesChanged").setFeatures(features);
+ findConnectionForAction(callId, "stopDtmfTone").onPostDialContinue(proceed);
}
- /** @hide */
- @Override
- protected void onPhoneAccountClicked(String callId) {
+ private void onPhoneAccountClicked(String callId) {
Log.d(this, "onPhoneAccountClicked %s", callId);
findConnectionForAction(callId, "onPhoneAccountClicked").onPhoneAccountClicked();
}
- /** @hide */
- @Override
- protected final void onAdapterAttached(CallServiceAdapter adapter) {
+ private void onAdapterAttached() {
if (mAreAccountsInitialized) {
// No need to query again if we already did it.
return;
}
- getAdapter().queryRemoteConnectionServices(new RemoteServiceCallback.Stub() {
+ mAdapter.queryRemoteConnectionServices(new RemoteServiceCallback.Stub() {
@Override
public void onResult(
final List<ComponentName> componentNames,
- final List<IBinder> callServices) {
+ final List<IBinder> services) {
mHandler.post(new Runnable() {
@Override public void run() {
- for (int i = 0; i < componentNames.size() && i < callServices.size(); i++) {
+ for (int i = 0; i < componentNames.size() && i < services.size(); i++) {
mRemoteConnectionManager.addConnectionService(
componentNames.get(i),
- ICallService.Stub.asInterface(callServices.get(i)));
+ IConnectionService.Stub.asInterface(services.get(i)));
}
mAreAccountsInitialized = true;
- Log.d(this, "remote call services found: " + callServices);
+ Log.d(this, "remote call services found: " + services);
maybeRespondToAccountLookup();
}
});
@@ -540,26 +671,6 @@ public abstract class ConnectionService extends CallService {
return builder.toString();
}
- private CallState connectionStateToCallState(int connectionState) {
- switch (connectionState) {
- case Connection.State.NEW:
- return CallState.NEW;
- case Connection.State.RINGING:
- return CallState.RINGING;
- case Connection.State.DIALING:
- return CallState.DIALING;
- case Connection.State.ACTIVE:
- return CallState.ACTIVE;
- case Connection.State.HOLDING:
- return CallState.ON_HOLD;
- case Connection.State.DISCONNECTED:
- return CallState.DISCONNECTED;
- default:
- Log.wtf(this, "Unknown Connection.State %d", connectionState);
- return CallState.NEW;
- }
- }
-
private void addConnection(String callId, Connection connection) {
mConnectionById.put(callId, connection);
mIdByConnection.put(connection, callId);
diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
index dcab566..1d21888 100644
--- a/telecomm/java/android/telecomm/CallServiceAdapter.java
+++ b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
@@ -21,8 +21,8 @@ import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
import android.os.RemoteException;
-import com.android.internal.telecomm.ICallService;
-import com.android.internal.telecomm.ICallServiceAdapter;
+import com.android.internal.telecomm.IConnectionService;
+import com.android.internal.telecomm.IConnectionServiceAdapter;
import com.android.internal.telecomm.ICallVideoProvider;
import com.android.internal.telecomm.RemoteServiceCallback;
@@ -32,24 +32,17 @@ import java.util.List;
import java.util.Set;
/**
- * Provides methods for ICallService implementations to interact with the system phone app.
- * TODO(santoscordon): Rename this to CallServiceAdapterDemultiplexer (or something).
+ * Provides methods for IConnectionService implementations to interact with the system phone app.
*
* @hide
*/
-public final class CallServiceAdapter implements DeathRecipient {
- private final Set<ICallServiceAdapter> mAdapters = new HashSet<>();
+final class ConnectionServiceAdapter implements DeathRecipient {
+ private final Set<IConnectionServiceAdapter> mAdapters = new HashSet<>();
- /**
- * @hide
- */
- public CallServiceAdapter() {
+ ConnectionServiceAdapter() {
}
- /**
- * @hide
- */
- public void addAdapter(ICallServiceAdapter adapter) {
+ void addAdapter(IConnectionServiceAdapter adapter) {
if (mAdapters.add(adapter)) {
try {
adapter.asBinder().linkToDeath(this, 0);
@@ -59,10 +52,7 @@ public final class CallServiceAdapter implements DeathRecipient {
}
}
- /**
- * @hide
- */
- public void removeAdapter(ICallServiceAdapter adapter) {
+ void removeAdapter(IConnectionServiceAdapter adapter) {
if (mAdapters.remove(adapter)) {
adapter.asBinder().unlinkToDeath(this, 0);
}
@@ -71,31 +61,25 @@ public final class CallServiceAdapter implements DeathRecipient {
/** ${inheritDoc} */
@Override
public void binderDied() {
- ICallServiceAdapter adapterToRemove = null;
- for (ICallServiceAdapter adapter : mAdapters) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
if (!adapter.asBinder().isBinderAlive()) {
- adapterToRemove = adapter;
- break;
+ removeAdapter(adapter);
}
}
-
- if (adapterToRemove != null) {
- removeAdapter(adapterToRemove);
- }
}
/**
* Provides Telecomm with the details of an incoming call. An invocation of this method must
- * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon the
- * invocation of this method, Telecomm will bring up the incoming-call interface where the user
- * can elect to answer or reject a call.
+ * follow {@link ConnectionService#setIncomingCallId} and use the call ID specified therein.
+ * Upon the invocation of this method, Telecomm will bring up the incoming-call interface where
+ * the user can elect to answer or reject a call.
*
- * @param callInfo The details of the relevant call.
+ * @param request The connection request.
*/
- public void notifyIncomingCall(CallInfo callInfo) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void notifyIncomingCall(ConnectionRequest request) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
- adapter.notifyIncomingCall(callInfo);
+ adapter.notifyIncomingCall(request);
} catch (RemoteException e) {
}
}
@@ -103,15 +87,13 @@ public final class CallServiceAdapter implements DeathRecipient {
/**
* Tells Telecomm that an attempt to place the specified outgoing call succeeded.
- * TODO(santoscordon): Consider adding a CallState parameter in case this outgoing call is
- * somehow no longer in the DIALING state.
*
- * @param callId The ID of the outgoing call.
+ * @param request The originating request for a connection.
*/
- public void handleSuccessfulOutgoingCall(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void handleSuccessfulOutgoingCall(ConnectionRequest request) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
- adapter.handleSuccessfulOutgoingCall(callId);
+ adapter.handleSuccessfulOutgoingCall(request);
} catch (RemoteException e) {
}
}
@@ -124,11 +106,11 @@ public final class CallServiceAdapter implements DeathRecipient {
* @param errorCode The error code associated with the failed call attempt.
* @param errorMsg The error message associated with the failed call attempt.
*/
- public void handleFailedOutgoingCall(
+ void handleFailedOutgoingCall(
ConnectionRequest request,
int errorCode,
String errorMsg) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.handleFailedOutgoingCall(request, errorCode, errorMsg);
} catch (RemoteException e) {
@@ -139,12 +121,12 @@ public final class CallServiceAdapter implements DeathRecipient {
/**
* Tells Telecomm to cancel the call.
*
- * @param callId The ID of the outgoing call.
+ * @param request The originating request for a connection.
*/
- public void cancelOutgoingCall(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void cancelOutgoingCall(ConnectionRequest request) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
- adapter.cancelOutgoingCall(callId);
+ adapter.cancelOutgoingCall(request);
} catch (RemoteException e) {
}
}
@@ -156,8 +138,8 @@ public final class CallServiceAdapter implements DeathRecipient {
*
* @param callId The unique ID of the call whose state is changing to active.
*/
- public void setActive(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setActive(String callId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setActive(callId);
} catch (RemoteException e) {
@@ -170,8 +152,8 @@ public final class CallServiceAdapter implements DeathRecipient {
*
* @param callId The unique ID of the call whose state is changing to ringing.
*/
- public void setRinging(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setRinging(String callId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setRinging(callId);
} catch (RemoteException e) {
@@ -184,8 +166,8 @@ public final class CallServiceAdapter implements DeathRecipient {
*
* @param callId The unique ID of the call whose state is changing to dialing.
*/
- public void setDialing(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setDialing(String callId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setDialing(callId);
} catch (RemoteException e) {
@@ -201,8 +183,8 @@ public final class CallServiceAdapter implements DeathRecipient {
* {@link android.telephony.DisconnectCause}.
* @param disconnectMessage Optional call-service-provided message about the disconnect.
*/
- public void setDisconnected(String callId, int disconnectCause, String disconnectMessage) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setDisconnected(String callId, int disconnectCause, String disconnectMessage) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setDisconnected(callId, disconnectCause, disconnectMessage);
} catch (RemoteException e) {
@@ -215,8 +197,8 @@ public final class CallServiceAdapter implements DeathRecipient {
*
* @param callId - The unique ID of the call whose state is changing to be on hold.
*/
- public void setOnHold(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setOnHold(String callId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setOnHold(callId);
} catch (RemoteException e) {
@@ -230,8 +212,8 @@ public final class CallServiceAdapter implements DeathRecipient {
* @param callId The unique ID of the call whose ringback is being changed.
* @param ringback Whether Telecomm should start playing a ringback tone.
*/
- public void setRequestingRingback(String callId, boolean ringback) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setRequestingRingback(String callId, boolean ringback) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setRequestingRingback(callId, ringback);
} catch (RemoteException e) {
@@ -244,10 +226,9 @@ public final class CallServiceAdapter implements DeathRecipient {
*
* @param callId The unique ID of the call.
* @param canConference Specified whether or not the call can be conferenced.
- * @hide
*/
- public void setCanConference(String callId, boolean canConference) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setCanConference(String callId, boolean canConference) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setCanConference(callId, canConference);
} catch (RemoteException ignored) {
@@ -262,10 +243,9 @@ public final class CallServiceAdapter implements DeathRecipient {
* @param callId The unique ID of the call being conferenced.
* @param conferenceCallId The unique ID of the conference call. Null if call is not
* conferenced.
- * @hide
*/
- public void setIsConferenced(String callId, String conferenceCallId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setIsConferenced(String callId, String conferenceCallId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setIsConferenced(callId, conferenceCallId);
} catch (RemoteException ignored) {
@@ -278,10 +258,9 @@ public final class CallServiceAdapter implements DeathRecipient {
* call.
*
* @param callId The unique ID of the call.
- * @hide
*/
- public void removeCall(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void removeCall(String callId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.removeCall(callId);
} catch (RemoteException ignored) {
@@ -289,8 +268,8 @@ public final class CallServiceAdapter implements DeathRecipient {
}
}
- public void onPostDialWait(String callId, String remaining) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void onPostDialWait(String callId, String remaining) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.onPostDialWait(callId, remaining);
} catch (RemoteException ignored) {
@@ -303,10 +282,10 @@ public final class CallServiceAdapter implements DeathRecipient {
*
* @param callId The unique ID of the conference call.
*/
- public void addConferenceCall(String callId) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void addConferenceCall(String callId) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
- adapter.addConferenceCall(callId, null);
+ adapter.addConferenceCall(callId);
} catch (RemoteException ignored) {
}
}
@@ -314,9 +293,8 @@ public final class CallServiceAdapter implements DeathRecipient {
/**
* Retrieves a list of remote connection services usable to place calls.
- * @hide
*/
- public void queryRemoteConnectionServices(RemoteServiceCallback callback) {
+ void queryRemoteConnectionServices(RemoteServiceCallback callback) {
// Only supported when there is only one adapter.
if (mAdapters.size() == 1) {
try {
@@ -333,8 +311,8 @@ public final class CallServiceAdapter implements DeathRecipient {
* @param callId The unique ID of the call to set with the given call video provider.
* @param callVideoProvider The call video provider instance to set on the call.
*/
- public void setCallVideoProvider(String callId, CallVideoProvider callVideoProvider) {
- for (ICallServiceAdapter adapter : mAdapters) {
+ void setCallVideoProvider(String callId, CallVideoProvider callVideoProvider) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setCallVideoProvider(callId, callVideoProvider.getInterface());
} catch (RemoteException e) {
@@ -350,9 +328,9 @@ public final class CallServiceAdapter implements DeathRecipient {
* @param callId The unique ID of the call to set features for.
* @param features The features.
*/
- public void setFeatures(String callId, int features) {
+ void setFeatures(String callId, int features) {
Log.v(this, "setFeatures: %d", features);
- for (ICallServiceAdapter adapter : mAdapters) {
+ for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setFeatures(callId, features);
} catch (RemoteException ignored) {
diff --git a/telecomm/java/android/telecomm/RemoteConnection.java b/telecomm/java/android/telecomm/RemoteConnection.java
index f200bc0..18df37d 100644
--- a/telecomm/java/android/telecomm/RemoteConnection.java
+++ b/telecomm/java/android/telecomm/RemoteConnection.java
@@ -22,7 +22,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.telephony.DisconnectCause;
-import com.android.internal.telecomm.ICallService;
+import com.android.internal.telecomm.IConnectionService;
import java.util.HashSet;
import java.util.Set;
@@ -36,10 +36,11 @@ public final class RemoteConnection {
void onDisconnected(RemoteConnection connection, int cause, String message);
void onRequestingRingback(RemoteConnection connection, boolean ringback);
void onPostDialWait(RemoteConnection connection, String remainingDigits);
+ void onFeaturesChanged(RemoteConnection connection, int features);
void onDestroyed(RemoteConnection connection);
}
- private final ICallService mCallService;
+ private final IConnectionService mConnectionService;
private final String mConnectionId;
private final Set<Listener> mListeners = new HashSet<>();
@@ -48,12 +49,13 @@ public final class RemoteConnection {
private String mDisconnectMessage;
private boolean mRequestingRingback;
private boolean mConnected;
+ private int mFeatures;
/**
* @hide
*/
- RemoteConnection(ICallService callService, String connectionId) {
- mCallService = callService;
+ RemoteConnection(IConnectionService connectionService, String connectionId) {
+ mConnectionService = connectionService;
mConnectionId = connectionId;
mConnected = true;
@@ -79,10 +81,14 @@ public final class RemoteConnection {
return mDisconnectMessage;
}
+ public int getFeatures() {
+ return mFeatures;
+ }
+
public void abort() {
try {
if (mConnected) {
- mCallService.abort(mConnectionId);
+ mConnectionService.abort(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -91,7 +97,7 @@ public final class RemoteConnection {
public void answer() {
try {
if (mConnected) {
- mCallService.answer(mConnectionId);
+ mConnectionService.answer(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -100,7 +106,7 @@ public final class RemoteConnection {
public void reject() {
try {
if (mConnected) {
- mCallService.reject(mConnectionId);
+ mConnectionService.reject(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -109,7 +115,7 @@ public final class RemoteConnection {
public void hold() {
try {
if (mConnected) {
- mCallService.hold(mConnectionId);
+ mConnectionService.hold(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -118,7 +124,7 @@ public final class RemoteConnection {
public void unhold() {
try {
if (mConnected) {
- mCallService.unhold(mConnectionId);
+ mConnectionService.unhold(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -127,7 +133,7 @@ public final class RemoteConnection {
public void disconnect() {
try {
if (mConnected) {
- mCallService.disconnect(mConnectionId);
+ mConnectionService.disconnect(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -136,7 +142,7 @@ public final class RemoteConnection {
public void playDtmf(char digit) {
try {
if (mConnected) {
- mCallService.playDtmfTone(mConnectionId, digit);
+ mConnectionService.playDtmfTone(mConnectionId, digit);
}
} catch (RemoteException ignored) {
}
@@ -145,7 +151,7 @@ public final class RemoteConnection {
public void stopDtmf() {
try {
if (mConnected) {
- mCallService.stopDtmfTone(mConnectionId);
+ mConnectionService.stopDtmfTone(mConnectionId);
}
} catch (RemoteException ignored) {
}
@@ -154,7 +160,7 @@ public final class RemoteConnection {
public void postDialContinue(boolean proceed) {
try {
if (mConnected) {
- mCallService.onPostDialContinue(mConnectionId, proceed);
+ mConnectionService.onPostDialContinue(mConnectionId, proceed);
}
} catch (RemoteException ignored) {
}
@@ -163,7 +169,7 @@ public final class RemoteConnection {
public void setAudioState(CallAudioState state) {
try {
if (mConnected) {
- mCallService.onAudioStateChanged(mConnectionId, state);
+ mConnectionService.onAudioStateChanged(mConnectionId, state);
}
} catch (RemoteException ignored) {
}
@@ -236,4 +242,14 @@ public final class RemoteConnection {
l.onPostDialWait(this, remainingDigits);
}
}
+
+ /**
+ * @hide
+ */
+ void setFeatures(int features) {
+ mFeatures = features;
+ for (Listener l : mListeners) {
+ l.onFeaturesChanged(this, features);
+ }
+ }
}
diff --git a/telecomm/java/android/telecomm/RemoteConnectionManager.java b/telecomm/java/android/telecomm/RemoteConnectionManager.java
index eb3154b..9cffdcc 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionManager.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionManager.java
@@ -20,7 +20,7 @@ import android.content.ComponentName;
import android.net.Uri;
import android.os.RemoteException;
-import com.android.internal.telecomm.ICallService;
+import com.android.internal.telecomm.IConnectionService;
import java.util.HashMap;
import java.util.LinkedList;
@@ -33,11 +33,11 @@ import java.util.Map;
public class RemoteConnectionManager {
private Map<ComponentName, RemoteConnectionService> mRemoteConnectionServices = new HashMap<>();
- void addConnectionService(ComponentName componentName, ICallService callService) {
+ void addConnectionService(ComponentName componentName, IConnectionService connectionService) {
if (!mRemoteConnectionServices.containsKey(componentName)) {
try {
RemoteConnectionService remoteConnectionService =
- new RemoteConnectionService(componentName, callService);
+ new RemoteConnectionService(componentName, connectionService);
mRemoteConnectionServices.put(componentName, remoteConnectionService);
} catch (RemoteException ignored) {
}
diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java
index 81bee98..73e7d77 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionService.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionService.java
@@ -24,8 +24,8 @@ import android.telephony.DisconnectCause;
import android.text.TextUtils;
-import com.android.internal.telecomm.ICallService;
-import com.android.internal.telecomm.ICallServiceAdapter;
+import com.android.internal.telecomm.IConnectionService;
+import com.android.internal.telecomm.IConnectionServiceAdapter;
import com.android.internal.telecomm.ICallVideoProvider;
import com.android.internal.telecomm.RemoteServiceCallback;
@@ -38,8 +38,8 @@ import java.util.UUID;
*
* @hide
*/
-public final class RemoteConnectionService implements DeathRecipient {
- private final ICallService mCallService;
+final class RemoteConnectionService implements DeathRecipient {
+ private final IConnectionService mConnectionService;
private final ComponentName mComponentName;
private String mConnectionId;
@@ -48,26 +48,26 @@ public final class RemoteConnectionService implements DeathRecipient {
// Remote connection services only support a single connection.
private RemoteConnection mConnection;
- private final ICallServiceAdapter mAdapter = new ICallServiceAdapter.Stub() {
+ private final IConnectionServiceAdapter mAdapter = new IConnectionServiceAdapter.Stub() {
/** ${inheritDoc} */
- @Override
- public void notifyIncomingCall(CallInfo callInfo) {
+ @Override
+ public void notifyIncomingCall(ConnectionRequest request) {
Log.w(this, "notifyIncomingCall not implemented in Remote connection");
}
/** ${inheritDoc} */
- @Override
- public void handleSuccessfulOutgoingCall(String connectionId) {
- if (isPendingConnection(connectionId)) {
- mConnection = new RemoteConnection(mCallService, connectionId);
- mPendingOutgoingCallResponse.onSuccess(mPendingRequest, mConnection);
+ @Override
+ public void handleSuccessfulOutgoingCall(ConnectionRequest request) {
+ if (isPendingConnection(request.getCallId())) {
+ mConnection = new RemoteConnection(mConnectionService, request.getCallId());
+ mPendingOutgoingCallResponse.onSuccess(request, mConnection);
clearPendingInformation();
}
}
/** ${inheritDoc} */
- @Override
+ @Override
public void handleFailedOutgoingCall(
ConnectionRequest request, int errorCode, String errorMessage) {
if (isPendingConnection(request.getCallId())) {
@@ -78,17 +78,17 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
- public void cancelOutgoingCall(String connectionId) {
- if (isPendingConnection(connectionId)) {
- mPendingOutgoingCallResponse.onCancel(mPendingRequest);
+ @Override
+ public void cancelOutgoingCall(ConnectionRequest request) {
+ if (isPendingConnection(request.getCallId())) {
+ mPendingOutgoingCallResponse.onCancel(request);
mConnectionId = null;
clearPendingInformation();
}
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setActive(String connectionId) {
if (isCurrentConnection(connectionId)) {
mConnection.setState(Connection.State.ACTIVE);
@@ -96,7 +96,7 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setRinging(String connectionId) {
if (isCurrentConnection(connectionId)) {
mConnection.setState(Connection.State.RINGING);
@@ -110,7 +110,7 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setDialing(String connectionId) {
if (isCurrentConnection(connectionId)) {
mConnection.setState(Connection.State.DIALING);
@@ -118,7 +118,7 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setDisconnected(
String connectionId, int disconnectCause, String disconnectMessage) {
if (isCurrentConnection(connectionId)) {
@@ -127,7 +127,7 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setOnHold(String connectionId) {
if (isCurrentConnection(connectionId)) {
mConnection.setState(Connection.State.HOLDING);
@@ -135,7 +135,7 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setRequestingRingback(String connectionId, boolean isRequestingRingback) {
if (isCurrentConnection(connectionId)) {
mConnection.setRequestingRingback(isRequestingRingback);
@@ -143,25 +143,25 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setCanConference(String connectionId, boolean canConference) {
// not supported for remote connections.
}
/** ${inheritDoc} */
- @Override
+ @Override
public void setIsConferenced(String connectionId, String conferenceConnectionId) {
// not supported for remote connections.
}
/** ${inheritDoc} */
- @Override
- public void addConferenceCall(String connectionId, CallInfo callInfo) {
+ @Override
+ public void addConferenceCall(String connectionId) {
// not supported for remote connections.
}
/** ${inheritDoc} */
- @Override
+ @Override
public void removeCall(String connectionId) {
if (isCurrentConnection(connectionId)) {
destroyConnection();
@@ -169,7 +169,7 @@ public final class RemoteConnectionService implements DeathRecipient {
}
/** ${inheritDoc} */
- @Override
+ @Override
public void onPostDialWait(String connectionId, String remainingDigits) {
if (isCurrentConnection(connectionId)) {
mConnection.setPostDialWait(remainingDigits);
@@ -189,23 +189,24 @@ public final class RemoteConnectionService implements DeathRecipient {
/** ${inheritDoc} */
@Override
public void setFeatures(String connectionId, int features) {
- // not supported for remote connections.
+ if (isCurrentConnection(connectionId)) {
+ mConnection.setFeatures(features);
+ }
}
};
- RemoteConnectionService(ComponentName componentName, ICallService callService)
+ RemoteConnectionService(ComponentName componentName, IConnectionService connectionService)
throws RemoteException {
mComponentName = componentName;
- mCallService = callService;
+ mConnectionService = connectionService;
- // TODO(santoscordon): Rename from setCallServiceAdapter to addCallServiceAdapter.
- mCallService.setCallServiceAdapter(mAdapter);
- mCallService.asBinder().linkToDeath(this, 0);
+ mConnectionService.addConnectionServiceAdapter(mAdapter);
+ mConnectionService.asBinder().linkToDeath(this, 0);
}
@Override
public String toString() {
- return "[RemoteCS - " + mCallService.asBinder().toString() + "]";
+ return "[RemoteCS - " + mConnectionService.asBinder().toString() + "]";
}
/** ${inheritDoc} */
@@ -221,15 +222,16 @@ public final class RemoteConnectionService implements DeathRecipient {
/**
* Places an outgoing call.
*/
- public final void createOutgoingConnection(
+ final void createOutgoingConnection(
ConnectionRequest request,
ConnectionService.OutgoingCallResponse<RemoteConnection> response) {
if (mConnectionId == null) {
String id = UUID.randomUUID().toString();
- CallInfo callInfo = new CallInfo(id, CallState.NEW, request.getHandle());
+ ConnectionRequest newRequest = new ConnectionRequest(request.getAccount(), id,
+ request.getHandle(), request.getExtras());
try {
- mCallService.call(callInfo);
+ mConnectionService.call(newRequest);
mConnectionId = id;
mPendingOutgoingCallResponse = response;
mPendingRequest = request;
@@ -244,7 +246,7 @@ public final class RemoteConnectionService implements DeathRecipient {
// TODO(santoscordon): Handle incoming connections
// public final void handleIncomingConnection() {}
- public final List<PhoneAccount> lookupAccounts(Uri handle) {
+ final List<PhoneAccount> lookupAccounts(Uri handle) {
// TODO(santoscordon): Update this so that is actually calls into the RemoteConnection
// each time.
List<PhoneAccount> accounts = new LinkedList<>();
@@ -264,7 +266,7 @@ public final class RemoteConnectionService implements DeathRecipient {
* the remote service is no longer being used.
*/
void release() {
- mCallService.asBinder().unlinkToDeath(this, 0);
+ mConnectionService.asBinder().unlinkToDeath(this, 0);
}
private boolean isPendingConnection(String id) {
diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java
index 80901cf..513a5ee 100644
--- a/telecomm/java/android/telecomm/TelecommConstants.java
+++ b/telecomm/java/android/telecomm/TelecommConstants.java
@@ -48,7 +48,7 @@ public final class TelecommConstants {
/**
* The service action used to bind to {@link ConnectionService} implementations.
*/
- public static final String ACTION_CALL_SERVICE = CallService.class.getName();
+ public static final String ACTION_CONNECTION_SERVICE = ConnectionService.class.getName();
/**
* Optional extra for {@link Intent#ACTION_CALL} containing a boolean that determines whether
@@ -94,6 +94,13 @@ public final class TelecommConstants {
"android.telecomm.extra.CALL_DISCONNECT_MESSAGE";
/**
+ * Optional extra for {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} containing the
+ * component name of the associated connection service.
+ */
+ public static final String EXTRA_CONNECTION_SERVICE =
+ "android.telecomm.extra.CONNECTION_SERVICE";
+
+ /**
* The dual tone multi-frequency signaling character sent to indicate the dialing system should
* pause for a predefined period.
*/
diff --git a/telecomm/java/com/android/internal/telecomm/ICallService.aidl b/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
index ac4e66c..c8ce4c6 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,25 +18,25 @@ package com.android.internal.telecomm;
import android.os.Bundle;
import android.telecomm.CallAudioState;
-import android.telecomm.CallInfo;
+import android.telecomm.ConnectionRequest;
-import com.android.internal.telecomm.ICallServiceAdapter;
+import com.android.internal.telecomm.IConnectionServiceAdapter;
/**
- * Internal remote interface for call services.
+ * Internal remote interface for connection services.
*
- * @see android.telecomm.CallService
+ * @see android.telecomm.ConnectionService
*
* @hide
*/
-oneway interface ICallService {
- void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter);
+oneway interface IConnectionService {
+ void addConnectionServiceAdapter(in IConnectionServiceAdapter adapter);
- void call(in CallInfo callInfo);
+ void call(in ConnectionRequest request);
void abort(String callId);
- void setIncomingCallId(String callId, in Bundle extras);
+ void createIncomingCall(in ConnectionRequest request);
void answer(String callId);
diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl
index eee64da..9acc920 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl
+++ b/telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,27 +16,26 @@
package com.android.internal.telecomm;
-import android.telecomm.CallInfo;
import android.telecomm.ConnectionRequest;
import com.android.internal.telecomm.ICallVideoProvider;
import com.android.internal.telecomm.RemoteServiceCallback;
/**
- * Internal remote callback interface for call services.
+ * Internal remote callback interface for connection services.
*
- * @see android.telecomm.CallServiceAdapter
+ * @see android.telecomm.ConnectionServiceAdapter
*
* {@hide}
*/
-oneway interface ICallServiceAdapter {
- void notifyIncomingCall(in CallInfo callInfo);
+oneway interface IConnectionServiceAdapter {
+ void notifyIncomingCall(in ConnectionRequest request);
- void handleSuccessfulOutgoingCall(String callId);
+ void handleSuccessfulOutgoingCall(in ConnectionRequest request);
void handleFailedOutgoingCall(in ConnectionRequest request, int errorCode, String errorMessage);
- void cancelOutgoingCall(String callId);
+ void cancelOutgoingCall(in ConnectionRequest request);
void setActive(String callId);
@@ -54,7 +53,7 @@ oneway interface ICallServiceAdapter {
void setIsConferenced(String callId, String conferenceCallId);
- void addConferenceCall(String callId, in CallInfo callInfo);
+ void addConferenceCall(String callId);
void removeCall(String callId);