projects
/
platform
/
core
/
csapi
/
tizenfx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e1ce1fc
)
[Connection][WiFi]Apply TizenSynchronizationContext for event handling (#138)
author
chleun-moon
<32117100+chleun-moon@users.noreply.github.com>
Wed, 7 Mar 2018 07:05:51 +0000
(16:05 +0900)
committer
GitHub
<noreply@github.com>
Wed, 7 Mar 2018 07:05:51 +0000
(16:05 +0900)
src/Tizen.Network.Connection/Tizen.Network.Connection.csproj
patch
|
blob
|
history
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
patch
|
blob
|
history
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
patch
|
blob
|
history
src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
patch
|
blob
|
history
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs
patch
|
blob
|
history
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
patch
|
blob
|
history
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
patch
|
blob
|
history
diff --git
a/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj
b/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj
index
7f4584f
..
4942b30
100644
(file)
--- a/
src/Tizen.Network.Connection/Tizen.Network.Connection.csproj
+++ b/
src/Tizen.Network.Connection/Tizen.Network.Connection.csproj
@@
-7,6
+7,7
@@
<ItemGroup>
<ProjectReference Include="..\Tizen\Tizen.csproj" />
<ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
<ItemGroup>
<ProjectReference Include="..\Tizen\Tizen.csproj" />
<ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
+ <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
</ItemGroup>
</Project>
</ItemGroup>
</Project>
diff --git
a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
index
a4ef319
..
c8fd585
100755
(executable)
--- a/
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
+++ b/
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
@@
-22,19
+22,20
@@
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
+using Tizen.Applications;
namespace Tizen.Network.Connection
{
class HandleHolder
{
private IntPtr Handle;
namespace Tizen.Network.Connection
{
class HandleHolder
{
private IntPtr Handle;
- private int tid;
+ private int
_
tid;
public HandleHolder()
{
public HandleHolder()
{
- tid = Thread.CurrentThread.ManagedThreadId;
- Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " + tid);
- int ret = Interop.Connection.Create(tid, out Handle);
+
_
tid = Thread.CurrentThread.ManagedThreadId;
+ Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " +
_
tid);
+ int ret = Interop.Connection.Create(
_
tid, out Handle);
Log.Info(Globals.LogTag, "Handle: " + Handle);
if(ret != (int)ConnectionError.None)
{
Log.Info(Globals.LogTag, "Handle: " + Handle);
if(ret != (int)ConnectionError.None)
{
@@
-57,8
+58,9
@@
namespace Tizen.Network.Connection
private void Destroy()
{
private void Destroy()
{
- Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " + tid);
- Interop.Connection.Destroy(tid, Handle);
+
+ Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " + _tid);
+ Interop.Connection.Destroy(_tid, Handle);
if (Handle != IntPtr.Zero)
{
Handle = IntPtr.Zero;
if (Handle != IntPtr.Zero)
{
Handle = IntPtr.Zero;
@@
-81,6
+83,8
@@
namespace Tizen.Network.Connection
private Interop.Connection.ConnectionAddressChangedCallback _proxyAddressChangedCallback;
private Interop.Connection.EthernetCableStateChangedCallback _ethernetCableStateChangedCallback;
private Interop.Connection.ConnectionAddressChangedCallback _proxyAddressChangedCallback;
private Interop.Connection.EthernetCableStateChangedCallback _ethernetCableStateChangedCallback;
+ private TizenSynchronizationContext context = new TizenSynchronizationContext();
+
internal static ConnectionInternalManager Instance
{
get
internal static ConnectionInternalManager Instance
{
get
@@
-102,6
+106,7
@@
namespace Tizen.Network.Connection
~ConnectionInternalManager()
{
~ConnectionInternalManager()
{
+ UnregisterEvents();
}
internal IntPtr GetHandle()
}
internal IntPtr GetHandle()
@@
-113,20
+118,25
@@
namespace Tizen.Network.Connection
{
add
{
{
add
{
- if (_ConnectionTypeChanged == null)
- {
- ConnectionTypeChangedStart();
- }
-
- _ConnectionTypeChanged += value;
+ context.Post((x) =>
+ {
+ if (_ConnectionTypeChanged == null)
+ {
+ ConnectionTypeChangedStart();
+ }
+ _ConnectionTypeChanged += value;
+ }, null);
}
remove
{
}
remove
{
- _ConnectionTypeChanged -= value;
- if (_ConnectionTypeChanged == null)
- {
- ConnectionTypeChangedStop();
- }
+ context.Post((x) =>
+ {
+ _ConnectionTypeChanged -= value;
+ if (_ConnectionTypeChanged == null)
+ {
+ ConnectionTypeChangedStop();
+ }
+ }, null);
}
}
}
}
@@
-162,19
+172,25
@@
namespace Tizen.Network.Connection
{
add
{
{
add
{
- if (_EthernetCableStateChanged == null)
- {
- EthernetCableStateChangedStart();
- }
- _EthernetCableStateChanged += value;
+ context.Post((x) =>
+ {
+ if (_EthernetCableStateChanged == null)
+ {
+ EthernetCableStateChangedStart();
+ }
+ _EthernetCableStateChanged += value;
+ }, null);
}
remove
{
}
remove
{
- _EthernetCableStateChanged -= value;
- if (_EthernetCableStateChanged == null)
- {
- EthernetCableStateChangedStop();
- }
+ context.Post((x) =>
+ {
+ _EthernetCableStateChanged -= value;
+ if (_EthernetCableStateChanged == null)
+ {
+ EthernetCableStateChangedStop();
+ }
+ }, null);
}
}
}
}
@@
-214,20
+230,26
@@
namespace Tizen.Network.Connection
{
add
{
{
add
{
- if (_IPAddressChanged == null)
- {
- IPAddressChangedStart();
- }
- _IPAddressChanged += value;
+ context.Post((x) =>
+ {
+ if (_IPAddressChanged == null)
+ {
+ IPAddressChangedStart();
+ }
+ _IPAddressChanged += value;
+ }, null);
}
remove
{
}
remove
{
- _IPAddressChanged -= value;
- if (_IPAddressChanged == null)
- {
- IPAddressChangedStop();
- }
+ context.Post((x) =>
+ {
+ _IPAddressChanged -= value;
+ if (_IPAddressChanged == null)
+ {
+ IPAddressChangedStop();
+ }
+ }, null);
}
}
}
}
@@
-267,22
+289,25
@@
namespace Tizen.Network.Connection
{
add
{
{
add
{
- //Console.WriteLine("ProxyAddressChanged Add **");
- if (_ProxyAddressChanged == null)
- {
- ProxyAddressChangedStart();
- }
-
- _ProxyAddressChanged += value;
+ context.Post((x) =>
+ {
+ if (_ProxyAddressChanged == null)
+ {
+ ProxyAddressChangedStart();
+ }
+ _ProxyAddressChanged += value;
+ }, null);
}
remove
{
}
remove
{
- //Console.WriteLine("ProxyAddressChanged Remove");
- _ProxyAddressChanged -= value;
- if (_ProxyAddressChanged == null)
- {
- ProxyAddressChangedStop();
- }
+ context.Post((x) =>
+ {
+ _ProxyAddressChanged -= value;
+ if (_ProxyAddressChanged == null)
+ {
+ ProxyAddressChangedStop();
+ }
+ }, null);
}
}
}
}
diff --git
a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
index
3215777
..
f0512f1
100755
(executable)
--- a/
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
+++ b/
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
@@
-19,6
+19,7
@@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
+using Tizen.Applications;
namespace Tizen.Network.Connection
{
namespace Tizen.Network.Connection
{
@@
-36,6
+37,8
@@
namespace Tizen.Network.Connection
private Interop.ConnectionProfile.ProfileStateChangedCallback _profileChangedCallback;
private Interop.ConnectionProfile.ProfileStateChangedCallback _profileChangedCallback;
+ private TizenSynchronizationContext context = new TizenSynchronizationContext();
+
internal IntPtr GetHandle()
{
return ProfileHandle;
internal IntPtr GetHandle()
{
return ProfileHandle;
@@
-55,20
+58,26
@@
namespace Tizen.Network.Connection
add
{
Log.Debug(Globals.LogTag, "ProfileStateChanged add");
add
{
Log.Debug(Globals.LogTag, "ProfileStateChanged add");
- if (_ProfileStateChanged == null)
- {
- ProfileStateChangedStart();
- }
- _ProfileStateChanged += value;
+ context.Post((x) =>
+ {
+ if (_ProfileStateChanged == null)
+ {
+ ProfileStateChangedStart();
+ }
+ _ProfileStateChanged += value;
+ }, null);
}
remove
{
Log.Debug(Globals.LogTag, "ProfileStateChanged remove");
}
remove
{
Log.Debug(Globals.LogTag, "ProfileStateChanged remove");
- _ProfileStateChanged -= value;
- if (_ProfileStateChanged == null)
- {
- ProfileStateChangedStop();
- }
+ context.Post((x) =>
+ {
+ _ProfileStateChanged -= value;
+ if (_ProfileStateChanged == null)
+ {
+ ProfileStateChangedStop();
+ }
+ }, null);
}
}
}
}
@@
-131,12
+140,9
@@
namespace Tizen.Network.Connection
if (disposed)
return;
if (disposed)
return;
- if (disposing)
- {
- // Free managed objects.
- UnregisterEvents();
- Destroy();
- }
+ // Free unmanaged objects
+ UnregisterEvents();
+ Destroy();
disposed = true;
}
disposed = true;
}
diff --git
a/src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
b/src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
index
b3b1ca1
..
52d22a1
100644
(file)
--- a/
src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
+++ b/
src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
@@
-6,6
+6,7
@@
<ItemGroup>
<ProjectReference Include="..\Tizen.Network.Connection\Tizen.Network.Connection.csproj" />
<ItemGroup>
<ProjectReference Include="..\Tizen.Network.Connection\Tizen.Network.Connection.csproj" />
+ <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
</ItemGroup>
</Project>
</ItemGroup>
</Project>
diff --git
a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs
b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs
index
96d613c
..
5cbdad5
100755
(executable)
--- a/
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs
+++ b/
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs
@@
-29,7
+29,7
@@
namespace Tizen.Network.WiFi
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class SafeWiFiManagerHandle : SafeHandle
{
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class SafeWiFiManagerHandle : SafeHandle
{
- private int tid;
+ private int
_
tid;
internal SafeWiFiManagerHandle() : base(IntPtr.Zero, true)
{
internal SafeWiFiManagerHandle() : base(IntPtr.Zero, true)
{
@@
-53,18
+53,15
@@
namespace Tizen.Network.WiFi
/// </summary>
protected override bool ReleaseHandle()
{
/// </summary>
protected override bool ReleaseHandle()
{
- Interop.WiFi.Deinitialize(tid, this.handle);
+ Interop.WiFi.Deinitialize(
_
tid, this.handle);
this.SetHandle(IntPtr.Zero);
return true;
}
this.SetHandle(IntPtr.Zero);
return true;
}
- internal
int TID
+ internal
void SetTID(int id)
{
{
- set
- {
- tid = value;
- Log.Info(Globals.LogTag, "New Handle for Thread " + tid);
- }
+ _tid = id;
+ Log.Info(Globals.LogTag, "New Handle for Thread " + _tid);
}
}
}
}
diff --git
a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
index
053949a
..
ada882e
100755
(executable)
--- a/
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
+++ b/
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
@@
-122,7
+122,7
@@
namespace Tizen.Network.WiFi
{
get
{
{
get
{
- return _instance.Value;
+ return _instance.Value;
}
}
}
}
@@
-153,7
+153,7
@@
namespace Tizen.Network.WiFi
Log.Error(Globals.LogTag, "Failed to initialize wifi, Error - " + (WiFiError)ret);
WiFiErrorFactory.ThrowWiFiException(ret, "http://tizen.org/privilege/network.get");
}
Log.Error(Globals.LogTag, "Failed to initialize wifi, Error - " + (WiFiError)ret);
WiFiErrorFactory.ThrowWiFiException(ret, "http://tizen.org/privilege/network.get");
}
- handle.
TID = tid
;
+ handle.
SetTID(tid)
;
return handle;
}
return handle;
}
diff --git
a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
index
ac1eabf
..
256f61f
100755
(executable)
--- a/
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
+++ b/
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
@@
-16,6
+16,8
@@
using System;
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
+using System.Threading;
+using Tizen.Applications;
namespace Tizen.Network.WiFi
{
namespace Tizen.Network.WiFi
{
@@
-52,23
+54,30
@@
namespace Tizen.Network.WiFi
private Interop.WiFi.RssiLevelChangedCallback _rssiChangedCallback;
private Interop.WiFi.VoidCallback _backgroundScanFinishedCallback;
private Interop.WiFi.RssiLevelChangedCallback _rssiChangedCallback;
private Interop.WiFi.VoidCallback _backgroundScanFinishedCallback;
+ private TizenSynchronizationContext context = new TizenSynchronizationContext();
internal event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
{
add
{
internal event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
{
add
{
- if (_deviceStateChanged == null)
- {
- RegisterDeviceStateChangedEvent();
- }
- _deviceStateChanged += value;
+ context.Post((x) =>
+ {
+ if (_deviceStateChanged == null)
+ {
+ RegisterDeviceStateChangedEvent();
+ }
+ _deviceStateChanged += value;
+ }, null);
}
remove
{
}
remove
{
- _deviceStateChanged -= value;
- if (_deviceStateChanged == null)
- {
- UnregisterDeviceStateChangedEvent();
- }
+ context.Post((x) =>
+ {
+ _deviceStateChanged -= value;
+ if (_deviceStateChanged == null)
+ {
+ UnregisterDeviceStateChangedEvent();
+ }
+ }, null);
}
}
}
}
@@
-76,19
+85,25
@@
namespace Tizen.Network.WiFi
{
add
{
{
add
{
- if (_connectionStateChanged == null)
- {
- RegisterConnectionStateChangedEvent();
- }
- _connectionStateChanged += value;
+ context.Post((x) =>
+ {
+ if (_connectionStateChanged == null)
+ {
+ RegisterConnectionStateChangedEvent();
+ }
+ _connectionStateChanged += value;
+ }, null);
}
remove
{
}
remove
{
- _connectionStateChanged -= value;
- if (_connectionStateChanged == null)
- {
- UnregisterConnectionStateChangedEvent();
- }
+ context.Post((x) =>
+ {
+ _connectionStateChanged -= value;
+ if (_connectionStateChanged == null)
+ {
+ UnregisterConnectionStateChangedEvent();
+ }
+ }, null);
}
}
}
}
@@
-96,19
+111,25
@@
namespace Tizen.Network.WiFi
{
add
{
{
add
{
- if (_rssiLevelChanged == null)
- {
- RegisterRssiLevelChangedEvent();
- }
- _rssiLevelChanged += value;
+ context.Post((x) =>
+ {
+ if (_rssiLevelChanged == null)
+ {
+ RegisterRssiLevelChangedEvent();
+ }
+ _rssiLevelChanged += value;
+ }, null);
}
remove
{
}
remove
{
- _rssiLevelChanged -= value;
- if (_rssiLevelChanged == null)
- {
- UnregisterRssiLevelChangedEvent();
- }
+ context.Post((x) =>
+ {
+ _rssiLevelChanged -= value;
+ if (_rssiLevelChanged == null)
+ {
+ UnregisterRssiLevelChangedEvent();
+ }
+ }, null);
}
}
}
}
@@
-116,24
+137,31
@@
namespace Tizen.Network.WiFi
{
add
{
{
add
{
- if (_backgroundScanFinished == null)
- {
- RegisterBackgroundScanFinishedEvent();
- }
- _backgroundScanFinished += value;
+ context.Post((x) =>
+ {
+ if (_backgroundScanFinished == null)
+ {
+ RegisterBackgroundScanFinishedEvent();
+ }
+ _backgroundScanFinished += value;
+ }, null);
}
remove
{
}
remove
{
- _backgroundScanFinished -= value;
- if (_backgroundScanFinished == null)
- {
- UnregisterBackgroundScanFinishedEvent();
- }
+ context.Post((x) =>
+ {
+ _backgroundScanFinished -= value;
+ if (_backgroundScanFinished == null)
+ {
+ UnregisterBackgroundScanFinishedEvent();
+ }
+ }, null);
}
}
private void RegisterDeviceStateChangedEvent()
{
}
}
private void RegisterDeviceStateChangedEvent()
{
+ Log.Info(Globals.LogTag, "RegisterDeviceStateChangedEvent in Thread " + Thread.CurrentThread.ManagedThreadId);
_deviceChangedCallback = (int deviceState, IntPtr userDate) =>
{
WiFiDeviceState state = (WiFiDeviceState)deviceState;
_deviceChangedCallback = (int deviceState, IntPtr userDate) =>
{
WiFiDeviceState state = (WiFiDeviceState)deviceState;
@@
-149,6
+177,7
@@
namespace Tizen.Network.WiFi
private void UnregisterDeviceStateChangedEvent()
{
private void UnregisterDeviceStateChangedEvent()
{
+ Log.Info(Globals.LogTag, "UnregisterDeviceStateChangedEvent in Thread " + Thread.CurrentThread.ManagedThreadId);
int ret = Interop.WiFi.UnsetDeviceStateChangedCallback(GetSafeHandle());
if (ret != (int)WiFiError.None)
{
int ret = Interop.WiFi.UnsetDeviceStateChangedCallback(GetSafeHandle());
if (ret != (int)WiFiError.None)
{