Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.telecom; |
| 18 | |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 19 | import android.annotation.FlaggedApi; |
| 20 | import android.annotation.NonNull; |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 21 | import android.annotation.Nullable; |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Youming Ye | d6de26e | 2019-01-30 11:20:35 -0800 | [diff] [blame] | 23 | import android.media.ToneGenerator; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 24 | import android.os.Parcel; |
| 25 | import android.os.Parcelable; |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 26 | import android.telephony.Annotation; |
| 27 | import android.telephony.PreciseDisconnectCause; |
| 28 | import android.telephony.ims.ImsReasonInfo; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 29 | import android.text.TextUtils; |
| 30 | |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 31 | import com.android.server.telecom.flags.Flags; |
| 32 | |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 33 | import java.util.Objects; |
| 34 | |
| 35 | /** |
| 36 | * Describes the cause of a disconnected call. This always includes a code describing the generic |
Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 37 | * 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 Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 41 | */ |
| 42 | public final class DisconnectCause implements Parcelable { |
| 43 | |
| 44 | /** Disconnected because of an unknown or unspecified reason. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 45 | public static final int UNKNOWN = TelecomProtoEnums.UNKNOWN; // = 0 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 46 | /** Disconnected because there was an error, such as a problem with the network. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 47 | public static final int ERROR = TelecomProtoEnums.ERROR; // = 1 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 48 | /** Disconnected because of a local user-initiated action, such as hanging up. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 49 | public static final int LOCAL = TelecomProtoEnums.LOCAL; // = 2 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 50 | /** |
Tyler Gunn | e8c5a29 | 2023-05-02 22:52:26 +0000 | [diff] [blame] | 51 | * Disconnected because the remote party hung up an ongoing call, or because an outgoing call |
| 52 | * was not answered by the remote party. |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 53 | */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 54 | public static final int REMOTE = TelecomProtoEnums.REMOTE; // = 3 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 55 | /** Disconnected because it has been canceled. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 56 | public static final int CANCELED = TelecomProtoEnums.CANCELED; // = 4 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 57 | /** Disconnected because there was no response to an incoming call. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 58 | public static final int MISSED = TelecomProtoEnums.MISSED; // = 5 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 59 | /** Disconnected because the user rejected an incoming call. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 60 | public static final int REJECTED = TelecomProtoEnums.REJECTED; // = 6 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 61 | /** Disconnected because the other party was busy. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 62 | public static final int BUSY = TelecomProtoEnums.BUSY; // = 7 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Disconnected because of a restriction on placing the call, such as dialing in airplane |
| 65 | * mode. |
| 66 | */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 67 | public static final int RESTRICTED = TelecomProtoEnums.RESTRICTED; // = 8 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 68 | /** Disconnected for reason not described by other disconnect codes. */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 69 | public static final int OTHER = TelecomProtoEnums.OTHER; // = 9 |
Sailesh Nepal | 7a69c92 | 2014-11-05 18:37:53 -0800 | [diff] [blame] | 70 | /** |
| 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 Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 74 | public static final int CONNECTION_MANAGER_NOT_SUPPORTED = |
| 75 | TelecomProtoEnums.CONNECTION_MANAGER_NOT_SUPPORTED; // = 10 |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 76 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 77 | /** |
| 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 Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 81 | public static final int ANSWERED_ELSEWHERE = TelecomProtoEnums.ANSWERED_ELSEWHERE; // = 11 |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Disconnected because the call was pulled from the current device to another device. |
| 85 | */ |
Tej Singh | c477d9c | 2018-02-05 18:31:39 -0800 | [diff] [blame] | 86 | public static final int CALL_PULLED = TelecomProtoEnums.CALL_PULLED; // = 12 |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 87 | |
Tyler Gunn | 6adbd2b | 2016-12-07 13:19:44 -0800 | [diff] [blame] | 88 | /** |
| 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 Gunn | 6adbd2b | 2016-12-07 13:19:44 -0800 | [diff] [blame] | 92 | */ |
| 93 | public static final String REASON_WIFI_ON_BUT_WFC_OFF = "REASON_WIFI_ON_BUT_WFC_OFF"; |
| 94 | |
Brad Ebinger | 8818c6f | 2017-06-30 15:34:32 -0700 | [diff] [blame] | 95 | /** |
Brad Ebinger | 153af01 | 2022-08-26 15:11:25 -0700 | [diff] [blame] | 96 | * Reason code (returned via {@link #getReason()}), which indicates that the call was |
| 97 | * disconnected because IMS access is blocked. |
Brad Ebinger | 8818c6f | 2017-06-30 15:34:32 -0700 | [diff] [blame] | 98 | */ |
| 99 | public static final String REASON_IMS_ACCESS_BLOCKED = "REASON_IMS_ACCESS_BLOCKED"; |
| 100 | |
Youming Ye | d6de26e | 2019-01-30 11:20:35 -0800 | [diff] [blame] | 101 | /** |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 102 | * 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 Ye | d6de26e | 2019-01-30 11:20:35 -0800 | [diff] [blame] | 108 | */ |
| 109 | public static final String REASON_EMULATING_SINGLE_CALL = "EMULATING_SINGLE_CALL"; |
| 110 | |
Brad Ebinger | 6271387 | 2019-11-18 18:43:35 -0800 | [diff] [blame] | 111 | /** |
| 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 Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 119 | private int mDisconnectCode; |
| 120 | private CharSequence mDisconnectLabel; |
| 121 | private CharSequence mDisconnectDescription; |
| 122 | private String mDisconnectReason; |
| 123 | private int mToneToPlay; |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 124 | private int mTelephonyDisconnectCause; |
| 125 | private int mTelephonyPreciseDisconnectCause; |
| 126 | private ImsReasonInfo mImsReasonInfo; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 127 | |
| 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 Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 149 | * |
Nancy Chen | f4cf77c | 2014-09-19 10:53:21 -0700 | [diff] [blame] | 150 | * @param code The code for the disconnect cause. |
Santos Cordon | a6018b9 | 2016-02-16 14:23:12 -0800 | [diff] [blame] | 151 | * @param label The localized label to show to the user to explain the disconnect. |
Nancy Chen | f4cf77c | 2014-09-19 10:53:21 -0700 | [diff] [blame] | 152 | * @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 Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 161 | * |
| 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 Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 170 | this(code, label, description, reason, toneToPlay, |
| 171 | android.telephony.DisconnectCause.ERROR_UNSPECIFIED, |
| 172 | PreciseDisconnectCause.ERROR_UNSPECIFIED, |
| 173 | null /* imsReasonInfo */); |
| 174 | } |
| 175 | |
| 176 | /** |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 177 | * Creates a new DisconnectCause instance. This is used by Telephony to pass in extra debug |
| 178 | * info to Telecom regarding the disconnect cause. |
| 179 | * |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 180 | * @param code The code for the disconnect cause. |
| 181 | * @param label The localized label to show to the user to explain the disconnect. |
| 182 | * @param description The localized description to show to the user to explain the disconnect. |
| 183 | * @param reason The reason for the disconnect. |
| 184 | * @param toneToPlay The tone to play on disconnect, as defined in {@link ToneGenerator}. |
| 185 | * @param telephonyDisconnectCause The Telephony disconnect cause. |
| 186 | * @param telephonyPreciseDisconnectCause The Telephony precise disconnect cause. |
| 187 | * @param imsReasonInfo The relevant {@link ImsReasonInfo}, or {@code null} if not available. |
| 188 | * @hide |
| 189 | */ |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 190 | @SystemApi |
| 191 | @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES) |
| 192 | public DisconnectCause(int code, @NonNull CharSequence label, |
| 193 | @NonNull CharSequence description, @NonNull String reason, |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 194 | int toneToPlay, @Annotation.DisconnectCauses int telephonyDisconnectCause, |
| 195 | @Annotation.PreciseDisconnectCauses int telephonyPreciseDisconnectCause, |
| 196 | @Nullable ImsReasonInfo imsReasonInfo) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 197 | mDisconnectCode = code; |
| 198 | mDisconnectLabel = label; |
| 199 | mDisconnectDescription = description; |
| 200 | mDisconnectReason = reason; |
| 201 | mToneToPlay = toneToPlay; |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 202 | mTelephonyDisconnectCause = telephonyDisconnectCause; |
| 203 | mTelephonyPreciseDisconnectCause = telephonyPreciseDisconnectCause; |
| 204 | mImsReasonInfo = imsReasonInfo; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Returns the code for the reason for this disconnect. |
| 209 | * |
| 210 | * @return The disconnect code. |
| 211 | */ |
| 212 | public int getCode() { |
| 213 | return mDisconnectCode; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Returns a short label which explains the reason for the disconnect cause and is for display |
Santos Cordon | c1ec931 | 2015-04-24 11:26:01 -0700 | [diff] [blame] | 218 | * in the user interface. If not null, it is expected that the In-Call UI should display this |
| 219 | * text where it would normally display the call state ("Dialing", "Disconnected") and is |
| 220 | * therefore expected to be relatively small. The {@link ConnectionService } is responsible for |
| 221 | * providing and localizing this label. If there is no string provided, returns null. |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 222 | * |
| 223 | * @return The disconnect label. |
| 224 | */ |
| 225 | public CharSequence getLabel() { |
| 226 | return mDisconnectLabel; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Returns a description which explains the reason for the disconnect cause and is for display |
Santos Cordon | c1ec931 | 2015-04-24 11:26:01 -0700 | [diff] [blame] | 231 | * in the user interface. This optional text is generally a longer and more descriptive version |
| 232 | * of {@link #getLabel}, however it can exist even if {@link #getLabel} is empty. The In-Call UI |
| 233 | * should display this relatively prominently; the traditional implementation displays this as |
| 234 | * an alert dialog. The {@link ConnectionService} is responsible for providing and localizing |
| 235 | * this message. If there is no string provided, returns null. |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 236 | * |
| 237 | * @return The disconnect description. |
| 238 | */ |
| 239 | public CharSequence getDescription() { |
| 240 | return mDisconnectDescription; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Returns an explanation of the reason for the disconnect. This is not intended for display to |
| 245 | * the user and is used mainly for logging. |
| 246 | * |
| 247 | * @return The disconnect reason. |
| 248 | */ |
| 249 | public String getReason() { |
| 250 | return mDisconnectReason; |
| 251 | } |
| 252 | |
| 253 | /** |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 254 | * Returns the telephony {@link android.telephony.DisconnectCause} for the call. This is only |
| 255 | * used internally by Telecom for providing extra debug information from Telephony. |
| 256 | * |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 257 | * @return The disconnect cause. |
| 258 | * @hide |
| 259 | */ |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 260 | @SystemApi |
| 261 | @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES) |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 262 | public @Annotation.DisconnectCauses int getTelephonyDisconnectCause() { |
| 263 | return mTelephonyDisconnectCause; |
| 264 | } |
| 265 | |
| 266 | /** |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 267 | * Returns the telephony {@link android.telephony.PreciseDisconnectCause} for the call. This is |
| 268 | * only used internally by Telecom for providing extra debug information from Telephony. |
| 269 | * |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 270 | * @return The precise disconnect cause. |
| 271 | * @hide |
| 272 | */ |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 273 | @SystemApi |
| 274 | @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES) |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 275 | public @Annotation.PreciseDisconnectCauses int getTelephonyPreciseDisconnectCause() { |
| 276 | return mTelephonyPreciseDisconnectCause; |
| 277 | } |
| 278 | |
| 279 | /** |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 280 | * Returns the telephony {@link ImsReasonInfo} associated with the call disconnection. This is |
| 281 | * only used internally by Telecom for providing extra debug information from Telephony. |
| 282 | * |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 283 | * @return The {@link ImsReasonInfo} or {@code null} if not known. |
| 284 | * @hide |
| 285 | */ |
Pranav Madapurmath | 4aaf2a2 | 2024-02-06 15:16:23 -0800 | [diff] [blame] | 286 | @SystemApi |
| 287 | @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES) |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 288 | public @Nullable ImsReasonInfo getImsReasonInfo() { |
| 289 | return mImsReasonInfo; |
| 290 | } |
| 291 | |
| 292 | /** |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 293 | * Returns the tone to play when disconnected. |
| 294 | * |
| 295 | * @return the tone as defined in {@link ToneGenerator} to play when disconnected. |
| 296 | */ |
| 297 | public int getTone() { |
| 298 | return mToneToPlay; |
| 299 | } |
| 300 | |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 301 | public static final @android.annotation.NonNull Creator<DisconnectCause> CREATOR |
| 302 | = new Creator<DisconnectCause>() { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 303 | @Override |
| 304 | public DisconnectCause createFromParcel(Parcel source) { |
| 305 | int code = source.readInt(); |
| 306 | CharSequence label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); |
| 307 | CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); |
| 308 | String reason = source.readString(); |
| 309 | int tone = source.readInt(); |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 310 | int telephonyDisconnectCause = source.readInt(); |
| 311 | int telephonyPreciseDisconnectCause = source.readInt(); |
Bernardo Rufino | 90bb370 | 2021-12-07 20:01:45 +0000 | [diff] [blame] | 312 | ImsReasonInfo imsReasonInfo = source.readParcelable(null, android.telephony.ims.ImsReasonInfo.class); |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 313 | return new DisconnectCause(code, label, description, reason, tone, |
| 314 | telephonyDisconnectCause, telephonyPreciseDisconnectCause, imsReasonInfo); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public DisconnectCause[] newArray(int size) { |
| 319 | return new DisconnectCause[size]; |
| 320 | } |
| 321 | }; |
| 322 | |
| 323 | @Override |
| 324 | public void writeToParcel(Parcel destination, int flags) { |
| 325 | destination.writeInt(mDisconnectCode); |
| 326 | TextUtils.writeToParcel(mDisconnectLabel, destination, flags); |
| 327 | TextUtils.writeToParcel(mDisconnectDescription, destination, flags); |
| 328 | destination.writeString(mDisconnectReason); |
| 329 | destination.writeInt(mToneToPlay); |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 330 | destination.writeInt(mTelephonyDisconnectCause); |
| 331 | destination.writeInt(mTelephonyPreciseDisconnectCause); |
| 332 | destination.writeParcelable(mImsReasonInfo, 0); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | @Override |
| 336 | public int describeContents() { |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | @Override |
| 341 | public int hashCode() { |
| 342 | return Objects.hashCode(mDisconnectCode) |
| 343 | + Objects.hashCode(mDisconnectLabel) |
| 344 | + Objects.hashCode(mDisconnectDescription) |
| 345 | + Objects.hashCode(mDisconnectReason) |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 346 | + Objects.hashCode(mToneToPlay) |
| 347 | + Objects.hashCode(mTelephonyDisconnectCause) |
| 348 | + Objects.hashCode(mTelephonyPreciseDisconnectCause) |
| 349 | + Objects.hashCode(mImsReasonInfo); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | @Override |
| 353 | public boolean equals(Object o) { |
| 354 | if (o instanceof DisconnectCause) { |
| 355 | DisconnectCause d = (DisconnectCause) o; |
| 356 | return Objects.equals(mDisconnectCode, d.getCode()) |
| 357 | && Objects.equals(mDisconnectLabel, d.getLabel()) |
| 358 | && Objects.equals(mDisconnectDescription, d.getDescription()) |
| 359 | && Objects.equals(mDisconnectReason, d.getReason()) |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 360 | && Objects.equals(mToneToPlay, d.getTone()) |
| 361 | && Objects.equals(mTelephonyDisconnectCause, d.getTelephonyDisconnectCause()) |
| 362 | && Objects.equals(mTelephonyPreciseDisconnectCause, |
| 363 | d.getTelephonyPreciseDisconnectCause()) |
| 364 | && Objects.equals(mImsReasonInfo, d.getImsReasonInfo()); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 365 | } |
| 366 | return false; |
| 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public String toString() { |
| 371 | String code = ""; |
Sailesh Nepal | 7a69c92 | 2014-11-05 18:37:53 -0800 | [diff] [blame] | 372 | switch (mDisconnectCode) { |
| 373 | case UNKNOWN: |
| 374 | code = "UNKNOWN"; |
| 375 | break; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 376 | case ERROR: |
| 377 | code = "ERROR"; |
| 378 | break; |
| 379 | case LOCAL: |
| 380 | code = "LOCAL"; |
| 381 | break; |
| 382 | case REMOTE: |
| 383 | code = "REMOTE"; |
| 384 | break; |
Sailesh Nepal | 7a69c92 | 2014-11-05 18:37:53 -0800 | [diff] [blame] | 385 | case CANCELED: |
| 386 | code = "CANCELED"; |
| 387 | break; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 388 | case MISSED: |
| 389 | code = "MISSED"; |
| 390 | break; |
| 391 | case REJECTED: |
| 392 | code = "REJECTED"; |
| 393 | break; |
| 394 | case BUSY: |
| 395 | code = "BUSY"; |
| 396 | break; |
| 397 | case RESTRICTED: |
| 398 | code = "RESTRICTED"; |
| 399 | break; |
| 400 | case OTHER: |
| 401 | code = "OTHER"; |
| 402 | break; |
Sailesh Nepal | 7a69c92 | 2014-11-05 18:37:53 -0800 | [diff] [blame] | 403 | case CONNECTION_MANAGER_NOT_SUPPORTED: |
| 404 | code = "CONNECTION_MANAGER_NOT_SUPPORTED"; |
| 405 | break; |
Tyler Gunn | 2a3f997 | 2016-06-09 07:58:25 -0700 | [diff] [blame] | 406 | case CALL_PULLED: |
| 407 | code = "CALL_PULLED"; |
| 408 | break; |
| 409 | case ANSWERED_ELSEWHERE: |
| 410 | code = "ANSWERED_ELSEWHERE"; |
| 411 | break; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 412 | default: |
Sailesh Nepal | 7a69c92 | 2014-11-05 18:37:53 -0800 | [diff] [blame] | 413 | code = "invalid code: " + mDisconnectCode; |
| 414 | break; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 415 | } |
| 416 | String label = mDisconnectLabel == null ? "" : mDisconnectLabel.toString(); |
| 417 | String description = mDisconnectDescription == null |
| 418 | ? "" : mDisconnectDescription.toString(); |
| 419 | String reason = mDisconnectReason == null ? "" : mDisconnectReason; |
| 420 | return "DisconnectCause [ Code: (" + code + ")" |
| 421 | + " Label: (" + label + ")" |
| 422 | + " Description: (" + description + ")" |
| 423 | + " Reason: (" + reason + ")" |
Tyler Gunn | bc9ecbc | 2021-03-09 15:06:30 -0800 | [diff] [blame] | 424 | + " Tone: (" + mToneToPlay + ") " |
| 425 | + " TelephonyCause: " + mTelephonyDisconnectCause + "/" |
| 426 | + mTelephonyPreciseDisconnectCause |
| 427 | + " ImsReasonInfo: " |
| 428 | + mImsReasonInfo |
| 429 | + "]"; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 430 | } |
| 431 | } |