diff options
-rw-r--r-- | nxp/jni/com_android_nfc_NativeNfcManager.cpp | 64 | ||||
-rw-r--r-- | nxp/jni/com_android_nfc_NativeNfcTag.cpp | 4 | ||||
-rwxr-xr-x | nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java | 10 | ||||
-rwxr-xr-x | nxp/src/com/android/nfc/dhimpl/NativeNfcTag.java | 3 | ||||
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 15 |
5 files changed, 87 insertions, 9 deletions
diff --git a/nxp/jni/com_android_nfc_NativeNfcManager.cpp b/nxp/jni/com_android_nfc_NativeNfcManager.cpp index e144ea99..b8fa9d56 100644 --- a/nxp/jni/com_android_nfc_NativeNfcManager.cpp +++ b/nxp/jni/com_android_nfc_NativeNfcManager.cpp @@ -81,6 +81,11 @@ static void nfc_jni_transaction_callback(void *context, phLibNfc_uSeEvtInfo_t *evt_info, NFCSTATUS status); static bool performDownload(struct nfc_jni_native_data *nat, bool takeLock); +extern void set_target_activationBytes(JNIEnv *e, jobject tag, + phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo); +extern void set_target_pollBytes(JNIEnv *e, jobject tag, + phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo); + /* * Deferred callback called when client thread must be exited */ @@ -1051,6 +1056,10 @@ static void nfc_jni_Discovery_notification_callback(void *pContext, f = e->GetFieldID(tag_cls.get(), "mConnectedHandle", "I"); e->SetIntField(tag.get(), f,(jint)-1); + + set_target_pollBytes(e, tag.get(), psRemoteDevList->psRemoteDevInfo); + + set_target_activationBytes(e, tag.get(), psRemoteDevList->psRemoteDevInfo); } storedHandle = remDevHandle; @@ -2419,6 +2428,55 @@ static void com_android_nfc_NfcManager_doAbort(JNIEnv *e, jobject o) emergency_recovery(NULL); } +static void com_android_nfc_NfcManager_doEnableReaderMode(JNIEnv *e, jobject o, + jint modes) +{ + struct nfc_jni_native_data *nat = NULL; + nat = nfc_jni_get_nat(e, o); + CONCURRENCY_LOCK(); + nat->p2p_initiator_modes = 0; + nat->p2p_target_modes = 0; + nat->discovery_cfg.PollDevInfo.PollCfgInfo.DisableCardEmulation = TRUE; + nat->discovery_cfg.Duration = 100000; /* in ms */ + if ((modes & 0x01) == 0) + { + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso14443A = FALSE; + } + if ((modes & 0x02) == 0) + { + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso14443B = FALSE; + } + if ((modes & 0x04) == 0) + { + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableFelica212 = FALSE; + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableFelica424 = FALSE; + } + if ((modes & 0x08) == 0) + { + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso15693 = FALSE; + } + nfc_jni_start_discovery_locked(nat, FALSE); + CONCURRENCY_UNLOCK(); +} + +static void com_android_nfc_NfcManager_doDisableReaderMode(JNIEnv *e, jobject o) +{ + struct nfc_jni_native_data *nat = NULL; + nat = nfc_jni_get_nat(e, o); + CONCURRENCY_LOCK(); + nat->p2p_initiator_modes = phNfc_eP2P_ALL; + nat->p2p_target_modes = 0x0E; // All passive except 106, active + nat->discovery_cfg.PollDevInfo.PollCfgInfo.DisableCardEmulation = FALSE; + nat->discovery_cfg.Duration = 300000; /* in ms */ + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso14443A = TRUE; + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso14443B = TRUE; + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableFelica212 = TRUE; + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableFelica424 = TRUE; + nat->discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso15693 = TRUE; + nfc_jni_start_discovery_locked(nat, FALSE); + CONCURRENCY_UNLOCK(); +} + static void com_android_nfc_NfcManager_doSetP2pInitiatorModes(JNIEnv *e, jobject o, jint modes) { @@ -2620,6 +2678,12 @@ static JNINativeMethod gMethods[] = {"doSetP2pTargetModes","(I)V", (void *)com_android_nfc_NfcManager_doSetP2pTargetModes}, + {"doEnableReaderMode","(I)V", + (void *)com_android_nfc_NfcManager_doEnableReaderMode}, + + {"doDisableReaderMode","()V", + (void *)com_android_nfc_NfcManager_doDisableReaderMode}, + {"doDump", "()Ljava/lang/String;", (void *)com_android_nfc_NfcManager_doDump}, }; diff --git a/nxp/jni/com_android_nfc_NativeNfcTag.cpp b/nxp/jni/com_android_nfc_NativeNfcTag.cpp index 1f469e4f..2badff42 100644 --- a/nxp/jni/com_android_nfc_NativeNfcTag.cpp +++ b/nxp/jni/com_android_nfc_NativeNfcTag.cpp @@ -291,7 +291,7 @@ clean_and_return: /* * Utility to recover poll bytes from target infos */ -static void set_target_pollBytes(JNIEnv *e, jobject tag, +void set_target_pollBytes(JNIEnv *e, jobject tag, phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo) { ScopedLocalRef<jclass> tag_cls(e, e->GetObjectClass(tag)); @@ -372,7 +372,7 @@ static void set_target_pollBytes(JNIEnv *e, jobject tag, /* * Utility to recover activation bytes from target infos */ -static void set_target_activationBytes(JNIEnv *e, jobject tag, +void set_target_activationBytes(JNIEnv *e, jobject tag, phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo) { ScopedLocalRef<jclass> tag_cls(e, e->GetObjectClass(tag)); diff --git a/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java index dca07872..108025c0 100755 --- a/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java +++ b/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java @@ -359,14 +359,16 @@ public class NativeNfcManager implements DeviceHost { doSetP2pTargetModes(modes); } + private native void doEnableReaderMode(int technologies); public boolean enableReaderMode(int technologies) { - // Not supported yet on NXP chipsets - return false; + doEnableReaderMode(technologies); + return true; } + private native void doDisableReaderMode(); public boolean disableReaderMode() { - // Not supported yet on NXP chipsets - return false; + doDisableReaderMode(); + return true; } @Override diff --git a/nxp/src/com/android/nfc/dhimpl/NativeNfcTag.java b/nxp/src/com/android/nfc/dhimpl/NativeNfcTag.java index 05de6a58..7be5a0ff 100755 --- a/nxp/src/com/android/nfc/dhimpl/NativeNfcTag.java +++ b/nxp/src/com/android/nfc/dhimpl/NativeNfcTag.java @@ -207,6 +207,9 @@ public class NativeNfcTag implements TagEndpoint { // Once we start presence checking, we allow the upper layers // to know the tag is in the field. mIsPresent = true; + if (mConnectedTechIndex == -1 && mTechList.length > 0) { + connect(mTechList[0]); + } if (mWatchdog == null) { mWatchdog = new PresenceCheckWatchdog(presenceCheckDelay); mWatchdog.start(); diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 34a1a54c..de3dff3f 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -2347,15 +2347,24 @@ public class NfcService implements DeviceHostListener { Tag tag = new Tag(tagEndpoint.getUid(), tagEndpoint.getTechList(), tagEndpoint.getTechExtras(), tagEndpoint.getHandle(), mNfcTagService); registerTagObject(tagEndpoint); - if (readerParams != null && readerParams.callback != null) { + if (readerParams != null) { try { - readerParams.callback.onTagDiscovered(tag); if ((readerParams.flags & NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS) == 0) { playSound(SOUND_END); } - return; + if (readerParams.callback != null) { + readerParams.callback.onTagDiscovered(tag); + return; + } else { + // Follow normal dispatch below + } } catch (RemoteException e) { Log.e(TAG, "Reader mode remote has died, falling back."); + // Intentional fall-through + } catch (Exception e) { + // Catch any other exception + Log.e(TAG, "App exception, not dispatching."); + return; } } if (!mNfcDispatcher.dispatchTag(tag)) { |