From ae92e4b56cc62da7d555ee3efe846ecd714e18aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 8 Aug 2022 16:23:41 +0200 Subject: [PATCH] QtNetwork: Modernize JNI usage Fixes: QTBUG-104188 Change-Id: Iba14fbe23a44df6cb5f2f82b33339606165d1ce5 Reviewed-by: Ievgenii Meshcheriakov Reviewed-by: Ivan Solovev Reviewed-by: Qt CI Bot --- src/network/kernel/qnetworkproxy_android.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/network/kernel/qnetworkproxy_android.cpp b/src/network/kernel/qnetworkproxy_android.cpp index 274a69a767..2e1fb50234 100644 --- a/src/network/kernel/qnetworkproxy_android.cpp +++ b/src/network/kernel/qnetworkproxy_android.cpp @@ -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(networkClass, "registerReceiver", - "(Landroid/content/Context;)V", QAndroidApplication::context()); } @@ -36,7 +38,6 @@ ProxyInfoObject::~ProxyInfoObject() { QJniObject::callStaticMethod(networkClass, "unregisterReceiver", - "(Landroid/content/Context;)V", QAndroidApplication::context()); } @@ -46,13 +47,11 @@ QList 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( + networkClass, "getProxyInfo", QAndroidApplication::context()); if (proxyInfo.isValid()) { - QJniObject exclusionList = proxyInfo.callObjectMethod("getExclusionList", - "()[Ljava/lang/String;"); + QJniObject exclusionList = + proxyInfo.callObjectMethod("getExclusionList"); bool exclude = false; if (exclusionList.isValid()) { jobjectArray listObject = exclusionList.object();