2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.telephony;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 import android.telephony.Rlog;
24 * Immutable cell information from a point in time.
26 public final class CellInfoCdma extends CellInfo implements Parcelable {
28 private static final String LOG_TAG = "CellInfoCdma";
29 private static final boolean DBG = false;
31 private CellIdentityCdma mCellIdentityCdma;
32 private CellSignalStrengthCdma mCellSignalStrengthCdma;
35 public CellInfoCdma() {
37 mCellIdentityCdma = new CellIdentityCdma();
38 mCellSignalStrengthCdma = new CellSignalStrengthCdma();
42 public CellInfoCdma(CellInfoCdma ci) {
44 this.mCellIdentityCdma = ci.mCellIdentityCdma.copy();
45 this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy();
48 public CellIdentityCdma getCellIdentity() {
49 return mCellIdentityCdma;
52 public void setCellIdentity(CellIdentityCdma cid) {
53 mCellIdentityCdma = cid;
56 public CellSignalStrengthCdma getCellSignalStrength() {
57 return mCellSignalStrengthCdma;
60 public void setCellSignalStrength(CellSignalStrengthCdma css) {
61 mCellSignalStrengthCdma = css;
68 public int hashCode() {
69 return super.hashCode() + mCellIdentityCdma.hashCode() + mCellSignalStrengthCdma.hashCode();
73 public boolean equals(Object other) {
74 if (!super.equals(other)) {
78 CellInfoCdma o = (CellInfoCdma) other;
79 return mCellIdentityCdma.equals(o.mCellIdentityCdma)
80 && mCellSignalStrengthCdma.equals(o.mCellSignalStrengthCdma);
81 } catch (ClassCastException e) {
87 public String toString() {
88 StringBuffer sb = new StringBuffer();
90 sb.append("CellInfoCdma:{");
91 sb.append(super.toString());
92 sb.append(" ").append(mCellIdentityCdma);
93 sb.append(" ").append(mCellSignalStrengthCdma);
99 /** Implement the Parcelable interface */
101 public int describeContents() {
105 /** Implement the Parcelable interface */
107 public void writeToParcel(Parcel dest, int flags) {
108 super.writeToParcel(dest, flags, TYPE_CDMA);
109 mCellIdentityCdma.writeToParcel(dest, flags);
110 mCellSignalStrengthCdma.writeToParcel(dest, flags);
114 * Construct a CellInfoCdma object from the given parcel
115 * where the token is already been processed.
117 private CellInfoCdma(Parcel in) {
119 mCellIdentityCdma = CellIdentityCdma.CREATOR.createFromParcel(in);
120 mCellSignalStrengthCdma = CellSignalStrengthCdma.CREATOR.createFromParcel(in);
121 if (DBG) log("CellInfoCdma(Parcel): " + toString());
124 /** Implement the Parcelable interface */
125 public static final Creator<CellInfoCdma> CREATOR = new Creator<CellInfoCdma>() {
127 public CellInfoCdma createFromParcel(Parcel in) {
128 in.readInt(); // Skip past token, we know what it is
129 return createFromParcelBody(in);
133 public CellInfoCdma[] newArray(int size) {
134 return new CellInfoCdma[size];
139 protected static CellInfoCdma createFromParcelBody(Parcel in) {
140 return new CellInfoCdma(in);
146 private static void log(String s) {