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.0 6.8 6.8.3
Change-Id: Ia3b5b6f1562194af4211b9d5bf6a0d56b43c1b05
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 7ca68d0e2eb130f7d9f6c4d8cc8cbb0bbb068746)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2025-03-10 15:17:49 +01:00 committed by Qt Cherry-pick Bot
parent f92b172757
commit 2054b00216
2 changed files with 8 additions and 2 deletions

View File

@ -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<jboolean>(
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<File>());
if (fileProviderUri.isValid())
return openURL(url);
return openURL(fileProviderUri.toString());
return false;
}

View File

@ -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);