blob: cfc803ca3639e1836908001fa0a361458c3ebcd8 [file] [log] [blame]
Brad Ebinger21013dc2017-02-02 16:21:22 -08001/*
2 * Copyright (C) 2017 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
Brad Ebinger0d36ed22018-10-31 11:22:26 -070019import android.os.Handler;
Brad Ebinger0d36ed22018-10-31 11:22:26 -070020import android.os.Looper;
Brad Ebinger21013dc2017-02-02 16:21:22 -080021import android.os.RemoteException;
22import android.telephony.Rlog;
Brad Ebingerf8c3cd82018-01-22 13:51:52 -080023import android.telephony.ims.ImsReasonInfo;
Brad Ebinger0d36ed22018-10-31 11:22:26 -070024import android.telephony.ims.ProvisioningManager;
Brad Ebinger112c36d2018-01-16 09:33:47 -080025import android.telephony.ims.aidl.IImsConfig;
Brad Ebinger0d36ed22018-10-31 11:22:26 -070026import android.telephony.ims.aidl.IImsConfigCallback;
27
Sooraj Sasindran041a6d32019-12-02 13:08:23 -080028import com.android.internal.telephony.util.HandlerExecutor;
29
Brad Ebinger0d36ed22018-10-31 11:22:26 -070030import java.util.concurrent.Executor;
Brad Ebinger21013dc2017-02-02 16:21:22 -080031
32/**
33 * Provides APIs to get/set the IMS service feature/capability/parameters.
34 * The config items include:
35 * 1) Items provisioned by the operator.
36 * 2) Items configured by user. Mainly service feature class.
37 *
Brad Ebinger0d36ed22018-10-31 11:22:26 -070038 * @deprecated Use {@link ProvisioningManager} to change these configurations in the ImsService.
Brad Ebinger21013dc2017-02-02 16:21:22 -080039 * @hide
40 */
Brad Ebinger0d36ed22018-10-31 11:22:26 -070041@Deprecated
Brad Ebinger21013dc2017-02-02 16:21:22 -080042public class ImsConfig {
43 private static final String TAG = "ImsConfig";
44 private boolean DBG = true;
45 private final IImsConfig miConfig;
Brad Ebinger21013dc2017-02-02 16:21:22 -080046
47 /**
48 * Broadcast action: the feature enable status was changed
49 *
50 * @hide
51 */
52 public static final String ACTION_IMS_FEATURE_CHANGED =
53 "com.android.intent.action.IMS_FEATURE_CHANGED";
54
55 /**
56 * Broadcast action: the configuration was changed
Brad Ebinger0d36ed22018-10-31 11:22:26 -070057 * @deprecated Use {@link android.telephony.ims.ProvisioningManager.Callback} instead.
Brad Ebinger21013dc2017-02-02 16:21:22 -080058 * @hide
59 */
60 public static final String ACTION_IMS_CONFIG_CHANGED =
61 "com.android.intent.action.IMS_CONFIG_CHANGED";
62
63 /**
64 * Extra parameter "item" of intent ACTION_IMS_FEATURE_CHANGED and ACTION_IMS_CONFIG_CHANGED.
65 * It is the value of FeatureConstants or ConfigConstants.
66 *
67 * @hide
68 */
69 public static final String EXTRA_CHANGED_ITEM = "item";
70
71 /**
72 * Extra parameter "value" of intent ACTION_IMS_FEATURE_CHANGED and ACTION_IMS_CONFIG_CHANGED.
73 * It is the new value of "item".
74 *
75 * @hide
76 */
77 public static final String EXTRA_NEW_VALUE = "value";
78
79 /**
80 * Defines IMS service/capability feature constants.
Brad Ebinger112c36d2018-01-16 09:33:47 -080081 * @deprecated Use
82 * {@link android.telephony.ims.feature.MmTelFeature.MmTelCapabilities.MmTelCapability} instead.
Brad Ebinger21013dc2017-02-02 16:21:22 -080083 */
84 public static class FeatureConstants {
85 public static final int FEATURE_TYPE_UNKNOWN = -1;
86
87 /**
88 * FEATURE_TYPE_VOLTE supports features defined in 3GPP and
89 * GSMA IR.92 over LTE.
90 */
91 public static final int FEATURE_TYPE_VOICE_OVER_LTE = 0;
92
93 /**
94 * FEATURE_TYPE_LVC supports features defined in 3GPP and
95 * GSMA IR.94 over LTE.
96 */
97 public static final int FEATURE_TYPE_VIDEO_OVER_LTE = 1;
98
99 /**
100 * FEATURE_TYPE_VOICE_OVER_WIFI supports features defined in 3GPP and
101 * GSMA IR.92 over WiFi.
102 */
103 public static final int FEATURE_TYPE_VOICE_OVER_WIFI = 2;
104
105 /**
106 * FEATURE_TYPE_VIDEO_OVER_WIFI supports features defined in 3GPP and
107 * GSMA IR.94 over WiFi.
108 */
109 public static final int FEATURE_TYPE_VIDEO_OVER_WIFI = 3;
110
111 /**
112 * FEATURE_TYPE_UT supports features defined in 3GPP and
113 * GSMA IR.92 over LTE.
114 */
115 public static final int FEATURE_TYPE_UT_OVER_LTE = 4;
116
117 /**
118 * FEATURE_TYPE_UT_OVER_WIFI supports features defined in 3GPP and
119 * GSMA IR.92 over WiFi.
120 */
121 public static final int FEATURE_TYPE_UT_OVER_WIFI = 5;
122 }
123
124 /**
125 * Defines IMS service/capability parameters.
126 */
127 public static class ConfigConstants {
128
129 // Define IMS config items
130 public static final int CONFIG_START = 0;
131
132 // Define operator provisioned config items
133 public static final int PROVISIONED_CONFIG_START = CONFIG_START;
134
135 /**
136 * AMR CODEC Mode Value set, 0-7 in comma separated sequence.
137 * Value is in String format.
138 */
139 public static final int VOCODER_AMRMODESET = CONFIG_START;
140
141 /**
142 * Wide Band AMR CODEC Mode Value set,0-7 in comma separated sequence.
143 * Value is in String format.
144 */
145 public static final int VOCODER_AMRWBMODESET = 1;
146
147 /**
148 * SIP Session Timer value (seconds).
149 * Value is in Integer format.
150 */
151 public static final int SIP_SESSION_TIMER = 2;
152
153 /**
154 * Minimum SIP Session Expiration Timer in (seconds).
155 * Value is in Integer format.
156 */
157 public static final int MIN_SE = 3;
158
159 /**
160 * SIP_INVITE cancellation time out value (in milliseconds). Integer format.
161 * Value is in Integer format.
162 */
163 public static final int CANCELLATION_TIMER = 4;
164
165 /**
166 * Delay time when an iRAT transition from eHRPD/HRPD/1xRTT to LTE.
167 * Value is in Integer format.
168 */
169 public static final int TDELAY = 5;
170
171 /**
172 * Silent redial status of Enabled (True), or Disabled (False).
173 * Value is in Integer format.
174 */
175 public static final int SILENT_REDIAL_ENABLE = 6;
176
177 /**
178 * SIP T1 timer value in milliseconds. See RFC 3261 for define.
179 * Value is in Integer format.
180 */
181 public static final int SIP_T1_TIMER = 7;
182
183 /**
184 * SIP T2 timer value in milliseconds. See RFC 3261 for define.
185 * Value is in Integer format.
186 */
187 public static final int SIP_T2_TIMER = 8;
188
189 /**
190 * SIP TF timer value in milliseconds. See RFC 3261 for define.
191 * Value is in Integer format.
192 */
193 public static final int SIP_TF_TIMER = 9;
194
195 /**
196 * VoLTE status for VLT/s status of Enabled (1), or Disabled (0).
197 * Value is in Integer format.
198 */
199 public static final int VLT_SETTING_ENABLED = 10;
200
201 /**
202 * VoLTE status for LVC/s status of Enabled (1), or Disabled (0).
203 * Value is in Integer format.
204 */
205 public static final int LVC_SETTING_ENABLED = 11;
206 /**
207 * Domain Name for the device to populate the request URI for REGISTRATION.
208 * Value is in String format.
209 */
210 public static final int DOMAIN_NAME = 12;
211 /**
212 * Device Outgoing SMS based on either 3GPP or 3GPP2 standards.
213 * Value is in Integer format. 3GPP2(0), 3GPP(1)
214 */
215 public static final int SMS_FORMAT = 13;
216 /**
217 * Turns IMS ON/OFF on the device.
218 * Value is in Integer format. ON (1), OFF(0).
219 */
220 public static final int SMS_OVER_IP = 14;
221 /**
222 * Requested expiration for Published Online availability.
223 * Value is in Integer format.
224 */
225 public static final int PUBLISH_TIMER = 15;
226 /**
227 * Requested expiration for Published Offline availability.
228 * Value is in Integer format.
229 */
230 public static final int PUBLISH_TIMER_EXTENDED = 16;
231 /**
232 *
233 * Value is in Integer format.
234 */
235 public static final int CAPABILITY_DISCOVERY_ENABLED = 17;
236 /**
237 * Period of time the capability information of the contact is cached on handset.
238 * Value is in Integer format.
239 */
240 public static final int CAPABILITIES_CACHE_EXPIRATION = 18;
241 /**
242 * Peiod of time the availability information of a contact is cached on device.
243 * Value is in Integer format.
244 */
245 public static final int AVAILABILITY_CACHE_EXPIRATION = 19;
246 /**
247 * Interval between successive capabilities polling.
248 * Value is in Integer format.
249 */
250 public static final int CAPABILITIES_POLL_INTERVAL = 20;
251 /**
252 * Minimum time between two published messages from the device.
253 * Value is in Integer format.
254 */
255 public static final int SOURCE_THROTTLE_PUBLISH = 21;
256 /**
257 * The Maximum number of MDNs contained in one Request Contained List.
258 * Value is in Integer format.
259 */
260 public static final int MAX_NUMENTRIES_IN_RCL = 22;
261 /**
262 * Expiration timer for subscription of a Request Contained List, used in capability
263 * polling.
264 * Value is in Integer format.
265 */
266 public static final int CAPAB_POLL_LIST_SUB_EXP = 23;
267 /**
268 * Applies compression to LIST Subscription.
269 * Value is in Integer format. Enable (1), Disable(0).
270 */
271 public static final int GZIP_FLAG = 24;
272 /**
273 * VOLTE Status for EAB/s status of Enabled (1), or Disabled (0).
274 * Value is in Integer format.
275 */
276 public static final int EAB_SETTING_ENABLED = 25;
277 /**
278 * Wi-Fi calling roaming status.
279 * Value is in Integer format. ON (1), OFF(0).
280 */
Brad Ebingerad9aec32019-01-11 16:36:34 -0800281 public static final int VOICE_OVER_WIFI_ROAMING =
282 ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE;
Brad Ebinger21013dc2017-02-02 16:21:22 -0800283 /**
284 * Wi-Fi calling modem - WfcModeFeatureValueConstants.
285 * Value is in Integer format.
286 */
Brad Ebingerad9aec32019-01-11 16:36:34 -0800287 public static final int VOICE_OVER_WIFI_MODE =
288 ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE;
Brad Ebinger21013dc2017-02-02 16:21:22 -0800289 /**
290 * VOLTE Status for voice over wifi status of Enabled (1), or Disabled (0).
291 * Value is in Integer format.
292 */
293 public static final int VOICE_OVER_WIFI_SETTING_ENABLED = 28;
294 /**
295 * Mobile data enabled.
296 * Value is in Integer format. On (1), OFF(0).
297 */
298 public static final int MOBILE_DATA_ENABLED = 29;
299 /**
300 * VoLTE user opted in status.
301 * Value is in Integer format. Opted-in (1) Opted-out (0).
302 */
303 public static final int VOLTE_USER_OPT_IN_STATUS = 30;
304 /**
305 * Proxy for Call Session Control Function(P-CSCF) address for Local-BreakOut(LBO).
306 * Value is in String format.
307 */
308 public static final int LBO_PCSCF_ADDRESS = 31;
309 /**
310 * Keep Alive Enabled for SIP.
311 * Value is in Integer format. On(1), OFF(0).
312 */
313 public static final int KEEP_ALIVE_ENABLED = 32;
314 /**
315 * Registration retry Base Time value in seconds.
316 * Value is in Integer format.
317 */
318 public static final int REGISTRATION_RETRY_BASE_TIME_SEC = 33;
319 /**
320 * Registration retry Max Time value in seconds.
321 * Value is in Integer format.
322 */
323 public static final int REGISTRATION_RETRY_MAX_TIME_SEC = 34;
324 /**
325 * Smallest RTP port for speech codec.
326 * Value is in integer format.
327 */
328 public static final int SPEECH_START_PORT = 35;
329 /**
330 * Largest RTP port for speech code.
331 * Value is in Integer format.
332 */
333 public static final int SPEECH_END_PORT = 36;
334 /**
335 * SIP Timer A's value in milliseconds. Timer A is the INVITE request
336 * retransmit interval, for UDP only.
337 * Value is in Integer format.
338 */
339 public static final int SIP_INVITE_REQ_RETX_INTERVAL_MSEC = 37;
340 /**
341 * SIP Timer B's value in milliseconds. Timer B is the wait time for
342 * INVITE message to be acknowledged.
343 * Value is in Integer format.
344 */
345 public static final int SIP_INVITE_RSP_WAIT_TIME_MSEC = 38;
346 /**
347 * SIP Timer D's value in milliseconds. Timer D is the wait time for
348 * response retransmits of the invite client transactions.
349 * Value is in Integer format.
350 */
351 public static final int SIP_INVITE_RSP_RETX_WAIT_TIME_MSEC = 39;
352 /**
353 * SIP Timer E's value in milliseconds. Timer E is the value Non-INVITE
354 * request retransmit interval, for UDP only.
355 * Value is in Integer format.
356 */
357 public static final int SIP_NON_INVITE_REQ_RETX_INTERVAL_MSEC = 40;
358 /**
359 * SIP Timer F's value in milliseconds. Timer F is the Non-INVITE transaction
360 * timeout timer.
361 * Value is in Integer format.
362 */
363 public static final int SIP_NON_INVITE_TXN_TIMEOUT_TIMER_MSEC = 41;
364 /**
365 * SIP Timer G's value in milliseconds. Timer G is the value of INVITE response
366 * retransmit interval.
367 * Value is in Integer format.
368 */
369 public static final int SIP_INVITE_RSP_RETX_INTERVAL_MSEC = 42;
370 /**
371 * SIP Timer H's value in milliseconds. Timer H is the value of wait time for
372 * ACK receipt.
373 * Value is in Integer format.
374 */
375 public static final int SIP_ACK_RECEIPT_WAIT_TIME_MSEC = 43;
376 /**
377 * SIP Timer I's value in milliseconds. Timer I is the value of wait time for
378 * ACK retransmits.
379 * Value is in Integer format.
380 */
381 public static final int SIP_ACK_RETX_WAIT_TIME_MSEC = 44;
382 /**
383 * SIP Timer J's value in milliseconds. Timer J is the value of wait time for
384 * non-invite request retransmission.
385 * Value is in Integer format.
386 */
387 public static final int SIP_NON_INVITE_REQ_RETX_WAIT_TIME_MSEC = 45;
388 /**
389 * SIP Timer K's value in milliseconds. Timer K is the value of wait time for
390 * non-invite response retransmits.
391 * Value is in Integer format.
392 */
393 public static final int SIP_NON_INVITE_RSP_RETX_WAIT_TIME_MSEC = 46;
394 /**
395 * AMR WB octet aligned dynamic payload type.
396 * Value is in Integer format.
397 */
398 public static final int AMR_WB_OCTET_ALIGNED_PT = 47;
399 /**
400 * AMR WB bandwidth efficient payload type.
401 * Value is in Integer format.
402 */
403 public static final int AMR_WB_BANDWIDTH_EFFICIENT_PT = 48;
404 /**
405 * AMR octet aligned dynamic payload type.
406 * Value is in Integer format.
407 */
408 public static final int AMR_OCTET_ALIGNED_PT = 49;
409 /**
410 * AMR bandwidth efficient payload type.
411 * Value is in Integer format.
412 */
413 public static final int AMR_BANDWIDTH_EFFICIENT_PT = 50;
414 /**
415 * DTMF WB payload type.
416 * Value is in Integer format.
417 */
418 public static final int DTMF_WB_PT = 51;
419 /**
420 * DTMF NB payload type.
421 * Value is in Integer format.
422 */
423 public static final int DTMF_NB_PT = 52;
424 /**
425 * AMR Default encoding mode.
426 * Value is in Integer format.
427 */
428 public static final int AMR_DEFAULT_MODE = 53;
429 /**
430 * SMS Public Service Identity.
431 * Value is in String format.
432 */
433 public static final int SMS_PSI = 54;
434 /**
435 * Video Quality - VideoQualityFeatureValuesConstants.
436 * Value is in Integer format.
437 */
438 public static final int VIDEO_QUALITY = 55;
439 /**
440 * LTE threshold.
441 * Handover from LTE to WiFi if LTE < THLTE1 and WiFi >= VOWT_A.
442 */
443 public static final int TH_LTE1 = 56;
444 /**
445 * LTE threshold.
446 * Handover from WiFi to LTE if LTE >= THLTE3 or (WiFi < VOWT_B and LTE >= THLTE2).
447 */
448 public static final int TH_LTE2 = 57;
449 /**
450 * LTE threshold.
451 * Handover from WiFi to LTE if LTE >= THLTE3 or (WiFi < VOWT_B and LTE >= THLTE2).
452 */
453 public static final int TH_LTE3 = 58;
454 /**
455 * 1x threshold.
456 * Handover from 1x to WiFi if 1x < TH1x
457 */
458 public static final int TH_1x = 59;
459 /**
460 * WiFi threshold.
461 * Handover from LTE to WiFi if LTE < THLTE1 and WiFi >= VOWT_A.
462 */
463 public static final int VOWT_A = 60;
464 /**
465 * WiFi threshold.
466 * Handover from WiFi to LTE if LTE >= THLTE3 or (WiFi < VOWT_B and LTE >= THLTE2).
467 */
468 public static final int VOWT_B = 61;
469 /**
470 * LTE ePDG timer.
471 * Device shall not handover back to LTE until the T_ePDG_LTE timer expires.
472 */
473 public static final int T_EPDG_LTE = 62;
474 /**
475 * WiFi ePDG timer.
476 * Device shall not handover back to WiFi until the T_ePDG_WiFi timer expires.
477 */
478 public static final int T_EPDG_WIFI = 63;
479 /**
480 * 1x ePDG timer.
481 * Device shall not re-register on 1x until the T_ePDG_1x timer expires.
482 */
483 public static final int T_EPDG_1X = 64;
484 /**
485 * MultiEndpoint status: Enabled (1), or Disabled (0).
486 * Value is in Integer format.
487 */
488 public static final int VICE_SETTING_ENABLED = 65;
489
Anju Mathapati7e177da2017-01-24 11:58:28 -0800490 /**
491 * RTT status: Enabled (1), or Disabled (0).
492 * Value is in Integer format.
493 */
494 public static final int RTT_SETTING_ENABLED = 66;
495
Brad Ebinger21013dc2017-02-02 16:21:22 -0800496 // Expand the operator config items as needed here, need to change
497 // PROVISIONED_CONFIG_END after that.
Anju Mathapati7e177da2017-01-24 11:58:28 -0800498 public static final int PROVISIONED_CONFIG_END = RTT_SETTING_ENABLED;
Brad Ebinger21013dc2017-02-02 16:21:22 -0800499
500 // Expand the operator config items as needed here.
501 }
502
503 /**
504 * Defines IMS set operation status.
505 */
506 public static class OperationStatusConstants {
507 public static final int UNKNOWN = -1;
508 public static final int SUCCESS = 0;
509 public static final int FAILED = 1;
510 public static final int UNSUPPORTED_CAUSE_NONE = 2;
511 public static final int UNSUPPORTED_CAUSE_RAT = 3;
512 public static final int UNSUPPORTED_CAUSE_DISABLED = 4;
513 }
514
515 /**
516 * Defines IMS get operation values.
517 */
518 public static class OperationValuesConstants {
519 /**
520 * Values related to Video Quality
521 */
522 public static final int VIDEO_QUALITY_UNKNOWN = -1;
523 public static final int VIDEO_QUALITY_LOW = 0;
524 public static final int VIDEO_QUALITY_HIGH = 1;
525 }
526
527 /**
528 * Defines IMS video quality feature value.
529 */
530 public static class VideoQualityFeatureValuesConstants {
531 public static final int LOW = 0;
532 public static final int HIGH = 1;
533 }
534
535 /**
536 * Defines IMS feature value.
537 */
538 public static class FeatureValueConstants {
Brad Ebinger27ca2682017-08-25 14:53:30 -0700539 public static final int ERROR = -1;
Brad Ebinger21013dc2017-02-02 16:21:22 -0800540 public static final int OFF = 0;
541 public static final int ON = 1;
542 }
543
544 /**
545 * Defines IMS feature value.
546 */
547 public static class WfcModeFeatureValueConstants {
548 public static final int WIFI_ONLY = 0;
549 public static final int CELLULAR_PREFERRED = 1;
550 public static final int WIFI_PREFERRED = 2;
551 }
552
Brad Ebinger515021e2018-04-26 14:27:10 -0700553 public ImsConfig(IImsConfig iconfig) {
Brad Ebinger21013dc2017-02-02 16:21:22 -0800554 miConfig = iconfig;
Brad Ebinger21013dc2017-02-02 16:21:22 -0800555 }
556
557 /**
Brad Ebinger515021e2018-04-26 14:27:10 -0700558 * @deprecated see {@link #getConfigInt(int)} instead.
Brad Ebinger112c36d2018-01-16 09:33:47 -0800559 */
560 public int getProvisionedValue(int item) throws ImsException {
561 return getConfigInt(item);
562 }
563
564 /**
565 * Gets the configuration value for IMS service/capabilities parameters used by IMS stack.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800566 *
567 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
568 * @return the value in Integer format.
Brad Ebinger112c36d2018-01-16 09:33:47 -0800569 * @throws ImsException if the ImsService is unavailable.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800570 */
Brad Ebinger112c36d2018-01-16 09:33:47 -0800571 public int getConfigInt(int item) throws ImsException {
Brad Ebinger21013dc2017-02-02 16:21:22 -0800572 int ret = 0;
573 try {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800574 ret = miConfig.getConfigInt(item);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800575 } catch (RemoteException e) {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800576 throw new ImsException("getInt()", e,
Brad Ebinger21013dc2017-02-02 16:21:22 -0800577 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
578 }
Brad Ebinger112c36d2018-01-16 09:33:47 -0800579 if (DBG) Rlog.d(TAG, "getInt(): item = " + item + ", ret =" + ret);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800580
581 return ret;
582 }
583
584 /**
Brad Ebinger112c36d2018-01-16 09:33:47 -0800585 * @deprecated see {@link #getConfigString(int)} instead
586 */
587 public String getProvisionedStringValue(int item) throws ImsException {
588 return getConfigString(item);
589 }
590
591 /**
592 * Gets the configuration value for IMS service/capabilities parameters used by IMS stack.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800593 *
594 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
595 * @return value in String format.
596 *
Brad Ebinger112c36d2018-01-16 09:33:47 -0800597 * @throws ImsException if the ImsService is unavailable.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800598 */
Brad Ebinger112c36d2018-01-16 09:33:47 -0800599 public String getConfigString(int item) throws ImsException {
Brad Ebinger21013dc2017-02-02 16:21:22 -0800600 String ret = "Unknown";
601 try {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800602 ret = miConfig.getConfigString(item);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800603 } catch (RemoteException e) {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800604 throw new ImsException("getConfigString()", e,
Brad Ebinger21013dc2017-02-02 16:21:22 -0800605 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
606 }
Brad Ebinger112c36d2018-01-16 09:33:47 -0800607 if (DBG) Rlog.d(TAG, "getConfigString(): item = " + item + ", ret =" + ret);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800608
609 return ret;
610 }
611
612 /**
Brad Ebinger112c36d2018-01-16 09:33:47 -0800613 * @deprecated see {@link #setConfig(int, int)} instead.
614 */
615 public int setProvisionedValue(int item, int value) throws ImsException {
616 return setConfig(item, value);
617 }
618
619 /**
620 * @deprecated see {@link #setConfig(int, String)} instead.
621 */
622 public int setProvisionedStringValue(int item, String value) throws ImsException {
623 return setConfig(item, value);
624 }
625
626 /**
627 * Sets the value for ImsService configuration item.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800628 *
629 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
630 * @param value in Integer format.
631 * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants
632 *
Brad Ebinger112c36d2018-01-16 09:33:47 -0800633 * @throws ImsException if the ImsService is unavailable.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800634 */
Brad Ebinger112c36d2018-01-16 09:33:47 -0800635 public int setConfig(int item, int value) throws ImsException {
Brad Ebinger21013dc2017-02-02 16:21:22 -0800636 int ret = OperationStatusConstants.UNKNOWN;
637 if (DBG) {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800638 Rlog.d(TAG, "setConfig(): item = " + item +
Brad Ebinger21013dc2017-02-02 16:21:22 -0800639 "value = " + value);
640 }
641 try {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800642 ret = miConfig.setConfigInt(item, value);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800643 } catch (RemoteException e) {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800644 throw new ImsException("setConfig()", e,
Brad Ebinger21013dc2017-02-02 16:21:22 -0800645 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
646 }
647 if (DBG) {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800648 Rlog.d(TAG, "setConfig(): item = " + item +
649 " value = " + value + " ret = " + ret);
650 }
651
652 return ret;
653
654 }
655
656 /**
657 * Sets the value for ImsService configuration item.
658 *
659 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
660 * @param value in Integer format.
661 * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants
662 *
663 * @throws ImsException if the ImsService is unavailable.
664 */
665 public int setConfig(int item, String value) throws ImsException {
666 int ret = OperationStatusConstants.UNKNOWN;
667 if (DBG) {
668 Rlog.d(TAG, "setConfig(): item = " + item +
669 "value = " + value);
670 }
671 try {
672 ret = miConfig.setConfigString(item, value);
673 } catch (RemoteException e) {
674 throw new ImsException("setConfig()", e,
675 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
676 }
677 if (DBG) {
678 Rlog.d(TAG, "setConfig(): item = " + item +
Brad Ebinger21013dc2017-02-02 16:21:22 -0800679 " value = " + value + " ret = " + ret);
680 }
Malcolm Chen2b460022017-11-01 13:19:30 -0700681
Brad Ebinger21013dc2017-02-02 16:21:22 -0800682 return ret;
683 }
684
685 /**
Brad Ebinger0d36ed22018-10-31 11:22:26 -0700686 * Adds a {@link ProvisioningManager.Callback} to the ImsService to notify when a Configuration
Brad Ebinger112c36d2018-01-16 09:33:47 -0800687 * item has changed.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800688 *
Brad Ebinger0d36ed22018-10-31 11:22:26 -0700689 * Make sure to call {@link #removeConfigCallback(IImsConfigCallback)} when finished
Brad Ebinger112c36d2018-01-16 09:33:47 -0800690 * using this callback.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800691 */
Brad Ebinger0d36ed22018-10-31 11:22:26 -0700692 public void addConfigCallback(ProvisioningManager.Callback callback) throws ImsException {
693 callback.setExecutor(getThreadExecutor());
694 addConfigCallback(callback.getBinder());
695 }
696
697 /**
698 * Adds a {@link IImsConfigCallback} to the ImsService to notify when a Configuration
699 * item has changed.
700 *
701 * Make sure to call {@link #removeConfigCallback(IImsConfigCallback)} when finished
702 * using this callback.
703 */
704 public void addConfigCallback(IImsConfigCallback callback) throws ImsException {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800705 if (DBG) Rlog.d(TAG, "addConfigCallback: " + callback);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800706 try {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800707 miConfig.addImsConfigCallback(callback);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800708 } catch (RemoteException e) {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800709 throw new ImsException("addConfigCallback()", e,
Brad Ebinger21013dc2017-02-02 16:21:22 -0800710 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
711 }
712 }
713
714 /**
Brad Ebinger0d36ed22018-10-31 11:22:26 -0700715 * Removes an existing {@link IImsConfigCallback} from the ImsService.
Brad Ebinger21013dc2017-02-02 16:21:22 -0800716 */
Brad Ebinger0d36ed22018-10-31 11:22:26 -0700717 public void removeConfigCallback(IImsConfigCallback callback) throws ImsException {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800718 if (DBG) Rlog.d(TAG, "removeConfigCallback: " + callback);
Brad Ebinger21013dc2017-02-02 16:21:22 -0800719 try {
Brad Ebinger112c36d2018-01-16 09:33:47 -0800720 miConfig.removeImsConfigCallback(callback);
721 } catch (RemoteException e) {
722 throw new ImsException("removeConfigCallback()", e,
Brad Ebinger21013dc2017-02-02 16:21:22 -0800723 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
724 }
725 }
Brad Ebingerc24bc102017-06-22 11:39:11 -0700726
727 /**
728 * @return true if the binder connection is alive, false otherwise.
729 */
730 public boolean isBinderAlive() {
731 return miConfig.asBinder().isBinderAlive();
732 }
Brad Ebinger0d36ed22018-10-31 11:22:26 -0700733
734 private Executor getThreadExecutor() {
735 if (Looper.myLooper() == null) {
736 Looper.prepare();
737 }
738 return new HandlerExecutor(new Handler(Looper.myLooper()));
739 }
Brad Ebinger21013dc2017-02-02 16:21:22 -0800740}