blob: 23e837df56e2ab1777357149f641aa8b2f455776 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#pragma once
#include "std/function.hpp"
class _JNIEnv;
class _jobject;
typedef _JNIEnv JNIEnv;
typedef _jobject * jobject;
namespace platform
{
class NetworkPolicy;
using PartnersApiFn = function<void(NetworkPolicy const & canUseNetwork)>;
}
namespace network_policy
{
void CallPartnersApi(platform::PartnersApiFn fn, bool force);
}
namespace platform
{
/// Class that is used to allow or disallow remote calls.
class NetworkPolicy
{
// Maker for android.
friend NetworkPolicy ToNativeNetworkPolicy(JNIEnv * env, jobject obj);
// iOS
friend void network_policy::CallPartnersApi(platform::PartnersApiFn fn, bool force);
friend NetworkPolicy GetCurrentNetworkPolicy();
public:
bool CanUse() const { return m_canUse; }
private:
NetworkPolicy(bool const canUseNetwork) : m_canUse(canUseNetwork) {}
bool m_canUse = false;
};
extern NetworkPolicy GetCurrentNetworkPolicy();
} // namespace platform
|