diff options
author | Sailesh Nepal <sail@google.com> | 2014-07-14 23:24:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-14 18:38:02 +0000 |
commit | 77ec2ceac689d80c8e645da4a83f0e5af8077cbc (patch) | |
tree | a2cbd50c953c494b16fda440a692ab61f3c0e536 /telecomm | |
parent | a5a2cf419d72b28d0ce3948199d6f6874d6dbf9b (diff) | |
parent | 864a2b291be09e3d260cd9e9d8fab37504188e5b (diff) | |
download | frameworks_base-77ec2ceac689d80c8e645da4a83f0e5af8077cbc.zip frameworks_base-77ec2ceac689d80c8e645da4a83f0e5af8077cbc.tar.gz frameworks_base-77ec2ceac689d80c8e645da4a83f0e5af8077cbc.tar.bz2 |
Merge "Remove CallServiceProvider and CallServiceDescriptor do not merge" into lmp-dev
Diffstat (limited to 'telecomm')
8 files changed, 13 insertions, 500 deletions
diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.aidl b/telecomm/java/android/telecomm/CallServiceDescriptor.aidl deleted file mode 100644 index f517c73..0000000 --- a/telecomm/java/android/telecomm/CallServiceDescriptor.aidl +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 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; - -parcelable CallServiceDescriptor; diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.java b/telecomm/java/android/telecomm/CallServiceDescriptor.java deleted file mode 100644 index 5ae07d3..0000000 --- a/telecomm/java/android/telecomm/CallServiceDescriptor.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 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.ComponentName; -import android.content.Context; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.Log; - -import java.util.Locale; -import java.util.UUID; - -/** - * An immutable object containing information about a given {@link ConnectionService}. Instances are - * created using the enclosed {@link Builder}. - */ -public final class CallServiceDescriptor implements Parcelable { - private static final String TAG = CallServiceDescriptor.class.getSimpleName(); - - /** - * A placeholder value indicating an invalid network type. - * @hide - */ - private static final int FLAG_INVALID = 0; - - /** - * Indicates that the device must be connected to a Wi-Fi network in order for the backing - * {@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 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 ConnectionService} to be used. - */ - public static final int FLAG_MOBILE = 0x04; - - /** - * Represents all of the defined FLAG_ constants so validity can be easily checked. - * @hide - */ - public static final int FLAG_ALL = FLAG_WIFI | FLAG_PSTN | FLAG_MOBILE; - - /** - * A unique ID used to identify a given instance. - */ - private final String mConnectionServiceId; - - /** - * The {@link ComponentName} of the {@link ConnectionService} implementation which this is - * describing. - */ - private final ComponentName mComponentName; - - /** - * 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 connectionServiceId, - ComponentName componentName, - int networkType) { - - mConnectionServiceId = connectionServiceId; - mComponentName = componentName; - mNetworkType = networkType; - } - - /** - * @return The ID used to identify this {@link ConnectionService}. - */ - public String getConnectionServiceId() { - return mConnectionServiceId; - } - - /** - * @return The {@link ComponentName} of the {@link ConnectionService}. - */ - public ComponentName getServiceComponent() { - return mComponentName; - } - - /** - * @return The network type required by the {@link ConnectionService} to place a call. - */ - public int getNetworkType() { - return mNetworkType; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (!(obj instanceof CallServiceDescriptor)) { - return false; - } - CallServiceDescriptor descriptor = (CallServiceDescriptor) obj; - return mConnectionServiceId.equals(descriptor.mConnectionServiceId) && - mComponentName.equals(descriptor.mComponentName) && - mNetworkType == descriptor.mNetworkType; - } - - @Override - public String toString() { - return String.format(Locale.US, "[%s, component: %s]", - CallServiceDescriptor.class.getSimpleName(), - mComponentName == null ? "null" : mComponentName.flattenToShortString()); - } - - /** - * @param context {@link Context} to use for the construction of the {@link Builder}. - * @return A new {@link Builder} instance. - */ - public static Builder newBuilder(Context context) { - return new Builder(context); - } - - /** - * Creates {@link CallServiceDescriptor} instances. Builders should be created with the - * {@link CallServiceDescriptor#newBuilder(Context)} method. - */ - public static class Builder { - /** The {@link Context} to use to verify {@link ComponentName} ownership. */ - private Context mContext; - - /** The {@link ComponentName} pointing to the backing {@link ConnectionService}. */ - private ComponentName mComponentName; - - /** The required network type that the {@link ConnectionService} needs. */ - private int mNetworkType = FLAG_INVALID; - - private Builder(Context context) { - mContext = context; - } - - /** - * Set which {@link ConnectionService} this {@link CallServiceDescriptor} is describing. - * - * @param serviceClass The {@link ConnectionService} class - * @return This {@link Builder} for method chaining. - */ - public Builder setConnectionService(Class<? extends ConnectionService> serviceClass) { - mComponentName = new ComponentName(mContext, serviceClass); - return this; - } - - /** - * 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 ConnectionService} requires. - * @return This {@link Builder} for method chaining. - */ - public Builder setNetworkType(int networkType) { - mNetworkType = networkType; - return this; - } - - /** - * @return A constructed {@link CallServiceDescriptor} object. - */ - public CallServiceDescriptor build() { - // STOPSHIP: Verify validity of ComponentName (permissions, intents, etc) - - // Make sure that they passed in a valid network flag combination - if (mNetworkType == FLAG_INVALID || ((mNetworkType & FLAG_ALL) == 0)) { - - Log.wtf(TAG, "Invalid network type for " + mComponentName); - // Revert them back to TYPE_INVALID so it won't be considered. - mNetworkType = FLAG_INVALID; - } - - // TODO: Should we use a sha1 of the ComponentName? Would prevent duplicates. - return new CallServiceDescriptor( - UUID.randomUUID().toString(), mComponentName, mNetworkType); - } - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mConnectionServiceId); - dest.writeParcelable(mComponentName, 0); - dest.writeInt(mNetworkType); - } - - public static final Creator<CallServiceDescriptor> CREATOR = - new Creator<CallServiceDescriptor>() { - @Override - public CallServiceDescriptor createFromParcel(Parcel source) { - String id = source.readString(); - ComponentName componentName = source.readParcelable( - CallServiceDescriptor.class.getClassLoader()); - int networkType = source.readInt(); - - return new CallServiceDescriptor(id, componentName, networkType); - } - - @Override - public CallServiceDescriptor[] newArray(int size) { - return new CallServiceDescriptor[size]; - } - }; -} diff --git a/telecomm/java/android/telecomm/CallServiceLookupResponse.java b/telecomm/java/android/telecomm/CallServiceLookupResponse.java deleted file mode 100644 index dd35a24..0000000 --- a/telecomm/java/android/telecomm/CallServiceLookupResponse.java +++ /dev/null @@ -1,51 +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.os.RemoteException; - -import com.android.internal.telecomm.ICallServiceLookupResponse; - -import java.util.List; - -/** - * Used by {@link CallServiceProvider} to return a list of {@link CallServiceDescriptor}s. - */ -public final class CallServiceLookupResponse { - private final ICallServiceLookupResponse mResponse; - - /** - * {@hide} - */ - public CallServiceLookupResponse(ICallServiceLookupResponse response) { - mResponse = response; - } - - /** - * Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm. Used - * in the context of attempting to place a pending outgoing call. - * - * @param callServiceDescriptors The set of call-service descriptors from - * {@link CallServiceProvider}. - */ - public void setCallServiceDescriptors(List<CallServiceDescriptor> callServiceDescriptors) { - try { - mResponse.setCallServiceDescriptors(callServiceDescriptors); - } catch (RemoteException e) { - } - } -} diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java deleted file mode 100644 index c50334a..0000000 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ /dev/null @@ -1,109 +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.Handler; -import android.os.IBinder; -import android.os.Message; - -import com.android.internal.telecomm.ICallServiceLookupResponse; -import com.android.internal.telecomm.ICallServiceProvider; - -/** - * Base implementation of a call service provider which extends {@link Service}. This class - * should be extended by an app that wants to supply phone calls to be handled and managed by - * the device's in-call interface. All method-calls from the framework to the call service provider - * are passed through to the main thread for before executing the overriden methods of - * CallServiceProvider. - * - * TODO(santoscordon): Improve paragraph above once the final design is in place. Needs more - * about how this can be used. - */ -public abstract class CallServiceProvider extends Service { - - /** - * Default Handler used to consolidate binder method calls onto a single thread. - */ - private final class CallServiceProviderMessageHandler extends Handler { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_LOOKUP_CALL_SERVICES: - CallServiceLookupResponse response = - new CallServiceLookupResponse((ICallServiceLookupResponse) msg.obj); - lookupCallServices(response); - break; - } - } - } - - /** - * Default ICallServiceProvider implementation provided to CallsManager via {@link #onBind}. - */ - private final class CallServiceProviderWrapper extends ICallServiceProvider.Stub { - /** {@inheritDoc} */ - @Override - public void lookupCallServices(ICallServiceLookupResponse callServiceLookupResponse) { - Message message = mMessageHandler.obtainMessage( - MSG_LOOKUP_CALL_SERVICES, callServiceLookupResponse); - message.sendToTarget(); - } - } - - // Only used internally by this class. - // Binder method calls on this service can occur on multiple threads. These messages are used - // 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_LOOKUP_CALL_SERVICES = 1; - - /** - * Message handler for consolidating binder callbacks onto a single thread. - * See {@link CallServiceProviderMessageHandler}. - */ - private final CallServiceProviderMessageHandler mMessageHandler; - - /** - * Default binder implementation of {@link ICallServiceProvider} interface. - */ - private final CallServiceProviderWrapper mBinder; - - /** - * Protected constructor called only by subclasses creates the binder interface and - * single-threaded message handler. - */ - protected CallServiceProvider() { - mMessageHandler = new CallServiceProviderMessageHandler(); - mBinder = new CallServiceProviderWrapper(); - } - - /** {@inheritDoc} */ - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - - /** - * Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by - * this provider. - * - * @param response The response object through which the list of call services is sent. - */ - public abstract void lookupCallServices(CallServiceLookupResponse response); -} diff --git a/telecomm/java/android/telecomm/InCallCall.java b/telecomm/java/android/telecomm/InCallCall.java index 7c35020..355c260 100644 --- a/telecomm/java/android/telecomm/InCallCall.java +++ b/telecomm/java/android/telecomm/InCallCall.java @@ -45,7 +45,6 @@ public final class InCallCall implements Parcelable { private final int mCallerDisplayNamePresentation; private final GatewayInfo mGatewayInfo; private final PhoneAccount mAccount; - private final CallServiceDescriptor mCurrentCallServiceDescriptor; private final ICallVideoProvider mCallVideoProvider; private RemoteCallVideoProvider mRemoteCallVideoProvider; private final String mParentCallId; @@ -67,7 +66,6 @@ public final class InCallCall implements Parcelable { int callerDisplayNamePresentation, GatewayInfo gatewayInfo, PhoneAccount account, - CallServiceDescriptor descriptor, ICallVideoProvider callVideoProvider, String parentCallId, List<String> childCallIds, @@ -85,7 +83,6 @@ public final class InCallCall implements Parcelable { mCallerDisplayNamePresentation = callerDisplayNamePresentation; mGatewayInfo = gatewayInfo; mAccount = account; - mCurrentCallServiceDescriptor = descriptor; mCallVideoProvider = callVideoProvider; mParentCallId = parentCallId; mChildCallIds = childCallIds; @@ -165,11 +162,6 @@ public final class InCallCall implements Parcelable { return mAccount; } - /** The descriptor for the call service currently routing this call. */ - public CallServiceDescriptor getCurrentCallServiceDescriptor() { - return mCurrentCallServiceDescriptor; - } - /** * Returns an object for remotely communicating through the call video provider's binder. * @return The call video provider. @@ -232,7 +224,6 @@ public final class InCallCall implements Parcelable { int callerDisplayNamePresentation = source.readInt(); GatewayInfo gatewayInfo = source.readParcelable(classLoader); PhoneAccount account = source.readParcelable(classLoader); - CallServiceDescriptor descriptor = source.readParcelable(classLoader); ICallVideoProvider callVideoProvider = ICallVideoProvider.Stub.asInterface(source.readStrongBinder()); String parentCallId = source.readString(); @@ -242,8 +233,7 @@ public final class InCallCall implements Parcelable { return new InCallCall(id, state, disconnectCauseCode, disconnectCauseMsg, cannedSmsResponses, capabilities, connectTimeMillis, handle, handlePresentation, callerDisplayName, callerDisplayNamePresentation, gatewayInfo, - account, descriptor, callVideoProvider, parentCallId, childCallIds, - statusHints); + account, callVideoProvider, parentCallId, childCallIds, statusHints); } @Override @@ -274,7 +264,6 @@ public final class InCallCall implements Parcelable { destination.writeInt(mCallerDisplayNamePresentation); destination.writeParcelable(mGatewayInfo, 0); destination.writeParcelable(mAccount, 0); - destination.writeParcelable(mCurrentCallServiceDescriptor, 0); destination.writeStrongBinder( mCallVideoProvider != null ? mCallVideoProvider.asBinder() : null); destination.writeString(mParentCallId); diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index b21ea60..a94841f 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.ComponentName; import android.content.Intent; import android.os.Bundle; import android.telephony.TelephonyManager; @@ -31,9 +32,9 @@ public final class TelecommConstants { * to find and bind to the appropriate {@link android.telecomm.ConnectionService} which * Telecomm will ultimately use to control and get information about the call.</p> * - * <p>Input: get*Extra field {@link #EXTRA_CALL_SERVICE_DESCRIPTOR} contains the component name - * of the {@link android.telecomm.ConnectionService} that Telecomm should bind to. Telecomm - * will then ask the call service for more information about the call prior to showing any UI. + * <p>Input: get*Extra field {@link #EXTRA_PHONE_ACCOUNT} contains the component name of the + * {@link android.telecomm.ConnectionService} that Telecomm should bind to. Telecomm will then + * ask the connection service for more information about the call prior to showing any UI. * * TODO(santoscordon): Needs permissions. * TODO(santoscordon): Consider moving this into a simple method call on a system service. @@ -41,11 +42,6 @@ public final class TelecommConstants { public static final String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; /** - * The service action used to bind to {@link CallServiceProvider} implementations. - */ - public static final String ACTION_CALL_SERVICE_PROVIDER = CallServiceProvider.class.getName(); - - /** * The service action used to bind to {@link ConnectionService} implementations. */ public static final String ACTION_CONNECTION_SERVICE = ConnectionService.class.getName(); @@ -75,11 +71,15 @@ public final class TelecommConstants { "android.intent.extra.START_CALL_WITH_VIDEO_STATE"; /** - * Extra for {@link #ACTION_INCOMING_CALL} containing the {@link CallServiceDescriptor} that - * describes the call service to use for the incoming call. + * The extra used with an {@link android.content.Intent#ACTION_CALL}, + * {@link #ACTION_INCOMING_CALL}, {@link android.content.Intent#ACTION_DIAL} {@code Intent} to + * specify a {@link PhoneAccount} to use when making the call. + * + * <p class="note"> + * Retrieve with + * {@link android.content.Intent#getParcelableExtra(String)}. */ - public static final String EXTRA_CALL_SERVICE_DESCRIPTOR = - "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; + public static final String EXTRA_PHONE_ACCOUNT = "android.intent.extra.PHONE_ACCOUNT"; /** * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl deleted file mode 100644 index 10d73be..0000000 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl +++ /dev/null @@ -1,32 +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.os.IBinder; -import android.telecomm.CallServiceDescriptor; -import java.util.List; - -/** - * Internal remote interface for call service lookup response. - * - * @see android.telecomm.CallServiceLookupResponse - * - * @hide - */ -oneway interface ICallServiceLookupResponse { - void setCallServiceDescriptors(in List<CallServiceDescriptor> callServiceDescriptors); -} diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl deleted file mode 100644 index 96daeed..0000000 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl +++ /dev/null @@ -1,32 +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 com.android.internal.telecomm; - -import android.telecomm.CallServiceDescriptor; - -import com.android.internal.telecomm.ICallServiceLookupResponse; - -/** - * Internal remote interface for call service providers. - * - * @see android.telecomm.CallServiceProvider - * - * @hide - */ -oneway interface ICallServiceProvider { - void lookupCallServices(in ICallServiceLookupResponse response); -} |