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 APIs that allow you to extract the information stored on a SIM card.
27 internal IntPtr _handle;
30 /// The SIM class constructor.
32 /// <since_tizen> 3 </since_tizen>
33 /// <param name="handle">
34 /// SlotHandle received in the Manager.Init API.
36 /// <feature>http://tizen.org/feature/network.telephony</feature>
37 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
38 /// <exception cref="ArgumentNullException">
39 /// This exception occurs if the handle provided is null.
41 public Sim(SlotHandle handle)
45 throw new ArgumentNullException();
48 _handle = handle._handle;
52 /// Enumeration for the state of the SIM card.
57 /// The SIM is not available on this device.
61 /// The SIM is locked.
65 /// The SIM is available on this device (SIM is not locked).
69 /// The SIM is in transition between states.
75 /// Enumeration for the lock state of the SIM card.
80 /// The SIM is not in lock.
84 /// The SIM is PIN (Personal Identification Number) locked.
88 /// The SIM is PUK (Personal Unblocking Code) locked.
92 /// The SIM is permanently blocked (All the attempts for PIN/PUK failed).
96 /// The SIM is NCK (Network Control Key) locked.
102 /// Enumeration for the type of the SIM card.
104 public enum ApplicationType
107 /// SIM (GSM) application.
111 /// USIM application.
115 /// CDMA application.
119 /// ISIM application.
125 /// Gets the Integrated Circuit Card IDentification (ICC-ID).
126 /// The Integrated Circuit Card Identification number internationally identifies SIM cards.
128 /// <since_tizen> 3 </since_tizen>
129 /// <privilege>http://tizen.org/privilege/telephony</privilege>
131 /// The Integrated Circuit Card Identification.
132 /// Empty string if unable to complete the operation.
135 /// The SIM state must be Available.
142 TelephonyError error = Interop.Sim.GetIccId(_handle, out iccId);
143 if (error != TelephonyError.None)
145 Tizen.Log.Error(Interop.Telephony.LogTag, "GetIccId Failed with error " + error);
154 /// Gets the SIM Operator (MCC [3 digits] + MNC [2~3 digits]).
155 /// The Operator is embedded in the SIM card.
157 /// <since_tizen> 3 </since_tizen>
158 /// <privilege>http://tizen.org/privilege/telephony</privilege>
160 /// The SIM Operator.
161 /// Empty string if unable to complete the operation.
164 /// The SIM state must be Available.
166 public string Operator
171 TelephonyError error = Interop.Sim.GetOperator(_handle, out simOperator);
172 if (error != TelephonyError.None)
174 Tizen.Log.Error(Interop.Telephony.LogTag, "GetOperator Failed with error " + error);
183 /// Gets the Mobile Subscription Identification Number (MSIN [9~10 digits]) of the SIM provider.
185 /// <since_tizen> 3 </since_tizen>
186 /// <privilege>http://tizen.org/privilege/telephony</privilege>
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 the SIM card, an empty string will be returned.
214 /// <since_tizen> 3 </since_tizen>
215 /// <privilege>http://tizen.org/privilege/telephony</privilege>
217 /// The Service Provider Name.
218 /// Empty string if unable to complete the operation.
221 /// The SIM state must be Available.
228 TelephonyError error = Interop.Sim.GetSpn(_handle, out spn);
229 if (error != TelephonyError.None)
231 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSpn Failed with error " + error);
240 /// Checks whether the current SIM card is different from the previous SIM card.
242 /// <since_tizen> 3 </since_tizen>
243 /// <privilege>http://tizen.org/privilege/telephony</privilege>
245 /// true if the current SIM card is different from the previous SIM card, otherwise false if the SIM card is not changed.
248 /// The SIM state must be Available.
250 public bool IsChanged
255 bool isChanged = false; ;
256 TelephonyError error = Interop.Sim.IsChanged(_handle, out ischanged);
257 if (error != TelephonyError.None)
259 Tizen.Log.Error(Interop.Telephony.LogTag, "IsChanged Failed with error " + error);
273 /// Gets the state of the SIM.
275 /// <since_tizen> 3 </since_tizen>
276 /// <privilege>http://tizen.org/privilege/telephony</privilege>
278 /// The current state of the SIM.
280 public State CurrentState
285 TelephonyError error = Interop.Sim.GetState(_handle, out currentState);
286 if (error != TelephonyError.None)
288 Tizen.Log.Error(Interop.Telephony.LogTag, "GetState Failed with error " + error);
289 return State.Unavailable;
297 /// Gets the count of an application on the UICC.
299 /// <since_tizen> 3 </since_tizen>
300 /// <privilege>http://tizen.org/privilege/telephony</privilege>
302 /// The masking value for below values are provided by the enumeration ApplicationType.
303 /// 0 if unable to complete the operation.
306 /// The SIM state must be Available.
308 public uint ApplicationList
313 TelephonyError error = Interop.Sim.GetApplicationList(_handle, out appList);
314 if (error != TelephonyError.None)
316 Tizen.Log.Error(Interop.Telephony.LogTag, "GetApplicationList Failed with error " + error);
325 /// Gets the subscriber number embedded in the SIM card. This value contains the MSISDN related to the subscriber.
326 /// If this value is not stored in SIM card, an empty string will be returned.
328 /// <since_tizen> 3 </since_tizen>
329 /// <privilege>http://tizen.org/privilege/telephony</privilege>
331 /// The subscriber number in the SIM.
332 /// Empty string if unable to complete the operation.
335 /// The SIM state must be Available.
337 public string SubscriberNumber
341 string subscriberNumber;
342 TelephonyError error = Interop.Sim.GetSubscriberNumber(_handle, out subscriberNumber);
343 if (error != TelephonyError.None)
345 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSubscriberNumber Failed with error " + error);
349 return subscriberNumber;
354 /// Gets the subscriber ID.
356 /// <since_tizen> 3 </since_tizen>
357 /// <privilege>http://tizen.org/privilege/telephony</privilege>
359 /// The subscriber ID.
360 /// Empty string if unable to complete the operation.
363 /// The SIM state must be Available.
365 public string SubscriberId
370 TelephonyError error = Interop.Sim.GetSubscriberId(_handle, out subscriberId);
371 if (error != TelephonyError.None)
373 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSubscriberId Failed with error " + error);
382 /// Gets the lock state of the SIM.
384 /// <since_tizen> 3 </since_tizen>
385 /// <privilege>http://tizen.org/privilege/telephony</privilege>
387 /// The current lock state of the SIM.
390 /// The SIM state must be Available.
392 public LockState CurrentLockState
396 LockState currentLockState;
397 TelephonyError error = Interop.Sim.GetLockState(_handle, out currentLockState);
398 if (error != TelephonyError.None)
400 Tizen.Log.Error(Interop.Telephony.LogTag, "GetLockState Failed with error " + error);
401 return LockState.Unknown;
404 return currentLockState;
409 /// Gets the GID1 (Group Identifier Level 1).
410 /// Gets Group Identifier Level 1 (GID1) embedded in the SIM card. If this value is not stored in SIM card, an empty string will be returned.
412 /// <since_tizen> 3 </since_tizen>
413 /// <privilege>http://tizen.org/privilege/telephony</privilege>
415 /// The GID1 (Group Identifier Level 1).
416 /// Empty string if unable to complete the operation.
419 /// The SIM state must be Available.
421 public string GroupId1
426 TelephonyError error = Interop.Sim.GetGroupId1(_handle, out groupId1);
427 if (error != TelephonyError.None)
429 Tizen.Log.Error(Interop.Telephony.LogTag, "GetGroupId1 Failed with error " + error);
438 /// Gets the call forwarding indicator state of the SIM.
439 /// If the state is true, the 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).
441 /// <since_tizen> 3 </since_tizen>
442 /// <privilege>http://tizen.org/privilege/telephony</privilege>
444 /// The value whether the incoming call will be forwarded or not (true: forwarded, false: not forwarded).
447 /// The SIM state must be Available.
449 public bool CallForwardingIndicatorState
453 bool callForwardingIndicatorState;
454 TelephonyError error = Interop.Sim.GetCallForwardingIndicatorState(_handle, out callForwardingIndicatorState);
455 if (error != TelephonyError.None)
457 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallForwardingIndicatorState Failed with error " + error);
461 return callForwardingIndicatorState;