diff options
author | Evan Charlton <evanc@google.com> | 2014-04-03 08:36:38 -0700 |
---|---|---|
committer | Evan Charlton <evanc@google.com> | 2014-04-04 09:26:01 -0700 |
commit | 924748fa3fc663c780c3fb21ec1332bd9757fcd2 (patch) | |
tree | 30ece111c1b629a57e26365aa1db4b0f3197dd57 | |
parent | 0e2b79e67f495110a8b0defc61299a49eb80045e (diff) | |
download | frameworks_base-924748fa3fc663c780c3fb21ec1332bd9757fcd2.zip frameworks_base-924748fa3fc663c780c3fb21ec1332bd9757fcd2.tar.gz frameworks_base-924748fa3fc663c780c3fb21ec1332bd9757fcd2.tar.bz2 |
Add lifecycle methods to telecomm services
Have the base classes track the adapters and provide an override-able
hook (onAdapterAttached()) to notify when the adapter is set.
Change-Id: I58ca5c6970328861327699ec497fa21288bce7df
-rw-r--r-- | api/current.txt | 9 | ||||
-rw-r--r-- | telecomm/java/android/telecomm/CallService.java | 21 | ||||
-rw-r--r-- | telecomm/java/android/telecomm/CallServiceSelector.java | 20 | ||||
-rw-r--r-- | telecomm/java/android/telecomm/InCallService.java | 22 |
4 files changed, 54 insertions, 18 deletions
diff --git a/api/current.txt b/api/current.txt index 09073d3..2c6047d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24900,14 +24900,15 @@ package android.telecomm { method public abstract void answer(java.lang.String); method public abstract void call(android.telecomm.CallInfo); method public abstract void disconnect(java.lang.String); + method protected final android.telecomm.CallServiceAdapter getAdapter(); method public final android.os.IBinder getBinder(); method public abstract void hold(java.lang.String); method public abstract void isCompatibleWith(android.telecomm.CallInfo); + method protected void onAdapterAttached(android.telecomm.CallServiceAdapter); method public abstract void onAudioStateChanged(java.lang.String, android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method public abstract void playDtmfTone(java.lang.String, char); method public abstract void reject(java.lang.String); - method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter); method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle); method public abstract void stopDtmfTone(java.lang.String); method public abstract void unhold(java.lang.String); @@ -24956,10 +24957,11 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); + method protected final android.telecomm.CallServiceSelectorAdapter getAdapter(); method protected final java.util.Collection<android.telecomm.CallInfo> getCalls(); + method protected void onAdapterAttached(android.telecomm.CallServiceSelectorAdapter); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void select(android.telecomm.CallInfo, java.util.List<android.telecomm.CallServiceDescriptor>); - method protected abstract void setCallServiceSelectorAdapter(android.telecomm.CallServiceSelectorAdapter); } public final class CallServiceSelectorAdapter { @@ -25006,13 +25008,14 @@ package android.telecomm { public abstract class InCallService extends android.app.Service { ctor protected InCallService(); method protected abstract void addCall(android.telecomm.CallInfo); + method protected final android.telecomm.InCallAdapter getAdapter(); + method protected void onAdapterAttached(android.telecomm.InCallAdapter); method protected abstract void onAudioStateChanged(android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void setActive(java.lang.String); method protected abstract void setDialing(java.lang.String); method protected abstract void setDisconnected(java.lang.String, int); method protected abstract void setHandoffEnabled(java.lang.String, boolean); - method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); method protected abstract void setOnHold(java.lang.String); method protected abstract void setPostDial(java.lang.String, java.lang.String); method protected abstract void setPostDialWait(java.lang.String, java.lang.String); diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index c34395b..142c37e 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -70,7 +70,8 @@ public abstract class CallService extends Service { case MSG_SET_CALL_SERVICE_ADAPTER: CallServiceAdapter adapter = new CallServiceAdapter((ICallServiceAdapter) msg.obj); - setCallServiceAdapter(adapter); + mAdapter = adapter; + onAdapterAttached(adapter); break; case MSG_IS_COMPATIBLE_WITH: isCompatibleWith((CallInfo) msg.obj); @@ -218,6 +219,8 @@ public abstract class CallService extends Service { */ private final CallServiceBinder mBinder = new CallServiceBinder(); + private CallServiceAdapter mAdapter = null; + /** {@inheritDoc} */ @Override public final IBinder onBind(Intent intent) { @@ -232,12 +235,20 @@ public abstract class CallService extends Service { } /** - * Sets an implementation of CallServiceAdapter for adding new calls and communicating state - * changes of existing calls. + * @return The attached {@link CallServiceAdapter} if the service is bound, null otherwise. + */ + protected final CallServiceAdapter getAdapter() { + return mAdapter; + } + + /** + * Lifecycle callback which is called when this {@link CallService} has been attached to a + * {@link CallServiceAdapter}, indicating {@link #getAdapter()} is now safe to use. * - * @param callServiceAdapter Adapter object for communicating call to CallsManager + * @param adapter The adapter now attached to this call service. */ - public abstract void setCallServiceAdapter(CallServiceAdapter callServiceAdapter); + protected void onAdapterAttached(CallServiceAdapter adapter) { + } /** * Determines if the CallService can place the specified call. Response is sent via diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 9e714b4..a2ff617 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -52,7 +52,8 @@ public abstract class CallServiceSelector extends Service { case MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER: CallServiceSelectorAdapter adapter = new CallServiceSelectorAdapter( (ICallServiceSelectorAdapter) msg.obj); - setCallServiceSelectorAdapter(adapter); + mAdapter = adapter; + onAdapterAttached(adapter); break; case MSG_SELECT: SomeArgs args = (SomeArgs) msg.obj; @@ -95,6 +96,8 @@ public abstract class CallServiceSelector extends Service { private final CallServiceSelectorBinder mBinder; + private CallServiceSelectorAdapter mAdapter = null; + protected CallServiceSelector() { mBinder = new CallServiceSelectorBinder(); } @@ -112,11 +115,20 @@ public abstract class CallServiceSelector extends Service { } /** - * Sets an adapter that allows the selector to communicate with Telecomm. + * @return The attached {@link CallServiceSelectorAdapter} if attached, or null otherwise. + */ + protected final CallServiceSelectorAdapter getAdapter() { + return mAdapter; + } + + /** + * Lifecycle callback which is called when this {@link CallServiceSelector} has been attached + * to a {@link CallServiceSelectorAdapter}, indicating {@link #getAdapter()} is now safe to use. * - * @param adapter Adapter object for communicating with Telecomm. + * @param adapter The adapter now attached to this call service selector. */ - protected abstract void setCallServiceSelectorAdapter(CallServiceSelectorAdapter adapter); + protected void onAdapterAttached(CallServiceSelectorAdapter adapter) { + } /** * Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index c70f56e..14c6f28 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -55,7 +55,8 @@ public abstract class InCallService extends Service { switch (msg.what) { case MSG_SET_IN_CALL_ADAPTER: InCallAdapter adapter = new InCallAdapter((IInCallAdapter) msg.obj); - setInCallAdapter(adapter); + mAdapter = adapter; + onAdapterAttached(adapter); break; case MSG_ADD_CALL: addCall((CallInfo) msg.obj); @@ -182,6 +183,8 @@ public abstract class InCallService extends Service { private final InCallServiceBinder mBinder; + private InCallAdapter mAdapter; + protected InCallService() { mBinder = new InCallServiceBinder(); } @@ -192,13 +195,20 @@ public abstract class InCallService extends Service { } /** - * Provides the in-call app an adapter object through which to send call-commands such as - * answering and rejecting incoming calls, disconnecting active calls, and putting calls in - * special states (mute, hold, etc). + * @return The attached {@link CallServiceSelectorAdapter} if attached, or null otherwise. + */ + protected final InCallAdapter getAdapter() { + return mAdapter; + } + + /** + * Lifecycle callback which is called when this {@link InCallService} has been attached + * to a {@link InCallAdapter}, indicating {@link #getAdapter()} is now safe to use. * - * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. + * @param adapter The adapter now attached to this in-call service. */ - protected abstract void setInCallAdapter(InCallAdapter inCallAdapter); + protected void onAdapterAttached(InCallAdapter adapter) { + } /** * Indicates to the in-call app that a new call has been created and an appropriate |