RF 0N/OFF events management added in the NFC Service
Change-Id: Ie32d36949c3520f9ece9bcb3c6f7bab2f9b24023
diff --git a/jni/com_android_nfc_NativeNfcManager.cpp b/jni/com_android_nfc_NativeNfcManager.cpp
index 8f036d8..302f5bd 100644
--- a/jni/com_android_nfc_NativeNfcManager.cpp
+++ b/jni/com_android_nfc_NativeNfcManager.cpp
@@ -40,6 +40,9 @@
static jmethodID cached_NfcManager_notifyLlcpLinkDeactivated;
static jmethodID cached_NfcManager_notifyTargetDeselected;
+static jmethodID cached_NfcManager_notifySeFieldActivated;
+static jmethodID cached_NfcManager_notifySeFieldDeactivated;
+
namespace android {
phLibNfc_Handle hIncommingLlcpSocket;
@@ -1111,6 +1114,20 @@
}
}break;
+ case phLibNfc_eSE_EvtFieldOn:
+ {
+ TRACE("> SE EVT_FIELD_ON");
+ TRACE("Notify Nfc Service");
+ e->CallVoidMethod(nat->manager, cached_NfcManager_notifySeFieldActivated);
+ }break;
+
+ case phLibNfc_eSE_EvtFieldOff:
+ {
+ TRACE("> SE EVT_FIELD_OFF");
+ TRACE("Notify Nfc Service");
+ e->CallVoidMethod(nat->manager, cached_NfcManager_notifySeFieldDeactivated);
+ }break;
+
default:
{
TRACE("Unknown SE event");
@@ -1506,9 +1523,14 @@
"notifyLlcpLinkDeactivated","(Lcom/android/nfc/NativeP2pDevice;)V");
cached_NfcManager_notifyTargetDeselected = e->GetMethodID(cls,
- "notifyTargetDeselected","()V");
-
-
+ "notifyTargetDeselected","()V");
+
+ cached_NfcManager_notifySeFieldActivated = e->GetMethodID(cls,
+ "notifySeFieldActivated", "()V");
+
+ cached_NfcManager_notifySeFieldDeactivated = e->GetMethodID(cls,
+ "notifySeFieldDeactivated", "()V");
+
if(nfc_jni_cache_object(e,"com/android/nfc/NativeNfcTag",&(nat->cached_NfcTag)) == -1)
{
LOGD("Native Structure initialization failed");
diff --git a/src/com/android/nfc/NativeNfcManager.java b/src/com/android/nfc/NativeNfcManager.java
index 4230c51..6a50de4 100755
--- a/src/com/android/nfc/NativeNfcManager.java
+++ b/src/com/android/nfc/NativeNfcManager.java
@@ -128,4 +128,11 @@
mNfcService.sendMessage(NfcService.MSG_LLCP_LINK_DEACTIVATED, device);
}
+ private void notifySeFieldActivated() {
+ mNfcService.sendMessage(NfcService.MSG_SE_FIELD_ACTIVATED, null);
+ }
+
+ private void notifySeFieldDeactivated() {
+ mNfcService.sendMessage(NfcService.MSG_SE_FIELD_DEACTIVATED, null);
+ }
}
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 514fcab..79aba34 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -212,6 +212,8 @@
static final int MSG_SHOW_MY_TAG_ICON = 5;
static final int MSG_HIDE_MY_TAG_ICON = 6;
static final int MSG_MOCK_NDEF = 7;
+ static final int MSG_SE_FIELD_ACTIVATED = 8;
+ static final int MSG_SE_FIELD_DEACTIVATED = 9;
// TODO: none of these appear to be synchronized but are
// read/written from different threads (notably Binder threads)...
@@ -2689,6 +2691,24 @@
break;
}
+ case MSG_SE_FIELD_ACTIVATED:{
+ if (DBG) Log.d(TAG, "SE FIELD ACTIVATED");
+ Intent eventFieldOnIntent = new Intent();
+ eventFieldOnIntent.setAction(NfcAdapter.ACTION_RF_FIELD_ON_DETECTED);
+ if (DBG) Log.d(TAG, "Broadcasting Intent");
+ mContext.sendBroadcast(eventFieldOnIntent, NFC_PERM);
+ break;
+ }
+
+ case MSG_SE_FIELD_DEACTIVATED:{
+ if (DBG) Log.d(TAG, "SE FIELD DEACTIVATED");
+ Intent eventFieldOffIntent = new Intent();
+ eventFieldOffIntent.setAction(NfcAdapter.ACTION_RF_FIELD_OFF_DETECTED);
+ if (DBG) Log.d(TAG, "Broadcasting Intent");
+ mContext.sendBroadcast(eventFieldOffIntent, NFC_PERM);
+ break;
+ }
+
default:
Log.e(TAG, "Unknown message received");
break;