blob: 320925ea63ae06d8adc3dd174268a7967fb69cab [file] [log] [blame]
Wink Savilleb208a242012-07-25 14:08:09 -07001/*
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
17package android.telephony;
18
Nathan Harold78cf8ac2019-04-08 19:21:02 -070019import android.annotation.NonNull;
Artur Satayev74cb7192019-12-10 17:47:56 +000020import android.compat.annotation.UnsupportedAppUsage;
Mathew Inwood55418ea2018-12-20 15:30:45 +000021import android.os.Build;
Wink Savilleb208a242012-07-25 14:08:09 -070022import android.os.Parcel;
23import android.os.Parcelable;
Pengquan Meng938905e2018-11-08 16:39:13 -080024
Meng Wang1dbea2f2020-01-30 12:25:08 -080025import com.android.telephony.Rlog;
26
Pengquan Meng938905e2018-11-08 16:39:13 -080027import java.util.Objects;
Wink Savilleb208a242012-07-25 14:08:09 -070028
29/**
Nathan Harold054b79d2018-03-28 08:39:43 -070030 * A {@link CellInfo} representing an LTE cell that provides identity and measurement info.
Wink Savilleb208a242012-07-25 14:08:09 -070031 */
32public final class CellInfoLte extends CellInfo implements Parcelable {
33
34 private static final String LOG_TAG = "CellInfoLte";
Wink Savillee2c50812013-02-12 10:47:32 -080035 private static final boolean DBG = false;
Wink Savilleb208a242012-07-25 14:08:09 -070036
37 private CellIdentityLte mCellIdentityLte;
38 private CellSignalStrengthLte mCellSignalStrengthLte;
Pengquan Meng938905e2018-11-08 16:39:13 -080039 private CellConfigLte mCellConfig;
Wink Savilleb208a242012-07-25 14:08:09 -070040
41 /** @hide */
Mathew Inwooda8382062018-08-16 17:01:12 +010042 @UnsupportedAppUsage
Wink Savilleb208a242012-07-25 14:08:09 -070043 public CellInfoLte() {
44 super();
45 mCellIdentityLte = new CellIdentityLte();
46 mCellSignalStrengthLte = new CellSignalStrengthLte();
Pengquan Meng938905e2018-11-08 16:39:13 -080047 mCellConfig = new CellConfigLte();
Wink Savilleb208a242012-07-25 14:08:09 -070048 }
49
50 /** @hide */
51 public CellInfoLte(CellInfoLte ci) {
52 super(ci);
53 this.mCellIdentityLte = ci.mCellIdentityLte.copy();
54 this.mCellSignalStrengthLte = ci.mCellSignalStrengthLte.copy();
Pengquan Meng938905e2018-11-08 16:39:13 -080055 this.mCellConfig = new CellConfigLte(ci.mCellConfig);
Wink Savilleb208a242012-07-25 14:08:09 -070056 }
57
Nathan Harold7ce5baf2018-12-10 13:39:40 -080058 /** @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 Meng629f1162019-01-14 17:14:58 -080076 /** @hide */
Nathan Harold6e3d94b2019-03-04 15:15:24 -080077 public CellInfoLte(android.hardware.radio.V1_4.CellInfo ci, long timeStamp) {
78 super(ci, timeStamp);
Pengquan Meng629f1162019-01-14 17:14:58 -080079 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 Chine9ce2ea2020-03-17 17:48:36 -070085 /** @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 Harold78cf8ac2019-04-08 19:21:02 -070094 /**
95 * @return a {@link CellIdentityLte} instance.
96 */
Nathan Harold7b3f7a42018-07-09 11:59:53 -070097 @Override
Nathan Harold78cf8ac2019-04-08 19:21:02 -070098 public @NonNull CellIdentityLte getCellIdentity() {
Wink Savillec6e4917a2012-09-21 13:54:05 -070099 if (DBG) log("getCellIdentity: " + mCellIdentityLte);
Wink Savilleb208a242012-07-25 14:08:09 -0700100 return mCellIdentityLte;
101 }
Nathan Harold78cf8ac2019-04-08 19:21:02 -0700102
Wink Savilleb208a242012-07-25 14:08:09 -0700103 /** @hide */
Mathew Inwood55418ea2018-12-20 15:30:45 +0000104 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Wink Savilleb208a242012-07-25 14:08:09 -0700105 public void setCellIdentity(CellIdentityLte cid) {
Wink Savillec6e4917a2012-09-21 13:54:05 -0700106 if (DBG) log("setCellIdentity: " + cid);
Wink Savilleb208a242012-07-25 14:08:09 -0700107 mCellIdentityLte = cid;
108 }
109
Nathan Harold78cf8ac2019-04-08 19:21:02 -0700110 /**
111 * @return a {@link CellSignalStrengthLte} instance.
112 */
Nathan Harold7b3f7a42018-07-09 11:59:53 -0700113 @Override
Nathan Harold78cf8ac2019-04-08 19:21:02 -0700114 public @NonNull CellSignalStrengthLte getCellSignalStrength() {
Wink Savillec6e4917a2012-09-21 13:54:05 -0700115 if (DBG) log("getCellSignalStrength: " + mCellSignalStrengthLte);
Wink Savilleb208a242012-07-25 14:08:09 -0700116 return mCellSignalStrengthLte;
117 }
Hall Liuc9d74302019-02-28 15:29:19 -0800118
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 Savilleb208a242012-07-25 14:08:09 -0700127 /** @hide */
Mathew Inwood55418ea2018-12-20 15:30:45 +0000128 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Wink Savilleb208a242012-07-25 14:08:09 -0700129 public void setCellSignalStrength(CellSignalStrengthLte css) {
Wink Savillec6e4917a2012-09-21 13:54:05 -0700130 if (DBG) log("setCellSignalStrength: " + css);
Wink Savilleb208a242012-07-25 14:08:09 -0700131 mCellSignalStrengthLte = css;
132 }
133
Pengquan Meng938905e2018-11-08 16:39:13 -0800134 /** @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 Savilleb208a242012-07-25 14:08:09 -0700146 /**
147 * @return hash code
148 */
149 @Override
150 public int hashCode() {
Pengquan Meng938905e2018-11-08 16:39:13 -0800151 return Objects.hash(
152 super.hashCode(),
153 mCellIdentityLte.hashCode(),
154 mCellSignalStrengthLte.hashCode(),
155 mCellConfig.hashCode());
Wink Savilleb208a242012-07-25 14:08:09 -0700156 }
157
158 @Override
159 public boolean equals(Object other) {
Pengquan Meng938905e2018-11-08 16:39:13 -0800160 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 Savilleb208a242012-07-25 14:08:09 -0700165 }
166
167 @Override
168 public String toString() {
169 StringBuffer sb = new StringBuffer();
170
Wink Saville094beec2013-04-05 15:03:31 -0700171 sb.append("CellInfoLte:{");
Wink Savilleb208a242012-07-25 14:08:09 -0700172 sb.append(super.toString());
Wink Saville094beec2013-04-05 15:03:31 -0700173 sb.append(" ").append(mCellIdentityLte);
174 sb.append(" ").append(mCellSignalStrengthLte);
Pengquan Meng938905e2018-11-08 16:39:13 -0800175 sb.append(" ").append(mCellConfig);
Wink Saville094beec2013-04-05 15:03:31 -0700176 sb.append("}");
Wink Savilleb208a242012-07-25 14:08:09 -0700177
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 Savillec6e4917a2012-09-21 13:54:05 -0700191 super.writeToParcel(dest, flags, TYPE_LTE);
Wink Savilleb208a242012-07-25 14:08:09 -0700192 mCellIdentityLte.writeToParcel(dest, flags);
193 mCellSignalStrengthLte.writeToParcel(dest, flags);
Pengquan Meng938905e2018-11-08 16:39:13 -0800194 mCellConfig.writeToParcel(dest, flags);
Wink Savilleb208a242012-07-25 14:08:09 -0700195 }
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 Meng938905e2018-11-08 16:39:13 -0800205 mCellConfig = CellConfigLte.CREATOR.createFromParcel(in);
Wink Savilleb208a242012-07-25 14:08:09 -0700206 if (DBG) log("CellInfoLte(Parcel): " + toString());
207 }
208
209 /** Implement the Parcelable interface */
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700210 public static final @android.annotation.NonNull Creator<CellInfoLte> CREATOR = new Creator<CellInfoLte>() {
Wink Savilleb208a242012-07-25 14:08:09 -0700211 @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 Saville599a90c2012-11-27 12:29:13 -0800232 Rlog.w(LOG_TAG, s);
Wink Savilleb208a242012-07-25 14:08:09 -0700233 }
234}