diff options
Diffstat (limited to 'telecomm/java')
13 files changed, 203 insertions, 35 deletions
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 5cd2044f8318..20911012e6ba 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -868,7 +868,8 @@ public final class Call { * @hide */ @IntDef({HANDOVER_FAILURE_DEST_APP_REJECTED, HANDOVER_FAILURE_DEST_NOT_SUPPORTED, - HANDOVER_FAILURE_DEST_INVALID_PERM, HANDOVER_FAILURE_DEST_USER_REJECTED}) + HANDOVER_FAILURE_DEST_INVALID_PERM, HANDOVER_FAILURE_DEST_USER_REJECTED, + HANDOVER_FAILURE_ONGOING_EMERG_CALL}) @Retention(RetentionPolicy.SOURCE) public @interface HandoverFailureErrors {} @@ -896,6 +897,12 @@ public final class Call { */ public static final int HANDOVER_FAILURE_DEST_USER_REJECTED = 4; + /** + * Handover failure reason returned via {@link #onHandoverFailed(Call, int)} when there + * is ongoing emergency call. + */ + public static final int HANDOVER_FAILURE_ONGOING_EMERG_CALL = 5; + /** * Invoked when the state of this {@code Call} has changed. See {@link #getState()}. @@ -1945,6 +1952,15 @@ public final class Call { } } + /** {@hide} */ + final void internalOnHandoverFailed(int error) { + for (CallbackRecord<Callback> record : mCallbackRecords) { + final Call call = this; + final Callback callback = record.getCallback(); + record.getHandler().post(() -> callback.onHandoverFailed(call, error)); + } + } + private void fireStateChanged(final int newState) { for (CallbackRecord<Callback> record : mCallbackRecords) { final Call call = this; diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index d71fde28480c..aaef8d3d3856 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -23,7 +23,6 @@ import com.android.internal.telecom.IVideoProvider; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; -import android.annotation.TestApi; import android.app.Notification; import android.bluetooth.BluetoothDevice; import android.content.Intent; @@ -397,9 +396,7 @@ public abstract class Connection extends Conferenceable { /** * Set by the framework to indicate that a connection has an active RTT session associated with * it. - * @hide */ - @TestApi public static final int PROPERTY_IS_RTT = 1 << 8; /** @@ -837,9 +834,7 @@ public abstract class Connection extends Conferenceable { /** * Provides methods to read and write RTT data to/from the in-call app. - * @hide */ - @TestApi public static final class RttTextStream { private static final int READ_BUFFER_SIZE = 1000; private final InputStreamReader mPipeFromInCall; @@ -1690,6 +1685,8 @@ public abstract class Connection extends Conferenceable { // The internal telecom call ID associated with this connection. private String mTelecomCallId; + // The PhoneAccountHandle associated with this connection. + private PhoneAccountHandle mPhoneAccountHandle; private int mState = STATE_NEW; private CallAudioState mCallAudioState; private Uri mAddress; @@ -2612,10 +2609,8 @@ public abstract class Connection extends Conferenceable { /** * Informs listeners that a previously requested RTT session via * {@link ConnectionRequest#isRequestingRtt()} or - * {@link #onStartRtt(ParcelFileDescriptor, ParcelFileDescriptor)} has succeeded. - * @hide + * {@link #onStartRtt(RttTextStream)} has succeeded. */ - @TestApi public final void sendRttInitiationSuccess() { setRttProperty(); mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this)); @@ -2623,14 +2618,11 @@ public abstract class Connection extends Conferenceable { /** * Informs listeners that a previously requested RTT session via - * {@link ConnectionRequest#isRequestingRtt()} or - * {@link #onStartRtt(ParcelFileDescriptor, ParcelFileDescriptor)} + * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)} * has failed. * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}. - * @hide */ - @TestApi public final void sendRttInitiationFailure(int reason) { unsetRttProperty(); mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason)); @@ -2639,9 +2631,7 @@ public abstract class Connection extends Conferenceable { /** * Informs listeners that a currently active RTT session has been terminated by the remote * side of the coll. - * @hide */ - @TestApi public final void sendRttSessionRemotelyTerminated() { mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this)); } @@ -2649,9 +2639,7 @@ public abstract class Connection extends Conferenceable { /** * Informs listeners that the remote side of the call has requested an upgrade to include an * RTT session in the call. - * @hide */ - @TestApi public final void sendRemoteRttRequest() { mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this)); } @@ -2868,17 +2856,13 @@ public abstract class Connection extends Conferenceable { * request, respectively. * @param rttTextStream The object that should be used to send text to or receive text from * the in-call app. - * @hide */ - @TestApi public void onStartRtt(@NonNull RttTextStream rttTextStream) {} /** * Notifies this {@link Connection} that it should terminate any existing RTT communication * channel. No response to Telecom is needed for this method. - * @hide */ - @TestApi public void onStopRtt() {} /** @@ -2886,11 +2870,9 @@ public abstract class Connection extends Conferenceable { * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is * indicated by the supplied {@link RttTextStream} being non-null, and rejection is * indicated by {@code rttTextStream} being {@code null} - * @hide * @param rttTextStream The object that should be used to send text to or receive text from * the in-call app. */ - @TestApi public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {} /** @@ -3105,6 +3087,27 @@ public abstract class Connection extends Conferenceable { } /** + * Sets the {@link PhoneAccountHandle} associated with this connection. + * + * @hide + */ + public void setPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) { + if (mPhoneAccountHandle != phoneAccountHandle) { + mPhoneAccountHandle = phoneAccountHandle; + notifyPhoneAccountChanged(phoneAccountHandle); + } + } + + /** + * Returns the {@link PhoneAccountHandle} associated with this connection. + * + * @hide + */ + public PhoneAccountHandle getPhoneAccountHandle() { + return mPhoneAccountHandle; + } + + /** * Sends an event associated with this {@code Connection} with associated event extras to the * {@link InCallService}. * <p> diff --git a/telecomm/java/android/telecom/ConnectionRequest.java b/telecomm/java/android/telecom/ConnectionRequest.java index e169e5f80741..658b4734b0b5 100644 --- a/telecomm/java/android/telecom/ConnectionRequest.java +++ b/telecomm/java/android/telecom/ConnectionRequest.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.TestApi; import android.net.Uri; import android.os.Bundle; import android.os.Parcel; @@ -310,9 +309,7 @@ public final class ConnectionRequest implements Parcelable { * send and receive RTT text to/from the in-call app. * @return An instance of {@link android.telecom.Connection.RttTextStream}, or {@code null} * if this connection request is not requesting an RTT session upon connection establishment. - * @hide */ - @TestApi public Connection.RttTextStream getRttTextStream() { if (isRequestingRtt()) { return new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall); @@ -324,9 +321,7 @@ public final class ConnectionRequest implements Parcelable { /** * Convenience method for determining whether the ConnectionRequest is requesting an RTT session * @return {@code true} if RTT is requested, {@code false} otherwise. - * @hide */ - @TestApi public boolean isRequestingRtt() { return mRttPipeFromInCall != null && mRttPipeToInCall != null; } diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index da8ac5ec00d7..70016157960a 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -143,6 +143,8 @@ public abstract class ConnectionService extends Service { private static final String SESSION_START_RTT = "CS.+RTT"; private static final String SESSION_STOP_RTT = "CS.-RTT"; private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR"; + private static final String SESSION_CONNECTION_SERVICE_FOCUS_LOST = "CS.cSFL"; + private static final String SESSION_CONNECTION_SERVICE_FOCUS_GAINED = "CS.cSFG"; private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; private static final int MSG_CREATE_CONNECTION = 2; @@ -172,6 +174,8 @@ public abstract class ConnectionService extends Service { private static final int MSG_ON_STOP_RTT = 27; private static final int MSG_RTT_UPGRADE_RESPONSE = 28; private static final int MSG_CREATE_CONNECTION_COMPLETE = 29; + private static final int MSG_CONNECTION_SERVICE_FOCUS_LOST = 30; + private static final int MSG_CONNECTION_SERVICE_FOCUS_GAINED = 31; private static Connection sNullConnection; @@ -591,6 +595,26 @@ public abstract class ConnectionService extends Service { Log.endSession(); } } + + @Override + public void connectionServiceFocusLost(Session.Info sessionInfo) throws RemoteException { + Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_LOST); + try { + mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_LOST).sendToTarget(); + } finally { + Log.endSession(); + } + } + + @Override + public void connectionServiceFocusGained(Session.Info sessionInfo) throws RemoteException { + Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_GAINED); + try { + mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_GAINED).sendToTarget(); + } finally { + Log.endSession(); + } + } }; private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -1012,6 +1036,12 @@ public abstract class ConnectionService extends Service { } break; } + case MSG_CONNECTION_SERVICE_FOCUS_GAINED: + onConnectionServiceFocusGained(); + break; + case MSG_CONNECTION_SERVICE_FOCUS_LOST: + onConnectionServiceFocusLost(); + break; default: break; } @@ -1371,9 +1401,19 @@ public abstract class ConnectionService extends Service { isIncoming, isUnknown); - Connection connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request) - : isIncoming ? onCreateIncomingConnection(callManagerAccount, request) - : onCreateOutgoingConnection(callManagerAccount, request); + Connection connection = null; + if (request.getExtras() != null && request.getExtras().getBoolean( + TelecomManager.EXTRA_IS_HANDOVER,false)) { + if (!isIncoming) { + connection = onCreateOutgoingHandoverConnection(callManagerAccount, request); + } else { + // Todo: Call onCreateIncommingHandoverConnection() + } + } else { + connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request) + : isIncoming ? onCreateIncomingConnection(callManagerAccount, request) + : onCreateOutgoingConnection(callManagerAccount, request); + } Log.d(this, "createConnection, connection: %s", connection); if (connection == null) { connection = Connection.createFailedConnection( @@ -1382,7 +1422,7 @@ public abstract class ConnectionService extends Service { connection.setTelecomCallId(callId); if (connection.getState() != Connection.STATE_DISCONNECTED) { - addConnection(callId, connection); + addConnection(request.getAccountHandle(), callId, connection); } Uri address = connection.getAddress(); @@ -1846,6 +1886,7 @@ public abstract class ConnectionService extends Service { mAdapter.setIsConferenced(connectionId, id); } } + onConferenceAdded(conference); } } @@ -1862,6 +1903,16 @@ public abstract class ConnectionService extends Service { } /** + * Call to inform Telecom that your {@link ConnectionService} has released call resources (e.g + * microphone, camera). + * + * @see ConnectionService#onConnectionServiceFocusLost() + */ + public final void connectionServiceFocusReleased() { + mAdapter.onConnectionServiceFocusReleased(); + } + + /** * Adds a connection created by the {@link ConnectionService} and informs telecom of the new * connection. * @@ -2093,6 +2144,30 @@ public abstract class ConnectionService extends Service { public void onConference(Connection connection1, Connection connection2) {} /** + * Called when a connection is added. + * @hide + */ + public void onConnectionAdded(Connection connection) {} + + /** + * Called when a connection is removed. + * @hide + */ + public void onConnectionRemoved(Connection connection) {} + + /** + * Called when a conference is added. + * @hide + */ + public void onConferenceAdded(Conference conference) {} + + /** + * Called when a conference is removed. + * @hide + */ + public void onConferenceRemoved(Conference conference) {} + + /** * Indicates that a remote conference has been created for existing {@link RemoteConnection}s. * When this method is invoked, this {@link ConnectionService} should create its own * representation of the conference call and send it to telecom using {@link #addConference}. @@ -2111,6 +2186,20 @@ public abstract class ConnectionService extends Service { public void onRemoteExistingConnectionAdded(RemoteConnection connection) {} /** + * Called when the {@link ConnectionService} has lost the call focus. + * The {@link ConnectionService} should release the call resources and invokes + * {@link ConnectionService#connectionServiceFocusReleased()} to inform telecom that it has + * released the call resources. + */ + public void onConnectionServiceFocusLost() {} + + /** + * Called when the {@link ConnectionService} has gained the call focus. The + * {@link ConnectionService} can acquire the call resources at this time. + */ + public void onConnectionServiceFocusGained() {} + + /** * @hide */ public boolean containsConference(Conference conference) { @@ -2159,16 +2248,18 @@ public abstract class ConnectionService extends Service { // prefix for a unique incremental call ID. id = handle.getComponentName().getClassName() + "@" + getNextCallId(); } - addConnection(id, connection); + addConnection(handle, id, connection); return id; } - private void addConnection(String callId, Connection connection) { + private void addConnection(PhoneAccountHandle handle, String callId, Connection connection) { connection.setTelecomCallId(callId); mConnectionById.put(callId, connection); mIdByConnection.put(connection, callId); connection.addConnectionListener(mConnectionListener); connection.setConnectionService(this); + connection.setPhoneAccountHandle(handle); + onConnectionAdded(connection); } /** {@hide} */ @@ -2180,6 +2271,7 @@ public abstract class ConnectionService extends Service { mConnectionById.remove(id); mIdByConnection.remove(connection); mAdapter.removeCall(id); + onConnectionRemoved(connection); } } @@ -2216,6 +2308,8 @@ public abstract class ConnectionService extends Service { mConferenceById.remove(id); mIdByConference.remove(conference); mAdapter.removeCall(id); + + onConferenceRemoved(conference); } } diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapter.java b/telecomm/java/android/telecom/ConnectionServiceAdapter.java index 92a9dc2303c8..0d319bbc1d2a 100644 --- a/telecomm/java/android/telecom/ConnectionServiceAdapter.java +++ b/telecomm/java/android/telecom/ConnectionServiceAdapter.java @@ -628,4 +628,17 @@ final class ConnectionServiceAdapter implements DeathRecipient { } } } + + /** + * Notifies Telecom that the {@link ConnectionService} has released the call resource. + */ + void onConnectionServiceFocusReleased() { + for (IConnectionServiceAdapter adapter : mAdapters) { + try { + Log.d(this, "onConnectionServiceFocusReleased"); + adapter.onConnectionServiceFocusReleased(Log.getExternalSession()); + } catch (RemoteException ignored) { + } + } + } } diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java index 3fbdeb1effb0..3e1bf7790304 100644 --- a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java +++ b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java @@ -73,6 +73,7 @@ final class ConnectionServiceAdapterServant { private static final int MSG_ON_RTT_REMOTELY_TERMINATED = 32; private static final int MSG_ON_RTT_UPGRADE_REQUEST = 33; private static final int MSG_SET_PHONE_ACCOUNT_CHANGED = 34; + private static final int MSG_CONNECTION_SERVICE_FOCUS_RELEASED = 35; private final IConnectionServiceAdapter mDelegate; @@ -329,6 +330,9 @@ final class ConnectionServiceAdapterServant { } break; } + case MSG_CONNECTION_SERVICE_FOCUS_RELEASED: + mDelegate.onConnectionServiceFocusReleased(null /*Session.Info*/); + break; } } }; @@ -601,6 +605,11 @@ final class ConnectionServiceAdapterServant { args.arg2 = pHandle; mHandler.obtainMessage(MSG_SET_PHONE_ACCOUNT_CHANGED, args).sendToTarget(); } + + @Override + public void onConnectionServiceFocusReleased(Session.Info sessionInfo) { + mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_RELEASED).sendToTarget(); + } }; public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) { diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java index d558bbaea6d3..74fa62d62ccf 100644 --- a/telecomm/java/android/telecom/InCallService.java +++ b/telecomm/java/android/telecom/InCallService.java @@ -80,6 +80,7 @@ public abstract class InCallService extends Service { private static final int MSG_ON_CONNECTION_EVENT = 9; private static final int MSG_ON_RTT_UPGRADE_REQUEST = 10; private static final int MSG_ON_RTT_INITIATION_FAILURE = 11; + private static final int MSG_ON_HANDOVER_FAILED = 12; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -150,6 +151,12 @@ public abstract class InCallService extends Service { mPhone.internalOnRttInitiationFailure(callId, reason); break; } + case MSG_ON_HANDOVER_FAILED: { + String callId = (String) msg.obj; + int error = msg.arg1; + mPhone.internalOnHandoverFailed(callId, error); + break; + } default: break; } @@ -225,6 +232,11 @@ public abstract class InCallService extends Service { public void onRttInitiationFailure(String callId, int reason) { mHandler.obtainMessage(MSG_ON_RTT_INITIATION_FAILURE, reason, 0, callId).sendToTarget(); } + + @Override + public void onHandoverFailed(String callId, int error) { + mHandler.obtainMessage(MSG_ON_HANDOVER_FAILED, error, 0, callId).sendToTarget(); + } } private Phone.Listener mPhoneListener = new Phone.Listener() { diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java index 421b1a4b22a5..b5394b9b0290 100644 --- a/telecomm/java/android/telecom/Phone.java +++ b/telecomm/java/android/telecom/Phone.java @@ -223,6 +223,13 @@ public final class Phone { } } + final void internalOnHandoverFailed(String callId, int error) { + Call call = mCallByTelecomCallId.get(callId); + if (call != null) { + call.internalOnHandoverFailed(error); + } + } + /** * Called to destroy the phone and cleanup any lingering calls. */ diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java index 85906ad116be..59ce590858ee 100644 --- a/telecomm/java/android/telecom/RemoteConnectionService.java +++ b/telecomm/java/android/telecom/RemoteConnectionService.java @@ -213,6 +213,9 @@ final class RemoteConnectionService { } @Override + public void onConnectionServiceFocusReleased(Session.Info sessionInfo) {} + + @Override public void addConferenceCall( final String callId, ParcelableConference parcel, Session.Info sessionInfo) { RemoteConference conference = new RemoteConference(callId, diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index e1247502fe86..15355ac745a4 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -582,6 +582,14 @@ public class TelecomManager { "android.telecom.extra.CALL_BACK_INTENT"; /** + * The dialer activity responsible for placing emergency calls from, for example, a locked + * keyguard. + * @hide + */ + public static final ComponentName EMERGENCY_DIALER_COMPONENT = + ComponentName.createRelative("com.android.phone", ".EmergencyDialer"); + + /** * The boolean indicated by this extra controls whether or not a call is eligible to undergo * assisted dialing. This extra is stored under {@link #EXTRA_OUTGOING_CALL_EXTRAS}. * @hide @@ -596,7 +604,7 @@ public class TelecomManager { /** * Indicates that the address or number of a call is allowed to be displayed for caller ID. - */ + */ public static final int PRESENTATION_ALLOWED = 1; /** diff --git a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl index e428286ad1e3..a74056607a24 100644 --- a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl +++ b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl @@ -100,4 +100,8 @@ oneway interface IConnectionService { void respondToRttUpgradeRequest(String callId, in ParcelFileDescriptor fromInCall, in ParcelFileDescriptor toInCall, in Session.Info sessionInfo); + + void connectionServiceFocusLost(in Session.Info sessionInfo); + + void connectionServiceFocusGained(in Session.Info sessionInfo); } diff --git a/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl b/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl index da2015f6b99b..be474bd467ca 100644 --- a/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl @@ -119,4 +119,6 @@ oneway interface IConnectionServiceAdapter { void onPhoneAccountChanged(String callId, in PhoneAccountHandle pHandle, in Session.Info sessionInfo); + + void onConnectionServiceFocusReleased(in Session.Info sessionInfo); } diff --git a/telecomm/java/com/android/internal/telecom/IInCallService.aidl b/telecomm/java/com/android/internal/telecom/IInCallService.aidl index e8cf8e975444..110109e6e276 100644 --- a/telecomm/java/com/android/internal/telecom/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecom/IInCallService.aidl @@ -54,4 +54,6 @@ oneway interface IInCallService { void onRttUpgradeRequest(String callId, int id); void onRttInitiationFailure(String callId, int reason); + + void onHandoverFailed(String callId, int error); } |