Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70decc1a authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Pipe through Call Quality reports to CallDiagnosticService

Receive connection event with call quality report and relay to the
CallDiagnosticService.

Test: Added CTS test.
Test: Manual test with test implementation of CDS.
Bug: 163085177
Change-Id: I97de7f88761d5c246edd46675da461fba52acc3c
parent 1efde65e
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import android.telecom.Response;
import android.telecom.StatusHints;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.CallQuality;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.telephony.emergency.EmergencyNumber;
@@ -162,6 +163,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        void onHandoverComplete(Call call);
        void onBluetoothCallQualityReport(Call call, BluetoothCallQualityReport report);
        void onReceivedDeviceToDeviceMessage(Call call, int messageType, int messageValue);
        void onReceivedCallQualityReport(Call call, CallQuality callQuality);
    }

    public abstract static class ListenerBase implements Listener {
@@ -254,6 +256,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        public void onBluetoothCallQualityReport(Call call, BluetoothCallQualityReport report) {}
        @Override
        public void onReceivedDeviceToDeviceMessage(Call call, int messageType, int messageValue) {}
        @Override
        public void onReceivedCallQualityReport(Call call, CallQuality callQuality) {}
    }

    private final CallerInfoLookupHelper.OnQueryCompleteListener mCallerInfoQueryListener =
@@ -3790,6 +3794,12 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            for (Listener l : mListeners) {
                l.onReceivedDeviceToDeviceMessage(this, messageType, messageValue);
            }
        } else if (Connection.EVENT_CALL_QUALITY_REPORT.equals(event)
                && extras != null && extras.containsKey(Connection.EXTRA_CALL_QUALITY_REPORT)) {
            CallQuality callQuality = extras.getParcelable(Connection.EXTRA_CALL_QUALITY_REPORT);
            for (Listener l : mListeners) {
                l.onReceivedCallQualityReport(this, callQuality);
            }
        } else {
            for (Listener l : mListeners) {
                l.onConnectionEvent(this, event, extras);
@@ -4154,7 +4164,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            mDisconnectFuture.thenRunAsync(() -> {
                if (!mReceivedCallDiagnosticPostCallResponse) {
                    Log.addEvent(this, LogUtils.Events.CALL_DIAGNOSTIC_SERVICE_TIMEOUT);
                }},
                }
                // Clear the future as a final step.
                mDisconnectFuture = null;
                },
                new LoggedHandlerExecutor(mHandler, "C.iDF", mLock))
                    .exceptionally((throwable) -> {
                        Log.e(this, throwable, "Error while executing disconnect future");
@@ -4176,7 +4189,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     * if this is handled immediately.
     */
    public boolean isDisconnectHandledViaFuture() {
        return mDisconnectFuture != null && !mDisconnectFuture.isDone();
        return mDisconnectFuture != null;
    }

    /**
+28 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.telecom.DisconnectCause;
import android.telecom.InCallService;
import android.telecom.Log;
import android.telecom.ParcelableCall;
import android.telephony.CallQuality;
import android.telephony.ims.ImsReasonInfo;
import android.text.TextUtils;

@@ -154,6 +155,16 @@ public class CallDiagnosticServiceController extends CallsManagerListenerBase {
        public void onReceivedDeviceToDeviceMessage(Call call, int messageType, int messageValue) {
            handleReceivedDeviceToDeviceMessage(call, messageType, messageValue);
        }

        /**
         * Handles an incoming {@link CallQuality} report from a {@link android.telecom.Connection}.
         * @param call The call.
         * @param callQualityReport The call quality report.
         */
        @Override
        public void onReceivedCallQualityReport(Call call, CallQuality callQualityReport) {
            handleCallQualityReport(call, callQualityReport);
        }
    };

    /**
@@ -650,6 +661,23 @@ public class CallDiagnosticServiceController extends CallsManagerListenerBase {
        }
    }

    /**
     * Handles a reported {@link CallQuality} report from a {@link android.telecom.Connection}.
     * @param call The call the report originated from.
     * @param callQualityReport The {@link CallQuality} report.
     */
    private void handleCallQualityReport(@NonNull Call call,
            @NonNull CallQuality callQualityReport) {
        try {
            if (isConnected()) {
                mCallDiagnosticService.callQualityChanged(call.getId(), callQualityReport);
            }
        } catch (RemoteException e) {
            Log.w(this, "handleCallQualityReport: callId=%s, exception=%s",
                    call.getId(), e);
        }
    }

    /**
     * Get a parcelled representation of a call for transport to the service.
     * @param call The call.