From 0a1c6d1bb44d830d4bc82d371c5f102d22916a58 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 12 Mar 2021 15:44:08 -0800 Subject: [PATCH] Propagate call quality reports from Telephony to CallDiagnosticService. Complete plumbing for call quality reports to get to the CDS. Test: Manual network testing. Test: Modify CTS tests to cover these cases. Bug: 163085177 Change-Id: I2bb68d29c4ad11cc8738c26cd69404fde4348843 --- .../telecom/CallDiagnosticService.java | 23 +++++++++++++++++++ telecomm/java/android/telecom/Connection.java | 18 +++++++++++++++ .../telecom/ICallDiagnosticService.aidl | 2 ++ 3 files changed, 43 insertions(+) diff --git a/telecomm/java/android/telecom/CallDiagnosticService.java b/telecomm/java/android/telecom/CallDiagnosticService.java index f5357b19c4de9..011dc17a1c1e4 100644 --- a/telecomm/java/android/telecom/CallDiagnosticService.java +++ b/telecomm/java/android/telecom/CallDiagnosticService.java @@ -27,6 +27,8 @@ import android.os.Handler; import android.os.HandlerExecutor; import android.os.IBinder; import android.os.RemoteException; + +import android.telephony.CallQuality; import android.util.ArrayMap; import com.android.internal.telecom.ICallDiagnosticService; @@ -111,6 +113,12 @@ public abstract class CallDiagnosticService extends Service { @NonNull DisconnectCause disconnectCause) throws RemoteException { handleCallDisconnected(callId, disconnectCause); } + + @Override + public void callQualityChanged(String callId, CallQuality callQuality) + throws RemoteException { + handleCallQualityChanged(callId, callQuality); + } } /** @@ -374,6 +382,21 @@ public abstract class CallDiagnosticService extends Service { getExecutor().execute(() -> onBluetoothCallQualityReportReceived(qualityReport)); } + /** + * Handles a change reported by Telecom to the call quality for a call. + * @param callId the call ID the change applies to. + * @param callQuality The new call quality. + */ + private void handleCallQualityChanged(@NonNull String callId, + @NonNull CallQuality callQuality) { + Log.i(this, "handleCallQualityChanged; call=%s, cq=%s", callId, callQuality); + CallDiagnostics callDiagnostics; + callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId); + if (callDiagnostics != null) { + callDiagnostics.onCallQualityReceived(callQuality); + } + } + /** * Handles a request from a {@link CallDiagnostics} to send a device to device message (received * via {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}. diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 6dab6df22cf94..2dc18e8563496 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -44,6 +44,7 @@ import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.RemoteException; import android.os.SystemClock; +import android.telephony.CallQuality; import android.telephony.ims.ImsStreamMediaProfile; import android.util.ArraySet; import android.view.Surface; @@ -978,6 +979,23 @@ public abstract class Connection extends Conferenceable { public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE = "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE"; + /** + * Connection event used to communicate a {@link android.telephony.CallQuality} report from + * telephony to Telecom for relaying to + * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}. + * @hide + */ + public static final String EVENT_CALL_QUALITY_REPORT = + "android.telecom.event.CALL_QUALITY_REPORT"; + + /** + * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the + * {@link android.telephony.CallQuality} data. + * @hide + */ + public static final String EXTRA_CALL_QUALITY_REPORT = + "android.telecom.extra.CALL_QUALITY_REPORT"; + // Flag controlling whether PII is emitted into the logs private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); diff --git a/telecomm/java/com/android/internal/telecom/ICallDiagnosticService.aidl b/telecomm/java/com/android/internal/telecom/ICallDiagnosticService.aidl index fc9879aaf0a80..4bd369f2c5565 100644 --- a/telecomm/java/com/android/internal/telecom/ICallDiagnosticService.aidl +++ b/telecomm/java/com/android/internal/telecom/ICallDiagnosticService.aidl @@ -20,6 +20,7 @@ import android.telecom.BluetoothCallQualityReport; import android.telecom.CallAudioState; import android.telecom.DisconnectCause; import android.telecom.ParcelableCall; +import android.telephony.CallQuality; import com.android.internal.telecom.ICallDiagnosticServiceAdapter; /** @@ -34,6 +35,7 @@ oneway interface ICallDiagnosticService { void updateCallAudioState(in CallAudioState callAudioState); void removeDiagnosticCall(in String callId); void receiveDeviceToDeviceMessage(in String callId, int message, int value); + void callQualityChanged(in String callId, in CallQuality callQuality); void receiveBluetoothCallQualityReport(in BluetoothCallQualityReport qualityReport); void notifyCallDisconnected(in String callId, in DisconnectCause disconnectCause); }