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 | |
Nathan Harold | 78cf8ac | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Artur Satayev | 74cb719 | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 20 | import android.compat.annotation.UnsupportedAppUsage; |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 21 | import android.os.Build; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 24 | |
Meng Wang | 1dbea2f | 2020-01-30 12:25:08 -0800 | [diff] [blame] | 25 | import com.android.telephony.Rlog; |
| 26 | |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 27 | import java.util.Objects; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 30 | * A {@link CellInfo} representing an LTE cell that provides identity and measurement info. |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 31 | */ |
| 32 | public final class CellInfoLte extends CellInfo implements Parcelable { |
| 33 | |
| 34 | private static final String LOG_TAG = "CellInfoLte"; |
Wink Saville | e2c5081 | 2013-02-12 10:47:32 -0800 | [diff] [blame] | 35 | private static final boolean DBG = false; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 36 | |
| 37 | private CellIdentityLte mCellIdentityLte; |
| 38 | private CellSignalStrengthLte mCellSignalStrengthLte; |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 39 | private CellConfigLte mCellConfig; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 40 | |
| 41 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 42 | @UnsupportedAppUsage |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 43 | public CellInfoLte() { |
| 44 | super(); |
| 45 | mCellIdentityLte = new CellIdentityLte(); |
| 46 | mCellSignalStrengthLte = new CellSignalStrengthLte(); |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 47 | mCellConfig = new CellConfigLte(); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /** @hide */ |
| 51 | public CellInfoLte(CellInfoLte ci) { |
| 52 | super(ci); |
| 53 | this.mCellIdentityLte = ci.mCellIdentityLte.copy(); |
| 54 | this.mCellSignalStrengthLte = ci.mCellSignalStrengthLte.copy(); |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 55 | this.mCellConfig = new CellConfigLte(ci.mCellConfig); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Nathan Harold | 7ce5baf | 2018-12-10 13:39:40 -0800 | [diff] [blame] | 58 | /** @hide */ |
| 59 | public CellInfoLte(android.hardware.radio.V1_0.CellInfo ci) { |
| 60 | super(ci); |
| 61 | final android.hardware.radio.V1_0.CellInfoLte cil = ci.lte.get(0); |
| 62 | mCellIdentityLte = new CellIdentityLte(cil.cellIdentityLte); |
| 63 | mCellSignalStrengthLte = new CellSignalStrengthLte(cil.signalStrengthLte); |
| 64 | mCellConfig = new CellConfigLte(); |
| 65 | } |
| 66 | |
| 67 | /** @hide */ |
| 68 | public CellInfoLte(android.hardware.radio.V1_2.CellInfo ci) { |
| 69 | super(ci); |
| 70 | final android.hardware.radio.V1_2.CellInfoLte cil = ci.lte.get(0); |
| 71 | mCellIdentityLte = new CellIdentityLte(cil.cellIdentityLte); |
| 72 | mCellSignalStrengthLte = new CellSignalStrengthLte(cil.signalStrengthLte); |
| 73 | mCellConfig = new CellConfigLte(); |
| 74 | } |
| 75 | |
Pengquan Meng | 629f116 | 2019-01-14 17:14:58 -0800 | [diff] [blame] | 76 | /** @hide */ |
Nathan Harold | 6e3d94b | 2019-03-04 15:15:24 -0800 | [diff] [blame] | 77 | public CellInfoLte(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) { |
| 78 | super(ci, timeStamp); |
Pengquan Meng | 629f116 | 2019-01-14 17:14:58 -0800 | [diff] [blame] | 79 | final android.hardware.radio.V1_4.CellInfoLte cil = ci.info.lte(); |
| 80 | mCellIdentityLte = new CellIdentityLte(cil.base.cellIdentityLte); |
| 81 | mCellSignalStrengthLte = new CellSignalStrengthLte(cil.base.signalStrengthLte); |
| 82 | mCellConfig = new CellConfigLte(cil.cellConfig); |
| 83 | } |
| 84 | |
Sarah Chin | e9ce2ea | 2020-03-17 17:48:36 -0700 | [diff] [blame] | 85 | /** @hide */ |
| 86 | public CellInfoLte(android.hardware.radio.V1_5.CellInfo ci, long timeStamp) { |
| 87 | super(ci, timeStamp); |
| 88 | final android.hardware.radio.V1_5.CellInfoLte cil = ci.ratSpecificInfo.lte(); |
| 89 | mCellIdentityLte = new CellIdentityLte(cil.cellIdentityLte); |
| 90 | mCellSignalStrengthLte = new CellSignalStrengthLte(cil.signalStrengthLte); |
| 91 | mCellConfig = new CellConfigLte(); |
| 92 | } |
| 93 | |
Nathan Harold | 78cf8ac | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 94 | /** |
| 95 | * @return a {@link CellIdentityLte} instance. |
| 96 | */ |
Nathan Harold | 7b3f7a4 | 2018-07-09 11:59:53 -0700 | [diff] [blame] | 97 | @Override |
Nathan Harold | 78cf8ac | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 98 | public @NonNull CellIdentityLte getCellIdentity() { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 99 | if (DBG) log("getCellIdentity: " + mCellIdentityLte); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 100 | return mCellIdentityLte; |
| 101 | } |
Nathan Harold | 78cf8ac | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 102 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 103 | /** @hide */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 104 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 105 | public void setCellIdentity(CellIdentityLte cid) { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 106 | if (DBG) log("setCellIdentity: " + cid); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 107 | mCellIdentityLte = cid; |
| 108 | } |
| 109 | |
Nathan Harold | 78cf8ac | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 110 | /** |
| 111 | * @return a {@link CellSignalStrengthLte} instance. |
| 112 | */ |
Nathan Harold | 7b3f7a4 | 2018-07-09 11:59:53 -0700 | [diff] [blame] | 113 | @Override |
Nathan Harold | 78cf8ac | 2019-04-08 19:21:02 -0700 | [diff] [blame] | 114 | public @NonNull CellSignalStrengthLte getCellSignalStrength() { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 115 | if (DBG) log("getCellSignalStrength: " + mCellSignalStrengthLte); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 116 | return mCellSignalStrengthLte; |
| 117 | } |
Hall Liu | c9d7430 | 2019-02-28 15:29:19 -0800 | [diff] [blame] | 118 | |
| 119 | /** @hide */ |
| 120 | @Override |
| 121 | public CellInfo sanitizeLocationInfo() { |
| 122 | CellInfoLte result = new CellInfoLte(this); |
| 123 | result.mCellIdentityLte = mCellIdentityLte.sanitizeLocationInfo(); |
| 124 | return result; |
| 125 | } |
| 126 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 127 | /** @hide */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 128 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 129 | public void setCellSignalStrength(CellSignalStrengthLte css) { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 130 | if (DBG) log("setCellSignalStrength: " + css); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 131 | mCellSignalStrengthLte = css; |
| 132 | } |
| 133 | |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 134 | /** @hide */ |
| 135 | public void setCellConfig(CellConfigLte cellConfig) { |
| 136 | if (DBG) log("setCellConfig: " + cellConfig); |
| 137 | mCellConfig = cellConfig; |
| 138 | } |
| 139 | |
| 140 | /** @hide */ |
| 141 | public CellConfigLte getCellConfig() { |
| 142 | if (DBG) log("getCellConfig: " + mCellConfig); |
| 143 | return mCellConfig; |
| 144 | } |
| 145 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 146 | /** |
| 147 | * @return hash code |
| 148 | */ |
| 149 | @Override |
| 150 | public int hashCode() { |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 151 | return Objects.hash( |
| 152 | super.hashCode(), |
| 153 | mCellIdentityLte.hashCode(), |
| 154 | mCellSignalStrengthLte.hashCode(), |
| 155 | mCellConfig.hashCode()); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public boolean equals(Object other) { |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 160 | if (!(other instanceof CellInfoLte)) return false; |
| 161 | CellInfoLte o = (CellInfoLte) other; |
| 162 | return super.equals(o) && mCellIdentityLte.equals(o.mCellIdentityLte) |
| 163 | && mCellSignalStrengthLte.equals(o.mCellSignalStrengthLte) |
| 164 | && mCellConfig.equals(o.mCellConfig); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | @Override |
| 168 | public String toString() { |
| 169 | StringBuffer sb = new StringBuffer(); |
| 170 | |
Wink Saville | 094beec | 2013-04-05 15:03:31 -0700 | [diff] [blame] | 171 | sb.append("CellInfoLte:{"); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 172 | sb.append(super.toString()); |
Wink Saville | 094beec | 2013-04-05 15:03:31 -0700 | [diff] [blame] | 173 | sb.append(" ").append(mCellIdentityLte); |
| 174 | sb.append(" ").append(mCellSignalStrengthLte); |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 175 | sb.append(" ").append(mCellConfig); |
Wink Saville | 094beec | 2013-04-05 15:03:31 -0700 | [diff] [blame] | 176 | sb.append("}"); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 177 | |
| 178 | return sb.toString(); |
| 179 | } |
| 180 | |
| 181 | /** Implement the Parcelable interface */ |
| 182 | @Override |
| 183 | public int describeContents() { |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | /** Implement the Parcelable interface */ |
| 188 | @Override |
| 189 | public void writeToParcel(Parcel dest, int flags) { |
| 190 | if (DBG) log("writeToParcel(Parcel, int): " + toString()); |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 191 | super.writeToParcel(dest, flags, TYPE_LTE); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 192 | mCellIdentityLte.writeToParcel(dest, flags); |
| 193 | mCellSignalStrengthLte.writeToParcel(dest, flags); |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 194 | mCellConfig.writeToParcel(dest, flags); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Construct a CellInfoLte object from the given parcel |
| 199 | * where the TYPE_LTE token is already been processed. |
| 200 | */ |
| 201 | private CellInfoLte(Parcel in) { |
| 202 | super(in); |
| 203 | mCellIdentityLte = CellIdentityLte.CREATOR.createFromParcel(in); |
| 204 | mCellSignalStrengthLte = CellSignalStrengthLte.CREATOR.createFromParcel(in); |
Pengquan Meng | 938905e | 2018-11-08 16:39:13 -0800 | [diff] [blame] | 205 | mCellConfig = CellConfigLte.CREATOR.createFromParcel(in); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 206 | if (DBG) log("CellInfoLte(Parcel): " + toString()); |
| 207 | } |
| 208 | |
| 209 | /** Implement the Parcelable interface */ |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 210 | public static final @android.annotation.NonNull Creator<CellInfoLte> CREATOR = new Creator<CellInfoLte>() { |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 211 | @Override |
| 212 | public CellInfoLte createFromParcel(Parcel in) { |
| 213 | in.readInt(); // Skip past token, we know what it is |
| 214 | return createFromParcelBody(in); |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public CellInfoLte[] newArray(int size) { |
| 219 | return new CellInfoLte[size]; |
| 220 | } |
| 221 | }; |
| 222 | |
| 223 | /** @hide */ |
| 224 | protected static CellInfoLte createFromParcelBody(Parcel in) { |
| 225 | return new CellInfoLte(in); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * log |
| 230 | */ |
| 231 | private static void log(String s) { |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 232 | Rlog.w(LOG_TAG, s); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 233 | } |
| 234 | } |