/**@class android.nfc.tech.MifareClassic @extends android.nfc.tech.BasicTagTechnology Provides access to MIFARE Classic properties and I/O operations on a {@link Tag}. <p>Acquire a {@link android.nfc.tech.MifareClassic} object using {@link #get}. <p>MIFARE Classic is also known as MIFARE Standard. <p>MIFARE Classic tags are divided into sectors, and each sector is sub-divided into blocks. Block size is always 16 bytes ({@link #BLOCK_SIZE}. Sector size varies. <ul> <li>MIFARE Classic Mini are 320 bytes ({@link #SIZE_MINI}), with 5 sectors each of 4 blocks. <li>MIFARE Classic 1k are 1024 bytes ({@link #SIZE_1K}), with 16 sectors each of 4 blocks. <li>MIFARE Classic 2k are 2048 bytes ({@link #SIZE_2K}), with 32 sectors each of 4 blocks. <li>MIFARE Classic 4k are 4096 bytes ({@link #SIZE_4K}). The first 32 sectors contain 4 blocks and the last 8 sectors contain 16 blocks. </ul> <p>MIFARE Classic tags require authentication on a per-sector basis before any other I/O operations on that sector can be performed. There are two keys per sector, and ACL bits determine what I/O operations are allowed on that sector after authenticating with a key. {@see #authenticateSectorWithKeyA} and {@see #authenticateSectorWithKeyB}. <p>Three well-known authentication keys are defined in this class: {@link #KEY_DEFAULT}, {@link #KEY_MIFARE_APPLICATION_DIRECTORY}, {@link #KEY_NFC_FORUM}. <ul> <li>{@link #KEY_DEFAULT} is the default factory key for MIFARE Classic. <li>{@link #KEY_MIFARE_APPLICATION_DIRECTORY} is the well-known key for MIFARE Classic cards that have been formatted according to the MIFARE Application Directory (MAD) specification. <li>{@link #KEY_NFC_FORUM} is the well-known key for MIFARE Classic cards that have been formatted according to the NXP specification for NDEF on MIFARE Classic. <p>Implementation of this class on a Android NFC device is optional. If it is not implemented, then {@link android.nfc.tech.MifareClassic} will never be enumerated in {@link Tag#getTechList}. If it is enumerated, then all {@link android.nfc.tech.MifareClassic} I/O operations will be supported, and {@link android.nfc.tech.Ndef#MIFARE_CLASSIC} NDEF tags will also be supported. In either case, {@link android.nfc.tech.NfcA} will also be enumerated on the tag, because all MIFARE Classic tags are also {@link android.nfc.tech.NfcA}. <p class="note"><strong>Note:</strong> Methods that perform I/O operations require the {@link android.Manifest.permission#NFC} permission. */ var MifareClassic = { /** The default factory key. */ KEY_DEFAULT : "null", /** The well-known key for tags formatted according to the MIFARE Application Directory (MAD) specification. */ KEY_MIFARE_APPLICATION_DIRECTORY : "null", /** The well-known key for tags formatted according to the NDEF on MIFARE Classic specification. */ KEY_NFC_FORUM : "null", /**A MIFARE Classic compatible card of unknown type */ TYPE_UNKNOWN : "-1", /**A MIFARE Classic tag */ TYPE_CLASSIC : "0", /**A MIFARE Plus tag */ TYPE_PLUS : "1", /**A MIFARE Pro tag */ TYPE_PRO : "2", /**Tag contains 16 sectors, each with 4 blocks. */ SIZE_1K : "1024", /**Tag contains 32 sectors, each with 4 blocks. */ SIZE_2K : "2048", /** Tag contains 40 sectors. The first 32 sectors contain 4 blocks and the last 8 sectors contain 16 blocks. */ SIZE_4K : "4096", /**Tag contains 5 sectors, each with 4 blocks. */ SIZE_MINI : "320", /**Size of a MIFARE Classic block (in bytes) */ BLOCK_SIZE : "16", /**Get an instance of {@link android.nfc.tech.MifareClassic} for the given tag. <p>Does not cause any RF activity and does not block. <p>Returns null if {@link android.nfc.tech.MifareClassic} was not enumerated in {@link Tag#getTechList}. This indicates the tag is not MIFARE Classic compatible, or this Android device does not support MIFARE Classic. @param {Object {Tag}} tag an MIFARE Classic compatible tag @return {Object {android.nfc.tech.MifareClassic}} MIFARE Classic object */ get : function( ) {}, /**Return the type of this MIFARE Classic compatible tag. <p>One of {@link #TYPE_UNKNOWN}, {@link #TYPE_CLASSIC}, {@link #TYPE_PLUS} or {@link #TYPE_PRO}. <p>Does not cause any RF activity and does not block. @return {Number} type */ getType : function( ) {}, /**Return the size of the tag in bytes <p>One of {@link #SIZE_MINI}, {@link #SIZE_1K}, {@link #SIZE_2K}, {@link #SIZE_4K}. These constants are equal to their respective size in bytes. <p>Does not cause any RF activity and does not block. @return {Number} size in bytes */ getSize : function( ) {}, /**Return true if the tag is emulated, determined at discovery time. These are actually smart-cards that emulate a MIFARE Classic interface. They can be treated identically to a MIFARE Classic tag. @hide */ isEmulated : function( ) {}, /**Return the number of MIFARE Classic sectors. <p>Does not cause any RF activity and does not block. @return {Number} number of sectors */ getSectorCount : function( ) {}, /**Return the total number of MIFARE Classic blocks. <p>Does not cause any RF activity and does not block. @return {Number} total number of blocks */ getBlockCount : function( ) {}, /**Return the number of blocks in the given sector. <p>Does not cause any RF activity and does not block. @param {Number} sectorIndex index of sector, starting from 0 @return {Number} number of blocks in the sector */ getBlockCountInSector : function( ) {}, /**Return the sector that contains a given block. <p>Does not cause any RF activity and does not block. @param {Number} blockIndex index of block to lookup, starting from 0 @return {Number} sector index that contains the block */ blockToSector : function( ) {}, /**Return the first block of a given sector. <p>Does not cause any RF activity and does not block. @param {Number} sectorIndex index of sector to lookup, starting from 0 @return {Number} block index of first block in sector */ sectorToBlock : function( ) {}, /**Authenticate a sector with key A. <p>Successful authentication of a sector with key A enables other I/O operations on that sector. The set of operations granted by key A key depends on the ACL bits set in that sector. For more information see the MIFARE Classic specification on <a href="http://www.nxp.com">http://www.nxp.com</a>. <p>A failed authentication attempt causes an implicit reconnection to the tag, so authentication to other sectors will be lost. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} sectorIndex index of sector to authenticate, starting from 0 @param {Object {byte[]}} key 6-byte authentication key @return {Boolean} true on success, false on authentication failure @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ authenticateSectorWithKeyA : function( ) {}, /**Authenticate a sector with key B. <p>Successful authentication of a sector with key B enables other I/O operations on that sector. The set of operations granted by key B depends on the ACL bits set in that sector. For more information see the MIFARE Classic specification on <a href="http://www.nxp.com">http://www.nxp.com</a>. <p>A failed authentication attempt causes an implicit reconnection to the tag, so authentication to other sectors will be lost. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} sectorIndex index of sector to authenticate, starting from 0 @param {Object {byte[]}} key 6-byte authentication key @return {Boolean} true on success, false on authentication failure @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ authenticateSectorWithKeyB : function( ) {}, /**Read 16-byte block. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} blockIndex index of block to read, starting from 0 @return {Number} 16 byte block @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ readBlock : function( ) {}, /**Write 16-byte block. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} blockIndex index of block to write, starting from 0 @param {Object {byte[]}} data 16 bytes of data to write @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ writeBlock : function( ) {}, /**Increment a value block, storing the result in the temporary block on the tag. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} blockIndex index of block to increment, starting from 0 @param {Number} value non-negative to increment by @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ increment : function( ) {}, /**Decrement a value block, storing the result in the temporary block on the tag. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} blockIndex index of block to decrement, starting from 0 @param {Number} value non-negative to decrement by @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ decrement : function( ) {}, /**Copy from the temporary block to a value block. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} blockIndex index of block to copy to @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ transfer : function( ) {}, /**Copy from a value block to the temporary block. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} blockIndex index of block to copy from @throws TagLostException if the tag leaves the field @throws IOException if there is an I/O failure, or the operation is canceled */ restore : function( ) {}, /**Send raw NfcA data to a tag and receive the response. <p>This is equivalent to connecting to this tag via {@link android.nfc.tech.NfcA} and calling {@link android.nfc.tech.NfcA#transceive}. Note that all MIFARE Classic tags are based on {@link android.nfc.tech.NfcA} technology. <p>Use {@link #getMaxTransceiveLength} to retrieve the maximum number of bytes that can be sent with {@link #transceive}. <p>This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with {@link IOException} if {@link #close} is called from another thread. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @see NfcA#transceive */ transceive : function( ) {}, /**Return the maximum number of bytes that can be sent with {@link #transceive}. @return {Number} the maximum number of bytes that can be sent with {@link #transceive}. */ getMaxTransceiveLength : function( ) {}, /**Set the {@link #transceive} timeout in milliseconds. <p>The timeout only applies to {@link #transceive} on this object, and is reset to a default value when {@link #close} is called. <p>Setting a longer timeout may be useful when performing transactions that require a long processing time on the tag such as key generation. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @param {Number} timeout timeout value in milliseconds */ setTimeout : function( ) {}, /**Get the current {@link #transceive} timeout in milliseconds. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. @return {Number} timeout value in milliseconds */ getTimeout : function( ) {}, };