1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <android-base/stringprintf.h>
18 #include <base/logging.h>
19 #include <log/log.h>
20 #include <nativehelper/JNIHelp.h>
21 
22 #include "JavaClassConstants.h"
23 #include "NfcJniUtil.h"
24 
25 using android::base::StringPrintf;
26 
27 extern bool nfc_debug_enabled;
28 
29 namespace android {
30 
nativeP2pDeviceDoConnect(JNIEnv *,jobject)31 static jboolean nativeP2pDeviceDoConnect(JNIEnv*, jobject) {
32   DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
33   return JNI_TRUE;
34 }
35 
nativeP2pDeviceDoDisconnect(JNIEnv *,jobject)36 static jboolean nativeP2pDeviceDoDisconnect(JNIEnv*, jobject) {
37   DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
38   return JNI_TRUE;
39 }
40 
nativeP2pDeviceDoTransceive(JNIEnv *,jobject,jbyteArray)41 static jbyteArray nativeP2pDeviceDoTransceive(JNIEnv*, jobject, jbyteArray) {
42   DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
43   return NULL;
44 }
45 
nativeP2pDeviceDoReceive(JNIEnv *,jobject)46 static jbyteArray nativeP2pDeviceDoReceive(JNIEnv*, jobject) {
47   DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
48   return NULL;
49 }
50 
nativeP2pDeviceDoSend(JNIEnv *,jobject,jbyteArray)51 static jboolean nativeP2pDeviceDoSend(JNIEnv*, jobject, jbyteArray) {
52   DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
53   return JNI_TRUE;
54 }
55 
56 /*****************************************************************************
57 **
58 ** Description:     JNI functions
59 **
60 *****************************************************************************/
61 static JNINativeMethod gMethods[] = {
62     {"doConnect", "()Z", (void*)nativeP2pDeviceDoConnect},
63     {"doDisconnect", "()Z", (void*)nativeP2pDeviceDoDisconnect},
64     {"doTransceive", "([B)[B", (void*)nativeP2pDeviceDoTransceive},
65     {"doReceive", "()[B", (void*)nativeP2pDeviceDoReceive},
66     {"doSend", "([B)Z", (void*)nativeP2pDeviceDoSend},
67 };
68 
69 /*******************************************************************************
70 **
71 ** Function:        register_com_android_nfc_NativeP2pDevice
72 **
73 ** Description:     Regisgter JNI functions with Java Virtual Machine.
74 **                  e: Environment of JVM.
75 **
76 ** Returns:         Status of registration.
77 **
78 *******************************************************************************/
register_com_android_nfc_NativeP2pDevice(JNIEnv * e)79 int register_com_android_nfc_NativeP2pDevice(JNIEnv* e) {
80   return jniRegisterNativeMethods(e, gNativeP2pDeviceClassName, gMethods,
81                                   NELEM(gMethods));
82 }
83 
84 }  // namespace android
85