From 6adbaf70f31e29c52fd0bb8849774f58224df6f9 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Tue, 18 Feb 2014 19:48:48 -0800 Subject: Addressing the TODO to rename CallServiceInfo. Also removing some unused imports etc. Change-Id: I48176d5394aee0110f3b7a081a1a616b72b574b9 --- telecomm/java/android/telecomm/CallService.java | 11 +- .../android/telecomm/CallServiceDescriptor.aidl | 19 ++ .../android/telecomm/CallServiceDescriptor.java | 208 +++++++++++++++++++++ .../java/android/telecomm/CallServiceInfo.aidl | 19 -- .../java/android/telecomm/CallServiceInfo.java | 203 -------------------- .../java/android/telecomm/CallServiceSelector.java | 15 +- .../telecomm/ICallServiceLookupResponse.aidl | 14 +- .../telecomm/ICallServiceSelectionResponse.aidl | 9 +- .../android/telecomm/ICallServiceSelector.aidl | 8 +- 9 files changed, 255 insertions(+), 251 deletions(-) create mode 100644 telecomm/java/android/telecomm/CallServiceDescriptor.aidl create mode 100644 telecomm/java/android/telecomm/CallServiceDescriptor.java delete mode 100644 telecomm/java/android/telecomm/CallServiceInfo.aidl delete mode 100644 telecomm/java/android/telecomm/CallServiceInfo.java (limited to 'telecomm') diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index a2fb7eb..7d1e32a 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -21,11 +21,8 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; - import android.telecomm.ICallService; import android.telecomm.ICallServiceAdapter; -import android.util.Log; -import android.util.Pair; import com.android.internal.os.SomeArgs; @@ -47,7 +44,6 @@ import com.android.internal.os.SomeArgs; * TODO(santoscordon): Improve paragraph above once the final design is in place. */ public abstract class CallService extends Service { - private static final String TAG = CallService.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -128,7 +124,7 @@ public abstract class CallService extends Service { /** * Message handler for consolidating binder callbacks onto a single thread. - * See {@link #CallServiceMessageHandler}. + * See {@link CallServiceMessageHandler}. */ private final CallServiceMessageHandler mMessageHandler = new CallServiceMessageHandler(); @@ -138,6 +134,7 @@ public abstract class CallService extends Service { private final CallServiceBinder mBinder = new CallServiceBinder(); /** {@inheritDoc} */ + @Override public IBinder onBind(Intent intent) { return getBinder(); } @@ -173,8 +170,8 @@ public abstract class CallService extends Service { * 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 ICallServiceAdapter#newOutgoingCall} if it can successfully - * make the call. + * call service respond via {@link ICallServiceAdapter#handleIncomingCall} if it can + * successfully make the call. * * @param callInfo The details of the relevant call. */ diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.aidl b/telecomm/java/android/telecomm/CallServiceDescriptor.aidl new file mode 100644 index 0000000..f517c73 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.aidl @@ -0,0 +1,19 @@ +/* + * 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 new file mode 100644 index 0000000..256b558 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.java @@ -0,0 +1,208 @@ +/* + * 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.UUID; + +/** + * An immutable object containing information about a given {@link CallService}. 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 CallService} 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 CallService} 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 CallService} 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 mCallServiceId; + + /** + * The {@link ComponentName} of the {@link CallService} implementation which this is describing. + */ + private final ComponentName mComponentName; + + /** + * The type of connection that the {@link CallService} requires; will be one of the FLAG_* + * constants defined in this class. + */ + private final int mNetworkType; + + private CallServiceDescriptor( + String callServiceId, + ComponentName componentName, + int networkType) { + + mCallServiceId = callServiceId; + mComponentName = componentName; + mNetworkType = networkType; + } + + /** + * @return The ID used to identify this {@link CallService}. + */ + public String getCallServiceId() { + return mCallServiceId; + } + + /** + * @return The {@link ComponentName} of the {@link CallService}. + */ + public ComponentName getServiceComponent() { + return mComponentName; + } + + /** + * @return The network type required by the {@link CallService} to place a call. + */ + public int getNetworkType() { + return mNetworkType; + } + + /** + * @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 CallService}. */ + private ComponentName mComponentName; + + /** The required network type that the {@link CallService} needs. */ + private int mNetworkType = FLAG_INVALID; + + private Builder(Context context) { + mContext = context; + } + + /** + * Set which {@link CallService} this {@link CallServiceDescriptor} is describing. + * + * @param callServiceClass The {@link CallService} class + * @return This {@link Builder} for method chaining. + */ + public Builder setCallService(Class callServiceClass) { + mComponentName = new ComponentName(mContext, callServiceClass); + return this; + } + + /** + * Which network type the backing {@link CallService} requires. This must be one of the + * {@link CallServiceDescriptor}.TYPE_* fields. + * + * @param networkType Which network type the backing {@link CallService} 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(mCallServiceId); + dest.writeParcelable(mComponentName, 0); + dest.writeInt(mNetworkType); + } + + static final Creator CREATOR = new Creator() { + @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/CallServiceInfo.aidl b/telecomm/java/android/telecomm/CallServiceInfo.aidl deleted file mode 100644 index fa6dea0..0000000 --- a/telecomm/java/android/telecomm/CallServiceInfo.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 CallServiceInfo; diff --git a/telecomm/java/android/telecomm/CallServiceInfo.java b/telecomm/java/android/telecomm/CallServiceInfo.java deleted file mode 100644 index f6d0827..0000000 --- a/telecomm/java/android/telecomm/CallServiceInfo.java +++ /dev/null @@ -1,203 +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.UUID; - -/** - * An immutable object containing information about a given {@link CallService}. Instances are - * created using the enclosed {@link Builder}. - */ -public final class CallServiceInfo implements Parcelable { - private static final String TAG = CallServiceInfo.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 CallService} 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 CallService} 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 CallService} 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 mCallServiceId; - - /** - * The {@link ComponentName} of the {@link CallService} implementation which this is describing. - */ - private final ComponentName mComponentName; - - /** - * The type of connection that the {@link CallService} requires; will be one of the FLAG_* - * constants defined in this class. - */ - private final int mNetworkType; - - private CallServiceInfo(String callServiceId, ComponentName componentName, int networkType) { - mCallServiceId = callServiceId; - mComponentName = componentName; - mNetworkType = networkType; - } - - /** - * @return The ID used to identify this {@link CallService}. - */ - public String getCallServiceId() { - return mCallServiceId; - } - - /** - * @return The {@link ComponentName} of the {@link CallService}. - */ - public ComponentName getServiceComponent() { - return mComponentName; - } - - /** - * @return The network type required by the {@link CallService} to place a call. - */ - public int getNetworkType() { - return mNetworkType; - } - - /** - * @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 CallServiceInfo} instances. Builders should be created with the - * {@link CallServiceInfo#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 CallService}. */ - private ComponentName mComponentName; - - /** The required network type that the {@link CallService} needs. */ - private int mNetworkType = FLAG_INVALID; - - private Builder(Context context) { - mContext = context; - } - - /** - * Set which {@link CallService} this {@link CallServiceInfo} is describing. - * - * @param callServiceClass The {@link CallService} class - * @return This {@link Builder} for method chaining. - */ - public Builder setCallService(Class callServiceClass) { - mComponentName = new ComponentName(mContext, callServiceClass); - return this; - } - - /** - * Which network type the backing {@link CallService} requires. This must be one of the - * {@link CallServiceInfo}.TYPE_* fields. - * - * @param networkType Which network type the backing {@link CallService} requires. - * @return This {@link Builder} for method chaining. - */ - public Builder setNetworkType(int networkType) { - mNetworkType = networkType; - return this; - } - - /** - * @return A constructed {@link CallServiceInfo} object. - */ - public CallServiceInfo 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 CallServiceInfo(UUID.randomUUID().toString(), mComponentName, mNetworkType); - } - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mCallServiceId); - dest.writeParcelable(mComponentName, 0); - dest.writeInt(mNetworkType); - } - - static final Creator CREATOR = new Creator() { - @Override - public CallServiceInfo createFromParcel(Parcel source) { - String id = source.readString(); - ComponentName componentName = source.readParcelable( - CallServiceInfo.class.getClassLoader()); - int networkType = source.readInt(); - - return new CallServiceInfo(id, componentName, networkType); - } - - @Override - public CallServiceInfo[] newArray(int size) { - return new CallServiceInfo[size]; - } - }; -} diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 74f05fe..cef9987 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -49,13 +49,14 @@ public abstract class CallServiceSelector extends Service { } @Override - public void select(CallInfo callInfo, List callServiceInfos, + public void select(CallInfo callInfo, List descriptors, ICallServiceSelectionResponse response) throws RemoteException { + // Ensure that we're running with the app's normal permission level long ident = Binder.clearCallingIdentity(); try { - response.setSelectedCallServiceInfos( - CallServiceSelector.this.select(callInfo, callServiceInfos)); + response.setSelectedCallServiceDescriptors( + CallServiceSelector.this.select(callInfo, descriptors)); } finally { Binder.restoreCallingIdentity(ident); } @@ -91,10 +92,10 @@ public abstract class CallServiceSelector extends Service { * 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 callServiceInfos The details of the available {@link CallService}s with which to place + * @param descriptors The descriptors of the available {@link CallService}s with which to place * the call. - * @return A list of prioritized {@link CallServiceInfo}s to use to complete the given call. + * @return A list of prioritized call-service descriptors to use to complete the given call. */ - protected abstract List select( - CallInfo callInfo, List callServiceInfos); + protected abstract List select( + CallInfo callInfo, List descriptors); } diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index 146d5f6..2f27257 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -17,19 +17,19 @@ package android.telecomm; import android.os.IBinder; -import android.telecomm.CallServiceInfo; +import android.telecomm.CallServiceDescriptor; import java.util.List; /** - * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations. + * Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s. */ oneway interface ICallServiceLookupResponse { /** - * Forwards the list of {@link ICallService}s as a list of {@link CallServiceInfo}s to be - * processed by Telecomm which will choose which call service, among potentially many, to - * place a call. + * 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 callServices The set of call service descriptors from {@link ICallServiceProvider}. + * @param callServiceDescriptors The set of call-service descriptors from + * {@link ICallServiceProvider}. */ - void setCallServices(in List callServices); + void setCallServiceDescriptors(in List callServiceDescriptors); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl index 1376763..51efb8e 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl @@ -17,7 +17,7 @@ package android.telecomm; import android.os.IBinder; -import android.telecomm.CallServiceInfo; +import android.telecomm.CallServiceDescriptor; import java.util.List; /** @@ -29,8 +29,9 @@ oneway interface ICallServiceSelectionResponse { * Records the sorted set of call services that are preferred by the corresponding * call-service selector. * - * @param selectedCallServiceInfos The prioritized list of preferred CallServices to use for - * completing the call. + * @param selectedCallServiceDescriptors The prioritized list of preferred call-service + * descriptors to use for completing the call. */ - void setSelectedCallServiceInfos(in List selectedCallServiceInfos); + void setSelectedCallServiceDescriptors( + in List selectedCallServiceDescriptors); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index 9652dec..8ca4c0c 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -17,7 +17,7 @@ package android.telecomm; import android.telecomm.CallInfo; -import android.telecomm.CallServiceInfo; +import android.telecomm.CallServiceDescriptor; import android.telecomm.ICallService; import android.telecomm.ICallServiceSelectionResponse; import android.telecomm.ICallSwitchabilityResponse; @@ -65,17 +65,17 @@ import java.util.List; oneway interface ICallServiceSelector { /** - * Initiates the process to retrieve the sorted set of call service IDs that are preferred by + * Initiates the process to retrieve the sorted set of call services that are preferred by * this call-service selector. * * @param callInfo The details of the relevant call. - * @param callServiceIds The list of call-service IDs. + * @param callServiceDescriptors The list of call-service descriptors to select from. * @param response The response object through which the selected service IDs are passed back * to Telecomm. */ void select( in CallInfo callInfo, - in List callServiceInfos, + in List callServiceDescriptors, in ICallServiceSelectionResponse response); /** -- cgit v1.1