diff options
| author | Ihab Awad <ihab@google.com> | 2014-06-03 18:40:45 -0700 |
|---|---|---|
| committer | Ihab Awad <ihab@google.com> | 2014-06-04 23:25:04 +0000 |
| commit | fc91b7d448507448703ce7c51c045578e20d9274 (patch) | |
| tree | 3735bfed7b0706e87b0ecca389ebed1b5101ce76 /telecomm | |
| parent | 94236c56ddef7f0a3db010c38940f6eae75f67b4 (diff) | |
| download | frameworks_base-fc91b7d448507448703ce7c51c045578e20d9274.zip frameworks_base-fc91b7d448507448703ce7c51c045578e20d9274.tar.gz frameworks_base-fc91b7d448507448703ce7c51c045578e20d9274.tar.bz2 | |
DO NOT MERGE. Implement connection error dialogs (1/4)
Implement reporting of connection errors from ConnectionServices through
Telecomm to the InCallUI.
Bug: 15195720
Bug: 15117141
Change-Id: I0e1443f75a175a212fb19afde5a7eadef15d239d
Diffstat (limited to 'telecomm')
7 files changed, 126 insertions, 32 deletions
diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/CallServiceAdapter.java index 7396808..0c57828 100644 --- a/telecomm/java/android/telecomm/CallServiceAdapter.java +++ b/telecomm/java/android/telecomm/CallServiceAdapter.java @@ -84,12 +84,16 @@ public final class CallServiceAdapter { /** * Tells Telecomm that an attempt to place the specified outgoing call failed. * - * @param callId The ID of the outgoing call. - * @param errorMessage The error associated with the failed call attempt. + * @param request The originating request for a connection. + * @param errorCode The error code associated with the failed call attempt. + * @param errorMsg The error message associated with the failed call attempt. */ - public void handleFailedOutgoingCall(String callId, String errorMessage) { + public void handleFailedOutgoingCall( + ConnectionRequest request, + int errorCode, + String errorMsg) { try { - mAdapter.handleFailedOutgoingCall(callId, errorMessage); + mAdapter.handleFailedOutgoingCall(request, errorCode, errorMsg); } catch (RemoteException e) { } } diff --git a/telecomm/java/android/telecomm/ConnectionRequest.aidl b/telecomm/java/android/telecomm/ConnectionRequest.aidl new file mode 100644 index 0000000..72e5c8c --- /dev/null +++ b/telecomm/java/android/telecomm/ConnectionRequest.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 ConnectionRequest; diff --git a/telecomm/java/android/telecomm/ConnectionRequest.java b/telecomm/java/android/telecomm/ConnectionRequest.java index c1f1871..bf5727b 100644 --- a/telecomm/java/android/telecomm/ConnectionRequest.java +++ b/telecomm/java/android/telecomm/ConnectionRequest.java @@ -18,23 +18,37 @@ package android.telecomm; import android.os.Bundle; import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; /** * Simple data container encapsulating a request to some entity to * create a new {@link Connection}. */ -public final class ConnectionRequest { +public final class ConnectionRequest implements Parcelable { // TODO: Token to limit recursive invocations // TODO: Consider upgrading "mHandle" to ordered list of handles, indicating a set of phone // numbers that would satisfy the client's needs, in order of preference + private final String mCallId; private final Uri mHandle; private final Bundle mExtras; public ConnectionRequest(Uri handle, Bundle extras) { - mHandle = handle; mExtras = extras; + this(null, handle, extras); } + public ConnectionRequest(String callId, Uri handle, Bundle extras) { + mCallId = callId; + mHandle = handle; + mExtras = extras; + } + + /** + * An identifier for this call. + */ + public String getCallId() { return mCallId; } + /** * The handle (e.g., phone number) to which the {@link Connection} is to connect. */ @@ -54,4 +68,40 @@ public final class ConnectionRequest { : ConnectionService.toLogSafePhoneNumber(mHandle.toString()), mExtras == null ? "" : mExtras); } -} + + /** + * Responsible for creating CallInfo objects for deserialized Parcels. + */ + public static final Parcelable.Creator<ConnectionRequest> CREATOR = + new Parcelable.Creator<ConnectionRequest> () { + @Override + public ConnectionRequest createFromParcel(Parcel source) { + String callId = source.readString(); + Uri handle = (Uri) source.readParcelable(getClass().getClassLoader()); + Bundle extras = (Bundle) source.readParcelable(getClass().getClassLoader()); + return new ConnectionRequest(callId, handle, extras); + } + + @Override + public ConnectionRequest[] newArray(int size) { + return new ConnectionRequest[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallInfo object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(mCallId); + destination.writeParcelable(mHandle, 0); + destination.writeParcelable(mExtras, 0); + }} diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java index aeb1c33..31de15c 100644 --- a/telecomm/java/android/telecomm/ConnectionService.java +++ b/telecomm/java/android/telecomm/ConnectionService.java @@ -18,6 +18,7 @@ package android.telecomm; import android.net.Uri; import android.os.Bundle; +import android.telephony.DisconnectCause; import java.util.HashMap; import java.util.LinkedList; @@ -115,9 +116,8 @@ public abstract class ConnectionService extends CallService { } @Override - public void onError(Uri handle, String reason) { - Log.w(this, "Error in onFindSubscriptions " + callInfo.getHandle() - + " error: " + reason); + 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); } } @@ -129,6 +129,7 @@ public abstract class ConnectionService extends CallService { Log.d(this, "call %s", callInfo); onCreateConnections( new ConnectionRequest( + callInfo.getId(), callInfo.getHandle(), callInfo.getExtras()), new Response<ConnectionRequest, Connection>() { @@ -137,7 +138,8 @@ public abstract class ConnectionService extends CallService { if (result.length != 1) { Log.d(this, "adapter handleFailedOutgoingCall %s", callInfo); getAdapter().handleFailedOutgoingCall( - callInfo.getId(), + request, + DisconnectCause.ERROR_UNSPECIFIED, "Created " + result.length + " Connections, expected 1"); for (Connection c : result) { c.abort(); @@ -150,8 +152,8 @@ public abstract class ConnectionService extends CallService { } @Override - public void onError(ConnectionRequest request, String reason) { - getAdapter().handleFailedOutgoingCall(callInfo.getId(), reason); + public void onError(ConnectionRequest request, int code, String msg) { + getAdapter().handleFailedOutgoingCall(request, code, msg); } } ); @@ -168,6 +170,7 @@ public abstract class ConnectionService extends CallService { Log.d(this, "setIncomingCallId %s %s", callId, extras); onCreateIncomingConnection( new ConnectionRequest( + callId, null, // TODO: Can we obtain this from "extras"? extras), new Response<ConnectionRequest, Connection>() { @@ -176,7 +179,8 @@ public abstract class ConnectionService extends CallService { if (result.length != 1) { Log.d(this, "adapter handleFailedOutgoingCall %s", callId); getAdapter().handleFailedOutgoingCall( - callId, + request, + DisconnectCause.ERROR_UNSPECIFIED, "Created " + result.length + " Connections, expected 1"); for (Connection c : result) { c.abort(); @@ -195,8 +199,9 @@ public abstract class ConnectionService extends CallService { } @Override - public void onError(ConnectionRequest request, String reason) { - Log.d(this, "adapter failed setIncomingCallId %s %s", request, reason); + public void onError(ConnectionRequest request, int code, String msg) { + Log.d(this, "adapter failed setIncomingCallId %s %d %s", + request, code, msg); } } ); diff --git a/telecomm/java/android/telecomm/InCallCall.java b/telecomm/java/android/telecomm/InCallCall.java index 346d207..b531ccd 100644 --- a/telecomm/java/android/telecomm/InCallCall.java +++ b/telecomm/java/android/telecomm/InCallCall.java @@ -31,7 +31,8 @@ import java.util.List; public final class InCallCall implements Parcelable { private final String mId; private final CallState mState; - private final int mDisconnectCause; + private final int mDisconnectCauseCode; + private final String mDisconnectCauseMsg; private final int mCapabilities; private final long mConnectTimeMillis; private final Uri mHandle; @@ -47,15 +48,16 @@ public final class InCallCall implements Parcelable { public InCallCall( String id, CallState state, - int disconnectCause, + int disconnectCauseCode, + String disconnectCauseMsg, int capabilities, long connectTimeMillis, Uri handle, GatewayInfo gatewayInfo, CallServiceDescriptor descriptor, CallServiceDescriptor handoffDescriptor) { - this(id, state, disconnectCause, capabilities, connectTimeMillis, handle, gatewayInfo, - descriptor, handoffDescriptor, Collections.EMPTY_LIST, null, + this(id, state, disconnectCauseCode, disconnectCauseMsg, capabilities, connectTimeMillis, + handle, gatewayInfo, descriptor, handoffDescriptor, Collections.EMPTY_LIST, null, Collections.EMPTY_LIST); } @@ -63,7 +65,8 @@ public final class InCallCall implements Parcelable { public InCallCall( String id, CallState state, - int disconnectCause, + int disconnectCauseCode, + String disconnectCauseMsg, int capabilities, long connectTimeMillis, Uri handle, @@ -75,7 +78,8 @@ public final class InCallCall implements Parcelable { List<String> childCallIds) { mId = id; mState = state; - mDisconnectCause = disconnectCause; + mDisconnectCauseCode = disconnectCauseCode; + mDisconnectCauseMsg = disconnectCauseMsg; mCapabilities = capabilities; mConnectTimeMillis = connectTimeMillis; mHandle = handle; @@ -101,8 +105,16 @@ public final class InCallCall implements Parcelable { * Reason for disconnection, values are defined in {@link DisconnectCause}. Valid when call * state is {@link CallState#DISCONNECTED}. */ - public int getDisconnectCause() { - return mDisconnectCause; + public int getDisconnectCauseCode() { + return mDisconnectCauseCode; + } + + /** + * Further optional textual information about the reason for disconnection. Valid when call + * state is {@link CallState#DISCONNECTED}. + */ + public String getDisconnectCauseMsg() { + return mDisconnectCauseMsg; } // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}. @@ -170,7 +182,8 @@ public final class InCallCall implements Parcelable { public InCallCall createFromParcel(Parcel source) { String id = source.readString(); CallState state = CallState.valueOf(source.readString()); - int disconnectCause = source.readInt(); + int disconnectCauseCode = source.readInt(); + String disconnectCauseMsg = source.readString(); int capabilities = source.readInt(); long connectTimeMillis = source.readLong(); ClassLoader classLoader = InCallCall.class.getClassLoader(); @@ -183,9 +196,9 @@ public final class InCallCall implements Parcelable { String parentCallId = source.readString(); List<String> childCallIds = new ArrayList<>(); source.readList(childCallIds, classLoader); - return new InCallCall(id, state, disconnectCause, capabilities, connectTimeMillis, - handle, gatewayInfo, descriptor, handoffDescriptor, conferenceCapableCallIds, - parentCallId, childCallIds); + return new InCallCall(id, state, disconnectCauseCode, disconnectCauseMsg, capabilities, + connectTimeMillis, handle, gatewayInfo, descriptor, handoffDescriptor, + conferenceCapableCallIds, parentCallId, childCallIds); } @Override @@ -205,7 +218,8 @@ public final class InCallCall implements Parcelable { public void writeToParcel(Parcel destination, int flags) { destination.writeString(mId); destination.writeString(mState.name()); - destination.writeInt(mDisconnectCause); + destination.writeInt(mDisconnectCauseCode); + destination.writeString(mDisconnectCauseMsg); destination.writeInt(mCapabilities); destination.writeLong(mConnectTimeMillis); destination.writeParcelable(mHandle, 0); diff --git a/telecomm/java/android/telecomm/Response.java b/telecomm/java/android/telecomm/Response.java index 14f8340..13c0702 100644 --- a/telecomm/java/android/telecomm/Response.java +++ b/telecomm/java/android/telecomm/Response.java @@ -33,7 +33,8 @@ public interface Response<IN, OUT> { * Indicates the inability to provide results. * * @param request The original request. - * @param reason The reason for the failure. + * @param code An integer code indicating the reason for failure. + * @param msg A message explaining the reason for failure. */ - void onError(IN request, String reason); + void onError(IN request, int code, String msg); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl index a92b176..f94eb32 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl @@ -17,6 +17,7 @@ package com.android.internal.telecomm; import android.telecomm.CallInfo; +import android.telecomm.ConnectionRequest; /** * Internal remote callback interface for call services. @@ -32,7 +33,7 @@ oneway interface ICallServiceAdapter { void handleSuccessfulOutgoingCall(String callId); - void handleFailedOutgoingCall(String callId, String errorMessage); + void handleFailedOutgoingCall(in ConnectionRequest request, int errorCode, String errorMessage); void setActive(String callId); |
