FileDocCategorySizeDatePackage
AidGroup.javaAPI DocAndroid 5.1 API6006Thu Mar 12 22:22:10 GMT 2015android.nfc.cardemulation

AidGroup

public final class AidGroup extends Object implements android.os.Parcelable
The AidGroup class represents a group of Application Identifiers (AIDs).

The format of AIDs is defined in the ISO/IEC 7816-4 specification. This class requires the AIDs to be input as a hexadecimal string, with an even amount of hexadecimal characters, e.g. "F014811481".

hide

Fields Summary
public static final int
MAX_NUM_AIDS
The maximum number of AIDs that can be present in any one group.
static final String
TAG
final List
aids
final String
category
final String
description
public static final Parcelable.Creator
CREATOR
Constructors Summary
public AidGroup(List aids, String category)
Creates a new AidGroup object.

param
aids The list of AIDs present in the group
param
category The category of this group, e.g. {@link CardEmulation#CATEGORY_PAYMENT}


                                  
         
        if (aids == null || aids.size() == 0) {
            throw new IllegalArgumentException("No AIDS in AID group.");
        }
        if (aids.size() > MAX_NUM_AIDS) {
            throw new IllegalArgumentException("Too many AIDs in AID group.");
        }
        for (String aid : aids) {
            if (!CardEmulation.isValidAid(aid)) {
                throw new IllegalArgumentException("AID " + aid + " is not a valid AID.");
            }
        }
        if (isValidCategory(category)) {
            this.category = category;
        } else {
            this.category = CardEmulation.CATEGORY_OTHER;
        }
        this.aids = new ArrayList<String>(aids.size());
        for (String aid : aids) {
            this.aids.add(aid.toUpperCase());
        }
        this.description = null;
    
AidGroup(String category, String description)

        this.aids = new ArrayList<String>();
        this.category = category;
        this.description = description;
    
Methods Summary
public static android.nfc.cardemulation.AidGroupcreateFromXml(org.xmlpull.v1.XmlPullParser parser)


            
        String category = null;
        ArrayList<String> aids = new ArrayList<String>();
        AidGroup group = null;
        boolean inGroup = false;

        int eventType = parser.getEventType();
        int minDepth = parser.getDepth();
        while (eventType != XmlPullParser.END_DOCUMENT && parser.getDepth() >= minDepth) {
            String tagName = parser.getName();
            if (eventType == XmlPullParser.START_TAG) {
                if (tagName.equals("aid")) {
                    if (inGroup) {
                        String aid = parser.getAttributeValue(null, "value");
                        if (aid != null) {
                            aids.add(aid.toUpperCase());
                        }
                    } else {
                        Log.d(TAG, "Ignoring <aid> tag while not in group");
                    }
                } else if (tagName.equals("aid-group")) {
                    category = parser.getAttributeValue(null, "category");
                    if (category == null) {
                        Log.e(TAG, "<aid-group> tag without valid category");
                        return null;
                    }
                    inGroup = true;
                } else {
                    Log.d(TAG, "Ignoring unexpected tag: " + tagName);
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                if (tagName.equals("aid-group") && inGroup && aids.size() > 0) {
                    group = new AidGroup(aids, category);
                    break;
                }
            }
            eventType = parser.next();
        }
        return group;
    
public intdescribeContents()

        return 0;
    
public java.util.ListgetAids()

return
the list of AIDs in this group

        return aids;
    
public java.lang.StringgetCategory()

return
the category of this AID group

        return category;
    
static booleanisValidCategory(java.lang.String category)

        return CardEmulation.CATEGORY_PAYMENT.equals(category) ||
                CardEmulation.CATEGORY_OTHER.equals(category);
    
public java.lang.StringtoString()

        StringBuilder out = new StringBuilder("Category: " + category +
                  ", AIDs:");
        for (String aid : aids) {
            out.append(aid);
            out.append(", ");
        }
        return out.toString();
    
public voidwriteAsXml(org.xmlpull.v1.XmlSerializer out)

        out.startTag(null, "aid-group");
        out.attribute(null, "category", category);
        for (String aid : aids) {
            out.startTag(null, "aid");
            out.attribute(null, "value", aid);
            out.endTag(null, "aid");
        }
        out.endTag(null, "aid-group");
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeString(category);
        dest.writeInt(aids.size());
        if (aids.size() > 0) {
            dest.writeStringList(aids);
        }