1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.apps.tag; 18 19 /** 20 * Tags that we've seen in the field, for testing purposes. 21 */ 22 public class MockNdefMessages { 23 24 /** 25 * A real NFC tag containing an NFC "smart poster". This smart poster 26 * consists of the text "NFC Forum Type 4 Tag" in english combined with 27 * the URL "http://www.nxp.com/nfc" 28 */ 29 public static final byte[] REAL_NFC_MSG = new byte[] { 30 (byte) 0xd1, // MB=1 ME=1 CF=0 SR=1 IL=0 TNF=001 31 (byte) 0x02, // Type Length = 2 32 (byte) 0x2b, // Payload Length = 43 33 (byte) 0x53, (byte) 0x70, // Type = {'S', 'p'} (smart poster) 34 35 // begin smart poster payload 36 // begin smart poster record #1 37 (byte) 0x91, // MB=1 ME=0 CF=0 SR=1 IL=0 TNF=001 38 (byte) 0x01, // Type Length = 1 39 (byte) 0x17, // Payload Length = 23 40 (byte) 0x54, // Type = {'T'} (Text data) 41 (byte) 0x02, // UTF-8 encoding, language code length = 2 42 (byte) 0x65, (byte) 0x6e, // language = {'e', 'n'} (english) 43 44 // Begin text data within smart poster record #1 45 (byte) 0x4e, // 'N' 46 (byte) 0x46, // 'F' 47 (byte) 0x43, // 'C' 48 (byte) 0x20, // ' ' 49 (byte) 0x46, // 'F' 50 (byte) 0x6f, // 'o' 51 (byte) 0x72, // 'r' 52 (byte) 0x75, // 'u' 53 (byte) 0x6d, // 'm' 54 (byte) 0x20, // ' ' 55 (byte) 0x54, // 'T' 56 (byte) 0x79, // 'y' 57 (byte) 0x70, // 'p' 58 (byte) 0x65, // 'e' 59 (byte) 0x20, // ' ' 60 (byte) 0x34, // '4' 61 (byte) 0x20, // ' ' 62 (byte) 0x54, // 'T' 63 (byte) 0x61, // 'a' 64 (byte) 0x67, // 'g' 65 // end Text data within smart poster record #1 66 // end smart poster record #1 67 68 // begin smart poster record #2 69 (byte) 0x51, // MB=0 ME=1 CF=0 SR=1 IL=0 TNF=001 70 (byte) 0x01, // Type Length = 1 71 (byte) 0x0c, // Payload Length = 12 72 (byte) 0x55, // Type = { 'U' } (URI) 73 74 // begin URI data within smart poster record #2 75 (byte) 0x01, // URI Prefix = 1 ("http://www.") 76 (byte) 0x6e, // 'n' 77 (byte) 0x78, // 'x' 78 (byte) 0x70, // 'p' 79 (byte) 0x2e, // '.' 80 (byte) 0x63, // 'c' 81 (byte) 0x6f, // 'o' 82 (byte) 0x6d, // 'm' 83 (byte) 0x2f, // '/' 84 (byte) 0x6e, // 'n' 85 (byte) 0x66, // 'f' 86 (byte) 0x63 // 'c' 87 // end URI data within smart poster record #2 88 // end smart poster record #2 89 // end smart poster payload 90 }; 91 92 93 /** 94 * A Smart Poster containing a URL and no text. This message was created 95 * using the NXP reference phone. 96 */ 97 public static final byte[] SMART_POSTER_URL_NO_TEXT = new byte[] { 98 (byte) 0xd1, (byte) 0x02, (byte) 0x0f, (byte) 0x53, (byte) 0x70, (byte) 0xd1, 99 (byte) 0x01, (byte) 0x0b, (byte) 0x55, (byte) 0x01, (byte) 0x67, (byte) 0x6f, 100 (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e, (byte) 0x63, 101 (byte) 0x6f, (byte) 0x6d 102 }; 103 104 /** 105 * A plain text tag in english. Generated using the NXP evaluation tool. 106 */ 107 public static final byte[] ENGLISH_PLAIN_TEXT = new byte[] { 108 (byte) 0xd1, (byte) 0x01, (byte) 0x1c, (byte) 0x54, (byte) 0x02, (byte) 0x65, 109 (byte) 0x6e, (byte) 0x53, (byte) 0x6f, (byte) 0x6d, (byte) 0x65, (byte) 0x20, 110 (byte) 0x72, (byte) 0x61, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x6d, 111 (byte) 0x20, (byte) 0x65, (byte) 0x6e, (byte) 0x67, (byte) 0x6c, (byte) 0x69, 112 (byte) 0x73, (byte) 0x68, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x78, 113 (byte) 0x74, (byte) 0x2e 114 }; 115 116 /** 117 * Smart Poster containing a URL and Text. Generated using the NXP 118 * evaluation tool. 119 */ 120 public static final byte[] SMART_POSTER_URL_AND_TEXT = new byte[] { 121 (byte) 0xd1, (byte) 0x02, (byte) 0x1c, (byte) 0x53, (byte) 0x70, (byte) 0x91, 122 (byte) 0x01, (byte) 0x09, (byte) 0x54, (byte) 0x02, (byte) 0x65, (byte) 0x6e, 123 (byte) 0x47, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, 124 (byte) 0x51, (byte) 0x01, (byte) 0x0b, (byte) 0x55, (byte) 0x01, (byte) 0x67, 125 (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e, 126 (byte) 0x63, (byte) 0x6f, (byte) 0x6d 127 }; 128 129 /** 130 * A plain URI. Generated using the NXP evaluation tool. 131 */ 132 public static final byte[] URI = new byte[] { 133 (byte) 0xd1, (byte) 0x01, (byte) 0x0b, (byte) 0x55, (byte) 0x01, (byte) 0x67, 134 (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e, 135 (byte) 0x63, (byte) 0x6f, (byte) 0x6d 136 }; 137 138 /** 139 * A vcard. Generated using the NXP evaluation tool. 140 */ 141 public static final byte[] VCARD = new byte[] { 142 (byte) 0xc2, (byte) 0x0c, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x05, 143 (byte) 0x74, (byte) 0x65, (byte) 0x78, (byte) 0x74, (byte) 0x2f, (byte) 0x78, 144 (byte) 0x2d, (byte) 0x76, (byte) 0x43, (byte) 0x61, (byte) 0x72, (byte) 0x64, 145 (byte) 0x42, (byte) 0x45, (byte) 0x47, (byte) 0x49, (byte) 0x4e, (byte) 0x3a, 146 (byte) 0x56, (byte) 0x43, (byte) 0x41, (byte) 0x52, (byte) 0x44, (byte) 0x0d, 147 (byte) 0x0a, (byte) 0x56, (byte) 0x45, (byte) 0x52, (byte) 0x53, (byte) 0x49, 148 (byte) 0x4f, (byte) 0x4e, (byte) 0x3a, (byte) 0x33, (byte) 0x2e, (byte) 0x30, 149 (byte) 0x0d, (byte) 0x0a, (byte) 0x46, (byte) 0x4e, (byte) 0x3a, (byte) 0x4a, 150 (byte) 0x6f, (byte) 0x65, (byte) 0x20, (byte) 0x47, (byte) 0x6f, (byte) 0x6f, 151 (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x20, (byte) 0x45, (byte) 0x6d, 152 (byte) 0x70, (byte) 0x6c, (byte) 0x6f, (byte) 0x79, (byte) 0x65, (byte) 0x65, 153 (byte) 0x0d, (byte) 0x0a, (byte) 0x41, (byte) 0x44, (byte) 0x52, (byte) 0x3b, 154 (byte) 0x54, (byte) 0x59, (byte) 0x50, (byte) 0x45, (byte) 0x3d, (byte) 0x57, 155 (byte) 0x4f, (byte) 0x52, (byte) 0x4b, (byte) 0x3a, (byte) 0x3b, (byte) 0x3b, 156 (byte) 0x31, (byte) 0x36, (byte) 0x30, (byte) 0x30, (byte) 0x20, (byte) 0x41, 157 (byte) 0x6d, (byte) 0x70, (byte) 0x68, (byte) 0x69, (byte) 0x74, (byte) 0x68, 158 (byte) 0x65, (byte) 0x61, (byte) 0x74, (byte) 0x72, (byte) 0x65, (byte) 0x20, 159 (byte) 0x50, (byte) 0x61, (byte) 0x72, (byte) 0x6b, (byte) 0x77, (byte) 0x61, 160 (byte) 0x79, (byte) 0x3b, (byte) 0x39, (byte) 0x34, (byte) 0x30, (byte) 0x34, 161 (byte) 0x33, (byte) 0x20, (byte) 0x4d, (byte) 0x6f, (byte) 0x75, (byte) 0x6e, 162 (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6e, (byte) 0x20, (byte) 0x56, 163 (byte) 0x69, (byte) 0x65, (byte) 0x77, (byte) 0x0d, (byte) 0x0a, (byte) 0x54, 164 (byte) 0x45, (byte) 0x4c, (byte) 0x3b, (byte) 0x54, (byte) 0x59, (byte) 0x50, 165 (byte) 0x45, (byte) 0x3d, (byte) 0x50, (byte) 0x52, (byte) 0x45, (byte) 0x46, 166 (byte) 0x2c, (byte) 0x57, (byte) 0x4f, (byte) 0x52, (byte) 0x4b, (byte) 0x3a, 167 (byte) 0x36, (byte) 0x35, (byte) 0x30, (byte) 0x2d, (byte) 0x32, (byte) 0x35, 168 (byte) 0x33, (byte) 0x2d, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, 169 (byte) 0x0d, (byte) 0x0a, (byte) 0x45, (byte) 0x4d, (byte) 0x41, (byte) 0x49, 170 (byte) 0x4c, (byte) 0x3b, (byte) 0x54, (byte) 0x59, (byte) 0x50, (byte) 0x45, 171 (byte) 0x3d, (byte) 0x49, (byte) 0x4e, (byte) 0x54, (byte) 0x45, (byte) 0x52, 172 (byte) 0x4e, (byte) 0x45, (byte) 0x54, (byte) 0x3a, (byte) 0x73, (byte) 0x75, 173 (byte) 0x70, (byte) 0x70, (byte) 0x6f, (byte) 0x72, (byte) 0x74, (byte) 0x40, 174 (byte) 0x67, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, 175 (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x0d, (byte) 0x0a, 176 (byte) 0x54, (byte) 0x49, (byte) 0x54, (byte) 0x4c, (byte) 0x45, (byte) 0x3a, 177 (byte) 0x53, (byte) 0x6f, (byte) 0x66, (byte) 0x74, (byte) 0x77, (byte) 0x61, 178 (byte) 0x72, (byte) 0x65, (byte) 0x20, (byte) 0x45, (byte) 0x6e, (byte) 0x67, 179 (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x65, (byte) 0x72, (byte) 0x0d, 180 (byte) 0x0a, (byte) 0x4f, (byte) 0x52, (byte) 0x47, (byte) 0x3a, (byte) 0x47, 181 (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x0d, 182 (byte) 0x0a, (byte) 0x55, (byte) 0x52, (byte) 0x4c, (byte) 0x3a, (byte) 0x68, 183 (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, 184 (byte) 0x77, (byte) 0x77, (byte) 0x77, (byte) 0x2e, (byte) 0x67, (byte) 0x6f, 185 (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e, (byte) 0x63, 186 (byte) 0x6f, (byte) 0x6d, (byte) 0x0d, (byte) 0x0a, (byte) 0x45, (byte) 0x4e, 187 (byte) 0x44, (byte) 0x3a, (byte) 0x56, (byte) 0x43, (byte) 0x41, (byte) 0x52, 188 (byte) 0x44, (byte) 0x0d, (byte) 0x0a 189 }; 190 191 /** 192 * Send the text message "hello world" to a phone number. This was generated using 193 * the NXP reference phone. 194 */ 195 public static final byte[] SEND_TEXT_MESSAGE = new byte[] { 196 (byte) 0xd1, (byte) 0x02, (byte) 0x25, (byte) 0x53, (byte) 0x70, (byte) 0xd1, 197 (byte) 0x01, (byte) 0x21, (byte) 0x55, (byte) 0x00, (byte) 0x73, (byte) 0x6d, 198 (byte) 0x73, (byte) 0x3a, (byte) 0x31, (byte) 0x36, (byte) 0x35, (byte) 0x30, 199 (byte) 0x32, (byte) 0x35, (byte) 0x33, (byte) 0x30, (byte) 0x30, (byte) 0x30, 200 (byte) 0x30, (byte) 0x3f, (byte) 0x62, (byte) 0x6f, (byte) 0x64, (byte) 0x79, 201 (byte) 0x3d, (byte) 0x48, (byte) 0x65, (byte) 0x6c, (byte) 0x6c, (byte) 0x6f, 202 (byte) 0x20, (byte) 0x77, (byte) 0x6f, (byte) 0x72, (byte) 0x6c, (byte) 0x64 203 }; 204 205 /** 206 * Call Google. Generated using the NXP reference phone. 207 */ 208 public static final byte[] CALL_GOOGLE = new byte[] { 209 (byte) 0xd1, (byte) 0x02, (byte) 0x10, (byte) 0x53, (byte) 0x70, (byte) 0xd1, 210 (byte) 0x01, (byte) 0x0c, (byte) 0x55, (byte) 0x05, (byte) 0x31, (byte) 0x36, 211 (byte) 0x35, (byte) 0x30, (byte) 0x32, (byte) 0x35, (byte) 0x33, (byte) 0x30, 212 (byte) 0x30, (byte) 0x30, (byte) 0x30 213 }; 214 215 /** 216 * All the real ndef messages we've seen in the field. 217 */ 218 public static final byte[][] ALL_MOCK_MESSAGES = new byte[][] { 219 REAL_NFC_MSG, SMART_POSTER_URL_NO_TEXT, ENGLISH_PLAIN_TEXT, 220 SMART_POSTER_URL_AND_TEXT, URI, VCARD, SEND_TEXT_MESSAGE, 221 CALL_GOOGLE 222 }; 223 224 } 225