internal static NetworkServing ConvertNetworkServingStruct(NetworkServingStruct servStruct) { NetworkServing servingInfo = new NetworkServing(); NetworkAreaStruct areaStruct = servStruct.Area; NetworkCdmaSysStruct cdmaStruct = areaStruct.Cdma; NetworkCdmaSysInfo cdmaInfo = ConvertCdmaStruct(cdmaStruct); NetworkAreaInfo areaInfo = new NetworkAreaInfo(); areaInfo.Code = areaStruct.Lac; areaInfo.Cdma = cdmaInfo; servingInfo.NwPlmn = servStruct.Plmn; servingInfo.Type = servStruct.SysType; servingInfo.Area = areaInfo; return(servingInfo); }
/// <summary> /// Get the network serving information asynchronously. /// </summary> /// <since_tizen> 4 </since_tizen> /// <returns>Instance of NetworkServing.</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 network instance is invalid or when method failed due to invalid operation.</exception> public Task <NetworkServing> GetNetworkServing() { TaskCompletionSource <NetworkServing> task = new TaskCompletionSource <NetworkServing>(); 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 getting the network serving information, " + (TapiError)result); task.SetException(new InvalidOperationException("Error occurs during getting the network serving information, " + (TapiError)result)); return; } NetworkServingStruct servStruct = Marshal.PtrToStructure <NetworkServingStruct>(dataResponse); NetworkServing servingInfo = NetworkStructConversions.ConvertNetworkServingStruct(servStruct); task.SetResult(servingInfo); }); resultTask.Start(); resultTask.Wait(); _response_map.Remove(key); }; int ret = Interop.Tapi.Network.GetNetworkServing(_handle, _response_map[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to get the network serving information, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); } return(task.Task); }