blob: 5ba5ee8836e17373619eadf5bcfa08caa847aa5b [file] [log] [blame]
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.telecom;
18
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -080019import android.annotation.FlaggedApi;
20import android.annotation.NonNull;
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -080021import android.annotation.Nullable;
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -080022import android.annotation.SystemApi;
Youming Yed6de26e2019-01-30 11:20:35 -080023import android.media.ToneGenerator;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070024import android.os.Parcel;
25import android.os.Parcelable;
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -080026import android.telephony.Annotation;
27import android.telephony.PreciseDisconnectCause;
28import android.telephony.ims.ImsReasonInfo;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070029import android.text.TextUtils;
30
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -080031import com.android.server.telecom.flags.Flags;
32
Andrew Lee7f3d41f2014-09-11 17:33:16 -070033import java.util.Objects;
34
35/**
36 * Describes the cause of a disconnected call. This always includes a code describing the generic
Santos Cordond9e614f2014-10-28 13:10:36 -070037 * cause of the disconnect. Optionally, it may include a label and/or description to display to the
38 * user. It is the responsibility of the {@link ConnectionService} to provide localized versions of
39 * the label and description. It also may contain a reason for the disconnect, which is intended for
40 * logging and not for display to the user.
Andrew Lee7f3d41f2014-09-11 17:33:16 -070041 */
42public final class DisconnectCause implements Parcelable {
43
44 /** Disconnected because of an unknown or unspecified reason. */
Tej Singhc477d9c2018-02-05 18:31:39 -080045 public static final int UNKNOWN = TelecomProtoEnums.UNKNOWN; // = 0
Andrew Lee7f3d41f2014-09-11 17:33:16 -070046 /** Disconnected because there was an error, such as a problem with the network. */
Tej Singhc477d9c2018-02-05 18:31:39 -080047 public static final int ERROR = TelecomProtoEnums.ERROR; // = 1
Andrew Lee7f3d41f2014-09-11 17:33:16 -070048 /** Disconnected because of a local user-initiated action, such as hanging up. */
Tej Singhc477d9c2018-02-05 18:31:39 -080049 public static final int LOCAL = TelecomProtoEnums.LOCAL; // = 2
Andrew Lee7f3d41f2014-09-11 17:33:16 -070050 /**
Tyler Gunne8c5a292023-05-02 22:52:26 +000051 * Disconnected because the remote party hung up an ongoing call, or because an outgoing call
52 * was not answered by the remote party.
Andrew Lee7f3d41f2014-09-11 17:33:16 -070053 */
Tej Singhc477d9c2018-02-05 18:31:39 -080054 public static final int REMOTE = TelecomProtoEnums.REMOTE; // = 3
Andrew Lee7f3d41f2014-09-11 17:33:16 -070055 /** Disconnected because it has been canceled. */
Tej Singhc477d9c2018-02-05 18:31:39 -080056 public static final int CANCELED = TelecomProtoEnums.CANCELED; // = 4
Andrew Lee7f3d41f2014-09-11 17:33:16 -070057 /** Disconnected because there was no response to an incoming call. */
Tej Singhc477d9c2018-02-05 18:31:39 -080058 public static final int MISSED = TelecomProtoEnums.MISSED; // = 5
Andrew Lee7f3d41f2014-09-11 17:33:16 -070059 /** Disconnected because the user rejected an incoming call. */
Tej Singhc477d9c2018-02-05 18:31:39 -080060 public static final int REJECTED = TelecomProtoEnums.REJECTED; // = 6
Andrew Lee7f3d41f2014-09-11 17:33:16 -070061 /** Disconnected because the other party was busy. */
Tej Singhc477d9c2018-02-05 18:31:39 -080062 public static final int BUSY = TelecomProtoEnums.BUSY; // = 7
Andrew Lee7f3d41f2014-09-11 17:33:16 -070063 /**
64 * Disconnected because of a restriction on placing the call, such as dialing in airplane
65 * mode.
66 */
Tej Singhc477d9c2018-02-05 18:31:39 -080067 public static final int RESTRICTED = TelecomProtoEnums.RESTRICTED; // = 8
Andrew Lee7f3d41f2014-09-11 17:33:16 -070068 /** Disconnected for reason not described by other disconnect codes. */
Tej Singhc477d9c2018-02-05 18:31:39 -080069 public static final int OTHER = TelecomProtoEnums.OTHER; // = 9
Sailesh Nepal7a69c922014-11-05 18:37:53 -080070 /**
71 * Disconnected because the connection manager did not support the call. The call will be tried
72 * again without a connection manager. See {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}.
73 */
Tej Singhc477d9c2018-02-05 18:31:39 -080074 public static final int CONNECTION_MANAGER_NOT_SUPPORTED =
75 TelecomProtoEnums.CONNECTION_MANAGER_NOT_SUPPORTED; // = 10
Andrew Lee7f3d41f2014-09-11 17:33:16 -070076
Tyler Gunn876dbfb2016-03-14 15:18:07 -070077 /**
78 * Disconnected because the user did not locally answer the incoming call, but it was answered
79 * on another device where the call was ringing.
80 */
Tej Singhc477d9c2018-02-05 18:31:39 -080081 public static final int ANSWERED_ELSEWHERE = TelecomProtoEnums.ANSWERED_ELSEWHERE; // = 11
Tyler Gunn876dbfb2016-03-14 15:18:07 -070082
83 /**
84 * Disconnected because the call was pulled from the current device to another device.
85 */
Tej Singhc477d9c2018-02-05 18:31:39 -080086 public static final int CALL_PULLED = TelecomProtoEnums.CALL_PULLED; // = 12
Tyler Gunn876dbfb2016-03-14 15:18:07 -070087
Tyler Gunn6adbd2b2016-12-07 13:19:44 -080088 /**
89 * Reason code (returned via {@link #getReason()}) which indicates that a call could not be
90 * completed because the cellular radio is off or out of service, the device is connected to
91 * a wifi network, but the user has not enabled wifi calling.
Tyler Gunn6adbd2b2016-12-07 13:19:44 -080092 */
93 public static final String REASON_WIFI_ON_BUT_WFC_OFF = "REASON_WIFI_ON_BUT_WFC_OFF";
94
Brad Ebinger8818c6f2017-06-30 15:34:32 -070095 /**
Brad Ebinger153af012022-08-26 15:11:25 -070096 * Reason code (returned via {@link #getReason()}), which indicates that the call was
97 * disconnected because IMS access is blocked.
Brad Ebinger8818c6f2017-06-30 15:34:32 -070098 */
99 public static final String REASON_IMS_ACCESS_BLOCKED = "REASON_IMS_ACCESS_BLOCKED";
100
Youming Yed6de26e2019-01-30 11:20:35 -0800101 /**
Hall Liu2ef04112020-09-14 18:34:10 -0700102 * Reason code (returned via {@link #getReason()}), which indicates that the connection service
103 * is setting the call's state to {@link Call#STATE_DISCONNECTED} because it is internally
104 * changing the representation of an IMS conference call to simulate a single-party call.
105 *
106 * This reason code is only used for communication between a {@link ConnectionService} and
107 * Telecom and should not be surfaced to the user.
Youming Yed6de26e2019-01-30 11:20:35 -0800108 */
109 public static final String REASON_EMULATING_SINGLE_CALL = "EMULATING_SINGLE_CALL";
110
Brad Ebinger62713872019-11-18 18:43:35 -0800111 /**
112 * This reason is set when a call is ended in order to place an emergency call when a
113 * {@link PhoneAccount} doesn't support holding an ongoing call to place an emergency call. This
114 * reason string should only be associated with the {@link #LOCAL} disconnect code returned from
115 * {@link #getCode()}.
116 */
117 public static final String REASON_EMERGENCY_CALL_PLACED = "REASON_EMERGENCY_CALL_PLACED";
118
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700119 private int mDisconnectCode;
120 private CharSequence mDisconnectLabel;
121 private CharSequence mDisconnectDescription;
122 private String mDisconnectReason;
123 private int mToneToPlay;
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800124 private int mTelephonyDisconnectCause;
125 private int mTelephonyPreciseDisconnectCause;
126 private ImsReasonInfo mImsReasonInfo;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700127
128 /**
129 * Creates a new DisconnectCause.
130 *
131 * @param code The code for the disconnect cause.
132 */
133 public DisconnectCause(int code) {
134 this(code, null, null, null, ToneGenerator.TONE_UNKNOWN);
135 }
136
137 /**
138 * Creates a new DisconnectCause.
139 *
140 * @param code The code for the disconnect cause.
141 * @param reason The reason for the disconnect.
142 */
143 public DisconnectCause(int code, String reason) {
144 this(code, null, null, reason, ToneGenerator.TONE_UNKNOWN);
145 }
146
147 /**
148 * Creates a new DisconnectCause.
Santos Cordond9e614f2014-10-28 13:10:36 -0700149 *
Nancy Chenf4cf77c2014-09-19 10:53:21 -0700150 * @param code The code for the disconnect cause.
Santos Cordona6018b92016-02-16 14:23:12 -0800151 * @param label The localized label to show to the user to explain the disconnect.
Nancy Chenf4cf77c2014-09-19 10:53:21 -0700152 * @param description The localized description to show to the user to explain the disconnect.
153 * @param reason The reason for the disconnect.
154 */
155 public DisconnectCause(int code, CharSequence label, CharSequence description, String reason) {
156 this(code, label, description, reason, ToneGenerator.TONE_UNKNOWN);
157 }
158
159 /**
160 * Creates a new DisconnectCause.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700161 *
162 * @param code The code for the disconnect cause.
163 * @param label The localized label to show to the user to explain the disconnect.
164 * @param description The localized description to show to the user to explain the disconnect.
165 * @param reason The reason for the disconnect.
166 * @param toneToPlay The tone to play on disconnect, as defined in {@link ToneGenerator}.
167 */
168 public DisconnectCause(int code, CharSequence label, CharSequence description, String reason,
169 int toneToPlay) {
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800170 this(code, label, description, reason, toneToPlay,
171 android.telephony.DisconnectCause.ERROR_UNSPECIFIED,
Pranav Madapurmath8c5695c2024-02-08 13:48:24 -0800172 PreciseDisconnectCause.ERROR_UNSPECIFIED, null /* imsReasonInfo */);
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800173 }
174
175 /**
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800176 * Creates a new DisconnectCause instance. This is used by Telephony to pass in extra debug
177 * info to Telecom regarding the disconnect cause.
178 *
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800179 * @param code The code for the disconnect cause.
180 * @param label The localized label to show to the user to explain the disconnect.
181 * @param description The localized description to show to the user to explain the disconnect.
182 * @param reason The reason for the disconnect.
183 * @param toneToPlay The tone to play on disconnect, as defined in {@link ToneGenerator}.
184 * @param telephonyDisconnectCause The Telephony disconnect cause.
185 * @param telephonyPreciseDisconnectCause The Telephony precise disconnect cause.
186 * @param imsReasonInfo The relevant {@link ImsReasonInfo}, or {@code null} if not available.
187 * @hide
188 */
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800189 public DisconnectCause(int code, @NonNull CharSequence label,
190 @NonNull CharSequence description, @NonNull String reason,
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800191 int toneToPlay, @Annotation.DisconnectCauses int telephonyDisconnectCause,
192 @Annotation.PreciseDisconnectCauses int telephonyPreciseDisconnectCause,
193 @Nullable ImsReasonInfo imsReasonInfo) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700194 mDisconnectCode = code;
195 mDisconnectLabel = label;
196 mDisconnectDescription = description;
197 mDisconnectReason = reason;
198 mToneToPlay = toneToPlay;
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800199 mTelephonyDisconnectCause = telephonyDisconnectCause;
200 mTelephonyPreciseDisconnectCause = telephonyPreciseDisconnectCause;
201 mImsReasonInfo = imsReasonInfo;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700202 }
203
204 /**
205 * Returns the code for the reason for this disconnect.
206 *
207 * @return The disconnect code.
208 */
209 public int getCode() {
210 return mDisconnectCode;
211 }
212
213 /**
214 * Returns a short label which explains the reason for the disconnect cause and is for display
Santos Cordonc1ec9312015-04-24 11:26:01 -0700215 * in the user interface. If not null, it is expected that the In-Call UI should display this
216 * text where it would normally display the call state ("Dialing", "Disconnected") and is
217 * therefore expected to be relatively small. The {@link ConnectionService } is responsible for
218 * providing and localizing this label. If there is no string provided, returns null.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700219 *
220 * @return The disconnect label.
221 */
222 public CharSequence getLabel() {
223 return mDisconnectLabel;
224 }
225
226 /**
227 * Returns a description which explains the reason for the disconnect cause and is for display
Santos Cordonc1ec9312015-04-24 11:26:01 -0700228 * in the user interface. This optional text is generally a longer and more descriptive version
229 * of {@link #getLabel}, however it can exist even if {@link #getLabel} is empty. The In-Call UI
230 * should display this relatively prominently; the traditional implementation displays this as
231 * an alert dialog. The {@link ConnectionService} is responsible for providing and localizing
232 * this message. If there is no string provided, returns null.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700233 *
234 * @return The disconnect description.
235 */
236 public CharSequence getDescription() {
237 return mDisconnectDescription;
238 }
239
240 /**
241 * Returns an explanation of the reason for the disconnect. This is not intended for display to
242 * the user and is used mainly for logging.
243 *
244 * @return The disconnect reason.
245 */
246 public String getReason() {
247 return mDisconnectReason;
248 }
249
250 /**
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800251 * Returns the telephony {@link android.telephony.DisconnectCause} for the call. This is only
252 * used internally by Telecom for providing extra debug information from Telephony.
253 *
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800254 * @return The disconnect cause.
255 * @hide
256 */
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800257 @SystemApi
258 @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800259 public @Annotation.DisconnectCauses int getTelephonyDisconnectCause() {
260 return mTelephonyDisconnectCause;
261 }
262
263 /**
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800264 * Returns the telephony {@link android.telephony.PreciseDisconnectCause} for the call. This is
265 * only used internally by Telecom for providing extra debug information from Telephony.
266 *
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800267 * @return The precise disconnect cause.
268 * @hide
269 */
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800270 @SystemApi
271 @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800272 public @Annotation.PreciseDisconnectCauses int getTelephonyPreciseDisconnectCause() {
273 return mTelephonyPreciseDisconnectCause;
274 }
275
276 /**
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800277 * Returns the telephony {@link ImsReasonInfo} associated with the call disconnection. This is
278 * only used internally by Telecom for providing extra debug information from Telephony.
279 *
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800280 * @return The {@link ImsReasonInfo} or {@code null} if not known.
281 * @hide
282 */
Pranav Madapurmath4aaf2a22024-02-06 15:16:23 -0800283 @SystemApi
284 @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800285 public @Nullable ImsReasonInfo getImsReasonInfo() {
286 return mImsReasonInfo;
287 }
288
289 /**
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700290 * Returns the tone to play when disconnected.
291 *
292 * @return the tone as defined in {@link ToneGenerator} to play when disconnected.
293 */
294 public int getTone() {
295 return mToneToPlay;
296 }
297
Pranav Madapurmath8c5695c2024-02-08 13:48:24 -0800298 /**
299 * @hide
300 */
301 @SystemApi
302 @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
303 public static final class Builder {
304 private int mDisconnectCode;
305 private CharSequence mDisconnectLabel;
306 private CharSequence mDisconnectDescription;
307 private String mDisconnectReason;
308 private int mToneToPlay;
309 private int mTelephonyDisconnectCause;
310 private int mTelephonyPreciseDisconnectCause;
311 private ImsReasonInfo mImsReasonInfo;
312
313 /**
314 * Sets the code for the reason for this disconnect.
315 * @param code The code denoting the type of disconnect.
316 */
317 public @NonNull DisconnectCause.Builder setCode(int code) {
318 mDisconnectCode = code;
319 return this;
320 }
321
322 /**
323 * Sets a label which explains the reason for the disconnect cause, used for display in the
324 * user interface.
325 * @param label The label to associate with the disconnect cause.
326 */
327 public @NonNull DisconnectCause.Builder setLabel(@Nullable CharSequence label) {
328 mDisconnectLabel = label;
329 return this;
330 }
331
332 /**
333 * Sets a description which provides the reason for the disconnect cause, used for display
334 * in the user interface.
335 * @param description The description to associate with the disconnect cause.
336 */
337 public @NonNull DisconnectCause.Builder setDescription(
338 @Nullable CharSequence description) {
339 mDisconnectDescription = description;
340 return this;
341 }
342
343 /**
344 * Sets a reason providing explanation for the disconnect (intended for logging and not for
345 * displaying in the user interface).
346 * @param reason The reason for the disconnect.
347 */
348 public @NonNull DisconnectCause.Builder setReason(@NonNull String reason) {
349 mDisconnectReason = reason;
350 return this;
351 }
352
353 /**
354 * Sets the tone to play when disconnected.
355 * @param toneToPlay The tone as defined in {@link ToneGenerator} to play when disconnected.
356 */
357 public @NonNull DisconnectCause.Builder setTone(int toneToPlay) {
358 mToneToPlay = toneToPlay;
359 return this;
360 }
361
362 /**
363 * Sets the telephony {@link android.telephony.DisconnectCause} for the call (used
364 * internally by Telecom for providing extra debug information from Telephony).
365 * @param telephonyDisconnectCause The disconnect cause as provided by Telephony.
366 */
367 public @NonNull DisconnectCause.Builder setTelephonyDisconnectCause(
368 @Annotation.DisconnectCauses int telephonyDisconnectCause) {
369 mTelephonyDisconnectCause = telephonyDisconnectCause;
370 return this;
371 }
372
373 /**
374 * Sets the telephony {@link android.telephony.PreciseDisconnectCause} for the call (used
375 * internally by Telecom for providing extra debug information from Telephony).
376 * @param telephonyPreciseDisconnectCause The precise disconnect cause as provided by
377 * Telephony.
378 */
379
380 public @NonNull DisconnectCause.Builder setTelephonyPreciseDisconnectCause(
381 @Annotation.PreciseDisconnectCauses int telephonyPreciseDisconnectCause) {
382 mTelephonyPreciseDisconnectCause = telephonyPreciseDisconnectCause;
383 return this;
384 }
385
386 /**
387 * Returns the telephony {@link ImsReasonInfo} associated with the call disconnection. This
388 * is only used internally by Telecom for providing extra debug information from Telephony.
389 *
390 * @param imsReasonInfo The {@link ImsReasonInfo} or {@code null} if not known.
391 */
392 public @NonNull DisconnectCause.Builder setImsReasonInfo(
393 @Nullable ImsReasonInfo imsReasonInfo) {
394 mImsReasonInfo = imsReasonInfo;
395 return this;
396 }
397
398 /**
399 * Build the {@link DisconnectCause} from the provided Builder config.
400 * @return The {@link DisconnectCause} instance from provided builder.
401 */
402 public @NonNull DisconnectCause build() {
403 return new DisconnectCause(mDisconnectCode, mDisconnectLabel, mDisconnectDescription,
404 mDisconnectReason, mToneToPlay, mTelephonyDisconnectCause,
405 mTelephonyPreciseDisconnectCause, mImsReasonInfo);
406 }
407 }
408
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800409 public static final @android.annotation.NonNull Creator<DisconnectCause> CREATOR
410 = new Creator<DisconnectCause>() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700411 @Override
412 public DisconnectCause createFromParcel(Parcel source) {
413 int code = source.readInt();
414 CharSequence label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
415 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
416 String reason = source.readString();
417 int tone = source.readInt();
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800418 int telephonyDisconnectCause = source.readInt();
419 int telephonyPreciseDisconnectCause = source.readInt();
Bernardo Rufino90bb3702021-12-07 20:01:45 +0000420 ImsReasonInfo imsReasonInfo = source.readParcelable(null, android.telephony.ims.ImsReasonInfo.class);
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800421 return new DisconnectCause(code, label, description, reason, tone,
422 telephonyDisconnectCause, telephonyPreciseDisconnectCause, imsReasonInfo);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700423 }
424
425 @Override
426 public DisconnectCause[] newArray(int size) {
427 return new DisconnectCause[size];
428 }
429 };
430
431 @Override
432 public void writeToParcel(Parcel destination, int flags) {
433 destination.writeInt(mDisconnectCode);
434 TextUtils.writeToParcel(mDisconnectLabel, destination, flags);
435 TextUtils.writeToParcel(mDisconnectDescription, destination, flags);
436 destination.writeString(mDisconnectReason);
437 destination.writeInt(mToneToPlay);
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800438 destination.writeInt(mTelephonyDisconnectCause);
439 destination.writeInt(mTelephonyPreciseDisconnectCause);
440 destination.writeParcelable(mImsReasonInfo, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700441 }
442
443 @Override
444 public int describeContents() {
445 return 0;
446 }
447
448 @Override
449 public int hashCode() {
450 return Objects.hashCode(mDisconnectCode)
451 + Objects.hashCode(mDisconnectLabel)
452 + Objects.hashCode(mDisconnectDescription)
453 + Objects.hashCode(mDisconnectReason)
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800454 + Objects.hashCode(mToneToPlay)
455 + Objects.hashCode(mTelephonyDisconnectCause)
456 + Objects.hashCode(mTelephonyPreciseDisconnectCause)
457 + Objects.hashCode(mImsReasonInfo);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700458 }
459
460 @Override
461 public boolean equals(Object o) {
462 if (o instanceof DisconnectCause) {
463 DisconnectCause d = (DisconnectCause) o;
464 return Objects.equals(mDisconnectCode, d.getCode())
465 && Objects.equals(mDisconnectLabel, d.getLabel())
466 && Objects.equals(mDisconnectDescription, d.getDescription())
467 && Objects.equals(mDisconnectReason, d.getReason())
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800468 && Objects.equals(mToneToPlay, d.getTone())
469 && Objects.equals(mTelephonyDisconnectCause, d.getTelephonyDisconnectCause())
470 && Objects.equals(mTelephonyPreciseDisconnectCause,
471 d.getTelephonyPreciseDisconnectCause())
472 && Objects.equals(mImsReasonInfo, d.getImsReasonInfo());
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700473 }
474 return false;
475 }
476
477 @Override
478 public String toString() {
479 String code = "";
Sailesh Nepal7a69c922014-11-05 18:37:53 -0800480 switch (mDisconnectCode) {
481 case UNKNOWN:
482 code = "UNKNOWN";
483 break;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700484 case ERROR:
485 code = "ERROR";
486 break;
487 case LOCAL:
488 code = "LOCAL";
489 break;
490 case REMOTE:
491 code = "REMOTE";
492 break;
Sailesh Nepal7a69c922014-11-05 18:37:53 -0800493 case CANCELED:
494 code = "CANCELED";
495 break;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700496 case MISSED:
497 code = "MISSED";
498 break;
499 case REJECTED:
500 code = "REJECTED";
501 break;
502 case BUSY:
503 code = "BUSY";
504 break;
505 case RESTRICTED:
506 code = "RESTRICTED";
507 break;
508 case OTHER:
509 code = "OTHER";
510 break;
Sailesh Nepal7a69c922014-11-05 18:37:53 -0800511 case CONNECTION_MANAGER_NOT_SUPPORTED:
512 code = "CONNECTION_MANAGER_NOT_SUPPORTED";
513 break;
Tyler Gunn2a3f9972016-06-09 07:58:25 -0700514 case CALL_PULLED:
515 code = "CALL_PULLED";
516 break;
517 case ANSWERED_ELSEWHERE:
518 code = "ANSWERED_ELSEWHERE";
519 break;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700520 default:
Sailesh Nepal7a69c922014-11-05 18:37:53 -0800521 code = "invalid code: " + mDisconnectCode;
522 break;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700523 }
524 String label = mDisconnectLabel == null ? "" : mDisconnectLabel.toString();
525 String description = mDisconnectDescription == null
526 ? "" : mDisconnectDescription.toString();
527 String reason = mDisconnectReason == null ? "" : mDisconnectReason;
528 return "DisconnectCause [ Code: (" + code + ")"
529 + " Label: (" + label + ")"
530 + " Description: (" + description + ")"
531 + " Reason: (" + reason + ")"
Tyler Gunnbc9ecbc2021-03-09 15:06:30 -0800532 + " Tone: (" + mToneToPlay + ") "
533 + " TelephonyCause: " + mTelephonyDisconnectCause + "/"
534 + mTelephonyPreciseDisconnectCause
535 + " ImsReasonInfo: "
536 + mImsReasonInfo
537 + "]";
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700538 }
539}