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