ImsCallProfile.java revision f8458ff9d97f8961d67c41ee107129ecba873f36
1/* 2 * Copyright (c) 2013 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 17package com.android.ims; 18 19import android.os.Bundle; 20import android.os.Parcel; 21import android.os.Parcelable; 22 23/** 24 * Parcelable object to handle IMS call profile. 25 * It is created from GSMA IR.92/IR.94, 3GPP TS 24.229/TS 26.114/TS26.111. 26 * It provides the service and call type, the additional information related to the call. 27 * 28 * @hide 29 */ 30public class ImsCallProfile implements Parcelable { 31 private static final String TAG = "ImsCallProfile"; 32 33 /** 34 * Service types 35 */ 36 /** 37 * It is for a special case. It helps that the application can make a call 38 * without IMS connection (not registered). 39 * In the moment of the call initiation, the device try to connect to the IMS network 40 * and initiates the call. 41 */ 42 public static final int SERVICE_TYPE_NONE = 0; 43 /** 44 * It is a default type and can be selected when the device is connected to the IMS network. 45 */ 46 public static final int SERVICE_TYPE_NORMAL = 1; 47 /** 48 * It is for an emergency call. 49 */ 50 public static final int SERVICE_TYPE_EMERGENCY = 2; 51 52 /** 53 * Call types 54 */ 55 /** 56 * IMSPhone to support IR.92 & IR.94 (voice + video upgrade/downgrade) 57 */ 58 public static final int CALL_TYPE_VOICE_N_VIDEO = 1; 59 /** 60 * IR.92 (Voice only) 61 */ 62 public static final int CALL_TYPE_VOICE = 2; 63 /** 64 * VT to support IR.92 & IR.94 (voice + video upgrade/downgrade) 65 */ 66 public static final int CALL_TYPE_VIDEO_N_VOICE = 3; 67 /** 68 * Video Telephony (audio / video two way) 69 */ 70 public static final int CALL_TYPE_VT = 4; 71 /** 72 * Video Telephony (audio two way / video TX one way) 73 */ 74 public static final int CALL_TYPE_VT_TX = 5; 75 /** 76 * Video Telephony (audio two way / video RX one way) 77 */ 78 public static final int CALL_TYPE_VT_RX = 6; 79 /** 80 * Video Telephony (audio two way / video inactive) 81 */ 82 public static final int CALL_TYPE_VT_NODIR = 7; 83 /** 84 * VideoShare (video two way) 85 */ 86 public static final int CALL_TYPE_VS = 8; 87 /** 88 * VideoShare (video TX one way) 89 */ 90 public static final int CALL_TYPE_VS_TX = 9; 91 /** 92 * VideoShare (video RX one way) 93 */ 94 public static final int CALL_TYPE_VS_RX = 10; 95 96 /** 97 * Extra properties for IMS call. 98 */ 99 /** 100 * Boolean extra properties - "true" / "false" 101 * conference : Indicates if the session is for the conference call or not. 102 * e_call : Indicates if the session is for the emergency call or not. 103 * vms : Indicates if the session is connected to the voice mail system or not. 104 * call_mode_changeable : Indicates if the session is able to upgrade/downgrade 105 * the video during voice call. 106 * conference_avail : Indicates if the session can be extended to the conference. 107 */ 108 public static final String EXTRA_CONFERENCE = "conference"; 109 public static final String EXTRA_E_CALL = "e_call"; 110 public static final String EXTRA_VMS = "vms"; 111 public static final String EXTRA_CALL_MODE_CHANGEABLE = "call_mode_changeable"; 112 public static final String EXTRA_CONFERENCE_AVAIL = "conference_avail"; 113 114 /** 115 * Integer extra properties 116 * oir : Rule for originating identity (number) presentation, MO/MT. 117 * {@link ImsCallProfile#OIR_DEFAULT} 118 * {@link ImsCallProfile#OIR_PRESENTATION_RESTRICTED} 119 * {@link ImsCallProfile#OIR_PRESENTATION_NOT_RESTRICTED} 120 * cnap : Rule for calling name presentation 121 * {@link ImsCallProfile#OIR_DEFAULT} 122 * {@link ImsCallProfile#OIR_PRESENTATION_RESTRICTED} 123 * {@link ImsCallProfile#OIR_PRESENTATION_NOT_RESTRICTED} 124 * dialstring : To identify the Ims call type, MO 125 * {@link ImsCallProfile#DIALSTRING_NORMAL_CALL} 126 * {@link ImsCallProfile#DIALSTRING_SS_CONF} 127 * {@link ImsCallProfile#DIALSTRING_USSD} 128 */ 129 public static final String EXTRA_OIR = "oir"; 130 public static final String EXTRA_CNAP = "cnap"; 131 public static final String EXTRA_DIALSTRING = "dialstring"; 132 133 /** 134 * Values for EXTRA_OIR / EXTRA_CNAP 135 */ 136 public static final int OIR_DEFAULT = 0; // "user subscription default value" 137 public static final int OIR_PRESENTATION_RESTRICTED = 1; 138 public static final int OIR_PRESENTATION_NOT_RESTRICTED = 2; 139 140 /** 141 * Values for EXTRA_DIALSTRING 142 */ 143 // default (normal call) 144 public static final int DIALSTRING_NORMAL = 0; 145 // Call for SIP-based user configuration 146 public static final int DIALSTRING_SS_CONF = 1; 147 // Call for USSD message 148 public static final int DIALSTRING_USSD = 2; 149 150 /** 151 * String extra properties 152 * oi : Originating identity (number), MT only 153 * cna : Calling name 154 * ussd : For network-initiated USSD, MT only 155 * remote_uri : Connected user identity (it can be used for the conference) 156 */ 157 public static final String EXTRA_OI = "oi"; 158 public static final String EXTRA_CNA = "cna"; 159 public static final String EXTRA_USSD = "ussd"; 160 public static final String EXTRA_REMOTE_URI = "remote_uri"; 161 162 public int mServiceType; 163 public int mCallType; 164 public Bundle mCallExtras; 165 public ImsStreamMediaProfile mMediaProfile; 166 167 168 169 public ImsCallProfile(Parcel in) { 170 readFromParcel(in); 171 } 172 173 public ImsCallProfile() { 174 mServiceType = SERVICE_TYPE_NORMAL; 175 mCallType = CALL_TYPE_VOICE_N_VIDEO; 176 mCallExtras = new Bundle(); 177 mMediaProfile = new ImsStreamMediaProfile(); 178 } 179 180 public ImsCallProfile(int serviceType, int callType) { 181 mServiceType = serviceType; 182 mCallType = callType; 183 mCallExtras = new Bundle(); 184 mMediaProfile = new ImsStreamMediaProfile(); 185 } 186 187 public String getCallExtra(String name) { 188 return getCallExtra(name, ""); 189 } 190 191 public String getCallExtra(String name, String defaultValue) { 192 if (mCallExtras == null) { 193 return defaultValue; 194 } 195 196 return mCallExtras.getString(name, defaultValue); 197 } 198 199 public boolean getCallExtraBoolean(String name) { 200 return getCallExtraBoolean(name, false); 201 } 202 203 public boolean getCallExtraBoolean(String name, boolean defaultValue) { 204 if (mCallExtras == null) { 205 return defaultValue; 206 } 207 208 return mCallExtras.getBoolean(name, defaultValue); 209 } 210 211 public int getCallExtraInt(String name) { 212 return getCallExtraInt(name, -1); 213 } 214 215 public int getCallExtraInt(String name, int defaultValue) { 216 if (mCallExtras == null) { 217 return defaultValue; 218 } 219 220 return mCallExtras.getInt(name, defaultValue); 221 } 222 223 public void setCallExtra(String name, String value) { 224 if (mCallExtras != null) { 225 mCallExtras.putString(name, value); 226 } 227 } 228 229 public void setCallExtraBoolean(String name, boolean value) { 230 if (mCallExtras != null) { 231 mCallExtras.putBoolean(name, value); 232 } 233 } 234 235 public void setCallExtraInt(String name, int value) { 236 if (mCallExtras != null) { 237 mCallExtras.putInt(name, value); 238 } 239 } 240 241 public void updateCallType(ImsCallProfile profile) { 242 mCallType = profile.mCallType; 243 } 244 245 public void updateCallExtras(ImsCallProfile profile) { 246 mCallExtras.clear(); 247 mCallExtras = (Bundle) profile.mCallExtras.clone(); 248 } 249 250 @Override 251 public String toString() { 252 return "{ serviceType=" + mServiceType + 253 ", callType=" + mCallType + 254 ", callExtras=" + mCallExtras.toString() + 255 ", mediaProfile=" + mMediaProfile.toString() + " }"; 256 } 257 258 @Override 259 public int describeContents() { 260 return 0; 261 } 262 263 @Override 264 public void writeToParcel(Parcel out, int flags) { 265 out.writeInt(mServiceType); 266 out.writeInt(mCallType); 267 out.writeParcelable(mCallExtras, 0); 268 out.writeParcelable(mMediaProfile, 0); 269 } 270 271 private void readFromParcel(Parcel in) { 272 mServiceType = in.readInt(); 273 mCallType = in.readInt(); 274 mCallExtras = in.readParcelable(null); 275 mMediaProfile = in.readParcelable(null); 276 } 277 278 public static final Creator<ImsCallProfile> CREATOR = new Creator<ImsCallProfile>() { 279 @Override 280 public ImsCallProfile createFromParcel(Parcel in) { 281 return new ImsCallProfile(in); 282 } 283 284 @Override 285 public ImsCallProfile[] newArray(int size) { 286 return new ImsCallProfile[size]; 287 } 288 }; 289} 290