Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
QtNetwork.java
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
package
org.qtproject.qt.android.network;
5
6
import
android
.content.BroadcastReceiver;
7
import
android
.content.Context;
8
import
android
.content.Intent;
9
import
android
.content.IntentFilter;
10
import
android
.net.ConnectivityManager;
11
import
android
.net.Proxy;
12
import
android
.net.ProxyInfo;
13
14
class
QtNetwork
15
{
16
private
static
final
String
LOG_TAG
=
"QtNetwork"
;
17
private
static
ProxyReceiver m_proxyReceiver =
null
;
18
private
static
final
Object
m_lock =
new
Object
();
19
private
static
volatile
ProxyInfo m_proxyInfo =
null
;
20
21
private
static
class
ProxyReceiver
extends
BroadcastReceiver
22
{
23
@Override
24
public
void
onReceive(
Context
context, Intent intent)
25
{
26
m_proxyInfo =
null
;
27
}
28
}
29
30
private
QtNetwork() {}
31
32
static
void
registerReceiver(
final
Context
context)
33
{
34
synchronized
(m_lock) {
35
if
(m_proxyReceiver ==
null
) {
36
m_proxyReceiver =
new
ProxyReceiver();
37
IntentFilter intentFilter =
new
IntentFilter(
Proxy
.PROXY_CHANGE_ACTION);
38
context.registerReceiver(m_proxyReceiver, intentFilter);
39
}
40
}
41
}
42
43
static
void
unregisterReceiver(
final
Context
context)
44
{
45
synchronized
(m_lock) {
46
if
(m_proxyReceiver ==
null
)
47
return
;
48
49
context.unregisterReceiver(m_proxyReceiver);
50
// Statics outlive a Qt shutdown and would block re-registering.
51
m_proxyReceiver =
null
;
52
m_proxyInfo =
null
;
53
}
54
}
55
56
static
ConnectivityManager getConnectivityManager(
final
Context
context)
57
{
58
return
(ConnectivityManager)context.getSystemService(
Context
.CONNECTIVITY_SERVICE);
59
}
60
61
static
ProxyInfo getProxyInfo(
final
Context
context)
62
{
63
if
(m_proxyInfo ==
null
)
64
m_proxyInfo = getConnectivityManager(context).getDefaultProxy();
65
return
m_proxyInfo;
66
}
67
}
Context
QPainter Context
Definition
container_qpainter.cpp:30
LOG_TAG
#define LOG_TAG
Definition
extract.cpp:14
NodeType::Proxy
@ Proxy
Definition
genustypes.h:190
Object
[vector_of_multirole_objects_0]
Definition
main.cpp:188
org.qtproject.qt.android
Definition
BackendRegister.java:3
qtbase
src
network
android
jar
src
org
qtproject
qt
android
network
QtNetwork.java
Generated on
for Qt by
1.18.0