summaryrefslogtreecommitdiffstats
path: root/nxp
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2013-09-03 17:30:25 -0700
committerMartijn Coenen <maco@google.com>2013-09-03 17:30:25 -0700
commit3dd24ecefb71ce4f585faa002ba1054a0c6dbd06 (patch)
tree5f4da570c22828cc669865d86722085b6cdfcea7 /nxp
parent31f39aee25964dad1038b7a9cc335d5a386113c8 (diff)
downloadandroid_packages_apps_Nfc-3dd24ecefb71ce4f585faa002ba1054a0c6dbd06.tar.gz
android_packages_apps_Nfc-3dd24ecefb71ce4f585faa002ba1054a0c6dbd06.tar.bz2
android_packages_apps_Nfc-3dd24ecefb71ce4f585faa002ba1054a0c6dbd06.zip
Implement reader mode API for NXP chipsets.
Bug: 10360259 Change-Id: I1339840ed900b73d3f9ae43e1a01b59c7e679f9e
Diffstat (limited to 'nxp')
-rw-r--r--nxp/jni/com_android_nfc_NativeNfcManager.cpp64
-rw-r--r--nxp/jni/com_android_nfc_NativeNfcTag.cpp4
-rwxr-xr-xnxp/src/com/android/nfc/dhimpl/NativeNfcManager.java10
-rwxr-xr-xnxp/src/com/android/nfc/dhimpl/NativeNfcTag.java3
4 files changed, 75 insertions, 6 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();