• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.ims;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.annotation.SystemApi;
23 import android.compat.annotation.UnsupportedAppUsage;
24 import android.os.Build;
25 import android.os.Parcel;
26 import android.os.Parcelable;
27 
28 import java.lang.annotation.Retention;
29 import java.lang.annotation.RetentionPolicy;
30 
31 /**
32  * Provides the result to the update operation for the supplementary service configuration.
33  *
34  * Also supports IMS specific Incoming Communication Barring (ICB) as well as Anonymous
35  * Communication Rejection (ACR), as per 3GPP 24.611.
36  *
37  * @see Builder
38  * @hide
39  */
40 @SystemApi
41 public final class ImsSsInfo implements Parcelable {
42 
43     /**@hide*/
44     @IntDef(value = {
45             NOT_REGISTERED,
46             DISABLED,
47             ENABLED
48     })
49     @Retention(RetentionPolicy.SOURCE)
50     public @interface ServiceStatus {}
51 
52     /**
53      * For the status of service registration or activation/deactivation.
54      */
55     public static final int NOT_REGISTERED = (-1);
56     public static final int DISABLED = 0;
57     public static final int ENABLED = 1;
58 
59     /**
60      * Provision status of service.
61      * @hide
62      */
63     @IntDef(value = {
64             SERVICE_PROVISIONING_UNKNOWN,
65             SERVICE_NOT_PROVISIONED,
66             SERVICE_PROVISIONED
67     }, prefix = "SERVICE_")
68     @Retention(RetentionPolicy.SOURCE)
69     public @interface ServiceProvisionStatus {}
70 
71     /**
72      * Unknown provision status for the service.
73      */
74     public static final int SERVICE_PROVISIONING_UNKNOWN = (-1);
75 
76     /**
77      * Service is not provisioned.
78      */
79     public static final int SERVICE_NOT_PROVISIONED = 0;
80 
81     /**
82      * Service is provisioned.
83      */
84     public static final int SERVICE_PROVISIONED = 1;
85 
86     /**@hide*/
87     @IntDef(value = {
88             CLIR_OUTGOING_DEFAULT,
89             CLIR_OUTGOING_INVOCATION,
90             CLIR_OUTGOING_SUPPRESSION
91     }, prefix = "CLIR_OUTGOING_")
92     @Retention(RetentionPolicy.SOURCE)
93     public @interface ClirOutgoingState {}
94 
95     /**
96      * Calling line identification restriction (CLIR) is set to the default according to the
97      * subscription of the CLIR service.
98      *
99      * See TS 27.007, section 7.7 for more information.
100      */
101     public static final int CLIR_OUTGOING_DEFAULT = 0;
102     /**
103      * Activate Calling line identification restriction for outgoing calls.
104      *
105      * See TS 27.007, section 7.7 for more information.
106      */
107     public static final int CLIR_OUTGOING_INVOCATION = 1;
108     /**
109      * Deactivate Calling line identification restriction for outgoing calls.
110      *
111      * See TS 27.007, section 7.7 for more information.
112      */
113     public static final int CLIR_OUTGOING_SUPPRESSION = 2;
114 
115     /**
116      * Calling line identification restriction is currently not provisioned.
117      *
118      * See TS 27.007, section 7.7 for more information.
119      */
120     public static final int CLIR_STATUS_NOT_PROVISIONED = 0;
121     /**
122      * Calling line identification restriction is currently provisioned in permanent mode.
123      *
124      * See TS 27.007, section 7.7 for more information.
125      */
126     public static final int CLIR_STATUS_PROVISIONED_PERMANENT = 1;
127     /**
128      * Calling line identification restriction is currently unknown, e.g. no network, etc.
129      *
130      * See TS 27.007, section 7.7 for more information.
131      */
132     public static final int CLIR_STATUS_UNKNOWN = 2;
133     /**
134      * Calling line identification restriction temporary mode, temporarily restricted.
135      *
136      * See TS 27.007, section 7.7 for more information.
137      */
138     public static final int CLIR_STATUS_TEMPORARILY_RESTRICTED = 3;
139     /**
140      * Calling line identification restriction temporary mode, temporarily allowed.
141      *
142      * See TS 27.007, section 7.7 for more information.
143      */
144     public static final int CLIR_STATUS_TEMPORARILY_ALLOWED = 4;
145 
146     /**@hide*/
147     @IntDef(value = {
148             CLIR_STATUS_NOT_PROVISIONED,
149             CLIR_STATUS_PROVISIONED_PERMANENT,
150             CLIR_STATUS_UNKNOWN,
151             CLIR_STATUS_TEMPORARILY_RESTRICTED,
152             CLIR_STATUS_TEMPORARILY_ALLOWED
153     }, prefix = "CLIR_STATUS_")
154     @Retention(RetentionPolicy.SOURCE)
155     public @interface ClirInterrogationStatus {}
156 
157     // 0: disabled, 1: enabled
158     /** @hide */
159     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
160     public int mStatus;
161     /** @hide */
162     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
163     public String mIcbNum;
164     /** @hide */
165     public int mProvisionStatus = SERVICE_PROVISIONING_UNKNOWN;
166     private int mClirInterrogationStatus = CLIR_STATUS_UNKNOWN;
167     private int mClirOutgoingState = CLIR_OUTGOING_DEFAULT;
168 
169     /**@hide*/
170     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
ImsSsInfo()171     public ImsSsInfo() {
172     }
173 
174     /**
175      * Builds {@link ImsSsInfo} instances, which may include optional parameters.
176      */
177     public static final class Builder {
178 
179         private final ImsSsInfo mImsSsInfo;
180 
Builder(@erviceStatus int status)181         public Builder(@ServiceStatus int status) {
182             mImsSsInfo = new ImsSsInfo();
183             mImsSsInfo.mStatus = status;
184         }
185 
186         /**
187          * Set the ICB number for IMS call barring.
188          * @param number The number in E.164 international format.
189          */
setIncomingCommunicationBarringNumber(@onNull String number)190         public @NonNull Builder setIncomingCommunicationBarringNumber(@NonNull String number) {
191             mImsSsInfo.mIcbNum = number;
192             return this;
193         }
194 
195         /**
196          * Set the provisioning status for a Supplementary Service interrogation response.
197          */
setProvisionStatus(@erviceProvisionStatus int provisionStatus)198         public @NonNull Builder setProvisionStatus(@ServiceProvisionStatus int provisionStatus) {
199             mImsSsInfo.mProvisionStatus = provisionStatus;
200             return this;
201         }
202 
203         /**
204          * Set the Calling Line Identification Restriction (CLIR) status for a supplementary service
205          * interrogation response.
206          */
setClirInterrogationStatus(@lirInterrogationStatus int status)207         public @NonNull Builder setClirInterrogationStatus(@ClirInterrogationStatus int status) {
208             mImsSsInfo.mClirInterrogationStatus = status;
209             return this;
210         }
211 
212         /**
213          * Set the Calling line identification Restriction (CLIR) state for outgoing calls.
214          */
setClirOutgoingState(@lirOutgoingState int state)215         public @NonNull Builder setClirOutgoingState(@ClirOutgoingState int state) {
216             mImsSsInfo.mClirOutgoingState = state;
217             return this;
218         }
219 
220         /**
221          * @return a built {@link ImsSsInfo} containing optional the parameters that were set.
222          */
build()223         public @NonNull ImsSsInfo build() {
224             return mImsSsInfo;
225         }
226     }
227 
228     /**
229      *
230      * @param status The status of the service registration of activation/deactiviation.
231      * @param icbNum The Incoming barring number.
232      * @deprecated use {@link ImsSsInfo.Builder} instead.
233      */
234     @Deprecated
ImsSsInfo(@erviceStatus int status, @Nullable String icbNum)235     public ImsSsInfo(@ServiceStatus int status, @Nullable String icbNum) {
236         mStatus = status;
237         mIcbNum = icbNum;
238     }
239 
ImsSsInfo(Parcel in)240     private ImsSsInfo(Parcel in) {
241         readFromParcel(in);
242     }
243 
244     @Override
describeContents()245     public int describeContents() {
246         return 0;
247     }
248 
249     @Override
writeToParcel(Parcel out, int flags)250     public void writeToParcel(Parcel out, int flags) {
251         out.writeInt(mStatus);
252         out.writeString(mIcbNum);
253         out.writeInt(mProvisionStatus);
254         out.writeInt(mClirInterrogationStatus);
255         out.writeInt(mClirOutgoingState);
256     }
257 
258     @NonNull
259     @Override
toString()260     public String toString() {
261         return super.toString() + ", Status: " + ((mStatus == 0) ? "disabled" : "enabled")
262                 + ", ProvisionStatus: " + provisionStatusToString(mProvisionStatus);
263     }
264 
provisionStatusToString(int pStatus)265     private static String provisionStatusToString(int pStatus) {
266         switch (pStatus) {
267             case SERVICE_NOT_PROVISIONED:
268                 return "Service not provisioned";
269              case SERVICE_PROVISIONED:
270                 return "Service provisioned";
271              default:
272                 return "Service provisioning unknown";
273         }
274     }
275 
readFromParcel(Parcel in)276     private void readFromParcel(Parcel in) {
277         mStatus = in.readInt();
278         mIcbNum = in.readString();
279         mProvisionStatus = in.readInt();
280         mClirInterrogationStatus = in.readInt();
281         mClirOutgoingState = in.readInt();
282     }
283 
284     public static final @android.annotation.NonNull Creator<ImsSsInfo> CREATOR =
285             new Creator<ImsSsInfo>() {
286         @Override
287         public ImsSsInfo createFromParcel(Parcel in) {
288             return new ImsSsInfo(in);
289         }
290 
291         @Override
292         public ImsSsInfo[] newArray(int size) {
293             return new ImsSsInfo[size];
294         }
295     };
296 
297     /**
298      * @return Supplementary Service Configuration status.
299      */
getStatus()300     public @ServiceStatus int getStatus() {
301         return mStatus;
302     }
303 
304     /** @deprecated Use {@link #getIncomingCommunicationBarringNumber()} instead.*/
305     @Deprecated
getIcbNum()306     public String getIcbNum() {
307         return mIcbNum;
308     }
309 
310     /**
311      * @return The Incoming Communication Barring (ICB) number.
312      */
getIncomingCommunicationBarringNumber()313     public @Nullable String getIncomingCommunicationBarringNumber() {
314         return mIcbNum;
315     }
316 
317     /**
318      * @return Supplementary Service Provision status.
319      */
getProvisionStatus()320     public @ServiceProvisionStatus int getProvisionStatus() {
321         return mProvisionStatus;
322     }
323 
324     /**
325      * @return the Calling Line Identification Restriction State for outgoing calls with respect to
326      * this subscription. Will be {@link #CLIR_OUTGOING_DEFAULT} if not applicable to this SS info.
327      */
getClirOutgoingState()328     public @ClirOutgoingState int getClirOutgoingState() {
329         return mClirOutgoingState;
330     }
331 
332     /**
333      * @return the calling line identification restriction provisioning status upon interrogation of
334      * the service for this subscription. Will be {@link #CLIR_STATUS_UNKNOWN} if not applicable to
335      * this SS info.
336      */
getClirInterrogationStatus()337     public @ClirInterrogationStatus int getClirInterrogationStatus() {
338         return mClirInterrogationStatus;
339     }
340 
341     /**
342      * Parts of telephony still use the old {m,n} 3GPP definition, so convert to that format.
343      * @hide
344      */
getCompatArray(@msSsData.ServiceType int type)345     public int[] getCompatArray(@ImsSsData.ServiceType int type) {
346         int[] result = new int[2];
347         // Convert ImsSsInfo into a form that telephony can read (as per 3GPP 27.007)
348         // CLIR (section 7.7)
349         if (type == ImsSsData.SS_CLIR) {
350             // Assume there will only be one ImsSsInfo.
351             // contains {"n","m"} parameters
352             result[0] = getClirOutgoingState();
353             result[1] = getClirInterrogationStatus();
354             return result;
355         }
356         // COLR 7.31
357         if (type == ImsSsData.SS_COLR) {
358             result[0] = getProvisionStatus();
359         }
360         // Facility Lock CLCK 7.4 (for call barring), CLIP 7.6, COLP 7.8, as well as any
361         // other result, just return the status for the "n" parameter and provisioning status for
362         // "m" as the default.
363         result[0] = getStatus();
364         result[1] = getProvisionStatus();
365         return result;
366     }
367 }
368