Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 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 | |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 19 | import android.annotation.UnsupportedAppUsage; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 22 | import android.telephony.Rlog; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
Nathan Harold | 88f4402 | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 25 | * A {@link CellInfo} representing a CDMA cell that provides identity and measurement info. |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 26 | */ |
| 27 | public 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 Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 36 | @UnsupportedAppUsage |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 37 | public CellInfoCdma() { |
| 38 | super(); |
| 39 | mCellIdentityCdma = new CellIdentityCdma(); |
| 40 | mCellSignalStrengthCdma = new CellSignalStrengthCdma(); |
| 41 | } |
| 42 | |
| 43 | /** @hide */ |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 44 | @UnsupportedAppUsage |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 45 | public CellInfoCdma(CellInfoCdma ci) { |
| 46 | super(ci); |
| 47 | this.mCellIdentityCdma = ci.mCellIdentityCdma.copy(); |
| 48 | this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy(); |
| 49 | } |
| 50 | |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 51 | @Override |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 52 | public CellIdentityCdma getCellIdentity() { |
| 53 | return mCellIdentityCdma; |
| 54 | } |
| 55 | /** @hide */ |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 56 | @UnsupportedAppUsage |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 57 | public void setCellIdentity(CellIdentityCdma cid) { |
| 58 | mCellIdentityCdma = cid; |
| 59 | } |
| 60 | |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 61 | @Override |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 62 | 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 Saville | 094beec | 2013-04-05 15:03:31 -0700 | [diff] [blame] | 96 | sb.append("CellInfoCdma:{"); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 97 | sb.append(super.toString()); |
Wink Saville | 094beec | 2013-04-05 15:03:31 -0700 | [diff] [blame] | 98 | sb.append(" ").append(mCellIdentityCdma); |
| 99 | sb.append(" ").append(mCellSignalStrengthCdma); |
| 100 | sb.append("}"); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 101 | |
| 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 Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 114 | super.writeToParcel(dest, flags, TYPE_CDMA); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 115 | 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 Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 153 | Rlog.w(LOG_TAG, s); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 154 | } |
| 155 | } |