diff options
| author | 2017-07-06 22:56:19 +0000 | |
|---|---|---|
| committer | 2017-07-06 22:56:19 +0000 | |
| commit | 67d32575196d2221797d4882628c5c12cc19a6aa (patch) | |
| tree | eaaf40f65c265addde915b01fc0cf40b00a82db8 | |
| parent | a161427214b359f211292a1894e585bbe64fe9ba (diff) | |
| parent | 4d08be4a528a3695ddcaf6a74e1b55ebe3e46d97 (diff) | |
Merge changes from topic 'NCI-2.0' am: 430dded515
am: 4d08be4a52
Change-Id: Ie427005b3fa448a33c1756afdea66715914c4ff4
| -rw-r--r-- | core/java/android/nfc/cardemulation/ApduServiceInfo.java | 25 | ||||
| -rw-r--r-- | core/java/android/nfc/cardemulation/CardEmulation.java | 12 |
2 files changed, 32 insertions, 5 deletions
diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 7678678f3513..218e4f223549 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -253,6 +253,20 @@ public final class ApduServiceInfo implements Parcelable { Log.e(TAG, "Ignoring invalid or duplicate aid: " + aid); } a.recycle(); + } else if (eventType == XmlPullParser.START_TAG && + tagName.equals("aid-suffix-filter") && currentGroup != null) { + final TypedArray a = res.obtainAttributes(attrs, + com.android.internal.R.styleable.AidFilter); + String aid = a.getString(com.android.internal.R.styleable.AidFilter_name). + toUpperCase(); + // Add wildcard char to indicate suffix + aid = aid.concat("#"); + if (CardEmulation.isValidAid(aid) && !currentGroup.aids.contains(aid)) { + currentGroup.aids.add(aid); + } else { + Log.e(TAG, "Ignoring invalid or duplicate aid: " + aid); + } + a.recycle(); } } } catch (NameNotFoundException e) { @@ -297,6 +311,17 @@ public final class ApduServiceInfo implements Parcelable { return prefixAids; } + public List<String> getSubsetAids() { + final ArrayList<String> subsetAids = new ArrayList<String>(); + for (AidGroup group : getAidGroups()) { + for (String aid : group.aids) { + if (aid.endsWith("#")) { + subsetAids.add(aid); + } + } + } + return subsetAids; + } /** * Returns the registered AID group for this category. */ diff --git a/core/java/android/nfc/cardemulation/CardEmulation.java b/core/java/android/nfc/cardemulation/CardEmulation.java index b49288e6e59e..6dd799396599 100644 --- a/core/java/android/nfc/cardemulation/CardEmulation.java +++ b/core/java/android/nfc/cardemulation/CardEmulation.java @@ -606,6 +606,8 @@ public final class CardEmulation { * <li>Consist of only hex characters * <li>Additionally, we allow an asterisk at the end, to indicate * a prefix + * <li>Additinally we allow an (#) at symbol at the end, to indicate + * a subset * </ul> * * @hide @@ -614,20 +616,20 @@ public final class CardEmulation { if (aid == null) return false; - // If a prefix AID, the total length must be odd (even # of AID chars + '*') - if (aid.endsWith("*") && ((aid.length() % 2) == 0)) { + // If a prefix/subset AID, the total length must be odd (even # of AID chars + '*') + if ((aid.endsWith("*") || aid.endsWith("#")) && ((aid.length() % 2) == 0)) { Log.e(TAG, "AID " + aid + " is not a valid AID."); return false; } - // If not a prefix AID, the total length must be even (even # of AID chars) - if (!aid.endsWith("*") && ((aid.length() % 2) != 0)) { + // If not a prefix/subset AID, the total length must be even (even # of AID chars) + if ((!(aid.endsWith("*") || aid.endsWith("#"))) && ((aid.length() % 2) != 0)) { Log.e(TAG, "AID " + aid + " is not a valid AID."); return false; } // Verify hex characters - if (!aid.matches("[0-9A-Fa-f]{10,32}\\*?")) { + if (!aid.matches("[0-9A-Fa-f]{10,32}\\*?\\#?")) { Log.e(TAG, "AID " + aid + " is not a valid AID."); return false; } |