Propagate Telephony disconnect cause to Telecom.
Propagate telephony disconnect causes and imsreasoninfo to Telecom for propagation to CAllDiagnosticService. Plumb through disconnect message override in CallDiagnosticService. Test: Added new CTS test coverage for these APIs. Test: Manual test with telecom test app; verify the disconnect message is overridden. Bug: 163085177 Change-Id: I0c6938f2d0a46d535ae201364193ef58e07ec488
This commit is contained in:
@@ -24,6 +24,8 @@ import android.app.Service;
|
||||
import android.content.Intent;
|
||||
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;
|
||||
@@ -96,6 +98,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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +264,32 @@ public abstract class CallDiagnosticService extends Service {
|
||||
diagnosticCall.onReceiveDeviceToDeviceMessage(message, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(
|
||||
|
||||
@@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user