Exemplo n.º 1
0
        /// <summary>
        /// Acquires the number of available handles to use the telephony API.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>
        /// A list of telephony handles.
        /// You will get 2 SlotHandles in case of the dual SIM device.
        /// Where, SlotHandle at Index '0' represents the primary SIM and Index '1' represents the secondary SIM.
        /// </returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="InvalidOperationException">
        /// This exception will be generated in the following cases:
        /// 1. The system is out of memory.
        /// 2. If the operation is not supported on the device.
        /// 3. If the operation failed.
        /// </exception>
        public static IEnumerable <SlotHandle> Init()
        {
            //DeInitialize Previous Handles if present
            if (_isInitialized)
            {
                Deinit();
            }

            TelephonyError err = Interop.Telephony.TelephonyInit(out _handleList);

            if (err != TelephonyError.None)
            {
                Exception e = ExceptionFactory.CreateException(err);
                // Check if error is Invalid Parameter then hide the error
                if (e is ArgumentException)
                {
                    e = new InvalidOperationException("Internal Error Occured");
                }

                throw e;
            }

            int offset = 0;

            for (int i = 0; i < _handleList.Count; i++)
            {
                _telephonyHandle.Add(new SlotHandle(Marshal.ReadIntPtr(_handleList.HandleArrayPointer, offset)));
                offset += Marshal.SizeOf(_handleList.HandleArrayPointer);
            }

            _isInitialized = true;
            //Tizen.Log.Info(Interop.Telephony.LogTag, "Returning the number of sims " + _handleList.Count);
            return(_telephonyHandle);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the list of the current call.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>
        /// The list of the CallHandle for existing calls.
        /// </returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="UnauthorizedAccessException">In case of privileges not defined.</exception>
        /// <exception cref="OutOfMemoryException">In case of out of memory.</exception>
        public IEnumerable <CallHandle> GetCallHandleList()
        {
            uint count;

            _callList = new IntPtr();
            _list.Clear();
            TelephonyError error = Interop.Call.GetCallList(_handle, out count, out _callList);

            if (error != TelephonyError.None)
            {
                Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallList Failed with error " + error);
                throw ExceptionFactory.CreateException(error);
            }

            _callHandle.Clear();
            if (count > 0)
            {
                IntPtr[] handleArray = new IntPtr[count];
                Marshal.Copy(_callList, handleArray, 0, (int)count);
                foreach (IntPtr handle in handleArray)
                {
                    CallHandle info = new CallHandle(handle);
                    _list.Add(info);
                }

                _safeCallList = new Interop.Call.SafeCallList(_callList, count);
            }
            return(_list);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deinitializes the telephony handles.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="InvalidOperationException">
        /// This exception can be generated in the following cases:
        /// 1. If the operation is not supported on the device.
        /// 2. If the operation failed.
        /// </exception>
        public static void Deinit()
        {
            TelephonyError error = Interop.Telephony.TelephonyDeinit(ref _handleList);

            if (error != 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;
            }

            _isInitialized = false;
            _telephonyHandle.Clear();
        }