diff options
author | Evan Charlton <evanc@google.com> | 2014-02-08 19:12:38 -0800 |
---|---|---|
committer | Evan Charlton <evanc@google.com> | 2014-02-20 17:07:41 -0800 |
commit | c3010b39c98e2b136c38d68172dbf2dfcbe58c12 (patch) | |
tree | 1272460200d909a4c6e9f8e006461587da566336 /telecomm | |
parent | 0e4430721157ae0affc2f1ba8b5517dcaabb13e7 (diff) | |
download | frameworks_base-c3010b39c98e2b136c38d68172dbf2dfcbe58c12.zip frameworks_base-c3010b39c98e2b136c38d68172dbf2dfcbe58c12.tar.gz frameworks_base-c3010b39c98e2b136c38d68172dbf2dfcbe58c12.tar.bz2 |
Add a CallServiceSelector base implementation
Add the base class for implementing CallServiceSelectors.
Change-Id: I292d962f1b73d0966af0c484ebddc724f8e6c925
Diffstat (limited to 'telecomm')
-rw-r--r-- | telecomm/java/android/telecomm/CallServiceSelector.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java new file mode 100644 index 0000000..cfa8eb3 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -0,0 +1,99 @@ +/* + * 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.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; +import android.os.RemoteException; + +import java.util.List; + +/** + * Allows for the organization of {@link CallService}s for outbound calls. Given a call and list of + * {@link CallService} IDs, order the list in terms of priority and return it using + * {@link #select(CallInfo, List)}. <br /> + * <br /> + * Also determine whether a call is switchable (can be moved between {@link CallService}s) or not + * using {@link #isSwitchable(CallInfo)}. + */ +public abstract class CallServiceSelector extends Service { + + /** Manages the binder calls so that the implementor does not need to deal it. */ + private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub { + @Override + public void isSwitchable(CallInfo callInfo, ICallSwitchabilityResponse response) + throws RemoteException { + // Ensure that we're running with the app's normal permission level + long ident = Binder.clearCallingIdentity(); + try { + response.setIsSwitchable(CallServiceSelector.this.isSwitchable(callInfo)); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override + public void select(CallInfo callInfo, List<String> callServiceIds, + ICallServiceSelectionResponse response) throws RemoteException { + // Ensure that we're running with the app's normal permission level + long ident = Binder.clearCallingIdentity(); + try { + response.setSelectedCallServiceIds( + CallServiceSelector.this.select(callInfo, callServiceIds)); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + } + + private final CallServiceSelectorBinder mBinder; + + protected CallServiceSelector() { + mBinder = new CallServiceSelectorBinder(); + } + + @Override + public final IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Determines (and returns) whether the given call is switchable. That is, whether the call can + * be moved to another {@link CallService} seamlessly.<br /> + * <br /> + * This method is not called on the UI thread and is safe to block. + * + * @param callInfo The call being potentially switched between {@link CallService}s. + * @return Whether the given call is switchable or not. + */ + protected abstract boolean isSwitchable(CallInfo callInfo); + + /** + * Return a list of prioritized {@link CallService}s which should be used to complete the given + * call.<br /> + * <br /> + * This method is not called on the UI thread and is safe to block. + * + * @param callInfo The call being placed using the {@link CallService}s. + * @param callServiceIds The IDs of the {@link CallService}s to organize for the call. + * + * @return A list of prioritized {@link CallService} IDs to use to complete the given call. + */ + protected abstract List<String> select(CallInfo callInfo, List<String> callServiceIds); +} |