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 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.os.Build; 21 import android.os.Bundle; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 25 import com.android.telephony.Rlog; 26 27 /** 28 * Contains LTE network state related information. 29 * @deprecated Only contains SRVCC state, which isn't specific to LTE handovers. For SRVCC 30 * indications, use {@link PhoneStateListener#onSrvccStateChanged(int)}. 31 * @hide 32 */ 33 @Deprecated 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 * 56 * This method is maybe used by external applications. 57 * 58 * @param m Bundle from intent notifier 59 * @return newly created VoLteServiceState 60 * 61 * @hide 62 */ newFromBundle(Bundle m)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 */ VoLteServiceState()75 public VoLteServiceState() { 76 initialize(); 77 } 78 79 /** 80 * Constructor 81 * 82 * @hide 83 */ 84 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) VoLteServiceState(int srvccState)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 */ VoLteServiceState(VoLteServiceState s)98 public VoLteServiceState(VoLteServiceState s) { 99 copyFrom(s); 100 } 101 102 /** 103 * Initialize values to defaults. 104 * 105 * @hide 106 */ initialize()107 private void initialize() { 108 mSrvccState = INVALID; 109 } 110 111 /** 112 * @hide 113 */ copyFrom(VoLteServiceState s)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 */ VoLteServiceState(Parcel in)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 */ writeToParcel(Parcel out, int flags)132 public void writeToParcel(Parcel out, int flags) { 133 out.writeInt(mSrvccState); 134 } 135 136 /** 137 * {@link Parcelable#describeContents} 138 */ describeContents()139 public int describeContents() { 140 return 0; 141 } 142 143 /** 144 * {@link Parcelable.Creator} 145 * 146 * @hide 147 */ 148 public static final @android.annotation.NonNull Parcelable.Creator<VoLteServiceState> CREATOR = new Parcelable.Creator() { 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 */ validateInput()167 public void validateInput() { 168 } 169 hashCode()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 equals(Object o)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 toString()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 */ setFromNotifierBundle(Bundle m)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 */ fillInNotifierBundle(Bundle m)220 public void fillInNotifierBundle(Bundle m) { 221 m.putInt("mSrvccState", mSrvccState); 222 } 223 getSrvccState()224 public int getSrvccState() { 225 return mSrvccState; 226 } 227 228 /** 229 * log 230 */ log(String s)231 private static void log(String s) { 232 Rlog.w(LOG_TAG, s); 233 } 234 } 235