Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 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 | |
| 17 | package com.android.ims; |
| 18 | |
| 19 | import java.util.HashMap; |
| 20 | import java.util.Map; |
| 21 | |
Leon Luu | 13fd98d | 2015-07-02 13:03:04 +0200 | [diff] [blame] | 22 | import android.content.res.Resources; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 23 | import android.os.AsyncResult; |
| 24 | import android.os.Bundle; |
Suresh Koleti | fd1611b | 2017-08-05 11:29:39 +0530 | [diff] [blame] | 25 | import android.os.Handler; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 26 | import android.os.Message; |
Suresh Koleti | fd1611b | 2017-08-05 11:29:39 +0530 | [diff] [blame] | 27 | import android.os.Registrant; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 28 | import android.os.RemoteException; |
| 29 | import android.telephony.Rlog; |
Brad Ebinger | 190ed93 | 2018-01-23 13:41:32 -0800 | [diff] [blame] | 30 | import android.telephony.ims.ImsCallForwardInfo; |
| 31 | import android.telephony.ims.ImsReasonInfo; |
| 32 | import android.telephony.ims.ImsSsData; |
| 33 | import android.telephony.ims.ImsSsInfo; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 34 | |
| 35 | import com.android.ims.internal.IImsUt; |
| 36 | import com.android.ims.internal.IImsUtListener; |
| 37 | |
| 38 | /** |
| 39 | * Provides APIs for the supplementary service settings using IMS (Ut interface). |
| 40 | * It is created from 3GPP TS 24.623 (XCAP(XML Configuration Access Protocol) |
| 41 | * over the Ut interface for manipulating supplementary services). |
| 42 | * |
| 43 | * @hide |
| 44 | */ |
| 45 | public class ImsUt implements ImsUtInterface { |
| 46 | /** |
| 47 | * Key string for an additional supplementary service configurations. |
| 48 | */ |
| 49 | /** |
| 50 | * Actions : string format of ImsUtInterface#ACTION_xxx |
| 51 | * "0" (deactivation), "1" (activation), "2" (not_used), |
| 52 | * "3" (registration), "4" (erasure), "5" (Interrogation) |
| 53 | */ |
| 54 | public static final String KEY_ACTION = "action"; |
| 55 | /** |
| 56 | * Categories : |
| 57 | * "OIP", "OIR", "TIP", "TIR", "CDIV", "CB", "CW", "CONF", |
| 58 | * "ACR", "MCID", "ECT", "CCBS", "AOC", "MWI", "FA", "CAT" |
| 59 | * |
| 60 | * Detailed parameter name will be determined according to the properties |
| 61 | * of the supplementary service configuration. |
| 62 | */ |
| 63 | public static final String KEY_CATEGORY = "category"; |
| 64 | public static final String CATEGORY_OIP = "OIP"; |
| 65 | public static final String CATEGORY_OIR = "OIR"; |
| 66 | public static final String CATEGORY_TIP = "TIP"; |
| 67 | public static final String CATEGORY_TIR = "TIR"; |
| 68 | public static final String CATEGORY_CDIV = "CDIV"; |
| 69 | public static final String CATEGORY_CB = "CB"; |
| 70 | public static final String CATEGORY_CW = "CW"; |
| 71 | public static final String CATEGORY_CONF = "CONF"; |
| 72 | |
| 73 | private static final String TAG = "ImsUt"; |
| 74 | private static final boolean DBG = true; |
| 75 | |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 76 | //These service class values are same as the one in CommandsInterface.java |
| 77 | private static final int SERVICE_CLASS_NONE = 0; |
| 78 | private static final int SERVICE_CLASS_VOICE = (1 << 0); |
| 79 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 80 | // For synchronization of private variables |
| 81 | private Object mLockObj = new Object(); |
| 82 | private final IImsUt miUt; |
| 83 | private HashMap<Integer, Message> mPendingCmds = |
| 84 | new HashMap<Integer, Message>(); |
Suresh Koleti | fd1611b | 2017-08-05 11:29:39 +0530 | [diff] [blame] | 85 | private Registrant mSsIndicationRegistrant; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 86 | |
| 87 | public ImsUt(IImsUt iUt) { |
| 88 | miUt = iUt; |
| 89 | |
| 90 | if (miUt != null) { |
| 91 | try { |
| 92 | miUt.setListener(new IImsUtListenerProxy()); |
| 93 | } catch (RemoteException e) { |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | public void close() { |
| 99 | synchronized(mLockObj) { |
| 100 | if (miUt != null) { |
| 101 | try { |
| 102 | miUt.close(); |
| 103 | } catch (RemoteException e) { |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if (!mPendingCmds.isEmpty()) { |
| 108 | Map.Entry<Integer, Message>[] entries = |
| 109 | mPendingCmds.entrySet().toArray(new Map.Entry[mPendingCmds.size()]); |
| 110 | |
| 111 | for (Map.Entry<Integer, Message> entry : entries) { |
| 112 | sendFailureReport(entry.getValue(), |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 113 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | mPendingCmds.clear(); |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /** |
Suresh Koleti | fd1611b | 2017-08-05 11:29:39 +0530 | [diff] [blame] | 122 | * Registers a handler for Supplementary Service Indications. The |
| 123 | * result is returned in the {@link AsyncResult#result) field |
| 124 | * of the {@link AsyncResult} object returned by {@link Message.obj}. |
| 125 | * Value of ((AsyncResult)result.obj) is of {@link ImsSsData}. |
| 126 | */ |
| 127 | public void registerForSuppServiceIndication(Handler h, int what, Object obj) { |
| 128 | mSsIndicationRegistrant = new Registrant (h, what, obj); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * UnRegisters a handler for Supplementary Service Indications. |
| 133 | */ |
| 134 | public void unregisterForSuppServiceIndication(Handler h) { |
| 135 | mSsIndicationRegistrant.clear(); |
| 136 | } |
| 137 | |
| 138 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 139 | * Operations for the supplementary service configuration |
| 140 | */ |
| 141 | |
| 142 | /** |
| 143 | * Retrieves the configuration of the call barring. |
| 144 | * |
| 145 | * @param cbType type of call barring to be queried; ImsUtInterface#CB_XXX |
| 146 | * @param result message to pass the result of this operation |
| 147 | * The return value of ((AsyncResult)result.obj) is an array of {@link ImsSsInfo}. |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 148 | * @deprecated Use {@link #queryCallBarring(int, Message, int)} instead. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 149 | */ |
| 150 | @Override |
| 151 | public void queryCallBarring(int cbType, Message result) { |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 152 | queryCallBarring(cbType, result, SERVICE_CLASS_NONE); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Retrieves the configuration of the call barring for specified service class. |
| 157 | * |
| 158 | * @param cbType type of call barring to be queried; ImsUtInterface#CB_XXX |
| 159 | * @param result message to pass the result of this operation |
| 160 | * The return value of ((AsyncResult)result.obj) is an array of {@link ImsSsInfo}. |
| 161 | * @param serviceClass service class for e.g. voice/video |
| 162 | */ |
| 163 | @Override |
| 164 | public void queryCallBarring(int cbType, Message result, int serviceClass) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 165 | if (DBG) { |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 166 | log("queryCallBarring :: Ut=" + miUt + ", cbType=" + cbType + ", serviceClass=" |
| 167 | + serviceClass); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | synchronized(mLockObj) { |
| 171 | try { |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 172 | int id = miUt.queryCallBarringForServiceClass(cbType, serviceClass); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 173 | |
| 174 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 175 | sendFailureReport(result, |
| 176 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 177 | return; |
| 178 | } |
| 179 | |
| 180 | mPendingCmds.put(Integer.valueOf(id), result); |
| 181 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 182 | sendFailureReport(result, |
| 183 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Retrieves the configuration of the call forward. |
| 190 | * The return value of ((AsyncResult)result.obj) is an array of {@link ImsCallForwardInfo}. |
| 191 | */ |
| 192 | @Override |
| 193 | public void queryCallForward(int condition, String number, Message result) { |
| 194 | if (DBG) { |
| 195 | log("queryCallForward :: Ut=" + miUt + ", condition=" + condition |
Shunta Sakai | fb688ca | 2016-12-06 20:32:07 +0900 | [diff] [blame] | 196 | + ", number=" + Rlog.pii(TAG, number)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | synchronized(mLockObj) { |
| 200 | try { |
| 201 | int id = miUt.queryCallForward(condition, number); |
| 202 | |
| 203 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 204 | sendFailureReport(result, |
| 205 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 206 | return; |
| 207 | } |
| 208 | |
| 209 | mPendingCmds.put(Integer.valueOf(id), result); |
| 210 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 211 | sendFailureReport(result, |
| 212 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Retrieves the configuration of the call waiting. |
| 219 | * The return value of ((AsyncResult)result.obj) is an array of {@link ImsSsInfo}. |
| 220 | */ |
| 221 | @Override |
| 222 | public void queryCallWaiting(Message result) { |
| 223 | if (DBG) { |
| 224 | log("queryCallWaiting :: Ut=" + miUt); |
| 225 | } |
| 226 | |
| 227 | synchronized(mLockObj) { |
| 228 | try { |
| 229 | int id = miUt.queryCallWaiting(); |
| 230 | |
| 231 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 232 | sendFailureReport(result, |
| 233 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 234 | return; |
| 235 | } |
| 236 | |
| 237 | mPendingCmds.put(Integer.valueOf(id), result); |
| 238 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 239 | sendFailureReport(result, |
| 240 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | /** |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 246 | * Retrieves the default CLIR setting. |
| 247 | */ |
| 248 | @Override |
| 249 | public void queryCLIR(Message result) { |
| 250 | if (DBG) { |
| 251 | log("queryCLIR :: Ut=" + miUt); |
| 252 | } |
| 253 | |
| 254 | synchronized(mLockObj) { |
| 255 | try { |
| 256 | int id = miUt.queryCLIR(); |
| 257 | |
| 258 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 259 | sendFailureReport(result, |
| 260 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 261 | return; |
| 262 | } |
| 263 | |
| 264 | mPendingCmds.put(Integer.valueOf(id), result); |
| 265 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 266 | sendFailureReport(result, |
| 267 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Retrieves the CLIP call setting. |
| 274 | */ |
| 275 | public void queryCLIP(Message result) { |
| 276 | if (DBG) { |
| 277 | log("queryCLIP :: Ut=" + miUt); |
| 278 | } |
| 279 | |
| 280 | synchronized(mLockObj) { |
| 281 | try { |
| 282 | int id = miUt.queryCLIP(); |
| 283 | |
| 284 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 285 | sendFailureReport(result, |
| 286 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 287 | return; |
| 288 | } |
| 289 | |
| 290 | mPendingCmds.put(Integer.valueOf(id), result); |
| 291 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 292 | sendFailureReport(result, |
| 293 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Retrieves the COLR call setting. |
| 300 | */ |
| 301 | public void queryCOLR(Message result) { |
| 302 | if (DBG) { |
| 303 | log("queryCOLR :: Ut=" + miUt); |
| 304 | } |
| 305 | |
| 306 | synchronized(mLockObj) { |
| 307 | try { |
| 308 | int id = miUt.queryCOLR(); |
| 309 | |
| 310 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 311 | sendFailureReport(result, |
| 312 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 313 | return; |
| 314 | } |
| 315 | |
| 316 | mPendingCmds.put(Integer.valueOf(id), result); |
| 317 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 318 | sendFailureReport(result, |
| 319 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Retrieves the COLP call setting. |
| 326 | */ |
| 327 | public void queryCOLP(Message result) { |
| 328 | if (DBG) { |
| 329 | log("queryCOLP :: Ut=" + miUt); |
| 330 | } |
| 331 | |
| 332 | synchronized(mLockObj) { |
| 333 | try { |
| 334 | int id = miUt.queryCOLP(); |
| 335 | |
| 336 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 337 | sendFailureReport(result, |
| 338 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 339 | return; |
| 340 | } |
| 341 | |
| 342 | mPendingCmds.put(Integer.valueOf(id), result); |
| 343 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 344 | sendFailureReport(result, |
| 345 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 351 | * Modifies the configuration of the call barring. |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 352 | * @deprecated Use {@link #updateCallBarring(int, int, Message, String[], int)} instead. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 353 | */ |
| 354 | @Override |
Shriram Ganesh | d3adfad | 2015-05-31 10:06:15 -0700 | [diff] [blame] | 355 | public void updateCallBarring(int cbType, int action, Message result, String[] barrList) { |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 356 | updateCallBarring(cbType, action, result, barrList, SERVICE_CLASS_NONE); |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * Modifies the configuration of the call barring for specified service class. |
| 361 | */ |
| 362 | @Override |
| 363 | public void updateCallBarring(int cbType, int action, Message result, |
| 364 | String[] barrList, int serviceClass) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 365 | if (DBG) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 366 | if (barrList != null) { |
| 367 | String bList = new String(); |
| 368 | for (int i = 0; i < barrList.length; i++) { |
| 369 | bList.concat(barrList[i] + " "); |
| 370 | } |
| 371 | log("updateCallBarring :: Ut=" + miUt + ", cbType=" + cbType |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 372 | + ", action=" + action + ", serviceClass=" + serviceClass |
| 373 | + ", barrList=" + bList); |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 374 | } |
| 375 | else { |
| 376 | log("updateCallBarring :: Ut=" + miUt + ", cbType=" + cbType |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 377 | + ", action=" + action + ", serviceClass=" + serviceClass); |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 378 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | synchronized(mLockObj) { |
| 382 | try { |
Benergy Meenan Ravuri | 7e083d8 | 2016-10-25 18:17:26 +0530 | [diff] [blame] | 383 | int id = miUt.updateCallBarringForServiceClass(cbType, action, |
| 384 | barrList, serviceClass); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 385 | |
| 386 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 387 | sendFailureReport(result, |
| 388 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 389 | return; |
| 390 | } |
| 391 | |
| 392 | mPendingCmds.put(Integer.valueOf(id), result); |
| 393 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 394 | sendFailureReport(result, |
| 395 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Modifies the configuration of the call forward. |
| 402 | */ |
| 403 | @Override |
| 404 | public void updateCallForward(int action, int condition, String number, |
Omkar Kolangade | 48738d5 | 2015-01-31 11:31:00 +0530 | [diff] [blame] | 405 | int serviceClass, int timeSeconds, Message result) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 406 | if (DBG) { |
| 407 | log("updateCallForward :: Ut=" + miUt + ", action=" + action |
Shunta Sakai | fb688ca | 2016-12-06 20:32:07 +0900 | [diff] [blame] | 408 | + ", condition=" + condition + ", number=" + Rlog.pii(TAG, number) |
| 409 | + ", serviceClass=" + serviceClass + ", timeSeconds=" + timeSeconds); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | synchronized(mLockObj) { |
| 413 | try { |
Omkar Kolangade | 48738d5 | 2015-01-31 11:31:00 +0530 | [diff] [blame] | 414 | int id = miUt.updateCallForward(action, condition, number, serviceClass, timeSeconds); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 415 | |
| 416 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 417 | sendFailureReport(result, |
| 418 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 419 | return; |
| 420 | } |
| 421 | |
| 422 | mPendingCmds.put(Integer.valueOf(id), result); |
| 423 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 424 | sendFailureReport(result, |
| 425 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Modifies the configuration of the call waiting. |
| 432 | */ |
| 433 | @Override |
Omkar Kolangade | 48738d5 | 2015-01-31 11:31:00 +0530 | [diff] [blame] | 434 | public void updateCallWaiting(boolean enable, int serviceClass, Message result) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 435 | if (DBG) { |
Omkar Kolangade | 48738d5 | 2015-01-31 11:31:00 +0530 | [diff] [blame] | 436 | log("updateCallWaiting :: Ut=" + miUt + ", enable=" + enable |
| 437 | + ",serviceClass=" + serviceClass); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | synchronized(mLockObj) { |
| 441 | try { |
Omkar Kolangade | 48738d5 | 2015-01-31 11:31:00 +0530 | [diff] [blame] | 442 | int id = miUt.updateCallWaiting(enable, serviceClass); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 443 | |
| 444 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 445 | sendFailureReport(result, |
| 446 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 447 | return; |
| 448 | } |
| 449 | |
| 450 | mPendingCmds.put(Integer.valueOf(id), result); |
| 451 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 452 | sendFailureReport(result, |
| 453 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 458 | /** |
| 459 | * Updates the configuration of the CLIR supplementary service. |
| 460 | */ |
| 461 | @Override |
| 462 | public void updateCLIR(int clirMode, Message result) { |
| 463 | if (DBG) { |
| 464 | log("updateCLIR :: Ut=" + miUt + ", clirMode=" + clirMode); |
| 465 | } |
| 466 | |
| 467 | synchronized(mLockObj) { |
| 468 | try { |
| 469 | int id = miUt.updateCLIR(clirMode); |
| 470 | |
| 471 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 472 | sendFailureReport(result, |
| 473 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 474 | return; |
| 475 | } |
| 476 | |
| 477 | mPendingCmds.put(Integer.valueOf(id), result); |
| 478 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 479 | sendFailureReport(result, |
| 480 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 481 | } |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | /** |
| 486 | * Updates the configuration of the CLIP supplementary service. |
| 487 | */ |
| 488 | @Override |
| 489 | public void updateCLIP(boolean enable, Message result) { |
| 490 | if (DBG) { |
| 491 | log("updateCLIP :: Ut=" + miUt + ", enable=" + enable); |
| 492 | } |
| 493 | |
| 494 | synchronized(mLockObj) { |
| 495 | try { |
| 496 | int id = miUt.updateCLIP(enable); |
| 497 | |
| 498 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 499 | sendFailureReport(result, |
| 500 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 501 | return; |
| 502 | } |
| 503 | |
| 504 | mPendingCmds.put(Integer.valueOf(id), result); |
| 505 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 506 | sendFailureReport(result, |
| 507 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | /** |
| 513 | * Updates the configuration of the COLR supplementary service. |
| 514 | */ |
| 515 | @Override |
| 516 | public void updateCOLR(int presentation, Message result) { |
| 517 | if (DBG) { |
| 518 | log("updateCOLR :: Ut=" + miUt + ", presentation=" + presentation); |
| 519 | } |
| 520 | |
| 521 | synchronized(mLockObj) { |
| 522 | try { |
| 523 | int id = miUt.updateCOLR(presentation); |
| 524 | |
| 525 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 526 | sendFailureReport(result, |
| 527 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 528 | return; |
| 529 | } |
| 530 | |
| 531 | mPendingCmds.put(Integer.valueOf(id), result); |
| 532 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 533 | sendFailureReport(result, |
| 534 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | /** |
| 540 | * Updates the configuration of the COLP supplementary service. |
| 541 | */ |
| 542 | @Override |
| 543 | public void updateCOLP(boolean enable, Message result) { |
| 544 | if (DBG) { |
| 545 | log("updateCallWaiting :: Ut=" + miUt + ", enable=" + enable); |
| 546 | } |
| 547 | |
| 548 | synchronized(mLockObj) { |
| 549 | try { |
| 550 | int id = miUt.updateCOLP(enable); |
| 551 | |
| 552 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 553 | sendFailureReport(result, |
| 554 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 555 | return; |
| 556 | } |
| 557 | |
| 558 | mPendingCmds.put(Integer.valueOf(id), result); |
| 559 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 560 | sendFailureReport(result, |
| 561 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Etan Cohen | 9b4ca89 | 2014-07-01 09:57:00 -0700 | [diff] [blame] | 562 | } |
| 563 | } |
| 564 | } |
| 565 | |
Brad Ebinger | f68247f | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 566 | /** |
| 567 | * @return returns true if the binder is alive, false otherwise. |
| 568 | */ |
| 569 | public boolean isBinderAlive() { |
| 570 | return miUt.asBinder().isBinderAlive(); |
| 571 | } |
| 572 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 573 | public void transact(Bundle ssInfo, Message result) { |
| 574 | if (DBG) { |
| 575 | log("transact :: Ut=" + miUt + ", ssInfo=" + ssInfo); |
| 576 | } |
| 577 | |
| 578 | synchronized(mLockObj) { |
| 579 | try { |
| 580 | int id = miUt.transact(ssInfo); |
| 581 | |
| 582 | if (id < 0) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 583 | sendFailureReport(result, |
| 584 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 585 | return; |
| 586 | } |
| 587 | |
| 588 | mPendingCmds.put(Integer.valueOf(id), result); |
| 589 | } catch (RemoteException e) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 590 | sendFailureReport(result, |
| 591 | new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 596 | private void sendFailureReport(Message result, ImsReasonInfo error) { |
| 597 | if (result == null || error == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 598 | return; |
| 599 | } |
| 600 | |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 601 | String errorString; |
| 602 | // If ImsReasonInfo object does not have a String error code, use a |
| 603 | // default error string. |
| 604 | if (error.mExtraMessage == null) { |
Leon Luu | 13fd98d | 2015-07-02 13:03:04 +0200 | [diff] [blame] | 605 | errorString = Resources.getSystem().getString( |
| 606 | com.android.internal.R.string.mmiError); |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 607 | } |
| 608 | else { |
| 609 | errorString = new String(error.mExtraMessage); |
| 610 | } |
| 611 | AsyncResult.forMessage(result, null, new ImsException(errorString, error.mCode)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 612 | result.sendToTarget(); |
| 613 | } |
| 614 | |
| 615 | private void sendSuccessReport(Message result) { |
| 616 | if (result == null) { |
| 617 | return; |
| 618 | } |
| 619 | |
| 620 | AsyncResult.forMessage(result, null, null); |
| 621 | result.sendToTarget(); |
| 622 | } |
| 623 | |
| 624 | private void sendSuccessReport(Message result, Object ssInfo) { |
| 625 | if (result == null) { |
| 626 | return; |
| 627 | } |
| 628 | |
| 629 | AsyncResult.forMessage(result, ssInfo, null); |
| 630 | result.sendToTarget(); |
| 631 | } |
| 632 | |
| 633 | private void log(String s) { |
| 634 | Rlog.d(TAG, s); |
| 635 | } |
| 636 | |
| 637 | private void loge(String s) { |
| 638 | Rlog.e(TAG, s); |
| 639 | } |
| 640 | |
| 641 | private void loge(String s, Throwable t) { |
| 642 | Rlog.e(TAG, s, t); |
| 643 | } |
| 644 | |
| 645 | /** |
| 646 | * A listener type for the result of the supplementary service configuration. |
| 647 | */ |
| 648 | private class IImsUtListenerProxy extends IImsUtListener.Stub { |
| 649 | /** |
| 650 | * Notifies the result of the supplementary service configuration udpate. |
| 651 | */ |
| 652 | @Override |
| 653 | public void utConfigurationUpdated(IImsUt ut, int id) { |
| 654 | Integer key = Integer.valueOf(id); |
| 655 | |
| 656 | synchronized(mLockObj) { |
| 657 | sendSuccessReport(mPendingCmds.get(key)); |
| 658 | mPendingCmds.remove(key); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | @Override |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 663 | public void utConfigurationUpdateFailed(IImsUt ut, int id, ImsReasonInfo error) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 664 | Integer key = Integer.valueOf(id); |
| 665 | |
| 666 | synchronized(mLockObj) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 667 | sendFailureReport(mPendingCmds.get(key), error); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 668 | mPendingCmds.remove(key); |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * Notifies the result of the supplementary service configuration query. |
| 674 | */ |
| 675 | @Override |
| 676 | public void utConfigurationQueried(IImsUt ut, int id, Bundle ssInfo) { |
| 677 | Integer key = Integer.valueOf(id); |
| 678 | |
| 679 | synchronized(mLockObj) { |
| 680 | sendSuccessReport(mPendingCmds.get(key), ssInfo); |
| 681 | mPendingCmds.remove(key); |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | @Override |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 686 | public void utConfigurationQueryFailed(IImsUt ut, int id, ImsReasonInfo error) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 687 | Integer key = Integer.valueOf(id); |
| 688 | |
| 689 | synchronized(mLockObj) { |
Shriram Ganesh | f54a9cc | 2014-07-08 18:48:35 -0700 | [diff] [blame] | 690 | sendFailureReport(mPendingCmds.get(key), error); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 691 | mPendingCmds.remove(key); |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | /** |
| 696 | * Notifies the status of the call barring supplementary service. |
| 697 | */ |
| 698 | @Override |
| 699 | public void utConfigurationCallBarringQueried(IImsUt ut, |
| 700 | int id, ImsSsInfo[] cbInfo) { |
| 701 | Integer key = Integer.valueOf(id); |
| 702 | |
| 703 | synchronized(mLockObj) { |
| 704 | sendSuccessReport(mPendingCmds.get(key), cbInfo); |
| 705 | mPendingCmds.remove(key); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | /** |
| 710 | * Notifies the status of the call forwarding supplementary service. |
| 711 | */ |
| 712 | @Override |
| 713 | public void utConfigurationCallForwardQueried(IImsUt ut, |
| 714 | int id, ImsCallForwardInfo[] cfInfo) { |
| 715 | Integer key = Integer.valueOf(id); |
| 716 | |
| 717 | synchronized(mLockObj) { |
| 718 | sendSuccessReport(mPendingCmds.get(key), cfInfo); |
| 719 | mPendingCmds.remove(key); |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | /** |
| 724 | * Notifies the status of the call waiting supplementary service. |
| 725 | */ |
| 726 | @Override |
| 727 | public void utConfigurationCallWaitingQueried(IImsUt ut, |
| 728 | int id, ImsSsInfo[] cwInfo) { |
| 729 | Integer key = Integer.valueOf(id); |
| 730 | |
| 731 | synchronized(mLockObj) { |
| 732 | sendSuccessReport(mPendingCmds.get(key), cwInfo); |
| 733 | mPendingCmds.remove(key); |
| 734 | } |
| 735 | } |
Suresh Koleti | fd1611b | 2017-08-05 11:29:39 +0530 | [diff] [blame] | 736 | |
| 737 | /** |
| 738 | * Notifies client when Supplementary Service indication is received |
| 739 | */ |
| 740 | @Override |
| 741 | public void onSupplementaryServiceIndication(ImsSsData ssData) { |
| 742 | if (mSsIndicationRegistrant != null) { |
| 743 | mSsIndicationRegistrant.notifyResult(ssData); |
| 744 | } |
| 745 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 746 | } |
| 747 | } |