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 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 21 | import android.telephony.Rlog; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
Nathan Harold | 054b79d | 2018-03-28 08:39:43 -0700 | [diff] [blame] | 24 | * A {@link CellInfo} representing an LTE cell that provides identity and measurement info. |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 25 | */ |
| 26 | public final class CellInfoLte extends CellInfo implements Parcelable { |
| 27 | |
| 28 | private static final String LOG_TAG = "CellInfoLte"; |
Wink Saville | e2c5081 | 2013-02-12 10:47:32 -0800 | [diff] [blame] | 29 | private static final boolean DBG = false; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 30 | |
| 31 | private CellIdentityLte mCellIdentityLte; |
| 32 | private CellSignalStrengthLte mCellSignalStrengthLte; |
| 33 | |
| 34 | /** @hide */ |
| 35 | public CellInfoLte() { |
| 36 | super(); |
| 37 | mCellIdentityLte = new CellIdentityLte(); |
| 38 | mCellSignalStrengthLte = new CellSignalStrengthLte(); |
| 39 | } |
| 40 | |
| 41 | /** @hide */ |
| 42 | public CellInfoLte(CellInfoLte ci) { |
| 43 | super(ci); |
| 44 | this.mCellIdentityLte = ci.mCellIdentityLte.copy(); |
| 45 | this.mCellSignalStrengthLte = ci.mCellSignalStrengthLte.copy(); |
| 46 | } |
| 47 | |
Nathan Harold | 7b3f7a4 | 2018-07-09 11:59:53 -0700 | [diff] [blame] | 48 | @Override |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 49 | public CellIdentityLte getCellIdentity() { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 50 | if (DBG) log("getCellIdentity: " + mCellIdentityLte); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 51 | return mCellIdentityLte; |
| 52 | } |
| 53 | /** @hide */ |
| 54 | public void setCellIdentity(CellIdentityLte cid) { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 55 | if (DBG) log("setCellIdentity: " + cid); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 56 | mCellIdentityLte = cid; |
| 57 | } |
| 58 | |
Nathan Harold | 7b3f7a4 | 2018-07-09 11:59:53 -0700 | [diff] [blame] | 59 | @Override |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 60 | public CellSignalStrengthLte getCellSignalStrength() { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 61 | if (DBG) log("getCellSignalStrength: " + mCellSignalStrengthLte); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 62 | return mCellSignalStrengthLte; |
| 63 | } |
| 64 | /** @hide */ |
| 65 | public void setCellSignalStrength(CellSignalStrengthLte css) { |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 66 | if (DBG) log("setCellSignalStrength: " + css); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 67 | mCellSignalStrengthLte = css; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @return hash code |
| 72 | */ |
| 73 | @Override |
| 74 | public int hashCode() { |
| 75 | return super.hashCode() + mCellIdentityLte.hashCode() + mCellSignalStrengthLte.hashCode(); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public boolean equals(Object other) { |
| 80 | if (!super.equals(other)) { |
| 81 | return false; |
| 82 | } |
| 83 | try { |
| 84 | CellInfoLte o = (CellInfoLte) other; |
| 85 | return mCellIdentityLte.equals(o.mCellIdentityLte) |
| 86 | && mCellSignalStrengthLte.equals(o.mCellSignalStrengthLte); |
| 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("CellInfoLte:{"); |
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(mCellIdentityLte); |
| 99 | sb.append(" ").append(mCellSignalStrengthLte); |
| 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) { |
| 114 | if (DBG) log("writeToParcel(Parcel, int): " + toString()); |
Wink Saville | c6e4917a | 2012-09-21 13:54:05 -0700 | [diff] [blame] | 115 | super.writeToParcel(dest, flags, TYPE_LTE); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 116 | mCellIdentityLte.writeToParcel(dest, flags); |
| 117 | mCellSignalStrengthLte.writeToParcel(dest, flags); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Construct a CellInfoLte object from the given parcel |
| 122 | * where the TYPE_LTE token is already been processed. |
| 123 | */ |
| 124 | private CellInfoLte(Parcel in) { |
| 125 | super(in); |
| 126 | mCellIdentityLte = CellIdentityLte.CREATOR.createFromParcel(in); |
| 127 | mCellSignalStrengthLte = CellSignalStrengthLte.CREATOR.createFromParcel(in); |
| 128 | if (DBG) log("CellInfoLte(Parcel): " + toString()); |
| 129 | } |
| 130 | |
| 131 | /** Implement the Parcelable interface */ |
| 132 | public static final Creator<CellInfoLte> CREATOR = new Creator<CellInfoLte>() { |
| 133 | @Override |
| 134 | public CellInfoLte createFromParcel(Parcel in) { |
| 135 | in.readInt(); // Skip past token, we know what it is |
| 136 | return createFromParcelBody(in); |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public CellInfoLte[] newArray(int size) { |
| 141 | return new CellInfoLte[size]; |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | /** @hide */ |
| 146 | protected static CellInfoLte createFromParcelBody(Parcel in) { |
| 147 | return new CellInfoLte(in); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * log |
| 152 | */ |
| 153 | private static void log(String s) { |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 154 | Rlog.w(LOG_TAG, s); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 155 | } |
| 156 | } |