Example #1
0
        /// <summary>
        /// Set the network roaming preference asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="roamPref">The network roaming preference.</param>
        /// <returns>A task indicating whether the SetRoamingPreference 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 network instance is invalid or when method failed due to invalid operation.</exception>
        public Task SetRoamingPreference(NetworkPreferred roamPref)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

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

                    task.SetResult(true);
                });

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

            int ret = Interop.Tapi.Network.SetNetworkRoamPreference(_handle, roamPref, _response_map[id], id);

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

            return(task.Task);
        }
Example #2
0
        private async void SetGetRoamPrefBtn_Clicked(object sender, EventArgs e)
        {
            try
            {
                Log.Debug(Globals.LogTag, "Set and get roaming preference start");
                var action = await DisplayActionSheet("Operation", "Cancel", null, Enum.GetNames(typeof(NetworkPreferred)));

                Log.Debug(Globals.LogTag, "Action: " + action);
                if (action != null)
                {
                    NetworkPreferred mode = (NetworkPreferred)Enum.Parse(typeof(NetworkPreferred), action);
                    await network.SetRoamingPreference(mode);

                    NetworkPreferred curMode = await network.GetRoamingPreference();

                    if (curMode == mode)
                    {
                        Log.Debug(Globals.LogTag, "Set and get roaming preference is success, currentmode = " + curMode);
                    }

                    else
                    {
                        Log.Debug(Globals.LogTag, "Set and get roaming preference has failed, currentmode = " + curMode + ", while the network mode was set to " + mode);
                    }
                }
            }

            catch (Exception ex)
            {
                Log.Debug(Globals.LogTag, "Set and Get roaming preference ,exception = " + ex.ToString());
            }
        }
Example #3
0
 internal static extern int SetNetworkRoamPreference(IntPtr handle, NetworkPreferred prefRoam, TapiResponseCallback cb, IntPtr userData);