From: Wootak Jung Date: Tue, 13 Apr 2021 04:25:45 +0000 (+0900) Subject: [Bluetooth][Non-ACR] Fix BluetoothDevice data converting issue (#2888) X-Git-Tag: submit/tizen_6.0/20210414.005501~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8fff6cf97aef58f88a2cd26ed99b3edfd9a7a15f;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Bluetooth][Non-ACR] Fix BluetoothDevice data converting issue (#2888) Signed-off-by: Wootak Jung --- diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs index 2e48533b4..e8349a0ba 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs @@ -115,8 +115,7 @@ namespace Tizen.Network.Bluetooth [MarshalAsAttribute(UnmanagedType.LPStr)] internal string Address; - [MarshalAsAttribute(UnmanagedType.LPStr)] - internal string Name; + internal IntPtr Name; internal BluetoothClassStruct Class; @@ -289,19 +288,24 @@ namespace Tizen.Network.Bluetooth { BluetoothDevice resultDevice = new BluetoothDevice(); Collection uuidList = null; + const int DeviceNameLengthMax = 248; + const int UuidLengthMax = 50; if (structDevice.ServiceCount > 0) { IntPtr[] extensionList = new IntPtr[structDevice.ServiceCount]; Marshal.Copy (structDevice.ServiceUuidList, extensionList, 0, structDevice.ServiceCount); uuidList = new Collection (); foreach (IntPtr extension in extensionList) { - string uuid = Marshal.PtrToStringAnsi (extension); - uuidList.Add (uuid); + if (extension != IntPtr.Zero) + { + string uuid = Marshal.PtrToStringAnsi(extension, UuidLengthMax); + uuidList.Add(uuid); + } } } resultDevice.RemoteDeviceAddress = structDevice.Address; - resultDevice.RemoteDeviceName = structDevice.Name; + resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(structDevice.Name, DeviceNameLengthMax); resultDevice.RemoteDeviceClass = new BluetoothClass(); resultDevice.Class.MajorType = structDevice.Class.MajorDeviceClassType;