From 7ca68d0e2eb130f7d9f6c4d8cc8cbb0bbb068746 Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Mon, 10 Mar 2025 15:17:49 +0100 Subject: [PATCH] Android: Fix for opening Url with authority It seems that even we correctly get Uri from FileProvider, we still do not used it. This patch started to use Uri received from FileProvider. Additionally, to avoid the issue of case insensitivity, we started using QString directly instead of QUrl for the openURL method. Fixes: QTBUG-133702 Pick-to: 6.9 6.9.0 6.8 6.8.3 Change-Id: Ia3b5b6f1562194af4211b9d5bf6a0d56b43c1b05 Reviewed-by: Assam Boudjelthia --- .../platforms/android/qandroidplatformservices.cpp | 9 +++++++-- src/plugins/platforms/android/qandroidplatformservices.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/android/qandroidplatformservices.cpp b/src/plugins/platforms/android/qandroidplatformservices.cpp index 54f274bf426..5cc5eca35bc 100644 --- a/src/plugins/platforms/android/qandroidplatformservices.cpp +++ b/src/plugins/platforms/android/qandroidplatformservices.cpp @@ -74,11 +74,16 @@ QString QAndroidPlatformServices::getMimeOfUrl(const QUrl &url) const } bool QAndroidPlatformServices::openURL(const QUrl &url) const +{ + return openURL(url.toString()); +} + +bool QAndroidPlatformServices::openURL(const QString &url) const { return QJniObject::callStaticMethod( QtAndroid::applicationClass(), "openURL", QNativeInterface::QAndroidApplication::context(), - url.toString(), + url, getMimeOfUrl(url)); } @@ -117,7 +122,7 @@ bool QAndroidPlatformServices::openUrlWithAuthority(const QUrl &url, const QStri QNativeInterface::QAndroidApplication::context(), authority, urlFile.object()); if (fileProviderUri.isValid()) - return openURL(url); + return openURL(fileProviderUri.toString()); return false; } diff --git a/src/plugins/platforms/android/qandroidplatformservices.h b/src/plugins/platforms/android/qandroidplatformservices.h index 25768ba10eb..9988cab0a4c 100644 --- a/src/plugins/platforms/android/qandroidplatformservices.h +++ b/src/plugins/platforms/android/qandroidplatformservices.h @@ -27,6 +27,7 @@ public: private: bool openURL(const QUrl &url) const; + bool openURL(const QString &url) const; bool openUrlWithFileProvider(const QUrl &url); bool openUrlWithAuthority(const QUrl &url, const QString &authority);