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 API's to obtain information about the current telephony service network.
26 internal IntPtr _handle;
29 /// Network Class Constructor
31 /// <param name="handle">
32 /// SlotHandle received in the Manager.Init API
34 /// <exception cref="ArgumentNullException">
35 /// This exception occurs if handle provided is null
37 public Network(SlotHandle handle)
41 throw new ArgumentNullException();
44 _handle = handle._handle;
48 /// Enumeration for RSSI (Receive Signal Strength Indicator).
49 /// Rssi6 indicates the highest strength.
88 /// Enumeration for Network Type.
97 /// 2G GSM network type
101 /// 2.5G GPRS network type
105 /// 2.5G EDGE network type
109 /// 3G UMTS network type
113 /// HSDPA network type
121 /// IS95A network type
125 /// IS95B network type
129 /// CDMA 1x network type
133 /// EVDO revision 0 network type
137 /// EVDO revision A network type
141 /// EVDO revision B network type
145 /// EVDV network type
149 /// EHRPD network type
155 /// Enumeration for PS Type.
182 /// Enumeration for Network Service State.
184 public enum ServiceState
195 /// Only emergency call is allowed
205 /// Enumeration for Network Name Priority.
207 public enum NameOption
214 /// Network name displayed by SPN
218 /// Network name displayed by Network
222 /// Network name displayed by SPN or Network
228 /// Enumeration for the possible 'default' Data Subscriptions for Packet Switched(PS).
230 public enum DefaultDataSubscription
247 /// Enumeration defines possible 'default' Subscriptions for Circuit Switched(CS).
249 public enum DefaultSubscription
266 /// Enumeration for network selection mode.
268 public enum SelectionMode
285 /// Gets the LAC (Location Area Code) of the current location.
288 /// http://tizen.org/privilege/location.coarse
291 /// This API can be used in GSM / WCDMA network.
294 /// The Location Area Code, -1 if unknown
301 TelephonyError error = Interop.Network.GetLac(_handle, out lac);
302 if (error != TelephonyError.None)
304 Tizen.Log.Error(Interop.Telephony.LogTag, "GetLac Failed with error " + error);
308 Log.Info(Interop.Telephony.LogTag, "Lac Value " + lac);
315 /// Gets the cell ID of the current location.
318 /// http://tizen.org/privilege/location.coarse
321 /// This API can be used in GSM / WCDMA / LTE network.
324 /// The cell identification number, -1 if unknown
331 TelephonyError error = Interop.Network.GetCellId(_handle, out cellId);
332 if (error != TelephonyError.None)
334 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCellId Failed with error " + error);
338 Log.Info(Interop.Telephony.LogTag, "CellId Value " + cellId);
344 /// Gets the RSSI (Received Signal Strength Indicator).
347 /// http://tizen.org/privilege/telephony
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.
374 /// http://tizen.org/privilege/telephony
377 /// true if roaming, otherwise false if not roaming
379 public bool RoamingStatus
384 TelephonyError error = Interop.Network.GetRoamingStatus(_handle, out roamingStatus);
385 if (error != TelephonyError.None)
387 Tizen.Log.Error(Interop.Telephony.LogTag, "GetRoamingStatus Failed with error " + error);
391 return roamingStatus;
396 /// Gets the MCC (Mobile Country Code) of the current registered network.
399 /// http://tizen.org/privilege/telephony
402 /// This API can be used in GSM / WCDMA / LTE network.
405 /// The Mobile Country Code (three digits) Mobile Country Code (MCC) identifies the country where the cell is being used.
406 /// empty string if unknown.
413 TelephonyError error = Interop.Network.GetMcc(_handle, out mcc);
414 if (error != TelephonyError.None)
416 Tizen.Log.Error(Interop.Telephony.LogTag, "GetMcc Failed with error " + error);
425 /// Gets the MNC (Mobile Network Code) of the current registered network.
428 /// http://tizen.org/privilege/telephony
431 /// This API can be used in GSM / WCDMA / LTE network.
434 /// The Mobile Network Code (three digits) The Mobile Network Code (MNC) identifies the mobile phone operator and network provider.
435 /// empty string if unknown.
442 TelephonyError error = Interop.Network.GetMnc(_handle, out mnc);
443 if (error != TelephonyError.None)
445 Tizen.Log.Error(Interop.Telephony.LogTag, "GetMnc Failed with error " + error);
454 /// Gets the name of the current registered network.
457 /// http://tizen.org/privilege/telephony
460 /// This API can be used in GSM / WCDMA / LTE network.
463 /// The name of the current registered network
464 /// empty string if unknown.
466 public string NetworkName
471 TelephonyError error = Interop.Network.GetNetworkName(_handle, out networkName);
472 if (error != TelephonyError.None)
474 Tizen.Log.Error(Interop.Telephony.LogTag, "GetNetworkName Failed with error " + error);
483 /// Gets the network service type of the current registered network.
486 /// http://tizen.org/privilege/telephony
489 /// This API can be used in case network is in service.
492 /// The network service type
494 public Type NetworkType
499 TelephonyError error = Interop.Network.GetType(_handle, out networkType);
500 if (error != TelephonyError.None)
502 Tizen.Log.Error(Interop.Telephony.LogTag, "GetType Failed with error " + error);
511 /// Gets the packet service type of the current registered network.
514 /// http://tizen.org/privilege/telephony
517 /// This API can be used in HSDPA network.
520 /// The type of packet service
522 public PsType NetworkPsType
526 PsType networkPsType;
527 TelephonyError error = Interop.Network.GetPsType(_handle, out networkPsType);
528 if (error != TelephonyError.None)
530 Tizen.Log.Error(Interop.Telephony.LogTag, "GetPsType Failed with error " + error);
531 return PsType.Unknown;
534 return networkPsType;
540 /// Gets the network name option of the current registered network.
543 /// http://tizen.org/privilege/telephony
546 /// The network name display option
548 public NameOption NetworkNameOption
552 NameOption networkNameOption;
553 TelephonyError error = Interop.Network.GetNetworkNameOption(_handle, out networkNameOption);
554 if (error != TelephonyError.None)
556 Tizen.Log.Error(Interop.Telephony.LogTag, "GetNetworkNameOption Failed with error " + error);
557 return NameOption.Unknown;
560 return networkNameOption;
566 /// Gets the current network state of the telephony service.
569 /// http://tizen.org/privilege/telephony
572 /// The current network state
574 public ServiceState NetworkServiceState
578 ServiceState networkServiceState;
579 TelephonyError error = Interop.Network.GetServiceState(_handle, out networkServiceState);
580 if (error != TelephonyError.None)
582 Tizen.Log.Error(Interop.Telephony.LogTag, "GetServiceState Failed with error " + error);
583 return ServiceState.Unavailable;
586 return networkServiceState;
592 /// Gets the current default subscription for data service (Packet Switched).
595 /// http://tizen.org/privilege/telephony
598 /// The current default data subscription
600 public DefaultDataSubscription NetworkDefaultDataSubscription
604 DefaultDataSubscription networkDefaultDataSubs;
605 TelephonyError error = Interop.Network.GetDefaultDataSubscription(_handle, out networkDefaultDataSubs);
606 if (error != TelephonyError.None)
608 Tizen.Log.Error(Interop.Telephony.LogTag, "GetDefaultDataSubscription Failed with error " + error);
609 return DefaultDataSubscription.Unknown;
612 return networkDefaultDataSubs;
618 /// Gets the current default subscription for voice service (Circuit Switched).
621 /// http://tizen.org/privilege/telephony
624 /// The current default voice subscription
626 public DefaultSubscription NetworkDefaultSubscription
630 DefaultSubscription networkDefaultSubscription;
631 TelephonyError error = Interop.Network.GetDefaultSubscription(_handle, out networkDefaultSubscription);
632 if (error != TelephonyError.None)
634 Tizen.Log.Error(Interop.Telephony.LogTag, "GetDefaultSubscription Failed with error " + error);
635 return DefaultSubscription.Unknown;
638 return networkDefaultSubscription;
644 /// Gets the network selection mode.
647 /// http://tizen.org/privilege/telephony
650 /// The network selection mode.
652 public SelectionMode NetworkSelectionMode
656 SelectionMode networkSelectionMode;
657 TelephonyError error = Interop.Network.GetSelectionMode(_handle, out networkSelectionMode);
658 if (error != TelephonyError.None)
660 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSelectionMode Failed with error " + error);
661 return SelectionMode.Unavailable;
664 return networkSelectionMode;
670 /// Gets the TAC (Tracking Area Code) of the current location.
673 /// http://tizen.org/privilege/telephony
676 /// This API can be used in LTE network.
679 /// The Tracking Area Code
687 TelephonyError error = Interop.Network.GetTac(_handle, out tac);
688 if (error != TelephonyError.None)
690 Tizen.Log.Error(Interop.Telephony.LogTag, "GetTac Failed with error " + error);
700 /// Gets the system ID of the current location.
703 /// http://tizen.org/privilege/telephony
706 /// This API can be used in CDMA network.
717 TelephonyError error = Interop.Network.GetSystemId(_handle, out systemId);
718 if (error != TelephonyError.None)
720 Tizen.Log.Error(Interop.Telephony.LogTag, "GetSystemId Failed with error " + error);
730 /// Gets the network ID of the current location.
733 /// http://tizen.org/privilege/location.coarse
736 /// This API can be used in CDMA network.
747 TelephonyError error = Interop.Network.GetNetworkId(_handle, out networkId);
748 if (error != TelephonyError.None)
750 Tizen.Log.Error(Interop.Telephony.LogTag, "GetNetworkId Failed with error " + error);
760 /// Gets the base station ID of the current location.
763 /// http://tizen.org/privilege/location.coarse
766 /// This API can be used in CDMA network.
769 /// The base station ID
773 public int BaseStationId
778 TelephonyError error = Interop.Network.GetBaseStationId(_handle, out baseStationId);
779 if (error != TelephonyError.None)
781 Tizen.Log.Error(Interop.Telephony.LogTag, "GetBaseStationId Failed with error " + error);
785 return baseStationId;
791 /// Gets the base station latitude of the current location.
794 /// http://tizen.org/privilege/location.coarse
797 /// This API can be used in CDMA network.
800 /// The base station latitude
801 /// 0x7FFFFFFF if unknown
803 public int BaseStationLatitude
807 int baseStationLatitude;
808 TelephonyError error = Interop.Network.GetBaseStationLatitude(_handle, out baseStationLatitude);
809 if (error != TelephonyError.None)
811 Tizen.Log.Error(Interop.Telephony.LogTag, "GetBaseStationLatitude Failed with error " + error);
815 return baseStationLatitude;
820 /// Gets the base station longitude of the current location.
823 /// http://tizen.org/privilege/location.coarse
826 /// This API can be used in CDMA network.
829 /// The base station latitude
830 /// 0x7FFFFFFF if unknown
832 public int BaseStationLongitude
836 int baseStationLongitude;
837 TelephonyError error = Interop.Network.GetBaseStationLongitude(_handle, out baseStationLongitude);
838 if (error != TelephonyError.None)
840 Tizen.Log.Error(Interop.Telephony.LogTag, "GetBaseStationLongitude Failed with error " + error);
844 return baseStationLongitude;