Enable NFC service as an application service.
Uses ServiceManager.addService() to register the service.
Uses BOOT_COMPLETE to start the service.
Uses sharedUserId com.android.nfc so that it has a fixed uid.
Uses android:persistant so that the process is not killed.
Change-Id: If4264baf5dc457ee0a3ad5788c5945e84173b1ea
Signed-off-by: Nick Pelly <npelly@google.com>
diff --git a/Android.mk.hide b/Android.mk
similarity index 100%
rename from Android.mk.hide
rename to Android.mk
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ac6a6f0..9c4d969 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,14 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.nfc" >
+ package="com.android.nfc"
+ android:sharedUserId="android.uid.nfc"
+ android:sharedUserLabel="@string/nfcUserLabel"
+>
<uses-permission android:name="android.permission.NFC_ADMIN" />
<uses-permission android:name="android.permission.NFC_RAW" />
<uses-permission android:name="android.permission.NFC_NOTIFY" />
<uses-permission android:name="android.permission.NFC_LLCP" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+
<application android:icon="@drawable/icon"
- android:label="@string/app_name"
- android:persistent="true">
- <service android:name=".NfcService">
+ android:label="@string/app_name"
+ android:persistent="true" >
+ <service android:name=".NfcService" >
</service>
+ <receiver android:name=".NfcReceiver" >
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
</application>
</manifest>
diff --git a/jni/Android.mk.hide b/jni/Android.mk
similarity index 88%
rename from jni/Android.mk.hide
rename to jni/Android.mk
index 30aab13..c725346 100644
--- a/jni/Android.mk.hide
+++ b/jni/Android.mk
@@ -12,8 +12,6 @@
com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp \
com_trustedlogic_trustednfc_android_internal_NativeNfcTag.cpp \
com_trustedlogic_trustednfc_android_internal_NativeP2pDevice.cpp \
- com_trustedlogic_trustednfc_android_NdefMessage.cpp \
- com_trustedlogic_trustednfc_android_NdefRecord.cpp \
trustednfc_jni.cpp
LOCAL_C_INCLUDES += \
diff --git a/jni/com_trustedlogic_trustednfc_android_NdefMessage.cpp b/jni/com_trustedlogic_trustednfc_android_NdefMessage.cpp
deleted file mode 100644
index 6ddbf7e..0000000
--- a/jni/com_trustedlogic_trustednfc_android_NdefMessage.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * File : com_trustedlogic_trustednfc_android_NdefMessage.c
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created : 06-10-2009
- */
-
-#include "trustednfc_jni.h"
-
-namespace android {
-
-static jint com_trustedlogic_trustednfc_android_NdefMessage_parseNdefMessage(
- JNIEnv *e, jobject o, jbyteArray array)
-{
- NFCSTATUS status;
- uint32_t i;
- jbyte *raw_msg;
- jsize raw_msg_size;
- uint32_t num_of_records = 0;
- uint8_t **records = NULL;
- uint8_t *is_chunked = NULL;
- jint ret = -1;
- phFriNfc_NdefRecord_t record;
-
- jclass record_cls;
- jobjectArray records_array;
- jmethodID ctor;
-
- jclass msg_cls;
- jfieldID mrecords;
-
- raw_msg_size = e->GetArrayLength(array);
- raw_msg = e->GetByteArrayElements(array, NULL);
- if(raw_msg == NULL)
- return -1;
-
- /* Get the number of records in the message so we can allocate buffers */
- LOGD("phFriNfc_NdefRecord_GetRecords(NULL)");
- REENTRANCE_LOCK();
- status = phFriNfc_NdefRecord_GetRecords((uint8_t *)raw_msg,
- (uint32_t)raw_msg_size, NULL, NULL, &num_of_records);
- REENTRANCE_UNLOCK();
- if(status != NFCSTATUS_SUCCESS)
- {
- LOGE("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
- goto end;
- }
- LOGD("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
-
- LOGD("found %d records in message", num_of_records);
-
- is_chunked = (uint8_t*)malloc(num_of_records);
- if(is_chunked == NULL)
- goto end;
- records = (uint8_t**)malloc(num_of_records * sizeof(uint8_t *));
- if(records == NULL)
- goto end;
-
- /* Now, actually retrieve records position in message */
- LOGD("phFriNfc_NdefRecord_GetRecords()");
- REENTRANCE_LOCK();
- status = phFriNfc_NdefRecord_GetRecords((uint8_t *)raw_msg,
- (uint32_t)raw_msg_size, records, is_chunked, &num_of_records);
- REENTRANCE_UNLOCK();
- if(status != NFCSTATUS_SUCCESS)
- {
- LOGE("phFriNfc_NdefRecord_GetRecords() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
- goto end;
- }
- LOGD("phFriNfc_NdefRecord_GetRecords() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
-
- /* Build NDEF records array */
- record_cls =
- e->FindClass("android/nfc/NdefRecord");
- records_array = e->NewObjectArray((jsize)num_of_records, record_cls,
- NULL);
- if(records_array == NULL)
- goto end;
-
- ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[B)V");
-
- LOGD("NFC_Number of records = %d\n",num_of_records);
-
- for(i = 0; i < num_of_records; i++)
- {
- jbyteArray type, id, payload;
- jobject new_record;
-
- LOGD("phFriNfc_NdefRecord_Parse()");
- REENTRANCE_LOCK();
- status = phFriNfc_NdefRecord_Parse(&record, records[i]);
- REENTRANCE_UNLOCK();
- if(status != NFCSTATUS_SUCCESS)
- {
- LOGE("phFriNfc_NdefRecord_Parse() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
- goto end;
- }
- LOGD("phFriNfc_NdefRecord_Parse() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
-
- type = e->NewByteArray(record.TypeLength);
- if(type == NULL)
- {
- LOGD("NFC_Set Record Type Error\n");
- goto end;
- }
-
- id = e->NewByteArray(record.IdLength);
- if(id == NULL)
- {
- LOGD("NFC_Set Record ID Error\n");
- goto end;
- }
-
- payload = e->NewByteArray(record.PayloadLength);
- if(payload == NULL)
- {
- LOGD("NFC_Set Record Payload Error\n");
- goto end;
- }
-
- e->SetByteArrayRegion(type, 0, record.TypeLength,
- (jbyte *)record.Type);
- e->SetByteArrayRegion(id, 0, record.IdLength,
- (jbyte *)record.Id);
- e->SetByteArrayRegion(payload, 0, record.PayloadLength,
- (jbyte *)record.PayloadData);
-
-
- new_record = e->NewObject(record_cls, ctor,
- (jshort)record.Tnf, type, id, payload);
-
-
- e->SetObjectArrayElement(records_array, i, new_record);
-
- /* Try not to clutter the Java stack too much */
- e->DeleteLocalRef(new_record);
- e->DeleteLocalRef(type);
- e->DeleteLocalRef(id);
- e->DeleteLocalRef(payload);
- }
-
- /* Store built array in our NDEFMessage instance */
- msg_cls = e->GetObjectClass(o);
- mrecords = e->GetFieldID(msg_cls, "mRecords",
- "[Landroid/nfc/NdefRecord;");
-
- e->SetObjectField(o, mrecords, (jobject)records_array);
-
- ret = 0;
-
-end:
- if(is_chunked)
- free(is_chunked);
- if(records)
- free(records);
- e->ReleaseByteArrayElements(array, raw_msg, JNI_ABORT);
-
- return ret;
-}
-
-/*
- * JNI registration.
- */
-static JNINativeMethod gMethods[] =
-{
- {"parseNdefMessage", "([B)I",
- (void *)com_trustedlogic_trustednfc_android_NdefMessage_parseNdefMessage},
-};
-
-int register_com_trustedlogic_trustednfc_android_NdefMessage(JNIEnv *e)
-{
- return jniRegisterNativeMethods(e,
- "android/nfc/NdefMessage",
- gMethods, NELEM(gMethods));
-}
-
-} // namespace android
diff --git a/jni/com_trustedlogic_trustednfc_android_NdefRecord.cpp b/jni/com_trustedlogic_trustednfc_android_NdefRecord.cpp
deleted file mode 100644
index 76b5791..0000000
--- a/jni/com_trustedlogic_trustednfc_android_NdefRecord.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * File : com_trustedlogic_trustednfc_android_NdefRecord.c
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created : 08-10-2009
- */
-
-#include "trustednfc_jni.h"
-
-namespace android {
-
-static jbyteArray com_trustedlogic_trustednfc_android_NdefRecord_generate(
- JNIEnv *e, jobject o, jshort flags, jshort tnf, jbyteArray type,
- jbyteArray id, jbyteArray payload)
-{
- NFCSTATUS status;
- phFriNfc_NdefRecord_t record;
- uint32_t buf_size;
- uint32_t record_size;
- uint8_t *buf = NULL;
- jbyteArray result = NULL;
-
- /* Prepare NDEF record structure */
- record.Flags = (uint8_t)flags;
- record.Tnf = (uint8_t)tnf;
- record.TypeLength = (uint32_t)e->GetArrayLength(type);
- record.Type = (uint8_t *)e->GetByteArrayElements(type, NULL);
- record.IdLength = (uint32_t)e->GetArrayLength(id);
- record.Id = (uint8_t *)e->GetByteArrayElements(id, NULL);
- record.PayloadLength = (uint32_t)e->GetArrayLength(payload);
- record.PayloadData = (uint8_t *)e->GetByteArrayElements(payload, NULL);
-
- buf_size = record.PayloadLength + record.IdLength + record.TypeLength + 8;
-
- buf = (uint8_t*)malloc(buf_size);
- if(buf == NULL)
- goto end;
-
- LOGD("phFriNfc_NdefRecord_Generate()");
- REENTRANCE_LOCK();
- status = phFriNfc_NdefRecord_Generate(&record, buf, buf_size, &record_size);
- REENTRANCE_UNLOCK();
- if(status != NFCSTATUS_SUCCESS)
- {
- LOGE("phFriNfc_NdefRecord_Generate() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
- goto end;
- }
- LOGD("phFriNfc_NdefRecord_Generate() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
-
- result = e->NewByteArray(record_size);
- if(result == NULL)
- goto end;
-
- e->SetByteArrayRegion(result, 0, record_size, (jbyte *)buf);
-
-end:
- e->ReleaseByteArrayElements(type, (jbyte *)record.Type, JNI_ABORT);
- e->ReleaseByteArrayElements(id, (jbyte *)record.Id, JNI_ABORT);
- e->ReleaseByteArrayElements(payload, (jbyte *)record.PayloadData, JNI_ABORT);
-
- if(buf)
- free(buf);
-
- return result;
-}
-
-/*
- * JNI registration.
- */
-static JNINativeMethod gMethods[] =
-{
- {"generate", "(SS[B[B[B)[B",
- (void *)com_trustedlogic_trustednfc_android_NdefRecord_generate},
-};
-
-int register_com_trustedlogic_trustednfc_android_NdefRecord(JNIEnv *e)
-{
- return jniRegisterNativeMethods(e,
- "android/nfc/NdefRecord",
- gMethods, NELEM(gMethods));
-}
-
-} // namespace android
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket.cpp
index b9de119..50d9d0e 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket.cpp
@@ -14,11 +14,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionLessSocket.c
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created : 04-03-2010
- */
#include <semaphore.h>
#include "trustednfc_jni.h"
@@ -30,8 +25,6 @@
namespace android {
-
-
/*
* Callbacks
*/
@@ -67,7 +60,7 @@
/*
* Methods
*/
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket_doSendTo(JNIEnv *e, jobject o, jint nsap, jbyteArray data)
+static jboolean com_android_nfc_NativeLlcpConnectionlessSocket_doSendTo(JNIEnv *e, jobject o, jint nsap, jbyteArray data)
{
NFCSTATUS ret;
struct timespec ts;
@@ -110,7 +103,7 @@
}
}
-static jobject com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket_doReceiveFrom(JNIEnv *e, jobject o, jint linkMiu)
+static jobject com_android_nfc_NativeLlcpConnectionlessSocket_doReceiveFrom(JNIEnv *e, jobject o, jint linkMiu)
{
NFCSTATUS ret;
struct timespec ts;
@@ -190,7 +183,7 @@
}
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket_doClose(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NativeLlcpConnectionlessSocket_doClose(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
phLibNfc_Handle hLlcpSocket;
@@ -221,18 +214,15 @@
*/
static JNINativeMethod gMethods[] =
{
- {"doSendTo", "(I[B)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket_doSendTo},
+ {"doSendTo", "(I[B)Z", (void *)com_android_nfc_NativeLlcpConnectionlessSocket_doSendTo},
- {"doReceiveFrom", "(I)Landroid/nfc/LlcpPacket;",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket_doReceiveFrom},
+ {"doReceiveFrom", "(I)Landroid/nfc/LlcpPacket;", (void *)com_android_nfc_NativeLlcpConnectionlessSocket_doReceiveFrom},
- {"doClose", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket_doClose},
+ {"doClose", "()Z", (void *)com_android_nfc_NativeLlcpConnectionlessSocket_doClose},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket(JNIEnv *e)
+int register_com_android_nfc_NativeLlcpConnectionlessSocket(JNIEnv *e)
{
if(sem_init(&trustednfc_jni_llcp_send_sem, 0, 0) == -1)
@@ -242,7 +232,7 @@
return -1;
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeLlcpConnectionlessSocket",
+ "com/android/nfc/NativeLlcpConnectionlessSocket",
gMethods, NELEM(gMethods));
}
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket.cpp
index e6a7eab..f866e83 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket.cpp
@@ -14,11 +14,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket.c
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created : 04-03-2010
- */
#include <semaphore.h>
#include "trustednfc_jni.h"
@@ -52,7 +47,7 @@
/*
* Methods
*/
-static jobject com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket_doAccept(JNIEnv *e, jobject o, int timeout, jint miu, jint rw, jint linearBufferLength)
+static jobject com__NativeLlcpServiceSocket_doAccept(JNIEnv *e, jobject o, int timeout, jint miu, jint rw, jint linearBufferLength)
{
NFCSTATUS ret;
struct timespec ts;
@@ -118,7 +113,7 @@
if(trustednfc_jni_cb_status == NFCSTATUS_SUCCESS)
{
/* Create new LlcpSocket object */
- if(trustednfc_jni_cache_object(e,"com/trustedlogic/trustednfc/android/internal/NativeLlcpSocket",&(clientSocket)) == -1)
+ if(trustednfc_jni_cache_object(e,"com/android/nfc/NativeLlcpSocket",&(clientSocket)) == -1)
{
LOGD("LLCP Socket creation error");
return NULL;
@@ -157,7 +152,7 @@
}
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket_doClose(JNIEnv *e, jobject o)
+static jboolean com__NativeLlcpServiceSocket_doClose(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
phLibNfc_Handle hLlcpSocket;
@@ -187,21 +182,21 @@
*/
static JNINativeMethod gMethods[] =
{
- {"doAccept", "(IIII)Lcom/trustedlogic/trustednfc/android/internal/NativeLlcpSocket;",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket_doAccept},
+ {"doAccept", "(IIII)Lcom/android/nfc/NativeLlcpSocket;",
+ (void *)com__NativeLlcpServiceSocket_doAccept},
{"doClose", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket_doClose},
+ (void *)com__NativeLlcpServiceSocket_doClose},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket(JNIEnv *e)
+int register_com_android_nfc_NativeLlcpServiceSocket(JNIEnv *e)
{
if(sem_init(&trustednfc_jni_llcp_sem, 0, 0) == -1)
return -1;
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeLlcpServiceSocket",
+ "com/android/nfc/NativeLlcpServiceSocket",
gMethods, NELEM(gMethods));
}
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket.cpp
index f62b531..e49994b 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket.cpp
@@ -14,11 +14,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket.c
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created : 04-03-2010
- */
#include <semaphore.h>
#include "trustednfc_jni.h"
@@ -121,7 +116,7 @@
/*
* Methods
*/
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doConnect(JNIEnv *e, jobject o, jint nSap, jint timeout)
+static jboolean com_android_nfc_NativeLlcpSocket_doConnect(JNIEnv *e, jobject o, jint nSap, jint timeout)
{
NFCSTATUS ret;
struct timespec ts;
@@ -172,7 +167,7 @@
}
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doConnectBy(JNIEnv *e, jobject o, jstring sn, jint timeout)
+static jboolean com_android_nfc_NativeLlcpSocket_doConnectBy(JNIEnv *e, jobject o, jstring sn, jint timeout)
{
NFCSTATUS ret;
struct timespec ts;
@@ -226,7 +221,7 @@
}
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doClose(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NativeLlcpSocket_doClose(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
phLibNfc_Handle hLlcpSocket;
@@ -247,7 +242,7 @@
return TRUE;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doSend(JNIEnv *e, jobject o, jbyteArray data)
+static jboolean com_android_nfc_NativeLlcpSocket_doSend(JNIEnv *e, jobject o, jbyteArray data)
{
NFCSTATUS ret;
struct timespec ts;
@@ -289,7 +284,7 @@
}
}
-static jint com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doReceive(JNIEnv *e, jobject o, jbyteArray buffer)
+static jint com_android_nfc_NativeLlcpSocket_doReceive(JNIEnv *e, jobject o, jbyteArray buffer)
{
NFCSTATUS ret;
struct timespec ts;
@@ -330,7 +325,7 @@
}
}
-static jint com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doGetRemoteSocketMIU(JNIEnv *e, jobject o)
+static jint com_android_nfc_NativeLlcpSocket_doGetRemoteSocketMIU(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
phLibNfc_Handle hLlcpSocket;
@@ -356,7 +351,7 @@
}
}
-static jint com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doGetRemoteSocketRW(JNIEnv *e, jobject o)
+static jint com_android_nfc_NativeLlcpSocket_doGetRemoteSocketRW(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
phLibNfc_Handle hLlcpSocket;
@@ -389,35 +384,35 @@
static JNINativeMethod gMethods[] =
{
{"doConnect", "(II)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doConnect},
+ (void *)com_android_nfc_NativeLlcpSocket_doConnect},
{"doConnectBy", "(Ljava/lang/String;I)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doConnectBy},
+ (void *)com_android_nfc_NativeLlcpSocket_doConnectBy},
{"doClose", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doClose},
+ (void *)com_android_nfc_NativeLlcpSocket_doClose},
{"doSend", "([B)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doSend},
+ (void *)com_android_nfc_NativeLlcpSocket_doSend},
{"doReceive", "([B)I",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doReceive},
+ (void *)com_android_nfc_NativeLlcpSocket_doReceive},
{"doGetRemoteSocketMiu", "()I",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doGetRemoteSocketMIU},
+ (void *)com_android_nfc_NativeLlcpSocket_doGetRemoteSocketMIU},
{"doGetRemoteSocketRw", "()I",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket_doGetRemoteSocketRW},
+ (void *)com_android_nfc_NativeLlcpSocket_doGetRemoteSocketRW},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket(JNIEnv *e)
+int register_com_android_nfc_NativeLlcpSocket(JNIEnv *e)
{
if(sem_init(&trustednfc_jni_llcp_sem, 0, 0) == -1)
return -1;
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeLlcpSocket",gMethods, NELEM(gMethods));
+ "com/android/nfc/NativeLlcpSocket",gMethods, NELEM(gMethods));
}
} // namespace android
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeNdefTag.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeNdefTag.cpp
index 10cd9c8..7dc6a57 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeNdefTag.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeNdefTag.cpp
@@ -14,11 +14,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeNdefTag.c
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created : 09-12-2009
- */
#include <semaphore.h>
#include "trustednfc_jni.h"
@@ -43,7 +38,7 @@
sem_post(&trustednfc_jni_ndef_tag_sem);
}
-static jbyteArray com_trustedlogic_trustednfc_android_internal_NativeNdefTag_doRead(JNIEnv *e,
+static jbyteArray com_android_nfc_NativeNdefTag_doRead(JNIEnv *e,
jobject o)
{
phLibNfc_Handle handle = 0;
@@ -89,7 +84,7 @@
return buf;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeNdefTag_doWrite(JNIEnv *e,
+static jboolean com_android_nfc_NativeNdefTag_doWrite(JNIEnv *e,
jobject o, jbyteArray buf)
{
NFCSTATUS status;
@@ -140,18 +135,18 @@
static JNINativeMethod gMethods[] =
{
{"doRead", "()[B",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNdefTag_doRead},
+ (void *)com_android_nfc_NativeNdefTag_doRead},
{"doWrite", "([B)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNdefTag_doWrite},
+ (void *)com_android_nfc_NativeNdefTag_doWrite},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeNdefTag(JNIEnv *e)
+int register_com_android_nfc_NativeNdefTag(JNIEnv *e)
{
if(sem_init(&trustednfc_jni_ndef_tag_sem, 0, 0) == -1)
return -1;
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeNdefTag",
+ "com/android/nfc/NativeNdefTag",
gMethods, NELEM(gMethods));
}
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp
index 3e624a5..022e8b8 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp
@@ -14,12 +14,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeNfcManager.c
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created : 20-08-2009
- */
-
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
@@ -1328,7 +1322,7 @@
LOGD("phLibNfc_Mgt_IoCtl(PRBS Test) returned 0x%08x\n", ret);
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_readerDiscovery(JNIEnv *e, jobject o)
+static void com_android_nfc_NfcManager_readerDiscovery(JNIEnv *e, jobject o)
{
struct trustednfc_jni_native_data *nat;
@@ -1342,7 +1336,7 @@
CONCURRENCY_UNLOCK();
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_disableDiscovery(JNIEnv *e, jobject o)
+static void com_android_nfc_NfcManager_disableDiscovery(JNIEnv *e, jobject o)
{
struct trustednfc_jni_native_data *nat;
@@ -1356,7 +1350,7 @@
CONCURRENCY_UNLOCK();
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_enableDiscovery(
+static void com_android_nfc_NfcManager_enableDiscovery(
JNIEnv *e, jobject o, jint mode)
{
NFCSTATUS ret;
@@ -1379,7 +1373,7 @@
CONCURRENCY_UNLOCK();
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_disableDiscoveryMode(
+static void com_android_nfc_NfcManager_disableDiscoveryMode(
JNIEnv *e, jobject o, jint mode)
{
struct trustednfc_jni_native_data *nat;
@@ -1394,7 +1388,7 @@
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NfcManager_init_native_struc(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NfcManager_init_native_struc(JNIEnv *e, jobject o)
{
NFCSTATUS status;
struct trustednfc_jni_native_data *nat = NULL;
@@ -1424,13 +1418,13 @@
/* Initialize native cached references */
cached_NfcManager_notifyNdefMessageListeners = e->GetMethodID(cls,
- "notifyNdefMessageListeners","(Lcom/trustedlogic/trustednfc/android/internal/NativeNfcTag;)V");
+ "notifyNdefMessageListeners","(Lcom/android/nfc/NativeNfcTag;)V");
cached_NfcManager_notifyTransactionListeners = e->GetMethodID(cls,
"notifyTransactionListeners", "([B)V");
cached_NfcManager_notifyLlcpLinkActivation = e->GetMethodID(cls,
- "notifyLlcpLinkActivation","(Lcom/trustedlogic/trustednfc/android/internal/NativeP2pDevice;)V");
+ "notifyLlcpLinkActivation","(Lcom/android/nfc/NativeP2pDevice;)V");
cached_NfcManager_notifyLlcpLinkDeactivated = e->GetMethodID(cls,
"notifyLlcpLinkDeactivated","()V");
@@ -1439,13 +1433,13 @@
"notifyTargetDeselected","()V");
- if(trustednfc_jni_cache_object(e,"com/trustedlogic/trustednfc/android/internal/NativeNfcTag",&(nat->cached_NfcTag)) == -1)
+ if(trustednfc_jni_cache_object(e,"com/android/nfc/NativeNfcTag",&(nat->cached_NfcTag)) == -1)
{
LOGD("Native Structure initialization failed [0x%08x]",nat->status);
return FALSE;
}
- if(trustednfc_jni_cache_object(e,"com/trustedlogic/trustednfc/android/internal/NativeP2pDevice",&(nat->cached_P2pDevice)) == -1)
+ if(trustednfc_jni_cache_object(e,"com/android/nfc/NativeP2pDevice",&(nat->cached_P2pDevice)) == -1)
{
LOGD("Native Structure initialization failed [0x%08x]",nat->status);
return FALSE;
@@ -1456,7 +1450,7 @@
}
/* Init/Deinit method */
-static jboolean com_trustedlogic_trustednfc_android_internal_NfcManager_initialize(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NfcManager_initialize(JNIEnv *e, jobject o)
{
struct trustednfc_jni_native_data *nat = NULL;
int init_result = JNI_FALSE;
@@ -1489,7 +1483,7 @@
return (init_result==TRUE)?JNI_TRUE:JNI_FALSE;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NfcManager_deinitialize(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NfcManager_deinitialize(JNIEnv *e, jobject o)
{
struct timespec ts;
NFCSTATUS status;
@@ -1563,7 +1557,7 @@
}
/* Secure Element methods */
-static jintArray com_trustedlogic_trustednfc_android_internal_NfcManager_doGetSecureElementList(JNIEnv *e, jobject o)
+static jintArray com_android_nfc_NfcManager_doGetSecureElementList(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
jintArray list= NULL;
@@ -1606,7 +1600,7 @@
return list;
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_doSelectSecureElement(JNIEnv *e, jobject o, jint seID)
+static void com_android_nfc_NfcManager_doSelectSecureElement(JNIEnv *e, jobject o, jint seID)
{
NFCSTATUS ret;
struct trustednfc_jni_native_data *nat;
@@ -1638,7 +1632,7 @@
CONCURRENCY_UNLOCK();
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_doDeselectSecureElement(JNIEnv *e, jobject o, jint seID)
+static void com_android_nfc_NfcManager_doDeselectSecureElement(JNIEnv *e, jobject o, jint seID)
{
NFCSTATUS ret;
struct trustednfc_jni_native_data *nat;
@@ -1673,7 +1667,7 @@
}
/* Open Tag/P2p Methods */
-static jobject com_trustedlogic_trustednfc_android_internal_NfcManager_doOpenP2pConnection(JNIEnv *e, jobject o, jint timeout)
+static jobject com_android_nfc_NfcManager_doOpenP2pConnection(JNIEnv *e, jobject o, jint timeout)
{
NFCSTATUS ret;
struct timespec ts;
@@ -1723,7 +1717,7 @@
return p2pDevice;
}
-static jobject com_trustedlogic_trustednfc_android_internal_NfcManager_doOpenTagConnection(JNIEnv *e, jobject o, jint timeout)
+static jobject com_android_nfc_NfcManager_doOpenTagConnection(JNIEnv *e, jobject o, jint timeout)
{
NFCSTATUS ret;
struct timespec ts;
@@ -1773,7 +1767,7 @@
return nfcTag;
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_doCancel(JNIEnv *e, jobject o)
+static void com_android_nfc_NfcManager_doCancel(JNIEnv *e, jobject o)
{
struct trustednfc_jni_native_data *nat;
@@ -1786,7 +1780,7 @@
/* Llcp methods */
-static jboolean com_trustedlogic_trustednfc_android_internal_NfcManager_doCheckLlcp(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NfcManager_doCheckLlcp(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
jboolean result = JNI_FALSE;
@@ -1826,7 +1820,7 @@
return result;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NfcManager_doActivateLlcp(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NfcManager_doActivateLlcp(JNIEnv *e, jobject o)
{
NFCSTATUS ret;
LOGD("phLibNfc_Llcp_Activate(hRemoteDevice=0x%08x)", hLlcpHandle);
@@ -1847,7 +1841,7 @@
-static jobject com_trustedlogic_trustednfc_android_internal_NfcManager_doCreateLlcpConnectionlessSocket(JNIEnv *e, jobject o, jint nSap)
+static jobject com_android_nfc_NfcManager_doCreateLlcpConnectionlessSocket(JNIEnv *e, jobject o, jint nSap)
{
NFCSTATUS ret;
jobject connectionlessSocket = NULL;
@@ -1899,7 +1893,7 @@
/* Create new NativeLlcpConnectionlessSocket object */
- if(trustednfc_jni_cache_object(e,"com/trustedlogic/trustednfc/android/internal/NativeLlcpConnectionlessSocket",&(connectionlessSocket)) == -1)
+ if(trustednfc_jni_cache_object(e,"com/android/nfc/NativeLlcpConnectionlessSocket",&(connectionlessSocket)) == -1)
{
return NULL;
}
@@ -1929,7 +1923,7 @@
return connectionlessSocket;
}
-static jobject com_trustedlogic_trustednfc_android_internal_NfcManager_doCreateLlcpServiceSocket(JNIEnv *e, jobject o, jint nSap, jstring sn, jint miu, jint rw, jint linearBufferLength)
+static jobject com_android_nfc_NfcManager_doCreateLlcpServiceSocket(JNIEnv *e, jobject o, jint nSap, jstring sn, jint miu, jint rw, jint linearBufferLength)
{
NFCSTATUS ret;
phLibNfc_Handle hLlcpSocket;
@@ -2013,7 +2007,7 @@
LOGD("phLibNfc_Llcp_Listen() returned 0x%04x[%s]", ret, trustednfc_jni_get_status_name(ret));
/* Create new NativeLlcpServiceSocket object */
- if(trustednfc_jni_cache_object(e,"com/trustedlogic/trustednfc/android/internal/NativeLlcpServiceSocket",&(serviceSocket)) == -1)
+ if(trustednfc_jni_cache_object(e,"com/android/nfc/NativeLlcpServiceSocket",&(serviceSocket)) == -1)
{
LOGE("Llcp Socket object creation error");
return NULL;
@@ -2050,7 +2044,7 @@
return serviceSocket;
}
-static jobject com_trustedlogic_trustednfc_android_internal_NfcManager_doCreateLlcpSocket(JNIEnv *e, jobject o, jint nSap, jint miu, jint rw, jint linearBufferLength)
+static jobject com_android_nfc_NfcManager_doCreateLlcpSocket(JNIEnv *e, jobject o, jint nSap, jint miu, jint rw, jint linearBufferLength)
{
jobject clientSocket = NULL;
NFCSTATUS ret;
@@ -2093,7 +2087,7 @@
LOGD("phLibNfc_Llcp_Socket() returned 0x%04x[%s]", ret, trustednfc_jni_get_status_name(ret));
/* Create new NativeLlcpSocket object */
- if(trustednfc_jni_cache_object(e,"com/trustedlogic/trustednfc/android/internal/NativeLlcpSocket",&(clientSocket)) == -1)
+ if(trustednfc_jni_cache_object(e,"com/android/nfc/NativeLlcpSocket",&(clientSocket)) == -1)
{
LOGE("Llcp socket object creation error");
return NULL;
@@ -2152,7 +2146,7 @@
return clientSocket;
}
-static jint com_trustedlogic_trustednfc_android_internal_NfcManager_doGetLastError(JNIEnv *e, jobject o)
+static jint com_android_nfc_NfcManager_doGetLastError(JNIEnv *e, jobject o)
{
LOGW("Last Error Status = 0x%02x",lastErrorStatus);
@@ -2170,7 +2164,7 @@
}
}
-static void com_trustedlogic_trustednfc_android_internal_NfcManager_doSetProperties(JNIEnv *e, jobject o, jint param, jint value)
+static void com_android_nfc_NfcManager_doSetProperties(JNIEnv *e, jobject o, jint param, jint value)
{
NFCSTATUS ret;
struct trustednfc_jni_native_data *nat;
@@ -2248,68 +2242,68 @@
static JNINativeMethod gMethods[] =
{
{"initializeNativeStructure", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_init_native_struc},
+ (void *)com_android_nfc_NfcManager_init_native_struc},
{"initialize", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_initialize},
+ (void *)com_android_nfc_NfcManager_initialize},
{"deinitialize", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_deinitialize},
+ (void *)com_android_nfc_NfcManager_deinitialize},
{"enableDiscovery", "(I)V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_enableDiscovery},
+ (void *)com_android_nfc_NfcManager_enableDiscovery},
{"disableDiscoveryMode", "(I)V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_disableDiscoveryMode},
+ (void *)com_android_nfc_NfcManager_disableDiscoveryMode},
{"doGetSecureElementList", "()[I",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doGetSecureElementList},
+ (void *)com_android_nfc_NfcManager_doGetSecureElementList},
{"doSelectSecureElement", "(I)V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doSelectSecureElement},
+ (void *)com_android_nfc_NfcManager_doSelectSecureElement},
{"doDeselectSecureElement", "(I)V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doDeselectSecureElement},
+ (void *)com_android_nfc_NfcManager_doDeselectSecureElement},
- {"doOpenP2pConnection", "(I)Lcom/trustedlogic/trustednfc/android/internal/NativeP2pDevice;",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doOpenP2pConnection},
+ {"doOpenP2pConnection", "(I)Lcom/android/nfc/NativeP2pDevice;",
+ (void *)com_android_nfc_NfcManager_doOpenP2pConnection},
- {"doOpenTagConnection", "(I)Lcom/trustedlogic/trustednfc/android/internal/NativeNfcTag;",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doOpenTagConnection},
+ {"doOpenTagConnection", "(I)Lcom/android/nfc/NativeNfcTag;",
+ (void *)com_android_nfc_NfcManager_doOpenTagConnection},
{"doCancel", "()V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doCancel},
+ (void *)com_android_nfc_NfcManager_doCancel},
{"doCheckLlcp", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doCheckLlcp},
+ (void *)com_android_nfc_NfcManager_doCheckLlcp},
{"doActivateLlcp", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doActivateLlcp},
+ (void *)com_android_nfc_NfcManager_doActivateLlcp},
- {"doCreateLlcpConnectionlessSocket", "(I)Lcom/trustedlogic/trustednfc/android/internal/NativeLlcpConnectionlessSocket;",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doCreateLlcpConnectionlessSocket},
+ {"doCreateLlcpConnectionlessSocket", "(I)Lcom/android/nfc/NativeLlcpConnectionlessSocket;",
+ (void *)com_android_nfc_NfcManager_doCreateLlcpConnectionlessSocket},
- {"doCreateLlcpServiceSocket", "(ILjava/lang/String;III)Lcom/trustedlogic/trustednfc/android/internal/NativeLlcpServiceSocket;",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doCreateLlcpServiceSocket},
+ {"doCreateLlcpServiceSocket", "(ILjava/lang/String;III)Lcom/android/nfc/NativeLlcpServiceSocket;",
+ (void *)com_android_nfc_NfcManager_doCreateLlcpServiceSocket},
- {"doCreateLlcpSocket", "(IIII)Lcom/trustedlogic/trustednfc/android/internal/NativeLlcpSocket;",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doCreateLlcpSocket},
+ {"doCreateLlcpSocket", "(IIII)Lcom/android/nfc/NativeLlcpSocket;",
+ (void *)com_android_nfc_NfcManager_doCreateLlcpSocket},
{"doGetLastError", "()I",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doGetLastError},
+ (void *)com_android_nfc_NfcManager_doGetLastError},
{"doSetProperties", "(II)V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doSetProperties},
+ (void *)com_android_nfc_NfcManager_doSetProperties},
{"disableDiscovery", "()V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_disableDiscovery},
+ (void *)com_android_nfc_NfcManager_disableDiscovery},
{"readerDiscovery", "()V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_readerDiscovery},
+ (void *)com_android_nfc_NfcManager_readerDiscovery},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeNfcManager(JNIEnv *e)
+int register_com_android_nfc_NativeNfcManager(JNIEnv *e)
{
trustednfc_jni_native_monitor_t *trustednfc_jni_native_monitor;
@@ -2346,7 +2340,7 @@
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeNfcManager",
+ "com/android/nfc/NativeNfcManager",
gMethods, NELEM(gMethods));
}
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcTag.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcTag.cpp
index 56e76ce..de839ae 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcTag.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeNfcTag.cpp
@@ -14,11 +14,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeNfcTag.c
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created : 27-08-2009
- */
#include <semaphore.h>
#include "trustednfc_jni.h"
@@ -183,7 +178,7 @@
}
/* Functions */
-static jbyteArray com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doRead(JNIEnv *e,
+static jbyteArray com_android_nfc_NativeNfcTag_doRead(JNIEnv *e,
jobject o)
{
NFCSTATUS status;
@@ -231,7 +226,7 @@
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doWrite(JNIEnv *e,
+static jboolean com_android_nfc_NativeNfcTag_doWrite(JNIEnv *e,
jobject o, jbyteArray buf)
{
NFCSTATUS status;
@@ -276,7 +271,7 @@
return result;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doConnect(JNIEnv *e,
+static jboolean com_android_nfc_NativeNfcTag_doConnect(JNIEnv *e,
jobject o)
{
phLibNfc_Handle handle = 0;
@@ -316,7 +311,7 @@
return result;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doDisconnect(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NativeNfcTag_doDisconnect(JNIEnv *e, jobject o)
{
phLibNfc_Handle handle = 0;
jclass cls;
@@ -383,7 +378,7 @@
return result;
}
-static void com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doAsyncDisconnect(JNIEnv *e, jobject o)
+static void com_android_nfc_NativeNfcTag_doAsyncDisconnect(JNIEnv *e, jobject o)
{
NFCSTATUS status;
@@ -419,7 +414,7 @@
LOGD("phLibNfc_RemoteDev_Disconnect() returned 0x%04x[%s]", status, trustednfc_jni_get_status_name(status));
}
-static jbyteArray com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doTransceive(JNIEnv *e,
+static jbyteArray com_android_nfc_NativeNfcTag_doTransceive(JNIEnv *e,
jobject o, jbyteArray data)
{
uint8_t offset = 0;
@@ -519,7 +514,7 @@
return result;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeNfcTag_checkNDEF(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NativeNfcTag_checkNDEF(JNIEnv *e, jobject o)
{
phLibNfc_Handle handle = 0;
NFCSTATUS status;
@@ -563,28 +558,28 @@
static JNINativeMethod gMethods[] =
{
{"doConnect", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doConnect},
+ (void *)com_android_nfc_NativeNfcTag_doConnect},
{"doDisconnect", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doDisconnect},
+ (void *)com_android_nfc_NativeNfcTag_doDisconnect},
{"doAsyncDisconnect", "()V",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doAsyncDisconnect},
+ (void *)com_android_nfc_NativeNfcTag_doAsyncDisconnect},
{"doTransceive", "([B)[B",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doTransceive},
+ (void *)com_android_nfc_NativeNfcTag_doTransceive},
{"checkNDEF", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_checkNDEF},
+ (void *)com_android_nfc_NativeNfcTag_checkNDEF},
{"doRead", "()[B",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doRead},
+ (void *)com_android_nfc_NativeNfcTag_doRead},
{"doWrite", "([B)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeNfcTag_doWrite},
+ (void *)com_android_nfc_NativeNfcTag_doWrite},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeNfcTag(JNIEnv *e)
+int register_com_android_nfc_NativeNfcTag(JNIEnv *e)
{
if(sem_init(&trustednfc_jni_tag_sem, 0, 0) == -1)
return -1;
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeNfcTag",
+ "com/android/nfc/NativeNfcTag",
gMethods, NELEM(gMethods));
}
diff --git a/jni/com_trustedlogic_trustednfc_android_internal_NativeP2pDevice.cpp b/jni/com_trustedlogic_trustednfc_android_internal_NativeP2pDevice.cpp
index 51f316a..e1133d3 100644
--- a/jni/com_trustedlogic_trustednfc_android_internal_NativeP2pDevice.cpp
+++ b/jni/com_trustedlogic_trustednfc_android_internal_NativeP2pDevice.cpp
@@ -15,11 +15,6 @@
* limitations under the License.
*/
-/**
- * File : com_trustedlogic_trustednfc_android_internal_NativeP2pDevice.c
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created : 04-03-2010
- */
#include <semaphore.h>
#include "trustednfc_jni.h"
@@ -122,7 +117,7 @@
sem_post(&trustednfc_jni_peer_sem);
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doConnect(JNIEnv *e, jobject o)
+static jboolean com_android_nfc_NativeP2pDevice_doConnect(JNIEnv *e, jobject o)
{
phLibNfc_Handle handle = 0;
NFCSTATUS status;
@@ -186,7 +181,7 @@
return result;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doDisconnect(JNIEnv *e,
+static jboolean com_android_nfc_NativeP2pDevice_doDisconnect(JNIEnv *e,
jobject o)
{
phLibNfc_Handle handle = 0;
@@ -233,7 +228,7 @@
return result;
}
-static jbyteArray com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doTransceive(JNIEnv *e,
+static jbyteArray com_android_nfc_NativeP2pDevice_doTransceive(JNIEnv *e,
jobject o, jbyteArray data)
{
NFCSTATUS status;
@@ -304,7 +299,7 @@
}
-static jbyteArray com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doReceive(
+static jbyteArray com_android_nfc_NativeP2pDevice_doReceive(
JNIEnv *e, jobject o)
{
NFCSTATUS status;
@@ -348,7 +343,7 @@
return buf;
}
-static jboolean com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doSend(
+static jboolean com_android_nfc_NativeP2pDevice_doSend(
JNIEnv *e, jobject o, jbyteArray buf)
{
NFCSTATUS status;
@@ -401,24 +396,24 @@
static JNINativeMethod gMethods[] =
{
{"doConnect", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doConnect},
+ (void *)com_android_nfc_NativeP2pDevice_doConnect},
{"doDisconnect", "()Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doDisconnect},
+ (void *)com_android_nfc_NativeP2pDevice_doDisconnect},
{"doTransceive", "([B)[B",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doTransceive},
+ (void *)com_android_nfc_NativeP2pDevice_doTransceive},
{"doReceive", "()[B",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doReceive},
+ (void *)com_android_nfc_NativeP2pDevice_doReceive},
{"doSend", "([B)Z",
- (void *)com_trustedlogic_trustednfc_android_internal_NativeP2pDevice_doSend},
+ (void *)com_android_nfc_NativeP2pDevice_doSend},
};
-int register_com_trustedlogic_trustednfc_android_internal_NativeP2pDevice(JNIEnv *e)
+int register_com_android_nfc_NativeP2pDevice(JNIEnv *e)
{
if(sem_init(&trustednfc_jni_peer_sem, 0, 0) == -1)
return -1;
return jniRegisterNativeMethods(e,
- "com/trustedlogic/trustednfc/android/internal/NativeP2pDevice",
+ "com/android/nfc/NativeP2pDevice",
gMethods, NELEM(gMethods));
}
diff --git a/jni/trustednfc_jni.cpp b/jni/trustednfc_jni.cpp
index 56de361..e55032d 100644
--- a/jni/trustednfc_jni.cpp
+++ b/jni/trustednfc_jni.cpp
@@ -14,15 +14,41 @@
* limitations under the License.
*/
-/**
- * File : trustednfc_jni.c
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created : 26-08-2009
- */
#include "errno.h"
#include "trustednfc_jni.h"
#include "phLibNfcStatus.h"
+/*
+ * JNI Initialization
+ */
+jint JNI_OnLoad(JavaVM *jvm, void *reserved)
+{
+ JNIEnv *e;
+
+ LOGE("NFC Service : loading JNI\n");
+
+ // Check JNI version
+ if(jvm->GetEnv((void **)&e, JNI_VERSION_1_6))
+ return JNI_ERR;
+
+ if (android::register_com_android_nfc_NativeNfcManager(e) == -1)
+ return JNI_ERR;
+ if (android::register_com_android_nfc_NativeNfcTag(e) == -1)
+ return JNI_ERR;
+ if (android::register_com_android_nfc_NativeNdefTag(e) == -1)
+ return JNI_ERR;
+ if (android::register_com_android_nfc_NativeP2pDevice(e) == -1)
+ return JNI_ERR;
+ if (android::register_com_android_nfc_NativeLlcpSocket(e) == -1)
+ return JNI_ERR;
+ if (android::register_com_android_nfc_NativeLlcpConnectionlessSocket(e) == -1)
+ return JNI_ERR;
+ if (android::register_com_android_nfc_NativeLlcpServiceSocket(e) == -1)
+ return JNI_ERR;
+
+ return JNI_VERSION_1_6;
+}
+
namespace android {
extern struct trustednfc_jni_native_data *exported_nat;
@@ -185,44 +211,7 @@
return type;
}
-/*
- * JNI Initialization
- */
-// TODO: not used any more, to be removed
-/*
-jint JNI_OnLoad(JavaVM *jvm, void *reserved)
-{
- JNIEnv *e;
- LOGD("NFC Service : loading JNI\n");
-
- // Check JNI version
- if(jvm->GetEnv((void **)&e, JNI_VERSION_1_4))
- return JNI_ERR;
-
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeNfcManager(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeNfcTag(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeNdefTag(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_NdefMessage(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_NdefRecord(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeP2pDevice(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket(e) == -1)
- return JNI_ERR;
- if(android::register_com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket(e) == -1)
- return JNI_ERR;
-
-
- return JNI_VERSION_1_4;
-}
-*/
//Display status code
const char* trustednfc_jni_get_status_name(NFCSTATUS status)
diff --git a/jni/trustednfc_jni.h b/jni/trustednfc_jni.h
index b4d1b79..f102458 100644
--- a/jni/trustednfc_jni.h
+++ b/jni/trustednfc_jni.h
@@ -146,7 +146,7 @@
trustednfc_jni_native_monitor_t* trustednfc_jni_init_monitor(void);
trustednfc_jni_native_monitor_t* trustednfc_jni_get_monitor(void);
-/* P2P */
+/* P2P */
phLibNfc_Handle trustednfc_jni_get_p2p_device_handle(JNIEnv *e, jobject o);
jshort trustednfc_jni_get_p2p_device_mode(JNIEnv *e, jobject o);
@@ -157,18 +157,13 @@
/* LLCP */
phLibNfc_Handle trustednfc_jni_get_nfc_socket_handle(JNIEnv *e, jobject o);
-int register_com_trustedlogic_trustednfc_android_internal_NativeNfcManager(JNIEnv *e);
-int register_com_trustedlogic_trustednfc_android_internal_NativeNfcTag(JNIEnv *e);
-
-int register_com_trustedlogic_trustednfc_android_internal_NativeNdefTag(JNIEnv *e);
-int register_com_trustedlogic_trustednfc_android_NdefMessage(JNIEnv *e);
-int register_com_trustedlogic_trustednfc_android_NdefRecord(JNIEnv *e);
-
-int register_com_trustedlogic_trustednfc_android_internal_NativeP2pDevice(JNIEnv *e);
-
-int register_com_trustedlogic_trustednfc_android_internal_NativeLlcpConnectionlessSocket(JNIEnv *e);
-int register_com_trustedlogic_trustednfc_android_internal_NativeLlcpServiceSocket(JNIEnv *e);
-int register_com_trustedlogic_trustednfc_android_internal_NativeLlcpSocket(JNIEnv *e);
+int register_com_android_nfc_NativeNfcManager(JNIEnv *e);
+int register_com_android_nfc_NativeNfcTag(JNIEnv *e);
+int register_com_android_nfc_NativeNdefTag(JNIEnv *e);
+int register_com_android_nfc_NativeP2pDevice(JNIEnv *e);
+int register_com_android_nfc_NativeLlcpConnectionlessSocket(JNIEnv *e);
+int register_com_android_nfc_NativeLlcpServiceSocket(JNIEnv *e);
+int register_com_android_nfc_NativeLlcpSocket(JNIEnv *e);
} // namespace android
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5c68218..de6c724 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">Nfc Service</string>
+ <string name="nfcUserLabel">Nfc</string>
</resources>
diff --git a/src/com/android/nfc/NfcReceiver.java b/src/com/android/nfc/NfcReceiver.java
new file mode 100755
index 0000000..bfeec1f
--- /dev/null
+++ b/src/com/android/nfc/NfcReceiver.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.nfc;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+
+public class NfcReceiver extends BroadcastReceiver {
+ private static final String TAG = "NfcService";
+
+ private static NfcService mNfcService;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "Internal NFC Intent received");
+
+ if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
+ mNfcService = new NfcService(context);
+ }
+ }
+}
+
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index bddbafc..3c13b07 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -14,12 +14,16 @@
* limitations under the License.
*/
-package com.trustedlogic.trustednfc.android.server;
+package com.android.nfc;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.ListIterator;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.nfc.ErrorCodes;
import android.nfc.FormatException;
import android.nfc.ILlcpConnectionlessSocket;
@@ -32,32 +36,22 @@
import android.nfc.LlcpPacket;
import android.nfc.NdefMessage;
import android.nfc.Tag;
-//import android.nfc.NfcException;
-//import android.nfc.NfcManager;
import android.nfc.NfcAdapter;
-import com.trustedlogic.trustednfc.android.internal.NativeLlcpConnectionlessSocket;
-import com.trustedlogic.trustednfc.android.internal.NativeLlcpServiceSocket;
-import com.trustedlogic.trustednfc.android.internal.NativeLlcpSocket;
-import com.trustedlogic.trustednfc.android.internal.NativeNfcManager;
-import com.trustedlogic.trustednfc.android.internal.NativeNfcTag;
-import com.trustedlogic.trustednfc.android.internal.NativeP2pDevice;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Log;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
public class NfcService extends INfcAdapter.Stub implements Runnable {
- /**
- * NFC Service tag
- */
+ static {
+ System.loadLibrary("nfc_jni");
+ }
+
private static final String TAG = "NfcService";
/**
@@ -1082,6 +1076,7 @@
mContext = context;
mManager = new NativeNfcManager(mContext);
+ /* TODO(nxp)
mContext.registerReceiver(mNfcServiceReceiver, new IntentFilter(
NativeNfcManager.INTERNAL_LLCP_LINK_STATE_CHANGED_ACTION));
@@ -1090,20 +1085,22 @@
mContext.registerReceiver(mNfcServiceReceiver, new IntentFilter(
NativeNfcManager.INTERNAL_TARGET_DESELECTED_ACTION));
+*/
Thread thread = new Thread(null, this, "NfcService");
thread.start();
mManager.initializeNativeStructure();
- int nfcState = Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.NFC_ON, 0);
+ int nfcState = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.NFC_ON, 0);
- if (nfcState == NFC_STATE_ENABLED) {
- if (this._enable()) {
- }
+ if (nfcState == NFC_STATE_ENABLED) {
+ if (this._enable()) {
}
+ }
+ ServiceManager.addService("nfc", this);
}
public void run() {