• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 import com.android.telephony.Rlog;
23 
24 import java.util.Objects;
25 
26 /**
27  * A {@link CellInfo} representing a WCDMA cell that provides identity and measurement info.
28  */
29 public final class CellInfoWcdma extends CellInfo implements Parcelable {
30 
31     private static final String LOG_TAG = "CellInfoWcdma";
32     private static final boolean DBG = false;
33 
34     private CellIdentityWcdma mCellIdentityWcdma;
35     private CellSignalStrengthWcdma mCellSignalStrengthWcdma;
36 
37     /** @hide */
CellInfoWcdma()38     public CellInfoWcdma() {
39         super();
40         mCellIdentityWcdma = new CellIdentityWcdma();
41         mCellSignalStrengthWcdma = new CellSignalStrengthWcdma();
42     }
43 
44     /** @hide */
CellInfoWcdma(CellInfoWcdma ci)45     public CellInfoWcdma(CellInfoWcdma ci) {
46         super(ci);
47         this.mCellIdentityWcdma = ci.mCellIdentityWcdma.copy();
48         this.mCellSignalStrengthWcdma = ci.mCellSignalStrengthWcdma.copy();
49     }
50 
51     /** @hide */
CellInfoWcdma(int connectionStatus, boolean registered, long timeStamp, CellIdentityWcdma cellIdentityWcdma, CellSignalStrengthWcdma cellSignalStrengthWcdma)52     public CellInfoWcdma(int connectionStatus, boolean registered, long timeStamp,
53             CellIdentityWcdma cellIdentityWcdma, CellSignalStrengthWcdma cellSignalStrengthWcdma) {
54         super(connectionStatus, registered, timeStamp);
55         mCellIdentityWcdma = cellIdentityWcdma;
56         mCellSignalStrengthWcdma = cellSignalStrengthWcdma;
57     }
58 
59     /**
60      * @return a {@link CellIdentityWcdma} instance.
61      */
62     @Override
getCellIdentity()63     public CellIdentityWcdma getCellIdentity() {
64         return mCellIdentityWcdma;
65     }
66 
67     /** @hide */
setCellIdentity(CellIdentityWcdma cid)68     public void setCellIdentity(CellIdentityWcdma cid) {
69         mCellIdentityWcdma = cid;
70     }
71 
72     /**
73      * @return a {@link CellSignalStrengthWcdma} instance.
74      */
75     @Override
getCellSignalStrength()76     public CellSignalStrengthWcdma getCellSignalStrength() {
77         return mCellSignalStrengthWcdma;
78     }
79 
80     /** @hide */
81     @Override
sanitizeLocationInfo()82     public CellInfo sanitizeLocationInfo() {
83         CellInfoWcdma result = new CellInfoWcdma(this);
84         result.mCellIdentityWcdma = mCellIdentityWcdma.sanitizeLocationInfo();
85         return result;
86     }
87 
88     /** @hide */
setCellSignalStrength(CellSignalStrengthWcdma css)89     public void setCellSignalStrength(CellSignalStrengthWcdma css) {
90         mCellSignalStrengthWcdma = css;
91     }
92 
93     /**
94      * @return hash code
95      */
96     @Override
hashCode()97     public int hashCode() {
98         return Objects.hash(super.hashCode(), mCellIdentityWcdma, mCellSignalStrengthWcdma);
99     }
100 
101     @Override
equals(Object other)102     public boolean equals(Object other) {
103         if (!super.equals(other)) {
104             return false;
105         }
106         try {
107             CellInfoWcdma o = (CellInfoWcdma) other;
108             return mCellIdentityWcdma.equals(o.mCellIdentityWcdma)
109                     && mCellSignalStrengthWcdma.equals(o.mCellSignalStrengthWcdma);
110         } catch (ClassCastException e) {
111             return false;
112         }
113     }
114 
115     @Override
toString()116     public String toString() {
117         StringBuffer sb = new StringBuffer();
118 
119         sb.append("CellInfoWcdma:{");
120         sb.append(super.toString());
121         sb.append(" ").append(mCellIdentityWcdma);
122         sb.append(" ").append(mCellSignalStrengthWcdma);
123         sb.append("}");
124 
125         return sb.toString();
126     }
127 
128     /** Implement the Parcelable interface */
129     @Override
describeContents()130     public int describeContents() {
131         return 0;
132     }
133 
134     /** Implement the Parcelable interface */
135     @Override
writeToParcel(Parcel dest, int flags)136     public void writeToParcel(Parcel dest, int flags) {
137         super.writeToParcel(dest, flags, TYPE_WCDMA);
138         mCellIdentityWcdma.writeToParcel(dest, flags);
139         mCellSignalStrengthWcdma.writeToParcel(dest, flags);
140     }
141 
142     /**
143      * Construct a CellInfoWcdma object from the given parcel
144      * where the token is already been processed.
145      */
CellInfoWcdma(Parcel in)146     private CellInfoWcdma(Parcel in) {
147         super(in);
148         mCellIdentityWcdma = CellIdentityWcdma.CREATOR.createFromParcel(in);
149         mCellSignalStrengthWcdma = CellSignalStrengthWcdma.CREATOR.createFromParcel(in);
150     }
151 
152     /** Implement the Parcelable interface */
153     public static final @android.annotation.NonNull Creator<CellInfoWcdma> CREATOR = new Creator<CellInfoWcdma>() {
154         @Override
155         public CellInfoWcdma createFromParcel(Parcel in) {
156             in.readInt(); // Skip past token, we know what it is
157             return createFromParcelBody(in);
158         }
159 
160         @Override
161         public CellInfoWcdma[] newArray(int size) {
162             return new CellInfoWcdma[size];
163         }
164     };
165 
166     /** @hide */
createFromParcelBody(Parcel in)167     protected static CellInfoWcdma createFromParcelBody(Parcel in) {
168         return new CellInfoWcdma(in);
169     }
170 
171     /**
172      * log
173      */
log(String s)174     private static void log(String s) {
175         Rlog.w(LOG_TAG, s);
176     }
177 }
178