From 6fbb1b73f82da0e7fe1244e4a44dea3c3c163997 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 8 Jan 2014 13:52:54 -0800 Subject: [PATCH] Remove CallServiceProviderAdapter and replace with CallServiceLookupResponse. Change-Id: I4d1c007bd46b804ecbb80163fc26de199cdbb2eb --- Android.mk | 2 +- .../android/telecomm/CallServiceProvider.java | 39 ++++++++--------- .../telecomm/ICallServiceLookupResponse.aidl | 42 +++++++++++++++++++ .../telecomm/ICallServiceProvider.aidl | 24 ++++------- .../telecomm/ICallServiceProviderAdapter.aidl | 35 ---------------- 5 files changed, 70 insertions(+), 72 deletions(-) create mode 100644 telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl delete mode 100644 telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl diff --git a/Android.mk b/Android.mk index dd7d5bcf0042d..f614d848d7443 100644 --- a/Android.mk +++ b/Android.mk @@ -279,8 +279,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRingtonePlayer.aidl \ telecomm/java/android/telecomm/ICallService.aidl \ telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ + telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \ telecomm/java/android/telecomm/ICallServiceProvider.aidl \ - telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 01e1271b1ff5d..f5fa1d19ef5a2 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -21,8 +21,11 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; +import android.os.RemoteException; import android.telecomm.ICallServiceProvider; +import android.telecomm.ICallServiceLookupResponse; +import android.util.Log; /** * Base implementation of CallServiceProvider service which implements ICallServiceProvider. @@ -33,7 +36,9 @@ import android.telecomm.ICallServiceProvider; * about how this can be used. * @hide */ -public abstract class CallServiceProvider extends Service { +public abstract class CallServiceProvider extends Service implements ICallServiceProvider { + /** Used to identify log entries by this class. */ + private static final String TAG = CallServiceProvider.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -42,8 +47,12 @@ public abstract class CallServiceProvider extends Service { @Override public void handleMessage(Message msg) { switch (msg.what) { - case MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER: - setCallServiceProviderAdapter((ICallServiceProviderAdapter) msg.obj); + case MSG_GET_CALL_SERVICES: + try { + lookupCallServices((ICallServiceLookupResponse) msg.obj); + } catch (RemoteException e) { + Log.e(TAG, "Remote exception on lookupCallServices().", e); + } break; default: break; @@ -55,15 +64,13 @@ public abstract class CallServiceProvider extends Service { * Default ICallServiceProvider implementation provided to CallsManager via {@link #onBind}. */ private final class CallServiceProviderWrapper extends ICallServiceProvider.Stub { - @Override - public void setCallServiceProviderAdapter( - ICallServiceProviderAdapter CallServiceProviderAdapter) { - mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER, - CallServiceProviderAdapter).sendToTarget(); - } + /** {@inheritDoc} */ @Override - public void initiateDiscoveryProtocol() {} + public void lookupCallServices(ICallServiceLookupResponse callServiceLookupResponse) { + mMessageHandler.obtainMessage(MSG_GET_CALL_SERVICES, callServiceLookupResponse) + .sendToTarget(); + } } // Only used internally by this class. @@ -71,7 +78,7 @@ public abstract class CallServiceProvider extends Service { // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a // single thread. Keeping it on a single thread allows CallService implementations to avoid // needing multi-threaded code in their own callback routines. - private static final int MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER = 1; + private static final int MSG_GET_CALL_SERVICES = 1; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -97,14 +104,4 @@ public abstract class CallServiceProvider extends Service { public IBinder onBind(Intent intent) { return mBinder; } - - /** - * Sets an implementation of ICallServiceProviderAdapter for adding providing instances of - * ICallService. - * TODO(santoscordon): Should we not reference ICallServiceProviderAdapter directly from here? - * Should we wrap that in a wrapper like we do for CallServiceProvider/ICallServiceProvider? - * @param callServiceAdapter Adapter object for communicating call to CallsManager - */ - public abstract void setCallServiceProviderAdapter( - ICallServiceProviderAdapter CallServiceProviderAdapter); } diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl new file mode 100644 index 0000000000000..2327c645764e9 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -0,0 +1,42 @@ +/* + * 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. + * 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.os.Bundle; + +/** + * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations or + * an errorCode in case of error. + */ +oneway interface ICallServiceLookupResponse { + /** + * Receives the list of {@link ICallServices} as a data value in the bundle parameter. + * TODO(santoscordon): Needs more specifics about the data key used for the list. + * + * @param bundle Container for the list of call services. + */ + void onResult(in Bundle bundle); + + /** + * Receives error code upon failure in retrieving the list of call services. + * TODO(santoscordon): Needs list of potential error codes. Also, do we really need this + * method or can we return codes as part of onResult? + * + * @param errorCode Error code describing the error condition. + */ + void onError(int errorCode); +} diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl index 1bd8d1fde376a..2e2610c68af60 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -16,7 +16,7 @@ package android.telecomm; -import android.telecomm.ICallServiceProviderAdapter; +import android.telecomm.ICallServiceLookupResponse; /** * Interface for applications interested in providing call-service implementations. Only used in @@ -24,9 +24,8 @@ import android.telecomm.ICallServiceProviderAdapter; * decided dynamically (unlike incoming call scenario where the call-service is known). * * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn - * gathers and binds all ICallServiceProvider implementations (using the framework). The actual - * bind is between each CallServiceProvider and the CallServiceProviderAdapter. Once bound, the - * CallsManager invokes the initiateDiscoveryProtocol API of each bound provider and waits until + * gathers and binds all ICallServiceProvider implementations (using the framework). Once bound, the + * CallsManager invokes the lookupCallServices API of each bound provider and waits until * either all providers reply (asynchronously) or some timeout is met. The resulted list is then * processed by the CallsManager and its helpers (potentially requesting input from the user) to * identify the best CallService. The user should obviously be notified upon zero candidates as @@ -36,17 +35,12 @@ import android.telecomm.ICallServiceProviderAdapter; oneway interface ICallServiceProvider { /** - * Sets an implementation of ICallServiceProviderAdapter to allow call-service providers to - * communicate with the CallsManager. + * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * this provider. + * TODO(santoscordon): Needs comments on how to populate the list within + * ICallServiceLookupResponse and how to handle error conditions. * - * @param callServiceProviderAdapter The interface through which {@link ICallService} - * implementations are passed to CallsManager. + * @param response The response object through which the list of call services is sent. */ - void setCallServiceProviderAdapter(in ICallServiceProviderAdapter callServiceProviderAdapter); - - /** - * Provides the application with the opportunity to "register" ICallServiceProvider - * implementations with the CallsManager for the purpose of issuing outgoing calls. - */ - void initiateDiscoveryProtocol(); + void lookupCallServices(in ICallServiceLookupResponse response); } diff --git a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl deleted file mode 100644 index ec88a06e44717..0000000000000 --- a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl +++ /dev/null @@ -1,35 +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.telecomm.ICallService; - -/** - * Provides ICallServiceProvider implementations with the relevant CallsManager APIs. - * @hide - */ -oneway interface ICallServiceProviderAdapter { - - /** - * Provides the CallsManager with the services made available by this application. - * - * @param callServices The relevant services to make the CallsManager aware of. Parameter is - * a list of IBinder which can be cast to ICallService. - * NOTE: IBinder is required by AIDL processor when passing a list of interfaces. - */ - void registerCallServices(in List callServices); -}