2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Threading.Tasks;
19 using System.Runtime.InteropServices;
20 using System.Collections.Generic;
26 /// A class which manages SIM card services.
30 private IntPtr _handle = IntPtr.Zero;
31 private Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback> _callbackMap = new Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback>();
32 private int _requestId = 0;
38 /// A constructor to instantiate Sim class using the Tapi handle.
40 /// <param name="handle">An instance of TapiHandle obtained from InitTapi in TapiManager API.</param>
41 /// <exception cref="ArgumentNullException">Thrown when handle is passed as null.</exception>
42 public Sim(TapiHandle handle)
46 throw new ArgumentNullException("Handle is null");
49 _handle = handle._handle;
53 /// Gets SIM card initialization status and SIM card identification.
55 /// <value>An instance of SimInitInfo class in case of success. Null in case of failure.</value>
56 public SimInitInfo InitInfo
62 int ret = Interop.Tapi.Sim.SimGetInitInfo(_handle, out status, out isCardChanged);
63 if (ret != (int)TapiError.Success)
65 Log.Error(TapiUtility.LogTag, "Failed to get SIM init info, Error: " + (TapiError)ret);
69 SimInitInfo initInfo = new SimInitInfo();
70 initInfo.SimStatus = status;
71 if (isCardChanged == 1)
73 initInfo.IsChanged = true;
76 else if (isCardChanged == 0)
78 initInfo.IsChanged = false;
86 /// Gets the card type (SIM/USIM).
88 public SimCardType SimType
93 int ret = Interop.Tapi.Sim.SimGetType(_handle, out type);
94 if (ret != (int)TapiError.Success)
96 Log.Error(TapiUtility.LogTag, "Failed to get SIM card type, Error: " + (TapiError)ret);
97 return default(SimCardType);
105 /// Gets SIM IMSI information.
107 public SimImsiInfo Imsi
111 SimImsiInfoStruct imsi;
112 int ret = Interop.Tapi.Sim.SimGetImsi(_handle, out imsi);
113 if (ret != (int)TapiError.Success)
115 Log.Error(TapiUtility.LogTag, "Failed to get SIM IMSI info, Error: " + (TapiError)ret);
119 return SimStructConversions.ConvertSimImsiInfoStruct(imsi);
124 /// Gets ECC(SIM) or UECC(USIM) data.
126 public SimEccInfoList Ecc
130 SimEccInfoListStruct eccInfo;
131 int ret = Interop.Tapi.Sim.SimGetEcc(_handle, out eccInfo);
132 if (ret != (int)TapiError.Success)
134 Log.Error(TapiUtility.LogTag, "Failed to get SIM ECC info, Error: " + (TapiError)ret);
138 return SimStructConversions.ConvertSimEccInfoListStruct(eccInfo);
143 /// Gets the list of application on UICC.
145 /// <returns>A byte containing the masking value for SimAppType.</returns>
146 /// <feature>http://tizen.org/feature/network.telephony</feature>
147 /// <privilege>http://tizen.org/privilege/telephony</privilege>
148 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
149 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
150 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
151 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
152 public byte SimGetApplicationList()
155 int ret = Interop.Tapi.Sim.SimGetApplicationList(_handle, out appList);
156 if (ret != (int)TapiError.Success)
158 Log.Error(TapiUtility.LogTag, "Failed to get list of applications, Error: " + (TapiError)ret);
159 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
166 /// Gets the unique identification number of the (U)ICC.
168 /// <returns>A task containing ICCID information.</returns>
169 /// <feature>http://tizen.org/feature/network.telephony</feature>
170 /// <privilege>http://tizen.org/privilege/telephony</privilege>
171 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
172 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
173 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
174 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
175 public Task<SimIccIdInfo> SimGetIccId()
177 TaskCompletionSource<SimIccIdInfo> task = new TaskCompletionSource<SimIccIdInfo>();
178 IntPtr id = (IntPtr)_requestId++;
179 _callbackMap[id] = (handle, result, data, key) =>
181 Task taskResult = new Task(() =>
183 if (result != (int)SimAccessResult.Success)
185 Log.Error(TapiUtility.LogTag, "Error occurs in getting ICCID info: " + (SimAccessResult)result);
186 task.SetException(new InvalidOperationException("Error occurs in getting ICCID info, " + (SimAccessResult)result));
190 SimIccIdInfoStruct info = Marshal.PtrToStructure<SimIccIdInfoStruct>(data);
191 task.SetResult(SimStructConversions.ConvertSimIccIdInfoStruct(info));
195 _callbackMap.Remove(key);
198 int ret = Interop.Tapi.Sim.SimGetIccId(_handle, _callbackMap[id], id);
199 if (ret != (int)TapiError.Success)
201 Log.Error(TapiUtility.LogTag, "Failed to get SIM ICCID info, Error: " + (TapiError)ret);
202 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
209 /// Gets language preference(indication) information.
211 /// <returns>A task containing information about SIM language preference.</returns>
212 /// <feature>http://tizen.org/feature/network.telephony</feature>
213 /// <privilege>http://tizen.org/privilege/telephony</privilege>
214 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
215 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
216 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
217 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
218 public Task<SimLanguagePreference> SimGetLanguagePreference()
220 TaskCompletionSource<SimLanguagePreference> task = new TaskCompletionSource<SimLanguagePreference>();
221 IntPtr id = (IntPtr)_requestId++;
222 _callbackMap[id] = (handle, result, data, key) =>
224 Task taskResult = new Task(() =>
226 if (result != (int)SimAccessResult.Success)
228 Log.Error(TapiUtility.LogTag, "Error occurs in getting language preference: " + (SimAccessResult)result);
229 task.SetException(new InvalidOperationException("Error occurs in getting language preference, " + (SimAccessResult)result));
233 task.SetResult((SimLanguagePreference)Marshal.ReadInt32(data));
237 _callbackMap.Remove(key);
240 int ret = Interop.Tapi.Sim.SimGetLanguage(_handle, _callbackMap[id], id);
241 if (ret != (int)TapiError.Success)
243 Log.Error(TapiUtility.LogTag, "Failed to get SIM language preference, Error: " + (TapiError)ret);
244 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
251 /// Updates language preference information to the SIM card.
253 /// <param name="language">The language preference information.</param>
254 /// <returns>A task indicating whether setting of language preference is done or not.</returns>
255 /// <feature>http://tizen.org/feature/network.telephony</feature>
256 /// <privlevel>platform</privlevel>
257 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
258 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
259 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
260 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
261 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
262 public Task<bool> SimSetLanguagePreference(SimLanguagePreference language)
264 TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
265 IntPtr id = (IntPtr)_requestId++;
266 _callbackMap[id] = (handle, result, data, key) =>
268 Task taskResult = new Task(() =>
270 if (result != (int)SimAccessResult.Success)
272 Log.Error(TapiUtility.LogTag, "Error occurs in setting language preference: " + (SimAccessResult)result);
273 task.SetException(new InvalidOperationException("Error occurs in setting language preference, " + (SimAccessResult)result));
277 task.SetResult(true);
281 _callbackMap.Remove(key);
284 int ret = Interop.Tapi.Sim.SimSetLanguage(_handle, language, _callbackMap[id], id);
285 if (ret != (int)TapiError.Success)
287 Log.Error(TapiUtility.LogTag, "Failed to set SIM language preference, Error: " + (TapiError)ret);
288 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
295 /// Gets SIM call forwarding indication related data(EF-CFIS and CPHS case).
297 /// <returns>A task containing call forward response information.</returns>
298 /// <feature>http://tizen.org/feature/network.telephony</feature>
299 /// <privilege>http://tizen.org/privilege/telephony</privilege>
300 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
301 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
302 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
303 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
304 public Task<SimCallForwardResponse> SimGetCallForwardInfo()
306 TaskCompletionSource<SimCallForwardResponse> task = new TaskCompletionSource<SimCallForwardResponse>();
307 IntPtr id = (IntPtr)_requestId++;
308 _callbackMap[id] = (handle, result, data, key) =>
310 Task taskResult = new Task(() =>
312 if (result != (int)SimAccessResult.Success)
314 Log.Error(TapiUtility.LogTag, "Error occurs in getting call forward info: " + (SimAccessResult)result);
315 task.SetException(new InvalidOperationException("Error occurs in getting call forward info, " + (SimAccessResult)result));
319 SimCallForwardResponseStruct info = Marshal.PtrToStructure<SimCallForwardResponseStruct>(data);
320 task.SetResult(SimStructConversions.ConvertSimCallForwardResponseStruct(info));
324 _callbackMap.Remove(key);
327 int ret = Interop.Tapi.Sim.SimGetCallForwardingInfo(_handle, _callbackMap[id], id);
328 if (ret != (int)TapiError.Success)
330 Log.Error(TapiUtility.LogTag, "Failed to get SIM call forward info, Error: " + (TapiError)ret);
331 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
338 /// Sets SIM call forwarding indication related data(EF-CFIS and CPHS case).
340 /// <param name="request">The data requesting for call forwarding.</param>
341 /// <returns>A task indicating whether setting call forward info is done or not.</returns>
342 /// <feature>http://tizen.org/feature/network.telephony</feature>
343 /// <privlevel>platform</privlevel>
344 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
345 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
346 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
347 /// <exception cref="ArgumentNullException">Thrown when call forward request is passed as null.</exception>
348 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
349 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
350 public Task<bool> SimSetCallForwardInfo(SimCallForwardRequest request)
352 TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
353 IntPtr id = (IntPtr)_requestId++;
354 _callbackMap[id] = (handle, result, data, key) =>
356 Task taskResult = new Task(() =>
358 if (result != (int)SimAccessResult.Success)
360 Log.Error(TapiUtility.LogTag, "Error occurs in setting call forward info: " + (SimAccessResult)result);
361 task.SetException(new InvalidOperationException("Error occurs in setting call forward info, " + (SimAccessResult)result));
365 task.SetResult(true);
369 _callbackMap.Remove(key);
374 throw new ArgumentNullException("SIM call forward request is null");
377 SimCallForwardRequestStruct requestStruct = SimClassConversions.ConvertSimCallForwardRequest(request);
378 int ret = Interop.Tapi.Sim.SimSetCallForwardingInfo(_handle, ref requestStruct, _callbackMap[id], id);
379 if (ret != (int)TapiError.Success)
381 Log.Error(TapiUtility.LogTag, "Failed to set SIM call forward info, Error: " + (TapiError)ret);
382 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
389 /// Gets SIM message waiting indication related data(EF-MWIS and CPHS case).
391 /// <returns>A task containing message waiting response information.</returns>
392 /// <feature>http://tizen.org/feature/network.telephony</feature>
393 /// <privilege>http://tizen.org/privilege/telephony</privilege>
394 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
395 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
396 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
397 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
398 public Task<SimMessageWaitingResponse> SimGetMessageWaitingInfo()
400 TaskCompletionSource<SimMessageWaitingResponse> task = new TaskCompletionSource<SimMessageWaitingResponse>();
401 IntPtr id = (IntPtr)_requestId++;
402 _callbackMap[id] = (handle, result, data, key) =>
404 Task taskResult = new Task(() =>
406 if (result != (int)SimAccessResult.Success)
408 Log.Error(TapiUtility.LogTag, "Error occurs in getting message waiting info: " + (SimAccessResult)result);
409 task.SetException(new InvalidOperationException("Error occurs in getting message waiting info, " + (SimAccessResult)result));
413 SimMessageWaitingResponseStruct info = Marshal.PtrToStructure<SimMessageWaitingResponseStruct>(data);
414 task.SetResult(SimStructConversions.ConvertSimMessageWaitingRespStruct(info));
418 _callbackMap.Remove(key);
421 int ret = Interop.Tapi.Sim.SimGetMessageWaitingInfo(_handle, _callbackMap[id], id);
422 if (ret != (int)TapiError.Success)
424 Log.Error(TapiUtility.LogTag, "Failed to get SIM message waiting info, Error: " + (TapiError)ret);
425 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
432 /// Sets SIM message waiting indication related data(EF-MWIS and CPHS case).
434 /// <param name="request">The data requesting for message waiting.</param>
435 /// <returns>A task indicating whether setting message waiting info is done or not.</returns>
436 /// <feature>http://tizen.org/feature/network.telephony</feature>
437 /// <privlevel>platform</privlevel>
438 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
439 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
440 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
441 /// <exception cref="ArgumentNullException">Thrown when message waiting request is passed as null.</exception>
442 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
443 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
444 public Task<bool> SimSetMessageWaitingInfo(SimMessageWaitingRequest request)
446 TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
447 IntPtr id = (IntPtr)_requestId++;
448 _callbackMap[id] = (handle, result, data, key) =>
450 Task taskResult = new Task(() =>
452 if (result != (int)SimAccessResult.Success)
454 Log.Error(TapiUtility.LogTag, "Error occurs in setting message waiting info: " + (SimAccessResult)result);
455 task.SetException(new InvalidOperationException("Error occurs in setting message waiting info, " + (SimAccessResult)result));
459 task.SetResult(true);
463 _callbackMap.Remove(key);
468 throw new ArgumentNullException("SIM message waiting request is null");
471 SimMessageWaitingRequestStruct requestStruct = SimClassConversions.ConvertSimMessageWaitingRequest(request);
472 int ret = Interop.Tapi.Sim.SimSetMessageWaitingInfo(_handle, ref requestStruct, _callbackMap[id], id);
473 if (ret != (int)TapiError.Success)
475 Log.Error(TapiUtility.LogTag, "Failed to set SIM message waiting info, Error: " + (TapiError)ret);
476 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
483 /// Gets SIM mailbox related data(EF-MBDN, MBDI, and CPHS case).
485 /// <returns>A task containing SimMailboxList information.</returns>
486 /// <feature>http://tizen.org/feature/network.telephony</feature>
487 /// <privilege>http://tizen.org/privilege/telephony</privilege>
488 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
489 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
490 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
491 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
492 public Task<SimMailboxList> SimGetMailboxInfo()
494 TaskCompletionSource<SimMailboxList> task = new TaskCompletionSource<SimMailboxList>();
495 IntPtr id = (IntPtr)_requestId++;
496 _callbackMap[id] = (handle, result, data, key) =>
498 Task taskResult = new Task(() =>
500 if (result != (int)SimAccessResult.Success)
502 Log.Error(TapiUtility.LogTag, "Error occurs in getting mailbox info: " + (SimAccessResult)result);
503 task.SetException(new InvalidOperationException("Error occurs in getting mailbox info, " + (SimAccessResult)result));
507 SimMailboxListStruct info = Marshal.PtrToStructure<SimMailboxListStruct>(data);
508 task.SetResult(SimStructConversions.ConvertSimMailboxListStruct(info));
512 _callbackMap.Remove(key);
515 int ret = Interop.Tapi.Sim.SimGetMailboxInfo(_handle, _callbackMap[id], id);
516 if (ret != (int)TapiError.Success)
518 Log.Error(TapiUtility.LogTag, "Failed to get SIM mailbox info, Error: " + (TapiError)ret);
519 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
526 /// Sets SIM mailbox related data(EF-MBDN, MBDI and CPHS case).
528 /// <param name="mailboxNumber">The data requesting for mailbox info.</param>
529 /// <returns>A task indicating whether setting mailbox info is done or not.</returns>
530 /// <feature>http://tizen.org/feature/network.telephony</feature>
531 /// <privlevel>platform</privlevel>
532 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
533 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
534 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
535 /// <exception cref="ArgumentNullException">Thrown when mailbox number is passed as null.</exception>
536 /// <exception cref="OutOfMemoryException">Thrown when the system runs out of memory.</exception>
537 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
538 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
539 public Task<bool> SimSetMailboxInfo(SimMailboxNumber mailboxNumber)
541 TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
542 IntPtr id = (IntPtr)_requestId++;
543 _callbackMap[id] = (handle, result, data, key) =>
545 Task taskResult = new Task(() =>
547 if (result != (int)SimAccessResult.Success)
549 Log.Error(TapiUtility.LogTag, "Error occurs in setting mailbox info: " + (SimAccessResult)result);
550 task.SetException(new InvalidOperationException("Error occurs in setting mailbox info, " + (SimAccessResult)result));
554 task.SetResult(true);
558 _callbackMap.Remove(key);
561 if (mailboxNumber == null)
563 throw new ArgumentNullException("SIM mailbox number is null");
566 SimMailboxNumberStruct mbStruct = SimClassConversions.ConvertSimMailboxNumber(mailboxNumber);
567 int ret = Interop.Tapi.Sim.SimSetMailboxInfo(_handle, ref mbStruct, _callbackMap[id], id);
568 if (ret != (int)TapiError.Success)
570 Log.Error(TapiUtility.LogTag, "Failed to set SIM mailbox info, Error: " + (TapiError)ret);
571 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
578 /// Gets SIM CPHS specific data.
580 /// <returns>A task containing SimCphs information.</returns>
581 /// <feature>http://tizen.org/feature/network.telephony</feature>
582 /// <privilege>http://tizen.org/privilege/telephony</privilege>
583 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
584 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
585 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
586 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
587 public Task<SimCphsInfo> SimGetCphsInfo()
589 TaskCompletionSource<SimCphsInfo> task = new TaskCompletionSource<SimCphsInfo>();
590 IntPtr id = (IntPtr)_requestId++;
591 _callbackMap[id] = (handle, result, data, key) =>
593 Task taskResult = new Task(() =>
595 if (result != (int)SimAccessResult.Success)
597 Log.Error(TapiUtility.LogTag, "Error occurs in getting CPHS info: " + (SimAccessResult)result);
598 task.SetException(new InvalidOperationException("Error occurs in getting CPHS info, " + (SimAccessResult)result));
602 SimCphsInfoStruct info = Marshal.PtrToStructure<SimCphsInfoStruct>(data);
603 task.SetResult(SimStructConversions.ConvertSimCphsInfoStruct(info));
607 _callbackMap.Remove(key);
610 int ret = Interop.Tapi.Sim.SimGetCphsInfo(_handle, _callbackMap[id], id);
611 if (ret != (int)TapiError.Success)
613 Log.Error(TapiUtility.LogTag, "Failed to get SIM CPHS info, Error: " + (TapiError)ret);
614 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
621 /// Gets the SIM Service Table.
623 /// <returns>A task containing SIM service table information.</returns>
624 /// <feature>http://tizen.org/feature/network.telephony</feature>
625 /// <privilege>http://tizen.org/privilege/telephony</privilege>
626 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
627 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
628 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
629 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
630 public Task<SimServiceTable> SimGetServiceTable()
632 TaskCompletionSource<SimServiceTable> task = new TaskCompletionSource<SimServiceTable>();
633 IntPtr id = (IntPtr)_requestId++;
634 _callbackMap[id] = (handle, result, data, key) =>
636 Task taskResult = new Task(() =>
638 if (result != (int)SimAccessResult.Success)
640 Log.Error(TapiUtility.LogTag, "Error occurs in getting service table: " + (SimAccessResult)result);
641 task.SetException(new InvalidOperationException("Error occurs in getting service table, " + (SimAccessResult)result));
645 SimServiceTableStruct info = Marshal.PtrToStructure<SimServiceTableStruct>(data);
646 task.SetResult(SimStructConversions.ConvertSimServiceTableStruct(info));
650 _callbackMap.Remove(key);
653 int ret = Interop.Tapi.Sim.SimGetServiceTable(_handle, _callbackMap[id], id);
654 if (ret != (int)TapiError.Success)
656 Log.Error(TapiUtility.LogTag, "Failed to get SIM service table, Error: " + (TapiError)ret);
657 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
664 /// Gets SIM MSISDN data.
666 /// <returns>A task containing SimMsisdnList information.</returns>
667 /// <feature>http://tizen.org/feature/network.telephony</feature>
668 /// <privilege>http://tizen.org/privilege/telephony</privilege>
669 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
670 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
671 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
672 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
673 public Task<SimMsisdnList> SimGetMsisdn()
675 TaskCompletionSource<SimMsisdnList> task = new TaskCompletionSource<SimMsisdnList>();
676 IntPtr id = (IntPtr)_requestId++;
677 _callbackMap[id] = (handle, result, data, key) =>
679 Task taskResult = new Task(() =>
681 if (result != (int)SimAccessResult.Success)
683 Log.Error(TapiUtility.LogTag, "Error occurs in getting MSISDN info: " + (SimAccessResult)result);
684 task.SetException(new InvalidOperationException("Error occurs in getting MSISDN info, " + (SimAccessResult)result));
688 SimMsisdnListStruct info = Marshal.PtrToStructure<SimMsisdnListStruct>(data);
689 task.SetResult(SimStructConversions.ConvertSimMsisdnListStruct(info));
693 _callbackMap.Remove(key);
696 int ret = Interop.Tapi.Sim.SimGetMsisdn(_handle, _callbackMap[id], id);
697 if (ret != (int)TapiError.Success)
699 Log.Error(TapiUtility.LogTag, "Failed to get SIM MSISDN data, Error: " + (TapiError)ret);
700 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
707 /// Gets SIM OPLMNWACT(Operator controlled PLMN Selector with Access Technology) data.
709 /// <returns>A task containing SimOplmnwactList information.</returns>
710 /// <feature>http://tizen.org/feature/network.telephony</feature>
711 /// <privilege>http://tizen.org/privilege/telephony</privilege>
712 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
713 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
714 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
715 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
716 public Task<SimOplmnwactList> SimGetOplmnwact()
718 TaskCompletionSource<SimOplmnwactList> task = new TaskCompletionSource<SimOplmnwactList>();
719 IntPtr id = (IntPtr)_requestId++;
720 _callbackMap[id] = (handle, result, data, key) =>
722 Task taskResult = new Task(() =>
724 if (result != (int)SimAccessResult.Success)
726 Log.Error(TapiUtility.LogTag, "Error occurs in getting OPLMNWACT info: " + (SimAccessResult)result);
727 task.SetException(new InvalidOperationException("Error occurs in getting OPLMNWACT info, " + (SimAccessResult)result));
731 SimOplmnwactListStruct info = Marshal.PtrToStructure<SimOplmnwactListStruct>(data);
732 task.SetResult(SimStructConversions.ConvertSimOplmnwactListStruct(info));
736 _callbackMap.Remove(key);
739 int ret = Interop.Tapi.Sim.SimGetOplmnwact(_handle, _callbackMap[id], id);
740 if (ret != (int)TapiError.Success)
742 Log.Error(TapiUtility.LogTag, "Failed to get SIM OPLMNWACT info, Error: " + (TapiError)ret);
743 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
750 /// Gets SIM SPN data.
752 /// <returns>A task containing SimSpn information.</returns>
753 /// <feature>http://tizen.org/feature/network.telephony</feature>
754 /// <privilege>http://tizen.org/privilege/telephony</privilege>
755 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
756 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
757 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
758 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
759 public Task<SimSpn> SimGetSpn()
761 TaskCompletionSource<SimSpn> task = new TaskCompletionSource<SimSpn>();
762 IntPtr id = (IntPtr)_requestId++;
763 _callbackMap[id] = (handle, result, data, key) =>
765 Task taskResult = new Task(() =>
767 if (result != (int)SimAccessResult.Success)
769 Log.Error(TapiUtility.LogTag, "Error occurs in getting SPN info: " + (SimAccessResult)result);
770 task.SetException(new InvalidOperationException("Error occurs in getting SPN info, " + (SimAccessResult)result));
774 SimSpnStruct info = Marshal.PtrToStructure<SimSpnStruct>(data);
775 task.SetResult(SimStructConversions.ConvertSimSpnStruct(info));
779 _callbackMap.Remove(key);
782 int ret = Interop.Tapi.Sim.SimGetSpn(_handle, _callbackMap[id], id);
783 if (ret != (int)TapiError.Success)
785 Log.Error(TapiUtility.LogTag, "Failed to get SIM SPN info, Error: " + (TapiError)ret);
786 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
793 /// Gets SIM CPHS NETNAME data.
795 /// <returns>A task containing SimCphsNetName information.</returns>
796 /// <feature>http://tizen.org/feature/network.telephony</feature>
797 /// <privilege>http://tizen.org/privilege/telephony</privilege>
798 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
799 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
800 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
801 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
802 public Task<SimCphsNetName> SimGetCphsNetName()
804 TaskCompletionSource<SimCphsNetName> task = new TaskCompletionSource<SimCphsNetName>();
805 IntPtr id = (IntPtr)_requestId++;
806 _callbackMap[id] = (handle, result, data, key) =>
808 Task taskResult = new Task(() =>
810 if (result != (int)SimAccessResult.Success)
812 Log.Error(TapiUtility.LogTag, "Error occurs in getting CPHS netname info: " + (SimAccessResult)result);
813 task.SetException(new InvalidOperationException("Error occurs in getting CPHS netname info, " + (SimAccessResult)result));
817 SimCphsNetNameStruct info = Marshal.PtrToStructure<SimCphsNetNameStruct>(data);
818 task.SetResult(SimStructConversions.ConvertSimCphsNetNameStruct(info));
822 _callbackMap.Remove(key);
825 int ret = Interop.Tapi.Sim.SimGetCphsNetName(_handle, _callbackMap[id], id);
826 if (ret != (int)TapiError.Success)
828 Log.Error(TapiUtility.LogTag, "Failed to get SIM CPHS netname info, Error: " + (TapiError)ret);
829 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
836 /// Executes an authentication procedure by using SIM.
838 /// <param name="authenticationData">The authentication code to be validated by the ISIM, 3G, and GSM application in the SIM card.</param>
839 /// <returns>A task containing SimAuthenticationResponse information.</returns>
840 /// <feature>http://tizen.org/feature/network.telephony</feature>
841 /// <privlevel>platform</privlevel>
842 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
843 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
844 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
845 /// <exception cref="ArgumentNullException">Thrown when authentication data is passed as null.</exception>
846 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
847 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
848 public Task<SimAuthenticationResponse> SimExecuteAuthentication(SimAuthenticationData authenticationData)
850 TaskCompletionSource<SimAuthenticationResponse> task = new TaskCompletionSource<SimAuthenticationResponse>();
851 IntPtr id = (IntPtr)_requestId++;
852 _callbackMap[id] = (handle, result, data, key) =>
854 Task taskResult = new Task(() =>
856 if (result != (int)SimAccessResult.Success)
858 Log.Error(TapiUtility.LogTag, "Error occurs in executing authentication procedure: " + (SimAccessResult)result);
859 task.SetException(new InvalidOperationException("Error occurs in executing authentication procedure, " + (SimAccessResult)result));
863 SimAuthenticationResponseStruct info = Marshal.PtrToStructure<SimAuthenticationResponseStruct>(data);
864 task.SetResult(SimStructConversions.ConvertSimAuthenticationResponseStruct(info));
868 _callbackMap.Remove(key);
871 if (authenticationData == null)
873 throw new ArgumentNullException("SIM authentication data is null");
876 SimAuthenticationDataStruct authStruct = SimClassConversions.ConvertSimAuthenticationDataStruct(authenticationData);
877 int ret = Interop.Tapi.Sim.SimExecuteAuthentication(_handle, ref authStruct, _callbackMap[id], id);
878 if (ret != (int)TapiError.Success)
880 Log.Error(TapiUtility.LogTag, "Failed to execute authentication procedure, Error: " + (TapiError)ret);
881 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
888 /// Performs PIN1/PIN2/SIM LOCK verification.
890 /// <param name="pinData">The PIN code.</param>
891 /// <returns>A task containing SimPinResult information.</returns>
892 /// <feature>http://tizen.org/feature/network.telephony</feature>
893 /// <privlevel>platform</privlevel>
894 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
895 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
896 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
897 /// <exception cref="ArgumentNullException">Thrown when pin data is passed as null.</exception>
898 /// <exception cref="OutOfMemoryException">Thrown when the system runs out of memory.</exception>
899 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
900 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
901 public Task<SimPinResult> SimVerifyPins(SimPinData pinData)
903 TaskCompletionSource<SimPinResult> task = new TaskCompletionSource<SimPinResult>();
904 IntPtr id = (IntPtr)_requestId++;
905 _callbackMap[id] = (handle, result, data, key) =>
907 Task taskResult = new Task(() =>
909 if (result != (int)SimAccessResult.Success)
911 Log.Error(TapiUtility.LogTag, "Error occurs in verifying SIM pins: " + (SimAccessResult)result);
912 task.SetException(new InvalidOperationException("Error occurs in verifying SIM pins, " + (SimAccessResult)result));
916 SimPinResultStruct info = Marshal.PtrToStructure<SimPinResultStruct>(data);
917 task.SetResult(SimStructConversions.ConvertSimPinResultStruct(info));
921 _callbackMap.Remove(key);
926 throw new ArgumentNullException("SIM PIN data is null");
929 SimPinDataStruct pinStruct = SimClassConversions.ConvertSimPinData(pinData);
930 int ret = Interop.Tapi.Sim.SimVerifyPins(_handle, ref pinStruct, _callbackMap[id], id);
931 if (ret != (int)TapiError.Success)
933 Log.Error(TapiUtility.LogTag, "Failed to verify SIM PIN, Error: " + (TapiError)ret);
934 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
941 /// Performs PIN1/PIN2 unblocking operation based on PUK information.
943 /// <param name="pukData">The unblocking PIN password.</param>
944 /// <param name="newPinData">The PIN password to use after the unblocking operation.</param>
945 /// <returns>A task containing SimPinResult information.</returns>
946 /// <feature>http://tizen.org/feature/network.telephony</feature>
947 /// <privlevel>platform</privlevel>
948 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
949 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
950 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
951 /// <exception cref="ArgumentNullException">Thrown when either of pukData or newPinData is passed as null.</exception>
952 /// <exception cref="OutOfMemoryException">Thrown when the system runs out of memory.</exception>
953 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
954 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
955 public Task<SimPinResult> SimVerifyPuks(SimPinData pukData, SimPinData newPinData)
957 TaskCompletionSource<SimPinResult> task = new TaskCompletionSource<SimPinResult>();
958 IntPtr id = (IntPtr)_requestId++;
959 _callbackMap[id] = (handle, result, data, key) =>
961 Task taskResult = new Task(() =>
963 if (result != (int)SimAccessResult.Success)
965 Log.Error(TapiUtility.LogTag, "Error occurs in verifying SIM puks: " + (SimAccessResult)result);
966 task.SetException(new InvalidOperationException("Error occurs in verifying SIM puks, " + (SimAccessResult)result));
970 SimPinResultStruct info = Marshal.PtrToStructure<SimPinResultStruct>(data);
971 task.SetResult(SimStructConversions.ConvertSimPinResultStruct(info));
975 _callbackMap.Remove(key);
978 if (pukData == null || newPinData == null)
980 throw new ArgumentNullException("SIM PIN/PUK data is null");
983 SimPinDataStruct pukStruct = SimClassConversions.ConvertSimPinData(pukData);
984 SimPinDataStruct pinStruct = SimClassConversions.ConvertSimPinData(newPinData);
985 int ret = Interop.Tapi.Sim.SimVerifyPuks(_handle, ref pukStruct, ref pinStruct, _callbackMap[id], id);
986 if (ret != (int)TapiError.Success)
988 Log.Error(TapiUtility.LogTag, "Failed to verify SIM puks, Error: " + (TapiError)ret);
989 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
996 /// Changes the PIN1/PIN2 code based on the PIN type passed along with old PIN data and new PIN data.
998 /// <param name="oldPin">The old PIN code entered by the user.</param>
999 /// <param name="newPin">The new PIN code entered by the user.</param>
1000 /// <returns>A task containing SimPinResult information.</returns>
1001 /// <feature>http://tizen.org/feature/network.telephony</feature>
1002 /// <privlevel>platform</privlevel>
1003 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
1004 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1005 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1006 /// <exception cref="ArgumentNullException">Thrown when either of oldPin or newPin is passed as null.</exception>
1007 /// <exception cref="OutOfMemoryException">Thrown when the system runs out of memory.</exception>
1008 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1009 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1010 public Task<SimPinResult> SimChangePins(SimPinData oldPin, SimPinData newPin)
1012 TaskCompletionSource<SimPinResult> task = new TaskCompletionSource<SimPinResult>();
1013 IntPtr id = (IntPtr)_requestId++;
1014 _callbackMap[id] = (handle, result, data, key) =>
1016 Task taskResult = new Task(() =>
1018 if (result != (int)SimAccessResult.Success)
1020 Log.Error(TapiUtility.LogTag, "Error occurs in changing SIM pins: " + (SimAccessResult)result);
1021 task.SetException(new InvalidOperationException("Error occurs in changing SIM pins, " + (SimAccessResult)result));
1025 SimPinResultStruct info = Marshal.PtrToStructure<SimPinResultStruct>(data);
1026 task.SetResult(SimStructConversions.ConvertSimPinResultStruct(info));
1030 _callbackMap.Remove(key);
1033 if (oldPin == null || newPin == null)
1035 throw new ArgumentNullException("Old/new PIN data is null");
1038 SimPinDataStruct oldPinStruct = SimClassConversions.ConvertSimPinData(oldPin);
1039 SimPinDataStruct newPinStruct = SimClassConversions.ConvertSimPinData(newPin);
1040 int ret = Interop.Tapi.Sim.SimChangePins(_handle, ref oldPinStruct, ref newPinStruct, _callbackMap[id], id);
1041 if (ret != (int)TapiError.Success)
1043 Log.Error(TapiUtility.LogTag, "Failed to change SIM pins, Error: " + (TapiError)ret);
1044 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
1051 /// Disables the SIM facility.
1053 /// <param name="facility">An object which contains the facility type and password.</param>
1054 /// <returns>A task containing SIM facility result information.</returns>
1055 /// <feature>http://tizen.org/feature/network.telephony</feature>
1056 /// <privlevel>platform</privlevel>
1057 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
1058 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1059 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1060 /// <exception cref="ArgumentNullException">Thrown when SIM facility info is passed as null.</exception>
1061 /// <exception cref="OutOfMemoryException">Thrown when the system runs out of memory.</exception>
1062 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1063 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1064 public Task<SimFacilityResult> SimDisableFacility(SimFacility facility)
1066 TaskCompletionSource<SimFacilityResult> task = new TaskCompletionSource<SimFacilityResult>();
1067 IntPtr id = (IntPtr)_requestId++;
1068 _callbackMap[id] = (handle, result, data, key) =>
1070 Task taskResult = new Task(() =>
1072 if (result != (int)SimAccessResult.Success)
1074 Log.Error(TapiUtility.LogTag, "Error occurs in disabling SIM facility: " + (SimAccessResult)result);
1075 task.SetException(new InvalidOperationException("Error occurs in disabling SIM facility, " + (SimAccessResult)result));
1079 SimFacilityResultStruct info = Marshal.PtrToStructure<SimFacilityResultStruct>(data);
1080 task.SetResult(SimStructConversions.ConvertSimFacilityResultStruct(info));
1084 _callbackMap.Remove(key);
1087 if (facility == null)
1089 throw new ArgumentNullException("SIM facility info is null");
1092 SimFacilityStruct facilityStruct = SimClassConversions.ConvertSimFacility(facility);
1093 int ret = Interop.Tapi.Sim.SimDisableFacility(_handle, ref facilityStruct, _callbackMap[id], id);
1094 if (ret != (int)TapiError.Success)
1096 Log.Error(TapiUtility.LogTag, "Failed to disable SIM facility, Error: " + (TapiError)ret);
1097 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
1104 /// Enables the SIM facility.
1106 /// <param name="facility">An object which contains the facility type and password.</param>
1107 /// <returns>A task containing SIM facility result information.</returns>
1108 /// <feature>http://tizen.org/feature/network.telephony</feature>
1109 /// <privlevel>platform</privlevel>
1110 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
1111 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1112 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1113 /// <exception cref="ArgumentNullException">Thrown when SIM facility info is passed as null.</exception>
1114 /// <exception cref="OutOfMemoryException">Thrown when the system runs out of memory.</exception>
1115 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1116 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1117 public Task<SimFacilityResult> SimEnableFacility(SimFacility facility)
1119 TaskCompletionSource<SimFacilityResult> task = new TaskCompletionSource<SimFacilityResult>();
1120 IntPtr id = (IntPtr)_requestId++;
1121 _callbackMap[id] = (handle, result, data, key) =>
1123 Task taskResult = new Task(() =>
1125 if (result != (int)SimAccessResult.Success)
1127 Log.Error(TapiUtility.LogTag, "Error occurs in enabling SIM facility: " + (SimAccessResult)result);
1128 task.SetException(new InvalidOperationException("Error occurs in enabling SIM facility, " + (SimAccessResult)result));
1132 SimFacilityResultStruct info = Marshal.PtrToStructure<SimFacilityResultStruct>(data);
1133 task.SetResult(SimStructConversions.ConvertSimFacilityResultStruct(info));
1137 _callbackMap.Remove(key);
1140 if (facility == null)
1142 throw new ArgumentNullException("SIM facility info is null");
1145 SimFacilityStruct facilityStruct = SimClassConversions.ConvertSimFacility(facility);
1146 int ret = Interop.Tapi.Sim.SimEnableFacility(_handle, ref facilityStruct, _callbackMap[id], id);
1147 if (ret != (int)TapiError.Success)
1149 Log.Error(TapiUtility.LogTag, "Failed to enable SIM facility, Error: " + (TapiError)ret);
1150 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
1157 /// Gets the SIM facility.
1159 /// <param name="lockType">The type of security lock.</param>
1160 /// <returns>A task containing SIM facility information.</returns>
1161 /// <feature>http://tizen.org/feature/network.telephony</feature>
1162 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1163 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1164 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1165 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1166 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1167 public Task<SimFacilityInfo> SimGetFacility(SimLockType lockType)
1169 TaskCompletionSource<SimFacilityInfo> task = new TaskCompletionSource<SimFacilityInfo>();
1170 IntPtr id = (IntPtr)_requestId++;
1171 _callbackMap[id] = (handle, result, data, key) =>
1173 Task taskResult = new Task(() =>
1175 if (result != (int)SimAccessResult.Success)
1177 Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM facility: " + (SimAccessResult)result);
1178 task.SetException(new InvalidOperationException("Error occurs in getting SIM facility, " + (SimAccessResult)result));
1182 SimFacilityInfoStruct info = Marshal.PtrToStructure<SimFacilityInfoStruct>(data);
1183 task.SetResult(SimStructConversions.ConvertSimFacilityInfoStruct(info));
1187 _callbackMap.Remove(key);
1190 int ret = Interop.Tapi.Sim.SimGetFacility(_handle, lockType, _callbackMap[id], id);
1191 if (ret != (int)TapiError.Success)
1193 Log.Error(TapiUtility.LogTag, "Failed to get SIM facility, Error: " + (TapiError)ret);
1194 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1201 /// Gets SIM lock type info.
1203 /// <param name="lockType">The type of security lock.</param>
1204 /// <returns>A task containing SIM lock information.</returns>
1205 /// <feature>http://tizen.org/feature/network.telephony</feature>
1206 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1207 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1208 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1209 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1210 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1211 public Task<SimLockInfo> SimGetLockInfo(SimLockType lockType)
1213 TaskCompletionSource<SimLockInfo> task = new TaskCompletionSource<SimLockInfo>();
1214 IntPtr id = (IntPtr)_requestId++;
1215 _callbackMap[id] = (handle, result, data, key) =>
1217 Task taskResult = new Task(() =>
1219 if (result != (int)SimAccessResult.Success)
1221 Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM lock info: " + (SimAccessResult)result);
1222 task.SetException(new InvalidOperationException("Error occurs in getting SIM lock info, " + (SimAccessResult)result));
1226 SimLockInfoStruct info = Marshal.PtrToStructure<SimLockInfoStruct>(data);
1227 task.SetResult(SimStructConversions.ConvertSimLockInfoStruct(info));
1231 _callbackMap.Remove(key);
1234 int ret = Interop.Tapi.Sim.SimGetLockInfo(_handle, lockType, _callbackMap[id], id);
1235 if (ret != (int)TapiError.Success)
1237 Log.Error(TapiUtility.LogTag, "Failed to get SIM lock info, Error: " + (TapiError)ret);
1238 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1245 /// Sets the SIM power state.
1247 /// <param name="state">The state of SIM to be set.</param>
1248 /// <returns>A task indicating whether setting SIM power state is done or not.</returns>
1249 /// <feature>http://tizen.org/feature/network.telephony</feature>
1250 /// <privlevel>platform</privlevel>
1251 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
1252 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1253 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1254 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1255 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1256 public Task<bool> SimSetPowerState(SimPowerState state)
1258 TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
1259 IntPtr id = (IntPtr)_requestId++;
1260 _callbackMap[id] = (handle, result, data, key) =>
1262 Task taskResult = new Task(() =>
1264 if (result != (int)SimPowerSetResult.Success)
1266 Log.Error(TapiUtility.LogTag, "Error occurs in setting SIM power state: " + (SimPowerSetResult)result);
1267 task.SetException(new InvalidOperationException("Error occurs in setting SIM power state, " + (SimPowerSetResult)result));
1271 task.SetResult(true);
1275 _callbackMap.Remove(key);
1278 int ret = Interop.Tapi.Sim.SimSetPowerState(_handle, state, _callbackMap[id], id);
1279 if (ret != (int)TapiError.Success)
1281 Log.Error(TapiUtility.LogTag, "Failed to set SIM power state, Error: " + (TapiError)ret);
1282 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
1289 /// Provides a common interface for accessing SIM data.
1291 /// <param name="apdu">The APDU data.</param>
1292 /// <returns>A task containing SIM APDU response information.</returns>
1293 /// <feature>http://tizen.org/feature/network.telephony</feature>
1294 /// <privlevel>platform</privlevel>
1295 /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
1296 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1297 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1298 /// <exception cref="ArgumentNullException">Thrown when SIM APDU is passed as null.</exception>
1299 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1300 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1301 public Task<SimApduResponse> SimRequestApdu(SimApdu apdu)
1303 TaskCompletionSource<SimApduResponse> task = new TaskCompletionSource<SimApduResponse>();
1304 IntPtr id = (IntPtr)_requestId++;
1305 _callbackMap[id] = (handle, result, data, key) =>
1307 Task taskResult = new Task(() =>
1309 if (result != (int)SimAccessResult.Success)
1311 Log.Error(TapiUtility.LogTag, "Error occurs in requesting SIM APDU: " + (SimAccessResult)result);
1312 task.SetException(new InvalidOperationException("Error occurs in requesting SIM APDU, " + (SimAccessResult)result));
1316 SimApduResponseStruct info = Marshal.PtrToStructure<SimApduResponseStruct>(data);
1317 task.SetResult(SimStructConversions.ConvertSimApduResponseStruct(info));
1321 _callbackMap.Remove(key);
1326 throw new ArgumentNullException("SIM APDU is null");
1329 SimApduStruct apduStruct = SimClassConversions.ConvertSimApdu(apdu);
1330 int ret = Interop.Tapi.Sim.SimRequestApdu(_handle, ref apduStruct, _callbackMap[id], id);
1331 if (ret != (int)TapiError.Success)
1333 Log.Error(TapiUtility.LogTag, "Failed to request SIM APDU, Error: " + (TapiError)ret);
1334 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
1341 /// Provides a common interface to get the SIM ATR(Answer To Reset) value.
1343 /// <returns>A task containing SIM ATR response information.</returns>
1344 /// <feature>http://tizen.org/feature/network.telephony</feature>
1345 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1346 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1347 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1348 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1349 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1350 public Task<SimAtrResponse> SimRequestAtr()
1352 TaskCompletionSource<SimAtrResponse> task = new TaskCompletionSource<SimAtrResponse>();
1353 IntPtr id = (IntPtr)_requestId++;
1354 _callbackMap[id] = (handle, result, data, key) =>
1356 Task taskResult = new Task(() =>
1358 if (result != (int)SimAccessResult.Success)
1360 Log.Error(TapiUtility.LogTag, "Error occurs in requesting SIM ATR: " + (SimAccessResult)result);
1361 task.SetException(new InvalidOperationException("Error occurs in requesting SIM ATR, " + (SimAccessResult)result));
1365 SimAtrResponseStruct info = Marshal.PtrToStructure<SimAtrResponseStruct>(data);
1366 task.SetResult(SimStructConversions.ConvertSimAtrResponseStruct(info));
1370 _callbackMap.Remove(key);
1373 int ret = Interop.Tapi.Sim.SimRequestAtr(_handle, _callbackMap[id], id);
1374 if (ret != (int)TapiError.Success)
1376 Log.Error(TapiUtility.LogTag, "Failed to request SIM ATR, Error: " + (TapiError)ret);
1377 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1384 /// Gets the IMPI(IMS private user identity). (ISIM only).
1386 /// <returns>A task containing IMPI string.</returns>
1387 /// <feature>http://tizen.org/feature/network.telephony</feature>
1388 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1389 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1390 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1391 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1392 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1393 public Task<string> SimGetImpi()
1395 TaskCompletionSource<string> task = new TaskCompletionSource<string>();
1396 IntPtr id = (IntPtr)_requestId++;
1397 _callbackMap[id] = (handle, result, data, key) =>
1399 Task taskResult = new Task(() =>
1401 if (result != (int)SimAccessResult.Success)
1403 Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM IMPI: " + (SimAccessResult)result);
1404 task.SetException(new InvalidOperationException("Error occurs in getting SIM IMPI, " + (SimAccessResult)result));
1408 task.SetResult(Marshal.PtrToStringAnsi(data));
1412 _callbackMap.Remove(key);
1415 int ret = Interop.Tapi.Sim.SimGetImpi(_handle, _callbackMap[id], id);
1416 if (ret != (int)TapiError.Success)
1418 Log.Error(TapiUtility.LogTag, "Failed to get SIM IMPI, Error: " + (TapiError)ret);
1419 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1426 /// Gets the IMPU(IMS public user identity). (ISIM only).
1428 /// <returns>A task containing SIM IMPU list information.</returns>
1429 /// <feature>http://tizen.org/feature/network.telephony</feature>
1430 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1431 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1432 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1433 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1434 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1435 public Task<SimImpuList> SimGetImpu()
1437 TaskCompletionSource<SimImpuList> task = new TaskCompletionSource<SimImpuList>();
1438 IntPtr id = (IntPtr)_requestId++;
1439 _callbackMap[id] = (handle, result, data, key) =>
1441 Task taskResult = new Task(() =>
1443 if (result != (int)SimAccessResult.Success)
1445 Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM IMPU: " + (SimAccessResult)result);
1446 task.SetException(new InvalidOperationException("Error occurs in getting SIM IMPU, " + (SimAccessResult)result));
1450 SimImpuListStruct info = Marshal.PtrToStructure<SimImpuListStruct>(data);
1451 task.SetResult(SimStructConversions.ConvertSimImpuListStruct(info));
1455 _callbackMap.Remove(key);
1458 int ret = Interop.Tapi.Sim.SimGetImpu(_handle, _callbackMap[id], id);
1459 if (ret != (int)TapiError.Success)
1461 Log.Error(TapiUtility.LogTag, "Failed to get SIM IMPU, Error: " + (TapiError)ret);
1462 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1469 /// Gets the Domain(Home Network Domain Name). (ISIM only)
1471 /// <returns>A task containing domain string.</returns>
1472 /// <feature>http://tizen.org/feature/network.telephony</feature>
1473 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1474 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1475 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1476 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1477 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1478 public Task<string> SimGetDomain()
1480 TaskCompletionSource<string> task = new TaskCompletionSource<string>();
1481 IntPtr id = (IntPtr)_requestId++;
1482 _callbackMap[id] = (handle, result, data, key) =>
1484 Task taskResult = new Task(() =>
1486 if (result != (int)SimAccessResult.Success)
1488 Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM domain: " + (SimAccessResult)result);
1489 task.SetException(new InvalidOperationException("Error occurs in getting SIM domain, " + (SimAccessResult)result));
1493 task.SetResult(Marshal.PtrToStringAnsi(data));
1497 _callbackMap.Remove(key);
1500 int ret = Interop.Tapi.Sim.SimGetDomain(_handle, _callbackMap[id], id);
1501 if (ret != (int)TapiError.Success)
1503 Log.Error(TapiUtility.LogTag, "Failed to get SIM domain, Error: " + (TapiError)ret);
1504 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1511 /// Gets the P-CSCF(Proxy Call Session Control Function). (ISIM only)
1513 /// <returns>A task containing SIM PCSCF list information.</returns>
1514 /// <feature>http://tizen.org/feature/network.telephony</feature>
1515 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1516 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1517 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1518 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1519 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1520 public Task<SimPcscfList> SimGetPcscf()
1522 TaskCompletionSource<SimPcscfList> task = new TaskCompletionSource<SimPcscfList>();
1523 IntPtr id = (IntPtr)_requestId++;
1524 _callbackMap[id] = (handle, result, data, key) =>
1526 Task taskResult = new Task(() =>
1528 if (result != (int)SimAccessResult.Success)
1530 Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM PCSCF: " + (SimAccessResult)result);
1531 task.SetException(new InvalidOperationException("Error occurs in getting SIM PCSCF, " + (SimAccessResult)result));
1535 SimPcscfListStruct info = Marshal.PtrToStructure<SimPcscfListStruct>(data);
1536 task.SetResult(SimStructConversions.ConvertSimPcscfListStruct(info));
1540 _callbackMap.Remove(key);
1543 int ret = Interop.Tapi.Sim.SimGetPcscf(_handle, _callbackMap[id], id);
1544 if (ret != (int)TapiError.Success)
1546 Log.Error(TapiUtility.LogTag, "Failed to get SIM PCSCF, Error: " + (TapiError)ret);
1547 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
1554 /// Gets the ISIM service table. (ISIM only).
1556 /// <returns>A task containing a byte array in which mask value of SimIsimService enum will be stored.</returns>
1557 /// <feature>http://tizen.org/feature/network.telephony</feature>
1558 /// <privilege>http://tizen.org/privilege/telephony</privilege>
1559 /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
1560 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1561 /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
1562 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
1563 public Task<byte[]> SimGetIsimServiceTable()
1565 TaskCompletionSource<byte[]> task = new TaskCompletionSource<byte[]>();
1566 IntPtr id = (IntPtr)_requestId++;
1567 _callbackMap[id] = (handle, result, data, key) =>
1569 Task taskResult = new Task(() =>
1571 if (result != (int)SimAccessResult.Success)
1573 Log.Error(TapiUtility.LogTag, "Error occurs in getting ISIM service table: " + (SimAccessResult)result);
1574 task.SetException(new InvalidOperationException("Error occurs in getting ISIM service table, " + (SimAccessResult)result));
1578 task.SetResult(Encoding.ASCII.GetBytes(Marshal.PtrToStringAnsi(data)));
1582 _callbackMap.Remove(key);
1585 int ret = Interop.Tapi.Sim.SimGetIsimServiceTable(_handle, _callbackMap[id], id);
1586 if (ret != (int)TapiError.Success)
1588 Log.Error(TapiUtility.LogTag, "Failed to get ISIM service table, Error: " + (TapiError)ret);
1589 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");