Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 | |
Nathan Harold | b2bfb29 | 2019-03-19 13:20:17 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Nathan Harold | 13d6b11 | 2018-12-18 13:40:08 -0800 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 21 | import android.os.Parcel; |
Nathan Harold | 7590fee | 2018-07-19 10:18:23 -0700 | [diff] [blame] | 22 | import android.telephony.gsm.GsmCellLocation; |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 23 | import android.util.ArraySet; |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 24 | |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 25 | import java.util.Collection; |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 26 | import java.util.Collections; |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 27 | import java.util.Objects; |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 28 | import java.util.Set; |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * CellIdentity is to represent a unique TD-SCDMA cell |
| 32 | */ |
| 33 | public final class CellIdentityTdscdma extends CellIdentity { |
| 34 | private static final String TAG = CellIdentityTdscdma.class.getSimpleName(); |
| 35 | private static final boolean DBG = false; |
| 36 | |
Nathan Harold | 251d0a9 | 2019-04-10 17:39:27 -0700 | [diff] [blame] | 37 | private static final int MAX_LAC = 65535; |
| 38 | private static final int MAX_CID = 268435455; |
| 39 | private static final int MAX_CPID = 127; |
| 40 | private static final int MAX_UARFCN = 65535; |
| 41 | |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 42 | // 16-bit Location Area Code, 0..65535, CellInfo.UNAVAILABLE if unknown. |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 43 | private final int mLac; |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 44 | // 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, CellInfo.UNAVAILABLE |
| 45 | // if unknown. |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 46 | private final int mCid; |
Nathan Harold | 251d0a9 | 2019-04-10 17:39:27 -0700 | [diff] [blame] | 47 | // 8-bit Cell Parameters ID described in TS 25.331 sec 10.3.6.9, |
| 48 | // 0..127, CellInfo.UNAVAILABLE if unknown. |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 49 | private final int mCpid; |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 50 | // 16-bit UMTS Absolute RF Channel Number described in TS 25.101 sec. 5.4.3 |
| 51 | private final int mUarfcn; |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 52 | |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 53 | // a list of additional PLMN-IDs reported for this cell |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 54 | private final ArraySet<String> mAdditionalPlmns; |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 55 | |
| 56 | private ClosedSubscriberGroupInfo mCsgInfo; |
| 57 | |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 58 | /** |
| 59 | * @hide |
| 60 | */ |
| 61 | public CellIdentityTdscdma() { |
Nathan Harold | 65c4b15 | 2018-07-30 16:10:50 -0700 | [diff] [blame] | 62 | super(TAG, CellInfo.TYPE_TDSCDMA, null, null, null, null); |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 63 | mLac = CellInfo.UNAVAILABLE; |
| 64 | mCid = CellInfo.UNAVAILABLE; |
| 65 | mCpid = CellInfo.UNAVAILABLE; |
| 66 | mUarfcn = CellInfo.UNAVAILABLE; |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 67 | mAdditionalPlmns = new ArraySet<>(); |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 68 | mCsgInfo = null; |
Mingming Cai | c78abaa | 2020-03-13 11:17:46 -0700 | [diff] [blame] | 69 | mGlobalCellId = null; |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /** |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 73 | * @param mcc 3-digit Mobile Country Code in string format |
| 74 | * @param mnc 2 or 3-digit Mobile Network Code in string format |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 75 | * @param lac 16-bit Location Area Code, 0..65535, CellInfo.UNAVAILABLE if unknown |
| 76 | * @param cid 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, |
| 77 | * CellInfo.UNAVAILABLE if unknown |
| 78 | * @param cpid 8-bit Cell Parameters ID described in TS 25.331, 0..127, |
| 79 | * CellInfo.UNAVAILABLE if unknown |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 80 | * @param uarfcn 16-bit UMTS Absolute RF Channel Number described in TS 25.101 sec. 5.4.3 |
Nathan Harold | a7b147e | 2018-03-19 16:59:40 -0700 | [diff] [blame] | 81 | * @param alphal long alpha Operator Name String or Enhanced Operator Name String |
| 82 | * @param alphas short alpha Operator Name String or Enhanced Operator Name String |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 83 | * @param additionalPlmns a list of additional PLMN IDs broadcast by the cell |
| 84 | * @param csgInfo info about the closed subscriber group broadcast by the cell |
Nathan Harold | a7b147e | 2018-03-19 16:59:40 -0700 | [diff] [blame] | 85 | * |
| 86 | * @hide |
| 87 | */ |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 88 | public CellIdentityTdscdma(@Nullable String mcc, @Nullable String mnc, int lac, int cid, |
| 89 | int cpid, int uarfcn, @Nullable String alphal, @Nullable String alphas, |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 90 | @NonNull Collection<String> additionalPlmns, |
| 91 | @Nullable ClosedSubscriberGroupInfo csgInfo) { |
Nathan Harold | 65c4b15 | 2018-07-30 16:10:50 -0700 | [diff] [blame] | 92 | super(TAG, CellInfo.TYPE_TDSCDMA, mcc, mnc, alphal, alphas); |
Nathan Harold | 251d0a9 | 2019-04-10 17:39:27 -0700 | [diff] [blame] | 93 | mLac = inRangeOrUnavailable(lac, 0, MAX_LAC); |
| 94 | mCid = inRangeOrUnavailable(cid, 0, MAX_CID); |
| 95 | mCpid = inRangeOrUnavailable(cpid, 0, MAX_CPID); |
| 96 | mUarfcn = inRangeOrUnavailable(uarfcn, 0, MAX_UARFCN); |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 97 | mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 98 | for (String plmn : additionalPlmns) { |
| 99 | if (isValidPlmn(plmn)) { |
| 100 | mAdditionalPlmns.add(plmn); |
| 101 | } |
| 102 | } |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 103 | mCsgInfo = csgInfo; |
Mingming Cai | c78abaa | 2020-03-13 11:17:46 -0700 | [diff] [blame] | 104 | updateGlobalCellId(); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 105 | } |
| 106 | |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 107 | private CellIdentityTdscdma(@NonNull CellIdentityTdscdma cid) { |
Nathan Harold | a7b147e | 2018-03-19 16:59:40 -0700 | [diff] [blame] | 108 | this(cid.mMccStr, cid.mMncStr, cid.mLac, cid.mCid, |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 109 | cid.mCpid, cid.mUarfcn, cid.mAlphaLong, |
| 110 | cid.mAlphaShort, cid.mAdditionalPlmns, cid.mCsgInfo); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Nathan Harold | 7ce5baf | 2018-12-10 13:39:40 -0800 | [diff] [blame] | 113 | /** @hide */ |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 114 | public CellIdentityTdscdma(@NonNull android.hardware.radio.V1_0.CellIdentityTdscdma cid) { |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 115 | this(cid.mcc, cid.mnc, cid.lac, cid.cid, cid.cpid, CellInfo.UNAVAILABLE, "", "", |
| 116 | Collections.emptyList(), null); |
Nathan Harold | 7ce5baf | 2018-12-10 13:39:40 -0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | /** @hide */ |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 120 | public CellIdentityTdscdma(@NonNull android.hardware.radio.V1_2.CellIdentityTdscdma cid) { |
Nathan Harold | 7ce5baf | 2018-12-10 13:39:40 -0800 | [diff] [blame] | 121 | this(cid.base.mcc, cid.base.mnc, cid.base.lac, cid.base.cid, cid.base.cpid, |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 122 | cid.uarfcn, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort, |
| 123 | Collections.emptyList(), null); |
| 124 | } |
| 125 | |
| 126 | /** @hide */ |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 127 | public CellIdentityTdscdma(@NonNull android.hardware.radio.V1_5.CellIdentityTdscdma cid) { |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 128 | this(cid.base.base.mcc, cid.base.base.mnc, cid.base.base.lac, cid.base.base.cid, |
| 129 | cid.base.base.cpid, cid.base.uarfcn, cid.base.operatorNames.alphaLong, |
| 130 | cid.base.operatorNames.alphaShort, |
Nathan Harold | b3cefba | 2020-03-26 13:08:32 -0700 | [diff] [blame] | 131 | cid.additionalPlmns, |
| 132 | cid.optionalCsgInfo.getDiscriminator() |
| 133 | == android.hardware.radio.V1_5.OptionalCsgInfo.hidl_discriminator.csgInfo |
| 134 | ? new ClosedSubscriberGroupInfo(cid.optionalCsgInfo.csgInfo()) |
| 135 | : null); |
Nathan Harold | 7ce5baf | 2018-12-10 13:39:40 -0800 | [diff] [blame] | 136 | } |
| 137 | |
Hall Liu | c9d7430 | 2019-02-28 15:29:19 -0800 | [diff] [blame] | 138 | /** @hide */ |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 139 | @Override |
| 140 | public @NonNull CellIdentityTdscdma sanitizeLocationInfo() { |
Hall Liu | c9d7430 | 2019-02-28 15:29:19 -0800 | [diff] [blame] | 141 | return new CellIdentityTdscdma(mMccStr, mMncStr, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 142 | CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort, |
| 143 | mAdditionalPlmns, null); |
Hall Liu | c9d7430 | 2019-02-28 15:29:19 -0800 | [diff] [blame] | 144 | } |
| 145 | |
Rambo Wang | 33f62a0 | 2020-01-29 14:37:05 -0800 | [diff] [blame] | 146 | @NonNull CellIdentityTdscdma copy() { |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 147 | return new CellIdentityTdscdma(this); |
| 148 | } |
| 149 | |
Mingming Cai | c78abaa | 2020-03-13 11:17:46 -0700 | [diff] [blame] | 150 | /** @hide */ |
| 151 | @Override |
| 152 | protected void updateGlobalCellId() { |
| 153 | mGlobalCellId = null; |
| 154 | String plmn = getPlmn(); |
| 155 | if (plmn == null) return; |
| 156 | |
| 157 | if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return; |
| 158 | |
| 159 | mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid); |
| 160 | } |
| 161 | |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 162 | /** |
| 163 | * Get Mobile Country Code in string format |
| 164 | * @return Mobile Country Code in string format, null if unknown |
| 165 | */ |
Nathan Harold | 4f41475 | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 166 | @Nullable |
Cassie | d062c322 | 2018-02-28 11:45:29 -0800 | [diff] [blame] | 167 | public String getMccString() { |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 168 | return mMccStr; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Get Mobile Network Code in string format |
| 173 | * @return Mobile Network Code in string format, null if unknown |
| 174 | */ |
Nathan Harold | 4f41475 | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 175 | @Nullable |
Cassie | d062c322 | 2018-02-28 11:45:29 -0800 | [diff] [blame] | 176 | public String getMncString() { |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 177 | return mMncStr; |
| 178 | } |
| 179 | |
| 180 | /** |
Nathan Harold | d285c8e | 2018-10-22 15:07:06 -0700 | [diff] [blame] | 181 | * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown |
| 182 | */ |
Nathan Harold | 13d6b11 | 2018-12-18 13:40:08 -0800 | [diff] [blame] | 183 | @Nullable |
Nathan Harold | d285c8e | 2018-10-22 15:07:06 -0700 | [diff] [blame] | 184 | public String getMobileNetworkOperator() { |
| 185 | return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr; |
| 186 | } |
| 187 | |
| 188 | /** |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 189 | * @return 16-bit Location Area Code, 0..65535, |
| 190 | * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 191 | */ |
| 192 | public int getLac() { |
| 193 | return mLac; |
| 194 | } |
| 195 | |
| 196 | /** |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 197 | * @return 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, |
| 198 | * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 199 | */ |
| 200 | public int getCid() { |
| 201 | return mCid; |
| 202 | } |
| 203 | |
| 204 | /** |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 205 | * @return 8-bit Cell Parameters ID described in TS 25.331, 0..127, |
| 206 | * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 207 | */ |
| 208 | public int getCpid() { |
| 209 | return mCpid; |
| 210 | } |
| 211 | |
Nathan Harold | da59b53 | 2019-02-12 10:20:46 -0800 | [diff] [blame] | 212 | /** |
| 213 | * @return 16-bit UMTS Absolute RF Channel Number, |
| 214 | * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. |
| 215 | */ |
| 216 | public int getUarfcn() { |
| 217 | return mUarfcn; |
| 218 | } |
| 219 | |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 220 | /** @hide */ |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 221 | @Override |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 222 | public int getChannelNumber() { |
| 223 | return mUarfcn; |
| 224 | } |
| 225 | |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 226 | /** |
| 227 | * @return a list of additional PLMN IDs supported by this cell. |
| 228 | */ |
| 229 | @NonNull |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 230 | public Set<String> getAdditionalPlmns() { |
| 231 | return Collections.unmodifiableSet(mAdditionalPlmns); |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /** |
| 235 | * @return closed subscriber group information about the cell if available, otherwise null. |
| 236 | */ |
| 237 | @Nullable |
| 238 | public ClosedSubscriberGroupInfo getClosedSubscriberGroupInfo() { |
| 239 | return mCsgInfo; |
| 240 | } |
| 241 | |
Nathan Harold | 7590fee | 2018-07-19 10:18:23 -0700 | [diff] [blame] | 242 | /** @hide */ |
Meng Wang | d75f97d | 2019-12-06 18:27:38 -0800 | [diff] [blame] | 243 | @NonNull |
Nathan Harold | 7590fee | 2018-07-19 10:18:23 -0700 | [diff] [blame] | 244 | @Override |
| 245 | public GsmCellLocation asCellLocation() { |
| 246 | GsmCellLocation cl = new GsmCellLocation(); |
Nathan Harold | a629ea3 | 2018-10-24 11:35:53 -0700 | [diff] [blame] | 247 | int lac = mLac != CellInfo.UNAVAILABLE ? mLac : -1; |
| 248 | int cid = mCid != CellInfo.UNAVAILABLE ? mCid : -1; |
Nathan Harold | 7590fee | 2018-07-19 10:18:23 -0700 | [diff] [blame] | 249 | cl.setLacAndCid(lac, cid); |
| 250 | cl.setPsc(-1); // There is no PSC for TD-SCDMA; not using this for CPI to stem shenanigans |
| 251 | return cl; |
| 252 | } |
| 253 | |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 254 | @Override |
| 255 | public boolean equals(Object other) { |
| 256 | if (this == other) { |
| 257 | return true; |
| 258 | } |
| 259 | |
| 260 | if (!(other instanceof CellIdentityTdscdma)) { |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | CellIdentityTdscdma o = (CellIdentityTdscdma) other; |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 265 | return mLac == o.mLac |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 266 | && mCid == o.mCid |
Nathan Harold | a7b147e | 2018-03-19 16:59:40 -0700 | [diff] [blame] | 267 | && mCpid == o.mCpid |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 268 | && mUarfcn == o.mUarfcn |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 269 | && mAdditionalPlmns.equals(o.mAdditionalPlmns) |
| 270 | && Objects.equals(mCsgInfo, o.mCsgInfo) |
Cassie | ae2b65a | 2018-03-21 16:20:34 -0700 | [diff] [blame] | 271 | && super.equals(other); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | @Override |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 275 | public int hashCode() { |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 276 | return Objects.hash(mLac, mCid, mCpid, mUarfcn, |
| 277 | mAdditionalPlmns.hashCode(), mCsgInfo, super.hashCode()); |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | @Override |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 281 | public String toString() { |
| 282 | return new StringBuilder(TAG) |
| 283 | .append(":{ mMcc=").append(mMccStr) |
| 284 | .append(" mMnc=").append(mMncStr) |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 285 | .append(" mAlphaLong=").append(mAlphaLong) |
| 286 | .append(" mAlphaShort=").append(mAlphaShort) |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 287 | .append(" mLac=").append(mLac) |
| 288 | .append(" mCid=").append(mCid) |
| 289 | .append(" mCpid=").append(mCpid) |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 290 | .append(" mUarfcn=").append(mUarfcn) |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 291 | .append(" mAdditionalPlmns=").append(mAdditionalPlmns) |
| 292 | .append(" mCsgInfo=").append(mCsgInfo) |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 293 | .append("}").toString(); |
| 294 | } |
| 295 | |
| 296 | /** Implement the Parcelable interface */ |
| 297 | @Override |
Nathan Harold | b2bfb29 | 2019-03-19 13:20:17 -0700 | [diff] [blame] | 298 | public int describeContents() { |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | /** Implement the Parcelable interface */ |
| 303 | @Override |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 304 | public void writeToParcel(Parcel dest, int flags) { |
| 305 | if (DBG) log("writeToParcel(Parcel, int): " + toString()); |
Nathan Harold | 65c4b15 | 2018-07-30 16:10:50 -0700 | [diff] [blame] | 306 | super.writeToParcel(dest, CellInfo.TYPE_TDSCDMA); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 307 | dest.writeInt(mLac); |
| 308 | dest.writeInt(mCid); |
| 309 | dest.writeInt(mCpid); |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 310 | dest.writeInt(mUarfcn); |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 311 | dest.writeArraySet(mAdditionalPlmns); |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 312 | dest.writeParcelable(mCsgInfo, flags); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /** Construct from Parcel, type has already been processed */ |
| 316 | private CellIdentityTdscdma(Parcel in) { |
Nathan Harold | 65c4b15 | 2018-07-30 16:10:50 -0700 | [diff] [blame] | 317 | super(TAG, CellInfo.TYPE_TDSCDMA, in); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 318 | mLac = in.readInt(); |
| 319 | mCid = in.readInt(); |
| 320 | mCpid = in.readInt(); |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 321 | mUarfcn = in.readInt(); |
Nathan Harold | 5522de1a | 2020-02-13 19:50:51 -0800 | [diff] [blame] | 322 | mAdditionalPlmns = (ArraySet<String>) in.readArraySet(null); |
Nathan Harold | ac37b63 | 2020-01-20 19:04:40 -0800 | [diff] [blame] | 323 | mCsgInfo = in.readParcelable(null); |
Nathan Harold | 3f7dfb8 | 2020-04-24 18:34:33 -0700 | [diff] [blame] | 324 | |
| 325 | updateGlobalCellId(); |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 326 | if (DBG) log(toString()); |
| 327 | } |
| 328 | |
| 329 | /** Implement the Parcelable interface */ |
| 330 | @SuppressWarnings("hiding") |
Nathan Harold | b2bfb29 | 2019-03-19 13:20:17 -0700 | [diff] [blame] | 331 | @NonNull |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 332 | public static final Creator<CellIdentityTdscdma> CREATOR = |
| 333 | new Creator<CellIdentityTdscdma>() { |
| 334 | @Override |
Nathan Harold | b2bfb29 | 2019-03-19 13:20:17 -0700 | [diff] [blame] | 335 | public @NonNull CellIdentityTdscdma createFromParcel(Parcel in) { |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 336 | in.readInt(); // skip |
| 337 | return createFromParcelBody(in); |
| 338 | } |
| 339 | |
| 340 | @Override |
Nathan Harold | b2bfb29 | 2019-03-19 13:20:17 -0700 | [diff] [blame] | 341 | public @NonNull CellIdentityTdscdma[] newArray(int size) { |
Jack Yu | 6cd4473 | 2017-12-28 14:41:12 -0800 | [diff] [blame] | 342 | return new CellIdentityTdscdma[size]; |
| 343 | } |
| 344 | }; |
| 345 | |
| 346 | /** @hide */ |
| 347 | protected static CellIdentityTdscdma createFromParcelBody(Parcel in) { |
| 348 | return new CellIdentityTdscdma(in); |
| 349 | } |
| 350 | } |