blob: 303a9fee50bee718f09a9eeaddd4c98aa80bffd0 [file] [log] [blame]
Wink Savillef8458ff2014-06-25 16:08:02 -07001/*
Brad Ebinger0e370b42018-01-22 13:51:52 -08002 * Copyright (C) 2018 The Android Open Source Project
Wink Savillef8458ff2014-06-25 16:08:02 -07003 *
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
Brad Ebinger0e370b42018-01-22 13:51:52 -080014 * limitations under the License
Wink Savillef8458ff2014-06-25 16:08:02 -070015 */
16
Brad Ebinger0e370b42018-01-22 13:51:52 -080017package android.telephony.ims;
Wink Savillef8458ff2014-06-25 16:08:02 -070018
Ashit Sood51832a72018-05-02 11:25:22 -070019import android.annotation.IntDef;
Brad Ebinger4123f952018-10-11 16:21:22 -070020import android.annotation.NonNull;
21import android.annotation.Nullable;
Brad Ebinger0e370b42018-01-22 13:51:52 -080022import android.annotation.SystemApi;
Mathew Inwooda8382062018-08-16 17:01:12 +010023import android.annotation.UnsupportedAppUsage;
Wink Savillef8458ff2014-06-25 16:08:02 -070024import android.os.Parcel;
25import android.os.Parcelable;
26
Ashit Sood51832a72018-05-02 11:25:22 -070027import java.lang.annotation.Retention;
28import java.lang.annotation.RetentionPolicy;
29
Wink Savillef8458ff2014-06-25 16:08:02 -070030/**
31 * Provides the result to the update operation for the supplementary service configuration.
32 *
Brad Ebinger4123f952018-10-11 16:21:22 -070033 * Also supports IMS specific Incoming Communication Barring (ICB) as well as Anonymous
34 * Communication Rejection (ACR), as per 3GPP 24.611.
35 *
36 * @see Builder
Wink Savillef8458ff2014-06-25 16:08:02 -070037 * @hide
38 */
Brad Ebinger0e370b42018-01-22 13:51:52 -080039@SystemApi
40public final class ImsSsInfo implements Parcelable {
Brad Ebinger4123f952018-10-11 16:21:22 -070041
42 /**@hide*/
43 @IntDef(value = {
44 NOT_REGISTERED,
45 DISABLED,
46 ENABLED
47 })
48 @Retention(RetentionPolicy.SOURCE)
49 public @interface ServiceStatus {}
50
Wink Savillef8458ff2014-06-25 16:08:02 -070051 /**
52 * For the status of service registration or activation/deactivation.
53 */
54 public static final int NOT_REGISTERED = (-1);
55 public static final int DISABLED = 0;
56 public static final int ENABLED = 1;
57
Ashit Sood51832a72018-05-02 11:25:22 -070058 /**
Brad Ebinger4123f952018-10-11 16:21:22 -070059 * Provision status of service.
60 * @hide
Ashit Sood51832a72018-05-02 11:25:22 -070061 */
Brad Ebinger4123f952018-10-11 16:21:22 -070062 @IntDef(value = {
Ashit Sood51832a72018-05-02 11:25:22 -070063 SERVICE_PROVISIONING_UNKNOWN,
64 SERVICE_NOT_PROVISIONED,
65 SERVICE_PROVISIONED
Brad Ebinger4123f952018-10-11 16:21:22 -070066 }, prefix = "SERVICE_")
Ashit Sood51832a72018-05-02 11:25:22 -070067 @Retention(RetentionPolicy.SOURCE)
68 public @interface ServiceProvisionStatus {}
Brad Ebinger4123f952018-10-11 16:21:22 -070069
Ashit Sood51832a72018-05-02 11:25:22 -070070 /**
71 * Unknown provision status for the service.
72 */
73 public static final int SERVICE_PROVISIONING_UNKNOWN = (-1);
Brad Ebinger4123f952018-10-11 16:21:22 -070074
Ashit Sood51832a72018-05-02 11:25:22 -070075 /**
76 * Service is not provisioned.
77 */
78 public static final int SERVICE_NOT_PROVISIONED = 0;
Brad Ebinger4123f952018-10-11 16:21:22 -070079
Ashit Sood51832a72018-05-02 11:25:22 -070080 /**
81 * Service is provisioned.
82 */
83 public static final int SERVICE_PROVISIONED = 1;
84
Brad Ebingerc9a6aab2018-11-29 17:02:35 -080085 /**@hide*/
Brad Ebinger4123f952018-10-11 16:21:22 -070086 @IntDef(value = {
87 CLIR_OUTGOING_DEFAULT,
88 CLIR_OUTGOING_INVOCATION,
89 CLIR_OUTGOING_SUPPRESSION
90 }, prefix = "CLIR_OUTGOING_")
91 @Retention(RetentionPolicy.SOURCE)
92 public @interface ClirOutgoingState {}
93
94 /**
95 * Calling line identification restriction (CLIR) is set to the default according to the
96 * subscription of the CLIR service.
97 *
98 * See TS 27.007, section 7.7 for more information.
99 */
100 public static final int CLIR_OUTGOING_DEFAULT = 0;
101 /**
102 * Activate Calling line identification restriction for outgoing calls.
103 *
104 * See TS 27.007, section 7.7 for more information.
105 */
106 public static final int CLIR_OUTGOING_INVOCATION = 1;
107 /**
108 * Deactivate Calling line identification restriction for outgoing calls.
109 *
110 * See TS 27.007, section 7.7 for more information.
111 */
112 public static final int CLIR_OUTGOING_SUPPRESSION = 2;
113
114 /**
115 * Calling line identification restriction is currently not provisioned.
116 *
117 * See TS 27.007, section 7.7 for more information.
118 */
119 public static final int CLIR_STATUS_NOT_PROVISIONED = 0;
120 /**
121 * Calling line identification restriction is currently provisioned in permanent mode.
122 *
123 * See TS 27.007, section 7.7 for more information.
124 */
125 public static final int CLIR_STATUS_PROVISIONED_PERMANENT = 1;
126 /**
127 * Calling line identification restriction is currently unknown, e.g. no network, etc.
128 *
129 * See TS 27.007, section 7.7 for more information.
130 */
131 public static final int CLIR_STATUS_UNKNOWN = 2;
132 /**
133 * Calling line identification restriction temporary mode, temporarily restricted.
134 *
135 * See TS 27.007, section 7.7 for more information.
136 */
137 public static final int CLIR_STATUS_TEMPORARILY_RESTRICTED = 3;
138 /**
139 * Calling line identification restriction temporary mode, temporarily allowed.
140 *
141 * See TS 27.007, section 7.7 for more information.
142 */
143 public static final int CLIR_STATUS_TEMPORARILY_ALLOWED = 4;
144
Brad Ebingerc9a6aab2018-11-29 17:02:35 -0800145 /**@hide*/
Brad Ebinger4123f952018-10-11 16:21:22 -0700146 @IntDef(value = {
147 CLIR_STATUS_NOT_PROVISIONED,
148 CLIR_STATUS_PROVISIONED_PERMANENT,
149 CLIR_STATUS_UNKNOWN,
150 CLIR_STATUS_TEMPORARILY_RESTRICTED,
151 CLIR_STATUS_TEMPORARILY_ALLOWED
152 }, prefix = "CLIR_STATUS_")
153 @Retention(RetentionPolicy.SOURCE)
154 public @interface ClirInterrogationStatus {}
155
Wink Savillef8458ff2014-06-25 16:08:02 -0700156 // 0: disabled, 1: enabled
Brad Ebinger0e370b42018-01-22 13:51:52 -0800157 /** @hide */
Mathew Inwooda8382062018-08-16 17:01:12 +0100158 @UnsupportedAppUsage
Wink Savillef8458ff2014-06-25 16:08:02 -0700159 public int mStatus;
Brad Ebinger0e370b42018-01-22 13:51:52 -0800160 /** @hide */
Mathew Inwooda8382062018-08-16 17:01:12 +0100161 @UnsupportedAppUsage
Shriram Ganeshddf570e2015-05-31 09:18:48 -0700162 public String mIcbNum;
Ashit Sood51832a72018-05-02 11:25:22 -0700163 /** @hide */
164 public int mProvisionStatus = SERVICE_PROVISIONING_UNKNOWN;
Brad Ebinger4123f952018-10-11 16:21:22 -0700165 private int mClirInterrogationStatus = CLIR_STATUS_UNKNOWN;
166 private int mClirOutgoingState = CLIR_OUTGOING_DEFAULT;
Wink Savillef8458ff2014-06-25 16:08:02 -0700167
Brad Ebinger4ae252f2018-03-29 11:12:24 -0700168 /**@hide*/
Mathew Inwooda8382062018-08-16 17:01:12 +0100169 @UnsupportedAppUsage
Wink Savillef8458ff2014-06-25 16:08:02 -0700170 public ImsSsInfo() {
171 }
172
Brad Ebinger4ae252f2018-03-29 11:12:24 -0700173 /**
Brad Ebinger4123f952018-10-11 16:21:22 -0700174 * Builds {@link ImsSsInfo} instances, which may include optional parameters.
Brad Ebinger4ae252f2018-03-29 11:12:24 -0700175 */
Brad Ebinger4123f952018-10-11 16:21:22 -0700176 public static class Builder {
177
178 private final ImsSsInfo mImsSsInfo;
179
180 public Builder(@ServiceStatus int status) {
181 mImsSsInfo = new ImsSsInfo();
182 mImsSsInfo.mStatus = status;
183 }
184
185 /**
186 * Set the ICB number for IMS call barring.
187 * @param number The number in E.164 international format.
188 */
Brad Ebingerc9a6aab2018-11-29 17:02:35 -0800189 public @NonNull Builder setIncomingCommunicationBarringNumber(@NonNull String number) {
Brad Ebinger4123f952018-10-11 16:21:22 -0700190 mImsSsInfo.mIcbNum = number;
191 return this;
192 }
193
194 /**
195 * Set the provisioning status for a Supplementary Service interrogation response.
196 */
Brad Ebingerc9a6aab2018-11-29 17:02:35 -0800197 public @NonNull Builder setProvisionStatus(@ServiceProvisionStatus int provisionStatus) {
Brad Ebinger4123f952018-10-11 16:21:22 -0700198 mImsSsInfo.mProvisionStatus = provisionStatus;
199 return this;
200 }
201
202 /**
203 * Set the Calling Line Identification Restriction (CLIR) status for a supplementary service
204 * interrogation response.
205 */
Brad Ebingerc9a6aab2018-11-29 17:02:35 -0800206 public @NonNull Builder setClirInterrogationStatus(@ClirInterrogationStatus int status) {
Brad Ebinger4123f952018-10-11 16:21:22 -0700207 mImsSsInfo.mClirInterrogationStatus = status;
208 return this;
209 }
210
211 /**
212 * Set the Calling line identification Restriction (CLIR) state for outgoing calls.
213 */
Brad Ebingerc9a6aab2018-11-29 17:02:35 -0800214 public @NonNull Builder setClirOutgoingState(@ClirOutgoingState int state) {
Brad Ebinger4123f952018-10-11 16:21:22 -0700215 mImsSsInfo.mClirOutgoingState = state;
216 return this;
217 }
218
219 /**
220 * @return a built {@link ImsSsInfo} containing optional the parameters that were set.
221 */
Brad Ebingerc9a6aab2018-11-29 17:02:35 -0800222 public @NonNull ImsSsInfo build() {
Brad Ebinger4123f952018-10-11 16:21:22 -0700223 return mImsSsInfo;
224 }
225 }
226
227 /**
228 *
229 * @param status The status of the service registration of activation/deactiviation.
230 * @param icbNum The Incoming barring number.
231 * @deprecated use {@link ImsSsInfo.Builder} instead.
232 */
233 @Deprecated
234 public ImsSsInfo(@ServiceStatus int status, @Nullable String icbNum) {
Brad Ebinger4ae252f2018-03-29 11:12:24 -0700235 mStatus = status;
236 mIcbNum = icbNum;
237 }
238
Brad Ebinger0e370b42018-01-22 13:51:52 -0800239 private ImsSsInfo(Parcel in) {
Wink Savillef8458ff2014-06-25 16:08:02 -0700240 readFromParcel(in);
241 }
242
243 @Override
244 public int describeContents() {
245 return 0;
246 }
247
248 @Override
249 public void writeToParcel(Parcel out, int flags) {
250 out.writeInt(mStatus);
Shriram Ganeshddf570e2015-05-31 09:18:48 -0700251 out.writeString(mIcbNum);
Ashit Sood51832a72018-05-02 11:25:22 -0700252 out.writeInt(mProvisionStatus);
Wink Savillef8458ff2014-06-25 16:08:02 -0700253 }
254
255 @Override
256 public String toString() {
Ashit Sood51832a72018-05-02 11:25:22 -0700257 return super.toString() + ", Status: " + ((mStatus == 0) ? "disabled" : "enabled")
258 + ", ProvisionStatus: " + provisionStatusToString(mProvisionStatus);
259 }
260
261 private static String provisionStatusToString(int pStatus) {
262 switch (pStatus) {
263 case SERVICE_NOT_PROVISIONED:
264 return "Service not provisioned";
265 case SERVICE_PROVISIONED:
266 return "Service provisioned";
267 default:
268 return "Service provisioning unknown";
269 }
Wink Savillef8458ff2014-06-25 16:08:02 -0700270 }
271
272 private void readFromParcel(Parcel in) {
273 mStatus = in.readInt();
Shriram Ganeshddf570e2015-05-31 09:18:48 -0700274 mIcbNum = in.readString();
Ashit Sood51832a72018-05-02 11:25:22 -0700275 mProvisionStatus = in.readInt();
Wink Savillef8458ff2014-06-25 16:08:02 -0700276 }
277
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700278 public static final @android.annotation.NonNull Creator<ImsSsInfo> CREATOR =
Wink Savillef8458ff2014-06-25 16:08:02 -0700279 new Creator<ImsSsInfo>() {
280 @Override
281 public ImsSsInfo createFromParcel(Parcel in) {
282 return new ImsSsInfo(in);
283 }
284
285 @Override
286 public ImsSsInfo[] newArray(int size) {
287 return new ImsSsInfo[size];
288 }
289 };
Brad Ebinger0e370b42018-01-22 13:51:52 -0800290
Brad Ebinger4ae252f2018-03-29 11:12:24 -0700291 /**
Brad Ebinger4123f952018-10-11 16:21:22 -0700292 * @return Supplementary Service Configuration status.
Brad Ebinger4ae252f2018-03-29 11:12:24 -0700293 */
Brad Ebinger4123f952018-10-11 16:21:22 -0700294 public @ServiceStatus int getStatus() {
Brad Ebinger0e370b42018-01-22 13:51:52 -0800295 return mStatus;
296 }
297
Brad Ebinger4123f952018-10-11 16:21:22 -0700298 /** @deprecated Use {@link #getIncomingCommunicationBarringNumber()} instead.*/
299 @Deprecated
Brad Ebinger0e370b42018-01-22 13:51:52 -0800300 public String getIcbNum() {
301 return mIcbNum;
302 }
Ashit Sood51832a72018-05-02 11:25:22 -0700303
304 /**
Brad Ebinger4123f952018-10-11 16:21:22 -0700305 * @return The Incoming Communication Barring (ICB) number.
Ashit Sood51832a72018-05-02 11:25:22 -0700306 */
Brad Ebinger4123f952018-10-11 16:21:22 -0700307 public String getIncomingCommunicationBarringNumber() {
308 return mIcbNum;
309 }
310
311 /**
312 * @return Supplementary Service Provision status.
313 */
314 public @ServiceProvisionStatus int getProvisionStatus() {
Ashit Sood51832a72018-05-02 11:25:22 -0700315 return mProvisionStatus;
316 }
Brad Ebinger4123f952018-10-11 16:21:22 -0700317
318 /**
319 * @return the Calling Line Identification Restriction State for outgoing calls with respect to
320 * this subscription. Will be {@link #CLIR_OUTGOING_DEFAULT} if not applicable to this SS info.
321 */
322 public @ClirOutgoingState int getClirOutgoingState() {
323 return mClirOutgoingState;
324 }
325
326 /**
327 * @return the calling line identification restriction provisioning status upon interrogation of
328 * the service for this subscription. Will be {@link #CLIR_STATUS_UNKNOWN} if not applicable to
329 * this SS info.
330 */
331 public @ClirInterrogationStatus int getClirInterrogationStatus() {
332 return mClirInterrogationStatus;
333 }
Wink Savillef8458ff2014-06-25 16:08:02 -0700334}