From: admin Date: Thu, 25 Mar 2021 05:42:08 +0000 (+0000) Subject: Merge remote-tracking branch 'origin/API8' into tizen_6.0 X-Git-Tag: accepted/tizen/6.0/unified/20210328.210333~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c03e288cbb16d346b73039ccf209b6ea84b1e32;hp=87645fc8585b3821b7a591809bb65846bc3c1946;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Merge remote-tracking branch 'origin/API8' into tizen_6.0 --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index f26a87b..e6243cc 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -2180,7 +2180,7 @@ namespace Tizen.NUI.BaseComponents value.Padding = Padding; // If Layout is a LayoutItem then it could be a View that handles it's own padding. // Let the View keeps it's padding. Still store Padding in Layout to reduce code paths. - if (typeof(LayoutGroup).IsAssignableFrom(Layout.GetType())) // If a Layout container of some kind. + if (typeof(LayoutGroup).IsAssignableFrom(value.GetType())) // If a Layout container of some kind. { SetValue(PaddingProperty, new Extents(0, 0, 0, 0)); NotifyPropertyChanged(); diff --git a/src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs b/src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs index 710b0f2..d7353b2 100644 --- a/src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs +++ b/src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs @@ -630,6 +630,9 @@ internal static partial class Interop [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] internal delegate void BtGattClientRequestCompletedCallback(int result, IntPtr requestHandle, IntPtr userData); + [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] + internal delegate void BtGattClientAttMtuChangedCallback(IntPtr clientHandle, ref AttMtuInfoStruct mtuInfo, IntPtr userData); + // Gatt Attribute [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_destroy")] @@ -745,6 +748,18 @@ internal static partial class Interop [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_write_value")] internal static extern int BtGattClientWriteValue(BluetoothGattAttributeHandle gattHandle, BtGattClientRequestCompletedCallback callback, IntPtr userData); + [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_get_att_mtu")] + internal static extern int BtGattClientGetAttMtu(BluetoothGattClientHandle clientHandle, out int mtu); + + [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_request_att_mtu_change")] + internal static extern int BtGattClientSetAttMtu(BluetoothGattClientHandle clientHandle, int mtu); + + [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_set_att_mtu_changed_cb")] + internal static extern int BtGattClientSetMtuChangedCallback(BluetoothGattClientHandle clientHandle, BtGattClientAttMtuChangedCallback callback, IntPtr userData); + + [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_unset_att_mtu_changed_cb")] + internal static extern int BtGattClientUnsetMtuChangedCallback(BluetoothGattClientHandle clientHandle); + // GATT Server [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_destroy")] diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs index 263d2d5..b728454 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs @@ -1215,6 +1215,32 @@ namespace Tizen.Network.Bluetooth } /// + /// An extended EventArgs class contains the changed MTU value. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public class AttMtuChangedEventArgs : EventArgs + { + internal AttMtuChangedEventArgs(string remoteAddress, int mtu) + { + RemoteAddress = remoteAddress; + Mtu = mtu; + } + + /// + /// The remote address. + /// + /// 8 + public string RemoteAddress { get; } + + /// + /// The MTU value + /// + /// 8 + public int Mtu { get; } + } + + /// /// An extended EventArgs class contains the changed attribute value. /// /// 3 diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs index 82f2cd8..7af1526 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; @@ -266,6 +267,12 @@ namespace Tizen.Network.Bluetooth _impl = new BluetoothGattClientImpl(remoteAddress); _remoteAddress = remoteAddress; StaticConnectionStateChanged += OnConnectionStateChanged; + _impl.AttMtuChanged += OnAttMtuChanged; + } + + private void OnAttMtuChanged(object s, AttMtuChangedEventArgs e) + { + AttMtuChanged?.Invoke(this, e); } /// @@ -517,6 +524,41 @@ namespace Tizen.Network.Bluetooth return await _impl.WriteValueAsyncTask(descriptor.GetHandle()); } + /// + /// Gets the value of the ATT MTU(Maximum Transmission Unit) for the connection. + /// + /// The MTU value + /// Thrown when the BT/BLE is not supported. + /// Thrown when the BT/BLE is not enabled + /// or when the remote device is disconnected, or when other specific error occurs. + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public int GetAttMtu() + { + return _impl.GetAttMtu(); + } + + /// + /// Sets the value of the ATT MTU(Maximum Transmission Unit) for the connection. + /// + /// The MTU value + /// Thrown when the BT/BLE is not supported. + /// Thrown when the BT/BLE is not enabled + /// or when the remote device is disconnected, or when other specific error occurs. + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetAttMtu(int mtu) + { + _impl.SetAttMtu(mtu); + } + + /// + /// The AttMtuChanged event is raised when the MTU value changed. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler AttMtuChanged; + internal bool Isvalid() { return _impl.GetHandle().IsInvalid == false; diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs index 559a14b..352757d 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs @@ -168,6 +168,8 @@ namespace Tizen.Network.Bluetooth Dictionary> _writeValueTaskSource = new Dictionary>(); private Interop.Bluetooth.BtGattClientRequestCompletedCallback _writeValueCallback; private Interop.Bluetooth.BtGattForeachCallback _serviceForeachCallback; + private Interop.Bluetooth.BtGattClientAttMtuChangedCallback _attMtuChangedCallback; + private event EventHandler _attMtuChanged; internal BluetoothGattClientImpl(string remoteAddress) { @@ -320,6 +322,69 @@ namespace Tizen.Network.Bluetooth return task.Task; } + internal int GetAttMtu() + { + int err = Interop.Bluetooth.BtGattClientGetAttMtu(_handle, out int mtu); + if (err.IsFailed()) + { + GattUtil.Error(err, "Failed to get MTU value"); + BluetoothErrorFactory.ThrowBluetoothException(err); + } + return mtu; + } + + internal void SetAttMtu(int mtu) + { + int err = Interop.Bluetooth.BtGattClientSetAttMtu(_handle, mtu); + if (err.IsFailed()) + { + GattUtil.Error(err, "Failed to set MTU value"); + BluetoothErrorFactory.ThrowBluetoothException(err); + } + } + + internal event EventHandler AttMtuChanged + { + add + { + if (_attMtuChanged == null) + { + RegisterMtuChangedEvent(); + } + _attMtuChanged += value; + } + remove + { + _attMtuChanged -= value; + if (_attMtuChanged == null) + { + UnregisterMtuChangedEvent(); + } + } + } + + private void RegisterMtuChangedEvent() + { + _attMtuChangedCallback = (IntPtr clientHandle, ref AttMtuInfoStruct mtuInfoStruct, IntPtr userData) => + { + _attMtuChanged?.Invoke(null, new AttMtuChangedEventArgs(mtuInfoStruct.RemoteAddress, mtuInfoStruct.Mtu)); + }; + int ret = Interop.Bluetooth.BtGattClientSetMtuChangedCallback(_handle, _attMtuChangedCallback, IntPtr.Zero); + if (ret != (int)BluetoothError.None) + { + Log.Error(Globals.LogTag, "Failed to set MTU changed callback, Error - " + (BluetoothError)ret); + } + } + + private void UnregisterMtuChangedEvent() + { + int ret = Interop.Bluetooth.BtGattClientUnsetMtuChangedCallback(_handle); + if (ret != (int)BluetoothError.None) + { + Log.Error(Globals.LogTag, "Failed to unset MTU changed callback, Error - " + (BluetoothError)ret); + } + } + internal BluetoothGattClientHandle GetHandle() { return _handle; diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs index af0744e..2e48533 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs @@ -236,6 +236,17 @@ namespace Tizen.Network.Bluetooth internal uint number; internal uint duration; } + + [NativeStruct("bt_gatt_client_att_mtu_info_s", Include = "bluetooth_type.h", PkgConfig = "capi-network-bluetooth")] + [StructLayout(LayoutKind.Sequential)] + internal struct AttMtuInfoStruct + { + [MarshalAsAttribute(UnmanagedType.LPStr)] + internal string RemoteAddress; + internal int Mtu; + internal int Status; + } + internal static class BluetoothUtils { internal static BluetoothDevice ConvertStructToDeviceClass(BluetoothDeviceStruct device)