diff options
Diffstat (limited to 'telecomm')
7 files changed, 462 insertions, 7 deletions
diff --git a/telecomm/java/android/telecom/BluetoothCallQualityReport.java b/telecomm/java/android/telecom/BluetoothCallQualityReport.java new file mode 100644 index 000000000000..10339a818205 --- /dev/null +++ b/telecomm/java/android/telecom/BluetoothCallQualityReport.java @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2020 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.telecom; + +import android.annotation.ElapsedRealtimeLong; +import android.annotation.IntRange; +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * This class represents the quality report that bluetooth framework sends + * whenever there's a bad voice quality is detected from their side. + * It is sent as part of a call event via {@link Call#sendCallEvent(String, Bundle)} + * associated with extra EXTRA_BLUETOOTH_CALL_QUALITY_REPORT. + * Note that this report will be sent only during an active voice/voip call. + * @hide + */ +@SystemApi +public final class BluetoothCallQualityReport implements Parcelable { + + /** + * Event that is sent via {@link Call#sendCallEvent(String, Bundle)} for a call quality report + */ + public static final String EVENT_BLUETOOTH_CALL_QUALITY_REPORT = + "android.telecom.event.BLUETOOTH_CALL_QUALITY_REPORT"; + + /** + * Extra key sent with {@link Call#sendCallEvent(String, Bundle)} + */ + public static final String EXTRA_BLUETOOTH_CALL_QUALITY_REPORT = + "android.telecom.extra.BLUETOOTH_CALL_QUALITY_REPORT"; + + private final long mSentTimestampMillis; + private final boolean mChoppyVoice; + private final int mRssiDbm; + private final int mSnrDb; + private final int mRetransmittedPacketsCount; + private final int mPacketsNotReceivedCount; + private final int mNegativeAcknowledgementCount; + + /** + * @return Time in milliseconds since the epoch. Designates when report was sent. + * Used to determine whether this report arrived too late to be useful. + */ + public @ElapsedRealtimeLong long getSentTimestampMillis() { + return mSentTimestampMillis; + } + + /** + * @return {@code true} if bluetooth hardware detects voice is choppy + */ + public boolean isChoppyVoice() { + return mChoppyVoice; + } + + /** + * @return Received Signal Strength Indication (RSSI) value in dBm. + * This value shall be an absolute received signal strength value. + */ + public @IntRange(from = -127, to = 20) int getRssiDbm() { + return mRssiDbm; + } + + /** + * @return Signal-to-Noise Ratio (SNR) value in dB. + * The controller shall provide the average SNR of all the channels currently used by the link. + */ + public int getSnrDb() { + return mSnrDb; + } + + /** + * @return The number of retransmissions since the last event. + * This count shall be reset after it is reported. + */ + public @IntRange(from = 0) int getRetransmittedPacketsCount() { + return mRetransmittedPacketsCount; + } + + /** + * @return No RX count since the last event. + * The count increases when no packet is received at the scheduled time slot or the received + * packet is corrupted. + * This count shall be reset after it is reported. + */ + public @IntRange(from = 0) int getPacketsNotReceivedCount() { + return mPacketsNotReceivedCount; + } + + /** + * @return NAK (Negative Acknowledge) count since the last event. + * This count shall be reset after it is reported. + */ + public @IntRange(from = 0) int getNegativeAcknowledgementCount() { + return mNegativeAcknowledgementCount; + } + + // + // Parcelable implementation + // + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel out, int flags) { + out.writeLong(mSentTimestampMillis); + out.writeBoolean(mChoppyVoice); + out.writeInt(mRssiDbm); + out.writeInt(mSnrDb); + out.writeInt(mRetransmittedPacketsCount); + out.writeInt(mPacketsNotReceivedCount); + out.writeInt(mNegativeAcknowledgementCount); + } + + public static final @android.annotation.NonNull Creator<BluetoothCallQualityReport> CREATOR = + new Creator<BluetoothCallQualityReport>() { + @Override + public BluetoothCallQualityReport createFromParcel(Parcel in) { + return new BluetoothCallQualityReport(in); + } + + @Override + public BluetoothCallQualityReport[] newArray(int size) { + return new BluetoothCallQualityReport[size]; + } + }; + + /** + * Builder class for {@link ConnectionRequest} + */ + public static final class Builder { + private long mSentTimestampMillis; + private boolean mChoppyVoice; + private int mRssiDbm; + private int mSnrDb; + private int mRetransmittedPacketsCount; + private int mPacketsNotReceivedCount; + private int mNegativeAcknowledgementCount; + + public Builder() { } + + /** + * Set the time when report was sent in milliseconds since the epoch. + * @param sentTimestampMillis + */ + public @NonNull Builder setSentTimestampMillis(long sentTimestampMillis) { + mSentTimestampMillis = sentTimestampMillis; + return this; + } + + /** + * Set if bluetooth hardware detects voice is choppy + * @param choppyVoice + */ + public @NonNull Builder setChoppyVoice(boolean choppyVoice) { + mChoppyVoice = choppyVoice; + return this; + } + + /** + * Set Received Signal Strength Indication (RSSI) value in dBm. + * @param rssiDbm + */ + public @NonNull Builder setRssiDbm(int rssiDbm) { + mRssiDbm = rssiDbm; + return this; + } + + /** + * Set Signal-to-Noise Ratio (SNR) value in dB. + * @param snrDb + */ + public @NonNull Builder setSnrDb(int snrDb) { + mSnrDb = snrDb; + return this; + } + + /** + * Set The number of retransmissions since the last event. + * @param retransmittedPacketsCount + */ + public @NonNull Builder setRetransmittedPacketsCount( + int retransmittedPacketsCount) { + mRetransmittedPacketsCount = retransmittedPacketsCount; + return this; + } + + /** + * Set No RX count since the last event. + * @param packetsNotReceivedCount + */ + public @NonNull Builder setPacketsNotReceivedCount( + int packetsNotReceivedCount) { + mPacketsNotReceivedCount = packetsNotReceivedCount; + return this; + } + + /** + * Set NAK (Negative Acknowledge) count since the last event. + * @param negativeAcknowledgementCount + */ + public @NonNull Builder setNegativeAcknowledgementCount( + int negativeAcknowledgementCount) { + mNegativeAcknowledgementCount = negativeAcknowledgementCount; + return this; + } + + /** + * Build the {@link BluetoothCallQualityReport} + * @return Result of the builder + */ + public @NonNull BluetoothCallQualityReport build() { + return new BluetoothCallQualityReport(this); + } + } + + private BluetoothCallQualityReport(Parcel in) { + mSentTimestampMillis = in.readLong(); + mChoppyVoice = in.readBoolean(); + mRssiDbm = in.readInt(); + mSnrDb = in.readInt(); + mRetransmittedPacketsCount = in.readInt(); + mPacketsNotReceivedCount = in.readInt(); + mNegativeAcknowledgementCount = in.readInt(); + } + + private BluetoothCallQualityReport(Builder builder) { + mSentTimestampMillis = builder.mSentTimestampMillis; + mChoppyVoice = builder.mChoppyVoice; + mRssiDbm = builder.mRssiDbm; + mSnrDb = builder.mSnrDb; + mRetransmittedPacketsCount = builder.mRetransmittedPacketsCount; + mPacketsNotReceivedCount = builder.mPacketsNotReceivedCount; + mNegativeAcknowledgementCount = builder.mNegativeAcknowledgementCount; + } +} diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 724a9e477b95..335a10221d06 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -109,6 +109,20 @@ import java.util.concurrent.ConcurrentHashMap; */ public abstract class Connection extends Conferenceable { + /**@hide*/ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = "STATE_", value = { + STATE_INITIALIZING, + STATE_NEW, + STATE_RINGING, + STATE_DIALING, + STATE_ACTIVE, + STATE_HOLDING, + STATE_DISCONNECTED, + STATE_PULLING_CALL + }) + public @interface ConnectionState {} + /** * The connection is initializing. This is generally the first state for a {@code Connection} * returned by a {@link ConnectionService}. @@ -2991,6 +3005,26 @@ public abstract class Connection extends Conferenceable { public void onCallAudioStateChanged(CallAudioState state) {} /** + * Inform this Connection when it will or will not be tracked by an {@link InCallService} which + * can provide an InCall UI. + * This is primarily intended for use by Connections reported by self-managed + * {@link ConnectionService} which typically maintain their own UI. + * + * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is + * currently tracking the self-managed call. + */ + public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {} + + /** + * Inform this Conenection when it will or will not be tracked by an non-UI + * {@link InCallService}. + * + * @param isTracked Indicates whether an non-UI InCallService is currently tracking the + * self-managed call. + */ + public void onTrackedByNonUiService(boolean isTracked) {} + + /** * Notifies this Connection of an internal state change. This method is called after the * state is changed. * diff --git a/telecomm/java/android/telecom/ConnectionRequest.java b/telecomm/java/android/telecom/ConnectionRequest.java index b73ef9b794e4..be5fae488d5e 100644 --- a/telecomm/java/android/telecom/ConnectionRequest.java +++ b/telecomm/java/android/telecom/ConnectionRequest.java @@ -18,6 +18,7 @@ package android.telecom; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.TestApi; import android.net.Uri; @@ -67,7 +68,8 @@ public final class ConnectionRequest implements Parcelable { * Sets the participants for the resulting {@link ConnectionRequest} * @param participants The participants to which the {@link Connection} is to connect. */ - public @NonNull Builder setParticipants(@Nullable List<Uri> participants) { + public @NonNull Builder setParticipants( + @SuppressLint("NullableCollection") @Nullable List<Uri> participants) { this.mParticipants = participants; return this; } diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index b1ccb533e83d..580513c12453 100755 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -137,6 +137,8 @@ public abstract class ConnectionService extends Service { private static final String SESSION_HOLD = "CS.h"; private static final String SESSION_UNHOLD = "CS.u"; private static final String SESSION_CALL_AUDIO_SC = "CS.cASC"; + private static final String SESSION_USING_ALTERNATIVE_UI = "CS.uAU"; + private static final String SESSION_TRACKED_BY_NON_UI_SERVICE = "CS.tBNUS"; private static final String SESSION_PLAY_DTMF = "CS.pDT"; private static final String SESSION_STOP_DTMF = "CS.sDT"; private static final String SESSION_CONFERENCE = "CS.c"; @@ -200,6 +202,9 @@ public abstract class ConnectionService extends Service { private static final int MSG_ADD_PARTICIPANT = 39; private static final int MSG_EXPLICIT_CALL_TRANSFER = 40; private static final int MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE = 41; + private static final int MSG_ON_CALL_FILTERING_COMPLETED = 42; + private static final int MSG_ON_USING_ALTERNATIVE_UI = 43; + private static final int MSG_ON_TRACKED_BY_NON_UI_SERVICE = 44; private static Connection sNullConnection; @@ -584,6 +589,36 @@ public abstract class ConnectionService extends Service { } @Override + public void onUsingAlternativeUi(String callId, boolean usingAlternativeUiShowing, + Session.Info sessionInfo) { + Log.startSession(sessionInfo, SESSION_USING_ALTERNATIVE_UI); + try { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = usingAlternativeUiShowing; + args.arg3 = Log.createSubsession(); + mHandler.obtainMessage(MSG_ON_USING_ALTERNATIVE_UI, args).sendToTarget(); + } finally { + Log.endSession(); + } + } + + @Override + public void onTrackedByNonUiService(String callId, boolean isTracked, + Session.Info sessionInfo) { + Log.startSession(sessionInfo, SESSION_TRACKED_BY_NON_UI_SERVICE); + try { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = isTracked; + args.arg3 = Log.createSubsession(); + mHandler.obtainMessage(MSG_ON_TRACKED_BY_NON_UI_SERVICE, args).sendToTarget(); + } finally { + Log.endSession(); + } + } + + @Override public void playDtmfTone(String callId, char digit, Session.Info sessionInfo) { Log.startSession(sessionInfo, SESSION_PLAY_DTMF); try { @@ -1226,6 +1261,34 @@ public abstract class ConnectionService extends Service { } break; } + case MSG_ON_USING_ALTERNATIVE_UI: { + SomeArgs args = (SomeArgs) msg.obj; + Log.continueSession((Session) args.arg3, + SESSION_HANDLER + SESSION_USING_ALTERNATIVE_UI); + try { + String callId = (String) args.arg1; + boolean isUsingAlternativeUi = (boolean) args.arg2; + onUsingAlternativeUi(callId, isUsingAlternativeUi); + } finally { + args.recycle(); + Log.endSession(); + } + break; + } + case MSG_ON_TRACKED_BY_NON_UI_SERVICE: { + SomeArgs args = (SomeArgs) msg.obj; + Log.continueSession((Session) args.arg3, + SESSION_HANDLER + SESSION_TRACKED_BY_NON_UI_SERVICE); + try { + String callId = (String) args.arg1; + boolean isTracked = (boolean) args.arg2; + onTrackedByNonUiService(callId, isTracked); + } finally { + args.recycle(); + Log.endSession(); + } + break; + } case MSG_PLAY_DTMF_TONE: { SomeArgs args = (SomeArgs) msg.obj; try { @@ -1928,10 +1991,12 @@ public abstract class ConnectionService extends Service { request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER, false); boolean isHandover = request.getExtras() != null && request.getExtras().getBoolean( TelecomManager.EXTRA_IS_HANDOVER_CONNECTION, false); - Log.d(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " + - "isIncoming: %b, isUnknown: %b, isLegacyHandover: %b, isHandover: %b", - callManagerAccount, callId, request, isIncoming, isUnknown, isLegacyHandover, - isHandover); + boolean addSelfManaged = request.getExtras() != null && request.getExtras().getBoolean( + PhoneAccount.EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE, true); + Log.i(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " + + "isIncoming: %b, isUnknown: %b, isLegacyHandover: %b, isHandover: %b, " + + " addSelfManaged: %b", callManagerAccount, callId, request, isIncoming, + isUnknown, isLegacyHandover, isHandover, addSelfManaged); Connection connection = null; if (isHandover) { @@ -2206,6 +2271,22 @@ public abstract class ConnectionService extends Service { } } + private void onUsingAlternativeUi(String callId, boolean isUsingAlternativeUi) { + Log.i(this, "onUsingAlternativeUi %s %s", callId, isUsingAlternativeUi); + if (mConnectionById.containsKey(callId)) { + findConnectionForAction(callId, "onUsingAlternativeUi") + .onUsingAlternativeUi(isUsingAlternativeUi); + } + } + + private void onTrackedByNonUiService(String callId, boolean isTracked) { + Log.i(this, "onTrackedByNonUiService %s %s", callId, isTracked); + if (mConnectionById.containsKey(callId)) { + findConnectionForAction(callId, "onTrackedByNonUiService") + .onTrackedByNonUiService(isTracked); + } + } + private void playDtmfTone(String callId, char digit) { Log.i(this, "playDtmfTone %s %c", callId, digit); if (mConnectionById.containsKey(callId)) { diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 5024ae27ee49..579b33e9c283 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -188,6 +188,15 @@ public final class PhoneAccount implements Parcelable { "android.telecom.extra.SKIP_CALL_FILTERING"; /** + * Boolean {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which + * indicates whether a Self-managed {@link PhoneAccount} want to expose its calls to all + * {@link InCallService} which declares the metadata + * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS}. + */ + public static final String EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE = + "android.telecom.extra.ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE"; + + /** * Flag indicating that this {@code PhoneAccount} can act as a connection manager for * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount} * will be allowed to manage phone calls including using its own proprietary phone-call @@ -361,7 +370,13 @@ public final class PhoneAccount implements Parcelable { */ public static final int CAPABILITY_ADHOC_CONFERENCE_CALLING = 0x4000; - /* NEXT CAPABILITY: 0x8000 */ + /** + * Flag indicating whether this {@link PhoneAccount} is capable of supporting the call composer + * functionality for enriched calls. + */ + public static final int CAPABILITY_CALL_COMPOSER = 0x8000; + + /* NEXT CAPABILITY: 0x10000 */ /** * URI scheme for telephone number URIs. @@ -1088,6 +1103,9 @@ public final class PhoneAccount implements Parcelable { if (hasCapabilities(CAPABILITY_ADHOC_CONFERENCE_CALLING)) { sb.append("AdhocConf"); } + if (hasCapabilities(CAPABILITY_CALL_COMPOSER)) { + sb.append("CallComposer "); + } return sb.toString(); } diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index afe186cba0db..422dc9574d18 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -266,10 +266,69 @@ public class TelecomManager { /** * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a string call * subject which will be associated with an outgoing call. Should only be specified if the - * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}. + * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT} + * or {@link PhoneAccount#CAPABILITY_CALL_COMPOSER}. */ public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT"; + // Values for EXTRA_PRIORITY + /** + * Indicates the call composer call priority is normal. + * + * Reference: RCC.20 Section 2.4.4.2 + */ + public static final int PRIORITY_NORMAL = 0; + + /** + * Indicates the call composer call priority is urgent. + * + * Reference: RCC.20 Section 2.4.4.2 + */ + public static final int PRIORITY_URGENT = 1; + + /** + * Extra for the call composer call priority, either {@link #PRIORITY_NORMAL} or + * {@link #PRIORITY_URGENT}. + * + * Reference: RCC.20 Section 2.4.4.2 + */ + public static final String EXTRA_PRIORITY = "android.telecom.extra.PRIORITY"; + + /** + * Extra for the call composer call location, an {@link android.location.Location} parcelable + * class to represent the geolocation as a latitude and longitude pair. + * + * Reference: RCC.20 Section 2.4.3.2 + */ + public static final String EXTRA_LOCATION = "android.telecom.extra.LOCATION"; + + /** + * A boolean extra set on incoming calls to indicate that the call has a picture specified. + * Given that image download could take a (short) time, the EXTRA is set immediately upon + * adding the call to the Dialer app, this allows the Dialer app to reserve space for an image + * if one is expected. The EXTRA may be unset if the image download ends up failing for some + * reason. + */ + public static final String EXTRA_HAS_PICTURE = "android.telecom.extra.HAS_PICTURE"; + + /** + * A URI representing the picture that was downloaded when a call is received. + * This is a content URI within the call log provider which can be used to open a file + * descriptor. This could be set a short time after a call is added to the Dialer app if the + * download is delayed for some reason. The Dialer app will receive a callback via + * {@link Call.Callback#onDetailsChanged} when this value has changed. + * + * Reference: RCC.20 Section 2.4.3.2 + */ + public static final String EXTRA_INCOMING_PICTURE = "android.telecom.extra.INCOMING_PICTURE"; + + // TODO(hallliu), This UUID is obtained from TelephonyManager#uploadCallComposerPicture. + /** + * A ParcelUuid used as a token to represent a picture that was uploaded prior to the call + * being placed. + */ + public static final String EXTRA_OUTGOING_PICTURE = "android.telecom.extra.OUTGOING_PICTURE"; + /** * The extra used by a {@link ConnectionService} to provide the handle of the caller that * has initiated a new incoming call. diff --git a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl index fb5417994b57..d5555474f248 100644 --- a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl +++ b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl @@ -136,4 +136,9 @@ oneway interface IConnectionService { int error, in Session.Info sessionInfo); void handoverComplete(String callId, in Session.Info sessionInfo); + + void onUsingAlternativeUi(String callId, boolean isUsingAlternativeUi, + in Session.Info sessionInfo); + + void onTrackedByNonUiService(String callId, boolean isTracked, in Session.Info sessionInfo); } |