blob: 27187e68d5cc74d82bac0de0d51cebc999771eec [file] [log] [blame]
Wink Savillefb40dd42014-06-12 17:02:31 -07001/*
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
17package android.telephony;
18
Artur Satayev74cb7192019-12-10 17:47:56 +000019import android.compat.annotation.UnsupportedAppUsage;
Mathew Inwood31755f92018-12-20 13:53:36 +000020import android.os.Build;
Wink Savillefb40dd42014-06-12 17:02:31 -070021import android.os.Bundle;
22import android.os.Parcel;
23import android.os.Parcelable;
Wink Savillefb40dd42014-06-12 17:02:31 -070024
Meng Wang1dbea2f2020-01-30 12:25:08 -080025import com.android.telephony.Rlog;
26
Wink Savillefb40dd42014-06-12 17:02:31 -070027/**
28 * Contains LTE network state related information.
Brad Ebingerefed9822018-10-26 10:25:57 -070029 * @deprecated Only contains SRVCC state, which isn't specific to LTE handovers. For SRVCC
30 * indications, use {@link PhoneStateListener#onSrvccStateChanged(int)}.
Wink Savillefb40dd42014-06-12 17:02:31 -070031 * @hide
32 */
Brad Ebingerefed9822018-10-26 10:25:57 -070033@Deprecated
Wink Savillefb40dd42014-06-12 17:02:31 -070034public 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 C4eda57e2020-01-07 16:20:33 -080056 * This method is maybe used by external applications.
Wink Savillefb40dd42014-06-12 17:02:31 -070057 *
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 Inwood31755f92018-12-20 13:53:36 +000084 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Wink Savillefb40dd42014-06-12 17:02:31 -070085 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 Sharkey9e8f83d2019-02-28 12:06:45 -0700148 public static final @android.annotation.NonNull Parcelable.Creator<VoLteServiceState> CREATOR = new Parcelable.Creator() {
Wink Savillefb40dd42014-06-12 17:02:31 -0700149 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}