blob: 97d856e39c80a12428642e039e26927b3452ab52 [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
19import android.os.Parcel;
20import android.os.Parcelable;
Wink Saville599a90c2012-11-27 12:29:13 -080021import android.telephony.Rlog;
Wink Savilleb208a242012-07-25 14:08:09 -070022
23/**
Nathan Harold054b79d2018-03-28 08:39:43 -070024 * A {@link CellInfo} representing an LTE cell that provides identity and measurement info.
Wink Savilleb208a242012-07-25 14:08:09 -070025 */
26public final class CellInfoLte extends CellInfo implements Parcelable {
27
28 private static final String LOG_TAG = "CellInfoLte";
Wink Savillee2c50812013-02-12 10:47:32 -080029 private static final boolean DBG = false;
Wink Savilleb208a242012-07-25 14:08:09 -070030
31 private CellIdentityLte mCellIdentityLte;
32 private CellSignalStrengthLte mCellSignalStrengthLte;
33
34 /** @hide */
35 public CellInfoLte() {
36 super();
37 mCellIdentityLte = new CellIdentityLte();
38 mCellSignalStrengthLte = new CellSignalStrengthLte();
39 }
40
41 /** @hide */
42 public CellInfoLte(CellInfoLte ci) {
43 super(ci);
44 this.mCellIdentityLte = ci.mCellIdentityLte.copy();
45 this.mCellSignalStrengthLte = ci.mCellSignalStrengthLte.copy();
46 }
47
Nathan Harold7b3f7a42018-07-09 11:59:53 -070048 @Override
Wink Savilleb208a242012-07-25 14:08:09 -070049 public CellIdentityLte getCellIdentity() {
Wink Savillec6e4917a2012-09-21 13:54:05 -070050 if (DBG) log("getCellIdentity: " + mCellIdentityLte);
Wink Savilleb208a242012-07-25 14:08:09 -070051 return mCellIdentityLte;
52 }
53 /** @hide */
54 public void setCellIdentity(CellIdentityLte cid) {
Wink Savillec6e4917a2012-09-21 13:54:05 -070055 if (DBG) log("setCellIdentity: " + cid);
Wink Savilleb208a242012-07-25 14:08:09 -070056 mCellIdentityLte = cid;
57 }
58
Nathan Harold7b3f7a42018-07-09 11:59:53 -070059 @Override
Wink Savilleb208a242012-07-25 14:08:09 -070060 public CellSignalStrengthLte getCellSignalStrength() {
Wink Savillec6e4917a2012-09-21 13:54:05 -070061 if (DBG) log("getCellSignalStrength: " + mCellSignalStrengthLte);
Wink Savilleb208a242012-07-25 14:08:09 -070062 return mCellSignalStrengthLte;
63 }
64 /** @hide */
65 public void setCellSignalStrength(CellSignalStrengthLte css) {
Wink Savillec6e4917a2012-09-21 13:54:05 -070066 if (DBG) log("setCellSignalStrength: " + css);
Wink Savilleb208a242012-07-25 14:08:09 -070067 mCellSignalStrengthLte = css;
68 }
69
70 /**
71 * @return hash code
72 */
73 @Override
74 public int hashCode() {
75 return super.hashCode() + mCellIdentityLte.hashCode() + mCellSignalStrengthLte.hashCode();
76 }
77
78 @Override
79 public boolean equals(Object other) {
80 if (!super.equals(other)) {
81 return false;
82 }
83 try {
84 CellInfoLte o = (CellInfoLte) other;
85 return mCellIdentityLte.equals(o.mCellIdentityLte)
86 && mCellSignalStrengthLte.equals(o.mCellSignalStrengthLte);
87 } catch (ClassCastException e) {
88 return false;
89 }
90 }
91
92 @Override
93 public String toString() {
94 StringBuffer sb = new StringBuffer();
95
Wink Saville094beec2013-04-05 15:03:31 -070096 sb.append("CellInfoLte:{");
Wink Savilleb208a242012-07-25 14:08:09 -070097 sb.append(super.toString());
Wink Saville094beec2013-04-05 15:03:31 -070098 sb.append(" ").append(mCellIdentityLte);
99 sb.append(" ").append(mCellSignalStrengthLte);
100 sb.append("}");
Wink Savilleb208a242012-07-25 14:08:09 -0700101
102 return sb.toString();
103 }
104
105 /** Implement the Parcelable interface */
106 @Override
107 public int describeContents() {
108 return 0;
109 }
110
111 /** Implement the Parcelable interface */
112 @Override
113 public void writeToParcel(Parcel dest, int flags) {
114 if (DBG) log("writeToParcel(Parcel, int): " + toString());
Wink Savillec6e4917a2012-09-21 13:54:05 -0700115 super.writeToParcel(dest, flags, TYPE_LTE);
Wink Savilleb208a242012-07-25 14:08:09 -0700116 mCellIdentityLte.writeToParcel(dest, flags);
117 mCellSignalStrengthLte.writeToParcel(dest, flags);
118 }
119
120 /**
121 * Construct a CellInfoLte object from the given parcel
122 * where the TYPE_LTE token is already been processed.
123 */
124 private CellInfoLte(Parcel in) {
125 super(in);
126 mCellIdentityLte = CellIdentityLte.CREATOR.createFromParcel(in);
127 mCellSignalStrengthLte = CellSignalStrengthLte.CREATOR.createFromParcel(in);
128 if (DBG) log("CellInfoLte(Parcel): " + toString());
129 }
130
131 /** Implement the Parcelable interface */
132 public static final Creator<CellInfoLte> CREATOR = new Creator<CellInfoLte>() {
133 @Override
134 public CellInfoLte createFromParcel(Parcel in) {
135 in.readInt(); // Skip past token, we know what it is
136 return createFromParcelBody(in);
137 }
138
139 @Override
140 public CellInfoLte[] newArray(int size) {
141 return new CellInfoLte[size];
142 }
143 };
144
145 /** @hide */
146 protected static CellInfoLte createFromParcelBody(Parcel in) {
147 return new CellInfoLte(in);
148 }
149
150 /**
151 * log
152 */
153 private static void log(String s) {
Wink Saville599a90c2012-11-27 12:29:13 -0800154 Rlog.w(LOG_TAG, s);
Wink Savilleb208a242012-07-25 14:08:09 -0700155 }
156}