Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [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.telephony; |
| 18 | |
chen xu | 8165386 | 2019-02-28 10:44:54 -0800 | [diff] [blame] | 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 22 | import android.annotation.TestApi; |
Shuo Qian | d0c8181 | 2020-01-13 16:01:46 -0800 | [diff] [blame] | 23 | import android.compat.Compatibility; |
| 24 | import android.compat.annotation.ChangeId; |
| 25 | import android.compat.annotation.EnabledAfter; |
Artur Satayev | 74cb719 | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 26 | import android.compat.annotation.UnsupportedAppUsage; |
Jack Yu | f05919a | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 27 | import android.net.LinkProperties; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 28 | import android.os.Build; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 29 | import android.os.Parcel; |
| 30 | import android.os.Parcelable; |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 31 | import android.telephony.Annotation.ApnType; |
| 32 | import android.telephony.Annotation.DataFailureCause; |
| 33 | import android.telephony.Annotation.DataState; |
| 34 | import android.telephony.Annotation.NetworkType; |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 35 | import android.telephony.data.ApnSetting; |
Jack Yu | f05919a | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 36 | |
| 37 | import java.util.Objects; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 38 | |
chen xu | 8165386 | 2019-02-28 10:44:54 -0800 | [diff] [blame] | 39 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 40 | /** |
| 41 | * Contains precise data connection state. |
| 42 | * |
| 43 | * The following data connection information is included in returned PreciseDataConnectionState: |
| 44 | * |
| 45 | * <ul> |
| 46 | * <li>Data connection state. |
| 47 | * <li>Network type of the connection. |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 48 | * <li>APN types. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 49 | * <li>APN. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 50 | * <li>The properties of the network link. |
| 51 | * <li>Data connection fail cause. |
| 52 | * </ul> |
| 53 | * |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 54 | */ |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 55 | public final class PreciseDataConnectionState implements Parcelable { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 56 | |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 57 | private @DataState int mState = TelephonyManager.DATA_UNKNOWN; |
| 58 | private @NetworkType int mNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 59 | private @DataFailureCause int mFailCause = DataFailCause.NONE; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 60 | private @ApnType int mApnTypes = ApnSetting.TYPE_NONE; |
| 61 | private String mApn = ""; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 62 | private LinkProperties mLinkProperties = null; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 63 | private ApnSetting mApnSetting = null; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Constructor |
| 67 | * |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 68 | * @deprecated this constructor has been superseded and should not be used. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 69 | * @hide |
| 70 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 71 | @TestApi |
| 72 | @Deprecated |
| 73 | @UnsupportedAppUsage // (maxTargetSdk = Build.VERSION_CODES.Q) |
| 74 | // FIXME: figure out how to remove the UnsupportedAppUsage and delete this constructor |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 75 | public PreciseDataConnectionState(@DataState int state, |
| 76 | @NetworkType int networkType, |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 77 | @ApnType int apnTypes, @NonNull String apn, |
| 78 | @Nullable LinkProperties linkProperties, |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 79 | @DataFailureCause int failCause) { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 80 | this(state, networkType, apnTypes, apn, linkProperties, failCause, null); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /** |
Shuo Qian | ac4c8da | 2019-12-23 11:41:44 -0800 | [diff] [blame] | 85 | * Constructor of PreciseDataConnectionState |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 86 | * |
| 87 | * @param state the state of the data connection |
| 88 | * @param networkType the access network that is/would carry this data connection |
| 89 | * @param apnTypes the APN types that this data connection carries |
Shuo Qian | ac4c8da | 2019-12-23 11:41:44 -0800 | [diff] [blame] | 90 | * @param apn the APN of this data connection |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 91 | * @param linkProperties if the data connection is connected, the properties of the connection |
| 92 | * @param failCause in case a procedure related to this data connection fails, a non-zero error |
| 93 | * code indicating the cause of the failure. |
Shuo Qian | ac4c8da | 2019-12-23 11:41:44 -0800 | [diff] [blame] | 94 | * @param apnSetting if there is a valid APN for this Data Connection, then the APN Settings; |
| 95 | * if there is no valid APN setting for the specific type, then this will be null |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 96 | * @hide |
| 97 | */ |
| 98 | public PreciseDataConnectionState(@DataState int state, |
| 99 | @NetworkType int networkType, |
| 100 | @ApnType int apnTypes, @NonNull String apn, |
| 101 | @Nullable LinkProperties linkProperties, |
| 102 | @DataFailureCause int failCause, |
| 103 | @Nullable ApnSetting apnSetting) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 104 | mState = state; |
| 105 | mNetworkType = networkType; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 106 | mApnTypes = apnTypes; |
| 107 | mApn = apn; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 108 | mLinkProperties = linkProperties; |
| 109 | mFailCause = failCause; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 110 | mApnSetting = apnSetting; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Empty Constructor |
| 115 | * |
| 116 | * @hide |
| 117 | */ |
| 118 | public PreciseDataConnectionState() { |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Construct a PreciseDataConnectionState object from the given parcel. |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 123 | * |
| 124 | * @hide |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 125 | */ |
| 126 | private PreciseDataConnectionState(Parcel in) { |
| 127 | mState = in.readInt(); |
| 128 | mNetworkType = in.readInt(); |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 129 | mApnTypes = in.readInt(); |
| 130 | mApn = in.readString(); |
| 131 | mLinkProperties = (LinkProperties) in.readParcelable(null); |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 132 | mFailCause = in.readInt(); |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 133 | mApnSetting = (ApnSetting) in.readParcelable(null); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /** |
Shuo Qian | b32797b | 2020-01-29 10:31:35 -0800 | [diff] [blame] | 137 | * Used for checking if the SDK version for |
| 138 | * {@code PreciseDataConnectionState#getDataConnectionState} is above Q. |
Shuo Qian | d0c8181 | 2020-01-13 16:01:46 -0800 | [diff] [blame] | 139 | */ |
| 140 | @ChangeId |
Shuo Qian | a78143c | 2020-01-14 19:16:31 -0800 | [diff] [blame] | 141 | @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q) |
Shuo Qian | b32797b | 2020-01-29 10:31:35 -0800 | [diff] [blame] | 142 | private static final long GET_DATA_CONNECTION_STATE_R_VERSION = 148535736L; |
Shuo Qian | d0c8181 | 2020-01-13 16:01:46 -0800 | [diff] [blame] | 143 | |
| 144 | /** |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 145 | * Returns the state of data connection that supported the apn types returned by |
| 146 | * {@link #getDataConnectionApnTypeBitMask()} |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 147 | * |
| 148 | * @deprecated use {@link #getState()} |
| 149 | * @hide |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 150 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 151 | @Deprecated |
| 152 | @SystemApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 153 | public @DataState int getDataConnectionState() { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 154 | if (mState == TelephonyManager.DATA_DISCONNECTING |
Shuo Qian | b32797b | 2020-01-29 10:31:35 -0800 | [diff] [blame] | 155 | && !Compatibility.isChangeEnabled(GET_DATA_CONNECTION_STATE_R_VERSION)) { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 156 | return TelephonyManager.DATA_CONNECTED; |
| 157 | } |
| 158 | |
| 159 | return mState; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Returns the high-level state of this data connection. |
| 164 | */ |
| 165 | public @DataState int getState() { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 166 | return mState; |
| 167 | } |
| 168 | |
| 169 | /** |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 170 | * Returns the network type associated with this data connection. |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 171 | * |
| 172 | * @deprecated use {@link getNetworkType()} |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 173 | * @hide |
Michael Wright | eec778c | 2020-03-30 21:25:02 +0100 | [diff] [blame] | 174 | * @removed Removed from the R preview SDK but was never part of the stable API surface. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 175 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 176 | @Deprecated |
| 177 | @SystemApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 178 | public @NetworkType int getDataConnectionNetworkType() { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 179 | return mNetworkType; |
| 180 | } |
| 181 | |
| 182 | /** |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 183 | * Returns the network type associated with this data connection. |
| 184 | * |
| 185 | * Return the current/latest (radio) bearer technology that carries this data connection. |
| 186 | * For a variety of reasons, the network type can change during the life of the data |
| 187 | * connection, and this information is not reliable unless the physical link is currently |
| 188 | * active; (there is currently no mechanism to know whether the physical link is active at |
| 189 | * any given moment). Thus, this value is generally correct but may not be relied-upon to |
| 190 | * represent the status of the radio bearer at any given moment. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 191 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 192 | public @NetworkType int getNetworkType() { |
| 193 | return mNetworkType; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /** |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 197 | * Returns the APN types mapped to this data connection. |
| 198 | * |
| 199 | * @deprecated use {@link #getApnSetting()} |
| 200 | * @hide |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 201 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 202 | @Deprecated |
| 203 | @SystemApi |
| 204 | public @ApnType int getDataConnectionApnTypeBitMask() { |
| 205 | return mApnTypes; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Returns APN of this data connection. |
| 210 | * |
| 211 | * @deprecated use {@link #getApnSetting()} |
| 212 | * @hide |
| 213 | */ |
| 214 | @NonNull |
| 215 | @SystemApi |
| 216 | @Deprecated |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 217 | public String getDataConnectionApn() { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 218 | return mApn; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /** |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 222 | * Get the properties of the network link {@link LinkProperties}. |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 223 | * |
| 224 | * @deprecated use {@link #getLinkProperties()} |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 225 | * @hide |
Michael Wright | eec778c | 2020-03-30 21:25:02 +0100 | [diff] [blame] | 226 | * @removed Removed from the R preview SDK but was never part of the stable API surface. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 227 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 228 | @Deprecated |
| 229 | @SystemApi |
| 230 | @Nullable |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 231 | public LinkProperties getDataConnectionLinkProperties() { |
| 232 | return mLinkProperties; |
| 233 | } |
| 234 | |
| 235 | /** |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 236 | * Get the properties of the network link {@link LinkProperties}. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 237 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 238 | @Nullable |
| 239 | public LinkProperties getLinkProperties() { |
| 240 | return mLinkProperties; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Returns the cause code generated by the most recent state change. |
| 245 | * |
| 246 | * @deprecated use {@link #getLastCauseCode()} |
| 247 | * @hide |
| 248 | */ |
| 249 | @Deprecated |
| 250 | @SystemApi |
| 251 | public int getDataConnectionFailCause() { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 252 | return mFailCause; |
| 253 | } |
| 254 | |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 255 | /** |
| 256 | * Returns the cause code generated by the most recent state change. |
| 257 | * |
| 258 | * Return the cause code for the most recent change in {@link #getState}. In the event of an |
| 259 | * error, this cause code will be non-zero. |
| 260 | */ |
Rambo Wang | 8a54f49 | 2020-02-12 23:49:41 -0800 | [diff] [blame] | 261 | public @DataFailureCause int getLastCauseCode() { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 262 | return mFailCause; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Return the APN Settings for this data connection. |
| 267 | * |
Nathan Harold | a61992b | 2020-01-29 16:17:22 -0800 | [diff] [blame] | 268 | * @return the ApnSetting that was used to configure this data connection. |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 269 | */ |
Nathan Harold | a61992b | 2020-01-29 16:17:22 -0800 | [diff] [blame] | 270 | public @Nullable ApnSetting getApnSetting() { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 271 | return mApnSetting; |
| 272 | } |
| 273 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 274 | @Override |
| 275 | public int describeContents() { |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | @Override |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 280 | public void writeToParcel(@NonNull Parcel out, int flags) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 281 | out.writeInt(mState); |
| 282 | out.writeInt(mNetworkType); |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 283 | out.writeInt(mApnTypes); |
| 284 | out.writeString(mApn); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 285 | out.writeParcelable(mLinkProperties, flags); |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 286 | out.writeInt(mFailCause); |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 287 | out.writeParcelable(mApnSetting, flags); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 288 | } |
| 289 | |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 290 | public static final @NonNull Parcelable.Creator<PreciseDataConnectionState> CREATOR |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 291 | = new Parcelable.Creator<PreciseDataConnectionState>() { |
| 292 | |
| 293 | public PreciseDataConnectionState createFromParcel(Parcel in) { |
| 294 | return new PreciseDataConnectionState(in); |
| 295 | } |
| 296 | |
| 297 | public PreciseDataConnectionState[] newArray(int size) { |
| 298 | return new PreciseDataConnectionState[size]; |
| 299 | } |
| 300 | }; |
| 301 | |
| 302 | @Override |
| 303 | public int hashCode() { |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 304 | return Objects.hash(mState, mNetworkType, mApnTypes, mApn, mLinkProperties, |
| 305 | mFailCause, mApnSetting); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | @Override |
Aurimas Liutikas | 4d1699d | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 309 | public boolean equals(@Nullable Object obj) { |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 310 | |
| 311 | if (!(obj instanceof PreciseDataConnectionState)) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 312 | return false; |
| 313 | } |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 314 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 315 | PreciseDataConnectionState other = (PreciseDataConnectionState) obj; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 316 | return Objects.equals(mApn, other.mApn) && mApnTypes == other.mApnTypes |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 317 | && mFailCause == other.mFailCause |
| 318 | && Objects.equals(mLinkProperties, other.mLinkProperties) |
| 319 | && mNetworkType == other.mNetworkType |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 320 | && mState == other.mState |
| 321 | && Objects.equals(mApnSetting, other.mApnSetting); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 322 | } |
| 323 | |
Aurimas Liutikas | 4d1699d | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 324 | @NonNull |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 325 | @Override |
| 326 | public String toString() { |
| 327 | StringBuilder sb = new StringBuilder(); |
| 328 | |
| 329 | sb.append("Data Connection state: " + mState); |
| 330 | sb.append(", Network type: " + mNetworkType); |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 331 | sb.append(", APN types: " + ApnSetting.getApnTypesStringFromBitmask(mApnTypes)); |
| 332 | sb.append(", APN: " + mApn); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 333 | sb.append(", Link properties: " + mLinkProperties); |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 334 | sb.append(", Fail cause: " + DataFailCause.toString(mFailCause)); |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 335 | sb.append(", Apn Setting: " + mApnSetting); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 336 | |
| 337 | return sb.toString(); |
| 338 | } |
| 339 | } |