summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMartijn Coenen <martijn.coenen@nxp.com>2010-11-01 13:42:01 -0600
committerNick Pelly <npelly@google.com>2010-11-02 13:00:33 -0500
commitd3c57c0c2419d595b8de940254814b5935932b28 (patch)
tree964c1006cbeabaefaf79e8ed04404cfe9081b2b2 /src/com
parent21545af22f9b913ec9cb124287aab2fcb0cf2b3b (diff)
downloadpackages_apps_nfc-d3c57c0c2419d595b8de940254814b5935932b28.zip
packages_apps_nfc-d3c57c0c2419d595b8de940254814b5935932b28.tar.gz
packages_apps_nfc-d3c57c0c2419d595b8de940254814b5935932b28.tar.bz2
Fix empty or incorrect ndef message not sending Intent.
Will now send an intent with an empty NDEF message array attached Change-Id: I58d86c9b5cfff127581824ca6af410a503059cbb Signed-off-by: Nick Pelly <npelly@google.com>
Diffstat (limited to 'src/com')
-rwxr-xr-xsrc/com/android/nfc/NfcService.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index efc6367..dd8fa7a 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -2249,6 +2249,7 @@ public class NfcService extends Application {
NativeNfcTag nativeTag = (NativeNfcTag) msg.obj;
if (nativeTag.connect()) {
if (nativeTag.checkNdef()) {
+ boolean generateEmptyIntent = false;
byte[] buff = nativeTag.read();
if (buff != null) {
NdefMessage[] msgNdef = new NdefMessage[1];
@@ -2270,12 +2271,29 @@ public class NfcService extends Application {
nativeTag.disconnect();
}
} catch (FormatException e) {
- Log.w(TAG, "Unable to create NDEF message object (tag empty or not well formated)");
- nativeTag.disconnect();
+ // Create an intent anyway, without NDEF messages
+ generateEmptyIntent = true;
}
} else {
- Log.w(TAG, "Unable to read NDEF message (tag empty or not well formated)");
- nativeTag.disconnect();
+ // Create an intent anyway, without NDEF messages
+ generateEmptyIntent = true;
+ }
+ if (generateEmptyIntent) {
+ // Create an intent with an empty ndef message array
+ NdefTag tag = new NdefTag(nativeTag.getUid(),
+ TagTarget.internalTypeToRawTargets(nativeTag.getType()),
+ null, null, nativeTag.getHandle(),
+ TagTarget.internalTypeToNdefTargets(nativeTag.getType()),
+ new NdefMessage[][] { {} });
+ Intent intent = buildNdefTagIntent(tag);
+ Log.d(TAG, "NDEF tag found, but length 0 or invalid format, starting corresponding activity");
+ try {
+ mContext.startActivity(intent);
+ registerTagObject(nativeTag);
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "No activity found, disconnecting");
+ nativeTag.disconnect();
+ }
}
} else {
Intent intent = new Intent();