blob: b3d4c8af2f95ac548f2a34d6c553a7a183c7f542 [file] [log] [blame]
Wink Savilleef36ef62014-06-11 08:39:38 -07001/*
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 java.util.HashMap;
20import java.util.Map;
21
Leon Luu13fd98d2015-07-02 13:03:04 +020022import android.content.res.Resources;
Wink Savilleef36ef62014-06-11 08:39:38 -070023import android.os.AsyncResult;
24import android.os.Bundle;
Suresh Koletifd1611b2017-08-05 11:29:39 +053025import android.os.Handler;
Wink Savilleef36ef62014-06-11 08:39:38 -070026import android.os.Message;
Suresh Koletifd1611b2017-08-05 11:29:39 +053027import android.os.Registrant;
Wink Savilleef36ef62014-06-11 08:39:38 -070028import android.os.RemoteException;
29import android.telephony.Rlog;
Brad Ebinger190ed932018-01-23 13:41:32 -080030import android.telephony.ims.ImsCallForwardInfo;
31import android.telephony.ims.ImsReasonInfo;
32import android.telephony.ims.ImsSsData;
33import android.telephony.ims.ImsSsInfo;
Wink Savilleef36ef62014-06-11 08:39:38 -070034
35import com.android.ims.internal.IImsUt;
36import 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 */
45public 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 Ravuri7e083d82016-10-25 18:17:26 +053076 //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 Savilleef36ef62014-06-11 08:39:38 -070080 // 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 Koletifd1611b2017-08-05 11:29:39 +053085 private Registrant mSsIndicationRegistrant;
Wink Savilleef36ef62014-06-11 08:39:38 -070086
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700113 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700114 }
115
116 mPendingCmds.clear();
117 }
118 }
119 }
120
121 /**
Suresh Koletifd1611b2017-08-05 11:29:39 +0530122 * 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 Savilleef36ef62014-06-11 08:39:38 -0700139 * 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 Ravuri7e083d82016-10-25 18:17:26 +0530148 * @deprecated Use {@link #queryCallBarring(int, Message, int)} instead.
Wink Savilleef36ef62014-06-11 08:39:38 -0700149 */
150 @Override
151 public void queryCallBarring(int cbType, Message result) {
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530152 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 Savilleef36ef62014-06-11 08:39:38 -0700165 if (DBG) {
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530166 log("queryCallBarring :: Ut=" + miUt + ", cbType=" + cbType + ", serviceClass="
167 + serviceClass);
Wink Savilleef36ef62014-06-11 08:39:38 -0700168 }
169
170 synchronized(mLockObj) {
171 try {
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530172 int id = miUt.queryCallBarringForServiceClass(cbType, serviceClass);
Wink Savilleef36ef62014-06-11 08:39:38 -0700173
174 if (id < 0) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700175 sendFailureReport(result,
176 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700177 return;
178 }
179
180 mPendingCmds.put(Integer.valueOf(id), result);
181 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700182 sendFailureReport(result,
183 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700184 }
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 Sakaifb688ca2016-12-06 20:32:07 +0900196 + ", number=" + Rlog.pii(TAG, number));
Wink Savilleef36ef62014-06-11 08:39:38 -0700197 }
198
199 synchronized(mLockObj) {
200 try {
201 int id = miUt.queryCallForward(condition, number);
202
203 if (id < 0) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700204 sendFailureReport(result,
205 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700206 return;
207 }
208
209 mPendingCmds.put(Integer.valueOf(id), result);
210 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700211 sendFailureReport(result,
212 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700213 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700232 sendFailureReport(result,
233 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700234 return;
235 }
236
237 mPendingCmds.put(Integer.valueOf(id), result);
238 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700239 sendFailureReport(result,
240 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700241 }
242 }
243 }
244
245 /**
Etan Cohen9b4ca892014-07-01 09:57:00 -0700246 * 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 Ganeshf54a9cc2014-07-08 18:48:35 -0700259 sendFailureReport(result,
260 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700261 return;
262 }
263
264 mPendingCmds.put(Integer.valueOf(id), result);
265 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700266 sendFailureReport(result,
267 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700268 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700285 sendFailureReport(result,
286 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700287 return;
288 }
289
290 mPendingCmds.put(Integer.valueOf(id), result);
291 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700292 sendFailureReport(result,
293 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700294 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700311 sendFailureReport(result,
312 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700313 return;
314 }
315
316 mPendingCmds.put(Integer.valueOf(id), result);
317 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700318 sendFailureReport(result,
319 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700320 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700337 sendFailureReport(result,
338 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700339 return;
340 }
341
342 mPendingCmds.put(Integer.valueOf(id), result);
343 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700344 sendFailureReport(result,
345 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700346 }
347 }
348 }
349
350 /**
Wink Savilleef36ef62014-06-11 08:39:38 -0700351 * Modifies the configuration of the call barring.
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530352 * @deprecated Use {@link #updateCallBarring(int, int, Message, String[], int)} instead.
Wink Savilleef36ef62014-06-11 08:39:38 -0700353 */
354 @Override
Shriram Ganeshd3adfad2015-05-31 10:06:15 -0700355 public void updateCallBarring(int cbType, int action, Message result, String[] barrList) {
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530356 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 Savilleef36ef62014-06-11 08:39:38 -0700365 if (DBG) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700366 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 Ravuri7e083d82016-10-25 18:17:26 +0530372 + ", action=" + action + ", serviceClass=" + serviceClass
373 + ", barrList=" + bList);
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700374 }
375 else {
376 log("updateCallBarring :: Ut=" + miUt + ", cbType=" + cbType
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530377 + ", action=" + action + ", serviceClass=" + serviceClass);
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700378 }
Wink Savilleef36ef62014-06-11 08:39:38 -0700379 }
380
381 synchronized(mLockObj) {
382 try {
Benergy Meenan Ravuri7e083d82016-10-25 18:17:26 +0530383 int id = miUt.updateCallBarringForServiceClass(cbType, action,
384 barrList, serviceClass);
Wink Savilleef36ef62014-06-11 08:39:38 -0700385
386 if (id < 0) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700387 sendFailureReport(result,
388 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700389 return;
390 }
391
392 mPendingCmds.put(Integer.valueOf(id), result);
393 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700394 sendFailureReport(result,
395 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700396 }
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 Kolangade48738d52015-01-31 11:31:00 +0530405 int serviceClass, int timeSeconds, Message result) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700406 if (DBG) {
407 log("updateCallForward :: Ut=" + miUt + ", action=" + action
Shunta Sakaifb688ca2016-12-06 20:32:07 +0900408 + ", condition=" + condition + ", number=" + Rlog.pii(TAG, number)
409 + ", serviceClass=" + serviceClass + ", timeSeconds=" + timeSeconds);
Wink Savilleef36ef62014-06-11 08:39:38 -0700410 }
411
412 synchronized(mLockObj) {
413 try {
Omkar Kolangade48738d52015-01-31 11:31:00 +0530414 int id = miUt.updateCallForward(action, condition, number, serviceClass, timeSeconds);
Wink Savilleef36ef62014-06-11 08:39:38 -0700415
416 if (id < 0) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700417 sendFailureReport(result,
418 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700419 return;
420 }
421
422 mPendingCmds.put(Integer.valueOf(id), result);
423 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700424 sendFailureReport(result,
425 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700426 }
427 }
428 }
429
430 /**
431 * Modifies the configuration of the call waiting.
432 */
433 @Override
Omkar Kolangade48738d52015-01-31 11:31:00 +0530434 public void updateCallWaiting(boolean enable, int serviceClass, Message result) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700435 if (DBG) {
Omkar Kolangade48738d52015-01-31 11:31:00 +0530436 log("updateCallWaiting :: Ut=" + miUt + ", enable=" + enable
437 + ",serviceClass=" + serviceClass);
Wink Savilleef36ef62014-06-11 08:39:38 -0700438 }
439
440 synchronized(mLockObj) {
441 try {
Omkar Kolangade48738d52015-01-31 11:31:00 +0530442 int id = miUt.updateCallWaiting(enable, serviceClass);
Wink Savilleef36ef62014-06-11 08:39:38 -0700443
444 if (id < 0) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700445 sendFailureReport(result,
446 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700447 return;
448 }
449
450 mPendingCmds.put(Integer.valueOf(id), result);
451 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700452 sendFailureReport(result,
453 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700454 }
455 }
456 }
457
Etan Cohen9b4ca892014-07-01 09:57:00 -0700458 /**
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700472 sendFailureReport(result,
473 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700474 return;
475 }
476
477 mPendingCmds.put(Integer.valueOf(id), result);
478 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700479 sendFailureReport(result,
480 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700481 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700499 sendFailureReport(result,
500 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700501 return;
502 }
503
504 mPendingCmds.put(Integer.valueOf(id), result);
505 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700506 sendFailureReport(result,
507 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700508 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700526 sendFailureReport(result,
527 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700528 return;
529 }
530
531 mPendingCmds.put(Integer.valueOf(id), result);
532 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700533 sendFailureReport(result,
534 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700535 }
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 Ganeshf54a9cc2014-07-08 18:48:35 -0700553 sendFailureReport(result,
554 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700555 return;
556 }
557
558 mPendingCmds.put(Integer.valueOf(id), result);
559 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700560 sendFailureReport(result,
561 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Etan Cohen9b4ca892014-07-01 09:57:00 -0700562 }
563 }
564 }
565
Brad Ebingerf68247f2017-06-20 16:29:50 -0700566 /**
567 * @return returns true if the binder is alive, false otherwise.
568 */
569 public boolean isBinderAlive() {
570 return miUt.asBinder().isBinderAlive();
571 }
572
Wink Savilleef36ef62014-06-11 08:39:38 -0700573 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 Ganeshf54a9cc2014-07-08 18:48:35 -0700583 sendFailureReport(result,
584 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700585 return;
586 }
587
588 mPendingCmds.put(Integer.valueOf(id), result);
589 } catch (RemoteException e) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700590 sendFailureReport(result,
591 new ImsReasonInfo(ImsReasonInfo.CODE_UT_SERVICE_UNAVAILABLE, 0));
Wink Savilleef36ef62014-06-11 08:39:38 -0700592 }
593 }
594 }
595
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700596 private void sendFailureReport(Message result, ImsReasonInfo error) {
597 if (result == null || error == null) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700598 return;
599 }
600
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700601 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 Luu13fd98d2015-07-02 13:03:04 +0200605 errorString = Resources.getSystem().getString(
606 com.android.internal.R.string.mmiError);
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700607 }
608 else {
609 errorString = new String(error.mExtraMessage);
610 }
611 AsyncResult.forMessage(result, null, new ImsException(errorString, error.mCode));
Wink Savilleef36ef62014-06-11 08:39:38 -0700612 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 Ganeshf54a9cc2014-07-08 18:48:35 -0700663 public void utConfigurationUpdateFailed(IImsUt ut, int id, ImsReasonInfo error) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700664 Integer key = Integer.valueOf(id);
665
666 synchronized(mLockObj) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700667 sendFailureReport(mPendingCmds.get(key), error);
Wink Savilleef36ef62014-06-11 08:39:38 -0700668 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 Ganeshf54a9cc2014-07-08 18:48:35 -0700686 public void utConfigurationQueryFailed(IImsUt ut, int id, ImsReasonInfo error) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700687 Integer key = Integer.valueOf(id);
688
689 synchronized(mLockObj) {
Shriram Ganeshf54a9cc2014-07-08 18:48:35 -0700690 sendFailureReport(mPendingCmds.get(key), error);
Wink Savilleef36ef62014-06-11 08:39:38 -0700691 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 Koletifd1611b2017-08-05 11:29:39 +0530736
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 Savilleef36ef62014-06-11 08:39:38 -0700746 }
747}