blob: f67733d63ef2a6c24bece4692fda7be73a92a993 [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
Bill Peckhama74879d2018-09-08 10:06:40 -070019import android.annotation.UnsupportedAppUsage;
Wink Savilleb208a242012-07-25 14:08:09 -070020import android.os.Parcel;
21import android.os.Parcelable;
Wink Saville599a90c2012-11-27 12:29:13 -080022import android.telephony.Rlog;
Wink Savilleb208a242012-07-25 14:08:09 -070023
24/**
Nathan Harold88f44022018-03-28 08:39:43 -070025 * A {@link CellInfo} representing a CDMA cell that provides identity and measurement info.
Wink Savilleb208a242012-07-25 14:08:09 -070026 */
27public final class CellInfoCdma extends CellInfo implements Parcelable {
28
29 private static final String LOG_TAG = "CellInfoCdma";
30 private static final boolean DBG = false;
31
32 private CellIdentityCdma mCellIdentityCdma;
33 private CellSignalStrengthCdma mCellSignalStrengthCdma;
34
35 /** @hide */
Bill Peckhama74879d2018-09-08 10:06:40 -070036 @UnsupportedAppUsage
Wink Savilleb208a242012-07-25 14:08:09 -070037 public CellInfoCdma() {
38 super();
39 mCellIdentityCdma = new CellIdentityCdma();
40 mCellSignalStrengthCdma = new CellSignalStrengthCdma();
41 }
42
43 /** @hide */
Bill Peckhama74879d2018-09-08 10:06:40 -070044 @UnsupportedAppUsage
Wink Savilleb208a242012-07-25 14:08:09 -070045 public CellInfoCdma(CellInfoCdma ci) {
46 super(ci);
47 this.mCellIdentityCdma = ci.mCellIdentityCdma.copy();
48 this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy();
49 }
50
Bill Peckhama74879d2018-09-08 10:06:40 -070051 @Override
Wink Savilleb208a242012-07-25 14:08:09 -070052 public CellIdentityCdma getCellIdentity() {
53 return mCellIdentityCdma;
54 }
55 /** @hide */
Bill Peckhama74879d2018-09-08 10:06:40 -070056 @UnsupportedAppUsage
Wink Savilleb208a242012-07-25 14:08:09 -070057 public void setCellIdentity(CellIdentityCdma cid) {
58 mCellIdentityCdma = cid;
59 }
60
Bill Peckhama74879d2018-09-08 10:06:40 -070061 @Override
Wink Savilleb208a242012-07-25 14:08:09 -070062 public CellSignalStrengthCdma getCellSignalStrength() {
63 return mCellSignalStrengthCdma;
64 }
65 /** @hide */
66 public void setCellSignalStrength(CellSignalStrengthCdma css) {
67 mCellSignalStrengthCdma = css;
68 }
69
70 /**
71 * @return hash code
72 */
73 @Override
74 public int hashCode() {
75 return super.hashCode() + mCellIdentityCdma.hashCode() + mCellSignalStrengthCdma.hashCode();
76 }
77
78 @Override
79 public boolean equals(Object other) {
80 if (!super.equals(other)) {
81 return false;
82 }
83 try {
84 CellInfoCdma o = (CellInfoCdma) other;
85 return mCellIdentityCdma.equals(o.mCellIdentityCdma)
86 && mCellSignalStrengthCdma.equals(o.mCellSignalStrengthCdma);
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("CellInfoCdma:{");
Wink Savilleb208a242012-07-25 14:08:09 -070097 sb.append(super.toString());
Wink Saville094beec2013-04-05 15:03:31 -070098 sb.append(" ").append(mCellIdentityCdma);
99 sb.append(" ").append(mCellSignalStrengthCdma);
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) {
Wink Savillec6e4917a2012-09-21 13:54:05 -0700114 super.writeToParcel(dest, flags, TYPE_CDMA);
Wink Savilleb208a242012-07-25 14:08:09 -0700115 mCellIdentityCdma.writeToParcel(dest, flags);
116 mCellSignalStrengthCdma.writeToParcel(dest, flags);
117 }
118
119 /**
120 * Construct a CellInfoCdma object from the given parcel
121 * where the token is already been processed.
122 */
123 private CellInfoCdma(Parcel in) {
124 super(in);
125 mCellIdentityCdma = CellIdentityCdma.CREATOR.createFromParcel(in);
126 mCellSignalStrengthCdma = CellSignalStrengthCdma.CREATOR.createFromParcel(in);
127 if (DBG) log("CellInfoCdma(Parcel): " + toString());
128 }
129
130 /** Implement the Parcelable interface */
131 public static final Creator<CellInfoCdma> CREATOR = new Creator<CellInfoCdma>() {
132 @Override
133 public CellInfoCdma createFromParcel(Parcel in) {
134 in.readInt(); // Skip past token, we know what it is
135 return createFromParcelBody(in);
136 }
137
138 @Override
139 public CellInfoCdma[] newArray(int size) {
140 return new CellInfoCdma[size];
141 }
142 };
143
144 /** @hide */
145 protected static CellInfoCdma createFromParcelBody(Parcel in) {
146 return new CellInfoCdma(in);
147 }
148
149 /**
150 * log
151 */
152 private static void log(String s) {
Wink Saville599a90c2012-11-27 12:29:13 -0800153 Rlog.w(LOG_TAG, s);
Wink Savilleb208a242012-07-25 14:08:09 -0700154 }
155}