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