Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
Artur Satayev | 74cb719 | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 20 | import android.os.Build; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 21 | import android.os.Bundle; |
| 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 24 | |
Meng Wang | 1dbea2f | 2020-01-30 12:25:08 -0800 | [diff] [blame] | 25 | import com.android.telephony.Rlog; |
| 26 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Contains LTE network state related information. |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 29 | * @deprecated Only contains SRVCC state, which isn't specific to LTE handovers. For SRVCC |
| 30 | * indications, use {@link PhoneStateListener#onSrvccStateChanged(int)}. |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 31 | * @hide |
| 32 | */ |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 33 | @Deprecated |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 34 | public final class VoLteServiceState implements Parcelable { |
| 35 | |
| 36 | private static final String LOG_TAG = "VoLteServiceState"; |
| 37 | private static final boolean DBG = false; |
| 38 | |
| 39 | //Use int max, as -1 is a valid value in signal strength |
| 40 | public static final int INVALID = 0x7FFFFFFF; |
| 41 | |
| 42 | public static final int NOT_SUPPORTED = 0; |
| 43 | public static final int SUPPORTED = 1; |
| 44 | |
| 45 | // Single Radio Voice Call Continuity(SRVCC) progress state |
| 46 | public static final int HANDOVER_STARTED = 0; |
| 47 | public static final int HANDOVER_COMPLETED = 1; |
| 48 | public static final int HANDOVER_FAILED = 2; |
| 49 | public static final int HANDOVER_CANCELED = 3; |
| 50 | |
| 51 | private int mSrvccState; |
| 52 | |
| 53 | /** |
| 54 | * Create a new VoLteServiceState from a intent notifier Bundle |
| 55 | * |
Jayachandran C | 4eda57e | 2020-01-07 16:20:33 -0800 | [diff] [blame] | 56 | * This method is maybe used by external applications. |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 57 | * |
| 58 | * @param m Bundle from intent notifier |
| 59 | * @return newly created VoLteServiceState |
| 60 | * |
| 61 | * @hide |
| 62 | */ |
| 63 | public static VoLteServiceState newFromBundle(Bundle m) { |
| 64 | VoLteServiceState ret; |
| 65 | ret = new VoLteServiceState(); |
| 66 | ret.setFromNotifierBundle(m); |
| 67 | return ret; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Empty constructor |
| 72 | * |
| 73 | * @hide |
| 74 | */ |
| 75 | public VoLteServiceState() { |
| 76 | initialize(); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Constructor |
| 81 | * |
| 82 | * @hide |
| 83 | */ |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 84 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 85 | public VoLteServiceState(int srvccState) { |
| 86 | initialize(); |
| 87 | |
| 88 | mSrvccState = srvccState; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Copy constructors |
| 93 | * |
| 94 | * @param s Source VoLteServiceState |
| 95 | * |
| 96 | * @hide |
| 97 | */ |
| 98 | public VoLteServiceState(VoLteServiceState s) { |
| 99 | copyFrom(s); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Initialize values to defaults. |
| 104 | * |
| 105 | * @hide |
| 106 | */ |
| 107 | private void initialize() { |
| 108 | mSrvccState = INVALID; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * @hide |
| 113 | */ |
| 114 | protected void copyFrom(VoLteServiceState s) { |
| 115 | mSrvccState = s.mSrvccState; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Construct a VoLteServiceState object from the given parcel. |
| 120 | * |
| 121 | * @hide |
| 122 | */ |
| 123 | public VoLteServiceState(Parcel in) { |
| 124 | if (DBG) log("Size of VoLteServiceState parcel:" + in.dataSize()); |
| 125 | |
| 126 | mSrvccState = in.readInt(); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * {@link Parcelable#writeToParcel} |
| 131 | */ |
| 132 | public void writeToParcel(Parcel out, int flags) { |
| 133 | out.writeInt(mSrvccState); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * {@link Parcelable#describeContents} |
| 138 | */ |
| 139 | public int describeContents() { |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * {@link Parcelable.Creator} |
| 145 | * |
| 146 | * @hide |
| 147 | */ |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 148 | public static final @android.annotation.NonNull Parcelable.Creator<VoLteServiceState> CREATOR = new Parcelable.Creator() { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 149 | public VoLteServiceState createFromParcel(Parcel in) { |
| 150 | return new VoLteServiceState(in); |
| 151 | } |
| 152 | |
| 153 | public VoLteServiceState[] newArray(int size) { |
| 154 | return new VoLteServiceState[size]; |
| 155 | } |
| 156 | }; |
| 157 | |
| 158 | /** |
| 159 | * Validate the individual fields as per the range |
| 160 | * specified in ril.h |
| 161 | * Set to invalid any field that is not in the valid range |
| 162 | * |
| 163 | * @return |
| 164 | * Valid values for all fields |
| 165 | * @hide |
| 166 | */ |
| 167 | public void validateInput() { |
| 168 | } |
| 169 | |
| 170 | public int hashCode() { |
| 171 | int primeNum = 31; |
| 172 | return ((mSrvccState * primeNum)); |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * @return true if the LTE network states are the same |
| 177 | */ |
| 178 | @Override |
| 179 | public boolean equals (Object o) { |
| 180 | VoLteServiceState s; |
| 181 | |
| 182 | try { |
| 183 | s = (VoLteServiceState) o; |
| 184 | } catch (ClassCastException ex) { |
| 185 | return false; |
| 186 | } |
| 187 | |
| 188 | if (o == null) { |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | return (mSrvccState == s.mSrvccState); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * @return string representation. |
| 197 | */ |
| 198 | @Override |
| 199 | public String toString() { |
| 200 | return ("VoLteServiceState:" |
| 201 | + " " + mSrvccState); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Set VoLteServiceState based on intent notifier map |
| 206 | * |
| 207 | * @param m intent notifier map |
| 208 | * @hide |
| 209 | */ |
| 210 | private void setFromNotifierBundle(Bundle m) { |
| 211 | mSrvccState = m.getInt("mSrvccState"); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Set intent notifier Bundle based on VoLteServiceState |
| 216 | * |
| 217 | * @param m intent notifier Bundle |
| 218 | * @hide |
| 219 | */ |
| 220 | public void fillInNotifierBundle(Bundle m) { |
| 221 | m.putInt("mSrvccState", mSrvccState); |
| 222 | } |
| 223 | |
| 224 | public int getSrvccState() { |
| 225 | return mSrvccState; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * log |
| 230 | */ |
| 231 | private static void log(String s) { |
| 232 | Rlog.w(LOG_TAG, s); |
| 233 | } |
| 234 | } |