• 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.annotation.FlaggedApi;
20 import android.annotation.NonNull;
21 import android.compat.annotation.UnsupportedAppUsage;
22 import android.os.Build;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 
26 import com.android.internal.telephony.flags.Flags;
27 import com.android.telephony.Rlog;
28 
29 /**
30  * A {@link CellInfo} representing a CDMA cell that provides identity and measurement info.
31  *
32  * @deprecated Legacy CDMA is unsupported.
33  */
34 @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
35 @Deprecated
36 public final class CellInfoCdma extends CellInfo implements Parcelable {
37 
38     private static final String LOG_TAG = "CellInfoCdma";
39     private static final boolean DBG = false;
40 
41     private CellIdentityCdma mCellIdentityCdma;
42     private CellSignalStrengthCdma mCellSignalStrengthCdma;
43 
44     /** @hide */
45     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
CellInfoCdma()46     public CellInfoCdma() {
47         super();
48         mCellIdentityCdma = new CellIdentityCdma();
49         mCellSignalStrengthCdma = new CellSignalStrengthCdma();
50     }
51 
52     /** @hide */
53     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
CellInfoCdma(CellInfoCdma ci)54     public CellInfoCdma(CellInfoCdma ci) {
55         super(ci);
56         this.mCellIdentityCdma = ci.mCellIdentityCdma.copy();
57         this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy();
58     }
59 
60     /** @hide */
CellInfoCdma(int connectionStatus, boolean registered, long timeStamp, CellIdentityCdma cellIdentityCdma, CellSignalStrengthCdma cellSignalStrengthCdma)61     public CellInfoCdma(int connectionStatus, boolean registered, long timeStamp,
62             CellIdentityCdma cellIdentityCdma, CellSignalStrengthCdma cellSignalStrengthCdma) {
63         super(connectionStatus, registered, timeStamp);
64         mCellIdentityCdma = cellIdentityCdma;
65         mCellSignalStrengthCdma = cellSignalStrengthCdma;
66     }
67 
68     /**
69      * @return a {@link CellIdentityCdma} instance.
70      * @deprecated Legacy CDMA is unsupported.
71      */
72     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
73     @Deprecated
74     @Override
getCellIdentity()75     public @NonNull CellIdentityCdma getCellIdentity() {
76         return mCellIdentityCdma;
77     }
78 
79     /** @hide */
80     @UnsupportedAppUsage
setCellIdentity(CellIdentityCdma cid)81     public void setCellIdentity(CellIdentityCdma cid) {
82         mCellIdentityCdma = cid;
83     }
84 
85     /**
86      * @return a {@link CellSignalStrengthCdma} instance.
87      * @deprecated Legacy CDMA is unsupported.
88      */
89     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
90     @Deprecated
91     @Override
getCellSignalStrength()92     public @NonNull CellSignalStrengthCdma getCellSignalStrength() {
93         return mCellSignalStrengthCdma;
94     }
95 
96     /** @hide */
97     @Override
sanitizeLocationInfo()98     public CellInfo sanitizeLocationInfo() {
99         CellInfoCdma result = new CellInfoCdma(this);
100         result.mCellIdentityCdma = mCellIdentityCdma.sanitizeLocationInfo();
101         return result;
102     }
103 
104     /** @hide */
setCellSignalStrength(CellSignalStrengthCdma css)105     public void setCellSignalStrength(CellSignalStrengthCdma css) {
106         mCellSignalStrengthCdma = css;
107     }
108 
109     /**
110      * @return hash code
111      */
112     @Override
hashCode()113     public int hashCode() {
114         return super.hashCode() + mCellIdentityCdma.hashCode() + mCellSignalStrengthCdma.hashCode();
115     }
116 
117     @Override
equals(Object other)118     public boolean equals(Object other) {
119         if (!super.equals(other)) {
120             return false;
121         }
122         try {
123             CellInfoCdma o = (CellInfoCdma) other;
124             return mCellIdentityCdma.equals(o.mCellIdentityCdma)
125                     && mCellSignalStrengthCdma.equals(o.mCellSignalStrengthCdma);
126         } catch (ClassCastException e) {
127             return false;
128         }
129     }
130 
131     @Override
toString()132     public String toString() {
133         StringBuffer sb = new StringBuffer();
134 
135         sb.append("CellInfoCdma:{");
136         sb.append(super.toString());
137         sb.append(" ").append(mCellIdentityCdma);
138         sb.append(" ").append(mCellSignalStrengthCdma);
139         sb.append("}");
140 
141         return sb.toString();
142     }
143 
144     /** Implement the Parcelable interface */
145     @Override
describeContents()146     public int describeContents() {
147         return 0;
148     }
149 
150     /**
151      * Implement the Parcelable interface
152      * @deprecated Legacy CDMA is unsupported.
153      */
154     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
155     @Deprecated
156     @Override
writeToParcel(Parcel dest, int flags)157     public void writeToParcel(Parcel dest, int flags) {
158         super.writeToParcel(dest, flags, TYPE_CDMA);
159         mCellIdentityCdma.writeToParcel(dest, flags);
160         mCellSignalStrengthCdma.writeToParcel(dest, flags);
161     }
162 
163     /**
164      * Construct a CellInfoCdma object from the given parcel
165      * where the token is already been processed.
166      */
CellInfoCdma(Parcel in)167     private CellInfoCdma(Parcel in) {
168         super(in);
169         mCellIdentityCdma = CellIdentityCdma.CREATOR.createFromParcel(in);
170         mCellSignalStrengthCdma = CellSignalStrengthCdma.CREATOR.createFromParcel(in);
171         if (DBG) log("CellInfoCdma(Parcel): " + toString());
172     }
173 
174     /**
175      * Implement the Parcelable interface
176      * @deprecated Legacy CDMA is unsupported.
177      */
178     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
179     @Deprecated
180     public static final @android.annotation.NonNull Creator<CellInfoCdma> CREATOR = new Creator<CellInfoCdma>() {
181         @Override
182         public CellInfoCdma createFromParcel(Parcel in) {
183             in.readInt(); // Skip past token, we know what it is
184             return createFromParcelBody(in);
185         }
186 
187         @Override
188         public CellInfoCdma[] newArray(int size) {
189             return new CellInfoCdma[size];
190         }
191     };
192 
193     /** @hide */
createFromParcelBody(Parcel in)194     protected static CellInfoCdma createFromParcelBody(Parcel in) {
195         return new CellInfoCdma(in);
196     }
197 
198     /**
199      * log
200      */
log(String s)201     private static void log(String s) {
202         Rlog.w(LOG_TAG, s);
203     }
204 }
205