summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xnci/jni/NativeNfcManager.cpp35
-rwxr-xr-xnci/jni/NativeNfcTag.cpp2
-rwxr-xr-xnci/jni/SecureElement.cpp5
-rwxr-xr-xnci/jni/SecureElement.h1
-rw-r--r--src/com/android/nfc/handover/HandoverManager.java5
5 files changed, 31 insertions, 17 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index ca1bb06..b97a20f 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -504,8 +504,6 @@ static jboolean nfcManager_initNativeStruc (JNIEnv* e, jobject o)
return JNI_FALSE;
}
- PowerSwitch::getInstance ().initialize (PowerSwitch::FULL_POWER);
-
ALOGD ("%s: exit", __FUNCTION__);
return JNI_TRUE;
}
@@ -660,6 +658,8 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o)
goto TheEnd;
}
+ PowerSwitch::getInstance ().initialize (PowerSwitch::FULL_POWER);
+
{
unsigned long num = 0;
tBRCM_DEV_INIT_CONFIG devInitConfig;
@@ -760,6 +760,7 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o)
}
TheEnd:
+ PowerSwitch::getInstance ().setLevel (PowerSwitch::LOW_POWER);
ALOGD ("%s: exit", __FUNCTION__);
return sIsNfaEnabled ? JNI_TRUE : JNI_FALSE;
}
@@ -852,8 +853,6 @@ void nfcManager_disableDiscovery (JNIEnv* e, jobject o)
if (sDiscoveryEnabled == false)
{
ALOGD ("%s: already disabled", __FUNCTION__);
- if (! sIsSecElemSelected)
- PowerSwitch::getInstance ().setLevel (PowerSwitch::LOW_POWER);
goto TheEnd;
}
@@ -874,7 +873,9 @@ void nfcManager_disableDiscovery (JNIEnv* e, jobject o)
}
PeerToPeer::getInstance().enableP2pListening (false);
- PowerSwitch::getInstance ().setLevel (PowerSwitch::LOW_POWER);
+
+ if (!sIsSecElemSelected)
+ PowerSwitch::getInstance ().setLevel (PowerSwitch::LOW_POWER);
TheEnd:
ALOGD ("%s: exit", __FUNCTION__);
@@ -1231,7 +1232,6 @@ static void nfcManager_doDeselectSecureElement(JNIEnv *e, jobject o)
{
ALOGD ("%s: enter", __FUNCTION__);
bool stat = false;
- bool isPowerLevelChanged = false;
if (! sIsSecElemSelected)
{
@@ -1257,7 +1257,7 @@ static void nfcManager_doDeselectSecureElement(JNIEnv *e, jobject o)
TheEnd:
//if power level was changed at the top of this method,
//then restore to low power
- if (isPowerLevelChanged || (!PowerSwitch::getInstance().isScreenOn() && (sDiscoveryEnabled == false)) )
+ if (!sDiscoveryEnabled)
PowerSwitch::getInstance ().setLevel (PowerSwitch::LOW_POWER);
ALOGD ("%s: exit", __FUNCTION__);
}
@@ -1635,6 +1635,7 @@ void doStartupConfig()
{
unsigned long num = 0;
struct nfc_jni_native_data *nat = getNative(0, 0);
+ tNFA_STATUS stat = NFA_STATUS_FAILED;
// Enable the "RC workaround" to allow our stack/firmware to work with a retail
// Nexus S that causes IOP issues. Only enable if value exists and set to 1.
@@ -1647,14 +1648,20 @@ void doStartupConfig()
#endif
ALOGD ("%s: Configure RC work-around", __FUNCTION__);
- NFA_SetConfig(NCI_PARAM_ID_FW_WORKAROUND, sizeof(nfa_dm_rc_workaround), &nfa_dm_rc_workaround[0]);
+ SyncEventGuard guard (sNfaSetConfigEvent);
+ stat = NFA_SetConfig(NCI_PARAM_ID_FW_WORKAROUND, sizeof(nfa_dm_rc_workaround), &nfa_dm_rc_workaround[0]);
+ if (stat == NFA_STATUS_OK)
+ sNfaSetConfigEvent.wait ();
}
// If polling for Active mode, set the ordering so that we choose Active over Passive mode first.
if (nat && (nat->tech_mask & (NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE)))
{
UINT8 act_mode_order_param[] = { 0x01 };
- NFA_SetConfig(NCI_PARAM_ID_ACT_ORDER, sizeof(act_mode_order_param), &act_mode_order_param[0]);
+ SyncEventGuard guard (sNfaSetConfigEvent);
+ stat = NFA_SetConfig(NCI_PARAM_ID_ACT_ORDER, sizeof(act_mode_order_param), &act_mode_order_param[0]);
+ if (stat == NFA_STATUS_OK)
+ sNfaSetConfigEvent.wait ();
}
// Set configuration to allow UICC to Power off if there is no traffic.
@@ -1674,7 +1681,10 @@ void doStartupConfig()
UINT8 * p = &swpcfg_param[12];
UINT32_TO_STREAM(p, num)
- NFA_SetConfig(NCI_PARAM_ID_SWPCFG, sizeof(swpcfg_param), &swpcfg_param[0]);
+ SyncEventGuard guard (sNfaSetConfigEvent);
+ stat = NFA_SetConfig(NCI_PARAM_ID_SWPCFG, sizeof(swpcfg_param), &swpcfg_param[0]);
+ if (stat == NFA_STATUS_OK)
+ sNfaSetConfigEvent.wait ();
}
// Set antenna tuning configuration if configured.
@@ -1683,7 +1693,10 @@ void doStartupConfig()
if (GetStrValue(NAME_PREINIT_DSP_CFG, (char*)&preinit_dsp_param[0], sizeof(preinit_dsp_param)))
{
- NFA_SetConfig(NCI_PARAM_ID_PREINIT_DSP_CFG, sizeof(preinit_dsp_param), &preinit_dsp_param[0]);
+ SyncEventGuard guard (sNfaSetConfigEvent);
+ stat = NFA_SetConfig(NCI_PARAM_ID_PREINIT_DSP_CFG, sizeof(preinit_dsp_param), &preinit_dsp_param[0]);
+ if (stat == NFA_STATUS_OK)
+ sNfaSetConfigEvent.wait ();
}
}
diff --git a/nci/jni/NativeNfcTag.cpp b/nci/jni/NativeNfcTag.cpp
index b4b517b..d4281ce 100755
--- a/nci/jni/NativeNfcTag.cpp
+++ b/nci/jni/NativeNfcTag.cpp
@@ -857,7 +857,7 @@ static jbyteArray nativeNfcTag_doTransceive (JNIEnv *e, jobject o, jbyteArray da
{
ALOGE ("%s: wait response timeout", __FUNCTION__);
if (targetLost)
- *targetLost = 2; //causes NFC service to throw IOException
+ *targetLost = 1; //causes NFC service to throw TagLostException
break;
}
diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp
index e4d9400..57c33bb 100755
--- a/nci/jni/SecureElement.cpp
+++ b/nci/jni/SecureElement.cpp
@@ -36,6 +36,7 @@ bool gUseStaticPipe = false; // if true, use gGatePipe as static pipe id. if
SecureElement SecureElement::sSecElem;
+const char* SecureElement::APP_NAME = "nfc_jni";
/*******************************************************************************
@@ -184,7 +185,7 @@ bool SecureElement::initialize (nfc_jni_native_data* native)
SyncEventGuard guard (mHciRegisterEvent);
- nfaStat = NFA_HciRegister (const_cast<char*>("nfc_jni"), nfaHciCallback, TRUE);
+ nfaStat = NFA_HciRegister (const_cast<char*>(APP_NAME), nfaHciCallback, TRUE);
if (nfaStat != NFA_STATUS_OK)
{
ALOGE ("%s: fail hci register; error=0x%X", fn, nfaStat);
@@ -223,7 +224,7 @@ void SecureElement::finalize ()
NFA_EeDeregister (nfaEeCallback);
if (mNfaHciHandle != NFA_HANDLE_INVALID)
- NFA_HciDeregister (const_cast<char*>("brcm_jni"));
+ NFA_HciDeregister (const_cast<char*>(APP_NAME));
mNfaHciHandle = NFA_HANDLE_INVALID;
mNativeData = NULL;
diff --git a/nci/jni/SecureElement.h b/nci/jni/SecureElement.h
index 65e779e..bfa54cc 100755
--- a/nci/jni/SecureElement.h
+++ b/nci/jni/SecureElement.h
@@ -347,6 +347,7 @@ private:
static const tNFA_HANDLE EE_HANDLE_0xF3 = 0x4F3; //handle to secure element in slot 0
static const tNFA_HANDLE EE_HANDLE_0xF4 = 0x4F4; //handle to secure element in slot 1
static SecureElement sSecElem;
+ static const char* APP_NAME;
UINT8 mDestinationGate; //destination gate of the UICC
tNFA_HANDLE mNfaHciHandle; //NFA handle to NFA's HCI component
diff --git a/src/com/android/nfc/handover/HandoverManager.java b/src/com/android/nfc/handover/HandoverManager.java
index 8983389..b4c2025 100644
--- a/src/com/android/nfc/handover/HandoverManager.java
+++ b/src/com/android/nfc/handover/HandoverManager.java
@@ -390,8 +390,7 @@ public class HandoverManager implements BluetoothProfile.ServiceListener,
notBuilder.setContentText(mContext.getString(R.string.beam_touch_to_view));
Intent viewIntent = buildViewIntent();
- PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, viewIntent,
- Intent.FLAG_ACTIVITY_NEW_TASK);
+ PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, viewIntent, 0);
notBuilder.setContentIntent(contentIntent);
@@ -538,7 +537,7 @@ public class HandoverManager implements BluetoothProfile.ServiceListener,
Uri uri = mediaUri != null ? mediaUri :
Uri.parse(ContentResolver.SCHEME_FILE + "://" + filePath);
viewIntent.setDataAndTypeAndNormalize(uri, mimeTypes.get(filePath));
-
+ viewIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return viewIntent;
}