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 package android.telephony.ims; 17 18 import android.annotation.IntDef; 19 import android.annotation.SystemApi; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 import java.lang.annotation.Retention; 24 import java.lang.annotation.RetentionPolicy; 25 26 /** 27 * Provides STK Call Control Supplementary Service information. 28 * 29 * {@hide} 30 */ 31 @SystemApi 32 public final class ImsSsData implements Parcelable { 33 34 // Supplementary Service Type 35 // Call Forwarding 36 public static final int SS_CFU = 0; 37 public static final int SS_CF_BUSY = 1; 38 public static final int SS_CF_NO_REPLY = 2; 39 public static final int SS_CF_NOT_REACHABLE = 3; 40 public static final int SS_CF_ALL = 4; 41 public static final int SS_CF_ALL_CONDITIONAL = 5; 42 public static final int SS_CFUT = 6; 43 // Called Line Presentation 44 public static final int SS_CLIP = 7; 45 public static final int SS_CLIR = 8; 46 public static final int SS_COLP = 9; 47 public static final int SS_COLR = 10; 48 // Calling Name Presentation 49 public static final int SS_CNAP = 11; 50 // Call Waiting 51 public static final int SS_WAIT = 12; 52 // Call Barring 53 public static final int SS_BAOC = 13; 54 public static final int SS_BAOIC = 14; 55 public static final int SS_BAOIC_EXC_HOME = 15; 56 public static final int SS_BAIC = 16; 57 public static final int SS_BAIC_ROAMING = 17; 58 public static final int SS_ALL_BARRING = 18; 59 public static final int SS_OUTGOING_BARRING = 19; 60 public static final int SS_INCOMING_BARRING = 20; 61 public static final int SS_INCOMING_BARRING_DN = 21; 62 public static final int SS_INCOMING_BARRING_ANONYMOUS = 22; 63 64 //Supplementary Service Request Types 65 public static final int SS_ACTIVATION = 0; 66 public static final int SS_DEACTIVATION = 1; 67 public static final int SS_INTERROGATION = 2; 68 public static final int SS_REGISTRATION = 3; 69 public static final int SS_ERASURE = 4; 70 71 // Supplementary Service Teleservice Type 72 public static final int SS_ALL_TELE_AND_BEARER_SERVICES = 0; 73 public static final int SS_ALL_TELESEVICES = 1; 74 public static final int SS_TELEPHONY = 2; 75 public static final int SS_ALL_DATA_TELESERVICES = 3; 76 public static final int SS_SMS_SERVICES = 4; 77 public static final int SS_ALL_TELESERVICES_EXCEPT_SMS = 5; 78 79 // Service Class of Supplementary Service 80 // See 27.007 +CCFC or +CLCK 81 /** @hide */ 82 public static final int SERVICE_CLASS_NONE = 0; // no user input 83 /** @hide */ 84 public static final int SERVICE_CLASS_VOICE = 1; 85 /** @hide */ 86 public static final int SERVICE_CLASS_DATA = (1 << 1); 87 /** @hide */ 88 public static final int SERVICE_CLASS_FAX = (1 << 2); 89 /** @hide */ 90 public static final int SERVICE_CLASS_SMS = (1 << 3); 91 /** @hide */ 92 public static final int SERVICE_CLASS_DATA_SYNC = (1 << 4); 93 /** @hide */ 94 public static final int SERVICE_CLASS_DATA_ASYNC = (1 << 5); 95 /** @hide */ 96 public static final int SERVICE_CLASS_PACKET = (1 << 6); 97 /** @hide */ 98 public static final int SERVICE_CLASS_PAD = (1 << 7); 99 100 /** 101 * Result code used if the operation was successful. See {@link #result}. 102 * @hide 103 */ 104 public static final int RESULT_SUCCESS = 0; 105 106 /** @hide */ 107 @IntDef(flag = true, prefix = { "SS_" }, value = { 108 SS_CFU, 109 SS_CF_BUSY, 110 SS_CF_NO_REPLY, 111 SS_CF_NOT_REACHABLE, 112 SS_CF_ALL, 113 SS_CF_ALL_CONDITIONAL, 114 SS_CFUT, 115 SS_CLIP, 116 SS_CLIR, 117 SS_COLP, 118 SS_COLR, 119 SS_CNAP, 120 SS_WAIT, 121 SS_BAOC, 122 SS_BAOIC, 123 SS_BAOIC_EXC_HOME, 124 SS_BAIC, 125 SS_BAIC_ROAMING, 126 SS_ALL_BARRING, 127 SS_OUTGOING_BARRING, 128 SS_INCOMING_BARRING, 129 SS_INCOMING_BARRING_DN, 130 SS_INCOMING_BARRING_ANONYMOUS 131 }) 132 @Retention(RetentionPolicy.SOURCE) 133 public @interface ServiceType{} 134 135 /** @hide */ 136 @IntDef(flag = true, prefix = { "SERVICE_CLASS" }, value = { 137 SERVICE_CLASS_NONE, 138 SERVICE_CLASS_VOICE, 139 SERVICE_CLASS_DATA, 140 SERVICE_CLASS_FAX, 141 SERVICE_CLASS_SMS, 142 SERVICE_CLASS_DATA_SYNC, 143 SERVICE_CLASS_DATA_ASYNC, 144 SERVICE_CLASS_PACKET, 145 SERVICE_CLASS_PAD 146 }) 147 @Retention(RetentionPolicy.SOURCE) 148 public @interface ServiceClass{} 149 150 /** 151 * The Service type of this Supplementary service. Valid values include: 152 * SS_CFU, 153 * SS_CF_BUSY, 154 * SS_CF_NO_REPLY, 155 * SS_CF_NOT_REACHABLE, 156 * SS_CF_ALL, 157 * SS_CF_ALL_CONDITIONAL, 158 * SS_CFUT, 159 * SS_CLIP, 160 * SS_CLIR, 161 * SS_COLP, 162 * SS_COLR, 163 * SS_CNAP, 164 * SS_WAIT, 165 * SS_BAOC, 166 * SS_BAOIC, 167 * SS_BAOIC_EXC_HOME, 168 * SS_BAIC, 169 * SS_BAIC_ROAMING, 170 * SS_ALL_BARRING, 171 * SS_OUTGOING_BARRING, 172 * SS_INCOMING_BARRING, 173 * SS_INCOMING_BARRING_DN, 174 * SS_INCOMING_BARRING_ANONYMOUS 175 * 176 * @hide 177 */ 178 // TODO: Make final, do not modify this field directly! 179 public int serviceType; 180 181 /** 182 * Supplementary Service request Type. Valid values are: 183 * SS_ACTIVATION, 184 * SS_DEACTIVATION, 185 * SS_INTERROGATION, 186 * SS_REGISTRATION, 187 * SS_ERASURE 188 * 189 * @hide 190 */ 191 // TODO: Make final, do not modify this field directly! 192 public int requestType; 193 194 /** 195 * Supplementary Service teleservice type: 196 * SS_TELESERVICE_ALL_TELE_AND_BEARER, 197 * SS_TELESERVICE_ALL_TELESEVICES, 198 * SS_TELESERVICE_TELEPHONY, 199 * SS_TELESERVICE_ALL_DATA, 200 * SS_TELESERVICE_SMS, 201 * SS_TELESERVICE_ALL_TELESERVICES_EXCEPT_SMS 202 * 203 * @hide 204 */ 205 // TODO: Make this param final! Do not try to modify this param directly. 206 public int teleserviceType; 207 208 /** 209 * Supplementary Service service class. Valid values are: 210 * SERVICE_CLASS_NONE, 211 * SERVICE_CLASS_VOICE, 212 * SERVICE_CLASS_DATA, 213 * SERVICE_CLASS_FAX, 214 * SERVICE_CLASS_SMS, 215 * SERVICE_CLASS_DATA_SYNC, 216 * SERVICE_CLASS_DATA_ASYNC, 217 * SERVICE_CLASS_PACKET, 218 * SERVICE_CLASS_PAD 219 * 220 * @hide 221 */ 222 // TODO: Make this param final! Do not try to modify this param directly. 223 public int serviceClass; 224 225 /** 226 * Result of Supplementary Service operation. Valid values are: 227 * RESULT_SUCCESS if the result is success, or 228 * ImsReasonInfo code if the result is a failure. 229 * 230 * @hide 231 */ 232 // TODO: Make this param final! Do not try to modify this param directly. 233 public final int result; 234 235 private int[] mSsInfo; 236 private ImsCallForwardInfo[] mCfInfo; 237 private ImsSsInfo[] mImsSsInfo; 238 239 /** 240 * Generate IMS Supplementary Service information. 241 * @param serviceType The Supplementary Service type. Valid entries: 242 * SS_CFU, 243 * SS_CF_BUSY, 244 * SS_CF_NO_REPLY, 245 * SS_CF_NOT_REACHABLE, 246 * SS_CF_ALL, 247 * SS_CF_ALL_CONDITIONAL, 248 * SS_CFUT, 249 * SS_CLIP, 250 * SS_CLIR, 251 * SS_COLP, 252 * SS_COLR, 253 * SS_CNAP, 254 * SS_WAIT, 255 * SS_BAOC, 256 * SS_BAOIC, 257 * SS_BAOIC_EXC_HOME, 258 * SS_BAIC, 259 * SS_BAIC_ROAMING, 260 * SS_ALL_BARRING, 261 * SS_OUTGOING_BARRING, 262 * SS_INCOMING_BARRING, 263 * SS_INCOMING_BARRING_DN, 264 * SS_INCOMING_BARRING_ANONYMOUS 265 * @param requestType Supplementary Service request Type. Valid values are: 266 * SS_ACTIVATION, 267 * SS_DEACTIVATION, 268 * SS_INTERROGATION, 269 * SS_REGISTRATION, 270 * SS_ERASURE 271 * @param teleserviceType Supplementary Service teleservice type: 272 * SS_TELESERVICE_ALL_TELE_AND_BEARER, 273 * SS_TELESERVICE_ALL_TELESEVICES, 274 * SS_TELESERVICE_TELEPHONY, 275 * SS_TELESERVICE_ALL_DATA, 276 * SS_TELESERVICE_SMS, 277 * SS_TELESERVICE_ALL_TELESERVICES_EXCEPT_SMS 278 * @param serviceClass Supplementary Service service class. See See 27.007 +CCFC or +CLCK. 279 * @param result Result of Supplementary Service operation. Valid values are 0 if the result is 280 * success, or ImsReasonInfo code if the result is a failure. 281 */ ImsSsData(@erviceType int serviceType, int requestType, int teleserviceType, @ServiceClass int serviceClass, int result)282 public ImsSsData(@ServiceType int serviceType, int requestType, int teleserviceType, 283 @ServiceClass int serviceClass, int result) { 284 this.serviceType = serviceType; 285 this.requestType = requestType; 286 this.teleserviceType = teleserviceType; 287 this.serviceClass = serviceClass; 288 this.result = result; 289 } 290 ImsSsData(Parcel in)291 private ImsSsData(Parcel in) { 292 serviceType = in.readInt(); 293 requestType = in.readInt(); 294 teleserviceType = in.readInt(); 295 serviceClass = in.readInt(); 296 result = in.readInt(); 297 mSsInfo = in.createIntArray(); 298 mCfInfo = (ImsCallForwardInfo[])in.readParcelableArray(this.getClass().getClassLoader()); 299 mImsSsInfo = (ImsSsInfo[])in.readParcelableArray(this.getClass().getClassLoader()); 300 } 301 302 public static final Creator<ImsSsData> CREATOR = new Creator<ImsSsData>() { 303 @Override 304 public ImsSsData createFromParcel(Parcel in) { 305 return new ImsSsData(in); 306 } 307 308 @Override 309 public ImsSsData[] newArray(int size) { 310 return new ImsSsData[size]; 311 } 312 }; 313 314 @Override writeToParcel(Parcel out, int flags)315 public void writeToParcel(Parcel out, int flags) { 316 out.writeInt(serviceType); 317 out.writeInt(requestType); 318 out.writeInt(teleserviceType); 319 out.writeInt(serviceClass); 320 out.writeInt(result); 321 out.writeIntArray(mSsInfo); 322 out.writeParcelableArray(mCfInfo, 0); 323 out.writeParcelableArray(mImsSsInfo, 0); 324 } 325 326 @Override describeContents()327 public int describeContents() { 328 return 0; 329 } 330 331 /** 332 * Old method, kept for compatibility. See {@link #isTypeCf()} 333 * @hide 334 */ isTypeCF()335 public boolean isTypeCF() { 336 return (serviceType == SS_CFU || serviceType == SS_CF_BUSY || 337 serviceType == SS_CF_NO_REPLY || serviceType == SS_CF_NOT_REACHABLE || 338 serviceType == SS_CF_ALL || serviceType == SS_CF_ALL_CONDITIONAL); 339 } 340 isTypeCf()341 public boolean isTypeCf() { 342 return isTypeCF(); 343 } 344 isTypeUnConditional()345 public boolean isTypeUnConditional() { 346 return (serviceType == SS_CFU || serviceType == SS_CF_ALL); 347 } 348 349 /** 350 * Old method, kept for compatibility. See {@link #isTypeCf()} 351 * @hide 352 */ isTypeCW()353 public boolean isTypeCW() { 354 return (serviceType == SS_WAIT); 355 } 356 isTypeCw()357 public boolean isTypeCw() { 358 return isTypeCW(); 359 } 360 isTypeClip()361 public boolean isTypeClip() { 362 return (serviceType == SS_CLIP); 363 } 364 isTypeColr()365 public boolean isTypeColr() { 366 return (serviceType == SS_COLR); 367 } 368 isTypeColp()369 public boolean isTypeColp() { 370 return (serviceType == SS_COLP); 371 } 372 isTypeClir()373 public boolean isTypeClir() { 374 return (serviceType == SS_CLIR); 375 } 376 isTypeIcb()377 public boolean isTypeIcb() { 378 return (serviceType == SS_INCOMING_BARRING_DN || 379 serviceType == SS_INCOMING_BARRING_ANONYMOUS); 380 } 381 isTypeBarring()382 public boolean isTypeBarring() { 383 return (serviceType == SS_BAOC || serviceType == SS_BAOIC || 384 serviceType == SS_BAOIC_EXC_HOME || serviceType == SS_BAIC || 385 serviceType == SS_BAIC_ROAMING || serviceType == SS_ALL_BARRING || 386 serviceType == SS_OUTGOING_BARRING || serviceType == SS_INCOMING_BARRING); 387 } 388 isTypeInterrogation()389 public boolean isTypeInterrogation() { 390 return (serviceType == SS_INTERROGATION); 391 } 392 393 /** @hide */ setSuppServiceInfo(int[] ssInfo)394 public void setSuppServiceInfo(int[] ssInfo) { 395 mSsInfo = ssInfo; 396 } 397 398 /** @hide */ setImsSpecificSuppServiceInfo(ImsSsInfo[] imsSsInfo)399 public void setImsSpecificSuppServiceInfo(ImsSsInfo[] imsSsInfo) { 400 mImsSsInfo = imsSsInfo; 401 } 402 403 /** @hide */ setCallForwardingInfo(ImsCallForwardInfo[] cfInfo)404 public void setCallForwardingInfo(ImsCallForwardInfo[] cfInfo) { 405 mCfInfo = cfInfo; 406 } 407 408 /** 409 * This field will be null for RequestType SS_INTERROGATION 410 * and ServiceType SS_CF_*, SS_INCOMING_BARRING_DN, 411 * SS_INCOMING_BARRING_ANONYMOUS. 412 * 413 * @hide 414 */ getSuppServiceInfo()415 public int[] getSuppServiceInfo() { 416 return mSsInfo; 417 } 418 419 /** 420 * Valid only for ServiceTypes 421 * - SS_INCOMING_BARRING_DN and 422 * - ServiceType SS_INCOMING_BARRING_ANONYMOUS. 423 * Will be null otherwise. 424 * @hide 425 */ getImsSpecificSuppServiceInfo()426 public ImsSsInfo[] getImsSpecificSuppServiceInfo() { 427 return mImsSsInfo; 428 } 429 430 /** 431 * Valid only for supplementary services 432 * - ServiceType SS_CF_* and 433 * - RequestType SS_INTERROGATION. 434 * Will be null otherwise. 435 * @hide 436 **/ getCallForwardInfo()437 public ImsCallForwardInfo[] getCallForwardInfo() { 438 return mCfInfo; 439 } 440 toString()441 public String toString() { 442 return "[ImsSsData] " + "ServiceType: " + serviceType 443 + " RequestType: " + requestType 444 + " TeleserviceType: " + teleserviceType 445 + " ServiceClass: " + serviceClass 446 + " Result: " + result; 447 } 448 } 449