diff options
Diffstat (limited to 'telecomm/java')
18 files changed, 330 insertions, 429 deletions
diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index cb7f2dc..4de9373 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -52,8 +52,7 @@ public final class CallInfo implements Parcelable { private final GatewayInfo mGatewayInfo; /** - * Additional information that can be persisted. For example, extra handoff information can - * attached to a call using {@link CallServiceSelectorAdapter#setHandoffInfo(String,Uri,Bundle). + * Additional information that can be persisted. */ private final Bundle mExtras; diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 0b5981c..cf7c901 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -49,21 +49,20 @@ import java.util.List; public abstract class CallService extends Service { private static final int MSG_SET_CALL_SERVICE_ADAPTER = 1; - private static final int MSG_IS_COMPATIBLE_WITH = 2; - private static final int MSG_CALL = 3; - private static final int MSG_ABORT = 4; - private static final int MSG_SET_INCOMING_CALL_ID = 5; - private static final int MSG_ANSWER = 6; - private static final int MSG_REJECT = 7; - private static final int MSG_DISCONNECT = 8; - private static final int MSG_HOLD = 9; - private static final int MSG_UNHOLD = 10; - private static final int MSG_ON_AUDIO_STATE_CHANGED = 11; - private static final int MSG_PLAY_DTMF_TONE = 12; - private static final int MSG_STOP_DTMF_TONE = 13; - private static final int MSG_CONFERENCE = 14; - private static final int MSG_SPLIT_FROM_CONFERENCE = 15; - private static final int MSG_ON_POST_DIAL_CONTINUE = 16; + 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; /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -76,9 +75,6 @@ public abstract class CallService extends Service { mAdapter = new CallServiceAdapter((ICallServiceAdapter) msg.obj); onAdapterAttached(mAdapter); break; - case MSG_IS_COMPATIBLE_WITH: - isCompatibleWith((CallInfo) msg.obj); - break; case MSG_CALL: call((CallInfo) msg.obj); break; @@ -170,11 +166,6 @@ public abstract class CallService extends Service { } @Override - public void isCompatibleWith(CallInfo callInfo) { - mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, callInfo).sendToTarget(); - } - - @Override public void call(CallInfo callInfo) { mMessageHandler.obtainMessage(MSG_CALL, callInfo).sendToTarget(); } @@ -300,21 +291,10 @@ public abstract class CallService extends Service { } /** - * Determines if the CallService can place the specified call. Response is sent via - * {@link CallServiceAdapter#setIsCompatibleWith}. When responding, the correct call ID must be - * specified. Only used in the context of outgoing calls and call switching (handoff). - * - * @param callInfo The details of the relevant call. - */ - public abstract void isCompatibleWith(CallInfo callInfo); - - /** * Attempts to call the relevant party using the specified call's handle, be it a phone number, * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary - * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the - * call service respond via {@link CallServiceAdapter#handleSuccessfulOutgoingCall(String)} - * if it can successfully make the call. Only used in the context of outgoing calls. + * handle-calling systems. * * @param callInfo The details of the relevant call. */ diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/CallServiceAdapter.java index ce89321..2c5f078 100644 --- a/telecomm/java/android/telecomm/CallServiceAdapter.java +++ b/telecomm/java/android/telecomm/CallServiceAdapter.java @@ -37,22 +37,6 @@ public final class CallServiceAdapter { } /** - * Receives confirmation of a call service's ability to place a call. This method is used in - * response to {@link CallService#isCompatibleWith}. - * - * @param callId The identifier of the call for which compatibility is being received. This ID - * should correspond to the ID given as part of the call information in - * {@link CallService#isCompatibleWith}. - * @param isCompatible True if the call service can place the call. - */ - public void setIsCompatibleWith(String callId, boolean isCompatible) { - try { - mAdapter.setIsCompatibleWith(callId, isCompatible); - } catch (RemoteException e) { - } - } - - /** * 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 @@ -227,6 +211,18 @@ public final class CallServiceAdapter { } /** + * Instructs Telecomm to handoff the call to another call service. + * + * @param callId The identifier of the call to handoff. + */ + public void handoffCall(String callId) { + try { + mAdapter.handoffCall(callId); + } catch (RemoteException e) { + } + } + + /** * Indicates that a new conference call has been created. * * @param callId The unique ID of the conference call. diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java deleted file mode 100644 index c9c6ff6..0000000 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.Handler; -import android.os.IBinder; -import android.os.Looper; -import android.os.Message; -import android.os.RemoteException; - -import com.android.internal.os.SomeArgs; -import com.android.internal.telecomm.ICallServiceSelector; -import com.android.internal.telecomm.ICallServiceSelectorAdapter; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -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)}. - */ -public abstract class CallServiceSelector extends Service { - private static final int MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER = 0; - private static final int MSG_SELECT = 1; - - private final HashMap<String, CallInfo> mCalls = new HashMap<String, CallInfo>(); - - /** Handler to move client-bound method calls to the main thread. */ - private final Handler mHandler = new Handler(Looper.getMainLooper()) { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER: - mAdapter = new CallServiceSelectorAdapter( - (ICallServiceSelectorAdapter) msg.obj); - onAdapterAttached(mAdapter); - break; - case MSG_SELECT: - SomeArgs args = (SomeArgs) msg.obj; - try { - select((CallInfo) args.arg1, (List<CallServiceDescriptor>) args.arg2); - } finally { - args.recycle(); - } - break; - } - } - }; - - /** Manages the binder calls so that the implementor does not need to deal with it. */ - private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub { - @Override - public void setCallServiceSelectorAdapter(ICallServiceSelectorAdapter adapter) { - mHandler.obtainMessage(MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER, adapter) - .sendToTarget(); - } - - @Override - public void select(CallInfo callInfo, List<CallServiceDescriptor> descriptors) { - SomeArgs args = SomeArgs.obtain(); - args.arg1 = callInfo; - args.arg2 = descriptors; - mHandler.obtainMessage(MSG_SELECT, args).sendToTarget(); - } - - @Override - public void onCallUpdated(CallInfo callInfo) { - mCalls.put(callInfo.getId(), callInfo); - } - - @Override - public void onCallRemoved(String callId) { - mCalls.remove(callId); - } - } - - private final CallServiceSelectorBinder mBinder; - - private CallServiceSelectorAdapter mAdapter = null; - - protected CallServiceSelector() { - mBinder = new CallServiceSelectorBinder(); - } - - @Override - public final IBinder onBind(Intent intent) { - return mBinder; - } - - /** - * Returns a list of all calls managed by this selector. - */ - protected final Collection<CallInfo> getCalls() { - return Collections.unmodifiableCollection(mCalls.values()); - } - - /** - * @return The attached {@link CallServiceSelectorAdapter} if attached, or null otherwise. - */ - protected final CallServiceSelectorAdapter getAdapter() { - return mAdapter; - } - - /** - * Cancel the outgoing call. Any subsequent calls to {@link #select(CallInfo, List)} will be - * ignored. - * - * @param callInfo The call to canceled. - */ - protected final void cancelOutgoingCall(CallInfo callInfo) { - getAdapter().cancelOutgoingCall(callInfo.getId()); - } - - /** - * 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 The adapter now attached to this call service selector. - */ - protected void onAdapterAttached(CallServiceSelectorAdapter adapter) { - } - - /** - * Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return - * them through - * {@link CallServiceSelectorAdapter#setSelectedCallServices(String,List)}. - * - * @param callInfo The call being placed using the {@link CallService}s. - * @param descriptors The descriptors of the available {@link CallService}s with which to place - * the call. - */ - protected abstract void select(CallInfo callInfo, List<CallServiceDescriptor> descriptors); -} diff --git a/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java deleted file mode 100644 index 4d2e8aa..0000000 --- a/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.net.Uri; -import android.os.Bundle; -import android.os.RemoteException; -import android.telecomm.CallServiceDescriptor; - -import com.android.internal.telecomm.ICallServiceSelectorAdapter; - -import java.util.List; - -/** - * Provides methods for ICallServiceSelector implementations to interact with Telecomm. - */ -public final class CallServiceSelectorAdapter { - private final ICallServiceSelectorAdapter mAdapter; - - /** - * {@hide} - */ - public CallServiceSelectorAdapter(ICallServiceSelectorAdapter adapter) { - mAdapter = adapter; - } - - /** - * Records the sorted set of call services that are preferred by the corresponding - * call-service selector. - * - * @param callId The ID of the call to complete. - * @param selectedCallServiceDescriptors The prioritized list of preferred call-service - * descriptors to use for completing the call. - */ - public void setSelectedCallServices( - String callId, - List<CallServiceDescriptor> selectedCallServiceDescriptors) { - try { - mAdapter.setSelectedCallServices(callId, selectedCallServiceDescriptors); - } catch (RemoteException e) { - } - } - - /** - * Cancels the specified outgoing call. - * - * @param callId The ID of the call to cancel. - */ - public void cancelOutgoingCall(String callId) { - try { - mAdapter.cancelOutgoingCall(callId); - } catch (RemoteException e) { - } - } - - /** - * Associates handoff information with an ongoing call. Calls can switch from one call service - * to another. Setting handle to a non-null value marks the call as switchable. - * - * @param callId The ID of the call to set handoff information for. - * @param handle The handle used to place the call when switching. - * @param extras Optional extra that's attached to the call. - */ - public void setHandoffInfo(String callId, Uri handle, Bundle extras) { - try { - mAdapter.setHandoffInfo(callId, handle, extras); - } catch (RemoteException e) { - } - } -} diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java index 164eeff..1783327 100644 --- a/telecomm/java/android/telecomm/Connection.java +++ b/telecomm/java/android/telecomm/Connection.java @@ -356,6 +356,13 @@ public abstract class Connection { } /** + * Returns whether this connection is capable of being conferenced. + */ + public boolean isConferenceCapable() { + return mIsConferenceCapable; + } + + /** * Sets the value of the {@link #getHandle()} property and notifies listeners. * * @param handle The new handle. diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java index d974509..5aba941 100644 --- a/telecomm/java/android/telecomm/ConnectionService.java +++ b/telecomm/java/android/telecomm/ConnectionService.java @@ -20,15 +20,9 @@ import android.net.Uri; import android.os.Bundle; import android.telephony.DisconnectCause; -import android.os.SystemClock; - import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; import java.util.Map; -import java.util.Set; /** * A {@link android.app.Service} that provides telephone connections to @@ -120,28 +114,6 @@ public abstract class ConnectionService extends CallService { }; @Override - public final void isCompatibleWith(final CallInfo callInfo) { - Log.d(this, "isCompatibleWith %s", callInfo); - onFindSubscriptions( - callInfo.getHandle(), - new Response<Uri, Subscription>() { - @Override - public void onResult(Uri handle, Subscription... result) { - boolean isCompatible = result.length > 0; - Log.d(this, "adapter setIsCompatibleWith "); - getAdapter().setIsCompatibleWith(callInfo.getId(), isCompatible); - } - - @Override - public void onError(Uri handle, int code, String msg) { - Log.w(this, "Error in onFindSubscriptions %s %d %s", handle, code, msg); - getAdapter().setIsCompatibleWith(callInfo.getId(), false); - } - } - ); - } - - @Override public final void call(final CallInfo callInfo) { Log.d(this, "call %s", callInfo); onCreateConnections( @@ -349,16 +321,6 @@ public abstract class ConnectionService extends CallService { } /** - * Find a set of Subscriptions matching a given handle (e.g. phone number). - * - * @param handle A handle (e.g. phone number) with which to connect. - * @param callback A callback for providing the result. - */ - public void onFindSubscriptions( - Uri handle, - Response<Uri, Subscription> callback) {} - - /** * Create a Connection given a request. * * @param request Data encapsulating details of the desired Connection. diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 3a63077..31291fb 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -156,7 +156,7 @@ public abstract class InCallService extends Service { } /** - * @return The attached {@link CallServiceSelectorAdapter} if attached, or null otherwise. + * @return The attached {@link InCallAdapter} if attached, or null otherwise. */ protected final InCallAdapter getAdapter() { return mAdapter; @@ -203,7 +203,7 @@ public abstract class InCallService extends Service { * {@link #setPostDial(String,String)} state but is now waiting for user confirmation before the * remaining digits can be sent. Normal transitions are to {@link #setPostDial(String,String)} * when the user asks Telecomm to proceed with the post-dial sequence and the in-call app - * informs Telecomm of this by invoking {@link InCallAdapter#postDialContinue(String)}. + * informs Telecomm of this by invoking {@link InCallAdapter#postDialContinue(String,boolean)}. * * @param callId The identifier of the call changing state. * @param remaining The remaining postdial string to be dialed. diff --git a/telecomm/java/android/telecomm/Subscription.aidl b/telecomm/java/android/telecomm/Subscription.aidl new file mode 100644 index 0000000..6327fcc --- /dev/null +++ b/telecomm/java/android/telecomm/Subscription.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2008 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; + +/** + * {@hide} + */ +parcelable Subscription; diff --git a/telecomm/java/android/telecomm/Subscription.java b/telecomm/java/android/telecomm/Subscription.java index f187f4d..964db4a 100644 --- a/telecomm/java/android/telecomm/Subscription.java +++ b/telecomm/java/android/telecomm/Subscription.java @@ -16,25 +16,169 @@ package android.telecomm; +import android.content.ComponentName; +import android.content.Context; +import android.content.pm.PackageManager; +import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; +import android.telephony.Rlog; +import android.util.DisplayMetrics; +import android.util.Log; + +import java.util.MissingResourceException; /** * Represents a distinct subscription, line of service or call placement method that - * a {@link ConnectionService} can use to place phone calls. + * the system can use to place phone calls. */ public class Subscription implements Parcelable { - public Subscription() {} + private static final int NO_DENSITY = -1; + + private static final String LOG_TAG = "Subscription"; + + private final ComponentName mComponentName; + private final String mId; + private final Uri mHandle; + private final int mLabelResId; + private final int mShortDescriptionResId; + private final int mIconResId; + private final boolean mIsEnabled; + private final boolean mIsSystemDefault; + + public Subscription( + ComponentName componentName, + String id, + Uri handle, + int labelResId, + int shortDescriptionResId, + int iconResId, + boolean isEnabled, + boolean isSystemDefault) { + mComponentName = componentName; + mId = id; + mHandle = handle; + mLabelResId = labelResId; + mShortDescriptionResId = shortDescriptionResId; + mIconResId = iconResId; + mIsSystemDefault = isSystemDefault; + mIsEnabled = isEnabled; + } + + /** + * The {@code ComponentName} of the {@link android.telecomm.ConnectionService} which is + * responsible for making phone calls using this {@code Subscription}. + * + * @return A suitable {@code ComponentName}. + */ + public ComponentName getComponentName() { + return mComponentName; + } + + /** + * A unique identifier for this {@code Subscription}, generated by and meaningful to the + * {@link android.telecomm.ConnectionService} that created it. + * + * @return A unique identifier for this {@code Subscription}. + */ + public String getId() { + return mId; + } + + /** + * The handle (e.g., a phone number) associated with this {@code Subscription}. This represents + * the destination from which outgoing calls using this {@code Subscription} will appear to come + * from, if applicable, and the destination to which incoming calls using this + * {@code Subscription} may be addressed. + * + * @return A handle expressed as a {@code Uri}, for example, a phone number. + */ + public Uri getHandle() { + return mHandle; + } + + /** + * A short string label describing this {@code Subscription}. + * + * @param context The invoking {@code Context}, used for retrieving resources. + * + * @return A label for this {@code Subscription}. + */ + public String getLabel(Context context) { + return getString(context, mLabelResId); + } + + /** + * A short paragraph describing this {@code Subscription}. + * + * @param context The invoking {@code Context}, used for retrieving resources. + * + * @return A description for this {@code Subscription}. + */ + public String getShortDescription(Context context) { + return getString(context, mShortDescriptionResId); + } + + /** + * An icon to represent this {@code Subscription} in a user interface. + * + * @param context The invoking {@code Context}, used for retrieving resources. + * + * @return An icon for this {@code Subscription}. + */ + public Drawable getIcon(Context context) { + return getIcon(context, mIconResId, NO_DENSITY); + } + + /** + * An icon to represent this {@code Subscription} in a user interface. + * + * @param context The invoking {@code Context}, used for retrieving resources. + * @param density A display density from {@link DisplayMetrics}. + * + * @return An icon for this {@code Subscription}. + */ + public Drawable getIcon(Context context, int density) { + return getIcon(context, mIconResId, density); + } + + /** + * Whether this {@code Subscription} is enabled for use. + * + * @return {@code true} if this {@code Subscription} is enabled. + */ + public boolean isEnabled() { + return mIsEnabled; + } + + /** + * Whether this {@code Subscription} is the system default. + * + * @return {@code true} if this {@code Subscription} is the system default. + */ + public boolean isSystemDefault() { + return mIsSystemDefault; + } public int describeContents() { return 0; } - public void writeToParcel(Parcel out, int flags) {} + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(mComponentName, flags); + out.writeString(mId); + out.writeString(mHandle != null ? mHandle.toString() : ""); + out.writeInt(mLabelResId); + out.writeInt(mShortDescriptionResId); + out.writeInt(mIconResId); + out.writeInt(mIsEnabled ? 1 : 0); + out.writeInt(mIsSystemDefault ? 1 : 0); + } - public static final Parcelable.Creator<Subscription> CREATOR - = new Parcelable.Creator<Subscription>() { + public static final Creator<Subscription> CREATOR + = new Creator<Subscription>() { public Subscription createFromParcel(Parcel in) { return new Subscription(in); } @@ -44,5 +188,54 @@ public class Subscription implements Parcelable { } }; - private Subscription(Parcel in) {} + private Subscription(Parcel in) { + mComponentName = in.readParcelable(getClass().getClassLoader()); + mId = in.readString(); + String uriString = in.readString(); + mHandle = uriString.length() > 0 ? Uri.parse(uriString) : null; + mLabelResId = in.readInt(); + mShortDescriptionResId = in.readInt(); + mIconResId = in.readInt(); + mIsEnabled = in.readInt() == 1; + mIsSystemDefault = in.readInt() == 1; + } + + private String getString(Context context, int resId) { + Context packageContext; + try { + packageContext = context.createPackageContext(mComponentName.getPackageName(), 0); + } catch (PackageManager.NameNotFoundException e) { + if (Rlog.isLoggable(LOG_TAG, Log.WARN)) { + Rlog.w(LOG_TAG, "Cannot find package " + mComponentName.getPackageName()); + } + return null; + } + String result = packageContext.getString(resId); + if (result == null && Rlog.isLoggable(LOG_TAG, Log.WARN)) { + Rlog.w(LOG_TAG, "Cannot find string " + resId + " in package " + + mComponentName.getPackageName()); + } + return result; + } + + private Drawable getIcon(Context context, int resId, int density) { + Context packageContext; + try { + packageContext = context.createPackageContext(mComponentName.getPackageName(), 0); + } catch (PackageManager.NameNotFoundException e) { + if (Rlog.isLoggable(LOG_TAG, Log.WARN)) { + Rlog.w(LOG_TAG, "Cannot find package " + mComponentName.getPackageName()); + } + return null; + } + try { + return density == NO_DENSITY ? + packageContext.getResources().getDrawable(resId) : + packageContext.getResources().getDrawableForDensity(resId, density); + } catch (MissingResourceException e) { + Rlog.e(LOG_TAG, "Cannot find icon " + resId + " in package " + + mComponentName.getPackageName() + ": " + e.toString()); + return null; + } + } } diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index 8300c92..4c08da0 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -16,6 +16,7 @@ package android.telecomm; +import android.content.Intent; import android.os.Bundle; import android.telephony.TelephonyManager; @@ -50,9 +51,11 @@ public final class TelecommConstants { public static final String ACTION_CALL_SERVICE = CallService.class.getName(); /** - * The service action used to bind to {@link CallServiceSelector} implementations. + * Optional extra for {@link Intent#ACTION_CALL} containing a boolean that determines whether + * the speakerphone should be automatically turned on for an outgoing call. */ - public static final String ACTION_CALL_SERVICE_SELECTOR = CallServiceSelector.class.getName(); + public static final String EXTRA_START_CALL_WITH_SPEAKERPHONE = + "android.intent.extra.START_CALL_WITH_SPEAKERPHONE"; /** * Extra for {@link #ACTION_INCOMING_CALL} containing the {@link CallServiceDescriptor} that diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java new file mode 100644 index 0000000..a97e7e4 --- /dev/null +++ b/telecomm/java/android/telecomm/TelecommManager.java @@ -0,0 +1,48 @@ +/* + * 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.content.Context; + +import com.android.internal.telecomm.ITelecommService; + +/** + * Provides access to Telecomm-related functionality. + */ +public class TelecommManager { + private static final String TAG = "TelecommManager"; + + private final Context mContext; + private final ITelecommService mService; + + /** @hide */ + public TelecommManager(Context context, ITelecommService service) { + Context appContext = context.getApplicationContext(); + if (appContext != null) { + mContext = appContext; + } else { + mContext = context; + } + + mService = service; + } + + /** {@hide} */ + public static TelecommManager from(Context context) { + return (TelecommManager) context.getSystemService(Context.TELECOMM_SERVICE); + } +} diff --git a/telecomm/java/android/telecomm/package.html b/telecomm/java/android/telecomm/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/telecomm/java/android/telecomm/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/telecomm/java/com/android/internal/telecomm/ICallService.aidl b/telecomm/java/com/android/internal/telecomm/ICallService.aidl index 827f331..62ebd54 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallService.aidl @@ -32,8 +32,6 @@ import com.android.internal.telecomm.ICallServiceAdapter; oneway interface ICallService { void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter); - void isCompatibleWith(in CallInfo callInfo); - void call(in CallInfo callInfo); void abort(String callId); diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl index ab269bb..270c551 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl @@ -27,8 +27,6 @@ import android.telecomm.ConnectionRequest; * {@hide} */ oneway interface ICallServiceAdapter { - void setIsCompatibleWith(String callId, boolean isCompatible); - void notifyIncomingCall(in CallInfo callInfo); void handleSuccessfulOutgoingCall(String callId); @@ -56,4 +54,6 @@ oneway interface ICallServiceAdapter { void removeCall(String callId); void onPostDialWait(String callId, String remaining); + + void handoffCall(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl deleted file mode 100644 index 9597dc1..0000000 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 com.android.internal.telecomm; - -import android.telecomm.CallInfo; -import android.telecomm.CallServiceDescriptor; - -import com.android.internal.telecomm.ICallService; -import com.android.internal.telecomm.ICallServiceSelectorAdapter; - -import java.util.List; - -/** - * Internal remote interface for call service selectors. - * - * @see android.telecomm.CallServiceSelector - * - * @hide - */ -oneway interface ICallServiceSelector { - void setCallServiceSelectorAdapter(in ICallServiceSelectorAdapter adapter); - - void select(in CallInfo callInfo, in List<CallServiceDescriptor> callServiceDescriptors); - - void onCallUpdated(in CallInfo callInfo); - - void onCallRemoved(String callId); -} diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl deleted file mode 100644 index ad71e3c..0000000 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 com.android.internal.telecomm; - -import android.net.Uri; -import android.os.Bundle; -import android.telecomm.CallInfo; -import android.telecomm.CallServiceDescriptor; - -import java.util.List; - -/** - * Internal remote interface for call service selector adapter. - * - * @see android.telecomm.CallServiceSelectorAdapter - * - * @hide - */ -oneway interface ICallServiceSelectorAdapter { - void setSelectedCallServices( - String callId, - in List<CallServiceDescriptor> selectedCallServiceDescriptors); - - void cancelOutgoingCall(String callId); - - void setHandoffInfo(String callId, in Uri handle, in Bundle extras); -} diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl index 0e94ffb..c758c6d 100644 --- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl @@ -16,6 +16,8 @@ package com.android.internal.telecomm; +import android.telecomm.Subscription; + /** * Interface used to interact with Telecomm. Mostly this is used by TelephonyManager for passing * commands that were previously handled by ITelephony. @@ -38,4 +40,19 @@ interface ITelecommService { * @param showDialpad if true, make the dialpad visible initially. */ void showCallScreen(boolean showDialpad); + + /** + * Gets a list of Subscriptions. + */ + List<Subscription> getSubscriptions(); + + /** + * Sets the enabled state of a given Subscription. + */ + void setEnabled(in Subscription subscription, boolean enabled); + + /** + * Sets a given Subscription as the system default. + */ + void setSystemDefault(in Subscription subscription); } |