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 static Interop.Telephony;
20 namespace Tizen.Telephony
23 /// This Class provides API's that allows you to extract information stored on a SIM card
27 internal IntPtr _handle;
30 /// Sim Class Constructor
32 /// <param name="handle">
33 /// SlotHandle received in the Manager.Init API
35 /// <exception cref="ArgumentNullException">
36 /// This exception occurs if handle provided is null
38 public Sim(SlotHandle handle)
42 throw new ArgumentNullException();
45 _handle = handle._handle;
49 /// Enumeration for the state of SIM card.
54 /// SIM is not available on this device
62 /// SIM is available on this device (SIM is not locked)
66 /// SIM is in transition between states
72 /// Enumeration for the lock state of SIM card.
77 /// SIM is not in lock
81 /// SIM is PIN(Personal Identification Number) locked
85 /// SIM is PUK(Personal Unblocking Code) locked
89 /// SIM is permanently blocked(All the attempts for PIN/PUK failed)
93 /// SIM is NCK(Network Control Key) locked
99 /// Enumeration for the type of SIM card.
101 public enum ApplicationType
104 /// SIM(GSM) Application
122 /// Gets the Integrated Circuit Card IDentification (ICC-ID).
123 /// The Integrated Circuit Card Identification number internationally identifies SIM cards.
126 /// http://tizen.org/privilege/telephony
129 /// The Integrated Circuit Card Identification
130 /// empty string if unable to complete the operation
133 /// The SIM state must be Available
140 TelephonyError error = Interop.Sim.GetIccId(_handle, out iccId);
141 if (error != TelephonyError.None)
143 Tizen.Log.Error(Interop.Telephony.LogTag, "GetIccId Failed with error " + error);
152 /// Gets the SIM Operator (MCC [3 digits] + MNC [2~3 digits]).
153 /// The Operator is embedded in the SIM card.
156 /// http://tizen.org/privilege/telephony
160 /// empty string if unable to complete the operation
163 /// The SIM state must be Available
165 public string Operator
170 TelephonyError error = Interop.Sim.GetOperator(_handle, out simOperator);
171 if (error != TelephonyError.None)
173 Tizen.Log.Error(Interop.Telephony.LogTag, "GetOperator Failed with error " + error);
182 /// Gets the Mobile Subscription Identification Number (MSIN [9~10 digits]) of the SIM provider.
185 /// http://tizen.org/privilege/telephony
188 /// The Mobile Subscription Identification Number
189 /// empty string if unable to complete the operation
192 /// The SIM state must be Available
199 TelephonyError error = Interop.Sim.GetMsin(_handle, out msin);
200 if (error != TelephonyError.None)
202 Tizen.Log.Error(Interop.Telephony.LogTag, "GetMsin Failed with error " + error);
211 /// Gets the Service Provider Name (SPN) of the SIM card.
212 /// Gets Service Provider Name embedded in the SIM card.If this value is not stored in SIM card, empty string will be returned.
215 /// http://tizen.org/privilege/telephony
218 /// The Service Provider Name
219 /// empty string if unable to complete the operation
222 /// The SIM state must be Available
229 TelephonyError error = Interop.Sim.GetSpn(_handle, out spn);
230 if (error != TelephonyError.None)
232 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSpn Failed with error " + error);
241 /// Checks whether the current SIM card is different from the previous SIM card.
244 /// http://tizen.org/privilege/telephony
247 /// true if the current SIM card is different from the previous SIM card, otherwise false if the SIM card is not changed
250 /// The SIM state must be Available
252 public bool IsChanged
257 bool isChanged = false; ;
258 TelephonyError error = Interop.Sim.IsChanged(_handle, out ischanged);
259 if (error != TelephonyError.None)
261 Tizen.Log.Error(Interop.Telephony.LogTag, "IsChanged Failed with error " + error);
275 /// Gets the state of the SIM.
278 /// http://tizen.org/privilege/telephony
281 /// The current state of the SIM
283 public State CurrentState
288 TelephonyError error = Interop.Sim.GetState(_handle, out currentState);
289 if (error != TelephonyError.None)
291 Tizen.Log.Error(Interop.Telephony.LogTag, "GetState Failed with error " + error);
292 return State.Unavailable;
300 /// Gets the list of application on UICC.
303 /// http://tizen.org/privilege/telephony
306 /// The masking value for below values are provided by the enum ApplicationType
307 /// 0 if unable to complete the operation
310 /// The SIM state must be Available
312 public uint ApplicationList
317 TelephonyError error = Interop.Sim.GetApplicationList(_handle, out appList);
318 if (error != TelephonyError.None)
320 Tizen.Log.Error(Interop.Telephony.LogTag, "GetApplicationList Failed with error " + error);
329 /// Gets subscriber number embedded in the SIM card. This value contains MSISDN related to the subscriber.
330 /// If this value is not stored in SIM card, empty string will be returned.
333 /// http://tizen.org/privilege/telephony
336 /// The subscriber number in the SIM
337 /// empty string if unable to complete the operation
340 /// The SIM state must be Available
342 public string SubscriberNumber
346 string subscriberNumber;
347 TelephonyError error = Interop.Sim.GetSubscriberNumber(_handle, out subscriberNumber);
348 if (error != TelephonyError.None)
350 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSubscriberNumber Failed with error " + error);
354 return subscriberNumber;
359 /// Gets the Subscriber ID.
362 /// http://tizen.org/privilege/telephony
365 /// The subscriber ID
366 /// empty string if unable to complete the operation
369 /// The SIM state must be Available
371 public string SubscriberId
376 TelephonyError error = Interop.Sim.GetSubscriberId(_handle, out subscriberId);
377 if (error != TelephonyError.None)
379 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSubscriberId Failed with error " + error);
388 /// Gets the lock state of the SIM.
391 /// http://tizen.org/privilege/telephony
394 /// The current lock state of the SIM
397 /// The SIM state must be Available
399 public LockState CurrentLockState
403 LockState currentLockState;
404 TelephonyError error = Interop.Sim.GetLockState(_handle, out currentLockState);
405 if (error != TelephonyError.None)
407 Tizen.Log.Error(Interop.Telephony.LogTag, "GetLockState Failed with error " + error);
408 return LockState.Unknown;
411 return currentLockState;
416 /// Gets the GID1 (Group Identifier Level 1).
417 /// Gets Group Identifier Level 1(GID1) embedded in the SIM card.If this value is not stored in SIM card, empty string will be returned.
420 /// http://tizen.org/privilege/telephony
423 /// The GID1 (Group Identifier Level 1)
424 /// empty string if unable to complete the operation
427 /// The SIM state must be Available
429 public string GroupId1
434 TelephonyError error = Interop.Sim.GetGroupId1(_handle, out groupId1);
435 if (error != TelephonyError.None)
437 Tizen.Log.Error(Interop.Telephony.LogTag, "GetGroupId1 Failed with error " + error);
446 /// Gets the call forwarding indicator state of the SIM.
447 /// If the state is true, incoming call will be forwarded to the selected number.state indicates the CFU(Call Forwarding Unconditional) indicator status - Voice. (3GPP TS 31.102 4.2.64 EF CFIS)
450 /// http://tizen.org/privilege/telephony
453 /// The value whether incoming call will be forwarded or not. (true: forwarded, false: not forwarded)
456 /// The SIM state must be Available
458 public bool CallForwardingIndicatorState
462 bool callForwardingIndicatorState;
463 TelephonyError error = Interop.Sim.GetCallForwardingIndicatorState(_handle, out callForwardingIndicatorState);
464 if (error != TelephonyError.None)
466 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallForwardingIndicatorState Failed with error " + error);
470 return callForwardingIndicatorState;