[Bluetooth][Non-ACR] Fix DeviceName converting issue (#3351)
authorWootak Jung <wootak.jung@samsung.com>
Thu, 29 Jul 2021 23:26:24 +0000 (08:26 +0900)
committerGitHub <noreply@github.com>
Thu, 29 Jul 2021 23:26:24 +0000 (08:26 +0900)
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs

index 5d97666..60e63fd 100644 (file)
@@ -250,9 +250,6 @@ namespace Tizen.Network.Bluetooth
     {
         internal static BluetoothDevice ConvertStructToDeviceClass(BluetoothDeviceStruct device)
         {
-            const int DeviceNameLengthMax = 248;
-            const int UuidLengthMax = 50;
-
             BluetoothDevice resultDevice = new BluetoothDevice();
             Collection<string> uuidList = null;
 
@@ -264,7 +261,7 @@ namespace Tizen.Network.Bluetooth
                 Log.Info(Globals.LogTag, "UUID Count: " + device.ServiceCount);
                 foreach (IntPtr extension in extensionList) {
                     if (extension != IntPtr.Zero) {
-                        string uuid = Marshal.PtrToStringAnsi (extension, UuidLengthMax);
+                        string uuid = Marshal.PtrToStringAnsi (extension);
                         Log.Info(Globals.LogTag, "UUID: " + uuid);
                         uuidList.Add (uuid);
                     }
@@ -273,7 +270,7 @@ namespace Tizen.Network.Bluetooth
 
             resultDevice.RemoteDeviceAddress = device.Address;
             if (device.Name != IntPtr.Zero) {
-                resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(device.Name, DeviceNameLengthMax);
+                resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(device.Name);
                 Log.Info(Globals.LogTag, "Device Name: " + resultDevice.RemoteDeviceName);
             }
             resultDevice.RemoteDeviceClass = new BluetoothClass();
@@ -297,8 +294,6 @@ namespace Tizen.Network.Bluetooth
         {
             BluetoothDevice resultDevice = new BluetoothDevice();
             Collection<string> uuidList = null;
-            const int DeviceNameLengthMax = 248;
-            const int UuidLengthMax = 50;
 
             if (structDevice.ServiceCount > 0) {
                 IntPtr[] extensionList = new IntPtr[structDevice.ServiceCount];
@@ -307,7 +302,7 @@ namespace Tizen.Network.Bluetooth
                 Log.Info(Globals.LogTag, "UUID Count: " + structDevice.ServiceCount);
                 foreach (IntPtr extension in extensionList) {
                     if (extension != IntPtr.Zero) {
-                        string uuid = Marshal.PtrToStringAnsi(extension, UuidLengthMax);
+                        string uuid = Marshal.PtrToStringAnsi(extension);
                         Log.Info(Globals.LogTag, "UUID: " + uuid);
                         uuidList.Add(uuid);
                     }
@@ -316,7 +311,7 @@ namespace Tizen.Network.Bluetooth
 
             resultDevice.RemoteDeviceAddress = structDevice.Address;
             if (structDevice.Name != IntPtr.Zero) {
-                resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(structDevice.Name, DeviceNameLengthMax);
+                resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(structDevice.Name);
                 Log.Info(Globals.LogTag, "Device Name: " + resultDevice.RemoteDeviceName);
             }