diff options
Diffstat (limited to 'src')
49 files changed, 0 insertions, 6352 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index e510208..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Generated from src.pro. - -# special case skip regeneration -# special case begin -# android -if (ANDROID) - add_subdirectory(androidextras) - add_subdirectory(jar) -endif() -# special case end - diff --git a/src/androidextras/CMakeLists.txt b/src/androidextras/CMakeLists.txt deleted file mode 100644 index 45e7cde..0000000 --- a/src/androidextras/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Generated from androidextras.pro. - -##################################################################### -## AndroidExtras Module: -##################################################################### - -qt_internal_add_module(AndroidExtras - SOURCES - android/qandroidactivitycallbackresultreceiver.cpp - android/qandroidactivityresultreceiver.cpp android/qandroidactivityresultreceiver.h android/qandroidactivityresultreceiver_p.h - android/qandroidbinder.cpp android/qandroidbinder.h android/qandroidbinder_p.h - android/qandroidfunctions.cpp android/qandroidfunctions.h - android/qandroidintent.cpp android/qandroidintent.h - android/qandroidparcel.cpp android/qandroidparcel.h android/qandroidparcel_p.h - android/qandroidservice.cpp android/qandroidservice.h - android/qandroidserviceconnection.cpp android/qandroidserviceconnection.h - android/qjnionload.cpp - jni/qandroidjnienvironment.cpp jni/qandroidjnienvironment.h - jni/qandroidjniobject.cpp jni/qandroidjniobject.h - DEFINES - QT_NO_USING_NAMESPACE - LIBRARIES - Qt::CorePrivate - PUBLIC_LIBRARIES - Qt::Core - PRIVATE_MODULE_INTERFACE - Qt::CorePrivate -) - -if(ANDROID) - set_property(TARGET AndroidExtras APPEND PROPERTY QT_ANDROID_BUNDLED_JAR_DEPENDENCIES - jar/Qt${QtAndroidExtras_VERSION_MAJOR}AndroidExtras.jar # special case - ) -endif() -qt_internal_add_docs(AndroidExtras - doc/qtandroidextras.qdocconf -) - diff --git a/src/androidextras/android/qandroidactivitycallbackresultreceiver.cpp b/src/androidextras/android/qandroidactivitycallbackresultreceiver.cpp deleted file mode 100644 index e32916f..0000000 --- a/src/androidextras/android/qandroidactivitycallbackresultreceiver.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidactivitycallbackresultreceiver_p.h" - -QAndroidActivityCallbackResultReceiver * QAndroidActivityCallbackResultReceiver::s_instance = nullptr; - -QAndroidActivityCallbackResultReceiver::QAndroidActivityCallbackResultReceiver() - : QAndroidActivityResultReceiver() - , callbackMap() -{ -} - -void QAndroidActivityCallbackResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &intent) -{ - callbackMap[receiverRequestCode](receiverRequestCode, resultCode, intent); - callbackMap.remove(receiverRequestCode); -} - -QAndroidActivityCallbackResultReceiver * QAndroidActivityCallbackResultReceiver::instance() { - if (!s_instance) { - s_instance = new QAndroidActivityCallbackResultReceiver(); - } - return s_instance; -} - -void QAndroidActivityCallbackResultReceiver::registerCallback(int receiverRequestCode, std::function<void(int, int, const QAndroidJniObject &data)> callbackFunc) -{ - callbackMap.insert(receiverRequestCode, callbackFunc); -} diff --git a/src/androidextras/android/qandroidactivitycallbackresultreceiver_p.h b/src/androidextras/android/qandroidactivitycallbackresultreceiver_p.h deleted file mode 100644 index 8232b53..0000000 --- a/src/androidextras/android/qandroidactivitycallbackresultreceiver_p.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDACTIVITYCALLBACKRESULTRECEIVER_P_H -#define QANDROIDACTIVITYCALLBACKRESULTRECEIVER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QMap> - -#include "qandroidactivityresultreceiver.h" - -class QAndroidActivityCallbackResultReceiver: public QAndroidActivityResultReceiver -{ -public: - QAndroidActivityCallbackResultReceiver(); - void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &intent) override; - void registerCallback(int receiverRequestCode, std::function<void(int, int, const QAndroidJniObject &)> callbackFunc); - - static QAndroidActivityCallbackResultReceiver *instance(); -private: - QMap<int, std::function<void(int, int, const QAndroidJniObject &data)>> callbackMap; - - static QAndroidActivityCallbackResultReceiver *s_instance; -}; - -#endif diff --git a/src/androidextras/android/qandroidactivityresultreceiver.cpp b/src/androidextras/android/qandroidactivityresultreceiver.cpp deleted file mode 100644 index 2dfe509..0000000 --- a/src/androidextras/android/qandroidactivityresultreceiver.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidactivityresultreceiver.h" -#include "qandroidactivityresultreceiver_p.h" -#include "qandroidfunctions.h" -#include <QtCore/private/qjnihelpers_p.h> -#include <QtCore/qmutex.h> - -QT_BEGIN_NAMESPACE - -// Get a unique activity request code. -static int uniqueActivityRequestCode() -{ - static QMutex mutex; - static int requestCode = 0x1000; // Reserve all request codes under 0x1000 for Qt. - - QMutexLocker locker(&mutex); - if (requestCode == 0xf3ee) // Special case for MINISTRO_INSTALL_REQUEST_CODE - requestCode++; - - if (requestCode == INT_MAX) - qWarning("Unique activity request code has wrapped. Unexpected behavior may occur."); - - return requestCode++; -} - -int QAndroidActivityResultReceiverPrivate::globalRequestCode(int localRequestCode) const -{ - if (!localToGlobalRequestCode.contains(localRequestCode)) { - int globalRequestCode = uniqueActivityRequestCode(); - localToGlobalRequestCode[localRequestCode] = globalRequestCode; - globalToLocalRequestCode[globalRequestCode] = localRequestCode; - } - return localToGlobalRequestCode.value(localRequestCode); -} - -bool QAndroidActivityResultReceiverPrivate::handleActivityResult(jint requestCode, jint resultCode, jobject data) -{ - if (globalToLocalRequestCode.contains(requestCode)) { - q->handleActivityResult(globalToLocalRequestCode.value(requestCode), resultCode, QAndroidJniObject(data)); - return true; - } - - return false; -} - -/*! - \class QAndroidActivityResultReceiver - \inmodule QtAndroidExtras - \since 5.3 - \brief Interface used for callbacks from onActivityResult() in the main Android activity. - - Create a subclass of this class to be notified of the results when using the - \c QtAndroid::startActivity() and \c QtAndroid::startIntentSender() APIs. - */ - -/*! - \internal -*/ -QAndroidActivityResultReceiver::QAndroidActivityResultReceiver() - : d(new QAndroidActivityResultReceiverPrivate) -{ - d->q = this; - QtAndroidPrivate::registerActivityResultListener(d.data()); -} - -/*! - \internal -*/ -QAndroidActivityResultReceiver::~QAndroidActivityResultReceiver() -{ - QtAndroidPrivate::unregisterActivityResultListener(d.data()); -} - -/*! - \fn void QAndroidActivityResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data) - - Reimplement this function to get activity results after starting an activity using either QtAndroid::startActivity() or - QtAndroid::startIntentSender(). The \a receiverRequestCode is the request code unique to this receiver which was originally - passed to the startActivity() or startIntentSender() functions. The \a resultCode is the result returned by the activity, - and \a data is either null or a Java object of the class android.content.Intent. Both the last to arguments are identical to the - arguments passed to onActivityResult(). -*/ - -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidactivityresultreceiver.h b/src/androidextras/android/qandroidactivityresultreceiver.h deleted file mode 100644 index b71f876..0000000 --- a/src/androidextras/android/qandroidactivityresultreceiver.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDACTIVITYRESULTRECEIVER_H -#define QANDROIDACTIVITYRESULTRECEIVER_H - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QtAndroidExtras/qandroidjniobject.h> - -QT_BEGIN_NAMESPACE - -class QAndroidActivityResultReceiverPrivate; -class Q_ANDROIDEXTRAS_EXPORT QAndroidActivityResultReceiver -{ -public: - QAndroidActivityResultReceiver(); - virtual ~QAndroidActivityResultReceiver(); - virtual void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data) = 0; - -private: - friend class QAndroidActivityResultReceiverPrivate; - Q_DISABLE_COPY(QAndroidActivityResultReceiver) - - QScopedPointer<QAndroidActivityResultReceiverPrivate> d; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDACTIVITYRESULTRECEIVER_H diff --git a/src/androidextras/android/qandroidactivityresultreceiver_p.h b/src/androidextras/android/qandroidactivityresultreceiver_p.h deleted file mode 100644 index 21553d3..0000000 --- a/src/androidextras/android/qandroidactivityresultreceiver_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDACTIVITYRESULTRECEIVER_P_H -#define QANDROIDACTIVITYRESULTRECEIVER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qhash.h> -#include <QtCore/private/qjnihelpers_p.h> -#include "qandroidactivityresultreceiver.h" - -QT_BEGIN_NAMESPACE - -class QAndroidActivityResultReceiverPrivate: public QtAndroidPrivate::ActivityResultListener -{ -public: - QAndroidActivityResultReceiver *q; - mutable QHash<int, int> localToGlobalRequestCode; - mutable QHash<int, int> globalToLocalRequestCode; - - int globalRequestCode(int localRequestCode) const; - bool handleActivityResult(jint requestCode, jint resultCode, jobject data); - - static QAndroidActivityResultReceiverPrivate *get(QAndroidActivityResultReceiver *publicObject) - { - return publicObject->d.data(); - } -}; - -QT_END_NAMESPACE - -#endif // QANDROIDACTIVITYRESULTRECEIVER_P_H diff --git a/src/androidextras/android/qandroidbinder.cpp b/src/androidextras/android/qandroidbinder.cpp deleted file mode 100644 index e6df77c..0000000 --- a/src/androidextras/android/qandroidbinder.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidbinder.h" - -#include "qandroidbinder_p.h" -#include "qandroidparcel.h" -#include "qandroidparcel_p.h" - -#include <jni/qandroidjnienvironment.h> - -QT_BEGIN_NAMESPACE -QAndroidBinderPrivate::QAndroidBinderPrivate(QAndroidBinder *binder) - : handle("org/qtproject/qt/android/extras/QtAndroidBinder", "(J)V", jlong(binder)) - , m_isQtAndroidBinder(true) -{ - QAndroidJniExceptionCleaner cleaner; -} - -QAndroidBinderPrivate::QAndroidBinderPrivate(const QAndroidJniObject &binder) - : handle(binder) - , m_isQtAndroidBinder(false) -{ -} - -QAndroidBinderPrivate::~QAndroidBinderPrivate() -{ - if (m_isQtAndroidBinder) { - QAndroidJniExceptionCleaner cleaner; - handle.callMethod<void>("setId", "(J)V", jlong(0)); - if (m_deleteListener) - m_deleteListener(); - } -} - -/*! - \class QAndroidBinder - \inmodule QtAndroidExtras - \brief Wraps the most important methods of Android Binder class. - - The QAndroidBinder is a convenience class that wraps the most important - \l {https://developer.android.com/reference/android/os/Binder.html}{Android Binder} - methods. - - \since 5.10 -*/ - - -/*! - \enum QAndroidBinder::CallType - - This enum is used with \l QAndroidBinder::transact() to describe the mode in which the - IPC call is performed. - - \value Normal normal IPC, meaning that the caller waits the result from the callee - \value OneWay one-way IPC, meaning that the caller returns immediately, without waiting for a result from the callee -*/ - -/*! - Creates a new object which can be used to perform IPC. - - \sa onTransact, transact - */ -QAndroidBinder::QAndroidBinder() - : d(new QAndroidBinderPrivate(this)) -{ -} - -/*! - Creates a new object from the \a binder Java object. - - \sa transact - */ -QAndroidBinder::QAndroidBinder(const QAndroidJniObject &binder) - : d(new QAndroidBinderPrivate(binder)) -{ -} - -QAndroidBinder::~QAndroidBinder() -{ -} - -/*! - Default implementation is a stub that returns false. - The user should override this method to get the transact data from the caller. - - The \a code is the action to perform. - The \a data is the marshaled data sent by the caller.\br - The \a reply is the marshaled data to be sent to the caller.\br - The \a flags are the additional operation flags.\br - - \warning This method is called from Binder's thread which is different - from the thread that this object was created. - - \sa transact - */ -bool QAndroidBinder::onTransact(int /*code*/, const QAndroidParcel &/*data*/, const QAndroidParcel &/*reply*/, CallType /*flags*/) -{ - return false; -} - -/*! - Performs an IPC call - - The \a code is the action to perform. Should be between - \l {https://developer.android.com/reference/android/os/IBinder.html#FIRST_CALL_TRANSACTION} - {FIRST_CALL_TRANSACTION} and - \l {https://developer.android.com/reference/android/os/IBinder.html#LAST_CALL_TRANSACTION} - {LAST_CALL_TRANSACTION}.\br - The \a data is the marshaled data to send to the target.\br - The \a reply (if specified) is the marshaled data to be received from the target. - May be \b nullptr if you are not interested in the return value.\br - The \a flags are the additional operation flags.\br - - \return true on success - */ -bool QAndroidBinder::transact(int code, const QAndroidParcel &data, QAndroidParcel *reply, CallType flags) const -{ - QAndroidJniExceptionCleaner cleaner; - return d->handle.callMethod<jboolean>("transact", "(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z", - jint(code), data.d->handle.object(), reply ? reply->d->handle.object() : nullptr, jint(flags)); -} - -/*! - The return value is useful to call other Java API which are not covered by this wrapper - */ -QAndroidJniObject QAndroidBinder::handle() const -{ - return d->handle; -} - -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidbinder.h b/src/androidextras/android/qandroidbinder.h deleted file mode 100644 index 1e73e7d..0000000 --- a/src/androidextras/android/qandroidbinder.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDBINDER_H -#define QANDROIDBINDER_H - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QSharedPointer> - -#include <jni.h> - -QT_BEGIN_NAMESPACE -class QAndroidBinderPrivate; -class QAndroidParcel; -class QAndroidJniObject; - -class Q_ANDROIDEXTRAS_EXPORT QAndroidBinder -{ -public: - enum class CallType { - Normal = 0, - OneWay = 1 - }; - -public: - explicit QAndroidBinder(); - QAndroidBinder(const QAndroidJniObject &binder); - - virtual ~QAndroidBinder(); - - virtual bool onTransact(int code, const QAndroidParcel &data, const QAndroidParcel &reply, CallType flags); - bool transact(int code, const QAndroidParcel &data, QAndroidParcel *reply = nullptr, CallType flags = CallType::Normal) const; - - QAndroidJniObject handle() const; - -private: - friend class QAndroidBinderPrivate; - friend class QAndroidParcelPrivate; - friend class QAndroidServicePrivate; - QSharedPointer<QAndroidBinderPrivate> d; -}; -QT_END_NAMESPACE - -#endif // QANDROIDBINDER_H diff --git a/src/androidextras/android/qandroidbinder_p.h b/src/androidextras/android/qandroidbinder_p.h deleted file mode 100644 index b132b33..0000000 --- a/src/androidextras/android/qandroidbinder_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDBINDER_P_H -#define QANDROIDBINDER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qandroidjniobject.h" - -#include <functional> -#include <jni.h> - -QT_BEGIN_NAMESPACE -class QAndroidBinder; -class QAndroidBinderPrivate -{ -public: - explicit QAndroidBinderPrivate(QAndroidBinder *binder); - explicit QAndroidBinderPrivate(const QAndroidJniObject &binder); - void setDeleteListener(const std::function<void()> &func) { m_deleteListener = func; } - ~QAndroidBinderPrivate(); - -private: - QAndroidJniObject handle; - std::function<void()> m_deleteListener; - bool m_isQtAndroidBinder; - friend class QAndroidBinder; -}; -QT_END_NAMESPACE - -#endif // QANDROIDBINDER_P_H diff --git a/src/androidextras/android/qandroidfunctions.cpp b/src/androidextras/android/qandroidfunctions.cpp deleted file mode 100644 index 8d049fc..0000000 --- a/src/androidextras/android/qandroidfunctions.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidfunctions.h" -#include "qandroidactivityresultreceiver.h" -#include "qandroidactivityresultreceiver_p.h" -#include "qandroidintent.h" -#include "qandroidserviceconnection.h" -#include "qandroidactivitycallbackresultreceiver_p.h" - -#include <QtCore/private/qjni_p.h> -#include <QtCore/private/qjnihelpers_p.h> - -#include <jni/qandroidjnienvironment.h> - -QT_BEGIN_NAMESPACE - -/*! - \namespace QtAndroid - \inmodule QtAndroidExtras - \since 5.3 - \brief The QtAndroid namespace provides miscellaneous functions to aid Android development. - \inheaderfile QtAndroid -*/ - -/*! - \since 5.10 - \enum QtAndroid::BindFlag - - This enum is used with QtAndroid::bindService to describe the mode in which the - binding is performed. - - \value None No options. - \value AutoCreate Automatically creates the service as long as the binding exist. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_AUTO_CREATE} - {BIND_AUTO_CREATE} documentation for more details. - \value DebugUnbind Include debugging help for mismatched calls to unbind. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_DEBUG_UNBIND} - {BIND_DEBUG_UNBIND} documentation for more details. - \value NotForeground Don't allow this binding to raise the target service's process to the foreground scheduling priority. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_NOT_FOREGROUND} - {BIND_NOT_FOREGROUND} documentation for more details. - \value AboveClient Indicates that the client application binding to this service considers the service to be more important than the app itself. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_ABOVE_CLIENT} - {BIND_ABOVE_CLIENT} documentation for more details. - \value AllowOomManagement Allow the process hosting the bound service to go through its normal memory management. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_ALLOW_OOM_MANAGEMENT} - {BIND_ALLOW_OOM_MANAGEMENT} documentation for more details. - \value WaivePriority Don't impact the scheduling or memory management priority of the target service's hosting process. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_WAIVE_PRIORITY} - {BIND_WAIVE_PRIORITY} documentation for more details. - \value Important This service is assigned a higher priority so that it is available to the client when needed. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_IMPORTANT} - {BIND_IMPORTANT} documentation for more details. - \value AdjustWithActivity If binding from an activity, allow the target service's process importance to be raised based on whether the activity is visible to the user. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_ADJUST_WITH_ACTIVITY} - {BIND_ADJUST_WITH_ACTIVITY} documentation for more details. - \value ExternalService The service being bound is an isolated, external service. - See \l {https://developer.android.com/reference/android/content/Context.html#BIND_EXTERNAL_SERVICE} - {BIND_EXTERNAL_SERVICE} documentation for more details. -*/ - -/*! - \since 5.3 - \fn QAndroidJniObject QtAndroid::androidActivity() - - Returns a handle to this application's main Activity - - \sa QAndroidJniObject, androidService(), androidContext() -*/ -QAndroidJniObject QtAndroid::androidActivity() -{ - return QtAndroidPrivate::activity(); -} - -/*! - \since 5.7 - \fn QAndroidJniObject QtAndroid::androidService() - - Returns a handle to this application's main Service - - \sa QAndroidJniObject, androidActivity(), androidContext() -*/ -QAndroidJniObject QtAndroid::androidService() -{ - return QtAndroidPrivate::service(); -} - -/*! - \since 5.8 - \fn QAndroidJniObject QtAndroid::androidContext() - - Returns a handle to this application's main Context. Depending on the nature of - the application the Context object is either the main Service or Activity - object. - - \sa QAndroidJniObject, androidActivity(), androidService() -*/ -QAndroidJniObject QtAndroid::androidContext() -{ - return QtAndroidPrivate::context(); -} - -/*! - \since 5.3 - \fn int QtAndroid::androidSdkVersion() - - Returns the Android SDK version. This is also known as the API level. -*/ -int QtAndroid::androidSdkVersion() -{ - return QtAndroidPrivate::androidSdkVersion(); -} - -/*! - \since 5.3 - - Starts the activity given by \a intent and provides the result asynchronously through the - \a resultReceiver if this is non-null. - - If \a resultReceiver is null, then the \c startActivity() method in the \c androidActivity() - will be called. Otherwise \c startActivityForResult() will be called. - - The \a receiverRequestCode is a request code unique to the \a resultReceiver, and will be - returned along with the result, making it possible to use the same receiver for more than - one intent. - - */ -void QtAndroid::startActivity(const QAndroidJniObject &intent, - int receiverRequestCode, - QAndroidActivityResultReceiver *resultReceiver) -{ - QAndroidJniObject activity = androidActivity(); - if (resultReceiver != 0) { - QAndroidActivityResultReceiverPrivate *resultReceiverD = QAndroidActivityResultReceiverPrivate::get(resultReceiver); - activity.callMethod<void>("startActivityForResult", - "(Landroid/content/Intent;I)V", - intent.object<jobject>(), - resultReceiverD->globalRequestCode(receiverRequestCode)); - } else { - activity.callMethod<void>("startActivity", - "(Landroid/content/Intent;)V", - intent.object<jobject>()); - } -} - -/*! - \since 5.13 - - Starts the activity given by \a intent and provides the result asynchronously through the - \a resultReceiver if this is non-null. - - If \a resultReceiver is null, then the \c startActivity() method in the \c androidActivity() - will be called. Otherwise \c startActivityForResult() will be called. - - The \a receiverRequestCode is a request code unique to the \a resultReceiver, and will be - returned along with the result, making it possible to use the same receiver for more than - one intent. - - */ -void QtAndroid::startActivity(const QAndroidIntent &intent, - int receiverRequestCode, - QAndroidActivityResultReceiver *resultReceiver) -{ - startActivity(intent.handle(), receiverRequestCode, resultReceiver); -} - -/*! - \since 5.13 - - Starts the activity given by \a intent, using the request code \a receiverRequestCode, - and provides the result by calling \a callbackFunc. -*/ -void QtAndroid::startActivity(const QAndroidJniObject &intent, - int receiverRequestCode, - std::function<void(int, int, const QAndroidJniObject &data)> callbackFunc) -{ - QAndroidJniObject activity = androidActivity(); - QAndroidActivityCallbackResultReceiver::instance()->registerCallback(receiverRequestCode, callbackFunc); - startActivity(intent, receiverRequestCode, QAndroidActivityCallbackResultReceiver::instance()); -} - -/*! - \since 5.3 - - Starts the activity given by \a intentSender and provides the result asynchronously through the - \a resultReceiver if this is non-null. - - If \a resultReceiver is null, then the \c startIntentSender() method in the \c androidActivity() - will be called. Otherwise \c startIntentSenderForResult() will be called. - - The \a receiverRequestCode is a request code unique to the \a resultReceiver, and will be - returned along with the result, making it possible to use the same receiver for more than - one intent. - -*/ -void QtAndroid::startIntentSender(const QAndroidJniObject &intentSender, - int receiverRequestCode, - QAndroidActivityResultReceiver *resultReceiver) -{ - QAndroidJniObject activity = androidActivity(); - if (resultReceiver != 0) { - QAndroidActivityResultReceiverPrivate *resultReceiverD = QAndroidActivityResultReceiverPrivate::get(resultReceiver); - activity.callMethod<void>("startIntentSenderForResult", - "(Landroid/content/IntentSender;ILandroid/content/Intent;III)V", - intentSender.object<jobject>(), - resultReceiverD->globalRequestCode(receiverRequestCode), - 0, // fillInIntent - 0, // flagsMask - 0, // flagsValues - 0); // extraFlags - } else { - activity.callMethod<void>("startIntentSender", - "(Landroid/content/IntentSender;Landroid/content/Intent;III)V", - intentSender.object<jobject>(), - 0, // fillInIntent - 0, // flagsMask - 0, // flagsValues - 0); // extraFlags - - } - -} - -/*! - \typedef QtAndroid::Runnable - - Synonym for std::function<void()>. -*/ - -/*! - \since 5.7 - \fn void QtAndroid::runOnAndroidThread(const Runnable &runnable) - - Posts the given \a runnable on the android thread. - The \a runnable will be queued and executed on the Android UI thread, unless it called on the - Android UI thread, in which case the runnable will be executed immediately. - - This function is useful to set asynchronously properties of objects that must be set on on Android UI thread. -*/ -void QtAndroid::runOnAndroidThread(const QtAndroid::Runnable &runnable) -{ - QtAndroidPrivate::runOnAndroidThread(runnable, QJNIEnvironmentPrivate()); -} - -/*! - \since 5.7 - \fn void QtAndroid::runOnAndroidThreadSync(const Runnable &runnable, int timeoutMs) - - Posts the \a runnable on the Android UI thread and waits until the runnable is executed, - or until \a timeoutMs has passed - - This function is useful to create objects, or get properties on Android UI thread: - - \code - QAndroidJniObject javaControl; - QtAndroid::runOnAndroidThreadSync([&javaControl](){ - - // create our Java control on Android UI thread. - javaControl = QAndroidJniObject("android/webkit/WebView", - "(Landroid/content/Context;)V", - QtAndroid::androidActivity().object<jobject>()); - javaControl.callMethod<void>("setWebViewClient", - "(Landroid/webkit/WebViewClient;)V", - QAndroidJniObject("android/webkit/WebViewClient").object()); - }); - - // Continue the execution normally - qDebug() << javaControl.isValid(); - \endcode -*/ -void QtAndroid::runOnAndroidThreadSync(const QtAndroid::Runnable &runnable, int timeoutMs) -{ - QtAndroidPrivate::runOnAndroidThreadSync(runnable, QJNIEnvironmentPrivate(), timeoutMs); -} - - -/*! - \since 5.7 - \fn void QtAndroid::hideSplashScreen() - - Hides the splash screen immediately. -*/ -void QtAndroid::hideSplashScreen() -{ - hideSplashScreen(0); -} - -/*! - \since 5.10 - \fn void QtAndroid::hideSplashScreen(int duration) - - Hides the splash screen, fading it for \a duration milliseconds. -*/ -void QtAndroid::hideSplashScreen(int duration) -{ - QtAndroidPrivate::hideSplashScreen(QJNIEnvironmentPrivate(), duration); -} - - -/*! - \since 5.10 - \fn bool QtAndroid::bindService(const QAndroidIntent &serviceIntent, const QAndroidServiceConnection &serviceConnection, BindFlags flags = BindFlag::None) - - Binds the service given by \a serviceIntent, \a serviceConnection and \a flags. - The \a serviceIntent object identifies the service to connect to. - The \a serviceConnection is a listener that receives the information as the service is started and stopped. - - \return true on success - - See \l {https://developer.android.com/reference/android/content/Context.html#bindService%28android.content.Intent,%20android.content.ServiceConnection,%20int%29} - {Android documentation} documentation for more details. - - \sa QAndroidIntent, QAndroidServiceConnection, BindFlag -*/ -bool QtAndroid::bindService(const QAndroidIntent &serviceIntent, - const QAndroidServiceConnection &serviceConnection, BindFlags flags) -{ - QAndroidJniExceptionCleaner cleaner; - return androidContext().callMethod<jboolean>("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z", - serviceIntent.handle().object(), serviceConnection.handle().object(), jint(flags)); -} - -static QtAndroid::PermissionResultMap privateToPublicPermissionsHash(const QtAndroidPrivate::PermissionsHash &privateHash) -{ - QtAndroid::PermissionResultMap hash; - for (auto it = privateHash.constBegin(); it != privateHash.constEnd(); ++it) - hash[it.key()] = QtAndroid::PermissionResult(it.value()); - return hash; -} - -/*! - \since 5.10 - \enum QtAndroid::PermissionResult - - This enum is used to describe the permission status. - - \value Granted The permission was granted. - \value Denied The permission was denied. -*/ - -/*! - \typedef QtAndroid::PermissionResultMap - - Synonym for QHash<QString, PermissionResult>. -*/ - -/*! - \typedef QtAndroid::PermissionResultCallback - - Synonym for std::function<void(const PermissionResultMap &)>. -*/ - -/*! - \since 5.10 - \fn void QtAndroid::requestPermissions(const QStringList &permissions, const PermissionResultCallback &callbackFunc) - - Asynchronously requests \a permissions to be granted to this application, \a callbackFunc will be called with the results. -*/ -void QtAndroid::requestPermissions(const QStringList &permissions, const QtAndroid::PermissionResultCallback &callbackFunc) -{ - QtAndroidPrivate::requestPermissions(QJNIEnvironmentPrivate(), permissions, - [callbackFunc](const QtAndroidPrivate::PermissionsHash &privatePerms){ - callbackFunc(privateToPublicPermissionsHash(privatePerms)); - }, false); -} - -/*! - \since 5.10 - \fn QtAndroid::PermissionResultMap QtAndroid::requestPermissionsSync(const QStringList &permissions, int timeoutMs) - - Synchronously requests \a permissions to be granted to this application, waits \a timeoutMs to complete. - */ -QtAndroid::PermissionResultMap QtAndroid::requestPermissionsSync(const QStringList &permissions, int timeoutMs) -{ - return privateToPublicPermissionsHash(QtAndroidPrivate::requestPermissionsSync(QJNIEnvironmentPrivate(), permissions, timeoutMs)); -} - -/*! - \since 5.10 - \fn QtAndroid::PermissionResult QtAndroid::checkPermission(const QString &permission) - - Checks if the \a permission was granted or not. This function should be called every time when - the application starts for needed permissions, as the users might disable them from Android Settings. - */ -QtAndroid::PermissionResult QtAndroid::checkPermission(const QString &permission) -{ - return QtAndroid::PermissionResult(QtAndroidPrivate::checkPermission(permission)); -} - -/*! - \since 5.10 - \fn bool QtAndroid::shouldShowRequestPermissionRationale(const QString &permission) - - Returns \c true if you should show UI with a rationale for requesting a \a permission. -*/ -bool QtAndroid::shouldShowRequestPermissionRationale(const QString &permission) -{ - return QtAndroidPrivate::shouldShowRequestPermissionRationale(permission); -} -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidfunctions.h b/src/androidextras/android/qandroidfunctions.h deleted file mode 100644 index 0433d21..0000000 --- a/src/androidextras/android/qandroidfunctions.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDFUNCTIONS_H -#define QANDROIDFUNCTIONS_H - -#if 0 -#pragma qt_class(QtAndroid) -#endif - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QtAndroidExtras/qandroidjniobject.h> - -#include <functional> - -QT_BEGIN_NAMESPACE - -class QAndroidActivityResultReceiver; -class QAndroidServiceConnection; -class QAndroidIntent; - -namespace QtAndroid -{ - Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject androidActivity(); - Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject androidService(); - Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject androidContext(); - Q_ANDROIDEXTRAS_EXPORT int androidSdkVersion(); - - Q_ANDROIDEXTRAS_EXPORT void startIntentSender(const QAndroidJniObject &intentSender, - int receiverRequestCode, - QAndroidActivityResultReceiver *resultReceiver = nullptr); - Q_ANDROIDEXTRAS_EXPORT void startActivity(const QAndroidJniObject &intent, - int receiverRequestCode, - QAndroidActivityResultReceiver *resultReceiver = nullptr); - Q_ANDROIDEXTRAS_EXPORT void startActivity(const QAndroidIntent &intent, - int receiverRequestCode, - QAndroidActivityResultReceiver *resultReceiver = nullptr); - Q_ANDROIDEXTRAS_EXPORT void startActivity(const QAndroidJniObject &intent, - int receiverRequestCode, - std::function<void(int, int, const QAndroidJniObject &data)> callbackFunc); - - enum class BindFlag { - None = 0x00000000, - AutoCreate = 0x00000001, - DebugUnbind = 0x00000002, - NotForeground = 0x00000004, - AboveClient = 0x00000008, - AllowOomManagement = 0x00000010, - WaivePriority = 0x00000020, - Important = 0x00000040, - AdjustWithActivity = 0x00000080, - ExternalService = -2147483648 // 0x80000000 - - }; - Q_DECLARE_FLAGS(BindFlags, BindFlag) - - Q_ANDROIDEXTRAS_EXPORT bool bindService(const QAndroidIntent &serviceIntent, - const QAndroidServiceConnection &serviceConnection, - BindFlags flags = BindFlag::None); - - typedef std::function<void()> Runnable; - Q_ANDROIDEXTRAS_EXPORT void runOnAndroidThread(const Runnable &runnable); - Q_ANDROIDEXTRAS_EXPORT void runOnAndroidThreadSync(const Runnable &runnable, int timeoutMs = INT_MAX); - - Q_ANDROIDEXTRAS_EXPORT void hideSplashScreen(); // ### Qt6: merge with next overload - Q_ANDROIDEXTRAS_EXPORT void hideSplashScreen(int duration); - - enum class PermissionResult { - Denied = -1, - Granted = 0 - }; - typedef QHash<QString, PermissionResult> PermissionResultMap; - typedef std::function<void(const PermissionResultMap &)> PermissionResultCallback; - Q_ANDROIDEXTRAS_EXPORT void requestPermissions(const QStringList &permissions, const PermissionResultCallback &callbackFunc); - Q_ANDROIDEXTRAS_EXPORT PermissionResultMap requestPermissionsSync(const QStringList &permissions, int timeoutMs = INT_MAX); - Q_ANDROIDEXTRAS_EXPORT PermissionResult checkPermission(const QString &permission); - Q_ANDROIDEXTRAS_EXPORT bool shouldShowRequestPermissionRationale(const QString &permission); -} - -QT_END_NAMESPACE - -#endif // QANDROIDFUNCTIONS_H diff --git a/src/androidextras/android/qandroidintent.cpp b/src/androidextras/android/qandroidintent.cpp deleted file mode 100644 index 9c0fecb..0000000 --- a/src/androidextras/android/qandroidintent.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidintent.h" - -#include <jni/qandroidjnienvironment.h> -#include <QtCore/private/qjni_p.h> -#include <QBuffer> -#include <QDataStream> -#include <QVariant> - -QT_BEGIN_NAMESPACE - -/*! - \class QAndroidIntent - \inmodule QtAndroidExtras - \brief Wraps the most important methods of Android Intent class. - - The QAndroidIntent is a convenience class that wraps the most important - \l {https://developer.android.com/reference/android/content/Intent.html}{Android Intent} - methods. - - \since 5.10 -*/ - -/*! - Create a new intent - */ -QAndroidIntent::QAndroidIntent() - : m_handle("android.content.Intent", "()V") -{ - -} - -QAndroidIntent::~QAndroidIntent() -{} - -/*! - Wraps the provided \a intent java object. - */ -QAndroidIntent::QAndroidIntent(const QAndroidJniObject &intent) - : m_handle(intent) -{ -} - -/*! - Creates a new intent and sets the provided \a action. - */ -QAndroidIntent::QAndroidIntent(const QString &action) - : m_handle("android.content.Intent", "(Ljava/lang/String;)V", - QAndroidJniObject::fromString(action).object()) -{ - QAndroidJniExceptionCleaner cleaner; -} - -/*! - Creates a new intent and sets the provided \a packageContext and the service \a className. - Example: - \code - auto serviceIntent = QAndroidIntent(QtAndroid::androidActivity().object(), "com.example.MyService"); - \endcode - - \sa QtAndroid::androidActivity, QtAndroid::bindService - */ -QAndroidIntent::QAndroidIntent(const QAndroidJniObject &packageContext, const char *className) - : m_handle("android/content/Intent", "(Landroid/content/Context;Ljava/lang/Class;)V", - packageContext.object(), QJNIEnvironmentPrivate::findClass(className)) -{ - QAndroidJniExceptionCleaner cleaner; -} - -/*! - Sets the \a key with the \a data in the Intent extras - */ -void QAndroidIntent::putExtra(const QString &key, const QByteArray &data) -{ - QAndroidJniExceptionCleaner cleaner; - QAndroidJniEnvironment env; - jbyteArray array = env->NewByteArray(data.size()); - env->SetByteArrayRegion(array, 0, data.length(), reinterpret_cast<const jbyte*>(data.constData())); - m_handle.callObjectMethod("putExtra", "(Ljava/lang/String;[B)Landroid/content/Intent;", - QAndroidJniObject::fromString(key).object(), array); - env->DeleteLocalRef(array); -} - -/*! - Returns the extra \a key data from the Intent extras - */ -QByteArray QAndroidIntent::extraBytes(const QString &key) -{ - QAndroidJniExceptionCleaner cleaner; - auto array = m_handle.callObjectMethod("getByteArrayExtra", "(Ljava/lang/String;)[B", - QAndroidJniObject::fromString(key).object()); - if (!array.isValid() || !array.object()) - return QByteArray(); - QAndroidJniEnvironment env; - auto sz = env->GetArrayLength(jarray(array.object())); - QByteArray res(sz, Qt::Initialization::Uninitialized); - env->GetByteArrayRegion(jbyteArray(array.object()), 0, sz, reinterpret_cast<jbyte *>(res.data())); - return res; -} - -/*! - Sets the \a key with the \a value in the Intent extras. - */ -void QAndroidIntent::putExtra(const QString &key, const QVariant &value) -{ - QByteArray buff; - QDataStream stream(&buff, QIODevice::WriteOnly); - stream << value; - putExtra(key, buff); -} - -/*! - Returns the extra \a key data from the Intent extras as a QVariant - */ -QVariant QAndroidIntent::extraVariant(const QString &key) -{ - QDataStream stream(extraBytes(key)); - QVariant res; - stream >> res; - return res; -} - -/*! - The return value is useful to call other Java API which are not covered by this wrapper - */ -QAndroidJniObject QAndroidIntent::handle() const -{ - return m_handle; -} -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidintent.h b/src/androidextras/android/qandroidintent.h deleted file mode 100644 index 3da5692..0000000 --- a/src/androidextras/android/qandroidintent.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDINTENT_H -#define QANDROIDINTENT_H - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QtAndroidExtras/qandroidjniobject.h> - -QT_BEGIN_NAMESPACE -class QAndroidJniObject; -class Q_ANDROIDEXTRAS_EXPORT QAndroidIntent -{ -public: - QAndroidIntent(); - virtual ~QAndroidIntent(); - explicit QAndroidIntent(const QAndroidJniObject &intent); - explicit QAndroidIntent(const QString &action); - explicit QAndroidIntent(const QAndroidJniObject &packageContext, const char *className); - - void putExtra(const QString &key, const QByteArray &data); - QByteArray extraBytes(const QString &key); - - void putExtra(const QString &key, const QVariant &value); - QVariant extraVariant(const QString &key); - - QAndroidJniObject handle() const; - -private: - QAndroidJniObject m_handle; -}; -QT_END_NAMESPACE - -#endif // QANDROIDINTENT_H diff --git a/src/androidextras/android/qandroidparcel.cpp b/src/androidextras/android/qandroidparcel.cpp deleted file mode 100644 index 6923f87..0000000 --- a/src/androidextras/android/qandroidparcel.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidparcel.h" - -#include "qandroidbinder.h" -#include "qandroidbinder_p.h" -#include "qandroidparcel_p.h" - -#include <QAndroidJniObject> -#include <QAndroidJniEnvironment> -#include <QBuffer> -#include <QDataStream> -#include <QVariant> - -QT_BEGIN_NAMESPACE - -struct FileDescriptor -{ - explicit FileDescriptor(int fd = -1) - : handle("java/io/FileDescriptor") - { - QAndroidJniExceptionCleaner cleaner; - setFileDescriptor(fd); - } - - inline void setFileDescriptor(int fd) - { - QAndroidJniExceptionCleaner cleaner; - handle.setField("descriptor", fd); - } - - QAndroidJniObject handle; -}; - -QAndroidParcelPrivate::QAndroidParcelPrivate() - : handle(QAndroidJniObject::callStaticObjectMethod("android/os/Parcel","obtain", "()Landroid/os/Parcel;").object()) -{} - -QAndroidParcelPrivate::QAndroidParcelPrivate(const QAndroidJniObject &parcel) - : handle(parcel) -{} - -void QAndroidParcelPrivate::writeData(const QByteArray &data) const -{ - if (data.isEmpty()) - return; - - QAndroidJniExceptionCleaner cleaner; - QAndroidJniEnvironment env; - jbyteArray array = env->NewByteArray(data.size()); - env->SetByteArrayRegion(array, 0, data.length(), reinterpret_cast<const jbyte*>(data.constData())); - handle.callMethod<void>("writeByteArray", "([B)V", array); - env->DeleteLocalRef(array); -} - -void QAndroidParcelPrivate::writeBinder(const QAndroidBinder &binder) const -{ - QAndroidJniExceptionCleaner cleaner; - handle.callMethod<void>("writeStrongBinder", "(Landroid/os/IBinder;)V", binder.handle().object()); -} - -void QAndroidParcelPrivate::writeFileDescriptor(int fd) const -{ - QAndroidJniExceptionCleaner cleaner; - handle.callMethod<void>("writeFileDescriptor", "(Ljava/io/FileDescriptor;)V", FileDescriptor(fd).handle.object()); -} - -QByteArray QAndroidParcelPrivate::readData() const -{ - QAndroidJniExceptionCleaner cleaner; - auto array = handle.callObjectMethod("createByteArray", "()[B"); - QAndroidJniEnvironment env; - auto sz = env->GetArrayLength(jbyteArray(array.object())); - QByteArray res(sz, Qt::Initialization::Uninitialized); - env->GetByteArrayRegion(jbyteArray(array.object()), 0, sz, reinterpret_cast<jbyte *>(res.data())); - return res; -} - -int QAndroidParcelPrivate::readFileDescriptor() const -{ - QAndroidJniExceptionCleaner cleaner; - auto parcelFD = handle.callObjectMethod("readFileDescriptor", "()Landroid/os/ParcelFileDescriptor;"); - if (parcelFD.isValid()) - return parcelFD.callMethod<jint>("getFd", "()I"); - return -1; -} - -QAndroidBinder QAndroidParcelPrivate::readBinder() const -{ - QAndroidJniExceptionCleaner cleaner; - auto strongBinder = handle.callObjectMethod("readStrongBinder", "()Landroid/os/IBinder;"); - return QAndroidBinder(strongBinder.object()); -} - -/*! - \class QAndroidParcel - \inmodule QtAndroidExtras - \brief Wraps the most important methods of Android Parcel class. - - The QAndroidParcel is a convenience class that wraps the most important - \l {https://developer.android.com/reference/android/os/Parcel.html}{Android Parcel} - methods. - - \since 5.10 -*/ - -/*! - Creates a new object. - */ -QAndroidParcel::QAndroidParcel() - : d(new QAndroidParcelPrivate()) -{ -} - -/*! - Wraps the \a parcel object. - */ -QAndroidParcel::QAndroidParcel(const QAndroidJniObject& parcel) - : d(new QAndroidParcelPrivate(parcel)) -{ - -} - -QAndroidParcel::~QAndroidParcel() -{ -} - -/*! - Writes the provided \a data as a byte array - */ -void QAndroidParcel::writeData(const QByteArray &data) const -{ - d->writeData(data); -} - -/*! - Writes the provided \a value. The value is converted into a - QByteArray before is written. - */ -void QAndroidParcel::writeVariant(const QVariant &value) const -{ - QByteArray buff; - QDataStream stream(&buff, QIODevice::WriteOnly); - stream << value; - d->writeData(buff); -} - -/*! - Writes a \a binder object. This is useful for a client to - send to a server a binder which can be used by the server callback the client. - */ -void QAndroidParcel::writeBinder(const QAndroidBinder &binder) const -{ - d->writeBinder(binder); -} - -/*! - Writes the provided \a fd. - */ -void QAndroidParcel::writeFileDescriptor(int fd) const -{ - d->writeFileDescriptor(fd); -} - -/*! - Returns the data as a QByteArray - */ -QByteArray QAndroidParcel::readData() const -{ - return d->readData(); -} - -/*! - Returns the data as a QVariant - */ -QVariant QAndroidParcel::readVariant() const -{ - QDataStream stream(d->readData()); - QVariant res; - stream >> res; - return res; -} - -/*! - Returns the binder as a QAndroidBinder - */ -QAndroidBinder QAndroidParcel::readBinder() const -{ - return d->readBinder(); -} - -/*! - Returns the file descriptor - */ -int QAndroidParcel::readFileDescriptor() const -{ - return d->readFileDescriptor(); -} - -/*! - The return value is useful to call other Java API which are not covered by this wrapper - */ -QAndroidJniObject QAndroidParcel::handle() const -{ - return d->handle; -} - -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidparcel.h b/src/androidextras/android/qandroidparcel.h deleted file mode 100644 index 23d1edc..0000000 --- a/src/androidextras/android/qandroidparcel.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDPARCEL_H -#define QANDROIDPARCEL_H - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QSharedPointer> -#include <QVariant> - -QT_BEGIN_NAMESPACE -class QAndroidBinder; -class QAndroidJniObject; -class QAndroidParcelPrivate; -class Q_ANDROIDEXTRAS_EXPORT QAndroidParcel -{ -public: - QAndroidParcel(); - explicit QAndroidParcel(const QAndroidJniObject& parcel); - virtual ~QAndroidParcel(); - - void writeData(const QByteArray &data) const; - void writeVariant(const QVariant &value) const; - void writeBinder(const QAndroidBinder &binder) const; - void writeFileDescriptor(int fd) const; - - QByteArray readData() const; - QVariant readVariant() const; - QAndroidBinder readBinder() const; - int readFileDescriptor() const; - - QAndroidJniObject handle() const; - -private: - friend class QAndroidParcelPrivate; - friend class QAndroidBinder; - QSharedPointer<QAndroidParcelPrivate> d; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDPARCEL_H diff --git a/src/androidextras/android/qandroidparcel_p.h b/src/androidextras/android/qandroidparcel_p.h deleted file mode 100644 index 0be55f8..0000000 --- a/src/androidextras/android/qandroidparcel_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDPARCEL_P_H -#define QANDROIDPARCEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QAndroidJniObject> -QT_BEGIN_NAMESPACE -class QAndroidBinder; -class QAndroidParcelPrivate -{ -public: - QAndroidParcelPrivate(); - explicit QAndroidParcelPrivate(const QAndroidJniObject& parcel); - - void writeData(const QByteArray &data) const; - void writeBinder(const QAndroidBinder &binder) const; - void writeFileDescriptor(int fd) const; - - QByteArray readData() const; - int readFileDescriptor() const; - QAndroidBinder readBinder() const; - -private: - friend class QAndroidBinder; - friend class QAndroidParcel; - QAndroidJniObject handle; -}; -QT_END_NAMESPACE - -#endif // QANDROIDPARCEL_P_H diff --git a/src/androidextras/android/qandroidservice.cpp b/src/androidextras/android/qandroidservice.cpp deleted file mode 100644 index 331f04a..0000000 --- a/src/androidextras/android/qandroidservice.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidservice.h" - -#include "qandroidintent.h" -#include "qandroidbinder.h" -#include "qandroidbinder_p.h" - -#include <private/qjnihelpers_p.h> - -#include <QMutex> -#include <QTimer> -#include <QSet> - -QT_BEGIN_NAMESPACE - -class QAndroidServicePrivate : public QObject, public QtAndroidPrivate::OnBindListener -{ -public: - QAndroidServicePrivate(QAndroidService *service, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder = {}) - : m_service(service) - , m_binder(binder) - { - QTimer::singleShot(0,this, [this]{ QtAndroidPrivate::setOnBindListener(this);}); - } - - ~QAndroidServicePrivate() - { - QMutexLocker lock(&m_bindersMutex); - while (!m_binders.empty()) { - auto it = m_binders.begin(); - lock.unlock(); - delete (*it); - lock.relock(); - } - } - - // OnBindListener interface - jobject onBind(jobject intent) override - { - auto qai = QAndroidIntent(intent); - auto binder = m_binder ? m_binder(qai) : m_service->onBind(qai); - if (binder) { - { - QMutexLocker lock(&m_bindersMutex); - binder->d->setDeleteListener([this, binder]{binderDestroied(binder);}); - m_binders.insert(binder); - } - return binder->handle().object(); - } - return nullptr; - } - -private: - void binderDestroied(QAndroidBinder* obj) - { - QMutexLocker lock(&m_bindersMutex); - m_binders.remove(obj); - } - -public: - QAndroidService *m_service = nullptr; - std::function<QAndroidBinder *(const QAndroidIntent &)> m_binder; - QMutex m_bindersMutex; - QSet<QAndroidBinder*> m_binders; -}; - -/*! - \class QAndroidService - \inmodule QtAndroidExtras - \brief Wraps the most important methods of Android Service class. - - The QAndroidService is a convenience class that wraps the most important - \l {https://developer.android.com/reference/android/app/Service.html}{Android Service} - methods. - - \since 5.10 -*/ - - -/*! - \fn QAndroidService::QAndroidService(int &argc, char **argv) - - Creates a new Android service, passing \a argc and \a argv as parameters. - - //! Parameter \a flags is omitted in the documentation. - - \sa QCoreApplication - */ -QAndroidService::QAndroidService(int &argc, char **argv, int flags) - : QCoreApplication (argc, argv, QtAndroidPrivate::acuqireServiceSetup(flags)) - , d(new QAndroidServicePrivate{this}) -{ -} - -/*! - \fn QAndroidService::QAndroidService(int &argc, char **argv, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder) - - Creates a new Android service, passing \a argc and \a argv as parameters. - - \a binder is used to create a \l {QAndroidBinder}{binder} when needed. - - //! Parameter \a flags is omitted in the documentation. - - \sa QCoreApplication - */ -QAndroidService::QAndroidService(int &argc, char **argv, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder, int flags) - : QCoreApplication (argc, argv, QtAndroidPrivate::acuqireServiceSetup(flags)) - , d(new QAndroidServicePrivate{this, binder}) -{ -} - -QAndroidService::~QAndroidService() -{} - -/*! - The user must override this method and to return a binder. - - The \a intent parameter contains all the caller information. - - The returned binder is used by the caller to perform IPC calls. - - \warning This method is called from Binder's thread which is different - from the thread that this object was created. - - \sa QAndroidBinder::onTransact, QAndroidBinder::transact - */ -QAndroidBinder* QAndroidService::onBind(const QAndroidIntent &/*intent*/) -{ - return nullptr; -} - -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidservice.h b/src/androidextras/android/qandroidservice.h deleted file mode 100644 index b9acd18..0000000 --- a/src/androidextras/android/qandroidservice.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDSERVICE_H -#define QANDROIDSERVICE_H - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QCoreApplication> -#include <QSharedPointer> -#include <functional> - -QT_BEGIN_NAMESPACE -class QAndroidServicePrivate; -class QAndroidIntent; -class QAndroidBinder; -class Q_ANDROIDEXTRAS_EXPORT QAndroidService : public QCoreApplication -{ - Q_OBJECT - -public: - QAndroidService(int &argc, char **argv -#ifndef Q_QDOC - , int flags = ApplicationFlags -#endif - ); - QAndroidService(int &argc, char **argv, - const std::function<QAndroidBinder*(const QAndroidIntent &intent)> & binder -#ifndef Q_QDOC - , int flags = ApplicationFlags -#endif - ); - virtual ~QAndroidService(); - - virtual QAndroidBinder* onBind(const QAndroidIntent &intent); - -private: - friend class QAndroidServicePrivate; - Q_DISABLE_COPY(QAndroidService) - - QScopedPointer<QAndroidServicePrivate> d; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDSERVICE_H diff --git a/src/androidextras/android/qandroidserviceconnection.cpp b/src/androidextras/android/qandroidserviceconnection.cpp deleted file mode 100644 index 3daf1cc..0000000 --- a/src/androidextras/android/qandroidserviceconnection.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidserviceconnection.h" -#include "qandroidjniobject.h" - -#include <QAndroidJniEnvironment> - -QT_BEGIN_NAMESPACE -/*! - \class QAndroidServiceConnection - \inmodule QtAndroidExtras - \brief Wraps the most important methods of Android ServiceConnection class. - - The QAndroidServiceConnection is a convenience abstract class which wraps the - \l {https://developer.android.com/reference/android/content/ServiceConnection.html}{Android ServiceConnection} - interface. - - It is useful when you perform a QtAndroid::bindService operation. - - \since 5.10 -*/ - - -/*! - Creates a new object - */ -QAndroidServiceConnection::QAndroidServiceConnection() - : m_handle("org/qtproject/qt/android/extras/QtAndroidServiceConnection", "(J)V", jlong(this)) -{ -} - -/*! - Creates a new object from an existing \a serviceConnection. - - It's useful when you have your own Java implementation. - Of course onServiceConnected()/onServiceDisconnected() - will not be called anymore. - */ -QAndroidServiceConnection::QAndroidServiceConnection(const QAndroidJniObject &serviceConnection) - : m_handle(serviceConnection) -{ -} - -QAndroidServiceConnection::~QAndroidServiceConnection() -{ - m_handle.callMethod<void>("setId", "(J)V", jlong(this)); -} - -/*! - returns the underline QAndroidJniObject - */ -QAndroidJniObject QAndroidServiceConnection::handle() const -{ - return m_handle; -} - -/*! - \fn void QAndroidServiceConnection::onServiceConnected(const QString &name, const QAndroidBinder &serviceBinder) - - This notification is called when the client managed to connect to the service. - The \a name contains the server name, the \a serviceBinder is the binder that the client - uses to perform IPC operations. - - \warning This method is called from Binder's thread which is different - from the thread that this object was created. - - returns the underline QAndroidJniObject - */ - -/*! - \fn void QAndroidServiceConnection::onServiceDisconnected(const QString &name) - - Called when a connection to the Service has been lost. - The \a name parameter specifies which connectioen was lost. - - \warning This method is called from Binder's thread which is different - from the thread that this object was created. - - returns the underline QAndroidJniObject - */ - -QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidserviceconnection.h b/src/androidextras/android/qandroidserviceconnection.h deleted file mode 100644 index a46c7bb..0000000 --- a/src/androidextras/android/qandroidserviceconnection.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTANDROIDSERVICECONNECTION_H -#define QTANDROIDSERVICECONNECTION_H - -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QtAndroidExtras/QAndroidJniObject> - -QT_BEGIN_NAMESPACE -class QAndroidBinder; -class Q_ANDROIDEXTRAS_EXPORT QAndroidServiceConnection -{ -public: - QAndroidServiceConnection(); - explicit QAndroidServiceConnection(const QAndroidJniObject &serviceConnection); - virtual ~QAndroidServiceConnection(); - - virtual void onServiceConnected(const QString &name, const QAndroidBinder &serviceBinder) = 0; - virtual void onServiceDisconnected(const QString &name) = 0; - - QAndroidJniObject handle() const; -private: - Q_DISABLE_COPY(QAndroidServiceConnection) - QAndroidJniObject m_handle; -}; - -QT_END_NAMESPACE - -#endif // QTANDROIDSERVICECONNECTION_H diff --git a/src/androidextras/android/qjnionload.cpp b/src/androidextras/android/qjnionload.cpp deleted file mode 100644 index 3a7ccc2..0000000 --- a/src/androidextras/android/qjnionload.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidbinder.h" -#include "qandroidparcel.h" -#include "qandroidserviceconnection.h" - -#include <android/log.h> -#include <QAndroidJniObject> -#include <jni.h> - -static jboolean onTransact(JNIEnv */*env*/, jclass /*cls*/, jlong id, jint code, jobject data, jobject reply, jint flags) -{ - if (!id) - return false; - return reinterpret_cast<QAndroidBinder*>(id)->onTransact(code, QAndroidParcel(data), QAndroidParcel(reply), QAndroidBinder::CallType(flags)); -} - -static void onServiceConnected(JNIEnv */*env*/, jclass /*cls*/, jlong id, jstring name, jobject service) -{ - if (!id) - return; - return reinterpret_cast<QAndroidServiceConnection *>(id)->onServiceConnected(QAndroidJniObject(name).toString(), - QAndroidBinder(service)); -} - -static void onServiceDisconnected(JNIEnv */*env*/, jclass /*cls*/, jlong id, jstring name) -{ - if (!id) - return; - return reinterpret_cast<QAndroidServiceConnection *>(id)->onServiceDisconnected(QAndroidJniObject(name).toString()); -} - -static JNINativeMethod methods[] = { - {"onTransact", "(JILandroid/os/Parcel;Landroid/os/Parcel;I)Z", (void *)onTransact}, - {"onServiceConnected", "(JLjava/lang/String;Landroid/os/IBinder;)V", (void *)onServiceConnected}, - {"onServiceDisconnected", "(JLjava/lang/String;)V", (void *)onServiceDisconnected} -}; - - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/) -{ - static bool initialized = false; - if (initialized) - return JNI_VERSION_1_6; - initialized = true; - - typedef union { - JNIEnv *nativeEnvironment; - void *venv; - } UnionJNIEnvToVoid; - - UnionJNIEnvToVoid uenv; - uenv.venv = nullptr; - - if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK) { - __android_log_print(ANDROID_LOG_FATAL, "Qt", "GetEnv failed"); - return -1; - } - - JNIEnv *env = uenv.nativeEnvironment; - jclass clazz; - clazz = env->FindClass("org/qtproject/qt/android/extras/QtNative"); - if (!clazz) { - __android_log_print(ANDROID_LOG_FATAL,"Qt", "Can't find \"org/qtproject/qt/android/extras/QtNative\" class"); - return -1; - } - - if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0) { - __android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed"); - return -1; - } - - return JNI_VERSION_1_6; -} diff --git a/src/androidextras/doc/QtAndroidExtras/QAndroidJniObject b/src/androidextras/doc/QtAndroidExtras/QAndroidJniObject deleted file mode 100644 index b96916d..0000000 --- a/src/androidextras/doc/QtAndroidExtras/QAndroidJniObject +++ /dev/null @@ -1 +0,0 @@ -#include "qandroidjniobject.h" diff --git a/src/androidextras/doc/QtAndroidExtras/jni.h b/src/androidextras/doc/QtAndroidExtras/jni.h deleted file mode 100644 index 9013345..0000000 --- a/src/androidextras/doc/QtAndroidExtras/jni.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* Dummy declarations passed to clang when generating the docs */ - -#ifndef JNI_H -#define JNI_H - -struct JNIEnv_; -struct JavaVM_; -typedef JNIEnv_ JNIEnv; -typedef JavaVM_ JavaVM; -typedef int jclass; -typedef char jobject; - -#endif diff --git a/src/androidextras/doc/QtAndroidExtras/qandroidextrasglobal.h b/src/androidextras/doc/QtAndroidExtras/qandroidextrasglobal.h deleted file mode 100644 index 9000f4e..0000000 --- a/src/androidextras/doc/QtAndroidExtras/qandroidextrasglobal.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../qandroidextrasglobal.h" -#include "QtCore/qvariant.h" diff --git a/src/androidextras/doc/QtAndroidExtras/qandroidjniobject.h b/src/androidextras/doc/QtAndroidExtras/qandroidjniobject.h deleted file mode 100644 index 7f58978..0000000 --- a/src/androidextras/doc/QtAndroidExtras/qandroidjniobject.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../jni/qandroidjniobject.h" diff --git a/src/androidextras/doc/QtAndroidExtrasDoc b/src/androidextras/doc/QtAndroidExtrasDoc deleted file mode 100644 index 2294259..0000000 --- a/src/androidextras/doc/QtAndroidExtrasDoc +++ /dev/null @@ -1,10 +0,0 @@ -#include "qandroidextrasglobal.h" -#include "qandroidactivityresultreceiver.h" -#include "qandroidbinder.h" -#include "qandroidfunctions.h" -#include "qandroidintent.h" -#include "qandroidjnienvironment.h" -#include "qandroidjniobject.h" -#include "qandroidparcel.h" -#include "qandroidserviceconnection.h" -#include "qandroidservice.h" diff --git a/src/androidextras/doc/images/androidservices.png b/src/androidextras/doc/images/androidservices.png Binary files differdeleted file mode 100644 index 5c837f6..0000000 --- a/src/androidextras/doc/images/androidservices.png +++ /dev/null diff --git a/src/androidextras/doc/images/customactivity.png b/src/androidextras/doc/images/customactivity.png Binary files differdeleted file mode 100644 index 4b01a0a..0000000 --- a/src/androidextras/doc/images/customactivity.png +++ /dev/null diff --git a/src/androidextras/doc/images/jnimessenger.png b/src/androidextras/doc/images/jnimessenger.png Binary files differdeleted file mode 100644 index 1cb4efd..0000000 --- a/src/androidextras/doc/images/jnimessenger.png +++ /dev/null diff --git a/src/androidextras/doc/images/musiclist.png b/src/androidextras/doc/images/musiclist.png Binary files differdeleted file mode 100644 index cc37613..0000000 --- a/src/androidextras/doc/images/musiclist.png +++ /dev/null diff --git a/src/androidextras/doc/images/notification.png b/src/androidextras/doc/images/notification.png Binary files differdeleted file mode 100644 index 6d7dba6..0000000 --- a/src/androidextras/doc/images/notification.png +++ /dev/null diff --git a/src/androidextras/doc/qtandroidextras.qdocconf b/src/androidextras/doc/qtandroidextras.qdocconf deleted file mode 100644 index 4b9c77a..0000000 --- a/src/androidextras/doc/qtandroidextras.qdocconf +++ /dev/null @@ -1,52 +0,0 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) -include($QT_INSTALL_DOCS/config/exampleurl-qtandroidextras.qdocconf) - -Cpp.ignoretokens += Q_ANDROIDEXTRAS_EXPORT -# dummy module header for clang, found under doc/ -moduleheader = QtAndroidExtrasDoc - -# pass include paths to clang -includepaths += -I . \ - -I .. \ - -I ../android \ - -I ../jni \ - -I ./QtAndroidExtras - -project = QtAndroidExtras -description = Qt Android Extras Reference Documentation -version = $QT_VERSION - -qhp.projects = QtAndroidExtras - -qhp.QtAndroidExtras.file = qtandroidextras.qhp -qhp.QtAndroidExtras.namespace = org.qt-project.qtandroidextras.$QT_VERSION_TAG -qhp.QtAndroidExtras.virtualFolder = qtandroidextras -qhp.QtAndroidExtras.indexTitle = Qt Android Extras -qhp.QtAndroidExtras.indexRoot = - -qhp.QtAndroidExtras.filterAttributes = qtandroidextras $QT_VERSION qtrefdoc -qhp.QtAndroidExtras.customFilters.Qt.name = QtAndroidExtras $QT_VERSION -qhp.QtAndroidExtras.customFilters.Qt.filterAttributes = qtandroidextras $QT_VERSION - -qhp.QtAndroidExtras.subprojects = classes examples -qhp.QtAndroidExtras.subprojects.classes.title = C++ Classes and Namespaces -qhp.QtAndroidExtras.subprojects.classes.indexTitle = Qt Android Extras C++ Classes -qhp.QtAndroidExtras.subprojects.classes.selectors = class function namespace fake:headerfile -qhp.QtAndroidExtras.subprojects.classes.sortPages = true -qhp.QtAndroidExtras.subprojects.examples.title = Examples -qhp.QtAndroidExtras.subprojects.examples.indexTitle = Qt Android Extras Examples -qhp.QtAndroidExtras.subprojects.examples.selectors = fake:example - -depends += qtcore qtdoc qtqml qtquick qtremoteobjects -headerdirs += .. -sourcedirs += .. -exampledirs += ../../../examples/androidextras \ - snippets -examples.fileextensions += *.java - -# Specify example install dir under QT_INSTALL_EXAMPLES -examplesinstallpath = androidextras - -imagedirs += images -navigation.landingpage = "Qt Android Extras" -navigation.cppclassespage = "Qt Android Extras C++ Classes" diff --git a/src/androidextras/doc/snippets/code/src_androidextras_qandroidjnienvironment.cpp b/src/androidextras/doc/snippets/code/src_androidextras_qandroidjnienvironment.cpp deleted file mode 100644 index 1b404d5..0000000 --- a/src/androidextras/doc/snippets/code/src_androidextras_qandroidjnienvironment.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) 2015 The Qt Company Ltd. - ** Contact: http://www.qt.io/licensing/ - ** - ** This file is part of the documentation of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:BSD$ - ** Commercial License Usage - ** Licensees holding valid commercial Qt licenses may use this file in - ** accordance with the commercial license agreement provided with the - ** Software or, alternatively, in accordance with the terms contained in - ** a written agreement between you and The Qt Company. For licensing terms - ** and conditions see https://www.qt.io/terms-conditions. For further - ** information use the contact form at https://www.qt.io/contact-us. - ** - ** BSD License Usage - ** Alternatively, you may use this file under the terms of the BSD license - ** as follows: - ** - ** "Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are - ** met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in - ** the documentation and/or other materials provided with the - ** distribution. - ** * Neither the name of The Qt Company Ltd nor the names of its - ** contributors may be used to endorse or promote products derived - ** from this software without specific prior written permission. - ** - ** - ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - ** - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ - -//! [Create QAndroidJniEnvironment] - -bool exceptionCheck() -{ - /* - The QAndroidJniEnvironment attaches the current thread to the JavaVM on - creation and detach when it goes out of scope. - */ - QAndroidJniEnvironment qjniEnv; - return qjniEnv->ExceptionCheck(); -} -//! [Create QAndroidJniEnvironment] diff --git a/src/androidextras/doc/snippets/code/src_androidextras_qandroidjniobject.cpp b/src/androidextras/doc/snippets/code/src_androidextras_qandroidjniobject.cpp deleted file mode 100644 index 96ae1a9..0000000 --- a/src/androidextras/doc/snippets/code/src_androidextras_qandroidjniobject.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) 2015 The Qt Company Ltd. - ** Contact: http://www.qt.io/licensing/ - ** - ** This file is part of the documentation of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:BSD$ - ** Commercial License Usage - ** Licensees holding valid commercial Qt licenses may use this file in - ** accordance with the commercial license agreement provided with the - ** Software or, alternatively, in accordance with the terms contained in - ** a written agreement between you and The Qt Company. For licensing terms - ** and conditions see https://www.qt.io/terms-conditions. For further - ** information use the contact form at https://www.qt.io/contact-us. - ** - ** BSD License Usage - ** Alternatively, you may use this file under the terms of the BSD license - ** as follows: - ** - ** "Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are - ** met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in - ** the documentation and/or other materials provided with the - ** distribution. - ** * Neither the name of The Qt Company Ltd nor the names of its - ** contributors may be used to endorse or promote products derived - ** from this software without specific prior written permission. - ** - ** - ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - ** - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ - -//! [Working with lists] -QStringList getTrackTitles(const QAndroidJniObject &album) { - QStringList stringList; - QAndroidJniObject list = album.callObjectMethod("getTitles", - "()Ljava/util/List;"); - - if (list.isValid()) { - const int size = list.callMethod<jint>("size"); - for (int i = 0; i < size; ++i) { - QAndroidJniObject title = list.callObjectMethod("get", "(I)Ljava/lang/Object;", i); - stringList.append(title.toString()); - } - } - return stringList; -} -//! [Working with lists] - -//! [QAndroidJniObject scope] -void functionScope() -{ - QString helloString("Hello"); - jstring myJString = 0; - { - QAndroidJniObject string = QAndroidJniObject::fromString(helloString); - myJString = string.object<jstring>(); - } - - // Ops! myJString is no longer valid. -} -//! [QAndroidJniObject scope] - -//! [Check for exceptions] -void functionException() -{ - QAndroidJniObject myString = QAndroidJniObject::fromString("Hello"); - jchar c = myString.callMethod<jchar>("charAt", "(I)C", 1000); - QAndroidJniEnvironment env; - if (env->ExceptionCheck()) { - // Handle exception here. - env->ExceptionClear(); - } -} -//! [Check for exceptions] - -//! [Registering native methods] -static void fromJavaOne(JNIEnv *env, jobject thiz, jint x) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - qDebug() << x << "< 100"; -} - -static void fromJavaTwo(JNIEnv *env, jobject thiz, jint x) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - qDebug() << x << ">= 100"; -} - -void registerNativeMethods() { - JNINativeMethod methods[] {{"callNativeOne", "(I)V", reinterpret_cast<void *>(fromJavaOne)}, - {"callNativeTwo", "(I)V", reinterpret_cast<void *>(fromJavaTwo)}}; - - QAndroidJniObject javaClass("my/java/project/FooJavaClass"); - QAndroidJniEnvironment env; - jclass objectClass = env->GetObjectClass(javaClass.object<jobject>()); - env->RegisterNatives(objectClass, - methods, - sizeof(methods) / sizeof(methods[0])); - env->DeleteLocalRef(objectClass); -} - -void foo() -{ - QAndroidJniObject::callStaticMethod<void>("my/java/project/FooJavaClass", "foo", "(I)V", 10); // Output: 10 < 100 - QAndroidJniObject::callStaticMethod<void>("my/java/project/FooJavaClass", "foo", "(I)V", 100); // Output: 100 >= 100 -} - -//! [Registering native methods] - -//! [Java native methods] -class FooJavaClass -{ - public static void foo(int x) - { - if (x < 100) - callNativeOne(x); - else - callNativeTwo(x); - } - -private static native void callNativeOne(int x); -private static native void callNativeTwo(int x); - -} -//! [Java native methods] diff --git a/src/androidextras/doc/src/external-resources.qdoc b/src/androidextras/doc/src/external-resources.qdoc deleted file mode 100644 index b27f97b..0000000 --- a/src/androidextras/doc/src/external-resources.qdoc +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtAndroidExtras module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \externalpage https://developer.android.com/reference/android/app/Service#onStartCommand(android.content.Intent,%20int,%20int) - \title Android: Service onStartCommand -*/ - -/*! - \externalpage https://developer.android.com/reference/android/content/Context#startService(android.content.Intent) - \title Android: Service startService -*/ - -/*! - \externalpage https://developer.android.com/reference/android/content/BroadcastReceiver - \title Android: BroadcastReceiver -*/ diff --git a/src/androidextras/doc/src/qtandroidextras-examples.qdoc b/src/androidextras/doc/src/qtandroidextras-examples.qdoc deleted file mode 100644 index 3daf5c9..0000000 --- a/src/androidextras/doc/src/qtandroidextras-examples.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ -/*! - \group examples-qtandroidextras - \title Qt Android Extras Examples - \brief Examples in the Qt Android Extras module. - \ingroup all-examples - - These are the examples available in the \l{Qt Android Extras} module. - - \note These examples will only work on Android. -*/ diff --git a/src/androidextras/doc/src/qtandroidextras-index.qdoc b/src/androidextras/doc/src/qtandroidextras-index.qdoc deleted file mode 100644 index 708df6d..0000000 --- a/src/androidextras/doc/src/qtandroidextras-index.qdoc +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qtandroidextras-index.html - \title Qt Android Extras - - \brief The Qt Android Extras module contains adittional functionality to aid development on Android. - - \section1 Getting Started - - To include the definitions of the module's classes, use the - following directive: - - \code - #include <QtAndroidExtras> - \endcode - - To link against the Qt Android Extras module, add this line to your project file: - - \code - QT += androidextras - \endcode - - \section1 API Reference - - Links to the API reference materials: - \list - \li \l{Qt Android Extras C++ Classes}{C++ Classes and Namespaces} - \endlist - - \section1 Examples - - \list - \li \l{Qt Android Extras Examples} - \endlist -*/ diff --git a/src/androidextras/doc/src/qtandroidextras-module.qdoc b/src/androidextras/doc/src/qtandroidextras-module.qdoc deleted file mode 100644 index 335d39d..0000000 --- a/src/androidextras/doc/src/qtandroidextras-module.qdoc +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \module QtAndroidExtras - \title Qt Android Extras C++ Classes - \brief The Qt Android Extras module contains additional functionality for development on Android. - - \ingroup modules - \qtcmakepackage AndroidExtras - \qtvariable androidextras - - To include the definitions of the module's classes, use the - following directive: - - \code - #include <QtAndroidExtras> - \endcode - - To link against the Qt Android Extras module, add this line to your project file: - - \code - QT += androidextras - \endcode -*/ diff --git a/src/androidextras/jni/qandroidjnienvironment.cpp b/src/androidextras/jni/qandroidjnienvironment.cpp deleted file mode 100644 index 70fd3e0..0000000 --- a/src/androidextras/jni/qandroidjnienvironment.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidjnienvironment.h" -#include <QtCore/private/qjni_p.h> -#include <QtCore/private/qjnihelpers_p.h> -#include <QtCore/qthreadstorage.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QAndroidJniEnvironment - \inmodule QtAndroidExtras - \brief The QAndroidJniEnvironment provides access to the JNI Environment. - \since 5.2 -*/ - -/*! - \fn QAndroidJniEnvironment::QAndroidJniEnvironment() - - Constructs a new QAndroidJniEnvironment object and attach the current thread to the Java VM. - - \snippet code/src_androidextras_qandroidjnienvironment.cpp Create QAndroidJniEnvironment -*/ - -/*! - \fn QAndroidJniEnvironment::~QAndroidJniEnvironment() - - Detaches the current thread from the Java VM and destroys the QAndroidJniEnvironment object. -*/ - -/*! - \fn JavaVM *QAndroidJniEnvironment::javaVM() - - Returns the Java VM interface. -*/ - -/*! - \fn JNIEnv *QAndroidJniEnvironment::operator->() - - Provides access to the QAndroidJniEnvironment's JNIEnv pointer. -*/ - -/*! - \fn QAndroidJniEnvironment::operator JNIEnv *() const - - Returns the JNI Environment pointer. - */ - -/*! - \fn jclass QAndroidJniEnvironment::findClass(const char *className) - - Searches for \a className using all available class loaders. Qt on Android - uses a custom class loader to load all the .jar files and it must be used - to find any classes that are created by that class loader because these - classes are not visible in the default class loader. - - Returns the class pointer or null if is not found. - - A use case for this function is searching for a custom class then calling - its memeber method. The following code snippet create an instance of the - class \c CustomClass and then calls \c printFromJava() method: - - \code - QAndroidJniEnvironment env; - jclass javaClass = env.findClass("org/qtproject/example/qtandroidextras/CustomClass"); - QAndroidJniObject classObject(javaClass); - - QAndroidJniObject javaMessage = QAndroidJniObject::fromString("findClass example"); - classObject.callMethod<void>("printFromJava", - "(Ljava/lang/String;)V", - javaMessage.object<jstring>()); - \endcode - - \since Qt 5.12 - */ - - -QAndroidJniEnvironment::QAndroidJniEnvironment() - : d(new QJNIEnvironmentPrivate) -{ -} - -QAndroidJniEnvironment::~QAndroidJniEnvironment() -{ -} - -JavaVM *QAndroidJniEnvironment::javaVM() -{ - return QtAndroidPrivate::javaVM(); -} - -JNIEnv *QAndroidJniEnvironment::operator->() -{ - return d->jniEnv; -} - -QAndroidJniEnvironment::operator JNIEnv*() const -{ - return d->jniEnv; -} - -jclass QAndroidJniEnvironment::findClass(const char *className) -{ - return QJNIEnvironmentPrivate::findClass(className, d->jniEnv); -} - -static void clearException(bool silent) -{ - QAndroidJniEnvironment env; - if (Q_UNLIKELY(env->ExceptionCheck())) { - if (!silent) - env->ExceptionDescribe(); - env->ExceptionClear(); - } -} - -/*! - \class QAndroidJniExceptionCleaner - \inmodule QtAndroidExtras - \brief Cleans pending JNI exceptions. - - The QAndroidJniExceptionCleaner is a convenience class useful to clean - the pending JNI exceptions from the current scope. - - \since 5.10 -*/ - -/*! - \enum QAndroidJniExceptionCleaner::OutputMode - - \value Silent the exceptions are cleaned silently - \value Verbose discribes the exceptions before cleaning them -*/ - -/*! - \fn QAndroidJniExceptionCleaner::QAndroidJniExceptionCleaner(OutputMode outputMode = OutputMode::Silent) - - Cleans any pending exceptions either silently or with descriptions, depending on the \a outputMode. - */ -QAndroidJniExceptionCleaner::QAndroidJniExceptionCleaner(QAndroidJniExceptionCleaner::OutputMode outputMode) - : m_outputMode(outputMode) -{ - clearException(outputMode == OutputMode::Silent); -} - -/*! - \fn QAndroidJniExceptionCleaner::~QAndroidJniExceptionCleaner() - - Clean any pending exceptions. - */ -QAndroidJniExceptionCleaner::~QAndroidJniExceptionCleaner() -{ - clearException(m_outputMode == OutputMode::Silent); -} - -/*! - \fn void QAndroidJniExceptionCleaner::clean() - - Manually cleans any pending exceptions - */ -void QAndroidJniExceptionCleaner::clean() -{ - clearException(m_outputMode == OutputMode::Silent); -} - -QT_END_NAMESPACE diff --git a/src/androidextras/jni/qandroidjnienvironment.h b/src/androidextras/jni/qandroidjnienvironment.h deleted file mode 100644 index 46d443d..0000000 --- a/src/androidextras/jni/qandroidjnienvironment.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDJNIENVIRONMENT_H -#define QANDROIDJNIENVIRONMENT_H - -#include <jni.h> -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QtCore/qglobal.h> -#include <QtCore/qscopedpointer.h> - -QT_BEGIN_NAMESPACE - -class QJNIEnvironmentPrivate; - -class Q_ANDROIDEXTRAS_EXPORT QAndroidJniEnvironment -{ -public: - QAndroidJniEnvironment(); - ~QAndroidJniEnvironment(); - static JavaVM *javaVM(); - JNIEnv *operator->(); - operator JNIEnv*() const; - jclass findClass(const char *className); - -private: - Q_DISABLE_COPY(QAndroidJniEnvironment) - QScopedPointer<QJNIEnvironmentPrivate> d; -}; - -class Q_ANDROIDEXTRAS_EXPORT QAndroidJniExceptionCleaner -{ -public: - enum class OutputMode { - Silent, - Verbose - }; - -public: - explicit QAndroidJniExceptionCleaner(OutputMode outputMode = OutputMode::Silent); - ~QAndroidJniExceptionCleaner(); - - void clean(); -private: - OutputMode m_outputMode; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDJNIENVIRONMENT_H diff --git a/src/androidextras/jni/qandroidjniobject.cpp b/src/androidextras/jni/qandroidjniobject.cpp deleted file mode 100644 index 4f00494..0000000 --- a/src/androidextras/jni/qandroidjniobject.cpp +++ /dev/null @@ -1,2507 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qandroidjniobject.h" -#include <QtCore/private/qjni_p.h> -#include <QtCore/qhash.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QAndroidJniObject - \inmodule QtAndroidExtras - \brief Provides APIs to call Java code from C++. - \since 5.2 - - \sa QAndroidJniEnvironment - - \section1 General Notes - - \list - \li Class names needs to contain the fully-qualified class name, for example: \b"java/lang/String". - \li Method signatures are written as \b"(Arguments)ReturnType" - \li All object types are returned as a QAndroidJniObject. - \endlist - - \section1 Method Signatures - - For functions that take no arguments, QAndroidJniObject provides convenience functions that will use - the correct signature based on the provided template type. For example: - - \code - jint x = QAndroidJniObject::callMethod<jint>("getSize"); - QAndroidJniObject::callMethod<void>("touch"); - \endcode - - In other cases you will need to supply the signature yourself, and it is important that the - signature matches the function you want to call. The signature structure is \b \(A\)R, where \b A - is the type of the argument\(s\) and \b R is the return type. Array types in the signature must - have the \b\[ suffix and the fully-qualified type names must have the \b L prefix and \b ; suffix. - - The example below demonstrates how to call two different static functions. - \code - // Java class - package org.qtproject.qt; - class TestClass - { - static String fromNumber(int x) { ... } - static String[] stringArray(String s1, String s2) { ... } - } - \endcode - - The signature for the first function is \b"\(I\)Ljava/lang/String;" - - \code - // C++ code - QAndroidJniObject stringNumber = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass", - "fromNumber" - "(I)Ljava/lang/String;", - 10); - \endcode - - and the signature for the second function is \b"\(Ljava/lang/String;Ljava/lang/String;\)\[Ljava/lang/String;" - - \code - // C++ code - QAndroidJniObject string1 = QAndroidJniObject::fromString("String1"); - QAndroidJniObject string2 = QAndroidJniObject::fromString("String2"); - QAndroidJniObject stringArray = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass", - "stringArray" - "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;" - string1.object<jstring>(), - string2.object<jstring>()); - \endcode - - - \section1 Handling Java Exception - - When calling Java functions that might throw an exception, it is important that you check, handle - and clear out the exception before continuing. - - \note It is unsafe to make a JNI call when there are exceptions pending. - - \snippet code/src_androidextras_qandroidjniobject.cpp Check for exceptions - - \section1 Java Native Methods - - Java native methods makes it possible to call native code from Java, this is done by creating a - function declaration in Java and prefixing it with the \b native keyword. - Before a native function can be called from Java, you need to map the Java native function to a - native function in your code. Mapping functions can be done by calling the RegisterNatives() function - through the \l{QAndroidJniEnvironment}{JNI environment pointer}. - - The example below demonstrates how this could be done. - - Java implementation: - \snippet code/src_androidextras_qandroidjniobject.cpp Java native methods - - C++ Implementation: - \snippet code/src_androidextras_qandroidjniobject.cpp Registering native methods - - \section1 The Lifetime of a Java Object - - Most \l{Object types}{objects} received from Java will be local references and will only stay valid - in the scope you received them. After that, the object becomes eligible for garbage collection. If you - want to keep a Java object alive you need to either create a new global reference to the object and - release it when you are done, or construct a new QAndroidJniObject and let it manage the lifetime of the Java object. - \sa object() - - \note The QAndroidJniObject does only manage its own references, if you construct a QAndroidJniObject from a - global or local reference that reference will not be released by the QAndroidJniObject. - - \section1 JNI Types - - \section2 Object Types - \table - \header - \li Type - \li Signature - \row - \li jobject - \li Ljava/lang/Object; - \row - \li jclass - \li Ljava/lang/Class; - \row - \li jstring - \li Ljava/lang/String; - \row - \li jthrowable - \li Ljava/lang/Throwable; - \row - \li jobjectArray - \li [Ljava/lang/Object; - \row - \li jarray - \li [\e<type> - \row - \li jbooleanArray - \li [Z - \row - \li jbyteArray - \li [B - \row - \li jcharArray - \li [C - \row - \li jshortArray - \li [S - \row - \li jintArray - \li [I - \row - \li jlongArray - \li [J - \row - \li jfloatArray - \li [F - \row - \li jdoubleArray - \li [D - \endtable - - - \section2 Primitive Types - \table - \header - \li Type - \li Signature - \row - \li jboolean - \li Z - \row - \li jbyte - \li B - \row - \li jchar - \li C - \row - \li jshort - \li S - \row - \li jint - \li I - \row - \li jlong - \li J - \row - \li jfloat - \li F - \row - \li jdouble - \li D - \endtable - - \section3 Other - \table - \header - \li Type - \li Signature - \row - \li void - \li V - \row - \li \e{Custom type} - \li L\e<fully-qualified-name>; - \endtable - - For more information about JNI see: \l http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/jniTOC.html -*/ - -/*! - \fn QAndroidJniObject::QAndroidJniObject() - - Constructs an invalid QAndroidJniObject. - - \sa isValid() -*/ - -/*! - \fn QAndroidJniObject::QAndroidJniObject(const char *className) - - Constructs a new QAndroidJniObject by calling the default constructor of \a className. - - \code - - ... - QAndroidJniObject myJavaString("java/lang/String"); - ... - - \endcode -*/ - -/*! - \fn QAndroidJniObject::QAndroidJniObject(const char *className, const char *signature, ...) - - Constructs a new QAndroidJniObject by calling the constructor of \a className with \a signature - and arguments. - - \code - - ... - jstring myJStringArg = ...; - QAndroidJniObject myNewJavaString("java/lang/String", "(Ljava/lang/String;)V", myJStringArg); - ... - - \endcode -*/ - -/*! - \fn QAndroidJniObject::QAndroidJniObject(jclass clazz) - - Constructs a new QAndroidJniObject by calling the default constructor of \a clazz. - - Note: The QAndroidJniObject will create a new reference to the class \a clazz - and releases it again when it is destroyed. References to the class created - outside the QAndroidJniObject needs to be managed by the caller. - -*/ - -/*! - \fn QAndroidJniObject::QAndroidJniObject(jclass clazz, const char *signature, ...) - - Constructs a new QAndroidJniObject from \a clazz by calling the constructor with \a signature - and arguments. - - \code - jclass myClazz = ...; - QAndroidJniObject::QAndroidJniObject(myClazz, "(I)V", 3); - \endcode -*/ - -/*! - \fn QAndroidJniObject::QAndroidJniObject(jobject object) - - Constructs a new QAndroidJniObject around the Java object \a object. - - Note: The QAndroidJniObject will hold a reference to the Java object \a object - and release it when destroyed. Any references to the Java object \a object - outside QAndroidJniObject needs to be managed by the caller. - - \sa fromLocalRef() -*/ - -/*! - Destroys the QAndroidJniObject and releases any references held by the QAndroidJniObject. -*/ -QAndroidJniObject::~QAndroidJniObject() -{ - // must be empty until ### Qt 6 -} - -/*! - \fn template <typename T> T QAndroidJniObject::callMethod(const char *methodName, const char *sig, ...) const - - Calls the method \a methodName with a signature \a sig and returns the value. - - \code - QAndroidJniObject myJavaString = ...; - jint index = myJavaString.callMethod<jint>("indexOf", "(I)I", 0x0051); - \endcode - -*/ - -/*! - \fn template <typename T> T QAndroidJniObject::callMethod(const char *methodName) const - - Calls the method \a methodName and returns the value. - - \code - QAndroidJniObject myJavaString = ...; - jint size = myJavaString.callMethod<jint>("length"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::callObjectMethod(const char *methodName) const - - Calls the Java objects method \a methodName and returns a new QAndroidJniObject for - the returned Java object. - - \code - ... - QAndroidJniObject myJavaString1 = ...; - QAndroidJniObject myJavaString2 = myJavaString1.callObjectMethod<jstring>("toString"); - ... - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::callObjectMethod(const char *methodName, const char *signature, ...) const - - Calls the Java object's method \a methodName with the signature \a signature and arguments - - \code - QAndroidJniObject myJavaString; ==> "Hello, Java" - QAndroidJniObject mySubstring = myJavaString.callObjectMethod("substring", "(II)Ljava/lang/String;", 7, 10); - \endcode -*/ - -/*! - \fn template <typename T> T QAndroidJniObject::callStaticMethod(jclass clazz, const char *methodName) - - Calls the static method \a methodName on \a clazz and returns the value. - - \code - ... - jclass javaMathClass = ...; // ("java/lang/Math") - jdouble randNr = QAndroidJniObject::callStaticMethod<jdouble>(javaMathClass, "random"); - ... - \endcode -*/ - -/*! - \fn template <typename T> T QAndroidJniObject::callStaticMethod(const char *className, const char *methodName) - - Calls the static method \a methodName on class \a className and returns the value. - - \code - jint value = QAndroidJniObject::callStaticMethod<jint>("MyClass", "staticMethod"); - \endcode -*/ - -/*! - \fn template <typename T> T QAndroidJniObject::callStaticMethod(const char *className, const char *methodName, const char *signature, ...) - - Calls the static method with \a methodName with \a signature on class \a className with optional arguments. - - \code - ... - jint a = 2; - jint b = 4; - jint max = QAndroidJniObject::callStaticMethod<jint>("java/lang/Math", "max", "(II)I", a, b); - ... - \endcode -*/ - -/*! - \fn template <typename T> T QAndroidJniObject::callStaticMethod(jclass clazz, const char *methodName, const char *signature, ...) - - Calls the static method \a methodName with \a signature on \a clazz and returns the value. - - \code - ... - jclass javaMathClass = ...; // ("java/lang/Math") - jint a = 2; - jint b = 4; - jint max = QAndroidJniObject::callStaticMethod<jint>(javaMathClass, "max", "(II)I", a, b); - ... - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(const char *className, const char *methodName) - - Calls the static method with \a methodName on the class \a className. - - \code - QAndroidJniObject string = QAndroidJniObject::callStaticObjectMethod<jstring>("CustomClass", "getClassName"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(const char *className, const char *methodName, const char *signature, ...) - - Calls the static method with \a methodName and \a signature on the class \a className. - - \code - QAndroidJniObject thread = QAndroidJniObject::callStaticObjectMethod("java/lang/Thread", "currentThread", "()Ljava/lang/Thread;"); - QAndroidJniObject string = QAndroidJniObject::callStaticObjectMethod("java/lang/String", "valueOf", "(I)Ljava/lang/String;", 10); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(jclass clazz, const char *methodName) - - Calls the static method with \a methodName on \a clazz. - -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(jclass clazz, const char *methodName, const char *signature, ...) - - Calls the static method with \a methodName and \a signature on class \a clazz. -*/ - -/*! - \fn T QAndroidJniObject::getField(const char *fieldName) const - - Retrieves the value of the field \a fieldName. - - \code - QAndroidJniObject volumeControl = ...; - jint fieldValue = volumeControl.getField<jint>("MAX_VOLUME"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::getObjectField(const char *fieldName) const - - Retrieves the object of field \a fieldName. - - \code - QAndroidJniObject field = jniObject.getObjectField<jstring>("FIELD_NAME"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::getObjectField(const char *fieldName, const char *signature) const - - Retrieves the object from the field with \a signature and \a fieldName. - - \note Since \b{Qt 5.3} this function can be used without a template type. - - \code - QAndroidJniObject field = jniObject.getObjectField("FIELD_NAME", "Ljava/lang/String;"); - \endcode -*/ - -/*! - \fn T QAndroidJniObject::getStaticField(const char *className, const char *fieldName) - - Retrieves the value from the static field \a fieldName on the class \a className. -*/ - -/*! - \fn T QAndroidJniObject::getStaticField(jclass clazz, const char *fieldName) - - Retrieves the value from the static field \a fieldName on \a clazz. -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::getStaticObjectField(const char *className, const char *fieldName) - - Retrieves the object from the field \a fieldName on the class \a className. - - \code - QAndroidJniObject jobj = QAndroidJniObject::getStaticObjectField<jstring>("class/with/Fields", "FIELD_NAME"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::getStaticObjectField(const char *className, const char *fieldName, const char *signature) - Retrieves the object from the field with \a signature and \a fieldName on class \a className. - - \note Since \b{Qt 5.3} this function can be used without a template type. - - \code - QAndroidJniObject jobj = QAndroidJniObject::getStaticObjectField("class/with/Fields", "FIELD_NAME", "Ljava/lang/String;"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::getStaticObjectField(jclass clazz, const char *fieldName) - - Retrieves the object from the field \a fieldName on \a clazz. - - \code - QAndroidJniObject jobj = QAndroidJniObject::getStaticObjectField<jstring>(clazz, "FIELD_NAME"); - \endcode -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::getStaticObjectField(jclass clazz, const char *fieldName, const char *signature) - Retrieves the object from the field with \a signature and \a fieldName on \a clazz. - - \note Since \b{Qt 5.3} this function can be used without a template type. - - \code - QAndroidJniObject jobj = QAndroidJniObject::getStaticObjectField(clazz, "FIELD_NAME", "Ljava/lang/String;"); - \endcode -*/ - -/*! - \fn template <typename T> void QAndroidJniObject::setField(const char *fieldName, T value) - - Sets the value of \a fieldName to \a value. - - \code - ... - QAndroidJniObject obj; - obj.setField<jint>("AN_INT_FIELD", 10); - jstring myString = ... - obj.setField<jstring>("A_STRING_FIELD", myString); - ... - \endcode -*/ - -/*! - \fn template <typename T> void QAndroidJniObject::setField(const char *fieldName, const char *signature, T value) - - Sets the value of \a fieldName with \a signature to \a value. - - \code - QAndroidJniObject stringArray = ...; - QAndroidJniObject obj = ...; - obj.setField<jobjectArray>("KEY_VALUES", "([Ljava/lang/String;)V", stringArray.object<jobjectArray>()) - \endcode -*/ - -/*! - \fn template <typename T> void QAndroidJniObject::setStaticField(const char *className, const char *fieldName, T value) - - Sets the value of the static field \a fieldName in class \a className to \a value. -*/ - -/*! - \fn template <typename T> void QAndroidJniObject::setStaticField(const char *className, const char *fieldName, const char *signature, T value); - - Sets the static field with \a fieldName and \a signature to \a value on class \a className. -*/ - -/*! - \fn template <typename T> void QAndroidJniObject::setStaticField(jclass clazz, const char *fieldName, T value) - - Sets the static field \a fieldName of the class \a clazz to \a value. -*/ - -/*! - \fn template <typename T> void QAndroidJniObject::setStaticField(jclass clazz, const char *fieldName, const char *signature, T value); - - Sets the static field with \a fieldName and \a signature to \a value on class \a clazz. -*/ - -/*! - \fn bool QAndroidJniObject::isClassAvailable(const char *className) - - Returns true if the Java class \a className is available. - - \code - ... - if (QAndroidJniObject::isClassAvailable("java/lang/String")) { - ... - } - ... - \endcode -*/ - -/*! - \fn bool QAndroidJniObject::isValid() const - - Returns true if this instance holds a valid Java object. - - \code - ... - QAndroidJniObject qjniObject; ==> isValid() == false - QAndroidJniObject qjniObject(0) ==> isValid() == false - QAndroidJniObject qjniObject("could/not/find/Class") ==> isValid() == false - ... - \endcode -*/ - -/*! - \fn template <typename T> T QAndroidJniObject::object() const - - Returns the object held by the QAndroidJniObject as type T. - - \code - QAndroidJniObject string = QAndroidJniObject::fromString("Hello, JNI"); - jstring jstring = string.object<jstring>(); - \endcode - - \note The returned object is still owned by the QAndroidJniObject. If you want to keep the object valid - you should create a new QAndroidJniObject or make a new global reference to the object and - free it yourself. - - \snippet code/src_androidextras_qandroidjniobject.cpp QAndroidJniObject scope - - \note Since \b{Qt 5.3} this function can be used without a template type, if the returned type - is a \c jobject. - - \code - jobject object = jniObject.object(); - \endcode -*/ - -/*! - \fn template <typename T> QAndroidJniObject &QAndroidJniObject::operator=(T object) - - Replace the current object with \a object. The old Java object will be released. -*/ - -/*! - \fn QString QAndroidJniObject::toString() const - - Returns a QString with a string representation of the java object. - Calling this function on a Java String object is a convenient way of getting the actual string - data. - - \code - QAndroidJniObject string = ...; // "Hello Java" - QString qstring = string.toString(); // "Hello Java" - \endcode - - \sa fromString() -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::fromString(const QString &string) - - Creates a Java string from the QString \a string and returns a QAndroidJniObject holding that string. - - \code - ... - QString myQString = "QString"; - QAndroidJniObject myJavaString = QAndroidJniObject::fromString(myQString); - ... - \endcode - - \sa toString() -*/ - -/*! - \fn QAndroidJniObject QAndroidJniObject::fromLocalRef(jobject localRef) - \since 5.7 - - Creates a QAndroidJniObject from the local JNI reference \a localRef. - This function takes ownership of \a localRef and frees it before returning. - - \note Only call this function with a local JNI reference. For example, most raw JNI calls, through - the JNI environment, returns local references to a java object. - - \code - jobject localRef = env->GetObjectArrayElement(array, index); - QAndroidJniObject element = QAndroidJniObject::fromLocalRef(localRef); - \endcode -*/ - -/*! - \fn bool operator==(const QAndroidJniObject &o1, const QAndroidJniObject &o2) - \relates QAndroidJniObject - - Returns true if both objects, \a o1 and \a o2, are referencing the same Java object, or if both - are NULL. In any other cases false will be returned. -*/ - -/*! - \fn bool operator!=(const QAndroidJniObject &o1, const QAndroidJniObject &o2) - \relates QAndroidJniObject - - Returns true if \a o1 holds a reference to a different object then \a o2. -*/ - - -QAndroidJniObject::QAndroidJniObject(const char *className, const char *sig, ...) -{ - va_list args; - QJNIObjectPrivate::QVaListPrivate vargs = { args }; - va_start(args, sig); - d = QSharedPointer<QJNIObjectPrivate>(new QJNIObjectPrivate(className, sig, vargs)); - va_end(args); -} - -QAndroidJniObject::QAndroidJniObject(jclass clazz, const char *sig, ...) -{ - va_list args; - QJNIObjectPrivate::QVaListPrivate vargs = { args }; - va_start(args, sig); - d = QSharedPointer<QJNIObjectPrivate>(new QJNIObjectPrivate(clazz, sig, vargs)); - va_end(args); -} - - -QAndroidJniObject::QAndroidJniObject() : d(new QJNIObjectPrivate) -{ - -} - -QAndroidJniObject::QAndroidJniObject(const char *className) : d(new QJNIObjectPrivate(className)) -{ -} - -QAndroidJniObject::QAndroidJniObject(jclass clazz) : d(new QJNIObjectPrivate(clazz)) -{ -} - -QAndroidJniObject::QAndroidJniObject(jobject obj) : d(new QJNIObjectPrivate(obj)) -{ -} - -QAndroidJniObject::QAndroidJniObject(const QJNIObjectPrivate &o) : d(new QJNIObjectPrivate(o)) -{ - -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::callMethod<void>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - d->callMethodV<void>(methodName, sig, args); - va_end(args); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::callMethod<jboolean>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jboolean res = d->callMethodV<jboolean>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::callMethod<jbyte>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jbyte res = d->callMethodV<jbyte>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::callMethod<jchar>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jchar res = d->callMethodV<jchar>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::callMethod<jshort>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jshort res = d->callMethodV<jshort>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::callMethod<jint>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jint res = d->callMethodV<jint>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::callMethod<jlong>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jlong res = d->callMethodV<jlong>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::callMethod<jfloat>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jfloat res = d->callMethodV<jfloat>(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::callMethod<jdouble>(const char *methodName, const char *sig, ...) const -{ - va_list args; - va_start(args, sig); - jdouble res = d->callMethodV<jdouble>(methodName, sig, args); - va_end(args); - return res; -} - -QAndroidJniObject QAndroidJniObject::callObjectMethod(const char *methodName, - const char *sig, - ...) const -{ - va_list args; - va_start(args, sig); - QJNIObjectPrivate res = d->callObjectMethodV(methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::callMethod<void>(const char *methodName) const -{ - callMethod<void>(methodName, "()V"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::callMethod<jboolean>(const char *methodName) const -{ - return callMethod<jboolean>(methodName, "()Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::callMethod<jbyte>(const char *methodName) const -{ - return callMethod<jbyte>(methodName, "()B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::callMethod<jchar>(const char *methodName) const -{ - return callMethod<jchar>(methodName, "()C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::callMethod<jshort>(const char *methodName) const -{ - return callMethod<jshort>(methodName, "()S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::callMethod<jint>(const char *methodName) const -{ - return callMethod<jint>(methodName, "()I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::callMethod<jlong>(const char *methodName) const -{ - return callMethod<jlong>(methodName, "()J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::callMethod<jfloat>(const char *methodName) const -{ - return callMethod<jfloat>(methodName, "()F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::callMethod<jdouble>(const char *methodName) const -{ - return callMethod<jdouble>(methodName, "()D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jobject>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jclass>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()Ljava/lang/Class;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jstring>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()Ljava/lang/String;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jobjectArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jbooleanArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jbyteArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jcharArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jshortArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jintArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jlongArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jfloatArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jdoubleArray>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()[D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callObjectMethod<jthrowable>(const char *methodName) const -{ - return d->callObjectMethod(methodName, "()Ljava/lang/Throwable;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::callStaticMethod<void>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - QJNIObjectPrivate::callStaticMethodV<void>(className, methodName, sig, args); - va_end(args); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::callStaticMethod<void>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - QJNIObjectPrivate::callStaticMethodV<void>(clazz, methodName, sig, args); - va_end(args); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::callStaticMethod<jboolean>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jboolean res = QJNIObjectPrivate::callStaticMethodV<jboolean>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::callStaticMethod<jboolean>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jboolean res = QJNIObjectPrivate::callStaticMethodV<jboolean>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::callStaticMethod<jbyte>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jbyte res = QJNIObjectPrivate::callStaticMethodV<jbyte>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::callStaticMethod<jbyte>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jbyte res = QJNIObjectPrivate::callStaticMethodV<jbyte>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::callStaticMethod<jchar>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jchar res = QJNIObjectPrivate::callStaticMethodV<jchar>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::callStaticMethod<jchar>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jchar res = QJNIObjectPrivate::callStaticMethodV<jchar>(clazz, methodName, sig, args); - va_end(args); - return res; -} - - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::callStaticMethod<jshort>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jshort res = QJNIObjectPrivate::callStaticMethodV<jshort>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::callStaticMethod<jshort>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jshort res = QJNIObjectPrivate::callStaticMethodV<jshort>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::callStaticMethod<jint>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jint res = QJNIObjectPrivate::callStaticMethodV<jint>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::callStaticMethod<jint>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jint res = QJNIObjectPrivate::callStaticMethodV<jint>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::callStaticMethod<jlong>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jlong res = QJNIObjectPrivate::callStaticMethodV<jlong>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::callStaticMethod<jlong>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jlong res = QJNIObjectPrivate::callStaticMethodV<jlong>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::callStaticMethod<jfloat>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jfloat res = QJNIObjectPrivate::callStaticMethodV<jfloat>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::callStaticMethod<jfloat>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jfloat res = QJNIObjectPrivate::callStaticMethodV<jfloat>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::callStaticMethod<jdouble>(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jdouble res = QJNIObjectPrivate::callStaticMethodV<jdouble>(className, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::callStaticMethod<jdouble>(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - jdouble res = QJNIObjectPrivate::callStaticMethodV<jdouble>(clazz, methodName, sig, args); - va_end(args); - return res; -} - -QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(const char *className, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - QJNIObjectPrivate res = QJNIObjectPrivate::callStaticObjectMethodV(className, - methodName, - sig, - args); - va_end(args); - return res; -} - -QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(jclass clazz, - const char *methodName, - const char *sig, - ...) -{ - va_list args; - va_start(args, sig); - QJNIObjectPrivate res = QJNIObjectPrivate::callStaticObjectMethodV(clazz, methodName, sig, args); - va_end(args); - return res; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::callStaticMethod<void>(const char *className, const char *methodName) -{ - callStaticMethod<void>(className, methodName, "()V"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::callStaticMethod<void>(jclass clazz, const char *methodName) -{ - callStaticMethod<void>(clazz, methodName, "()V"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::callStaticMethod<jboolean>(const char *className, const char *methodName) -{ - return callStaticMethod<jboolean>(className, methodName, "()Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::callStaticMethod<jboolean>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jboolean>(clazz, methodName, "()Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::callStaticMethod<jbyte>(const char *className, const char *methodName) -{ - return callStaticMethod<jbyte>(className, methodName, "()B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::callStaticMethod<jbyte>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jbyte>(clazz, methodName, "()B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::callStaticMethod<jchar>(const char *className, const char *methodName) -{ - return callStaticMethod<jchar>(className, methodName, "()C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::callStaticMethod<jchar>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jchar>(clazz, methodName, "()C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::callStaticMethod<jshort>(const char *className, const char *methodName) -{ - return callStaticMethod<jshort>(className, methodName, "()S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::callStaticMethod<jshort>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jshort>(clazz, methodName, "()S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::callStaticMethod<jint>(const char *className, const char *methodName) -{ - return callStaticMethod<jint>(className, methodName, "()I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::callStaticMethod<jint>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jint>(clazz, methodName, "()I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::callStaticMethod<jlong>(const char *className, const char *methodName) -{ - return callStaticMethod<jlong>(className, methodName, "()J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::callStaticMethod<jlong>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jlong>(clazz, methodName, "()J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::callStaticMethod<jfloat>(const char *className, const char *methodName) -{ - return callStaticMethod<jfloat>(className, methodName, "()F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::callStaticMethod<jfloat>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jfloat>(clazz, methodName, "()F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::callStaticMethod<jdouble>(const char *className, const char *methodName) -{ - return callStaticMethod<jdouble>(className, methodName, "()D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::callStaticMethod<jdouble>(jclass clazz, const char *methodName) -{ - return callStaticMethod<jdouble>(clazz, methodName, "()D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jobject>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jobject>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jclass>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()Ljava/lang/Class;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jclass>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()Ljava/lang/Class;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jstring>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()Ljava/lang/String;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jstring>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()Ljava/lang/String;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jobjectArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jobjectArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jbooleanArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jbooleanArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jbyteArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jbyteArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jcharArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jcharArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jshortArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jshortArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jintArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jintArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jlongArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jlongArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jfloatArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jfloatArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jdoubleArray>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()[D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jdoubleArray>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()[D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jthrowable>(const char *className, - const char *methodName) -{ - return callStaticObjectMethod(className, methodName, "()Ljava/lang/Throwable;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::callStaticObjectMethod<jthrowable>(jclass clazz, - const char *methodName) -{ - return callStaticObjectMethod(clazz, methodName, "()Ljava/lang/Throwable;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::getField<jboolean>(const char *fieldName) const -{ - return d->getField<jboolean>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::getField<jbyte>(const char *fieldName) const -{ - return d->getField<jbyte>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::getField<jchar>(const char *fieldName) const -{ - return d->getField<jchar>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::getField<jshort>(const char *fieldName) const -{ - return d->getField<jshort>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::getField<jint>(const char *fieldName) const -{ - return d->getField<jint>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::getField<jlong>(const char *fieldName) const -{ - return d->getField<jlong>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::getField<jfloat>(const char *fieldName) const -{ - return d->getField<jfloat>(fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::getField<jdouble>(const char *fieldName) const -{ - return d->getField<jdouble>(fieldName); -} - -QAndroidJniObject QAndroidJniObject::getObjectField(const char *fieldName, const char *sig) const -{ - return d->getObjectField(fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jobject>(const char *fieldName, const char *sig) const -{ - return d->getObjectField(fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jobject>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jclass>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "Ljava/lang/Class;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jbooleanArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jbyteArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jcharArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jshortArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jintArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jlongArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jfloatArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jdoubleArray>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "[D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jstring>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "Ljava/lang/String;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jthrowable>(const char *fieldName) const -{ - return d->getObjectField(fieldName, "Ljava/lang/Throwable;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getObjectField<jobjectArray>(const char *fieldName, - const char *sig) const -{ - return d->getObjectField(fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jboolean>(const char *fieldName, jboolean value) -{ - d->setField<jboolean>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jbyte>(const char *fieldName, jbyte value) -{ - d->setField<jbyte>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jchar>(const char *fieldName, jchar value) -{ - d->setField<jchar>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jshort>(const char *fieldName, jshort value) -{ - d->setField<jshort>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jint>(const char *fieldName, jint value) -{ - d->setField<jint>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jlong>(const char *fieldName, jlong value) -{ - d->setField<jlong>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jfloat>(const char *fieldName, jfloat value) -{ - d->setField<jfloat>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jdouble>(const char *fieldName, jdouble value) -{ - d->setField<jdouble>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jobject>(const char *fieldName, - const char *sig, - jobject value) -{ - d->setField<jobject>(fieldName, sig, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jobjectArray>(const char *fieldName, - const char *sig, - jobjectArray value) -{ - d->setField<jobjectArray>(fieldName, sig, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jobject>(const char *fieldName, - jobject value) -{ - setField<jobject>(fieldName, "Ljava/lang/Object;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jclass>(const char *fieldName, - jclass value) -{ - setField<jobject>(fieldName, "Ljava/lang/Class;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jstring>(const char *fieldName, jstring value) -{ - d->setField<jstring>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jbooleanArray>(const char *fieldName, jbooleanArray value) -{ - d->setField<jbooleanArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jbyteArray>(const char *fieldName, jbyteArray value) -{ - d->setField<jbyteArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jcharArray>(const char *fieldName, jcharArray value) -{ - d->setField<jcharArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jshortArray>(const char *fieldName, jshortArray value) -{ - d->setField<jshortArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jintArray>(const char *fieldName, jintArray value) -{ - d->setField<jintArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jlongArray>(const char *fieldName, jlongArray value) -{ - d->setField<jlongArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jfloatArray>(const char *fieldName, jfloatArray value) -{ - d->setField<jfloatArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jdoubleArray>(const char *fieldName, jdoubleArray value) -{ - d->setField<jdoubleArray>(fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setField<jthrowable>(const char *fieldName, jthrowable value) -{ - d->setField<jobject>(fieldName, "Ljava/lang/Throwable;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::getStaticField<jboolean>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jboolean>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jboolean QAndroidJniObject::getStaticField<jboolean>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jboolean>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::getStaticField<jbyte>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jbyte>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jbyte QAndroidJniObject::getStaticField<jbyte>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jbyte>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::getStaticField<jchar>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jchar>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jchar QAndroidJniObject::getStaticField<jchar>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jchar>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::getStaticField<jshort>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jshort>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jshort QAndroidJniObject::getStaticField<jshort>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jshort>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::getStaticField<jint>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jint>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jint QAndroidJniObject::getStaticField<jint>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jint>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::getStaticField<jlong>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jlong>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jlong QAndroidJniObject::getStaticField<jlong>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jlong>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::getStaticField<jfloat>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jfloat>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jfloat QAndroidJniObject::getStaticField<jfloat>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jfloat>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::getStaticField<jdouble>(jclass clazz, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jdouble>(clazz, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT jdouble QAndroidJniObject::getStaticField<jdouble>(const char *className, const char *fieldName) -{ - return QJNIObjectPrivate::getStaticField<jdouble>(className, fieldName); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobject>(jclass clazz, - const char *fieldName, - const char *sig) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, sig); -} - -QAndroidJniObject QAndroidJniObject::getStaticObjectField(jclass clazz, - const char *fieldName, - const char *sig) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, sig); -} - -QAndroidJniObject QAndroidJniObject::getStaticObjectField(const char *className, - const char *fieldName, - const char *sig) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobject>(const char *className, - const char *fieldName, - const char *sig) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobjectArray>(jclass clazz, - const char *fieldName, - const char *sig) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobjectArray>(const char *className, - const char *fieldName, - const char *sig) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, sig); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobject>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobject>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jclass>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "Ljava/lang/Class;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jclass>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "Ljava/lang/Class;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jstring>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "Ljava/lang/String;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jstring>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "Ljava/lang/String;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobjectArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jobjectArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[Ljava/lang/Object;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jbooleanArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jbooleanArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[Z"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jbyteArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[B"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jbyteArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[B");; -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jcharArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jcharArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[C"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jshortArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jshortArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[S"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jintArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jintArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[I"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jlongArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jlongArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[J"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jfloatArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jfloatArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[F"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jdoubleArray>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "[D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jdoubleArray>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "[D"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jthrowable>(jclass clazz, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(clazz, fieldName, "Ljava/lang/Throwable;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject QAndroidJniObject::getStaticObjectField<jthrowable>(const char *className, - const char *fieldName) -{ - return QJNIObjectPrivate::getStaticObjectField(className, fieldName, "Ljava/lang/Throwable;"); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jboolean>(jclass clazz, const char *fieldName, jboolean value) -{ - QJNIObjectPrivate::setStaticField<jboolean>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jboolean>(const char *className, - const char *fieldName, - jboolean value) -{ - QJNIObjectPrivate::setStaticField<jboolean>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jbyte>(jclass clazz, const char *fieldName, jbyte value) -{ - QJNIObjectPrivate::setStaticField<jbyte>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jbyte>(const char *className, - const char *fieldName, - jbyte value) -{ - QJNIObjectPrivate::setStaticField<jbyte>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jchar>(jclass clazz, const char *fieldName, jchar value) -{ - QJNIObjectPrivate::setStaticField<jchar>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jchar>(const char *className, - const char *fieldName, - jchar value) -{ - QJNIObjectPrivate::setStaticField<jchar>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jshort>(jclass clazz, const char *fieldName, jshort value) -{ - QJNIObjectPrivate::setStaticField<jshort>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jshort>(const char *className, - const char *fieldName, - jshort value) -{ - QJNIObjectPrivate::setStaticField<jshort>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jint>(jclass clazz, const char *fieldName, jint value) -{ - QJNIObjectPrivate::setStaticField<jint>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jint>(const char *className, const char *fieldName, jint value) -{ - QJNIObjectPrivate::setStaticField<jint>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jlong>(jclass clazz, const char *fieldName, jlong value) -{ - QJNIObjectPrivate::setStaticField<jlong>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jlong>(const char *className, - const char *fieldName, - jlong value) -{ - QJNIObjectPrivate::setStaticField<jlong>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jfloat>(jclass clazz, const char *fieldName, jfloat value) -{ - QJNIObjectPrivate::setStaticField<jfloat>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jfloat>(const char *className, - const char *fieldName, - jfloat value) -{ - QJNIObjectPrivate::setStaticField<jfloat>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jdouble>(jclass clazz, const char *fieldName, jdouble value) -{ - QJNIObjectPrivate::setStaticField<jdouble>(clazz, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jdouble>(const char *className, - const char *fieldName, - jdouble value) -{ - QJNIObjectPrivate::setStaticField<jdouble>(className, fieldName, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jobject>(jclass clazz, - const char *fieldName, - const char *sig, - jobject value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, sig, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jobject>(const char *className, - const char *fieldName, - const char *sig, - jobject value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, sig, value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jclass>(const char *className, - const char *fieldName, - jclass value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "Ljava/lang/Class;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jclass>(jclass clazz, const char *fieldName, jclass value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "Ljava/lang/Class;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jstring>(const char *className, - const char *fieldName, - jstring value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "Ljava/lang/String;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jstring>(jclass clazz, const char *fieldName, jstring value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "Ljava/lang/String;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jobjectArray>(const char *className, - const char *fieldName, - jobjectArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[Ljava/lang/Object;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jobjectArray>(jclass clazz, - const char *fieldName, - jobjectArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[Ljava/lang/Object;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jbooleanArray>(const char *className, - const char *fieldName, - jbooleanArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[Z", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jbooleanArray>(jclass clazz, - const char *fieldName, - jbooleanArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[Z", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jbyteArray>(const char *className, - const char *fieldName, - jbyteArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[B", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jbyteArray>(jclass clazz, - const char *fieldName, - jbyteArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[B", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jcharArray>(const char *className, - const char *fieldName, - jcharArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[C", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jcharArray>(jclass clazz, - const char *fieldName, - jcharArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[C", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jshortArray>(const char *className, - const char *fieldName, - jshortArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[S", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jshortArray>(jclass clazz, - const char *fieldName, - jshortArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[S", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jintArray>(const char *className, - const char *fieldName, - jintArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[I", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jintArray>(jclass clazz, - const char *fieldName, - jintArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[I", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jlongArray>(const char *className, - const char *fieldName, - jlongArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[J", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jlongArray>(jclass clazz, - const char *fieldName, - jlongArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[J", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jfloatArray>(const char *className, - const char *fieldName, - jfloatArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[F", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jfloatArray>(jclass clazz, - const char *fieldName, - jfloatArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[F", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jdoubleArray>(const char *className, - const char *fieldName, - jdoubleArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "[D", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jdoubleArray>(jclass clazz, - const char *fieldName, - jdoubleArray value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "[D", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jthrowable>(const char *className, - const char *fieldName, - jthrowable value) -{ - QJNIObjectPrivate::setStaticField<jobject>(className, fieldName, "Ljava/lang/Throwable;", value); -} - -template <> -Q_ANDROIDEXTRAS_EXPORT void QAndroidJniObject::setStaticField<jthrowable>(jclass clazz, - const char *fieldName, - jthrowable value) -{ - QJNIObjectPrivate::setStaticField<jobject>(clazz, fieldName, "Ljava/lang/Throwable;", value); -} - -QAndroidJniObject QAndroidJniObject::fromString(const QString &string) -{ - return QJNIObjectPrivate::fromString(string); -} - -QString QAndroidJniObject::toString() const -{ - return d->toString(); -} - -bool QAndroidJniObject::isClassAvailable(const char *className) -{ - return QJNIObjectPrivate::isClassAvailable(className); -} - -bool QAndroidJniObject::isValid() const -{ - return d->isValid(); -} - -QAndroidJniObject QAndroidJniObject::fromLocalRef(jobject obj) -{ - return QJNIObjectPrivate::fromLocalRef(obj); -} - -jobject QAndroidJniObject::javaObject() const -{ - return d->object(); -} - -bool QAndroidJniObject::isSameObject(jobject obj) const -{ - return d->isSameObject(obj); -} - -bool QAndroidJniObject::isSameObject(const QAndroidJniObject &obj) const -{ - return d->isSameObject(*obj.d); -} - -void QAndroidJniObject::assign(jobject o) -{ - if (d->isSameObject(o)) - return; - - d = QSharedPointer<QJNIObjectPrivate>(new QJNIObjectPrivate(o)); -} - -QT_END_NAMESPACE diff --git a/src/androidextras/jni/qandroidjniobject.h b/src/androidextras/jni/qandroidjniobject.h deleted file mode 100644 index 94bd901..0000000 --- a/src/androidextras/jni/qandroidjniobject.h +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANDROIDJNIOBJECT_H -#define QANDROIDJNIOBJECT_H - -#include <jni.h> -#include <QtAndroidExtras/qandroidextrasglobal.h> -#include <QtCore/qglobal.h> -#include <QtCore/qsharedpointer.h> - -QT_BEGIN_NAMESPACE - -class QJNIObjectPrivate; - -class Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject -{ -public: - QAndroidJniObject(); - explicit QAndroidJniObject(const char *className); - explicit QAndroidJniObject(const char *className, const char *sig, ...); - explicit QAndroidJniObject(jclass clazz); - explicit QAndroidJniObject(jclass clazz, const char *sig, ...); - QAndroidJniObject(jobject obj); - ~QAndroidJniObject(); - - template <typename T> - inline T object() const { return static_cast<T>(javaObject()); } -#ifndef Q_QDOC - inline jobject object() const { return javaObject(); } -#endif // Q_QDOC - - template <typename T> - T callMethod(const char *methodName) const; - template <typename T> - T callMethod(const char *methodName, const char *sig, ...) const; - template <typename T> - QAndroidJniObject callObjectMethod(const char *methodName) const; - QAndroidJniObject callObjectMethod(const char *methodName, - const char *sig, - ...) const; - - template <typename T> - static T callStaticMethod(const char *className, const char *methodName); - template <typename T> - static T callStaticMethod(const char *className, const char *methodName, const char *sig, ...); - template <typename T> - static QAndroidJniObject callStaticObjectMethod(const char *className, const char *methodName); - static QAndroidJniObject callStaticObjectMethod(const char *className, - const char *methodName, - const char *sig, ...); - template <typename T> - static T callStaticMethod(jclass clazz, const char *methodName); - template <typename T> - static T callStaticMethod(jclass clazz, const char *methodName, const char *sig, ...); - template <typename T> - static QAndroidJniObject callStaticObjectMethod(jclass clazz, const char *methodName); - static QAndroidJniObject callStaticObjectMethod(jclass clazz, - const char *methodName, - const char *sig, ...); - template <typename T> - T getField(const char *fieldName) const; - template <typename T> - QAndroidJniObject getObjectField(const char *fieldName) const; -#if QT_DEPRECATED_SINCE(5, 5) -# ifndef Q_QDOC - template <typename T> - QT_DEPRECATED_X("Use the non-template version instead") - QAndroidJniObject getObjectField(const char *fieldName, const char *sig) const; -# endif // Q_QDOC -#endif // QT_DEPRECATED_SINCE - QAndroidJniObject getObjectField(const char *fieldName, const char *sig) const; - template <typename T> - void setField(const char *fieldName, T value); - template <typename T> - void setField(const char *fieldName, const char *sig, T value); - template <typename T> - static QAndroidJniObject getStaticObjectField(const char *className, const char *fieldName); -#if QT_DEPRECATED_SINCE(5, 5) -# ifndef Q_QDOC - template <typename T> - QT_DEPRECATED_X("Use the non-template version instead") - static QAndroidJniObject getStaticObjectField(const char *className, - const char *fieldName, - const char *sig); -# endif // Q_QDOC -#endif // QT_DEPRECATED_SINCE - static QAndroidJniObject getStaticObjectField(const char *className, - const char *fieldName, - const char *sig); - template <typename T> - static T getStaticField(const char *className, const char *fieldName); - template <typename T> - static QAndroidJniObject getStaticObjectField(jclass clazz, const char *fieldName); -#if QT_DEPRECATED_SINCE(5, 5) -# ifndef Q_QDOC - template <typename T> - QT_DEPRECATED_X("Use the non-template version instead") - static QAndroidJniObject getStaticObjectField(jclass clazz, - const char *fieldName, - const char *sig); -# endif // Q_QDOC -#endif // QT_DEPRECATED_SINCE - static QAndroidJniObject getStaticObjectField(jclass clazz, - const char *fieldName, - const char *sig); - template <typename T> - static T getStaticField(jclass clazz, const char *fieldName); - - template <typename T> - static void setStaticField(const char *className, - const char *fieldName, - const char *sig, - T value); - template <typename T> - static void setStaticField(const char *className, const char *fieldName, T value); - template <typename T> - static void setStaticField(jclass clazz, const char *fieldName, const char *sig, T value); - template <typename T> - static void setStaticField(jclass clazz, const char *fieldName, T value); - - static QAndroidJniObject fromString(const QString &string); - QString toString() const; - - static bool isClassAvailable(const char *className); - bool isValid() const; - - static QAndroidJniObject fromLocalRef(jobject obj); - - template <typename T> - inline QAndroidJniObject &operator=(T o) - { - assign(static_cast<jobject>(o)); - return *this; - } - -private: - friend bool operator==(const QAndroidJniObject &, const QAndroidJniObject &); - friend bool operator!=(const QAndroidJniObject &, const QAndroidJniObject &); - template <typename T> friend bool operator!=(const QAndroidJniObject &, const QAndroidJniObject &); - template <typename T> friend bool operator==(const QAndroidJniObject &, const QAndroidJniObject &); - - QAndroidJniObject(const QJNIObjectPrivate &o); - - void assign(jobject o); - jobject javaObject() const; - bool isSameObject(jobject obj) const; - bool isSameObject(const QAndroidJniObject &obj) const; - - QSharedPointer<QJNIObjectPrivate> d; -}; - -inline bool operator==(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2) -{ - return obj1.isSameObject(obj2); -} - -inline bool operator!=(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2) -{ - return !obj1.isSameObject(obj2); -} - -#if QT_DEPRECATED_SINCE(5, 5) -template<typename T> -QT_DEPRECATED inline bool operator==(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2) -{ - return obj1.isSameObject(obj2.object()); -} - -template <typename T> -QT_DEPRECATED inline bool operator!=(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2) -{ - return !obj1.isSameObject(obj2.object()); -} -#endif // QT_DEPRECATED_SINCE - -QT_END_NAMESPACE - -#endif // QANDROIDJNIOBJECT_H diff --git a/src/androidextras/qandroidextrasglobal.h b/src/androidextras/qandroidextrasglobal.h deleted file mode 100644 index 90a78ad..0000000 --- a/src/androidextras/qandroidextrasglobal.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTANDROIDEXTRASGLOBAL_H -#define QTANDROIDEXTRASGLOBAL_H - -#include <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_ANDROIDEXTRAS_LIB) -# define Q_ANDROIDEXTRAS_EXPORT Q_DECL_EXPORT -# else -# define Q_ANDROIDEXTRAS_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_ANDROIDEXTRAS_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QTANDROIDEXTRASGLOBAL_H diff --git a/src/jar/AndroidManifest.xml b/src/jar/AndroidManifest.xml deleted file mode 100644 index 17019fb..0000000 --- a/src/jar/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.qtproject.qt.android.multimedia" - android:versionCode="1" - android:versionName="1.0" > - <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> -</manifest> diff --git a/src/jar/CMakeLists.txt b/src/jar/CMakeLists.txt deleted file mode 100644 index 0aab31a..0000000 --- a/src/jar/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Generated from jar.pro. - -set(java_sources - src/org/qtproject/qt/android/extras/QtAndroidBinder.java - src/org/qtproject/qt/android/extras/QtAndroidServiceConnection.java - src/org/qtproject/qt/android/extras/QtNative.java -) - -qt_internal_add_jar(Qt${QtAndroidExtras_VERSION_MAJOR}AndroidExtras # special case - INCLUDE_JARS ${QT_ANDROID_JAR} - SOURCES ${java_sources} - OUTPUT_DIR "${QT_BUILD_DIR}/jar" -) - -install_jar(Qt${QtAndroidExtras_VERSION_MAJOR}AndroidExtras # special case - DESTINATION jar - COMPONENT Devel -) - diff --git a/src/jar/src/org/qtproject/qt/android/extras/QtAndroidBinder.java b/src/jar/src/org/qtproject/qt/android/extras/QtAndroidBinder.java deleted file mode 100644 index 4e34955..0000000 --- a/src/jar/src/org/qtproject/qt/android/extras/QtAndroidBinder.java +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Android port of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -package org.qtproject.qt.android.extras; - -import android.os.Binder; -import android.os.Parcel; - -public class QtAndroidBinder extends Binder -{ - public QtAndroidBinder(long id) - { - m_id = id; - } - - public void setId(long id) - { - synchronized(this) - { - m_id = id; - } - } - @Override - protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) - { - synchronized(this) - { - return QtNative.onTransact(m_id, code, data, reply, flags); - } - } - - private long m_id; -} diff --git a/src/jar/src/org/qtproject/qt/android/extras/QtAndroidServiceConnection.java b/src/jar/src/org/qtproject/qt/android/extras/QtAndroidServiceConnection.java deleted file mode 100644 index bab4d3f..0000000 --- a/src/jar/src/org/qtproject/qt/android/extras/QtAndroidServiceConnection.java +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Android port of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -package org.qtproject.qt.android.extras; - -import android.content.ComponentName; -import android.content.ServiceConnection; -import android.os.IBinder; - -public class QtAndroidServiceConnection implements ServiceConnection -{ - public QtAndroidServiceConnection(long id) - { - m_id = id; - } - - public void setId(long id) - { - synchronized(this) - { - m_id = id; - } - } - - @Override - public void onServiceConnected(ComponentName name, IBinder service) - { - synchronized(this) { - QtNative.onServiceConnected(m_id, name.flattenToString(), service); - } - } - - @Override - public void onServiceDisconnected(ComponentName name) - { - synchronized(this) { - QtNative.onServiceDisconnected(m_id, name.flattenToString()); - } - } - - private long m_id; -} diff --git a/src/jar/src/org/qtproject/qt/android/extras/QtNative.java b/src/jar/src/org/qtproject/qt/android/extras/QtNative.java deleted file mode 100644 index 86a9151..0000000 --- a/src/jar/src/org/qtproject/qt/android/extras/QtNative.java +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 BogDan Vatra <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Android port of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -package org.qtproject.qt.android.extras; - -import android.content.ComponentName; -import android.content.ServiceConnection; -import android.os.IBinder; -import android.os.Parcel; - -public class QtNative { - // Binder - public static native boolean onTransact(long id, int code, Parcel data, Parcel reply, int flags); - - - // ServiceConnection - public static native void onServiceConnected(long id, String name, IBinder service); - public static native void onServiceDisconnected(long id, String name); -} |