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

Commit deb61608 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Propagate Telephony disconnect cause to Telecom." into sc-dev

parents 2cd2ed4c bc9ecbcf
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ 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;
@@ -105,6 +107,12 @@ public abstract class CallDiagnosticService extends Service {
                throws RemoteException {
            handleBluetoothCallQualityReport(qualityReport);
        }

        @Override
        public void notifyCallDisconnected(@NonNull String callId,
                @NonNull DisconnectCause disconnectCause) throws RemoteException {
            handleCallDisconnected(callId, disconnectCause);
        }
    }

    /**
@@ -328,6 +336,32 @@ public abstract class CallDiagnosticService extends Service {
        }
    }

    /**
     * Handles a request from the Telecom framework to get a disconnect message from the
     * {@link CallDiagnosticService}.
     * @param callId The ID of the call.
     * @param disconnectCause The telecom disconnect cause.
     */
    private void handleCallDisconnected(@NonNull String callId,
            @NonNull DisconnectCause disconnectCause) {
        Log.i(this, "handleCallDisconnected: call=%s; cause=%s", callId, disconnectCause);
        DiagnosticCall diagnosticCall = mDiagnosticCallByTelecomCallId.get(callId);
        CharSequence message;
        if (disconnectCause.getImsReasonInfo() != null) {
            message = diagnosticCall.onCallDisconnected(disconnectCause.getImsReasonInfo());
        } else {
            message = diagnosticCall.onCallDisconnected(
                    disconnectCause.getTelephonyDisconnectCause(),
                    disconnectCause.getTelephonyPreciseDisconnectCause());
        }
        try {
            mAdapter.overrideDisconnectMessage(callId, message);
        } catch (RemoteException e) {
            Log.w(this, "handleCallDisconnected: call=%s; cause=%s; %s",
                    callId, disconnectCause, e);
        }
    }

    /**
     * Handles an incoming bluetooth call quality report from Telecom.  Notifies via
     * {@link CallDiagnosticService#onBluetoothCallQualityReportReceived(
+84 −5
Original line number Diff line number Diff line
@@ -16,9 +16,13 @@

package android.telecom;

import android.annotation.Nullable;
import android.media.ToneGenerator;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.Annotation;
import android.telephony.PreciseDisconnectCause;
import android.telephony.ims.ImsReasonInfo;
import android.text.TextUtils;

import java.util.Objects;
@@ -112,6 +116,9 @@ public final class DisconnectCause implements Parcelable {
    private CharSequence mDisconnectDescription;
    private String mDisconnectReason;
    private int mToneToPlay;
    private int mTelephonyDisconnectCause;
    private int mTelephonyPreciseDisconnectCause;
    private ImsReasonInfo mImsReasonInfo;

    /**
     * Creates a new DisconnectCause.
@@ -155,11 +162,36 @@ public final class DisconnectCause implements Parcelable {
     */
    public DisconnectCause(int code, CharSequence label, CharSequence description, String reason,
            int toneToPlay) {
        this(code, label, description, reason, toneToPlay,
                android.telephony.DisconnectCause.ERROR_UNSPECIFIED,
                PreciseDisconnectCause.ERROR_UNSPECIFIED,
                null /* imsReasonInfo */);
    }

    /**
     * Creates a new DisconnectCause instance.
     * @param code The code for the disconnect cause.
     * @param label The localized label to show to the user to explain the disconnect.
     * @param description The localized description to show to the user to explain the disconnect.
     * @param reason The reason for the disconnect.
     * @param toneToPlay The tone to play on disconnect, as defined in {@link ToneGenerator}.
     * @param telephonyDisconnectCause The Telephony disconnect cause.
     * @param telephonyPreciseDisconnectCause The Telephony precise disconnect cause.
     * @param imsReasonInfo The relevant {@link ImsReasonInfo}, or {@code null} if not available.
     * @hide
     */
    public DisconnectCause(int code, CharSequence label, CharSequence description, String reason,
            int toneToPlay, @Annotation.DisconnectCauses int telephonyDisconnectCause,
            @Annotation.PreciseDisconnectCauses int telephonyPreciseDisconnectCause,
            @Nullable ImsReasonInfo imsReasonInfo) {
        mDisconnectCode = code;
        mDisconnectLabel = label;
        mDisconnectDescription = description;
        mDisconnectReason = reason;
        mToneToPlay = toneToPlay;
        mTelephonyDisconnectCause = telephonyDisconnectCause;
        mTelephonyPreciseDisconnectCause = telephonyPreciseDisconnectCause;
        mImsReasonInfo = imsReasonInfo;
    }

    /**
@@ -208,6 +240,33 @@ public final class DisconnectCause implements Parcelable {
        return mDisconnectReason;
    }

    /**
     * Returns the telephony {@link android.telephony.DisconnectCause} for the call.
     * @return The disconnect cause.
     * @hide
     */
    public @Annotation.DisconnectCauses int getTelephonyDisconnectCause() {
        return mTelephonyDisconnectCause;
    }

    /**
     * Returns the telephony {@link android.telephony.PreciseDisconnectCause} for the call.
     * @return The precise disconnect cause.
     * @hide
     */
    public @Annotation.PreciseDisconnectCauses int getTelephonyPreciseDisconnectCause() {
        return mTelephonyPreciseDisconnectCause;
    }

    /**
     * Returns the telephony {@link ImsReasonInfo} associated with the call disconnection.
     * @return The {@link ImsReasonInfo} or {@code null} if not known.
     * @hide
     */
    public @Nullable ImsReasonInfo getImsReasonInfo() {
        return mImsReasonInfo;
    }

    /**
     * Returns the tone to play when disconnected.
     *
@@ -217,7 +276,8 @@ public final class DisconnectCause implements Parcelable {
        return mToneToPlay;
    }

    public static final @android.annotation.NonNull Creator<DisconnectCause> CREATOR = new Creator<DisconnectCause>() {
    public static final @android.annotation.NonNull Creator<DisconnectCause> CREATOR
            = new Creator<DisconnectCause>() {
        @Override
        public DisconnectCause createFromParcel(Parcel source) {
            int code = source.readInt();
@@ -225,7 +285,11 @@ public final class DisconnectCause implements Parcelable {
            CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            String reason = source.readString();
            int tone = source.readInt();
            return new DisconnectCause(code, label, description, reason, tone);
            int telephonyDisconnectCause = source.readInt();
            int telephonyPreciseDisconnectCause = source.readInt();
            ImsReasonInfo imsReasonInfo = source.readParcelable(null);
            return new DisconnectCause(code, label, description, reason, tone,
                    telephonyDisconnectCause, telephonyPreciseDisconnectCause, imsReasonInfo);
        }

        @Override
@@ -241,6 +305,9 @@ public final class DisconnectCause implements Parcelable {
        TextUtils.writeToParcel(mDisconnectDescription, destination, flags);
        destination.writeString(mDisconnectReason);
        destination.writeInt(mToneToPlay);
        destination.writeInt(mTelephonyDisconnectCause);
        destination.writeInt(mTelephonyPreciseDisconnectCause);
        destination.writeParcelable(mImsReasonInfo, 0);
    }

    @Override
@@ -254,7 +321,10 @@ public final class DisconnectCause implements Parcelable {
                + Objects.hashCode(mDisconnectLabel)
                + Objects.hashCode(mDisconnectDescription)
                + Objects.hashCode(mDisconnectReason)
                + Objects.hashCode(mToneToPlay);
                + Objects.hashCode(mToneToPlay)
                + Objects.hashCode(mTelephonyDisconnectCause)
                + Objects.hashCode(mTelephonyPreciseDisconnectCause)
                + Objects.hashCode(mImsReasonInfo);
    }

    @Override
@@ -265,7 +335,11 @@ public final class DisconnectCause implements Parcelable {
                    && Objects.equals(mDisconnectLabel, d.getLabel())
                    && Objects.equals(mDisconnectDescription, d.getDescription())
                    && Objects.equals(mDisconnectReason, d.getReason())
                    && Objects.equals(mToneToPlay, d.getTone());
                    && Objects.equals(mToneToPlay, d.getTone())
                    && Objects.equals(mTelephonyDisconnectCause, d.getTelephonyDisconnectCause())
                    && Objects.equals(mTelephonyPreciseDisconnectCause,
                    d.getTelephonyPreciseDisconnectCause())
                    && Objects.equals(mImsReasonInfo, d.getImsReasonInfo());
        }
        return false;
    }
@@ -325,6 +399,11 @@ public final class DisconnectCause implements Parcelable {
                + " Label: (" + label + ")"
                + " Description: (" + description + ")"
                + " Reason: (" + reason + ")"
                + " Tone: (" + mToneToPlay + ") ]";
                + " Tone: (" + mToneToPlay + ") "
                + " TelephonyCause: " + mTelephonyDisconnectCause + "/"
                + mTelephonyPreciseDisconnectCause
                + " ImsReasonInfo: "
                + mImsReasonInfo
                + "]";
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.telecom;

import android.telecom.BluetoothCallQualityReport;
import android.telecom.CallAudioState;
import android.telecom.DisconnectCause;
import android.telecom.ParcelableCall;
import com.android.internal.telecom.ICallDiagnosticServiceAdapter;

@@ -34,4 +35,5 @@ oneway interface ICallDiagnosticService {
    void removeDiagnosticCall(in String callId);
    void receiveDeviceToDeviceMessage(in String callId, int message, int value);
    void receiveBluetoothCallQualityReport(in BluetoothCallQualityReport qualityReport);
    void notifyCallDisconnected(in String callId, in DisconnectCause disconnectCause);
}