[framework] Add route type to routingTableEntry.
Bug: 339326805
Test: atest CtsNfcTestCases
Change-Id: I2b12cb4be015d0e15b2e4c709aba54355e2fefd4
diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt
index 3ed9b76..e97b15d 100644
--- a/nfc/api/system-current.txt
+++ b/nfc/api/system-current.txt
@@ -124,6 +124,7 @@
@FlaggedApi("android.nfc.nfc_oem_extension") public abstract class NfcRoutingTableEntry {
method public int getNfceeId();
+ method public int getRouteType();
method public int getType();
field public static final int TYPE_AID = 0; // 0x0
field public static final int TYPE_PROTOCOL = 1; // 0x1
diff --git a/nfc/java/android/nfc/Entry.java b/nfc/java/android/nfc/Entry.java
index 49d0f10..aa5ba58 100644
--- a/nfc/java/android/nfc/Entry.java
+++ b/nfc/java/android/nfc/Entry.java
@@ -25,11 +25,13 @@
private final byte mType;
private final byte mNfceeId;
private final String mEntry;
+ private final String mRoutingType;
- public Entry(String entry, byte type, byte nfceeId) {
+ public Entry(String entry, byte type, byte nfceeId, String routingType) {
mEntry = entry;
mType = type;
mNfceeId = nfceeId;
+ mRoutingType = routingType;
}
public byte getType() {
@@ -44,6 +46,10 @@
return mEntry;
}
+ public String getRoutingType() {
+ return mRoutingType;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -53,6 +59,7 @@
this.mEntry = in.readString();
this.mNfceeId = in.readByte();
this.mType = in.readByte();
+ this.mRoutingType = in.readString();
}
public static final @NonNull Parcelable.Creator<Entry> CREATOR =
@@ -73,5 +80,6 @@
dest.writeString(mEntry);
dest.writeByte(mNfceeId);
dest.writeByte(mType);
+ dest.writeString(mRoutingType);
}
}
diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java
index f78161e..fb11875 100644
--- a/nfc/java/android/nfc/NfcOemExtension.java
+++ b/nfc/java/android/nfc/NfcOemExtension.java
@@ -887,18 +887,22 @@
switch (entry.getType()) {
case TYPE_TECHNOLOGY -> result.add(
new RoutingTableTechnologyEntry(entry.getNfceeId(),
- RoutingTableTechnologyEntry.techStringToInt(entry.getEntry()))
+ RoutingTableTechnologyEntry.techStringToInt(entry.getEntry()),
+ routeStringToInt(entry.getRoutingType()))
);
case TYPE_PROTOCOL -> result.add(
new RoutingTableProtocolEntry(entry.getNfceeId(),
- RoutingTableProtocolEntry.protocolStringToInt(entry.getEntry()))
+ RoutingTableProtocolEntry.protocolStringToInt(entry.getEntry()),
+ routeStringToInt(entry.getRoutingType()))
);
case TYPE_AID -> result.add(
- new RoutingTableAidEntry(entry.getNfceeId(), entry.getEntry())
+ new RoutingTableAidEntry(entry.getNfceeId(), entry.getEntry(),
+ routeStringToInt(entry.getRoutingType()))
);
case TYPE_SYSTEMCODE -> result.add(
new RoutingTableSystemCodeEntry(entry.getNfceeId(),
- entry.getEntry().getBytes(StandardCharsets.UTF_8))
+ entry.getEntry().getBytes(StandardCharsets.UTF_8),
+ routeStringToInt(entry.getRoutingType()))
);
}
}
diff --git a/nfc/java/android/nfc/NfcRoutingTableEntry.java b/nfc/java/android/nfc/NfcRoutingTableEntry.java
index c2cbbed..4153779 100644
--- a/nfc/java/android/nfc/NfcRoutingTableEntry.java
+++ b/nfc/java/android/nfc/NfcRoutingTableEntry.java
@@ -19,6 +19,7 @@
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.SystemApi;
+import android.nfc.cardemulation.CardEmulation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -35,6 +36,7 @@
public abstract class NfcRoutingTableEntry {
private final int mNfceeId;
private final int mType;
+ private final int mRouteType;
/**
* AID routing table type.
@@ -67,9 +69,11 @@
public @interface RoutingTableType {}
/** @hide */
- protected NfcRoutingTableEntry(int nfceeId, @RoutingTableType int type) {
+ protected NfcRoutingTableEntry(int nfceeId, @RoutingTableType int type,
+ @CardEmulation.ProtocolAndTechnologyRoute int routeType) {
mNfceeId = nfceeId;
mType = type;
+ mRouteType = routeType;
}
/**
@@ -88,4 +92,14 @@
public int getType() {
return mType;
}
+
+ /**
+ * Get the route type of this entry.
+ * @return an integer defined in
+ * {@link android.nfc.cardemulation.CardEmulation.ProtocolAndTechnologyRoute}
+ */
+ @CardEmulation.ProtocolAndTechnologyRoute
+ public int getRouteType() {
+ return mRouteType;
+ }
}
diff --git a/nfc/java/android/nfc/RoutingTableAidEntry.java b/nfc/java/android/nfc/RoutingTableAidEntry.java
index bf697d6..be94f9f 100644
--- a/nfc/java/android/nfc/RoutingTableAidEntry.java
+++ b/nfc/java/android/nfc/RoutingTableAidEntry.java
@@ -18,6 +18,7 @@
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.nfc.cardemulation.CardEmulation;
/**
* Represents an Application ID (AID) entry in current routing table.
@@ -29,8 +30,9 @@
private final String mValue;
/** @hide */
- public RoutingTableAidEntry(int nfceeId, String value) {
- super(nfceeId, TYPE_AID);
+ public RoutingTableAidEntry(int nfceeId, String value,
+ @CardEmulation.ProtocolAndTechnologyRoute int routeType) {
+ super(nfceeId, TYPE_AID, routeType);
this.mValue = value;
}
diff --git a/nfc/java/android/nfc/RoutingTableProtocolEntry.java b/nfc/java/android/nfc/RoutingTableProtocolEntry.java
index 536de4d..a68d8c1 100644
--- a/nfc/java/android/nfc/RoutingTableProtocolEntry.java
+++ b/nfc/java/android/nfc/RoutingTableProtocolEntry.java
@@ -18,6 +18,7 @@
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.SystemApi;
+import android.nfc.cardemulation.CardEmulation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -96,8 +97,9 @@
private final @ProtocolValue int mValue;
/** @hide */
- public RoutingTableProtocolEntry(int nfceeId, @ProtocolValue int value) {
- super(nfceeId, TYPE_PROTOCOL);
+ public RoutingTableProtocolEntry(int nfceeId, @ProtocolValue int value,
+ @CardEmulation.ProtocolAndTechnologyRoute int routeType) {
+ super(nfceeId, TYPE_PROTOCOL, routeType);
this.mValue = value;
}
diff --git a/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java b/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java
index f61892d..06cc0a5 100644
--- a/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java
+++ b/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java
@@ -18,6 +18,7 @@
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.nfc.cardemulation.CardEmulation;
/**
* Represents a system code entry in current routing table, where system codes are two-byte values
@@ -31,8 +32,9 @@
private final byte[] mValue;
/** @hide */
- public RoutingTableSystemCodeEntry(int nfceeId, byte[] value) {
- super(nfceeId, TYPE_SYSTEM_CODE);
+ public RoutingTableSystemCodeEntry(int nfceeId, byte[] value,
+ @CardEmulation.ProtocolAndTechnologyRoute int routeType) {
+ super(nfceeId, TYPE_SYSTEM_CODE, routeType);
this.mValue = value;
}
diff --git a/nfc/java/android/nfc/RoutingTableTechnologyEntry.java b/nfc/java/android/nfc/RoutingTableTechnologyEntry.java
index 2dbc942..86239ce 100644
--- a/nfc/java/android/nfc/RoutingTableTechnologyEntry.java
+++ b/nfc/java/android/nfc/RoutingTableTechnologyEntry.java
@@ -18,6 +18,7 @@
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.SystemApi;
+import android.nfc.cardemulation.CardEmulation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -77,8 +78,9 @@
private final @TechnologyValue int mValue;
/** @hide */
- public RoutingTableTechnologyEntry(int nfceeId, @TechnologyValue int value) {
- super(nfceeId, TYPE_TECHNOLOGY);
+ public RoutingTableTechnologyEntry(int nfceeId, @TechnologyValue int value,
+ @CardEmulation.ProtocolAndTechnologyRoute int routeType) {
+ super(nfceeId, TYPE_TECHNOLOGY, routeType);
this.mValue = value;
}