internal static OemData ConvertOemStruct(OemDataStruct info) { OemData data = new OemData(); data.OemId = info.OemId; int length = Convert.ToInt32(info.Length); data.OemDataInfo = new byte[length]; Marshal.Copy(info.Data, data.OemDataInfo, 0, length); return(data); }
/// <summary> /// Sends oem data directly. /// </summary> /// <param name="oemId">Oem id for user specification.</param> /// <param name="data">Oem data for sending.</param> /// <returns>The oem data which is sent.</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 call instance is invalid or when method failed due to invalid operation.</exception> public OemData SendOemDataSync(int oemId, byte[] data) { OemDataStruct oemStruct; int length = data.Length; IntPtr oemData = Marshal.AllocHGlobal(length); Marshal.Copy(data, 0, oemData, length); int ret = Interop.Tapi.Oem.SendOemDataSync(_handle, oemId, oemData, Convert.ToUInt32(length), out oemStruct); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to send oem data directly, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); } OemData oemDataSend = OemStructConversions.ConvertOemStruct(oemStruct); return(oemDataSend); }
/// <summary> /// Sends oem data directly. /// </summary> /// <param name="oemId">Oem id for user specification.</param> /// <param name="data">Oem data for sending.</param> /// <returns>The oem data which is sent.</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 call instance is invalid or when method failed due to invalid operation.</exception> public Task <OemData> SendOemDataAsync(int oemId, byte[] data) { TaskCompletionSource <OemData> task = new TaskCompletionSource <OemData>(); IntPtr id; id = (IntPtr)_requestId++; _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) => { Task resultTask = new Task(() => { if (result != (int)NetworkOperationCause.NoError) { Log.Error(TapiUtility.LogTag, "Error occurs during sending oem data, " + (NetworkOperationCause)result); task.SetException(new InvalidOperationException("Error occurs during sending oem data, " + (NetworkOperationCause)result)); return; } OemDataStruct oemStruct = Marshal.PtrToStructure <OemDataStruct>(dataResponse); OemData oemClass = OemStructConversions.ConvertOemStruct(oemStruct); task.SetResult(oemClass); }); resultTask.Start(); resultTask.Wait(); _response_map.Remove(key); }; int length = data.Length; IntPtr oemData = Marshal.AllocHGlobal(length); Marshal.Copy(data, 0, oemData, length); int ret = Interop.Tapi.Oem.SendOemDataAsync(_handle, oemId, oemData, Convert.ToUInt32(length), _response_map[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to send oem data, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); } return(task.Task); }