2 * Copyright (C) 2016 Christian Browet
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "network/Network.h"
12 #include "threads/CriticalSection.h"
14 #include "platform/android/activity/JNIXBMCConnectivityManagerNetworkCallback.h"
16 #include <androidjni/LinkProperties.h>
17 #include <androidjni/Network.h>
18 #include <androidjni/NetworkInterface.h>
20 class CNetworkInterfaceAndroid
: public CNetworkInterface
23 CNetworkInterfaceAndroid(const CJNINetwork
& network
,
24 const CJNILinkProperties
& lp
,
25 const CJNINetworkInterface
& intf
);
26 std::vector
<std::string
> GetNameServers();
28 // CNetworkInterface interface
30 bool IsEnabled() const override
;
31 bool IsConnected() const override
;
32 std::string
GetMacAddress() const override
;
33 void GetMacAddressRaw(char rawMac
[6]) const override
;
34 bool GetHostMacAddress(unsigned long host_ip
, std::string
& mac
) const override
;
35 std::string
GetCurrentIPAddress() const override
;
36 std::string
GetCurrentNetmask() const override
;
37 std::string
GetCurrentDefaultGateway() const override
;
39 std::string
GetHostName();
43 CJNINetwork m_network
;
44 CJNILinkProperties m_lp
;
45 CJNINetworkInterface m_intf
;
48 class CNetworkAndroid
: public CNetworkBase
, public jni::CJNIXBMCConnectivityManagerNetworkCallback
53 ~CNetworkAndroid() override
;
57 bool GetHostName(std::string
& hostname
) override
;
58 std::vector
<CNetworkInterface
*>& GetInterfaceList() override
;
59 CNetworkInterface
* GetFirstConnectedInterface() override
;
60 std::vector
<std::string
> GetNameServers() override
;
63 using CNetworkBase::PingHost
;
64 bool PingHost(unsigned long remote_ip
, unsigned int timeout_ms
= 2000) override
;
67 void RetrieveInterfaces();
68 std::vector
<CNetworkInterface
*> m_interfaces
;
69 std::vector
<CNetworkInterface
*> m_oldInterfaces
;
70 CCriticalSection m_refreshMutex
;
72 std::unique_ptr
<CNetworkInterface
> m_defaultInterface
;
75 void onAvailable(const CJNINetwork network
) override
;
76 void onLost(const CJNINetwork network
) override
;