summaryrefslogtreecommitdiff
path: root/src/nfc/android/androidjninfc.cpp
blob: 2f2c77c427c08e59e123b9c8c24b25dffcc56e95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (C) 2016 Centria research and development
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "androidjninfc_p.h"

QT_BEGIN_NAMESPACE

namespace QtNfc {

bool startDiscovery()
{
    return QJniObject::callStaticMethod<jboolean>(QtJniTypes::className<QtJniTypes::QtNfc>(),
                                                  "startDiscovery");
}

bool isEnabled()
{
    return QJniObject::callStaticMethod<jboolean>(QtJniTypes::className<QtJniTypes::QtNfc>(),
                                                  "isEnabled");
}

bool isSupported()
{
    return QJniObject::callStaticMethod<jboolean>(QtJniTypes::className<QtJniTypes::QtNfc>(),
                                                  "isSupported");
}

bool stopDiscovery()
{
    return QJniObject::callStaticMethod<jboolean>(QtJniTypes::className<QtJniTypes::QtNfc>(),
                                                  "stopDiscovery");
}

QJniObject getStartIntent()
{
    return QJniObject::callStaticMethod<QtJniTypes::Intent>(
            QtJniTypes::className<QtJniTypes::QtNfc>(), "getStartIntent");
}

QJniObject getTag(const QJniObject &intent)
{
    return QJniObject::callStaticMethod<QtJniTypes::Parcellable>(
            QtJniTypes::className<QtJniTypes::QtNfc>(), "getTag",
            intent.object<QtJniTypes::Intent>());
}

} // namespace QtNfc

QT_END_NAMESPACE

Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
{
    static bool initialized = false;
    if (initialized)
        return JNI_VERSION_1_6;
    initialized = true;

    JNIEnv* env;
    if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
        return -1;
    }

    return JNI_VERSION_1_6;
}