Beispiel #1
0
        /// <summary>
        /// Turn the modem on/off asynchronously.
        /// </summary>
        /// <param name="cmd">Power command value.</param>
        /// <returns>A task indicating whether the ProcessPowerCommand method is done or not.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task ProcessPowerCommand(PhonePowerCommand cmd)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during turning modem on/off, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during turning modem on/off, " + (TapiError)result));
                        return;
                    }

                    task.SetResult(true);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.ProcessPowerCommand(_handle, cmd, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to turn the modem on/off, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Beispiel #2
0
        /// <summary>
        /// Get the Misc Me Imei asynchronously.
        /// </summary>
        /// <returns>The imei string.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <string> GetMiscMeImei()
        {
            TaskCompletionSource <string> task = new TaskCompletionSource <string>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Misc Me Imei, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the Misc Me Imei, " + (TapiError)result));
                        return;
                    }

                    task.SetResult(Marshal.PtrToStringAnsi(data));
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetMiscMeImei(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the Misc Me Imei information, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Beispiel #3
0
        /// <summary>
        /// Check the modem power status.
        /// </summary>
        /// <returns>Phone power status value.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public PhonePowerStatus CheckPowerStatus()
        {
            int result;
            int ret = Interop.Tapi.Modem.CheckPowerStatus(_handle, out result);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to check the modem power status, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return((PhonePowerStatus)result);
        }
Beispiel #4
0
        /// <summary>
        /// Get the flight mode asynchronously.
        /// </summary>
        /// <returns>If flight mode is On, it returns true else it returns false.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <bool> GetFlightMode()
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the flight mode, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the flight mode, " + (TapiError)result));
                        return;
                    }

                    int mode = Marshal.ReadInt32(data);
                    if (mode == 1)
                    {
                        task.SetResult(true);
                    }

                    else
                    {
                        task.SetResult(false);
                    }
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetFlightMode(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the flight mode, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Beispiel #5
0
        /// <summary>
        /// Get device vendor name and device name of cellular dongle.
        /// </summary>
        /// <returns>Instance of MiscDeviceInfo.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <remarks>
        /// Result can be delivered with only cellular dongle insertion.
        /// </remarks>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <MiscDeviceInfo> GetDeviceInfo()
        {
            TaskCompletionSource <MiscDeviceInfo> task = new TaskCompletionSource <MiscDeviceInfo>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the device name and vendor name, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the device name and vendor name, " + (TapiError)result));
                        return;
                    }

                    MiscDeviceInfoStruct infoStruct = Marshal.PtrToStructure <MiscDeviceInfoStruct>(data);
                    MiscDeviceInfo deviceInfo       = ModemStructConversions.ConvertMiscInfoStruct(infoStruct);
                    task.SetResult(deviceInfo);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetDeviceInfo(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the device vendor name and device name, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Beispiel #6
0
        /// <summary>
        /// Get the Me Esn/Meid for each phone type asynchronously.
        /// </summary>
        /// <returns>Instance of MiscSerialNumberInformation.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <MiscSerialNumberInformation> GetMiscMeSn()
        {
            TaskCompletionSource <MiscSerialNumberInformation> task = new TaskCompletionSource <MiscSerialNumberInformation>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Me Esn/Meid, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the Me Esn/Meid, " + (TapiError)result));
                        return;
                    }

                    MiscSerialNumInfoStruct infoStruct            = Marshal.PtrToStructure <MiscSerialNumInfoStruct>(data);
                    MiscSerialNumberInformation serialNumberClass = ModemStructConversions.ConvertSerialNumberStruct(infoStruct);
                    task.SetResult(serialNumberClass);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetMiscMeSn(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the Me Esn/Meid information for each phone type, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }