diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 54c666314f985..0eb5553e11fa7 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10452,11 +10452,32 @@ package android.telecom { method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onBluetoothCallQualityReportReceived(@NonNull android.telecom.BluetoothCallQualityReport); method public abstract void onCallAudioStateChanged(@NonNull android.telecom.CallAudioState); - method @NonNull public abstract android.telecom.DiagnosticCall onInitializeDiagnosticCall(@NonNull android.telecom.Call.Details); - method public abstract void onRemoveDiagnosticCall(@NonNull android.telecom.DiagnosticCall); + method @NonNull public abstract android.telecom.CallDiagnostics onInitializeCallDiagnostics(@NonNull android.telecom.Call.Details); + method public abstract void onRemoveCallDiagnostics(@NonNull android.telecom.CallDiagnostics); field public static final String SERVICE_INTERFACE = "android.telecom.CallDiagnosticService"; } + public abstract class CallDiagnostics { + ctor public CallDiagnostics(); + method public final void clearDiagnosticMessage(int); + method public final void displayDiagnosticMessage(int, @NonNull CharSequence); + method public abstract void onCallDetailsChanged(@NonNull android.telecom.Call.Details); + method @Nullable public abstract CharSequence onCallDisconnected(int, int); + method @Nullable public abstract CharSequence onCallDisconnected(@NonNull android.telephony.ims.ImsReasonInfo); + method public abstract void onCallQualityReceived(@NonNull android.telephony.CallQuality); + method public abstract void onReceiveDeviceToDeviceMessage(int, int); + method public final void sendDeviceToDeviceMessage(int, int); + field public static final int BATTERY_STATE_CHARGING = 3; // 0x3 + field public static final int BATTERY_STATE_GOOD = 2; // 0x2 + field public static final int BATTERY_STATE_LOW = 1; // 0x1 + field public static final int COVERAGE_GOOD = 2; // 0x2 + field public static final int COVERAGE_POOR = 1; // 0x1 + field public static final int MESSAGE_CALL_AUDIO_CODEC = 2; // 0x2 + field public static final int MESSAGE_CALL_NETWORK_TYPE = 1; // 0x1 + field public static final int MESSAGE_DEVICE_BATTERY_STATE = 3; // 0x3 + field public static final int MESSAGE_DEVICE_NETWORK_COVERAGE = 4; // 0x4 + } + public static class CallScreeningService.CallResponse.Builder { method @NonNull @RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_OUTPUT) public android.telecom.CallScreeningService.CallResponse.Builder setShouldScreenCallViaAudioProcessing(boolean); } @@ -10517,25 +10538,8 @@ package android.telecom { method public final void addExistingConnection(@NonNull android.telecom.PhoneAccountHandle, @NonNull android.telecom.Connection, @NonNull android.telecom.Conference); } - public abstract class DiagnosticCall { - ctor public DiagnosticCall(); - method public final void clearDiagnosticMessage(int); - method public final void displayDiagnosticMessage(int, @NonNull CharSequence); - method public abstract void onCallDetailsChanged(@NonNull android.telecom.Call.Details); - method @Nullable public abstract CharSequence onCallDisconnected(int, int); - method @Nullable public abstract CharSequence onCallDisconnected(@NonNull android.telephony.ims.ImsReasonInfo); - method public abstract void onCallQualityReceived(@NonNull android.telephony.CallQuality); - method public abstract void onReceiveDeviceToDeviceMessage(int, int); - method public final void sendDeviceToDeviceMessage(int, int); - field public static final int BATTERY_STATE_CHARGING = 3; // 0x3 - field public static final int BATTERY_STATE_GOOD = 2; // 0x2 - field public static final int BATTERY_STATE_LOW = 1; // 0x1 - field public static final int COVERAGE_GOOD = 2; // 0x2 - field public static final int COVERAGE_POOR = 1; // 0x1 - field public static final int MESSAGE_CALL_AUDIO_CODEC = 2; // 0x2 - field public static final int MESSAGE_CALL_NETWORK_TYPE = 1; // 0x1 - field public static final int MESSAGE_DEVICE_BATTERY_STATE = 3; // 0x3 - field public static final int MESSAGE_DEVICE_NETWORK_COVERAGE = 4; // 0x4 + @Deprecated public abstract class DiagnosticCall extends android.telecom.CallDiagnostics { + ctor @Deprecated public DiagnosticCall(); } public abstract class InCallService extends android.app.Service { diff --git a/telecomm/java/android/telecom/CallDiagnosticService.java b/telecomm/java/android/telecom/CallDiagnosticService.java index 5fb6b3381360d..f5357b19c4de9 100644 --- a/telecomm/java/android/telecom/CallDiagnosticService.java +++ b/telecomm/java/android/telecom/CallDiagnosticService.java @@ -27,8 +27,6 @@ import android.os.Handler; import android.os.HandlerExecutor; import android.os.IBinder; import android.os.RemoteException; -import android.telephony.Annotation; -import android.telephony.ims.ImsReasonInfo; import android.util.ArrayMap; import com.android.internal.telecom.ICallDiagnosticService; @@ -59,7 +57,7 @@ import java.util.concurrent.Executor; * *
*
- * The {@link CallDiagnosticService} returns an implementation of {@link DiagnosticCall} to be + * The {@link CallDiagnosticService} returns an implementation of {@link CallDiagnostics} to be * used for the lifespan of this call. *
* Calls to this method will use the {@link CallDiagnosticService}'s {@link Executor}; see * {@link CallDiagnosticService#getExecutor()} for more information. * * @param call The details of the new call. - * @return An instance of {@link DiagnosticCall} which the {@link CallDiagnosticService} + * @return An instance of {@link CallDiagnostics} which the {@link CallDiagnosticService} * provides to be used for the lifespan of the call. - * @throws IllegalArgumentException if a {@code null} {@link DiagnosticCall} is returned. + * @throws IllegalArgumentException if a {@code null} {@link CallDiagnostics} is returned. */ - public abstract @NonNull DiagnosticCall onInitializeDiagnosticCall(@NonNull + public abstract @NonNull CallDiagnostics onInitializeCallDiagnostics(@NonNull android.telecom.Call.Details call); /** - * Telecom calls this method when a previous created {@link DiagnosticCall} is no longer needed. - * This happens when Telecom is no longer tracking the call in question. + * Telecom calls this method when a previous created {@link CallDiagnostics} is no longer + * needed. This happens when Telecom is no longer tracking the call in question. *
* Calls to this method will use the {@link CallDiagnosticService}'s {@link Executor}; see * {@link CallDiagnosticService#getExecutor()} for more information. * * @param call The diagnostic call which is no longer tracked by Telecom. */ - public abstract void onRemoveDiagnosticCall(@NonNull DiagnosticCall call); + public abstract void onRemoveCallDiagnostics(@NonNull CallDiagnostics call); /** * Telecom calls this method when the audio routing or available audio route information @@ -260,35 +260,35 @@ public abstract class CallDiagnosticService extends Service { } getExecutor().execute(() -> { - DiagnosticCall diagnosticCall = onInitializeDiagnosticCall(newCallDetails); - if (diagnosticCall == null) { + CallDiagnostics callDiagnostics = onInitializeCallDiagnostics(newCallDetails); + if (callDiagnostics == null) { throw new IllegalArgumentException( "A valid DiagnosticCall instance was not provided."); } synchronized (mLock) { - diagnosticCall.setListener(mDiagnosticCallListener); - diagnosticCall.setCallId(telecomCallId); - mDiagnosticCallByTelecomCallId.put(telecomCallId, diagnosticCall); + callDiagnostics.setListener(mDiagnosticCallListener); + callDiagnostics.setCallId(telecomCallId); + mDiagnosticCallByTelecomCallId.put(telecomCallId, callDiagnostics); } }); } /** * Handles an update to {@link Call.Details} notified by Telecom. - * Caches the call details and notifies the {@link DiagnosticCall} of the change via - * {@link DiagnosticCall#onCallDetailsChanged(Call.Details)}. + * Caches the call details and notifies the {@link CallDiagnostics} of the change via + * {@link CallDiagnostics#onCallDetailsChanged(Call.Details)}. * @param parcelableCall the new parceled call details from Telecom. */ private void handleCallUpdated(@NonNull ParcelableCall parcelableCall) { String telecomCallId = parcelableCall.getId(); Log.i(this, "handleCallUpdated: callId=%s - updated", telecomCallId); Call.Details newCallDetails = Call.Details.createFromParcelableCall(parcelableCall); - DiagnosticCall diagnosticCall; + CallDiagnostics callDiagnostics; synchronized (mLock) { - diagnosticCall = mDiagnosticCallByTelecomCallId.get(telecomCallId); + callDiagnostics = mDiagnosticCallByTelecomCallId.get(telecomCallId); mCallByTelecomCallId.put(telecomCallId, newCallDetails); } - getExecutor().execute(() -> diagnosticCall.handleCallUpdated(newCallDetails)); + getExecutor().execute(() -> callDiagnostics.handleCallUpdated(newCallDetails)); } /** @@ -302,37 +302,37 @@ public abstract class CallDiagnosticService extends Service { mCallByTelecomCallId.remove(telecomCallId); } - DiagnosticCall diagnosticCall; + CallDiagnostics callDiagnostics; synchronized (mLock) { if (mDiagnosticCallByTelecomCallId.containsKey(telecomCallId)) { - diagnosticCall = mDiagnosticCallByTelecomCallId.remove(telecomCallId); + callDiagnostics = mDiagnosticCallByTelecomCallId.remove(telecomCallId); } else { - diagnosticCall = null; + callDiagnostics = null; } } // Inform the service of the removed call. - if (diagnosticCall != null) { - getExecutor().execute(() -> onRemoveDiagnosticCall(diagnosticCall)); + if (callDiagnostics != null) { + getExecutor().execute(() -> onRemoveCallDiagnostics(callDiagnostics)); } } /** * Handles an incoming device to device message received from Telecom. Notifies the - * {@link DiagnosticCall} via {@link DiagnosticCall#onReceiveDeviceToDeviceMessage(int, int)}. + * {@link CallDiagnostics} via {@link CallDiagnostics#onReceiveDeviceToDeviceMessage(int, int)}. * @param callId * @param message * @param value */ private void handleReceivedD2DMessage(@NonNull String callId, int message, int value) { Log.i(this, "handleReceivedD2DMessage: callId=%s, msg=%d/%d", callId, message, value); - DiagnosticCall diagnosticCall; + CallDiagnostics callDiagnostics; synchronized (mLock) { - diagnosticCall = mDiagnosticCallByTelecomCallId.get(callId); + callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId); } - if (diagnosticCall != null) { + if (callDiagnostics != null) { getExecutor().execute( - () -> diagnosticCall.onReceiveDeviceToDeviceMessage(message, value)); + () -> callDiagnostics.onReceiveDeviceToDeviceMessage(message, value)); } } @@ -345,12 +345,12 @@ public abstract class CallDiagnosticService extends Service { private void handleCallDisconnected(@NonNull String callId, @NonNull DisconnectCause disconnectCause) { Log.i(this, "handleCallDisconnected: call=%s; cause=%s", callId, disconnectCause); - DiagnosticCall diagnosticCall = mDiagnosticCallByTelecomCallId.get(callId); + CallDiagnostics callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId); CharSequence message; if (disconnectCause.getImsReasonInfo() != null) { - message = diagnosticCall.onCallDisconnected(disconnectCause.getImsReasonInfo()); + message = callDiagnostics.onCallDisconnected(disconnectCause.getImsReasonInfo()); } else { - message = diagnosticCall.onCallDisconnected( + message = callDiagnostics.onCallDisconnected( disconnectCause.getTelephonyDisconnectCause(), disconnectCause.getTelephonyPreciseDisconnectCause()); } @@ -375,15 +375,15 @@ public abstract class CallDiagnosticService extends Service { } /** - * Handles a request from a {@link DiagnosticCall} to send a device to device message (received - * via {@link DiagnosticCall#sendDeviceToDeviceMessage(int, int)}. - * @param diagnosticCall + * Handles a request from a {@link CallDiagnostics} to send a device to device message (received + * via {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}. + * @param callDiagnostics * @param message * @param value */ - private void handleSendDeviceToDeviceMessage(@NonNull DiagnosticCall diagnosticCall, + private void handleSendDeviceToDeviceMessage(@NonNull CallDiagnostics callDiagnostics, int message, int value) { - String callId = diagnosticCall.getCallId(); + String callId = callDiagnostics.getCallId(); try { mAdapter.sendDeviceToDeviceMessage(callId, message, value); Log.i(this, "handleSendDeviceToDeviceMessage: call=%s; msg=%d/%d", callId, message, @@ -395,15 +395,15 @@ public abstract class CallDiagnosticService extends Service { } /** - * Handles a request from a {@link DiagnosticCall} to display an in-call diagnostic message. - * Originates from {@link DiagnosticCall#displayDiagnosticMessage(int, CharSequence)}. - * @param diagnosticCall + * Handles a request from a {@link CallDiagnostics} to display an in-call diagnostic message. + * Originates from {@link CallDiagnostics#displayDiagnosticMessage(int, CharSequence)}. + * @param callDiagnostics * @param messageId * @param message */ - private void handleDisplayDiagnosticMessage(DiagnosticCall diagnosticCall, int messageId, + private void handleDisplayDiagnosticMessage(CallDiagnostics callDiagnostics, int messageId, CharSequence message) { - String callId = diagnosticCall.getCallId(); + String callId = callDiagnostics.getCallId(); try { mAdapter.displayDiagnosticMessage(callId, messageId, message); Log.i(this, "handleDisplayDiagnosticMessage: call=%s; msg=%d/%s", callId, messageId, @@ -415,14 +415,14 @@ public abstract class CallDiagnosticService extends Service { } /** - * Handles a request from a {@link DiagnosticCall} to clear a previously shown diagnostic + * Handles a request from a {@link CallDiagnostics} to clear a previously shown diagnostic * message. - * Originates from {@link DiagnosticCall#clearDiagnosticMessage(int)}. - * @param diagnosticCall + * Originates from {@link CallDiagnostics#clearDiagnosticMessage(int)}. + * @param callDiagnostics * @param messageId */ - private void handleClearDiagnosticMessage(DiagnosticCall diagnosticCall, int messageId) { - String callId = diagnosticCall.getCallId(); + private void handleClearDiagnosticMessage(CallDiagnostics callDiagnostics, int messageId) { + String callId = callDiagnostics.getCallId(); try { mAdapter.clearDiagnosticMessage(callId, messageId); Log.i(this, "handleClearDiagnosticMessage: call=%s; msg=%d", callId, messageId); diff --git a/telecomm/java/android/telecom/CallDiagnostics.java b/telecomm/java/android/telecom/CallDiagnostics.java new file mode 100644 index 0000000000000..3356431f17b12 --- /dev/null +++ b/telecomm/java/android/telecom/CallDiagnostics.java @@ -0,0 +1,374 @@ +/* + * Copyright (C) 2021 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.IntDef; +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.SystemApi; +import android.telephony.Annotation; +import android.telephony.CallQuality; +import android.telephony.ims.ImsReasonInfo; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.concurrent.Executor; + +/** + * {@link CallDiagnostics} provides a way for a {@link CallDiagnosticService} to receive diagnostic + * information about a mobile call on the device. A {@link CallDiagnostics} instance is similar to + * a {@link Call}, however it does not expose call control capabilities and exposes extra diagnostic + * and messaging capabilities not present on a {@link Call}. The {@link CallDiagnosticService} + * creates a {@link CallDiagnostics} for each {@link Call} on the device. This means that for each + * in progress call on the device, the {@link CallDiagnosticService} will create an instance of + * {@link CallDiagnostics}. + *
+ * The {@link CallDiagnosticService} can generate mid-call diagnostic messages using the + * {@link #displayDiagnosticMessage(int, CharSequence)} API which provides the user with valuable + * information about conditions impacting their call and corrective actions. For example, if the + * {@link CallDiagnosticService} determines that conditions on the call are degrading, it can inform + * the user that the call may soon drop and that they can try using a different calling method + * (e.g. VOIP or WIFI). + *
+ * Valid values are below: + *
+ * The audio codec communicated here is an intentional simplification of the + * {@link Connection#EXTRA_AUDIO_CODEC} for a call and focuses on communicating the most common + * variants of these audio codecs. Other variants of these codecs are reported as the next + * closest variant. For example, the {@link Connection#AUDIO_CODEC_EVS_FB} full band codec + * is reported via device to device communication as {@link Connection#AUDIO_CODEC_EVS_WB}. + * For a discussion on the necessity of this simplification, see + * {@link #sendDeviceToDeviceMessage(int, int)}. + *
+ * Valid values: + *
+ * Valid values: + *
+ * Valid values: + *
+ * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; + * see {@link CallDiagnosticService#getExecutor()} for more information. + */ + public abstract void onCallDetailsChanged(@NonNull android.telecom.Call.Details details); + + /** + * The {@link CallDiagnosticService} implements this method to handle messages received via + * device to device communication. + *
+ * See {@link #sendDeviceToDeviceMessage(int, int)} for background on device to device + * communication. + *
+ * The underlying device to device communication protocol assumes that where there the two + * devices communicating are using a different version of the protocol, messages the recipient + * are not aware of are silently discarded. This means an older client talking to a new client + * will not receive newer messages and values sent by the new client. + *
+ * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; + * see {@link CallDiagnosticService#getExecutor()} for more information. + */ + public abstract void onReceiveDeviceToDeviceMessage( + @MessageType int message, + int value); + + /** + * Sends a device to device message to the device on the other end of this call. + *
+ * Device to device communication is an Android platform feature which supports low bandwidth + * communication between Android devices while they are in a call. The device to device + * communication leverages DTMF tones or RTP header extensions to pass messages. The + * messages are unacknowledged and sent in a best-effort manner. The protocols assume that the + * nature of the message are informational only and are used only to convey basic state + * information between devices. + *
+ * Device to device messages are intentional simplifications of more rich indicators in the + * platform due to the extreme bandwidth constraints inherent with underlying device to device + * communication transports used by the telephony framework. Device to device communication is + * either accomplished by adding RFC8285 compliant RTP header extensions to the audio packets + * for a call, or using the DTMF digits A-D as a communication pathway. RTP header extension + * packets ride alongside a the audio for a call, and are thus limited to roughly a byte for + * a message. Signalling requirements for DTMF digits place even more significant limitations + * on the amount of information which can be communicated during a call, offering only a few + * bits of potential information per message. The messages and values are constrained in order + * to meet the limited bandwidth inherent with DTMF signalling. + *
+ * Allowed message types are: + *
+ * @param disconnectCause the disconnect cause for the call. + * @param preciseDisconnectCause the precise disconnect cause for the call. + * @return the disconnect message to use in place of the default Telephony message, or + * {@code null} if the default message will not be overridden. + *
+ * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; + * see {@link CallDiagnosticService#getExecutor()} for more information. + */ + // TODO: Wire in Telephony support for this. + public abstract @Nullable CharSequence onCallDisconnected( + @Annotation.DisconnectCauses int disconnectCause, + @Annotation.PreciseDisconnectCauses int preciseDisconnectCause); + + /** + * Telecom calls this method when an IMS call disconnects and Telephony has already + * provided the disconnect reason info and disconnect message for the call. The + * {@link CallDiagnosticService} can intercept the raw IMS disconnect reason at this point and + * combine it with other call diagnostic information it is aware of to override the disconnect + * call message if desired. + * + * @param disconnectReason The {@link ImsReasonInfo} associated with the call disconnection. + * @return A user-readable call disconnect message to use in place of the platform-generated + * disconnect message, or {@code null} if the disconnect message should not be overridden. + *
+ * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; + * see {@link CallDiagnosticService#getExecutor()} for more information. + */ + // TODO: Wire in Telephony support for this. + public abstract @Nullable CharSequence onCallDisconnected( + @NonNull ImsReasonInfo disconnectReason); + + /** + * Telecom calls this method when a {@link CallQuality} report is received from the telephony + * stack for a call. + * @param callQuality The call quality report for this call. + *
+ * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; + * see {@link CallDiagnosticService#getExecutor()} for more information. + */ + public abstract void onCallQualityReceived(@NonNull CallQuality callQuality); + + /** + * Signals the active default dialer app to display a call diagnostic message. This can be + * used to report problems encountered during the span of a call. + *
+ * The {@link CallDiagnosticService} provides a unique client-specific identifier used to + * identify the specific diagnostic message type. + *
+ * The {@link CallDiagnosticService} should call {@link #clearDiagnosticMessage(int)} when the + * diagnostic condition has cleared. + * @param messageId the unique message identifier. + * @param message a human-readable, localized message to be shown to the user indicating a + * call issue which has occurred, along with potential mitigating actions. + */ + public final void displayDiagnosticMessage(int messageId, @NonNull + CharSequence message) { + if (mListener != null) { + mListener.onDisplayDiagnosticMessage(this, messageId, message); + } + } + + /** + * Signals to the active default dialer that the diagnostic message previously signalled using + * {@link #displayDiagnosticMessage(int, CharSequence)} with the specified messageId is no + * longer applicable (e.g. service has improved, for example. + * @param messageId the message identifier for a message previously shown via + * {@link #displayDiagnosticMessage(int, CharSequence)}. + */ + public final void clearDiagnosticMessage(int messageId) { + if (mListener != null) { + mListener.onClearDiagnosticMessage(this, messageId); + } + } + + /** + * Called by the {@link CallDiagnosticService} to update the call details for this + * {@link CallDiagnostics} based on an update received from Telecom. + * @param newDetails the new call details. + * @hide + */ + public void handleCallUpdated(@NonNull Call.Details newDetails) { + onCallDetailsChanged(newDetails); + } +} diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 335857af8883d..6dab6df22cf94 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -947,7 +947,7 @@ public abstract class Connection extends Conferenceable { * {@link CallDiagnosticService} implementation which is active. *
* Likewise, if a {@link CallDiagnosticService} sends a message using - * {@link DiagnosticCall#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony + * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the * message to the other device. * @hide @@ -960,7 +960,7 @@ public abstract class Connection extends Conferenceable { * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device * message type. * - * See {@link DiagnosticCall} for more information. + * See {@link CallDiagnostics} for more information. * @hide */ @SystemApi @@ -971,7 +971,7 @@ public abstract class Connection extends Conferenceable { * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device * message value. *
- * See {@link DiagnosticCall} for more information. + * See {@link CallDiagnostics} for more information. * @hide */ @SystemApi diff --git a/telecomm/java/android/telecom/DiagnosticCall.java b/telecomm/java/android/telecom/DiagnosticCall.java index af46b7759fb5e..a6b7258052a4e 100644 --- a/telecomm/java/android/telecom/DiagnosticCall.java +++ b/telecomm/java/android/telecom/DiagnosticCall.java @@ -16,338 +16,12 @@ package android.telecom; -import android.annotation.IntDef; -import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.SystemApi; -import android.telephony.Annotation; -import android.telephony.CallQuality; -import android.telephony.ims.ImsReasonInfo; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.concurrent.Executor; /** - * A {@link DiagnosticCall} provides a way for a {@link CallDiagnosticService} to receive diagnostic - * information about a mobile call on the device. A {@link DiagnosticCall} is similar to a - * {@link Call}, however it does not expose call control capabilities and exposes extra diagnostic - * and messaging capabilities not present on a {@link Call}. The {@link CallDiagnosticService} - * creates a {@link DiagnosticCall} for each {@link Call} on the device. This means that for each - * in progress call on the device, the {@link CallDiagnosticService} will create an instance of - * {@link DiagnosticCall}. - *
- * The {@link CallDiagnosticService} can generate mid-call diagnostic messages using the - * {@link #displayDiagnosticMessage(int, CharSequence)} API which provides the user with valuable - * information about conditions impacting their call and corrective actions. For example, if the - * {@link CallDiagnosticService} determines that conditions on the call are degrading, it can inform - * the user that the call may soon drop and that they can try using a different calling method - * (e.g. VOIP or WIFI). - *
- * Valid values are below: - *
- * The audio codec communicated here is an intentional simplification of the - * {@link Connection#EXTRA_AUDIO_CODEC} for a call and focuses on communicating the most common - * variants of these audio codecs. Other variants of these codecs are reported as the next - * closest variant. For example, the {@link Connection#AUDIO_CODEC_EVS_FB} full band codec - * is reported via device to device communication as {@link Connection#AUDIO_CODEC_EVS_WB}. - * For a discussion on the necessity of this simplification, see - * {@link #sendDeviceToDeviceMessage(int, int)}. - *
- * Valid values: - *
- * Valid values: - *
- * Valid values: - *
- * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; - * see {@link CallDiagnosticService#getExecutor()} for more information. - */ - public abstract void onCallDetailsChanged(@NonNull android.telecom.Call.Details details); - - /** - * The {@link CallDiagnosticService} implements this method to handle messages received via - * device to device communication. - *
- * See {@link #sendDeviceToDeviceMessage(int, int)} for background on device to device - * communication. - *
- * The underlying device to device communication protocol assumes that where there the two - * devices communicating are using a different version of the protocol, messages the recipient - * are not aware of are silently discarded. This means an older client talking to a new client - * will not receive newer messages and values sent by the new client. - *
- * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; - * see {@link CallDiagnosticService#getExecutor()} for more information. - */ - public abstract void onReceiveDeviceToDeviceMessage( - @MessageType int message, - int value); - - /** - * Sends a device to device message to the device on the other end of this call. - *
- * Device to device communication is an Android platform feature which supports low bandwidth - * communication between Android devices while they are in a call. The device to device - * communication leverages DTMF tones or RTP header extensions to pass messages. The - * messages are unacknowledged and sent in a best-effort manner. The protocols assume that the - * nature of the message are informational only and are used only to convey basic state - * information between devices. - *
- * Device to device messages are intentional simplifications of more rich indicators in the - * platform due to the extreme bandwidth constraints inherent with underlying device to device - * communication transports used by the telephony framework. Device to device communication is - * either accomplished by adding RFC8285 compliant RTP header extensions to the audio packets - * for a call, or using the DTMF digits A-D as a communication pathway. RTP header extension - * packets ride alongside a the audio for a call, and are thus limited to roughly a byte for - * a message. Signalling requirements for DTMF digits place even more significant limitations - * on the amount of information which can be communicated during a call, offering only a few - * bits of potential information per message. The messages and values are constrained in order - * to meet the limited bandwidth inherent with DTMF signalling. - *
- * Allowed message types are: - *
- * @param disconnectCause the disconnect cause for the call. - * @param preciseDisconnectCause the precise disconnect cause for the call. - * @return the disconnect message to use in place of the default Telephony message, or - * {@code null} if the default message will not be overridden. - *
- * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; - * see {@link CallDiagnosticService#getExecutor()} for more information. - */ - // TODO: Wire in Telephony support for this. - public abstract @Nullable CharSequence onCallDisconnected( - @Annotation.DisconnectCauses int disconnectCause, - @Annotation.PreciseDisconnectCauses int preciseDisconnectCause); - - /** - * Telecom calls this method when an IMS call disconnects and Telephony has already - * provided the disconnect reason info and disconnect message for the call. The - * {@link CallDiagnosticService} can intercept the raw IMS disconnect reason at this point and - * combine it with other call diagnostic information it is aware of to override the disconnect - * call message if desired. - * - * @param disconnectReason The {@link ImsReasonInfo} associated with the call disconnection. - * @return A user-readable call disconnect message to use in place of the platform-generated - * disconnect message, or {@code null} if the disconnect message should not be overridden. - *
- * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; - * see {@link CallDiagnosticService#getExecutor()} for more information. - */ - // TODO: Wire in Telephony support for this. - public abstract @Nullable CharSequence onCallDisconnected( - @NonNull ImsReasonInfo disconnectReason); - - /** - * Telecom calls this method when a {@link CallQuality} report is received from the telephony - * stack for a call. - * @param callQuality The call quality report for this call. - *
- * Calls to this method will use the same {@link Executor} as the {@link CallDiagnosticService}; - * see {@link CallDiagnosticService#getExecutor()} for more information. - */ - public abstract void onCallQualityReceived(@NonNull CallQuality callQuality); - - /** - * Signals the active default dialer app to display a call diagnostic message. This can be - * used to report problems encountered during the span of a call. - *
- * The {@link CallDiagnosticService} provides a unique client-specific identifier used to - * identify the specific diagnostic message type. - *
- * The {@link CallDiagnosticService} should call {@link #clearDiagnosticMessage(int)} when the - * diagnostic condition has cleared. - * @param messageId the unique message identifier. - * @param message a human-readable, localized message to be shown to the user indicating a - * call issue which has occurred, along with potential mitigating actions. - */ - public final void displayDiagnosticMessage(int messageId, @NonNull - CharSequence message) { - if (mListener != null) { - mListener.onDisplayDiagnosticMessage(this, messageId, message); - } - } - - /** - * Signals to the active default dialer that the diagnostic message previously signalled using - * {@link #displayDiagnosticMessage(int, CharSequence)} with the specified messageId is no - * longer applicable (e.g. service has improved, for example. - * @param messageId the message identifier for a message previously shown via - * {@link #displayDiagnosticMessage(int, CharSequence)}. - */ - public final void clearDiagnosticMessage(int messageId) { - if (mListener != null) { - mListener.onClearDiagnosticMessage(this, messageId); - } - } - - /** - * Called by the {@link CallDiagnosticService} to update the call details for this - * {@link DiagnosticCall} based on an update received from Telecom. - * @param newDetails the new call details. - * @hide - */ - public void handleCallUpdated(@NonNull Call.Details newDetails) { - onCallDetailsChanged(newDetails); - } +public abstract class DiagnosticCall extends CallDiagnostics { }