AidGrouppublic final class AidGroup extends Object implements android.os.ParcelableThe 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". |
Fields Summary |
---|
public static final int | MAX_NUM_AIDSThe 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.
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.AidGroup | createFromXml(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 int | describeContents()
return 0;
| public java.util.List | getAids()
return aids;
| public java.lang.String | getCategory()
return category;
| static boolean | isValidCategory(java.lang.String category)
return CardEmulation.CATEGORY_PAYMENT.equals(category) ||
CardEmulation.CATEGORY_OTHER.equals(category);
| public java.lang.String | toString()
StringBuilder out = new StringBuilder("Category: " + category +
", AIDs:");
for (String aid : aids) {
out.append(aid);
out.append(", ");
}
return out.toString();
| public void | writeAsXml(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 void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeString(category);
dest.writeInt(aids.size());
if (aids.size() > 0) {
dest.writeStringList(aids);
}
|
|