summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nci/jni/NativeLlcpServiceSocket.cpp3
-rwxr-xr-xnci/jni/NativeNfcManager.cpp34
-rwxr-xr-xnci/jni/NativeNfcTag.cpp86
-rwxr-xr-xnci/jni/NfcTag.cpp3
-rw-r--r--nci/jni/PeerToPeer.cpp50
-rw-r--r--nci/jni/PeerToPeer.h19
-rwxr-xr-xsrc/com/android/nfc/NfcService.java1
-rw-r--r--src/com/android/nfc/SendUi.java2
8 files changed, 55 insertions, 143 deletions
diff --git a/nci/jni/NativeLlcpServiceSocket.cpp b/nci/jni/NativeLlcpServiceSocket.cpp
index ca57410..7572690 100644
--- a/nci/jni/NativeLlcpServiceSocket.cpp
+++ b/nci/jni/NativeLlcpServiceSocket.cpp
@@ -24,7 +24,6 @@ extern "C"
#include "nfa_api.h"
#include "nfa_p2p_api.h"
}
-extern tBRCM_JNI_HANDLE gNextJniHandle;
namespace android
@@ -56,7 +55,7 @@ static jobject nativeLlcpServiceSocket_doAccept(JNIEnv *e, jobject o, jint miu,
jfieldID f = 0;
tBRCM_JNI_HANDLE serverHandle; //handle of the local server
bool stat = false;
- tBRCM_JNI_HANDLE connHandle = gNextJniHandle++;
+ tBRCM_JNI_HANDLE connHandle = PeerToPeer::getInstance().getNewJniHandle ();
ALOGD ("%s: enter", __FUNCTION__);
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index 330e38d..40b9539 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -68,8 +68,6 @@ namespace android
** public variables and functions
**
*****************************************************************************/
-tBRCM_JNI_HANDLE gNextJniHandle = 1;
-long gJniVersion = 411;
namespace android
{
@@ -470,13 +468,13 @@ static jboolean nfcManager_initNativeStruc (JNIEnv* e, jobject o)
/* Initialize native cached references */
gCachedNfcManagerNotifyNdefMessageListeners = e->GetMethodID (cls,
- "notifyNdefMessageListeners",(gJniVersion >= 401) ? "(Lcom/android/nfc/dhimpl/NativeNfcTag;)V" : "(Lcom/android/nfc/NativeNfcTag;)V");
+ "notifyNdefMessageListeners", "(Lcom/android/nfc/dhimpl/NativeNfcTag;)V");
gCachedNfcManagerNotifyTransactionListeners = e->GetMethodID (cls,
"notifyTransactionListeners", "([B)V");
gCachedNfcManagerNotifyLlcpLinkActivation = e->GetMethodID (cls,
- "notifyLlcpLinkActivation",(gJniVersion >= 401) ? "(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V" : "(Lcom/android/nfc/NativeP2pDevice;)V");
+ "notifyLlcpLinkActivation", "(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V");
gCachedNfcManagerNotifyLlcpLinkDeactivated = e->GetMethodID (cls,
- "notifyLlcpLinkDeactivated",(gJniVersion >= 401) ? "(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V" : "(Lcom/android/nfc/NativeP2pDevice;)V");
+ "notifyLlcpLinkDeactivated", "(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V");
sCachedNfcManagerNotifyTargetDeselected = e->GetMethodID (cls,
"notifyTargetDeselected","()V");
gCachedNfcManagerNotifySeFieldActivated = e->GetMethodID (cls,
@@ -484,23 +482,14 @@ static jboolean nfcManager_initNativeStruc (JNIEnv* e, jobject o)
gCachedNfcManagerNotifySeFieldDeactivated = e->GetMethodID (cls,
"notifySeFieldDeactivated", "()V");
- if (gJniVersion > 235)
- {
- sCachedNfcManagerNotifySeApduReceived = e->GetMethodID(cls,
+ sCachedNfcManagerNotifySeApduReceived = e->GetMethodID(cls,
"notifySeApduReceived", "([B)V");
- sCachedNfcManagerNotifySeMifareAccess = e->GetMethodID(cls,
+ sCachedNfcManagerNotifySeMifareAccess = e->GetMethodID(cls,
"notifySeMifareAccess", "([B)V");
- sCachedNfcManagerNotifySeEmvCardRemoval = e->GetMethodID(cls,
+ sCachedNfcManagerNotifySeEmvCardRemoval = e->GetMethodID(cls,
"notifySeEmvCardRemoval", "()V");
- }
- else
- {
- sCachedNfcManagerNotifySeApduReceived = NULL;
- sCachedNfcManagerNotifySeMifareAccess = NULL;
- sCachedNfcManagerNotifySeEmvCardRemoval = NULL;
- }
if (nfc_jni_cache_object(e,gNativeNfcTagClassName, &(nat->cached_NfcTag)) == -1)
{
@@ -633,7 +622,7 @@ void nfaDeviceManagementCallback (UINT8 dmEvent, tNFA_DM_CBACK_DATA* eventData)
tNFA_BRCM_FW_BUILD_INFO* bldInfo =
(tNFA_BRCM_FW_BUILD_INFO*) eventData->p_vs_evt_data;
if (bldInfo != NULL) {
- ALOGD("BCM2079x NFC FW version %d.%d", bldInfo->patch.major_ver,
+ ALOGE("BCM2079x NFC FW version %d.%d", bldInfo->patch.major_ver,
bldInfo->patch.minor_ver);
}
sNfaBuildInfoEvent.notifyOne();
@@ -711,7 +700,7 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o)
SecureElement::getInstance().initialize (getNative(e, o));
nativeNfcTag_registerNdefTypeHandler ();
NfcTag::getInstance().initialize (getNative(e, o));
- PeerToPeer::getInstance().initialize (gJniVersion);
+ PeerToPeer::getInstance().initialize ();
PeerToPeer::getInstance().handleNfcOnOff (true);
/////////////////////////////////////////////////////////////////////////////////
@@ -939,7 +928,7 @@ static jobject nfcManager_doCreateLlcpServiceSocket (JNIEnv* e, jobject o, jint
jobject serviceSocket = NULL;
jclass clsNativeLlcpServiceSocket = NULL;
jfieldID f = 0;
- tBRCM_JNI_HANDLE jniHandle = gNextJniHandle++;
+ tBRCM_JNI_HANDLE jniHandle = PeerToPeer::getInstance().getNewJniHandle ();
const char* serviceName = e->GetStringUTFChars (sn, JNI_FALSE); //convert jstring, which is unicode, into char*
std::string serviceName2 (serviceName);
@@ -1090,7 +1079,7 @@ static jobject nfcManager_doCreateLlcpSocket (JNIEnv* e, jobject o, jint nSap, j
jobject clientSocket = NULL;
jclass clsNativeLlcpSocket;
jfieldID f;
- tBRCM_JNI_HANDLE jniHandle = gNextJniHandle++;
+ tBRCM_JNI_HANDLE jniHandle = PeerToPeer::getInstance().getNewJniHandle ();
bool stat = false;
stat = PeerToPeer::getInstance().createClient (jniHandle, miu, rw);
@@ -1582,8 +1571,7 @@ static JNINativeMethod gMethods[] =
*******************************************************************************/
int register_com_android_nfc_NativeNfcManager (JNIEnv *e)
{
- GetNumValue (NAME_JNI_VERSION, &gJniVersion, sizeof(gJniVersion));
- ALOGD ("%s: enter, %s=%lu", __FUNCTION__, NAME_JNI_VERSION, gJniVersion);
+ ALOGD ("%s: enter", __FUNCTION__);
PowerSwitch::getInstance ().initialize (PowerSwitch::UNKNOWN_LEVEL);
ALOGD ("%s: exit", __FUNCTION__);
return jniRegisterNativeMethods (e, gNativeNfcManagerClassName, gMethods, NELEM (gMethods));
diff --git a/nci/jni/NativeNfcTag.cpp b/nci/jni/NativeNfcTag.cpp
index 53c2384..25b9826 100755
--- a/nci/jni/NativeNfcTag.cpp
+++ b/nci/jni/NativeNfcTag.cpp
@@ -40,7 +40,6 @@ namespace android
extern bool nfcManager_isNfcActive();
extern int gGeneralTransceiveTimeout;
}
-extern long gJniVersion;
/*****************************************************************************
@@ -632,24 +631,6 @@ static bool switchRfInterface (tNFA_INTF_TYPE rfInterface)
return rVal;
}
-/*******************************************************************************
-**
-** Function: nativeNfcTag_doConnect_z
-**
-** Description: Connect to the tag in RF field.
-** e: JVM environment.
-** o: Java object.
-** targetHandle: Handle of the tag.
-**
-** Returns: True if ok.
-**
-*******************************************************************************/
-static jboolean nativeNfcTag_doConnect_z (JNIEnv *e, jobject o, jint targetHandle)
-{
- jint result = nativeNfcTag_doConnect (e, o, targetHandle);
- return result == NFCSTATUS_SUCCESS ? JNI_TRUE : JNI_FALSE;
-}
-
/*******************************************************************************
**
@@ -682,24 +663,6 @@ static jint nativeNfcTag_doReconnect (JNIEnv *e, jobject o)
return reSelect(intf);
}
-/*******************************************************************************
-**
-** Function: nativeNfcTag_doReconnect_z
-**
-** Description: Re-connect to the tag in RF field.
-** e: JVM environment.
-** o: Java object.
-**
-** Returns: True if ok.
-**
-*******************************************************************************/
-static jboolean nativeNfcTag_doReconnect_z (JNIEnv *e, jobject o)
-{
- ALOGD ("%s", __FUNCTION__);
- //do nothing as the tag has already been activated
- return JNI_TRUE;
-}
-
/*******************************************************************************
**
@@ -722,25 +685,6 @@ static jint nativeNfcTag_doHandleReconnect (JNIEnv *e, jobject o, jint targetHan
/*******************************************************************************
**
-** Function: nativeNfcTag_doHandleReconnect_z
-**
-** Description: Re-connect to the tag in RF field.
-** e: JVM environment.
-** o: Java object.
-** targetHandle: Handle of the tag.
-**
-** Returns: True if ok.
-**
-*******************************************************************************/
-static jboolean nativeNfcTag_doHandleReconnect_z (JNIEnv *e, jobject o, jint targetHandle)
-{
- ALOGD ("%s: targetHandle = %d", __FUNCTION__, targetHandle);
- return nativeNfcTag_doConnect_z (e, o, targetHandle);
-}
-
-
-/*******************************************************************************
-**
** Function: nativeNfcTag_doDisconnect
**
** Description: Deactivate the RF field.
@@ -852,7 +796,7 @@ static jbyteArray nativeNfcTag_doTransceive (JNIEnv *e, jobject o, jbyteArray da
{
if (natTag.mTechList[1] == TARGET_TYPE_MIFARE_CLASSIC)
{
- // MifareClassic tag, we do not support transeive for this
+ // MifareClassic tag, we do not support transceive for this
if (statusTargetLost)
{
targetLost = e->GetIntArrayElements (statusTargetLost, 0);
@@ -903,7 +847,7 @@ static jbyteArray nativeNfcTag_doTransceive (JNIEnv *e, jobject o, jbyteArray da
waitOk = sTransceiveEvent.wait (gGeneralTransceiveTimeout);
}
- if (waitOk == false) //if timeout occured
+ if (waitOk == false) //if timeout occurred
{
ALOGE ("%s: wait response timeout", __FUNCTION__);
if (targetLost)
@@ -1180,28 +1124,6 @@ TheEnd:
/*******************************************************************************
**
-** Function: nativeNfcTag_doCheckNdef_z
-**
-** Description: Does the tag contain a NDEF message?
-** e: JVM environment.
-** o: Java object.
-** ndefInfo: NDEF info.
-**
-** Returns: True if tag contains a NDEF message.
-**
-*******************************************************************************/
-static bool nativeNfcTag_doCheckNdef_z (JNIEnv *e, jobject o, jintArray ndefInfo)
-{
- ALOGD ("%s: enter", __FUNCTION__);
- jint result = nativeNfcTag_doCheckNdef (e, o, ndefInfo);
- bool retval = (result == NFA_STATUS_OK) ? JNI_TRUE : JNI_FALSE;
- ALOGD ("%s: exit; detected NDEF=%u", __FUNCTION__, retval);
- return retval;
-}
-
-
-/*******************************************************************************
-**
** Function: nativeNfcTag_resetPresenceCheck
**
** Description: Reset variables related to presence-check.
@@ -1545,9 +1467,7 @@ static JNINativeMethod gMethods[] =
*******************************************************************************/
int register_com_android_nfc_NativeNfcTag (JNIEnv *e)
{
- GetNumValue (NAME_JNI_VERSION, &gJniVersion, sizeof(gJniVersion));
- ALOGD ("%s: enter, %s=%ld", __FUNCTION__, NAME_JNI_VERSION, gJniVersion);
- ALOGD ("%s: exit; using %s", __FUNCTION__, gNativeNfcTagClassName);
+ ALOGD ("%s", __FUNCTION__);
return jniRegisterNativeMethods (e, gNativeNfcTagClassName, gMethods, NELEM (gMethods));
}
diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp
index ebec941..9d629a2 100755
--- a/nci/jni/NfcTag.cpp
+++ b/nci/jni/NfcTag.cpp
@@ -15,7 +15,6 @@ extern "C"
#include "rw_int.h"
}
-extern long gJniVersion;
namespace android
{
@@ -580,7 +579,7 @@ void NfcTag::fillNativeNfcTagMembers2 (JNIEnv* e, jclass tag_cls, jobject tag, t
ALOGD ("%s", fn);
jfieldID f = NULL;
- f = e->GetFieldID (tag_cls, (gJniVersion >= 401) ? "mConnectedTechIndex" : "mConnectedTechnology", "I");
+ f = e->GetFieldID (tag_cls, "mConnectedTechIndex", "I");
e->SetIntField (tag, f, (jint) 0);
}
diff --git a/nci/jni/PeerToPeer.cpp b/nci/jni/PeerToPeer.cpp
index 0622ac0..3c46a02 100644
--- a/nci/jni/PeerToPeer.cpp
+++ b/nci/jni/PeerToPeer.cpp
@@ -51,7 +51,7 @@ PeerToPeer::PeerToPeer ()
mNppTotalLen (0),
mNppReadSoFar (0),
mNdefTypeHandlerHandle (NFA_HANDLE_INVALID),
- mJniVersion (403)
+ mNextJniHandle (1)
{
unsigned long num = 0;
memset (mServers, 0, sizeof(mServers));
@@ -93,16 +93,13 @@ PeerToPeer& PeerToPeer::getInstance ()
** Function: initialize
**
** Description: Initialize member variables.
-** jniVersion: JNI version.
**
** Returns: None
**
*******************************************************************************/
-void PeerToPeer::initialize (long jniVersion)
+void PeerToPeer::initialize ()
{
ALOGD ("PeerToPeer::initialize");
- mJniVersion = jniVersion;
-
unsigned long num = 0;
if (GetNumValue ("P2P_LISTEN_TECH_MASK", &num, sizeof (num)))
@@ -1422,29 +1419,6 @@ void PeerToPeer::handleNfcOnOff (bool isOn)
// Start with no clients or servers
memset (mServers, 0, sizeof(mServers));
memset (mClients, 0, sizeof(mClients));
-
- //Android older than 4.0.3 (Ice Cream Sandwich) do not have SNEP in the
- //NFC service, so the JNI and stack have to implement SNEP.
- if (mJniVersion < 403)
- {
- {
- SyncEventGuard guard (mSnepDefaultServerStartStopEvent);
- stat = NFA_SnepStartDefaultServer (snepClientCallback);
- if (stat == NFA_STATUS_OK)
- mSnepDefaultServerStartStopEvent.wait (); //wait for NFA_SNEP_DEFAULT_SERVER_STARTED_EVT
- else
- ALOGE ("%s: fail start snep server; error=0x%X", fn, stat);
- }
-
- {
- SyncEventGuard guard (mSnepRegisterEvent);
- stat = NFA_SnepRegisterClient (snepClientCallback);
- if (stat == NFA_STATUS_OK)
- mSnepRegisterEvent.wait (); //wait for NFA_SNEP_REG_EVT
- else
- ALOGE ("%s: fail register snep client; error=0x%X", fn, stat);
- }
- }
}
else
{
@@ -2020,6 +1994,26 @@ void PeerToPeer::connectionEventHandler (UINT8 event, tNFA_CONN_EVT_DATA* eventD
}
+/*******************************************************************************
+**
+** Function: getNextJniHandle
+**
+** Description: Get a new JNI handle.
+**
+** Returns: A new JNI handle.
+**
+*******************************************************************************/
+tBRCM_JNI_HANDLE PeerToPeer::getNewJniHandle ()
+{
+ tBRCM_JNI_HANDLE newHandle = 0;
+
+ mNewJniHandleMutex.lock ();
+ newHandle = mNextJniHandle++;
+ mNewJniHandleMutex.unlock ();
+ return newHandle;
+}
+
+
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
diff --git a/nci/jni/PeerToPeer.h b/nci/jni/PeerToPeer.h
index b9c7b39..d689298 100644
--- a/nci/jni/PeerToPeer.h
+++ b/nci/jni/PeerToPeer.h
@@ -78,12 +78,11 @@ public:
** Function: initialize
**
** Description: Initialize member variables.
- ** jniVersion: JNI version.
**
** Returns: None
**
*******************************************************************************/
- void initialize (long jniVersion);
+ void initialize ();
/*******************************************************************************
@@ -320,6 +319,19 @@ public:
*******************************************************************************/
void handleNfcOnOff (bool isOn);
+
+ /*******************************************************************************
+ **
+ ** Function: getNextJniHandle
+ **
+ ** Description: Get a new JNI handle.
+ **
+ ** Returns: A new JNI handle.
+ **
+ *******************************************************************************/
+ tBRCM_JNI_HANDLE getNewJniHandle ();
+
+
private:
static const int sMax = 10;
static PeerToPeer sP2p;
@@ -335,7 +347,7 @@ private:
UINT32 mNppTotalLen;
UINT32 mNppReadSoFar;
tNFA_HANDLE mNdefTypeHandlerHandle;
- long mJniVersion;
+ tBRCM_JNI_HANDLE mNextJniHandle;
P2pServer *mServers [sMax];
P2pClient *mClients [sMax];
@@ -343,6 +355,7 @@ private:
SyncEvent mSnepDefaultServerStartStopEvent; // completion event for NFA_SnepStartDefaultServer(), NFA_SnepStopDefaultServer()
SyncEvent mSnepRegisterEvent; // completion event for NFA_SnepRegisterClient()
Mutex mDisconnectMutex; // synchronize the disconnect operation
+ Mutex mNewJniHandleMutex; // synchronize the creation of a new JNI handle
/*******************************************************************************
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 5f9fc21..3acfa1c 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -597,7 +597,6 @@ public class NfcService extends Application implements DeviceHostListener {
// A convenient way to stop the watchdog properly consists of
// disconnecting the tag. The polling loop shall be stopped before
// to avoid the tag being discovered again.
- applyRouting(true);
maybeDisconnectTarget();
mNfcDispatcher.setForegroundDispatch(null, null, null);
diff --git a/src/com/android/nfc/SendUi.java b/src/com/android/nfc/SendUi.java
index 23602c9..c54f54e 100644
--- a/src/com/android/nfc/SendUi.java
+++ b/src/com/android/nfc/SendUi.java
@@ -183,7 +183,7 @@ public class SendUi implements Animator.AnimatorListener, View.OnTouchListener,
// We're only allowed to use hardware acceleration if
// isHighEndGfx() returns true - otherwise, we're too limited
// on resources to do it.
- mHardwareAccelerated = ActivityManager.isHighEndGfx(mDisplay);
+ mHardwareAccelerated = ActivityManager.isHighEndGfx();
int hwAccelerationFlags = mHardwareAccelerated ?
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED : 0;