Пример #1
0
 /// <summary>
 /// The notification IDs for which the ChangeNotification event will not be triggered.
 /// </summary>
 /// <since_tizen> 3 </since_tizen>
 /// <param name="list">
 /// The list of notification IDs for which the ChangeNotification event will be not be triggered.
 /// </param>
 /// <feature>http://tizen.org/feature/network.telephony</feature>
 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
 /// <exception cref="InvalidOperationException">
 /// This Exception can occur due to:
 /// 1. Operation not supported.
 /// 2. Operation failed.
 /// </exception>
 public void RemoveNotificationId(IEnumerable <ChangeNotificationEventArgs.Notification> list)
 {
     foreach (ChangeNotificationEventArgs.Notification n in list)
     {
         Interop.Telephony.TelephonyError error = Interop.Telephony.TelephonyUnsetNotiCb(_handle, n);
         if (error != Interop.Telephony.TelephonyError.None)
         {
             throw ExceptionFactory.CreateException(error);
         }
     }
 }
Пример #2
0
        internal static Exception CreateException(Interop.Telephony.TelephonyError err)
        {
            Tizen.Log.Error(Interop.Telephony.LogTag, "Error " + err);
            Exception exp;

            switch (err)
            {
            case Interop.Telephony.TelephonyError.InvalidParameter:
            {
                exp = new ArgumentException("Invalid Parameters Provided");
                break;
            }

            case Interop.Telephony.TelephonyError.NotSupported:
            {
                exp = new NotSupportedException("Not Supported");
                break;
            }

            case Interop.Telephony.TelephonyError.OperationFailed:
            {
                exp = new InvalidOperationException("Operation Failed");
                break;
            }

            case Interop.Telephony.TelephonyError.OutOfMemory:
            {
                exp = new OutOfMemoryException("Out Of Memory");
                break;
            }

            case Interop.Telephony.TelephonyError.PermissionDenied:
            {
                exp = new UnauthorizedAccessException("Permission Denied");
                break;
            }

            case Interop.Telephony.TelephonyError.SIMNotAvailable:
            {
                exp = new InvalidOperationException("SIM is Not Available");
                break;
            }

            default:
            {
                exp = new Exception("");
                break;
            }
            }

            return(exp);
        }
Пример #3
0
        private void SetCallback(ChangeNotificationEventArgs.Notification n)
        {
            Interop.Telephony.NotificationCallback NotificationDelegate = (IntPtr handle, ChangeNotificationEventArgs.Notification notiId, IntPtr data, IntPtr userData) =>
            {
                SlotHandle simHandle = Manager.FindHandle(handle);
                object     notiData  = null;
                switch (notiId)
                {
                case ChangeNotificationEventArgs.Notification.SimStatus:
                {
                    notiData = (Sim.State)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.SimCallForwardingIndicatorState:
                {
                    notiData = ((Marshal.ReadInt32(data) == 0) ? false : true);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkServiceState:
                {
                    notiData = (Network.ServiceState)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkCellid:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkRoamingStatus:
                {
                    notiData = (Marshal.ReadInt32(data) == 0) ? false : true;
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkSignalstrengthLevel:
                {
                    notiData = (Network.Rssi)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkNetworkName:
                {
                    notiData = Marshal.PtrToStringAnsi(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkPsType:
                {
                    notiData = (Network.PsType)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkDefaultDataSubscription:
                {
                    notiData = (Network.DefaultDataSubscription)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkDefaultSubscription:
                {
                    notiData = (Network.DefaultSubscription)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkLac:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkTac:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkSystemId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsLatitude:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsLongitude:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusIdle:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusActive:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusHeld:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusDialing:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusAlerting:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusIncoming:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusIdle:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusActive:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusDialing:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusAlerting:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusIncoming:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.CallPreferredVoiceSubscription:
                {
                    notiData = (CallPreferredVoiceSubscription)Marshal.ReadInt32(data);
                    break;
                }
                }

                ChangeNotificationEventArgs args = new ChangeNotificationEventArgs(notiId, notiData);
                ChangeNotification?.Invoke(simHandle, args);
            };
            _changeNotificationList.Add(NotificationDelegate);

            Interop.Telephony.TelephonyError error = Interop.Telephony.TelephonySetNotiCb(_handle, n, NotificationDelegate, IntPtr.Zero);
            if (error != Interop.Telephony.TelephonyError.None)
            {
                Exception e = ExceptionFactory.CreateException(error);
                // Check if error is Invalid Parameter then hide the error
                if (e is ArgumentException)
                {
                    e = new InvalidOperationException("Internal Error Occured");
                }

                throw e;
            }
        }