diff options
author | Justin Klaassen <justinklaassen@google.com> | 2018-01-03 13:39:41 -0500 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2018-01-03 13:39:41 -0500 |
commit | 98fe7819c6d14f4f464a5cac047f9e82dee5da58 (patch) | |
tree | a6b8b93eb21e205b27590ab5e2a1fb9efe27f892 /android/telecom | |
parent | 4217cf85c20565a3446a662a7f07f26137b26b7f (diff) | |
download | android-28-98fe7819c6d14f4f464a5cac047f9e82dee5da58.tar.gz |
Import Android SDK Platform P [4524038]
/google/data/ro/projects/android/fetch_artifact \
--bid 4524038 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4524038.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: Ic193bf1cf0cae78d4f2bfb4fbddfe42025c5c3c2
Diffstat (limited to 'android/telecom')
-rw-r--r-- | android/telecom/Call.java | 30 | ||||
-rw-r--r-- | android/telecom/Connection.java | 32 | ||||
-rw-r--r-- | android/telecom/ConnectionRequest.java | 5 | ||||
-rw-r--r-- | android/telecom/ConnectionService.java | 130 | ||||
-rw-r--r-- | android/telecom/ConnectionServiceAdapter.java | 13 | ||||
-rw-r--r-- | android/telecom/ConnectionServiceAdapterServant.java | 9 | ||||
-rw-r--r-- | android/telecom/InCallService.java | 12 | ||||
-rw-r--r-- | android/telecom/Phone.java | 7 | ||||
-rw-r--r-- | android/telecom/PhoneAccount.java | 3 | ||||
-rw-r--r-- | android/telecom/RemoteConnectionService.java | 3 | ||||
-rw-r--r-- | android/telecom/TelecomManager.java | 18 |
11 files changed, 227 insertions, 35 deletions
diff --git a/android/telecom/Call.java b/android/telecom/Call.java index a07f2bbf..20911012 100644 --- a/android/telecom/Call.java +++ b/android/telecom/Call.java @@ -416,8 +416,15 @@ public final class Call { */ public static final int PROPERTY_SELF_MANAGED = 0x00000100; + /** + * Indicates the call used Assisted Dialing. + * See also {@link Connection#PROPERTY_ASSISTED_DIALING_USED} + * @hide + */ + public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200; + //****************************************************************************************** - // Next PROPERTY value: 0x00000200 + // Next PROPERTY value: 0x00000400 //****************************************************************************************** private final String mTelecomCallId; @@ -577,6 +584,9 @@ public final class Call { if(hasProperty(properties, PROPERTY_HAS_CDMA_VOICE_PRIVACY)) { builder.append(" PROPERTY_HAS_CDMA_VOICE_PRIVACY"); } + if(hasProperty(properties, PROPERTY_ASSISTED_DIALING_USED)) { + builder.append(" PROPERTY_ASSISTED_DIALING_USED"); + } builder.append("]"); return builder.toString(); } @@ -858,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 {} @@ -886,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()}. @@ -1935,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/android/telecom/Connection.java b/android/telecom/Connection.java index 2bb1c4ed..aaef8d3d 100644 --- a/android/telecom/Connection.java +++ b/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,13 +396,17 @@ 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; + /** + * Set by the framework to indicate that a connection is using assisted dialing. + * @hide + */ + public static final int PROPERTY_ASSISTED_DIALING_USED = 1 << 9; + //********************************************************************************************** - // Next PROPERTY value: 1<<9 + // Next PROPERTY value: 1<<10 //********************************************************************************************** /** @@ -831,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; @@ -2608,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)); @@ -2619,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)); @@ -2635,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)); } @@ -2645,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)); } @@ -2864,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() {} /** @@ -2882,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) {} /** diff --git a/android/telecom/ConnectionRequest.java b/android/telecom/ConnectionRequest.java index e169e5f8..658b4734 100644 --- a/android/telecom/ConnectionRequest.java +++ b/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/android/telecom/ConnectionService.java b/android/telecom/ConnectionService.java index 7e833066..6af01aee 100644 --- a/android/telecom/ConnectionService.java +++ b/android/telecom/ConnectionService.java @@ -21,6 +21,7 @@ import android.app.Service; import android.content.ComponentName; import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -143,6 +144,9 @@ 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 String SESSION_HANDOVER_FAILED = "CS.haF"; private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; private static final int MSG_CREATE_CONNECTION = 2; @@ -172,6 +176,9 @@ 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 final int MSG_HANDOVER_FAILED = 32; private static Connection sNullConnection; @@ -275,6 +282,22 @@ public abstract class ConnectionService extends Service { } @Override + public void handoverFailed(String callId, ConnectionRequest request, int reason, + Session.Info sessionInfo) { + Log.startSession(sessionInfo, SESSION_HANDOVER_FAILED); + try { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = request; + args.arg3 = Log.createSubsession(); + args.arg4 = reason; + mHandler.obtainMessage(MSG_HANDOVER_FAILED, args).sendToTarget(); + } finally { + Log.endSession(); + } + } + + @Override public void abort(String callId, Session.Info sessionInfo) { Log.startSession(sessionInfo, SESSION_ABORT); try { @@ -591,6 +614,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()) { @@ -723,6 +766,36 @@ public abstract class ConnectionService extends Service { } break; } + case MSG_HANDOVER_FAILED: { + SomeArgs args = (SomeArgs) msg.obj; + Log.continueSession((Session) args.arg3, SESSION_HANDLER + + SESSION_HANDOVER_FAILED); + try { + final String id = (String) args.arg1; + final ConnectionRequest request = (ConnectionRequest) args.arg2; + final int reason = (int) args.arg4; + if (!mAreAccountsInitialized) { + Log.d(this, "Enqueueing pre-init request %s", id); + mPreInitializationConnectionRequests.add( + new android.telecom.Logging.Runnable( + SESSION_HANDLER + + SESSION_HANDOVER_FAILED + ".pICR", + null /*lock*/) { + @Override + public void loggedRun() { + handoverFailed(id, request, reason); + } + }.prepare()); + } else { + Log.i(this, "createConnectionFailed %s", id); + handoverFailed(id, request, reason); + } + } finally { + args.recycle(); + Log.endSession(); + } + break; + } case MSG_ABORT: { SomeArgs args = (SomeArgs) msg.obj; Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ABORT); @@ -1012,6 +1085,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,13 +1450,25 @@ 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 (getApplicationContext().getApplicationInfo().targetSdkVersion > + Build.VERSION_CODES.O_MR1 && request.getExtras() != null && + request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER,false)) { + if (!isIncoming) { + connection = onCreateOutgoingHandoverConnection(callManagerAccount, request); + } else { + connection = onCreateIncomingHandoverConnection(callManagerAccount, request); + } + } else { + connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request) + : isIncoming ? onCreateIncomingConnection(callManagerAccount, request) + : onCreateOutgoingConnection(callManagerAccount, request); + } Log.d(this, "createConnection, connection: %s", connection); if (connection == null) { + Log.i(this, "createConnection, implementation returned null connection."); connection = Connection.createFailedConnection( - new DisconnectCause(DisconnectCause.ERROR)); + new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONNECTION")); } connection.setTelecomCallId(callId); @@ -1442,6 +1533,13 @@ public abstract class ConnectionService extends Service { } } + private void handoverFailed(final String callId, final ConnectionRequest request, + int reason) { + + Log.i(this, "handoverFailed %s", callId); + onHandoverFailed(request, reason); + } + /** * Called by Telecom when the creation of a new Connection has completed and it is now added * to Telecom. @@ -1863,6 +1961,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. * @@ -2136,6 +2244,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) { diff --git a/android/telecom/ConnectionServiceAdapter.java b/android/telecom/ConnectionServiceAdapter.java index 92a9dc23..0d319bbc 100644 --- a/android/telecom/ConnectionServiceAdapter.java +++ b/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/android/telecom/ConnectionServiceAdapterServant.java b/android/telecom/ConnectionServiceAdapterServant.java index 3fbdeb1e..3e1bf779 100644 --- a/android/telecom/ConnectionServiceAdapterServant.java +++ b/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/android/telecom/InCallService.java b/android/telecom/InCallService.java index d558bbae..74fa62d6 100644 --- a/android/telecom/InCallService.java +++ b/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/android/telecom/Phone.java b/android/telecom/Phone.java index 421b1a4b..b5394b9b 100644 --- a/android/telecom/Phone.java +++ b/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/android/telecom/PhoneAccount.java b/android/telecom/PhoneAccount.java index 74b94650..fcfc5931 100644 --- a/android/telecom/PhoneAccount.java +++ b/android/telecom/PhoneAccount.java @@ -964,6 +964,9 @@ public final class PhoneAccount implements Parcelable { if (hasCapabilities(CAPABILITY_SIM_SUBSCRIPTION)) { sb.append("SimSub "); } + if (hasCapabilities(CAPABILITY_RTT)) { + sb.append("Rtt"); + } return sb.toString(); } diff --git a/android/telecom/RemoteConnectionService.java b/android/telecom/RemoteConnectionService.java index 85906ad1..59ce5908 100644 --- a/android/telecom/RemoteConnectionService.java +++ b/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/android/telecom/TelecomManager.java b/android/telecom/TelecomManager.java index 92d458f1..15355ac7 100644 --- a/android/telecom/TelecomManager.java +++ b/android/telecom/TelecomManager.java @@ -582,13 +582,29 @@ 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 + */ + public static final String EXTRA_USE_ASSISTED_DIALING = + "android.telecom.extra.USE_ASSISTED_DIALING"; + + /** * The following 4 constants define how properties such as phone numbers and names are * displayed to the user. */ /** * Indicates that the address or number of a call is allowed to be displayed for caller ID. - */ + */ public static final int PRESENTATION_ALLOWED = 1; /** |