summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2012-01-24 13:30:32 -0800
committerNick Pelly <npelly@google.com>2012-01-26 13:32:47 -0800
commitea78e5beebff19ece23870b4ff5e5fd69d61aaa1 (patch)
treef3aed9baa257348dd0ceecd0268254a9c55c6c2a
parent550ef7b998f4185eaea992066e72409022ef096b (diff)
downloadpackages_apps_nfc-ea78e5beebff19ece23870b4ff5e5fd69d61aaa1.zip
packages_apps_nfc-ea78e5beebff19ece23870b4ff5e5fd69d61aaa1.tar.gz
packages_apps_nfc-ea78e5beebff19ece23870b4ff5e5fd69d61aaa1.tar.bz2
Don't need to pass the NdefMessage in dispatch().
Change-Id: Ib1463aa51b1ce48cf7217866cb7c11ab8caa4e06
-rw-r--r--src/com/android/nfc/NfcDispatcher.java8
-rwxr-xr-xsrc/com/android/nfc/NfcService.java14
2 files changed, 14 insertions, 8 deletions
diff --git a/src/com/android/nfc/NfcDispatcher.java b/src/com/android/nfc/NfcDispatcher.java
index 715dd57..2f442e6 100644
--- a/src/com/android/nfc/NfcDispatcher.java
+++ b/src/com/android/nfc/NfcDispatcher.java
@@ -35,6 +35,7 @@ import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
+import android.nfc.tech.Ndef;
import android.os.RemoteException;
import android.util.Log;
@@ -173,7 +174,12 @@ public class NfcDispatcher {
}
/** Returns false if no activities were found to dispatch to */
- public boolean dispatchTag(Tag tag, NdefMessage message) {
+ public boolean dispatchTag(Tag tag) {
+ NdefMessage message = null;
+ Ndef ndef = Ndef.get(tag);
+ if (ndef != null) {
+ message = ndef.getCachedNdefMessage();
+ }
if (DBG) Log.d(TAG, "dispatch tag: " + tag.toString() + " message: " + message);
PendingIntent overrideIntent;
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 3e16a2e..851e49b 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -782,9 +782,9 @@ public class NfcService extends Application implements DeviceHostListener {
}
@Override
- public void dispatch(Tag tag, NdefMessage message) throws RemoteException {
+ public void dispatch(Tag tag) throws RemoteException {
enforceAdminPerm(mContext);
- mNfcDispatcher.dispatchTag(tag, message);
+ mNfcDispatcher.dispatchTag(tag);
}
}
@@ -1538,7 +1538,7 @@ public class NfcService extends Application implements DeviceHostListener {
new Bundle[] { extras });
Log.d(TAG, "mock NDEF tag, starting corresponding activity");
Log.d(TAG, tag.toString());
- boolean delivered = mNfcDispatcher.dispatchTag(tag, ndefMsg);
+ boolean delivered = mNfcDispatcher.dispatchTag(tag);
if (delivered) {
playSound(SOUND_END);
} else {
@@ -1555,11 +1555,11 @@ public class NfcService extends Application implements DeviceHostListener {
if (ndefMsg != null) {
tag.startPresenceChecking();
- dispatchTagEndpoint(tag, ndefMsg);
+ dispatchTagEndpoint(tag);
} else {
if (tag.reconnect()) {
tag.startPresenceChecking();
- dispatchTagEndpoint(tag, null);
+ dispatchTagEndpoint(tag);
} else {
tag.disconnect();
playSound(SOUND_ERROR);
@@ -1747,11 +1747,11 @@ public class NfcService extends Application implements DeviceHostListener {
return false;
}
- private void dispatchTagEndpoint(TagEndpoint tagEndpoint, NdefMessage msg) {
+ private void dispatchTagEndpoint(TagEndpoint tagEndpoint) {
Tag tag = new Tag(tagEndpoint.getUid(), tagEndpoint.getTechList(),
tagEndpoint.getTechExtras(), tagEndpoint.getHandle(), mNfcTagService);
registerTagObject(tagEndpoint);
- if (!mNfcDispatcher.dispatchTag(tag, msg)) {
+ if (!mNfcDispatcher.dispatchTag(tag)) {
unregisterObject(tagEndpoint.getHandle());
playSound(SOUND_ERROR);
} else {