qtbase/src/plugins/platforms/android/qandroidplatformservices.h
Ahmed El Khazari a96e0eddd9 Android: Support custom FileProvider in openUrl
Previously, qtprovider was set as the default FileProvider, which
causes issues when creating a custom FileProvider on application side or
having multiple FileProviders.
To address this problem, we have implemented a solution that checks for
all available FileProviders and ,in case of multiple FileProviders,
selects first non-default FileProvider.

Fixes: QTBUG-117417
Pick-to: 6.7 6.5
Change-Id: I2a68983403f964036dc3177e13fe7ea4f9b4788b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit d3508d48c0e4ef73a3a673ea14fb59cd8d930398)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-22 13:41:19 +00:00

45 lines
1.3 KiB
C++

// Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef ANDROIDPLATFORMDESKTOPSERVICE_H
#define ANDROIDPLATFORMDESKTOPSERVICE_H
#include <qpa/qplatformservices.h>
#include "androidjnimain.h"
#include <QtCore/private/qjnihelpers_p.h>
#include <QtCore/qobject.h>
#include <QUrl>
QT_BEGIN_NAMESPACE
class QAndroidPlatformServices : public QObject,
public QPlatformServices,
public QtAndroidPrivate::NewIntentListener
{
public:
QAndroidPlatformServices();
bool openUrl(const QUrl &url) override;
bool openDocument(const QUrl &url) override;
QByteArray desktopEnvironment() const override;
bool handleNewIntent(JNIEnv *env, jobject intent) override;
private:
bool openURL(const QUrl &url) const;
bool openUrlWithFileProvider(const QUrl &url);
bool openUrlWithAuthority(const QUrl &url, const QString &authority);
QString getMimeOfUrl(const QUrl &url) const;
QStringList getFileProviderAuthorities(const QJniObject &context) const;
QString getAdequateFileproviderAuthority(const QStringList &authorities) const;
private:
QUrl m_handlingUrl;
QString m_actionView;
};
QT_END_NAMESPACE
#endif // ANDROIDPLATFORMDESKTOPSERVICE_H