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