From 5e991a129c308805da25957d9f5bf1bab8bcb60d Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Tue, 16 Sep 2014 16:03:28 -0700 Subject: [PATCH] Upper-case incoming AIDs. This fixes scenarios where different services register the same AID in a different case, and we don't see any conflict. Bug: 16517161 Change-Id: I610b585ce7d57b4e32c21004a1d4c50e1133986a --- core/java/android/nfc/cardemulation/AidGroup.java | 11 +++++------ .../android/nfc/cardemulation/ApduServiceInfo.java | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/java/android/nfc/cardemulation/AidGroup.java b/core/java/android/nfc/cardemulation/AidGroup.java index f440874af06e9..4407c9deb9115 100644 --- a/core/java/android/nfc/cardemulation/AidGroup.java +++ b/core/java/android/nfc/cardemulation/AidGroup.java @@ -15,10 +15,6 @@ import android.util.Log; /** * The AidGroup class represents a group of Application Identifiers (AIDs). * - *

An instance of this object can be used with - * {@link CardEmulation#registerAidsForService(android.content.ComponentName, String, java.util.List)} - * to tell the OS which AIDs are handled by your HCE- or SE-based service. - * *

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". @@ -60,7 +56,10 @@ public final class AidGroup implements Parcelable { } else { this.category = CardEmulation.CATEGORY_OTHER; } - this.aids = aids; + this.aids = new ArrayList(aids.size()); + for (String aid : aids) { + this.aids.add(aid.toUpperCase()); + } this.description = null; } @@ -144,7 +143,7 @@ public final class AidGroup implements Parcelable { if (inGroup) { String aid = parser.getAttributeValue(null, "value"); if (aid != null) { - aids.add(aid); + aids.add(aid.toUpperCase()); } } else { Log.d(TAG, "Ignoring tag while not in group"); diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 38113751c85f9..00b2ee3c619e6 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -311,7 +311,7 @@ public final class ApduServiceInfo implements Parcelable { public String getCategoryForAid(String aid) { ArrayList groups = getAidGroups(); for (AidGroup group : groups) { - if (group.aids.contains(aid)) { + if (group.aids.contains(aid.toUpperCase())) { return group.category; } } @@ -425,7 +425,7 @@ public final class ApduServiceInfo implements Parcelable { public ApduServiceInfo createFromParcel(Parcel source) { ResolveInfo info = ResolveInfo.CREATOR.createFromParcel(source); String description = source.readString(); - boolean onHost = (source.readInt() != 0) ? true : false; + boolean onHost = source.readInt() != 0; ArrayList staticAidGroups = new ArrayList(); int numStaticGroups = source.readInt(); if (numStaticGroups > 0) { @@ -436,7 +436,7 @@ public final class ApduServiceInfo implements Parcelable { if (numDynamicGroups > 0) { source.readTypedList(dynamicAidGroups, AidGroup.CREATOR); } - boolean requiresUnlock = (source.readInt() != 0) ? true : false; + boolean requiresUnlock = source.readInt() != 0; int bannerResource = source.readInt(); int uid = source.readInt(); return new ApduServiceInfo(info, onHost, description, staticAidGroups,