Package amlib.ccid

It provides classes to communicating with AlcorMicro smart card reader on Android 3.1 or above.

See:
          Description

Class Summary
Error  
Reader  
Reader4428  
Reader4442  
 

Exception Summary
ReaderException  
 

Package amlib.ccid Description

It provides classes to communicating with AlcorMicro smart card reader on Android 3.1 or above.

To create Reader object
Object HardwareInterface is needed when constructing a class Reader,
you should create and initial 'HardwareInterface myDev' before create Reader

  Reader myReader

  try {
      mReader = new Reader(myDev);                      
  }
  catch(Exception e){
       e.printStackTrace();
  }
 
To connect to Reader object
  int status;
  try {
       status = mReader.connect();
   }
   catch(Exception e){
       e.printStackTrace();
  }
  

To power on/power off ICC
  int status;
  try {
       status = mReader.setPower(Reader.CCID_POWERON );
   }
   catch(Exception e){
       e.printStackTrace();
  }
  try {
       status = mReader.setPower(Reader.CCID_POWEROFF );
   }
   catch(Exception e){
       e.printStackTrace();
  }
  

Transmitting APDU
  byte pSendAPDU[] = new byte[] {(byte) 0xA0, (byte) 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00};
  byte pRxBuff[] = new byte [128];
  int pRxLen[] = new int[1];
  int status;
  try{
      status = mReader.transmit(pSendAPDU, pSendAPDU.legnth, pRxBuff, pRxLen);
      if (status != error.READER_SUCCESSFUL){
            //shows error
      }
      else{
                 for (int i=0;i<pRxLen[0]; i++){
                      Log.d(TAG, "Received byte["+ i+ "]=0x"+ Integer.toHexString(pRxBuff[i]));
                 }
      }
  }
  catch (Exception e){
           e.printStackTrace();
  }
 

Send Escape
  byte pData[] = new byte[] {CMD_VENDOR_OP_CODE, VENDOR_CMD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  byte pRxBuff[] = new byte [128];
  int pRxLen[] = new int[1];
  int status;
  try{
      status = mReader.escape(pData, pData.legnth, pRxBuff, pRxLen);
      if (status != error.READER_SUCCESSFUL){
                //shows error
           }
           else{
            for (int i=0;i<pRxLen[0]; i++){
                Log.d(TAG, "Received byte["+ i+ "]=0x"+ Integer.toHexString(pRxBuff[i]));
             }
       }
  }
 catch (Exception e){
           e.printStackTrace();
 }
 

To get ATR
  String atr;
  byte []atrArray = new byte[64];
  try {
      atr = mReader.getAtrString();
      atrArray = mReader.getAtr();
  }
  catch (Exception e){
           e.printStackTrace();
  }
 
To get Card Status
 byte pCardStatus[] = new byte[1];
 int status;
 try {
       status = mReader.getCardStatus(pCardStatus);
   }
   catch(Exception e){
       e.printStackTrace();
   }
   if (status == error.READER_SUCCESSFUL){
       //shows card status  
   }
   
To get current protcol
 
    byte []proto = new byte[1];
    try {
        status = mReader.getProtocol(proto);
    }
    catch(Exception e){
        e.printStackTrace();
    }

    if (status == error.READER_SUCCESSFUL && proto[0] == Reader.CCID_PROTOCOL_T0){
        //do something
    }
 
To get SN in EEPROM
 
    byte pLen[] = new byte[1];
    byte []pSN;
    pLen[0] = 32;
    pSN = new byte[pLen[0]];
    try {
        status = mReader.getSN(pSN, pLen);
    }
    catch(Exception e){
        e.printStackTrace();
    }
    if (status == error.READER_SUCCESSFUL){
        //shows the SN   
    }
To close Reader
  try {
        if (myDev.Close()){
             //shows error
        }
    }
    catch(Exception e){
        e.printStackTrace();
    }