internal static MiscSerialNumberInformation ConvertSerialNumberStruct(MiscSerialNumInfoStruct infoStruct) { MiscSerialNumberInformation serialNumberInfo = new MiscSerialNumberInformation(); serialNumberInfo.SzEsn = infoStruct.Esn; serialNumberInfo.SzImei = infoStruct.Imei; serialNumberInfo.SzImeiSv = infoStruct.ImeiSv; serialNumberInfo.SzMeid = infoStruct.MeId; return(serialNumberInfo); }
/// <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); }