Home | History | Annotate | Download | only in nfc
      1 package android.nfc;
      2 
      3 import android.os.Parcel;
      4 import android.os.Parcelable;
      5 
      6 import java.util.ArrayList;
      7 import java.util.List;
      8 
      9 /**
     10  * @hide
     11  */
     12 public class ApduList implements Parcelable {
     13 
     14     private ArrayList<byte[]> commands = new ArrayList<byte[]>();
     15 
     16     public ApduList() {
     17     }
     18 
     19     public void add(byte[] command) {
     20         commands.add(command);
     21     }
     22 
     23     public List<byte[]> get() {
     24         return commands;
     25     }
     26 
     27     public static final Parcelable.Creator<ApduList> CREATOR =
     28         new Parcelable.Creator<ApduList>() {
     29         @Override
     30         public ApduList createFromParcel(Parcel in) {
     31             return new ApduList(in);
     32         }
     33 
     34         @Override
     35         public ApduList[] newArray(int size) {
     36             return new ApduList[size];
     37         }
     38     };
     39 
     40     private ApduList(Parcel in) {
     41         int count = in.readInt();
     42 
     43         for (int i = 0 ; i < count ; i++) {
     44 
     45             int length = in.readInt();
     46             byte[] cmd = new byte[length];
     47             in.readByteArray(cmd);
     48             commands.add(cmd);
     49         }
     50     }
     51 
     52     @Override
     53     public int describeContents() {
     54         return 0;
     55     }
     56 
     57     @Override
     58     public void writeToParcel(Parcel dest, int flags) {
     59         dest.writeInt(commands.size());
     60 
     61         for (byte[] cmd : commands) {
     62             dest.writeInt(cmd.length);
     63             dest.writeByteArray(cmd);
     64         }
     65     }
     66 }
     67 
     68 
     69