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.SystemApi; 22 import android.compat.annotation.UnsupportedAppUsage; 23 import android.os.Build; 24 import android.os.Parcel; 25 import android.os.Parcelable; 26 27 import java.lang.annotation.Retention; 28 import java.lang.annotation.RetentionPolicy; 29 30 /** 31 * Provides the call forward information for the supplementary service configuration. 32 * 33 * @hide 34 */ 35 @SystemApi 36 public final class ImsCallForwardInfo implements Parcelable { 37 38 /** 39 * CDIV (Communication Diversion, 3GPP TS 24.604) call forwarding reason for unconditional call 40 * forwarding. See TC 27.007 41 */ 42 public static final int CDIV_CF_REASON_UNCONDITIONAL = 0; 43 44 /** 45 * CDIV (Communication Diversion, 3GPP TS 24.604) call forwarding reason for call forwarding 46 * when the user is busy. 47 */ 48 public static final int CDIV_CF_REASON_BUSY = 1; 49 50 /** 51 * CDIV (Communication Diversion, 3GPP TS 24.604) call forwarding reason for call forwarding 52 * when there is no reply from the user. 53 */ 54 public static final int CDIV_CF_REASON_NO_REPLY = 2; 55 56 /** 57 * CDIV (Communication Diversion, 3GPP TS 24.604) call forwarding reason for call forwarding 58 * when the user is not reachable. 59 */ 60 public static final int CDIV_CF_REASON_NOT_REACHABLE = 3; 61 62 /** 63 * CDIV (Communication Diversion, 3GPP TS 24.604) call forwarding reason for setting all call 64 * forwarding reasons simultaneously (i.e. unconditional, busy, no reply, and not reachable). 65 */ 66 public static final int CDIV_CF_REASON_ALL = 4; 67 68 /** 69 * CDIV (Communication Diversion, 3GPP TS 24.604) call forwarding reason for setting all 70 * conditional call forwarding reasons simultaneously (i.e. if busy, if no reply, and if not 71 * reachable). 72 */ 73 public static final int CDIV_CF_REASON_ALL_CONDITIONAL = 5; 74 75 /** 76 * CDIV (Communication Diversion) IMS only call forwarding reason for call forwarding when the 77 * user is not logged in. 78 */ 79 public static final int CDIV_CF_REASON_NOT_LOGGED_IN = 6; 80 81 /**@hide*/ 82 @IntDef(prefix = {"CDIV_CF_REASON_"}, value = { 83 CDIV_CF_REASON_UNCONDITIONAL, 84 CDIV_CF_REASON_BUSY, 85 CDIV_CF_REASON_NO_REPLY, 86 CDIV_CF_REASON_NOT_REACHABLE, 87 CDIV_CF_REASON_ALL, 88 CDIV_CF_REASON_ALL_CONDITIONAL, 89 CDIV_CF_REASON_NOT_LOGGED_IN}) 90 @Retention(RetentionPolicy.SOURCE) 91 public @interface CallForwardReasons{} 92 93 /** 94 * Call forwarding is not active for any service class. 95 */ 96 public static final int STATUS_NOT_ACTIVE = 0; 97 98 /** 99 * Call forwarding is active for one or more service classes. 100 */ 101 public static final int STATUS_ACTIVE = 1; 102 103 /**@hide*/ 104 @IntDef(prefix = {"STATUS_"}, value = { 105 STATUS_NOT_ACTIVE, 106 STATUS_ACTIVE}) 107 @Retention(RetentionPolicy.SOURCE) 108 public @interface CallForwardStatus{} 109 110 /** 111 * The address defined in {@link #getNumber()} is in an unknown format. 112 * 113 * See TS 27.007, section 7.11 for more information. 114 */ 115 public static final int TYPE_OF_ADDRESS_UNKNOWN = 0x81; 116 /** 117 * The address defined in {@link #getNumber()} is in E.164 international format, which includes 118 * international access code "+". 119 * 120 * See TS 27.007, section 7.11 for more information. 121 */ 122 public static final int TYPE_OF_ADDRESS_INTERNATIONAL = 0x91; 123 124 /**@hide*/ 125 @IntDef(prefix = {"TYPE_OF_ADDRESS_"}, value = { 126 TYPE_OF_ADDRESS_INTERNATIONAL, 127 TYPE_OF_ADDRESS_UNKNOWN}) 128 @Retention(RetentionPolicy.SOURCE) 129 public @interface TypeOfAddress{} 130 131 /**@hide*/ 132 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 133 public @CallForwardReasons int mCondition; 134 /** @hide */ 135 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 136 public @CallForwardStatus int mStatus; 137 /** @hide */ 138 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 139 public @TypeOfAddress int mToA; 140 /** @hide */ 141 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 142 public @ImsSsData.ServiceClassFlags int mServiceClass; 143 /** @hide */ 144 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 145 public String mNumber; 146 /** @hide */ 147 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 148 public int mTimeSeconds; 149 150 /** @hide */ 151 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) ImsCallForwardInfo()152 public ImsCallForwardInfo() { 153 } 154 155 /** 156 * IMS Call Forward Information. 157 */ ImsCallForwardInfo(@allForwardReasons int reason, @CallForwardStatus int status, @TypeOfAddress int toA, @ImsSsData.ServiceClassFlags int serviceClass, @NonNull String number, int replyTimerSec)158 public ImsCallForwardInfo(@CallForwardReasons int reason, @CallForwardStatus int status, 159 @TypeOfAddress int toA, @ImsSsData.ServiceClassFlags int serviceClass, 160 @NonNull String number, int replyTimerSec) { 161 mCondition = reason; 162 mStatus = status; 163 mToA = toA; 164 mServiceClass = serviceClass; 165 mNumber = number; 166 mTimeSeconds = replyTimerSec; 167 } 168 169 /** @hide */ ImsCallForwardInfo(Parcel in)170 public ImsCallForwardInfo(Parcel in) { 171 readFromParcel(in); 172 } 173 174 @Override describeContents()175 public int describeContents() { 176 return 0; 177 } 178 179 @Override writeToParcel(Parcel out, int flags)180 public void writeToParcel(Parcel out, int flags) { 181 out.writeInt(mCondition); 182 out.writeInt(mStatus); 183 out.writeInt(mToA); 184 out.writeString(mNumber); 185 out.writeInt(mTimeSeconds); 186 out.writeInt(mServiceClass); 187 } 188 189 @NonNull 190 @Override toString()191 public String toString() { 192 return super.toString() + ", Condition: " + mCondition 193 + ", Status: " + ((mStatus == 0) ? "disabled" : "enabled") 194 + ", ToA: " + mToA 195 + ", Service Class: " + mServiceClass 196 + ", Number=" + mNumber 197 + ", Time (seconds): " + mTimeSeconds; 198 } 199 readFromParcel(Parcel in)200 private void readFromParcel(Parcel in) { 201 mCondition = in.readInt(); 202 mStatus = in.readInt(); 203 mToA = in.readInt(); 204 mNumber = in.readString(); 205 mTimeSeconds = in.readInt(); 206 mServiceClass = in.readInt(); 207 } 208 209 public static final @android.annotation.NonNull Creator<ImsCallForwardInfo> CREATOR = 210 new Creator<ImsCallForwardInfo>() { 211 @Override 212 public ImsCallForwardInfo createFromParcel(Parcel in) { 213 return new ImsCallForwardInfo(in); 214 } 215 216 @Override 217 public ImsCallForwardInfo[] newArray(int size) { 218 return new ImsCallForwardInfo[size]; 219 } 220 }; 221 222 /** 223 * @return the condition of call forwarding for the service classes specified. 224 */ getCondition()225 public @CallForwardReasons int getCondition() { 226 return mCondition; 227 } 228 229 /** 230 * @return The call forwarding status. 231 */ getStatus()232 public @CallForwardStatus int getStatus() { 233 return mStatus; 234 } 235 236 /** 237 * @return the type of address (ToA) for the number. 238 * @see #getNumber() 239 */ getToA()240 public @TypeOfAddress int getToA() { 241 return mToA; 242 } 243 244 /** 245 * @return a bitfield containing the service classes that are enabled for call forwarding. 246 */ getServiceClass()247 public @ImsSsData.ServiceClassFlags int getServiceClass() { 248 return mServiceClass; 249 } 250 251 /** 252 * @return the call forwarding number associated with call forwarding, with a number type 253 * defined by {@link #getToA()}. 254 */ getNumber()255 public String getNumber() { 256 return mNumber; 257 } 258 259 /** 260 * @return the number in seconds to wait before the call is forwarded for call forwarding 261 * condition {@link #CDIV_CF_REASON_NO_REPLY} 262 */ getTimeSeconds()263 public int getTimeSeconds() { 264 return mTimeSeconds; 265 } 266 } 267