QtNetwork: Modernize JNI usage

Fixes: QTBUG-104188
Change-Id: Iba14fbe23a44df6cb5f2f82b33339606165d1ce5
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Mårten Nordheim 2022-08-08 16:23:41 +02:00
parent 72cfcf13c5
commit ae92e4b56c

View File

@ -24,11 +24,13 @@ Q_GLOBAL_STATIC(ProxyInfoObject, proxyInfoInstance)
static const char networkClass[] = "org/qtproject/qt/android/network/QtNetwork";
Q_DECLARE_JNI_TYPE(ProxyInfo, "Landroid/net/ProxyInfo;")
Q_DECLARE_JNI_TYPE(JStringArray, "[Ljava/lang/String;")
ProxyInfoObject::ProxyInfoObject()
{
QJniObject::callStaticMethod<void>(networkClass,
"registerReceiver",
"(Landroid/content/Context;)V",
QAndroidApplication::context());
}
@ -36,7 +38,6 @@ ProxyInfoObject::~ProxyInfoObject()
{
QJniObject::callStaticMethod<void>(networkClass,
"unregisterReceiver",
"(Landroid/content/Context;)V",
QAndroidApplication::context());
}
@ -46,13 +47,11 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
if (!proxyInfoInstance)
return proxyList;
QJniObject proxyInfo = QJniObject::callStaticObjectMethod(networkClass,
"getProxyInfo",
"(Landroid/content/Context;)Landroid/net/ProxyInfo;",
QAndroidApplication::context());
QJniObject proxyInfo = QJniObject::callStaticObjectMethod<QtJniTypes::ProxyInfo>(
networkClass, "getProxyInfo", QAndroidApplication::context());
if (proxyInfo.isValid()) {
QJniObject exclusionList = proxyInfo.callObjectMethod("getExclusionList",
"()[Ljava/lang/String;");
QJniObject exclusionList =
proxyInfo.callObjectMethod<QtJniTypes::JStringArray>("getExclusionList");
bool exclude = false;
if (exclusionList.isValid()) {
jobjectArray listObject = exclusionList.object<jobjectArray>();