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;
19 namespace Tizen.Telephony
22 /// The Network class provides APIs to obtain information about the current telephony service network.
26 internal IntPtr _handle;
29 /// The Network class constructor.
31 /// <since_tizen> 3 </since_tizen>
32 /// <param name="handle">
33 /// SlotHandle received in the Manager.Init API.
35 /// <feature>http://tizen.org/feature/network.telephony</feature>
36 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
37 /// <exception cref="ArgumentNullException">
38 /// This exception occurs if the handle provided is null.
40 public Network(SlotHandle handle)
44 throw new ArgumentNullException();
47 _handle = handle._handle;
51 /// Enumeration for the RSSI (Receive Signal Strength Indicator).
52 /// Rssi6 indicates the highest strength.
91 /// Enumeration for the network types.
100 /// 2G GSM network type.
104 /// 2.5G GPRS network type.
108 /// 2.5G EDGE network type.
112 /// 3G UMTS network type.
116 /// HSDPA network type.
120 /// LTE network type.
124 /// IS95A network type.
128 /// IS95B network type.
132 /// CDMA 1x network type.
136 /// EVDO revision 0 network type.
140 /// EVDO revision A network type.
144 /// EVDO revision B network type.
148 /// EVDV network type.
152 /// EHRPD network type.
158 /// Enumeration for the PS types.
185 /// Enumeration for the network service states.
187 public enum ServiceState
198 /// Only emergency call is allowed.
208 /// Enumeration for the network name priority.
210 public enum NameOption
217 /// The network name displayed by the SPN.
221 /// The network name displayed by the Network.
225 /// The network name displayed by the SPN or the Network.
231 /// Enumeration for the possible 'default' Data Subscriptions for the Packet Switched(PS).
233 public enum DefaultDataSubscription
250 /// Enumeration for defining the possible 'default' Subscriptions for the Circuit Switched(CS).
252 public enum DefaultSubscription
269 /// Enumeration for the network selection modes.
271 public enum SelectionMode
288 /// Gets the LAC (Location Area Code) of the current location.
290 /// <since_tizen> 3 </since_tizen>
291 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
293 /// This API can be used in the GSM/WCDMA network.
296 /// The Location Area Code, -1 if unknown.
303 TelephonyError error = Interop.Network.GetLac(_handle, out lac);
304 if (error != TelephonyError.None)
306 Tizen.Log.Error(Interop.Telephony.LogTag, "GetLac Failed with error " + error);
310 Log.Info(Interop.Telephony.LogTag, "Lac Value " + lac);
317 /// Gets the cell ID of the current location.
319 /// <since_tizen> 3 </since_tizen>
320 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
322 /// This API can be used in the GSM/WCDMA/LTE network.
325 /// The cell identification number, -1 if unknown.
332 TelephonyError error = Interop.Network.GetCellId(_handle, out cellId);
333 if (error != TelephonyError.None)
335 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCellId Failed with error " + error);
339 Log.Info(Interop.Telephony.LogTag, "CellId Value " + cellId);
345 /// Gets the RSSI (Received Signal Strength Indicator).
347 /// <since_tizen> 3 </since_tizen>
348 /// <privilege>http://tizen.org/privilege/telephony</privilege>
350 /// The Received Signal Strength Indicator.
351 /// Higher the received number, the stronger the signal strength.
353 public Rssi CurrentRssi
358 TelephonyError error = Interop.Network.GetRssi(_handle, out currentRssi);
359 if (error != TelephonyError.None)
361 Tizen.Log.Error(Interop.Telephony.LogTag, "GetRssi Failed with error " + error);
362 return Rssi.Unavailable;
365 Log.Info(Interop.Telephony.LogTag, "CurrentRssi Value " + currentRssi);
371 /// Gets the roaming state of the current registered network.
373 /// <since_tizen> 3 </since_tizen>
374 /// <privilege>http://tizen.org/privilege/telephony</privilege>
376 /// true if roaming, otherwise false if not roaming.
378 public bool RoamingStatus
383 TelephonyError error = Interop.Network.GetRoamingStatus(_handle, out roamingStatus);
384 if (error != TelephonyError.None)
386 Tizen.Log.Error(Interop.Telephony.LogTag, "GetRoamingStatus Failed with error " + error);
390 return roamingStatus;
395 /// Gets the MCC (Mobile Country Code) of the current registered network.
397 /// <since_tizen> 3 </since_tizen>
398 /// <privilege>http://tizen.org/privilege/telephony</privilege>
400 /// This API can be used in the GSM/WCDMA/LTE network.
403 /// The Mobile Country Code (three digits). The Mobile Country Code (MCC) identifies the country where the cell is being used.
404 /// Empty string if unknown.
411 TelephonyError error = Interop.Network.GetMcc(_handle, out mcc);
412 if (error != TelephonyError.None)
414 Tizen.Log.Error(Interop.Telephony.LogTag, "GetMcc Failed with error " + error);
423 /// Gets the MNC (Mobile Network Code) of the current registered network.
425 /// <since_tizen> 3 </since_tizen>
426 /// <privilege>http://tizen.org/privilege/telephony</privilege>
428 /// This API can be used in the GSM/WCDMA/LTE network.
431 /// The Mobile Network Code (three digits). The Mobile Network Code (MNC) identifies the mobile phone operator and the network provider.
432 /// Empty string if unknown.
439 TelephonyError error = Interop.Network.GetMnc(_handle, out mnc);
440 if (error != TelephonyError.None)
442 Tizen.Log.Error(Interop.Telephony.LogTag, "GetMnc Failed with error " + error);
451 /// Gets the name of the current registered network.
453 /// <since_tizen> 3 </since_tizen>
454 /// <privilege>http://tizen.org/privilege/telephony</privilege>
456 /// This API can be used in the GSM/WCDMA/LTE network.
459 /// The name of the current registered network.
460 /// Empty string if unknown.
462 public string NetworkName
467 TelephonyError error = Interop.Network.GetNetworkName(_handle, out networkName);
468 if (error != TelephonyError.None)
470 Tizen.Log.Error(Interop.Telephony.LogTag, "GetNetworkName Failed with error " + error);
479 /// Gets the network service type of the current registered network.
481 /// <since_tizen> 3 </since_tizen>
482 /// <privilege>http://tizen.org/privilege/telephony</privilege>
484 /// This API can be used in case the network is in service.
487 /// The network service type.
489 public Type NetworkType
494 TelephonyError error = Interop.Network.GetType(_handle, out networkType);
495 if (error != TelephonyError.None)
497 Tizen.Log.Error(Interop.Telephony.LogTag, "GetType Failed with error " + error);
506 /// Gets the packet service type of the current registered network.
508 /// <since_tizen> 3 </since_tizen>
509 /// <privilege>http://tizen.org/privilege/telephony</privilege>
511 /// This API can be used in the HSDPA network.
514 /// The type of the packet service.
516 public PsType NetworkPsType
520 PsType networkPsType;
521 TelephonyError error = Interop.Network.GetPsType(_handle, out networkPsType);
522 if (error != TelephonyError.None)
524 Tizen.Log.Error(Interop.Telephony.LogTag, "GetPsType Failed with error " + error);
525 return PsType.Unknown;
528 return networkPsType;
534 /// Gets the network name option of the current registered network.
536 /// <since_tizen> 3 </since_tizen>
537 /// <privilege>http://tizen.org/privilege/telephony</privilege>
539 /// The network name display option.
541 public NameOption NetworkNameOption
545 NameOption networkNameOption;
546 TelephonyError error = Interop.Network.GetNetworkNameOption(_handle, out networkNameOption);
547 if (error != TelephonyError.None)
549 Tizen.Log.Error(Interop.Telephony.LogTag, "GetNetworkNameOption Failed with error " + error);
550 return NameOption.Unknown;
553 return networkNameOption;
559 /// Gets the current network state of the telephony service.
561 /// <since_tizen> 3 </since_tizen>
562 /// <privilege>http://tizen.org/privilege/telephony</privilege>
564 /// The current network state.
566 public ServiceState NetworkServiceState
570 ServiceState networkServiceState;
571 TelephonyError error = Interop.Network.GetServiceState(_handle, out networkServiceState);
572 if (error != TelephonyError.None)
574 Tizen.Log.Error(Interop.Telephony.LogTag, "GetServiceState Failed with error " + error);
575 return ServiceState.Unavailable;
578 return networkServiceState;
584 /// Gets the current default subscription for the data service (Packet Switched).
586 /// <since_tizen> 3 </since_tizen>
587 /// <privilege>http://tizen.org/privilege/telephony</privilege>
589 /// The current default data subscription.
591 public DefaultDataSubscription NetworkDefaultDataSubscription
595 DefaultDataSubscription networkDefaultDataSubs;
596 TelephonyError error = Interop.Network.GetDefaultDataSubscription(_handle, out networkDefaultDataSubs);
597 if (error != TelephonyError.None)
599 Tizen.Log.Error(Interop.Telephony.LogTag, "GetDefaultDataSubscription Failed with error " + error);
600 return DefaultDataSubscription.Unknown;
603 return networkDefaultDataSubs;
609 /// Gets the current default subscription for the voice service (Circuit Switched).
611 /// <since_tizen> 3 </since_tizen>
612 /// <privilege>http://tizen.org/privilege/telephony</privilege>
614 /// The current default voice subscription.
616 public DefaultSubscription NetworkDefaultSubscription
620 DefaultSubscription networkDefaultSubscription;
621 TelephonyError error = Interop.Network.GetDefaultSubscription(_handle, out networkDefaultSubscription);
622 if (error != TelephonyError.None)
624 Tizen.Log.Error(Interop.Telephony.LogTag, "GetDefaultSubscription Failed with error " + error);
625 return DefaultSubscription.Unknown;
628 return networkDefaultSubscription;
634 /// Gets the network selection mode.
636 /// <since_tizen> 3 </since_tizen>
637 /// <privilege>http://tizen.org/privilege/telephony</privilege>
639 /// The network selection mode.
641 public SelectionMode NetworkSelectionMode
645 SelectionMode networkSelectionMode;
646 TelephonyError error = Interop.Network.GetSelectionMode(_handle, out networkSelectionMode);
647 if (error != TelephonyError.None)
649 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSelectionMode Failed with error " + error);
650 return SelectionMode.Unavailable;
653 return networkSelectionMode;
659 /// Gets the TAC (Tracking Area Code) of the current location.
661 /// <since_tizen> 3 </since_tizen>
662 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
664 /// This API can be used in the LTE network.
667 /// The Tracking Area Code.
675 TelephonyError error = Interop.Network.GetTac(_handle, out tac);
676 if (error != TelephonyError.None)
678 Tizen.Log.Error(Interop.Telephony.LogTag, "GetTac Failed with error " + error);
688 /// Gets the system ID of the current location.
690 /// <since_tizen> 3 </since_tizen>
691 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
693 /// This API can be used in the CDMA network.
704 TelephonyError error = Interop.Network.GetSystemId(_handle, out systemId);
705 if (error != TelephonyError.None)
707 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSystemId Failed with error " + error);
717 /// Gets the network ID of the current location.
719 /// <since_tizen> 3 </since_tizen>
720 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
722 /// This API can be used in the CDMA network.
733 TelephonyError error = Interop.Network.GetNetworkId(_handle, out networkId);
734 if (error != TelephonyError.None)
736 Tizen.Log.Error(Interop.Telephony.LogTag, "GetNetworkId Failed with error " + error);
746 /// Gets the base station ID of the current location.
748 /// <since_tizen> 3 </since_tizen>
749 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>>
751 /// This API can be used in the CDMA network.
754 /// The base station ID.
758 public int BaseStationId
763 TelephonyError error = Interop.Network.GetBaseStationId(_handle, out baseStationId);
764 if (error != TelephonyError.None)
766 Tizen.Log.Error(Interop.Telephony.LogTag, "GetBaseStationId Failed with error " + error);
770 return baseStationId;
776 /// Gets the base station latitude of the current location.
778 /// <since_tizen> 3 </since_tizen>
779 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
781 /// This API can be used in the CDMA network.
784 /// The base station latitude.
785 /// 0x7FFFFFFF if unknown.
787 public int BaseStationLatitude
791 int baseStationLatitude;
792 TelephonyError error = Interop.Network.GetBaseStationLatitude(_handle, out baseStationLatitude);
793 if (error != TelephonyError.None)
795 Tizen.Log.Error(Interop.Telephony.LogTag, "GetBaseStationLatitude Failed with error " + error);
799 return baseStationLatitude;
804 /// Gets the base station longitude of the current location.
806 /// <since_tizen> 3 </since_tizen>
807 /// <privilege>http://tizen.org/privilege/location.coarse</privilege>
809 /// This API can be used in the CDMA network.
812 /// The base station latitude.
813 /// 0x7FFFFFFF if unknown.
815 public int BaseStationLongitude
819 int baseStationLongitude;
820 TelephonyError error = Interop.Network.GetBaseStationLongitude(_handle, out baseStationLongitude);
821 if (error != TelephonyError.None)
823 Tizen.Log.Error(Interop.Telephony.LogTag, "GetBaseStationLongitude Failed with error " + error);
827 return baseStationLongitude;